Esempio n. 1
0
//----
void TPZBndCond::Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<REAL> &ek, TPZFMatrix<REAL> &ef) {

    //this->UpdataBCValues(datavec);

    int typetmp = fType;
    if (fType == 50) {
//		int i;
#ifdef DEBUG2
        {
            for(int iref=0; iref < datavec.size(); iref++) {
                std::stringstream sout;
                sout << __PRETTY_FUNCTION__ << datavec[iref].sol << " " << datavec[iref].x;
                LOGPZ_DEBUG(logger,sout.str().c_str());
            }
        }
#endif
        //for (i = 0; i <data.sol.NElements(); i++){
//			fBCVal2(i,0) = gBigNumber*data.sol[i];
//			fBCVal1(i,i) = gBigNumber;
//		}
//		fType = 2;
    }

    this->fMaterial->ContributeBC(datavec,weight,ek,ef,*this);
    fType = typetmp;
}
Esempio n. 2
0
void TPZBndCond::Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<REAL> &ef) {
    this->UpdataBCValues(data);
    int numbersol = data.sol.size();
    //clone meshes required analysis
    int typetmp = fType;
    if (fType == 50) {
        int i;
#ifdef DEBUG2
        {
            std::stringstream sout;
            sout << __PRETTY_FUNCTION__ << data.sol << " " << data.x;
            LOGPZ_DEBUG(logger,sout.str().c_str());
        }
#endif
        for (i = 0; i <data.sol.NElements(); i++) {
            for (int is=0; is<numbersol; is++) {
                fBCVal2(i,0) = gBigNumber*data.sol[is][i];
            }
            fBCVal1(i,i) = gBigNumber;
        }
        fType = 2;
    }

    this->fMaterial->ContributeBC(data,weight,ef,*this);
    fType = typetmp;
}
Esempio n. 3
0
OOPMReturnType OOPMergeMatrix::Execute()
{
	
	cout << "Executing Task " << Id() << " For Dispersed vector aggregation ";
	TPZMatrix<REAL> * GlobalVector = dynamic_cast<TPZMatrix<REAL> * > (fDependRequest.ObjectPtr(0));
	OOPParMatIndexation * Indices = NULL;
	Indices = dynamic_cast<OOPParMatIndexation * >  (fDependRequest.ObjectPtr(1));
	
#ifdef LOGPZ
	{
		if(!Indices)
		{
			std::stringstream sout;
			sout << "Indices Object not available";
			LOGPZ_ERROR(logger, sout.str().c_str());
		}
	}
#endif
	
	std::vector<int> rows = Indices->GetRowVector(m_SubId);
	
#ifdef LOGPZ
	{
		std::stringstream sout;
		sout << "Rows.size on MergeTask = " << rows.size();
		LOGPZ_ERROR(logger, sout.str().c_str());
	}
#endif
	int i;
#ifdef LOGPZ
	std::stringstream sout;
	for(i = 0; i < rows.size(); i++)
	{
		sout << "Row[" << i << "] = " << rows[i] << endl;
	}
	GlobalVector->Print("Global Vector Original", sout, EFormatted);
#endif
	for(i = 0; i < rows.size(); i++)
	{
		GlobalVector->Put(rows[i], 0, GlobalVector->Get(rows[i], 0) + m_Vector.Get(i, 0));
	}
	
	//IncrementWriteDependentData();
#ifdef LOGPZ
	{
		std::stringstream sout;
		sout << "Leaving Merge Task Id " << Id();
		sout << "\nResulting Vector\n";
		m_Vector.Print("Local Vector", sout, EFormatted);
		GlobalVector->Print("Global Vector After Contribution", sout, EFormatted);
		LOGPZ_DEBUG(logger, sout.str().c_str());
	}
#endif
	cout << "Leaving Merge Task execution " << endl;
	return ESuccess;
}
Esempio n. 4
0
void TPZHelmholtzComplex1D::Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) {

    TPZManVector<STATE,2> alphaval(1), betaval(1), phiaval(1);
    fAlpha->Execute(data.x, alphaval);
    fBeta->Execute(data.x, betaval);
    fPhi->Execute(data.x, phiaval);
    
    #ifdef LOG4CXX 
    {
        std::stringstream sout;        
        sout << "Coordenate x: " << data.x << " alpha = " << alphaval << " beta = " << betaval << " phi = " << phiaval;
        LOGPZ_DEBUG(logger, sout.str());
    }
    #endif
    
    TPZFNMatrix<4, STATE> xk(1, 1), xb(1, 1), xc(1, 1, 0.), xf(1, 1);
    xk(0,0) = alphaval[0];    
    xb(0,0) = betaval[0];    
    xf(0,0) = -phiaval[0];   
       
    SetMaterial(xk, xc, xb, xf);
    TPZMat1dLin::Contribute(data, weight, ek, ef);
}
Esempio n. 5
0
TPZMultiphysicsInterfaceElement * TPZMultiphysicsElement::CreateInterface(int side)
{
	//  LOGPZ_INFO(logger, "Entering CreateInterface");
	TPZMultiphysicsInterfaceElement * newcreatedinterface = NULL;
	
	TPZGeoEl *ref = Reference();
	if(!ref) {
		LOGPZ_WARN(logger, "Exiting CreateInterface Null reference reached - NULL interface returned");
		return newcreatedinterface;
	}
	
	TPZCompElSide thisside(this,side);
	TPZStack<TPZCompElSide> list;
	list.Resize(0);
	thisside.EqualLevelElementList(list,0,0);//retorna distinto ao atual ou nulo
	int64_t size = list.NElements();
	//espera-se ter os elementos computacionais esquerdo e direito
	//ja criados antes de criar o elemento interface
    // try to create an interface element between myself and an equal sized neighbour
    for (int64_t is=0; is<size; is++)
    {
		//Interface has the same material of the neighbour with lesser dimension.
		//It makes the interface have the same material of boundary conditions (TPZCompElDisc with interface dimension)
		int matid;
		int thisdim = this->Dimension();
		int neighbourdim = list[is].Element()->Dimension();
        
        if(thisdim != neighbourdim)
        {
            if (thisdim < neighbourdim)
            {
                // return the material id of boundary condition IF the associated material is derived from bndcond
                TPZMaterial *mat = this->Material();
                TPZBndCond *bnd = dynamic_cast<TPZBndCond *>(mat);
                if(bnd)
                {
                    matid = this->Material()->Id();
                }
                else
                {
                    matid = this->Mesh()->Reference()->InterfaceMaterial(this->Reference()->MaterialId(),list[0].Element()->Reference()->MaterialId());
                    continue;
                }
            }
			else
            {
                TPZMaterial *mat = list[is].Element()->Material();
                TPZBndCond *bnd = dynamic_cast<TPZBndCond *>(mat);
                if (bnd) {
                    matid = bnd->Id();
                }
                else {
                    matid = this->Mesh()->Reference()->InterfaceMaterial(this->Reference()->MaterialId(), list[0].Element()->Reference()->MaterialId());
                    continue;
                }
            }
        }else
        {
            matid = this->Mesh()->Reference()->InterfaceMaterial(this->Reference()->MaterialId(), list[0].Element()->Reference()->MaterialId());
            if(matid == GMESHNOMATERIAL)
            {
                continue;
            }
        }
		
		int64_t index;
		
		
		TPZGeoEl *gel = ref->CreateBCGeoEl(side,matid); //isto acertou as vizinhanas da interface geometrica com o atual
		if(!gel){
			DebugStop();
#ifdef LOG4CXX
            if (logger->isDebugEnabled())
			{
				std::stringstream sout;
				sout << "CreateBCGeoEl devolveu zero!@@@@";
				LOGPZ_DEBUG(logger,sout.str());
			}
#endif
		}
        bool withmem = fMesh->ApproxSpace().NeedsMemory();
		if(Dimension() > list[is].Reference().Dimension()) {
			//o de volume eh o direito caso um deles seja BC
			//a normal aponta para fora do contorno
			TPZCompElSide thiscompelside(this, thisside.Side());
			TPZCompElSide neighcompelside(list[is]);
            if (!withmem) {
                newcreatedinterface = new TPZMultiphysicsInterfaceElement(*fMesh,gel,index,thiscompelside,neighcompelside);
            }
            else
            {
                newcreatedinterface = new TPZCompElWithMem<TPZMultiphysicsInterfaceElement>(*fMesh,gel,index,thiscompelside,neighcompelside);
            }
		} else {
			//caso contrario ou caso ambos sejam de volume
			TPZCompElSide thiscompelside(this, thisside.Side());
			TPZCompElSide neighcompelside(list[is]);
            if (!withmem) {
                newcreatedinterface = new TPZMultiphysicsInterfaceElement(*fMesh,gel,index,neighcompelside,thiscompelside);
            }
            else
            {
                newcreatedinterface = new TPZCompElWithMem<TPZMultiphysicsInterfaceElement>(*fMesh,gel,index,neighcompelside,thiscompelside);
            }
		}
		
		
		
		return newcreatedinterface;
	}
	
	//If there is no equal or lower level element, we try the lower elements.
	//Higher elements will not be considered by this method. In that case the interface must be created by the neighbour.
	TPZCompElSide lower = thisside.LowerLevelElementList(0);
	if(lower.Exists()){
		//Interface has the same material of the neighbour with lesser dimension.
		//It makes the interface has the same material of boundary conditions (TPZCompElDisc with interface dimension)
		int matid = GMESHNOMATERIAL;
		int thisdim = this->Dimension();
		int neighbourdim = lower.Element()->Dimension();
        matid = this->Mesh()->Reference()->InterfaceMaterial(this->Material()->Id(), lower.Element()->Material()->Id() );
		
		if (matid == GMESHNOMATERIAL && thisdim == neighbourdim){
			//      matid = this->Material()->Id();
            //break;
        }
        else if(matid == GMESHNOMATERIAL && thisdim != neighbourdim)
        {
			if (thisdim < neighbourdim) 
            {
                // return the material id of boundary condition IF the associated material is derived from bndcond
                TPZMaterial *mat = this->Material();
                TPZBndCond *bnd = dynamic_cast<TPZBndCond *>(mat);
                if(bnd)
                {
                    matid = this->Material()->Id();
                }
                else {
                    //continue;
                }
            }
			else 
            {
                TPZMaterial *mat = lower.Element()->Material();
                TPZBndCond *bnd = dynamic_cast<TPZBndCond *>(mat);
                if (bnd) {
                    matid = bnd->Id();
                }
                else {
                    //continue;
                }
            }
		}
		
        // return zero
        if(matid == GMESHNOMATERIAL)
        {
            return newcreatedinterface;
        }
		
		TPZCompEl *lowcel = lower.Element();
		//int lowside = lower.Side();
		//existem esquerdo e direito: this e lower
		TPZGeoEl *gel = ref->CreateBCGeoEl(side,matid);
		int64_t index;
		
        bool withmem = fMesh->ApproxSpace().NeedsMemory();
        
		if(Dimension() > lowcel->Dimension()){
			//para que o elemento esquerdo seja de volume
			TPZCompElSide thiscompelside(this, thisside.Side());
			TPZCompElSide lowcelcompelside(lower);
            if (!withmem) {
                newcreatedinterface = new TPZMultiphysicsInterfaceElement(*fMesh,gel,index,thiscompelside,lowcelcompelside);
            }
            else
            {
                newcreatedinterface = new TPZCompElWithMem<TPZMultiphysicsInterfaceElement>(*fMesh,gel,index,thiscompelside,lowcelcompelside);
            }
		} else {
			TPZCompElSide thiscompelside(this, thisside.Side());
			TPZCompElSide lowcelcompelside(lower);
#ifdef LOG4CXX_KEEP
            if (logger->isDebugEnabled())
			{
				std::stringstream sout;
				sout << __PRETTY_FUNCTION__ << " left element";
				sout << lowcelcompelside << thiscompelside;
				sout << "Left Element ";
				lowcelcompelside.Element()->Print(sout);
				sout << "Right Element ";
				thiscompelside.Element()->Print(sout);
				LOGPZ_DEBUG(logger,sout.str())
			}
#endif
            if (!withmem)
            {
                newcreatedinterface = new TPZMultiphysicsInterfaceElement(*fMesh,gel,index,lowcelcompelside,thiscompelside);
            }
            else
            {
                newcreatedinterface = new TPZCompElWithMem<TPZMultiphysicsInterfaceElement>(*fMesh,gel,index,lowcelcompelside,thiscompelside);
            }
		}
Esempio n. 6
0
void TPZMaterialCoupling::ContributeInterface2(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, 
                                              REAL weight,TPZFMatrix<REAL> &ek,TPZFMatrix<REAL> &ef){
		
		
		
		
//    TPZFMatrix<REAL>  &dphixL = dataleft.dphix;
		TPZFMatrix<REAL>  &phixL = dataleft.phi;
		
		TPZFMatrix<REAL>  &phixR = dataright.phi;
		
		
		
		int numvec=dataright.fVecShapeIndex.NElements();
		int nrowR=phixR.Rows();//funcao a direita Hdiv
		int nrowL=phixL.Rows();//Funcao a esquerda H1
		int numdual = dataright.numberdualfunctions;

		std::cout << "numero de funcoes de Hdiv( direita ) " << nrowR<<std::endl;
		std::cout << "numero de funcoes de de pressao(direita) " << numdual<<std::endl;
		std::cout << "numero de funcoes de H1 (esquerda ) " << nrowL<<std::endl;
#ifdef LOG4CXX
		{
				std::stringstream sout;
				sout << "numero de funcoes de Hdiv( direita ) " << nrowR<<std::endl;
				sout << "numero de funcoes de de pressao(direita) " << numdual<<std::endl;
				sout << "numero de funcoes de H1 (esquerda ) " << nrowL<<std::endl;
				LOGPZ_DEBUG(logger, sout.str().c_str());
		}
#endif
		
		/*
		for(int ir=0; ir<nrowL; ir++) {
				
				for(int jl=0; jl<nrowL; jl++) {
						REAL prod1 =	phixL(ir)* phixL(jl);
				}
		}
         */
		
		
		
		
		for(int ir=0; ir<nrowR-1; ir++) {
//				int ivecind = dataright.fVecShapeIndex[ir].first;
				int ishapeind = dataright.fVecShapeIndex[ir].second;
				for(int jl=0; jl<nrowL; jl++) {
						REAL prod1 =	phixR(ishapeind,0)* phixL(jl);
#ifdef LOG4CXX
						{
								std::stringstream sout;
								sout << "produto das phis " << prod1<<std::endl;
								LOGPZ_DEBUG(logger, sout.str().c_str());
						}
#endif
						ek(ir,numvec+jl) += weight  * prod1;
						ek(numvec+jl,ir) += weight  *(-prod1);
				}
    }
		
		
#ifdef LOG4CXX
		{
				std::stringstream sout;
				ek.Print("Matriz de Acoplamento",sout);
				LOGPZ_DEBUG(logger, sout.str().c_str());
		}
#endif
		
		
		
		
}
Esempio n. 7
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
		
		
		
		
}
Esempio n. 8
0
void SolveSystemTransient(REAL deltaT,REAL maxTime, TPZAnalysis *NonLinearAn, TPZCompMesh* CMesh)
{
    
    TPZFMatrix<STATE> Patn;
    TPZFMatrix<STATE> PatnMinusOne;    
//  {
//      TPZBFileStream load;
//      load.OpenRead("MultiphaseSaturationSol.bin");
//      SolutiontoLoad.Read(load,0);
//      meshvec[2]->LoadSolution(SolutiontoLoad);
//      TPZBuildMultiphysicsMesh::TransferFromMeshes(meshvec, mphysics);        
//  }

  
    std::string OutPutFile = "WaveSolution";
    TPZMaterial *mat1 = CMesh->FindMaterial(1);    
    
    TPZLinearWave * material1 = dynamic_cast<TPZLinearWave *>(mat1);  
    //    TPZMultiphase * material2 = dynamic_cast<TPZMultiphase *>(mat2);      
    material1->SetTimeStep(deltaT);
    
    //  Starting Newton Iterations
    TPZFMatrix<STATE> DeltaX = CMesh->Solution();
    TPZFMatrix<STATE> Uatn = CMesh->Solution();
    TPZFMatrix<STATE> Uatk = CMesh->Solution();      
    
    
    REAL TimeValue = 0.0;
    REAL Tolerance = 1.0e-7;
    int cent = 0;
    int MaxIterations = 50;
    TimeValue = cent*deltaT;
    REAL NormValue =1.0;
    bool StopCriteria = false;
    TPZFMatrix<STATE> RhsAtnMinusOne, RhsAtn, RhsAtnPlusOne, Residual;

    
    std::string outputfile;
    outputfile = OutPutFile;
    std::stringstream outputfiletemp;
    outputfiletemp << outputfile << ".vtk";
    std::string plotfile = outputfiletemp.str();
    PosProcess(material1->Dimension(),*NonLinearAn,outputfile,2);      

    std::cout << " Starting the time computations. " << std::endl;  
    while (TimeValue < maxTime)
    {
        
        material1->SetMinusOneState();
        CMesh->LoadSolution(PatnMinusOne);
        NonLinearAn->AssembleResidual();
        RhsAtnMinusOne = NonLinearAn->Rhs();

        material1->SetNState();
        CMesh->LoadSolution(Patn);        
        NonLinearAn->AssembleResidual();
        RhsAtn = NonLinearAn->Rhs();        
        
        material1->SetPlusOneState();
        CMesh->LoadSolution(Patn);        
        NonLinearAn->Assemble();
        RhsAtnPlusOne = NonLinearAn->Rhs();
        
        Residual= RhsAtnMinusOne + RhsAtn + RhsAtnPlusOne;       
        NormValue = Norm(Residual);
        


        
        int iterations= 0;      
        while (NormValue > Tolerance)
        {       
            
            Residual*=-1.0;
            NonLinearAn->Rhs()=Residual;
            NonLinearAn->Solve();           
            DeltaX = NonLinearAn->Solution();
            Uatk = (Uatn + DeltaX);
            
            
            CMesh->LoadSolution(Uatn + DeltaX);          
            
#ifdef LOG4CXX
            if(logdata->isDebugEnabled())
            {
                std::stringstream sout;
                sout.precision(20);
                Residual.Print(sout);
                Uatk.Print(sout);       
                LOGPZ_DEBUG(logdata,sout.str());
            }
#endif          


            material1->SetPlusOneState();
            NonLinearAn->Assemble();
            RhsAtnPlusOne = NonLinearAn->Rhs();
            Residual= RhsAtnMinusOne + RhsAtn + RhsAtnPlusOne;
            NormValue = Norm(Residual); 
                
            
#ifdef LOG4CXX
            if(logdata->isDebugEnabled())
            {
                std::stringstream sout;
                sout.precision(15);             
                Uatk.Print(sout);
                Residual.Print("Res = ",sout,EMathematicaInput);
                LOGPZ_DEBUG(logdata,sout.str());
            }
#endif      

            
        
            
            iterations++;
            std::cout << " Newton's Iteration = : " << iterations  << "     L2 norm = : " << NormValue <<  std::endl;
            if (iterations == MaxIterations) 
            {
                StopCriteria = true;
                std::cout << " Time Step number = : " << iterations  << "\n Exceed max iterations numbers = : " << MaxIterations <<  std::endl;                 
                break;
            }

                
            Uatn = Uatk;
            
        }   

        outputfile = OutPutFile;
        std::stringstream outputfiletemp;
        outputfiletemp << outputfile << ".vtk";
        std::string plotfile = outputfiletemp.str();
        PosProcess(material1->Dimension(),*NonLinearAn,outputfile,2);      
        
        if (StopCriteria) {
            std::cout << " Newton's Iteration = : " << iterations  << "     L2 norm = : " << NormValue <<  std::endl;       
            break;
        }
        
        cent++;
        TimeValue = cent*deltaT;
        
        std::cout << " Time Step :  " << cent  << "  Time :  " << TimeValue <<  std::endl; 
        
        PatnMinusOne = Patn;
        Patn = Uatk;
        
    }
   
}