/// Delete very short fractures void TPZFracSet::DeleteVeryShortFractures(REAL length) { int64_t nel = fgmesh.NElements(); double lmin = 2000.; for (int64_t el=0; el<nel; el++) { TPZGeoEl *gel = fgmesh.Element(el); if (!gel) { continue; } int64_t inode0 = gel->NodeIndex(0); int64_t inode1 = gel->NodeIndex(1); if (gel->Neighbour(0).Element() == gel || gel->Neighbour(1).Element() == gel) { REAL l = Length(gel); if (l<lmin) { lmin = l; } if(l < length) { std::cout << "Deleting Fracture " << gel->Index() << " length " << l << std::endl; std::cout << "Index " << gel->NodeIndex(0) << " "; gel->Node(0).Print(); std::cout << "Index " << gel->NodeIndex(1) << " "; gel->Node(1).Print(); gel->RemoveConnectivities(); delete gel; fgmesh.ElementVec()[el] = 0; gel = 0; } } } std::cout << "shortest fracture length " << lmin << std::endl; }
/// Merge lines which are parallel void TPZFracSet::MergeParallelLines() { int64_t nel = fgmesh.NElements(); REAL maxcos = 0.; for (int64_t el = 0; el<nel; el++) { TPZGeoEl *gel = fgmesh.Element(el); if(!gel) continue; TPZManVector<REAL,3> dir1(3); Direction(gel, dir1); int nnodes = gel->NCornerNodes(); for(int is = 0; is<nnodes; is++) { TPZGeoElSide gelside(gel,is); TPZGeoElSide neighbour = gelside.Neighbour(); while (neighbour != gelside) { TPZManVector<REAL,3> dir2(3); Direction(neighbour.Element(), dir2); if (neighbour.Side() != is) { for (int i=0; i<3; i++) { dir2[i] *= -1.; } } REAL cosangle = 0.; for (int i=0; i<3; i++) { cosangle += dir1[i]*dir2[i]; } if (cosangle> maxcos) { maxcos = cosangle; } if (cosangle > 0.99) { std::cout << "Fractures " << gel->Index() << " and " << neighbour.Element()->Index() << " are parallel " << cosangle << "\n"; std::cout << "Index " << gel->NodeIndex(0) << " "; gel->Node(0).Print(); std::cout << "Index " << gel->NodeIndex(1) << " "; gel->Node(1).Print(); std::cout << "Index " << neighbour.Element()->NodeIndex(0) << " "; neighbour.Element()->Node(0).Print(); std::cout << "Index " << neighbour.Element()->NodeIndex(1) << " "; neighbour.Element()->Node(1).Print(); REAL l1 = Length(gel); REAL l2 = Length(neighbour.Element()); if (l1 < l2) { gel->RemoveConnectivities(); delete gel; fgmesh.ElementVec()[el] = 0; gel = 0; break; } else { neighbour.Element()->RemoveConnectivities(); int64_t neighindex = neighbour.Element()->Index(); delete neighbour.Element(); fgmesh.ElementVec()[neighindex] = 0; neighbour = gelside; } } neighbour = neighbour.Neighbour(); } if(!gel) break; } } std::cout << "max cosine angle " << maxcos << std::endl; }
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); } }