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

Public Member Functions

 CPPUNIT_TEST_SUITE (MixedDimensionNonUniformRefinementTriangle)
 Given a mesh with four TRI3 elements and an overlapping EDG2 element this test ensures that when a single TRI3 element that is flagged for refinement, which is a neighbor of the EDGE2 element, that the EDGE2 element will is also be flagged for refinement due to an underrefined_boundary_limit of 0 (default) and the neighboring TRI3 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 603 of file mixed_dim_mesh_test.C.

Member Function Documentation

◆ build_mesh()

void MixedDimensionNonUniformRefinementTriangle::build_mesh ( )
inlineprotected

We start with this

(0,1) (1,1) 3------—2

-
-
-
-

(0,0) 0------—1 (1,0)

-
-
-
-

4------—5 (0,-1) (1,-1)

But the single element refinement should result with this for the default max_mismatch = 0 case

(0,1) (1,1) 3------—2 | -| | - | | 7-—8 | - | - | |- |- | (0,0) 0-—6-—1 (1,0) | - | -| |- | - | 10-—9 | | - | |- | 4------—5 (0,-1) (1,-1)

Definition at line 627 of file mixed_dim_mesh_test.C.

628  {
630 
672 
673  _mesh->add_point( Point(0.0,-1.0), 4 );
674  _mesh->add_point( Point(1.0,-1.0), 5 );
675  _mesh->add_point( Point(1.0, 0.0), 1 );
676  _mesh->add_point( Point(1.0, 1.0), 2 );
677  _mesh->add_point( Point(0.0, 1.0), 3 );
678  _mesh->add_point( Point(0.0, 0.0), 0 );
679 
680  {
681  Elem* elem0 = _mesh->add_elem( new Tri3 );
682  elem0->set_node(0) = _mesh->node_ptr(0);
683  elem0->set_node(1) = _mesh->node_ptr(1);
684  elem0->set_node(2) = _mesh->node_ptr(2);
685 
686  Elem* elem1 = _mesh->add_elem( new Tri3 );
687  elem1->set_node(0) = _mesh->node_ptr(2);
688  elem1->set_node(1) = _mesh->node_ptr(3);
689  elem1->set_node(2) = _mesh->node_ptr(0);
690 
691  Elem* elem2 = _mesh->add_elem( new Tri3 );
692  elem2->set_node(0) = _mesh->node_ptr(1);
693  elem2->set_node(1) = _mesh->node_ptr(0);
694  elem2->set_node(2) = _mesh->node_ptr(4);
695 
696  Elem* elem3 = _mesh->add_elem( new Tri3 );
697  elem3->set_node(0) = _mesh->node_ptr(4);
698  elem3->set_node(1) = _mesh->node_ptr(5);
699  elem3->set_node(2) = _mesh->node_ptr(1);
700 
701  Elem* edge = _mesh->add_elem( new Edge2 );
702  edge->set_node(0) = _mesh->node_ptr(0);
703  edge->set_node(1) = _mesh->node_ptr(1);
704 
705  // 2D elements will have subdomain id 0, this one will have 1
706  edge->subdomain_id() = 1;
707 
708  }
709 
710  // libMesh will renumber, but we numbered according to its scheme
711  // anyway. We do this because when we call uniformly_refine subsequently,
712  // it's going use skip_renumber=false.
713  _mesh->prepare_for_use(false /*skip_renumber*/);
714 
715 #ifdef LIBMESH_ENABLE_AMR
716  //Flag the bottom element for refinement
717  _mesh->elem_ref(4).set_refinement_flag(Elem::REFINE);
719 #endif
720  }

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]

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST() [2/2]

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST_SUITE()

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST_SUITE ( MixedDimensionNonUniformRefinementTriangle  )

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

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void MixedDimensionNonUniformRefinementTriangle::setUp ( )
inline

Definition at line 723 of file mixed_dim_mesh_test.C.

724  {
725 #if LIBMESH_DIM > 1
726  this->build_mesh();
727 #endif
728  }

◆ tearDown()

void MixedDimensionNonUniformRefinementTriangle::tearDown ( )
inline

Definition at line 730 of file mixed_dim_mesh_test.C.

731  {
732 #if LIBMESH_DIM > 1
733  delete _mesh;
734 #endif
735  }

◆ testDofOrdering()

void MixedDimensionNonUniformRefinementTriangle::testDofOrdering ( )
inline

Definition at line 802 of file mixed_dim_mesh_test.C.

