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 597 of file mixed_dim_mesh_test.C.

Member Function Documentation

void MixedDimensionNonUniformRefinementTriangle::build_mesh ( )
protected

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 617 of file mixed_dim_mesh_test.C.

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.

618  {
620 
662 
663  _mesh->add_point( Point(0.0,-1.0), 4 );
664  _mesh->add_point( Point(1.0,-1.0), 5 );
665  _mesh->add_point( Point(1.0, 0.0), 1 );
666  _mesh->add_point( Point(1.0, 1.0), 2 );
667  _mesh->add_point( Point(0.0, 1.0), 3 );
668  _mesh->add_point( Point(0.0, 0.0), 0 );
669 
670  {
671  Elem* elem0 = _mesh->add_elem( new Tri3 );
672  elem0->set_node(0) = _mesh->node_ptr(0);
673  elem0->set_node(1) = _mesh->node_ptr(1);
674  elem0->set_node(2) = _mesh->node_ptr(2);
675 
676  Elem* elem1 = _mesh->add_elem( new Tri3 );
677  elem1->set_node(0) = _mesh->node_ptr(2);
678  elem1->set_node(1) = _mesh->node_ptr(3);
679  elem1->set_node(2) = _mesh->node_ptr(0);
680 
681  Elem* elem2 = _mesh->add_elem( new Tri3 );
682  elem2->set_node(0) = _mesh->node_ptr(1);
683  elem2->set_node(1) = _mesh->node_ptr(0);
684  elem2->set_node(2) = _mesh->node_ptr(4);
685 
686  Elem* elem3 = _mesh->add_elem( new Tri3 );
687  elem3->set_node(0) = _mesh->node_ptr(4);
688  elem3->set_node(1) = _mesh->node_ptr(5);
689  elem3->set_node(2) = _mesh->node_ptr(1);
690 
691  Elem* edge = _mesh->add_elem( new Edge2 );
692  edge->set_node(0) = _mesh->node_ptr(0);
693  edge->set_node(1) = _mesh->node_ptr(1);
694 
695  // 2D elements will have subdomain id 0, this one will have 1
696  edge->subdomain_id() = 1;
697 
698  }
699 
700  // libMesh will renumber, but we numbered according to its scheme
701  // anyway. We do this because when we call uniformly_refine subsequently,
702  // it's going use skip_renumber=false.
703  _mesh->prepare_for_use(false /*skip_renumber*/);
704 
705 #ifdef LIBMESH_ENABLE_AMR
706  //Flag the bottom element for refinement
707  _mesh->elem_ref(4).set_refinement_flag(Elem::REFINE);
709 #endif
710  }
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) libmesh_override
functions for adding /deleting nodes elements.
The Tri3 is an element in 2D composed of 3 nodes.
Definition: face_tri3.h:54
virtual const Node * node_ptr(const dof_id_type i) const libmesh_override
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1941
virtual Elem * add_elem(Elem *e) libmesh_override
Add elem e to the end of the element array.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
Definition: elem.h:2513
This is the MeshRefinement class.
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly created (or read) mesh for use.
Definition: mesh_base.C:174
subdomain_id_type subdomain_id() const
Definition: elem.h:1951
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
Definition: mesh_base.h:199
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
bool refine_and_coarsen_elements()
Refines and coarsens user-requested elements.
The Edge2 is an element in 1D composed of 2 nodes.
Definition: edge_edge2.h:43
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testMesh  )
MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testDofOrdering  )
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).

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST_SUITE_END ( )
void MixedDimensionNonUniformRefinementTriangle::setUp ( )

Definition at line 713 of file mixed_dim_mesh_test.C.

714  {
715  this->build_mesh();
716  }
void MixedDimensionNonUniformRefinementTriangle::tearDown ( )

Definition at line 718 of file mixed_dim_mesh_test.C.

719  {
720  delete _mesh;
721  }
void MixedDimensionNonUniformRefinementTriangle::testDofOrdering ( )

Definition at line 788 of file mixed_dim_mesh_test.C.

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

