void TPZQuadraticQuad::InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size) { TPZManVector<REAL,3> co(3),shift(3),scale(3); TPZManVector<int64_t,4> nodeindexes(NCornerNodes); for (int i=0; i<3; i++) { scale[i] = size[i]/3.; shift[i] = size[i]/2.+lowercorner[i]; } for (int i=0; i<NCornerNodes; i++) { ParametricDomainNodeCoord(i, co); co.Resize(3,0.); for (int j=0; j<3; j++) { co[j] = shift[j]+scale[j]*co[j]+(rand()*0.2/RAND_MAX)-0.1; } nodeindexes[i] = gmesh.NodeVec().AllocateNewElement(); gmesh.NodeVec()[nodeindexes[i]].Initialize(co, gmesh); } int64_t index; CreateGeoElement(gmesh, EQuadrilateral, nodeindexes, matid, index); TPZGeoEl *gel = gmesh.Element(index); int nsides = gel->NSides(); for (int is=0; is<nsides; is++) { gel->SetSideDefined(is); } gel = TPZChangeEl::ChangeToQuadratic(&gmesh, index); for (int node = gel->NCornerNodes(); node < gel->NNodes(); node++) { TPZManVector<REAL,3> co(3); gel->NodePtr(node)->GetCoordinates(co); for (int i=0; i<3; i++) { co[i] += (0.2*rand())/RAND_MAX - 0.1; } gel->NodePtr(node)->SetCoord(co); } }
int64_t TPZGeoCloneMesh::CloneElement(TPZGeoEl *orgel){ int64_t i,j; // int nnod = orgel->NNodes(); // cout << "Original element nodes = " << nnod << endl; if(HasElement(orgel)) return Index(fMapElements[orgel]); // Create a cloned element TPZGeoEl *el = InitializeClone(orgel); int64_t elindex = Index(el); // cout << "\nClonned element\n"; // el->Print(cout); //fill the map fMapElements[orgel] = el; if(elindex >= fReferenceElement.NElements()) { fReferenceElement.Resize(elindex+1,0); } fReferenceElement[elindex] = orgel; //fill the neighbours for (i=0;i<orgel->NSides();i++){ el->SetSideDefined(i); TPZGeoElSide neig = orgel->Neighbour(i); if(!neig.Element()) continue; // insert all neighbours which have been cloned as neighbours // THIS IS OVERKILL it would be suficient to insert a single neighbour while(neig.Element() != orgel) { // verify if neig.Element has been cloned if (HasElement((neig.Element()))){ TPZGeoElSide sid(el,i); // sid.SetConnectivity(sid); //SetNeighbour(i,neig); TPZGeoElSide localneig(fMapElements[neig.Element()],neig.Side()); if(!sid.NeighbourExists(localneig)) { sid.SetConnectivity(localneig); } } neig = neig.Neighbour(); } } //loop over the sons if (orgel->HasSubElement()){ int subel = orgel->NSubElements(); for (j=0;j<subel;j++){ TPZGeoEl *gelson = orgel->SubElement(j); CloneElement(gelson); fMapElements[gelson]->SetFather(el); fMapElements[gelson]->SetFather(el->Index()); el->SetSubElement(j,fMapElements[gelson]); } } // el->Print(cout); return elindex; }