Line data Source code
1 : //* This file is part of the MOOSE framework
2 : //* https://mooseframework.inl.gov
3 : //*
4 : //* All rights reserved, see COPYRIGHT for full restrictions
5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 : //*
7 : //* Licensed under LGPL 2.1, please see LICENSE for details
8 : //* https://www.gnu.org/licenses/lgpl-2.1.html
9 :
10 : #pragma once
11 :
12 : #include "GeneralUserObject.h"
13 : #include "Coupleable.h"
14 :
15 : /**
16 : * This holds maps between the nonlinear variables
17 : * used in a PorousFlow simulation and the
18 : * variable number used internally by MOOSE, as
19 : * well as the number of fluid phases and
20 : * the number of fluid components.
21 : *
22 : * The Dictator performs sanity checks on all
23 : * PorousFlow simulations and helps users
24 : * rectify errors (for instance if parts of
25 : * the input file suggest it is a 2-phase
26 : * simulation, while other parts suggest it
27 : * is 1-phase).
28 : *
29 : * All PorousFlow Materials and Kernels calculate
30 : * and use derivatives with respect to all the variables
31 : * mentioned in this Object, at least in principal
32 : * (in practice they may be lazy and not compute
33 : * all derivatives).
34 : */
35 :
36 : /**
37 : ` `:;@;:.:::#@@@'.`
38 : ` ,@;@@@@@@@@@@@@@@@@@@@@'';''``
39 : ,;@@@@@@@@@@@@T@@@@@H@@@@@E@@@@@@@@++@@@+:.:.`
40 : '@@'@@@@@@@D@@@@@I@@@@@C@@@@@T@@@@@A@@@@@T@@@@@O@@@@@R@@@@@@..`
41 : `..,;@@@@@@@@@@@@@@@@@@@@@@@@@@@@I@@@@@S@@@@@@@@@@@@@@@@@@@@@@@@@@@;.
42 : .:@@@@@@@@@@@@@@@@@@@@W@@@@@A@@@@@T@@@@@C@@@@@H@@@@@I@@@@@N@@@@@G@@@@@@@@@#;:.`
43 : .:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:,@@@@@@@@@@+` ``
44 : ,@@@@@@@@@@@';'@@@@@@@@@@:@@@@+@+:;@@@@@@@;:#';::'@@@@@@. `::;,..`::+:,;@@@@@@:.``
45 : `'@@@@@@'..```.,,....``` `` ` ..:;@@@@@@@@+.
46 : @;;;;@;,,`` `` `:@@@@@@:`
47 : @@++';:,.``` ``;+@#:,.
48 : @@@@#+:.` `,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'@@@@@+:. `.:'::,
49 : @@@@@@:,`...`,@@@@@@@@@@, +@@@@@@@@@@@@@@@@@@@@@@@@` `;'@@@@# .,,,,
50 : @@@@@@':::@@@@@@@@.` `@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. ``,@@@` `.::,
51 : @@@@@@#@@@@@';. `@@@@@@@@;,@`@@@@@@@@@@@@@@@@@@@@@@@@@@@@@` .,@@@@ ``..,
52 : @@@@@@@@@:.. @@@@@, ;@@@@@@@@@@@@@@@@@@ ,@@@@@:@@@@@ `,'@@@ ```.
53 : @@@@@':,,` @@@@:` @@@@@@@@@@@@@@@@@@ ,@@: `:@@@@@; ..:@@@` ```
54 : @@@@;:` @@@@@@.. '@@@@@@@@@@@@@@@@@@ `@@` .@@@@@,`:'@@@. `
55 : @@@@;:.`@@@@@, `` @@@@@@@@@@@@@@@@@@@@@@@@@ ,@@@@@@.'@@@@,`
56 : @@@+':''` ;@@@@@@,,` @@@@@@@@@@@@@@@@@@@@@@' `.:@@@#@:@@@@':.
57 : :;;;:@@,,.` `@@@+, `+. @@@@@@@@@@@@@@@@@@@@` ```. @@:';,,,.`
58 : .,,,,,,;;+;:.`..;,., ,,` @@@@@@@@@@@@@@@@` ``` ,@@, ``` `
59 : `......,,;+++#';@@@@@@. '@@@@@@; ``` .;@@@@.
60 : ```` `,;'+@@+;:'@@@'@@@@@:. ` ,#@@@@+,
61 : .:+'@';::'@+':,;,#@@@@@@@@@@@@@@@@@@: .@@@@@@@:
62 : `:,,::,.`...,,`..,,,,...,,,,,...`:;@@@@@@@@;
63 : `.....```` `,.`````````..,,,,,.....``````
64 : */
65 :
66 : class PorousFlowDictator : public GeneralUserObject, public Coupleable
67 : {
68 : public:
69 : static InputParameters validParams();
70 :
71 : PorousFlowDictator(const InputParameters & parameters);
72 :
73 72513 : virtual void initialize() override{};
74 72513 : virtual void execute() override{};
75 72513 : virtual void finalize() override{};
76 :
77 : /**
78 : * The number of PorousFlow variables. Materials
79 : * and Kernels will calculate and use derivatives
80 : * with respect to these variables in the Jacobian
81 : */
82 : unsigned int numVariables() const;
83 :
84 : /// The number of fluid phases
85 : unsigned int numPhases() const;
86 :
87 : /// The number of fluid components
88 : unsigned int numComponents() const;
89 :
90 : /// The number of aqueous equilibrium secondary species
91 : unsigned int numAqueousEquilibrium() const;
92 :
93 : /// The number of aqueous kinetic secondary species
94 : unsigned int numAqueousKinetic() const;
95 :
96 : /// The aqueous phase number
97 : unsigned int aqueousPhaseNumber() const;
98 :
99 : /**
100 : * The PorousFlow variable number
101 : * @param moose_var_num the MOOSE variable number
102 : * eg if porous_flow_vars = 'pwater pgas', and the variables in
103 : * the simulation are 'energy pwater pgas shape'
104 : * then porousFlowVariableNum(2) = 1
105 : */
106 : unsigned int porousFlowVariableNum(unsigned int moose_var_num) const;
107 :
108 : /**
109 : * The Moose variable number
110 : * @param porous_flow_var_num the PorousFlow variable number
111 : * eg if porous_flow_vars = 'pwater pgas', and the variables in
112 : * the simulation are 'energy pwater pgas shape'
113 : * then mooseVariableNum(1) = 2
114 : */
115 : unsigned int mooseVariableNum(unsigned int porous_flow_var_num) const;
116 :
117 : /**
118 : * Returns true if moose_var_num is a porous flow variable
119 : * @param moose_var_num the MOOSE variable number
120 : * eg if porous_flow_vars = 'pwater pgas', and the variables in
121 : * the simulation are 'energy pwater pgas shape'
122 : * then isPorousFlowVariable(0) = false, isPorousFlowVariable(1) = true
123 : */
124 : bool isPorousFlowVariable(unsigned int moose_var_num) const;
125 :
126 : /**
127 : * Returns true if moose_var_num is not a porous flow variabe
128 : * @param moose_var_num the MOOSE variable number
129 : * eg if porous_flow_vars = 'pwater pgas', and the variables in
130 : * the simulation are 'energy pwater pgas shape'
131 : * then notPorousFlowVariable(0) = true, notPorousFlowVariable(1) = false
132 : */
133 : bool notPorousFlowVariable(unsigned int moose_var_num) const;
134 :
135 : /**
136 : * Whether the porous_flow_vars all have the same FEType or
137 : * if no porous_flow_vars were provided
138 : */
139 : bool consistentFEType() const;
140 :
141 : /**
142 : * The FEType of the first porous_flow_variable.
143 : * Note, this is meaningless if there are no named porous_flow_variables: consistentFEType()
144 : * should be used to check this
145 : */
146 : libMesh::FEType feType() const;
147 :
148 : /**
149 : * Check if the simulation includes derivatives of permeability
150 : * Note: when the permeability is constant, expensive tensor calculations
151 : * can be ignored in Jacobian calculations
152 : */
153 10783 : bool usePermDerivs() const { return _perm_derivs; };
154 :
155 : /**
156 : * Set the _perm_derivs flag
157 : */
158 1076 : void usePermDerivs(bool flag) const { _perm_derivs = flag; };
159 :
160 : protected:
161 : /// Number of PorousFlow variables
162 : const unsigned int _num_variables;
163 :
164 : /// Number of fluid phases
165 : const unsigned int _num_phases;
166 :
167 : /// Number of fluid components
168 : const unsigned int _num_components;
169 :
170 : /// Number of aqueous-equilibrium secondary species
171 : const unsigned int _num_aqueous_equilibrium;
172 :
173 : /// Number of aqeuous-kinetic secondary species that are involved in mineralisation
174 : const unsigned int _num_aqueous_kinetic;
175 :
176 : /// Aqueous phase number
177 : const unsigned int _aqueous_phase_number;
178 :
179 : /// Indicates whether the simulation includes derivatives of permeability
180 : mutable bool _perm_derivs;
181 :
182 : private:
183 : /// Whether the porous_flow_vars all have the same fe_type
184 : bool _consistent_fe_type;
185 :
186 : /// FE type used by the PorousFlow variables
187 : libMesh::FEType _fe_type;
188 :
189 : /// _moose_var_num[i] = the moose variable number corresponding to porous flow variable i
190 : std::vector<unsigned int> _moose_var_num;
191 :
192 : /// _pf_var_num[i] = the porous flow variable corresponding to moose variable i
193 : std::vector<unsigned int> _pf_var_num;
194 : };
|