libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
OverlappingFunctorTest Class Reference
Inheritance diagram for OverlappingFunctorTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (OverlappingFunctorTest)
 
 CPPUNIT_TEST (checkCouplingFunctorQuad)
 
 CPPUNIT_TEST (checkCouplingFunctorTri)
 
 CPPUNIT_TEST (checkOverlappingPartitioner)
 
 CPPUNIT_TEST (checkCouplingFunctorQuadUnifRef)
 
 CPPUNIT_TEST (checkCouplingFunctorTriUnifRef)
 
 CPPUNIT_TEST (checkOverlappingPartitionerUnifRef)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void checkCouplingFunctorQuad ()
 
void checkCouplingFunctorQuadUnifRef ()
 
void checkCouplingFunctorTri ()
 
void checkCouplingFunctorTriUnifRef ()
 
void checkOverlappingPartitioner ()
 
void checkOverlappingPartitionerUnifRef ()
 

Protected Member Functions

void build_quad_mesh (unsigned int n_refinements=0)
 
void init ()
 
void clear ()
 
void setup_coupling_matrix (std::unique_ptr< CouplingMatrix > &coupling)
 

Protected Attributes

std::unique_ptr< MeshBase > _mesh
 
std::unique_ptr< EquationSystems > _es
 

Private Member Functions

void run_coupling_functor_test (unsigned int n_refinements)
 
void run_partitioner_test (unsigned int n_refinements)
 

Detailed Description

Definition at line 367 of file overlapping_coupling_test.C.

Member Function Documentation

◆ build_quad_mesh()

void OverlappingTestBase::build_quad_mesh ( unsigned int  n_refinements = 0)
inlineprotectedinherited

Definition at line 251 of file overlapping_coupling_test.C.

252 {
253 // We are making assumptions in various places about the presence
254 // of the elements on the current processor so we're restricting to
255 // ReplicatedMesh for now.
256 _mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
257
258 _mesh->set_mesh_dimension(2);
259
260 _mesh->add_point( Point(0.0,0.0),0 );
261 _mesh->add_point( Point(1.0,0.0),1 );
262 _mesh->add_point( Point(1.0,1.0),2 );
263 _mesh->add_point( Point(0.0,1.0),3 );
264
265 {
266 Elem * elem = _mesh->add_elem(Elem::build_with_id(QUAD4, 0));
267 elem->subdomain_id() = 1;
268
269 for (unsigned int n=0; n<4; n++)
270 elem->set_node(n, _mesh->node_ptr(n));
271 }
272
273 _mesh->add_point( Point(1.0,2.0),4 );
274 _mesh->add_point( Point(0.0,2.0),5 );
275
276 {
277 Elem * elem = _mesh->add_elem(Elem::build_with_id(QUAD4, 1));
278 elem->subdomain_id() = 1;
279
280 elem->set_node(0, _mesh->node_ptr(3));
281 elem->set_node(1, _mesh->node_ptr(2));
282 elem->set_node(2, _mesh->node_ptr(4));
283 elem->set_node(3, _mesh->node_ptr(5));
284 }
285
286 _mesh->add_point( Point(0.0,0.0),6 );
287 _mesh->add_point( Point(1.0,0.0),7 );
288 _mesh->add_point( Point(1.0,2.0),8 );
289 _mesh->add_point( Point(0.0,2.0),9 );
290
291 {
292 Elem* elem = _mesh->add_elem(Elem::build_with_id(QUAD4, 2));
293 elem->subdomain_id() = 2;
294
295 elem->set_node(0, _mesh->node_ptr(6));
296 elem->set_node(1, _mesh->node_ptr(7));
297 elem->set_node(2, _mesh->node_ptr(8));
298 elem->set_node(3, _mesh->node_ptr(9));
299 }
300
301 _mesh->partitioner() = std::make_unique<OverlappingTestPartitioner>();
302
303 _mesh->prepare_for_use();
304
305#ifdef LIBMESH_ENABLE_AMR
306 if (n_refinements > 0)
307 {
308 MeshRefinement refine(*_mesh);
309 refine.uniformly_refine(n_refinements);
310 }
311#else
312 CPPUNIT_ASSERT_EQUAL(n_refinements, 0u);
313#endif // LIBMESH_ENABLE_AMR
314 }
std::unique_ptr< MeshBase > _mesh
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2688
static std::unique_ptr< Elem > build_with_id(const ElemType type, dof_id_type id)
Calls the build() method above with a nullptr parent, and additionally sets the newly-created Elem's ...
Definition elem.C:496
subdomain_id_type subdomain_id() const
Definition elem.h:2712
Implements (adaptive) mesh refinement algorithms for a MeshBase.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41

