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

Public Member Functions

 CPPUNIT_TEST_SUITE (PointNeighborCouplingTest)
 
 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 32 of file point_neighbor_coupling_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnEdge3  )

◆ CPPUNIT_TEST() [2/4]

PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnHex27  )

◆ CPPUNIT_TEST() [3/4]

PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnQuad9  )

◆ CPPUNIT_TEST() [4/4]

PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnTri6  )

◆ CPPUNIT_TEST_SUITE()

PointNeighborCouplingTest::CPPUNIT_TEST_SUITE ( PointNeighborCouplingTest  )

◆ CPPUNIT_TEST_SUITE_END()

PointNeighborCouplingTest::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void PointNeighborCouplingTest::setUp ( )
inline

Definition at line 50 of file point_neighbor_coupling_test.C.

51  {}

◆ tearDown()

void PointNeighborCouplingTest::tearDown ( )
inline

Definition at line 53 of file point_neighbor_coupling_test.C.

54  {}

◆ testCoupling()

void PointNeighborCouplingTest::testCoupling ( const ElemType  elem_type)
inline

Definition at line 56 of file point_neighbor_coupling_test.C.

57  {
59 
61  System &sys = es.add_system<System> ("SimpleSystem");
62  sys.add_variable("u", THIRD, HIERARCHIC);
63 
64  // Remove the default DoF ghosting functors
66  (sys.get_dof_map().default_coupling());
69 
70  // Create a replacement functor
71  PointNeighborCoupling point_neighbor_coupling;
72 
73  // This just re-sets the default; real users may want a real
74  // coupling matrix instead.
75  point_neighbor_coupling.set_dof_coupling(nullptr);
76 
77  point_neighbor_coupling.set_n_levels(3);
78 
80  (point_neighbor_coupling);
81 
82  const unsigned int n_elem_per_side = 5;
83  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
84  const unsigned int ymax = test_elem->dim() > 1;
85  const unsigned int zmax = test_elem->dim() > 2;
86  const unsigned int ny = ymax * n_elem_per_side;
87  const unsigned int nz = zmax * n_elem_per_side;
88 
90  n_elem_per_side,
91  ny,
92  nz,
93  0., 1.,
94  0., ymax,
95  0., zmax,
96  elem_type);
97 
98  es.init();
99  sys.project_solution(cubic_point_neighbor_coupling_test, nullptr, es.parameters);
100 
101  for (const auto & elem : mesh.active_local_element_ptr_range())
102  for (unsigned int s1=0; s1 != elem->n_neighbors(); ++s1)
103  {
104  const Elem * n1 = elem->neighbor_ptr(s1);
105  if (!n1)
106  continue;
107 
108  libmesh_assert(sys.get_dof_map().is_evaluable(*n1, 0));
109 
110  // Let's speed up this test by only checking the ghosted
111  // elements which are most likely to break.
112  if (n1->processor_id() == mesh.processor_id())
113  continue;
114 
115  for (unsigned int s2=0; s2 != elem->n_neighbors(); ++s2)
116  {
117  const Elem * n2 = elem->neighbor_ptr(s2);
118  if (!n2 ||
119  n2->processor_id() == mesh.processor_id())
120  continue;
121 
122  libmesh_assert(sys.get_dof_map().is_evaluable(*n2, 0));
123 
124  for (unsigned int s3=0; s3 != elem->n_neighbors(); ++s3)
125  {
126  const Elem * n3 = elem->neighbor_ptr(s3);
127  if (!n3 ||
128  n3->processor_id() == mesh.processor_id())
129  continue;
130 
131  libmesh_assert(sys.get_dof_map().is_evaluable(*n3, 0));
132 
133  Point p = n3->centroid();
134 
135  LIBMESH_ASSERT_FP_EQUAL(libmesh_real(sys.point_value(0,p,n3)),
136  libmesh_real(cubic_point_neighbor_coupling_test(p,es.parameters,"","")),
138  }
139  }
140  }
141  }

References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::DofMap::add_algebraic_ghosting_functor(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::Elem::centroid(), cubic_point_neighbor_coupling_test(), libMesh::DofMap::default_algebraic_ghosting(), libMesh::DofMap::default_coupling(), libMesh::System::get_dof_map(), libMesh::HIERARCHIC, libMesh::EquationSystems::init(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), 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::DofMap::remove_algebraic_ghosting_functor(), libMesh::DofMap::remove_coupling_functor(), libMesh::PointNeighborCoupling::set_dof_coupling(), libMesh::PointNeighborCoupling::set_n_levels(), TestCommWorld, libMesh::THIRD, and libMesh::TOLERANCE.

◆ testCouplingOnEdge3()

void PointNeighborCouplingTest::testCouplingOnEdge3 ( )
inline

Definition at line 145 of file point_neighbor_coupling_test.C.

145 { testCoupling(EDGE3); }

References libMesh::EDGE3.

◆ testCouplingOnHex27()

void PointNeighborCouplingTest::testCouplingOnHex27 ( )
inline

Definition at line 148 of file point_neighbor_coupling_test.C.

148 { testCoupling(HEX27); }

References libMesh::HEX27.

◆ testCouplingOnQuad9()

void PointNeighborCouplingTest::testCouplingOnQuad9 ( )
inline

Definition at line 146 of file point_neighbor_coupling_test.C.

146 { testCoupling(QUAD9); }

References libMesh::QUAD9.

◆ testCouplingOnTri6()

void PointNeighborCouplingTest::testCouplingOnTri6 ( )
inline

Definition at line 147 of file point_neighbor_coupling_test.C.

147 { testCoupling(TRI6); }

References libMesh::TRI6.


The documentation for this class was generated from the following file:
libMesh::DofMap::add_algebraic_ghosting_functor
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:1862
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::DofMap::remove_coupling_functor
void remove_coupling_functor(GhostingFunctor &coupling_functor)
Removes a functor which was previously added to the set of coupling functors, from both this DofMap a...
Definition: dof_map.C:1849
cubic_point_neighbor_coupling_test
Number cubic_point_neighbor_coupling_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: point_neighbor_coupling_test.C:18
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::DofMap::default_coupling
DefaultCoupling & default_coupling()
Default coupling functor.
Definition: dof_map.h:341
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::libmesh_assert
libmesh_assert(ctx)
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
libMesh::PointNeighborCoupling::set_n_levels
void set_n_levels(unsigned int n_levels)
Definition: point_neighbor_coupling.h:66
libMesh::HIERARCHIC
Definition: enum_fe_family.h:37
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::DofMap::remove_algebraic_ghosting_functor
void remove_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor)
Removes a functor which was previously added to the set of algebraic ghosting functors,...
Definition: dof_map.C:1873
libMesh::TRI6
Definition: enum_elem_type.h:40
libMesh::PointNeighborCoupling::set_dof_coupling
void set_dof_coupling(const CouplingMatrix *dof_coupling)
Definition: point_neighbor_coupling.h:58
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
PointNeighborCouplingTest::testCoupling
void testCoupling(const ElemType elem_type)
Definition: point_neighbor_coupling_test.C:56
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::PointNeighborCoupling
This class implements the default algebraic coupling in libMesh: elements couple to themselves,...
Definition: point_neighbor_coupling.h:41