ChemicalFemPhysics
The GeMA Standard Chemical FEM Physics Plugin
Loading...
Searching...
No Matches
GmpChemicalFemPhysics Class Referenceabstract

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>

Inheritance diagram for GmpChemicalFemPhysics:
Collaboration diagram for GmpChemicalFemPhysics:

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)
 

Detailed Description

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

Member Enumeration Documentation

◆ BoundaryConditionIds

IDs for accepted boundary condition types.

Enumerator
PRESCRIBED_C_BC_ID 

Id for prescribed concentration boundary condition.

PRESCRIBED_FLUX_BC_ID 

Id for prescribed flux boundary condition.

PRESCRIBED_MIXED_BC_ID 

Id for third kind boundary condition.

PRESCRIBED_CN_BC_ID 

Id for prescribed concentration on node boundary condition.

NUM_BC_IDS 

The number of BC ids above.

◆ BoundaryConditionValueIds

IDs for property values from accepted boundary condition types.

Enumerator
BC_C_ID 

Nodal concentration for prescribed concentration boundary condition.

BC_CN_ID 

Nodal concentration for prescribed concentration boundary condition.

BC_Q_ID 

Flux for prescribed flux boundary condition.

BC_QDIR_ID 

Flux direction for prescribed flux boundary condition.

BC_MX_ID 

Third Kind Boundary Condition. Robin/Cauchy.

NUM_BCV_IDS 

The number of BC ids above.

◆ ElementPropertyIds

IDs for physics element properties.

Enumerator
D_ID 

Id for retrieving the dispersion coefficient accessor.

K_ID 

Id for retrieving the retardation coefficient accessor.

V_ID 

Id for retrieving the fluid velocity accessor.

PHI_ID 

Id for retrieving the porosity accessor.

THICKNESS_ID 

Id for retrieving the plane width accessor.

NUM_PROPERTY_IDS 

The number of property ids above.

◆ GaussAttributeIds

IDs for physics Gauss attributes.

Enumerator
V_GA_ID 

Id for retrieving the Gauss attribute providing the fluid velocity.

NUM_GA_IDS 

The number of gauss attribute ids above.

◆ NodeAttributeIds

IDs for physics node attributes.

Enumerator
NUM_NA_IDS 

The number of node attribute ids above.

◆ PhysicsAttributeIds

IDs for physics attributes.

Enumerator
ISOPARAMETRIC_ID 

Id for retrieving the isoParametric physics attribute.

MULTI_DISPERSION_ID 

Id for retrieving the multiDispersion physics attribute.

MULTI_RETARDATION_ID 

Id for retrieving the multiRetardation physics attribute.

ALKALINITY_ID 

Id for retrieving the including alkalanity physics attribute.

NUM_ATTRIBUTE_IDS 

The number of attribute ids above.

◆ StateVarIds

IDs fo physics state vars.

Enumerator
C_ID 

Id for retrieving the acessor to the concentration state var.

Member Function Documentation

◆ addSpeciesToElementMatrix()

void GmpChemicalFemPhysics::addSpeciesToElementMatrix ( int s,
const GmMatrix & speciesMat,
GmMatrix & elemMat )
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]]

◆ calcDerivedResults()

bool GmpChemicalFemPhysics::calcDerivedResults ( bool nonLinearSolver)
virtual

Calc velocity and flow on nodes and/or Gauss points.

Reimplemented in GmpChemicalInterface, GmpChemicalReaction, GmpIphreeqcBasaltReaction, GmpIphreeqcReaction, and GmpNeuralNetworkReaction.

◆ checkLoadedData()

bool GmpChemicalFemPhysics::checkLoadedData ( )
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.

◆ fillDispersionCoefficient()

void GmpChemicalFemPhysics::fillDispersionCoefficient ( const GmElement * e,
const GmVector & ipCoord,
int ipIndex,
int s,
GmMatrix & D )
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):

  • A vector with size ns (for a single species scalar D)
  • A matrix with size ns x d (for a single species vector D), stacking each species D vector
  • A matrix with size d * ns x d (for a single species matrix D), stacking each species D matrix

◆ fillElementData()

GmpFemPhysics::FemResultType GmpChemicalFemPhysics::fillElementData ( const GmElement * e,
GmpFemMatrixSet & elemMatrices,
GmpFemVectorSet & elemVectors )
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.

◆ fillElementDataForBc()

GmpFemPhysics::FemResultType GmpChemicalFemPhysics::fillElementDataForBc ( const GmElement * e,
const GmBoundaryCondition * bc,
int bcIndex,
int bcListIndex,
int border,
GmpFemMatrixSet & elemMatrices,
GmpFemVectorSet & elemVectors )
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

  1. Prescribed of concentration variable, c.
  1. Prescribed of flux of concentration variable, q = -D grad(c) = qb
  1. Third kind boundary condition (Robin/Cauchy), alpha * v * c + beta x q = gamma

Reimplemented in GmpChemicalInterface, and GmpChemicalPipe.

◆ fixedNodalDofsBc()

bool GmpChemicalFemPhysics::fixedNodalDofsBc ( QVector< int > & nodes,
QVector< int > & dof,
QVector< double > & values,
bool * constantValues ) const
virtual

See comments on base class. Fills vectors with prescribed node concentrations

Reimplemented in GmpChemicalInterface, and GmpChemicalPipe.

◆ physicsMetaDataMap()

const QVariantMap * GmpChemicalFemPhysics::physicsMetaDataMap ( )
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.

◆ reactionRate()

virtual bool GmpChemicalFemPhysics::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 )
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.


The documentation for this class was generated from the following files: