libMesh
Public Member Functions | List of all members
EquationSystemsTest Class Reference
Inheritance diagram for EquationSystemsTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (EquationSystemsTest)
 
 CPPUNIT_TEST (testConstruction)
 
 CPPUNIT_TEST (testAddSystem)
 
 CPPUNIT_TEST (testInit)
 
 CPPUNIT_TEST (testPostInitAddSystem)
 
 CPPUNIT_TEST (testPostInitAddElem)
 
 CPPUNIT_TEST (testReinitWithNodeElem)
 
 CPPUNIT_TEST (testBadVarNames)
 
 CPPUNIT_TEST (testRefineThenReinitPreserveFlags)
 
 CPPUNIT_TEST (testRepartitionThenReinit)
 
 CPPUNIT_TEST (testSelectivePRefine)
 
 CPPUNIT_TEST (testDisableDefaultGhosting)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testConstruction ()
 
void testAddSystem ()
 
void testInit ()
 
void testPostInitAddSystem ()
 
void testPostInitAddRealSystem ()
 
void testPostInitAddElem ()
 
void testBadVarNames ()
 
void testReinitWithNodeElem ()
 
void testRefineThenReinitPreserveFlags ()
 
void testSelectivePRefine ()
 
void testRepartitionThenReinit ()
 
void testDisableDefaultGhosting ()
 

Detailed Description

Definition at line 34 of file equation_systems_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/11]

EquationSystemsTest::CPPUNIT_TEST ( testConstruction  )

◆ CPPUNIT_TEST() [2/11]

EquationSystemsTest::CPPUNIT_TEST ( testAddSystem  )

◆ CPPUNIT_TEST() [3/11]

EquationSystemsTest::CPPUNIT_TEST ( testInit  )

◆ CPPUNIT_TEST() [4/11]

EquationSystemsTest::CPPUNIT_TEST ( testPostInitAddSystem  )

◆ CPPUNIT_TEST() [5/11]

EquationSystemsTest::CPPUNIT_TEST ( testPostInitAddElem  )

◆ CPPUNIT_TEST() [6/11]

EquationSystemsTest::CPPUNIT_TEST ( testReinitWithNodeElem  )

◆ CPPUNIT_TEST() [7/11]

EquationSystemsTest::CPPUNIT_TEST ( testBadVarNames  )

◆ CPPUNIT_TEST() [8/11]

EquationSystemsTest::CPPUNIT_TEST ( testRefineThenReinitPreserveFlags  )

◆ CPPUNIT_TEST() [9/11]

EquationSystemsTest::CPPUNIT_TEST ( testRepartitionThenReinit  )

◆ CPPUNIT_TEST() [10/11]

EquationSystemsTest::CPPUNIT_TEST ( testSelectivePRefine  )

◆ CPPUNIT_TEST() [11/11]

EquationSystemsTest::CPPUNIT_TEST ( testDisableDefaultGhosting  )

◆ CPPUNIT_TEST_SUITE_END()

EquationSystemsTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

EquationSystemsTest::LIBMESH_CPPUNIT_TEST_SUITE ( EquationSystemsTest  )

◆ setUp()

void EquationSystemsTest::setUp ( )
inline

Definition at line 59 of file equation_systems_test.C.

60  {}

◆ tearDown()

void EquationSystemsTest::tearDown ( )
inline

Definition at line 62 of file equation_systems_test.C.

63  {}

◆ testAddSystem()

void EquationSystemsTest::testAddSystem ( )
inline

Definition at line 75 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), mesh, and TestCommWorld.

76  {
77  LOG_UNIT_TEST;
78 
81  /*System &sys = */es.add_system<System> ("SimpleSystem");
82  }
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
MeshBase & mesh
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testBadVarNames()

void EquationSystemsTest::testBadVarNames ( )
inline

Definition at line 145 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_square(), libMesh::EquationSystems::build_variable_names(), libMesh::FIRST, libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL_VEC, libMesh::EquationSystems::reinit(), TestCommWorld, and libMesh::System::variable_type().

