160 {
161 LOG_UNIT_TEST;
162
163
164 Point top(0.5, 0.5, 0.0);
165
166
167 Point bottom(0.5, -0.5, 0.0);
168
169
170 Point face(0.5, 0.0, 0.0);
171
172
176
177 es.init();
179
180 std::vector<unsigned int> variables;
182 std::unique_ptr<NumericVector<Number>> mesh_function_vector =
184 mesh_function_vector->init(sys.
n_dofs(),
false,
SERIAL);
185 sys.
solution->localize(*mesh_function_vector);
186
189 mesh_function.init();
190
191
192 std::map<const Elem *, Number> top_val = mesh_function.discontinuous_value(top);
193
194
195 CPPUNIT_ASSERT (top_val.size() == 1);
196
197
198 for (std::map<const Elem *, Number>::const_iterator it = top_val.begin(); it != top_val.end(); ++it)
199 CPPUNIT_ASSERT (it->first->id() == 0 && std::abs(it->second) < 1.0e-10);
200
201
202 std::map<const Elem *, Number> bottom_val = mesh_function.discontinuous_value(bottom);
203
204
205 CPPUNIT_ASSERT (bottom_val.size() == 1);
206
207
208 for (std::map<const Elem *, Number>::const_iterator it = bottom_val.begin(); it != bottom_val.end(); ++it)
209 CPPUNIT_ASSERT (it->first->id() == 1 && std::abs(it->second - 1.0) < 1.0e-10);
210
211
212 std::map<const Elem *, Number> face_val = mesh_function.discontinuous_value(face);
213
214
215 CPPUNIT_ASSERT (face_val.size() == 2);
216
217
218 for (std::map<const Elem *, Number>::const_iterator it = face_val.begin(); it != face_val.end(); ++it)
219 if (it->first->id() == 0)
220 CPPUNIT_ASSERT (std::abs(it->second) < 1.0e-10);
221 else if (it->first->id() == 1)
222 CPPUNIT_ASSERT (std::abs(it->second - 1.0) < 1.0e-10);
223 else
224 CPPUNIT_ASSERT (false);
225
226 }
This is the EquationSystems class.
This class provides function-like objects for data distributed over a mesh.
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...
Manages consistently variables, degrees of freedom, and coefficient vectors.
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.
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...
dof_id_type n_dofs() const
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.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const DofMap & get_dof_map() const
Number position_function(const Point &p, const Parameters &, const std::string &, const std::string &)