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

Public Member Functions

void setUp ()
 
void tearDown ()
 
void testContainsPoint ()
 

Protected Attributes

std::string libmesh_suite_name
 

Private Attributes

unsigned int _dim
 
unsigned int _nx
 
unsigned int _ny
 
unsigned int _nz
 
Elem_elem
 
std::vector< dof_id_type_dof_indices
 
std::unique_ptr< Mesh_mesh
 
std::unique_ptr< EquationSystems_es
 
std::unique_ptr< FEBase_fe
 

Detailed Description

template<ElemType elem_type>
class RationalMapTest< elem_type >

Definition at line 22 of file fe_rational_map.C.

Member Function Documentation

◆ setUp()

template<ElemType elem_type>
void RationalMapTest< elem_type >::setUp ( )
inline

Definition at line 36 of file fe_rational_map.C.

37 {
38 _mesh = std::make_unique<Mesh>(*TestCommWorld);
39 const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
40 _dim = test_elem->dim();
41 const unsigned int ny = _dim > 1;
42 const unsigned int nz = _dim > 2;
43
44 // Make sure we can handle non-zero weight indices
45 _mesh->add_node_integer("buffer integer1");
46 _mesh->add_node_integer("buffer integer2");
47
48 // Default weight to 1.0 so we don't get NaN from contains_point
49 // checks with a default GhostPointNeighbors ghosting
50 const Real default_weight = 1.0;
51 unsigned char weight_index = cast_int<unsigned char>
52 (_mesh->add_node_datum<Real>("rational_weight", true,
53 &default_weight));
54
55 libmesh_assert_not_equal_to(weight_index, 0);
56
57 _mesh->set_default_mapping_type(RATIONAL_BERNSTEIN_MAP);
58 _mesh->set_default_mapping_data(weight_index);
59
61 1, ny, nz,
62 0., 1., 0., ny, 0., nz,
63 elem_type);
64
65 for (auto elem : _mesh->element_ptr_range())
66 {
67 CPPUNIT_ASSERT_EQUAL(elem->mapping_type(), RATIONAL_BERNSTEIN_MAP);
68 CPPUNIT_ASSERT_EQUAL(elem->mapping_data(), weight_index);
69 }
70
71 // Transform the cube / square into a rotated quarter-annulus,
72 // with central axis at (-.5, 0) and radii ranging from .5 to 1.5
73
74 for (auto node : _mesh->node_ptr_range())
75 {
76 // Workaround for nvc++ bug
77 Node & n = *node;
78
79 Real & x = (*node)(0);
80 Real & y = (*node)(1);
81 n.set_extra_datum<Real>(weight_index, 1);
82 if (y > .6)
83 {
84 y = .5 + x;
85 x = -.5;
86 }
87 else if (y > .4)
88 {
89 y = .5 + x;
90 x = y - .5;
91 n.set_extra_datum<Real>(weight_index, sqrt(Real(2))/2);
92 }
93 }
94
95 _es = std::make_unique<EquationSystems>(*_mesh);
96 System * sys = &(_es->add_system<System> ("SimpleSystem"));
97 sys->add_variable("u", FIRST);
98 _es->init();
99
100 _fe = FEBase::build(_dim, sys->variable_type("u"));
101 _fe->get_xyz();
102 _fe->get_phi();
103 _fe->get_dphi();
104 _fe->get_dphidx();
105#if LIBMESH_DIM > 1
106 _fe->get_dphidy();
107#endif
108#if LIBMESH_DIM > 2
109 _fe->get_dphidz();
110#endif
111
112 auto rng = _mesh->active_local_element_ptr_range();
113 _elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
114
115 _nx = 10;
116 _ny = (_dim > 1) ? _nx : 0;
117 _nz = (_dim > 2) ? _nx : 0;
118 }
std::unique_ptr< Mesh > _mesh
unsigned int _dim
unsigned int _nz
unsigned int _nx
std::unique_ptr< EquationSystems > _es
unsigned int _ny
std::unique_ptr< FEBase > _fe
void set_extra_datum(const unsigned int index, const T value)
Sets the value on this object of the extra datum associated with index, which should have been obtain...
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:442
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
A Node is like a Point, but with more information.
Definition node.h:55
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
const FEType & variable_type(const unsigned int i) const
Definition system.C:2721
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
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.
@ RATIONAL_BERNSTEIN_MAP
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References RationalMapTest< elem_type >::_dim, RationalMapTest< elem_type >::_elem, RationalMapTest< elem_type >::_es, RationalMapTest< elem_type >::_fe, RationalMapTest< elem_type >::_mesh, RationalMapTest< elem_type >::_nx, RationalMapTest< elem_type >::_ny, RationalMapTest< elem_type >::_nz, libMesh::System::add_variable(), libMesh::Elem::build(), libMesh::FEGenericBase< OutputType >::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::FIRST, libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::Real, libMesh::DofObject::set_extra_datum(), TestCommWorld, and libMesh::System::variable_type().