References OverlappingTestBase::_mesh, libMesh::Elem::build_with_id(), libMesh::QUAD4, libMesh::Elem::set_node(), libMesh::Elem::subdomain_id(), TestCommWorld, and libMesh::MeshRefinement::uniformly_refine().

Referenced by OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), and setUp().

◆ checkCouplingFunctorQuad()

void OverlappingFunctorTest::checkCouplingFunctorQuad ( )
inline

Definition at line 399 of file overlapping_coupling_test.C.

400 { this->run_coupling_functor_test(0); }
void run_coupling_functor_test(unsigned int n_refinements)

References run_coupling_functor_test().

◆ checkCouplingFunctorQuadUnifRef()

void OverlappingFunctorTest::checkCouplingFunctorQuadUnifRef ( )
inline

Definition at line 402 of file overlapping_coupling_test.C.

403 { this->run_coupling_functor_test(1); }

References run_coupling_functor_test().

◆ checkCouplingFunctorTri()

void OverlappingFunctorTest::checkCouplingFunctorTri ( )
inline

Definition at line 405 of file overlapping_coupling_test.C.

406 {
408 _es->reinit();
410 }
std::unique_ptr< EquationSystems > _es
void all_tri(MeshBase &mesh)
Subdivides any non-simplex elements in a Mesh to produce simplex (triangular in 2D,...

References OverlappingTestBase::_es, OverlappingTestBase::_mesh, libMesh::MeshTools::Modification::all_tri(), and run_coupling_functor_test().

◆ checkCouplingFunctorTriUnifRef()

void OverlappingFunctorTest::checkCouplingFunctorTriUnifRef ( )
inline

◆ checkOverlappingPartitioner()

void OverlappingFunctorTest::checkOverlappingPartitioner ( )
inline

Definition at line 419 of file overlapping_coupling_test.C.

420 {
421 this->run_partitioner_test(0);
422 }
void run_partitioner_test(unsigned int n_refinements)

References run_partitioner_test().

◆ checkOverlappingPartitionerUnifRef()

void OverlappingFunctorTest::checkOverlappingPartitionerUnifRef ( )
inline

Definition at line 424 of file overlapping_coupling_test.C.

425 {
426 this->run_partitioner_test(1);
427 }

References run_partitioner_test().

◆ clear()

void OverlappingTestBase::clear ( )
inlineprotectedinherited

◆ CPPUNIT_TEST() [1/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkCouplingFunctorQuad  )

◆ CPPUNIT_TEST() [2/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkCouplingFunctorQuadUnifRef  )

◆ CPPUNIT_TEST() [3/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkCouplingFunctorTri  )

◆ CPPUNIT_TEST() [4/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkCouplingFunctorTriUnifRef  )

◆ CPPUNIT_TEST() [5/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkOverlappingPartitioner  )

◆ CPPUNIT_TEST() [6/6]

OverlappingFunctorTest::CPPUNIT_TEST ( checkOverlappingPartitionerUnifRef  )

◆ CPPUNIT_TEST_SUITE_END()

OverlappingFunctorTest::CPPUNIT_TEST_SUITE_END ( )

◆ init()

void OverlappingTestBase::init ( )
inlineprotectedinherited

Definition at line 316 of file overlapping_coupling_test.C.

317 {
318 _es = std::make_unique<EquationSystems>(*_mesh);
319 LinearImplicitSystem & sys = _es->add_system<LinearImplicitSystem> ("SimpleSystem");
320
321 std::set<subdomain_id_type> sub_one;
322 sub_one.insert(1);
323
324 std::set<subdomain_id_type> sub_two;
325 sub_two.insert(2);
326
327 sys.add_variable("U", FIRST, LAGRANGE, &sub_two);
328 sys.add_variable("L", FIRST, LAGRANGE, &sub_two);
329
330 sys.add_variable("V", FIRST, LAGRANGE, &sub_one);
331 sys.add_variable("p", FIRST, LAGRANGE, &sub_one);
332
333 _es->init();
334 }
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
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

References OverlappingTestBase::_es, OverlappingTestBase::_mesh, libMesh::System::add_variable(), libMesh::FIRST, and libMesh::LAGRANGE.

Referenced by OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), and setUp().

