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

Member Function Documentation

void MixedDimensionNonUniformRefinement::build_mesh ( )
protected

Definition at line 366 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.

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

MixedDimensionNonUniformRefinement::CPPUNIT_TEST_SUITE_END ( )
void MixedDimensionNonUniformRefinement::setUp ( )

Definition at line 492 of file mixed_dim_mesh_test.C.

493  {
494  this->build_mesh();
495  }
void MixedDimensionNonUniformRefinement::tearDown ( )

Definition at line 497 of file mixed_dim_mesh_test.C.

498  {
499  delete _mesh;
500  }
void MixedDimensionNonUniformRefinement::testDofOrdering ( )

Definition at line 554 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().

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

Definition at line 502 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().

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

Definition at line 364 of file mixed_dim_mesh_test.C.


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