void UpwindFactory::produce(Grid * g){ if(contains(g)){ return; } Divergence div(g); CellToFaceOperator F; F.setGrid(g); vector<Face*>::iterator it; for(it = g->faces.begin(); it != g->faces.end(); it++){ if((*it) != 0 && (*it)->isBoundary()){ FaceIndex faceIndex = (*it)->getIndex(); Coord pos = (*it)->getCentroid(); TinyVector<double,2> aSpeed = (*c)(pos); double a = sum(aSpeed*((*it)->getNormal())); if(a > 0){ CellIndex upwind((*it)->getFrom()->getI(),(*it)->getFrom()->getJ()); F.coefficients[faceIndex][upwind] = -a; } if(a < 0){ F.constantTerm(faceIndex) = -a; } } else if((*it) != 0 && (*it)->isInterior()){ FaceIndex faceIndex = (*it)->getIndex(); Coord pos = (*it)->getCentroid(); TinyVector<double,2> aSpeed = (*c)(pos); double a = sum(aSpeed*((*it)->getNormal())); if(a > 0){ CellIndex upwind((*it)->getFrom()->getI(),(*it)->getFrom()->getJ()); F.coefficients[faceIndex][upwind] = -a; } else if(a < 0){ //cout << "Negative speed through face" << endl; CellIndex upwind((*it)->getTo()->getI(),(*it)->getTo()->getJ()); F.coefficients[faceIndex][upwind] = -a; } } } operators[g] = new CellToCellOperator(div(F)); }
void Q2PPorepressureFlux::computeOffDiagJacobian(unsigned int jvar) { upwind(false, true, jvar); }
void RichardsFullyUpwindFlux::computeOffDiagJacobian(unsigned int jvar) { upwind(false, true, jvar); return; }
void RichardsFullyUpwindFlux::computeResidual() { upwind(true, false, 0); return; }
void Q2PSaturationFlux::computeJacobian() { upwind(false, true, _var.number()); }
void Q2PSaturationFlux::computeResidual() { upwind(true, false, 0); }
void Q2PSaturationFlux::computeOffDiagJacobian(unsigned int jvar) { upwind(false, true, jvar); }
void Q2PSaturationFlux::computeOffDiagJacobian(MooseVariableFEBase & jvar) { upwind(false, true, jvar.number()); }
void PorousFlowDarcyBase::computeResidual() { upwind(JacRes::CALCULATE_RESIDUAL, 0.0); }
void PorousFlowDarcyBase::computeOffDiagJacobian(unsigned int jvar) { upwind(JacRes::CALCULATE_JACOBIAN, jvar); }
void PorousFlowAdvectiveFlux::computeOffDiagJacobian(unsigned int jvar) { upwind(CALCULATE_JACOBIAN, jvar); }
void PorousFlowAdvectiveFlux::computeJacobian() { upwind(CALCULATE_JACOBIAN, _var.number()); }
void PorousFlowAdvectiveFlux::computeResidual() { upwind(CALCULATE_RESIDUAL, 0.0); }
void RichardsFullyUpwindFlux::computeJacobian() { upwind(false, true, _var.number()); return; }
void Q2PPorepressureFlux::computeResidual() { upwind(true, false, 0); }
void Q2PPorepressureFlux::computeJacobian() { upwind(false, true, _var.number()); }
void PorousFlowDarcyBase::computeJacobian() { upwind(JacRes::CALCULATE_JACOBIAN, _var.number()); }