void TPZGeoCloneMesh::Read(TPZStream &buf, void *context) { TPZGeoMesh::Read(buf,context); try { fGeoReference = dynamic_cast<TPZGeoMesh *>(TPZPersistenceManager::GetInstance(&buf)); buf.Read<int64_t>(fMapNodes); std::map<int64_t,int64_t> MappingElements; TPZGeoEl *gelorig, *gelcloned; buf.Read<int64_t>(MappingElements); std::map<int64_t,int64_t>::iterator it = MappingElements.begin(); while(it != MappingElements.end()) { gelorig = fGeoReference->ElementVec()[it->first]; gelcloned = ElementVec()[it->second]; fMapElements.insert(std::make_pair(gelorig,gelcloned)); it++; } // Writing index of the elements in fReferenceElement TPZStack<int64_t> RefElements; buf.Read(RefElements); for(int64_t ii=0;ii<RefElements.size();ii++) { fReferenceElement.push_back(fGeoReference->ElementVec()[RefElements[ii]]); } // Reading index of the elements in fPatchElement std::set<int> PatchElements; buf.Read(PatchElements); std::set<int>::iterator itpatch = PatchElements.begin(); while(itpatch != PatchElements.end()) { fPatchElements.insert(fGeoReference->ElementVec()[*itpatch]); itpatch++; } int64_t indexroot; buf.Read(&indexroot); fGeoRoot = ElementVec()[indexroot]; } catch(const exception& e) { cout << "Exception catched! " << e.what() << std::endl; cout.flush(); } }
void RefinamentoSingular(TPZAutoPointer<TPZGeoMesh> gmesh,int nref) { int64_t nnodes = gmesh->NNodes(); int64_t in; for (in=0; in<nnodes; in++) { TPZGeoNode *gno = &gmesh->NodeVec()[in]; if (abs(gno->Coord(0))< 1.e-6 && abs(gno->Coord(1)) < 1.e-6) { break; } } if (in == nnodes) { DebugStop(); } TPZGeoElSide gelside; int64_t nelem = gmesh->NElements(); for (int64_t el = 0; el<nelem; el++) { TPZGeoEl *gel = gmesh->ElementVec()[el]; int ncorner = gel->NCornerNodes(); for (int ic=0; ic<ncorner; ic++) { int64_t nodeindex = gel->NodeIndex(ic); if (nodeindex == in) { gelside = TPZGeoElSide(gel, ic); break; } } if (gelside.Element()) { break; } } if (!gelside.Element()) { DebugStop(); } for (int iref = 0; iref <nref; iref++) { TPZStack<TPZGeoElSide> gelstack; gelstack.Push(gelside); TPZGeoElSide neighbour = gelside.Neighbour(); while (neighbour != gelside) { gelstack.Push(neighbour); neighbour = neighbour.Neighbour(); } int64_t nstack = gelstack.size(); for (int64_t ist=0; ist < nstack; ist++) { if (!gelstack[ist].Element()->HasSubElement()) { TPZVec<TPZGeoEl *> subel; gelstack[ist].Element()->Divide(subel); } } } }
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; }