示例#1
0
void TPZMaterialTest::ContributeBC(TPZMaterialData &data,
                                   REAL weight,
                                   TPZFMatrix<STATE> &ek,
                                   TPZFMatrix<STATE> &ef,
                                   TPZBndCond &bc) {
	TPZFMatrix<REAL> &phi = data.phi;
	
	if(bc.Material() != this) {
		PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
	}
	
	if(bc.Type() < 0 && bc.Type() > 2){
		PZError << "TPZMat1dLin.aplybc, unknown boundary condition type :"  <<
		bc.Type() << " boundary condition ignored\n";
	}
	
	
	int numdof = NStateVariables();
	int numnod = ek.Rows()/numdof;
	int r = numdof;
	
	int idf,jdf,in,jn;
	switch(bc.Type()) {
			
		case 0:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
					}
				}
			}
			break;
			
		case 1:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
			}
			break;
			
		case 2:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						for(jdf = 0;jdf<r;jdf++) {
							ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
						}
					}
				}
			}//fim switch
	}
}
示例#2
0
void TPZConsLawTest::ContributeBC(TPZMaterialData &data,
                                  REAL weight,
                                  TPZFMatrix &ek,
                                  TPZFMatrix &ef,
                                  TPZBndCond &bc) {
	
	// TPZFMatrix &dphi = data.dphix;
	// TPZFMatrix &dphiL = data.dphixl;
	// TPZFMatrix &dphiR = data.dphixr;
	TPZFMatrix &phi = data.phi;
	// TPZFMatrix &phiL = data.phil;
	// TPZFMatrix &phiR = data.phir;
	// TPZManVector<REAL,3> &normal = data.normal;
	// TPZManVector<REAL,3> &x = data.x;
	// int &POrder=data.p;
	// int &LeftPOrder=data.leftp;
	// int &RightPOrder=data.rightp;
	// TPZVec<REAL> &sol=data.sol;
	// TPZVec<REAL> &solL=data.soll;
	// TPZVec<REAL> &solR=data.solr;
	// TPZFMatrix &dsol=data.dsol;
	// TPZFMatrix &dsolL=data.dsoll;
	// TPZFMatrix &dsolR=data.dsolr;
	// REAL &faceSize=data.HSize;
	// TPZFMatrix &daxesdksi=data.daxesdksi;
	// TPZFMatrix &axes=data.axes;
	
	int phr = phi.Rows();
	short in,jn;
	REAL v2[1];
	v2[0] = bc.Val2()(0,0);
	
	switch (bc.Type()) {
		case 0 :			// Dirichlet condition
			for(in = 0 ; in < phr; in++) {
				ef(in,0) += gBigNumber * v2[0] * phi(in,0) * weight;
				for (jn = 0 ; jn < phr; jn++) {
					ek(in,jn) += gBigNumber * phi(in,0) * phi(jn,0) * weight;
				}
			}
			break;
		case 1 :			// Neumann condition
			for(in = 0 ; in < phi.Rows(); in++) {
				ef(in,0) += v2[0] * phi(in,0) * weight;
			}
			break;
		case 2 :		// condi�o mista
			for(in = 0 ; in < phi.Rows(); in++) {
				ef(in, 0) += v2[0] * phi(in, 0) * weight;
				for (jn = 0 ; jn < phi.Rows(); jn++) {
					ek(in,jn) += bc.Val1()(0,0) * phi(in,0) *
					phi(jn,0) * weight;     // peso de contorno => integral de contorno
				}
			}
	}
}
示例#3
0
void TPZNonDarcyFlow::ContributeBC(TPZMaterialData &data, REAL weight,
									TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc) {
	
	TPZFMatrix<STATE> &phi = data.phi;
	const int nphi = phi.Rows();
	
	if(bc.Val2().Rows() != 1 || bc.Val2().Cols() != 1){
		PZError << "Val2 must be of size (1,1)!\n";
		DebugStop();
	}
	
	if (globData.fState == ELastState) return;
	
	REAL v2 = bc.Val2()(0,0);
	if (bc.HasForcingFunction()){
		TPZManVector <REAL,1> Pbc(1,0.);
		bc.ForcingFunction()->Execute(data.x,Pbc); // here, data.x is useless
		v2 = Pbc[0];
	}
	
	const REAL p = data.sol[0][0];
	const REAL DdirValue = p - v2;
	
	switch(bc.Type()){
		case 0: //Dirichlet
			for (int i = 0 ; i < nphi ; i++){
				ef(i,0) += -1.*phi(i,0)*gBigNumber*DdirValue*weight;
				for (int j = 0 ; j < nphi ; j++){
					ek(i,j) += phi(i,0)*phi(j,0)*gBigNumber*weight;
				}
			}
			break;
		case 1: // Neumann - vazao massica
			for (int i = 0 ; i < nphi ; i++){
				ef(i,0) += -1.*phi(i,0)*weight*v2;
			}
			break;
		default:
			PZError << __PRETTY_FUNCTION__ << "bc type not implemented\n";
			DebugStop();
	}
	
}
示例#4
0
void TPZEulerConsLawDEP::ContributeBC(TPZMaterialData &data,REAL weight,
                                   TPZFMatrix &ek,TPZFMatrix &ef,TPZBndCond &bc) {
	TPZFMatrix dphi = data.dphix;
	TPZFMatrix dphiL = data.dphixl;
	TPZFMatrix dphiR = data.dphixr;
	TPZFMatrix phi = data.phi;
	TPZFMatrix phiL = data.phil;
	TPZFMatrix phiR = data.phir;
	TPZManVector<REAL,3> normal = data.normal;
	TPZManVector<REAL,3> x = data.x;
	// int POrder=data.p;
	// int LeftPOrder=data.leftp;
	// int RightPOrder=data.rightp;
	TPZVec<REAL> sol=data.sol;
	TPZVec<REAL> solL=data.soll;
	TPZVec<REAL> solR=data.solr;
	TPZFMatrix dsol=data.dsol;
	TPZFMatrix dsolL=data.dsoll;
	TPZFMatrix dsolR=data.dsolr;
	// REAL faceSize=data.HSize;
	
	int phr = phi.Rows();
	short in,jn,i,j;
	int nstate = NStateVariables();
	REAL v2[5];//m�imo nstate
	for(i=0;i<nstate;i++) v2[i] = bc.Val2()(i,0);
	
	switch (bc.Type()) {
		case 0 :// Dirichlet condition
			for(in = 0 ; in < phr; in++) {
				for(i = 0 ; i < nstate; i++)
					ef(in*nstate+i,0) += gBigNumber * weight * v2[i] * phi(in,0);
				for (jn = 0 ; jn < phr; jn++) {
					for(i = 0 ; i < nstate; i++)
						ek(in*nstate+i,jn*nstate+i) += gBigNumber * weight * phi(in,0) * phi(jn,0);
				}
			}
			break;
		case 1 :// Neumann condition
			for(in = 0 ; in < phi.Rows(); in++) {
				for(i = 0 ; i < nstate; i++)
					ef(in*nstate+i,0) += v2[i] * phi(in,0) * weight;
			}
			break;
		case 2 :// condi�o mista
			for(in = 0 ; in < phi.Rows(); in++) {
				for(i = 0 ; i < nstate; i++)
					ef(in*nstate+i, 0) += weight * v2[i] * phi(in, 0);
				for (jn = 0 ; jn < phi.Rows(); jn++) {
					for(i = 0 ; i < nstate; i++) for(j = 0 ; j < nstate; j++)
						ek(in*nstate+i,jn*nstate+j) += weight * bc.Val1()(i,j) * phi(in,0) * phi(jn,0);
				}
			}
	}
}
示例#5
0
void TPZMixedDarcyFlow::ContributeBC(TPZVec<TPZMaterialData> &datavec,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc){
    
    int qb = 0;
    TPZFNMatrix<100,REAL> phi_qs       = datavec[qb].phi;
    
    int nphi_q       = phi_qs.Rows();
    int first_q      = 0;
    
    TPZManVector<STATE,3> q  = datavec[qb].sol[0];
    
    TPZManVector<STATE,1> bc_data(1,0.0);
    bc_data[0] = bc.Val2()(0,0);
    
    switch (bc.Type()) {
        case 0 :    // Dirichlet BC  PD
        {
            STATE p_D = bc_data[0];
            for (int iq = 0; iq < nphi_q; iq++)
            {
                ef(iq + first_q) += -1.0 *  weight * p_D * phi_qs(iq,0);
            }
        }
            break;
            
        case 1 :    // Neumann BC  QN
        {
            
            for (int iq = 0; iq < nphi_q; iq++)
            {
                REAL qn_N = bc_data[0], qn = q[0];
                ef(iq + first_q) += -1.0 * weight * gBigNumber * (qn - qn_N) * phi_qs(iq,0);
                
                for (int jq = 0; jq < nphi_q; jq++)
                {
                    
                    ek(iq + first_q,jq + first_q) += -1.0 * weight * gBigNumber * phi_qs(jq,0) * phi_qs(iq,0);
                }
                
            }
            
        }
            break;
            
        default: std::cout << "This BC doesn't exist." << std::endl;
        {
            
            DebugStop();
        }
            break;
    }
    
    return;
    
}
示例#6
0
/** @brief Boundary contribute */
void TPZPrimalPoisson::ContributeBC(TPZMaterialData &data,REAL weight,TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc){
    
    TPZFMatrix<REAL> &phi =     data.phi;
    TPZVec<STATE>    &p   =     data.sol[0];
    
    int nphi_p = phi.Rows();

    TPZManVector<STATE,1> bc_data(1,0.0);
    bc_data[0] = bc.Val2()(0,0);
    if (bc.HasForcingFunction()) {
        //TPZFMatrix<STATE> df;
        bc.ForcingFunction()->Execute(data.x, bc_data);   ///Jorge  2017 It is not used: , df);
    }

    
    switch (bc.Type()) {
        case 0 : {      // Dirichlet condition
            STATE p_D = bc_data[0];
            for(int ip = 0 ; ip < nphi_p; ip++) {
                ef(ip,0) += weight * gBigNumber * ( p[0] -  p_D ) * phi(ip,0);
                for (int jp = 0 ; jp < nphi_p; jp++) {
                    ek(ip,jp) += gBigNumber * phi(ip,0) * phi(jp,0) * weight;
                }
            }
        }
            break;
            
        case 1 : {      // Neumann condition
            STATE q_N = bc_data[0];
            for(int ip = 0 ; ip < nphi_p; ip++) {
                ef(ip,0) += weight * q_N * phi(ip,0);
            }
        }
            break;
        default :{
            PZError << __PRETTY_FUNCTION__ << " at line " << __LINE__ << " - Error! boundary condition not implemented\n";
            DebugStop();
        }
            break;
    }
    
}
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
示例#8
0
void TPZMatPoissonD3::ContributeBCInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc)
{
    
    
#ifdef PZDEBUG
	int nref =  dataleft.size();
	if (nref != 2 ) {
        std::cout << " Error. This implementation needs only two computational meshes. \n";
		DebugStop();
	}
#endif
    
#ifdef PZDEBUG
	int bref =  bc.Val2().Rows();
	if (bref != 2 ) {
        std::cout << " Erro. The size of the datavec is different from 2 \n";
		DebugStop();
	}
#endif
    
    REAL Qn = bc.Val2()(0,0); // cuidado para, na hora de passar os valores de cond contorno, seguir essa ordem
    REAL Pd = 0.0; // = bc.Val2()(1,0); // fluxo normal na primeira casa e pressao na segunda
    
	TPZManVector<REAL,3> &normal = data.normal;
	//REAL n1 = normal[0];
	//REAL n2 = normal[1];
    
    //REAL v2;
    if(bc.HasForcingFunction())
    {
		TPZManVector<STATE> res(3);
		bc.ForcingFunction()->Execute(dataleft[0].x,res);
		Pd = res[0];
        Qn = res[0];
	}else
    {
        Pd = bc.Val2()(1,0);
    }
    

    // Setting the phis
    TPZFMatrix<REAL>  &phiQ =  dataleft[0].phi;
    TPZFMatrix<REAL>  &phip =  dataleft[1].phi;
	//TPZFMatrix<REAL> &dphiQ = datavec[0].dphix;
    //TPZFMatrix<REAL> &dphip = datavec[1].dphix;

    int phrq, phrp;
    phrp = phip.Rows();
    phrq = dataleft[0].fVecShapeIndex.NElements();

	//Calculate the matrix contribution for boundary conditions
    for (int iq = 0; iq<phrq; iq++)
    {
        int ivecind = dataleft[0].fVecShapeIndex[iq].first;
        int ishapeind = dataleft[0].fVecShapeIndex[iq].second;
        TPZFNMatrix<3> ivec(3,1);
        ivec(0,0) = dataleft[0].fNormalVec(0,ivecind);
        ivec(1,0) = dataleft[0].fNormalVec(1,ivecind);
        ivec(2,0) = dataleft[0].fNormalVec(2,ivecind);
        ivec *= phiQ(ishapeind,0);
        
        
        REAL NormalProjectioni = 0.;
        for(int iloc=0; iloc<fDim; iloc++)
        {
            NormalProjectioni += ivec(iloc,0)*normal[iloc];
        }
        
        for (int jp=0; jp<phrp; jp++)
        {
            
            REAL integration = weight*NormalProjectioni*phip(jp,0);
            
            //para a equacao do fluxo - 1o conjunto da formulacao
            ek(iq, phrq+jp) += (-1.0)*integration;
            
            // para a equacao da pressao - 2o conjunto da formulacao
            ek(phrq+jp, iq) += (-1.0)*integration;
            
        }
    }
    

    //if (bc.Type()==0){std::cout << "...." << std::endl;}

    switch (bc.Type())
    {  
        case 0:  // Dirichlet
        {
            //REAL InvK = 1./fK;
            
                        //termo fonte referente a equacao do fluxo
            for (int iq = 0; iq<phrq; iq++)
            {
                int ivecind = dataleft[0].fVecShapeIndex[iq].first;
                int ishapeind = dataleft[0].fVecShapeIndex[iq].second;
                TPZFNMatrix<3> ivec(3,1);
                ivec(0,0) = dataleft[0].fNormalVec(0,ivecind);
                ivec(1,0) = dataleft[0].fNormalVec(1,ivecind);
                ivec(2,0) = dataleft[0].fNormalVec(2,ivecind);
                ivec *= phiQ(ishapeind,0);
                
                
                REAL NormalProjectioni = 0.;
                for(int iloc=0; iloc<fDim; iloc++)
                {
                    NormalProjectioni += ivec(iloc,0)*normal[iloc];
                }
                
                //para a equacao do fluxo
                ef(iq,0) += (-1.0)*weight*Pd*NormalProjectioni;
            }

            // fim dirichlet

        }
            break;
        case 1:  // Neumann
        {
//            REAL InvK = 1./fK;
            for (int iq = 0; iq<phrq; iq++)
            {
                int ivecind = dataleft[0].fVecShapeIndex[iq].first;
                int ishapeind = dataleft[0].fVecShapeIndex[iq].second;
                TPZFNMatrix<3> ivec(3,1);
                ivec(0,0) = dataleft[0].fNormalVec(0,ivecind);
                ivec(1,0) = dataleft[0].fNormalVec(1,ivecind);
                ivec(2,0) = dataleft[0].fNormalVec(2,ivecind);
                ivec *= phiQ(ishapeind,0);
                
                
                REAL NormalProjectioni = 0.;
                for(int iloc=0; iloc<fDim; iloc++)
                {
                    NormalProjectioni += ivec(iloc,0)*normal[iloc];
                }
                ef(iq,0) += gBigNumber*weight*(Qn)*NormalProjectioni;
                //ef(iq,0) += gBigNumber*weight*(ValorPhin - Qn)*NormalProjectioni;

                for (int jq=0; jq<phrq; jq++)
                {
                    TPZFNMatrix<3> jvec(3,1);
                    int jvecind = dataleft[0].fVecShapeIndex[jq].first;
                    int jshapeind = dataleft[0].fVecShapeIndex[jq].second;
                    jvec(0,0) = dataleft[0].fNormalVec(0,jvecind);
                    jvec(1,0) = dataleft[0].fNormalVec(1,jvecind);
                    jvec(2,0) = dataleft[0].fNormalVec(2,jvecind);
                    
                    jvec *= phiQ(jshapeind,0);

                    REAL NormalProjectionj = 0.;
                    for(int iloc=0; iloc<fDim; iloc++)
                    {
                        NormalProjectionj += jvec(iloc,0)*normal[iloc];
                    }
                    
                    ek(iq,jq) += gBigNumber*weight*NormalProjectioni*NormalProjectionj;

                }
            }
//            //termo fonte referente a equacao da pressao no entra!!!!
//            for (int jp = 0; jp < phrp ; jp++)
//            {
//                TPZFNMatrix<3> jvec(3,1);
//                int jvecind = dataleft[0].fVecShapeIndex[jp].first;
//                int jshapeind = dataleft[0].fVecShapeIndex[jp].second;
//                jvec(0,0) = dataleft[0].fNormalVec(0,jvecind);
//                jvec(1,0) = dataleft[0].fNormalVec(1,jvecind);
//                jvec(2,0) = dataleft[0].fNormalVec(2,jvecind);
//                
//                jvec *= phiQ(jshapeind,0);
//                
//                REAL NormalProjectionj = 0.;
//                for(int iloc=0; iloc<fDim; iloc++)
//                {
//                    NormalProjectionj += jvec(iloc,0)*normal[iloc];
//                }
//
//                ef(jp,0) += gBigNumber*weight*Qn*NormalProjectionj;
//            }

            // fim neumann
        }
            break;
        case 3:  // Robin
        {
            std::cout << " Robin Nao implementada " << std::endl;
            DebugStop();
        }
            break;
        default:
        {
            std::cout << " Nao implementada " << std::endl;
            DebugStop();
        }
            break;
    }
    
}
示例#9
0
void TPZTracerFlow::ContributeBCInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc){
    
    if(gState == ELastState){
		return;
	}
    
    if (fPressureEquationFilter == true)
    {
        return;
    }

    
    TPZFMatrix<REAL> &phiL = dataleft[0].phi;
	TPZManVector<REAL,3> &normal = data.normal;
    
    fConvDir[0] = dataleft[1].sol[0][0];
    fConvDir[1] = dataleft[1].sol[0][1];
	
	int il,jl,nrowl,id;
	nrowl = phiL.Rows();
	REAL ConvNormal = 0.;
    
	for(id=0; id<fDim; id++) ConvNormal += fConvDir[id]*normal[id];
    
    STATE DeltaT = fTimeStep;
    STATE val2sat = bc.Val2()(0,0);
    
	switch(bc.Type()) {
		case 3: // Inflow or Dirichlet
			
            //convection
			if(ConvNormal > 0.)
            {
				for(il=0; il<nrowl; il++){
					for(jl=0; jl<nrowl; jl++)
                    {
						ek(il,jl) += weight*DeltaT*ConvNormal*phiL(il)*phiL(jl);
					}
				}
			}
            else{
				for(il=0; il<nrowl; il++)
                {
					ef(il,0) -= weight*DeltaT*ConvNormal*val2sat*phiL(il);
				}
			}
			
			break;
            
			
        case 1: // Neumann
			for(il=0; il<nrowl; il++) {
				ef(il,0) += 0.;//ainda nao temos condicao de Neumann
			}
            break;
            
        case 0: // Dirichlet
			for(il=0; il<nrowl; il++) {
				
			}
            break;
            
		case 4: // outflow condition
			if(ConvNormal > 0.) {
				for(il=0; il<nrowl; il++) {
					for(jl=0; jl<nrowl; jl++) {
						ek(il,jl) += weight*DeltaT*ConvNormal*phiL(il)*phiL(jl);
					}
				}
			}
			else {
				if (ConvNormal < 0.) std::cout << "Boundary condition error: inflow detected in outflow boundary condition: ConvNormal = " << ConvNormal << "\n";
			}
			break;
            
        case 5: // // Neumann(pressure)-Inflow(saturation)
			
            //convection
			if(ConvNormal > 0.)
            {
				for(il=0; il<nrowl; il++){
					for(jl=0; jl<nrowl; jl++)
                    {
						ek(il,jl) += weight*DeltaT*ConvNormal*phiL(il)*phiL(jl);
					}
				}
			}
            else{
				for(il=0; il<nrowl; il++)
                {
					ef(il,0) -= weight*DeltaT*ConvNormal*val2sat*phiL(il);
				}
			}
			break;
            
        case 6: // Dirichlet(pressure)-Outflow(saturation)
			if(ConvNormal > 0.) {
				for(il=0; il<nrowl; il++) {
					for(jl=0; jl<nrowl; jl++) {
						ek(il,jl) += weight*DeltaT*ConvNormal*phiL(il)*phiL(jl);
					}
				}
			}
			else {
				if (ConvNormal < 0.) std::cout << "Boundary condition error: inflow detected in outflow boundary condition: ConvNormal = " << ConvNormal << "\n";
			}
			break;
            
        case 7: // Dirichlet(pressure)-Inflow(saturation)
			
            //convection
			if(ConvNormal > 0.)
            {
				for(il=0; il<nrowl; il++){
					for(jl=0; jl<nrowl; jl++)
                    {
						ek(il,jl) += weight*DeltaT*ConvNormal*phiL(il)*phiL(jl);
					}
				}
			}
            else{
				for(il=0; il<nrowl; il++)
                {
					ef(il,0) -= weight*DeltaT*ConvNormal*val2sat*phiL(il);
				}
			}
			break;

			
		default:
			PZError << __PRETTY_FUNCTION__ << " - Wrong boundary condition type\n";
			break;
	}
}
示例#10
0
void TPZTracerFlow::ContributeBC(TPZVec<TPZMaterialData> &datavec,REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc){
    
    if (fPressureEquationFilter == false)
    {
        return;
    }
#ifdef PZDEBUG
    int nref =  datavec.size();
	if (nref != 3 ) {
        std::cout << " Erro.!! datavec tem que ser de tamanho 2 \n";
		DebugStop();
	}
#endif
	
	TPZFMatrix<REAL>  &phiQ = datavec[1].phi;
	int phrQ = phiQ.Rows();//datavec[1].fVecShapeIndex.NElements();
    int phrS = datavec[0].phi.Rows();
    
	REAL v2;
	v2 = bc.Val2()(1,0);
    
    STATE BigNum = gBigNumber;
	
	switch (bc.Type()) {
		case 0 :		// Dirichlet condition
			//primeira equacao
			for(int iq=0; iq<phrQ; iq++)
            {
                //the contribution of the Dirichlet boundary condition appears in the flow equation
                ef(iq+phrS,0) += (-1.)*v2*phiQ(iq,0)*weight;
            }
            break;
			
		case 1 :			// Neumann condition
			//primeira equacao
            if(IsZero(v2)) BigNum = 1.e10;
			for(int iq=0; iq<phrQ; iq++)
            {
                ef(iq+phrS,0)+= BigNum*v2*phiQ(iq,0)*weight;
                for (int jq=0; jq<phrQ; jq++) {
                    
                    ek(iq+phrS,jq+phrS)+= BigNum*phiQ(iq,0)*phiQ(jq,0)*weight;
                }
            }
			break;
            
        case 2 :			// mixed condition
            for(int iq = 0; iq < phrQ; iq++) {
                
				ef(iq+phrS,0) += v2*phiQ(iq,0)*weight;
				for (int jq = 0; jq < phrQ; jq++) {
					ek(iq+phrS,jq+phrS) += weight*bc.Val1()(0,0)*phiQ(iq,0)*phiQ(jq,0);
				}
			}
            
            break;
            
        case 5 :        // Neumann(pressure)-Inflow(saturation)
			//primeira equacao
			for(int iq=0; iq<phrQ; iq++)
            {
                ef(iq+phrS,0)+= BigNum*v2*phiQ(iq,0)*weight;
                for (int jq=0; jq<phrQ; jq++) {
                    
                    ek(iq+phrS,jq+phrS)+= BigNum*phiQ(iq,0)*phiQ(jq,0)*weight;
                }
            }
			break;
            
        case 6 :		// Dirichlet(pressure)-Outflow(saturation)
			//primeira equacao
			for(int iq=0; iq<phrQ; iq++)
            {
                //the contribution of the Dirichlet boundary condition appears in the flow equation
                ef(iq+phrS,0) += (-1.)*v2*phiQ(iq,0)*weight;
            }
            break;
            
        case 7 :		// Dirichlet(pressure)-Inflow(saturation)
			//primeira equacao
			for(int iq=0; iq<phrQ; iq++)
            {
                //the contribution of the Dirichlet boundary condition appears in the flow equation
                ef(iq+phrS,0) += (-1.)*v2*phiQ(iq,0)*weight;
            }
            break;
	}
}
示例#11
0
void TPZBiharmonic::ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft,
                                          REAL weight,
                                          TPZFMatrix<REAL> &ek,
                                          TPZFMatrix<REAL> &ef,
                                          TPZBndCond &bc) {
	
	// TPZFMatrix<REAL> &dphi = data.dphix;
	TPZFMatrix<REAL> &dphiL = dataleft.dphix;
	// TPZFMatrix<REAL> &dphiR = dataright.dphix;
	// TPZFMatrix<REAL> &phi = data.phi;
	TPZFMatrix<REAL> &phiL = dataleft.phi;
	// TPZFMatrix<REAL> &phiR = data.phir;
	TPZManVector<REAL,3> &normal = data.normal;
	// TPZManVector<REAL,3> &x = data.x;
	//int POrder=data.p;
	//int LeftPOrder=data.leftp;
	//int RightPOrder=data.rightp;
	// TPZVec<REAL> &sol=data.sol;
	// TPZVec<REAL> &solL=data.soll;
	// TPZVec<REAL> &solR=data.solr;
	// TPZFMatrix<REAL> &dsol=data.dsol;
	// TPZFMatrix<REAL> &dsolL=data.dsoll;
	// TPZFMatrix<REAL> &dsolR=data.dsolr;
	//REAL faceSize=data.HSize;
	// TPZFMatrix<REAL> &jacinv = data.jacinv;
	// TPZFMatrix<REAL> &axes = data.axes;
	// int &LeftPOrder=data.leftp;
	// int &RightPOrder=data.rightp;
	int POrder=data.p;                            // I need some explains, why you use reference & - Jorge
	REAL faceSize=data.HSize;
	
	REAL alpha = gSigmaA*pow(((REAL)POrder), gL_alpha) /  pow(faceSize, gM_alpha);
	REAL betta = gSigmaB*pow(((REAL)POrder), gL_betta) /  pow(faceSize, gM_betta);
	//   cout <<  "faceSize em ContributeBCInterface = " <<faceSize << endl;
	//   cout <<  "POrder em ContributeBCInterface = " <<POrder << endl;
	//   cout <<  "alpha em ContributeBCInterface = " <<alpha << endl;
	//   cout <<  "betta em ContributeBCInterface = " <<betta << endl;
	
	int il,jl,nrowl,id;
	nrowl = phiL.Rows();
	
	/* Primeira Integral */
	for(il=0; il<nrowl; il++) {
		
		REAL dphiLinormal = 0.;
		for(id=0; id<2; id++) {
			dphiLinormal += dphiL(3+id,il)*normal[id];
		}
		
		// Termos de Dirichlet     -     em Val2()(0,0)
		ef(il,0) += + gLambda1*weight*dphiLinormal*bc.Val2()(0,0)
		+ alpha * weight*bc.Val2()(0,0)*phiL(il) ;
		
		for(jl=0; jl<nrowl; jl++) {
			REAL dphiLjnormal = 0.;
			for(id=0; id<2; id++) {
				dphiLjnormal += dphiL(3+id,jl)*normal[id];
			}
			ek(il,jl) += weight*(+ gLambda1*dphiLinormal*phiL(jl,0)+ dphiLjnormal*phiL(il,0)); //2 1
		}
	}
	
	/* Segunda Integral */
	for(il=0; il<nrowl; il++) {
		REAL dphiLinormal = 0.;
		for(id=0; id<2; id++) {
			dphiLinormal += dphiL(id,il)*normal[id];
		}
		
		// Termos de Neuwmann     -      em Val2()(1,0)
		ef(il,0) += - gLambda2*weight*bc.Val2()(1,0)*dphiL(2,il)
		+ betta * weight*bc.Val2()(1,0)*dphiLinormal ;
		
		for(jl=0; jl<nrowl; jl++) {
			REAL dphiLjnormal = 0.;
			for(id=0; id<2; id++) {
				dphiLjnormal += dphiL(id,jl)*normal[id];
			}
			ek(il,jl) += weight*(- dphiLinormal*dphiL(2,jl) - gLambda2*dphiLjnormal*dphiL(2,il) );
		}
    }
	
	
	for(il=0; il<nrowl; il++) {
		REAL dphiLinormal = 0.;
		for(id=0; id<2; id++) {
			dphiLinormal += dphiL(id,il)*normal[id];
		}
		for(jl=0; jl<nrowl; jl++) {
			REAL dphiLjnormal = 0.;
			for(id=0; id<2; id++) {
				dphiLjnormal += dphiL(id,jl)*normal[id];
			}
			ek(il,jl) += weight*(
								 alpha * phiL(jl,0)*phiL(il,0) +
								 betta * dphiLinormal*dphiLjnormal
								 );
		}
	}
}
示例#12
0
void TPZEuler::ContributeBC(TPZMaterialData &data,REAL weight,
							TPZFMatrix<REAL> &ek,
							TPZFMatrix<REAL> &ef,TPZBndCond &bc) {
	// TPZFMatrix<REAL> &dphi = data.dphix;
	// TPZFMatrix<REAL> &dphiL = data.dphixl;
	// TPZFMatrix<REAL> &dphiR = data.dphixr;
	TPZFMatrix<REAL> &phi = data.phi;
	// TPZFMatrix<REAL> &phiL = data.phil;
	// TPZFMatrix<REAL> &phiR = data.phir;
	// TPZManVector<REAL,3> &normal = data.normal;
	// TPZManVector<REAL,3> &x = data.x;
	// int &POrder=data.p;
	// int &LeftPOrder=data.leftp;
	// int &RightPOrder=data.rightp;
    int numbersol = data.sol.size();
    if (numbersol != 1) {
        DebugStop();
    }

	TPZVec<REAL> &sol=data.sol[0];
	// TPZVec<REAL> &solL=data.soll;
	// TPZVec<REAL> &solR=data.solr;
	// TPZFMatrix<REAL> &dsol=data.dsol;
	// TPZFMatrix<REAL> &dsolL=data.dsoll;
	// TPZFMatrix<REAL> &dsolR=data.dsolr;
	// REAL &faceSize=data.HSize;
	// TPZFMatrix<REAL> &daxesdksi=data.daxesdksi;
	TPZFMatrix<REAL> &axes=data.axes;
	
	if(fState == 0) return;
	if(bc.Material().operator ->() != this){
		PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
	}
	
	if(bc.Type() < 0 && bc.Type() > 3){
		PZError << "TPZEuler.aplybc, unknown boundary condition type :"  <<
		bc.Type() << " boundary condition ignored\n";
		return;
	}
	
	
	int numdof = NStateVariables();
	int numnod = ek.Rows()/numdof;
	int r = numdof;
	
	TPZVec<REAL> flux(8);
	gEul.Flux(sol,flux);
	REAL normal[2] = {axes(0,1),-axes(0,0)};
	/*
	 int i;
	 cout << " flux = " << x[0] << ' ' << x[1] << ' ' << "normal" << normal[0] << ' ' << normal[1] << ' ';
	 for(i=0; i<4; i++) cout << flux[i+4] << ' ';
	 cout << endl;
	 */
	int idf,jdf,in,jn;
	switch(bc.Type()){
			
		case 0:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
					}
				}
			}
			break;
			
		case 1:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
			}
			break;
			
		case 2:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						for(jdf = 0;jdf<r;jdf++) {
							ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
						}
					}
				}
			case 3: {
				TPZFMatrix<REAL> A(4,4),B(4,4);
				gEul.JacobFlux(sol,A,B);
				for(in=0; in<numnod; in++) {
					for(idf=0; idf<4; idf++) {
						/*
						 ef(4*in+idf) += weight*fDeltaT*(
						 -phi(in,0)*flux[idf]*normal[0]
						 -phi(in,0)*flux[idf+4]*normal[1]
						 );
						 */
						for(jn=0; jn<numnod; jn++) {
							for(jdf=0; jdf<4; jdf++) {      
								ek(4*in+idf,4*jn+jdf) += weight*fDeltaT*
								(phi(in,0)*A(idf,jdf)*phi(jn,0)*normal[0]
								 + phi(in,0)*B(idf,jdf)*phi(jn,0)*normal[1]);
								
							}
						}
					}
				}
			}
			}//fim switch
	}
}
示例#13
0
void TPZMatHybrid::ContributeBC(TPZMaterialData &data,
                                REAL weight,
                                TPZFMatrix<REAL> &ek,
                                TPZFMatrix<REAL> &ef,
                                TPZBndCond &bc) {
	
	// TPZFMatrix<REAL> &dphi = data.dphix;
	// TPZFMatrix<REAL> &dphiL = data.dphixl;
	// TPZFMatrix<REAL> &dphiR = data.dphixr;
	TPZFMatrix<REAL> &phi = data.phi;
	// TPZFMatrix<REAL> &phiL = data.phil;
	// TPZFMatrix<REAL> &phiR = data.phir;
	// TPZManVector<REAL,3> &normal = data.normal;
	// TPZManVector<REAL,3> &x = data.x;
	// int &POrder=data.p;
	// int &LeftPOrder=data.leftp;
	// int &RightPOrder=data.rightp;
	// TPZVec<REAL> &sol=data.sol;
	// TPZVec<REAL> &solL=data.soll;
	// TPZVec<REAL> &solR=data.solr;
	// TPZFMatrix<REAL> &dsol=data.dsol;
	// TPZFMatrix<REAL> &dsolL=data.dsoll;
	// TPZFMatrix<REAL> &dsolR=data.dsolr;
	// REAL &faceSize=data.HSize;
	// TPZFMatrix<REAL> &daxesdksi=data.daxesdksi;
	// TPZFMatrix<REAL> &axes=data.axes;
	
	if(bc.Material().operator ->() != this){
		PZError << "TPZMat1dLin.apply_bc warning : this material didn't create the boundary condition!\n";
	}
	
	if(bc.Type() < 0 && bc.Type() > 2){
		PZError << "TPZMat1dLin.aplybc, unknown boundary condition type :"  <<
		bc.Type() << " boundary condition ignored\n";
	}
	
	
	int numdof = NStateVariables();
	int numnod = ek.Rows()/numdof;
	int r = numdof;
	
	int idf,jdf,in,jn;
	switch(bc.Type()){
			
		case 0:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += gBigNumber*phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						ek(in*r+idf,jn*r+idf) += gBigNumber*phi(in,0)*phi(jn,0)*weight;
					}
				}
			}
			break;
			
		case 1:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
			}
			break;
			
		case 2:
			for(in=0 ; in<numnod ; ++in){
				for(idf = 0;idf<r;idf++) {
					(ef)(in*r+idf,0) += phi(in,0)*bc.Val2()(idf,0)*weight;
				}
				for(jn=0 ; jn<numnod ; ++jn) {
					for(idf = 0;idf<r;idf++) {
						for(jdf = 0;jdf<r;jdf++) {
							ek(in*r+idf,jn*r+jdf) += bc.Val1()(idf,jdf)*phi(in,0)*phi(jn,0)*weight;
						}
					}
				}
			}//fim switch
	}
}