00001 #include "mixedhybridcompositional.h"
00002 #include "numericmethods.h"
00003 #include "hdf5orthowriter.h"
00004 #include "gnuplotanim.h"
00005
00006
00007 MixedHybridCompositional::MixedHybridCompositional(OrthoMesh &mesh,Function3D &fInitP,Function3D &fPrescribedVelocities, Function3D &fPrescribedPression, const VecDouble &K, const VecDouble &vPor, GeneralFunctionInterface &fMobT, GeneralFunctionInterface &fFracFlux,double grav, double dt, FlashCompositional &flash,LinearSolver &solver,int debugLevel,bool bCheckNoBC)
00008 :m_mesh(mesh),
00009 m_fMobT(fMobT),
00010 m_fFracFlux(fFracFlux),
00011 m_vPor(vPor),
00012 m_vK(K),
00013 m_grav(grav),
00014 m_dt(dt),
00015 m_solver(solver),
00016 m_flash(flash),
00017 _debugLevel(debugLevel)
00018 {
00019
00020
00021 this->setBoundaryCondition(m_bc,m_mesh,fPrescribedVelocities,fPrescribedPression,bCheckNoBC);
00022 this->buildSparsityPattern(mesh,m_sparsePattern);
00023 m_A.reinit(m_sparsePattern);
00024 m_B.reinit(m_mesh.numCells());
00025 m_sol.reinit(m_mesh.numCells(),NAN);
00026 m_Vq.reinit(m_mesh.numFaces());
00027
00028 mesh.setCentralValuesFromFunction(fInitP,m_sol);
00029
00030
00031 m_vInvH2.reinit(3);
00032 m_vInvH2(OrthoMesh::NORMAL_X)=1.0/(pow(mesh.get_dx(),2));
00033 m_vInvH2(OrthoMesh::NORMAL_Y)=1.0/(pow(mesh.get_dy(),2));
00034 m_vInvH2(OrthoMesh::NORMAL_Z)=1.0/(pow(mesh.get_dz(),2));
00035 m_inv_hz=1.0/mesh.get_dz();
00036
00037
00038 }
00039
00040 MixedHybridCompositional::~MixedHybridCompositional()
00041 {
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 void MixedHybridCompositional::getVelocitiesAtFaces(Matrix &vel)
00055 {
00056 assert(vel.m() == m_mesh.numFaces() && vel.n() == 3);
00057
00058 vel = 0.0;
00059
00060 OrthoMesh::Face_It face = m_mesh.begin_face();
00061 OrthoMesh::Face_It endf = m_mesh.end_face();
00062
00063
00064 for (;face!=endf;face++)
00065 {
00066 vel(face->index(),face->getNormalOrientation()) = m_Vq(face->index());
00067 }
00068 }
00069
00070 void MixedHybridCompositional::getVelocitiesAtCells(Matrix &vel)
00071 {
00072 m_mesh.projectVelocitiesInFacesToCells(vel,m_Vq);
00073 }
00074
00075
00076
00077 void MixedHybridCompositional::printOutput()
00078 {
00079 if (_debugLevel > 0)
00080 {
00081 VecDouble v(m_mesh.numCells());
00082 VecDouble Vv(m_mesh.numVertices());
00083 HDF5OrthoWriter &hdf5 = HDF5OrthoWriter::getHDF5OrthoWriter();
00084
00085 m_mesh.projectCentralValuesAtVertices(getPressureAtCells(),Vv);
00086 hdf5.writeScalarField(Vv,"P");
00087
00088
00089
00090
00091 if (_debugLevel > 1)
00092 {
00093 Matrix Mvel(m_mesh.numCells(),3);
00094 FEValuesExtractors::Vector velocities(0);
00095 this->getVelocitiesAtCells(Mvel);
00096 if (_debugLevel > 2)
00097 {
00098
00099
00100 }
00101 VecDouble v(m_mesh.numCells());
00102 for (unsigned i=0;i<v.size();i++)
00103 {
00104 v(i) = Mvel(i,0);
00105 }
00106 VecDouble minVel(3);
00107 VecDouble maxVel(3);
00108 NumericMethods::getMinMaxValueByColumn(Mvel,minVel,maxVel);
00109 printf("Min Vel <%g,%g,%g> - Max Vel <%g,%g,%g>\n",minVel(0),minVel(1),minVel(2),maxVel(0),maxVel(1),maxVel(2));
00110
00111 m_mesh.projectCentralValuesAtVertices(v,Vv);
00112 hdf5.writeScalarField(Vv,"Vel");
00113 }
00114 }
00115
00116 }
00117
00118
00119
00120
00121 void MixedHybridCompositional::getNormalVelocityAtFaces(VecDouble &vFNC)
00122 {
00123 vFNC=m_Vq;
00124 }
00125
00126
00127 const VecDouble& MixedHybridCompositional::getPressureAtCells()
00128 {
00129 return m_sol;
00130 }
00131
00132
00133