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

Public Member Functions

 CPPUNIT_TEST_SUITE (MixedDimensionNonUniformRefinement)
 Given a mesh with four 2D elements and an overlapping 1D element this test ensures that when a single 2D element that is flagged for refinement, which is a neighbor of the 1D element, that the 1D element will is also be flagged for refinement due to an underrefined_boundary_limit of 0 (default) and the neighboring 2D element will also refined due to an overrefined_boundary_limit of 0 (default). More...
 
 CPPUNIT_TEST (testMesh)
 
 CPPUNIT_TEST (testDofOrdering)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testMesh ()
 
void testDofOrdering ()
 

Protected Member Functions

void build_mesh ()
 

Protected Attributes

ReplicatedMesh_mesh
 

Detailed Description

Definition at line 343 of file mixed_dim_mesh_test.C.

Member Function Documentation

◆ build_mesh()

void MixedDimensionNonUniformRefinement::build_mesh ( )
inlineprotected

Definition at line 368 of file mixed_dim_mesh_test.C.

369  {
371  // We start with this
372  //
373  //
374  // (0,2) (1,2)
375  // 4---------------5
376  // | |
377  // | |
378  // | 1 |
379  // | |
380  // | |
381  // (0,1) (1,1)
382  // 3---------------2
383  // | |
384  // | |
385  // | 0 |
386  // | |
387  // | |
388  // 0---------------1
389  // (0,0) (1,0)
390  // | |
391  // | 2 |
392  // | |
393  // | |
394  // 6---------------7
395  // (0,-1) (1,-1)
396  // | |
397  // | 3 |
398  // | |
399  // | |
400  // 9---------------8
401  // (0,-2) (1,-2)
402  //
403  // But the single element refinement should result
404  // with this for the default max_mismatch = 0 case
405  //
406  // 4---------------5
407  // | |
408  // | |
409  // | 1 |
410  // | |
411  // | |
412  // 3------14-------2
413  // | | |
414  // | 7 | 8 |
415  // 12------11-------13
416  // | | |
417  // | 5 | 6 |
418  // 0------10-------1
419  // | | |
420  // | 11 | 12 |
421  // 17------16-------18
422  // | | |
423  // | 9 | 10 |
424  // 6------15-------7
425  // | |
426  // | |
427  // | 3 |
428  // | |
429  // | |
430  // 9---------------8
431 
433 
434  _mesh->add_point( Point(0.0,0.0), 0 );
435  _mesh->add_point( Point(1.0,0.0), 1 );
436  _mesh->add_point( Point(1.0,1.0), 2 );
437  _mesh->add_point( Point(0.0,1.0), 3 );
438  _mesh->add_point( Point(0.0,2.0), 4 );
439  _mesh->add_point( Point(1.0,2.0), 5 );
440  _mesh->add_point( Point(0.0,-1.0), 6 );
441  _mesh->add_point( Point(1.0,-1.0), 7 );
442  _mesh->add_point( Point(1.0,-2.0), 8 );
443  _mesh->add_point( Point(0.0,-2.0), 9 );
444 
445 
446  {
447  Elem* quad0 = _mesh->add_elem( new Quad4 );
448  quad0->set_node(0) = _mesh->node_ptr(0);
449  quad0->set_node(1) = _mesh->node_ptr(1);
450  quad0->set_node(2) = _mesh->node_ptr(2);
451  quad0->set_node(3) = _mesh->node_ptr(3);
452 
453  Elem* quad1 = _mesh->add_elem( new Quad4 );
454  quad1->set_node(0) = _mesh->node_ptr(3);
455  quad1->set_node(1) = _mesh->node_ptr(2);
456  quad1->set_node(2) = _mesh->node_ptr(5);
457  quad1->set_node(3) = _mesh->node_ptr(4);
458 
459  Elem* quad2 = _mesh->add_elem( new Quad4 );
460  quad2->set_node(0) = _mesh->node_ptr(6);
461  quad2->set_node(1) = _mesh->node_ptr(7);
462  quad2->set_node(2) = _mesh->node_ptr(1);
463  quad2->set_node(3) = _mesh->node_ptr(0);
464 
465  Elem* quad3 = _mesh->add_elem( new Quad4 );
466  quad3->set_node(0) = _mesh->node_ptr(9);
467  quad3->set_node(1) = _mesh->node_ptr(8);
468  quad3->set_node(2) = _mesh->node_ptr(7);
469  quad3->set_node(3) = _mesh->node_ptr(6);
470 
471  Elem* edge = _mesh->add_elem( new Edge2 );
472  edge->set_node(0) = _mesh->node_ptr(0);
473  edge->set_node(1) = _mesh->node_ptr(1);
474 
475  // 2D elements will have subdomain id 0, this one will have 1
476  edge->subdomain_id() = 1;
477  }
478 
479  // libMesh will renumber, but we numbered according to its scheme
480  // anyway. We do this because when we call uniformly_refine subsequently,
481  // it's going use skip_renumber=false.
482  _mesh->prepare_for_use(false /*skip_renumber*/);
483 
484 
485 #ifdef LIBMESH_ENABLE_AMR
486  //Flag the bottom element for refinement
487  _mesh->elem_ref(0).set_refinement_flag(Elem::REFINE);
489 #endif
490 
491  }

