1 #include <libmesh/equation_systems.h> 2 #include <libmesh/replicated_mesh.h> 3 #include <libmesh/mesh_generation.h> 4 #include <libmesh/dof_map.h> 5 #include <libmesh/system.h> 6 #include <libmesh/mesh_function.h> 7 #include <libmesh/numeric_vector.h> 8 #include <libmesh/elem.h> 32 return 8*p(0) + 80*p(1) + 800*p(2);
45 CPPUNIT_TEST( test_subdomain_id_sets );
48 #ifdef LIBMESH_ENABLE_AMR 49 CPPUNIT_TEST( test_p_level );
53 CPPUNIT_TEST_SUITE_END();
76 for (
auto & elem :
mesh.active_element_ptr_range())
78 Point c = elem->vertex_average();
79 elem->subdomain_id() =
98 const std::set<subdomain_id_type> sbdids1 {0,2,11,13,20,22,31,33};
99 const std::set<subdomain_id_type> sbdids2 {1,3,10,12,21,23,30,32};
100 mesh_function.
init();
102 mesh_function.set_subdomain_ids(&sbdids1);
105 const std::string dummy;
109 for (
auto & elem :
mesh.active_local_element_ptr_range())
111 const Point c = elem->vertex_average();
112 const Real expected_value =
114 const std::vector<Point> offsets
115 {{0,-1/8.}, {1/8.,0}, {0,1/8.}, {-1/8.,0}};
116 for (
Point offset : offsets)
118 const Point p = c + offset;
119 mesh_function(p, 0, vec_values, &sbdids1);
120 const Number retval1 = vec_values.
empty() ? -12345 : vec_values(0);
121 mesh_function(p, 0, vec_values, &sbdids2);
122 const Number retval2 = vec_values.
empty() ? -12345 : vec_values(0);
123 mesh_function(c, 0, vec_values,
nullptr);
124 const Number retval3 = vec_values.
empty() ? -12345 : vec_values(0);
126 LIBMESH_ASSERT_NUMBERS_EQUAL
129 if (sbdids1.count(elem->subdomain_id()))
131 CPPUNIT_ASSERT(!sbdids2.count(elem->subdomain_id()));
132 LIBMESH_ASSERT_NUMBERS_EQUAL
135 mesh_function(c, 0, vec_values, &sbdids2);
136 CPPUNIT_ASSERT(vec_values.
empty());
140 LIBMESH_ASSERT_NUMBERS_EQUAL
143 mesh_function(c, 0, vec_values, &sbdids1);
144 CPPUNIT_ASSERT(vec_values.
empty());
152 #ifdef LIBMESH_ENABLE_AMR 171 for (
auto & elem :
mesh.active_element_ptr_range())
172 elem->set_p_level(1);
182 std::unique_ptr<NumericVector<Number>> mesh_function_vector
188 sys.
solution->localize(*mesh_function_vector,
194 std::vector<unsigned int> variables {u_var};
198 *mesh_function_vector,
202 mesh_function->init();
203 mesh_function->set_point_locator_tolerance(0.0001);
209 for (
const auto & node :
mesh.local_node_ptr_range())
211 (*mesh_function)(*node, 0., vec_values);
212 Number mesh_function_value =
218 LIBMESH_ASSERT_NUMBERS_EQUAL
222 #endif // LIBMESH_ENABLE_AMR
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Number trilinear_function(const Point &p, const Parameters &, const std::string &, const std::string &)
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all...
Number projection_function(const Point &p, const Parameters &, const std::string &, const std::string &)
const EquationSystems & get_equation_systems() const
const Parallel::Communicator & comm() const
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type n_local_dofs() const
dof_id_type n_dofs() const
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Manages consistently variables, degrees of freedom, and coefficient vectors.
virtual bool empty() const override final
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void init() override
Override the FunctionBase::init() member function.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void test_subdomain_id_sets()
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Parameters parameters
Data structure holding arbitrary parameters.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
virtual void init()
Initialize all the systems.
This class provides function-like objects for data distributed over a mesh.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
CPPUNIT_TEST_SUITE_REGISTRATION(MeshFunctionTest)
const DofMap & get_dof_map() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
const std::vector< dof_id_type > & get_send_list() const