ChemicalFemPhysics
The GeMA Standard Chemical FEM Physics Plugin
Loading...
Searching...
No Matches
gmpChemicalReaction.h
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_CHEMICAL_REACTION_H_
25#define _GEMA_PLUGIN_CHEMICAL_REACTION_H_
26
28#include <gmSimulationData.h>
29
30#pragma warning( push ) // Phreeqc messes with warning 4251 and ends-up re-enabling it
31#include <IPhreeqc.hpp>
32#pragma warning( pop )
33
34
36class GMP_CHEMICAL_FEM_PHYSICS_API_EXPORT GmpChemicalReaction : public GmpChemicalFemPhysics
37{
38public:
39 GmpChemicalReaction(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
40 virtual ~GmpChemicalReaction();
41
42 // Comments on the base class
43 virtual const char* pluginType() const { return "chemicalReaction"; }
44
45 // Comments on the base class
46 virtual const QVariantMap* physicsMetaDataMap();
47
48 // Comments on the base class
49 virtual bool checkLoadedData();
50
51 // Comments on the base class
52 virtual bool beforeElementStiffnessLoop(const GmpFemMatrixSet& elemMatrices, const GmpFemVectorSet& elemVectors);
53
54 // INITIAL CONDITIONS SIMULATION
55
56 // Function to fill in IPhreeqc input data for initial condition
57 virtual void createIPhreeqcIC(IPhreeqc& R, int node);
58
59 // Function to Run IPhreeqc for calculate initial condition
60 virtual bool runIPhreeqcIC(IPhreeqc& R);
61
62 // save IPhreeqc Results value to node mesh attributes for Initial Conditions
63 virtual bool saveIPhreeqcValuestoMeshIC(IPhreeqc& R, int node);
64
65 //BOUNDARY CONDITIONS VALUE SIMULATION
66
67 // Function to fill IPhreeqc input data for Boundary Conditions
68 virtual bool createIPhreeqcBC(IPhreeqc& R);
69
70 //Function to run Iphreeqc Boundary Conditions
71 virtual bool runIPhreeqcBC(IPhreeqc& R);
72
73 // Save IPhreeqc Results value to Boundary Conditions
74 virtual bool saveIPhreeqcValuestoBCNode(IPhreeqc& R);
75
76 // RUN IPREEQC FOR NODE VALUE CALCULATIOS
77 // Function to fill in IPhreeqc input data
78 virtual bool createIPhreeqcInput(IPhreeqc& R, int node);
79
80 // Function to Run IPhreeqc
81 virtual bool runIPhreeqc(IPhreeqc& R);
82
83 // save IPhreeqc value to node mesh attributes
84 virtual bool saveIPhreeqcValuestoNode(IPhreeqc& R, int node);
85
86 // concatenate input data
87 char *concatenateChar(std::string name, long double val);
88 char *concatenateChar(std::string name, GmVector val);
89 char *concatenateChar(std::string name, long double val1, std::string name2, long double val2);
90 char *concatenateChar(std::string name, long double val1, std::string name2);
91 char *concatenateChar(std::string name, std::string name2, int val1, std::string name3);
92 // Fill parameters to solution and equilibrium reaction
93 virtual GmVector fillSolutionParameters(GmCellAccessor* ac, const GmElement* e, const GmVector* coord, int ip) const;
94 virtual GmMatrix fillEquilibriumParameters(GmCellAccessor* ac, const GmElement* e, const GmVector* coord, int ip) const;
95
96 // Get results after convergence
97 virtual bool calcDerivedResults(bool nonLinearSolver);
98
99 // method to run Iphreeqc at every node fo the mesh
100 virtual bool runIphreeqcNodes();
101
102 // funtion to run Iphreeqc to calculate initial condition to mesh
103 virtual bool runInitIphreeqcNodes();
104
105 // function to run Iphreeqc for boundary conditions value
106 virtual bool runBCIPhreeqc();
107
108 // read node reaction values
109 virtual void getReactionValues(const GmElement* e, const GmVector& Rg, GmVector& Re, int pos) const;
110
111 // Fill vector for element data
112 virtual void FillElementalReaction(const GmElement* e, GmVector& elemFe, const GmVector& Fr, int pos) const;
113 char buffer[200];
114
115protected:
116
117 virtual bool reactionRate(const GmElement* e, const GmVector* ip, int ipIndex, const GmVector& N,
118 const GmVector& C, double wtJ, GmVector& elemFe, GmMatrix& elemK,
119 bool needsFe, bool needsK);
120
123 {
126 TEMP_A_ID,
127 PE_A_ID,
128 DW_A_ID,
129 MW_A_ID,
130 ALK_A_ID,
131 PH_A_ID,
132 Ca_A_ID,
133 Cl_A_ID,
134 Mg_A_ID,
135 C_A_ID,
136 Fe_A_ID,
137 Na_A_ID,
138 NEc_A_ID,
139 NEd_A_ID,
140 SIc_A_ID,
141 SId_A_ID,
142 nKc_A_ID,
143 nKd_A_ID,
144 SRc_A_ID,
145 SRd_A_ID,
146 POROS_A_ID,
147 // Boundary conditions fluid compositions
148 TEMP_Abc_ID,
149 PE_Abc_ID,
150 DW_Abc_ID,
151 MW_Abc_ID,
152 ALK_Abc_ID,
153 PH_Abc_ID,
154 Ca_Abc_ID,
155 Cl_Abc_ID,
156 Mg_Abc_ID,
157 C_Abc_ID,
158 Fe_Abc_ID,
159 Na_Abc_ID,
160
161
162 // --- NO ADDING BELOW THIS LINE
164 };
165
168 {
172 SIndexOld_NA_ID,
174 PHOld_NA_ID,
176 EqRxnOld_NA_ID,
178 MineralOld_NA_ID,
180 poroMOld_NA_ID,
182 KinCtrOld_NA_ID,
183
184 // ------ NO ADDING BELOW THIS LINE
186 };
187
190 {
192 BonCon_D,
193 Fip_D,
194
195
196 // --- NO ADDING BELOW THIS LINE
198 };
199
200private:
201 IPhreeqc _IPhreeqcReaction; // IPhreeqc reaction
202
203};
204
205#endif
Basic class for chemical fem physics. Treats the diffusion and convective terms of the transport equa...
Definition gmpChemicalFemPhysics.h:35
virtual const QVariantMap * physicsMetaDataMap()
Returns a pointer to the basic chemical physics attribute map, built when the function is called for ...
Definition gmpChemicalFemPhysics.cpp:95
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 a...
@ NUM_PROPERTY_IDS
The number of property ids above.
Definition gmpChemicalFemPhysics.h:120
@ NUM_ATTRIBUTE_IDS
The number of attribute ids above.
Definition gmpChemicalFemPhysics.h:84
virtual bool calcDerivedResults(bool nonLinearSolver)
Calc velocity and flow on nodes and/or Gauss points.
Definition gmpChemicalFemPhysics.cpp:1030
virtual bool checkLoadedData()
Checks the existance of the velocity accessor, and also sizes for the dispersion and retardation coef...
Definition gmpChemicalFemPhysics.cpp:176
@ NUM_NA_IDS
The number of node attribute ids above.
Definition gmpChemicalFemPhysics.h:97
Extends the basic chemical physics transport equation by providing reaction rates based on the Iphree...
Definition gmpChemicalReaction.h:37
iPhreeqcReactionPhysicsAttributeIds
Additional IDs for physics attributes.
Definition gmpChemicalReaction.h:123
@ REACTION_TYPE_ID
Id for retrieving the reaction type physics attribute.
Definition gmpChemicalReaction.h:125
@ NUM_ATTRIBUTE_IDS
The number of attribute ids above.
Definition gmpChemicalReaction.h:163
iPHreeqcReactionElemPropertyIds
Additional IDs for physics element properties.
Definition gmpChemicalReaction.h:190
@ NUM_PROPERTY_IDS
The number of property ids above.
Definition gmpChemicalReaction.h:197
NodeAttributeIds
IDs for physics node attributes.
Definition gmpChemicalReaction.h:168
@ IonSolOld_NA_ID
Base Id for history of Ion transport node attribute(s)
Definition gmpChemicalReaction.h:170
@ SIndex_NA_ID
Base Id for Saturation index.
Definition gmpChemicalReaction.h:171
@ Mineral_NA_ID
Base Id for mineral for reaction.
Definition gmpChemicalReaction.h:177
@ poroM_NA_ID
Base Id for porosity variation.
Definition gmpChemicalReaction.h:179
@ NUM_NA_IDS
The number of node attribute ids above.
Definition gmpChemicalReaction.h:185
@ PH_NA_ID
Base Id for pH solution.
Definition gmpChemicalReaction.h:173
@ EqRxn_NA_ID
Base Id for Reaction in equillibrium.
Definition gmpChemicalReaction.h:175
@ KinCtr_NA_ID
Base Id for Kinetics reaction Control.
Definition gmpChemicalReaction.h:181
arma::mat GmMatrix
arma::vec GmVector
Declaration of the GmpChemicalFemPhysics classes.