789  {
790 #ifdef LIBMESH_ENABLE_AMR
791  EquationSystems es(*_mesh);
792  es.add_system<LinearImplicitSystem>("TestDofSystem");
793  es.get_system("TestDofSystem").add_variable("u",FIRST);
794  es.init();
795 
796  DofMap& dof_map = es.get_system("TestDofSystem").get_dof_map();
797 
798  //Elements above the EDGE2 elements
799  std::vector<dof_id_type> elem5_dof_indices, elem6_dof_indices, elem8_dof_indices;
800 
801  //Elements below the EDGE2 elements
802  std::vector<dof_id_type> elem9_dof_indices, elem10_dof_indices, elem12_dof_indices;
803 
804  //EDGE2 Elements
805  std::vector<dof_id_type> elem13_dof_indices, elem14_dof_indices;
806 
807  dof_map.dof_indices( _mesh->elem_ptr(5), elem5_dof_indices );
808  dof_map.dof_indices( _mesh->elem_ptr(6), elem6_dof_indices );
809  dof_map.dof_indices( _mesh->elem_ptr(8), elem8_dof_indices );
810  dof_map.dof_indices( _mesh->elem_ptr(9), elem9_dof_indices );
811  dof_map.dof_indices( _mesh->elem_ptr(10), elem10_dof_indices );
812  dof_map.dof_indices( _mesh->elem_ptr(12), elem12_dof_indices );
813  dof_map.dof_indices( _mesh->elem_ptr(13), elem13_dof_indices );
814  dof_map.dof_indices( _mesh->elem_ptr(14), elem14_dof_indices );
815 
816  /* The dofs for the EDGE2 (id = 13 and id =14) element should be the same
817  as the bottom edge of the top TRI3 (id=5 and id=6) and the tip of
818  TRI3 id = 8 dofs */
819  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[0], elem5_dof_indices[0] );
820  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem5_dof_indices[1] );
821  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem6_dof_indices[0] );
822  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem8_dof_indices[0] );
823  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem6_dof_indices[0] );
824  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[1], elem6_dof_indices[1] );
825  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem5_dof_indices[1] );
826  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem8_dof_indices[0] );
827 
828  /* The dofs for the EDGE2 (id = 13 and id =14) element should be the same
829  as the top edge of the bottom TRI3 (id=9 and id=10) and the tip of
830  TRI3 id = 12 dofs */
831  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[0], elem10_dof_indices[1] );
832  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem10_dof_indices[0] );
833  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem9_dof_indices[1] );
834  CPPUNIT_ASSERT_EQUAL( elem13_dof_indices[1], elem12_dof_indices[0] );
835  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem9_dof_indices[1] );
836  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[1], elem9_dof_indices[0] );
837  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem10_dof_indices[0] );
838  CPPUNIT_ASSERT_EQUAL( elem14_dof_indices[0], elem12_dof_indices[0] );
839 
840  /* The nodes for the bottom edge of the top TRI3 elements should have
841  the same global ids as the top edge of the bottom TRI3 elements. */
842  CPPUNIT_ASSERT_EQUAL( elem5_dof_indices[0], elem10_dof_indices[1] );
843  CPPUNIT_ASSERT_EQUAL( elem5_dof_indices[1], elem10_dof_indices[0] );
844  CPPUNIT_ASSERT_EQUAL( elem6_dof_indices[0], elem9_dof_indices[1] );
845  CPPUNIT_ASSERT_EQUAL( elem6_dof_indices[1], elem9_dof_indices[0] );
846  CPPUNIT_ASSERT_EQUAL( elem8_dof_indices[0], elem12_dof_indices[0] );
847 #endif // LIBMESH_ENABLE_AMR
848  }
virtual const Elem * elem_ptr(const dof_id_type i) const libmesh_override
This is the EquationSystems class.
This class provides a specific system class.
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 class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
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:1917
void MixedDimensionNonUniformRefinementTriangle::testMesh ( )

Definition at line 723 of file mixed_dim_mesh_test.C.

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().

724  {
725 #ifdef LIBMESH_ENABLE_AMR
726  // We should have 15 total and 12 active elements.
727  CPPUNIT_ASSERT_EQUAL( (dof_id_type)15, _mesh->n_elem() );
728  CPPUNIT_ASSERT_EQUAL( (dof_id_type)12, _mesh->n_active_elem() );
729 
730  // We should have 15 nodes
731  CPPUNIT_ASSERT_EQUAL( (dof_id_type)11, _mesh->n_nodes() );
732 
733  // EDGE2,id=13 should have same nodes of the base of TRI3, id=5
734  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
735  _mesh->elem_ref(5).node_id(0) );
736  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
737  _mesh->elem_ref(5).node_id(1) );
738 
739  // EDGE2,id=13 should have same nodes of the base of TRI3, id=10
740  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(0),
741  _mesh->elem_ref(10).node_id(1) );
742  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
743  _mesh->elem_ref(10).node_id(0) );
744 
745  // EDGE2,id=13 should have same node as the tip of TRI3, id=8 and id=12
746  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
747  _mesh->elem_ref(8).node_id(0) );
748  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
749  _mesh->elem_ref(12).node_id(0) );
750 
751  // EDGE2,id=14 should have same nodes of the base of TRI3, id=6
752  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
753  _mesh->elem_ref(6).node_id(0) );
754  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
755  _mesh->elem_ref(6).node_id(1) );
756 
757  // EDGE2,id=14 should have same nodes of the base of TRI3, id=9
758  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
759  _mesh->elem_ref(9).node_id(1) );
760  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(1),
761  _mesh->elem_ref(9).node_id(0) );
762 
763  // EDGE2,id=14 should have same node as the tip of TRI3, id=8 and id=12
764  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
765  _mesh->elem_ref(8).node_id(0) );
766  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).node_id(0),
767  _mesh->elem_ref(12).node_id(0) );
768 
769  // Shared node between the EDGE2 elements should have the same global id
770  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).node_id(1),
771  _mesh->elem_ref(14).node_id(0) );
772 
773  // EDGE2 child elements should have the correct parent
774  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).parent(),
775  _mesh->elem_ptr(4) );
776  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).parent(),
777  _mesh->elem_ptr(4) );
778 
779  // EDGE2 child elements should have the correct interior_parent
780  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(13).interior_parent(),
781  _mesh->elem_ptr(5) );
782  CPPUNIT_ASSERT_EQUAL( _mesh->elem_ref(14).interior_parent(),
783  _mesh->elem_ptr(6) );
784 
785 #endif // LIBMESH_ENABLE_AMR
786  }
virtual const Elem * elem_ptr(const dof_id_type i) const libmesh_override
const Elem * parent() const
Definition: elem.h:2346
const Elem * interior_parent() const
Definition: elem.C:951
virtual dof_id_type n_elem() const libmesh_override
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
virtual dof_id_type n_nodes() const libmesh_override
virtual dof_id_type n_active_elem() const libmesh_override
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

ReplicatedMesh* MixedDimensionNonUniformRefinementTriangle::_mesh
protected

Definition at line 615 of file mixed_dim_mesh_test.C.


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