示例#1
0
TPZIntelGen<TSHAPE>::TPZIntelGen(TPZCompMesh &mesh, TPZGeoEl *gel, int &index) :
TPZInterpolatedElement(mesh,gel,index) {
	int i;
	fPreferredOrder = mesh.GetDefaultOrder();
	for(i=0;i<TSHAPE::NSides-TSHAPE::NCornerNodes;i++) {
		//    fSideOrder[i] = gOrder;
	}
	for(i=0; i<TSHAPE::NSides; i++) fConnectIndexes[i]=-1;
	//  RemoveSideRestraintsII(EInsert);
	gel->SetReference(this);
	for(i=0;i<TSHAPE::NCornerNodes;i++) {
		fConnectIndexes[i] = CreateMidSideConnect(i);
		mesh.ConnectVec()[fConnectIndexes[i]].IncrementElConnected();
	}
	for(;i<TSHAPE::NSides;i++) {
		fConnectIndexes[i] = CreateMidSideConnect(i);
		mesh.ConnectVec()[fConnectIndexes[i]].IncrementElConnected();
		IdentifySideOrder(i);
	}
	
	int sideorder = SideOrder(TSHAPE::NSides-1);
	sideorder = 2*sideorder;
	if (sideorder > fIntRule.GetMaxOrder()) sideorder = fIntRule.GetMaxOrder();
	//  TPZManVector<int,3> order(3,2*sideorder+2);
	TPZManVector<int,3> order(3,sideorder);
	//TPZManVector<int,3> order(3,20);
	fIntRule.SetOrder(order);
	
}
示例#2
0
///Funcao principal do programa
int main(int argc, char *argv[])
{
    int dim = 2;//dimensao do problema
    int uNDiv=3,
    vNDiv=4;//numero de divisoes feitas no dominio
	int nel = uNDiv*vNDiv; //numero de elementos a serem utilizados
    int pOrder = 4; //ordem polinomial de aproximacao
	TPZGeoMesh *gmesh = CreateGMesh(nel, uNDiv, vNDiv); //funcao para criar a malha geometrica
	
	TPZCompMesh *cmesh = CMesh(gmesh, pOrder); //funcao para criar a malha computacional

	// Resolvendo o Sistema
    bool optimizeBandwidth = false; //impede a renumeracao das equacoes do problema(para obter o mesmo resultado do Oden)
	TPZAnalysis an(cmesh, optimizeBandwidth); //cria objeto de analise que gerenciaria a analise do problema
	an.Run();//assembla a matriz de rigidez (e o vetor de carga) global e inverte o sistema de equacoes
    
	TPZFMatrix<STATE> solucao=cmesh->Solution();//Pegando o vetor de solucao, alphaj
	solucao.Print("Sol",cout,EMathematicaInput);//imprime na formatacao do Mathematica
	
    //fazendo pos processamento para paraview
    TPZStack<string> scalnames, vecnames;
    scalnames.Push("State");//setando para imprimir u
    string plotfile = "ModelProblemSol.vtk";//arquivo de saida que estara na pasta debug
    an.DefineGraphMesh(dim, scalnames, vecnames, plotfile);//define malha grafica
	int postProcessResolution = 3;//define resolucao do pos processamento
    an.PostProcess(postProcessResolution);//realiza pos processamento
    
	std::cout << "FINISHED!" << std::endl;
	
	return 0;
}
示例#3
0
文件: main.cpp 项目: labmec/neopz
TPZCompMesh *TetraMesh(){
  REAL Coord [8][3] = {
    {0.,0.,0.},{1.,0.,0.},{1.,1.,0.},{0.,1.,0.},
    {0.,0.,1.},{1.,0.,1.},{1.,1.,1.},{0.,1.,1.}
  };

  int Connects [5][4] = {
    {0,1,3,4},
    {1,2,3,6},
    {5,6,4,1},
    {7,6,4,3},
    {1,3,4,6}
  };

  int i,j;
  TPZGeoMesh *gmesh = new TPZGeoMesh();
  TPZGeoEl * elvec[5];
  TPZVec <REAL> coord (3,0.);
  int index;
  //Nodes initialization
  for(i = 0; i < 8; i++){
    for(j=0;j<3;j++){
      coord[j] = Coord[i][j];
    }
    index = gmesh->NodeVec().AllocateNewElement();
    gmesh->NodeVec()[index] = TPZGeoNode(i,coord,*gmesh);
  }

  TPZVec<TPZRefPattern *> refinement_Patterns(6,0);
//  refinement_Patterns.Resize(6);
  refinement_Patterns[0] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_4.rpt");
  refinement_Patterns[1] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_5.rpt");
  refinement_Patterns[2] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_6.rpt");
  refinement_Patterns[3] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_7.rpt");
  refinement_Patterns[4] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_8.rpt");
  refinement_Patterns[5] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Rib_Side_9.rpt");

  for (i=0;i<6;i++) gmesh->InsertRefPattern(refinement_Patterns[i]);

  for (i=0;i<5;i++){
    int ncon = 4;
    TPZVec <int> connect(ncon,0);
    for(j=0; j<ncon;j++){
      connect[j] = Connects[i][j];
    }
    elvec[i] = GeoElementRefPattern(gmesh,7,connect,1,i,refinement_Patterns);
  }
  //Generate neighborhod information
//  gmesh->Print(cout);
  gmesh->BuildConnectivity();
//  gmesh->Print(cout);
  //Create computational mesh
  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
  TPZMaterial *mat;
  mat = new TPZMaterialTest3D (1);
  cmesh->InsertMaterialObject(mat);

  cmesh->AutoBuild();
  return cmesh;
}
示例#4
0
/**
 * @brief transform in low order Raviar Tomas
 */
void TPZCreateApproximationSpace::UndoMakeRaviartTomas(TPZCompMesh &cmesh)
{
    int numcell = cmesh.NElements();
    int el;
    for (el = 0; el<numcell ; el++) {
        TPZCompEl *cel = cmesh.ElementVec()[el];
        TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
        if (!intel) {
            continue;
        }
        TPZGeoEl *gel = intel->Reference();
        int geldim = gel->Dimension();
        int is;
        int nsides = gel->NSides();
        for (is=0; is<nsides; is++) {
            if (gel->SideDimension(is) != geldim-1) {
                continue;
            }
            int nsconnects = intel->NSideConnects(is);
            // only interested in HDiv elements
            if (nsconnects != 1) {
                continue;
            }
//            int cindex = intel->SideConnectIndex(0, is);
            TPZConnect &c = intel->Connect(intel->SideConnectLocId(0,is));
            if (c.HasDependency()) {
                c.RemoveDepend();
            }
        }
    }
    cmesh.ExpandSolution();
    cmesh.CleanUpUnconnectedNodes();
}
示例#5
0
TPZCompMesh * ComputationalMesh(TPZGeoMesh * gmesh, int p)
{
    int matid = 1;
    int dim = 2;
    REAL wavespeed = 1.0;

    ///Computational Mesh
    TPZCompEl::SetgOrder(p);
    TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
    cmesh->SetDimModel(dim);    
    cmesh->SetAllCreateFunctionsContinuous();
    
    TPZMaterial * Air = new TPZLinearWave(matid,dim);
    cmesh->InsertMaterialObject(Air);
    
    {
        //Boundary Conditions
        TPZFMatrix<STATE> k1(dim,dim,0.), k2(dim,dim,0.);
        TPZMaterial * BCD = Air->CreateBC(Air, 2, 0, k1, k2);
        cmesh->InsertMaterialObject(BCD);
        
        TPZMaterial * BCN = Air->CreateBC(Air, 3, 1, k1, k2);
        cmesh->InsertMaterialObject(BCN);
    }   
        
    cmesh->AutoBuild();
    cmesh->AdjustBoundaryElements();
    cmesh->CleanUpUnconnectedNodes();    
    
    return cmesh;
}
示例#6
0
TPZCompMesh *CompMesh1D(TPZGeoMesh *gmesh,int p, TPZMaterial *material,TPZVec<int> &bc,TPZVec<int> &bcType) {
	if(!material || bc.NElements()<2 || bcType.NElements() != bc.NElements()) return NULL;
	int dim = 1;
	
	
	TPZAutoPointer<TPZMaterial> mat(material);
	
	// related to interpolation space
	TPZCompEl::SetgOrder(p);
	TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
	cmesh->SetDimModel(dim);
	cmesh->SetAllCreateFunctionsContinuous();
	cmesh->InsertMaterialObject(mat);
	
	// Related to boundary conditions
	//	REAL uN=1-cosh(1.)/sinh(1.);
	TPZFMatrix<STATE> val1(1,1,0.), val2(1,1,0.);
	if(!bcType[0])  // dirichlet
		val2.PutVal(0,0,0.0);
	TPZAutoPointer<TPZMaterial> BCond1 = material->CreateBC(mat, bc[0],bcType[0], val1, val2);
	cmesh->InsertMaterialObject(BCond1);
	
	if(!bcType[1])  // dirichlet
		val2.PutVal(0,0,0.0);
	TPZAutoPointer<TPZMaterial> BCond2 = material->CreateBC(mat, bc[1],bcType[1], val1, val2);
	cmesh->InsertMaterialObject(BCond2);
	
	//Adjusting data
	cmesh->AutoBuild();
	cmesh->AdjustBoundaryElements(); 
	cmesh->CleanUpUnconnectedNodes();
	
	return cmesh;
}
示例#7
0
/**
 * @brief Undo the encapsulate elements
 */
