libMesh
Loading...
Searching...
No Matches
systems_test.C
Go to the documentation of this file.
1#include <libmesh/equation_systems.h>
2#include <libmesh/int_range.h>
3#include <libmesh/mesh.h>
4#include <libmesh/node.h>
5#include <libmesh/dof_map.h>
6#include <libmesh/mesh_generation.h>
7#include <libmesh/replicated_mesh.h>
8#include <libmesh/mesh_function.h>
9#include <libmesh/numeric_vector.h>
10#include <libmesh/mesh_refinement.h>
11#include <libmesh/sparse_matrix.h>
12#include "libmesh/string_to_enum.h"
13#include <libmesh/cell_tet4.h>
14#include <libmesh/zero_function.h>
15#include <libmesh/linear_implicit_system.h>
16#include <libmesh/transient_system.h>
17#include <libmesh/quadrature_gauss.h>
18#include <libmesh/node_elem.h>
19#include <libmesh/edge_edge2.h>
20#include <libmesh/dg_fem_context.h>
21#include <libmesh/enum_solver_type.h>
22#include <libmesh/enum_preconditioner_type.h>
23#include <libmesh/linear_solver.h>
24#include <libmesh/parallel.h>
25#include <libmesh/face_quad4.h>
26#include <libmesh/face_quad9.h>
27#include <libmesh/face_quad8.h>
28#include <libmesh/face_tri3.h>
29#include <libmesh/face_tri6.h>
30#include <libmesh/face_tri7.h>
31#include <libmesh/cell_hex8.h>
32#include <libmesh/cell_hex20.h>
33#include <libmesh/cell_hex27.h>
34#include <libmesh/cell_tet10.h>
35#include <libmesh/cell_tet14.h>
36#include <libmesh/boundary_info.h>
37#include <libmesh/petsc_vector.h>
38#include <libmesh/petsc_matrix.h>
39
40#include "test_comm.h"
41#include "libmesh_cppunit.h"
42
43#include <string>
44
45using namespace libMesh;
46
47// Sparsity pattern augmentation class used in testDofCouplingWithVarGroups
49{
50private:
51
56
57public:
58
66
67 virtual std::unique_ptr<GhostingFunctor> clone () const override
68 {
69 return std::make_unique<AugmentSparsityOnNodes>(_mesh);
70 }
71
75 virtual void operator() (const MeshBase::const_element_iterator & range_begin,
76 const MeshBase::const_element_iterator & range_end,
78 map_type & coupled_elements) override
79 {
80 dof_id_type node_elem_id_1 = 2;
81 dof_id_type node_elem_id_2 = 3;
82
83 const CouplingMatrix * const null_mat = nullptr;
84
85 for (const auto & elem : as_range(range_begin, range_end))
86 {
87 if (elem->id() == node_elem_id_1)
88 {
89 if (elem->processor_id() != p)
90 {
91 coupled_elements.emplace(elem, null_mat);
92
93 const Elem * neighbor = _mesh.elem_ptr(node_elem_id_2);
94 if (neighbor->processor_id() != p)
95 coupled_elements.emplace(neighbor, null_mat);
96 }
97 }
98 if (elem->id() == node_elem_id_2)
99 {
100 if (elem->processor_id() != p)
101 {
102 coupled_elements.emplace(elem, null_mat);
103
104 const Elem * neighbor = _mesh.elem_ptr(node_elem_id_1);
105 if (neighbor->processor_id() != p)
106 coupled_elements.emplace(neighbor, null_mat);
107 }
108 }
109 }
110 }
111
116 virtual void mesh_reinit () override
117 {
118 }
119
124 virtual void redistribute () override
125 { this->mesh_reinit(); }
126
127};
128
129// Assembly function used in testDofCouplingWithVarGroups
131 const std::string&)
132{
133 const MeshBase& mesh = es.get_mesh();
135 const DofMap& dof_map = system.get_dof_map();
136
139
140 std::vector<dof_id_type> dof_indices;
141
142 SparseMatrix<Number> & matrix = system.get_system_matrix();
143
144 MeshBase::const_element_iterator el = mesh.active_local_elements_begin();
145 const MeshBase::const_element_iterator end_el = mesh.active_local_elements_end();
146
147 for ( ; el != end_el; ++el)
148 {
149 const Elem* elem = *el;
150
151 if(elem->type() == NODEELEM)
152 {
153 continue;
154 }
155
156 dof_map.dof_indices (elem, dof_indices);
157 const unsigned int n_dofs = dof_indices.size();
158
159 Ke.resize (n_dofs, n_dofs);
160 Fe.resize (n_dofs);
161
162 for(unsigned int i=0; i<n_dofs; i++)
163 {
164 Ke(i,i) = 1.;
165 Fe(i) = 1.;
166 }
167
168 matrix.add_matrix (Ke, dof_indices);
169 system.rhs->add_vector (Fe, dof_indices);
170 }
171
172 // Add matrix for extra coupled dofs
173 {
174 const Node & node_1 = mesh.node_ref(1);
175 const Node & node_2 = mesh.node_ref(2);
176 dof_indices.resize(6);
177 dof_indices[0] =
178 node_1.dof_number(system.number(), system.variable_number("u"), 0);
179 dof_indices[1] =
180 node_1.dof_number(system.number(), system.variable_number("v"), 0);
181 dof_indices[2] =
182 node_1.dof_number(system.number(), system.variable_number("w"), 0);
183
184 dof_indices[3] =
185 node_2.dof_number(system.number(), system.variable_number("u"), 0);
186 dof_indices[4] =
187 node_2.dof_number(system.number(), system.variable_number("v"), 0);
188 dof_indices[5] =
189 node_2.dof_number(system.number(), system.variable_number("w"), 0);
190
191 const unsigned int n_dofs = dof_indices.size();
192 Ke.resize (n_dofs, n_dofs);
193 Fe.resize (n_dofs);
194
195 for(unsigned int i=0; i<n_dofs; i++)
196 {
197 Ke(i,i) = 1.;
198 Fe(i) = 1.;
199 }
200
201 matrix.add_matrix (Ke, dof_indices);
202 system.rhs->add_vector (Fe, dof_indices);
203 }
204
205 system.rhs->close();
206 matrix.close();
207}
208
209// Assembly function that uses a DGFEMContext
211 const std::string& /*system_name*/)
212{
213 const MeshBase& mesh = es.get_mesh();
215
218
219 std::vector<dof_id_type> dof_indices;
220 SparseMatrix<Number> & matrix = system.get_system_matrix();
221
222 DGFEMContext context(system);
223 {
224 // For efficiency, we should prerequest all
225 // the data we will need to build the
226 // linear system before doing an element loop.
227 FEBase* elem_fe = NULL;
228 context.get_element_fe(0, elem_fe);
229 elem_fe->get_JxW();
230 elem_fe->get_phi();
231 elem_fe->get_dphi();
232
233 FEBase* side_fe = NULL;
234 context.get_side_fe( 0, side_fe );
235 side_fe->get_JxW();
236 side_fe->get_phi();
237
238 FEBase* neighbor_side_fe = NULL;
239 context.get_neighbor_side_fe(0, neighbor_side_fe);
240 neighbor_side_fe->get_phi();
241 }
242
243 for (const auto & elem : mesh.active_local_element_ptr_range())
244 {
245 context.pre_fe_reinit(system, elem);
246 context.elem_fe_reinit();
247
248 // Element interior assembly
249 {
250 FEBase* elem_fe = NULL;
251 context.get_element_fe(0, elem_fe);
252
253 const std::vector<Real> &JxW = elem_fe->get_JxW();
254 const std::vector<std::vector<Real> >& phi = elem_fe->get_phi();
255 const std::vector<std::vector<RealGradient> >& dphi = elem_fe->get_dphi();
256
257 unsigned int n_dofs = context.get_dof_indices(0).size();
258 unsigned int n_qpoints = context.get_element_qrule().n_points();
259
260 for (unsigned int qp=0; qp != n_qpoints; qp++)
261 for (unsigned int i=0; i != n_dofs; i++)
262 for (unsigned int j=0; j != n_dofs; j++)
263 context.get_elem_jacobian()(i,j) += JxW[qp] * dphi[i][qp]*dphi[j][qp];
264
265 for (unsigned int qp=0; qp != n_qpoints; qp++)
266 for (unsigned int i=0; i != n_dofs; i++)
267 context.get_elem_residual()(i) += JxW[qp] * phi[i][qp];
268 }
269
270 matrix.add_matrix (context.get_elem_jacobian(), context.get_dof_indices());
271 system.rhs->add_vector (context.get_elem_residual(), context.get_dof_indices());
272
273 // Element side assembly
274 for (context.side = 0; context.side != elem->n_sides(); ++context.side)
275 {
276 // If there is a neighbor, then we proceed with assembly
277 // that involves elem and neighbor
278 const Elem* neighbor = elem->neighbor_ptr(context.get_side());
279 if(neighbor)
280 {
281 context.side_fe_reinit();
282 context.set_neighbor(*neighbor);
283
284 // This call initializes neighbor data, and also sets
285 // context.dg_terms_are_active() to true
286 context.neighbor_side_fe_reinit();
287
288 FEBase* side_fe = NULL;
289 context.get_side_fe(0, side_fe);
290
291 const std::vector<Real> &JxW_face = side_fe->get_JxW();
292 const std::vector<std::vector<Real> >& phi_face = side_fe->get_phi();
293
294 FEBase* neighbor_side_fe = NULL;
295 context.get_neighbor_side_fe(0, neighbor_side_fe);
296
297 // These shape functions have been evaluated on the quadrature points
298 // for elem->side on the neighbor element
299 const std::vector<std::vector<Real> >& phi_neighbor_face =
300 neighbor_side_fe->get_phi();
301
302 const unsigned int n_dofs = context.get_dof_indices(0).size();
303 const unsigned int n_neighbor_dofs = context.get_neighbor_dof_indices(0).size();
304 unsigned int n_sidepoints = context.get_side_qrule().n_points();
305
306 for (unsigned int qp=0; qp<n_sidepoints; qp++)
307 {
308 for (unsigned int i=0; i<n_dofs; i++)
309 for (unsigned int j=0; j<n_dofs; j++)
310 {
311 context.get_elem_elem_jacobian()(i,j) +=
312 JxW_face[qp] * phi_face[i][qp] * phi_face[j][qp];
313 }
314
315 for (unsigned int i=0; i<n_dofs; i++)
316 for (unsigned int j=0; j<n_neighbor_dofs; j++)
317 {
318 context.get_elem_neighbor_jacobian()(i,j) +=
319 JxW_face[qp] * phi_face[i][qp] * phi_neighbor_face[j][qp];
320 }
321
322 for (unsigned int i=0; i<n_neighbor_dofs; i++)
323 for (unsigned int j=0; j<n_neighbor_dofs; j++)
324 {
325 context.get_neighbor_neighbor_jacobian()(i,j) +=
326 JxW_face[qp] * phi_neighbor_face[i][qp] * phi_neighbor_face[j][qp];
327 }
328
329 for (unsigned int i=0; i<n_neighbor_dofs; i++)
330 for (unsigned int j=0; j<n_dofs; j++)
331 {
332 context.get_neighbor_elem_jacobian()(i,j) +=
333 JxW_face[qp] * phi_neighbor_face[i][qp] * phi_face[j][qp];
334 }
335 }
336
337 matrix.add_matrix (context.get_elem_elem_jacobian(),
338 context.get_dof_indices(),
339 context.get_dof_indices());
340
341 matrix.add_matrix (context.get_elem_neighbor_jacobian(),
342 context.get_dof_indices(),
343 context.get_neighbor_dof_indices());
344
345 matrix.add_matrix (context.get_neighbor_elem_jacobian(),
346 context.get_neighbor_dof_indices(),
347 context.get_dof_indices());
348
350 context.get_neighbor_dof_indices(),
351 context.get_neighbor_dof_indices());
352 }
353 }
354 }
355}
356
357
359 const Parameters&,
360 const std::string&,
361 const std::string&)
362{
363 const Real & x = p(0);
364 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
365 const Real & z = LIBMESH_DIM > 2 ? p(2) : 0;
366
367 return x*(1-x)*(1-x) + x*x*(1-y) + x*(1-y)*(1-z) + y*(1-y)*z + z*(1-z)*(1-z);
368}
369
370
372 const Parameters&,
373 const std::string&,
374 const std::string&)
375{
376 const Real & x = p(0);
377 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
378 const Real & z = LIBMESH_DIM > 2 ? p(2) : 0;
379
380 return x + 2*y + 3*z - 1;
381}
382
383
385 const Parameters&,
386 const std::string&,
387 const std::string&)
388{
389 const Real & x = p(0);
390 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
391 const Real & z = LIBMESH_DIM > 2 ? p(2) : 0;
392
393 return (3*x < 1) + (3*y < 2) + (3*z > 2);
394}
395
396
397struct TripleFunction : public FunctionBase<Number>
398{
399 TripleFunction(Number _offset = 0) : offset(_offset) {}
400
401 virtual std::unique_ptr<FunctionBase<Number>> clone () const
402 { return std::make_unique<TripleFunction>(offset); }
403
404 // We only really need the vector-valued output for projections
405 virtual Number operator() (const Point &,
406 const Real /*time*/ = 0.) override
407 { libmesh_error(); }
408
409 virtual void operator() (const Point & p,
410 const Real,
411 DenseVector<Number> & output) override
412 {
413 libmesh_assert_greater(output.size(), 0);
414 Parameters params;
415 output(0) = cubic_test(p, params, "", "") + offset;
416 if (output.size() > 0)
417 output(1) = new_linear_test(p, params, "", "") + offset;
418 if (output.size() > 1)
419 output(2) = disc_thirds_test(p, params, "", "") + offset;
420 }
421
422 Number component (unsigned int i,
423 const Point & p,
424 Real /* time */) override
425 {
426 Parameters params;
427 switch (i) {
428 case 0:
429 return cubic_test(p, params, "", "") + offset;
430 case 1:
431 return new_linear_test(p, params, "", "") + offset;
432 case 2:
433 return disc_thirds_test(p, params, "", "") + offset;
434 default:
435 libmesh_error();
436 }
437 return 0;
438 }
439
441};
442
443
444class SystemsTest : public CppUnit::TestCase {
445public:
447
449
451
456#ifdef LIBMESH_HAVE_PETSC
458#endif
459
461#if LIBMESH_DIM > 1
471#ifdef LIBMESH_HAVE_SOLVER
473#endif
474#endif // LIBMESH_DIM > 1
475#if LIBMESH_DIM > 2
486#ifdef LIBMESH_HAVE_SOLVER
489#endif
490#endif // LIBMESH_DIM > 2
491#ifdef LIBMESH_HAVE_SOLVER
493#endif
494
495#ifdef LIBMESH_ENABLE_AMR
497
498#ifdef LIBMESH_HAVE_METAPHYSICL
499#ifdef LIBMESH_HAVE_PETSC
501#if LIBMESH_DIM > 1
504#endif // LIBMESH_DIM > 1
505#if LIBMESH_DIM > 2
508#endif // LIBMESH_DIM > 2
509#endif // LIBMESH_HAVE_PETSC
510#endif // LIBMESH_HAVE_METAPHYSICL
511#endif // LIBMESH_ENABLE_AMR
512
514
515private:
516 void tripleValueTest (const Point & p,
517 const TransientExplicitSystem & sys,
518 const PointLocatorBase & locator,
519 std::set<subdomain_id_type> & u_subdomains,
520 std::set<subdomain_id_type> & v_subdomains,
521 std::set<subdomain_id_type> & w_subdomains,
522 const Parameters & param)
523 {
524 const Elem * elem = locator(p);
525 subdomain_id_type sbd_id = elem ? elem->subdomain_id() : 0;
526 TestCommWorld->max(sbd_id);
527
528 if (u_subdomains.count(sbd_id))
529 {
530 LIBMESH_ASSERT_NUMBERS_EQUAL(cubic_test(p,param,"",""),
531 sys.point_value(0,p),
533 LIBMESH_ASSERT_NUMBERS_EQUAL
534 (cubic_test(p,param,"","") + Number(10),
535 sys.point_value(0,p,sys.old_local_solution),
536 TOLERANCE*TOLERANCE*100);
537 LIBMESH_ASSERT_NUMBERS_EQUAL
538 (cubic_test(p,param,"","") + Number(20),
539 sys.point_value(0,p,sys.older_local_solution),
540 TOLERANCE*TOLERANCE*100);
541 }
542 if (v_subdomains.count(sbd_id))
543 {
544 LIBMESH_ASSERT_NUMBERS_EQUAL
545 (new_linear_test(p,param,"",""), sys.point_value(1,p),
547 LIBMESH_ASSERT_NUMBERS_EQUAL
548 (new_linear_test(p,param,"","") + Number(10),
549 sys.point_value(1,p,sys.old_local_solution),
550 TOLERANCE*TOLERANCE*100);
551 LIBMESH_ASSERT_NUMBERS_EQUAL
552 (new_linear_test(p,param,"","") + Number(20),
553 sys.point_value(1,p,sys.older_local_solution),
554 TOLERANCE*TOLERANCE*100);
555 }
556 if (w_subdomains.count(sbd_id))
557 {
558 LIBMESH_ASSERT_NUMBERS_EQUAL
559 (disc_thirds_test(p,param,"",""), sys.point_value(2,p),
561 LIBMESH_ASSERT_NUMBERS_EQUAL
562 (disc_thirds_test(p,param,"","") + Number(10),
563 sys.point_value(2,p,sys.old_local_solution),
564 TOLERANCE*TOLERANCE*100);
565 LIBMESH_ASSERT_NUMBERS_EQUAL
566 (disc_thirds_test(p,param,"","") + Number(20),
567 sys.point_value(2,p,sys.older_local_solution),
568 TOLERANCE*TOLERANCE*100);
569 }
570 }
571
572public:
573 void setUp()
574 {}
575
576 void tearDown()
577 {}
578
579
581 EquationSystems & es)
582 {
583 ExplicitSystem &sys =
584 es.add_system<ExplicitSystem> ("Simple");
585
586 sys.add_variable("u", FIRST);
587
589 10,
590 0., 1.,
591 EDGE3);
592
593 return sys;
594 }
595
596
598 {
600
602 1, 1, 1,
603 0., 1., 0., 1., 0., 1.,
604 HEX8);
605
607 System &sys = es.add_system<System> ("SimpleSystem");
608
609 const FEFamily types[3] = {MONOMIAL_VEC, LAGRANGE_VEC, NEDELEC_ONE};
610 const Order orders[3] = {CONSTANT, SECOND, FIRST};
611 const std::string names[3] = {"u", "v", "w"};
612 const unsigned int var_nums[3] =
613 {
617 };
618
619 for (unsigned int i : {0, 1, 2})
620 {
621 // We did just add these in order
622 CPPUNIT_ASSERT_EQUAL(i, var_nums[i]);
623
624 auto & var = sys.variable(i);
625 CPPUNIT_ASSERT_EQUAL(var.system(), &sys);
626 CPPUNIT_ASSERT_EQUAL(var.name(), names[i]);
627 CPPUNIT_ASSERT_EQUAL(var.number(), i);
628 CPPUNIT_ASSERT_EQUAL(var.first_scalar_number(), i*3);
629 CPPUNIT_ASSERT_EQUAL(var.type().family, types[i]);
630 CPPUNIT_ASSERT_EQUAL(Order(var.type().order), orders[i]);
631 CPPUNIT_ASSERT_EQUAL(var.n_components(mesh), 3u);
632 }
633 }
634
635
637 {
640 ExplicitSystem &sys =
641 es.add_system<ExplicitSystem> ("100KVars");
642
643 dof_id_type n_dofs = 100000;
644
645 // This takes 16 seconds in opt mode for me, 200 in dbg!?
646 /*
647 for (auto i : make_range(n_dofs))
648 sys.add_variable(std::to_string(i), FIRST);
649 */
650
651 std::vector<std::string> var_names(n_dofs);
652 for (auto i : make_range(n_dofs))
653 var_names[i] = std::to_string(i);
654
655 sys.add_variables(var_names, FIRST);
656
658 4,
659 0., 1.,
660 EDGE3);
661
662 es.init();
663
664 CPPUNIT_ASSERT_EQUAL(sys.n_dofs(), n_dofs*5);
665 for (const Node * node : mesh.node_ptr_range())
666 CPPUNIT_ASSERT_EQUAL(dof_id_type(node->n_vars(0)), n_dofs);
667
668 std::vector<dof_id_type> each = sys.get_dof_map().n_dofs_per_processor(888);
669 CPPUNIT_ASSERT_EQUAL(std::accumulate(each.begin(), each.end(), dof_id_type(0)), dof_id_type(5));
670 CPPUNIT_ASSERT_EQUAL(sys.get_dof_map().n_dofs(888), dof_id_type(5));
671 }
672
674 {
677 ExplicitSystem & sys = simpleSetup(mesh, es);
678
679 auto info = sys.get_info();
680
681 CPPUNIT_ASSERT (info.find("uninitialized") != std::string::npos);
682 }
683
684
686 {
689 ExplicitSystem & sys = simpleSetup(mesh, es);
690 es.init();
691
692 auto & late_vec = sys.add_vector("late");
693
694 CPPUNIT_ASSERT_EQUAL(sys.n_dofs(), dof_id_type(11));
695
696 // late_vec should be initialized
697 CPPUNIT_ASSERT_EQUAL(late_vec.size(), dof_id_type(11));
698 CPPUNIT_ASSERT_EQUAL(late_vec.local_size(), sys.solution->local_size());
699 }
700
701
703 {
706 ExplicitSystem & sys = simpleSetup(mesh, es);
707
708 sys.add_vector("late", /* projections = */ false);
709 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), false);
710
711 sys.add_vector("late");
712 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), true);
713 }
714
715
717 {
718 // Vector types are all pretty much equivalent in serial.
719 if (TestCommWorld->size() == 1)
720 return;
721
724 ExplicitSystem & sys = simpleSetup(mesh, es);
725
726 auto & late_vec = sys.add_vector("late");
727 CPPUNIT_ASSERT_EQUAL(late_vec.type(), PARALLEL);
728 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), true);
729
730 // We should never downgrade projection settings, so "false"
731 // should be safely ignored here
732 sys.add_vector("late", false, GHOSTED);
733 CPPUNIT_ASSERT_EQUAL(late_vec.type(), GHOSTED);
734 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), true);
735
736 // We should never downgrade storage settings, so this should be a
737 // no-op.
738 sys.add_vector("late", true, PARALLEL);
739 CPPUNIT_ASSERT_EQUAL(late_vec.type(), GHOSTED);
740 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), true);
741 }
742
743
745 {
746 // Vector types are all pretty much equivalent in serial.
747 if (TestCommWorld->size() == 1)
748 return;
749
752 ExplicitSystem & sys = simpleSetup(mesh, es);
753
754 auto & late_vec = sys.add_vector("late");
755 CPPUNIT_ASSERT_EQUAL(late_vec.type(), PARALLEL);
756 CPPUNIT_ASSERT_EQUAL(sys.vector_preservation("late"), true);
757
758 es.init();
759
760 auto & dof_map = sys.get_dof_map();
761
762 // Set some data to make sure it's preserved
763 CPPUNIT_ASSERT_EQUAL(sys.n_dofs(), dof_id_type(11));
764 for (auto i : make_range(dof_map.first_dof(),
765 dof_map.end_dof()))
766 late_vec.set(i, 2.0*i);
767 late_vec.close();
768
769 sys.add_vector("late", false, GHOSTED);
770 CPPUNIT_ASSERT_EQUAL(late_vec.type(), GHOSTED);
771
772 std::vector<dof_id_type> dof_indices;
773 for (auto & elem : mesh.active_local_element_ptr_range())
774 {
775 dof_map.dof_indices (elem, dof_indices);
776
777 for (auto d : dof_indices)
778 CPPUNIT_ASSERT_EQUAL(late_vec(d), Number(2.0*d));
779 }
780 }
781
782
783
784#ifdef LIBMESH_HAVE_PETSC
786 {
788 return;
789
793 sys.add_variable("u", FIRST);
795
796 // Objects added before and after the prefix is set both get it
797 sys.add_vector("early", true, GHOSTED);
798 sys.set_options_prefix("simple_");
799 sys.add_vector("late", true, PARALLEL);
800 sys.add_matrix("late_matrix");
801
802 auto check = [&sys]()
803 {
804 const auto prefix_of = [](PetscObject obj)
805 {
806 const char * prefix;
807 LibmeshPetscCallA(PETSC_COMM_WORLD, PetscObjectGetOptionsPrefix(obj, &prefix));
808 return std::string(prefix ? prefix : "");
809 };
810 const auto vec_prefix = [&prefix_of](const NumericVector<Number> & vec)
811 { return prefix_of((PetscObject)cast_ref<const PetscVector<Number> &>(vec).vec()); };
812 const std::string ghosted =
813 sys.n_processors() > 1 ? "simple_ghost_" : "simple_";
814
815 CPPUNIT_ASSERT_EQUAL(std::string("simple_"), vec_prefix(*sys.solution));
816 CPPUNIT_ASSERT_EQUAL(ghosted, vec_prefix(*sys.current_local_solution));
817 CPPUNIT_ASSERT_EQUAL(ghosted, vec_prefix(sys.get_vector("early")));
818 CPPUNIT_ASSERT_EQUAL(std::string("simple_"), vec_prefix(sys.get_vector("late")));
819 CPPUNIT_ASSERT_EQUAL(std::string("simple_"), vec_prefix(*sys.rhs));
820 CPPUNIT_ASSERT_EQUAL(
821 std::string("simple_"),
822 prefix_of((PetscObject)cast_ref<PetscMatrix<Number> &>(sys.get_matrix("late_matrix")).mat()));
823 CPPUNIT_ASSERT_EQUAL(std::string("simple_"),
824 vec_prefix(*sys.get_vector("late").zero_clone()));
825 };
826
827 es.init();
828 check();
829
830#ifdef LIBMESH_ENABLE_AMR
831 // Refinement rebuilds every vector and matrix
833 es.reinit();
834 check();
835#endif
836 }
837#endif
838
839
840 void testProjectLine(const ElemType elem_type)
841 {
843
846 es.add_system<TransientExplicitSystem> ("SimpleSystem");
847
848 std::set<subdomain_id_type> u_subdomains {0, 1, 4, 5},
849 v_subdomains {1, 2, 3, 4},
850 w_subdomains {0, 1, 2, 3, 4};
851
852 sys.add_variable("u", THIRD, HIERARCHIC, &u_subdomains);
853 sys.add_variable("v", FIRST, LAGRANGE, &v_subdomains);
854 sys.add_variable("w", CONSTANT, MONOMIAL, &w_subdomains);
855
857 6,
858 0., 1.,
859 elem_type);
860
861 for (auto & elem : mesh.element_ptr_range())
862 elem->subdomain_id() = elem->id();
863
864 es.init();
865 TripleFunction tfunc;
866 sys.project_solution(&tfunc);
867 tfunc.offset = 10;
868 sys.project_vector(*sys.old_local_solution, &tfunc);
869 tfunc.offset = 20;
870 sys.project_vector(*sys.older_local_solution, &tfunc);
871
872 std::unique_ptr<PointLocatorBase> locator = mesh.sub_point_locator();
873 locator->enable_out_of_mesh_mode();
874 for (Real x = 0.1; x < 1; x += 0.2)
875 tripleValueTest(Point(x), sys, *locator,
876 u_subdomains, v_subdomains, w_subdomains,
877 es.parameters);
878
879#ifdef LIBMESH_ENABLE_AMR
880 for (auto & elem : mesh.element_ptr_range())
881 if ((elem->id()/2)%2)
882 elem->set_refinement_flag(Elem::REFINE);
883 es.reinit();
884
885 locator = mesh.sub_point_locator();
886 locator->enable_out_of_mesh_mode();
887 for (Real x = 0.1; x < 1; x += 0.2)
888 tripleValueTest(Point(x), sys, *locator,
889 u_subdomains, v_subdomains, w_subdomains,
890 es.parameters);
891#endif
892 }
893
894#ifdef LIBMESH_ENABLE_AMR
896 {
898
900 2, 2,
901 0., 1.,
902 0., 1.,
903 QUAD4);
904
905 // Initialize the EquationSystems on a refined mesh so that the
906 // subsequent reinit performs a fine-to-coarse projection.
907 MeshRefinement mesh_refinement(mesh);
908 for (auto & elem : mesh.active_element_ptr_range())
909 elem->set_refinement_flag(Elem::REFINE);
910 mesh_refinement.refine_elements();
912
914 ExplicitSystem & sys =
915 es.add_system<ExplicitSystem>("SimpleSystem");
916
917 sys.add_variable("u", CONSTANT, MONOMIAL);
918 const unsigned int scalar_var =
919 sys.add_variable("scalar", FIRST, SCALAR);
920
921 es.init();
922
923 std::vector<dof_id_type> scalar_dofs;
924 sys.get_dof_map().SCALAR_dof_indices(scalar_dofs, scalar_var);
925 CPPUNIT_ASSERT_EQUAL(std::size_t(1), scalar_dofs.size());
926
927 NumericVector<Number> & solution = *sys.solution;
928 const dof_id_type scalar_dof = scalar_dofs[0];
929 if (scalar_dof >= solution.first_local_index() &&
930 scalar_dof < solution.last_local_index())
931 solution.set(scalar_dof, 7.25);
932 solution.close();
933
934 for (auto & elem : mesh.active_element_ptr_range())
935 elem->set_refinement_flag(Elem::COARSEN);
936
937 es.reinit();
938
939 scalar_dofs.clear();
940 sys.get_dof_map().SCALAR_dof_indices(scalar_dofs, scalar_var);
941 CPPUNIT_ASSERT_EQUAL(std::size_t(1), scalar_dofs.size());
942
943 std::unique_ptr<NumericVector<Number>> localized_solution =
945 localized_solution->init(sys.n_dofs(), false, SERIAL);
946 sys.solution->localize(*localized_solution);
947
948 LIBMESH_ASSERT_NUMBERS_EQUAL((*localized_solution)(scalar_dofs[0]),
949 Number(7.25),
950 TOLERANCE);
951 }
952#endif
953
954 void test2DProjectVectorFE(const ElemType elem_type)
955 {
957
960 es.add_system<TransientExplicitSystem> ("SimpleSystem");
961
962 auto u_var = sys.add_variable("u", Elem::type_to_default_order_map[elem_type], LAGRANGE_VEC);
963
965 1, 1,
966 0., 1., 0., 1.,
967 elem_type);
968
969 es.init();
970
971 // Manually set-up the solution because I'm too lazy to set-up all the generic
972 // function projection code right now
973 for (const auto & node : mesh.local_node_ptr_range())
974 {
975 for (unsigned int i : make_range(Elem::type_to_dim_map[elem_type]))
976 {
977 auto dof_index = node->dof_number(sys.number(), u_var, i);
978 sys.solution->set(dof_index, (*node)(i));
979 }
980 }
981
982 // After setting values, we need to assemble
983 sys.solution->close();
984
985
986#ifdef LIBMESH_ENABLE_AMR
987 for (auto & elem : mesh.element_ptr_range())
988 elem->set_refinement_flag(Elem::REFINE);
989 es.reinit();
990#endif
991
992 for (const auto & node : mesh.local_node_ptr_range())
993 {
994 // 2D element here
995 for (unsigned int i : make_range(Elem::type_to_dim_map[elem_type]))
996 {
997 auto dof_index = node->dof_number(sys.number(), u_var, i);
998 auto value = (*sys.solution)(dof_index);
999 LIBMESH_ASSERT_NUMBERS_EQUAL(value, (*node)(i), TOLERANCE*TOLERANCE);
1000 }
1001 }
1002 }
1003
1004 void test3DProjectVectorFE(const ElemType elem_type)
1005 {
1007
1010 es.add_system<TransientExplicitSystem> ("SimpleSystem");
1011
1012 auto u_var = sys.add_variable
1014
1016 1, 1, 1,
1017 0., 1., 0., 1., 0., 1.,
1018 elem_type);
1019
1020 es.init();
1021
1022 // Manually set-up the solution because I'm too lazy to set-up all the generic
1023 // function projection code right now
1024 for (const auto & node : mesh.local_node_ptr_range())
1025 {
1026 for (unsigned int i : make_range(Elem::type_to_dim_map[elem_type]))
1027 {
1028 auto dof_index = node->dof_number(sys.number(), u_var, i);
1029 sys.solution->set(dof_index, (*node)(i));
1030 }
1031 }
1032
1033 // After setting values, we need to assemble
1034 sys.solution->close();
1035
1036
1037#ifdef LIBMESH_ENABLE_AMR
1038 for (auto & elem : mesh.element_ptr_range())
1039 elem->set_refinement_flag(Elem::REFINE);
1040 es.reinit();
1041#endif
1042
1043 for (const auto & node : mesh.local_node_ptr_range())
1044 {
1045 for (unsigned int i : make_range(Elem::type_to_dim_map[elem_type]))
1046 {
1047 auto dof_index = node->dof_number(sys.number(), u_var, i);
1048 auto value = (*sys.solution)(dof_index);
1049 LIBMESH_ASSERT_NUMBERS_EQUAL(value, (*node)(i), TOLERANCE*TOLERANCE);
1050 }
1051 }
1052 }
1053
1054 void testProjectSquare(const ElemType elem_type)
1055 {
1057
1060 es.add_system<TransientExplicitSystem> ("SimpleSystem");
1061
1062 std::set<subdomain_id_type> u_subdomains {0, 1, 4, 5},
1063 v_subdomains {1, 2, 3, 4},
1064 w_subdomains {0, 1, 2, 3, 4};
1065
1066 sys.add_variable("u", THIRD, HIERARCHIC, &u_subdomains);
1067 sys.add_variable("v", FIRST, LAGRANGE, &v_subdomains);
1068 sys.add_variable("w", CONSTANT, MONOMIAL, &w_subdomains);
1069
1071 3, 3,
1072 0., 1., 0., 1.,
1073 elem_type);
1074
1075 for (auto & elem : mesh.element_ptr_range())
1076 elem->subdomain_id() = elem->id()/2;
1077
1078 es.init();
1079 TripleFunction tfunc;
1080 sys.project_solution(&tfunc);
1081 tfunc.offset = 10;
1082 sys.project_vector(*sys.old_local_solution, &tfunc);
1083 tfunc.offset = 20;
1084 sys.project_vector(*sys.older_local_solution, &tfunc);
1085
1086 std::unique_ptr<PointLocatorBase> locator = mesh.sub_point_locator();
1087 locator->enable_out_of_mesh_mode();
1088 for (Real x = 0.1; x < 1; x += 0.2)
1089 for (Real y = 0.1; y < 1; y += 0.2)
1090 tripleValueTest(Point(x,y), sys, *locator,
1091 u_subdomains, v_subdomains, w_subdomains,
1092 es.parameters);
1093
1094#ifdef LIBMESH_ENABLE_AMR
1095 for (auto & elem : mesh.element_ptr_range())
1096 if ((elem->id()/2)%2)
1097 elem->set_refinement_flag(Elem::REFINE);
1098 es.reinit();
1099
1100 locator = mesh.sub_point_locator();
1101 locator->enable_out_of_mesh_mode();
1102 for (Real x = 0.1; x < 1; x += 0.2)
1103 for (Real y = 0.1; y < 1; y += 0.2)
1104 tripleValueTest(Point(x,y), sys, *locator,
1105 u_subdomains, v_subdomains, w_subdomains,
1106 es.parameters);
1107#endif
1108 }
1109
1110 void testProjectCube(const ElemType elem_type)
1111 {
1113
1116 es.add_system<TransientExplicitSystem> ("SimpleSystem");
1117
1118 std::set<subdomain_id_type> u_subdomains {0, 1, 4, 5},
1119 v_subdomains {1, 2, 3, 4},
1120 w_subdomains {0, 1, 2, 3, 4};
1121
1122 sys.add_variable("u", THIRD, HIERARCHIC, &u_subdomains);
1123 sys.add_variable("v", FIRST, LAGRANGE, &v_subdomains);
1124 sys.add_variable("w", CONSTANT, MONOMIAL, &w_subdomains);
1125
1127 3, 3, 3,
1128 0., 1., 0., 1., 0., 1.,
1129 elem_type);
1130
1131 for (auto & elem : mesh.element_ptr_range())
1132 elem->subdomain_id() = elem->id()/6;
1133
1134 es.init();
1135 TripleFunction tfunc;
1136 sys.project_solution(&tfunc);
1137 tfunc.offset = 10;
1138 sys.project_vector(*sys.old_local_solution, &tfunc);
1139 tfunc.offset = 20;
1140 sys.project_vector(*sys.older_local_solution, &tfunc);
1141
1142 std::unique_ptr<PointLocatorBase> locator = mesh.sub_point_locator();
1143 locator->enable_out_of_mesh_mode();
1144 for (Real x = 0.1; x < 1; x += 0.2)
1145 for (Real y = 0.1; y < 1; y += 0.2)
1146 for (Real z = 0.1; z < 1; z += 0.2)
1147 tripleValueTest(Point(x,y,z), sys, *locator,
1148 u_subdomains, v_subdomains, w_subdomains,
1149 es.parameters);
1150
1151 #ifdef LIBMESH_ENABLE_AMR
1152 for (auto & elem : mesh.element_ptr_range())
1153 if ((elem->id()/2)%2)
1154 elem->set_refinement_flag(Elem::REFINE);
1155 es.reinit();
1156
1157 locator = mesh.sub_point_locator();
1158 locator->enable_out_of_mesh_mode();
1159 for (Real x = 0.1; x < 1; x += 0.2)
1160 for (Real y = 0.1; y < 1; y += 0.2)
1161 for (Real z = 0.1; z < 1; z += 0.2)
1162 tripleValueTest(Point(x,y,z), sys, *locator,
1163 u_subdomains, v_subdomains, w_subdomains,
1164 es.parameters);
1165 #endif
1166 }
1167
1169 {
1170 // The source mesh needs to exist everywhere it's queried, so we
1171 // use a ReplicatedMesh
1173
1175 System &sys = es.add_system<System> ("SimpleSystem");
1176 sys.add_variable("u", THIRD, MONOMIAL);
1177
1179 3, 3, 3,
1180 0., 1., 0., 1., 0., 1.,
1181 elem_type);
1182
1183 es.init();
1184 sys.project_solution(cubic_test, nullptr, es.parameters);
1185
1186 std::vector<unsigned int> variables;
1187 sys.get_all_variable_numbers(variables);
1188 std::sort(variables.begin(),variables.end());
1189
1190 std::unique_ptr< NumericVector<Number> > mesh_function_vector =
1192 mesh_function_vector->init(sys.n_dofs(), false, SERIAL);
1193 sys.solution->localize( *mesh_function_vector );
1194
1195 MeshFunction mesh_function(es,
1196 *mesh_function_vector,
1197 sys.get_dof_map(),
1198 variables);
1199 mesh_function.init();
1200
1201 // Make a second system and project onto it using a MeshFunction
1202 Mesh proj_mesh(*TestCommWorld);
1203 EquationSystems proj_es(proj_mesh);
1204
1205 System &proj_sys = proj_es.add_system<System> ("ProjectionSystem");
1206
1207 // use 3rd order again so we can expect exact results
1208 proj_sys.add_variable("u", THIRD, HIERARCHIC);
1209
1211 5, 5, 5,
1212 0., 1., 0., 1., 0., 1.,
1213 elem_type);
1214
1215 proj_es.init();
1216 proj_sys.project_solution(&mesh_function);
1217
1218 for (Real x = 0.1; x < 1; x += 0.2)
1219 for (Real y = 0.1; y < 1; y += 0.2)
1220 for (Real z = 0.1; z < 1; z += 0.2)
1221 {
1222 Point p(x,y,z);
1223 LIBMESH_ASSERT_NUMBERS_EQUAL
1224 (cubic_test(p,es.parameters,"",""),
1225 proj_sys.point_value(0,p), TOLERANCE*TOLERANCE);
1226 }
1227 }
1228
1230 {
1231 LOG_UNIT_TEST;
1232
1234
1235 // const boundary_id_type BOUNDARY_ID_MIN_Z = 0;
1236 const boundary_id_type BOUNDARY_ID_MIN_Y = 1;
1237 const boundary_id_type BOUNDARY_ID_MAX_X = 2;
1238 const boundary_id_type BOUNDARY_ID_MAX_Y = 3;
1239 const boundary_id_type BOUNDARY_ID_MIN_X = 4;
1240 const boundary_id_type BOUNDARY_ID_MAX_Z = 5;
1241 const boundary_id_type NODE_BOUNDARY_ID = 10;
1242 const boundary_id_type EDGE_BOUNDARY_ID = 20;
1243 const boundary_id_type SIDE_BOUNDARY_ID = BOUNDARY_ID_MIN_X;
1244
1246 System &sys = es.add_system<System> ("SimpleSystem");
1247 unsigned int u_var = sys.add_variable("u", FIRST, LAGRANGE);
1248
1250 3, 3, 3,
1251 0., 1., 0., 1., 0., 1.,
1252 HEX8);
1253
1254 // Count the number of nodes on SIDE_BOUNDARY_ID
1255 std::set<dof_id_type> projected_nodes_set;
1256
1257 for (const auto & elem : mesh.element_ptr_range())
1258 {
1259 for (auto side : elem->side_index_range())
1260 {
1261 std::vector<boundary_id_type> vec_to_fill;
1262 mesh.get_boundary_info().boundary_ids(elem, side, vec_to_fill);
1263
1264 auto vec_it = std::find(vec_to_fill.begin(), vec_to_fill.end(), SIDE_BOUNDARY_ID);
1265 if (vec_it != vec_to_fill.end())
1266 {
1267 for (unsigned int node_index=0; node_index<elem->n_nodes(); node_index++)
1268 {
1269 if( elem->is_node_on_side(node_index, side))
1270 {
1271 projected_nodes_set.insert(elem->node_id(node_index));
1272 }
1273 }
1274 }
1275 }
1276 }
1277
1278 // Also add some edge and node boundary IDs
1279 for (const auto & elem : mesh.element_ptr_range())
1280 {
1281 unsigned int
1282 side_max_x = 0, side_min_y = 0,
1283 side_max_y = 0, side_max_z = 0;
1284
1285 bool
1286 found_side_max_x = false, found_side_max_y = false,
1287 found_side_min_y = false, found_side_max_z = false;
1288
1289 for (auto side : elem->side_index_range())
1290 {
1291 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_X))
1292 {
1293 side_max_x = side;
1294 found_side_max_x = true;
1295 }
1296
1297 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MIN_Y))
1298 {
1299 side_min_y = side;
1300 found_side_min_y = true;
1301 }
1302
1303 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_Y))
1304 {
1305 side_max_y = side;
1306 found_side_max_y = true;
1307 }
1308
1309 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_Z))
1310 {
1311 side_max_z = side;
1312 found_side_max_z = true;
1313 }
1314 }
1315
1316 // If elem has sides on boundaries
1317 // BOUNDARY_ID_MAX_X, BOUNDARY_ID_MAX_Y, BOUNDARY_ID_MAX_Z
1318 // then let's set a node boundary condition
1319 if (found_side_max_x && found_side_max_y && found_side_max_z)
1320 for (auto n : elem->node_index_range())
1321 if (elem->is_node_on_side(n, side_max_x) &&
1322 elem->is_node_on_side(n, side_max_y) &&
1323 elem->is_node_on_side(n, side_max_z))
1324 {
1325 projected_nodes_set.insert(elem->node_id(n));
1326 mesh.get_boundary_info().add_node(elem->node_ptr(n), NODE_BOUNDARY_ID);
1327 }
1328
1329 // If elem has sides on boundaries
1330 // BOUNDARY_ID_MAX_X and BOUNDARY_ID_MIN_Y
1331 // then let's set an edge boundary condition
1332 if (found_side_max_x && found_side_min_y)
1333 for (auto e : elem->edge_index_range())
1334 if (elem->is_edge_on_side(e, side_max_x) &&
1335 elem->is_edge_on_side(e, side_min_y))
1336 {
1337 mesh.get_boundary_info().add_edge(elem, e, EDGE_BOUNDARY_ID);
1338
1339 for (unsigned int node_index=0; node_index<elem->n_nodes(); node_index++)
1340 {
1341 if (elem->is_node_on_edge(node_index, e))
1342 {
1343 projected_nodes_set.insert(elem->node_id(node_index));
1344 }
1345 }
1346 }
1347 }
1348
1349 es.init();
1350
1351 sys.solution->add(1.0);
1352
1353 std::set<boundary_id_type> boundary_ids;
1354 boundary_ids.insert(NODE_BOUNDARY_ID);
1355 boundary_ids.insert(EDGE_BOUNDARY_ID);
1356 boundary_ids.insert(SIDE_BOUNDARY_ID);
1357 std::vector<unsigned int> variables;
1358 variables.push_back(u_var);
1359 ZeroFunction<> zf;
1360 sys.boundary_project_solution(boundary_ids, variables, &zf);
1361
1362 // On a distributed mesh we may not have every node on every
1363 // processor
1364 TestCommWorld->set_union(projected_nodes_set);
1365
1366 // We set the solution to be 1 everywhere and then zero on specific boundary
1367 // nodes, so the final l1 norm of the solution is the difference between the
1368 // number of nodes in the mesh and the number of nodes we zero on.
1369 Real ref_l1_norm = static_cast<Real>(mesh.n_nodes()) - static_cast<Real>(projected_nodes_set.size());
1370
1371 LIBMESH_ASSERT_FP_EQUAL(sys.solution->l1_norm(), ref_l1_norm, TOLERANCE*TOLERANCE);
1372 }
1373
1375 {
1376 LOG_UNIT_TEST;
1377
1379
1381 1,
1382 0,
1383 0,
1384 0., 1.,
1385 0., 0.,
1386 0., 0.,
1387 EDGE2);
1388
1389 Point new_point_a(2.);
1390 Point new_point_b(3.);
1391 Node* new_node_a = mesh.add_point( new_point_a );
1392 Node* new_node_b = mesh.add_point( new_point_b );
1393 auto new_edge_elem = mesh.add_elem(Elem::build(EDGE2));
1394 new_edge_elem->set_node(0, new_node_a);
1395 new_edge_elem->set_node(1, new_node_b);
1396
1397 mesh.elem_ref(0).subdomain_id() = 10;
1398 mesh.elem_ref(1).subdomain_id() = 10;
1399
1400 // Add NodeElems for coupling purposes
1401 auto node_elem_1 = mesh.add_elem(Elem::build(NODEELEM));
1402 node_elem_1->set_node(0, mesh.elem_ref(0).node_ptr(1));
1403 auto node_elem_2 = mesh.add_elem(Elem::build(NODEELEM));
1404 node_elem_2->set_node(0, new_node_a);
1405
1407
1408 // Create an equation systems object.
1409 EquationSystems equation_systems (mesh);
1410 LinearImplicitSystem & system =
1411 equation_systems.add_system<LinearImplicitSystem> ("test");
1412
1413 system.add_variable ("u", libMesh::FIRST);
1414 system.add_variable ("v", libMesh::FIRST);
1415 system.add_variable ("w", libMesh::FIRST);
1416
1417 std::set<subdomain_id_type> theta_subdomains;
1418 theta_subdomains.insert(10);
1419 system.add_variable ("theta_x", libMesh::FIRST, &theta_subdomains);
1420 system.add_variable ("theta_y", libMesh::FIRST, &theta_subdomains);
1421 system.add_variable ("theta_z", libMesh::FIRST, &theta_subdomains);
1422
1424
1425 AugmentSparsityOnNodes augment_sparsity(mesh);
1426 system.get_dof_map().add_coupling_functor(augment_sparsity);
1427
1428 // LASPACK GMRES + ILU defaults don't like this problem, but it's
1429 // small enough to just use a simpler iteration.
1432
1433 equation_systems.init ();
1434
1435 system.solve();
1436
1437 // We set the solution to be 1 everywhere, so the final l1 norm of the
1438 // solution is the product of the number of variables and number of nodes.
1439 Real ref_l1_norm = static_cast<Real>(mesh.n_nodes() * system.n_vars());
1440
1441 LIBMESH_ASSERT_FP_EQUAL(system.solution->l1_norm(), ref_l1_norm, TOLERANCE*TOLERANCE);
1442 }
1443
1444
1446 {
1447 LOG_UNIT_TEST;
1448
1450
1452 1,
1453 0,
1454 0,
1455 0., 1.,
1456 0., 0.,
1457 0., 0.,
1458 EDGE2);
1459
1460 Point new_point_a(2.);
1461 Point new_point_b(3.);
1462 Node* new_node_a = mesh.add_point( new_point_a );
1463 Node* new_node_b = mesh.add_point( new_point_b );
1464 auto new_edge_elem = mesh.add_elem(Elem::build(EDGE2));
1465 new_edge_elem->set_node(0, new_node_a);
1466 new_edge_elem->set_node(1, new_node_b);
1467
1468 mesh.elem_ref(0).subdomain_id() = 10;
1469 mesh.elem_ref(1).subdomain_id() = 10;
1470
1472
1473 // Create an equation systems object.
1474 EquationSystems equation_systems (mesh);
1475
1476 // Set some parameters to the equation system that would cause a failed test
1477 equation_systems.parameters.set<unsigned int>("linear solver maximum iterations") = 0;
1478
1479 // Setup Linear Implicit system
1480 LinearImplicitSystem & li_system =
1481 equation_systems.add_system<LinearImplicitSystem> ("test");
1482
1483 // We must use a discontinuous variable type in this test or
1484 // else the sparsity pattern will not be correct
1485 li_system.add_variable("u", FIRST, L2_LAGRANGE);
1486
1488 5, 5, 5,
1489 0., 1., 0., 1., 0., 1.,
1490 HEX8);
1491
1492 li_system.attach_assemble_function (assembly_with_dg_fem_context);
1493 li_system.get_linear_solver()->set_solver_type(GMRES);
1494 // Need 5 iterations, dont overdo the preconditioning
1495 li_system.get_linear_solver()->set_preconditioner_type(IDENTITY_PRECOND);
1496
1497 // Set some parameters to the system that work for the solve
1498 li_system.parameters.set<unsigned int>("linear solver maximum iterations") = 5;
1499 li_system.parameters.set<Real>("linear solver tolerance") = 1e-100;
1500
1501 // Need to init before we can access the system matrix
1502 equation_systems.init ();
1503
1504 // See the solve pass, indicating system parameters are used over equation system parameters
1505 li_system.solve();
1506
1507 // Check that the number of iterations from the systems got obeyed
1508 CPPUNIT_ASSERT_EQUAL(li_system.n_linear_iterations(), 5u);
1509}
1510
1512 {
1513 LOG_UNIT_TEST;
1514
1516
1518 System &sys = es.add_system<LinearImplicitSystem> ("test");
1519
1520 // We must use a discontinuous variable type in this test or
1521 // else the sparsity pattern will not be correct
1522 sys.add_variable("u", FIRST, L2_LAGRANGE);
1523
1525 5, 5, 5,
1526 0., 1., 0., 1., 0., 1.,
1527 HEX8);
1528
1529 es.init();
1531 sys.solve();
1532
1533 // We don't actually assert anything in this test. We just want to check that
1534 // the assembly and solve do not encounter any errors.
1535 }
1536
1538 {
1539 LOG_UNIT_TEST;
1540
1542
1544 4,
1545 4,
1546 0,
1547 0., 1.,
1548 0., 1.,
1549 0., 0.,
1550 QUAD4);
1551
1552 for (const auto & elem : mesh.element_ptr_range())
1553 {
1554 Point c = elem->vertex_average();
1555 if (c(0) <= 0.5 && c(1) <= 0.5)
1556 elem->subdomain_id() = 0;
1557 else
1558 elem->subdomain_id() = 1;
1559 }
1560
1562
1563 // Create an equation systems object.
1564 EquationSystems equation_systems (mesh);
1565 ExplicitSystem& system =
1566 equation_systems.add_system<LinearImplicitSystem> ("test");
1567
1568 std::set<subdomain_id_type> block0;
1569 std::set<subdomain_id_type> block1;
1570 block0.insert(0);
1571 block1.insert(1);
1572 auto u0 = system.add_variable ("u0", libMesh::FIRST, &block0);
1573 auto u1 = system.add_variable ("u1", libMesh::FIRST, &block1);
1574 equation_systems.init();
1575
1576 std::vector<dof_id_type> u0_dofs;
1577 system.get_dof_map().local_variable_indices(u0_dofs, mesh, u0);
1578 std::vector<dof_id_type> u1_dofs;
1579 system.get_dof_map().local_variable_indices(u1_dofs, mesh, u1);
1580
1581 std::set<dof_id_type> sys_u0_dofs;
1582 system.local_dof_indices(u0, sys_u0_dofs);
1583 std::set<dof_id_type> sys_u1_dofs;
1584 system.local_dof_indices(u1, sys_u1_dofs);
1585
1586 // Get local indices from other processors too
1587 mesh.comm().allgather(u0_dofs);
1588 mesh.comm().allgather(u1_dofs);
1589 mesh.comm().set_union(sys_u0_dofs);
1590 mesh.comm().set_union(sys_u1_dofs);
1591
1592 const std::size_t c9 = 9;
1593 const std::size_t c21 = 21;
1594 CPPUNIT_ASSERT_EQUAL(c9, u0_dofs.size());
1595 CPPUNIT_ASSERT_EQUAL(c21, u1_dofs.size());
1596 CPPUNIT_ASSERT_EQUAL(c9, sys_u0_dofs.size());
1597 CPPUNIT_ASSERT_EQUAL(c21, sys_u1_dofs.size());
1598 }
1599
1600#ifdef LIBMESH_ENABLE_AMR
1601#ifdef LIBMESH_HAVE_METAPHYSICL
1602#ifdef LIBMESH_HAVE_PETSC
1603 void testProjectMatrix1D(const ElemType elem_type)
1604 {
1605 // Use ReplicatedMesh to get consistent child element node
1606 // numbering during refinement
1608
1609 // fix the node numbering to resolve dof_id numbering issues in parallel tests
1610 mesh.allow_renumbering(false);
1611
1612 // init a simple 1d system
1614 System &sys = es.add_system<System> ("SimpleSystem");
1615 sys.add_variable("u", FIRST, LAGRANGE);
1616
1618 4, 0., 1.,
1619 elem_type);
1620
1621 es.init();
1622
1623 // static set of coarse nodes / order of fine grid nodes from x=0 to x=1 going left to right
1624 std::set<dof_id_type> coarse_nodes({0,1,2,3,4});
1625 std::vector<dof_id_type> node_order_f({0,5,1,6,2,7,3,8,4});
1626
1627 // stash number of dofs on coarse grid for projection sizing
1628 int n_old_dofs = sys.n_dofs();
1629
1630 // save old coarse dof_ids in order of coarse nodes
1631 std::map <dof_id_type, dof_id_type> node2dof_c;
1632 for ( const auto & node : mesh.node_ptr_range() )
1633 {
1634 dof_id_type cdof_id = node->dof_number(0,0,0);
1635 node2dof_c.insert( std::pair<dof_id_type,dof_id_type>( node->id() , cdof_id) );
1636 }
1637
1638 // refine the mesh so we can utilize old_dof_indices for projection_matrix
1639 MeshRefinement mr(mesh);
1640 mr.uniformly_refine(1);
1642
1643 // fine node to dof map
1644 std::map <dof_id_type, dof_id_type> node2dof_f;
1645 for ( const auto & node : mesh.local_node_ptr_range() )
1646 {
1647 dof_id_type fdof_id = node->dof_number(0,0,0);
1648 node2dof_f.insert( std::pair<dof_id_type,dof_id_type>(node->id() , fdof_id) );
1649 }
1650
1651 // local and global projection_matrix sizes infos
1652 int n_new_dofs = sys.n_dofs();
1653 int n_new_dofs_local = sys.get_dof_map().n_local_dofs();
1654 int ndofs_old_first = sys.get_dof_map().first_old_dof();
1655 int ndofs_old_end = sys.get_dof_map().end_old_dof();
1656 int n_old_dofs_local = ndofs_old_end - ndofs_old_first;
1657
1658 // init and compute the projection matrix using GenericProjector
1659 std::unique_ptr<SparseMatrix<Number> > proj_mat_ptr =
1661 SparseMatrix<Number> & proj_mat = *proj_mat_ptr;
1662 proj_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1663 sys.projection_matrix(proj_mat);
1664 proj_mat.close();
1665
1666 // init the gold standard projection matrix
1667 std::unique_ptr<SparseMatrix<Number> > gold_mat_ptr =
1669 SparseMatrix<Number> & gold_mat = *gold_mat_ptr;
1670 gold_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1671
1672 // construct the gold projection matrix using static node numbering as reference info
1673 for ( const auto & node : mesh.local_node_ptr_range() )
1674 {
1675 dof_id_type node_id = node->id();
1676 dof_id_type fdof_id = (node2dof_f.find(node_id))->second;
1677
1678 if (coarse_nodes.find(node_id) != coarse_nodes.end() )
1679 { //direct inject coarse nodes
1680 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
1681 {
1682 auto cdof_id = node2dof_c.find(node_id);
1683 gold_mat.set(fdof_id, cdof_id->second, 1.0);
1684 }
1685 }
1686 else
1687 { // new nodes with old_dof neighbor contributions
1688 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
1689 {
1690 auto node_loc = std::find(node_order_f.begin(), node_order_f.end(), node_id);
1691 auto node_n = *std::next(node_loc, 1);
1692 auto node_p = *std::prev(node_loc, 1);
1693 auto dof_p = node2dof_c.find(node_p);
1694 auto dof_n = node2dof_c.find(node_n);
1695
1696 gold_mat.set(fdof_id, dof_p->second, 0.5);
1697 gold_mat.set(fdof_id, dof_n->second, 0.5);
1698 }
1699 }
1700 } // end gold mat build
1701 gold_mat.close();
1702
1703 // calculate relative difference norm between the two projection matrices
1704 Real gold_norm = gold_mat.linfty_norm();
1705 gold_mat.add(-1.0, proj_mat);
1706 Real diff_norm = gold_mat.linfty_norm();
1707 CPPUNIT_ASSERT(diff_norm/gold_norm < TOLERANCE*TOLERANCE);
1708 }
1709
1710 void testProjectMatrix2D(const ElemType elem_type)
1711 {
1712 // Use ReplicatedMesh to get consistent child element node
1713 // numbering during refinement
1715
1716 // fix the node numbering to resolve dof_id numbering issues in parallel tests
1717 mesh.allow_renumbering(false);
1718
1719 // init a simple 1d system
1721 System &sys = es.add_system<System> ("SimpleSystem");
1722 sys.add_variable("u", FIRST, LAGRANGE);
1723
1724 if (elem_type == Utility::string_to_enum<ElemType>("QUAD4"))
1726 2, 2,
1727 0., 1., 0., 1.,
1728 elem_type);
1729 else if (elem_type == Utility::string_to_enum<ElemType>("TRI3"))
1731 1, 1,
1732 0., 1., 0., 1.,
1733 elem_type);
1734
1735 es.init();
1736
1737 // static sets of nodes and their neighbors
1738 std::set<dof_id_type> coarse_nodes;
1739 std::map<dof_id_type, std::vector<dof_id_type>> side_nbr_nodes;
1740 std::map<dof_id_type, std::vector<dof_id_type>> int_nbr_nodes;
1741
1742 // fill neighbor maps based on static node numbering
1743 if (elem_type == Utility::string_to_enum<ElemType>("QUAD4"))
1744 {
1745 coarse_nodes.insert({0,1,2,3,4,5,6,7,8});
1746
1747 side_nbr_nodes.insert({9, {0,1}});
1748 side_nbr_nodes.insert({14, {1,2}});
1749 side_nbr_nodes.insert({11, {0,3}});
1750 side_nbr_nodes.insert({12, {1,4}});
1751 side_nbr_nodes.insert({16, {2,5}});
1752 side_nbr_nodes.insert({13, {3,4}});
1753 side_nbr_nodes.insert({17, {4,5}});
1754 side_nbr_nodes.insert({19, {3,6}});
1755 side_nbr_nodes.insert({20, {4,7}});
1756 side_nbr_nodes.insert({23, {5,8}});
1757 side_nbr_nodes.insert({21, {6,7}});
1758 side_nbr_nodes.insert({24, {7,8}});
1759
1760 int_nbr_nodes.insert({10, {0,1,3,4}});
1761 int_nbr_nodes.insert({15, {1,2,4,5}});
1762 int_nbr_nodes.insert({18, {3,4,6,7}});
1763 int_nbr_nodes.insert({22, {4,5,7,8}});
1764 }
1765 else if (elem_type == Utility::string_to_enum<ElemType>("TRI3"))
1766 {
1767 coarse_nodes.insert({0,1,2,3});
1768
1769 side_nbr_nodes.insert({4, {0,1}});
1770 side_nbr_nodes.insert({5, {0,3}});
1771 side_nbr_nodes.insert({6, {1,3}});
1772 side_nbr_nodes.insert({7, {0,2}});
1773 side_nbr_nodes.insert({8, {2,3}});
1774 }
1775
1776 // stash number of dofs on coarse grid for projection sizing
1777 int n_old_dofs = sys.n_dofs();
1778
1779 // save old coarse dof_ids in order of coarse nodes
1780 std::map <dof_id_type, dof_id_type> node2dof_c;
1781 for ( const auto & node : mesh.node_ptr_range() )
1782 {
1783 dof_id_type cdof_id = node->dof_number(0,0,0);
1784 node2dof_c.insert( std::pair<dof_id_type,dof_id_type>( node->id() , cdof_id) );
1785 }
1786
1787 // refine the mesh so we can utilize old_dof_indices for projection_matrix
1788 MeshRefinement mr(mesh);
1789 mr.uniformly_refine(1);
1791
1792 // fine node to dof map
1793 std::map <dof_id_type, dof_id_type> node2dof_f;
1794 for ( const auto & node : mesh.local_node_ptr_range() )
1795 {
1796 dof_id_type fdof_id = node->dof_number(0,0,0);
1797 node2dof_f.insert( std::pair<dof_id_type,dof_id_type>(node->id() , fdof_id) );
1798 }
1799
1800 // local and global projection_matrix sizes infos
1801 int n_new_dofs = sys.n_dofs();
1802 int n_new_dofs_local = sys.get_dof_map().n_local_dofs();
1803 int ndofs_old_first = sys.get_dof_map().first_old_dof();
1804 int ndofs_old_end = sys.get_dof_map().end_old_dof();
1805 int n_old_dofs_local = ndofs_old_end - ndofs_old_first;
1806
1807 // init and compute the projection matrix using GenericProjector
1808 std::unique_ptr<SparseMatrix<Number> > proj_mat_ptr =
1810 SparseMatrix<Number> & proj_mat = *proj_mat_ptr;
1811 proj_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1812 sys.projection_matrix(proj_mat);
1813 proj_mat.close();
1814
1815 // init the gold standard projection matrix
1816 std::unique_ptr<SparseMatrix<Number> > gold_mat_ptr =
1818 SparseMatrix<Number> & gold_mat = *gold_mat_ptr;
1819 gold_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1820
1821 // construct the gold projection matrix using static node numbering as reference info
1822 for ( const auto & node : mesh.local_node_ptr_range() )
1823 {
1824 dof_id_type node_id = node->id();
1825 dof_id_type fdof_id = (node2dof_f.find(node_id))->second;
1826
1827 if (coarse_nodes.find(node_id) != coarse_nodes.end() )
1828 { // direct inject coarse nodes
1829 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
1830 {
1831 auto cdof_id = node2dof_c.find(node_id);
1832 gold_mat.set(fdof_id, cdof_id->second, 1.0);
1833 }
1834 }
1835 else if ( side_nbr_nodes.find(node_id) != side_nbr_nodes.end() )
1836 { // new side nodes with old_dof neighbor contributions
1837 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
1838 {
1839 auto node_nbrs = side_nbr_nodes.find(node_id);
1840 for (auto nbr : node_nbrs->second)
1841 {
1842 auto nbr_dof = node2dof_c.find(nbr);
1843 gold_mat.set(fdof_id, nbr_dof->second, 0.5);
1844 }
1845 }
1846 }
1847 else
1848 { // new interior nodes with old_dof neighbor contributions
1849 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
1850 {
1851 auto node_nbrs = int_nbr_nodes.find(node_id);
1852 for (auto nbr : node_nbrs->second)
1853 {
1854 auto nbr_dof = node2dof_c.find(nbr);
1855 gold_mat.set(fdof_id, nbr_dof->second, 0.25);
1856 }
1857 }
1858 }
1859 } // end gold mat build
1860 gold_mat.close();
1861
1862 // calculate relative difference norm between the two projection matrices
1863 Real gold_norm = gold_mat.linfty_norm();
1864 proj_mat.add(-1.0, gold_mat);
1865 Real diff_norm = proj_mat.linfty_norm();
1866 CPPUNIT_ASSERT(diff_norm/gold_norm < TOLERANCE*TOLERANCE);
1867 }
1868
1869 void testProjectMatrix3D(const ElemType elem_type)
1870 {
1871 // Use ReplicatedMesh to get consistent child element node
1872 // numbering during refinement
1874
1875 // fix the node numbering to resolve dof_id numbering issues in parallel tests
1876 mesh.allow_renumbering(false);
1877
1878 // init a simple 1d system
1880 System &sys = es.add_system<System> ("SimpleSystem");
1881 sys.add_variable("u", FIRST, LAGRANGE);
1882
1883 if (elem_type == Utility::string_to_enum<ElemType>("HEX8"))
1885 1, 1, 1,
1886 0., 1., 0., 1., 0., 1.,
1887 elem_type);
1888 else if (elem_type == Utility::string_to_enum<ElemType>("TET4"))
1889 {
1890 // manually build a Tet4 element
1891 mesh.add_point( Point(0,0,0), 0 );
1892 mesh.add_point( Point(1,0,0), 1 );
1893 mesh.add_point( Point(0,1,0), 2 );
1894 mesh.add_point( Point(1./3.,1./3.,1), 3 );
1895
1897 elem->set_node(0, mesh.node_ptr(0));
1898 elem->set_node(1, mesh.node_ptr(1));
1899 elem->set_node(2, mesh.node_ptr(2));
1900 elem->set_node(3, mesh.node_ptr(3));
1901
1903 }
1904 es.init();
1905
1906 // static sets of nodes and their neighbors
1907 std::set<dof_id_type> coarse_nodes;
1908 std::map<dof_id_type, std::vector<dof_id_type>> side_nbr_nodes;
1909 std::map<dof_id_type, std::vector<dof_id_type>> face_nbr_nodes;
1910 std::map<dof_id_type, std::vector<dof_id_type>> int_nbr_nodes;
1911
1912 if (elem_type == Utility::string_to_enum<ElemType>("HEX8"))
1913 {
1914 coarse_nodes.insert({0,1,2,3,4,5,6,7});
1915
1916 // fill neighbor maps based on static node numbering
1917 side_nbr_nodes.insert({8, {0,1}});
1918 side_nbr_nodes.insert({10, {0,2}});
1919 side_nbr_nodes.insert({15, {1,3}});
1920 side_nbr_nodes.insert({18, {2,3}});
1921 side_nbr_nodes.insert({11, {0,4}});
1922 side_nbr_nodes.insert({16, {1,5}});
1923 side_nbr_nodes.insert({21, {3,7}});
1924 side_nbr_nodes.insert({20, {2,6}});
1925 side_nbr_nodes.insert({22, {4,5}});
1926 side_nbr_nodes.insert({24, {4,6}});
1927 side_nbr_nodes.insert({25, {5,7}});
1928 side_nbr_nodes.insert({26, {6,7}});
1929
1930 face_nbr_nodes.insert({12, {0,1,4,5}});
1931 face_nbr_nodes.insert({9 , {0,1,2,3}});
1932 face_nbr_nodes.insert({14, {0,2,4,6}});
1933 face_nbr_nodes.insert({17, {1,3,5,7}});
1934 face_nbr_nodes.insert({19, {2,3,6,7}});
1935 face_nbr_nodes.insert({23, {4,5,6,7}});
1936
1937 int_nbr_nodes.insert({13, {0,1,2,3,4,5,6,7}});
1938 }
1939 else if (elem_type == Utility::string_to_enum<ElemType>("TET4"))
1940 {
1941 coarse_nodes.insert({0,1,2,3});
1942
1943 // fill neighbor maps based on static node numbering
1944 side_nbr_nodes.insert({4, {0,1}});
1945 side_nbr_nodes.insert({5, {0,2}});
1946 side_nbr_nodes.insert({6, {0,3}});
1947 side_nbr_nodes.insert({7, {1,2}});
1948 side_nbr_nodes.insert({8, {1,3}});
1949 side_nbr_nodes.insert({9, {2,3}});
1950 }
1951
1952 // stash number of dofs on coarse grid for projection sizing
1953 int n_old_dofs = sys.n_dofs();
1954
1955 // save old coarse dof_ids in order of coarse nodes
1956 std::map <dof_id_type, dof_id_type> node2dof_c;
1957 for ( const auto & node : mesh.node_ptr_range() )
1958 {
1959 dof_id_type cdof_id = node->dof_number(0,0,0);
1960 node2dof_c.insert( std::pair<dof_id_type,dof_id_type>( node->id() , cdof_id) );
1961 }
1962
1963 // refine the mesh so we can utilize old_dof_indices for projection_matrix
1964 MeshRefinement mr(mesh);
1965 mr.uniformly_refine(1);
1967
1968 // fine node to dof map
1969 std::map <dof_id_type, dof_id_type> node2dof_f;
1970 for ( const auto & node : mesh.local_node_ptr_range() )
1971 {
1972 dof_id_type fdof_id = node->dof_number(0,0,0);
1973 node2dof_f.insert( std::pair<dof_id_type,dof_id_type>(node->id() , fdof_id) );
1974 }
1975
1976 // local and global projection_matrix sizes infos
1977 int n_new_dofs = sys.n_dofs();
1978 int n_new_dofs_local = sys.get_dof_map().n_dofs_on_processor(sys.processor_id());
1979 int ndofs_old_first = sys.get_dof_map().first_old_dof(sys.processor_id());
1980 int ndofs_old_end = sys.get_dof_map().end_old_dof(sys.processor_id());
1981 int n_old_dofs_local = ndofs_old_end - ndofs_old_first;
1982
1983 // init and compute the projection matrix using GenericProjector
1984 std::unique_ptr<SparseMatrix<Number> > proj_mat_ptr =
1986 SparseMatrix<Number> & proj_mat = *proj_mat_ptr;
1987 proj_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1988 sys.projection_matrix(proj_mat);
1989 proj_mat.close();
1990
1991 // init the gold standard projection matrix
1992 std::unique_ptr<SparseMatrix<Number> > gold_mat_ptr =
1994 SparseMatrix<Number> & gold_mat = *gold_mat_ptr;
1995 gold_mat.init(n_new_dofs, n_old_dofs, n_new_dofs_local, n_old_dofs_local);
1996
1997 // construct the gold projection matrix using static node numbering as reference info
1998 for ( const auto & node : mesh.local_node_ptr_range() )
1999 {
2000 dof_id_type node_id = node->id();
2001 dof_id_type fdof_id = (node2dof_f.find(node_id))->second;
2002
2003 if (coarse_nodes.find(node_id) != coarse_nodes.end() )
2004 { // direct inject coarse nodes
2005 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
2006 {
2007 auto cdof_id = node2dof_c.find(node_id);
2008 gold_mat.set(fdof_id, cdof_id->second, 1.0);
2009 }
2010 }
2011 else if ( side_nbr_nodes.find(node_id) != side_nbr_nodes.end() )
2012 { // new side nodes with old_dof neighbor contributions
2013 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
2014 {
2015 auto node_nbrs = side_nbr_nodes.find(node_id);
2016 for (auto nbr : node_nbrs->second)
2017 {
2018 auto nbr_dof = node2dof_c.find(nbr);
2019 gold_mat.set(fdof_id, nbr_dof->second, 0.5);
2020 }
2021 }
2022 }
2023 else if ( face_nbr_nodes.find(node_id) != face_nbr_nodes.end() )
2024 { // new face nodes with old_dof neighbor contributions
2025 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
2026 {
2027 auto node_nbrs = face_nbr_nodes.find(node_id);
2028 for (auto nbr : node_nbrs->second)
2029 {
2030 auto nbr_dof = node2dof_c.find(nbr);
2031 gold_mat.set(fdof_id, nbr_dof->second, 0.25);
2032 }
2033 }
2034 }
2035 else
2036 { // new interior nodes with old_dof neighbor contributions
2037 if (fdof_id >= gold_mat.row_start() && fdof_id < gold_mat.row_stop())
2038 {
2039 auto node_nbrs = int_nbr_nodes.find(node_id);
2040 for (auto nbr : node_nbrs->second)
2041 {
2042 auto nbr_dof = node2dof_c.find(nbr);
2043 gold_mat.set(fdof_id, nbr_dof->second, 0.125);
2044 }
2045 }
2046 }
2047 } // end gold mat build
2048 gold_mat.close();
2049
2050 // calculate relative difference norm between the two projection matrices
2051 Real gold_norm = gold_mat.linfty_norm();
2052 proj_mat.add(-1.0, gold_mat);
2053 Real diff_norm = proj_mat.linfty_norm();
2054 CPPUNIT_ASSERT(diff_norm/gold_norm < TOLERANCE*TOLERANCE);
2055 }
2056#endif // LIBMESH_HAVE_PETSC
2057#endif // LIBMESH_HAVE_METAPHYSICL
2058#endif // LIBMESH_ENABLE_AMR
2059
2060
2079
2080#ifdef LIBMESH_ENABLE_AMR
2081#ifdef LIBMESH_HAVE_METAPHYSICL
2082#ifdef LIBMESH_HAVE_PETSC
2083 // projection matrix tests
2089#endif // LIBMESH_HAVE_PETSC
2090#endif // LIBMESH_HAVE_METAPHYSICL
2091#endif // LIBMESH_ENABLE_AMR
2092
2093};
2094
MeshBase & _mesh
The Mesh we're calculating on.
virtual void mesh_reinit() override
Rebuild the cached _lower_to_upper map whenever our Mesh has changed.
virtual std::unique_ptr< GhostingFunctor > clone() const override
A clone() is needed because GhostingFunctor can not be shared between different meshes.
virtual void operator()(const MeshBase::const_element_iterator &range_begin, const MeshBase::const_element_iterator &range_end, processor_id_type p, map_type &coupled_elements) override
User-defined function to augment the sparsity pattern.
AugmentSparsityOnNodes(MeshBase &mesh)
Constructor.
virtual void redistribute() override
Update the cached _lower_to_upper map whenever our Mesh has been redistributed.
void test3DProjectVectorFEHex20()
CPPUNIT_TEST(test3DProjectVectorFETet10)
void test2DProjectVectorFE(const ElemType elem_type)
CPPUNIT_TEST(testAddVectorProjChange)
void testProjectHierarchicEdge3()
void tripleValueTest(const Point &p, const TransientExplicitSystem &sys, const PointLocatorBase &locator, std::set< subdomain_id_type > &u_subdomains, std::set< subdomain_id_type > &v_subdomains, std::set< subdomain_id_type > &w_subdomains, const Parameters &param)
void testProjectMeshFunctionHex27()
void test100KVariables()
CPPUNIT_TEST(test3DProjectVectorFETet14)
CPPUNIT_TEST(testPetscOptionsPrefix)
void testProjectScalarCoarsening()
CPPUNIT_TEST(testFirstScalarNumber)
CPPUNIT_TEST(testBoundaryProjectCube)
void testAddVectorProjChange()
void testProjectMatrixTri3()
void testAddVectorTypeChange()
void testProjectSquare(const ElemType elem_type)
CPPUNIT_TEST(test2DProjectVectorFETri3)
void testBlockRestrictedVarNDofs()
void testDofCouplingWithVarGroups()
CPPUNIT_TEST(test3DProjectVectorFETet4)
void testAssemblyWithDgFemContext()
void testProjectMatrix3D(const ElemType elem_type)
void testProjectHierarchicQuad9()
CPPUNIT_TEST(testAssemblyWithDgFemContext)
void testProjectMatrixQuad4()
CPPUNIT_TEST(testProjectMatrixTri3)
CPPUNIT_TEST(testProjectHierarchicHex27)
void testProjectCubeWithMeshFunction(const ElemType elem_type)
void testProjectMatrix2D(const ElemType elem_type)
void test3DProjectVectorFEHex27()
void testProjectMatrix1D(const ElemType elem_type)
CPPUNIT_TEST(testProjectMatrixEdge2)
ExplicitSystem & simpleSetup(UnstructuredMesh &mesh, EquationSystems &es)
CPPUNIT_TEST(test3DProjectVectorFEHex20)
void testFirstScalarNumber()
void test2DProjectVectorFETri6()
CPPUNIT_TEST(testBlockRestrictedVarNDofs)
void test3DProjectVectorFE(const ElemType elem_type)
CPPUNIT_TEST(test2DProjectVectorFEQuad8)
CPPUNIT_TEST(test3DProjectVectorFEHex8)
void testPostInitAddVectorTypeChange()
CPPUNIT_TEST(testProjectHierarchicQuad9)
void testProjectHierarchicTri6()
void testUninitializedInfo()
CPPUNIT_TEST(test2DProjectVectorFEQuad4)
CPPUNIT_TEST(testPostInitAddVectorTypeChange)
void testProjectLine(const ElemType elem_type)
CPPUNIT_TEST(test2DProjectVectorFEQuad9)
void testPetscOptionsPrefix()
void test3DProjectVectorFETet10()
void tearDown()
void testProjectHierarchicHex27()
LIBMESH_CPPUNIT_TEST_SUITE(SystemsTest)
CPPUNIT_TEST(testProjectMeshFunctionHex27)
CPPUNIT_TEST(testProjectMatrixHex8)
void test2DProjectVectorFEQuad4()
void testProjectMatrixHex8()
CPPUNIT_TEST(testPostInitAddVector)
CPPUNIT_TEST_SUITE_END()
CPPUNIT_TEST(testProjectScalarCoarsening)
void test3DProjectVectorFETet14()
CPPUNIT_TEST(testProjectHierarchicTri6)
CPPUNIT_TEST(testSetSystemParameterOverEquationSystem)
CPPUNIT_TEST(testAddVectorTypeChange)
CPPUNIT_TEST(test2DProjectVectorFETri6)
CPPUNIT_TEST(testProjectMatrixTet4)
void testBoundaryProjectCube()
void testProjectHierarchicTri7()
void test2DProjectVectorFETri3()
CPPUNIT_TEST(testProjectMatrixQuad4)
CPPUNIT_TEST(testUninitializedInfo)
CPPUNIT_TEST(testDofCouplingWithVarGroups)
void testSetSystemParameterOverEquationSystem()
void test2DProjectVectorFEQuad8()
void test3DProjectVectorFEHex8()
void test2DProjectVectorFEQuad9()
CPPUNIT_TEST(testProjectHierarchicEdge3)
void testProjectMatrixEdge2()
CPPUNIT_TEST(testProjectHierarchicTri7)
void testProjectMatrixTet4()
CPPUNIT_TEST(test2DProjectVectorFETri7)
CPPUNIT_TEST(test3DProjectVectorFEHex27)
void test2DProjectVectorFETri7()
CPPUNIT_TEST(test100KVariables)
void test3DProjectVectorFETet4()
void testPostInitAddVector()
void testProjectCube(const ElemType elem_type)
void set_union(T &data, const unsigned int root_id) const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure.
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
void boundary_ids(const Node *node, std::vector< boundary_id_type > &vec_to_fill) const
Fills a user-provided std::vector with the boundary ids associated with Node node.
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
This class defines a coupling matrix.
This class extends FEMContext in order to provide extra data required to perform local element residu...
void set_neighbor(const Elem &neighbor)
Set the neighbor element which we will use to assemble DG terms.
const std::vector< dof_id_type > & get_neighbor_dof_indices() const
Accessor for neighbor dof indices.
virtual void side_fe_reinit() override
Override side_fe_reinit to set a boolean flag so that by default DG terms are assumed to be inactive.
void get_neighbor_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for neighbor edge/face (2D/3D) finite element object for variable var.
const DenseMatrix< Number > & get_neighbor_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseMatrix< Number > & get_elem_elem_jacobian() const
Const accessor for element-element Jacobian.
void neighbor_side_fe_reinit()
Initialize neighbor side data needed to assemble DG terms.
const DenseMatrix< Number > & get_neighbor_elem_jacobian() const
Const accessor for element-neighbor Jacobian.
const DenseMatrix< Number > & get_elem_neighbor_jacobian() const
Const accessor for element-neighbor Jacobian.
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual unsigned int size() const override final
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
dof_id_type end_old_dof(const processor_id_type proc) const
dof_id_type first_old_dof(const processor_id_type proc) const
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
std::size_t distribute_dofs(MeshBase &)
Distribute dofs on the current mesh.
Definition dof_map.C:974
std::vector< dof_id_type > n_dofs_per_processor(const unsigned int vn) const
Definition dof_map.h:812
dof_id_type n_local_dofs(const unsigned int vn) const
Definition dof_map.h:801
void SCALAR_dof_indices(std::vector< dof_id_type > &di, const unsigned int vn, const bool old_dofs=false) const
Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn...
Definition dof_map.C:2635
dof_id_type n_dofs(const unsigned int vn) const
Definition dof_map.h:783
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
Definition dof_map.C:2035
void local_variable_indices(T &idx, const MeshBase &mesh, unsigned int var_num) const
If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices w...
Definition dof_map.C:1152
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
processor_id_type processor_id() const
Definition dof_object.h:895
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2688
static std::unique_ptr< Elem > build_with_id(const ElemType type, dof_id_type id)
Calls the build() method above with a nullptr parent, and additionally sets the newly-created Elem's ...
Definition elem.C:496
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
subdomain_id_type subdomain_id() const
Definition elem.h:2712
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
Definition elem.h:649
const Node * node_ptr(const unsigned int i) const
Definition elem.h:2637
static const Order type_to_default_order_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the default approximation order of...
Definition elem.h:1089
virtual ElemType type() const =0
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2736
This is the EquationSystems class.
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
const MeshBase & get_mesh() const
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 T_sys & get_system(std::string_view name) const
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
NumericVector< Number > * rhs
The system matrix.
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class forms the foundation from which generic finite elements may be derived.
Definition fe_base.h:86
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition fe_base.h:207
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition fe_base.h:252
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
unsigned char side
Current side for side_* to examine.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
unsigned char get_side() const
Accessor for current side of Elem object.
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
Base class for functors that can be evaluated at a point and (optionally) time.
This abstract base class defines the interface by which library code and user code can report associa...
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
const SparseMatrix< Number > & get_system_matrix() const
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
virtual LinearSolver< Number > * get_linear_solver() const override
virtual void solve() override
Assembles & solves the linear system A*x=b.
void set_preconditioner_type(const PreconditionerType pct)
Sets the type of preconditioner to use.
void set_solver_type(const SolverType st)
Sets the type of solver to use.
This is the MeshBase class.
Definition mesh_base.h:81
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:750
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:178
virtual const Node * node_ptr(const dof_id_type i) const =0
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
Definition mesh_base.h:1367
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:901
virtual dof_id_type n_nodes() const =0
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:793
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1952
This class provides function-like objects for data distributed over a mesh.
virtual void init() override
Override the FunctionBase::init() member function.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
bool refine_elements()
Only refines the user-requested elements.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
A Node is like a Point, but with more information.
Definition node.h:55
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual numeric_index_type last_local_index() const =0
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
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...
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
virtual numeric_index_type first_local_index() const =0
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
T & set(const std::string &)
Definition parameters.h:494
This class provides a nice interface to the PETSc C-based AIJ data structures for parallel,...
This class provides a nice interface to PETSc's Vec object.
This is the base class for point locators.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
unsigned int n_points() const
Definition quadrature.h:131
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
Generic sparse matrix.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
virtual numeric_index_type row_stop() const =0
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
virtual numeric_index_type row_start() const =0
virtual Real linfty_norm() const =0
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
Definition system.C:1038
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.
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
Definition system.C:1167
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:1679
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition system.C:2759
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:1459
std::string get_info() const
Definition system.C:1882
dof_id_type n_dofs() const
Definition system.C:120
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2274
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in assembling the system matrix and RHS.
Definition system.C:2014
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:1400
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition system.C:794
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable ...
Definition system.C:1465
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1667
virtual void solve()
Solves the system.
Definition system.h:361
bool vector_preservation(std::string_view vec_name) const
Definition system.C:1191
unsigned int variable_number(std::string_view var) const
Definition system.C:1454
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
Definition system.C:1422
void projection_matrix(SparseMatrix< Number > &proj_mat) const
This method creates a projection matrix which corresponds to the operation of project_vector between ...
unsigned int n_vars() const
Definition system.C:2729
const DofMap & get_dof_map() const
Definition system.h:2448
void set_options_prefix(std::string options_prefix)
Sets the solver-package options prefix of every vector and matrix this system owns,...
Definition system.C:1117
unsigned int number() const
Definition system.h:2424
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition system.C:971
Manages storage and variables for transient systems.
NumericVector< Number > * older_local_solution
All the values I need to compute my contribution to the simulation at hand.
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
The UnstructuredMesh class is derived from the MeshBase class.
ConstFunction that simply returns 0.
Communicator * TestCommWorld
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.
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.
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.
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Tnew cast_ref(Told &oldvar)
ElemType
Defines an enum for geometric element types.
int8_t boundary_id_type
Definition id_types.h:51
SolverPackage default_solver_package()
Definition libmesh.C:1064
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176
virtual std::unique_ptr< FunctionBase< Number > > clone() const
Number component(unsigned int i, const Point &p, Real) override
TripleFunction(Number _offset=0)
virtual Number operator()(const Point &, const Real=0.) override
The definition of the const_element_iterator struct.
Definition mesh_base.h:2726
void assembly_with_dg_fem_context(EquationSystems &es, const std::string &)
Number disc_thirds_test(const Point &p, const Parameters &, const std::string &, const std::string &)
CPPUNIT_TEST_SUITE_REGISTRATION(SystemsTest)
void assemble_matrix_and_rhs(EquationSystems &es, const std::string &)
Number cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Number new_linear_test(const Point &p, const Parameters &, const std::string &, const std::string &)
static const bool value
Definition xdr_io.C:55