![]() |
ChemicalFemPhysics
The GeMA Standard Chemical FEM Physics Plugin
|
Basic class for chemical fem physics. Treats the diffusion and convective terms of the transport equation, leaving the reactive term to be handled by derived classes. More...
#include <gmpChemicalFemPhysics.h>


Public Member Functions | |
| GmpChemicalFemPhysics (GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger) | |
| Constructor. Will be called by the plugin loading code. | |
| virtual | ~GmpChemicalFemPhysics () |
| Destructor. | |
| virtual const char * | pluginName () const |
| virtual const QVariantMap * | physicsMetaDataMap () |
| Returns a pointer to the basic chemical physics attribute map, built when the function is called for the first time. Will be extended by sub-classes providing the reactive term. | |
| virtual bool | checkLoadedData () |
| Checks the existance of the velocity accessor, and also sizes for the dispersion and retardation coefficients, as well as sizes for the prescribed concentration and prescribed flux boundary conditions. | |
| virtual FemResultType | fillElementData (const GmElement *e, GmpFemMatrixSet &elemMatrices, GmpFemVectorSet &elemVectors) |
| Fills the element stiffness matrix for element 'e' with diffusive and convective terms. Calls the virtual function reactionRate() for filling the external forces(). | |
| virtual FemResultType | fillElementDataForBc (const GmElement *e, const GmBoundaryCondition *bc, int bcIndex, int bcListIndex, int border, GmpFemMatrixSet &elemMatrices, GmpFemVectorSet &elemVectors) |
| Fills the element force vector elemF for element 'e', taking into account fixed flux boundary conditions. | |
| virtual bool | fixedNodalDofsBc (QVector< int > &nodes, QVector< int > &dof, QVector< double > &values, bool *constantValues) const |
| See comments on base class. Fills vectors with prescribed node concentrations | |
| virtual bool | fillFixedNodalDofsBCAlkalinity (QVector< int > &nodes, QVector< int > &dof, QVector< double > &values, bool *constantValues) const |
| See comments on base class. Fills vectors with prescribed node concentrations. | |
| virtual bool | fillFixedNodalDofsBCbasalt (QVector< int > &nodes, QVector< int > &dof, QVector< double > &values, bool *constantValues) const |
| virtual bool | calcDerivedResults (bool nonLinearSolver) |
| Calc velocity and flow on nodes and/or Gauss points. | |
Protected Types | |
| enum | PhysicsAttributeIds { ISOPARAMETRIC_ID , MULTI_DISPERSION_ID , MULTI_RETARDATION_ID , ALKALINITY_ID , BASALTRXN_ID , NUM_ATTRIBUTE_IDS } |
| IDs for physics attributes. More... | |
| enum | StateVarIds { C_ID } |
| IDs fo physics state vars. More... | |
| enum | NodeAttributeIds { NUM_NA_IDS } |
| IDs for physics node attributes. More... | |
| enum | GaussAttributeIds { V_GA_ID , NUM_GA_IDS } |
| IDs for physics Gauss attributes. More... | |
| enum | ElementPropertyIds { D_ID , K_ID , V_ID , PHI_ID , THICKNESS_ID , NUM_PROPERTY_IDS } |
| IDs for physics element properties. More... | |
| enum | BoundaryConditionIds { PRESCRIBED_C_BC_ID , PRESCRIBED_FLUX_BC_ID , PRESCRIBED_MIXED_BC_ID , PRESCRIBED_CN_BC_ID , NUM_BC_IDS } |
| IDs for accepted boundary condition types. More... | |
| enum | BoundaryConditionValueIds { BC_C_ID , BC_CN_ID , BC_Q_ID , BC_QDIR_ID , BC_MX_ID , NUM_BCV_IDS } |
| IDs for property values from accepted boundary condition types. More... | |
Protected Member Functions | |
| virtual bool | reactionRate (const GmElement *e, const GmVector *ip, int ipIndex, const GmVector &N, const GmVector &C, double wtJ, GmVector &elemFe, GmMatrix &elemK, bool needsFe, bool needsK)=0 |
| Virtual function called by fillElementData() for each integration point so that derived classes can add specific reaction rate terms to the convection-diffusion equation. | |
Protected Attributes | |
| GmVector | _data |
| Save alkalinity data for boundary condition. | |
| GmVector | _Cglobal |
Private Member Functions | |
| void | fillDispersionCoefficient (const GmElement *e, const GmVector &ipCoord, int ipIndex, int s, GmMatrix &D) |
| Fills the dispersion coefficient matrix for the given point and species. | |
| void | addSpeciesToElementMatrix (int s, const GmMatrix &speciesMat, GmMatrix &elemMat) |
| Assembles the given species matrix inside the "global" element matrix for species "s", adding values. | |
| void | addSpeciesToElementVector (int s, const GmVector &speciesVec, GmVector &elemVec) |
Basic class for chemical fem physics. Treats the diffusion and convective terms of the transport equation, leaving the reactive term to be handled by derived classes.
This base class implements the convective and diffusive terms of the convection-diffusion equation, calling the reactionRate() virtual function to provide the generation term.
Basic equation:
k * phi * dC/dt = div (phi * D * grad C) - div (v * C) + R, where:
C is the concentration [mol/m3] phi is the material porosity [0 to 1] k is the retardation coefficient [adimensional] D is the dispersion coefficient [m2/s] v is the fluid velocity [m/s] R is the reaction rate [mol/(m3.s)]
This implementation does not include any stabilization terms for the convection and is based on the temperature equation discretization described in "Fundamentals of the Finite Element Method for Heat and Fluid Flow", Lewis et al, section 3.4.1, equations 3.260 and 3.261.
For multi-species calculation, the concentration state variable should be declared as a vector with dimension equal to the desired number of species. In that case, both D and k can assume individual values per species D[s] and k[s], depending on the physics parameters multiDispersion and multiRetardation. If individual values for k are given (multiRetardation = true), the given property value should be a vector with dimension equal to the number of species.
On single species scenarios, the D property can be given as a scalar, a vector with the x, y (x, y and z for 3D) components of the D matrix or as a full matrix. For the multi-species scenario, if multiDispersion is set to true, D should be a vector with a scalar for each species, a matrix with one line for each species and one column for each dimension (stacking single species vectors) or a matrix stacking each species full matrix.
On multi-species calculations, the diffusion and convection terms are independent for each species. Coupling terms are given only by the reaction term R.
The basic discretization for this equation is:
wtJ = w * t * detJ (integration point weight * elem width if 2D * Jacobian determinat)
elemK = (wtJ * Bt * phi * D[s] * B) - (wtJ * Bt * v * Nt) = wtJ * Bt * (phi * D[s] * B - v * Nt) nxd dxd dxn nxd dx1 1xn
elemC += wtJ * phi * k[s] * N * Nt nx1 1xn
|
protected |
IDs for accepted boundary condition types.
|
protected |
IDs for property values from accepted boundary condition types.
|
protected |
IDs for physics element properties.
|
protected |
|
protected |
|
protected |
IDs for physics attributes.
|
protected |
|
private |
Assembles the given species matrix inside the "global" element matrix for species "s", adding values.
Layout example (for a 3 node element, 2 species):
speciesMat = [[k11, k12, k13] [k21, k22, k23] [k31, k32, k33]]
elemMat = [[k11a, 0, k12a, 0, k13a, 0 ] [0, k11b, 0, k12b, 0, k13b] [k21a, 0, k22a, 0, k23a, 0 ] [0, k21b, 0, k22b, 0, k23b] [k31a, 0, k32a, 0, k33a, 0 ] [0, k31b, 0, k32b, 0, k33b]]
|
virtual |
Calc velocity and flow on nodes and/or Gauss points.
Reimplemented in GmpChemicalInterface, GmpChemicalReaction, GmpIphreeqcBasaltReaction, GmpIphreeqcReaction, and GmpNeuralNetworkReaction.
|
virtual |
Checks the existance of the velocity accessor, and also sizes for the dispersion and retardation coefficients, as well as sizes for the prescribed concentration and prescribed flux boundary conditions.
Reimplemented in GmpChemicalPipe, GmpChemicalReaction, GmpFixedReaction, GmpIphreeqcBasaltReaction, GmpIphreeqcReaction, GmpLinearReaction, GmpNeuralNetworkReaction, GmpPipeFixedReaction, and GmpPipeNonLinearReaction.
|
private |
Fills the dispersion coefficient matrix for the given point and species.
Expects the "D" property to be either (d = dimension and ns = number of species):
|
virtual |
Fills the element stiffness matrix for element 'e' with diffusive and convective terms. Calls the virtual function reactionRate() for filling the external forces().
Diffusive and convective terms for multi-species are independent. The reactive term, on the other hand, can have inter-species dependencies.
Reference: "Fundamentals of the Finite Element Method for Heat and Fluid Flow", Lewis et al, section 3.4.1, equations 3.260 and 3.261 If requested in the matrix set, the function can also fill a C matrix used in transiente analysis (see chapter 6, equation 6.21 on the previous book reference).
Reimplemented in GmpChemicalFixedEmbeddedFracture, GmpChemicalInterface, and GmpChemicalPipe.
|
virtual |
Fills the element force vector elemF for element 'e', taking into account fixed flux boundary conditions.
Reference: "Fundamentals of the Finite Element Method for Heat and Fluid Flow", Lewis et al, section 3.4.1, equations 3.260 and 3.261
Definition of q flux concentration vector
Its different of v fluid vector.
Boundary Conditions Treatment for Adv-Diff Problem
Reimplemented in GmpChemicalInterface, and GmpChemicalPipe.
|
virtual |
See comments on base class. Fills vectors with prescribed node concentrations
Reimplemented in GmpChemicalInterface, and GmpChemicalPipe.
|
virtual |
Returns a pointer to the basic chemical physics attribute map, built when the function is called for the first time. Will be extended by sub-classes providing the reactive term.
Reimplemented in GmpChemicalFixedEmbeddedFracture, GmpChemicalInterface, GmpChemicalPipe, GmpChemicalReaction, GmpFixedReaction, GmpIphreeqcBasaltReaction, GmpIphreeqcReaction, GmpLinearReaction, GmpNeuralNetworkReaction, GmpPipeFixedReaction, and GmpPipeNonLinearReaction.
|
protectedpure virtual |
Virtual function called by fillElementData() for each integration point so that derived classes can add specific reaction rate terms to the convection-diffusion equation.
It receives as parameters the current element, integration point coordinate and index being processed, along with the shape function vector calculated over this point, a concentration vector for the element nodes and a constant 'wtJ' storing the product of the current integration point weight, the element thickness for 2D scenarions and the element Jacobian determinant.
The function should add its contributions to the elemFe and elemK vector / matrix according to the request given by needsFe and needsK.
Implemented in GmpChemicalInterface, GmpChemicalReaction, GmpFixedReaction, GmpIphreeqcBasaltReaction, GmpIphreeqcReaction, GmpLinearReaction, GmpNeuralNetworkReaction, GmpPipeFixedReaction, and GmpPipeNonLinearReaction.