void TPZCreateApproximationSpace::UndoCondenseLocalEquations(TPZCompMesh &cmesh)
{
    int nel = cmesh.NElements();
    int iel;
    for (iel=0; iel<nel; iel++) {
        TPZCompEl *cel = cmesh.ElementVec()[iel];
        TPZCondensedCompEl *condel = dynamic_cast<TPZCondensedCompEl *>(cel);
        if(!condel) {
            continue;
        }
        condel->Unwrap();
    }    
}
示例#8
0
/**
 * @brief Encapsulate the elements in condensed computational elements
 */
void TPZCreateApproximationSpace::CondenseLocalEquations(TPZCompMesh &cmesh)
{
    int nel = cmesh.NElements();
    int iel;
    for (iel=0; iel<nel; iel++) {
        TPZCompEl *cel = cmesh.ElementVec()[iel];
        if(!cel) {
            continue;
        }
        new TPZCondensedCompEl(cel);
    }

}
示例#9
0
TPZCompMesh *MeshH1(TPZGeoMesh *gmesh, int pOrder, int dim,bool hasbc)
{
    /// criar materiais
    dim = 2;
    TPZMatPoisson3d *material = new TPZMatPoisson3d( MatId,  dim);
    material->NStateVariables();
	
    TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
    cmesh->SetDimModel(dim);
    TPZMaterial * mat(material);
    cmesh->InsertMaterialObject(mat);
	
    ///Inserir condicao de contorno
    if(hasbc){
    TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.);
	
        TPZMaterial * BCond0 = material->CreateBC(mat, bc0,dirichlet, val1, val2);
        TPZMaterial * BCond1 = material->CreateBC(mat, bc1,dirichlet, val1, val2);
        TPZMaterial * BCond2 = material->CreateBC(mat, bc2,dirichlet, val1, val2);
        TPZMaterial * BCond3 = material->CreateBC(mat, bc3,dirichlet, val1, val2);
	
        cmesh->InsertMaterialObject(BCond0);
        cmesh->InsertMaterialObject(BCond1);
        cmesh->InsertMaterialObject(BCond2);
        cmesh->InsertMaterialObject(BCond3);
    }
    
    //solucao exata
