예제 #1
0
void TPZEulerConsLawDEP::Flux(TPZVec<REAL> &x,TPZVec<REAL> &Sol,TPZFMatrix &DSol,
						   TPZFMatrix &axes,TPZVec<REAL> &flux) {
	TPZVec<REAL> Fx,Fy,Fz;
	Flux(Sol,Fx,Fy,Fz);
	int cap = Sol.NElements();
	int nstate = NStateVariables(),i;
	if(cap != nstate){
		PZError << "\nTPZEulerConsLawDEP::Flux data size error\n";
		flux.Resize(0);
		return;
	}
	if(nstate == 3){
		flux.Resize(3);
		for(i=0;i<3;i++) flux[i] = Fx[i];
		return;
	} else
		if(nstate == 4){
			flux.Resize(8);
			for(i=0;i<4;i++) flux[i] = Fx[i];
			for(i=4;i<8;i++) flux[i] = Fy[i];
			return;
		} else
			if(nstate == 5){
				flux.Resize(15);
				for(i=00;i<05;i++) flux[i] = Fx[i];
				for(i=05;i<10;i++) flux[i] = Fy[i];
				for(i=10;i<15;i++) flux[i] = Fz[i];
			}
}
void RSNAMeshPoints(TPZVec< TPZVec<REAL> > & pt, TPZVec< TPZVec< int64_t> > &elms)
{
   REAL x1 = 0.,
        x2 = 4.12791,
	y1 = 0.,
	y2 = 1.;

   pt.Resize(6);
   TPZVec<REAL> coord(3);

   coord[0] = x1;
   coord[1] = y1;
   coord[2] = 0.;
   pt[0] = coord;

   coord[0] = x2/2.;
   coord[1] = y1;
   coord[2] = 0.;
   pt[1] = coord;

   coord[0] = x2;
   coord[1] = y1;
   coord[2] = 0.;
   pt[2] = coord;

   coord[0] = x1;
   coord[1] = y2;
   coord[2] = 0.;
   pt[3] = coord;

   coord[0] = x2/2;
   coord[1] = y2;
   coord[2] = 0.;
   pt[4] = coord;

   coord[0] = x2;
   coord[1] = y2;
   coord[2] = 0.;
   pt[5] = coord;

// quadrilateral data

   TPZVec< int64_t > nodes(4);

   elms.Resize(2);

   nodes[0] = 0;
   nodes[1] = 1;
   nodes[2] = 4;
   nodes[3] = 3;
   elms[0] = nodes;

   nodes[0] = 1;
   nodes[1] = 2;
   nodes[2] = 5;
   nodes[3] = 4;
   elms[1] = nodes;

}
예제 #3
0
void TPZEuler::Solution(TPZVec<REAL> &Sol,TPZFMatrix<REAL> &DSol,TPZFMatrix<REAL> &axes,int var,
						TPZVec<REAL> &Solout){
	if(var == 1) {
		Solout.Resize(1);
		Solout[0] = gEul.Pressure(Sol);
	} else if(var ==2) {
		Solout.Resize(1);
		Solout[0] = Sol[0];
	} else if(var == 3) {
		Solout.Resize(2);
		Solout[0] = Sol[1];
		Solout[1] = Sol[2];
	} else TPZMaterial::Solution(Sol,DSol,axes,var,Solout);
}
예제 #4
0
파일: main.cpp 프로젝트: labmec/neopz
void ReadSolution(ifstream &arq, TPZVec<REAL> &sol, TPZCompMesh *cmesh, int &nstate, TPZVec<int> &dimstate){

  int i,j,totaldim=0;
  for(i=0;i<nstate;i++) totaldim += dimstate[i];
  TPZVec<REAL> pt(3,0.);
  TPZVec<REAL> coord(3,0.);
  TPZVec<REAL> auxsol(totaldim,0.);

  int iter = 0;
  int nel = cmesh->NElements();
  int solsize = totaldim * nel;
  sol.Resize(solsize);
  sol.Fill(0.);

  for(i=0; i<nel; i++){
    TPZCompEl *el = cmesh->ElementVec()[i];
    if (!el) continue;
    el->Reference()->CenterPoint(el->Reference()->NSides()-1,pt);
    el->Reference()->X(pt,coord);
    EvaluateSolution(coord,auxsol);
    for (j=0;j<totaldim;j++){
      sol[iter] = auxsol[j];
      iter++;
    }
  }
}
예제 #5
0
파일: pzartdiff.cpp 프로젝트: labmec/neopz
void TPZArtDiff::PrepareFastDiff(int dim, TPZFMatrix<REAL> &jacinv, TPZVec<STATE> &sol,
								 TPZFMatrix<STATE> &dsol, TPZFMatrix<REAL> & dphi,
								 TPZVec<TPZVec<STATE> > & TauDiv, TPZVec<TPZDiffMatrix<STATE> > * pTaudDiv)
{
	TPZVec<TPZDiffMatrix<STATE> > Ai;
	TPZVec<TPZDiffMatrix<STATE> > Tau;
	
	TPZEulerConsLaw::JacobFlux(fGamma, dim, sol, Ai);
	ComputeTau(dim, jacinv, sol, Ai, Tau);
	
	TPZVec<STATE> Div;
	
	TPZDiffMatrix<STATE> * pdDiv = NULL;
	TPZDiffMatrix<STATE> dDiv;
	if(pTaudDiv) pdDiv = & dDiv;
	
	//Computing the divergent
	Divergent(dsol, dphi, Ai, Div, pdDiv);
	TauDiv.Resize(dim);
	if(pTaudDiv)pTaudDiv->Resize(dim);
	
	// computing Tau.Div = {Tx.Div, Ty.Div, Tz.Div}
	// and Tau.dDiv = {Tx.dDiv, Ty.dDiv, Tz.dDiv}, if requested
	int k;
	for(k=0;k<dim;k++)
	{
		Tau[k].Multiply(Div, TauDiv[k]);
		if(pTaudDiv)Tau[k].Multiply(dDiv, pTaudDiv->operator[](k));
		
	}
}
예제 #6
0
파일: tpzprism.cpp 프로젝트: labmec/neopz
	void TPZPrism::CenterPoint(int side, TPZVec<REAL> &center) {
		center.Resize(Dimension);
		int i;
		for(i=0; i<Dimension; i++) {
			center[i] = MidSideNode[side][i];
		}
	}