146  {
147 #ifdef LIBMESH_ENABLE_EXCEPTIONS
148  LOG_UNIT_TEST;
149 
152  EquationSystems es(mesh);
153  System &sys1 = es.add_system<System> ("SimpleSystem");
154  sys1.add_variable("u", FIRST, MONOMIAL_VEC);
155  es.init();
156 
157  const FEType & fe_type = sys1.variable_type ("u");
158  std::vector<std::string> var_names;
159  std::set<std::string> system_names = {"SimpleSystem"};
160  es.build_variable_names(var_names, &fe_type);
161 
162  System &sys2 = es.add_system<System> ("SecondSystem");
163  sys2.add_variable("u_x", FIRST);
164  sys2.add_variable("u_y", FIRST);
165  sys2.add_variable("u_z", FIRST);
166  es.reinit();
167 
168  var_names.clear();
169  CPPUNIT_ASSERT_THROW_MESSAGE("Duplicate var names not detected",
170  es.build_variable_names(var_names,
171  &fe_type),
173 #endif // LIBMESH_ENABLE_EXCEPTIONS
174  }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:196
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
MeshBase & mesh
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2508
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testConstruction()

void EquationSystemsTest::testConstruction ( )
inline

Definition at line 67 of file equation_systems_test.C.

References mesh, and TestCommWorld.

68  {
69  LOG_UNIT_TEST;
70 
73  }
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
MeshBase & mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testDisableDefaultGhosting()

void EquationSystemsTest::testDisableDefaultGhosting ( )
inline

Definition at line 309 of file equation_systems_test.C.

References libMesh::DofMap::add_algebraic_ghosting_functor(), libMesh::DofMap::add_coupling_functor(), libMesh::MeshBase::add_ghosting_functor(), libMesh::EquationSystems::add_system(), distance(), libMesh::EquationSystems::enable_default_ghosting(), libMesh::System::get_dof_map(), libMesh::MeshBase::ghosting_functors_begin(), libMesh::MeshBase::ghosting_functors_end(), int, mesh, libMesh::MeshBase::remove_ghosting_functor(), and TestCommWorld.

310  {
311  LOG_UNIT_TEST;
312 
314  EquationSystems es(mesh);
315 
316  auto n_ghosts = [&mesh]() {
319  };
320 
321  auto n_evaluables = [](System &sys) {
322  return int(std::distance(sys.get_dof_map().algebraic_ghosting_functors_begin(),
323  sys.get_dof_map().algebraic_ghosting_functors_end()));
324  };
325 
326  auto n_couplings = [](System &sys) {
327  return int(std::distance(sys.get_dof_map().coupling_functors_begin(),
328  sys.get_dof_map().coupling_functors_end()));
329  };
330 
331  // One default ghosting functor on the mesh
332  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
333 
334  // Add another functor, making two
335  auto gpn = std::make_shared<GhostPointNeighbors>(mesh);
337  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 2);
338 
339  // Remove the default, leaving just the user functor
340  es.enable_default_ghosting(false);
341  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
342 
343  // Which can be removed too
345  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 0);
346 
347  // Adding a new system shouldn't add any default ghosting if the
348  // EquationSystems disabled it
349  System & sys1 = es.add_system<System>("System1");
350  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 0);
351  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 0);
352  CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 0);
353 
354  // But if we reenable it then now we should have three functors,
355  // with the default algebraic and coupling functors from sys1.
356  //
357  // We currently iterate over coupling functors manually even when
358  // using them for evaluability... this test will need to change
359  // eventually, when that does.
360  es.enable_default_ghosting(true);
361  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 3);
362  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 1);
363  CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
364 
365  // Adding a second system with default ghosting reenabled should
366  // give us 2 more functors.
367  System & sys2 = es.add_system<System>("System2");
368  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 5);
369  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys2), 1);
370  CPPUNIT_ASSERT_EQUAL(n_couplings(sys2), 1);
371 
372  // Adding a user functor to evaluables and couplings should add it
373  // to the mesh
376  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 6);
377  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 2);
378  CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
379 
380  // Unless we say not to.
381  auto gpn3 = std::make_shared<GhostPointNeighbors>(mesh);
382  sys1.get_dof_map().add_coupling_functor(gpn3, /*to_mesh=*/false);
383  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 6);
384  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 2);
385  CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 2);
386 
387  // Turning off default coupling again should get rid of everything
388  // except the user functors.
389  es.enable_default_ghosting(false);
390  CPPUNIT_ASSERT_EQUAL(n_ghosts(), 1);
391  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys1), 1);
392  CPPUNIT_ASSERT_EQUAL(n_couplings(sys1), 1);
393  CPPUNIT_ASSERT_EQUAL(n_evaluables(sys2), 0);
394  CPPUNIT_ASSERT_EQUAL(n_couplings(sys2), 0);
395  }
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition: mesh_base.C:948
MeshBase & mesh
Real distance(const Point &p)
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
Definition: dof_map.C:2033
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:1291
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...
Definition: dof_map.C:2058
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
const DofMap & get_dof_map() const
Definition: system.h:2374
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
This class implements the original default geometry ghosting requirements in libMesh: point neighbors...
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:1297
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition: mesh_base.h:1267

