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

Public Member Functions

 LIBMESH_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 (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 348 of file mixed_dim_mesh_test.C.

Member Function Documentation

◆ build_mesh()

void MixedDimensionNonUniformRefinement::build_mesh ( )
inlineprotected

Definition at line 373 of file mixed_dim_mesh_test.C.

374 {
375 _mesh = std::make_unique<ReplicatedMesh>(*TestCommWorld);
376 // We start with this
377 //
378 //
379 // (0,2) (1,2)
380 // 4---------------5
381 // | |
382 // | |
383 // | 1 |
384 // | |
385 // | |
386 // (0,1) (1,1)
387 // 3---------------2
388 // | |
389 // | |
390 // | 0 |
391 // | |
392 // | |
393 // 0---------------1
394 // (0,0) (1,0)
395 // | |
396 // | 2 |
397 // | |
398 // | |
399 // 6---------------7
400 // (0,-1) (1,-1)
401 // | |
402 // | 3 |
403 // | |
404 // | |
405 // 9---------------8
406 // (0,-2) (1,-2)
407 //
408 // But the single element refinement should result
409 // with this for the default max_mismatch = 0 case
410 //
411 // 4---------------5
412 // | |
413 // | |
414 // | 1 |
415 // | |
416 // | |
417 // 3------14-------2
418 // | | |
419 // | 7 | 8 |
420 // 12------11-------13
421 // | | |
422 // | 5 | 6 |
423 // 0------10-------1
424 // | | |
425 // | 11 | 12 |
426 // 17------16-------18
427 // | | |
428 // | 9 | 10 |
429 // 6------15-------7
430 // | |
431 // | |
432 // | 3 |
433 // | |
434 // | |
435 // 9---------------8
436
437 _mesh->set_mesh_dimension(2);
438
439 _mesh->add_point( Point(0.0,0.0), 0 );
440 _mesh->add_point( Point(1.0,0.0), 1 );
441 _mesh->add_point( Point(1.0,1.0), 2 );
442 _mesh->add_point( Point(0.0,1.0), 3 );
443 _mesh->add_point( Point(0.0,2.0), 4 );
444 _mesh->add_point( Point(1.0,2.0), 5 );
445 _mesh->add_point( Point(0.0,-1.0), 6 );
446 _mesh->add_point( Point(1.0,-1.0), 7 );
447 _mesh->add_point( Point(1.0,-2.0), 8 );
448 _mesh->add_point( Point(0.0,-2.0), 9 );
449
450
451 {
452 Elem * quad0 = _mesh->add_elem(Elem::build(QUAD4));
453 quad0->set_node(0, _mesh->node_ptr(0));
454 quad0->set_node(1, _mesh->node_ptr(1));
455 quad0->set_node(2, _mesh->node_ptr(2));
456 quad0->set_node(3, _mesh->node_ptr(3));
457
458 Elem * quad1 = _mesh->add_elem(Elem::build(QUAD4));
459 quad1->set_node(0, _mesh->node_ptr(3));
460 quad1->set_node(1, _mesh->node_ptr(2));
461 quad1->set_node(2, _mesh->node_ptr(5));
462 quad1->set_node(3, _mesh->node_ptr(4));
463
464 Elem * quad2 = _mesh->add_elem(Elem::build(QUAD4));
465 quad2->set_node(0, _mesh->node_ptr(6));
466 quad2->set_node(1, _mesh->node_ptr(7));
467 quad2->set_node(2, _mesh->node_ptr(1));
468 quad2->set_node(3, _mesh->node_ptr(0));
469
470 Elem * quad3 = _mesh->add_elem(Elem::build(QUAD4));
471 quad3->set_node(0, _mesh->node_ptr(9));
472 quad3->set_node(1, _mesh->node_ptr(8));
473 quad3->set_node(2, _mesh->node_ptr(7));
474 quad3->set_node(3, _mesh->node_ptr(6));
475
476 Elem * edge = _mesh->add_elem(Elem::build(EDGE2));
477 edge->set_node(0, _mesh->node_ptr(0));
478 edge->set_node(1, _mesh->node_ptr(1));
479
480 // 2D elements will have subdomain id 0, this one will have 1
481 edge->subdomain_id() = 1;
482 }
483
484 _mesh->allow_renumbering(true);
485 _mesh->prepare_for_use();
486
487
488#ifdef LIBMESH_ENABLE_AMR
489 //Flag the bottom element for refinement
490 _mesh->elem_ref(0).set_refinement_flag(Elem::REFINE);
492#endif
493
494 }
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::QUAD4, libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::Elem::set_node(), libMesh::Elem::subdomain_id(), and TestCommWorld.

Referenced by setUp().

◆ CPPUNIT_TEST() [1/2]

MixedDimensionNonUniformRefinement::CPPUNIT_TEST ( testDofOrdering  )

◆ CPPUNIT_TEST() [2/2]

MixedDimensionNonUniformRefinement::CPPUNIT_TEST ( testMesh  )

◆ CPPUNIT_TEST_SUITE_END()

MixedDimensionNonUniformRefinement::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

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

◆ setUp()

void MixedDimensionNonUniformRefinement::setUp ( )
inline

Definition at line 497 of file mixed_dim_mesh_test.C.

498 {
499#if LIBMESH_DIM > 1
500 this->build_mesh();
501#endif
502 }

References build_mesh().

◆ tearDown()

void MixedDimensionNonUniformRefinement::tearDown ( )
inline

Definition at line 504 of file mixed_dim_mesh_test.C.

504{}

◆ testDofOrdering()

void MixedDimensionNonUniformRefinement::testDofOrdering ( )
inline

Definition at line 560 of file mixed_dim_mesh_test.C.

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

Definition at line 506 of file mixed_dim_mesh_test.C.

507 {
508#ifdef LIBMESH_ENABLE_AMR
509 LOG_UNIT_TEST;
510
511 // We should have 13 total and 10 active elements.
512 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(15), _mesh->n_elem());
513 CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(12), _mesh->n_active_elem());
514
515 // We should have 15 nodes
516 CPPUNIT_ASSERT_EQUAL(static_cast<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 }
uint8_t dof_id_type
Definition id_types.h:67

References _mesh.

Member Data Documentation

◆ _mesh

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

Definition at line 371 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: