00001 #include "godunovmethod.h"
00002
00003
00004 GodunovMethod::GodunovMethod(OrthoMesh &mesh,Function3D &fInitU,const VecDouble &cPor,Function3D &fPrescribedU,FaceFluxFunction &flux, FixedValueCondition &fixedC,double CFL)
00005 :LaxFriedrichsForSystem(mesh,fInitU,cPor,fPrescribedU,flux,fixedC,CFL)
00006 {
00007
00008 }
00009
00010
00011
00012 void GodunovMethod::iterateN(unsigned nSteps, double dt)
00013 {
00014 unsigned posCell,negCell;
00015
00016
00017
00018
00019
00020 static VecDouble vBC(n_components),vFlux(n_components);
00021 static VecDoubleRef vQPos(n_components),vQNeg(n_components);
00022
00023
00024 for (unsigned count = 0; count < nSteps; count++)
00025 {
00026
00027 OrthoMesh::Cash_Face_It face = m_mesh.begin_cash_face();
00028 OrthoMesh::Cash_Face_It endf = m_mesh.end_cash_face();
00029 m_vbc.rewind();
00030 bool hasbc;
00031
00032
00033 m_solAnt = m_sol;
00034
00035
00036 for (;face!=endf;face++)
00037 {
00038 face->getAdjCellIndices(negCell,posCell);
00039
00040 hasbc=this->getValuesOfTheFaceCells(m_mesh,m_vbc,m_solAnt,face->index(),negCell,posCell,vQNeg,vQPos);
00041
00042
00043
00044
00045
00046
00047 if (posCell == OrthoMesh::INVALID_INDEX)
00048 posCell=negCell;
00049 else if (negCell == OrthoMesh::INVALID_INDEX)
00050 negCell=posCell;
00051
00052
00053
00054 double posPor = getPorosity()(posCell);
00055 double negPor = getPorosity()(negCell);
00056 double mPor = (posPor + negPor)/2.0;
00057
00058
00059
00060 m_flux.exactFluxAtFace(vFlux,face,vQNeg,vQPos);
00061
00062
00063
00064 for (unsigned cmp=0;cmp<n_components;cmp++)
00065 {
00066
00067
00068 double flux;
00069 if (!hasbc)
00070 {
00071
00072
00073
00074
00075
00076
00077
00078 flux = dt*face->areaPerCellVol() * vFlux(cmp) - mPor*(vQPos(cmp)-vQNeg(cmp))/6.0;
00079 }
00080 else
00081 {
00082 flux = dt*face->areaPerCellVol() * vFlux(cmp);
00083 }
00084
00085
00086
00087
00088 if (face->hasPosCell())
00089 m_sol(posCell,cmp) += + flux/posPor;
00090
00091 if (face->hasNegCell())
00092 m_sol(negCell,cmp) += - flux/negPor;
00093
00094 }
00095 }
00096
00097
00098 }
00099
00100
00101 }
00102
00103