예제 #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
void TPZAnalysisError::ExpandConnected(TPZStack<TPZCompElSide> &singel){
	int64_t nelem = singel.NElements();
	TPZStack<TPZGeoElSide> gelstack;
	TPZStack<TPZCompElSide> celstack;
	int64_t iel;
	for(iel=0; iel<nelem; iel++) {
		TPZCompElSide celside = singel[iel];
		TPZGeoElSide gelside;
		gelside = celside.Reference();
		if(!gelside.Exists()) continue;
		gelstack.Resize(0);
		cout << "This part needs to be fixed\n";
		//		gelside.Element()->LowerDimensionSides(gelside.Side(),gelstack);
		while(gelstack.NElements()) {
			TPZGeoElSide gelsideloc;
			gelsideloc = gelstack.Pop();
			gelsideloc.EqualLevelCompElementList(celstack,1,0);
			while(celstack.NElements()) {
				TPZCompElSide celsideloc = celstack.Pop();
				if(! celsideloc.Exists()) continue;
				int64_t nelsing = singel.NElements();
				int64_t smel;
				for(smel=0; smel<nelsing; smel++) if(singel[smel].Element() == celsideloc.Element()) break;
				if(smel != nelsing) singel.Push(celsideloc);
			}
		}
	}
}
예제 #3
0
int TPZCheckGeom::CheckRefinement(TPZGeoEl *gel){
	
	int check = 0;
	if(!gel || !gel->HasSubElement()) return check;
	int nsides = gel->NSides();
	int is;
	for(is=0; is<nsides; is++) {
		TPZStack<TPZGeoElSide> subel;
		gel->GetSubElements2(is,subel);
		int nsub = subel.NElements();
		int isub;
		for(isub=0; isub<nsub; isub++) {
			TPZGeoElSide fath = subel[isub].Father2();
			int son = subel[isub].Element()->WhichSubel();
			if(fath.Side() != is) {
				PZError << "TPZCheckGeom::CheckRefinement non corresponding subelement/sides son "
				<< son << " sonside " << subel[isub].Side() << " fathside " << is <<
				" fath2side " << fath.Side() << endl;
				gel->Print();
				check = 1;
			}
		}
	}
	int nsub = gel->NSubElements();
	for(is=0; is<nsub; is++) {
		TPZGeoEl *sub = gel->SubElement(is);
		int nsubsides = sub->NSides();
		int iss;
		for(iss=0; iss<nsubsides; iss++) {
			check = (CheckSubFatherTransform(sub,iss) || check);
		}
	}
	
	return check;
}
예제 #4
0
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;
}
예제 #5
0
void TPZRefPrism::NewMidSideNode(TPZGeoEl *gel,int side,int &index) {

    MidSideNodeIndex(gel,side,index);
    if(side == 15 || side > 18) {
        return;//o nó geométrico não pode ser criado
    }
    if(index < 0) {
        TPZGeoElSide gelside = gel->Neighbour(side);
        if(gelside.Element()) {
            while(gelside.Element() != gel) {
                gelside.Element()->MidSideNodeIndex(gelside.Side(),index);
                if(index!=-1) return;
                gelside = gelside.Neighbour();
            }
        }
        TPZVec<REAL> par(3,0.);
        TPZVec<REAL> coord(3,0.);
        if(side < TPZShapePrism::NCornerNodes) {
            index = gel->NodeIndex(side);
            return;
        }
        //aqui side = 6 a 20
        side-=TPZShapePrism::NCornerNodes;//0,1,..,13
        par[0] = MidCoord[side][0];
        par[1] = MidCoord[side][1];
        par[2] = MidCoord[side][2];
        gel->X(par,coord);
        index = gel->Mesh()->NodeVec().AllocateNewElement();
        gel->Mesh()->NodeVec()[index].Initialize(coord,*gel->Mesh());
    }
}
예제 #6
0
	void TPZRefQuad::NewMidSideNode(TPZGeoEl *gel,int side,int &index) {
		
		MidSideNodeIndex(gel,side,index);
		if(index < 0) {
			TPZGeoElSide gelside = gel->Neighbour(side);
			if(gelside.Element()) {
				while(gelside.Element() != gel) {
					gelside.Element()->MidSideNodeIndex(gelside.Side(),index);
					if(index!=-1) return;
					gelside = gelside.Neighbour();
				}
			}
			TPZVec<REAL> par(3,0.);
			TPZVec<REAL> coord(3,0.);
			if(side < TPZShapeQuad::NCornerNodes) {
				index = gel->NodeIndex(side); 
				return;
			}
			//aqui side = 8 a 26
			side-=TPZShapeQuad::NCornerNodes;//0,1,..,18
			par[0] = MidCoord[side][0];
			par[1] = MidCoord[side][1];
			gel->X(par,coord);
			index = gel->Mesh()->NodeVec().AllocateNewElement();
			gel->Mesh()->NodeVec()[index].Initialize(coord,*gel->Mesh());
		}
	}