803  {
804 #ifdef LIBMESH_ENABLE_AMR
805  EquationSystems es(*_mesh);
806  es.add_system<LinearImplicitSystem>("TestDofSystem");
807  es.get_system("TestDofSystem").add_variable("u",FIRST);
808  es.init();
809 
810  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
811 
812  //Elements above the EDGE2 elements
813  std::vector<dof_id_type> elem5_dof_indices, elem6_dof_indices, elem8_dof_indices;
814 
815  //Elements below the EDGE2 elements
816  std::vector<dof_id_type> elem9_dof_indices, elem10_dof_indices, elem12_dof_indices;
817 
818  //EDGE2 Elements
819  std::vector<dof_id_type> elem13_dof_indices, elem14_dof_indices;
820 
821  dof_map.dof_indices( _mesh->elem_ptr(5), elem5_dof_indices );
822  dof_map.dof_indices( _mesh->elem_ptr(6), elem6_dof_indices );
823  dof_map.dof_indices( _mesh->elem_ptr(8), elem8_dof_indices );
824  dof_map.dof_indices( _mesh->elem_ptr(9), elem9_dof_indices );
825  dof_map.dof_indices( _mesh->elem_ptr(10), elem10_dof_indices );
826  dof_map.dof_indices( _mesh->elem_ptr(12), elem12_dof_indices );
827  dof_map.dof_indices( _mesh->elem_ptr(13), elem13_dof_indices );
828  dof_map.dof_indices( _mesh->elem_ptr(14), elem14_dof_indices );
829 
830  /* The dofs for the EDGE2 (id = 13 and id =14) element should be the same
831  as the bottom edge of the top TRI3 (id=5 and id=6) and the tip of
832  TRI3 id = 8 dofs */
833  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[0], elem5_dof_indices[0] );
834  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem5_dof_indices[1] );
835  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem6_dof_indices[0] );
836  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem8_dof_indices[0] );
837  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem6_dof_indices[0] );
838  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[1], elem6_dof_indices[1] );
839  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem5_dof_indices[1] );
840  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem8_dof_indices[0] );
841 
842  /* The dofs for the EDGE2 (id = 13 and id =14) element should be the same
843  as the top edge of the bottom TRI3 (id=9 and id=10) and the tip of
844  TRI3 id = 12 dofs */
845  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[0], elem10_dof_indices[1] );
846  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem10_dof_indices[0] );
847  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem9_dof_indices[1] );
848  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem12_dof_indices[0] );
849  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem9_dof_indices[1] );
850  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[1], elem9_dof_indices[0] );
851  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem10_dof_indices[0] );
852  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem12_dof_indices[0] );
853 
854  /* The nodes for the bottom edge of the top TRI3 elements should have
855  the same global ids as the top edge of the bottom TRI3 elements. */
856  CPPUNIT_ASSERT_EQUAL( elem5_dof_indices[0], elem10_dof_indices[1] );
857  CPPUNIT_ASSERT_EQUAL( elem5_dof_indices[1], elem10_dof_indices[0] );
858  CPPUNIT_ASSERT_EQUAL( elem6_dof_indices[0], elem9_dof_indices[1] );
859  CPPUNIT_ASSERT_EQUAL( elem6_dof_indices[1], elem9_dof_indices[0] );
860  CPPUNIT_ASSERT_EQUAL( elem8_dof_indices[0], elem12_dof_indices[0] );
861 #endif // LIBMESH_ENABLE_AMR
862  }

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 MixedDimensionNonUniformRefinementTriangle::testMesh ( )
inline

Definition at line 737 of file mixed_dim_mesh_test.C.

738  {
739 #ifdef LIBMESH_ENABLE_AMR
740  // We should have 15 total and 12 active elements.
741  CPPUNIT_ASSERT_EQUAL( (dof_id_type)15, _mesh->n_elem() );
742  CPPUNIT_ASSERT_EQUAL( (dof_id_type)12, _mesh->n_active_elem() );
743 
744  // We should have 15 nodes
745  CPPUNIT_ASSERT_EQUAL( (dof_id_type)11, _mesh->n_nodes() );
746 
747  // EDGE2,id=13 should have same nodes of the base of TRI3, id=5
748  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
749  _mesh->elem_ref(5).node_id(0) );
750  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
751  _mesh->elem_ref(5).node_id(1) );
752 
753  // EDGE2,id=13 should have same nodes of the base of TRI3, id=10
754  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
755  _mesh->elem_ref(10).node_id(1) );
756  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
757  _mesh->elem_ref(10).node_id(0) );
758 
759  // EDGE2,id=13 should have same node as the tip of TRI3, id=8 and id=12
760  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
761  _mesh->elem_ref(8).node_id(0) );
762  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
763  _mesh->elem_ref(12).node_id(0) );
764 
765  // EDGE2,id=14 should have same nodes of the base of TRI3, id=6
766  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
767  _mesh->elem_ref(6).node_id(0) );
768  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
769  _mesh->elem_ref(6).node_id(1) );
770 
771  // EDGE2,id=14 should have same nodes of the base of TRI3, id=9
772  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
773  _mesh->elem_ref(9).node_id(1) );
774  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
775  _mesh->elem_ref(9).node_id(0) );
776 
777  // EDGE2,id=14 should have same node as the tip of TRI3, id=8 and id=12
778  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
779  _mesh->elem_ref(8).node_id(0) );
780  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
781  _mesh->elem_ref(12).node_id(0) );
782 
783  // Shared node between the EDGE2 elements should have the same global id
784  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
785  _mesh->elem_ref(14).node_id(0) );
786 
787  // EDGE2 child elements should have the correct parent
788  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).parent(),
789  _mesh->elem_ptr(4) );
790  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).parent(),
791  _mesh->elem_ptr(4) );
792 
793  // EDGE2 child elements should have the correct interior_parent
794  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).interior_parent(),
795  _mesh->elem_ptr(5) );
796  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).interior_parent(),
797  _mesh->elem_ptr(6) );
798 
799 #endif // LIBMESH_ENABLE_AMR
800  }

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* MixedDimensionNonUniformRefinementTriangle::_mesh
protected

Definition at line 625 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
libMesh::MeshRefinement
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Definition: mesh_refinement.h:61
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
MixedDimensionNonUniformRefinementTriangle::build_mesh
void build_mesh()
Definition: mixed_dim_mesh_test.C:627
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::Tri3
The Tri3 is an element in 2D composed of 3 nodes.
Definition: face_tri3.h:56
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
MixedDimensionNonUniformRefinementTriangle::_mesh
ReplicatedMesh * _mesh
Definition: mixed_dim_mesh_test.C:625
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