◆ tearDown()

template<ElemType elem_type>
void RationalMapTest< elem_type >::tearDown ( )
inline

Definition at line 120 of file fe_rational_map.C.

120{}

◆ testContainsPoint()

template<ElemType elem_type>
void RationalMapTest< elem_type >::testContainsPoint ( )
inline

Definition at line 122 of file fe_rational_map.C.

123 {
124 LOG_UNIT_TEST;
125
126 // Handle the "more processors than elements" case
127 if (!_elem)
128 return;
129
130 // These tests require exceptions to be enabled because a
131 // TypeTensor::solve() call down in Elem::contains_point()
132 // actually throws a non-fatal exception for a certain Point which
133 // is not in the Elem. When exceptions are not enabled, this test
134 // simply aborts.
135#ifdef LIBMESH_ENABLE_EXCEPTIONS
136 for (unsigned int j=0; j != _ny+1; ++j)
137 for (unsigned int k=0; k != _nz+1; ++k)
138 {
139 for (int i=-1; i != int(_nx+2); ++i)
140 {
141 Real r = (Real(i)/_nx) + 0.5,
142 theta = (Real(j)/_nx)*pi/2,
143 z = (Real(k)/_nx);
144 Real x = -.5 + r * std::cos(theta),
145 y = r * std::sin(theta);
146 Point p(x,y,z);
147 // Test for false negatives
148 if (i >= 0 && i <= int(_nx))
149 CPPUNIT_ASSERT(_elem->contains_point(p));
150 // Also test for false positives
151 else
152 CPPUNIT_ASSERT(!_elem->contains_point(p));
153 }
154 }
155#endif
156 }
void ErrorVector unsigned int
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition elem.C:2784
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
const Real pi
.
Definition libmesh.h:292

References RationalMapTest< elem_type >::_elem, RationalMapTest< elem_type >::_nx, RationalMapTest< elem_type >::_ny, RationalMapTest< elem_type >::_nz, libMesh::Elem::contains_point(), int, libMesh::pi, and libMesh::Real.

Member Data Documentation

◆ _dim

template<ElemType elem_type>
unsigned int RationalMapTest< elem_type >::_dim
private

Definition at line 25 of file fe_rational_map.C.

Referenced by RationalMapTest< elem_type >::setUp().

◆ _dof_indices

template<ElemType elem_type>
std::vector<dof_id_type> RationalMapTest< elem_type >::_dof_indices
private

Definition at line 27 of file fe_rational_map.C.

◆ _elem

template<ElemType elem_type>
Elem* RationalMapTest< elem_type >::_elem
private

◆ _es

template<ElemType elem_type>
std::unique_ptr<EquationSystems> RationalMapTest< elem_type >::_es
private

Definition at line 29 of file fe_rational_map.C.

Referenced by RationalMapTest< elem_type >::setUp().

◆ _fe

template<ElemType elem_type>
std::unique_ptr<FEBase> RationalMapTest< elem_type >::_fe
private

Definition at line 30 of file fe_rational_map.C.

Referenced by RationalMapTest< elem_type >::setUp().

◆ _mesh

template<ElemType elem_type>
std::unique_ptr<Mesh> RationalMapTest< elem_type >::_mesh
private

Definition at line 28 of file fe_rational_map.C.

Referenced by RationalMapTest< elem_type >::setUp().

◆ _nx

template<ElemType elem_type>
unsigned int RationalMapTest< elem_type >::_nx
private

◆ _ny

template<ElemType elem_type>
unsigned int RationalMapTest< elem_type >::_ny
private

◆ _nz

template<ElemType elem_type>
unsigned int RationalMapTest< elem_type >::_nz
private

◆ libmesh_suite_name

template<ElemType elem_type>
std::string RationalMapTest< elem_type >::libmesh_suite_name
protected

Definition at line 33 of file fe_rational_map.C.


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