예제 #1
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);
        }
    }
}
예제 #2
0
TPZGeoEl* TPZGeoCloneMesh::InitializeClone(TPZGeoEl *orgel){
    
    TPZManVector<int64_t,27> clonindex(orgel->NNodes(),-1);
    int64_t nnod = orgel->NNodes();
    for (int64_t i=0; i<nnod; i++){
        int64_t nodindex = orgel->NodeIndex(i);	
        if (!HasNode(nodindex)){
            //  cout << "Cloning node " << nodindex << "  resulting node ";
            clonindex[i] = CloneNode(nodindex);
            //      cout << clonid << endl;
        }
        else{
            clonindex[i] = fMapNodes[nodindex];
        }
//        el->SetNodeIndex(i,clonid);
    }

    // the nodeindexes of the new element are equal to the node indexes of the original mesh?
    int64_t index;
    TPZGeoEl *gel = CreateGeoElement((MElementType)orgel->Type(),clonindex,orgel->MaterialId(),index);
    gel->SetRefPattern(orgel->GetRefPattern());
    return gel;
    //   TPZGeoEl1d *el1d = dynamic_cast<TPZGeoEl1d *>(org);
    //   if (el1d){
    //     TPZVec<int> ni(2,0);
    //     for (i=0;i<2;i++){
    //       ni[i]=el1d->NodeIndex(i);
    //     }
    //     TPZGeoEl1d *gel = new TPZGeoEl1d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElC3d *elc3d = dynamic_cast<TPZGeoElC3d *>(org);
    //   if (elc3d) {
    //     TPZVec<int> ni(8,0);
    //     for (i=0;i<8;i++){
    //       ni[i]=elc3d->NodeIndex(i);
    //     }
    //     TPZGeoElC3d *gel = new TPZGeoElC3d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElPi3d *elpi3d = dynamic_cast<TPZGeoElPi3d *>(org);
    //   if (elpi3d) {
    //     TPZVec<int> ni(5,0);
    //     for (i=0;i<5;i++){
    //       ni[i]=elpi3d->NodeIndex(i);
    //     }
    //     TPZGeoElPi3d *gel = new TPZGeoElPi3d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElPoint *elpoint = dynamic_cast<TPZGeoElPoint *>(org);
    //   if (elpoint) {
    //     TPZVec<int> ni(1,0);
    //     for (i=0;i<1;i++){
    //       ni[i]=elpoint->NodeIndex(i);
    //     }
    //     TPZGeoElPoint *gel = new TPZGeoElPoint (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElPr3d *elpr3d = dynamic_cast<TPZGeoElPr3d *>(org);
    //   if (elpr3d) {
    //     TPZVec<int> ni(6,0);
    //     for (i=0;i<6;i++){
    //       ni[i]=elpr3d->NodeIndex(i);
    //     }
    //     TPZGeoElPr3d *gel = new TPZGeoElPr3d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElQ2d *elq2d = dynamic_cast<TPZGeoElQ2d *>(org);
    //   if (elq2d) {
    //     TPZVec<int> ni(4,0);
    //     for (i=0;i<4;i++){
    //       ni[i]=elq2d->NodeIndex(i);
    //     }
    //     TPZGeoElQ2d *gel = new TPZGeoElQ2d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElT2d *elt2d = dynamic_cast<TPZGeoElT2d *>(org);
    //   if (elt2d) {
    //     TPZVec<int> ni(3,0);
    //     for (i=0;i<3;i++){
    //       ni[i]=elt2d->NodeIndex(i);
    //     }
    //     TPZGeoElT2d *gel = new TPZGeoElT2d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   TPZGeoElT3d *elt3d = dynamic_cast<TPZGeoElT3d *>(org);
    //   if (elt3d) {
    //     TPZVec<int> ni(4,0);
    //     for (i=0;i<4;i++){
    //       ni[i]=elt3d->NodeIndex(i);
    //     }
    //     TPZGeoElT3d *gel = new TPZGeoElT3d (ni,org->MaterialId(),*this);
    //     return gel;
    //   }
    //   return 0;
}