//    TPZAutoPointer<TPZFunction<STATE> > solexata;
//    solexata = new TPZDummyFunction<STATE>(EstadoAd);
//    material->SetForcingFunctionExact(solexata);
//
//    //funcao do lado direito da equacao do problema
//    TPZAutoPointer<TPZFunction<STATE> > force;
//    TPZDummyFunction<STATE> *dum;
//    
//    dum = new TPZDummyFunction<STATE>(ForcingOpt);
//    dum->SetPolynomialOrder(20);
//    force = dum;
//    material->SetForcingFunction(force);
	
    
    cmesh->SetDefaultOrder(pOrder);
    cmesh->SetDimModel(dim);
	
	
    cmesh->SetAllCreateFunctionsContinuous();
    
    //Ajuste da estrutura de dados computacional
    cmesh->AutoBuild();
    
    
    return cmesh;
    
}
示例#10
0
TPZCompElHDivFull<TSHAPE>::TPZCompElHDivFull(TPZCompMesh &mesh, TPZGeoEl *gel, int64_t &index) :
TPZRegisterClassId(&TPZCompElHDivFull::ClassId),
TPZCompElHDiv<TSHAPE>(mesh,gel,index) {
	
	int i;
	int nconflux= TPZCompElHDiv<TSHAPE>::NConnects();
    this->fConnectIndexes.Resize(nconflux);
	gel->SetReference(this);
	
	for(i=0;i< nconflux;i++)
	{
        int sideaux= i + TSHAPE::NCornerNodes;
		this->fConnectIndexes[i] = this->CreateMidSideConnect(sideaux);
#ifdef LOG4CXX
        if (logger->isDebugEnabled())
        {
            std::stringstream sout;
            sout << "After creating last flux connect " << i << std::endl;
            //	this->Print(sout);
            LOGPZ_DEBUG(logger,sout.str())
        }
#endif
        
		mesh.ConnectVec()[this->fConnectIndexes[i]].IncrementElConnected();
		this->IdentifySideOrder(sideaux);
    }	
示例#11
0
void TPZBndCond::Read(TPZStream &buf, void *context)
{
    TPZMaterial::Read(buf, context);
    buf.Read(&fType, 1);
    fBCVal1.Read(buf, 0);
    fBCVal2.Read(buf, 0);
    int MatId;
    buf.Read(&MatId,1);
    TPZCompMesh * pCM = (TPZCompMesh * )/*dynamic_cast<TPZCompMesh *>*/(context);
    fMaterial = pCM->FindMaterial(MatId);
    if(!fMaterial)
    {
        std::cout << " reading a boundary condition without material object!!\n";
#ifdef LOG4CXX
        LOGPZ_FATAL(logger,"reading a boundary condition without material object!!");
#endif
    }
}
示例#12
0
TPZCompMesh *CMesh(TPZGeoMesh *gmesh, int pOrder)
{
	const int dim = 2; //dimensao do problema
	const int matId = 1, bc0 = -1, bc1 = -2, bc2=-3, bc3=-4; //MESMOS ids da malha geometrica
    const int dirichlet = 0, neumann = 1;
//    const int mixed = 2; //tipo da condicao de contorno do problema ->default dirichlet na esquerda e na direita
	
    
	///criar malha computacional
	TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
	cmesh->SetDefaultOrder(pOrder);//seta ordem polimonial de aproximacao
	cmesh->SetDimModel(dim);//seta dimensao do modelo
	
    // Criando material
    TPZMatExSimples2D *material = new TPZMatExSimples2D(matId);//criando material que implementa a formulacao fraca do problema modelo
    
	// Inserindo material na malha
	cmesh->InsertMaterialObject(material);
		
	///Inserir condicao de contorno esquerda
	TPZFMatrix<STATE> val1(1,1,0.), val2(1,1,0.);
	TPZMaterial * BCond0 = material->CreateBC(material, bc0, neumann, val1, val2);//cria material que implementa a condicao de contorno da esquerda
	
    cmesh->InsertMaterialObject(BCond0);//insere material na malha
    
	// Condicao de contorno da direita
	TPZMaterial * BCond1 = material->CreateBC(material, bc1, neumann, val1, val2);//cria material que implementa a condicao de contorno da direita
    
    cmesh->InsertMaterialObject(BCond1);//insere material na malha
    
    val2(0,0) = 1.0;//potencial na placa inferior
    // Condicao de contorno da placa inferior
    TPZMaterial * BCond2 = material->CreateBC(material, bc2, dirichlet, val1, val2);//cria material que implementa a condicao de contorno da placa inferior
    
    cmesh->InsertMaterialObject(BCond2);//insere material na malha
    
    val2(0,0) = 1.5;//potencial na placa superior
    // Condicao de contorno da placa superior
    TPZMaterial * BCond3 = material->CreateBC(material, bc3, dirichlet, val1, val2);//cria material que implementa a condicao de contorno da placa superior
	
    cmesh->InsertMaterialObject(BCond3);//insere material na malha
	
	//Cria elementos computacionais que gerenciarao o espaco de aproximacao da malha
	cmesh->AutoBuild();
	
	return cmesh;
	
}
示例#13
0
TPZCompMesh  *TPZMGAnalysis::UniformlyRefineMesh(TPZCompMesh *mesh, bool withP) {
	
	TPZGeoMesh *gmesh = mesh->Reference();
	if(!gmesh) {
		cout << "TPZMGAnalysis::UniformlyRefineMesh encountered no geometric mesh\n";
		return 0;
	}
	gmesh->ResetReference();
	TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
	mesh->CopyMaterials(*cmesh);
	TPZAdmChunkVector<TPZCompEl *> &elementvec = mesh->ElementVec();
	int el,nelem = elementvec.NElements();
	for(el=0; el<nelem; el++) {
		TPZCompEl *cel = elementvec[el];
		if(!cel) continue;
		TPZInterpolatedElement *cint = dynamic_cast<TPZInterpolatedElement *> (cel);
		if(!cint) {
			cout << "TPZMGAnalysis::UniformlyRefineMesh encountered a non interpolated element\n";
			continue;
		}
		int ncon = cint->NConnects();
		int porder = cint->PreferredSideOrder(ncon-1);
		
		TPZGeoEl *gel = cint->Reference();
		if(!gel) {
			cout << "TPZMGAnalysis::UniformlyRefineMesh encountered an element without geometric reference\n";
			continue;
		}
		TPZVec<TPZGeoEl *> sub;
		gel->Divide(sub);
		int nsub = sub.NElements();
		int isub;
		int celindex;
		for(isub=0; isub<nsub; isub++) {
			TPZInterpolatedElement *csint;
			csint = (TPZInterpolatedElement *) cmesh->CreateCompEl(sub[isub],celindex);
			if(withP) csint->PRefine(porder+1);
			else csint->PRefine(porder);
		}
	}
	return cmesh;
}
示例#14
0
/**
 * @brief transform in low order Raviar Tomas
 */
void TPZCreateApproximationSpace::MakeRaviartTomas(TPZCompMesh &cmesh)
{
    int numcell = cmesh.NElements();
    int el;
    for (el = 0; el<numcell ; el++) {
        TPZCompEl *cel = cmesh.ElementVec()[el];
        TPZInterpolationSpace *intel = dynamic_cast<TPZInterpolationSpace *>(cel);
        if (!intel) {
            continue;
        }
        intel->SetPreferredOrder(1);
    }
    cmesh.ExpandSolution();
    for (el = 0; el<numcell ; el++) {
        TPZCompEl *cel = cmesh.ElementVec()[el];
        TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
        if (!intel) {
            continue;
        }
        TPZGeoEl *gel = intel->Reference();
        int geldim = gel->Dimension();
        int is;
        int nsides = gel->NSides();
        for (is=0; is<nsides; is++) {
            if (gel->SideDimension(is) != geldim-1) {
                continue;
            }
            int nsconnects = intel->NSideConnects(is);
            // only interested in HDiv elements
            if (nsconnects != 1) {
                continue;
            }
            int cindex = intel->SideConnectIndex(0, is);
            TPZConnect &c = intel->Connect(intel->SideConnectLocId(0,is));
            if (c.HasDependency()) {
                continue;
            }
            int nshape = 1;
            int nstate = 1;
            int order = 0;
            int cindex2 = cmesh.AllocateNewConnect(nshape, nstate, order);
//            TPZConnect &c2 = cmesh.ConnectVec()[cindex];
            TPZFNMatrix<2> depmat(2,1,1.);
            c.AddDependency(cindex, cindex2, depmat, 0, 0, 2, 1);
        }
    }
    cmesh.ExpandSolution();
}
示例#15
0
TPZCompMesh *L2ProjectionP(TPZGeoMesh *gmesh, int pOrder, TPZVec<STATE> &solini)
{
    /// criar materiais
    int dim = 2;
    TPZL2Projection *material;
    material = new TPZL2Projection(1, dim, 1, solini, pOrder);
    
    TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
    cmesh->SetDimModel(dim);
    TPZMaterial * mat(material);
    cmesh->InsertMaterialObject(mat);
    TPZAutoPointer<TPZFunction<STATE> > forcef = new TPZDummyFunction<STATE>(InitialPressure);
    material->SetForcingFunction(forcef);
    cmesh->SetAllCreateFunctionsContinuous();
    cmesh->SetDefaultOrder(pOrder);
    cmesh->SetDimModel(dim);
    cmesh->AutoBuild();
    
    
    return cmesh;
    
}
示例#16
0
文件: main.cpp 项目: labmec/neopz
void InsertMaterialObjects(TPZCompMesh &cmesh)
{
	/// criar materiais
	int dim = cmesh.Dimension();
    
    TPZMatLaplacianLagrange *materialcoarse = new TPZMatLaplacianLagrange(matcoarsemesh,dim);
//    TPZAutoPointer<TPZFunction<REAL> > forcef = new TPZDummyFunction<REAL>(ForceSuave);
//    materialcoarse->SetForcingFunction(forcef);
    
	TPZMaterial * mat1(materialcoarse);
    
	cmesh.InsertMaterialObject(mat1);
	
	///Inserir condicao de contorno
	TPZFMatrix<STATE> val1(2,2,1.), val2(2,1,0.);
	
    //BC -1
    TPZMaterial * BCondD1 = materialcoarse->CreateBC(mat1, bc1,dirichlet, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet1 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD1->SetForcingFunction(bcmatDirichlet1);
    cmesh.InsertMaterialObject(BCondD1);
    
    //BC -2
	TPZMaterial * BCondD2 = materialcoarse->CreateBC(mat1, bc2,dirichlet, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet2 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD2->SetForcingFunction(bcmatDirichlet2);
    cmesh.InsertMaterialObject(BCondD2);
    
    //BC -3
	TPZMaterial * BCondD3 = materialcoarse->CreateBC(mat1, bc3,dirichlet, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet3 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD3->SetForcingFunction(bcmatDirichlet3);
    cmesh.InsertMaterialObject(BCondD3);
    
    //BC -4
	TPZMaterial * BCondD4 = materialcoarse->CreateBC(mat1, bc4,dirichlet, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet4 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD4->SetForcingFunction(bcmatDirichlet4);
    cmesh.InsertMaterialObject(BCondD4);
}
示例#17
0
文件: Main.cpp 项目: labmec/neopz
TPZCompMesh * ComputationalElasticityMesh3D(TPZGeoMesh *gmesh,int pOrder)
{
    // Getting mesh dimension
    const int dim = 3;
    TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
    cmesh->SetDefaultOrder(pOrder);
    cmesh->SetDimModel(dim);
    
    {//material da chapa
        const REAL Ey = 205000.;
        const REAL poisson = 0.3;
        const int matid = matchapa;
        TPZManVector<STATE,3> fx(3,0.);
        TPZElasticity3D * mat = new TPZElasticity3D(matid,Ey,poisson,fx);
        mat->SetVonMises(300.);
        cmesh->InsertMaterialObject(mat);
    }
    
    {//material da trilho1
        const REAL Ey = 205000.;
        const REAL poisson = 0.3;
        const int matid = mattrilho1;
        TPZManVector<STATE,3> fx(3,0.);
        TPZElasticity3D * mat = new TPZElasticity3D(matid,Ey,poisson,fx);
        mat->SetVonMises(690.);
        cmesh->InsertMaterialObject(mat);
        //int bcsidex = 9;
        TPZFNMatrix<9,STATE> val1(3,3,0.), val2(3,1,0.);
        val2(0,0) = 1.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bctrilho1, 3, val1, val2));
    }
    
    if(1)
    {//material da trilho2
        const REAL Ey = 205000.;
        const REAL poisson = 0.3;
        const int matid = mattrilho2;
        TPZManVector<STATE,3> fx(3,0.);
        TPZElasticity3D * mat = new TPZElasticity3D(matid,Ey,poisson,fx);
        mat->SetVonMises(690.);
        cmesh->InsertMaterialObject(mat);
        
        //int bcsidex = 9;
        TPZFNMatrix<9,STATE> val1(3,3,0.), val2(3,1,0.);
        val2(0,0) = 1.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bctrilho2, 3, val1, val2));
    }
    
    REAL percTracao = 0.1;
    {//material do concreto de 40 MPa
        const REAL Ey = 35417.;
        const REAL poisson = 0.2;
        const int matid = matgraut;
        TPZManVector<STATE,3> fx(3,0.);
        TPZElasticity3D * mat = new TPZElasticity3D(matid,Ey,poisson,fx);
        mat->SetMohrCoulomb(40.,percTracao*40.);
        cmesh->InsertMaterialObject(mat);
    }
    
    {//material do concreto de 30 MPa
        const REAL Ey = 27000;
        const REAL poisson = 0.2;
        const int matid = matenchimento;
        TPZManVector<STATE,3> fx(3,0.);
        TPZElasticity3D * mat = new TPZElasticity3D(matid,Ey,poisson,fx);
        mat->SetMohrCoulomb(30.,percTracao*30.);
        cmesh->InsertMaterialObject(mat);
        
        //c.c.
        //int bcbottom = 8;
        TPZFNMatrix<9,STATE> val1(3,3,0.), val2(3,1,0.);
//        val1(0,0) = 1.e-3;
//        val1(1,1) = 1.e-3;
//        val1(2,2) = 1.e12;
        val2(2) = 1.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bcbottom, 3, val1, val2));
        val1.Zero();
        val2.Zero();
        
        //int bcsidex = 9;
        val2.Zero();
        val2(0,0) = 1.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bcsidex, 3, val1, val2));
        
        //int bcsidey = 10;
        val1.Zero();
        val2.Zero();
        val2(1,0) = 1.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bcsidey, 3, val1, val2));
        
        //int bcloadtop = 11;
        val2.Zero();
        val2(2,0) = -800000./120.;
        cmesh->InsertMaterialObject(mat->CreateBC(mat, bcloadtop, 1, val1, val2));
        
