libMesh
Loading...
Searching...
No Matches
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 ( testCouplingOnHex27  )

◆ CPPUNIT_TEST() [3/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnQuad9  )

◆ CPPUNIT_TEST() [4/4]

DefaultCouplingTest::CPPUNIT_TEST ( testCouplingOnTri6  )

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

56 {
57 LOG_UNIT_TEST;
58
59 Mesh mesh(*TestCommWorld);
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 ||
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_NUMBERS_EQUAL(sys.point_value(0,p,n3),
134 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 }
void set_n_levels(unsigned int n_levels)
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition dof_map.h:440
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition dof_map.C:2673
processor_id_type processor_id() const
Definition dof_object.h:881
dof_id_type id() const
Definition dof_object.h:819
This is the base class from which all geometric element types are derived.
Definition elem.h:96
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2615
Point vertex_average() const
Definition elem.C:669
This is the EquationSystems class.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
processor_id_type processor_id() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2219
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:1344
const DofMap & get_dof_map() const
Definition system.h:2417
Number cubic_default_coupling_test(const Point &p, const Parameters &, const std::string &, const std::string &)
MeshBase & mesh
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.
static constexpr Real TOLERANCE

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(), libMesh::System::get_dof_map(), libMesh::HIERARCHIC, libMesh::DofObject::id(), libMesh::EquationSystems::init(), libMesh::DofMap::is_evaluable(), mesh, libMesh::Elem::neighbor_ptr(), libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), libMesh::System::project_solution(), libMesh::DefaultCoupling::set_n_levels(), TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::Elem::vertex_average().

Referenced by testCouplingOnEdge3(), testCouplingOnHex27(), testCouplingOnQuad9(), and testCouplingOnTri6().

◆ testCouplingOnEdge3()

void DefaultCouplingTest::testCouplingOnEdge3 ( )
inline

Definition at line 150 of file default_coupling_test.C.

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

References libMesh::EDGE3, and testCoupling().

◆ testCouplingOnHex27()

void DefaultCouplingTest::testCouplingOnHex27 ( )
inline

Definition at line 153 of file default_coupling_test.C.

153{ LOG_UNIT_TEST; testCoupling(HEX27); }

References libMesh::HEX27, and testCoupling().

◆ testCouplingOnQuad9()

void DefaultCouplingTest::testCouplingOnQuad9 ( )
inline

Definition at line 151 of file default_coupling_test.C.

151{ LOG_UNIT_TEST; testCoupling(QUAD9); }

References libMesh::QUAD9, and testCoupling().

◆ testCouplingOnTri6()

void DefaultCouplingTest::testCouplingOnTri6 ( )
inline

Definition at line 152 of file default_coupling_test.C.

152{ LOG_UNIT_TEST; testCoupling(TRI6); }

References testCoupling(), and libMesh::TRI6.


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