References libMesh::ReplicatedMesh::add_elem(), libMesh::ReplicatedMesh::add_point(), libMesh::MeshBase::elem_ref(), libMesh::ReplicatedMesh::node_ptr(), libMesh::MeshBase::prepare_for_use(), libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), libMesh::Elem::set_refinement_flag(), libMesh::Elem::subdomain_id(), and TestCommWorld.

◆ CPPUNIT_TEST() [1/2]

MixedDimensionNonUniformRefinement::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST() [2/2]

MixedDimensionNonUniformRefinement::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST_SUITE()

MixedDimensionNonUniformRefinement::CPPUNIT_TEST_SUITE ( MixedDimensionNonUniformRefinement  )

Given a mesh with four 2D elements and an overlapping 1D element this test ensures that when a single 2D element that is flagged for refinement, which is a neighbor of the 1D element, that the 1D element will is also be flagged for refinement due to an underrefined_boundary_limit of 0 (default) and the neighboring 2D element will also refined due to an overrefined_boundary_limit of 0 (default).

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionNonUniformRefinement::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void MixedDimensionNonUniformRefinement::setUp ( )
inline

Definition at line 494 of file mixed_dim_mesh_test.C.

495  {
496 #if LIBMESH_DIM > 1
497  this->build_mesh();
498 #endif
499  }

◆ tearDown()

void MixedDimensionNonUniformRefinement::tearDown ( )
inline

Definition at line 501 of file mixed_dim_mesh_test.C.

502  {
503 #if LIBMESH_DIM > 1
504  delete _mesh;
505 #endif
506  }

◆ testDofOrdering()

void MixedDimensionNonUniformRefinement::testDofOrdering ( )
inline

Definition at line 560 of file mixed_dim_mesh_test.C.