//        somente para teste de tensao uniforme
//        cmesh->InsertMaterialObject(mat->CreateBC(mat, bcloadtopTESTE, 1, val1, val2));//toto
        
        
    }
    
    
    cmesh->SetAllCreateFunctionsContinuous();
    cmesh->AutoBuild();
    return cmesh;
    
}
示例#18
0
文件: Main.cpp 项目: labmec/neopz
TPZCompMesh *ComputationalElasticityMesh2D(TPZAutoPointer<TPZGeoMesh>  gmesh,int pOrder)
{
    
    // remove some connectivities 3, 5
    TPZGeoEl *gel = gmesh->Element(0);
    TPZGeoElSide gelside(gel,3);
    gelside.RemoveConnectivity();
    gelside.SetSide(5);
    gelside.RemoveConnectivity();
    gelside.SetSide(4);
    TPZGeoElSide neighbour = gelside.NNeighbours();
    int matid = neighbour.Element()->MaterialId();
    gel->SetMaterialId(matid);
    neighbour.Element()->RemoveConnectivities();
    int64_t index = neighbour.Element()->Index();
    delete neighbour.Element();
    gmesh->ElementVec()[index] = 0;
    
    
    // Plane strain assumption
    int planestress = 0;
    
    // Getting mesh dimension
    int dim = 2;
    
    TPZMatElasticity2D *materialConcrete;
    materialConcrete = new TPZMatElasticity2D(EMatConcrete);
    
    TPZMatElasticity2D *materialSteel;
    materialSteel = new TPZMatElasticity2D(EMatSteel);
    
    
    // Setting up paremeters
    materialConcrete->SetfPlaneProblem(planestress);
    materialConcrete->SetElasticity(25.e6, 0.25);
    materialSteel->SetElasticity(205.e6, 0.25);
    
    //material->SetBiotAlpha(Alpha);cade o metodo?
    
    
    TPZCompMesh * cmesh = new TPZCompMesh(gmesh);
    cmesh->SetDefaultOrder(pOrder);
    cmesh->SetDimModel(dim);
    
    TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.);
    
    val2(0,0) = 0.0;
    val2(1,0) = 0.0;
    val1(1,1) = 1.e12;
    TPZMaterial * BCond2 = materialConcrete->CreateBC(materialConcrete,EBottom,3, val1, val2);
    
    val2(0,0) = 0.0;
    val2(1,0) = 0.0;
    val1.Zero();
    val1(0,0) = 1.e12;
    TPZMaterial * BCond3 = materialConcrete->CreateBC(materialConcrete,ELateral,3, val1, val2);
    
    val2(0,0) = 0.0;
    val2(1,0) = -1000.0;
    val1.Zero();
    TPZMaterial * BCond4 = materialSteel->CreateBC(materialSteel,EBeam,1, val1, val2);
    
    cmesh->SetAllCreateFunctionsContinuous();
    cmesh->InsertMaterialObject(materialConcrete);
    cmesh->InsertMaterialObject(materialSteel);
    cmesh->InsertMaterialObject(BCond2);
    cmesh->InsertMaterialObject(BCond3);
    cmesh->InsertMaterialObject(BCond4);
    cmesh->AutoBuild();
    return cmesh;
    
}
示例#19
0
文件: Main.cpp 项目: labmec/neopz
int main(int argc, char *argv[])
{
    
    std::string dirname = PZSOURCEDIR;
#ifdef LOG4CXX
    InitializePZLOG();
#endif
    
    gRefDBase.InitializeRefPatterns();
    
    TPZReadGIDGrid readGid;
    
    TPZGeoMesh *gmesh =  readGid.GeometricGIDMesh("../rail.dump");
    
    {
        std::ofstream out("../GmeshOrig.vtk");
        TPZVTKGeoMesh::PrintGMeshVTK(gmesh, out);
    }
    InsertBoundaryElements(gmesh);
    // CASO NAO TEM TRILHO 2
    SwitchBCTrilho2(gmesh);
    
    AddZZeroFaces(gmesh);

    RefineGMesh(gmesh);
    
    {
        std::ofstream out("../GmeshRef.vtk");
        TPZVTKGeoMesh::PrintGMeshVTK(gmesh, out);
    }
    
    const int porder = 2;
    TPZCompMesh * cmesh = ComputationalElasticityMesh3D(gmesh,porder);
    
    AdaptPOrders(cmesh, -400., 2);

    // toto
//    {
//        std::set<int> mats;
//        mats.insert(bcbottom);
//        TPZManVector<STATE> force(1,0.);
//        force = cmesh->Integrate("StressZ", mats);
//        std::cout << "force = " << force << std::endl;
//    }
    
    {
        std::ofstream out("../CmeshRef.vtk");
        TPZVTKGeoMesh::PrintCMeshVTK(cmesh, out);
    }
    {
        TPZFMatrix<STATE> visualf;
        cmesh->ComputeFillIn(150, visualf);
        VisualMatrix(visualf,"../VisualMatrixBefore.vtk");
    }

    
    TPZAnalysis an;
    TPZAutoPointer<TPZRenumbering> renumber;
//    renumber = new TPZSloan;
//    renumber = new TPZCutHillMcKee;
    renumber = new TPZMetis;
    an.SetRenumber(renumber);
    an.SetCompMesh(cmesh, true);
    
#ifdef PZDEBUG
    {
        std::ofstream out("../gmesh.txt");
        gmesh->Print(out);
    }
    
    {
        std::ofstream out("../cmesh.txt");
        cmesh->Print(out);
    }
    
#endif
    {
        TPZFMatrix<STATE> visualf;
        cmesh->ComputeFillIn(150, visualf);
        VisualMatrix(visualf,"../MatrixMetis.vtk");
    }

    std::cout << "NEquations " << an.Solution().Rows() << std::endl;
    
    SolveSist(&an,cmesh);
    
    std::set<int> mats;
    mats.insert(bcbottom);
    TPZManVector<STATE> Force(1,0.);
    Force = cmesh->Integrate("StressZ", mats);
    std::cout << "Integrated sigma_Z " << Force << std::endl;
    
    std::cout << "Post processing" << std::endl;
    
    PostProcessElasticity(an, "../postProc.vtk");
    
    std::cout << "Finished\n";
//    delete cmesh;
//    delete gmesh;
    return EXIT_SUCCESS;
}
示例#20
0
文件: main.cpp 项目: labmec/neopz
void InsertMaterialObjectsMHM(TPZCompMesh &cmesh, bool useDPGPhil, bool useDPG)
{
	/// criar materiais
	int dim = cmesh.Dimension();
    TPZMatLaplacianLagrange *materialFiner = new TPZMatLaplacianLagrange(matfinermesh,dim);
    
//    TPZAutoPointer<TPZFunction<REAL> > forcef = new TPZDummyFunction<REAL>(ForceSuave);
//    materialFiner->SetForcingFunction(forcef);
    
    TPZAutoPointer<TPZFunction<STATE> > solExata= new TPZDummyFunction<STATE>(SolSuave);
    materialFiner->SetForcingFunctionExact(solExata);
    
    TPZAutoPointer<TPZFunction<STATE> > forcef;
    TPZDummyFunction<STATE> *dum;
    dum = new TPZDummyFunction<STATE>(ForceSuave);
    dum->SetPolynomialOrder(20);
    forcef = dum;
    materialFiner->SetForcingFunction(forcef);
    
    
    if(useDPGPhil==true){
        materialFiner->SetDPGPhil();
        useDPG=false;
    }
    if(useDPG==true){
        materialFiner->SetMDP();
        useDPGPhil=false;
    }
    
	TPZMaterial * mat1(materialFiner);
    
    TPZMat1dLin *materialSkeleton = new TPZMat1dLin(matskeletonmesh);
    TPZFNMatrix<1,STATE> xk(1,1,0.),xb(1,1,0.),xc(1,1,0.),xf(1,1,0.);
    materialSkeleton->SetMaterial(xk, xc, xb, xf);
    
	cmesh.InsertMaterialObject(mat1);
    cmesh.InsertMaterialObject(materialSkeleton);
	
	///Inserir condicao de contorno
	TPZFMatrix<STATE> val1(2,2,1.), val2(2,1,0.);
	
    int boundcond = dirichlet;
    if(useDPG) boundcond = neumanndirichlet;
    
    //BC -1
    TPZMaterial * BCondD1 = materialFiner->CreateBC(mat1, bc1,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet1 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD1->SetForcingFunction(bcmatDirichlet1);
    cmesh.InsertMaterialObject(BCondD1);
    
    //BC -2
	TPZMaterial * BCondD2 = materialFiner->CreateBC(mat1, bc2,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet2 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD2->SetForcingFunction(bcmatDirichlet2);
    cmesh.InsertMaterialObject(BCondD2);
    
    //BC -3
	TPZMaterial * BCondD3 = materialFiner->CreateBC(mat1, bc3,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet3 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD3->SetForcingFunction(bcmatDirichlet3);
    cmesh.InsertMaterialObject(BCondD3);
    
    //BC -4
	TPZMaterial * BCondD4 = materialFiner->CreateBC(mat1, bc4,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet4 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD4->SetForcingFunction(bcmatDirichlet4);
    cmesh.InsertMaterialObject(BCondD4);
}
示例#21
0
//*************************************
//************Option 0*****************
//*******L Shape Quadrilateral*********
//*************************************
TPZCompMesh *CreateCubeMesh(){
  //malha 2 cubos
  const int nelem = 2;
  //número de nós
  const int ncoord = 12;
  //TPZVec<REAL> coord(ncoord,0.);
  REAL Coord[ncoord][3] = { { 0.,0.,0.} , 
		       { 1.,0.,0.} ,
		       { 2.,0.,0.} ,
		       { 0.,1.,0.} , 
		       { 1.,1.,0.} ,
		       { 2.,1.,0.} ,
                       { 0.,0.,1.} , 
		       { 1.,0.,1.} ,
		       { 2.,0.,1.} ,
		       { 0.,1.,1.} , 
		       { 1.,1.,1.} ,
		       { 2.,1.,1.}                
                                            
                                   };
  int Connect[nelem][8] = { {0,1,4,3,6,7,10,9},
			    {1,2,5,4,7,8,11,10} };
  int nConnect[nelem] = {8,8};
  
  // criar um objeto tipo malha geometrica
  TPZGeoMesh *geomesh = new TPZGeoMesh();
  
  // criar nos
  int i,j;
  for(i=0; i<(ncoord); i++) {
    int nodind = geomesh->NodeVec().AllocateNewElement();
    TPZVec<REAL> coord(3);
    for (j=0; j<3; j++) {
      coord[j] = Coord[i][j];
    }
    geomesh->NodeVec()[nodind] = TPZGeoNode(i,coord,*geomesh);
  }

  // criação dos elementos
  TPZGeoEl *gel[nelem];

  for(i=0;i<nelem;i++) {  
    TPZVec<int64_t> indices(nConnect[i]);
    for(j=0;j<nConnect[i];j++) {
      indices[j] = Connect[i][j];
    }
    int64_t index;
    switch (nConnect[i]){
    case (4): 
      gel[i] = geomesh->CreateGeoElement(EQuadrilateral,indices,1,index);
      break;
    case(3):
      gel[i] = geomesh->CreateGeoElement(ETriangle,indices,1,index);
      break;
    case (8) :
      gel[i] = geomesh->CreateGeoElement(ECube,indices,1,index);  
      break; 
    default:
      cout << "Erro : elemento nao implementado" << endl;
    }
  }
 
  // Descomentar o trecho abaixo para habilitar a
  // divisão dos elementos geométricos criados 
                      
  geomesh->BuildConnectivity();
  //  geomesh->Print(cout);

  //Divisão dos elementos
  // TPZVec<TPZGeoEl *> sub,subsub;
  //  gel[0]->Divide(sub);
  //  sub[0]->Divide(subsub);
  //  subsub[2]->Divide(sub);
  
  //  for (i=0;i< (sub.NElements()-1) ;i++){
  //    sub[i]->Divide(subsub);
  //  }
  
  // Criação das condições de contorno geométricas
  TPZGeoElBC heman_1(gel[0],20,-1);
  TPZGeoElBC heman_2(gel[1],20,-1);
  //  geomesh->BuildConnectivity2();
  //geomesh->Print(cout);

  // Criação da malha computacional
  TPZCompMesh *comp = new TPZCompMesh(geomesh);

  // Criar e inserir os materiais na malha
  TPZMaterial *mat = new TPZMatPoisson3d(1,3);
  comp->InsertMaterialObject(mat);
 
  TPZMaterial *meumat = mat;

  // Condições de contorno
  // Dirichlet
  TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
  TPZMaterial *bnd = meumat->CreateBC (meumat,-1,0,val1,val2);
  comp->InsertMaterialObject(bnd);
  bnd = meumat->CreateBC (meumat,-1,0,val1,val2);
  
  // comp->Print(cout);

  // Ajuste da estrutura de dados computacional
  comp->AutoBuild();
  return comp;
}
示例#22
0
文件: main.cpp 项目: labmec/neopz
int main(){
#define HUGE_DEBUG
  int i;
  TPZCompMesh *cmesh;
  TPZVec <REAL> solution;
  int nstate, nsteps;
  TPZVec<int> meshsize(3,0);
  TPZVec<int> dimstate(3,0);
  TPZVec<int> usestate(3,0);
  TPZVec<int> erind(3,0);
  TPZVec<int> erantype(3,0);
  TPZVec <REAL> maxerror;
  TPZVec <REAL> minerror;
  ifstream arq_control ("/compile/cesar/NeoPZ/Projects/Error/control.txt");
  ReadControl(arq_control,meshsize,nstate,dimstate,usestate,erind,erantype,maxerror,minerror,nsteps);
  //  cout << "Reading Mesh\n";
  ifstream arq_mesh ("/compile/cesar/NeoPZ/Projects/Error/Mesh.data");
  //cmesh = ReadMesh(arq_mesh,meshsize);
  //cmesh = ReadElementsMesh();
  cmesh = TetraMesh();
  cout << "Reading Solution\n";
  ifstream arq_solution ("/compile/cesar/NeoPZ/Projects/Error/Solution.data");
  TPZStack<char *> scalnames,vecnames;
  scalnames.Push("POrder");
  //cmesh->Print(cout);
  //cmesh->Reference()->Print(cout);
  for (i=0;i<nsteps;i++){
    cout << "\n\nEntering step...: " << i << endl;
    //Just for visualization purposes...
    TPZAnalysis an (cmesh);
    char buf [256];
    sprintf(buf,"htest%d.dx",i);
    //an.DefineGraphMesh(3,scalnames,vecnames,buf);
    //an.PostProcess(0,3);
    ofstream arq(buf);
    WriteMesh(cmesh->Reference(),arq);

    ReadSolution(arq_solution,solution,cmesh,nstate,dimstate);
    //  cout << solution << endl;
    TPZCompMesh *adaptmesh;
    TMBAdaptInterface adapt(cmesh,nstate,dimstate,usestate,solution);
    adapt.SetMaxMinError(maxerror,minerror);
    adaptmesh = adapt.GetAdaptedMesh(erind,erantype,true,1,1,0);
    //cmesh->Reference()->ResetReference();
    //   cmesh->LoadReferences();
    //delete cmesh;
    cmesh = adaptmesh;
    //cmesh->Reference()->Print(cout);
  }
  //Just for visualization purposes...
  TPZAnalysis an (cmesh);
  char buf [256];
  sprintf(buf,"htest%d.dx",i);
  ofstream arq (buf);
  WriteMesh(cmesh->Reference(),arq);
//  an.DefineGraphMesh(3,scalnames,vecnames,buf);
//  an.PostProcess(0,3);

//  WriteCompMesh(cmesh,cout);
  delete cmesh;
  cout << "End..." << endl;
  return 0;
}
示例#23
0
文件: main.cpp 项目: labmec/neopz
TPZCompMesh *ReadElementsMesh(){

  REAL Coord [18][3] = {
    {0.,0.,0.},{0.5,0.,0.},{1.,0.,0.},
    {0.,1.,0.},{0.5,1.,0.},{1.,1.,0.},

    {0.,0.,0.5},{0.5,0.,0.5},{1.,0.,0.5},
    {0.,1.,0.5},{0.5,1.,0.5},{1.,1.,0.5},

    {0.,0.,1.},{0.5,0.,1.},{1.,0.,1.},
    {0.,1.,1.},{0.5,1.,1.},{1.,1.,1.}
  };

  int NodesPerEl [11] = { 8,
                          5,5,5,
                          6,6,
                          4,4,4,4,4};

  int Connects [11][8] = {
    {0,1,4,3,6,7,10,9},

    {6,7,10,9,16,-1,-1,-1},
    {6,7,13,12,16,-1,-1,-1},
    {6,9,15,12,16,-1,-1,-1},

    {1,2,5,7,8,11,-1,-1},
    {1,5,4,7,11,10,-1,-1},

    {7,8,11,14,-1,-1,-1,-1},
    {7,11,10,16,-1,-1,-1,-1},
    {16,17,14,11,-1,-1,-1,-1},
    {16,14,13,7,-1,-1,-1,-1},
    {7,11,16,14,-1,-1,-1,-1}
  };

  int i,j;
  TPZGeoMesh *gmesh = new TPZGeoMesh();
  TPZGeoEl * elvec[11];

  TPZVec <REAL> coord (3,0.);

  int index;

  //Nodes initialization
  for(i = 0; i < 18; i++){
    for(j=0;j<3;j++){
      coord[j] = Coord[i][j];
    }
    index = gmesh->NodeVec().AllocateNewElement();
    gmesh->NodeVec()[index] = TPZGeoNode(i,coord,*gmesh);
  }

  TPZVec<TPZRefPattern *> refinement_Patterns;
  refinement_Patterns.Resize(8);
  refinement_Patterns[0] = 0;
  refinement_Patterns[1] = new TPZRefPattern("/home/pos/cesar/RefPattern/Line_Unif_Side_2.rpt");
  refinement_Patterns[2] = new TPZRefPattern("/home/pos/cesar/RefPattern/Triang_Unif.rpt");
  refinement_Patterns[3] = new TPZRefPattern("/home/pos/cesar/RefPattern/Quad_Unif.rpt");
  refinement_Patterns[4] = new TPZRefPattern("/home/pos/cesar/RefPattern/Tetra_Unif.rpt");
  refinement_Patterns[5] = new TPZRefPattern("/home/pos/cesar/RefPattern/Piram_Unif.rpt");
  refinement_Patterns[6] = new TPZRefPattern("/home/pos/cesar/RefPattern/Prism_Unif.rpt");
  refinement_Patterns[7] = new TPZRefPattern("/home/pos/cesar/RefPattern/Hexa_Unif.rpt");
                             
  
  for (i=0;i<11;i++){
    int ncon = NodesPerEl[i];
    TPZVec <int> connect(ncon,0);
    for(j=0; j<ncon;j++){
      connect[j] = Connects[i][j];
    }
    //elvec[i] = GeoElement(gmesh,ncon,connect,1,i);
    if (ncon ==4 ) ncon = 7;
    elvec[i] = GeoElementRefPattern(gmesh,ncon,connect,1,i,refinement_Patterns);
  }
  //Generate neighborhod information
  gmesh->Print(cout);
  gmesh->BuildConnectivity();
  gmesh->Print(cout);
  //Create computational mesh
  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
  TPZMaterial *mat;
  mat = new TPZMaterialTest3D (1);
  cmesh->InsertMaterialObject(mat);

  cmesh->AutoBuild();
  return cmesh;
}
示例#24
0
文件: main.cpp 项目: labmec/neopz
TPZCompMesh *ReadMesh(ifstream &arq, TPZVec<int> &meshsize){
  int nx = meshsize[0];
  int ny = meshsize[1];
  int nz = meshsize[2];
  int i,j,k;
  TPZGeoMesh *gmesh = new TPZGeoMesh();
  TPZGeoEl * elvec[(const int)((nx-1)*(ny-1)*(nz-1))];

  TPZVec <REAL> coord (3,0.);
  TPZVec <int> connect(8,0);
  REAL lx = 1.;
  REAL ly = 1.;
  REAL lz = 1.;
  int id, index;
  //Nodes initialization
  for(i = 0; i < nx; i++){
    for(j = 0; j < ny; j++){
      for(k = 0; k < nz; k++){
        id = (i)*nz*ny + (j)*nz + k;
        coord[0] = (i)*lx/(nx - 1);
        coord[1] = (j)*ly/(ny - 1);
        coord[2] = (k)*lz/(nz - 1);
        //cout << coord << endl;
        index = gmesh->NodeVec().AllocateNewElement();
        gmesh->NodeVec()[index] = TPZGeoNode(id,coord,*gmesh);
      }
    }
  }

  //Element connectivities
  TPZRefPattern *unifcube = new TPZRefPattern ("/home/pos/cesar/RefPattern/Hexa_Unif.rpt");
  for(i = 0; i < (nx - 1); i++){
    for(j = 0; j < (ny - 1); j++){
      for(k = 0; k < (nz - 1); k++){
        index = (i)*(nz - 1)*(ny - 1) + (j)*(nz - 1) + k;
        connect[0] = (i)*nz*ny + (j)*nz + k;
        connect[1] = connect[0]+(ny)*(nz);
        connect[2] = connect[1]+(nz);
        connect[3] = connect[0]+(nz);
        connect[4] = connect[0] + 1;
        connect[5] = connect[1] + 1;
        connect[6] = connect[2] + 1;
        connect[7] = connect[3] + 1;
        //cout << connect << endl;
//        elvec[index] = gmesh->CreateGeoElement(ECube,connect,1,id);
        TPZGeoElRefPattern <TPZShapeCube,TPZGeoCube> *gel =
             new TPZGeoElRefPattern <TPZShapeCube,TPZGeoCube> (index,connect,1,*gmesh,unifcube);
        elvec[index] = gel;
      }
    }
  }
  //Generate neighborhod information
  gmesh->BuildConnectivity();
  gmesh->Print(cout);
  //Create computational mesh

  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
  TPZMaterial *mat;
  mat = new TPZMaterialTest3D (1);
  cmesh->InsertMaterialObject(mat);

  cmesh->AutoBuild();
  return cmesh;
}
示例#25
0
文件: main.cpp 项目: labmec/neopz
int main2(int argc, char *argv[])
{
#ifdef LOG4CXX
    InitializePZLOG();
#endif
    
    REAL Lx = 1.;
    REAL Ly = 1.;
    
    {// Checando funcoes
        TPZVec<REAL> pto(2,0.);
        TPZVec<STATE> disp(1,0.),solp(1,0.);
        pto[0]=0.200935;
        pto[1]=0.598129;
        TPZFMatrix<STATE>flux(3,1,0.);
        SolExata(pto, solp,flux);
        Forcing(pto, disp);
        
        solp.Print(std::cout);
        flux.Print(std::cout);
        disp.Print(std::cout);
    }
    
   // ofstream saidaerro("../ErroPoissonHdivMalhaQuad.txt",ios::app);
    ofstream saidaerro("../ErroPoissonHdivMalhaTriang.txt",ios::app);

    for(int p = 1; p<2; p++)
    {
        int pq = p;
        int pp;
        if(ftriang==true){
            pp = pq-1;
        }else{
            pp = pq;
        }
        
        int ndiv;
        saidaerro<<"\n CALCULO DO ERRO, COM ORDEM POLINOMIAL pq = " << pq << " e pp = "<< pp <<endl;
        for (ndiv = 1; ndiv< 2; ndiv++)
        {
            
            //std::cout << "p order " << p << " number of divisions " << ndiv << std::endl;
            
            saidaerro<<"\n<<<<<< Numero de divisoes uniforme ndiv = " << ndiv <<" >>>>>>>>>>> "<<endl;
            
            TPZGeoMesh *gmesh = GMesh(ftriang, Lx, Ly);
            ofstream arg("gmesh1.txt");
            gmesh->Print(arg);
            
            UniformRefine(gmesh, ndiv);
            
            TPZCompMesh *cmesh1 = CMeshFlux(gmesh, pq);
            TPZCompMesh *cmesh2 = CMeshPressure(gmesh, pp);
            
//            ofstream arg1("cmeshflux.txt");
//            cmesh1->Print(arg1);
//            
//            ofstream arg2("cmeshpressure.txt");
//            cmesh2->Print(arg2);
//            
//            ofstream arg4("gmesh2.txt");
//            gmesh->Print(arg4);
            
            
            //malha multifisica
            TPZVec<TPZCompMesh *> meshvec(2);
            meshvec[0] = cmesh1;
            meshvec[1] = cmesh2;
            
            TPZCompMesh * mphysics = CMeshMixed(gmesh,meshvec);
            
            std::cout << "Number of equations " << mphysics->NEquations() << std::endl;
            int numthreads = 8;
            std::cout << "Number of threads " << numthreads << std::endl;

            TPZAnalysis an(mphysics);
            SolveSyst(an, mphysics,numthreads);
            
            
//            ofstream arg5("cmeshmultiphysics.txt");
//            mphysics->Print(arg5);

            //Calculo do erro
            TPZBuildMultiphysicsMesh::TransferFromMultiPhysics(meshvec, mphysics);
            TPZVec<REAL> erros;
    
            saidaerro << "Valor de epsilone " << EPSILON << std::endl;
            saidaerro << "Numero de threads " << numthreads << std::endl;
            saidaerro<<" \nErro da simulacao multifisica do fluxo (q)" <<endl;
            ErrorHDiv(cmesh1, saidaerro);
            
            saidaerro<<" Erro da simulacao multifisica da pressao (p)" <<endl;
            ErrorL2(cmesh2, saidaerro);
            
            std::cout << "Postprocessed\n";
            
            //Plot da solucao aproximada
//            string plotfile("Solution_mphysics.vtk");
//            PosProcessMultphysics(meshvec,  mphysics, an, plotfile);
        }
    }
    
	return EXIT_SUCCESS;
}
示例#26
0
文件: main.cpp 项目: labmec/neopz
//malha multifisica para o metodo da dupla projecao
TPZCompMesh *MalhaMDP(TPZVec<TPZCompMesh *> meshvec,TPZGeoMesh * gmesh){
    
    //Creating computational mesh for multiphysic elements
	gmesh->ResetReference();
	TPZCompMesh *mphysics = new TPZCompMesh(gmesh);
    
    //criando material
    int dim =2;
    TPZMDPMaterial *material = new TPZMDPMaterial(1,dim);
    
    //incluindo os dados do problema
    REAL coefk = 1.;
    material->SetParameters(coefk, 0.);
    
    //solucao exata
    TPZAutoPointer<TPZFunction<STATE> > solexata;
    solexata = new TPZDummyFunction<STATE>(SolSuave);
    material->SetForcingFunctionExact(solexata);
    
    //funcao do lado direito da equacao do problema
    TPZAutoPointer<TPZFunction<STATE> > force;
    TPZDummyFunction<STATE> *dum;
    dum = new TPZDummyFunction<STATE>(ForceSuave);
    dum->SetPolynomialOrder(20);
    force = dum;
    material->SetForcingFunction(force);
    
    //inserindo o material na malha computacional
    TPZMaterial *mat(material);
    mphysics->InsertMaterialObject(mat);
    
    //Criando condicoes de contorno
    TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.);
    int boundcond = dirichlet;
    //BC -1
    TPZMaterial * BCondD1 = material->CreateBC(mat, bc1,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet1 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD1->SetForcingFunction(bcmatDirichlet1);
    mphysics->InsertMaterialObject(BCondD1);
    
    //BC -2
	TPZMaterial * BCondD2 = material->CreateBC(mat, bc2,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet2 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD2->SetForcingFunction(bcmatDirichlet2);
    mphysics->InsertMaterialObject(BCondD2);
    
    //BC -3
	TPZMaterial * BCondD3 = material->CreateBC(mat, bc3,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet3 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD3->SetForcingFunction(bcmatDirichlet3);
    mphysics->InsertMaterialObject(BCondD3);
    
    //BC -4
	TPZMaterial * BCondD4 = material->CreateBC(mat, bc4,boundcond, val1, val2);
    TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet4 = new TPZDummyFunction<REAL>(DirichletSuave);
    BCondD4->SetForcingFunction(bcmatDirichlet4);
    mphysics->InsertMaterialObject(BCondD4);

    
    mphysics->InsertMaterialObject(BCondD1);
    mphysics->InsertMaterialObject(BCondD2);
    mphysics->InsertMaterialObject(BCondD3);
    mphysics->InsertMaterialObject(BCondD4);
    
    
    //set multiphysics element
    mphysics->SetDimModel(dim);
    mphysics->SetAllCreateFunctionsMultiphysicElem();
    
    //Fazendo auto build
    mphysics->AutoBuild();
	mphysics->AdjustBoundaryElements();
	mphysics->CleanUpUnconnectedNodes();
    
    // Creating multiphysic elements into mphysics computational mesh
	TPZBuildMultiphysicsMesh::AddElements(meshvec, mphysics);
	TPZBuildMultiphysicsMesh::AddConnects(meshvec,mphysics);
	TPZBuildMultiphysicsMesh::TransferFromMeshes(meshvec, mphysics);
    
    return mphysics;
}
示例#27
0
int main(/*int argc, char *argv[]*/)
{
    InitializePZLOG();
    gRefDBase.InitializeUniformRefPattern(EOned);
    gRefDBase.InitializeUniformRefPattern(EQuadrilateral);
    gRefDBase.InitializeUniformRefPattern(ETriangle);
    
    
    int p =1;
    int ndiv = 1;
    TPZGeoMesh *gmesh = GMesh(false, 1, 1);
    UniformRefine( gmesh,ndiv);
    
    ofstream filegmesh1("gmes.txt");
    gmesh->Print(filegmesh1);
    
    
    TPZCompMesh *cmesh1 = MeshH1(gmesh, p, 2,true);//malha para y(estado)
        ofstream filemesh1("malhaY.txt");
        cmesh1->Print(filemesh1);
    TPZCompMesh *cmesh2 = MeshL2(gmesh, p, 2);//malha para controle(u)
    ofstream filemesh2("malhaU.txt");
    cmesh2->Print(filemesh2);
    TPZCompMesh *cmesh3 = MeshH1(gmesh, p, 2,false);//malha para mult.lagrange(p)
    ofstream filemesh3("malhaP.txt");
    cmesh3->Print(filemesh3);
    
    TPZManVector<TPZCompMesh *,3> meshvec(3);
    meshvec[0] = cmesh1;
    meshvec[1] = cmesh2;
    meshvec[2] = cmesh3;
    TPZCompMesh * mphysics = MalhaMultifisicaOpt(meshvec, gmesh);
    ofstream filemesh4("malhaMulti.txt");
    mphysics->Print(filemesh4);
    
    
    
    //Resolver problema
    TPZAnalysis analysis(mphysics,false);
    //TPZParFrontStructMatrix<TPZFrontSym<STATE> > strmat(mphysics);
    //strmat.SetDecomposeType(ELDLt);
    TPZSkylineStructMatrix strmat(mphysics);
    
    //strmat.SetNumThreads(6);
    analysis.SetStructuralMatrix(strmat);
    TPZStepSolver<STATE> step;
    step.SetDirect(ELDLt); //caso simetrico
    analysis.SetSolver(step);
    analysis.Assemble();
    analysis.Solve();
    
    std::ofstream out("SolOpt.txt");
    analysis.Solution().Print("Solucao",out);

    
    
    //Post-Process
    TPZBuildMultiphysicsMesh::TransferFromMultiPhysics(meshvec, mphysics);
    
    TPZManVector<std::string,10> scalnames(4), vecnames(0);
    scalnames[0] = "State";
    scalnames[1] = "Control";
    scalnames[2]="LagrangeMult";
    scalnames[3]="ExactState";
    
    std::stringstream name;
    name << "Solution_Opt" <<ndiv<< ".vtk";
    std::string paraviewfile(name.str());
    analysis.DefineGraphMesh(2,scalnames,vecnames,paraviewfile);
    analysis.PostProcess(0);
    
    //visualizar matriz no vtk
    //    TPZFMatrix<REAL> vismat(100,100);
    //    mphysics->ComputeFillIn(100,vismat);
    //    VisualMatrixVTK(vismat,"matrixstruct.vtk");
    
    
	return EXIT_SUCCESS;
}
示例#28
0
TPZCompMesh *MalhaMultifisicaOpt(TPZVec<TPZCompMesh *> meshvec, TPZGeoMesh *gmesh){
    
    //Creating computational mesh for multiphysic elements
    gmesh->ResetReference();
    TPZCompMesh *mphysics = new TPZCompMesh(gmesh);
    
    //criando material
    int dim =2;
    
    TPZMatPoissonControl *material = new TPZMatPoissonControl(MatId,dim);
    
    
    //incluindo os dados do problema
    REAL k=1;
    REAL alpha=1;
    material-> SetParameters( k, alpha);
    
    //solucao exata
    TPZAutoPointer<TPZFunction<STATE> > solexata;
    solexata = new TPZDummyFunction<STATE>(StateAd, 5);
    material->SetForcingFunctionExact(solexata);
    
    //funcao do lado direito da equacao do problema
    TPZAutoPointer<TPZFunction<STATE> > force;
    TPZDummyFunction<STATE> *dum;
    dum = new TPZDummyFunction<STATE>(OptForcing, 5);
    dum->SetPolynomialOrder(20);
    force = dum;
    material->SetForcingFunction(force);
    
    //inserindo o material na malha computacional
    TPZMaterial *mat(material);
    mphysics->InsertMaterialObject(mat);
    mphysics->SetDimModel(dim);
    
    //Criando condicoes de contorno
    TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.);
    
    
    TPZMaterial * BCond0 = material->CreateBC(mat, bc0, bcdirichlet, val1, val2);
    TPZMaterial * BCond1 = material->CreateBC(mat, bc1, bcdirichlet, val1, val2);
    TPZMaterial * BCond2 = material->CreateBC(mat, bc2, bcdirichlet, val1, val2);
    TPZMaterial * BCond3 = material->CreateBC(mat, bc3, bcdirichlet, val1, val2);
    
    ///Inserir condicoes de contorno
    mphysics->InsertMaterialObject(BCond0);
    mphysics->InsertMaterialObject(BCond1);
    mphysics->InsertMaterialObject(BCond2);
    mphysics->InsertMaterialObject(BCond3);
    
    mphysics->SetAllCreateFunctionsMultiphysicElem();
    
    //Fazendo auto build
    mphysics->AutoBuild();
    mphysics->AdjustBoundaryElements();
    mphysics->CleanUpUnconnectedNodes();
    
    TPZBuildMultiphysicsMesh::AddElements(meshvec, mphysics);
    TPZBuildMultiphysicsMesh::AddConnects(meshvec,mphysics);
    TPZBuildMultiphysicsMesh::TransferFromMeshes(meshvec, mphysics);
    
    return mphysics;
    
}
示例#29
0
//*************************************
//************Option 8*****************
//*****All element types Mesh**********
//*************************************
TPZCompMesh * CreateTestMesh() {

  REAL nodeco[12][3] = {
    {0.,0.,0.},
    {1.,0.,0.},
    {2.,0.,0.},
    {0.,1.,0.},
    {1.,1.,0.},
    {2.,1.,0.},
    {0.,0.,1.},
    {1.,0.,1.},
    {2.,0.,1.},
    {0.,1.,1.},
    {1.,1.,1.},
    {2.,1.,1.}
  };

  int nodind[7][8] = {
    {0,1,4,3,6,7,10,9},
    {2,4,10,8,5},
    {8,10,11,5},
    {2,4,1,8,10,7},
    {0,1},
    {0,1,7,6},
    {1,2,7}
  };

  int numnos[7] = {8,5,4,6,2,4,3};

  TPZGeoMesh *gmesh = new TPZGeoMesh();

  int noind[12];
  int no;
  for(no=0; no<12; no++) {
    noind[no] = gmesh->NodeVec().AllocateNewElement();
    TPZVec<REAL> coord(3);
    coord[0] = nodeco[no][0];
    coord[1] = nodeco[no][1];
    coord[2] = nodeco[no][2];
    gmesh->NodeVec()[noind[no]].Initialize(coord,*gmesh);
  }
  int matid = 1;
  TPZVec<int> nodeindex;
  int nel;
  TPZVec<TPZGeoEl *> gelvec;
  gelvec.Resize(4);
  for(nel=0; nel<4; 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:
      //      elvec[el] = gmesh->CreateGeoElement(ECube,nodeindex,1,index);
//      gelvec[nel]=new TPZGeoElC3d(nodeindex,matid,*gmesh);
      break;
    case 1:
      gelvec[nel] = gmesh->CreateGeoElement(EPiramide,nodeindex,matid,index);
      //       gelvec[nel]=new TPZGeoElPi3d(nodeindex,matid,*gmesh);
      break;
    case 2:
      gelvec[nel] = gmesh->CreateGeoElement(ETetraedro,nodeindex,matid,index);
    //       gelvec[nel]=new TPZGeoElT3d(nodeindex,matid,*gmesh);
      break;
    case 3:
//       gelvec[nel]=new TPZGeoElPr3d(nodeindex,matid,*gmesh);
//      gelvec[nel] = gmesh->CreateGeoElement(EPrisma,nodeindex,matid,index);
      break;
    case 4:
      //      gelvec[nel]=new TPZGeoEl1d(nodeindex,2,*gmesh);
      break;
    case 5:
      //      gelvec[nel]=new TPZGeoElQ2d(nodeindex,3,*gmesh);
      break;
    case 6:
      //      gelvec[nel]=new TPZGeoElT2d(nodeindex,3,*gmesh);
      break;
    default:
      break;
    }
  }
  gmesh->BuildConnectivity2();

  //TPZVec<TPZGeoEl *> sub;
  //elvec[0]->Divide(sub);
  //   	elvec[1]->Divide(sub);
  //   	elvec[2]->Divide(sub);

//  TPZGeoElBC gbc;

  // bc -1 -> Dirichlet
//  TPZGeoElBC gbc1(gelvec[0],20,-1,*gmesh);
  TPZGeoElBC gbc11(gelvec[1],14,-1,*gmesh);
//  TPZGeoElBC gbc12(gelvec[3],15,-1,*gmesh);



  // bc -2 -> Neumann at the right x==1
//  TPZGeoElBC gbc2(gelvec[0],25,-2,*gmesh);
//  TPZGeoElBC gbc21(gelvec[3],19,-2,*gmesh);
  TPZGeoElBC gbc22(gelvec[2],10,-2,*gmesh);

  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);

  TPZAutoPointer<TPZMaterial> mat;
  //  if(nstate == 3) {
    mat = new TPZMaterialTest3D(1);
    TPZFMatrix mp (3,1,0.);
    TPZMaterialTest3D * mataux = dynamic_cast<TPZMaterialTest3D *> (mat.operator ->());
    TPZMaterialTest3D::geq3=1;
    mataux->SetMaterial(mp);
    /*  } else {
    TPZMat2dLin *mat2d = new TPZMat2dLin(1);
    int ist,jst;
    TPZFMatrix xk(nstate,nstate,1.),xc(nstate,nstate,0.),xf(nstate,1,0.);
    for(ist=0; ist<nstate; ist++) {
      if(nstate != 1) xf(ist,0) = 1.;
      for(jst=0; jst<nstate; jst++) {
	if(ist != jst) xk(ist,jst) = 0.;
      }
    }
    mat2d->SetMaterial(xk,xc,xf);
    mat = mat2d;
    }*/

  TPZFMatrix val1(3,3,0.),val2(3,1,0.);
  TPZAutoPointer<TPZMaterial> bc[2];

  bc[0] = mat->CreateBC(mat,-1,0,val1,val2);
  val2(0,0) = 1.;
  bc[1] = mat->CreateBC(mat,-2,1,val1,val2);
  cmesh->InsertMaterialObject(mat);

  int i;
  for(i=0; i<2; i++) cmesh->InsertMaterialObject(bc[i]);

  gmesh->Print(cout);

  cmesh->AutoBuild();
  cmesh->AdjustBoundaryElements();
  cmesh->CleanUpUnconnectedNodes();

  gmesh->Print(cout);
  return cmesh;
}
示例#30
0
文件: flavio.c 项目: labmec/neopz
int main() {

   //malha geometrica
   TPZGeoMesh *firstmesh = new TPZGeoMesh;
   firstmesh->SetName("Malha Geometrica : Nós e Elementos");
   firstmesh->NodeVec().Resize(10);
   TPZVec<REAL> coord(2);   //,coordtrans(2);
//   REAL ct,st,PI=3.141592654;
//   cout << "\nEntre rotacao do eixo n1 (graus) -> ";
//   REAL g;
//   cin >> g;
//   g = g*PI/180.;
//   ct = cos(g);
//   st = sin(g);
//ct = 1.;
//st = 0.;

   //nos geometricos

   //no 0
   coord[0] = 0;
   coord[1] = 0;
// coordtrans[0] =  ct*coord[0]-st*coord[1];
// coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[0].Initialize(coord,*firstmesh);

   //no 1
   coord[0] = 1.;
   coord[1] = 0;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[1].Initialize(coord,*firstmesh);

   //no 2
   coord[0] = 2.;
   coord[1] = 0.;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[2].Initialize(coord,*firstmesh);

   //no 3
   coord[0] = 3.;
   coord[1] = 0.;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[3].Initialize(coord,*firstmesh);

   //no 4
   coord[0] = 4;
   coord[1] = 0.;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[4].Initialize(coord,*firstmesh);

   //no 5
   coord[0] = 0;
   coord[1] = 1;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[5].Initialize(coord,*firstmesh);

   //no 6
   coord[0] = 1.;
   coord[1] = 1.;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[6].Initialize(coord,*firstmesh);

   //no 7
   coord[0] = 2.;
   coord[1] = 1.;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[7].Initialize(coord,*firstmesh);

   //no 8
   coord[0] = 3.;
   coord[1] = 1;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//  coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[8].Initialize(coord,*firstmesh);

   //no 9
   coord[0] = 4;
   coord[1] = 1;
//   coordtrans[0] =  ct*coord[0]-st*coord[1];
//   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[9].Initialize(coord,*firstmesh);

   /*
   TPZVec<int> nodeindexes(3);
   nodeindexes[0] = 0;
   nodeindexes[1] = 1;
   nodeindexes[2] = 2;
    //elementos geometricos
   TPZGeoElT2d *elg0 = new TPZGeoElT2d(nodeindexes,1,*firstmesh);
   nodeindexes[0] = 0;
   nodeindexes[1] = 2;
   nodeindexes[2] = 3;
   TPZGeoElT2d *elg1 = new TPZGeoElT2d(nodeindexes,1,*firstmesh);
   nodeindexes[0] = 0;
   nodeindexes[1] = 1;
   nodeindexes[2] = 2;
   TPZGeoElT2d *elg2 = new TPZGeoElT2d(nodeindexes,2,*firstmesh);
   nodeindexes[0] = 0;
   nodeindexes[1] = 2;
   nodeindexes[2] = 3;
   TPZGeoElT2d *elg3 = new TPZGeoElT2d(nodeindexes,2,*firstmesh);
*/
   TPZVec<int> nodeindexes(4);
    //elementos geometricos
   TPZGeoEl *elg[4];

   nodeindexes[0] = 0;
   nodeindexes[1] = 1;
   nodeindexes[2] = 6;
   nodeindexes[3] = 5;
   elg[0] = new TPZGeoElQ2d(nodeindexes,1,*firstmesh);

   nodeindexes[0] = 1;
   nodeindexes[1] = 2;
   nodeindexes[2] = 7;
   nodeindexes[3] = 6;
   elg[1] = new TPZGeoElQ2d(nodeindexes,1,*firstmesh);

   nodeindexes[0] = 2;
   nodeindexes[1] = 3;
   nodeindexes[2] = 8;
   nodeindexes[3] = 7;
   elg[2] = new TPZGeoElQ2d(nodeindexes,1,*firstmesh);

   nodeindexes[0] = 3;
   nodeindexes[1] = 4;
   nodeindexes[2] = 9;
   nodeindexes[3] = 8;
   elg[3] = new TPZGeoElQ2d(nodeindexes,1,*firstmesh);

   //Arquivos de saida
   ofstream outgm1("outgm1.dat");
   ofstream outcm1("outcm1.dat");
   ofstream outcm2("outcm2.dat");

   //montagem de conectividades entre elementos
   firstmesh->BuildConnectivity();
   //malha computacional
   TPZCompMesh *secondmesh = new TPZCompMesh(firstmesh);
   secondmesh->SetName("Malha Computacional : Conectividades e Elementos");


   //material
   TPZMaterial *pl = LerMaterial("flavio.dat");
   secondmesh->InsertMaterialObject(pl);
//   pl = LerMaterial("placa2.dat");
//   secondmesh->InsertMaterialObject(pl);
//   pl = LerMaterial("placa3.dat");
//   secondmesh->InsertMaterialObject(pl);

   // carregamento hidrostatico no plano vertica xz
   pl->SetForcingFunction(PressaoHid);

   //CC : condicões de contorno
   TPZBndCond *bc;
   REAL big = 1.e12;
   TPZFMatrix val1(6,6,0.),val2(6,1,0.);

   // engastes nos lados 4 e 7 do elemento 0
   TPZGeoElBC(elg[0],4,-2,*firstmesh);
   TPZGeoElBC(elg[0],7,-2,*firstmesh);

   // engaste no lado 4 do elemento 1
   TPZGeoElBC(elg[1],4,-2,*firstmesh);

   // engaste no lado 4 do elemento 2
   TPZGeoElBC(elg[2],4,-2,*firstmesh);

   // engaste no lado 4 do elemento 3
   TPZGeoElBC(elg[3],4,-2,*firstmesh);

   // imposicao do valor zero associado a condicao -2 (engaste)
   bc = pl->CreateBC(-2,0,val1,val2);
   secondmesh->InsertMaterialObject(bc);

   // imposicao da condicao de simetria no lado 5 do elemento 4
   val1(0,0)=big;
   val1(1,1)=0.;
   val1(2,2)=0.;
   val1(3,3)=0.;
   val1(4,4)=big;
   val1(5,5)=big;
   TPZGeoElBC(elg[3],5,-3,*firstmesh);
   bc = pl->CreateBC(-3,2,val1,val2);
   secondmesh->InsertMaterialObject(bc);

   //ordem de interpolacao
   int ord;
   cout << "Entre ordem 1,2,3,4,5 : ";
   cin >> ord;
//   TPZCompEl::gOrder = ord;
   firstmesh.SetDefaultOrder(order);
   //construção malha computacional
   TPZVec<int> csub(0);
   TPZManVector<TPZGeoEl *> pv(4);
   int n1=1,level=0;
   cout << "\nDividir ate nivel ? ";
   int resp;
   cin >> resp;
   int nelc = firstmesh->ElementVec().NElements();
   int el;
   TPZGeoEl *cpel;
   for(el=0;el<firstmesh->ElementVec().NElements();el++) {
     cpel = firstmesh->ElementVec()[el];
     if(cpel && cpel->Level() < resp)
		cpel->Divide(pv);

   }
   cout << "\nDividir o elemento esquerdo superior quantas vezes? ";
   cin >> resp;
   cpel = firstmesh->ElementVec()[0];
   for(el=0; el<resp; el++) {
		cpel->Divide(pv);
		cpel = pv[3];
   }
   //analysis
   secondmesh->AutoBuild();
   firstmesh->Print(outgm1);
   outgm1.flush();
   secondmesh->AdjustBoundaryElements();
   secondmesh->InitializeBlock();
   secondmesh->Print(outcm1);
   TPZAnalysis an(secondmesh,outcm1);
   int numeq = secondmesh->NEquations();
   secondmesh->Print(outcm1);
   outcm1.flush();
   TPZVec<int> skyline;
   secondmesh->Skyline(skyline);
   TPZSkylMatrix *stiff = new TPZSkylMatrix(numeq,skyline);
   an.SetMatrix(stiff);
   an.Solver().SetDirect(ECholesky);
   secondmesh->SetName("Malha Computacional :  Connects e Elementos");
   // Posprocessamento
   an.Run(outcm2);
   TPZVec<char *> scalnames(5);
   scalnames[0] = "Mn1";
   scalnames[1] = "Mn2";
   scalnames[2] = "Vn1";
   scalnames[3] = "Vn2";
   scalnames[4] = "Deslocz";
   TPZVec<char *> vecnames(0);
   char plotfile[] =  "placaPos.pos";
   char pltfile[] =  "placaView.plt";
   an.DefineGraphMesh(2, scalnames, vecnames, plotfile);
   an.Print("FEM SOLUTION ",outcm1);
   an.PostProcess(3);
   an.DefineGraphMesh(2, scalnames, vecnames, pltfile);
   an.PostProcess(2);
   firstmesh->Print(outgm1);
   outgm1.flush();
   delete secondmesh;
   delete firstmesh;
   return 0;
}