void TPZSpaceTimeRichardsEq::ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix<REAL> &ek, TPZFMatrix<REAL> &ef, TPZBndCond &bc){ const REAL v2 = bc.Val2()(0,0); TPZFMatrix<REAL> &phi = data.phi; const int phr = phi.Rows(); int in, jn; int numbersol = data.sol.size(); if (numbersol != 1) { DebugStop(); } switch (bc.Type()){ // Dirichlet condition case 0 : { for(in = 0 ; in < phr; in++) { ef(in,0) += weight * ( gBigNumber * phi(in,0) * (v2 - data.sol[0][0]) ); for (jn = 0 ; jn < phr; jn++) { ek(in,jn) += gBigNumber * phi(in,0) * phi(jn,0) * weight; } } break; } // Neumann condition case 1:{ // please implement me } break; // outflow condition case 3 : { const REAL sol = data.sol[0][0]; // const REAL C = this->C_Coef(sol); // REAL ConvDir[2] = {0., C}; REAL ConvDir[2] = {0., 1.}; REAL normal[2]; normal[0] = data.axes(0,1); normal[1] = -1.*data.axes(0,0); REAL ConvNormal = ConvDir[0]*normal[0] + ConvDir[1]*normal[1]; if(ConvNormal > 0.) { for(int il = 0; il < phr; il++) { for(int jl = 0; jl < phr; jl++) { ek(il,jl) += weight * ConvNormal * phi(il)*phi(jl); } ef(il,0) += -1. * weight * ConvNormal * phi(il) * sol; } } else{ if (ConvNormal < 0.) std::cout << "Boundary condition error: inflow detected in outflow boundary condition: ConvNormal = " << ConvNormal << "\n"; } } break; default:{ std::cout << __PRETTY_FUNCTION__ << " at line " << __LINE__ << " not implemented\n"; } }//switch }//ContributeBC
REAL TPZAdaptMesh::UseTrueError(TPZInterpolatedElement *coarse, void (*f)(const TPZVec<REAL> &loc, TPZVec<REAL> &val, TPZFMatrix<REAL> &deriv)){ if (coarse->Material()->Id() < 0) return 0.0; REAL error = 0.; // REAL loclocmatstore[500] = {0.},loccormatstore[500] = {0.}; // TPZFMatrix loccormat(locmatsize,cormatsize,loccormatstore,500); //Cesar 25/06/03 - Uso a ordem m�xima??? TPZAutoPointer<TPZIntPoints> intrule = coarse->GetIntegrationRule().Clone(); int dimension = coarse->Dimension(); int numdof = coarse->Material()->NStateVariables(); //TPZSolVec corsol; //TPZGradSolVec cordsol; TPZGradSolVec cordsolxy; // TPZVec<REAL> corsol(numdof); // TPZFNMatrix<9,REAL> cordsol(dimension,numdof),cordsolxy(dimension,numdof); TPZManVector<int> order(dimension,20); intrule->SetOrder(order); // derivative of the shape function // in the master domain TPZManVector<REAL,3> coarse_int_point(dimension); // TPZFNMatrix<9,REAL> jaccoarse(dimension,dimension),jacinvcoarse(dimension,dimension); // TPZFNMatrix<9,REAL> axescoarse(3,3); // TPZManVector<REAL,3> xcoarse(3); TPZFNMatrix<9,REAL> axesinner(3,3); TPZMaterialData datacoarse; coarse->InitMaterialData(datacoarse); // REAL jacdetcoarse; int numintpoints = intrule->NPoints(); REAL weight; TPZVec<REAL> truesol(numdof); TPZFMatrix<REAL> truedsol(dimension,numdof); for(int int_ind = 0; int_ind < numintpoints; ++int_ind) { intrule->Point(int_ind,coarse_int_point,weight); //coarse->Reference()->X(coarse_int_point, xcoarse); coarse->Reference()->X(coarse_int_point, datacoarse.x); //if(f) f(xcoarse,truesol,truedsol); if(f) f(datacoarse.x,truesol,truedsol); // coarse->Reference()->Jacobian(coarse_int_point, jaccoarse, axescoarse, jacdetcoarse, jacinvcoarse); coarse->Reference()->Jacobian(coarse_int_point, datacoarse.jacobian, datacoarse.axes, datacoarse.detjac, datacoarse.jacinv); //weight *= fabs(jacdetcoarse); weight *= fabs(datacoarse.detjac); //Er int iv=0; // corsol[0].Fill(0.); // cordsol[0].Zero(); //coarse->ComputeSolution(coarse_int_point, corsol, cordsol, axescoarse); coarse->ComputeShape(coarse_int_point,datacoarse); coarse->ComputeSolution(coarse_int_point,datacoarse); //int nc = cordsol[0].Cols(); int nc = datacoarse.dsol[0].Cols(); for (int col=0; col<nc; col++) { for (int d=0; d<dimension; d++) { REAL deriv = 0.; for (int d2=0; d2<dimension; d2++) { deriv += datacoarse.dsol[0](d2,col)*datacoarse.axes(d2,d); } // cordsolxy[0](d,col) = deriv; } } int jn; for(jn=0; jn<numdof; jn++) { for(int d=0; d<dimension; d++) { error += (datacoarse.dsol[0](d,jn)-truedsol(d,jn))*(datacoarse.dsol[0](d,jn)-truedsol(d,jn))*weight; } } } return error; }