libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
FEAMRConstraintTest< elem_type, order, family > Class Template Reference
Inheritance diagram for FEAMRConstraintTest< elem_type, order, family >:
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void testConstrainedSpaceHoldsPolynomials ()
 

Protected Attributes

std::unique_ptr< Mesh > _mesh
 
std::string libmesh_suite_name
 

Detailed Description

template<ElemType elem_type, Order order, FEFamily family>
class FEAMRConstraintTest< elem_type, order, family >

Definition at line 52 of file fe_amr_constraint_test.C.

Member Function Documentation

◆ setUp()

template<ElemType elem_type, Order order, FEFamily family>
void FEAMRConstraintTest< elem_type, order, family >::setUp ( )
inline

Definition at line 59 of file fe_amr_constraint_test.C.

60 {
61 _mesh = std::make_unique<Mesh>(*TestCommWorld);
62
63 const unsigned int dim = Elem::type_to_dim_map[elem_type];
64
65 // For a second-order type, build the first-order mesh and then convert it. Families above
66 // order one need the mid-edge and face nodes of the second-order type.
67 ElemType base = elem_type;
68 if (elem_type == QUAD9) base = QUAD4;
69 if (elem_type == HEX27) base = HEX8;
70 if (elem_type == EDGE3) base = EDGE2;
71
72 if (dim == 1)
74 else if (dim == 2)
75 MeshTools::Generation::build_square(*_mesh, 2, 2, 0., 1., 0., 1., base);
76 else
77 MeshTools::Generation::build_cube(*_mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1., base);
78
79 if (base != elem_type)
80 _mesh->all_second_order();
81
82 // Refine part of the mesh. This puts hanging nodes on the interface between the refined
83 // elements and their unrefined neighbors.
84 MeshRefinement refine(*_mesh);
85
86 for (auto * elem : _mesh->active_element_ptr_range())
87 if (elem->id() % 4 == 0)
88 elem->set_refinement_flag(Elem::REFINE);
89
90 refine.refine_and_coarsen_elements();
91 }
unsigned int dim
std::unique_ptr< Mesh > _mesh
This is the base class from which all geometric element types are derived.
Definition elem.h:96
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
Definition elem.h:649
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
ElemType
Defines an enum for geometric element types.

References FEAMRConstraintTest< elem_type, order, family >::_mesh, libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_line(), libMesh::MeshTools::Generation::build_square(), dim, libMesh::EDGE2, libMesh::EDGE3, libMesh::HEX27, libMesh::HEX8, libMesh::QUAD4, libMesh::QUAD9, libMesh::Elem::REFINE, libMesh::MeshRefinement::refine_and_coarsen_elements(), TestCommWorld, and libMesh::Elem::type_to_dim_map.

◆ tearDown()

template<ElemType elem_type, Order order, FEFamily family>
void FEAMRConstraintTest< elem_type, order, family >::tearDown ( )
inline

Definition at line 93 of file fe_amr_constraint_test.C.

93{ _mesh.reset(); }

References FEAMRConstraintTest< elem_type, order, family >::_mesh.

◆ testConstrainedSpaceHoldsPolynomials()

template<ElemType elem_type, Order order, FEFamily family>
void FEAMRConstraintTest< elem_type, order, family >::testConstrainedSpaceHoldsPolynomials ( )
inline

Definition at line 95 of file fe_amr_constraint_test.C.

96 {
97 LOG_UNIT_TEST;
98
100 System & sys = es.add_system<System>("amr");
101 sys.add_variable("u", FEType(order, family));
102 es.init();
103
104 sys.project_solution(amr_test_poly<static_cast<unsigned int>(order)>,
105 nullptr, es.parameters);
106
107 // The projection enforced the constraints. Check that the solution still equals the
108 // polynomial at points in the refined and the unrefined parts of the mesh.
109 Parameters dummy;
110 unsigned int n_checked = 0;
111
112 for (const auto a : make_range(1, 8))
113 for (const auto b : make_range(1, 8))
114 {
115 const unsigned int dim = Elem::type_to_dim_map[elem_type];
116 const Point q(a/8., (dim > 1) ? b/8. : 0., (dim > 2) ? (a + b)/16. : 0.);
117
118 const Number expected =
119 amr_test_poly<static_cast<unsigned int>(order)>(q, dummy, "", "");
120 const Number actual = sys.point_value(0, q);
121
122 LIBMESH_ASSERT_NUMBERS_EQUAL(expected, actual, TOLERANCE*std::sqrt(TOLERANCE));
123 ++n_checked;
124 }
125
126 CPPUNIT_ASSERT(n_checked > 0);
127 }
This is the EquationSystems class.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2274
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:1400
static const Real b
static constexpr Real TOLERANCE
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

References FEAMRConstraintTest< elem_type, order, family >::_mesh, libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), b, dim, libMesh::EquationSystems::init(), libMesh::make_range(), libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::TOLERANCE, and libMesh::Elem::type_to_dim_map.

Member Data Documentation

◆ _mesh

template<ElemType elem_type, Order order, FEFamily family>
std::unique_ptr<Mesh> FEAMRConstraintTest< elem_type, order, family >::_mesh
protected

◆ libmesh_suite_name

template<ElemType elem_type, Order order, FEFamily family>
std::string FEAMRConstraintTest< elem_type, order, family >::libmesh_suite_name
protected

Definition at line 56 of file fe_amr_constraint_test.C.


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