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 46 of file point_neighbor_coupling_test.C.

Member Function Documentation

PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnEdge3  )
PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnQuad9  )
PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnTri6  )
PointNeighborCouplingTest::CPPUNIT_TEST ( testCouplingOnHex27  )
PointNeighborCouplingTest::CPPUNIT_TEST_SUITE ( PointNeighborCouplingTest  )
PointNeighborCouplingTest::CPPUNIT_TEST_SUITE_END ( )
void PointNeighborCouplingTest::setUp ( )

Definition at line 60 of file point_neighbor_coupling_test.C.

61  {}
void PointNeighborCouplingTest::tearDown ( )

Definition at line 63 of file point_neighbor_coupling_test.C.

64  {}
void PointNeighborCouplingTest::testCoupling ( const ElemType  elem_type)

Definition at line 66 of file point_neighbor_coupling_test.C.

References libMesh::DistributedMesh::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::Real, libMesh::DofMap::remove_algebraic_ghosting_functor(), libMesh::DofMap::remove_coupling_functor(), libMesh::PointNeighborCoupling::set_dof_coupling(), libMesh::PointNeighborCoupling::set_n_levels(), libMesh::sys, TestCommWorld, libMesh::THIRD, and libMesh::TOLERANCE.

67  {
69 
71  System &sys = es.add_system<System> ("SimpleSystem");
72  sys.add_variable("u", THIRD, HIERARCHIC);
73 
74  // Remove the default DoF ghosting functors
76  (sys.get_dof_map().default_coupling());
79 
80  // Create a replacement functor
81  PointNeighborCoupling point_neighbor_coupling;
82 
83  // This just re-sets the default; real users may want a real
84  // coupling matrix instead.
85  point_neighbor_coupling.set_dof_coupling(NULL);
86 
87  point_neighbor_coupling.set_n_levels(3);
88 
90  (point_neighbor_coupling);
91 
92  const unsigned n_elem_per_side = 5;
93  const UniquePtr<Elem> test_elem = Elem::build(elem_type);
94  const Real ymax = test_elem->dim() > 1;
95  const Real zmax = test_elem->dim() > 2;
96  const unsigned int ny = ymax * n_elem_per_side;
97  const unsigned int nz = zmax * n_elem_per_side;
98 
100  n_elem_per_side,
101  ny,
102  nz,
103  0., 1.,
104  0., ymax,
105  0., zmax,
106  elem_type);
107 
108  es.init();
109  sys.project_solution(cubic_point_neighbor_coupling_test, NULL, es.parameters);
110 
111  for (const auto & elem : mesh.active_local_element_ptr_range())
112  for (unsigned int s1=0; s1 != elem->n_neighbors(); ++s1)
113  {
114  const Elem * n1 = elem->neighbor_ptr(s1);
115  if (!n1)
116  continue;
117 
118  libmesh_assert(sys.get_dof_map().is_evaluable(*n1, 0));
119 
120  // Let's speed up this test by only checking the ghosted
121  // elements which are most likely to break.
122  if (n1->processor_id() == mesh.processor_id())
123  continue;
124 
125  for (unsigned int s2=0; s2 != elem->n_neighbors(); ++s2)
126  {
127  const Elem * n2 = elem->neighbor_ptr(s2);
128  if (!n2 ||
129  n2->processor_id() == mesh.processor_id())
130  continue;
131 
132  libmesh_assert(sys.get_dof_map().is_evaluable(*n2, 0));
133 
134  for (unsigned int s3=0; s3 != elem->n_neighbors(); ++s3)
135  {
136  const Elem * n3 = elem->neighbor_ptr(s3);
137  if (!n3 ||
138  n3->processor_id() == mesh.processor_id())
139  continue;
140 
141  libmesh_assert(sys.get_dof_map().is_evaluable(*n3, 0));
142 
143  Point p = n3->centroid();
144 
145  CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(sys.point_value(0,p,n3)),
146  libmesh_real(cubic_point_neighbor_coupling_test(p,es.parameters,"","")),
148  }
149  }
150  }
151  }
T libmesh_real(T a)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2011
This is the EquationSystems class.
DefaultCoupling & default_coupling()
Default coupling functor.
Definition: dof_map.h:287
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2357
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
ImplicitSystem & sys
void set_n_levels(unsigned int n_levels)
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1101
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
MeshBase & mesh
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition: dof_map.h:323
static const Real TOLERANCE
Number cubic_point_neighbor_coupling_test(const Point &p, const Parameters &, const std::string &, const std::string &)
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
Projects arbitrary functions onto the current solution.
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1967
void add_algebraic_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors...
Definition: dof_map.C:1813
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
This class implements the default algebraic coupling in libMesh: elements couple to themselves...
const DofMap & get_dof_map() const
Definition: system.h:2030
void remove_algebraic_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of algebraic ghosting functors.
Definition: dof_map.C:1822
void set_dof_coupling(const CouplingMatrix *dof_coupling)
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
void remove_coupling_functor(GhostingFunctor &coupling_functor)
Removes a functor which was previously added to the set of coupling functors.
Definition: dof_map.C:1803
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Point centroid() const
Definition: elem.C:446
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:38
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.
processor_id_type processor_id() const
processor_id_type processor_id() const
Definition: dof_object.h:694
void PointNeighborCouplingTest::testCouplingOnEdge3 ( )

Definition at line 155 of file point_neighbor_coupling_test.C.

References libMesh::EDGE3.

155 { testCoupling(EDGE3); }
void testCoupling(const ElemType elem_type)
void PointNeighborCouplingTest::testCouplingOnHex27 ( )
void PointNeighborCouplingTest::testCouplingOnQuad9 ( )

Definition at line 156 of file point_neighbor_coupling_test.C.

References libMesh::QUAD9.

156 { testCoupling(QUAD9); }
void testCoupling(const ElemType elem_type)
void PointNeighborCouplingTest::testCouplingOnTri6 ( )

Definition at line 157 of file point_neighbor_coupling_test.C.

References libMesh::TRI6.

157 { testCoupling(TRI6); }
void testCoupling(const ElemType elem_type)

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