HydroFemPhysics
The GeMA Hydraulic FEM Physics Plugin
Loading...
Searching...
No Matches
gmpHydraulicTwoPhaseUtils.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_PLUGIN_HYDRAULIC_TWOPHASEUTILS_H_
25#define _GEMA_PLUGIN_HYDRAULIC_TWOPHASEUTILS_H_
26
27#include<gmElement.h>
29#include <gmVector.h>
30#include <gmMatrix.h>
31
32namespace GmpHydraulicTwoPhaseUtils
33{
34 // structure for nodal variables
35 // Saturation terms
37 {
38 double Slm; // Mean liquid saturation
39 double Sgm; // Mean gas saturation
40 GmVector Sl; // Liquid saturation degree vector at the current time step
41 GmVector SlOld; // Liquid saturation degree vector at the previous time step
42 GmVector Sg; // Gas saturation degree vector
43 GmVector SgOld; // Gas saturation degree vector at previous time step
44 GmVector dSldPc; // Derivative of liquid saturation degree in terms of capillary pressure
45 GmVector dSlmdPl; // Derivative of mean liquid saturation in terms of nodal liquid pressure
46 GmVector dSlmdPg; // Derivative of mean liquid saturation in terms of nodal gas pressure
47
48 explicit saturationTerms(size_t np)
49 :Sl(np), SlOld(np), Sg(np), SgOld(np),
50 dSldPc(np), dSlmdPl(np), dSlmdPg(np) {}
51 };
52
53 // Density terms
55 {
56 double rholm; // Mean liquid density
57 double rhogm; // Mean gas density
58 GmVector rhol; // Liquid density at the nodes vector
59 GmVector rhog; // Gas density at the nodes vector
60 GmVector rholOld; // Liquid density vector at previous time step
61 GmVector rhogOld; // Gas density vector at previous time step
62 GmVector drholmdPl; // Derivative of mean liquid density in terms of nodal liquid pressure
63 GmVector drhogmdPg; // Derivative of mean gas density in terms of nodal gas pressure
64 explicit densityTerms(size_t np)
65 : rhol(np), rhog(np), rholOld(np),
66 rhogOld(np), drholmdPl(np), drhogmdPg(np) {}
67 };
68
69 // Viscosity terms
71 {
72 double mul = 0.0; // Dynamic viscosity of fluid
73 double mug = 0.0; // Dynamic viscosity of gas
74 GmVector dmulmdPl; // Derivative of mean liquid viscosity in terms of nodal liquid pressure
75 GmVector dmugmdPg; // Derivative of mean gas viscosity in terms of nodal gas pressure
76
77 explicit viscosityTerms(size_t np)
78 : dmulmdPl(np), dmugmdPg(np) {}
79 };
80
81 // Mass terms
82 struct massTerms
83 {
84 GmVector ml; // Liquid mass vector at the nodes: ml = rhol * Sl
85 GmVector mg; // Gas mass vector at the nodes: mg = rhog * Sg
86 GmVector Dml; // Liquid mass increment vector
87 GmVector Dmg; // Gas mass increment vector
88 GmVector dmldPl; // Derivative of liquid mass (rhol*Sl) in terms of nodal liquid pressure at the nodes
89 GmVector dmldPg; // Derivative of liquid mass (rhol*Sl) in terms of nodal gas pressure at the nodes
90 GmVector dmgdPl; // Derivative of gas mass (rhog*Sg) in terms of nodal liquid pressure at the nodes
91 GmVector dmgdPg; // Derivative of gas mass (rhog*Sg) in terms of nodal gas pressure at the nodes
92
93 explicit massTerms(size_t np)
94 : ml(np), mg(np), Dml(np), Dmg(np), dmldPl(np),
95 dmldPg(np), dmgdPl(np), dmgdPg(np) {}
96 };
97
98 // Pressure terms
100 {
101 GmVector Pl; // Liquid phase pore pressure
102 GmVector Pg; // Gas phase pore pressure
103 GmVector PlOld; // Liquid phase pore pressure at previous time
104 GmVector PgOld; // Gas phase pore pressure at previous time
105 GmVector Ps; // Nodal effective pore pressure vector: Ps = Pl * Sl + Pg * Sg
106 GmVector PsOld; // Nodal effective pore pressure vector at previous time: PsOld = PlOld * SlOld + PgOld * SgOld
107 GmVector Pc; // Nodal capillarity pressure: Pc = Pg - Pl
108 GmVector PcOld; // Nodal capillarity pressure at previous time: PcOld = PgOld - PlOld
109 const double dPcdPl = - 1.0; // Derivative of capillary pressure in terms of liquid pressure
110 const double dPcdPg = 1.0; // Derivative of capillary pressure in terms of gas pressure
111
112 explicit pressureTerms(size_t np)
113 : Pl(np), Pg(np), PlOld(np), PgOld(np),
114 Ps(np), PsOld(np), Pc(np), PcOld(np) {}
115 };
116
117 // Relative permeability terms
119 {
120 double krl; // Liquid relative permeability
121 double krg; // Gas relative permeability
122 double dkrlmdSl; // Derivative of liquid relative permeability in terms of the mean liquid saturation
123 double dkrgmdSl; // Derivative of gas relative permeability in terms of the mean liquid saturation
124 GmVector dkrlmdPl; // Derivative of liquid relative permeability in terms of nodal liquid pressure
125 GmVector dkrlmdPg; // Derivative of liquid relative permeability in terms of nodal gas pressure
126 GmVector dkrgmdPl; // Derivative of gas relative permeability in terms of nodal liquid pressure
127 GmVector dkrgmdPg; // Derivative of gas relative permeability in terms of nodal gas pressure
128
129 explicit permeabilityTerms(size_t np)
130 : dkrlmdPl(np), dkrlmdPg(np), dkrgmdPl(np), dkrgmdPg(np) {}
131 };
132 // Mass mobility terms
134 {
135 double massMobilityL; // mass mobility of liquid phase
136 double massMobilityG; // mass mobility of gas phase
137 // Mass mobilities derivatives. The densities and the fluid viscosities are considered a function of the corresponding phase only.
138 GmVector dmassMobilityLdPl; // Derivative of liquid mass mobility in terms of nodal liquid paressure
139 GmVector dmassMobilityLdPg; // Derivative of liquid mass mobility in terms of nodal gas paressure
140 GmVector dmassMobilityGdPl; // Derivative of gas mass mobility in terms of nodal liquid paressure
141 GmVector dmassMobilityGdPg; // Derivative of gas mass mobility in terms of nodal gas paressure
142
143 explicit massMobilityTerms(size_t np)
144 : dmassMobilityLdPl(np), dmassMobilityLdPg(np), dmassMobilityGdPl(np), dmassMobilityGdPg(np) {}
145 };
146
147 // Jacobian matrix terms
149 {
150 GmMatrix dfildpl; // Derivative of the liquid phase pressure internal force vector wrt to the liquid pore-pressures
151 GmMatrix dfildpg; // Derivative of the liquid phase pressure internal force vector wrt to the gas pore-pressures
152 GmMatrix dfigdpl; // Derivative of the gas phase pressure internal force vector wrt to the liquid pore-pressures
153 GmMatrix dfigdpg; // Derivative of the gas phase pressure internal force vector wrt to the gas pore-pressures
154
155 explicit jacobianTerms(size_t np)
156 : dfildpl(np, np), dfildpg(np, np), dfigdpl(np, np), dfigdpg(np, np) {}
157 };
158
159 // Methods used by two phase formulations
160 // Evaluates nodal variables
161 //bool evaluateNodalVariables(const GmElement* e, saturationTerms& Sat, densityTerms& Den,
162 // viscosityTerms& Mu, massTerms& Ms, pressureTerms& Pres);
163
164 // Evaluates relative permeabilities
165 GMP_HYDRAULIC_PHYSICS_API_EXPORT bool evaluateRelativePermeability(const GmElement* e, const GmpHydraulicMaterialTwoPhase* hmat, saturationTerms& Sat, permeabilityTerms& kr, int np);
166
167 // Evaluates the hydraulic gravity vector for each ip
168 GMP_HYDRAULIC_PHYSICS_API_EXPORT void evaluateHydraulicGravityVector(const GmElement* e, GmMatrix& Kh, GmVector& fgrav, GmMatrix& Bp,
169 const GmVector& grav, double c);
170
171 GMP_HYDRAULIC_PHYSICS_API_EXPORT bool evaluateAdvectiveForceAndJacobian(const GmElement* e, GmVector& Fil, GmVector& Fig, jacobianTerms& K,
173
174 GMP_HYDRAULIC_PHYSICS_API_EXPORT bool evaluateMassStorageForceAndJacobian(const GmElement* e, GmVector& Fil, GmVector& Fig, jacobianTerms& K,
175 saturationTerms& sat, massTerms& mass, pressureTerms& pres, GmVector& iN, double Cp, double phi, double dt, int np);
176
177 GMP_HYDRAULIC_PHYSICS_API_EXPORT bool evaluateGravityForceAndJacobian(const GmElement* e, GmVector& Fil, GmVector& Fig, jacobianTerms& K,
178 GmVector& fgravp, massMobilityTerms& mMb, saturationTerms& sat, densityTerms& den, double phi);
179
180}
181#endif
Definition gmpHydraulicMaterialTwoPhase.h:30
arma::mat GmMatrix
arma::vec GmVector
Declaration of the GmpHydraulicMaterialTwoPhase class.
Definition gmpHydraulicTwoPhaseUtils.h:55
Definition gmpHydraulicTwoPhaseUtils.h:149
Definition gmpHydraulicTwoPhaseUtils.h:134
Definition gmpHydraulicTwoPhaseUtils.h:83
Definition gmpHydraulicTwoPhaseUtils.h:119
Definition gmpHydraulicTwoPhaseUtils.h:100
Definition gmpHydraulicTwoPhaseUtils.h:37
Definition gmpHydraulicTwoPhaseUtils.h:71