本文整理汇总了C++中EquationSystems::write方法的典型用法代码示例。如果您正苦于以下问题:C++ EquationSystems::write方法的具体用法?C++ EquationSystems::write怎么用?C++ EquationSystems::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EquationSystems
的用法示例。
在下文中一共展示了EquationSystems::write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRestart
void testRestart()
{
SlitFunc slitfunc;
_mesh->write("slit_mesh.xda");
_es->write("slit_solution.xda",
EquationSystems::WRITE_DATA |
EquationSystems::WRITE_SERIAL_FILES);
Mesh mesh2(*TestCommWorld);
mesh2.read("slit_mesh.xda");
EquationSystems es2(mesh2);
es2.read("slit_solution.xda");
System & sys2 = es2.get_system<System> ("SimpleSystem");
unsigned int dim = 2;
CPPUNIT_ASSERT_EQUAL( sys2.n_vars(), 1u );
FEMContext context(sys2);
FEBase * fe = NULL;
context.get_element_fe( 0, fe, dim );
const std::vector<Point> & xyz = fe->get_xyz();
fe->get_phi();
MeshBase::const_element_iterator el =
mesh2.active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh2.active_local_elements_end();
for (; el != end_el; ++el)
{
const Elem * elem = *el;
context.pre_fe_reinit(sys2, elem);
context.elem_fe_reinit();
const unsigned int n_qp = xyz.size();
for (unsigned int qp=0; qp != n_qp; ++qp)
{
const Number exact_val = slitfunc(context, xyz[qp]);
const Number discrete_val = context.interior_value(0, qp);
CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(exact_val),
libmesh_real(discrete_val),
TOLERANCE*TOLERANCE);
}
}
}
示例2: write_output
void write_output(EquationSystems & es,
unsigned int t_step, // The timestep count
unsigned int a_step, // The adaptive step count
std::string solution_type, // primal or adjoint solve
FEMParameters & param)
{
MeshBase & mesh = es.get_mesh();
#ifdef LIBMESH_HAVE_GMV
if (param.output_gmv)
{
std::ostringstream file_name_gmv;
file_name_gmv << solution_type
<< ".out.gmv."
<< std::setw(3)
<< std::setfill('0')
<< std::right
<< t_step
<< '.'
<< std::setw(2)
<< std::setfill('0')
<< std::right
<< a_step;
GMVIO(mesh).write_equation_systems
(file_name_gmv.str(), es);
}
#endif
#ifdef LIBMESH_HAVE_TECPLOT_API
if (param.output_tecplot)
{
std::ostringstream file_name_tecplot;
file_name_tecplot << solution_type
<< ".out."
<< std::setw(3)
<< std::setfill('0')
<< std::right
<< t_step
<< '.'
<< std::setw(2)
<< std::setfill('0')
<< std::right
<< a_step
<< ".plt";
TecplotIO(mesh).write_equation_systems
(file_name_tecplot.str(), es);
}
#endif
if (param.output_xda || param.output_xdr)
mesh.renumber_nodes_and_elements();
if (param.output_xda)
{
mesh.write(numbered_filename(t_step, a_step, solution_type, "mesh", "xda", param));
es.write(numbered_filename(t_step, a_step, solution_type, "soln", "xda", param),
WRITE, EquationSystems::WRITE_DATA |
EquationSystems::WRITE_ADDITIONAL_DATA);
}
if (param.output_xdr)
{
mesh.write(numbered_filename(t_step, a_step, solution_type, "mesh", "xdr", param));
es.write(numbered_filename(t_step, a_step, solution_type, "soln", "xdr", param),
WRITE, EquationSystems::WRITE_DATA |
EquationSystems::WRITE_ADDITIONAL_DATA);
}
}
示例3: testRestart
void testRestart()
{
SlitFunc slitfunc;
_mesh->write("slit_mesh.xda");
_es->write("slit_solution.xda",
EquationSystems::WRITE_DATA |
EquationSystems::WRITE_SERIAL_FILES);
Mesh mesh2(*TestCommWorld);
mesh2.read("slit_mesh.xda");
EquationSystems es2(mesh2);
es2.read("slit_solution.xda");
System & sys2 = es2.get_system<System> ("SimpleSystem");
unsigned int dim = 2;
CPPUNIT_ASSERT_EQUAL( sys2.n_vars(), 1u );
FEMContext context(sys2);
FEBase * fe = NULL;
context.get_element_fe( 0, fe, dim );
const std::vector<Point> & xyz = fe->get_xyz();
fe->get_phi();
// While we're in the middle of a unique id based test case, let's
// make sure our unique ids were all read in correctly too.
UniquePtr<PointLocatorBase> locator = _mesh->sub_point_locator();
MeshBase::const_element_iterator el =
mesh2.active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh2.active_local_elements_end();
for (; el != end_el; ++el)
{
const Elem * elem = *el;
const Elem * mesh1_elem = (*locator)(elem->centroid());
if (mesh1_elem)
{
CPPUNIT_ASSERT_EQUAL( elem->unique_id(),
mesh1_elem->unique_id() );
for (unsigned int n=0; n != elem->n_nodes(); ++n)
{
const Node & node = elem->node_ref(n);
const Node & mesh1_node = mesh1_elem->node_ref(n);
CPPUNIT_ASSERT_EQUAL( node.unique_id(),
mesh1_node.unique_id() );
}
}
context.pre_fe_reinit(sys2, elem);
context.elem_fe_reinit();
const unsigned int n_qp = xyz.size();
for (unsigned int qp=0; qp != n_qp; ++qp)
{
const Number exact_val = slitfunc(context, xyz[qp]);
const Number discrete_val = context.interior_value(0, qp);
CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(exact_val),
libmesh_real(discrete_val),
TOLERANCE*TOLERANCE);
}
}
}