libMesh
Public Member Functions | List of all members
SystemsTest Class Reference
Inheritance diagram for SystemsTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (SystemsTest)
 
 CPPUNIT_TEST (testProjectHierarchicEdge3)
 
 CPPUNIT_TEST (testProjectHierarchicQuad9)
 
 CPPUNIT_TEST (testProjectHierarchicTri6)
 
 CPPUNIT_TEST (testProjectHierarchicHex27)
 
 CPPUNIT_TEST (testProjectMeshFunctionHex27)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testProjectLine (const ElemType elem_type)
 
void testProjectSquare (const ElemType elem_type)
 
void testProjectCube (const ElemType elem_type)
 
void testProjectCubeWithMeshFunction (const ElemType elem_type)
 
void testProjectHierarchicEdge3 ()
 
void testProjectHierarchicQuad9 ()
 
void testProjectHierarchicTri6 ()
 
void testProjectHierarchicHex27 ()
 
void testProjectMeshFunctionHex27 ()
 

Detailed Description

Definition at line 41 of file systems_test.C.

Member Function Documentation

SystemsTest::CPPUNIT_TEST ( testProjectHierarchicEdge3  )
SystemsTest::CPPUNIT_TEST ( testProjectHierarchicQuad9  )
SystemsTest::CPPUNIT_TEST ( testProjectHierarchicTri6  )
SystemsTest::CPPUNIT_TEST ( testProjectHierarchicHex27  )
SystemsTest::CPPUNIT_TEST ( testProjectMeshFunctionHex27  )
SystemsTest::CPPUNIT_TEST_SUITE ( SystemsTest  )
SystemsTest::CPPUNIT_TEST_SUITE_END ( )
void SystemsTest::setUp ( )

Definition at line 56 of file systems_test.C.

57  {}
void SystemsTest::tearDown ( )

Definition at line 59 of file systems_test.C.

60  {}
void SystemsTest::testProjectCube ( const ElemType  elem_type)

Definition at line 118 of file systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_cube(), cubic_test(), libMesh::HIERARCHIC, libMesh::EquationSystems::init(), libMesh::libmesh_real(), mesh, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::Real, libMesh::sys, TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::x.

119  {
121 
122  EquationSystems es(mesh);
123  System &sys = es.add_system<System> ("SimpleSystem");
124  sys.add_variable("u", THIRD, HIERARCHIC);
125 
127  3, 3, 3,
128  0., 1., 0., 1., 0., 1.,
129  elem_type);
130 
131  es.init();
132  sys.project_solution(cubic_test, NULL, es.parameters);
133 
134  for (Real x = 0.1; x < 1; x += 0.2)
135  for (Real y = 0.1; y < 1; y += 0.2)
136  for (Real z = 0.1; z < 1; z += 0.2)
137  {
138  Point p(x,y,z);
139  CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(sys.point_value(0,p)),
140  libmesh_real(cubic_test(p,es.parameters,"","")),
142  }
143  }
T libmesh_real(T a)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2011
Number cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: systems_test.C:28
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
ImplicitSystem & sys
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
MeshBase & mesh
static const Real TOLERANCE
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
Projects arbitrary functions onto the current solution.
PetscErrorCode Vec x
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
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.
void SystemsTest::testProjectCubeWithMeshFunction ( const ElemType  elem_type)

Definition at line 145 of file systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::NumericVector< T >::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::ParallelObject::comm(), cubic_test(), libMesh::System::get_all_variable_numbers(), libMesh::System::get_dof_map(), libMesh::HIERARCHIC, libMesh::MeshFunction::init(), libMesh::EquationSystems::init(), libMesh::LAGRANGE, libMesh::libmesh_real(), mesh, libMesh::System::n_dofs(), libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::Real, libMesh::SECOND, libMesh::SERIAL, libMesh::System::solution, libMesh::sys, TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::x.

