libMesh
Public Member Functions | 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 ()
 

Private Attributes

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

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 34 of file fe_rational_map.C.

35  {
36  _mesh = new Mesh(*TestCommWorld);
37  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
38  _dim = test_elem->dim();
39  const unsigned int ny = _dim > 1;
40  const unsigned int nz = _dim > 2;
41 
42  // Make sure we can handle non-zero weight indices
43  _mesh->add_node_integer("buffer integer1");
44  _mesh->add_node_integer("buffer integer2");
45  unsigned char weight_index = cast_int<unsigned char>
46  (_mesh->add_node_datum<Real>("rational_weight"));
47  libmesh_assert_not_equal_to(weight_index, 0);
48 
50  _mesh->set_default_mapping_data(weight_index);
51 
53  1, ny, nz,
54  0., 1., 0., ny, 0., nz,
55  elem_type);
56 
57  for (auto elem : _mesh->element_ptr_range())
58  {
59  CPPUNIT_ASSERT_EQUAL(elem->mapping_type(), RATIONAL_BERNSTEIN_MAP);
60  CPPUNIT_ASSERT_EQUAL(elem->mapping_data(), weight_index);
61  }
62 
63  // Transform the cube / square into a rotated quarter-annulus,
64  // with central axis at (-.5, 0) and radii ranging from .5 to 1.5
65 
66  for (auto node : _mesh->node_ptr_range())
67  {
68  Real & x = (*node)(0);
69  Real & y = (*node)(1);
70  node->set_extra_datum<Real>(weight_index, 1);
71  if (y > .6)
72  {
73  y = .5 + x;
74  x = -.5;
75  }
76  else if (y > .4)
77  {
78  y = .5 + x;
79  x = y - .5;
80  node->set_extra_datum<Real>(weight_index, sqrt(Real(2))/2);
81  }
82  }
83 
84  _es = new EquationSystems(*_mesh);
85  _sys = &(_es->add_system<System> ("SimpleSystem"));
86  _sys->add_variable("u", FIRST);
87  _es->init();
88 
89  _fe = FEBase::build(_dim, _sys->variable_type("u")).release();
90  _fe->get_xyz();
91  _fe->get_phi();
92  _fe->get_dphi();
93  _fe->get_dphidx();
94 #if LIBMESH_DIM > 1
95  _fe->get_dphidy();
96 #endif
97 #if LIBMESH_DIM > 2
98  _fe->get_dphidz();
99 #endif
100 
102  _elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
103 
104  _nx = 10;
105  _ny = (_dim > 1) ? _nx : 0;
106  _nz = (_dim > 2) ? _nx : 0;
107  }

