00001 #ifndef _MY_MainApp_
00002 #define _MY_MainApp_
00003 #include <string>
00004 #include "dealbase.h"
00005 #include "configfile.h"
00006 #include "transportbase.h"
00007 #include "dynamicbase.h"
00008 #include "orthomesh.h"
00009 #include "sequencer.h"
00010 #include "facefluxfunction.h"
00011 #include "co2gridgenerator.h"
00012 #include "constvelocitymodule.h"
00013 #include "facefluxfunction.h"
00014 #include "flashbase.h"
00015 #include "opointer.h"
00016 #include "linearsolver.h"
00017 #include "fixedvaluecondition.h"
00018 #include "diffusivestep.h"
00019 #include "stringhashfun.h"
00020 #include "doubleporositydiff.h"
00021 #include "blockmatrixmodule.h"
00022 #include "monitorwells.h"
00023
00024 using std::string;
00025
00026 class UnitTests;
00030 class MainApp
00031 {
00032 std::ostream *pOut;
00033 friend class UnitTests;
00034 std::string m_suffix;
00035 protected:
00036 Dictionary log;
00037
00038 ConfigFile configFile;
00039 VecWellInfo m_wells;
00040 OPointer<MonitorWells> m_pMonitorWells;
00041 bool m_bPrint;
00042 OPointer<OrthoMesh> m_pMesh;
00043 OPointer<OrthoMesh> m_pMB_Mesh;
00044 VecDouble m_cPor;
00045 VecDouble m_cK;
00046 VecDouble m_mbcPor;
00047 VecDouble m_mbcK;
00048
00049
00050 OPointer<GeneralFunctionInterface> m_fMob,m_fMobT,m_fMobGrav,m_fFracFlux;
00051 OPointer<GeneralFunctionInterface> m_mb_fMob,m_mb_fMobT,m_mb_fMobGrav,m_mb_fFracFlux;
00052 OPointer<GeneralFunctionInterface> m_fKr1, m_fKr2, m_fDKr1,m_fDKr2;
00053
00054
00055
00056 OPointer<GeneralFunctionInterface> m_DfMobGrav,m_DfFracFlux,m_fKr,m_fDKr;
00057 OPointer<GeneralFunctionInterface> m_mb_DfMobGrav, m_mb_DfFracFlux;
00058 OPointer<GeneralFunctionInterface> m_fPc,m_dfPc,m_fPcInv;
00059 OPointer<GeneralFunctionInterface> m_mb_fPc, m_mb_dfPc, m_mb_fPcInv;
00060 OPointer<Function3D> m_fSource;
00061
00062 FaceFluxFunction *m_flux;
00063 Function3D *m_fTransBC;
00064 Function3D *m_fInit;
00065 Function3D *m_fPor;
00066 Function3D *m_mbfPor;
00067 Function3D *m_pVelFunction;
00068 Function3D *m_fK;
00069 Function3D *m_mbfK;
00070 OPointer<Function3D> m_fFluxBC,m_fDP;
00071 OPointer<Function3D> m_fDU,m_fTensionBC;
00072 OPointer<Function3D> m_fInitPressure;
00073 OPointer<LinearSolver> m_pSolver;
00074 OPointer<DiffusiveStep> m_pDiff;
00075 OPointer<DynamicBase> m_pDynamicModule;
00076 OPointer<TransportBase> m_pTransportModule;
00077 Sequencer *m_pSequencer;
00078 FlashBase *m_pFlash;
00079 OPointer<Function1D> m_pRelMob;
00080
00081
00082 FixedValueCondition m_fixedC;
00083 FixedValueCondition m_fixedP;
00084
00085 BlockMatrixModule *m_blockMatrix;
00086
00087 BlockMatrixModule& getBlockMatrix();
00088
00089
00090
00091
00092 void adjustInitialConditionForCompressibleModel(DynamicBase &dyn,ConservativeMethodForSystem &trans, FlashCompositional &flash);
00093
00094 void setOutput(std::ostream &out){pOut = &out;}
00095
00096 void printTriangulation();
00097 void printBeginSection(std::string str,std::ostream &out=std::cout);
00098 void textcolor(int attr, int fg, int bg);
00099 void printMeshInfo();
00100
00101 void setTriangulation(Triangulation<3>& tria);
00102 void appendSuffixToFileNames(std::string suffix){m_suffix=suffix;}
00103 std::string getHDF5FileName();
00104 std::string getMonitorWellsOutputFileName();
00105 unsigned hasSystemOfTransportEquations();
00106
00107 protected:
00108
00109 Point3D getP0();
00110 Point3D getP1();
00111 Point3D getDX();
00112 std::vector<unsigned> getNElements();
00113 OrthoMesh& getMesh();
00114
00115 OrthoMesh& getMB_Mesh();
00116
00117
00118 VecWellInfo getWells();
00119 VecWellInfo getSourceWells();
00120 MonitorWells& getMonitorWells();
00121 void getWellsPressureBC(Function3D *&fP,Function3D *&fFlux) ;
00122 Function3D& getWellsSourceTerm();
00123 Function3D* getWellTransportBC(std::string varName);
00124
00125
00126 double getYoung();
00127 double getPoisson();
00128 double getDynamicTimeStep();
00129
00130
00131 void getMobilities(GeneralFunctionInterface* &fMob,GeneralFunctionInterface* &fMobT,GeneralFunctionInterface* &fFracFlux,GeneralFunctionInterface* &DfFracFlux,GeneralFunctionInterface* &fMobGrav,GeneralFunctionInterface* &DfMobGrav);
00132
00133 void getKr(GeneralFunctionInterface* &fKr,GeneralFunctionInterface* &DfKr);
00134
00135
00136 void mb_getMobilities(GeneralFunctionInterface* &fMob,GeneralFunctionInterface* &fMobT,GeneralFunctionInterface* &fFracFlux,GeneralFunctionInterface* &DfFracFlux,GeneralFunctionInterface* &fMobGrav,GeneralFunctionInterface* &DfMobGrav);
00137
00138 void getPcFunction(GeneralFunctionInterface **fpc,GeneralFunctionInterface **dfpc,GeneralFunctionInterface **fpcInv);
00139
00140 void mb_getPcFunction(GeneralFunctionInterface **mb_fpc, GeneralFunctionInterface **mb_dfpc, GeneralFunctionInterface **mb_fpcInv);
00141
00142 void getPBoundaryCondition(Function3D * &fDP, Function3D * &fFlux);
00143 void getUBoundaryCondition(Function3D * &fDU, Function3D * &fTensionBC);
00144 FixedValueCondition& getTransportFixedConditions();
00145 FixedValueCondition& getPressureFixedConditions();
00146
00147 ConstVelocityModule* getConstVelocityDynamicModule();
00148 LinearSolver* getLinearSolver();
00149 DynamicBase* getDynamicModule();
00150 Function3D* getPressureIC();
00151
00152 Function3D* getTransportBC(std::string compName);
00153 Function3D* getTransportIC(std::string compName);
00154
00155
00156 FaceFluxFunction* getFluxFunction();
00157 TransportBase* getTransportModule();
00159
00160 FlashBase* getFlash();
00161 FlashCompositional* getFlashCompositional();
00162 bool isCompositionalFlash();
00163
00164
00165 DiffusiveStep* getDiffusiveStep();
00166 Function3D* getTransportForSystemBC(unsigned nCmps);
00167 Function3D* getTransportForSystemIC(unsigned nCmps);
00168
00169 Sequencer* getSequencer();
00171 void enablePrint(bool b){m_bPrint = b;}
00172 Point3D getSpatialDiscretizationSteps();
00173 Point3D getDomainDimensions();
00174
00175 Function3D* getPorousMediaProperty(std::string key);
00176
00177 VecDouble& getPorosityAtCells();
00178 VecDouble& getPermeabilityAtCells();
00179
00180 VecDouble& mb_getPorosityAtCells();
00181 VecDouble& mb_getPermeabilityAtCells();
00182 void print(std::string section,const char *format,...);
00183 void printLog(std::ostream &out);
00184 void print_log_entry(std::string section,std::ostream &out);
00185 public:
00186
00187 MainApp();
00188 void execute(std::string fileName,bool unitests=false);
00189 void coarseMesh(unsigned nX,unsigned nY,unsigned nZ,string fileIn,string fileOut);
00190 void abortEvent();
00191
00192 ~MainApp();
00193
00194 };
00195
00196 #endif