示例#1
0
文件: main.cpp 项目: labmec/neopz
void LoadingRamp(REAL pseudo_t, TPZCompMesh * cmesh){
    
    if (!cmesh) {
        DebugStop();
    }
    
    TPZMaterial *mat = cmesh->FindMaterial(ERock);
    if (!mat) {
        DebugStop();
    }
    
    /// Compute the footing lenght
    REAL footing_lenght = 0;
    {
        TPZGeoMesh * gmesh = cmesh->Reference();
        if (!gmesh) {
            DebugStop();
        }
        int n_el = gmesh ->NElements();
        for (int iel = 0; iel < n_el; iel++) {
            TPZGeoEl * gel = gmesh->Element(iel);
            if (!gel) {
                DebugStop();
            }
            
            if (gel->MaterialId() != ETopBC) {
                continue;
            }
            REAL gel_length = gel->SideArea(gel->NSides() - 1);
            footing_lenght += gel_length;
        }
    }
    
    /// Apply loading
    REAL max_uy = 100.0;
    REAL min_uy = 0.0;
    
    /// Compute current displacement
//    REAL uy = (footing_lenght*(max_uy - min_uy)*pseudo_t)/100.0;
    REAL uy = (footing_lenght*(max_uy - min_uy)*pseudo_t);
    
    /// Apply current displacement
    TPZFMatrix<STATE> val2(2,1,0.);
    val2(1,0) = -uy;
    TPZBndCond * bc_top = NULL;
    bc_top = dynamic_cast<TPZBndCond *> (cmesh->FindMaterial(ETopBC));
    if (!bc_top || bc_top->Material() != mat) {
        DebugStop();
    } else {
        bc_top->Val2() = val2;
    }
    
    
}
示例#2
0
文件: Main.cpp 项目: labmec/neopz
void UniformRefinement(TPZGeoMesh * gMesh, int nh, int MatId)
{
    for ( int ref = 0; ref < nh; ref++ ){
        TPZVec<TPZGeoEl *> filhos;
        int64_t n = gMesh->NElements();
        for ( int64_t i = 0; i < n; i++ ){
            TPZGeoEl * gel = gMesh->ElementVec() [i];
            if (gel->Dimension() == 2 || gel->Dimension() == 1){
                if (gel->MaterialId()== MatId){
                    gel->Divide (filhos);
                }
            }
        }//for i
    }//ref
}
示例#3
0
/// Transfer to the geometric mesh
void TPZFracSet::ToGeoMesh()
{
    fgmesh.CleanUp();
    fgmesh.NodeVec() = fNodeVec;
    int64_t nfrac = fFractureVec.NElements();
    for (int64_t ifr = 0; ifr < nfrac; ifr++) {
        TPZManVector<int64_t,2> nodes(2);
        nodes = fFractureVec[ifr].fNodes;
        int64_t index;
        fgmesh.CreateGeoElement(EOned, nodes, fFractureVec[ifr].fMatId, index);
    }
    fgmesh.BuildConnectivity();
    
    int64_t nel = fgmesh.NElements();
    for (int64_t el=0; el<nel; el++) {
        TPZGeoEl *gel = fgmesh.Element(el);
        if(!gel) continue;
        if (gel->Neighbour(2).Element() != gel) {
            std::cout << "gel index " << el << " is overlapping with " << gel->Neighbour(2).Element()->Index() << std::endl;
            TPZGeoEl *neigh = gel->Neighbour(2).Element();
            int matid = min(gel->MaterialId(),neigh->MaterialId());
            if(gel->MaterialId() == neigh->MaterialId())
            {
                matid = gel->MaterialId();
            }
            else if(gel->MaterialId() == matid_BC || neigh->MaterialId() == matid_BC)
            {
                matid = matid_BC;
            }
            else if((gel->MaterialId() == matid_internal_frac && neigh->MaterialId() == matid_MHM_line) ||
                (gel->MaterialId() == matid_MHM_line && neigh->MaterialId() == matid_internal_frac))
            {
                matid = matid_MHM_frac;
            }
            else
            {
                DebugStop();
            }
            gel->SetMaterialId(matid);
            neigh->SetMaterialId(matid);
            // remove the element with the lowest index
            if (gel->Index() > neigh->Index())
            {
                // delete neigh
                neigh->RemoveConnectivities();
                int64_t neighindex = neigh->Index();
                delete neigh;
                fgmesh.ElementVec()[neighindex] = 0;
                std::string matname = fFractureVec[neighindex].fPhysicalName;
                fFractureVec[gel->Index()].fPhysicalName = matname + "_MHM";
            }
            else
            {
                gel->RemoveConnectivities();
                std::string matname = fFractureVec[gel->Index()].fPhysicalName;
                fFractureVec[neigh->Index()].fPhysicalName = matname + "_MHM";
                delete gel;
                fgmesh.ElementVec()[el] = 0;
            }
        }
        
    }
}
示例#4
0
void TPZAnalysisError::MathematicaPlot() {
	
	TPZGeoMesh *gmesh = fCompMesh->Reference();
	TPZAdmChunkVector<TPZGeoNode> &listnodes = gmesh->NodeVec();
	int64_t nnodes = gmesh->NNodes();
	TPZAdmChunkVector<TPZGeoNode> nodes(listnodes);
	TPZVec<int64_t> nodeindex(0);
	int64_t keepindex;
	int64_t in;
    TPZGeoNode *nodei = 0;   /// jorge 2017 - I think it's unnecessary, because if node is created its exists always
	for(in=0;in<nnodes;in++) {
		nodei = &nodes[in];
		REAL xi;
		if(nodei) xi = nodei->Coord(0);
		else continue;
		keepindex = in;
		for(int64_t jn=in;jn<nnodes;jn++) {
			TPZGeoNode *nodej = &nodes[jn];
			REAL xj;
			if(nodej) xj = nodej->Coord(0); else continue;
			if(xj < xi) {
				keepindex = jn;
				xi = xj;
			}
		}
		if(keepindex!=in) {
			TPZGeoNode commut = nodes[in];
			nodes[in] = nodes[keepindex];
			nodes[keepindex] = commut;
		}
	}
	ofstream mesh("Malha.dat");
	ofstream graph("Graphic.nb");
	mesh << "\nDistribuicao de nos\n\n";
	int64_t i;
	for(i=0;i<nnodes;i++) {
        nodei = &nodes[i];
		if(nodei) mesh << nodei->Coord(0) << endl;
	}
	//2a parte
	TPZVec<int64_t> locnodid(nnodes,0);
	TPZVec<TPZGeoEl *> gelptr(nnodes);
	int64_t nel = gmesh->NElements();
	int64_t count = 0;
	for(in=0;in<nnodes;in++) {
		nodei = &nodes[in];
		if(!nodei) continue;
		for(int64_t iel=0;iel<nel;iel++) {
			TPZGeoEl *gel = gmesh->ElementVec()[iel];
			if(!gel || !gel->Reference() || gel->MaterialId() < 0) continue;
			//int numnodes = gel->NNodes();
			int ic=0;//for(int ic=0;ic<numnodes;ic++)
			if(in==nnodes-1) ic = 1;
			if(nodei->Id() == gel->NodePtr(ic)->Id()) {
				gelptr[count] = gel;
				locnodid[count++] = ic;
				break;
            }
		}
	}
	TPZVec<int64_t> connects(nnodes);
	int64_t iel;
	for(iel=0;iel<nnodes;iel++) {
		//if(!gelptr[iel] || !(gelptr[iel]->Reference())) continue;
		connects[iel] = gelptr[iel]->Reference()->ConnectIndex(locnodid[iel]);
	}
	TPZVec<STATE> sol(nnodes);
	for(i=0; i<nnodes; i++) {
        TPZConnect *df = &fCompMesh->ConnectVec()[connects[i]];
        if(!df) {
         	cout << "\nError in structure of dates\n";
            mesh << "\nError in structure of dates\n";
            return;//exit(-1);
        }
        int64_t seqnum = df->SequenceNumber();
        int64_t pos = fCompMesh->Block().Position(seqnum);
        sol[i] = fCompMesh->Solution()(pos,0);
	}
	mesh << "\nSolucao nodal\n\n";
	for(i=0;i<nnodes;i++) {
		mesh << sol[i] << endl;
	}
	// expanding solution
	int64_t numsols = 5*(nnodes-1)+1;   // 5 values by element: 3 interpolated (interior) + 2 over corners
	TPZVec<STATE> expand_sol(numsols);
	TPZVec<REAL> expand_nodes(numsols);
 	TPZVec<REAL> qsi(1);
	int64_t exp_iel = -1;
	for(iel=0;iel<nnodes-1;iel++) {
		TPZManVector<STATE> locsol(1);
		exp_iel++;
		expand_sol[exp_iel] = sol[iel];
		qsi[0] = -1.;
		expand_nodes[exp_iel] = nodes[iel].Coord(0);
		REAL h = h_Parameter(gelptr[iel]->Reference());
		for(int i=1;i<5;i++) {
			exp_iel++;
			expand_nodes[exp_iel] = i*h/5. + nodes[iel].Coord(0);
			qsi[0] += .4;
			gelptr[iel]->Reference()->Solution(qsi,0,locsol);
			expand_sol[exp_iel] = locsol[0];
		}
	}
	expand_nodes[numsols-1] = nodes[nnodes-1].Coord(0);
	expand_sol[numsols-1] = sol[nnodes-1];
	// Mathematica output format
	graph << "list = {" << endl;
	for(int64_t isol=0;isol<numsols;isol++) {
		if(isol > 0) graph << ",";
		STATE expandsol = expand_sol[isol];
		if(fabs(expandsol) < 1.e-10) expandsol = 0.;
		graph << "{" << expand_nodes[isol] << "," << expandsol << "}";
		if( !((isol+1)%5) ) graph << endl;
	}
	graph << "\n};\n";
	graph << "ListPlot[list, PlotJoined->True, PlotRange->All];" << endl;
}
示例#5
0
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;
    
}