561  {
562 #ifdef LIBMESH_ENABLE_AMR
563  EquationSystems es(*_mesh);
564  es.add_system<LinearImplicitSystem>("TestDofSystem");
565  es.get_system("TestDofSystem").add_variable("u",FIRST);
566  es.init();
567 
568  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
569 
570  std::vector<dof_id_type> top_quad5_dof_indices, top_quad6_dof_indices;
571  std::vector<dof_id_type> bottom_quad11_dof_indices, bottom_quad12_dof_indices;
572  std::vector<dof_id_type> edge13_dof_indices, edge14_dof_indices;
573 
574  dof_map.dof_indices( _mesh->elem_ptr(5), top_quad5_dof_indices );
575  dof_map.dof_indices( _mesh->elem_ptr(6), top_quad6_dof_indices );
576  dof_map.dof_indices( _mesh->elem_ptr(11), bottom_quad11_dof_indices );
577  dof_map.dof_indices( _mesh->elem_ptr(12), bottom_quad12_dof_indices );
578  dof_map.dof_indices( _mesh->elem_ptr(13), edge13_dof_indices );
579  dof_map.dof_indices( _mesh->elem_ptr(14), edge14_dof_indices );
580 
581  // EDGE2,id=13 should have same dofs as of bottom of QUAD4, id=5
582  CPPUNIT_ASSERT_EQUAL( edge13_dof_indices[0], top_quad5_dof_indices[0] );
583  CPPUNIT_ASSERT_EQUAL( edge13_dof_indices[1], top_quad5_dof_indices[1] );
584 
585  // EDGE2,id=14 should have same dofs of bottom of QUAD4, id=6
586  CPPUNIT_ASSERT_EQUAL( edge14_dof_indices[0], top_quad6_dof_indices[0] );
587  CPPUNIT_ASSERT_EQUAL( edge14_dof_indices[1], top_quad6_dof_indices[1] );
588 
589  // EDGE2,id=13 should have same dofs of top of QUAD4, id=11
590  CPPUNIT_ASSERT_EQUAL( edge13_dof_indices[0], bottom_quad11_dof_indices[3] );
591  CPPUNIT_ASSERT_EQUAL( edge13_dof_indices[1], bottom_quad11_dof_indices[2] );
592 
593  // EDGE2,id=14 should have same dofs of top of QUAD4, id=12
594  CPPUNIT_ASSERT_EQUAL( edge14_dof_indices[0], bottom_quad12_dof_indices[3] );
595  CPPUNIT_ASSERT_EQUAL( edge14_dof_indices[1], bottom_quad12_dof_indices[2] );
596 
597  //EDGE2 elements should have same shared dof number
598  CPPUNIT_ASSERT_EQUAL( edge13_dof_indices[1], edge14_dof_indices[0] );
599 #endif
600  }

References libMesh::EquationSystems::add_system(), libMesh::DofMap::dof_indices(), libMesh::ReplicatedMesh::elem_ptr(), libMesh::FIRST, libMesh::EquationSystems::get_system(), and libMesh::EquationSystems::init().

◆ testMesh()

void MixedDimensionNonUniformRefinement::testMesh ( )
inline

Definition at line 508 of file mixed_dim_mesh_test.C.

509  {
510 #ifdef LIBMESH_ENABLE_AMR
511  // We should have 13 total and 10 active elements.
512  CPPUNIT_ASSERT_EQUAL( (dof_id_type)15, _mesh->n_elem() );
513  CPPUNIT_ASSERT_EQUAL( (dof_id_type)12, _mesh->n_active_elem() );
514 
515  // We should have 15 nodes
516  CPPUNIT_ASSERT_EQUAL( (dof_id_type)19, _mesh->n_nodes() );
517 
518  // EDGE2,id=13 should have same nodes of bottom of QUAD4, id=5
519  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
520  _mesh->elem_ref(5).node_id(0) );
521  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
522  _mesh->elem_ref(5).node_id(1) );
523 
524  // EDGE2,id=14 should have same nodes of bottom of QUAD4, id=6
525  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
526  _mesh->elem_ref(6).node_id(0) );
527  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
528  _mesh->elem_ref(6).node_id(1) );
529 
530  // EDGE2,id=13 should have same nodes of top of QUAD4, id=11
531  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
532  _mesh->elem_ref(11).node_id(3) );
533  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
534  _mesh->elem_ref(11).node_id(2) );
535 
536  // EDGE2,id=14 should have same nodes of top of QUAD4, id=12
537  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
538  _mesh->elem_ref(12).node_id(3) );
539  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
540  _mesh->elem_ref(12).node_id(2) );
541 
542  // Shared node between the EDGE2 elements should have the same global id
543  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
544  _mesh->elem_ref(14).node_id(0) );
545 
546  // EDGE2 child elements should have the correct parent
547  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).parent(),
548  _mesh->elem_ptr(4) );
549  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).parent(),
550  _mesh->elem_ptr(4) );
551 
552  // EDGE2 child elements should have the correct interior_parent
553  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).interior_parent(),
554  _mesh->elem_ptr(5) );
555  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).interior_parent(),
556  _mesh->elem_ptr(6) );
557 #endif
558  }

