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/elem.h> 7 #include <libmesh/numeric_vector.h> 15 #include <libmesh/exodusII_io.h> 27 return 0.5 * p(0) + 0.25 * p(1);
46 CPPUNIT_TEST(test_partial_project_solution);
47 CPPUNIT_TEST_SUITE_END();
81 const Real r2 = 0.5 * 0.5;
83 std::vector<const Elem *> selected_elems;
84 for (
const auto &e :
mesh.active_local_element_ptr_range())
86 const Point c = e->vertex_average();
87 if (c(0) * c(0) + c(1) * c(1) <= r2)
88 selected_elems.push_back(e);
96 std::vector<unsigned int> vars_to_project = {u_var};
102 const Real tol = 1e-3;
104 for (
const auto &e :
mesh.active_local_element_ptr_range())
106 const Point c = e->vertex_average();
107 const bool inside = (c(0) * c(0) + c(1) * c(1) <= r2);
109 std::vector<dof_id_type> u_indices, v_indices;
116 const Number val_baseline = baseline_linear_function(c, es.
parameters,
"",
"");
117 const Number val_projected = circle_projection_function(c, es.
parameters,
"",
"");
120 LIBMESH_ASSERT_NUMBERS_EQUAL(u_val, val_projected, tol);
123 LIBMESH_ASSERT_NUMBERS_EQUAL(u_val, val_baseline, tol);
126 LIBMESH_ASSERT_NUMBERS_EQUAL(v_val, val_baseline, tol);
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
void test_partial_project_solution()
This class provides the ability to map between arbitrary, user-defined strings and several data types...
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
libMesh::Parallel::Communicator * TestCommWorld
The StoredRange class defines a contiguous, divisible set of objects.
The libMesh namespace provides an interface to certain functionality in the library.
This class handles the numbering of degrees of freedom on a mesh.
CPPUNIT_TEST_SUITE_REGISTRATION(ProjectSolutionTest)
Manages consistently variables, degrees of freedom, and coefficient vectors.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
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.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Parameters parameters
Data structure holding arbitrary parameters.
virtual void init()
Initialize all the systems.
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.
const DofMap & get_dof_map() const
A Point defines a location in LIBMESH_DIM dimensional Real space.