本文整理汇总了C++中meshlib::Mesh::getElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::getElement方法的具体用法?C++ Mesh::getElement怎么用?C++ Mesh::getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meshlib::Mesh
的用法示例。
在下文中一共展示了Mesh::getElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
LOGOG_INITIALIZE();
logog::Cout* logogCout = new logog::Cout;
TCLAP::CmdLine cmd("Simple mesh loading test", ' ', "0.1");
// Define a value argument and add it to the command line.
// A value arg defines a flag and a type of value that it expects,
// such as "-m meshfile".
TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"homer","string");
// Add the argument mesh_arg to the CmdLine object. The CmdLine object
// uses this Arg to parse the command line.
cmd.add( mesh_arg );
cmd.parse( argc, argv );
std::string fname (mesh_arg.getValue());
FileIO::MeshIO mesh_io;
#ifndef WIN32
BaseLib::MemWatch mem_watch;
unsigned long mem_without_mesh (mem_watch.getVirtMemUsage());
#endif
BaseLib::RunTime run_time;
run_time.start();
MeshLib::Mesh* mesh = mesh_io.loadMeshFromFile(fname);
#ifndef WIN32
unsigned long mem_with_mesh (mem_watch.getVirtMemUsage());
// std::cout << "mem for mesh: " << (mem_with_mesh - mem_without_mesh)/(1024*1024) << " MB" << std::endl;
INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024));
#endif
run_time.stop();
// std::cout << "time for reading: " << run_time.elapsed() << " s" << std::endl;
INFO ("time for reading: %f s", run_time.elapsed());
unsigned elem_id = 25000;
const MeshLib::Element* e = mesh->getElement(elem_id);
const size_t nElems = mesh->getNElements();
for (unsigned i=0; i< e->getNNeighbors(); i++)
{
for (unsigned j=0; j< nElems; j++)
if (mesh->getElement(j) == e->getNeighbor(i))
std::cout << "neighbour of element " << elem_id << elem_id << " : " << j << std::endl;
}
delete mesh;
delete logogCout;
LOGOG_SHUTDOWN();
}
示例2: mesh
TEST(MeshLib, Duplicate)
{
MeshLib::Mesh* mesh (MeshLib::MeshGenerator::generateRegularQuadMesh(10, 5, 1));
std::vector<MeshLib::Node*> new_nodes (MeshLib::copyNodeVector(mesh->getNodes()));
std::vector<MeshLib::Element*> new_elements (MeshLib::copyElementVector(mesh->getElements(), new_nodes));
MeshLib::Mesh new_mesh ("new", new_nodes, new_elements);
ASSERT_EQ (mesh->getNElements(), new_mesh.getNElements());
ASSERT_EQ (mesh->getNNodes(), new_mesh.getNNodes());
std::vector<std::size_t> del_idx(1,1);
MeshLib::removeMeshNodes(*mesh, del_idx);
ASSERT_EQ (mesh->getNElements(), new_mesh.getNElements()-2);
ASSERT_EQ (mesh->getNNodes(), new_mesh.getNNodes()-2);
ASSERT_DOUBLE_EQ (4.0, MathLib::sqrDist(*mesh->getNode(0), *new_mesh.getNode(0)));
ASSERT_DOUBLE_EQ (0.0, MathLib::sqrDist(*mesh->getNode(0), *new_mesh.getNode(2)));
ASSERT_DOUBLE_EQ (4.0, MathLib::sqrDist(*mesh->getElement(0)->getNode(0), *new_mesh.getElement(0)->getNode(0)));
ASSERT_DOUBLE_EQ (0.0, MathLib::sqrDist(*mesh->getElement(0)->getNode(0), *new_mesh.getElement(2)->getNode(0)));
}