本文整理汇总了C++中meshlib::Mesh::getNumberOfBaseNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::getNumberOfBaseNodes方法的具体用法?C++ Mesh::getNumberOfBaseNodes怎么用?C++ Mesh::getNumberOfBaseNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meshlib::Mesh
的用法示例。
在下文中一共展示了Mesh::getNumberOfBaseNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh, std::string const& new_mesh_name)
{
std::vector<MeshLib::Node*> vec_new_nodes = MeshLib::copyNodeVector(MeshLib::getBaseNodes(org_mesh.getElements()));
// create new elements with the quadratic nodes
std::vector<MeshLib::Element*> vec_new_eles;
for (MeshLib::Element const* e : org_mesh.getElements())
{
if (e->getCellType() == MeshLib::CellType::LINE3)
{
vec_new_eles.push_back(createLinearElement<MeshLib::Line>(
e, vec_new_nodes));
}
else if (e->getCellType() == MeshLib::CellType::QUAD8)
{
vec_new_eles.push_back(createLinearElement<MeshLib::Quad>(
e, vec_new_nodes));
}
else if (e->getCellType() == MeshLib::CellType::TRI6)
{
vec_new_eles.push_back(createLinearElement<MeshLib::Tri>(
e, vec_new_nodes));
}
else if (e->getCellType() == MeshLib::CellType::HEX20)
{
vec_new_eles.push_back(createLinearElement<MeshLib::Hex>(
e, vec_new_nodes));
}
else if (e->getCellType() == MeshLib::CellType::TET10)
{
vec_new_eles.push_back(createLinearElement<MeshLib::Tet>(
e, vec_new_nodes));
}
else
{
OGS_FATAL("Mesh element type %s is not supported", MeshLib::CellType2String(e->getCellType()).c_str());
}
}
auto new_mesh = std::make_unique<MeshLib::Mesh>(
new_mesh_name, vec_new_nodes, vec_new_eles,
org_mesh.getProperties().excludeCopyProperties(
std::vector<MeshLib::MeshItemType>(1,
MeshLib::MeshItemType::Node)));
// copy property vectors for nodes
MeshLib::Properties const& src_properties = org_mesh.getProperties();
for (auto name : src_properties.getPropertyVectorNames())
{
if (!src_properties.existsPropertyVector<double>(name))
{
continue;
}
auto const* src_prop = src_properties.getPropertyVector<double>(name);
if (src_prop->getMeshItemType() != MeshLib::MeshItemType::Node)
{
continue;
}
auto const n_src_comp = src_prop->getNumberOfComponents();
auto new_prop =
new_mesh->getProperties().createNewPropertyVector<double>(
name, MeshLib::MeshItemType::Node, n_src_comp);
new_prop->resize(new_mesh->getNumberOfNodes() * n_src_comp);
// copy only base node values
for (unsigned i=0; i<org_mesh.getNumberOfBaseNodes(); i++)
{
for (int j = 0; j < n_src_comp; j++)
{
(*new_prop)[i * n_src_comp + j] =
(*src_prop)[i * n_src_comp + j];
}
}
}
return new_mesh;
}