#include <upwindforsystem.h>
Public Member Functions | |
UpwindForSystem (OrthoMesh &mesh, Function3D &fInitU, const VecDouble &cPor, Function3D &fPrescribedU, FaceFluxFunction &flux, FixedValueCondition &fixedC, double CFL, DiffusiveStep *diffStp) | |
virtual void | iterateN (unsigned nSteps, double dt) |
~UpwindForSystem () |
Definition at line 9 of file upwindforsystem.h.
UpwindForSystem::UpwindForSystem | ( | OrthoMesh & | mesh, | |
Function3D & | fInitU, | |||
const VecDouble & | cPor, | |||
Function3D & | fPrescribedU, | |||
FaceFluxFunction & | flux, | |||
FixedValueCondition & | fixedC, | |||
double | CFL, | |||
DiffusiveStep * | diffStp | |||
) |
Definition at line 10 of file upwindforsystem.cpp.
00011 :LaxFriedrichsForSystem(mesh,fInitU,cPor,fPrescribedU,flux,fixedC,CFL) 00012 { 00013 00014 }
UpwindForSystem::~UpwindForSystem | ( | ) |
Definition at line 5 of file upwindforsystem.cpp.
void UpwindForSystem::iterateN | ( | unsigned | nSteps, | |
double | dt | |||
) | [virtual] |
Reimplemented from LaxFriedrichsForSystem.
Definition at line 19 of file upwindforsystem.cpp.
00020 { 00021 unsigned posCell,negCell; 00022 00023 //We iterate the method along faces, so 00024 //alloc the vectors to contain the solutions in neg 00025 //and pos cells of the faces. Remeber that the solution 00026 //in a cell is vector with a value for each component 00027 VecDouble vBC(n_components),vFluxPos(n_components),vFluxNeg(n_components); 00028 VecDoubleRef vQPos(n_components),vQNeg(n_components); 00029 00030 //For each time step 00031 for (unsigned count = 0; count < nSteps; count++) 00032 { 00033 //Get the face iterator and the number of faces. 00034 OrthoMesh::Face_It face = m_mesh.begin_face(); 00035 OrthoMesh::Face_It endf = m_mesh.end_face(); 00036 00037 00038 //m_solAnt receives the solution in time tn since 00039 //m_sol will contain the solution in tn+1. 00040 m_solAnt = m_sol; 00041 00042 //For each face 00043 for (;face!=endf;face++) 00044 { 00045 00046 face->getAdjCellIndices(negCell,posCell); 00047 00048 //Get the values of the previous solution in the right and left of the face 00049 this->getValuesOfTheFaceCells(m_mesh,m_vbc,m_solAnt,face->index(),negCell,posCell,vQNeg,vQPos); 00050 00051 //Get the indices of the cells that contain the face. 00052 //If the face is at boundary, it has just one cell. 00053 //In this case the method getAdjCells() return posCell == negCell 00054 if (posCell == OrthoMesh::INVALID_INDEX) 00055 posCell=negCell; 00056 else if (negCell == OrthoMesh::INVALID_INDEX) 00057 negCell=posCell; 00058 00059 //Get the porsity 00060 double posPor = getPorosity()(posCell); 00061 double negPor = getPorosity()(negCell); 00062 00063 00064 m_flux.fluxAtFace(vFluxPos,face,vQPos,vQPos); 00065 m_flux.fluxAtFace(vFluxNeg,face,vQNeg,vQNeg); 00066 00067 //Now get the flux component by component 00068 for (unsigned cmp=0;cmp<n_components;cmp++) 00069 { 00070 assert(vQPos(cmp) >= 0.0 && vQNeg(cmp) >= 0.0); 00071 00072 double fluxPos,fluxNeg,flux; 00073 00074 //Get the flux from the positive and negative side 00075 fluxPos = dt*face->areaPerCellVol() * vFluxPos(cmp); 00076 fluxNeg = dt*face->areaPerCellVol() * vFluxNeg(cmp); 00077 00078 00079 //if the flux is coming from the positive cell, use the flux computed from the value of the Pos Cell 00080 if (fluxPos >= 0.0 && fluxNeg >= 0.0) 00081 flux = fluxNeg; 00082 else if (fluxPos <0.0 && fluxNeg < 0.0) //if the flux comes from the other direction use the Neg flux 00083 flux = fluxPos; 00084 else 00085 { 00086 flux = (fluxPos + fluxNeg)/2.0 - (posPor+negPor)/2.0 * (vQPos(cmp)-vQNeg(cmp))/6.0; 00087 //printf("Sonic Point: %g %g %d\n",fluxPos,fluxNeg,face->getNormalOrientation()); 00088 } 00089 if (OrthoMesh::isValid(posCell)) 00090 m_sol(posCell,cmp) += + flux/posPor; 00091 00092 if (OrthoMesh::isValid(negCell)) 00093 m_sol(posCell,cmp) += - flux/negPor; 00094 00095 } //end for each component 00096 } //end for each face 00097 } //end for each time step 00098 00099 }