libMesh
mesh_function.C
Go to the documentation of this file.
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>
9 
10 #include "test_comm.h"
11 #include "libmesh_cppunit.h"
12 #include "libmesh/enum_xdr_mode.h"
13 
14 
15 using namespace libMesh;
16 
18  const Parameters &,
19  const std::string &,
20  const std::string &)
21 {
22  return
23  cos(.5*libMesh::pi*p(0)) *
24  sin(.5*libMesh::pi*p(1)) *
25  cos(.5*libMesh::pi*p(2));
26 }
27 
29  const Parameters &,
30  const std::string &,
31  const std::string &)
32 {
33  return 8*p(0) + 80*p(1) + 800*p(2);
34 }
35 
36 
38  const Parameters &,
39  const std::string &,
40  const std::string &)
41 {
42  return 8*p(0) + 80*p(1);
43 }
44 
45 
47  const Parameters &,
48  const std::string &,
49  const std::string &)
50 {
51  return 7.5*p(0)*p(0) + 75*p(1)*p(1) + 0.75*p(1)*p(0);
52 }
53 
54 
55 
56 class MeshFunctionTest : public CppUnit::TestCase
57 {
61 public:
62  LIBMESH_CPPUNIT_TEST_SUITE( MeshFunctionTest );
63 
64 #if LIBMESH_DIM > 1
65  CPPUNIT_TEST( test_subdomain_id_sets );
66  CPPUNIT_TEST( test_bad_gradient_var_with_out_of_mesh_value );
67 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
68  CPPUNIT_TEST( test_bad_hessian_var_with_out_of_mesh_value );
69 #endif
70 #ifdef LIBMESH_HAVE_PETSC
71  CPPUNIT_TEST( vectorMeshFunctionLagrange );
72  CPPUNIT_TEST( vectorMeshFunctionNedelec );
73  CPPUNIT_TEST( vectorMeshFunctionRaviartThomas );
74  CPPUNIT_TEST( mixedScalarAndVectorVariables );
75 #endif // LIBMESH_HAVE_PETSC
76 #endif
77 #if LIBMESH_DIM > 2
78 #ifdef LIBMESH_ENABLE_AMR
79  CPPUNIT_TEST( test_p_level );
80 #endif
81 #endif
82 
83  CPPUNIT_TEST_SUITE_END();
84 
85 protected:
86 
87 public:
88  void setUp() {}
89 
90  void tearDown() {}
91 
92  // test that mesh function works correctly with subdomain id sets.
94  {
95  LOG_UNIT_TEST;
96 
98 
100  4, 4,
101  0., 1.,
102  0., 1.,
103  QUAD4);
104 
105  // Set a subdomain id for all elements, based on location.
106  for (auto & elem : mesh.active_element_ptr_range())
107  {
108  Point c = elem->vertex_average();
109  elem->subdomain_id() =
110  subdomain_id_type(c(0)*4) + subdomain_id_type(c(1)*4)*10;
111  }
112 
113  // Add a discontinuous variable so we can easily see what side of
114  // an interface we're querying
115  EquationSystems es(mesh);
116  System & sys = es.add_system<System> ("SimpleSystem");
117  unsigned int u_var = sys.add_variable("u", CONSTANT, MONOMIAL);
118 
119  es.init();
121 
122  MeshFunction mesh_function (sys.get_equation_systems(),
124  sys.get_dof_map(),
125  u_var);
126 
127  // Checkerboard pattern
128  const std::set<subdomain_id_type> sbdids1 {0,2,11,13,20,22,31,33};
129  const std::set<subdomain_id_type> sbdids2 {1,3,10,12,21,23,30,32};
130  mesh_function.init();
131  mesh_function.enable_out_of_mesh_mode(DenseVector<Number>());
132  mesh_function.set_subdomain_ids(&sbdids1);
133 
134  DenseVector<Number> vec_values;
135  const std::string dummy;
136 
137  // Make sure the MeshFunction's values interpolate the projected solution
138  // at the nodes
139  for (auto & elem : mesh.active_local_element_ptr_range())
140  {
141  const Point c = elem->vertex_average();
142  const Real expected_value =
143  libmesh_real(trilinear_function(c, es.parameters, dummy, dummy));
144  const std::vector<Point> offsets
145  {{0,-1/8.}, {1/8.,0}, {0,1/8.}, {-1/8.,0}};
146  for (Point offset : offsets)
147  {
148  const Point p = c + offset;
149  mesh_function(p, 0, vec_values, &sbdids1);
150  const Number retval1 = vec_values.empty() ? -12345 : vec_values(0);
151  mesh_function(p, 0, vec_values, &sbdids2);
152  const Number retval2 = vec_values.empty() ? -12345 : vec_values(0);
153  mesh_function(c, 0, vec_values, nullptr);
154  const Number retval3 = vec_values.empty() ? -12345 : vec_values(0);
155 
156  LIBMESH_ASSERT_NUMBERS_EQUAL
157  (retval3, expected_value, TOLERANCE * TOLERANCE);
158 
159  if (sbdids1.count(elem->subdomain_id()))
160  {
161  CPPUNIT_ASSERT(!sbdids2.count(elem->subdomain_id()));
162  LIBMESH_ASSERT_NUMBERS_EQUAL
163  (retval1, expected_value, TOLERANCE * TOLERANCE);
164 
165  mesh_function(c, 0, vec_values, &sbdids2);
166  CPPUNIT_ASSERT(vec_values.empty());
167  }
168  else
169  {
170  LIBMESH_ASSERT_NUMBERS_EQUAL
171  (retval2, expected_value, TOLERANCE * TOLERANCE);
172 
173  mesh_function(c, 0, vec_values, &sbdids1);
174  CPPUNIT_ASSERT(vec_values.empty());
175  }
176  }
177  }
178  }
179 
181  {
182  LOG_UNIT_TEST;
183 
185 
187  4, 4,
188  0., 1.,
189  0., 1.,
190  QUAD4);
191 
192  EquationSystems es(mesh);
193  System & sys = es.add_system<System>("SimpleSystem");
194  const unsigned int u_var = sys.add_variable("u", FIRST, LAGRANGE);
195  const unsigned int v_var = sys.add_variable("v", CONSTANT, MONOMIAL);
196 
197  es.init();
199 
200  std::vector<unsigned int> variables {u_var, v_var, libMesh::invalid_uint};
201  MeshFunction mesh_function(es,
203  sys.get_dof_map(),
204  variables);
205  mesh_function.init();
206 
207  DenseVector<Number> out_of_mesh_value(3);
208  out_of_mesh_value(0) = -99.0;
209  out_of_mesh_value(1) = 5.25;
210  out_of_mesh_value(1) = 42;
211  mesh_function.enable_out_of_mesh_mode(out_of_mesh_value);
212 
213  // Pick an element centroid so u and v agree
214  const Point good_p(0.375, 0.625, 0.0);
215 
216  // On a distributed mesh not every processor may have every
217  // element
218  const Elem * elem = (*mesh.sub_point_locator())(good_p);
219  bool someone_found_elem = elem;
220  mesh.comm().max(someone_found_elem);
221  CPPUNIT_ASSERT(someone_found_elem);
222 
223  std::vector<Gradient> gradients;
224  mesh_function.gradient(good_p, 0.0, gradients);
225 
226  CPPUNIT_ASSERT_EQUAL(std::size_t(3), gradients.size());
227 
228  // Let's only test our evaluation where we know we can evaluate, in parallel
229  if (!elem || elem->processor_id() != mesh.processor_id())
230  return;
231 
232  LIBMESH_ASSERT_NUMBERS_EQUAL(8.0, gradients[0](0), TOLERANCE * TOLERANCE);
233  LIBMESH_ASSERT_NUMBERS_EQUAL(80.0, gradients[0](1), TOLERANCE * TOLERANCE);
234  if (LIBMESH_DIM > 2)
235  LIBMESH_ASSERT_NUMBERS_EQUAL(0.0, gradients[0](2), TOLERANCE * TOLERANCE);
236 
237  // Piecewise-constant functions have zero gradients
238  for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
239  LIBMESH_ASSERT_NUMBERS_EQUAL(0, gradients[1](d), TOLERANCE * TOLERANCE);
240 
241  LIBMESH_ASSERT_NUMBERS_EQUAL(out_of_mesh_value(2),
242  gradients[2](0),
243  TOLERANCE * TOLERANCE);
244  for (unsigned int d = 1; d < LIBMESH_DIM; ++d)
245  LIBMESH_ASSERT_NUMBERS_EQUAL(0, gradients[2](d),
246  TOLERANCE * TOLERANCE);
247 
248  const Point bad_p(1.375, 0.625, 0.0);
249  mesh_function.gradient(bad_p, 0.0, gradients);
250 
251  for (unsigned int vn = 0; vn != 3; ++vn)
252  {
253  LIBMESH_ASSERT_NUMBERS_EQUAL(out_of_mesh_value(vn),
254  gradients[vn](0),
255  TOLERANCE * TOLERANCE);
256  for (unsigned int d = 1; d < LIBMESH_DIM; ++d)
257  LIBMESH_ASSERT_NUMBERS_EQUAL(0, gradients[vn](d),
258  TOLERANCE * TOLERANCE);
259  }
260  }
261 
262 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
264  {
265  LOG_UNIT_TEST;
266 
267  // Hessian calculations are a little weaker in FP on some systems
268  const Real tol = TOLERANCE * std::sqrt(TOLERANCE);
269 
271 
273  4, 4,
274  0., 1.,
275  0., 1.,
276  QUAD9);
277 
278  EquationSystems es(mesh);
279  System & sys = es.add_system<System>("SimpleSystem");
280  unsigned int u_var = sys.add_variable("u", SECOND, LAGRANGE);
281  unsigned int v_var = sys.add_variable("v", CONSTANT, MONOMIAL);
282 
283  es.init();
285 
286  std::vector<unsigned int> variables {u_var, v_var, libMesh::invalid_uint};
287  MeshFunction mesh_function(es,
289  sys.get_dof_map(),
290  variables);
291  mesh_function.init();
292 
293  DenseVector<Number> out_of_mesh_value(3);
294  out_of_mesh_value(0) = -99.0;
295  out_of_mesh_value(1) = 5.25;
296  out_of_mesh_value(2) = 42;
297  mesh_function.enable_out_of_mesh_mode(out_of_mesh_value);
298 
299  std::vector<Tensor> hessians;
300  const Point p(0.4, 0.6, 0.0);
301 
302  // On a distributed mesh not every processor may have every
303  // element
304  const Elem * elem = (*mesh.sub_point_locator())(p);
305  bool someone_found_elem = elem;
306  mesh.comm().max(someone_found_elem);
307  CPPUNIT_ASSERT(someone_found_elem);
308 
309  mesh_function.hessian(p, 0.0, hessians);
310 
311  CPPUNIT_ASSERT_EQUAL(std::size_t(3), hessians.size());
312 
313  // Let's only test our evaluation where we know we can evaluate, in parallel
314  if (!elem || elem->processor_id() != mesh.processor_id())
315  return;
316 
317  LIBMESH_ASSERT_NUMBERS_EQUAL(15.0, hessians[0](0,0), tol);
318  LIBMESH_ASSERT_NUMBERS_EQUAL(0.75, hessians[0](0,1), tol);
319  LIBMESH_ASSERT_NUMBERS_EQUAL(0.75, hessians[0](1,0), tol);
320  LIBMESH_ASSERT_NUMBERS_EQUAL(150.0, hessians[0](1,1), tol);
321 
322  if (LIBMESH_DIM > 2)
323  for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
324  for (unsigned int d2 = 0; d2 < LIBMESH_DIM; ++d2)
325  if (d>1 || d2>1)
326  LIBMESH_ASSERT_NUMBERS_EQUAL(0, hessians[0](d,d2),
327  tol);
328 
329  // Piecewise-constant functions have zero Hessians
330  for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
331  for (unsigned int d2 = 0; d2 < LIBMESH_DIM; ++d2)
332  LIBMESH_ASSERT_NUMBERS_EQUAL(0, hessians[1](d,d2), tol);
333 
334  LIBMESH_ASSERT_NUMBERS_EQUAL(out_of_mesh_value(2),
335  hessians[2](0,0),
336  tol);
337  for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
338  for (unsigned int d2 = 0; d2 < LIBMESH_DIM; ++d2)
339  if (d || d2)
340  LIBMESH_ASSERT_NUMBERS_EQUAL(0, hessians[2](d,d2),
341  tol);
342 
343  const Point bad_p(1.375, 0.625, 0.0);
344  mesh_function.hessian(bad_p, 0.0, hessians);
345 
346  for (unsigned int vn = 0; vn != 2; ++vn)
347  {
348  LIBMESH_ASSERT_NUMBERS_EQUAL(out_of_mesh_value(vn),
349  hessians[vn](0,0), tol);
350  for (unsigned int d = 0; d < LIBMESH_DIM; ++d)
351  for (unsigned int d2 = 0; d2 < LIBMESH_DIM; ++d2)
352  if (d || d2)
353  LIBMESH_ASSERT_NUMBERS_EQUAL(0, hessians[vn](d,d2), tol);
354  }
355  }
356 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
357 
358  // test that mesh function works correctly with non-zero
359  // Elem::p_level() values.
360 #ifdef LIBMESH_ENABLE_AMR
362  {
363  LOG_UNIT_TEST;
364 
366 
368  5, 5, 5,
369  0., 1.,
370  0., 1.,
371  0., 1.,
372  HEX20);
373 
374  // Bump the p-level for all elements. We will create a system with
375  // a FIRST, LAGRANGE variable and then use the additional p-level
376  // to solve with quadratic elements. Note: set_p_level(1) actually
377  // _increases_ the existing variable order by 1, it does not set
378  // it to 1.
379  for (auto & elem : mesh.active_element_ptr_range())
380  elem->set_p_level(1);
381 
382  EquationSystems es(mesh);
383  System & sys = es.add_system<System> ("SimpleSystem");
384  unsigned int u_var = sys.add_variable("u", FIRST, LAGRANGE);
385 
386  es.init();
388 
389 
390  std::unique_ptr<NumericVector<Number>> mesh_function_vector
392  mesh_function_vector->init(sys.n_dofs(), sys.n_local_dofs(),
393  sys.get_dof_map().get_send_list(), false,
394  GHOSTED);
395 
396  sys.solution->localize(*mesh_function_vector,
397  sys.get_dof_map().get_send_list());
398 
399 
400  // So the MeshFunction knows which variables to compute values for.
401  // std::make_unique doesn't like if we try to use {u_var} in-place?
402  std::vector<unsigned int> variables {u_var};
403 
404  auto mesh_function =
405  std::make_unique<MeshFunction>(sys.get_equation_systems(),
406  *mesh_function_vector,
407  sys.get_dof_map(),
408  variables);
409 
410  mesh_function->init();
411  mesh_function->set_point_locator_tolerance(0.0001);
412  DenseVector<Number> vec_values;
413  std::string dummy;
414 
415  // Make sure the MeshFunction's values interpolate the projected solution
416  // at the nodes
417  for (const auto & node : mesh.local_node_ptr_range())
418  {
419  (*mesh_function)(*node, /*time=*/ 0., vec_values);
420  Number mesh_function_value =
421  projection_function(*node,
422  es.parameters,
423  dummy,
424  dummy);
425 
426  LIBMESH_ASSERT_NUMBERS_EQUAL
427  (vec_values(0), mesh_function_value, TOLERANCE*TOLERANCE);
428  }
429  }
430 #endif // LIBMESH_ENABLE_AMR
431 
432 #ifdef LIBMESH_HAVE_PETSC
433 
434  // A helper function that populates the solution data from output files
436  const std::string & solutions_name)
437  {
438  DenseVector<Number> output;
439 
440  // Reading mesh and solution information from XDA files
442  mesh.read(mesh_name);
443  EquationSystems es(mesh);
444  es.read(solutions_name, READ,
448  es.update();
449 
450  // Pulling the correct system and variable information from
451  // the XDA files (the default system name is "nl0")
452  System & sys = es.get_system<System>("nl0");
453  std::unique_ptr<NumericVector<Number>> mesh_function_vector =
455  mesh_function_vector->init(sys.n_dofs(), false, SERIAL);
456  sys.solution->localize(*mesh_function_vector);
457 
458  // Pulling the total number of variables stored in XDA file
459  std::vector<unsigned int> variables;
460  sys.get_all_variable_numbers(variables);
461  std::sort(variables.begin(),variables.end());
462 
463  // Setting up libMesh::MeshFunction
464  MeshFunction mesh_function(es, *mesh_function_vector,
465  sys.get_dof_map(), variables);
466  mesh_function.init();
467 
468  // Defining input parameters for MeshFunction::operator()
469  const std::set<subdomain_id_type> * subdomain_ids = nullptr;
470  const Point & p = Point(0.5, 0.5);
471 
472  // Supplying the variable values at center of mesh to output
473  (mesh_function)(p, 0.0, output, subdomain_ids);
474 
475  return output;
476  }
477 
478  // Tests the projection of Lagrange Vectors using MeshFunction
480  {
481  LOG_UNIT_TEST;
482 
483  // Populating the solution data using a helper function
484  DenseVector<Number> output = read_variable_info_from_output_data("solutions/lagrange_vec_solution_mesh.xda","solutions/lagrange_vec_solution.xda");
485  Gradient output_vec = VectorValue(output(0),output(1));
486 
487  // Expected value at center mesh
488  Gradient output_expected = VectorValue(0.100977281077292,0.201954562154583);
489 
490  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(0)), libMesh::libmesh_real(output_expected(0)),
491  TOLERANCE * TOLERANCE);
492  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(1)), libMesh::libmesh_real(output_expected(1)),
493  TOLERANCE * TOLERANCE);
494  }
495 
496  // Tests the projection of Nedelec Vectors using MeshFunction
498  {
499  LOG_UNIT_TEST;
500 
501  // Populating the solution data using a helper function
502  DenseVector<Number> output = read_variable_info_from_output_data("solutions/nedelec_one_solution_mesh.xda","solutions/nedelec_one_solution.xda");
503  Gradient output_vec = VectorValue(output(0),output(1));
504 
505  // Expected value at center mesh
506  Gradient output_expected = VectorValue(0.0949202883998996,-0.0949202883918033);
507 
508  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(0)), libMesh::libmesh_real(output_expected(0)),
509  TOLERANCE * TOLERANCE);
510  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(1)), libMesh::libmesh_real(output_expected(1)),
511  TOLERANCE * TOLERANCE);
512  }
513 
514  // Tests the projection of Raviart Thomas Vectors using MeshFunction
516  {
517  LOG_UNIT_TEST;
518 
519  // Populating the solution data using a helper function
520  DenseVector<Number> output = read_variable_info_from_output_data("solutions/raviart_thomas_solution_mesh.xda","solutions/raviart_thomas_solution.xda");
521  Gradient output_vec = VectorValue(output(0),output(1));
522 
523  // Expected value at center mesh
524  Gradient output_expected = VectorValue(0.0772539939808116,-0.0772537479511396);
525 
526  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(0)), libMesh::libmesh_real(output_expected(0)),
527  TOLERANCE * TOLERANCE);
528  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_vec(1)), libMesh::libmesh_real(output_expected(1)),
529  TOLERANCE * TOLERANCE);
530  }
531 
532  // Tests MeshFunction for mixed scalar and vector variable outputs
533  // In this case, the variables types are:
534  // - variable index: 0, variable family: Raviart Thomas, Order: First
535  // - variable index: 1, variable family: Monomial, Order: Constant
536  // - variable index: 2, variable family: Scalar, Order: First
538  {
539  LOG_UNIT_TEST;
540 
541  // Populating the solution data using a helper function
542  DenseVector<Number> output = read_variable_info_from_output_data("solutions/raviart_thomas_solution_mesh.xda","solutions/raviart_thomas_solution.xda");
543  Gradient output_raviart_thomas = VectorValue(output(0),output(1));
544 
545  // Expected value at center mesh
546  Gradient raviart_thomas_expected = VectorValue(0.0772539939808116,-0.0772537479511396);
547  Number monomial_expected = -0.44265566716952;
548  Number scalar_expected = -2.86546e-18;
549 
550  // Checking Raviart Thomas variable family values
551  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_raviart_thomas(0)), libMesh::libmesh_real(raviart_thomas_expected(0)),
552  TOLERANCE * TOLERANCE);
553  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output_raviart_thomas(1)), libMesh::libmesh_real(raviart_thomas_expected(1)),
554  TOLERANCE * TOLERANCE);
555  // Checking Monomial variable family value
556  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output(2)), libMesh::libmesh_real(monomial_expected),
557  TOLERANCE * TOLERANCE);
558  // Checking scalar variable family value
559  LIBMESH_ASSERT_FP_EQUAL(libMesh::libmesh_real(output(3)), libMesh::libmesh_real(scalar_expected),
560  TOLERANCE * TOLERANCE);
561  }
562 #endif // LIBMESH_HAVE_PETSC
563 };
564 
T libmesh_real(T a)
void vectorMeshFunctionNedelec()
Number biquadratic_function(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: mesh_function.C:46
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
DenseVector< Number > read_variable_info_from_output_data(const std::string &mesh_name, const std::string &solutions_name)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:303
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:1826
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition: parameters.h:74
Number trilinear_function(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: mesh_function.C:28
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:218
static constexpr Real TOLERANCE
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn&#39;t work with exodusII at all...
Definition: id_types.h:43
Number projection_function(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: mesh_function.C:17
const EquationSystems & get_equation_systems() const
Definition: system.h:767
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
const Parallel::Communicator & comm() const
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:1403
Number bilinear_function(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: mesh_function.C:37
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.
void test_bad_hessian_var_with_out_of_mesh_value()
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type n_local_dofs() const
Definition: system.C:155
const T_sys & get_system(std::string_view name) const
void test_bad_gradient_var_with_out_of_mesh_value()
dof_id_type n_dofs() const
Definition: system.C:118
void vectorMeshFunctionRaviartThomas()
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:98
virtual bool empty() const override final
Definition: dense_vector.h:109
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1655
virtual void init() override
Override the FunctionBase::init() member function.
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
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.
Definition: system.C:1344
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 vectorMeshFunctionLagrange()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void test_subdomain_id_sets()
Definition: mesh_function.C:93
void max(const T &r, T &o, Request &req) const
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.
Definition: system.h:1667
virtual void init()
Initialize all the systems.
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:54
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.
processor_id_type processor_id() const
CPPUNIT_TEST_SUITE_REGISTRATION(MeshFunctionTest)
const DofMap & get_dof_map() const
Definition: system.h:2417
processor_id_type processor_id() const
Definition: dof_object.h:881
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:533
void update()
Updates local values for all the systems.
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.
const Real pi
.
Definition: libmesh.h:292
void mixedScalarAndVectorVariables()