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

Public Member Functions

 LIBMESH_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 (testMesh)
 
 CPPUNIT_TEST (testDofOrdering)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testMesh ()
 
void testDofOrdering ()
 

Protected Member Functions

void build_mesh ()
 

Protected Attributes

std::unique_ptr< ReplicatedMesh_mesh
 

Detailed Description

Definition at line 605 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 629 of file mixed_dim_mesh_test.C.

630 {
631 _mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
632
673 _mesh->set_mesh_dimension(2);
674
675 _mesh->add_point( Point(0.0,-1.0), 4 );
676 _mesh->add_point( Point(1.0,-1.0), 5 );
677 _mesh->add_point( Point(1.0, 0.0), 1 );
678 _mesh->add_point( Point(1.0, 1.0), 2 );
679 _mesh->add_point( Point(0.0, 1.0), 3 );
680 _mesh->add_point( Point(0.0, 0.0), 0 );
681
682 {
683 Elem * elem0 = _mesh->add_elem(Elem::build(TRI3));
684 elem0->set_node(0, _mesh->node_ptr(0));
685 elem0->set_node(1, _mesh->node_ptr(1));
686 elem0->set_node(2, _mesh->node_ptr(2));
687
688 Elem * elem1 = _mesh->add_elem(Elem::build(TRI3));
689 elem1->set_node(0, _mesh->node_ptr(2));
690 elem1->set_node(1, _mesh->node_ptr(3));
691 elem1->set_node(2, _mesh->node_ptr(0));
692
693 Elem * elem2 = _mesh->add_elem(Elem::build(TRI3));
694 elem2->set_node(0, _mesh->node_ptr(1));
695 elem2->set_node(1, _mesh->node_ptr(0));
696 elem2->set_node(2, _mesh->node_ptr(4));
697
698 Elem * elem3 = _mesh->add_elem(Elem::build(TRI3));
699 elem3->set_node(0, _mesh->node_ptr(4));
700 elem3->set_node(1, _mesh->node_ptr(5));
701 elem3->set_node(2, _mesh->node_ptr(1));
702
703 Elem * edge = _mesh->add_elem(Elem::build(EDGE2));
704 edge->set_node(0, _mesh->node_ptr(0));
705 edge->set_node(1, _mesh->node_ptr(1));
706
707 // 2D elements will have subdomain id 0, this one will have 1
708 edge->subdomain_id() = 1;
709
710 }
711
712 _mesh->allow_renumbering(true);
713 _mesh->prepare_for_use();
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 }
std::unique_ptr< ReplicatedMesh > _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:2567
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
subdomain_id_type subdomain_id() const
Definition elem.h:2591
Implements (adaptive) mesh refinement algorithms for a MeshBase.
bool refine_and_coarsen_elements()
Refines and coarsens user-requested elements.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40

References _mesh, libMesh::Elem::build(), libMesh::EDGE2, libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::Elem::set_node(), libMesh::Elem::subdomain_id(), TestCommWorld, and libMesh::TRI3.

Referenced by setUp().

◆ CPPUNIT_TEST() [1/2]

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST() [2/2]

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionNonUniformRefinementTriangle::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

MixedDimensionNonUniformRefinementTriangle::LIBMESH_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).

◆ 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 }

References build_mesh().

◆ tearDown()

void MixedDimensionNonUniformRefinementTriangle::tearDown ( )
inline

Definition at line 730 of file mixed_dim_mesh_test.C.

730{}

◆ testDofOrdering()

void MixedDimensionNonUniformRefinementTriangle::testDofOrdering ( )
inline

Definition at line 799 of file mixed_dim_mesh_test.C.

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

◆ testMesh()

void MixedDimensionNonUniformRefinementTriangle::testMesh ( )
inline

Definition at line 732 of file mixed_dim_mesh_test.C.

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

References _mesh.

Member Data Documentation

◆ _mesh

std::unique_ptr<ReplicatedMesh> MixedDimensionNonUniformRefinementTriangle::_mesh
protected

Definition at line 627 of file mixed_dim_mesh_test.C.

Referenced by build_mesh(), testDofOrdering(), and testMesh().


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