예제 #1
0
파일: main.cpp 프로젝트: labmec/neopz
void RefinamentoUniforme(TPZAutoPointer<TPZGeoMesh> gmesh, int nref,TPZVec<int> dims)
{
    
    int ir, iel, k;
    int nel=0, dim=0;
    int ndims = dims.size();
	for(ir = 0; ir < nref; ir++ )
    {
		TPZVec<TPZGeoEl *> filhos;
        nel = gmesh->NElements();
        
		for (iel = 0; iel < nel; iel++ )
        {
			TPZGeoEl * gel = gmesh->ElementVec()[iel];
            if(!gel) DebugStop();
            
            dim = gel->Dimension();
            
            for(k = 0; k<ndims; k++)
            {
                if(dim == dims[k])
                {
                    gel->Divide (filhos);
                    break;
                }
            }
		}
	}
    
}
예제 #2
0
파일: Main.cpp 프로젝트: labmec/neopz
void AdjustBoundary(TPZGeoMesh *gmesh)
{
    int64_t nel = gmesh->NElements();
    for (int64_t el = 0; el<nel; el++) {
        TPZGeoEl *gel = gmesh->Element(el);
        if (gel->Dimension() == 3 || gel->HasSubElement()) {
            continue;
        }
        TPZGeoElSide gelside(gel,gel->NSides()-1);
        TPZGeoElSide neighbour = gelside.Neighbour();
        bool should_refine = false;
        int nsub = -1;
        int numneigh = 0;
        while (gelside != neighbour) {
            nsub = neighbour.Element()->NSideSubElements(neighbour.Side());
            if (neighbour.Element()->HasSubElement() && nsub > 1) {
                should_refine = true;
            }
            numneigh++;
            neighbour = neighbour.Neighbour();
        }
        if (should_refine == true) {
            TPZAutoPointer<TPZRefPattern> match = TPZRefPatternTools::PerfectMatchRefPattern(gel);
            if (!match) {
                DebugStop();
            }
            gel->SetRefPattern(match);
            TPZStack<TPZGeoEl *> subels;
            gel->Divide(subels);
        }
    }
}
예제 #3
0
파일: Main.cpp 프로젝트: labmec/neopz
void UniformRefinement(TPZGeoMesh *gMesh, int nh)
{
    for ( int ref = 0; ref < nh; ref++ ){
        TPZVec<TPZGeoEl *> filhos;
        int64_t n = gMesh->NElements();
        for ( int64_t i = 0; i < n; i++ ){
            TPZGeoEl * gel = gMesh->ElementVec() [i];
            if (gel->Dimension() == 2 || gel->Dimension() == 1) gel->Divide (filhos);
        }//for i
    }//ref
}
예제 #4
0
파일: PZ_Process.cpp 프로젝트: labmec/neopz
void UniformRefinement(int h,TPZGeoMesh *gmesh) {
	//uniform refinement
	TPZVec<TPZGeoEl *> filhos;
	for (int ref = 0; ref < h; ref++) {
		int n = gmesh->NElements();
		for(int i = 0; i < n; i++ ) {
			TPZGeoEl *gel = gmesh->ElementVec()[i];
			if(gel->Type() != EPoint) gel->Divide(filhos);  // You can to divide point element but it do nothing (only error message)
		}
	}
}
예제 #5
0
파일: LinearWave.cpp 프로젝트: labmec/neopz
void RefinamentoUniforme(TPZGeoMesh *gMesh, int nh){
	for ( int ref = 0; ref < nh; ref++ ){
		TPZVec<TPZGeoEl *> filhos;
		int n = gMesh->NElements();
		for ( int i = 0; i < n; i++ ){
			TPZGeoEl * gel = gMesh->ElementVec() [i];
			int GelDimension = gel->Dimension();
			if (GelDimension == 2 || GelDimension == 1) 
			{
				gel->Divide (filhos);
			}
		}//for i
	}//ref
}
예제 #6
0
파일: TPZSurface.cpp 프로젝트: labmec/neopz
void TPZSurface::RefineMe(int i)
{
    int nref = i;
    TPZVec<TPZGeoEl *> sons;
    for (int iref = 0; iref < nref; iref++)
    {
        int nel = fgeometricmesh->NElements();
        for (int iel = 0; iel < nel; iel++)
        {
            TPZGeoEl *gel = fgeometricmesh->ElementVec()[iel];
            if (gel->HasSubElement()) {
                continue;
            }
            gel->Divide(sons);
        }
    }
}
예제 #7
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;
}
예제 #8
0
//ofstream lula("FPD");//TESTE
int TPZCheckGeom::PerformCheck() {
	int nel = fMesh->NElements();
	int iel;
	int check = 0;
	for(iel = 0; iel<nel; iel++) {
		TPZGeoEl *gel = fMesh->ElementVec()[iel];
		if(!gel) continue;
		TPZStack<TPZGeoEl *> subel;
		gel->Divide(subel);		
		if(iel==3){//TESTE
			cout << "\nElemento PirÁmide\n";			
			//subel[0]->Print(lula);
			//lula.flush();
			//lula.close();
		}//TESTE
		if(iel == 4)
			cout << "\nElemento de Linha";
		if(iel == 5)
			cout << "\nElemento Quadrilátero\n";
		check = (CheckElement(gel) || check);
		check = (CheckRefinement(gel) || check);
	}
	return check;
}
예제 #9
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;
}
예제 #10
0
파일: main.cpp 프로젝트: labmec/neopz
TPZGeoMesh *MalhaGeom(int NRefUnif, REAL Lx, REAL Ly)
{
    int64_t Qnodes = 4;
	
	TPZGeoMesh * gmesh = new TPZGeoMesh;
	gmesh->SetMaxNodeId(Qnodes-1);
	gmesh->NodeVec().Resize(Qnodes);
	TPZVec<TPZGeoNode> Node(Qnodes);
	
	TPZVec <int64_t> TopolQuad(4);
	TPZVec <int64_t> TopolLine(2);
	
	//indice dos nos
	int64_t id = 0;
	REAL valx;
	for(int64_t xi = 0; xi < Qnodes/2; xi++)
	{
		valx = xi*Lx;
		Node[id].SetNodeId(id);
		Node[id].SetCoord(0 ,valx );//coord X
		Node[id].SetCoord(1 ,0. );//coord Y
		gmesh->NodeVec()[id] = Node[id];
		id++;
	}
	
	for(int64_t xi = 0; xi < Qnodes/2; xi++)
	{
		valx = Lx - xi*Lx;
		Node[id].SetNodeId(id);
		Node[id].SetCoord(0 ,valx );//coord X
		Node[id].SetCoord(1 ,Ly);//coord Y
		gmesh->NodeVec()[id] = Node[id];
		id++;
	}

	//indice dos elementos
	id = 0;
    
    //elementos internos
    TopolQuad[0] = 0;
	TopolQuad[1] = 1;
	TopolQuad[2] = 2;
	TopolQuad[3] = 3;
	new TPZGeoElRefPattern< pzgeom::TPZGeoQuad> (id,TopolQuad,matInterno,*gmesh);
	id++;
	    
    //elementos de contorno
	TopolLine[0] = 0;
	TopolLine[1] = 1;
	new TPZGeoElRefPattern< pzgeom::TPZGeoLinear > (id,TopolLine,bc1,*gmesh);
	id++;
	
	TopolLine[0] = 1;
	TopolLine[1] = 2;
	new TPZGeoElRefPattern< pzgeom::TPZGeoLinear > (id,TopolLine,bc2,*gmesh);
	id++;
	
	TopolLine[0] = 2;
	TopolLine[1] = 3;
	new TPZGeoElRefPattern< pzgeom::TPZGeoLinear > (id,TopolLine,bc3,*gmesh);
	id++;
	
	TopolLine[0] = 3;
	TopolLine[1] = 0;
	new TPZGeoElRefPattern< pzgeom::TPZGeoLinear > (id,TopolLine,bc4,*gmesh);
	id++;
    
    // define entre quais materiais vou criar interfaces e o terceiro argumento é o tipo de material que quero nessa interface.
    gmesh->AddInterfaceMaterial(lagrangemat,matInterno, interfacemat);
    gmesh->AddInterfaceMaterial(lagrangemat,bc1, bc1);
    gmesh->AddInterfaceMaterial(lagrangemat,bc2, bc2);
    gmesh->AddInterfaceMaterial(lagrangemat,bc3, bc3);
    gmesh->AddInterfaceMaterial(lagrangemat,bc4, bc4);

    //construir a malha
	gmesh->BuildConnectivity();
	
    
    //Refinamento uniforme
	for( int ref = 0; ref < NRefUnif; ref++ ){
		TPZVec<TPZGeoEl *> filhos;
		int64_t n = gmesh->NElements();
		for ( int64_t i = 0; i < n; i++ ){
			TPZGeoEl * gel = gmesh->ElementVec()[i];
            gel->Divide (filhos);
		}//for i
	}//ref
		
	return gmesh;
	
}
예제 #11
0
파일: placa.c 프로젝트: 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;
}
예제 #12
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;
    
}