Go to the documentation of this file. 1 #include <libmesh/equation_systems.h>
2 #include <libmesh/mesh.h>
3 #include <libmesh/mesh_generation.h>
4 #include <libmesh/edge_edge2.h>
5 #include <libmesh/face_quad4.h>
6 #include <libmesh/cell_hex8.h>
7 #include <libmesh/dof_map.h>
8 #include <libmesh/linear_implicit_system.h>
9 #include <libmesh/mesh_refinement.h>
27 virtual std::unique_ptr<FEMFunctionBase<Number>>
30 return libmesh_make_unique<SlitFunc>();
35 const Real = 0.)
override
37 const Real & x = p(0);
38 const Real & y = p(1);
50 for (
unsigned int i=0; i != output.
size(); ++i)
51 output(i) = (*this)(c, p, time);
70 CPPUNIT_TEST( testMesh );
73 CPPUNIT_TEST_SUITE_END();
118 elem_top_left->
set_id() = 0;
126 elem_bottom_left->
set_id() = 1;
134 elem_top_right->
set_id() = 2;
142 elem_bottom_right->
set_id() = 3;
204 CPPUNIT_TEST( testMesh );
207 CPPUNIT_TEST_SUITE_END();
217 #ifdef LIBMESH_ENABLE_AMR
225 #ifdef LIBMESH_ENABLE_AMR
227 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)20, _mesh->n_elem() );
228 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)16, _mesh->n_active_elem() );
231 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)28, _mesh->n_nodes() );
246 CPPUNIT_TEST( testMesh );
248 CPPUNIT_TEST( testSystem );
250 #ifdef LIBMESH_ENABLE_UNIQUE_ID
251 CPPUNIT_TEST( testRestart );
255 CPPUNIT_TEST_SUITE_END();
271 _mesh->allow_renumbering(
true);
281 #ifdef LIBMESH_ENABLE_AMR
299 #ifdef LIBMESH_ENABLE_AMR
301 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)(4+16+64), _mesh->n_elem() );
302 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)64, _mesh->n_active_elem() );
305 CPPUNIT_ASSERT_EQUAL( (
dof_id_type)88, _mesh->n_nodes() );
313 unsigned int dim = 2;
315 CPPUNIT_ASSERT_EQUAL( _sys->
n_vars(), 1u );
319 context.get_element_fe( 0, fe,
dim );
320 const std::vector<Point> & xyz = fe->
get_xyz();
323 for (
const auto & elem : _mesh->active_local_element_ptr_range())
325 context.pre_fe_reinit(*_sys, elem);
326 context.elem_fe_reinit();
328 const unsigned int n_qp = xyz.size();
330 for (
unsigned int qp=0; qp != n_qp; ++qp)
332 const Number exact_val = slitfunc(context, xyz[qp]);
334 const Number discrete_val = context.interior_value(0, qp);
347 _mesh->write(
"slit_mesh.xda");
348 _es->
write(
"slit_solution.xda",
353 mesh2.
read(
"slit_mesh.xda");
355 es2.
read(
"slit_solution.xda");
359 unsigned int dim = 2;
361 CPPUNIT_ASSERT_EQUAL( sys2.
n_vars(), 1u );
365 context.get_element_fe( 0, fe,
dim );
366 const std::vector<Point> & xyz = fe->
get_xyz();
371 std::unique_ptr<PointLocatorBase> locator = _mesh->sub_point_locator();
373 if (!_mesh->is_serial())
374 locator->enable_out_of_mesh_mode();
378 const Elem * mesh1_elem = (*locator)(elem->centroid());
381 CPPUNIT_ASSERT_EQUAL( elem->unique_id(),
384 for (
unsigned int n=0; n != elem->n_nodes(); ++n)
386 const Node & node = elem->node_ref(n);
393 context.pre_fe_reinit(sys2, elem);
394 context.elem_fe_reinit();
396 const unsigned int n_qp = xyz.
size();
398 for (
unsigned int qp=0; qp != n_qp; ++qp)
400 const Number exact_val = slitfunc(context, xyz[qp]);
402 const Number discrete_val = context.interior_value(0, qp);
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned int n_vars() const
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const override
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const std::vector< Point > & get_xyz() const
virtual System & add_system(const std::string &system_type, const std::string &name)
Add the system of type system_type named name to the systems array.
virtual SimpleRange< element_iterator > active_local_element_ptr_range() override
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id) override
functions for adding /deleting nodes elements.
virtual const Elem & elem_ref(const dof_id_type i) const
The libMesh namespace provides an interface to certain functionality in the library.
This class forms the foundation from which generic finite elements may be derived.
const T_sys & get_system(const std::string &name) const
const Elem & get_elem() const
Accessor for current Elem object.
static const Real TOLERANCE
virtual Point centroid() const
auto size() const -> decltype(std::norm(T()))
Implements (adaptive) mesh refinement algorithms for a MeshBase.
virtual dof_id_type n_nodes() const override
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
virtual dof_id_type n_elem() const override
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
libMesh::Parallel::Communicator * TestCommWorld
virtual void init()
Initialize all the systems.
A Point defines a location in LIBMESH_DIM dimensional Real space.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) override
Reads the file specified by name.
virtual Elem * add_elem(Elem *e) override
Add elem e to the end of the element array.
A Node is like a Point, but with more information.
The QUAD4 is an element in 2D composed of 4 nodes.
unique_id_type unique_id() const
virtual unsigned int size() const override
CPPUNIT_TEST_SUITE_REGISTRATION(SlitMeshTest)
void read(const std::string &name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
This is the EquationSystems class.
virtual Node *& set_node(const unsigned int i)
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
virtual const Elem * query_elem_ptr(const dof_id_type i) const override
This is the base class from which all geometric element types are derived.
void write(const std::string &name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
const std::vector< std::vector< OutputShape > > & get_phi() const
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
dof_id_type node_id(const unsigned int i) const
const Node & node_ref(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
virtual void init_context(const FEMContext &) override
Prepares a context object for use.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
virtual const Node * node_ptr(const dof_id_type i) const override
This class provides all data required for a physics package (e.g.