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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (DefaultCouplingTest)
 
 CPPUNIT_TEST (testCouplingOnEdge3)
 
 CPPUNIT_TEST (testCouplingOnQuad9)
 
 CPPUNIT_TEST (testCouplingOnTri6)
 
 CPPUNIT_TEST (testCouplingOnHex27)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testCoupling (const ElemType elem_type)
 
void testCouplingOnEdge3 ()
 
void testCouplingOnQuad9 ()
 
void testCouplingOnTri6 ()
 
void testCouplingOnHex27 ()
 

Detailed Description

Definition at line 31 of file default_coupling_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnEdge3  )

◆ CPPUNIT_TEST() [2/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnQuad9  )

◆ CPPUNIT_TEST() [3/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnTri6  )

◆ CPPUNIT_TEST() [4/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnHex27  )

◆ CPPUNIT_TEST_SUITE_END()

DefaultCouplingTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

DefaultCouplingTest::LIBMESH_CPPUNIT_TEST_SUITE ( DefaultCouplingTest  )

◆ setUp()

void DefaultCouplingTest::setUp ( )
inline

Definition at line 49 of file default_coupling_test.C.

50  {}

◆ tearDown()

void DefaultCouplingTest::tearDown ( )
inline

Definition at line 52 of file default_coupling_test.C.

53  {}

◆ testCoupling()

void DefaultCouplingTest::testCoupling ( const ElemType  elem_type)
inline

Definition at line 55 of file default_coupling_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), cubic_default_coupling_test(), libMesh::DofMap::default_algebraic_ghosting(), distance(), libMesh::System::get_dof_map(), libMesh::HIERARCHIC, libMesh::DofObject::id(), libMesh::EquationSystems::init(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_real(), mesh, libMesh::Elem::neighbor_ptr(), libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::System::project_solution(), libMesh::DefaultCoupling::set_n_levels(), TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::Elem::vertex_average().

56  {
57  LOG_UNIT_TEST;
58 
60 
62  System &sys = es.add_system<System> ("SimpleSystem");
63  sys.add_variable("u", THIRD, HIERARCHIC);
65 
66  const unsigned int n_elem_per_side = 5;
67  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
68  const unsigned int ymax = test_elem->dim() > 1;
69  const unsigned int zmax = test_elem->dim() > 2;
70  const unsigned int ny = ymax * n_elem_per_side;
71  const unsigned int nz = zmax * n_elem_per_side;
72 
74  n_elem_per_side,
75  ny,
76  nz,
77  0., 1.,
78  0., ymax,
79  0., zmax,
80  elem_type);
81 
82  es.init();
83  sys.project_solution(cubic_default_coupling_test, nullptr, es.parameters);
84 
85  std::set<dof_id_type> evaluable_elements;
86 
87  for (const auto & elem : mesh.active_local_element_ptr_range())
88  {
89  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*elem));
90  evaluable_elements.insert(elem->id());
91 
92  for (unsigned int s1=0; s1 != elem->n_neighbors(); ++s1)
93  {
94  const Elem * n1 = elem->neighbor_ptr(s1);
95  // Let's speed up this test by only checking the ghosted
96  // elements which are most likely to break.
97  if (!n1 ||
98  n1->processor_id() == mesh.processor_id())
99  continue;
100 
101  if (!evaluable_elements.count(n1->id()))
102  {
103  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n1));
104  evaluable_elements.insert(n1->id());
105  }
106 
107  for (unsigned int s2=0; s2 != elem->n_neighbors(); ++s2)
108  {
109  const Elem * n2 = n1->neighbor_ptr(s2);
110  if (!n2 ||
111  n2->processor_id() == mesh.processor_id())
112  continue;
113 
114  if (!evaluable_elements.count(n2->id()))
115  {
116  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n2));
117  evaluable_elements.insert(n2->id());
118  }
119 
120  for (unsigned int s3=0; s3 != elem->n_neighbors(); ++s3)
121  {
122  const Elem * n3 = n2->neighbor_ptr(s3);
123  if (!n3 ||
124  n3->processor_id() == mesh.processor_id() ||
125  evaluable_elements.count(n3->id()))
126  continue;
127 
128  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n3));
129  evaluable_elements.insert(n3->id());
130 
131  Point p = n3->vertex_average();
132 
133  LIBMESH_ASSERT_FP_EQUAL(libmesh_real(sys.point_value(0,p,n3)),
134  libmesh_real(cubic_default_coupling_test(p,es.parameters,"","")),
136  }
137  }
138  }
139  }
140 
141  const std::size_t n_evaluable =
142  std::distance(mesh.evaluable_elements_begin(sys.get_dof_map()),
143  mesh.evaluable_elements_end(sys.get_dof_map()));
144 
145  CPPUNIT_ASSERT_EQUAL(evaluable_elements.size(), n_evaluable);
146  }
T libmesh_real(T a)
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
static constexpr Real TOLERANCE
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition: dof_map.h:418
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2369
Real distance(const Point &p)
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Number cubic_default_coupling_test(const Point &p, const Parameters &, const std::string &, const std::string &)
dof_id_type id() const
Definition: dof_object.h:823
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:1305
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:2407
void set_n_levels(unsigned int n_levels)
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
processor_id_type processor_id() const
Definition: dof_object.h:898
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
Point vertex_average() const
Definition: elem.C:498
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2609

◆ testCouplingOnEdge3()

void DefaultCouplingTest::testCouplingOnEdge3 ( )
inline

Definition at line 150 of file default_coupling_test.C.

References libMesh::EDGE3.

150 { LOG_UNIT_TEST; testCoupling(EDGE3); }
void testCoupling(const ElemType elem_type)

◆ testCouplingOnHex27()

void DefaultCouplingTest::testCouplingOnHex27 ( )
inline

Definition at line 153 of file default_coupling_test.C.

References libMesh::HEX27.

153 { LOG_UNIT_TEST; testCoupling(HEX27); }
void testCoupling(const ElemType elem_type)

◆ testCouplingOnQuad9()

void DefaultCouplingTest::testCouplingOnQuad9 ( )
inline

Definition at line 151 of file default_coupling_test.C.

References libMesh::QUAD9.

151 { LOG_UNIT_TEST; testCoupling(QUAD9); }
void testCoupling(const ElemType elem_type)

◆ testCouplingOnTri6()

void DefaultCouplingTest::testCouplingOnTri6 ( )
inline

Definition at line 152 of file default_coupling_test.C.

References libMesh::TRI6.

152 { LOG_UNIT_TEST; testCoupling(TRI6); }
void testCoupling(const ElemType elem_type)

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