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

Public Member Functions

 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 ( testCouplingOnHex27  )

◆ CPPUNIT_TEST() [3/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnQuad9  )

◆ CPPUNIT_TEST() [4/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnTri6  )

◆ CPPUNIT_TEST_SUITE()

DefaultCouplingTest::CPPUNIT_TEST_SUITE ( DefaultCouplingTest  )

◆ CPPUNIT_TEST_SUITE_END()

DefaultCouplingTest::CPPUNIT_TEST_SUITE_END ( )

◆ 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.

56  {
58 
60  System &sys = es.add_system<System> ("SimpleSystem");
61  sys.add_variable("u", THIRD, HIERARCHIC);
63 
64  const unsigned int n_elem_per_side = 5;
65  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
66  const unsigned int ymax = test_elem->dim() > 1;
67  const unsigned int zmax = test_elem->dim() > 2;
68  const unsigned int ny = ymax * n_elem_per_side;
69  const unsigned int nz = zmax * n_elem_per_side;
70 
72  n_elem_per_side,
73  ny,
74  nz,
75  0., 1.,
76  0., ymax,
77  0., zmax,
78  elem_type);
79 
80  es.init();
81  sys.project_solution(cubic_default_coupling_test, nullptr, es.parameters);
82 
83  std::set<dof_id_type> evaluable_elements;
84 
85  for (const auto & elem : mesh.active_local_element_ptr_range())
86  {
87  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*elem));
88  evaluable_elements.insert(elem->id());
89 
90  for (unsigned int s1=0; s1 != elem->n_neighbors(); ++s1)
91  {
92  const Elem * n1 = elem->neighbor_ptr(s1);
93  // Let's speed up this test by only checking the ghosted
94  // elements which are most likely to break.
95  if (!n1 ||
96  n1->processor_id() == mesh.processor_id())
97  continue;
98 
99  if (!evaluable_elements.count(n1->id()))
100  {
101  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n1));
102  evaluable_elements.insert(n1->id());
103  }
104 
105  for (unsigned int s2=0; s2 != elem->n_neighbors(); ++s2)
106  {
107  const Elem * n2 = n1->neighbor_ptr(s2);
108  if (!n2 ||
109  n2->processor_id() == mesh.processor_id())
110  continue;
111 
112  if (!evaluable_elements.count(n2->id()))
113  {
114  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n2));
115  evaluable_elements.insert(n2->id());
116  }
117 
118  for (unsigned int s3=0; s3 != elem->n_neighbors(); ++s3)
119  {
120  const Elem * n3 = n2->neighbor_ptr(s3);
121  if (!n3 ||
122  n3->processor_id() == mesh.processor_id() ||
123  evaluable_elements.count(n3->id()))
124  continue;
125 
126  CPPUNIT_ASSERT(sys.get_dof_map().is_evaluable(*n3));
127  evaluable_elements.insert(n3->id());
128 
129  Point p = n3->centroid();
130 
131  LIBMESH_ASSERT_FP_EQUAL(libmesh_real(sys.point_value(0,p,n3)),
132  libmesh_real(cubic_default_coupling_test(p,es.parameters,"","")),
134  }
135  }
136  }
137  }
138 
139  const std::size_t n_evaluable =
142 
143  CPPUNIT_ASSERT_EQUAL(evaluable_elements.size(), n_evaluable);
144  }

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::Elem::centroid(), cubic_default_coupling_test(), libMesh::DofMap::default_algebraic_ghosting(), distance(), libMesh::MeshBase::evaluable_elements_begin(), libMesh::MeshBase::evaluable_elements_end(), 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, and libMesh::TOLERANCE.

◆ testCouplingOnEdge3()

void DefaultCouplingTest::testCouplingOnEdge3 ( )
inline

Definition at line 148 of file default_coupling_test.C.

148 { testCoupling(EDGE3); }

References libMesh::EDGE3.

◆ testCouplingOnHex27()

void DefaultCouplingTest::testCouplingOnHex27 ( )
inline

Definition at line 151 of file default_coupling_test.C.

151 { testCoupling(HEX27); }

References libMesh::HEX27.

◆ testCouplingOnQuad9()

void DefaultCouplingTest::testCouplingOnQuad9 ( )
inline

Definition at line 149 of file default_coupling_test.C.

149 { testCoupling(QUAD9); }

References libMesh::QUAD9.

◆ testCouplingOnTri6()

void DefaultCouplingTest::testCouplingOnTri6 ( )
inline

Definition at line 150 of file default_coupling_test.C.

150 { testCoupling(TRI6); }

References libMesh::TRI6.


The documentation for this class was generated from the following file:
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::DofMap::is_evaluable
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2553
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
libMesh::libmesh_real
T libmesh_real(T a)
Definition: libmesh_common.h:166
libMesh::MeshBase::active_local_element_ptr_range
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
libMesh::MeshTools::Generation::build_cube
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.
Definition: mesh_generation.C:298
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::MeshBase::evaluable_elements_begin
virtual element_iterator evaluable_elements_begin(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
Iterate over elements in the Mesh where the solution (as distributed by the given DofMap) can be eval...
libMesh::DofObject::processor_id
processor_id_type processor_id() const
Definition: dof_object.h:829
libMesh::Elem::centroid
virtual Point centroid() const
Definition: elem.C:345
libMesh::MeshBase::evaluable_elements_end
virtual element_iterator evaluable_elements_end(const DofMap &dof_map, unsigned int var_num=libMesh::invalid_uint)=0
cubic_default_coupling_test
Number cubic_default_coupling_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: default_coupling_test.C:17
libMesh::HEX27
Definition: enum_elem_type.h:49
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::System::add_variable
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.
Definition: system.C:1069
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
DefaultCouplingTest::testCoupling
void testCoupling(const ElemType elem_type)
Definition: default_coupling_test.C:55
libMesh::HIERARCHIC
Definition: enum_fe_family.h:37
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::TRI6
Definition: enum_elem_type.h:40
distance
Real distance(const Point &p)
Definition: subdomains_ex3.C:50
libMesh::System::point_value
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:1971
libMesh::DofObject::id
dof_id_type id() const
Definition: dof_object.h:767
libMesh::EDGE3
Definition: enum_elem_type.h:36
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::THIRD
Definition: enum_order.h:44
libMesh::DofMap::default_algebraic_ghosting
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition: dof_map.h:403
libMesh::QUAD9
Definition: enum_elem_type.h:43
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::Elem::neighbor_ptr
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:2085
libMesh::System::project_solution
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Definition: system_projection.C:950
libMesh::DefaultCoupling::set_n_levels
void set_n_levels(unsigned int n_levels)
Definition: default_coupling.h:65