Exemplo n.º 1
0
Arquivo: placa.c Projeto: labmec/neopz
int main() {

   //malha geometrica
   TPZGeoMesh *firstmesh = new TPZGeoMesh;
   firstmesh->SetName("Malha Geometrica : Nós e Elementos");
   firstmesh->NodeVec().Resize(4);
   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.;
   coord[0] = 0;
   coord[1] = 0;
   coordtrans[0] =  ct*coord[0]-st*coord[1];
   coordtrans[1] =  st*coord[0]+ct*coord[1];
   //nos geometricos
   firstmesh->NodeVec()[0].Initialize(coordtrans,*firstmesh);
   coord[0] = 5;
   coordtrans[0] =  ct*coord[0]-st*coord[1];
   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[1].Initialize(coordtrans,*firstmesh);
   coord[0] = 5;
   coord[1] = 5;
   coordtrans[0] =  ct*coord[0]-st*coord[1];
   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[2].Initialize(coordtrans,*firstmesh);
   coord[0] = 0;
   coordtrans[0] =  ct*coord[0]-st*coord[1];
   coordtrans[1] =  st*coord[0]+ct*coord[1];
   firstmesh->NodeVec()[3].Initialize(coordtrans,*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);
   nodeindexes[0] = 0;
   nodeindexes[1] = 1;
   nodeindexes[2] = 2;
   nodeindexes[3] = 3;
    //elementos geometricos
   TPZGeoEl *elg0 = new TPZGeoElQ2d(nodeindexes,1,*firstmesh);
   TPZGeoEl *elg1 = new TPZGeoElQ2d(nodeindexes,2,*firstmesh);
   TPZGeoEl *elg2 = new TPZGeoElQ2d(nodeindexes,3,*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("placa1.dat");
   secondmesh->InsertMaterialObject(pl);
   pl = LerMaterial("placa2.dat");
   secondmesh->InsertMaterialObject(pl);
   pl = LerMaterial("placa3.dat");
   secondmesh->InsertMaterialObject(pl);
   //CC : condicões de contorno
   TPZBndCond *bc;
   REAL big = 1.e12;
   TPZFMatrix val1(6,6,0.),val2(6,1,0.);

   val1(0,0)=big;
   val1(1,1)=big;
   val1(2,2)=big;
   val1(3,3)=0.;
   val1(4,4)=0.;
   val1(5,5)=0.;

   TPZGeoElBC(elg0,5,-2,*firstmesh);
   bc = pl->CreateBC(-2,2,val1,val2);
   secondmesh->InsertMaterialObject(bc);


   TPZGeoElBC(elg0,6,-3,*firstmesh);
   bc = pl->CreateBC(-3,2,val1,val2);
   secondmesh->InsertMaterialObject(bc);

   val1(0,0)=0.;
   val1(1,1)=big;
   val1(2,2)=0.;
   val1(3,3)=big;
   val1(4,4)=0.;
   val1(5,5)=0.;

	TPZGeoElBC(elg0,4,-1,*firstmesh);
   bc = pl->CreateBC(-1,2,val1,val2);
   secondmesh->InsertMaterialObject(bc);

   val1(0,0)=big;
   val1(1,1)=0.;
   val1(2,2)=0.;
   val1(3,3)=0.;
   val1(4,4)=big;
   val1(5,5)=0.;

	TPZGeoElBC(elg0,7,-4,*firstmesh);
   bc = pl->CreateBC(-4,2,val1,val2);
   secondmesh->InsertMaterialObject(bc);

   //ordem de interpolacao
   int ord;
   cout << "Entre ordem 1,2,3,4,5 : ";
   cin >> ord;
//   TPZCompEl::gOrder = ord;
   cmesh.SetDefaultOrder(ord);
   //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);

   }
   //analysis
   secondmesh->AutoBuild();
   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] = "Sign1";
   scalnames[3] = "Sign2";
   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(2);
   an.DefineGraphMesh(2, scalnames, vecnames, pltfile);
   an.PostProcess(2);
   firstmesh->Print(outgm1);
   outgm1.flush();
   delete secondmesh;
   delete firstmesh;
   return 0;
}
Exemplo n.º 2
0
TPZCompMesh *TPZAdaptMesh::CreateCompMesh (TPZCompMesh *mesh,                                          //malha a refinar
                                           TPZVec<TPZGeoEl *> &gelstack,   //
                                           TPZVec<int> &porders) {
    
    //Cria um ponteiro para a malha geom�trica de mesh
    TPZGeoMesh *gmesh = mesh->Reference();
    if(!gmesh) {
        cout << "TPZAdaptMesh::CreateCompMesh encountered no geometric mesh\n";
        return 0;
    }
    
    //Reseta as refer�ncias do ponteiro para a malha geom�trica criada
    //e cria uma nova malha computacional baseada nesta malha geom�trica
    gmesh->ResetReference();
    TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
//    int nmat = mesh->MaterialVec().size();
  //  int m;
    
    //Cria um clone do vetor de materiais da malha mesh
    mesh->CopyMaterials(*cmesh);
    /*  for(m=0; m<nmat; m++) {
     TPZMaterial * mat = mesh->MaterialVec()[m];
     if(!mat) continue;
     mat->Clone(cmesh->MaterialVec());
     }
     */
    //Idenifica o vetor de elementos computacionais de mesh
    //  TPZAdmChunkVector<TPZCompEl *> &elementvec = mesh->ElementVec();
    
    int el,nelem = gelstack.NElements();
    //  cmesh->SetName("Antes PRefine");
    //  cmesh->Print(cout);
    for(el=0; el<nelem; el++) {
        
        //identifica os elementos geom�tricos passados em gelstack
        TPZGeoEl *gel = gelstack[el];
        if(!gel) {
            cout << "TPZAdaptMesh::CreateCompMesh encountered an null element\n";
            continue;
        }
        long celindex;
        
        //Cria um TPZIntel baseado no gel identificado
        TPZInterpolatedElement *csint;
        csint = dynamic_cast<TPZInterpolatedElement *> (cmesh->CreateCompEl(gel,celindex));
        if(!csint) continue;
        
        //Refina em p o elemento criado
        //	cmesh->SetName("depois criar elemento");
        //	cmesh->Print(cout);
        
        csint->PRefine(porders[el]);
        //	cmesh->SetName("depois prefine no elemento");
        //	cmesh->Print(cout);
    }
#ifndef CLONEBCTOO
    nelem = gmesh->NElements();
    for (el=0; el<nelem; el++) {
        TPZGeoEl *gel = gmesh->ElementVec()[el];
        if (!gel || gel->Reference()) {
            continue;
        }
        int matid = gel->MaterialId();
        if (matid < 0) {
            TPZStack<TPZCompElSide> celstack;
            int ns = gel->NSides();
            TPZGeoElSide gelside(gel,ns-1);
            gelside.HigherLevelCompElementList2(celstack, 1, 1);
            if (celstack.size()) {
                TPZStack<TPZGeoEl *> subels;
                gel->Divide(subels);
            }
        }
    }
    nelem = gmesh->NElements();
    for (el=0; el<nelem; el++) {
        TPZGeoEl *gel = gmesh->ElementVec()[el];
        if (!gel || gel->Reference()) {
            continue;
        }
        int matid = gel->MaterialId();
        if (matid < 0) {
            TPZStack<TPZCompElSide> celstack;
            int ns = gel->NSides();
            TPZGeoElSide gelside(gel,ns-1);
            gelside.EqualLevelCompElementList(celstack, 1, 0);
            if (celstack.size()) {
                long index;
                cmesh->CreateCompEl(gel, index);
            }
        }
    }
#endif
    //Mais einh!!
    //	cmesh->SetName("Antes Adjust");
    //	cmesh->Print(cout);
    cmesh->AdjustBoundaryElements();
    //  cmesh->SetName("Depois");
    //  cmesh->Print(cout);
    return cmesh;
    
}
Exemplo n.º 3
0
// Output as Mathematica format
void OutputMathematica(std::ofstream &outMath,int var,int pointsByElement,TPZCompMesh *cmesh) {
	int i, j, k, nnodes;
	int nelem = cmesh->ElementVec().NElements();
	int dim = cmesh->Dimension();   // Dimension of the model
	REAL w;
	if(var-1 < 0) var = 1;
	// Map to store the points and values 
	map<REAL,TPZVec<REAL> > Graph;
	TPZVec<REAL> tograph(4,0.);
	map<TPZVec<REAL>,REAL> Graphics;
	
	for(i=0;i<nelem;i++) {
		TPZCompEl *cel = cmesh->ElementVec()[i];
		TPZGeoEl *gel = cel->Reference();
		TPZInterpolationSpace * sp = dynamic_cast <TPZInterpolationSpace*>(cel);
		int nstates = cel->Material()->NStateVariables();
		// If var is higher than nstates of the element, go to next element
		if(var > nstates)
			continue;
		TPZVec<REAL> qsi(3,0.), sol(nstates,0.), outfem(3,0.);
		nnodes = gel->NNodes();
		if(pointsByElement < nnodes) pointsByElement = nnodes;
		for(j=0;j<gel->NNodes();j++) {
			// Get corners points to compute solution on
			gel->CenterPoint(j,qsi);
			sp->Solution(qsi,0,sol);
			cel->Reference()->X(qsi,outfem);
			// Jointed point coordinates and solution value on			
			for(k=0;k<3;k++) tograph[k] = outfem[k];
			tograph[k] = sol[var-1];
			Graph.insert(pair<REAL,TPZVec<REAL> >(outfem[0],tograph));
			Graphics.insert(pair<TPZVec<REAL>,REAL>(outfem,sol[var-1]));
			// If cel is point gets one point value
			if(cel->Type() == EPoint) {
				break;
			}
		}
		// If cel is point gets one point value
		if(cel->Type() == EPoint) continue;
		// Print another points using integration points
		TPZIntPoints *rule = NULL;
		int order = 1, npoints = 0;
		while(pointsByElement-(npoints+nnodes) > 0) {
			if(rule) delete rule;   // Cleaning unnecessary allocation
			int nsides = gel->NSides();
			// Get the integration rule to compute internal points to print, not to print
			rule = gel->CreateSideIntegrationRule(nsides-1,order);
			if(!rule) break;
			npoints = rule->NPoints();
			order += 2;
		}
		for(j=0;j<npoints;j++) {
			// Get integration points to get internal points
			rule->Point(j,qsi,w);
			sp->Solution(qsi,0,sol);
			cel->Reference()->X(qsi,outfem);
			// Jointed point coordinates and solution value on
			for(k=0;k<3;k++) tograph[k] = outfem[k];
			tograph[k] = sol[var-1];
			Graph.insert(pair<REAL,TPZVec<REAL> >(outfem[0],tograph));
			Graphics.insert(pair<TPZVec<REAL>,REAL>(outfem,sol[var-1]));
		}
	}
	
	// Printing the points and values into the Mathematica file
	outMath << "Saida = { ";
	// Formatting output
	outMath << fixed << setprecision(10);
	if(dim<2) {
		map<REAL,TPZVec<REAL> >::iterator it;
		for(it=Graph.begin();it!=Graph.end();it++) {
			if(it!=Graph.begin()) outMath << ",";
			outMath << "{";
			for(j=0;j<dim;j++)
				outMath << (*it).second[j] << ",";
			outMath << (*it).second[3] << "}";
		}
		outMath << "};" << std::endl;
		// Choose Mathematica command depending on model dimension
		outMath << "ListPlot[Saida,Joined->True]"<< endl;
	}
	else {
		map<TPZVec<REAL>,REAL>::iterator it;
		for(it=Graphics.begin();it!=Graphics.end();it++) {
			if(it!=Graphics.begin()) outMath << ",";
			outMath << "{";
			for(j=0;j<dim;j++)
				outMath << (*it).first[j] << ",";
			outMath << (*it).second << "}";
		}
		outMath << "};" << std::endl;
		outMath << "ListPlot3D[Saida]"<< endl;
	}
}
Exemplo n.º 4
0
void TPZAdaptMesh::BuildReferencePatch() {
    
    // the fGeoRef elements are a partition of the computational domain (should be)
    // create a computational element based on each reference element
    TPZGeoMesh *gmesh = fReferenceCompMesh->Reference();
    gmesh->ResetReference();
    TPZCompMesh *tmpcmesh = new TPZCompMesh (gmesh);
    int i,j;
    for (i=0;i<fGeoRef.NElements();i++){
        long index;
        tmpcmesh->CreateCompEl(fGeoRef[i],index);
    } 
    tmpcmesh->CleanUpUnconnectedNodes();
	tmpcmesh->ExpandSolution();
    TPZStack <long> patchelindex;
    TPZStack <TPZGeoEl *> toclonegel;
    TPZStack<long> elgraph;
    TPZVec<long> n2elgraph;
    TPZVec<long> n2elgraphid;
    TPZVec<long> elgraphindex;

    tmpcmesh->GetNodeToElGraph(n2elgraph,n2elgraphid,elgraph,elgraphindex);
    // we use the  node to elgraph structure to decide which elements will be included
    int clnel = tmpcmesh->NElements();
    // clnel corresponds to the number of patches
    // fPatch and fPatchIndex form a compacted list which form the patches.
    // Boundary elements will be added to each patch.
    fPatchIndex.Push(0);
    for (int ipatch=0; ipatch<clnel; ipatch++){
        tmpcmesh->GetElementPatch(n2elgraph,n2elgraphid,elgraph,elgraphindex,ipatch,patchelindex);
        for (j=0; j<patchelindex.NElements(); j++){
            TPZGeoEl *gel = tmpcmesh->ElementVec()[patchelindex[j]]->Reference();
            //      int count = 0;
            if(gel) fPatch.Push(gel);
        }
        int sum = fPatch.NElements();
        fPatchIndex.Push(sum);
    }
	
#ifdef DEBUG2 
	// CAJU TOOL
	{
		std::string filename("cMeshVtk.");
		{
			std::stringstream finalname;
			finalname << filename << 0 << ".vtk";
			ofstream file(finalname.str().c_str());
			/** @brief Generate an output of all geometric elements that have a computational counterpart to VTK */
			//static void PrintCMeshVTK(TPZGeoMesh *gmesh, std::ofstream &file, bool matColor = false);
			TPZVTKGeoMesh::PrintCMeshVTK(gmesh,file,true);
		}
		for (int ip=0; ip<clnel; ip++) {
			int firstindex = fPatchIndex[ip];
			int lastindex = fPatchIndex[ip+1];
			gmesh->ResetReference();
			tmpcmesh->LoadReferences();
			std::set<TPZGeoEl *> loaded;
			for (int ind=firstindex; ind<lastindex; ind++) {
				TPZGeoEl *gel = fPatch[ind];
				loaded.insert(gel);
			}
			int ngel = gmesh->NElements();
			for (int el=0; el<ngel; el++) {
				TPZGeoEl *gel = gmesh->ElementVec()[el];
				if (!gel) {
					continue;
				}
				if (gel->Reference() && loaded.find(gel) == loaded.end()) {
					gel->ResetReference();
				}
			}
			std::stringstream finalname;
			finalname << filename << ip+1 << ".vtk";
			ofstream file(finalname.str().c_str());
			/** @brief Generate an output of all geometric elements that have a computational counterpart to VTK */
			//static void PrintCMeshVTK(TPZGeoMesh *gmesh, std::ofstream &file, bool matColor = false);
			TPZVTKGeoMesh::PrintCMeshVTK(gmesh,file,true);
			
		}
	}
#endif
	// cleaning reference to computational elements into temporary cmesh
    gmesh->ResetReference();
    delete tmpcmesh;
	// loading references between geometric and computational meshes (originals)
    fReferenceCompMesh->LoadReferences();
}
Exemplo n.º 5
0
void TPZHierarquicalGrid::CreateGeometricElement(int n, int iel,int eldim, int elmatid, int &elid)
{
    int jump =  fBase->NNodes();
    int dim = fBase->Dimension();
    
    TPZGeoEl *gel =  fBase->ElementVec()[iel];
    int gelNodes = gel->NNodes();

    // Computing  current topology
    TPZManVector<int64_t,10> CTopology(gelNodes);
    for(int inode = 0; inode < CTopology.size(); inode++)
    {
        CTopology[inode] = gel->Node(inode).Id();
    }
    
    bool Is1D = false;
    bool Is2D = false;
    bool Is3D = false;
    
    for(int il = 1; il < (n+1); il++ )
    {
        
        switch (eldim) {
            case 0:
            {
                
                //Defining boundaries
                if (dim==0) {
                    if (il==1){
                        TPZVec<int64_t> Topology(gelNodes);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoPoint > (elid++, Topology, ffrontMatID,*fComputedGeomesh);
                    }
                    if (il==n)
                    {
                        TPZVec<int64_t> Topology(gelNodes);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoPoint > (elid++, Topology, fbackMatID,*fComputedGeomesh);
                    }
                }
                
                //                    if (dim==1) {
                //                        if (il==1){
                //                            TPZVec<int64_t> Topology(gelNodes+1);
                //                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                //                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                //                            new TPZGeoElRefPattern < pzgeom::TPZGeoLinear > (elid++, Topology, elmatid,*fComputedGeomesh);
                //                        }
                //                        if (il==n)
                //                        {
                //                            TPZVec<int64_t> Topology(gelNodes+1);
                //                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                //                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                //                            new TPZGeoElRefPattern < pzgeom::TPZGeoLinear > (elid++, Topology, elmatid,*fComputedGeomesh);
                //
                //                        }
                //                    }
                
                TPZVec<int64_t> Topology(gelNodes+1);
                Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                Topology[1]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                new TPZGeoElRefPattern < pzgeom::TPZGeoLinear > (elid++, Topology, elmatid,*fComputedGeomesh);
                Is1D = true;
            }
                break;
            case 1:
            {
                if (dim==1) {
                    if (il==1){
                        TPZVec<int64_t> Topology(gelNodes+1);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoLinear > (elid++, Topology, ffrontMatID,*fComputedGeomesh);
                    }
                    if (il==n)
                    {
                        TPZVec<int64_t> Topology(gelNodes+1);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoLinear > (elid++, Topology, fbackMatID,*fComputedGeomesh);
                    }
                }
                
                if (fIsQuad) {
                    // quadrilateras
                    TPZVec<int64_t> Topology(gelNodes+2);
                    Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                    Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                    Topology[2]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                    Topology[3]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                    new TPZGeoElRefPattern < pzgeom::TPZGeoQuad > (elid++, Topology, elmatid,*fComputedGeomesh);
                }
                else
                {
                    // triangles
                    TPZVec<int64_t> Topology(gelNodes+1);
                    Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                    Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                    Topology[2]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                    new TPZGeoElRefPattern < pzgeom::TPZGeoTriangle > (elid++, Topology, elmatid,*fComputedGeomesh);
                    
                    Topology[0]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                    Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                    Topology[2]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                    new TPZGeoElRefPattern < pzgeom::TPZGeoTriangle > (elid++, Topology, elmatid,*fComputedGeomesh);
                    
                }
                Is2D = true;
                
            }
                break;
            case 2:
            {
                
                if (dim==2) {
                    if (il==1){
                        
                        if (gel->Type() == EQuadrilateral) {
                            // quadrilateras
                            TPZVec<int64_t> Topology(gelNodes+2);
                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                            Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                            Topology[3]=fComputedGeomesh->NodeVec()[CTopology[3] + (il - 1) * jump].Id();
                            new TPZGeoElRefPattern < pzgeom::TPZGeoQuad > (elid++, Topology, ffrontMatID,*fComputedGeomesh);
                        }
                        else{
                            // triangles
                            TPZVec<int64_t> Topology(gelNodes+1);
                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                            Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                            new TPZGeoElRefPattern < pzgeom::TPZGeoTriangle > (elid++, Topology, ffrontMatID,*fComputedGeomesh);
                            
                        }
                    }
                    if (il==n)
                    {
                        if (gel->Type() == EQuadrilateral) {
                            // quadrilateras
                            TPZVec<int64_t> Topology(gelNodes+2);
                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                            Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                            Topology[3]=fComputedGeomesh->NodeVec()[CTopology[3] + (il - 0) * jump].Id();
                            new TPZGeoElRefPattern < pzgeom::TPZGeoQuad > (elid++, Topology, fbackMatID,*fComputedGeomesh);
                        }
                        else{
                            // triangles
                            TPZVec<int64_t> Topology(gelNodes+1);
                            Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                            Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                            Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                            new TPZGeoElRefPattern < pzgeom::TPZGeoTriangle > (elid++, Topology, fbackMatID,*fComputedGeomesh);
                            
                        }
                    }
                }
                
                if (!fIsTetrahedron) {

                    if (fIsPrism) {
                        // Prisms
                        TPZVec<int64_t> Topology(2*gelNodes);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[4]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        Topology[5]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoPrism > (elid++, Topology, elmatid,*fComputedGeomesh);
                    }
                    else
                    {
                        // Cubes
                        TPZVec<int64_t> Topology(gelNodes+4);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[3] + (il - 1) * jump].Id();
                        Topology[4]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[5]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        Topology[6]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                        Topology[7]=fComputedGeomesh->NodeVec()[CTopology[3] + (il - 0) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoCube > (elid++, Topology, elmatid,*fComputedGeomesh);
                    }
                }
                else
                {
                    if (fIsPrism) {
                        // Prisms
                        TPZVec<int64_t> Topology(2*gelNodes);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[4]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        Topology[5]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoPrism > (elid++, Topology, elmatid,*fComputedGeomesh);
                    }
                    else{
                        // Tetrahedron
                        TPZVec<int64_t> Topology(gelNodes+1);
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoTetrahedra > (elid++, Topology, elmatid,*fComputedGeomesh);
                        
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 1) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoTetrahedra > (elid++, Topology, elmatid,*fComputedGeomesh);
                        
                        Topology[0]=fComputedGeomesh->NodeVec()[CTopology[0] + (il - 0) * jump].Id();
                        Topology[1]=fComputedGeomesh->NodeVec()[CTopology[1] + (il - 0) * jump].Id();
                        Topology[2]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 0) * jump].Id();
                        Topology[3]=fComputedGeomesh->NodeVec()[CTopology[2] + (il - 1) * jump].Id();
                        new TPZGeoElRefPattern < pzgeom::TPZGeoTetrahedra > (elid++, Topology, elmatid,*fComputedGeomesh);
                        
                    }
                    
                }
                Is3D = true;
                
            }
                break;
            default:
            {
                std::cout << "Connection not implemented " << std::endl;
                DebugStop();
            }
                break;
        }
    }
    
    if (Is1D) {
        fComputedGeomesh->SetDimension(1);
    }
    
    if (Is2D) {
        fComputedGeomesh->SetDimension(2);
    }
    
    if (Is3D) {
        fComputedGeomesh->SetDimension(3);
    }
    
}