◆ testInit()

void EquationSystemsTest::testInit ( )
inline

Definition at line 84 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::MeshTools::Generation::build_point(), libMesh::EquationSystems::init(), mesh, and TestCommWorld.

85  {
86  LOG_UNIT_TEST;
87 
90  /*System &sys = */es.add_system<System> ("SimpleSystem");
92  es.init();
93  }
This is the EquationSystems class.
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
MeshBase & mesh
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testPostInitAddElem()

void EquationSystemsTest::testPostInitAddElem ( )
inline

Definition at line 123 of file equation_systems_test.C.

References libMesh::MeshBase::add_elem(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_line(), libMesh::Elem::build_with_id(), libMesh::EDGE2, libMesh::FIRST, libMesh::EquationSystems::init(), libMesh::MeshBase::max_elem_id(), mesh, libMesh::MeshBase::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::DofObject::processor_id(), libMesh::EquationSystems::reinit(), libMesh::Elem::set_node(), and TestCommWorld.

124  {
125  LOG_UNIT_TEST;
126 
128 
129  EquationSystems es(mesh);
130  System &sys = es.add_system<System> ("SimpleSystem");
131  sys.add_variable("u", FIRST);
132 
134  es.init();
135 
136  Elem * e = mesh.add_elem(Elem::build_with_id(EDGE2, mesh.max_elem_id()));
137  e->processor_id() = 0;
138  e->set_node(0, mesh.node_ptr(2));
139  e->set_node(1, mesh.node_ptr(8));
141 
142  es.reinit();
143  }
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2558
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
Definition: mesh_base.C:759
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual dof_id_type max_elem_id() const =0
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
Definition: dof_object.h:905

◆ testPostInitAddRealSystem()

void EquationSystemsTest::testPostInitAddRealSystem ( )
inline

Definition at line 108 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_point(), libMesh::FIRST, libMesh::EquationSystems::init(), mesh, libMesh::EquationSystems::reinit(), and TestCommWorld.

109  {
110  LOG_UNIT_TEST;
111 
114  EquationSystems es(mesh);
115  System &sys1 = es.add_system<System> ("SimpleSystem");
116  sys1.add_variable("u1", FIRST);
117  es.init();
118  System &sys2 = es.add_system<System> ("SecondSystem");
119  sys2.add_variable("u2", FIRST);
120  es.reinit();
121  }
This is the EquationSystems class.
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
MeshBase & mesh
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testPostInitAddSystem()

void EquationSystemsTest::testPostInitAddSystem ( )
inline

Definition at line 95 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::MeshTools::Generation::build_point(), libMesh::EquationSystems::init(), mesh, libMesh::EquationSystems::reinit(), and TestCommWorld.

96  {
97  LOG_UNIT_TEST;
98 
101  EquationSystems es(mesh);
102  /*System &sys1 = */es.add_system<System> ("SimpleSystem");
103  es.init();
104  /*System &sys2 = */es.add_system<System> ("SecondSystem");
105  es.reinit();
106  }
This is the EquationSystems class.
void build_point(UnstructuredMesh &mesh, const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 0D meshes.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
Definition: system.C:454
MeshBase & mesh
void init()
Initializes degrees of freedom on the current mesh.
Definition: system.C:197
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50

◆ testRefineThenReinitPreserveFlags()

void EquationSystemsTest::testRefineThenReinitPreserveFlags ( )
inline

Definition at line 194 of file equation_systems_test.C.

References libMesh::Elem::active(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_square(), libMesh::Elem::child_ptr(), libMesh::EquationSystems::disable_refine_in_reinit(), libMesh::MeshBase::elem_ptr(), libMesh::FIRST, libMesh::Elem::INACTIVE, libMesh::EquationSystems::init(), libMesh::Elem::JUST_REFINED, mesh, libMesh::Elem::n_children(), libMesh::MeshBase::query_elem_ptr(), libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_elements(), libMesh::Elem::refinement_flag(), libMesh::EquationSystems::reinit(), libMesh::remote_elem, libMesh::Elem::set_refinement_flag(), and TestCommWorld.

195  {
196  // This test requires AMR support since it sets refinement flags.
197 #ifdef LIBMESH_ENABLE_AMR
198  LOG_UNIT_TEST;
199 
201  mesh.allow_renumbering(false);
202  EquationSystems es(mesh);
203  System & sys = es.add_system<System> ("SimpleSystem");
204  sys.add_variable("u", FIRST);
206  es.init();
207 
208  Elem * to_refine = mesh.query_elem_ptr(0);
209  if (to_refine)
210  to_refine->set_refinement_flag(Elem::REFINE);
211 
212  MeshRefinement mr(mesh);
213  mr.refine_elements();
214  es.disable_refine_in_reinit();
215  es.reinit();
216 
217  if (mesh.query_elem_ptr(1))
218  CPPUNIT_ASSERT( mesh.elem_ptr(1)->active() );
219 
220  const Elem * elem = mesh.query_elem_ptr(0);
221  if (elem)
222  {
223  CPPUNIT_ASSERT_EQUAL( Elem::INACTIVE,elem->refinement_flag() );
224 
225  for (unsigned int c=0; c<elem->n_children(); c++)
226  if (elem->child_ptr(c) != remote_elem)
227  CPPUNIT_ASSERT_EQUAL(Elem::JUST_REFINED,
228  elem->child_ptr(c)->refinement_flag());
229  }
230 #endif
231  }
RefinementState refinement_flag() const
Definition: elem.h:3210
This is the EquationSystems class.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
Definition: mesh_base.h:1196
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
Definition: elem.h:3218
virtual unsigned int n_children() const =0
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
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
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
bool active() const
Definition: elem.h:2941
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:3163
const RemoteElem * remote_elem
Definition: remote_elem.C:57

◆ testReinitWithNodeElem()

void EquationSystemsTest::testReinitWithNodeElem ( )
inline

Definition at line 176 of file equation_systems_test.C.

References libMesh::MeshBase::add_elem(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_line(), libMesh::CONSTANT, libMesh::EDGE2, libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL, libMesh::MeshBase::node_ptr(), libMesh::NODEELEM, libMesh::MeshBase::prepare_for_use(), libMesh::EquationSystems::reinit(), libMesh::Elem::set_node(), and TestCommWorld.

177  {
178  LOG_UNIT_TEST;
179 
181 
183  auto node_elem = mesh.add_elem(Elem::build(NODEELEM));
184  node_elem->set_node(0, mesh.node_ptr(0));
186 
187  EquationSystems es(mesh);
188  System &sys = es.add_system<System> ("SimpleSystem");
189  sys.add_variable("u", CONSTANT, MONOMIAL);
190  es.init();
191  es.reinit();
192  }
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2558
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
Definition: mesh_base.C:759
MeshBase & mesh
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
virtual const Node * node_ptr(const dof_id_type i) const =0

◆ testRepartitionThenReinit()

void EquationSystemsTest::testRepartitionThenReinit ( )
inline

Definition at line 277 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_renumbering(), libMesh::MeshTools::Generation::build_square(), libMesh::FIRST, libMesh::EquationSystems::init(), mesh, libMesh::EquationSystems::parameters, libMesh::MeshBase::partition(), libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::Real, libMesh::EquationSystems::reinit(), TestCommWorld, and libMesh::TOLERANCE.

278  {
279  LOG_UNIT_TEST;
280 
282  mesh.allow_renumbering(false);
283  EquationSystems es(mesh);
284  System & sys = es.add_system<System> ("SimpleSystem");
285  sys.add_variable("u", FIRST);
287  es.init();
288  sys.project_solution(bilinear_test, NULL, es.parameters);
289 
290  // Force (in parallel) a different partitioning - we'll simply put
291  // everything on rank 0, which hopefully is not what our default
292  // partitioner did!
293  mesh.partition(1);
294 
295  // Make sure the solution is still intact after reinit
296  es.reinit();
297 
298  for (Real x = 0.1; x < 1; x += 0.2)
299  for (Real y = 0.1; y < 1; y += 0.2)
300  {
301  Point p(x,y);
302  LIBMESH_ASSERT_NUMBERS_EQUAL
303  (sys.point_value(0,p),
304  bilinear_test(p,es.parameters,"",""),
306  }
307  }
This is the EquationSystems class.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
Definition: mesh_base.h:1196
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
static constexpr Real TOLERANCE
MeshBase & mesh
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2421
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
virtual void partition(const unsigned int n_parts)
Call the default partitioner (currently metis_partition()).
Definition: mesh_base.C:1576
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39

◆ testSelectivePRefine()

void EquationSystemsTest::testSelectivePRefine ( )
inline

Definition at line 234 of file equation_systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_line(), libMesh::CONSTANT, libMesh::EquationSystems::disable_refine_in_reinit(), libMesh::FIRST, libMesh::System::get_dof_map(), libMesh::EquationSystems::init(), mesh, libMesh::MONOMIAL, libMesh::MeshBase::n_elem(), libMesh::MeshBase::query_elem_ptr(), libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_elements(), libMesh::EquationSystems::reinit(), libMesh::Elem::set_refinement_flag(), libMesh::MeshRefinement::switch_h_to_p_refinement(), TestCommWorld, and libMesh::DofMap::var_group_from_var_number().

235  {
236  // This test requires AMR support since it sets refinement flags.
237 #ifdef LIBMESH_ENABLE_AMR
238  LOG_UNIT_TEST;
239 
241  EquationSystems es(mesh);
242  System & sys = es.add_system<System> ("SimpleSystem");
243  const auto un = sys.add_variable("u", FIRST);
244  const auto vn = sys.add_variable("v", CONSTANT, MONOMIAL);
246  es.init();
247  auto & dof_map = sys.get_dof_map();
248  const auto ug = dof_map.var_group_from_var_number(un);
249  const auto vg = dof_map.var_group_from_var_number(vn);
250  dof_map.should_p_refine(ug, false);
251  dof_map.should_p_refine(vg, true);
252 
253  Elem * to_refine = mesh.query_elem_ptr(0);
254  if (to_refine)
255  to_refine->set_refinement_flag(Elem::REFINE);
256 
257  MeshRefinement mr(mesh);
258  mr.switch_h_to_p_refinement();
259  mr.refine_elements();
260  es.disable_refine_in_reinit();
261  es.reinit();
262 
263  CPPUNIT_ASSERT_EQUAL(mesh.n_elem(), dof_id_type(1));
264  const Elem * elem = mesh.query_elem_ptr(0);
265  if (elem)
266  {
267  std::vector<dof_id_type> dof_indices;
268  dof_map.dof_indices(elem, dof_indices, un);
269  CPPUNIT_ASSERT_EQUAL(dof_indices.size(), std::size_t(2));
270  dof_map.dof_indices(elem, dof_indices, vn);
271  CPPUNIT_ASSERT_EQUAL(dof_indices.size(), std::size_t(2));
272  }
273 #endif
274  }
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:171
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
Definition: elem.h:3218
unsigned int var_group_from_var_number(unsigned int var_num) const
Definition: dof_map.h:2430
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
unsigned int add_variable(std::string_view 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.
Definition: system.C:1357
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
virtual dof_id_type n_elem() const =0
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
const DofMap & get_dof_map() const
Definition: system.h:2374
uint8_t dof_id_type
Definition: id_types.h:67

The documentation for this class was generated from the following file: