示例#1
0
InputParameters
validParams<TaggingInterface>()
{
  InputParameters params = emptyInputParameters();

  // These are the default names for tags, but users will be able to add their own
  MultiMooseEnum vtags("nontime time", "nontime", true);
  MultiMooseEnum mtags("nontime system", "system", true);

  params.addParam<MultiMooseEnum>(
      "vector_tags", vtags, "The tag for the vectors this Kernel should fill");

  params.addParam<MultiMooseEnum>(
      "matrix_tags", mtags, "The tag for the matrices this Kernel should fill");

  params.addParam<std::vector<TagName>>("extra_vector_tags",
                                        "The extra tags for the vectors this Kernel should fill");

  params.addParam<std::vector<TagName>>("extra_matrix_tags",
                                        "The extra tags for the matrices this Kernel should fill");

  params.addParamNamesToGroup("vector_tags matrix_tags extra_vector_tags extra_matrix_tags",
                              "Tagging");

  return params;
}
示例#2
0
int OPS_TetMesh()
{
    if (OPS_GetNumRemainingInputArgs() < 6) {
        opserr<<"WARNING: want tag? nummesh? mtags? id? ndf? size? eleType? eleArgs?\n";
        return -1;
    }

    // get tag and number mesh
    int num = 2;
    int idata[2];
    if (OPS_GetIntInput(&num,idata) < 0) {
        opserr<<"WARNING: failed to read mesh tag and number of 2D boundary mesh\n";
        return -1;
    }

    if (OPS_GetNumRemainingInputArgs() < idata[1]+3) {
        opserr<<"WARNING: want mtags? id? ndf? size? <eleType? eleArgs?>\n";
        return -1;
    }

    // create mesh
    TetMesh* mesh = new TetMesh(idata[0]);
    if(OPS_addMesh(mesh) == false) {
        opserr<<"WARNING: failed to add mesh\n";
        return -1;
    }

    // get mesh tags
    num = idata[1];
    ID mtags(num);
    if (OPS_GetIntInput(&num,&mtags(0)) < 0) {
        opserr<<"WARNING: failed to read boundary mesh tags\n";
        return -1;
    }
    mesh->setMeshTags(mtags);

    // get id and ndf
    num = 2;
    int data[2];
    if (OPS_GetIntInput(&num,data) < 0) {
        opserr<<"WARNING: failed to read id and ndf\n";
        return -1;
    }
    mesh->setID(data[0]);
    mesh->setNdf(data[1]);

    // get size
    num = 1;
    double size;
    if (OPS_GetDoubleInput(&num,&size) < 0) {
        opserr<<"WARNING: failed to read mesh size\n";
        return -1;
    }
    mesh->setMeshsize(size);

    // set eleArgs
    if (mesh->setEleArgs() < 0) {
        opserr << "WARNING: failed to set element arguments\n";
        return -1;
    }

    // mesh
    if (mesh->mesh() < 0) {
        opserr<<"WARNING: failed to do triangular mesh\n";
        return -1;
    }

    return 0;
}
示例#3
0
int
TetMesh::mesh()
{
    Domain* domain = OPS_GetDomain();
    if (domain == 0) {
        opserr << "WARNING: domain is not created\n";
        return -1;
    }

    // check
    double size = this->getMeshsize();
    if(size <= 0) {
        opserr<<"WARNING: mesh size <= 0\n";
        return -1;
    }
    if (mtags.Size() == 0) return 0;

    // get nodes and elements from boundary mesh
    ID ndtags;
    std::vector<TetMeshGenerator::Facet> facets;
    for (int i=0; i<mtags.Size(); ++i) {
	// get mesh
        Mesh* mesh = OPS_getMesh(mtags(i));
        if (mesh == 0) {
            opserr << "WARNING: mesh "<<mtags(i)<<" does not exist\n";
            return -1;
        }

	// get nodes
        const ID& tags = mesh->getNodeTags();
        for (int j=0; j<tags.Size(); ++j) {
            ndtags.insert(tags(j));
        }
        const ID& newtags = mesh->getNewNodeTags();
        for (int j=0; j<newtags.Size(); ++j) {
            ndtags.insert(newtags(j));
        }

	// get polygons
	int numelenodes = mesh->getNumEleNodes();
        const ID& elends = mesh->getEleNodes();
	TetMeshGenerator::Facet facet;
        for (int j=0; j<elends.Size()/numelenodes; ++j) {
	    TetMeshGenerator::Polygon polygon(numelenodes);
	    for (int k=0; k<numelenodes; ++k) {
		polygon[k] = elends(numelenodes*j+k);
	    }
            facet.push_back(polygon);
        }

	// add the mesh as a facet
	facets.push_back(facet);
    }
    if(ndtags.Size() < 4) {
        opserr<<"WARNING: input number of nodes < 4\n";
        return -1;
    }
    if(facets.size() < 4) {
        opserr<<"WARNING: input number of facets < 4\n";
        return -1;
    }
    this->setNodeTags(ndtags);

    // get correct index for factes
    for (unsigned int i=0; i<facets.size(); ++i) {
	for (unsigned int j=0; j<facets[i].size(); ++j) {
	    for (unsigned int k=0; k<facets[i][j].size(); ++k) {
		facets[i][j][k] = ndtags.getLocationOrdered(facets[i][j][k]);
		if (facets[i][j][k] < 0) {
		    opserr << "WARNING: failed to get a node in a facet -- Tetmesh::mesh\n";
		    return -1;
		}
	    }
	}
    }

    // calling mesh generator
    TetMeshGenerator gen;
    int nodecounter = nextNodeTag();
    for(int i=0; i<ndtags.Size(); i++) {
        // get node
        Node* theNode = domain->getNode(ndtags(i));
        if(theNode == 0) {
            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 newndtags(nump-ndtags.Size());
    ID allndtags(nump);
    for (int i=0; i<ndtags.Size(); ++i) {
        allndtags(i) = ndtags(i);
    }

    for (int i=ndtags.Size(); i<nump; ++i) {
        // get point
        Vector crds(3);
        int mark = 0;
        gen.getPoint(i,crds(0),crds(1),crds(2),mark);
        Node* node = newNode(nodecounter++,crds);
        if (node == 0) {
            opserr << "WARING: failed to create node\n";
            return -1;
        }
        if (domain->addNode(node) == false) {
            opserr << "WARNING: failed to add node to domain\n";
            delete node;
            return -1;
        }
        allndtags(i) = node->getTag();
        newndtags(i-ndtags.Size()) = node->getTag();

        // add pc
        if (this->isFluid()) {
	    // create pressure constraint
	    Pressure_Constraint* thePC = domain->getPressure_Constraint(node->getTag());
	    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(node->getTag(), 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;
		}
	    }
        }
    }
    this->setNewNodeTags(newndtags);

    // get tetrahedrons
    int numtet = gen.getNumTets();
    if (numtet == 0) return 0;
    ID elenodes(numtet*4);

    for(int i=0; i<numtet; i++) {
        int p1,p2,p3,p4;
        gen.getTet(i,p1,p2,p3,p4);
        elenodes(4*i) = allndtags(p1);
        elenodes(4*i+1) = allndtags(p2);
        elenodes(4*i+2) = allndtags(p3);
        elenodes(4*i+3) = allndtags(p4);
    }
    this->setEleNodes(elenodes);

    // create elemnts
    if (this->newElements(elenodes) < 0) {
        opserr << "WARNING: failed to create elements\n";
        return -1;
    }

    return 0;
}