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; }
TPZCompMesh *MalhaCompDois(TPZGeoMesh * gmesh, int pOrder, bool isdiscontinuous) { /// criar materiais int dim = 2; TPZMatPoisson3d *material; material = new TPZMatPoisson3d(matId,dim); TPZMaterial * mat(material); material->SetNoPenalty(); material->SetNonSymmetric(); REAL diff = -1.; REAL conv = 0.; TPZVec<REAL> convdir(3,0.); REAL flux = 0.; material->SetParameters(diff, conv, convdir); material->SetInternalFlux(flux); material->NStateVariables(); TPZCompEl::SetgOrder(pOrder); TPZCompMesh * cmesh = new TPZCompMesh(gmesh); cmesh->SetDimModel(dim); //cmesh->SetAllCreateFunctionsContinuous(); cmesh->InsertMaterialObject(mat); TPZAutoPointer<TPZFunction<STATE> > forcef = new TPZDummyFunction<STATE>(ForcingF, 5); material->SetForcingFunction(forcef); ///Inserir condicao de contorno TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.); TPZMaterial * BCond0 = material->CreateBC(mat, bc0,dirichlet, val1, val2); TPZMaterial * BCond2 = material->CreateBC(mat, bc2,dirichlet, val1, val2); TPZMaterial * BCond1 = material->CreateBC(mat, bc1,dirichlet, val1, val2); TPZMaterial * BCond3 = material->CreateBC(mat, bc3,dirichlet, val1, val2); cmesh->InsertMaterialObject(BCond0); cmesh->InsertMaterialObject(BCond1); cmesh->InsertMaterialObject(BCond2); cmesh->InsertMaterialObject(BCond3); //Ajuste da estrutura de dados computacional if (isdiscontinuous==true) { //Set discontinuous functions cmesh->SetAllCreateFunctionsDiscontinuous(); cmesh->AutoBuild(); cmesh->ExpandSolution(); cmesh->AdjustBoundaryElements(); cmesh->CleanUpUnconnectedNodes(); } else{ cmesh->SetAllCreateFunctionsContinuous(); cmesh->AutoBuild(); cmesh->ExpandSolution(); cmesh->AdjustBoundaryElements(); cmesh->CleanUpUnconnectedNodes(); } return cmesh; }
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; }
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; }
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; }
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; }
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); }
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; }
//************************************* //************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; }
TPZCompMesh *MalhaCompMultifisica(TPZGeoMesh * gmesh,TPZVec<TPZCompMesh *> meshvec, TPZMatUncoupledPoissonDisc* &mymaterial){ // Creating computational mesh for multiphysic elements gmesh->ResetReference(); TPZCompMesh *mphysics = new TPZCompMesh(gmesh); mphysics->SetAllCreateFunctionsMultiphysicElem(); int dim = 2; mphysics->SetDimModel(dim); mymaterial = new TPZMatUncoupledPoissonDisc(matId, mphysics->Dimension()); mymaterial->SetParameters(1., 1.); mymaterial->SetInternalFlux(-8.,0.); //mymaterial->SetInternalFlux(0.,0.); mymaterial->SetNonSymmetricOne(); mymaterial->SetNonSymmetricTwo(); mymaterial->SetPenaltyConstant(0., 0.); TPZMaterial * mat(mymaterial); mphysics->InsertMaterialObject(mat); TPZAutoPointer<TPZFunction<STATE> > forcef = new TPZDummyFunction<STATE>(ForcingF, 5); // // TPZAutoPointer<TPZFunction<STATE> > forcef = new TPZDummyFunction<STATE>(ForcingF); mymaterial->SetForcingFunction(forcef); ///Inserir condicao de contorno TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.); TPZMaterial * BCond0 = mymaterial->CreateBC(mat, bc0,neumann_dirichlet, val1, val2); TPZMaterial * BCond2 = mymaterial->CreateBC(mat, bc2,neumann_dirichlet, val1, val2); TPZMaterial * BCond1 = mymaterial->CreateBC(mat, bc1,dirichlet, val1, val2); TPZMaterial * BCond3 = mymaterial->CreateBC(mat, bc3,dirichlet, val1, val2); // TPZMaterial * BCond0 = mymaterial->CreateBC(mat, bc0,dirichlet, val1, val2); // TPZMaterial * BCond2 = mymaterial->CreateBC(mat, bc2,dirichlet, val1, val2); // TPZMaterial * BCond1 = mymaterial->CreateBC(mat, bc1,dirichlet, val1, val2); // TPZMaterial * BCond3 = mymaterial->CreateBC(mat, bc3,dirichlet, val1, val2); mphysics->InsertMaterialObject(BCond0); mphysics->InsertMaterialObject(BCond1); mphysics->InsertMaterialObject(BCond2); mphysics->InsertMaterialObject(BCond3); 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); mphysics->Reference()->ResetReference(); mphysics->LoadReferences(); if (disc_functions==true){ //criar elementos de interface int nel = mphysics->ElementVec().NElements(); for(int el = 0; el < nel; el++) { TPZCompEl * compEl = mphysics->ElementVec()[el]; if(!compEl) continue; int index = compEl ->Index(); if(compEl->Dimension() == mphysics->Dimension()) { TPZMultiphysicsElement * InterpEl = dynamic_cast<TPZMultiphysicsElement *>(mphysics->ElementVec()[index]); if(!InterpEl) continue; InterpEl->CreateInterfaces(); } } } return mphysics; }
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; }
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; }
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; }
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; }
int TPZGeoCloneMesh::main(){ cout << "**************************************" << endl; cout << "****** Getting Patchs!************" << endl; cout << "**************************************" << endl; /******************************************************* * Constru��o da malha * *****************************************************/ //malha quadrada de nr x nc const int numrel = 3; const int numcel = 3; // int numel = numrel*numcel; TPZVec<REAL> coord(2,0.); // criar um objeto tipo malha geometrica TPZGeoMesh geomesh; // criar nos int i,j; for(i=0; i<(numrel+1); i++) { for (j=0; j<(numcel+1); j++) { int64_t nodind = geomesh.NodeVec().AllocateNewElement(); TPZVec<REAL> coord(2); coord[0] = j;//co[nod][0]; coord[1] = i;//co[nod][1]; geomesh.NodeVec()[nodind] = TPZGeoNode(i*(numrel+1)+j,coord,geomesh); } } // cria��o dos elementos int elc, elr; TPZGeoEl *gel[numrel*numcel]; TPZVec<int64_t> indices(4); for(elr=0; elr<numrel; elr++) { for(elc=0; elc<numcel; elc++) { indices[0] = (numrel+1)*elr+elc; indices[1] = indices[0]+1; indices[3] = indices[0]+numrel+1; indices[2] = indices[1]+numrel+1; // O proprio construtor vai inserir o elemento na malha int64_t index; gel[elr*numrel+elc] = geomesh.CreateGeoElement(EQuadrilateral,indices,1,index); //gel[elr*numrel+elc] = new TPZGeoElQ2d(elr*numrel+elc,indices,1,geomesh); } } //Divis�o dos elementos TPZVec<TPZGeoEl *> sub; gel[0]->Divide(sub); // gel[1]->Divide(sub); // gel[3]->Divide(sub); ofstream output("patches.dat"); geomesh.Print(output); // TPZGeoElBC t3(gel[0],4,-1,geomesh); // TPZGeoElBC t4(gel[numel-1],6,-2,geomesh); geomesh.Print(output); geomesh.BuildConnectivity(); std::set <TPZGeoEl *> patch; TPZCompMesh *comp = new TPZCompMesh(&geomesh); // inserir os materiais TPZMaterial *meumat = new TPZElasticityMaterial(1,1.e5,0.2,0,0); comp->InsertMaterialObject(meumat); // inserir a condicao de contorno // TPZFMatrix val1(3,3,0.),val2(3,1,0.); // TPZMaterial *bnd = meumat->CreateBC (-1,0,val1,val2); // comp->InsertMaterialObject(bnd); // TPZFMatrix val3(3,3,1); // bnd = meumat->CreateBC (-2,1,val3,val2); // comp->InsertMaterialObject(bnd); comp->AutoBuild(); comp->Print(output); output.flush(); /********************************************************************** * Cria��o de uma malha computacional clone * ********************************************************************/ comp->GetRefPatches(patch); geomesh.ResetReference(); TPZStack <int64_t> patchel; TPZStack <TPZGeoEl *> toclonegel; TPZStack <int64_t> patchindex; TPZVec<int64_t> n2elgraph; TPZVec<int64_t> n2elgraphid; TPZStack<int64_t> elgraph; TPZVec<int64_t> elgraphindex; int64_t k; TPZCompMesh *clonecmesh = new TPZCompMesh(&geomesh); cout << "Check 1: number of reference elements for patch before createcompel: " << patch.size() << endl; std::set<TPZGeoEl *>::iterator it; for (it=patch.begin(); it!=patch.end(); it++) { //patch[i]->Print(cout); int64_t index; TPZGeoEl *gel = *it; clonecmesh->CreateCompEl(gel, index); // patch[i]->CreateCompEl(*clonecmesh,i); } // cout << "Check 2: number of reference elements for patch after createcompel: " << patch.NElements() << endl; clonecmesh->CleanUpUnconnectedNodes(); // clonecmesh->Print(cout); clonecmesh->GetNodeToElGraph(n2elgraph,n2elgraphid,elgraph,elgraphindex); int64_t clnel = clonecmesh->NElements(); // cout << "Number of elements in clonemessh: " << clnel << endl; //o primeiro patch come�a em zero patchindex.Push(0); for (i=0; i<clnel; i++){ //cout << endl << endl << "Evaluating patch for element: " << i << endl; clonecmesh->GetElementPatch(n2elgraph,n2elgraphid,elgraph,elgraphindex,i,patchel); cout << "Patch elements: " << patchel.NElements() << endl; /*for (k=0;k<patchel.NElements();k++){ clonecmesh->ElementVec()[patchel[k]]->Reference()->Print(); cout << endl; }*/ for (j=0; j<patchel.NElements(); j++){ //obten��o do elemento geom�trico do patch //cout << "Creating geometric clone elements for computational element :" << j << endl; TPZGeoEl *gel = clonecmesh->ElementVec()[patchel[j]]->Reference(); //gel->Print(cout); //inserir todos os pais do elemento geom�trico do patch int64_t count = 0; //cout << "Inserting father element:" << "\t"; while(gel){ TPZGeoEl *father = gel->Father(); if (father){ //father->Print(cout); gel = father; continue; } else toclonegel.Push(gel); gel = father; //cout << count << "\t"; count ++; } //cout << endl; } int64_t sum = toclonegel.NElements()-1; //cout << endl << sum << endl; patchindex.Push(sum); /*for (k=patchindex[i];k<patchindex[i+1];k++){ toclonegel[k]->Print(); }*/ } cout <<endl; cout << endl; TPZGeoCloneMesh geoclone(&geomesh); TPZStack<TPZGeoEl*> testpatch; for (j=0; j<1/*patchindex.NElements()-1*/;j++){ cout << "\n\n\nClone do Patch do elemento: " << j <<endl; k=0; cout << patchindex[j] << "\t" << patchindex[j+1] <<endl; for (i=patchindex[j];i<=patchindex[j+1];i++){ testpatch.Push(toclonegel[i]); toclonegel[i]->Print(); cout << k << endl; k++; } geoclone.SetElements(testpatch,testpatch[patchindex[j]]); geoclone.Print(cout); } //geoclone.SetElements(testpatch); //geoclone.Print(cout); /************************************************************************** * Fim da cria��o do clone **************************************************************************/ /* output <<"Impress�o dos Pathces\nN�mero total de patches encontrados\t" << patchindex.NElements()-1 << endl; cout << "\n\n&&&&&&&&&&&&&&&&&&&&&&&&\n N�mero total de patches: " << patchindex.NElements()-1 << endl << "&&&&&&&&&&&&&&&&&&&&&&&&" << endl; for (i=0;i<patchindex.NElements()-1;i++){ cout << "Patch do elemento " << i << "\t" << "N�mero de elementos componentes do patch: " << (patchindex[i+1]-patchindex[i]) << endl; for (j = patchindex[i]; j<patchindex[i+1]; j++){ toclonegel[j]->Print(); cout << "||||||||||||||||||||||||||||||||" << endl; } cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" <<">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"; cout.flush(); } */ comp->LoadReferences(); cout.flush(); cout << endl; cout.flush(); delete comp; delete clonecmesh; return (0); }
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; }
//************************************* //************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; }
TPZCompMesh * CMeshFooting2D(TPZGeoMesh * gmesh, int p_order){ unsigned int dim = gmesh->Dimension(); const std::string name("ElastoPlastic Footing Problem "); // Setting up attributes TPZCompMesh * cmesh = new TPZCompMesh(gmesh); cmesh->SetName(name); cmesh->SetDefaultOrder(p_order); cmesh->SetDimModel(dim); // Mohr Coulomb data REAL mc_cohesion = 10.0; REAL mc_phi = (20.0*M_PI/180); REAL mc_psi = mc_phi; /// ElastoPlastic Material using Mohr Coulomb // Elastic predictor TPZElasticResponse ER; REAL G = 400*mc_cohesion; REAL nu = 0.3; REAL E = 2.0*G*(1+nu); TPZPlasticStepPV<TPZYCMohrCoulombPV, TPZElasticResponse> LEMC; ER.SetEngineeringData(E, nu); LEMC.SetElasticResponse(ER); LEMC.fYC.SetUp(mc_phi, mc_psi, mc_cohesion, ER); int PlaneStrain = 1; // TPZElasticCriterion MatEla; // MatEla.SetElasticResponse(ER); // TPZMatElastoPlastic2D < TPZElasticCriterion, TPZElastoPlasticMem > * material = new TPZMatElastoPlastic2D < TPZElasticCriterion, TPZElastoPlasticMem >(ERock,PlaneStrain); // material->SetPlasticityModel(MatEla); // cmesh->InsertMaterialObject(material); TPZMatElastoPlastic2D < TPZPlasticStepPV<TPZYCMohrCoulombPV, TPZElasticResponse>, TPZElastoPlasticMem > * material = new TPZMatElastoPlastic2D < TPZPlasticStepPV<TPZYCMohrCoulombPV, TPZElasticResponse>, TPZElastoPlasticMem >(ERock,PlaneStrain); material->SetPlasticityModel(LEMC); cmesh->InsertMaterialObject(material); TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.); val2(0,0) = 0; val2(1,0) = 1; TPZBndCond * bc_bottom = material->CreateBC(material, EBottomBC, Eu_null, val1, val2); val2(0,0) = 1; val2(1,0) = 0; TPZBndCond * bc_lateral = material->CreateBC(material, ELateralBC, Eu_null, val1, val2); // val2(0,0) = 0; // val2(1,0) = 0; // val1(0,0) = 0; // val1(1,1) = 1; val2(0,0) = 0; val2(1,0) = 0; TPZBndCond * bc_top = material->CreateBC(material, ETopBC, ETn, val1, val2); val2(0,0) = 0; val2(1,0) = 0; TPZBndCond * bc_top_null = material->CreateBC(material, ETopNullBC, ETn, val1, val2); cmesh->InsertMaterialObject(bc_bottom); cmesh->InsertMaterialObject(bc_lateral); cmesh->InsertMaterialObject(bc_top); // cmesh->InsertMaterialObject(bc_top_null); cmesh->SetAllCreateFunctionsContinuousWithMem(); cmesh->AutoBuild(); #ifdef PZDEBUG std::ofstream out("cmesh.txt"); cmesh->Print(out); #endif return cmesh; }
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); }
//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; }
TPZCompMesh * CompMesh(TPZGeoMesh *gmesh, int porder) { /// criar materiais int dim = gmesh->Dimension(); TPZCompMesh * cmesh = new TPZCompMesh(gmesh); TPZMatLaplacian *material = new TPZMatLaplacian(1,dim); // TPZAutoPointer<TPZFunction<REAL> > forcef = new TPZDummyFunction<REAL>(ForceSuave); // material->SetForcingFunction(forcef); TPZAutoPointer<TPZFunction<STATE> > force; TPZDummyFunction<STATE> *dum; dum = new TPZDummyFunction<STATE>(ForceSuave); dum->SetPolynomialOrder(20); force = dum; material->SetForcingFunction(force); TPZAutoPointer<TPZFunction<STATE> > solExata= new TPZDummyFunction<STATE>(SolSuave); material->SetForcingFunctionExact(solExata); TPZMaterial * mat(material); cmesh->InsertMaterialObject(mat); cmesh->SetDimModel(dim); cmesh->SetDefaultOrder(porder); ///Inserir condicao de contorno TPZFMatrix<STATE> val1(2,2,1.), val2(2,1,0.); //BC -1 TPZMaterial * BCondD1 = material->CreateBC(mat, bc1,dirichlet, val1, val2); TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet1 = new TPZDummyFunction<REAL>(DirichletSuave); BCondD1->SetForcingFunction(bcmatDirichlet1); cmesh->InsertMaterialObject(BCondD1); //BC -2 TPZMaterial * BCondD2 = material->CreateBC(mat, bc2,dirichlet, val1, val2); TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet2 = new TPZDummyFunction<REAL>(DirichletSuave); BCondD2->SetForcingFunction(bcmatDirichlet2); cmesh->InsertMaterialObject(BCondD2); //BC -3 TPZMaterial * BCondD3 = material->CreateBC(mat, bc3,dirichlet, val1, val2); TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet3 = new TPZDummyFunction<REAL>(DirichletSuave); BCondD3->SetForcingFunction(bcmatDirichlet3); cmesh->InsertMaterialObject(BCondD3); //BC -4 TPZMaterial * BCondD4 = material->CreateBC(mat, bc4,dirichlet, val1, val2); TPZAutoPointer<TPZFunction<REAL> > bcmatDirichlet4 = new TPZDummyFunction<REAL>(DirichletSuave); BCondD4->SetForcingFunction(bcmatDirichlet4); cmesh->InsertMaterialObject(BCondD4); //Fazendo auto build cmesh->SetAllCreateFunctionsContinuous(); cmesh->AutoBuild(); cmesh->AdjustBoundaryElements(); cmesh->CleanUpUnconnectedNodes(); return cmesh; }
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; }
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; }
TPZCompMesh*MalhaComp(TPZGeoMesh * gmesh, int pOrder) { /// criar materiais int dim = 2; TPZElasticityHybridMaterial *material = new TPZElasticityHybridMaterial(matInterno, 1., 1., 10., 10.); TPZElasticityHybridMaterial *matlagrange = new TPZElasticityHybridMaterial(lagrangemat, 1., 1., 0., 0.); TPZElasticityHybridMaterial *matinterface = new TPZElasticityHybridMaterial(interfacemat, 1., 1., 0., 0.); TPZMaterial * mat1(material); TPZMaterial * mat2(matlagrange); TPZMaterial * mat3(matinterface); material->NStateVariables(); matlagrange->NStateVariables(); matinterface->NStateVariables(); TPZCompEl::SetgOrder(pOrder); TPZCompMesh * cmesh = new TPZCompMesh(gmesh); cmesh->SetDimModel(dim); cmesh->InsertMaterialObject(mat1); cmesh->InsertMaterialObject(mat2); cmesh->InsertMaterialObject(mat3); ///Inserir condicao de contorno TPZFMatrix<STATE> val1(2,2,0.), val2(2,1,0.); REAL uN=0.; val2(0,0)=uN; TPZMaterial * BCondN1 = material->CreateBC(mat1, bc1,neumann, val1, val2); cmesh->InsertMaterialObject(BCondN1); TPZMaterial * BCondN2 = material->CreateBC(mat1, bc3,neumann, val1, val2); cmesh->InsertMaterialObject(BCondN2); TPZFMatrix<STATE> val12(2,2,0.), val22(2,1,0.); REAL uD=0.; val22(0,0)=uD; TPZMaterial * BCondD1 = material->CreateBC(mat1, bc2,dirichlet, val12, val22); cmesh->InsertMaterialObject(BCondD1); TPZMaterial * BCondD2 = material->CreateBC(mat1, bc4,dirichlet, val12, val22); cmesh->InsertMaterialObject(BCondD2); cmesh->SetAllCreateFunctionsContinuous(); set<int> SETmat1; SETmat1.insert(bc1); SETmat1.insert(bc2); SETmat1.insert(bc3); SETmat1.insert(bc4); //criar set dos materiais std::set<int> MaterialIDs; std::set<int> BCMaterialIDs; MaterialIDs.insert(matInterno); // MaterialIDs.insert(lagrangemat); // MaterialIDs.insert(interfacemat); // MaterialIDs.insert(bc1); // MaterialIDs.insert(bc2); // MaterialIDs.insert(bc3); // MaterialIDs.insert(bc4); BCMaterialIDs.insert(bc1); BCMaterialIDs.insert(bc2); BCMaterialIDs.insert(bc3); BCMaterialIDs.insert(bc4); TPZBuildMultiphysicsMesh::BuildHybridMesh(cmesh, MaterialIDs, BCMaterialIDs, lagrangemat, interfacemat); return cmesh; }