本文整理汇总了C++中MeshBase::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBase::clone方法的具体用法?C++ MeshBase::clone怎么用?C++ MeshBase::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBase
的用法示例。
在下文中一共展示了MeshBase::clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plot_error
void ErrorVector::plot_error(const std::string& filename,
const MeshBase& oldmesh) const
{
AutoPtr<MeshBase> meshptr = oldmesh.clone();
MeshBase &mesh = *meshptr;
mesh.all_first_order();
EquationSystems temp_es (mesh);
ExplicitSystem& error_system
= temp_es.add_system<ExplicitSystem> ("Error");
error_system.add_variable("error", CONSTANT, MONOMIAL);
temp_es.init();
const DofMap& error_dof_map = error_system.get_dof_map();
MeshBase::const_element_iterator el =
mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh.active_local_elements_end();
std::vector<unsigned int> dof_indices;
for ( ; el != end_el; ++el)
{
const Elem* elem = *el;
error_dof_map.dof_indices(elem, dof_indices);
const unsigned int elem_id = elem->id();
//0 for the monomial basis
const unsigned int solution_index = dof_indices[0];
// libMesh::out << "elem_number=" << elem_number << std::endl;
libmesh_assert_less (elem_id, (*this).size());
// We may have zero error values in special circumstances
// libmesh_assert_greater ((*this)[elem_id], 0.);
error_system.solution->set(solution_index, (*this)[elem_id]);
}
// We may have to renumber if the original numbering was not
// contiguous. Since this is just a temporary mesh, that's probably
// fine.
if (mesh.max_elem_id() != mesh.n_elem() ||
mesh.max_node_id() != mesh.n_nodes())
{
mesh.allow_renumbering(true);
mesh.renumber_nodes_and_elements();
}
if (filename.rfind(".gmv") < filename.size())
{
GMVIO(mesh).write_discontinuous_gmv(filename,
temp_es, false);
}
else if (filename.rfind(".plt") < filename.size())
{
TecplotIO (mesh).write_equation_systems
(filename, temp_es);
}
#ifdef LIBMESH_HAVE_EXODUS_API
else if( (filename.rfind(".exo") < filename.size()) ||
(filename.rfind(".e") < filename.size()) )
{
ExodusII_IO io(mesh);
io.write(filename);
io.write_element_data(temp_es);
}
#endif
else
{
libmesh_here();
libMesh::err << "Warning: ErrorVector::plot_error currently only"
<< " supports .gmv and .plt and .exo/.e (if enabled) output;" << std::endl;
libMesh::err << "Could not recognize filename: " << filename
<< std::endl;
}
}
示例2: plot_error
void ErrorVector::plot_error(const std::string & filename,
const MeshBase & oldmesh) const
{
std::unique_ptr<MeshBase> meshptr = oldmesh.clone();
MeshBase & mesh = *meshptr;
// The all_first_order routine will prepare_for_use(), which would
// break our ordering if elements get changed.
mesh.allow_renumbering(false);
mesh.all_first_order();
#ifdef LIBMESH_ENABLE_AMR
// We don't want p elevation when plotting a single constant value
// per element
for (auto & elem : mesh.element_ptr_range())
{
elem->set_p_refinement_flag(Elem::DO_NOTHING);
elem->set_p_level(0);
}
#endif // LIBMESH_ENABLE_AMR
EquationSystems temp_es (mesh);
ExplicitSystem & error_system
= temp_es.add_system<ExplicitSystem> ("Error");
error_system.add_variable("error", CONSTANT, MONOMIAL);
temp_es.init();
const DofMap & error_dof_map = error_system.get_dof_map();
std::vector<dof_id_type> dof_indices;
for (const auto & elem : mesh.active_local_element_ptr_range())
{
error_dof_map.dof_indices(elem, dof_indices);
const dof_id_type elem_id = elem->id();
//0 for the monomial basis
const dof_id_type solution_index = dof_indices[0];
// libMesh::out << "elem_number=" << elem_number << std::endl;
libmesh_assert_less (elem_id, (*this).size());
// We may have zero error values in special circumstances
// libmesh_assert_greater ((*this)[elem_id], 0.);
error_system.solution->set(solution_index, (*this)[elem_id]);
}
error_system.solution->close();
// We may have to renumber if the original numbering was not
// contiguous. Since this is just a temporary mesh, that's probably
// fine.
if (mesh.max_elem_id() != mesh.n_elem() ||
mesh.max_node_id() != mesh.n_nodes())
{
mesh.allow_renumbering(true);
mesh.renumber_nodes_and_elements();
}
if (filename.rfind(".gmv") < filename.size())
{
GMVIO(mesh).write_discontinuous_gmv(filename,
temp_es, false);
}
else if (filename.rfind(".plt") < filename.size())
{
TecplotIO (mesh).write_equation_systems
(filename, temp_es);
}
#ifdef LIBMESH_HAVE_EXODUS_API
else if ((filename.rfind(".exo") < filename.size()) ||
(filename.rfind(".e") < filename.size()))
{
ExodusII_IO io(mesh);
io.write(filename);
io.write_element_data(temp_es);
}
#endif
else if (filename.rfind(".xda") < filename.size())
{
XdrIO(mesh).write("mesh-"+filename);
temp_es.write("soln-"+filename,WRITE,
EquationSystems::WRITE_DATA |
EquationSystems::WRITE_ADDITIONAL_DATA);
}
else if (filename.rfind(".xdr") < filename.size())
{
XdrIO(mesh,true).write("mesh-"+filename);
temp_es.write("soln-"+filename,ENCODE,
EquationSystems::WRITE_DATA |
EquationSystems::WRITE_ADDITIONAL_DATA);
}
else
{
libmesh_here();
libMesh::err << "Warning: ErrorVector::plot_error currently only"
<< " supports .gmv, .plt, .xdr/.xda, and .exo/.e (if enabled) output;" << std::endl;
libMesh::err << "Could not recognize filename: " << filename
<< std::endl;
}
//.........这里部分代码省略.........