References libMesh::ReplicatedMesh::elem_ptr(), libMesh::MeshBase::elem_ref(), libMesh::Elem::interior_parent(), libMesh::ReplicatedMesh::n_active_elem(), libMesh::ReplicatedMesh::n_elem(), libMesh::ReplicatedMesh::n_nodes(), libMesh::Elem::node_id(), and libMesh::Elem::parent().

Member Data Documentation

◆ _mesh

ReplicatedMesh* MixedDimensionNonUniformRefinement::_mesh
protected

Definition at line 366 of file mixed_dim_mesh_test.C.


The documentation for this class was generated from the following file:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::MeshRefinement::refine_and_coarsen_elements
bool refine_and_coarsen_elements()
Refines and coarsens user-requested elements.
Definition: mesh_refinement.C:476
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::ReplicatedMesh::node_ptr
virtual const Node * node_ptr(const dof_id_type i) const override
Definition: replicated_mesh.C:182
libMesh::MeshBase::elem_ref
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:521
libMesh::ReplicatedMesh::add_elem
virtual Elem * add_elem(Elem *e) override
Add elem e to the end of the element array.
Definition: replicated_mesh.C:282
libMesh::ReplicatedMesh
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Definition: replicated_mesh.h:47
MixedDimensionNonUniformRefinement::build_mesh
void build_mesh()
Definition: mixed_dim_mesh_test.C:368
libMesh::MeshRefinement
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Definition: mesh_refinement.h:61
MixedDimensionNonUniformRefinement::_mesh
ReplicatedMesh * _mesh
Definition: mixed_dim_mesh_test.C:366
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::ReplicatedMesh::n_nodes
virtual dof_id_type n_nodes() const override
Definition: replicated_mesh.h:104
libMesh::Quad4
The QUAD4 is an element in 2D composed of 4 nodes.
Definition: face_quad4.h:51
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::Elem::set_node
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:2059
libMesh::Elem::parent
const Elem * parent() const
Definition: elem.h:2434
libMesh::Elem::interior_parent
const Elem * interior_parent() const
Definition: elem.C:749
libMesh::ReplicatedMesh::n_elem
virtual dof_id_type n_elem() const override
Definition: replicated_mesh.h:116
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::Elem::subdomain_id
subdomain_id_type subdomain_id() const
Definition: elem.h:2069
libMesh::ReplicatedMesh::elem_ptr
virtual const Elem * elem_ptr(const dof_id_type i) const override
Definition: replicated_mesh.C:232
libMesh::Edge2
The Edge2 is an element in 1D composed of 2 nodes.
Definition: edge_edge2.h:43
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::Elem::set_refinement_flag
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
Definition: elem.h:2622
libMesh::Elem::node_id
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1977
libMesh::MeshBase::prepare_for_use
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
Definition: mesh_base.C:318
libMesh::LinearImplicitSystem
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
Definition: linear_implicit_system.h:55
libMesh::MeshBase::set_mesh_dimension
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:218
libMesh::FIRST
Definition: enum_order.h:42
libMesh::ReplicatedMesh::add_point
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id) override
functions for adding /deleting nodes elements.
Definition: replicated_mesh.C:417
libMesh::ReplicatedMesh::n_active_elem
virtual dof_id_type n_active_elem() const override
Definition: replicated_mesh.C:1424