Go to the documentation of this file.    1 #include <libmesh/dof_map.h> 
    2 #include <libmesh/elem.h> 
    3 #include <libmesh/equation_systems.h> 
    4 #include <libmesh/ghost_point_neighbors.h> 
    5 #include <libmesh/mesh.h> 
    6 #include <libmesh/mesh_generation.h> 
    7 #include <libmesh/mesh_refinement.h> 
    8 #include <libmesh/remote_elem.h> 
    9 #include <libmesh/replicated_mesh.h> 
   10 #include <libmesh/node_elem.h> 
   26   const Real & x = p(0);
 
   27   const Real & y = p(1);
 
   29   return 4*x*y - 3*x + 2*y - 1;
 
   38   CPPUNIT_TEST( testConstruction );
 
   39   CPPUNIT_TEST( testAddSystem );
 
   40   CPPUNIT_TEST( testInit );
 
   41   CPPUNIT_TEST( testPostInitAddSystem );
 
   42   CPPUNIT_TEST( testPostInitAddElem );
 
   43   CPPUNIT_TEST( testReinitWithNodeElem );
 
   45   CPPUNIT_TEST( testRefineThenReinitPreserveFlags );
 
   46 #ifdef LIBMESH_ENABLE_AMR // needs project_solution, even for reordering 
   47   CPPUNIT_TEST( testRepartitionThenReinit );
 
   50   CPPUNIT_TEST( testDisableDefaultGhosting );
 
   52   CPPUNIT_TEST_SUITE_END();
 
  152 #ifdef LIBMESH_ENABLE_AMR 
  178         for (
unsigned int c=0; c<elem->
n_children(); c++)
 
  207     for (
Real x = 0.1; x < 1; x += 0.2)
 
  208       for (
Real y = 0.1; y < 1; y += 0.2)
 
  222     auto n_ghosts = [&
mesh]() {
 
  227     auto n_evaluables = [](
System &sys) {
 
  228       return int(
std::distance(sys.get_dof_map().algebraic_ghosting_functors_begin(),
 
  229                                sys.get_dof_map().algebraic_ghosting_functors_end()));
 
  232     auto n_couplings = [](
System &sys) {
 
  234                                sys.get_dof_map().coupling_functors_end()));
 
  238     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
 
  241     auto gpn = std::make_shared<GhostPointNeighbors>(
mesh);
 
  243     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 2);
 
  247     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
 
  251     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 0);
 
  256     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 0);
 
  257     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 0);
 
  258     CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 0);
 
  267     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 3);
 
  268     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 1);
 
  269     CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
 
  274     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 5);
 
  275     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys2), 1);
 
  276     CPPUNIT_ASSERT_EQUAL(n_couplings(sys2), 1);
 
  282     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 6);
 
  283     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 2);
 
  284     CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
 
  287     auto gpn3 = std::make_shared<GhostPointNeighbors>(
mesh);
 
  289     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 6);
 
  290     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 2);
 
  291     CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 2);
 
  296     CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
 
  297     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 1);
 
  298     CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
 
  299     CPPUNIT_ASSERT_EQUAL(n_evaluables(sys2), 0);
 
  300     CPPUNIT_ASSERT_EQUAL(n_couplings(sys2), 0);
 
 
void add_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor, bool to_mesh=true)
Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.
 
Manages consistently variables, degrees of freedom, and coefficient vectors.
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
 
const Elem * child_ptr(unsigned int i) const
 
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
 
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
 
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.
 
void testRepartitionThenReinit()
 
bool refine_elements()
Only refines the user-requested elements.
 
void testRefineThenReinitPreserveFlags()
 
virtual dof_id_type max_elem_id() const =0
 
The libMesh namespace provides an interface to certain functionality in the library.
 
static const Real TOLERANCE
 
void testDisableDefaultGhosting()
 
This class implements the default geometry ghosting in libMesh: point neighbors and interior_parent e...
 
virtual const Node * node_ptr(const dof_id_type i) const =0
 
processor_id_type processor_id() const
 
virtual const Elem * elem_ptr(const dof_id_type i) const =0
 
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
 
void testPostInitAddRealSystem()
 
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
 
Implements (adaptive) mesh refinement algorithms for a MeshBase.
 
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
 
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.
 
The NodeElem is a point element, generally used as a side of a 1D element.
 
virtual void enable_default_ghosting(bool enable)
Enable or disable default ghosting functors on the Mesh and on all Systems.
 
void testReinitWithNodeElem()
 
void testPostInitAddElem()
 
This is the EquationSystems class.
 
virtual Node *& set_node(const unsigned int i)
 
void disable_refine_in_reinit()
Calls to reinit() will not try to coarsen or refine the mesh.
 
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
 
RefinementState refinement_flag() const
 
Real distance(const Point &p)
 
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
 
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
virtual unsigned int n_children() const =0
 
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
 
This is the base class from which all geometric element types are derived.
 
CPPUNIT_TEST_SUITE_REGISTRATION(EquationSystemsTest)
 
void testPostInitAddSystem()
 
const DofMap & get_dof_map() const
 
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
 
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
 
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.
 
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
 
const RemoteElem * remote_elem
 
void ErrorVector unsigned int
 
This class provides the ability to map between arbitrary, user-defined strings and several data types...
 
virtual void partition(const unsigned int n_parts)
Call the default partitioner (currently metis_partition()).
 
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
 
Parameters parameters
Data structure holding arbitrary parameters.