예제 #7
0
void TPZIntelGen<TSHAPE>::GetInterpolationOrder(TPZVec<int> &ord) {
	ord.Resize(TSHAPE::NSides-TSHAPE::NCornerNodes);
	int i;
	for(i=0; i<TSHAPE::NSides-TSHAPE::NCornerNodes; i++) {
		ord[i] = SideOrder(i+TSHAPE::NCornerNodes);
	}
}
예제 #8
0
void TPZMetis::Subdivide(int nParts, TPZVec < int > & Domains)
{
	TPZManVector<int> Adjacency,AdjacencyIndex;
	TPZManVector<int> AdjacencyWeight;
	ConvertToElementoToElementGraph(fElementGraph,fElementGraphIndex,Adjacency,AdjacencyWeight,AdjacencyIndex);
	
#ifdef LOG4CXX
	{
		std::stringstream sout;
		TPZRenumbering::Print(Adjacency,AdjacencyIndex,"Element to element graph",sout);
		LOGPZ_DEBUG(logger,sout.str())
	}
#endif
	
#ifdef USING_METIS
	int nVertices = AdjacencyIndex.NElements() -1;

	Domains.Resize(nVertices);
	// Upon successful completion, nEdgesCutted stores the edge-cut or the total communication volume of the partitioning solution.
	int nEdgesCutted = 0;

	TPZVec<int> Options(METIS_NOPTIONS);
	METIS_SetDefaultOptions(&Options[0]);
	
    int ncon = 2;
	if(METIS_PartGraphRecursive(&nVertices, &ncon, &AdjacencyIndex[0], &Adjacency[0], NULL, NULL, NULL,   // &AdjacencyWeight[0],
					&nParts, NULL, NULL, &Options[0], &nEdgesCutted, &Domains[0]) != METIS_OK)
		DebugStop();
#else
    DebugStop();
#endif
	
}
예제 #9
0
// metodo para computar erros
void TPZMatPoissonD3::Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout){
    
    Solout.Resize( this->NSolutionVariables(var));

    
    if(var == 1){ //function (state variable Q)
        for (int ip = 0; ip<fDim; ip++)
        {
            Solout[ip] = data.sol[0][ip];
        }
        
        return;
    }
    
    if(var == 2){ //function (state variable p)
        
        TPZVec<STATE> SolP;
        SolP = data.sol[0];
        
        Solout[0] = SolP[0];
        return;
    }
    
    
}
예제 #10
0
void TPZMaterial::Solution(TPZVec<REAL> &Sol,TPZFMatrix<REAL> &/*DSol*/,TPZFMatrix<REAL> &/*axes*/,int var,
						   TPZVec<REAL> &Solout){
	if(var == 0) Solout = Sol;
	else if(var == 99 || var == 100 || var == 101 || var == 102) {
		//  	PZError << "TPZMaterial var = "<< var << " the element should treat this case\n";
		Solout[0] = Sol[0]; // = 0.;
	} else Solout.Resize(0);
}
예제 #11
0
파일: tpzprism.cpp 프로젝트: labmec/neopz
 void TPZPrism::ParametricDomainNodeCoord(int node, TPZVec<REAL> &nodeCoord)
 {
     if(node > NCornerNodes)
     {
         DebugStop();
     }
     nodeCoord.Resize(Dimension, 0.);
     switch (node) {
         case (0):
         {
             nodeCoord[0] =  0.;
             nodeCoord[1] =  0.;
             nodeCoord[2] = -1.;
             break;
         }
         case (1):
         {
             nodeCoord[0] =  1.;
             nodeCoord[1] =  0.;
             nodeCoord[2] = -1.;
             break;
         }
         case (2):
         {
             nodeCoord[0] =  0.;
             nodeCoord[1] =  1.;
             nodeCoord[2] = -1.;
             break;
         }
         case (3):
         {
             nodeCoord[0] = 0.;
             nodeCoord[1] = 0.;
             nodeCoord[2] = 1.;
             break;
         }
         case (4):
         {
             nodeCoord[0] = 1.;
             nodeCoord[1] = 0.;
             nodeCoord[2] = 1.;
             break;
         }
         case (5):
         {
             nodeCoord[0] = 0.;
             nodeCoord[1] = 1.;
             nodeCoord[2] = 1.;
             break;
         }
         default:
         {
             DebugStop();
             break;
         }
     }
 }
