opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
printlinearsolverparameter.hpp
1
/*
2
Copyright 2025 Equinor ASA
3
4
This file is part of the Open Porous Media project (OPM).
5
OPM is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
OPM is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with OPM. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
#ifndef OPM_PRINTLINEARSOLVERPARAMETERS_HEADER_INCLUDED
17
#define OPM_PRINTLINEARSOLVERPARAMETERS_HEADER_INCLUDED
18
19
#include <ostream>
20
#include <vector>
21
22
#include <opm/common/OpmLog/OpmLog.hpp>
23
#include <opm/simulators/linalg/FlowLinearSolverParameters.hpp>
24
#include <opm/simulators/linalg/PropertyTree.hpp>
25
26
namespace
Opm::detail
27
{
28
32
inline
void
writeJsonToStream(
const
Opm::PropertyTree& prm, std::ostream& os)
33
{
34
// Write the property tree in JSON format to the output stream
35
prm.
write_json
(os,
true
);
36
}
37
41
inline
void
writeJsonToStream(
const
std::vector<Opm::PropertyTree>& prms, std::ostream& os)
42
{
43
// Write each property tree in the vector in JSON format to the output stream
44
for
(
const
auto
& p : prms) {
45
writeJsonToStream(p, os);
46
}
47
}
48
59
template
<
class
VectorOrSingle,
class
Comm>
60
void
61
printLinearSolverParameters(
const
FlowLinearSolverParameters& parameters,
62
const
VectorOrSingle& prm,
63
const
Comm& comm)
64
{
65
// Check if we are on the IO rank
66
const
bool
on_io_rank = comm.rank() == 0;
67
if
(on_io_rank && parameters.linear_solver_print_json_definition_) {
68
std::ostringstream os;
69
os <<
"\nProperty tree for linear solvers:\n"
;
70
writeJsonToStream(prm, os);
71
// Write the parameters in JSON format
72
OpmLog::note(os.str());
73
}
74
}
75
87
template
<
class
Comm>
88
void
89
printLinearSolverParameters(
const
std::vector<FlowLinearSolverParameters>& parameters,
90
int
activeSolverNum,
91
const
std::vector<Opm::PropertyTree>& prm,
92
const
Comm& comm)
93
{
94
printLinearSolverParameters(parameters[activeSolverNum], prm, comm);
95
}
96
97
}
// namespace Opm::detail
98
99
#endif
// OPM_PRINTLINEARSOLVERPARAMETERS_HEADER_INCLUDED
Opm::PropertyTree::write_json
void write_json(std::ostream &os, bool pretty) const
Emit a textual representation of the property tree in JSON form.
Definition
PropertyTree.cpp:76
opm
simulators
linalg
printlinearsolverparameter.hpp
Generated by
1.17.0