Пример #1
0
int
Mesh::setEleArgs()
{
    // no elements
    if (OPS_GetNumRemainingInputArgs() < 1) {
        eleType = 0;
        return 0;
    }

    // get type and set info
    const char* type = OPS_GetString();
    int ndm = OPS_GetNDM();
    ID info(2);
    info(0) = 1; //save data
    info(1) = this->getTag();

    if (strcmp(type, "elasticBeamColumn") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_ElasticBeam2d;
            if (OPS_ElasticBeam2d(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
	    numelenodes = 2;
        }

    } else if(strcmp(type, "forceBeamColumn") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_ForceBeamColumn2d;
            if (OPS_ForceBeamColumn2d(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
	    numelenodes = 2;
        }

    } else if(strcmp(type, "dispBeamColumn") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_DispBeamColumn2d;
            if (OPS_DispBeamColumn2d(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
	    numelenodes = 2;
        }

    } else if(strcmp(type, "PFEMElementBubble") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_PFEMElement2DBubble;
            if (OPS_PFEMElement2DBubble(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
            fluid = true;
	    numelenodes = 3;
	    
        } else {
	    eleType = ELE_TAG_PFEMElement3DBubble;
            if (OPS_PFEMElement3DBubble(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
            fluid = true;
	    numelenodes = 4;
	}

    } else if(strcmp(type, "MINI") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_PFEMElement2Dmini;
            if (OPS_PFEMElement2Dmini(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
            fluid = true;
	    numelenodes = 3;
        }

    } else if(strcmp(type, "PFEMElementCompressible") == 0) {
        if (ndm == 2) {
            eleType = ELE_TAG_PFEMElement2DCompressible;
            if (OPS_PFEMElement2DCompressible(info) == 0) {
                opserr << "WARNING: failed to read eleArgs\n";
                return -1;
            }
            fluid = true;
	    numelenodes = 3;
        }

    } else if(strcmp(type, "tri31") == 0) {
        eleType = ELE_TAG_Tri31;
        if (OPS_Tri31(info) == 0) {
            opserr << "WARNING: failed to read eleArgs\n";
            return -1;
        }
	numelenodes = 3;

    } else if(strcmp(type, "FourNodeTetrahedron") == 0) {
        eleType = ELE_TAG_FourNodeTetrahedron;
        if (OPS_FourNodeTetrahedron(info) == 0) {
            opserr << "WARNING: failed to read eleArgs\n";
            return -1;
        }
	numelenodes = 4;
    } else if (strcmp(type, "ShellMITC4") == 0) {
	eleType = ELE_TAG_ShellMITC4;
        if (OPS_ShellMITC4(info) == 0) {
            opserr << "WARNING: failed to read eleArgs\n";
            return -1;
        }
	numelenodes = 4;
	
    } else {
        opserr << "WARNING: element "<<type<<" is not currently supported in mesh\n";
        return -1;
    }

    return 0;
}
Пример #2
0
int
TriMesh::mesh(double alpha, const ID& rtags2, const ID& rtags)
{
    // get all regions
    int numregions = rtags.Size()+rtags2.Size();
    int numpoints = 0;
    std::vector<MeshRegion*> regions(numregions);
    for(int i=0; i<rtags.Size(); i++) {
	MeshRegion* region = theDomain->getRegion(rtags(i));
	if(region == 0) {
	    opserr<<"WARNING: region "<<rtags(i)<<" is not defined\n";
	    return -1;
	}
	numpoints += region->getNodes().Size();
	regions[i] = region;
    }
    for(int i=0; i<rtags2.Size(); i++) {
	MeshRegion* region = theDomain->getRegion(rtags2(i));
	if(region == 0) {
	    opserr<<"WARNING: region "<<rtags2(i)<<" is not defined\n";
	    return -1;
	}
	numpoints += region->getNodes().Size();
	regions[i+rtags.Size()] = region;

	// remove elements
	const ID& eles = region->getExtraEles();
	for (int j=0; j<eles.Size(); j++) {
	    Element* ele = theDomain->removeElement(eles(j));
	    if (ele != 0) {
		delete ele;
	    }
	}

    }

    // get all points
    ID ptreg(0,numpoints), ptnode(0,numpoints);
    for(int i=0; i<numregions; i++) {
	const ID& nodes = regions[i]->getNodes();
	for(int j=0; j<nodes.Size(); j++) {
	    int index = ptreg.Size();
	    ptreg[index] = i;
	    ptnode[index] = nodes(j);
	}
    }

    // calling mesh generator
    TriangleMeshGenerator gen;
    for(int i=0; i<ptnode.Size(); i++) {
	// get node
	Node* theNode = theDomain->getNode(ptnode(i));
	if(theNode == 0) {
	    opserr<<"WARNING: node "<<ptnode(i)<<" is not defined\n";
	    return -1;
	}
	const Vector& crds = theNode->getCrds();
	const Vector& disp = theNode->getTrialDisp();
	if(crds.Size() < 2 || disp.Size() < 2) {
	    opserr<<"WARNING: ndm < 2 or ndf < 2\n";
	    return -1;
	}
	
	// add point
	gen.addPoint(crds(0)+disp(0), crds(1)+disp(1));
    }

    // meshing
    gen.remesh(alpha);

    // get elenodes
    std::vector<ID> regelenodes(rtags2.Size());
    for(int i=0; i<gen.getNumTriangles(); i++) {
	int p1,p2,p3;
	gen.getTriangle(i,p1,p2,p3);

	// if all connected to fixed regions
	int numfix = rtags.Size();
	if(ptreg(p1)<numfix && ptreg(p2)<numfix && ptreg(p3)<numfix) {
	    continue;
	}
	
	// which region it belongs to
	int reg = ptreg(p1);
	if(reg<numfix || (reg>ptreg(p2) && ptreg(p2)>=numfix)) reg = ptreg(p2);
	if(reg<numfix || (reg>ptreg(p3) && ptreg(p3)>=numfix)) reg = ptreg(p3);
	reg -= numfix;

	// elenodes
	int index = regelenodes[reg].Size();
	regelenodes[reg][index++] = ptnode(p1);
	regelenodes[reg][index++] = ptnode(p2);
	regelenodes[reg][index++] = ptnode(p3);
    }

    // all elenodes
    ID allelenodes;
    for(int i=0; i<(int)regelenodes.size(); i++) {
	int num = allelenodes.Size();
	int num1 = regelenodes[i].Size();
	allelenodes.resize(num+num1);
	for (int j=0; j<num1; j++) {
	    allelenodes(num+j) = regelenodes[i](j);
	}
    }

    // create elements
    std::string eletype = OPS_GetString();
    ID eletags;
    if (eletype=="PFEMElement2D") {
	if (OPS_PFEMElement2D(*theDomain,allelenodes,eletags) < 0) {
	    return -1;
	}
    } else if (eletype=="PFEMElement2DQuasi") {
	if (OPS_PFEMElement2DCompressible(*theDomain,allelenodes,eletags) < 0) {
	    return -1;
	}
    } else if (eletype=="PFEMElement2DBubble") {
	if (OPS_PFEMElement2DBubble(*theDomain,allelenodes,eletags) < 0) {
	    return -1;
	}

    }  else if (eletype=="tri31") {
	if (OPS_Tri31(*theDomain,allelenodes,eletags) < 0) {
	    return -1;
	}

    } else {
	opserr<<"WARNING: element "<<eletype.c_str()<<" can't be used for tri mesh at this time\n";
	return -1;
    }

    // add to region
    int num = 0;

    for(int i=rtags.Size(); i<numregions; i++) {
	int num1 = regelenodes[i-rtags.Size()].Size()/3;
	ID eletag(num1);
	for (int j=0; j<num1; j++) {
	    eletag(j) = eletags(num+j);
	}
	num += num1;
	regions[i]->setExtraEles(eletag);
    }
    return 0;
}