Exemplo n.º 1
0
void TPZDiscontinuousGalerkin::FillDataRequirementsInterface(TPZMaterialData &data){
	data.SetAllRequirements(true);
	data.fNeedsSol = false;
	if(fLinearContext == false){
		data.fNeedsNeighborSol = true;
	}
}
Exemplo n.º 2
0
void TPZMaterial::FillDataRequirements(TPZMaterialData &data)
{
	data.SetAllRequirements(true);
	data.fNeedsNeighborSol = false;
	data.fNeedsNeighborCenter = false;
	data.fNeedsNormal = false;
}
Exemplo n.º 3
0
int CompareShapeFunctions(TPZCompElSide celsideA, TPZCompElSide celsideB)
{
    TPZGeoElSide gelsideA = celsideA.Reference();
    TPZGeoElSide gelsideB = celsideB.Reference();
    int sideA = gelsideA.Side();
    int sideB = gelsideB.Side();
    TPZCompEl *celA = celsideA.Element();
    TPZCompEl *celB = celsideB.Element();    TPZMultiphysicsElement *MFcelA = dynamic_cast<TPZMultiphysicsElement *>(celA);
    TPZMultiphysicsElement *MFcelB = dynamic_cast<TPZMultiphysicsElement *>(celB);
    TPZInterpolatedElement *interA = dynamic_cast<TPZInterpolatedElement *>(MFcelA->Element(0));
    TPZInterpolatedElement *interB = dynamic_cast<TPZInterpolatedElement *>(MFcelB->Element(0));
    
    TPZMaterialData dataA;
    TPZMaterialData dataB;
    interA->InitMaterialData(dataA);
    interB->InitMaterialData(dataB);
    TPZTransform<> tr = gelsideA.NeighbourSideTransform(gelsideB);
    TPZGeoEl *gelA = gelsideA.Element();
    TPZTransform<> trA = gelA->SideToSideTransform(gelsideA.Side(), gelA->NSides()-1);
    TPZGeoEl *gelB = gelsideB.Element();
    TPZTransform<> trB = gelB->SideToSideTransform(gelsideB.Side(), gelB->NSides()-1);
    
    int dimensionA = gelA->Dimension();
    int dimensionB = gelB->Dimension();
    
    int nSideshapeA = interA->NSideShapeF(sideA);
    int nSideshapeB = interB->NSideShapeF(sideB);
    int is;
    int firstShapeA = 0;
    int firstShapeB = 0;
    for (is=0; is<sideA; is++) {
        firstShapeA += interA->NSideShapeF(is);
    }
    for (is=0; is<sideB; is++) {
        firstShapeB += interB->NSideShapeF(is);
    }
    
    TPZIntPoints *intrule = gelA->CreateSideIntegrationRule(gelsideA.Side(), 4);
    int nwrong = 0;
    int npoints = intrule->NPoints();
    int ip;
    for (ip=0; ip<npoints; ip++) {
        TPZManVector<REAL,3> pointA(gelsideA.Dimension()),pointB(gelsideB.Dimension()), pointElA(gelA->Dimension()),pointElB(gelB->Dimension());
        REAL weight;
        intrule->Point(ip, pointA, weight);
        int sidedim = gelsideA.Dimension();
        TPZFNMatrix<9> jacobian(sidedim,sidedim),jacinv(sidedim,sidedim),axes(sidedim,3);
        REAL detjac;
        gelsideA.Jacobian(pointA, jacobian, jacinv, detjac, jacinv);
        TPZManVector<REAL,3> normal(3,0.), xA(3),xB(3);
        normal[0] = axes(0,1);
        normal[1] = -axes(0,0);
        tr.Apply(pointA, pointB);
        trA.Apply(pointA, pointElA);
        trB.Apply(pointB, pointElB);
        gelsideA.Element()->X(pointElA, xA);
        gelsideB.Element()->X(pointElB, xB);
        for (int i=0; i<3; i++) {
            if(fabs(xA[i]- xB[i])> 1.e-6) DebugStop();
        }
        int nshapeA = 0, nshapeB = 0;
        interA->ComputeRequiredData(dataA, pointElA);
        interB->ComputeRequiredData(dataB, pointElB);
        nshapeA = dataA.phi.Rows();
        nshapeB = dataB.phi.Rows();
        if(nSideshapeA != nSideshapeB) DebugStop();
        
        TPZManVector<REAL> shapesA(nSideshapeA), shapesB(nSideshapeB);
        int nwrongkeep(nwrong);
        int i,j;
        for(i=firstShapeA,j=firstShapeB; i<firstShapeA+nSideshapeA; i++,j++)
        {
            int Ashapeind = i;
            int Bshapeind = j;
            int Avecind = -1;
            int Bvecind = -1;
            // if A or B are boundary elements, their shapefunctions come in the right order
            if (dimensionA != sidedim) {
                Ashapeind = dataA.fVecShapeIndex[i].second;
                Avecind = dataA.fVecShapeIndex[i].first;
            }
            if (dimensionB != sidedim) {
                Bshapeind = dataB.fVecShapeIndex[j].second;
                Bvecind = dataB.fVecShapeIndex[j].first;
            }
            if (dimensionA != sidedim && dimensionB != sidedim) {
                // vefify that the normal component of the normal vector corresponds
                Avecind = dataA.fVecShapeIndex[i].first;
                Bvecind = dataB.fVecShapeIndex[j].first;
                REAL vecnormalA = dataA.fNormalVec(0,Avecind)*normal[0]+dataA.fNormalVec(1,Avecind)*normal[1];
                REAL vecnormalB = dataB.fNormalVec(0,Bvecind)*normal[0]+dataB.fNormalVec(1,Bvecind)*normal[1];
                if(fabs(vecnormalA-vecnormalB) > 1.e-6)
                {
                    nwrong++;
                    LOGPZ_ERROR(logger, "normal vectors aren't equal")
                }
                
            }
            shapesA[i-firstShapeA] = dataA.phi(Ashapeind,0);
            shapesB[j-firstShapeB] = dataB.phi(Bshapeind,0);
            REAL valA = dataA.phi(Ashapeind,0);
            REAL valB = dataB.phi(Bshapeind,0);
            REAL diff = valA-valB;
            REAL decision = fabs(diff)-1.e-6;
            if(decision > 0.)
            {
                nwrong ++;
                std::cout << "valA = " << valA << " valB = " << valB << " Avecind " << Avecind << " Bvecind " << Bvecind <<
                " Ashapeind " << Ashapeind << " Bshapeind " << Bshapeind <<
                " sideA " << sideA << " sideB " << sideB << std::endl;
                LOGPZ_ERROR(logger, "shape function values are different")
            }
Exemplo n.º 4
0
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
Exemplo n.º 5
0
void TPZMaterialCoupling::ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft,TPZMaterialData &dataright, REAL weight,TPZFMatrix<REAL> &ek,TPZFMatrix<REAL> &ef){
				
		TPZFMatrix<REAL>  &phiH1 = dataright.phi;
		TPZFMatrix<REAL>  &phiHdiv = dataleft.phi;		
		int numvec=dataleft.fVecShapeIndex.NElements();
//		int nrowHdiv=phiHdiv.Rows();//funcao a esquerda Hdiv
		int nrowH1=phiH1.Rows();//Funcao a direita H1
		int numdual = dataleft.numberdualfunctions;
		
		TPZFMatrix<REAL> ekCouple(numvec+numdual,nrowH1,0.);
		//vou precisar da  orientacao das normais na interface
		
		REAL leftX0=data.normal[0];
		REAL leftX1=data.normal[1];
		REAL leftX2=data.normal[2];
		
				
		for(int ilinha=0; ilinha<numvec; ilinha++) {
				int ivecind = dataleft.fVecShapeIndex[ilinha].first;
				int ishapeind = dataleft.fVecShapeIndex[ilinha].second;
				REAL prod=dataleft.fNormalVec(0,ivecind)*leftX0+dataleft.fNormalVec(1,ivecind)*leftX1+dataleft.fNormalVec(2,ivecind)*leftX2;
				
			
				for(int jcol=0; jcol<nrowH1; jcol++) {
						
						REAL prod1 =	phiHdiv(ishapeind,0)*phiH1(jcol,0)*prod;
						
						
#ifdef LOG4CXX
						{
								std::stringstream sout;
								sout << "prod phiHdiv[ " <<ishapeind << "]= " << phiHdiv(ishapeind,0)<< " phiH1[ "<< jcol << "] = " << phiH1(jcol,0)<< std::endl;
								LOGPZ_DEBUG(logger, sout.str().c_str());
						}
#endif
						ekCouple(ilinha,jcol)+= weight  * prod1;
						ek(ilinha,numdual+ numvec+jcol) += weight  * (prod1);
						
#ifdef LOG4CXX
						{
								std::stringstream sout;
								sout << "-- PosJ " << numdual+ numvec+jcol<< std::endl;
								LOGPZ_DEBUG(logger, sout.str().c_str());
						}
#endif
						ek(jcol+numvec+numdual,ilinha) += weight  *(-prod1);
						
						
				}
    }
		
		ekCouple.Print("Matriz teste Acoplamento",std::cout);
#ifdef LOG4CXX
		{
				std::stringstream sout;
				ekCouple.Print("Matriz teste Acoplamento",sout);
				//ek.Print("Matriz de Acoplamento",sout);
				LOGPZ_DEBUG(logger, sout.str().c_str());
		}
#endif
		
		
		
		
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
void TPZPrimalPoisson::FillBoundaryConditionDataRequirement(int type,TPZMaterialData &data)
{
    data.SetAllRequirements(false);
    data.fNeedsSol = true;
}
Exemplo n.º 8
0
void TPZPrimalPoisson::FillDataRequirements(TPZMaterialData &data)
{
    data.SetAllRequirements(false);
    data.fNeedsSol = true;
}
Exemplo n.º 9
0
/// Compute the contribution at an integration point to the stiffness matrix of the HDiv formulation
void TPZMatPoisson3d::ContributeHDiv(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef)
{
	/** monta a matriz
	 |A B^T |  = |0 |
	 |B 0   |    |f |
	 
	 **/
    
    //TPZVec<REAL>  &x = data.x;
	STATE fXfLoc = fXf;
	if(fForcingFunction) {                           // phi(in, 0) = phi_in
		TPZManVector<STATE> res(1);
		fForcingFunction->Execute(data.x,res);       // dphi(i,j) = dphi_j/dxi
		fXfLoc = res[0];
	}
	int numvec = data.fVecShapeIndex.NElements();
	int numdual = data.numberdualfunctions;
	int numprimalshape = data.phi.Rows()-numdual;
	
	int i,j;
    REAL kreal = 0.;
#ifdef STATE_COMPLEX
    kreal = fK.real();
#else
    kreal = fK;
#endif
    REAL ratiok = 1./kreal;
	for(i=0; i<numvec; i++)
	{
		int ivecind = data.fVecShapeIndex[i].first;
		int ishapeind = data.fVecShapeIndex[i].second;
		for (j=0; j<numvec; j++) {
			int jvecind = data.fVecShapeIndex[j].first;
			int jshapeind = data.fVecShapeIndex[j].second;
			REAL prod = data.fNormalVec(0,ivecind)*data.fNormalVec(0,jvecind)+
			data.fNormalVec(1,ivecind)*data.fNormalVec(1,jvecind)+
			data.fNormalVec(2,ivecind)*data.fNormalVec(2,jvecind);//faz o produto escalar entre u e v--> Matriz A
			ek(i,j) += weight*ratiok*data.phi(ishapeind,0)*data.phi(jshapeind,0)*prod;
			
			
			
		}
		TPZFNMatrix<3> ivec(3,1);
		ivec(0,0) = data.fNormalVec(0,ivecind);
		ivec(1,0) = data.fNormalVec(1,ivecind);
		ivec(2,0) = data.fNormalVec(2,ivecind);
		TPZFNMatrix<3> axesvec(3,1);
		data.axes.Multiply(ivec,axesvec);
		int iloc;
		REAL divwq = 0.;
		for(iloc=0; iloc<fDim; iloc++)
		{
			divwq += axesvec(iloc,0)*data.dphix(iloc,ishapeind);
		}
		for (j=0; j<numdual; j++) {
			REAL fact = (-1.)*weight*data.phi(numprimalshape+j,0)*divwq;//calcula o termo da matriz B^T  e B
			ek(i,numvec+j) += fact;
			ek(numvec+j,i) += fact;//-div
		}
	}
	for(i=0; i<numdual; i++)
	{
		ef(numvec+i,0) += (STATE)((-1.)*weight*data.phi(numprimalshape+i,0))*fXfLoc;//calcula o termo da matriz f
        
#ifdef LOG4CXX
        if (logger->isDebugEnabled()) 
		{
            std::stringstream sout;
            sout<< "Verificando termo fonte\n";
            sout << "  pto  " <<data.x << std::endl;
            sout<< " fpto " <<fXfLoc <<std::endl;
            LOGPZ_DEBUG(logger,sout.str())
		}
#endif
	}
Exemplo n.º 10
0
void TPZNonDarcyFlow::FillBoundaryConditionDataRequirement(int type,TPZMaterialData &data)
{
	data.SetAllRequirements(false);
	data.fNeedsSol = true;
	data.fNeedsNormal = true;
}
Exemplo n.º 11
0
void TPZNonDarcyFlow::FillDataRequirements(TPZMaterialData &data)
{
	data.SetAllRequirements(false);
	data.fNeedsSol = true;
	data.fNeedsNormal = true;
}