当前位置: 首页>>代码示例>>C++>>正文


C++ Domain::addNode方法代码示例

本文整理汇总了C++中Domain::addNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Domain::addNode方法的具体用法?C++ Domain::addNode怎么用?C++ Domain::addNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Domain的用法示例。


在下文中一共展示了Domain::addNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// main routine
int main(int argc, char **argv)
{
    //
    //	now create a domain and a modelbuilder
    //  and build the model
    //

    Domain *theDomain = new Domain();
    
    // create the nodes using constructor: 
    //		Node(tag, ndof, crd1, crd2)
    // and then add them to the domain
    
    Node *node1 = new Node(1, 2,   0.0,  0.0);
    Node *node2 = new Node(2, 2, 144.0,  0.0);
    Node *node3 = new Node(3, 2, 168.0,  0.0);    
    Node *node4 = new Node(4, 2,  72.0, 96.0);        
    theDomain->addNode(node1);
    theDomain->addNode(node2);
    theDomain->addNode(node3);
    theDomain->addNode(node4);
    
    // create an elastic material using constriuctor:  
    //		ElasticMaterialModel(tag, E)

    UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000);
    
    // create the truss elements using constructor:
    //		Truss(tag, dim, nd1, nd2, Material &,A)
    // and then add them to the domain
    
    Truss *truss1 = new Truss(1, 2, 1, 4, *theMaterial, 10.0);
    Truss *truss2 = new Truss(2, 2, 2, 4, *theMaterial,  5.0);    
    Truss *truss3 = new Truss(3, 2, 3, 4, *theMaterial,  5.0);        
    theDomain->addElement(truss1);
    theDomain->addElement(truss2);
    theDomain->addElement(truss3);    
    
    // create the single-point constraint objects using constructor:
    //		SP_Constraint(tag, nodeTag, dofID, value)
    // and then add them to the domain
    
    SP_Constraint *sp1 = new SP_Constraint(1, 1, 0, 0.0);
    SP_Constraint *sp2 = new SP_Constraint(2, 1, 1, 0.0);    
    SP_Constraint *sp3 = new SP_Constraint(3, 2, 0, 0.0);
    SP_Constraint *sp4 = new SP_Constraint(4, 2, 1, 0.0);    
    SP_Constraint *sp5 = new SP_Constraint(5, 3, 0, 0.0);
    SP_Constraint *sp6 = new SP_Constraint(6, 3, 1, 0.0);        
    theDomain->addSP_Constraint(sp1);
    theDomain->addSP_Constraint(sp2);
    theDomain->addSP_Constraint(sp3);
    theDomain->addSP_Constraint(sp4);    
    theDomain->addSP_Constraint(sp5);    
    theDomain->addSP_Constraint(sp6);    

    // construct a linear time series object using constructor:
    //		LinearSeries()
    
    TimeSeries *theSeries = new LinearSeries();
    
    // construct a load pattren using constructor:
    //		LoadPattern(tag)
    // and then set it's TimeSeries and add it to the domain
    
    LoadPattern *theLoadPattern = new LoadPattern(1);
    theLoadPattern->setTimeSeries(theSeries);
    theDomain->addLoadPattern(theLoadPattern);
    
    // construct a nodal load using constructor:
    //		NodalLoad(tag, nodeID, Vector &)
    // first construct a Vector of size 2 and set the values NOTE C INDEXING
    // then construct the load and add it to the domain
    
    Vector theLoadValues(2);
    theLoadValues(0) = 100.0;
    theLoadValues(1) = -50.0;
    NodalLoad *theLoad = new NodalLoad(1, 4, theLoadValues);
    theDomain->addNodalLoad(theLoad, 1);

    // create an Analysis object to perform a static analysis of the model
    //  - constructs:
    //    AnalysisModel of type AnalysisModel,
    //	  EquiSolnAlgo of type Linear
    //	  StaticIntegrator of type LoadControl
    //	  ConstraintHandler of type Penalty
    //    DOF_Numberer which uses RCM
    //    LinearSOE of type Band SPD
    // and then the StaticAnalysis object
    
    AnalysisModel     *theModel = new AnalysisModel();
    EquiSolnAlgo      *theSolnAlgo = new Linear();
    StaticIntegrator  *theIntegrator = new LoadControl(1.0, 1, 1.0, 1.0);
    ConstraintHandler *theHandler = new PenaltyConstraintHandler(1.0e8,1.0e8);
    RCM               *theRCM = new RCM();
    DOF_Numberer      *theNumberer = new DOF_Numberer(*theRCM);    
    BandSPDLinSolver  *theSolver = new BandSPDLinLapackSolver();       
    LinearSOE         *theSOE = new BandSPDLinSOE(*theSolver);        

    StaticAnalysis    theAnalysis(*theDomain,
//.........这里部分代码省略.........
开发者ID:lge88,项目名称:OpenSees,代码行数:101,代码来源:main.cpp

示例2: main

int main(int argc, char **argv)
{
    //  first build our error handler
    g3ErrorHandler = new ConsoleErrorHandler();

    //
    //	now create a domain and a modelbuilder
    //  and build the model
    //

    //  Domain *theDomain = new Domain();

    MapOfTaggedObjects theStorage;
    //  ArrayOfTaggedObjects theStorage(32);    
    Domain *theDomain = new Domain(theStorage);
    
    // create the nodes using constructor: 
    //		Node(tag, ndof, crd1, crd2, crd3 )
    // and then add them to the domain
    
    Node *node1 = new Node(1, 3, 1.0, 1.0, 0.0 );
    Node *node2 = new Node(2, 3, 0.0, 1.0, 0.0 );
    Node *node3 = new Node(3, 3, 0.0, 0.0, 0.0 );    
    Node *node4 = new Node(4, 3, 1.0, 0.0, 0.0 );        
    Node *node5 = new Node(5, 3, 1.0, 1.0, 1.0 );
    Node *node6 = new Node(6, 3, 0.0, 1.0, 1.0 );
    Node *node7 = new Node(7, 3, 0.0, 0.0, 1.0 );    
    Node *node8 = new Node(8, 3, 1.0, 0.0, 1.0 );        
   
    theDomain->addNode(node1);
    theDomain->addNode(node2);
    theDomain->addNode(node3);
    theDomain->addNode(node4);
    theDomain->addNode(node5);
    theDomain->addNode(node6);
    theDomain->addNode(node7);
    theDomain->addNode(node8);
    
    // create an elastic isotropic 3D material using constriuctor:  
    //		ElasticIsotropic3D(tag, E, v)

    NDMaterial *theMaterial = new ElasticIsotropic3D(1, 3000, 0.3);
    
    // create the EightNodeBrick elements using constructor:
    //		EightNodeBrick(tag, nd1, nd2, nd3, nd4, nd5, nd6, nd7, nd8, 
    //                           Material &, const *char type, double bodyforce1, double bodyforce2,
    //			         double pressure, double rho, EPState *InitEPS)
    // and then add them to the domain
        
    // For elastic material, no EPState, just supply null.
    EPState *eps = 0; 
    EightNodeBrick *brick = new EightNodeBrick(1, 5, 6, 7, 8, 1, 2, 3, 4,
                              theMaterial, "ElasticIsotropic3D", 
			      0.0, 0.0, 0.0, 1.8, eps);        
    
    theDomain->addElement( brick );    
    
    // create the single-point constraint objects using constructor:
    //		SP_Constraint(tag, nodeTag, dofID, value)
    // and then add them to the domain
    
    SP_Constraint *sp1  = new SP_Constraint(1,  1, 0, 0.0);
    SP_Constraint *sp2  = new SP_Constraint(2,  1, 1, 0.0);    
    SP_Constraint *sp3  = new SP_Constraint(3,  1, 2, 0.0);
    SP_Constraint *sp4  = new SP_Constraint(4,  2, 0, 0.0);    
    SP_Constraint *sp5  = new SP_Constraint(5,  2, 1, 0.0);
    SP_Constraint *sp6  = new SP_Constraint(6,  2, 2, 0.0);        
    SP_Constraint *sp7  = new SP_Constraint(7,  3, 0, 0.0);
    SP_Constraint *sp8  = new SP_Constraint(8,  3, 1, 0.0);    
    SP_Constraint *sp9  = new SP_Constraint(9,  3, 2, 0.0);
    SP_Constraint *sp10 = new SP_Constraint(10, 4, 0, 0.0);    
    SP_Constraint *sp11 = new SP_Constraint(11, 4, 1, 0.0);
    SP_Constraint *sp12 = new SP_Constraint(12, 4, 2, 0.0);        

    theDomain->addSP_Constraint(sp1 );
    theDomain->addSP_Constraint(sp2 );
    theDomain->addSP_Constraint(sp3 );
    theDomain->addSP_Constraint(sp4 );    
    theDomain->addSP_Constraint(sp5 );    
    theDomain->addSP_Constraint(sp6 );    
    theDomain->addSP_Constraint(sp7 );
    theDomain->addSP_Constraint(sp8 );
    theDomain->addSP_Constraint(sp9 );
    theDomain->addSP_Constraint(sp10);    
    theDomain->addSP_Constraint(sp11);    
    theDomain->addSP_Constraint(sp12);    

    // construct a linear time series object using constructor:
    //		LinearSeries()
    
    TimeSeries *theSeries = new LinearSeries();
    
    // construct a load pattren using constructor:
    //		LoadPattern(tag)
    // and then set it's TimeSeries and add it to the domain
    
    LoadPattern *theLoadPattern = new LoadPattern(1);
    theLoadPattern->setTimeSeries(theSeries);
    theDomain->addLoadPattern(theLoadPattern);
    
//.........这里部分代码省略.........
开发者ID:DBorello,项目名称:OpenSees,代码行数:101,代码来源:main_ElasticIsotropic3D.cpp

示例3: while

int
TetMesh::remesh(double alpha)
{
    int ndm = OPS_GetNDM();
    if (ndm != 3) {
	opserr << "WARNING: TetMesh::remesh is only for 3D problem\n";
	return -1;
    }
    Domain* domain = OPS_GetDomain();
    if (domain == 0) {
        opserr << "WARNING: domain is not created\n";
        return -1;
    }

    // get all nodes
    std::map<int, std::vector<int> > ndinfo;
    TaggedObjectIter& meshes = OPS_getAllMesh();
    ID nodetags;
    Mesh* msh = 0;
    while((msh = dynamic_cast<Mesh*>(meshes())) != 0) {

        int id = msh->getID();
        int mtag = msh->getTag();

        if (id == 0) continue;

        // get bound nodes
        const ID& tags = msh->getNodeTags();
        for (int i=0; i<tags.Size(); ++i) {
            std::vector<int>& info = ndinfo[tags(i)];
            info.push_back(mtag);
            info.push_back(id);
            nodetags.insert(tags(i));
        }

        // get internal nodes
        const ID& newtags = msh->getNewNodeTags();
        for (int i=0; i<newtags.Size(); ++i) {
            std::vector<int>& info = ndinfo[newtags(i)];
            info.push_back(mtag);
            info.push_back(id);
            nodetags.insert(newtags(i));
        }
    }

    if (nodetags.Size() == 0) return 0;

    // calling mesh generator
    TetMeshGenerator gen;
    int nodecounter = nextNodeTag();
    for(int i=0; i<nodetags.Size(); ++i) {

        // get node
        Node* theNode = domain->getNode(nodetags(i));
        if(theNode == 0) {
            opserr<<"WARNING: node "<<nodetags(i)<<" is not defined\n";
            return -1;
        }
        const Vector& crds = theNode->getCrds();
        const Vector& disp = theNode->getTrialDisp();
        if(crds.Size() < ndm || disp.Size() < ndm) {
            opserr<<"WARNING: ndm < 3 or ndf < 3\n";
            return -1;
        }

	// create pc if not
	Pressure_Constraint* thePC = domain->getPressure_Constraint(nodetags(i));
	if(thePC != 0) {
	    thePC->setDomain(domain);
	} else {

	    // create pressure node
	    Node* pnode = 0;
	    pnode = new Node(nodecounter++, 1, crds(0), crds(1), crds(2));
	    if (pnode == 0) {
		opserr << "WARNING: run out of memory -- BgMesh::gridNodes\n";
		return -1;
	    }
	    if (domain->addNode(pnode) == false) {
		opserr << "WARNING: failed to add node to domain -- BgMesh::gridNodes\n";
		delete pnode;
		return -1;
	    }

	    thePC = new Pressure_Constraint(nodetags(i), pnode->getTag());
	    if(thePC == 0) {
		opserr<<"WARNING: no enough memory for Pressure_Constraint\n";
		return -1;
	    }
	    if (domain->addPressure_Constraint(thePC) == false) {
		opserr << "WARNING: failed to add PC to domain -- BgMesh::gridNodes\n";
		delete thePC;
		return -1;
	    }
	}

        // add point
        gen.addPoint(crds(0)+disp(0), crds(1)+disp(1), crds(2)+disp(2), 0);
    }

//.........这里部分代码省略.........
开发者ID:fmckenna,项目名称:OpenSees,代码行数:101,代码来源:TetMesh.cpp

示例4: main

int main(int argc, char **argv)
{
    //  first build our error handler
    g3ErrorHandler = new ConsoleErrorHandler();

    //
    //	now create a domain and a modelbuilder
    //  and build the model
    //

//    Domain *theDomain = new Domain();

    MapOfTaggedObjects theStorage;
//    ArrayOfTaggedObjects theStorage(32);
    Domain *theDomain = new Domain(theStorage);

    // create the nodes using constructor:
    //		Node(tag, ndof, crd1, crd2)
    // and then add them to the domain

    Node *node1 = new Node(1, 3, 1.0, 1.0, 0.0 );
    Node *node2 = new Node(2, 3, 0.0, 1.0, 0.0 );
    Node *node3 = new Node(3, 3, 0.0, 0.0, 0.0 );
    Node *node4 = new Node(4, 3, 1.0, 0.0, 0.0 );
    Node *node5 = new Node(5, 3, 1.0, 1.0, 1.0 );
    Node *node6 = new Node(6, 3, 0.0, 1.0, 1.0 );
    Node *node7 = new Node(7, 3, 0.0, 0.0, 1.0 );
    Node *node8 = new Node(8, 3, 1.0, 0.0, 1.0 );

    theDomain->addNode(node1);
    theDomain->addNode(node2);
    theDomain->addNode(node3);
    theDomain->addNode(node4);
    theDomain->addNode(node5);
    theDomain->addNode(node6);
    theDomain->addNode(node7);
    theDomain->addNode(node8);

    // create an elastic material using constriuctor:
    //		ElasticMaterialModel(tag, E)

    //UniaxialMaterial *theMaterial = new ElasticMaterial(1, 3000);

    double PIo3 = PI/3.0;
    PIo3 = 0.0;

    //Drucker-Prager Model
    DPYieldSurface DP_YS;
    DPPotentialSurface DP_PS(0.05);
    //EvolutionLaw_NL_Eeq DP_ELS1;
    EvolutionLaw_L_Eeq DP_ELS1(10.0);
    EvolutionLaw_T DP_ELT;
    double scalars[] = {0.3, 0.0};  //alfa1, k
    double NOS = 2; //Number of scalar vars
    double NOT = 1; //Number of tensorial vars

    stresstensor startstress;
    straintensor startstrain, otherstrain;
    startstrain = startstrain.pqtheta2strain( 0.000, 0.0000, 0.0);
    otherstrain = otherstrain.pqtheta2strain( 0.000, 0.0000, 0.0);

    stresstensor *tensors = new stresstensor[1];

    EPState EPS(3000.0, 3000.0, 0.3, 0.0, startstress, otherstrain,
                otherstrain, otherstrain, NOS, scalars, NOT, tensors);

    Template3Dep MP(1, &DP_YS, &DP_PS, &EPS, &DP_ELS1, &DP_ELT);

    NDMaterial *theMaterial = &MP;
    //NDMaterial *theMaterial = new ElasticIsotropic3D(1, 3000, 0.3);

    // create the truss elements using constructor:
    //		Truss(tag, dim, nd1, nd2, Material &,A)
    // and then add them to the domain

    //Truss *truss1 = new Truss(1, 2, 1, 4, *theMaterial, 10.0);
    //Truss *truss2 = new Truss(2, 2, 2, 4, *theMaterial,  5.0);

    //EPState *eps = 0;

    EightNodeBrick *brick = new EightNodeBrick(1, 5, 6, 7, 8, 1, 2, 3, 4,
            theMaterial, "Template3Dep",
            0.0, 0.0, 0.0, 1.8, &EPS);

    //theDomain->addElement(truss1);
    //theDomain->addElement(truss2);
    theDomain->addElement( brick );

    // create the single-point constraint objects using constructor:
    //		SP_Constraint(tag, nodeTag, dofID, value)
    // and then add them to the domain

    SP_Constraint *sp1  = new SP_Constraint(1,  1, 0,  0.0259999);
    SP_Constraint *sp2  = new SP_Constraint(2,  1, 1,  0.0259999);
    SP_Constraint *sp3  = new SP_Constraint(3,  1, 2, -0.1213350);
    SP_Constraint *sp4  = new SP_Constraint(4,  2, 0, -0.0259999);
    SP_Constraint *sp5  = new SP_Constraint(5,  2, 1,  0.0259999);
    SP_Constraint *sp6  = new SP_Constraint(6,  2, 2, -0.1213350);
    SP_Constraint *sp7  = new SP_Constraint(7,  3, 0, -0.0259999);
    SP_Constraint *sp8  = new SP_Constraint(8,  3, 1, -0.0259999);
//.........这里部分代码省略.........
开发者ID:lge88,项目名称:OpenSees,代码行数:101,代码来源:main_Template3Dep.cpp

示例5: polygon


//.........这里部分代码省略.........
            opserr<<"WARNING: node "<<ndtags(i)<<" is not defined\n";
            return -1;
        }
        Vector crds = theNode->getCrds();
        const Vector& disp = theNode->getTrialDisp();
        if(crds.Size() != 3) {
            opserr<<"WARNING: ndm != 3\n";
            return -1;
        }
        if (disp.Size() >= crds.Size()) {
            for (int j=0; j<crds.Size(); ++j) {
                crds(j) += disp(j);
            }
        }

        // add point
        gen.addPoint(crds(0), crds(1), crds(2), 0);

        // add pc
        if (this->isFluid()) {
	    // create pressure constraint
	    Pressure_Constraint* thePC = domain->getPressure_Constraint(ndtags(i));
	    if(thePC != 0) {
		thePC->setDomain(domain);
	    } else {

		// create pressure node
		Node* pnode = 0;
		pnode = new Node(nodecounter++, 1, crds[0], crds[1], crds[2]);
		if (pnode == 0) {
		    opserr << "WARNING: run out of memory -- BgMesh::gridNodes\n";
		    return -1;
		}
		if (domain->addNode(pnode) == false) {
		    opserr << "WARNING: failed to add node to domain -- BgMesh::gridNodes\n";
		    delete pnode;
		    return -1;
		}

		thePC = new Pressure_Constraint(ndtags(i), pnode->getTag());
		if(thePC == 0) {
		    opserr<<"WARNING: no enough memory for Pressure_Constraint\n";
		    return -1;
		}
		if (domain->addPressure_Constraint(thePC) == false) {
		    opserr << "WARNING: failed to add PC to domain -- BgMesh::gridNodes\n";
		    delete thePC;
		    return -1;
		}
	    }
        }
    }

    for (unsigned int i=0; i<facets.size(); ++i) {
	gen.addFacet(facets[i],0);
    }

    // meshing
    gen.mesh(size*size*size/(6.0*1.414),false);

    // get points and create nodes
    int nump = gen.getNumPoints();
    if (nump == 0) {
        opserr << "WARNING: no nodes is meshed\n";
        return -1;
    }
开发者ID:fmckenna,项目名称:OpenSees,代码行数:67,代码来源:TetMesh.cpp


注:本文中的Domain::addNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。