예제 #7
0
// IT IS BAD !!!! IMPROVE IT !!!
void TPZGeoCloneMesh::AddBoundaryConditionElements(TPZGeoEl *eltoadd) {
    int nsides = eltoadd->NSides();
    int is;
    for(is=0; is<nsides; is++) {
        TPZGeoElSide elside(eltoadd,is);
        TPZGeoElSide neighbour = elside.Neighbour();
#ifdef PZDEBUG
        if (!neighbour.Element()) DebugStop();
#endif
        while(neighbour != elside) {
            if(neighbour.Element()->Dimension() < eltoadd->Dimension() &&
               neighbour.Side() == neighbour.Element()->NSides() - 1
               // && neighbour.Element()->Reference()
			   ) {
			   
                TPZGeoEl *gel = neighbour.Element();
                if (HasElement(gel)) {
                    neighbour = neighbour.Neighbour();
                    continue;
                }
                TPZGeoEl *father = gel->Father();
                while(father) {
                    gel = father;
                    father = gel->Father();
                }
                CloneElement(gel);
                // verificar se neighbour.Element ja esta no map
          //      TPZGeoEl *localpatch = fMapElements[neighbour.Element()];
				TPZGeoEl *localpatch = fMapElements[gel];							// Jorge 2013/03/28
                fPatchElements.insert(localpatch);
            }
            neighbour = neighbour.Neighbour();
#ifdef PZDEBUG
            if (!neighbour.Exists()) {
                DebugStop();
            }
#endif
        }
    }
}
예제 #8
0
파일: main.cpp 프로젝트: labmec/neopz
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);
            }
        }
    }
}
예제 #9
0
파일: Main.cpp 프로젝트: labmec/neopz
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;
    
}
예제 #10
0
파일: Main.cpp 프로젝트: labmec/neopz
void InsertBoundaryElements(TPZGeoMesh *gmesh)
{
    REAL xplane = 1435;
    REAL yplane = 1161;
    REAL zplane = -1530;
    REAL ztop = 122.8;
    REAL minx = 0;
    REAL minz = 0;
    REAL maxz = 0;
    
    int64_t nel = gmesh->NElements();
    for (int64_t el=0; el<nel; el++) {
        TPZGeoEl *gel = gmesh->Element(el);
        if (gel->HasSubElement()) {
            continue;
        }
        int nsides = gel->NSides();
        for (int is=0; is<nsides; is++) {
            int bccreated = 999;
            TPZGeoElSide gelside(gel,is);
            if (gel->SideDimension(is) == 1) {
                TPZManVector<REAL,3> xcenter(3);
                gelside.CenterX(xcenter);
                if (xcenter[2] > maxz) {
                    maxz = xcenter[2];
                }
                if (fabs(xcenter[0]) < 1 && fabs(xcenter[2]-ztop) < 1) {
                    bccreated = bcloadtop;
                    TPZGeoElSide neighbour = gelside.Neighbour();
                    while (neighbour != gelside) {
                        if (neighbour.Element()->MaterialId() == bcloadtop) {
                            bccreated = 999;
                        }
                        neighbour = neighbour.Neighbour();
                        
                    }
                    if (bccreated == bcloadtop)
                    {
                        std::cout << "Added boundary bcloadtop xcenter = " << xcenter << std::endl;
                    }
                }
            }
            if (gel->SideDimension(is) == 2)
            {
                TPZManVector<REAL,3> xcenter(3);
                gelside.CenterX(xcenter);
                if (xcenter[0] < minx) {
                    minx = xcenter[0];
                }
                if (xcenter[2] < minz) {
                    minz = xcenter[2];
                }
                if (fabs(xcenter[2] - zplane) < 1.) {
                    bccreated = bcbottom;
                }
                if (fabs(fabs(xcenter[0])-xplane) < 1) {
                    bccreated = bcsidex;
                }
                if (fabs(fabs(xcenter[1])-yplane) < 1) {
                    bccreated = bcsidey;
                }
                if (fabs(xcenter[2]-ztop) <1) {
                    bccreated = bctopsurface;
                }
            }
            if(bccreated != 999)
            {
                if (gelside.Dimension() == 2 && gelside.Neighbour() != gelside) {
                    DebugStop();;
                }
                gel->CreateBCGeoEl(is, bccreated);
            }
        }
    }
    std::cout << "minx = " << minx << " minz = " << minz << " maxz " << maxz << std::endl;
}
예제 #11
0
int CompareShapeFunctions(TPZCompElSide celsideA, TPZCompElSide celsideB)
{
    TPZGeoElSide gelsideA = celsideA.Reference();
    TPZGeoElSide gelsideB = celsideB.Reference();
    int sideA = gelsideA.Side();
    int sideB = gelsideB.Side();
    TPZCompEl *celA = celsideA.Element();
    TPZCompEl *celB = celsideB.Element();    TPZMultiphysicsElement *MFcelA = dynamic_cast<TPZMultiphysicsElement *>(celA);
    TPZMultiphysicsElement *MFcelB = dynamic_cast<TPZMultiphysicsElement *>(celB);
    TPZInterpolatedElement *interA = dynamic_cast<TPZInterpolatedElement *>(MFcelA->Element(0));
    TPZInterpolatedElement *interB = dynamic_cast<TPZInterpolatedElement *>(MFcelB->Element(0));
    
    TPZMaterialData dataA;
    TPZMaterialData dataB;
    interA->InitMaterialData(dataA);
    interB->InitMaterialData(dataB);
    TPZTransform<> tr = gelsideA.NeighbourSideTransform(gelsideB);
    TPZGeoEl *gelA = gelsideA.Element();
    TPZTransform<> trA = gelA->SideToSideTransform(gelsideA.Side(), gelA->NSides()-1);
    TPZGeoEl *gelB = gelsideB.Element();
    TPZTransform<> trB = gelB->SideToSideTransform(gelsideB.Side(), gelB->NSides()-1);
    
    int dimensionA = gelA->Dimension();
    int dimensionB = gelB->Dimension();
    
    int nSideshapeA = interA->NSideShapeF(sideA);
    int nSideshapeB = interB->NSideShapeF(sideB);
    int is;
    int firstShapeA = 0;
    int firstShapeB = 0;
    for (is=0; is<sideA; is++) {
        firstShapeA += interA->NSideShapeF(is);
    }
    for (is=0; is<sideB; is++) {
        firstShapeB += interB->NSideShapeF(is);
    }
    
    TPZIntPoints *intrule = gelA->CreateSideIntegrationRule(gelsideA.Side(), 4);
    int nwrong = 0;
    int npoints = intrule->NPoints();
    int ip;
    for (ip=0; ip<npoints; ip++) {
        TPZManVector<REAL,3> pointA(gelsideA.Dimension()),pointB(gelsideB.Dimension()), pointElA(gelA->Dimension()),pointElB(gelB->Dimension());
        REAL weight;
        intrule->Point(ip, pointA, weight);
        int sidedim = gelsideA.Dimension();
        TPZFNMatrix<9> jacobian(sidedim,sidedim),jacinv(sidedim,sidedim),axes(sidedim,3);
        REAL detjac;
        gelsideA.Jacobian(pointA, jacobian, jacinv, detjac, jacinv);
        TPZManVector<REAL,3> normal(3,0.), xA(3),xB(3);
        normal[0] = axes(0,1);
        normal[1] = -axes(0,0);
        tr.Apply(pointA, pointB);
        trA.Apply(pointA, pointElA);
        trB.Apply(pointB, pointElB);
        gelsideA.Element()->X(pointElA, xA);
        gelsideB.Element()->X(pointElB, xB);
        for (int i=0; i<3; i++) {
            if(fabs(xA[i]- xB[i])> 1.e-6) DebugStop();
        }
        int nshapeA = 0, nshapeB = 0;
        interA->ComputeRequiredData(dataA, pointElA);
        interB->ComputeRequiredData(dataB, pointElB);
        nshapeA = dataA.phi.Rows();
        nshapeB = dataB.phi.Rows();
        if(nSideshapeA != nSideshapeB) DebugStop();
        
        TPZManVector<REAL> shapesA(nSideshapeA), shapesB(nSideshapeB);
        int nwrongkeep(nwrong);
        int i,j;
        for(i=firstShapeA,j=firstShapeB; i<firstShapeA+nSideshapeA; i++,j++)
        {
            int Ashapeind = i;
            int Bshapeind = j;
            int Avecind = -1;
            int Bvecind = -1;
            // if A or B are boundary elements, their shapefunctions come in the right order
            if (dimensionA != sidedim) {
                Ashapeind = dataA.fVecShapeIndex[i].second;
                Avecind = dataA.fVecShapeIndex[i].first;
            }
            if (dimensionB != sidedim) {
                Bshapeind = dataB.fVecShapeIndex[j].second;
                Bvecind = dataB.fVecShapeIndex[j].first;
            }
            if (dimensionA != sidedim && dimensionB != sidedim) {
                // vefify that the normal component of the normal vector corresponds
                Avecind = dataA.fVecShapeIndex[i].first;
                Bvecind = dataB.fVecShapeIndex[j].first;
                REAL vecnormalA = dataA.fNormalVec(0,Avecind)*normal[0]+dataA.fNormalVec(1,Avecind)*normal[1];
                REAL vecnormalB = dataB.fNormalVec(0,Bvecind)*normal[0]+dataB.fNormalVec(1,Bvecind)*normal[1];
                if(fabs(vecnormalA-vecnormalB) > 1.e-6)
                {
                    nwrong++;
                    LOGPZ_ERROR(logger, "normal vectors aren't equal")
                }
                
            }
            shapesA[i-firstShapeA] = dataA.phi(Ashapeind,0);
            shapesB[j-firstShapeB] = dataB.phi(Bshapeind,0);
            REAL valA = dataA.phi(Ashapeind,0);
            REAL valB = dataB.phi(Bshapeind,0);
            REAL diff = valA-valB;
            REAL decision = fabs(diff)-1.e-6;
            if(decision > 0.)
            {
                nwrong ++;
                std::cout << "valA = " << valA << " valB = " << valB << " Avecind " << Avecind << " Bvecind " << Bvecind <<
                " Ashapeind " << Ashapeind << " Bshapeind " << Bshapeind <<
                " sideA " << sideA << " sideB " << sideB << std::endl;
                LOGPZ_ERROR(logger, "shape function values are different")
            }
예제 #12
0
파일: TPZFracSet.cpp 프로젝트: labmec/neopz
/// 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;
}
예제 #13
0
//SingularElements(..)
void TPZAnalysisError::ZoomInSingularity(REAL csi, TPZCompElSide elside, REAL singularity_strength) {

	REAL hn = 1./pow(csi,1./singularity_strength);
	REAL Q=2.;
	REAL NcReal = log( 1.+(1./hn - 1.)*(Q - 1.) )/log(Q);
	int Nc = 0;
	while(REAL(Nc) < (NcReal+0.5)) Nc++;
	int minporder = 2;
	
	TPZStack<TPZCompElSide> ElToRefine;
	TPZStack<int> POrder;
	TPZStack<TPZGeoElSide> subelements;
	TPZStack<int64_t> csubindex;
	ElToRefine.Push(elside);
	POrder.Push(Nc);
	while(ElToRefine.NElements()) {
		/** Take the next element and its interpolation order from the stack*/
		TPZCompElSide curelside = ElToRefine.Pop();
		int curporder = POrder.Pop();
		if(!curelside.Exists()) continue;
		int64_t cindex = curelside.Element()->Index();
		if(cindex < 0) continue;
		
		/** Cast the element to an interpolated element if possible*/
		TPZCompEl *cel = curelside.Element();
		TPZInterpolatedElement *cintel = 0;
		cintel = dynamic_cast<TPZInterpolatedElement *> (cel);
		/** If the element is not interpolated, nothing to do */
		if(!cintel) continue;
		/** Set the interpolation order of the current element to curporder*/
		if(curporder == minporder) {
			cintel->PRefine(Nc);
			fSingular.Push(curelside);
		} else {
			cintel->PRefine(curporder);
			cintel->Divide(cindex,csubindex,1);
			/** Identify the subelements along the side and push them on the stack*/
		}
		TPZGeoElSide gelside = curelside.Reference();
		if(!gelside.Exists()) continue;
		gelside.GetSubElements2(subelements);
		int64_t ns = subelements.NElements();
		curporder--;
		int64_t is;
		for(is=0; is<ns; is++) {
			TPZGeoElSide sub = subelements[is];
			TPZCompElSide csub = sub.Reference();
			if(csub.Exists()) {
				ElToRefine.Push(csub);
				POrder.Push(curporder);
			}
		}
	}
	ExpandConnected(fSingular);
	
	/*
	 REAL H1_error,L2_error,estimate;
	 TPZBlock *flux=0;
	 int64_t nel = fElIndexes.NElements();
	 for(int64_t elloc=0;elloc<nel;elloc++) {
	 int64_t el = fElIndexes[elloc];
	 estimate = fElErrors[elloc];
	 REAL csi = estimate / fAdmissibleError;
	 REAL h = h_Parameter(intellist[el]);
	 REAL hn = h/pow(csi,1./.9);
	 REAL Nc = log( 1.+(h/hn - 1.)*(Q - 1.) )/log(Q);
	 if(hn > 1.3*h) hn = 2.0*h*hn / (h + hn);
	 REAL hsub = h;//100.0;//pode ser = h ; Cedric
	 TPZCompEl *locel = intellist[el];
	 //obter um subelemento que contem o ponto singular e tem tamanho <= hn
	 TPZAdmChunkVector<TPZCompEl *> sublist;
	 while(hsub > hn) {
	 TPZVec<int64_t> indexsubs;
	 int64_t index = locel->Index();
	 locel->Divide(index,indexsubs,1);
	 int64_t nsub = indexsubs.NElements();
	 TPZAdmChunkVector<TPZCompEl *> listsub(0);
	 for(int64_t k=0;k<nsub;k++) {
	 index = listsub.AllocateNewElement();
	 listsub[index] = Mesh()->ElementVec()[indexsubs[k]];
	 }
	 //existe um unico filho que contem o ponto singular
	 SingularElement(point,listsub,sublist);
	 hsub = h_Parameter(sublist[0]);
	 }
	 TPZInterpolatedElement *intel = (TPZInterpolatedElement *) locel;
	 intel->PRefine(Nc+1);
	 indexlist.Push(intel->Index());
	 //os elemento viz devem ter ordens menores a cel quanto mais longe de point
	 TPZInterpolatedElement *neighkeep,*neigh;
	 //feito s�para o caso 1d , extender para o caso geral
	 int dim = intel->Dimension();
	 if(dim != 1) {
	 cout << "TPZAnalysisError::Step3 not dimension implemented , dimension = " << intellist[el]->Dimension() << endl;
	 return ;//exit(1);
	 }
	 for(int side=0;side<2;side++) {
	 int ly = 1;
	 TPZGeoElSide neighside = intel->Reference()->Neighbour(side);
	 TPZGeoElSide neighsidekeep = neighside;
	 TPZCompElSide neighsidecomp(0,0);
	 TPZStack<TPZCompElSide> elvec(0);
	 TPZCompElSide thisside(intel,side);
	 if(!neighsidekeep.Exists()) thisside.HigherLevelElementList(elvec,1,1);
	 if(!neighsidekeep.Exists() && elvec.NElements() == 0) {
	 neighsidekeep = thisside.LowerLevelElementList(1).Reference();
	 } else if(elvec.NElements() != 0) {
	 neighsidekeep = elvec[0].Reference();
	 }
	 while(ly < (Nc+1) && neighsidekeep.Exists() && neighsidekeep.Element()->Reference()->Material()->Id() > -1) {
	 neigh = (TPZInterpolatedElement *) neighsidekeep.Element()->Reference();
	 if(neigh) {
	 neigh->PRefine(ly);
	 int otherside = (neighsidekeep.Side()+1)%2;
	 neighsidekeep.SetSide(otherside);
	 indexlist.Push(neighsidekeep.Reference().Element()->Index());
	 }
	 neighside = neighsidekeep.Neighbour();
	 while(!neighside.Exists()) {
	 neighsidecomp = neighsidekeep.Reference();
	 neighsidecomp.HigherLevelElementList(elvec,1,1);
	 if(elvec.NElements()) {
	 neighside = elvec[0].Reference();
	 break;
	 }
	 neighside = neighsidecomp.LowerLevelElementList(1).Reference();
	 if(!neighside.Exists()) break;
	 }
	 neighsidekeep = neighside;
	 ly++;
	 }
	 }
	 }//for
	 Mesh()->InitializeBlock();
	 */
}
예제 #14
0
int TPZCheckGeom::CheckSubFatherTransform(TPZGeoEl *subel, int sidesub) {
	int check = 0;
	TPZGeoElSide father = subel->Father2(sidesub);
	if(!father.Exists()) return check;
	TPZIntPoints *integ = subel->CreateSideIntegrationRule(sidesub,2);
	int subsidedim = subel->SideDimension(sidesub);
	int subdim = subel->Dimension();
	TPZTransform trans(subsidedim);
	trans = subel->BuildTransform2(sidesub,father.Element(),trans);
	int fathsidedim = father.Dimension();
	int fathdim = father.Element()->Dimension();
	int nsubsides = subel->NSides();
	int nfathsides = father.Element()->NSides();
	TPZTransform trans1 = subel->SideToSideTransform(sidesub,nsubsides-1);
	TPZTransform trans2 = father.Element()->SideToSideTransform(father.Side(),nfathsides-1);
	TPZVec<REAL> intpoint(subsidedim);
	TPZVec<REAL> sidetopoint(fathsidedim);
	TPZVec<REAL> elpoint1(subdim),elpoint2(fathdim);
	TPZVec<REAL> x1(3),x2(3);
	int nintpoints = integ->NPoints();
	int ip;
	REAL w;
	for(ip=0; ip<nintpoints; ip++) {
		integ->Point(ip,intpoint,w);
		trans.Apply(intpoint,sidetopoint);
		trans1.Apply(intpoint,elpoint1);
		trans2.Apply(sidetopoint,elpoint2);
		subel->X(elpoint1,x1);
		father.Element()->X(elpoint2,x2);
		int otherfatherside = father.Element()->WhichSide(elpoint2);
		if(otherfatherside != father.Side()) {
			int son = subel->WhichSubel();
			PZError << "TPZCheckGeom::CheckSubFatherTransform son " << son << " sidesub = "<< sidesub
			<< " fathside = " << father.Side() << " otherfatherside = " << otherfatherside << endl;
			check=1;
		}
		REAL dif = 0;
		int nx = x1.NElements();
		int ix;
		for(ix=0; ix<nx; ix++) dif += (x1[ix]-x2[ix])*(x1[ix]-x2[ix]);
		if(dif > 1.e-6) {
			int son = subel->WhichSubel();
			PZError << "TPZCheckGeom::CheckSubFatherTransform son " << son << " sidesub = "<< sidesub
			<< " fathside = " << father.Side() << " dif = " << dif << endl;
			//			subel->Print();
			check = 1;
			TPZTransform t = subel->ComputeParamTrans(father.Element(),father.Side(),sidesub);
			t.PrintInputForm(cout);
			cout << endl;
			trans.PrintInputForm(cout);
			cout << endl;
			check = 1;
		}
		
	}
	if(check == 0) {
		TPZTransform t = subel->ComputeParamTrans(father.Element(),father.Side(),sidesub);
		check = t.Compare(trans);
		if(check == 1){
			int son = subel->WhichSubel();
			PZError << "TPZCheckGeom::CheckSubFatherTransform son " << son << " sidesub = "<< sidesub
			<< " fathside = " << father.Side()  << endl;
			t.PrintInputForm(cout);
			cout << endl;
			trans.PrintInputForm(cout);
			cout << endl;
		}
		// compare t with trans
	}
	
	delete integ;
	return check;
	
}