opm-simulators
TTagFlowProblemTPSA.hpp
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  Copyright 2025 NORCE AS
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 
21  Consult the COPYING file in the top-level source directory of this
22  module for the precise wording of the license and the list of
23  copyright holders.
24 */
25 #ifndef TTAG_FLOW_PROBLEM_TPSA_HPP
26 #define TTAG_FLOW_PROBLEM_TPSA_HPP
27 
28 #include <dune/common/fvector.hh>
29 #include <dune/istl/bvector.hh>
30 
31 #include <opm/material/densead/Evaluation.hpp>
32 
33 #include <opm/models/discretization/common/tpsalinearizer.hpp>
34 #include <opm/models/tpsa/elasticityindices.hpp>
35 #include <opm/models/tpsa/elasticitylocalresidualtpsa.hpp>
36 #include <opm/models/tpsa/elasticityprimaryvariables.hpp>
37 #include <opm/models/tpsa/tpsabaseproperties.hpp>
38 #include <opm/models/tpsa/tpsamodel.hpp>
39 #include <opm/models/tpsa/tpsanewtonmethod.hpp>
40 
41 #include <opm/simulators/flow/BlackoilModelTPSA.hpp>
42 #include <opm/simulators/flow/FlowProblemTPSA.hpp>
43 #include <opm/simulators/linalg/matrixblock.hh>
44 #include <opm/simulators/linalg/ISTLSolverTPSA.hpp>
46 
47 
48 namespace Opm::Properties {
49 
50 namespace TTag {
51 
52 struct FlowProblemTpsa {};
53 
54 } // Opm::Properties::TTag
55 
56 // TPSA indices for primary variables and equations
57 template<class TypeTag>
58 struct IndicesTPSA<TypeTag, TTag::FlowProblemTpsa>
59 {
60  using type = ElasticityIndices</*PVOffset=*/0>;
61 };
62 
63 // Number of TPSA equations
64 template<class TypeTag>
65 struct NumEqTPSA<TypeTag, TTag::FlowProblemTpsa>
66 { static constexpr int value = GetPropType<TypeTag, Properties::IndicesTPSA>::numEq; };
67 
68 // TPSA linearizer
69 template<class TypeTag>
70 struct LinearizerTPSA<TypeTag, TTag::FlowProblemTpsa>
71 { using type = TpsaLinearizer<TypeTag>; };
72 
73 // Set the function evaluation w.r.t. the TPSA primary variables
74 template<class TypeTag>
75 struct EvaluationTPSA<TypeTag, TTag::FlowProblemTpsa>
76 {
77 private:
78  static constexpr unsigned numEq = getPropValue<TypeTag, Properties::NumEqTPSA>();
79 
80  using Scalar = GetPropType<TypeTag, Scalar>;
81 
82 public:
83  using type = DenseAd::Evaluation<Scalar, numEq>;
84 };
85 
86 // TPSA equation vector
87 template<class TypeTag>
88 struct EqVectorTPSA<TypeTag, TTag::FlowProblemTpsa>
89 {
90  using type = Dune::FieldVector<GetPropType<TypeTag, Scalar>,
91  getPropValue<TypeTag, Properties::NumEqTPSA>()>;
92 };
93 
94 // Global TPSA equation vector
95 template<class TypeTag>
96 struct GlobalEqVectorTPSA<TypeTag, TTag::FlowProblemTpsa>
97 { using type = Dune::BlockVector<GetPropType<TypeTag, Properties::EqVectorTPSA>>; };
98 
99 // TPSA Newton method
100 template<class TypeTag>
101 struct NewtonMethodTPSA<TypeTag, TTag::FlowProblemTpsa>
102 { using type = TpsaNewtonMethod<TypeTag>; };
103 
104 // TPSA primary variables
105 template<class TypeTag>
106 struct PrimaryVariablesTPSA<TypeTag, TTag::FlowProblemTpsa>
108 
109 // TPSA solution vector
110 template<class TypeTag>
111 struct SolutionVectorTPSA<TypeTag, TTag::FlowProblemTpsa>
112 { using type = Dune::BlockVector<GetPropType<TypeTag, Properties::PrimaryVariablesTPSA>>; };
113 
114 // TPSA number of historic solutions to save
115 template<class TypeTag>
116 struct SolutionHistorySizeTPSA<TypeTag, TTag::FlowProblemTpsa>
117 { static constexpr int value = 2; };
118 
119 // TPSA model
120 template<class TypeTag>
121 struct ModelTPSA<TypeTag, TTag::FlowProblemTpsa>
122 { using type = TpsaModel<TypeTag>; };
123 
124 // TPSA local residual
125 template<class TypeTag>
126 struct LocalResidualTPSA<TypeTag, TTag::FlowProblemTpsa>
128 
129 // TPSA sparse matrix adapter for Jacobian
130 template<class TypeTag>
131 struct SparseMatrixAdapterTPSA<TypeTag, TTag::FlowProblemTpsa>
132 {
133 private:
134  using Scalar = GetPropType<TypeTag, Scalar>;
135  enum { numEq = getPropValue<TypeTag, Properties::NumEqTPSA>() };
137 
138 public:
139  using type = typename Linear::IstlSparseMatrixAdapter<Block>;
140 
141 };
142 
143 // Set linear solver backend
144 template<class TypeTag>
145 struct LinearSolverBackendTPSA<TypeTag, TTag::FlowProblemTpsa>
146 { using type = ISTLSolverTPSA<TypeTag>; };
147 
148 } // namespace Opm::Properties
149 
150 #endif
Definition: tpsabaseproperties.hpp:34
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
Primary variables in (linear) elasticity equations.
Definition: elasticityprimaryvariables.hpp:51
Newton method solving for generic TPSA model.
Definition: tpsanewtonmethod.hpp:57
Definition: elasticityindices.hpp:32
Definition: tpsabaseproperties.hpp:73
Definition: tpsabaseproperties.hpp:67
Definition: tpsabaseproperties.hpp:46
Definition: tpsabaseproperties.hpp:70
Class for setting up ISTL linear solvers for TPSA.
Definition: ISTLSolverTPSA.hpp:66
Definition: matrixblock.hh:228
Definition: tpsabaseproperties.hpp:58
Definition: tpsabaseproperties.hpp:64
Linearizes TPSA equations and generates system matrix and residual for linear solver.
Definition: tpsalinearizer.hpp:52
Definition: TTagFlowProblemTPSA.hpp:52
Definition: tpsabaseproperties.hpp:40
Definition: tpsabaseproperties.hpp:55
Definition: tpsabaseproperties.hpp:61
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: tpsabaseproperties.hpp:49
Calculation of (linear) elasticity model terms for the residual.
Definition: elasticitylocalresidualtpsa.hpp:67
Definition: tpsabaseproperties.hpp:52
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: istlsparsematrixadapter.hh:42
Definition: tpsabaseproperties.hpp:37
Definition: blackoilmodel.hh:80
TPSA geomechanics model.
Definition: tpsamodel.hpp:50
Definition: tpsabaseproperties.hpp:43