示例#1
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();
	}
	
}
示例#2
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;
    }
    
}
示例#3
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;
    }
    
}