예제 #12
0
/// associate scale factors with the equations and state variables
void TPBrSteamFlux::InletScales(TPZVec<REAL> &eqscales, TPZVec<REAL> &statescales)
{
    eqscales.Resize(NumInletVars+NumFluxEq);
    statescales.Resize(NumInletVars+NumFluxEq);
    eqscales[EInletMassFlux] = 1.;
    eqscales[EInletEnergyFlux] = 1.;
    eqscales[EInletStateEqs] = 1.;
    statescales[EInletPressure] = TPBrScales::fReferencePressure;
    statescales[EInletSteamSaturation] = 1.;
    statescales[EInletTemperature] = 1.;
    TPZManVector<REAL> loceqscale,locstatescale;
    Scales(loceqscale, locstatescale);
    int ist;
    int nst = loceqscale.NElements();
    for (ist=0; ist<nst; ist++) {
        eqscales[NumInletVars+ist] = loceqscale[ist];
        statescales[NumInletVars+ist] = locstatescale[ist];
    }
}
예제 #13
0
/// associate scale factors with the equations and state variables
void TPBrSteamFlux::Scales(TPZVec<REAL> &eqscales, TPZVec<REAL> &statescales)
{
    eqscales.Resize(NumFluxEq);
    statescales.Resize(NumFluxEq);
    eqscales[EMassFluxWaterEq] = 1.;
    eqscales[EMassFluxSteamEq] = 1.;
    eqscales[EMassFluxOilEq] = 1.;
    eqscales[EDarcyVelocityWaterEq] = 1.;
    eqscales[EDarcyVelocitySteamEq] = 1.;
    eqscales[EDarcyVelocityOilEq] = 1.;
    eqscales[EEnergyFluxEq] = 1.;
    statescales[EMassFluxWater] = 1.;
    statescales[EMassFluxSteam] = 1.;
    statescales[EMassFluxOil] = 1.;
    statescales[EDarcyVelocityWater] = 1.;
    statescales[EDarcyVelocitySteam] = 1.;
    statescales[EDarcyVelocityOil] = 1.;
    statescales[EEnergyFlux] = 1.;
}
예제 #14
0
void TPZPrimalPoisson::Solution(TPZMaterialData &data, int var, TPZVec<STATE> &Solout){
    
    Solout.Resize( this->NSolutionVariables(var));
    TPZVec<STATE> p, q, f;
    
    if(var == 1){
        for (int i=0; i < this->Dimension(); i++)
        {
            Solout[i] = -data.dsol[0][i];
        }
        return;
    }
    
    if(var == 2){
            Solout[0] = data.sol[0][0];
        return;
    }
    
    if(var == 3){
        TPZManVector<STATE,1> f(1,0.0);
        TPZFNMatrix<4,STATE> df(4,1,0.0);
        if (this->HasForcingFunctionExact()) {
            this->fForcingFunctionExact->Execute(data.x, f, df);
        }
        
        for (int i=0; i < this->Dimension(); i++)
        {
            Solout[i] = df(i,0);
        }
        return;
    }
    
    if(var == 4){
        TPZManVector<STATE,1> f(1,0.0);
        TPZFNMatrix<4,STATE> df(4,1,0.0);
        if (this->HasForcingFunctionExact()) {
            this->fForcingFunctionExact->Execute(data.x, f, df);
        }
        Solout[0] = f[0];
        return;
    }
    
    if(var == 5){
        TPZManVector<STATE,1> f(1,0.0);
        TPZFNMatrix<4,STATE> df(4,1,0.0);
        if (this->HasForcingFunctionExact()) {
            this->fForcingFunctionExact->Execute(data.x, f, df);
        }
        Solout[0] = df(3,0);
        return;
    }
    
    DebugStop();
    
}
예제 #15
0
void TPZBiharmonic::Solution(TPZVec<REAL> &Sol,TPZFMatrix<REAL> &DSol,TPZFMatrix<REAL> &/*axes*/,
							 int var,TPZVec<REAL> &Solout){
	if(var == 0 || var == 1) Solout[0] = Sol[0];//function
	if(var == 2) {
		Solout.Resize(DSol.Rows());
		int id;
		for(id=0 ; id  < DSol.Rows(); id++) {
			Solout[id] = DSol(id,0);//derivate
		}
	}
}
예제 #16
0
void TPZGeoTriangle::VectorialProduct(TPZVec<REAL> &v1, TPZVec<REAL> &v2,TPZVec<REAL> &result) {
    if(v1.NElements()!=3||v2.NElements()!=3)
    {
        cout << " o tamanho do vetores eh diferente de 3"<< endl;
    }
    REAL x1=v1[0], y1=v1[1],z1=v1[2];
    REAL x2=v2[0], y2=v2[1],z2=v2[2];
    result.Resize(v1.NElements());
    result[0]=y1*z2-z1*y2;
    result[1]=z1*x2-x1*z2;
    result[2]=x1*y2-y1*x2;
}
예제 #17
0
void TPZMGAnalysis::MeshError(TPZCompMesh *fine, TPZCompMesh *coarse, TPZVec<REAL> &ervec,
							  void (*f)(TPZVec<REAL> &loc, TPZVec<REAL> &val, TPZFMatrix<REAL> &deriv),TPZVec<REAL> &truervec){
	coarse->Reference()->ResetReference();
	coarse->LoadReferences();
	int dim = fine->MaterialVec().begin()->second->Dimension();
	ervec.Resize(coarse->NElements());
	if(f) {
		truervec.Resize(coarse->NElements());
		truervec.Fill(0.,0);
	}
	ervec.Fill(0.,0);
	TPZCompEl *cel;
	TPZAdmChunkVector<TPZCompEl *> &elementvec = fine->ElementVec();
	int numel = elementvec.NElements();
	int el;
	for(el=0; el<numel; el++) {
		cel = elementvec[el];
		if (!cel) continue;
		TPZInterpolatedElement *cint = dynamic_cast<TPZInterpolatedElement *> (cel);
		if(!cint) continue;
		int ncon = cint->NConnects();
		TPZGeoElSide gelside(cint->Reference(),ncon-1);
		if(gelside.Dimension() != dim) continue;
		TPZGeoElSide gellarge(gelside);
		while(!gellarge.Reference().Exists() && gellarge.Father2().Exists()) gellarge = gellarge.Father2();
		if(!gellarge.Reference().Exists()) {
			cout << "TPZMGAnalsysis::BuildTransferMatrix element " << el << " found no corresponding element\n";
			continue;
		}
		TPZCompElSide cellargeside = gellarge.Reference();
		TPZCompEl *cellarge = cellargeside.Element();
		TPZInterpolatedElement *cintlarge = (TPZInterpolatedElement *) cellarge;
		TPZTransform transform(gelside.Dimension(),gellarge.Dimension());
		gelside.SideTransform3(gellarge,transform);
		int index = cellarge->Index();
		REAL truerror = 0.;
		ervec[index] += ElementError(cint,cintlarge,transform,f,truerror);
		if(f) truervec[index]  += truerror;
	}
}
예제 #18
0
	void TPZRefLinear::Divide(TPZGeoEl *geo,TPZVec<TPZGeoEl *> &SubElVec) {
		
		int i;
		if(geo->HasSubElement()) {
			SubElVec.Resize(NSubEl);
			for(i=0;i<NSubEl;i++) SubElVec[i] = geo->SubElement(i);
			return;//If exist fSubEl return this sons
		}
		int j,sub,matid=geo->MaterialId(),index;
		int np[TPZShapeLinear::NSides];//guarda conectividades dos 8 subelementos
		
		for(j=0;j<TPZShapeLinear::NCornerNodes;j++) np[j] = geo->NodeIndex(j);
		for(sub=TPZShapeLinear::NCornerNodes;sub<TPZShapeLinear::NSides;sub++) {
			NewMidSideNode(geo,sub,index);
			np[sub] = index;
		}
		// creating new subelements
		for(i=0;i<TPZShapeLinear::NCornerNodes;i++) {
			TPZManVector<int> cornerindexes(TPZShapeLinear::NCornerNodes);
			for(int j=0;j<TPZShapeLinear::NCornerNodes;j++) cornerindexes[j] = np[CornerSons[i][j]];
			int index;
			TPZGeoEl *subel = geo->Mesh()->CreateGeoElement(EOned,cornerindexes,matid,index);
			geo->SetSubElement(i , subel);
		}
		
		SubElVec.Resize(NSubEl);
		for(sub=0;sub<NSubEl;sub++) {
			SubElVec[sub] = geo->SubElement(sub);
			SubElVec[sub]->SetFather(geo);
			SubElVec[sub]->SetFather(geo->Index());
		}
		for(i=0;i<NSubEl;i++) {//conectividades entre os filhos : viz interna
			for(j=0;j<1;j++) {        //lado do subel                                          numero do filho viz.             lado do viz.
				geo->SubElement(i)->SetNeighbour(InNeigh[i][j][0],TPZGeoElSide(geo->SubElement(InNeigh[i][j][1]),InNeigh[i][j][2]));
			}
		}
		
		geo->SetSubElementConnectivities();
		
	}