◆ LIBMESH_CPPUNIT_TEST_SUITE()

OverlappingFunctorTest::LIBMESH_CPPUNIT_TEST_SUITE ( OverlappingFunctorTest  )

◆ run_coupling_functor_test()

void OverlappingFunctorTest::run_coupling_functor_test ( unsigned int  n_refinements)
inlineprivate

Definition at line 435 of file overlapping_coupling_test.C.

436 {
437#if defined(LIBMESH_ENABLE_AMR) && defined(LIBMESH_HAVE_SOLVER)
438 if( n_refinements > 0 )
439 {
440 MeshRefinement refine(*_mesh);
441 refine.uniformly_refine(n_refinements);
442 _es->reinit();
443 }
444#else
445 CPPUNIT_ASSERT_EQUAL(n_refinements, 0u);
446#endif
447
448 System & system = _es->get_system("SimpleSystem");
449
450 OverlappingCouplingFunctor coupling_functor(system);
451
452 GhostingFunctor::map_type subdomain_one_couplings;
453 GhostingFunctor::map_type subdomain_two_couplings;
454
455 coupling_functor( _mesh->active_subdomain_elements_begin(1),
456 _mesh->active_subdomain_elements_end(1),
458 subdomain_one_couplings );
459
460 coupling_functor( _mesh->active_subdomain_elements_begin(2),
461 _mesh->active_subdomain_elements_end(2),
463 subdomain_two_couplings );
464
465 dof_id_type n_elems_subdomain_two = std::distance( _mesh->active_subdomain_elements_begin(2),
466 _mesh->active_subdomain_elements_end(2) );
467
468 CPPUNIT_ASSERT_EQUAL(n_elems_subdomain_two, static_cast<dof_id_type>(subdomain_one_couplings.size()));
469 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(2*n_elems_subdomain_two), static_cast<dof_id_type>(subdomain_two_couplings.size()));
470 }
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
uint8_t dof_id_type
Definition id_types.h:67

References OverlappingTestBase::_es, OverlappingTestBase::_mesh, libMesh::DofObject::invalid_processor_id, and libMesh::MeshRefinement::uniformly_refine().

Referenced by checkCouplingFunctorQuad(), checkCouplingFunctorQuadUnifRef(), checkCouplingFunctorTri(), and checkCouplingFunctorTriUnifRef().

◆ run_partitioner_test()

void OverlappingFunctorTest::run_partitioner_test ( unsigned int  n_refinements)
inlineprivate

Definition at line 472 of file overlapping_coupling_test.C.