References libMesh::DistributedMesh::active_local_element_ptr_range(), libMesh::MeshBase::add_node_datum(), libMesh::MeshBase::add_node_integer(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::DistributedMesh::element_ptr_range(), libMesh::FIRST, libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEGenericBase< OutputType >::get_dphidx(), libMesh::FEGenericBase< OutputType >::get_dphidy(), libMesh::FEGenericBase< OutputType >::get_dphidz(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEAbstract::get_xyz(), libMesh::EquationSystems::init(), libMesh::DistributedMesh::node_ptr_range(), libMesh::RATIONAL_BERNSTEIN_MAP, libMesh::Real, libMesh::MeshBase::set_default_mapping_data(), libMesh::MeshBase::set_default_mapping_type(), std::sqrt(), TestCommWorld, and libMesh::System::variable_type().

◆ tearDown()

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

Definition at line 109 of file fe_rational_map.C.

110  {
111  delete _fe;
112  delete _es;
113  delete _mesh;
114  }

◆ testContainsPoint()

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

Definition at line 116 of file fe_rational_map.C.

117  {
118  // Handle the "more processors than elements" case
119  if (!_elem)
120  return;
121 
122  // These tests require exceptions to be enabled because a
123  // TypeTensor::solve() call down in Elem::contains_point()
124  // actually throws a non-fatal exception for a certain Point which
125  // is not in the Elem. When exceptions are not enabled, this test
126  // simply aborts.
127 #ifdef LIBMESH_ENABLE_EXCEPTIONS
128  for (unsigned int j=0; j != _ny+1; ++j)
129  for (unsigned int k=0; k != _nz+1; ++k)
130  {
131  for (int i=-1; i != int(_nx+2); ++i)
132  {
133  Real r = (Real(i)/_nx) + 0.5,
134  theta = (Real(j)/_nx)*pi/2,
135  z = (Real(k)/_nx);
136  Real x = -.5 + r * std::cos(theta),
137  y = r * std::sin(theta);
138  Point p(x,y,z);
139  // Test for false negatives
140  if (i >= 0 && i <= int(_nx))
141  CPPUNIT_ASSERT(_elem->contains_point(p));
142  // Also test for false positives
143  else
144  CPPUNIT_ASSERT(!_elem->contains_point(p));
145  }
146  }
147 #endif
148  }

References 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.

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

Definition at line 26 of file fe_rational_map.C.

◆ _es

template<ElemType elem_type>
EquationSystems* RationalMapTest< elem_type >::_es
private

Definition at line 31 of file fe_rational_map.C.

◆ _fe

template<ElemType elem_type>
FEBase* RationalMapTest< elem_type >::_fe
private

Definition at line 28 of file fe_rational_map.C.

◆ _mesh

template<ElemType elem_type>
Mesh* RationalMapTest< elem_type >::_mesh
private

Definition at line 29 of file fe_rational_map.C.

◆ _nx

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

Definition at line 25 of file fe_rational_map.C.

◆ _ny

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

Definition at line 25 of file fe_rational_map.C.

◆ _nz

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

Definition at line 25 of file fe_rational_map.C.

◆ _sys

template<ElemType elem_type>
System* RationalMapTest< elem_type >::_sys
private

Definition at line 30 of file fe_rational_map.C.


The documentation for this class was generated from the following file:
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
RationalMapTest::_mesh
Mesh * _mesh
Definition: fe_rational_map.C:29
libMesh::pi
const Real pi
.
Definition: libmesh.h:237
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
libMesh::FEAbstract::get_xyz
const std::vector< Point > & get_xyz() const
Definition: fe_abstract.h:237
libMesh::EquationSystems::add_system
virtual System & add_system(const std::string &system_type, const std::string &name)
Add the system of type system_type named name to the systems array.
Definition: equation_systems.C:345
libMesh::DistributedMesh::active_local_element_ptr_range
virtual SimpleRange< element_iterator > active_local_element_ptr_range() override
Definition: distributed_mesh.h:372
libMesh::Elem::contains_point
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition: elem.C:2094
RationalMapTest::_dim
unsigned int _dim
Definition: fe_rational_map.C:25
RationalMapTest::_es
EquationSystems * _es
Definition: fe_rational_map.C:31
libMesh::FEGenericBase::get_dphidx
const std::vector< std::vector< OutputShape > > & get_dphidx() const
Definition: fe_base.h:238
RationalMapTest::_ny
unsigned int _ny
Definition: fe_rational_map.C:25
libMesh::MeshBase::set_default_mapping_data
void set_default_mapping_data(const unsigned char data)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:732
libMesh::MeshTools::Generation::build_cube
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.
Definition: mesh_generation.C:298
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::FEGenericBase::get_dphi
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition: fe_base.h:214
libMesh::DistributedMesh::node_ptr_range
virtual SimpleRange< node_iterator > node_ptr_range() override
Definition: distributed_mesh.h:501
libMesh::RATIONAL_BERNSTEIN_MAP
Definition: enum_elem_type.h:84
RationalMapTest::_sys
System * _sys
Definition: fe_rational_map.C:30
RationalMapTest::_fe
FEBase * _fe
Definition: fe_rational_map.C:28
libMesh::System::add_variable
unsigned int add_variable(const std::string &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:1069
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::EquationSystems::init
virtual void init()
Initialize all the systems.
Definition: equation_systems.C:96
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::MeshBase::add_node_integer
unsigned int add_node_integer(const std::string &name, bool allocate_data=true)
Register an integer datum (of type dof_id_type) to be added to each node in the mesh.
Definition: mesh_base.C:247
RationalMapTest::_nz
unsigned int _nz
Definition: fe_rational_map.C:25
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::System::variable_type
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2233
libMesh::FEGenericBase::get_dphidy
const std::vector< std::vector< OutputShape > > & get_dphidy() const
Definition: fe_base.h:246
RationalMapTest::_nx
unsigned int _nx
Definition: fe_rational_map.C:25
libMesh::DistributedMesh::element_ptr_range
virtual SimpleRange< element_iterator > element_ptr_range() override
Definition: distributed_mesh.h:308
RationalMapTest::_elem
Elem * _elem
Definition: fe_rational_map.C:26
libMesh::MeshBase::set_default_mapping_type
void set_default_mapping_type(const ElemMappingType type)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
Definition: mesh_base.h:716
libMesh::MeshBase::add_node_datum
unsigned int add_node_datum(const std::string &name, bool allocate_data=true)
Register a datum (of type T) to be added to each node in the mesh.
Definition: mesh_base.h:2011
libMesh::FEGenericBase::get_dphidz
const std::vector< std::vector< OutputShape > > & get_dphidz() const
Definition: fe_base.h:254
libMesh::FEGenericBase::get_phi
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition: fe_base.h:206
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::FIRST
Definition: enum_order.h:42
int
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360