예제 #19
0
void TPZCheckGeom::CreateMesh() {
	
	if(fMesh) delete fMesh;
	fMesh = new TPZGeoMesh();
	int noind[12];
	int no;
	for(no=0; no<12; no++) {
		noind[no] = fMesh->NodeVec().AllocateNewElement();
		TPZVec<REAL> coord(3);
		coord[0] = nodeco[no][0];
		coord[1] = nodeco[no][1];
		coord[2] = nodeco[no][2];
		fMesh->NodeVec()[noind[no]].Initialize(coord,*fMesh);
	}
	int matid = 1;
	TPZVec<int> nodeindex;
	int nel;
	for(nel=0; nel<7; nel++) {
		int in;
		nodeindex.Resize(numnos[nel]);
		for(in=0; in<numnos[nel]; in++) {
			nodeindex[in] = nodind[nel][in];
		}
		int index;  
		switch(nel) {
			case 0:
				fMesh->CreateGeoElement(ECube, nodeindex, matid, index);
				break;
			case 1:
				fMesh->CreateGeoElement(EPiramide, nodeindex,matid, index);
				break;
			case 2:
				fMesh->CreateGeoElement(ETetraedro, nodeindex,matid, index);
				break;
			case 3:
				fMesh->CreateGeoElement(EPrisma, nodeindex,matid, index);
				break;
			case 4:
				fMesh->CreateGeoElement(EOned, nodeindex,matid, index);
				break;
			case 5:
				fMesh->CreateGeoElement(EQuadrilateral, nodeindex,matid, index);
				break;
			case 6:
				fMesh->CreateGeoElement(ETriangle, nodeindex,matid, index);
				break;
			default:
				break;
		}
	}
	fMesh->BuildConnectivity();
}
예제 #20
0
void TPZMetis::Resequence(TPZVec<int> &perm, TPZVec<int> &inverseperm){
	TPZVec<int> nodegraph(0),nodegraphindex(0);
	ConvertGraph(fElementGraph,fElementGraphIndex,nodegraph,nodegraphindex);
	int numelnodegraph = nodegraphindex[fNNodes];
	if (numelnodegraph == nodegraph.NElements() )
	{
		nodegraph.Resize(numelnodegraph+1);
	}
	int nod;
	for (nod = numelnodegraph; nod>0; nod--) nodegraph[nod] = nodegraph[nod-1];
	perm.Resize(fNNodes);
	inverseperm.Resize(fNNodes);
	for(nod=0;nod<fNNodes;nod++) 
	{
		perm[nod] = inverseperm[nod] = nod;
	}
	
#ifdef USING_METIS
	int numflag = 0;
	int options = 0;
	METIS_NodeND(&fNNodes,&nodegraphindex[0],&nodegraph[1],&numflag,&options,&perm[0],&inverseperm[0]);
#endif
}
예제 #21
0
void TPZSkylMatrix<TVar>::InitializeElem(const TPZVec<int> &skyline, TPZManVector<REAL> &storage, TPZVec<REAL *> &point) {
	int dim = skyline.NElements();
	int nel = NumElements(skyline);
	storage.Resize(nel);
	storage.Fill(0.);
	int i;
	point.Resize(dim+1);
	if(dim) {
		point[0] = &storage[0];
		point[dim] = &storage[0]+nel;
	} else {
		point[0] = 0;
	}
	for(i=1; i<dim+1; i++) point[i] = point[i-1]+(i-1)-skyline[i-1]+1;
}
예제 #22
0
void TPZEulerConsLawDEP::Flux(TPZVec<REAL> &U,TPZVec<REAL> &Fx,TPZVec<REAL> &Fy,TPZVec<REAL> &Fz) {
	
	REAL press = Pressure(U);
	int nstate = NStateVariables();
	if(nstate < 3 && nstate > 5){
		cout << "TPZEulerConsLawDEP::Flux case not implemented\n";
		Fx.Resize(0);
		Fy.Resize(0);
		Fz.Resize(0);
		exit(-1);
	}
	
	Fx.Resize(5,0.0);//v�ido
	Fy.Resize(5,0.0);//para
	Fz.Resize(5,0.0);//R , R , R
	
	if(nstate == 5){
		Fx[0] = U[1];//ro u
		Fx[1] = (U[1]/U[0])*U[1] + press;//ro u2 + p
		Fx[2] = U[1]*(U[2]/U[0]);//ro u v
		Fx[3] = U[1]*(U[3]/U[0]);//ro u w
		Fx[4] = (U[4]+press)*(U[1]/U[0]);//(ro e + p) u
		
		Fy[0] = U[2];//ro v
		Fy[1] = U[2]*(U[1]/U[0]);//ro v u
		Fy[2] = (U[2]/U[0])*U[2] + press;//ro v2 + p
		Fy[3] = U[2]*(U[3]/U[0]);//ro v w
		Fy[4] = (U[4] + press)*(U[2]/U[0]);//(ro e + p) v
		
		Fz[0] = U[3];//ro w
		Fz[1] = U[3]*(U[1]/U[0]);//ro w u
		Fz[2] = U[3]*(U[2]/U[0]);//ro w v
		Fz[3] = (U[2]/U[0])*U[2] + press;//ro w2 + p  
		Fz[4] = (U[4] + press)*(U[2]/U[0]);//(ro e + p) w
		return;
	}
	
	if(nstate == 4){
		Fx[0] = U[1];//ro u
		Fx[1] = U[1]*U[1] / U[0] + press;//ro u2 + p
		Fx[2] = U[1]*U[2] / U[0];//ro u v
		Fx[3] = (U[3]+press)*U[1] / U[0];//(E + p) u
		
		Fy[0] = U[2];//ro v
		Fy[1] = U[1]*U[2] / U[0];//ro u v
		Fy[2] = U[2]*U[2] / U[0] + press;//ro v2 + p
		Fy[3] = (U[3] + press)*U[2] / U[0];//(E + p) v
		return;
	}
	
	if(nstate == 3){
		Fx[0] = U[1];//ro u
		Fx[1] = (U[1]/U[0])*U[1] + press;//ro u2 + p
		Fx[2] = (U[2]+press)*(U[1]/U[0]);//(ro e + p) u
	}
}
예제 #23
0
void EstadoAd(const TPZVec<REAL> &loc, TPZVec<STATE> &u, TPZFMatrix<STATE> &du){
    
    const REAL x = loc[0];
    const REAL y = loc[1];
    u.Resize(1, 0.);
    du.Resize(3, 1.);
    du(0,0)=du(1,0)=du(2,0)=0.;
    
	//const REAL alpha=0.001;
    
    const REAL sol = 10.*x*y*(1-x)*(1-y);
    u[0] = sol;
    
    
}
예제 #24
0
void TPZSkylMatrix<TVar>::ComputeMaxSkyline(const TPZSkylMatrix<TVar> &first, const TPZSkylMatrix<TVar> &second, TPZVec<int> &res) {
	
	if (first.Rows() != second.Rows()) {
		cout<<"ComputeMaxSkyline : incompatible dimension";
		return;
	}
	int i, dim = first.Rows();
	res.Resize(dim+1);
	
	for(i=1; i<dim+1; i++) {
		
		int aux = ( first.Size(i) > second.Size(i) ) ? first.Size(i) : second.Size(i);
		res[i] = i-aux-1;
	}
}
예제 #25
0
파일: pzartdiff.cpp 프로젝트: labmec/neopz
void TPZArtDiff::ODotOperator(TPZVec<REAL> &dphi, TPZVec<TPZVec<T> > &TauDiv, TPZVec<T> &Result){
	
	int dim = TauDiv.NElements();
	int size = dphi.NElements();
	int neq = TauDiv[0].NElements();
	if(size<1 || size>3){
		PZError << "TPZArtDiff::PointOperator: error data size";
	}
	
	Result.Resize(neq);
	Result.Fill(REAL(0.));
	
	int i, k;
	for(k=0;k<dim;k++)
		for(i=0;i<neq;i++)Result[i] += TauDiv[k][i] * dphi[k];
}
예제 #26
0
void TPZTracerFlow::Solution(TPZVec<TPZMaterialData> &datavec, int var, TPZVec<STATE> &Solout){
	
	Solout.Resize(this->NSolutionVariables(var));
    
    TPZVec<STATE> ExactSol(1);
    TPZFMatrix<STATE> deriv(3,1);
    ExactSol.Resize(1, 0.);
    
    if(var == 1){ //function (state variable Q)
		Solout[0] = datavec[1].sol[0][0];
        Solout[1] = datavec[1].sol[0][1];
		return;
	}
    
    if(var == 2){
		Solout[0] = datavec[2].sol[0][0];//function (state variable p)
		return;
	}
    
	if(var == 3){
		Solout[0] = datavec[0].sol[0][0];//function (state variable S)
		return;
	}
    
	if(var == 4) {
		int id;
		for(id=0 ; id<fDim; id++) {
            fConvDir[id] = datavec[1].sol[0][id];
			Solout[id] = fConvDir[id]*datavec[0].sol[0][0];//function (state variable Q*S)
		}
		return;
	}
    
    if(var==5){
        Solout[0]=datavec[1].dsol[0](0,0)+datavec[1].dsol[0](1,1);
        return;
    }
    
    if(var == 6){
		fForcingFunctionExact->Execute(datavec[0].x, ExactSol, deriv);
		Solout[0] = ExactSol[0];
		return;
	}

}
예제 #27
0
void TPZYCCamClayPV::DDistanceToSurface(const TPZVec<STATE> &sigma_trial_pv, const STATE theta, const STATE beta, const REAL a, const REAL aPrev, TPZVec<STATE> &fxn) const {
    const STATE stheta = sin(theta);
    const STATE ctheta = cos(theta);
    const STATE sbeta = sin(beta);
    const STATE cbeta = cos(beta);
    const REAL sqrt2_sqrt3 = sqrt(2. / 3.);
    const REAL sqrt3_3 = sqrt(3.) / 3;
    const STATE b = bFromTheta(theta);
    TPZVec<STATE> ptcart(3);
    TPZHWTools::FromPrincipalToHWCart(sigma_trial_pv, ptcart);
    const STATE sig1 = ptcart[0];
    const STATE sig2 = ptcart[1];
    const STATE sig3 = ptcart[2];
    fxn.Resize(3);
    fxn[0] = 2. * a * b * stheta / fER.K()*(-sqrt3_3 * sig1 + fPt - a * (1 + b * ctheta)) + a * fM * sqrt2_sqrt3 * ctheta * (-sig2 * cbeta - sig3 * sbeta + a * fM * sqrt2_sqrt3 * stheta) / fER.G();
    fxn[1] = a * fM * sqrt2_sqrt3 * stheta * (sbeta * sig2 - cbeta * sig3) / fER.G();
    fxn[2] = ResLFunc(sigma_trial_pv, theta, beta, a, aPrev);
}
예제 #28
0
TPZConsLawTest::TPZConsLawTest(int nummat, TPZVec<REAL> B,int artdiff,REAL delta_t,int dim,REAL delta,int test) : TPZConservationLaw(nummat,delta_t,dim), fXf(1,1,0.), fB(dim)  {
	
	if(artdiff<0 || artdiff>3){
		PZError << "TPZConsLawTest::TPZConsLawTest artificial diffusion parameter, default 1\n";
		artdiff = 1;
	}
	if(B.NElements() != dim){
		PZError << "TPZConsLawTest::TPZConsLawTest error in dimension of B, default dimension " << dim << endl;
		B.Resize(dim);
		int i;
		for(i=0;i<dim;i++) B[i] = 0.;
		B[dim-1] = 1.0;
	}
	int i;
	for(i=0;i<dim;i++) fB[i] = B[i];
	fArtificialDiffusion = artdiff;//SUPG, SL or Bornhauss
	fDelta = delta;
	fTest = test;
}
예제 #29
0
파일: pzartdiff.cpp 프로젝트: labmec/neopz
void TPZArtDiff::Divergent(TPZFMatrix<STATE> &dsol,
						   TPZFMatrix<REAL> & dphi,
						   TPZVec<TPZDiffMatrix<STATE> > & Ai,
						   TPZVec<STATE> & Div,
						   TPZDiffMatrix<STATE> * dDiv)
{
	int nstate = Ai[0].Cols();
	int dim = nstate - 2;
	int nshape = dphi.Cols();
	Div.Resize(nstate);
	Div.Fill(0.);
	
	int i, j, k;
	
	// computing the divergent:
	// A.du/dx + B.du/dy + C.du/dz
	for(k=0;k<dim;k++)
		for(i=0;i<nstate; i++)
			for(j=0;j<nstate;j++)
			{
				Div[i]+=Ai[k](i,j)*dsol(k,j);
			}
	
	if(!dDiv)return;
	// computing an approximation to the divergent derivative:
	
	// dDiv/dUj ~= A.d2U/dUidx + B.d2U/dUidy + C.d2U/dUidz
	dDiv->Redim(nstate, nstate * nshape);
	int l;
	REAL buff;
	for(l=0;l<nshape;l++)
		for(j=0;j<nstate;j++)
			for(i=0;i<nstate; i++)
			{
				buff =0.;
				for(k=0;k<dim;k++)
				{
					buff+=Ai[k](i,j)*dphi(k,l);
				}
				dDiv->operator()(i,j+l*nstate)=buff;
			}
	
}
예제 #30
0
파일: tpzpoint.cpp 프로젝트: labmec/neopz
    void TPZPoint::ParametricDomainNodeCoord(int node, TPZVec<REAL> &nodeCoord)
    {

        if(node > NCornerNodes)
        {
            DebugStop();
        }
        nodeCoord.Resize(Dimension, 0.);
        switch (node) {
            case (0):
            {
                return;
                break;
            }
            default:
            {
                DebugStop();
                break;
            }
        }
    }