473 {
474#ifdef LIBMESH_ENABLE_AMR
475 if( n_refinements > 0 )
476 {
477 MeshRefinement refine(*_mesh);
478 refine.uniformly_refine(n_refinements);
479 _es->reinit();
480 }
481#else
482 CPPUNIT_ASSERT_EQUAL(n_refinements, 0u);
483#endif // LIBMESH_ENABLE_AMR
484
485 System & system = _es->get_system("SimpleSystem");
486
487 std::set<processor_id_type> sub_one_proc_ids, sub_two_proc_ids;
488 for (auto & elem : _mesh->active_subdomain_elements_ptr_range(1))
489 sub_one_proc_ids.insert(elem->processor_id());
490
491 for (auto & elem : _mesh->active_subdomain_elements_ptr_range(2))
492 sub_two_proc_ids.insert(elem->processor_id());
493
494
495 // Everyone should be on the same processor if only 1 processor
496 if( system.n_processors() == 1 )
497 {
498 CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(sub_one_proc_ids.size()));
499 CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(sub_two_proc_ids.size()));
500 CPPUNIT_ASSERT( sub_one_proc_ids == sub_two_proc_ids );
501 }
502 // Otherwise these sets should be disjoint
503 else
504 {
505 // Make sure no subdomain one ids in the subdomain two ids
506 for (auto & id : sub_one_proc_ids )
507 CPPUNIT_ASSERT( sub_two_proc_ids.find(id) == sub_two_proc_ids.end() );
508
509 // Vice-versa
510 for (auto & id : sub_two_proc_ids )
511 CPPUNIT_ASSERT( sub_one_proc_ids.find(id) == sub_one_proc_ids.end() );
512 }
513 }
processor_id_type n_processors() const

References OverlappingTestBase::_es, OverlappingTestBase::_mesh, libMesh::ParallelObject::n_processors(), and libMesh::MeshRefinement::uniformly_refine().

Referenced by checkOverlappingPartitioner(), and checkOverlappingPartitionerUnifRef().

◆ setUp()

void OverlappingFunctorTest::setUp ( )
inline

Definition at line 390 of file overlapping_coupling_test.C.

391 {
392 this->build_quad_mesh();
393 this->init();
394 }
void build_quad_mesh(unsigned int n_refinements=0)

References OverlappingTestBase::build_quad_mesh(), and OverlappingTestBase::init().

◆ setup_coupling_matrix()

void OverlappingTestBase::setup_coupling_matrix ( std::unique_ptr< CouplingMatrix > &  coupling)
inlineprotectedinherited

Definition at line 342 of file overlapping_coupling_test.C.

343 {
344 System & system = _es->get_system("SimpleSystem");
345
346 coupling = std::make_unique<CouplingMatrix>(system.n_vars());
347
348 const unsigned int u_var = system.variable_number("U");
349 const unsigned int l_var = system.variable_number("L");
350 const unsigned int v_var = system.variable_number("V");
351 const unsigned int p_var = system.variable_number("p");
352
353 // Only adding the overlapping couplings since the primary ones should
354 // be there by default.
355 (*coupling)(u_var,v_var) = true;
356 (*coupling)(l_var,v_var) = true;
357 (*coupling)(l_var,p_var) = true;
358 (*coupling)(v_var,u_var) = true;
359 (*coupling)(v_var,l_var) = true;
360 }
unsigned int variable_number(std::string_view var) const
Definition system.C:1398
unsigned int n_vars() const
Definition system.C:2674

References OverlappingTestBase::_es, libMesh::System::n_vars(), and libMesh::System::variable_number().

Referenced by OverlappingAlgebraicGhostingTest::run_ghosting_test(), and OverlappingCouplingGhostingTest::run_sparsity_pattern_test().

◆ tearDown()

void OverlappingFunctorTest::tearDown ( )
inline

Definition at line 396 of file overlapping_coupling_test.C.

397 { this->clear(); }

References OverlappingTestBase::clear().

Member Data Documentation

◆ _es

std::unique_ptr<EquationSystems> OverlappingTestBase::_es
protectedinherited

◆ _mesh

std::unique_ptr<MeshBase> OverlappingTestBase::_mesh
protectedinherited

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