KTMethodDByD Class Reference

#include <ktmethoddbyd.h>

Inheritance diagram for KTMethodDByD:
Inheritance graph
[legend]
Collaboration diagram for KTMethodDByD:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KTMethodDByD (OrthoMesh &mesh, Function3D &fInitU, const VecDouble &cPor, Function3D &fPrescribedU, FaceFluxFunction &flux, FixedValueCondition &fixedC, double CFL)
 ~KTMethodDByD ()
virtual void iterate (double t, double tEnd)

Private Member Functions

void iterateOnce (VecDouble &prev, VecDouble &sol, double dt)

Private Attributes

double DX_2 [3]
Matrix _MG
VecDouble m_cValuesAux
VecDouble m_cValues
VecDouble m_cValuesPrev

Detailed Description

Definition at line 9 of file ktmethoddbyd.h.


Constructor & Destructor Documentation

KTMethodDByD::KTMethodDByD ( OrthoMesh mesh,
Function3D fInitU,
const VecDouble cPor,
Function3D fPrescribedU,
FaceFluxFunction flux,
FixedValueCondition fixedC,
double  CFL 
)

Definition at line 7 of file ktmethoddbyd.cpp.

00008   :LaxFriedrichsForSystem(mesh,fInitU,cPor,fPrescribedU,flux,fixedC,CFL)
00009  {
00010    DX_2[0]=mesh.get_dx()/2.0;
00011    DX_2[1]=mesh.get_dy()/2.0;
00012    DX_2[2]=mesh.get_dz()/2.0;
00013    assert(n_components == 1);
00014    m_cValues.setRef(&(m_sol(0,0)),m_sol.size());
00015    m_cValuesPrev.setRef(&(m_solAnt(0,0)),m_sol.size());
00016 
00017    
00018    _MG.reinit(mesh.numCells(),3);
00019    m_cValuesAux.reinit(mesh.numCells());
00020    
00021 
00022    return;
00023 
00024    
00025 }

KTMethodDByD::~KTMethodDByD (  )  [inline]

Definition at line 21 of file ktmethoddbyd.h.

00021 {}


Member Function Documentation

void KTMethodDByD::iterate ( double  t,
double  tEnd 
) [virtual]

Definition at line 28 of file ktmethoddbyd.cpp.

00029 {
00030 
00031   double timeInterval = tEnd-t;
00032   double dt = this->calculateTimeStep(m_mesh,timeInterval,m_CFL,getPorosity(),m_flux);
00033   int nIteraction = (int) round(timeInterval/dt); //number of iteractions
00034 
00035   printf("KT dt = %g\n",dt);
00036   //For each time step
00037   for (int count = 0; count < nIteraction; count++)
00038   {
00039     iterateOnce(m_cValuesPrev,m_cValues,dt);
00040     iterateOnce(m_cValuesAux,m_cValues,dt);
00041     m_cValues.sadd(0.5,0.5,m_cValuesPrev);
00042   }
00043 }

void KTMethodDByD::iterateOnce ( VecDouble prev,
VecDouble sol,
double  dt 
) [private]

Definition at line 46 of file ktmethoddbyd.cpp.

00047 {
00048   buildDerivatives(m_mesh,vSol,_MG);
00049 
00050 
00051     //Get the face iterator and the number of faces.
00052     //OrthoMesh::Cash_Face_It face = m_mesh.begin_cash_face();
00053     //OrthoMesh::Cash_Face_It endf = m_mesh.end_cash_face();
00054   OrthoMesh::Face_It face = m_mesh.begin_face();
00055   OrthoMesh::Face_It endf = m_mesh.end_face();
00056   m_vbc.rewind();
00057   bool hasbc;
00058 
00059   vAux=vSol;
00060 
00061     //For each face
00062     for (;face!=endf;face++)
00063     {
00064       //Get the values of the previous solution in the right and left of the face
00065       static VecDouble SwNeg(1),SwPos(1),vFlux(1);
00066       unsigned negCell,posCell;
00067 
00068       face->getAdjCellIndices(negCell,posCell);
00069 
00070       //Get the values of the previous solution in the right and left of the face
00071       hasbc=this->getValuesOfTheFaceCellsScalar(m_mesh,m_vbc,vAux,face->index(),negCell,posCell,&SwNeg(0),&SwPos(0));
00072 
00073 
00074       //Get the indices of the cells that contain the face.
00075       //If the face is at boundary, it has just one cell.
00076       //In this case the method getAdjCells() return posCell == negCell
00077       if (posCell == OrthoMesh::INVALID_INDEX)
00078         posCell=negCell;
00079       else if (negCell == OrthoMesh::INVALID_INDEX)
00080         negCell=posCell;
00081 
00082 
00083 
00084       unsigned normal = face->getNormalOrientation();
00085       
00086       double posPor = getPorosity()(posCell);
00087       double negPor = getPorosity()(negCell);
00088       //double mPor = (posPor + negPor)/2.0;
00089       
00090       SwNeg(0) += DX_2[normal]*_MG(negCell,normal); 
00091       SwPos(0) -= DX_2[normal]*_MG(posCell,normal); 
00092 
00093       //calculate the right coefficient of diffusion 
00094       double a;
00095       a = fabs(m_flux.maxLocalCharVelocity(face,SwNeg,SwPos));
00096 
00097       //printf("%g ",a);
00098        //Calculate the amount of the mass passed through the face and divide it by the cell volume
00099       m_flux.fluxAtFace(vFlux,face,SwNeg,SwPos);
00100       double flux =  dt*face->areaPerCellVol()* (vFlux(0)  - a*(SwPos(0)-SwNeg(0))/2.0);
00101       //printf("face %d = %g,Pos: %d,Neg %d, SwPos = %g,SwNeg = %g \n",faceIndex,flux,face->getPosCellIndex(),face->getNegCellIndex(),SwPos,SwNeg);
00102       if (face->hasNegCell())
00103         vSol(negCell) +=  - flux/negPor;
00104 
00105       if (face->hasPosCell())
00106         vSol(posCell) +=  + flux/posPor;
00107     }
00108 }


Member Data Documentation

Definition at line 13 of file ktmethoddbyd.h.

double KTMethodDByD::DX_2[3] [private]

Definition at line 12 of file ktmethoddbyd.h.

Definition at line 14 of file ktmethoddbyd.h.

Definition at line 14 of file ktmethoddbyd.h.

Definition at line 14 of file ktmethoddbyd.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:13 2012 for CO2INJECTION by  doxygen 1.6.3