146  {
147  // The source mesh needs to exist everywhere it's queried, so we
148  // use a ReplicatedMesh
150 
151  EquationSystems es(mesh);
152  System &sys = es.add_system<System> ("SimpleSystem");
153  sys.add_variable("u", THIRD, HIERARCHIC);
154 
156  3, 3, 3,
157  0., 1., 0., 1., 0., 1.,
158  elem_type);
159 
160  es.init();
161  sys.project_solution(cubic_test, NULL, es.parameters);
162 
163  std::vector<unsigned int> variables;
164  sys.get_all_variable_numbers(variables);
165  std::sort(variables.begin(),variables.end());
166 
167  UniquePtr<NumericVector<Number>> mesh_function_vector =
168  NumericVector<Number>::build(es.comm());
169  mesh_function_vector->init(sys.n_dofs(), false, SERIAL);
170  sys.solution->localize( *mesh_function_vector );
171 
172  MeshFunction mesh_function(es,
173  *mesh_function_vector,
174  sys.get_dof_map(),
175  variables);
176  mesh_function.init();
177 
178  // Make a second system and project onto it using a MeshFunction
179  Mesh proj_mesh(*TestCommWorld);
180  EquationSystems proj_es(proj_mesh);
181 
182  System &proj_sys = proj_es.add_system<System> ("ProjectionSystem");
183  proj_sys.add_variable("u", SECOND, LAGRANGE);
184 
186  5, 5, 5,
187  0., 1., 0., 1., 0., 1.,
188  elem_type);
189 
190  proj_es.init();
191  proj_sys.project_solution(&mesh_function);
192 
193  for (Real x = 0.1; x < 1; x += 0.2)
194  for (Real y = 0.1; y < 1; y += 0.2)
195  for (Real z = 0.1; z < 1; z += 0.2)
196  {
197  Point p(x,y,z);
198  CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(proj_sys.point_value(0,p)),
199  libmesh_real(cubic_test(p,es.parameters,"","")),
201  }
202  }
T libmesh_real(T a)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2011
Number cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: systems_test.C:28
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual void init(const numeric_index_type, const numeric_index_type, const bool=false, const ParallelType=AUTOMATIC)=0
Change the dimension of the vector to N.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
ImplicitSystem & sys
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
MeshBase & mesh
Numeric vector.
Definition: dof_map.h:66
static const Real TOLERANCE
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
Projects arbitrary functions onto the current solution.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
PetscErrorCode Vec x
const DofMap & get_dof_map() const
Definition: system.h:2030
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
UniquePtr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1523
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
dof_id_type n_dofs() const
Definition: system.C:148
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:53
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
Fills all_variable_numbers with all the variable numbers for the variables that have been added to th...
Definition: system.C:1278
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
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.
virtual void init() libmesh_override
Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES ...
Definition: mesh_function.h:96
void SystemsTest::testProjectHierarchicEdge3 ( )

Definition at line 204 of file systems_test.C.

References libMesh::EDGE3.

void testProjectLine(const ElemType elem_type)
Definition: systems_test.C:64
void SystemsTest::testProjectHierarchicHex27 ( )

Definition at line 207 of file systems_test.C.

References libMesh::HEX27.

void testProjectCube(const ElemType elem_type)
Definition: systems_test.C:118
void SystemsTest::testProjectHierarchicQuad9 ( )

Definition at line 205 of file systems_test.C.

References libMesh::QUAD9.

void testProjectSquare(const ElemType elem_type)
Definition: systems_test.C:91
void SystemsTest::testProjectHierarchicTri6 ( )

Definition at line 206 of file systems_test.C.

References libMesh::TRI6.

void testProjectSquare(const ElemType elem_type)
Definition: systems_test.C:91
void SystemsTest::testProjectLine ( const ElemType  elem_type)

Definition at line 64 of file systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_line(), cubic_test(), libMesh::HIERARCHIC, libMesh::EquationSystems::init(), libMesh::libmesh_real(), mesh, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::Real, libMesh::sys, TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::x.

65  {
67 
69  System &sys = es.add_system<System> ("SimpleSystem");
70  sys.add_variable("u", THIRD, HIERARCHIC);
71 
73  3,
74  0., 1.,
75  elem_type);
76 
77  es.init();
78  sys.project_solution(cubic_test, NULL, es.parameters);
79 
80  for (Real x = 0.1; x < 1; x += 0.2)
81  {
82  Point p(x);
83  CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(sys.point_value(0,p)),
84  libmesh_real(cubic_test(p,es.parameters,"","")),
86  }
87  }
T libmesh_real(T a)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2011
Number cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: systems_test.C:28
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
ImplicitSystem & sys
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
MeshBase & mesh
static const Real TOLERANCE
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
Projects arbitrary functions onto the current solution.
PetscErrorCode Vec x
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
void SystemsTest::testProjectMeshFunctionHex27 ( )

Definition at line 208 of file systems_test.C.

References CPPUNIT_TEST_SUITE_REGISTRATION(), and libMesh::HEX27.

void testProjectCubeWithMeshFunction(const ElemType elem_type)
Definition: systems_test.C:145
void SystemsTest::testProjectSquare ( const ElemType  elem_type)

Definition at line 91 of file systems_test.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshTools::Generation::build_square(), cubic_test(), libMesh::HIERARCHIC, libMesh::EquationSystems::init(), libMesh::libmesh_real(), mesh, libMesh::EquationSystems::parameters, libMesh::System::point_value(), libMesh::System::project_solution(), libMesh::Real, libMesh::sys, TestCommWorld, libMesh::THIRD, libMesh::TOLERANCE, and libMesh::x.

92  {
94 
96  System &sys = es.add_system<System> ("SimpleSystem");
97  sys.add_variable("u", THIRD, HIERARCHIC);
98 
100  3, 3,
101  0., 1., 0., 1.,
102  elem_type);
103 
104  es.init();
105  sys.project_solution(cubic_test, NULL, es.parameters);
106 
107  for (Real x = 0.1; x < 1; x += 0.2)
108  for (Real y = 0.1; y < 1; y += 0.2)
109  {
110  Point p(x,y);
111  CPPUNIT_ASSERT_DOUBLES_EQUAL(libmesh_real(sys.point_value(0,p)),
112  libmesh_real(cubic_test(p,es.parameters,"","")),
114  }
115  }
T libmesh_real(T a)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2011
Number cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: systems_test.C:28
This is the EquationSystems class.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
ImplicitSystem & sys
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
MeshBase & mesh
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.
static const Real TOLERANCE
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
Projects arbitrary functions onto the current solution.
PetscErrorCode Vec x
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38

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