00001 #include "russanovforsystem.h"
00002
00003
00004 RussanovForSystem::RussanovForSystem(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 RussanovForSystem::~RussanovForSystem()
00013 {
00014
00015 }
00016
00017
00018
00019
00020 void RussanovForSystem::iterateN(unsigned nSteps, double dt)
00021 {
00022
00023
00024 unsigned posCell,negCell;
00025 double a;
00026
00027
00028
00029
00030 static VecDouble vBC(n_components),vFlux(n_components),vA(n_components);
00031
00032 VecDoubleRef vQPos(n_components),vQNeg(n_components);
00033
00034
00035 for (unsigned count = 0; count < nSteps; count++)
00036 {
00037
00038
00039
00040 OrthoMesh::Face_It face = m_mesh.begin_face();
00041 OrthoMesh::Face_It endf = m_mesh.end_face();
00042 bool hasbc;
00043 m_vbc.rewind();
00044
00045
00046 m_solAnt = m_sol;
00047
00048
00049 for (;face!=endf; face++)
00050 {
00051
00052 face->getAdjCellIndices(negCell,posCell);
00053 hasbc=this->getValuesOfTheFaceCells(m_mesh,m_vbc,m_solAnt,face->index(),negCell,posCell,vQNeg,vQPos);
00054
00055 FaceInfo fInfo(face);
00056
00057
00058
00059
00060
00061
00062
00063 double posPor = getPorosity()(fInfo.cell2);
00064 double negPor = getPorosity()(fInfo.cell1);
00065
00066
00067
00068 m_flux.fluxAtFace(vFlux,fInfo,vQNeg,vQPos);
00069 if (!hasbc)
00070 {
00071 a=fabs(m_flux.maxLocalCharVelocity(fInfo,vQNeg,vQPos));
00072 }
00073
00074
00075 for (unsigned cmp=0;cmp<n_components;cmp++)
00076 {
00077
00078 double flux;
00079 if (!hasbc)
00080 {
00081
00082
00083
00084
00085
00086
00087 assert(a*dt<=m_mesh.get_dx()/2.0);
00088 flux = dt*face->areaPerCellVol()*(vFlux(cmp) -a*(vQPos(cmp)-vQNeg(cmp))/2.0);
00089 }
00090 else
00091 {
00092 flux = dt*face->areaPerCellVol() * vFlux(cmp);
00093 }
00094
00095
00096
00097
00098 if (face->hasPosCell())
00099 m_sol(posCell,cmp) += + flux/posPor;
00100
00101 if (face->hasNegCell())
00102 m_sol(negCell,cmp) += - flux/negPor;
00103
00104 }
00105 }
00106 }
00107 }
00108