libMesh
system.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // C++ includes
21 #include <sstream> // for std::ostringstream
22 
23 // Local includes
24 #include "libmesh/dof_map.h"
25 #include "libmesh/equation_systems.h"
26 #include "libmesh/int_range.h"
27 #include "libmesh/libmesh_logging.h"
28 #include "libmesh/mesh_base.h"
29 #include "libmesh/numeric_vector.h"
30 #include "libmesh/parameter_vector.h"
31 #include "libmesh/point.h" // For point_value
32 #include "libmesh/point_locator_base.h" // For point_value
33 #include "libmesh/qoi_set.h"
34 #include "libmesh/enum_to_string.h"
35 #include "libmesh/system.h"
36 #include "libmesh/system_norm.h"
37 #include "libmesh/utility.h"
38 #include "libmesh/elem.h"
39 #include "libmesh/fe_type.h"
40 #include "libmesh/fe_interface.h"
41 #include "libmesh/fe_compute_data.h"
42 #include "libmesh/auto_ptr.h" // libmesh_make_unique
43 
44 // includes for calculate_norm, point_*
45 #include "libmesh/fe_base.h"
46 #include "libmesh/fe_interface.h"
47 #include "libmesh/parallel.h"
48 #include "libmesh/parallel_algebra.h"
49 #include "libmesh/quadrature.h"
50 #include "libmesh/tensor_value.h"
51 #include "libmesh/vector_value.h"
52 #include "libmesh/tensor_tools.h"
53 #include "libmesh/enum_norm_type.h"
54 
55 namespace libMesh
56 {
57 
58 
59 // ------------------------------------------------------------
60 // System implementation
62  const std::string & name_in,
63  const unsigned int number_in) :
64 
65  ParallelObject (es),
66  assemble_before_solve (true),
67  use_fixed_solution (false),
68  extra_quadrature_order (0),
69  solution (NumericVector<Number>::build(this->comm())),
70  current_local_solution (NumericVector<Number>::build(this->comm())),
71  time (0.),
72  qoi (0),
73  _init_system_function (nullptr),
74  _init_system_object (nullptr),
75  _assemble_system_function (nullptr),
76  _assemble_system_object (nullptr),
77  _constrain_system_function (nullptr),
78  _constrain_system_object (nullptr),
79  _qoi_evaluate_function (nullptr),
80  _qoi_evaluate_object (nullptr),
81  _qoi_evaluate_derivative_function (nullptr),
82  _qoi_evaluate_derivative_object (nullptr),
83  _dof_map (libmesh_make_unique<DofMap>(number_in, es.get_mesh())),
84  _equation_systems (es),
85  _mesh (es.get_mesh()),
86  _sys_name (name_in),
87  _sys_number (number_in),
88  _active (true),
89  _solution_projection (true),
90  _basic_system_only (false),
91  _is_initialized (false),
92  _identify_variable_groups (true),
93  _additional_data_written (false),
94  adjoint_already_solved (false),
95  _hide_output (false)
96 {
97 }
98 
99 
100 
101 // No copy construction of System objects!
102 System::System (const System & other) :
104  ParallelObject(other),
105  _equation_systems(other._equation_systems),
106  _mesh(other._mesh),
107  _sys_number(other._sys_number)
108 {
109  libmesh_not_implemented();
110 }
111 
112 
113 
115 {
116  libmesh_not_implemented();
117 }
118 
119 
121 {
122  // Null-out the function pointers. Since this
123  // class is getting destructed it is pointless,
124  // but a good habit.
127  _constrain_system_function = nullptr;
128 
129  _qoi_evaluate_function = nullptr;
131 
132  // nullptr-out user-provided objects.
133  _init_system_object = nullptr;
134  _assemble_system_object = nullptr;
135  _constrain_system_object = nullptr;
136  _qoi_evaluate_object = nullptr;
138 
139  // Clear data
140  // Note: although clear() is virtual, C++ only calls
141  // the clear() of the base class in the destructor.
142  // Thus we add System namespace to make it clear.
143  System::clear ();
144 
145  libmesh_exceptionless_assert (!libMesh::closed());
146 }
147 
148 
149 
151 {
152  return _dof_map->n_dofs();
153 }
154 
155 
156 
158 {
159 #ifdef LIBMESH_ENABLE_CONSTRAINTS
160 
161  return _dof_map->n_constrained_dofs();
162 
163 #else
164 
165  return 0;
166 
167 #endif
168 }
169 
170 
171 
173 {
174 #ifdef LIBMESH_ENABLE_CONSTRAINTS
175 
176  return _dof_map->n_local_constrained_dofs();
177 
178 #else
179 
180  return 0;
181 
182 #endif
183 }
184 
185 
186 
188 {
189  return _dof_map->n_dofs_on_processor (this->processor_id());
190 }
191 
192 
193 
194 Number System::current_solution (const dof_id_type global_dof_number) const
195 {
196  // Check the sizes
197  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
198  libmesh_assert_less (global_dof_number, current_local_solution->size());
199 
200  return (*current_local_solution)(global_dof_number);
201 }
202 
203 
204 
206 {
207  _variables.clear();
208 
209  _variable_numbers.clear();
210 
211  _dof_map->clear ();
212 
213  solution->clear ();
214 
215  current_local_solution->clear ();
216 
217  // clear any user-added vectors
218  {
219  for (auto & pr : _vectors)
220  {
221  pr.second->clear ();
222  delete pr.second;
223  pr.second = nullptr;
224  }
225 
226  _vectors.clear();
227  _vector_projections.clear();
228  _vector_is_adjoint.clear();
229  _vector_types.clear();
230  _is_initialized = false;
231  }
232 
233 }
234 
235 
236 
238 {
239  // Calling init() twice on the same system currently works evil
240  // magic, whether done directly or via EquationSystems::read()
241  libmesh_assert(!this->is_initialized());
242 
243  // First initialize any required data:
244  // either only the basic System data
245  if (_basic_system_only)
247  // or all the derived class' data too
248  else
249  this->init_data();
250 
251  // If no variables have been added to this system
252  // don't do anything
253  if (!this->n_vars())
254  return;
255 
256  // Then call the user-provided initialization function
257  this->user_initialization();
258 }
259 
260 
261 
263 {
264  MeshBase & mesh = this->get_mesh();
265 
266  // Add all variable groups to our underlying DofMap
267  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
268  _dof_map->add_variable_group(this->variable_group(vg));
269 
270  // Distribute the degrees of freedom on the mesh
271  _dof_map->distribute_dofs (mesh);
272 
273  // Recreate any user or internal constraints
274  this->reinit_constraints();
275 
276  // And clean up the send_list before we first use it
277  _dof_map->prepare_send_list();
278 
279  // Resize the solution conformal to the current mesh
280  solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
281 
282  // Resize the current_local_solution for the current mesh
283 #ifdef LIBMESH_ENABLE_GHOSTED
284  current_local_solution->init (this->n_dofs(), this->n_local_dofs(),
285  _dof_map->get_send_list(), false,
286  GHOSTED);
287 #else
288  current_local_solution->init (this->n_dofs(), false, SERIAL);
289 #endif
290 
291  // from now on, adding additional vectors or variables can't be done
292  // without immediately initializing them
293  _is_initialized = true;
294 
295  // initialize & zero other vectors, if necessary
296  for (auto & pr : _vectors)
297  {
298  ParallelType type = _vector_types[pr.first];
299 
300  if (type == GHOSTED)
301  {
302 #ifdef LIBMESH_ENABLE_GHOSTED
303  pr.second->init (this->n_dofs(), this->n_local_dofs(),
304  _dof_map->get_send_list(), false,
305  GHOSTED);
306 #else
307  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
308 #endif
309  }
310  else if (type == SERIAL)
311  {
312  pr.second->init (this->n_dofs(), false, type);
313  }
314  else
315  {
316  libmesh_assert_equal_to(type, PARALLEL);
317  pr.second->init (this->n_dofs(), this->n_local_dofs(), false, type);
318  }
319  }
320 }
321 
322 
323 
325 {
326 #ifdef LIBMESH_ENABLE_AMR
327  // Restrict the _vectors on the coarsened cells
328  for (auto & pr : _vectors)
329  {
330  NumericVector<Number> * v = pr.second;
331 
332  if (_vector_projections[pr.first])
333  {
334  this->project_vector (*v, this->vector_is_adjoint(pr.first));
335  }
336  else
337  {
338  ParallelType type = _vector_types[pr.first];
339 
340  if (type == GHOSTED)
341  {
342 #ifdef LIBMESH_ENABLE_GHOSTED
343  pr.second->init (this->n_dofs(), this->n_local_dofs(),
344  _dof_map->get_send_list(), false,
345  GHOSTED);
346 #else
347  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
348 #endif
349  }
350  else
351  pr.second->init (this->n_dofs(), this->n_local_dofs(), false, type);
352  }
353  }
354 
355  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
356 
357  // Restrict the solution on the coarsened cells
359  this->project_vector (*solution);
360  // Or at least make sure the solution vector is the correct size
361  else
362  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
363 
364 #ifdef LIBMESH_ENABLE_GHOSTED
365  current_local_solution->init(this->n_dofs(),
366  this->n_local_dofs(), send_list,
367  false, GHOSTED);
368 #else
369  current_local_solution->init(this->n_dofs());
370 #endif
371 
373  solution->localize (*current_local_solution, send_list);
374 
375 #endif // LIBMESH_ENABLE_AMR
376 }
377 
378 
379 
381 {
382 #ifdef LIBMESH_ENABLE_AMR
383  // Currently project_vector handles both restriction and prolongation
384  this->restrict_vectors();
385 #endif
386 }
387 
388 
389 
391 {
392  // project_vector handles vector initialization now
393  libmesh_assert_equal_to (solution->size(), current_local_solution->size());
394 }
395 
396 
398 {
399 #ifdef LIBMESH_ENABLE_CONSTRAINTS
401  user_constrain();
403 #endif
405 }
406 
407 
409 {
410  libmesh_assert(solution->closed());
411 
412  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
413 
414  // Check sizes
415  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
416  // More processors than elements => empty send_list
417  // libmesh_assert (!send_list.empty());
418  libmesh_assert_less_equal (send_list.size(), solution->size());
419 
420  // Create current_local_solution from solution. This will
421  // put a local copy of solution into current_local_solution.
422  // Only the necessary values (specified by the send_list)
423  // are copied to minimize communication
424  solution->localize (*current_local_solution, send_list);
425 }
426 
427 
428 
430 {
431  parallel_object_only();
432 
433  // If this system is empty... don't do anything!
434  if (!this->n_vars())
435  return;
436 
437  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
438 
439  // Check sizes
440  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
441  // Not true with ghosted vectors
442  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
443  // libmesh_assert (!send_list.empty());
444  libmesh_assert_less_equal (send_list.size(), solution->size());
445 
446  // Create current_local_solution from solution. This will
447  // put a local copy of solution into current_local_solution.
448  solution->localize (*current_local_solution, send_list);
449 }
450 
451 
452 
454  const SubsetSolveMode /*subset_solve_mode*/)
455 {
456  if (subset != nullptr)
457  libmesh_not_implemented();
458 }
459 
460 
461 
463 {
464  // Log how long the user's assembly code takes
465  LOG_SCOPE("assemble()", "System");
466 
467  // Call the user-specified assembly function
468  this->user_assembly();
469 }
470 
471 
472 
473 void System::assemble_qoi (const QoISet & qoi_indices)
474 {
475  // Log how long the user's assembly code takes
476  LOG_SCOPE("assemble_qoi()", "System");
477 
478  // Call the user-specified quantity of interest function
479  this->user_QOI(qoi_indices);
480 }
481 
482 
483 
484 void System::assemble_qoi_derivative(const QoISet & qoi_indices,
485  bool include_liftfunc,
486  bool apply_constraints)
487 {
488  // Log how long the user's assembly code takes
489  LOG_SCOPE("assemble_qoi_derivative()", "System");
490 
491  // Call the user-specified quantity of interest function
492  this->user_QOI_derivative(qoi_indices, include_liftfunc,
493  apply_constraints);
494 }
495 
496 
497 
498 void System::qoi_parameter_sensitivity (const QoISet & qoi_indices,
499  const ParameterVector & parameters,
500  SensitivityData & sensitivities)
501 {
502  // Forward sensitivities are more efficient for Nq > Np
503  if (qoi_indices.size(*this) > parameters.size())
504  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
505  // Adjoint sensitivities are more efficient for Np > Nq,
506  // and an adjoint may be more reusable than a forward
507  // solution sensitivity in the Np == Nq case.
508  else
509  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
510 }
511 
512 
513 
514 bool System::compare (const System & other_system,
515  const Real threshold,
516  const bool verbose) const
517 {
518  // we do not care for matrices, but for vectors
520  libmesh_assert (other_system._is_initialized);
521 
522  if (verbose)
523  {
524  libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
525  libMesh::out << " comparing matrices not supported." << std::endl;
526  libMesh::out << " comparing names...";
527  }
528 
529  // compare the name: 0 means identical
530  const int name_result = _sys_name.compare(other_system.name());
531  if (verbose)
532  {
533  if (name_result == 0)
534  libMesh::out << " identical." << std::endl;
535  else
536  libMesh::out << " names not identical." << std::endl;
537  libMesh::out << " comparing solution vector...";
538  }
539 
540 
541  // compare the solution: -1 means identical
542  const int solu_result = solution->compare (*other_system.solution.get(),
543  threshold);
544 
545  if (verbose)
546  {
547  if (solu_result == -1)
548  libMesh::out << " identical up to threshold." << std::endl;
549  else
550  libMesh::out << " first difference occurred at index = "
551  << solu_result << "." << std::endl;
552  }
553 
554 
555  // safety check, whether we handle at least the same number
556  // of vectors
557  std::vector<int> ov_result;
558 
559  if (this->n_vectors() != other_system.n_vectors())
560  {
561  if (verbose)
562  {
563  libMesh::out << " Fatal difference. This system handles "
564  << this->n_vectors() << " add'l vectors," << std::endl
565  << " while the other system handles "
566  << other_system.n_vectors()
567  << " add'l vectors." << std::endl
568  << " Aborting comparison." << std::endl;
569  }
570  return false;
571  }
572  else if (this->n_vectors() == 0)
573  {
574  // there are no additional vectors...
575  ov_result.clear ();
576  }
577  else
578  {
579  // compare other vectors
580  for (auto & pr : _vectors)
581  {
582  if (verbose)
583  libMesh::out << " comparing vector \""
584  << pr.first << "\" ...";
585 
586  // assume they have the same name
587  const NumericVector<Number> & other_system_vector =
588  other_system.get_vector(pr.first);
589 
590  ov_result.push_back(pr.second->compare (other_system_vector,
591  threshold));
592 
593  if (verbose)
594  {
595  if (ov_result[ov_result.size()-1] == -1)
596  libMesh::out << " identical up to threshold." << std::endl;
597  else
598  libMesh::out << " first difference occurred at" << std::endl
599  << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
600  }
601  }
602  } // finished comparing additional vectors
603 
604 
605  bool overall_result;
606 
607  // sum up the results
608  if ((name_result==0) && (solu_result==-1))
609  {
610  if (ov_result.size()==0)
611  overall_result = true;
612  else
613  {
614  bool ov_identical;
615  unsigned int n = 0;
616  do
617  {
618  ov_identical = (ov_result[n]==-1);
619  n++;
620  }
621  while (ov_identical && n<ov_result.size());
622  overall_result = ov_identical;
623  }
624  }
625  else
626  overall_result = false;
627 
628  if (verbose)
629  {
630  libMesh::out << " finished comparisons, ";
631  if (overall_result)
632  libMesh::out << "found no differences." << std::endl << std::endl;
633  else
634  libMesh::out << "found differences." << std::endl << std::endl;
635  }
636 
637  return overall_result;
638 }
639 
640 
641 
642 void System::update_global_solution (std::vector<Number> & global_soln) const
643 {
644  global_soln.resize (solution->size());
645 
646  solution->localize (global_soln);
647 }
648 
649 
650 
651 void System::update_global_solution (std::vector<Number> & global_soln,
652  const processor_id_type dest_proc) const
653 {
654  global_soln.resize (solution->size());
655 
656  solution->localize_to_one (global_soln, dest_proc);
657 }
658 
659 
660 
661 NumericVector<Number> & System::add_vector (const std::string & vec_name,
662  const bool projections,
663  const ParallelType type)
664 {
665  // Return the vector if it is already there.
666  if (this->have_vector(vec_name))
667  return *(_vectors[vec_name]);
668 
669  // Otherwise build the vector
670  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
671  _vectors.insert (std::make_pair (vec_name, buf));
672  _vector_projections.insert (std::make_pair (vec_name, projections));
673 
674  _vector_types.insert (std::make_pair (vec_name, type));
675 
676  // Vectors are primal by default
677  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
678 
679  // Initialize it if necessary
680  if (_is_initialized)
681  {
682  if (type == GHOSTED)
683  {
684 #ifdef LIBMESH_ENABLE_GHOSTED
685  buf->init (this->n_dofs(), this->n_local_dofs(),
686  _dof_map->get_send_list(), false,
687  GHOSTED);
688 #else
689  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
690 #endif
691  }
692  else
693  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
694  }
695 
696  return *buf;
697 }
698 
699 void System::remove_vector (const std::string & vec_name)
700 {
701  vectors_iterator pos = _vectors.find(vec_name);
702 
703  //Return if the vector does not exist
704  if (pos == _vectors.end())
705  return;
706 
707  delete pos->second;
708 
709  _vectors.erase(pos);
710 
711  _vector_projections.erase(vec_name);
712  _vector_is_adjoint.erase(vec_name);
713  _vector_types.erase(vec_name);
714 }
715 
716 const NumericVector<Number> * System::request_vector (const std::string & vec_name) const
717 {
718  const_vectors_iterator pos = _vectors.find(vec_name);
719 
720  if (pos == _vectors.end())
721  return nullptr;
722 
723  return pos->second;
724 }
725 
726 
727 
728 NumericVector<Number> * System::request_vector (const std::string & vec_name)
729 {
730  vectors_iterator pos = _vectors.find(vec_name);
731 
732  if (pos == _vectors.end())
733  return nullptr;
734 
735  return pos->second;
736 }
737 
738 
739 
740 const NumericVector<Number> * System::request_vector (const unsigned int vec_num) const
741 {
744  unsigned int num = 0;
745  while ((num<vec_num) && (v!=v_end))
746  {
747  num++;
748  ++v;
749  }
750  if (v==v_end)
751  return nullptr;
752  return v->second;
753 }
754 
755 
756 
757 NumericVector<Number> * System::request_vector (const unsigned int vec_num)
758 {
760  vectors_iterator v_end = vectors_end();
761  unsigned int num = 0;
762  while ((num<vec_num) && (v!=v_end))
763  {
764  num++;
765  ++v;
766  }
767  if (v==v_end)
768  return nullptr;
769  return v->second;
770 }
771 
772 
773 
774 const NumericVector<Number> & System::get_vector (const std::string & vec_name) const
775 {
776  return *(libmesh_map_find(_vectors, vec_name));
777 }
778 
779 
780 
781 NumericVector<Number> & System::get_vector (const std::string & vec_name)
782 {
783  return *(libmesh_map_find(_vectors, vec_name));
784 }
785 
786 
787 
788 const NumericVector<Number> & System::get_vector (const unsigned int vec_num) const
789 {
792  unsigned int num = 0;
793  while ((num<vec_num) && (v!=v_end))
794  {
795  num++;
796  ++v;
797  }
798  libmesh_assert (v != v_end);
799  return *(v->second);
800 }
801 
802 
803 
804 NumericVector<Number> & System::get_vector (const unsigned int vec_num)
805 {
807  vectors_iterator v_end = vectors_end();
808  unsigned int num = 0;
809  while ((num<vec_num) && (v!=v_end))
810  {
811  num++;
812  ++v;
813  }
814  libmesh_assert (v != v_end);
815  return *(v->second);
816 }
817 
818 
819 
820 const std::string & System::vector_name (const unsigned int vec_num) const
821 {
824  unsigned int num = 0;
825  while ((num<vec_num) && (v!=v_end))
826  {
827  num++;
828  ++v;
829  }
830  libmesh_assert (v != v_end);
831  return v->first;
832 }
833 
834 const std::string & System::vector_name (const NumericVector<Number> & vec_reference) const
835 {
838 
839  for (; v != v_end; ++v)
840  {
841  // Check if the current vector is the one whose name we want
842  if (&vec_reference == v->second)
843  break; // exit loop if it is
844  }
845 
846  // Before returning, make sure we didnt loop till the end and not find any match
847  libmesh_assert (v != v_end);
848 
849  // Return the string associated with the current vector
850  return v->first;
851 }
852 
853 
854 
855 void System::set_vector_preservation (const std::string & vec_name,
856  bool preserve)
857 {
858  _vector_projections[vec_name] = preserve;
859 }
860 
861 
862 
863 bool System::vector_preservation (const std::string & vec_name) const
864 {
865  if (_vector_projections.find(vec_name) == _vector_projections.end())
866  return false;
867 
868  return _vector_projections.find(vec_name)->second;
869 }
870 
871 
872 
873 void System::set_vector_as_adjoint (const std::string & vec_name,
874  int qoi_num)
875 {
876  // We reserve -1 for vectors which get primal constraints, -2 for
877  // vectors which get no constraints
878  libmesh_assert_greater_equal(qoi_num, -2);
879  _vector_is_adjoint[vec_name] = qoi_num;
880 }
881 
882 
883 
884 int System::vector_is_adjoint (const std::string & vec_name) const
885 {
886  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
887  _vector_is_adjoint.end());
888 
889  return _vector_is_adjoint.find(vec_name)->second;
890 }
891 
892 
893 
895 {
896  std::ostringstream sensitivity_name;
897  sensitivity_name << "sensitivity_solution" << i;
898 
899  return this->add_vector(sensitivity_name.str());
900 }
901 
902 
903 
905 {
906  std::ostringstream sensitivity_name;
907  sensitivity_name << "sensitivity_solution" << i;
908 
909  return this->get_vector(sensitivity_name.str());
910 }
911 
912 
913 
915 {
916  std::ostringstream sensitivity_name;
917  sensitivity_name << "sensitivity_solution" << i;
918 
919  return this->get_vector(sensitivity_name.str());
920 }
921 
922 
923 
925 {
926  return this->add_vector("weighted_sensitivity_solution");
927 }
928 
929 
930 
932 {
933  return this->get_vector("weighted_sensitivity_solution");
934 }
935 
936 
937 
939 {
940  return this->get_vector("weighted_sensitivity_solution");
941 }
942 
943 
944 
946 {
947  std::ostringstream adjoint_name;
948  adjoint_name << "adjoint_solution" << i;
949 
950  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
951  this->set_vector_as_adjoint(adjoint_name.str(), i);
952  return returnval;
953 }
954 
955 
956 
958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  return this->get_vector(adjoint_name.str());
963 }
964 
965 
966 
968 {
969  std::ostringstream adjoint_name;
970  adjoint_name << "adjoint_solution" << i;
971 
972  return this->get_vector(adjoint_name.str());
973 }
974 
975 
976 
978 {
979  std::ostringstream adjoint_name;
980  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
981 
982  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
983  this->set_vector_as_adjoint(adjoint_name.str(), i);
984  return returnval;
985 }
986 
987 
988 
990 {
991  std::ostringstream adjoint_name;
992  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
993 
994  return this->get_vector(adjoint_name.str());
995 }
996 
997 
998 
1000 {
1001  std::ostringstream adjoint_name;
1002  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1003 
1004  return this->get_vector(adjoint_name.str());
1005 }
1006 
1007 
1008 
1010 {
1011  std::ostringstream adjoint_rhs_name;
1012  adjoint_rhs_name << "adjoint_rhs" << i;
1013 
1014  return this->add_vector(adjoint_rhs_name.str(), false);
1015 }
1016 
1017 
1018 
1020 {
1021  std::ostringstream adjoint_rhs_name;
1022  adjoint_rhs_name << "adjoint_rhs" << i;
1023 
1024  return this->get_vector(adjoint_rhs_name.str());
1025 }
1026 
1027 
1028 
1029 const NumericVector<Number> & System::get_adjoint_rhs (unsigned int i) const
1030 {
1031  std::ostringstream adjoint_rhs_name;
1032  adjoint_rhs_name << "adjoint_rhs" << i;
1033 
1034  return this->get_vector(adjoint_rhs_name.str());
1035 }
1036 
1037 
1038 
1040 {
1041  std::ostringstream sensitivity_rhs_name;
1042  sensitivity_rhs_name << "sensitivity_rhs" << i;
1043 
1044  return this->add_vector(sensitivity_rhs_name.str(), false);
1045 }
1046 
1047 
1048 
1050 {
1051  std::ostringstream sensitivity_rhs_name;
1052  sensitivity_rhs_name << "sensitivity_rhs" << i;
1053 
1054  return this->get_vector(sensitivity_rhs_name.str());
1055 }
1056 
1057 
1058 
1060 {
1061  std::ostringstream sensitivity_rhs_name;
1062  sensitivity_rhs_name << "sensitivity_rhs" << i;
1063 
1064  return this->get_vector(sensitivity_rhs_name.str());
1065 }
1066 
1067 
1068 
1069 unsigned int System::add_variable (const std::string & var,
1070  const FEType & type,
1071  const std::set<subdomain_id_type> * const active_subdomains)
1072 {
1073  libmesh_assert(!this->is_initialized());
1074 
1075  // Make sure the variable isn't there already
1076  // or if it is, that it's the type we want
1077  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1078  if (this->variable_name(v) == var)
1079  {
1080  if (this->variable_type(v) == type)
1081  return _variables[v].number();
1082 
1083  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1084  }
1085 
1086  // Optimize for VariableGroups here - if the user is adding multiple
1087  // variables of the same FEType and subdomain restriction, catch
1088  // that here and add them as members of the same VariableGroup.
1089  //
1090  // start by setting this flag to whatever the user has requested
1091  // and then consider the conditions which should negate it.
1092  bool should_be_in_vg = this->identify_variable_groups();
1093 
1094  // No variable groups, nothing to add to
1095  if (!this->n_variable_groups())
1096  should_be_in_vg = false;
1097 
1098  else
1099  {
1100  VariableGroup & vg(_variable_groups.back());
1101 
1102  // get a pointer to their subdomain restriction, if any.
1103  const std::set<subdomain_id_type> * const
1104  their_active_subdomains (vg.implicitly_active() ?
1105  nullptr : &vg.active_subdomains());
1106 
1107  // Different types?
1108  if (vg.type() != type)
1109  should_be_in_vg = false;
1110 
1111  // they are restricted, we aren't?
1112  if (their_active_subdomains &&
1113  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1114  should_be_in_vg = false;
1115 
1116  // they aren't restricted, we are?
1117  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1118  should_be_in_vg = false;
1119 
1120  if (their_active_subdomains && active_subdomains)
1121  // restricted to different sets?
1122  if (*their_active_subdomains != *active_subdomains)
1123  should_be_in_vg = false;
1124 
1125  // OK, after all that, append the variable to the vg if none of the conditions
1126  // were violated
1127  if (should_be_in_vg)
1128  {
1129  const unsigned short curr_n_vars = cast_int<unsigned short>
1130  (this->n_vars());
1131 
1132  vg.append (var);
1133 
1134  _variables.push_back(vg(vg.n_variables()-1));
1135  _variable_numbers[var] = curr_n_vars;
1136  return curr_n_vars;
1137  }
1138  }
1139 
1140  // otherwise, fall back to adding a single variable group
1141  return this->add_variables (std::vector<std::string>(1, var),
1142  type,
1143  active_subdomains);
1144 }
1145 
1146 
1147 
1148 unsigned int System::add_variable (const std::string & var,
1149  const Order order,
1150  const FEFamily family,
1151  const std::set<subdomain_id_type> * const active_subdomains)
1152 {
1153  return this->add_variable(var,
1154  FEType(order, family),
1155  active_subdomains);
1156 }
1157 
1158 
1159 
1160 unsigned int System::add_variables (const std::vector<std::string> & vars,
1161  const FEType & type,
1162  const std::set<subdomain_id_type> * const active_subdomains)
1163 {
1164  libmesh_assert(!this->is_initialized());
1165 
1166  // Make sure the variable isn't there already
1167  // or if it is, that it's the type we want
1168  for (auto ovar : vars)
1169  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1170  if (this->variable_name(v) == ovar)
1171  {
1172  if (this->variable_type(v) == type)
1173  return _variables[v].number();
1174 
1175  libmesh_error_msg("ERROR: incompatible variable " << ovar << " has already been added for this system!");
1176  }
1177 
1178  const unsigned short curr_n_vars = cast_int<unsigned short>
1179  (this->n_vars());
1180 
1181  const unsigned int next_first_component = this->n_components();
1182 
1183  // Add the variable group to the list
1184  _variable_groups.push_back((active_subdomains == nullptr) ?
1185  VariableGroup(this, vars, curr_n_vars,
1186  next_first_component, type) :
1187  VariableGroup(this, vars, curr_n_vars,
1188  next_first_component, type, *active_subdomains));
1189 
1190  const VariableGroup & vg (_variable_groups.back());
1191 
1192  // Add each component of the group individually
1193  for (auto v : IntRange<unsigned int>(0, vars.size()))
1194  {
1195  _variables.push_back (vg(v));
1196  _variable_numbers[vars[v]] = cast_int<unsigned short>
1197  (curr_n_vars+v);
1198  }
1199 
1200  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1201 
1202  // BSK - Defer this now to System::init_data() so we can detect
1203  // VariableGroups 12/28/2012
1204  // // Add the variable group to the _dof_map
1205  // _dof_map->add_variable_group (vg);
1206 
1207  // Return the number of the new variable
1208  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1209 }
1210 
1211 
1212 
1213 unsigned int System::add_variables (const std::vector<std::string> & vars,
1214  const Order order,
1215  const FEFamily family,
1216  const std::set<subdomain_id_type> * const active_subdomains)
1217 {
1218  return this->add_variables(vars,
1219  FEType(order, family),
1220  active_subdomains);
1221 }
1222 
1223 
1224 
1225 bool System::has_variable (const std::string & var) const
1226 {
1227  return _variable_numbers.count(var);
1228 }
1229 
1230 
1231 
1232 unsigned short int System::variable_number (const std::string & var) const
1233 {
1234  auto var_num = libmesh_map_find(_variable_numbers, var);
1235  libmesh_assert_equal_to (_variables[var_num].name(), var);
1236  return var_num;
1237 }
1238 
1239 
1240 void System::get_all_variable_numbers(std::vector<unsigned int> & all_variable_numbers) const
1241 {
1242  all_variable_numbers.resize(n_vars());
1243 
1244  // Make sure the variable exists
1245  std::map<std::string, unsigned short int>::const_iterator
1246  it = _variable_numbers.begin();
1247  std::map<std::string, unsigned short int>::const_iterator
1248  it_end = _variable_numbers.end();
1249 
1250  unsigned int count = 0;
1251  for ( ; it != it_end; ++it)
1252  {
1253  all_variable_numbers[count] = it->second;
1254  count++;
1255  }
1256 }
1257 
1258 
1259 void System::local_dof_indices(const unsigned int var,
1260  std::set<dof_id_type> & var_indices) const
1261 {
1262  // Make sure the set is clear
1263  var_indices.clear();
1264 
1265  std::vector<dof_id_type> dof_indices;
1266 
1267  const dof_id_type
1268  first_local = this->get_dof_map().first_dof(),
1269  end_local = this->get_dof_map().end_dof();
1270 
1271  // Begin the loop over the elements
1272  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1273  {
1274  this->get_dof_map().dof_indices (elem, dof_indices, var);
1275 
1276  for (dof_id_type dof : dof_indices)
1277  //If the dof is owned by the local processor
1278  if (first_local <= dof && dof < end_local)
1279  var_indices.insert(dof);
1280  }
1281 
1282  // we may have missed assigning DOFs to nodes that we own
1283  // but to which we have no connected elements matching our
1284  // variable restriction criterion. this will happen, for example,
1285  // if variable V is restricted to subdomain S. We may not own
1286  // any elements which live in S, but we may own nodes which are
1287  // *connected* to elements which do.
1288  for (const auto & node : this->get_mesh().local_node_ptr_range())
1289  {
1290  libmesh_assert(node);
1291  this->get_dof_map().dof_indices (node, dof_indices, var);
1292  for (auto dof : dof_indices)
1293  if (first_local <= dof && dof < end_local)
1294  var_indices.insert(dof);
1295  }
1296 }
1297 
1298 
1299 
1301  unsigned int var_num) const
1302 {
1303  /* Make sure the call makes sense. */
1304  libmesh_assert_less (var_num, this->n_vars());
1305 
1306  /* Get a reference to the mesh. */
1307  const MeshBase & mesh = this->get_mesh();
1308 
1309  /* Check which system we are. */
1310  const unsigned int sys_num = this->number();
1311 
1312  // Loop over nodes.
1313  for (const auto & node : mesh.local_node_ptr_range())
1314  {
1315  unsigned int n_comp = node->n_comp(sys_num,var_num);
1316  for (unsigned int i=0; i<n_comp; i++)
1317  {
1318  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1319  v.set(index,0.0);
1320  }
1321  }
1322 
1323  // Loop over elements.
1324  for (const auto & elem : mesh.active_local_element_ptr_range())
1325  {
1326  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1327  for (unsigned int i=0; i<n_comp; i++)
1328  {
1329  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1330  v.set(index,0.0);
1331  }
1332  }
1333 }
1334 
1335 
1336 
1338  unsigned int var,
1339  FEMNormType norm_type) const
1340 {
1341  std::set<dof_id_type> var_indices;
1342  local_dof_indices(var, var_indices);
1343 
1344  if (norm_type == DISCRETE_L1)
1345  return v.subset_l1_norm(var_indices);
1346  if (norm_type == DISCRETE_L2)
1347  return v.subset_l2_norm(var_indices);
1348  if (norm_type == DISCRETE_L_INF)
1349  return v.subset_linfty_norm(var_indices);
1350  else
1351  libmesh_error_msg("Invalid norm_type = " << norm_type);
1352 }
1353 
1354 
1355 
1357  unsigned int var,
1358  FEMNormType norm_type,
1359  std::set<unsigned int> * skip_dimensions) const
1360 {
1361  //short circuit to save time
1362  if (norm_type == DISCRETE_L1 ||
1363  norm_type == DISCRETE_L2 ||
1364  norm_type == DISCRETE_L_INF)
1365  return discrete_var_norm(v,var,norm_type);
1366 
1367  // Not a discrete norm
1368  std::vector<FEMNormType> norms(this->n_vars(), L2);
1369  std::vector<Real> weights(this->n_vars(), 0.0);
1370  norms[var] = norm_type;
1371  weights[var] = 1.0;
1372  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1373  return val;
1374 }
1375 
1376 
1377 
1379  const SystemNorm & norm,
1380  std::set<unsigned int> * skip_dimensions) const
1381 {
1382  // This function must be run on all processors at once
1383  parallel_object_only();
1384 
1385  LOG_SCOPE ("calculate_norm()", "System");
1386 
1387  // Zero the norm before summation
1388  Real v_norm = 0.;
1389 
1390  if (norm.is_discrete())
1391  {
1392  //Check to see if all weights are 1.0 and all types are equal
1393  FEMNormType norm_type0 = norm.type(0);
1394  unsigned int check_var = 0, check_end = this->n_vars();
1395  for (; check_var != check_end; ++check_var)
1396  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1397  break;
1398 
1399  //All weights were 1.0 so just do the full vector discrete norm
1400  if (check_var == this->n_vars())
1401  {
1402  if (norm_type0 == DISCRETE_L1)
1403  return v.l1_norm();
1404  if (norm_type0 == DISCRETE_L2)
1405  return v.l2_norm();
1406  if (norm_type0 == DISCRETE_L_INF)
1407  return v.linfty_norm();
1408  else
1409  libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
1410  }
1411 
1412  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1413  {
1414  // Skip any variables we don't need to integrate
1415  if (norm.weight(var) == 0.0)
1416  continue;
1417 
1418  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1419  }
1420 
1421  return v_norm;
1422  }
1423 
1424  // Localize the potentially parallel vector
1425  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1426  local_v->init(v.size(), true, SERIAL);
1427  v.localize (*local_v, _dof_map->get_send_list());
1428 
1429  // I'm not sure how best to mix Hilbert norms on some variables (for
1430  // which we'll want to square then sum then square root) with norms
1431  // like L_inf (for which we'll just want to take an absolute value
1432  // and then sum).
1433  bool using_hilbert_norm = true,
1434  using_nonhilbert_norm = true;
1435 
1436  // Loop over all variables
1437  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1438  {
1439  // Skip any variables we don't need to integrate
1440  Real norm_weight_sq = norm.weight_sq(var);
1441  if (norm_weight_sq == 0.0)
1442  continue;
1443  Real norm_weight = norm.weight(var);
1444 
1445  // Check for unimplemented norms (rather than just returning 0).
1446  FEMNormType norm_type = norm.type(var);
1447  if ((norm_type==H1) ||
1448  (norm_type==H2) ||
1449  (norm_type==L2) ||
1450  (norm_type==H1_SEMINORM) ||
1451  (norm_type==H2_SEMINORM))
1452  {
1453  if (!using_hilbert_norm)
1454  libmesh_not_implemented();
1455  using_nonhilbert_norm = false;
1456  }
1457  else if ((norm_type==L1) ||
1458  (norm_type==L_INF) ||
1459  (norm_type==W1_INF_SEMINORM) ||
1460  (norm_type==W2_INF_SEMINORM))
1461  {
1462  if (!using_nonhilbert_norm)
1463  libmesh_not_implemented();
1464  using_hilbert_norm = false;
1465  }
1466  else
1467  libmesh_not_implemented();
1468 
1469  const FEType & fe_type = this->get_dof_map().variable_type(var);
1470 
1471  // Allow space for dims 0-3, even if we don't use them all
1472  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1473  std::vector<std::unique_ptr<QBase>> q_rules(4);
1474 
1475  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1476 
1477  // Prepare finite elements for each dimension present in the mesh
1478  for (const auto & dim : elem_dims)
1479  {
1480  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1481  continue;
1482 
1483  // Construct quadrature and finite element objects
1484  q_rules[dim] = fe_type.default_quadrature_rule (dim);
1485  fe_ptrs[dim] = FEBase::build(dim, fe_type);
1486 
1487  // Attach quadrature rule to FE object
1488  fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1489  }
1490 
1491  std::vector<dof_id_type> dof_indices;
1492 
1493  // Begin the loop over the elements
1494  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1495  {
1496  const unsigned int dim = elem->dim();
1497 
1498 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1499 
1500  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1501  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1502  // or in which sense they could make sense.
1503  if (elem->infinite() )
1504  libmesh_not_implemented();
1505 
1506 #endif
1507 
1508  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1509  continue;
1510 
1511  FEBase * fe = fe_ptrs[dim].get();
1512  QBase * qrule = q_rules[dim].get();
1513  libmesh_assert(fe);
1514  libmesh_assert(qrule);
1515 
1516  const std::vector<Real> & JxW = fe->get_JxW();
1517  const std::vector<std::vector<Real>> * phi = nullptr;
1518  if (norm_type == H1 ||
1519  norm_type == H2 ||
1520  norm_type == L2 ||
1521  norm_type == L1 ||
1522  norm_type == L_INF)
1523  phi = &(fe->get_phi());
1524 
1525  const std::vector<std::vector<RealGradient>> * dphi = nullptr;
1526  if (norm_type == H1 ||
1527  norm_type == H2 ||
1528  norm_type == H1_SEMINORM ||
1529  norm_type == W1_INF_SEMINORM)
1530  dphi = &(fe->get_dphi());
1531 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1532  const std::vector<std::vector<RealTensor>> * d2phi = nullptr;
1533  if (norm_type == H2 ||
1534  norm_type == H2_SEMINORM ||
1535  norm_type == W2_INF_SEMINORM)
1536  d2phi = &(fe->get_d2phi());
1537 #endif
1538 
1539  fe->reinit (elem);
1540 
1541  this->get_dof_map().dof_indices (elem, dof_indices, var);
1542 
1543  const unsigned int n_qp = qrule->n_points();
1544 
1545  const unsigned int n_sf = cast_int<unsigned int>
1546  (dof_indices.size());
1547 
1548  // Begin the loop over the Quadrature points.
1549  for (unsigned int qp=0; qp<n_qp; qp++)
1550  {
1551  if (norm_type == L1)
1552  {
1553  Number u_h = 0.;
1554  for (unsigned int i=0; i != n_sf; ++i)
1555  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1556  v_norm += norm_weight *
1557  JxW[qp] * std::abs(u_h);
1558  }
1559 
1560  if (norm_type == L_INF)
1561  {
1562  Number u_h = 0.;
1563  for (unsigned int i=0; i != n_sf; ++i)
1564  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1565  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
1566  }
1567 
1568  if (norm_type == H1 ||
1569  norm_type == H2 ||
1570  norm_type == L2)
1571  {
1572  Number u_h = 0.;
1573  for (unsigned int i=0; i != n_sf; ++i)
1574  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1575  v_norm += norm_weight_sq *
1576  JxW[qp] * TensorTools::norm_sq(u_h);
1577  }
1578 
1579  if (norm_type == H1 ||
1580  norm_type == H2 ||
1581  norm_type == H1_SEMINORM)
1582  {
1583  Gradient grad_u_h;
1584  for (unsigned int i=0; i != n_sf; ++i)
1585  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1586  v_norm += norm_weight_sq *
1587  JxW[qp] * grad_u_h.norm_sq();
1588  }
1589 
1590  if (norm_type == W1_INF_SEMINORM)
1591  {
1592  Gradient grad_u_h;
1593  for (unsigned int i=0; i != n_sf; ++i)
1594  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1595  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1596  }
1597 
1598 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1599  if (norm_type == H2 ||
1600  norm_type == H2_SEMINORM)
1601  {
1602  Tensor hess_u_h;
1603  for (unsigned int i=0; i != n_sf; ++i)
1604  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1605  v_norm += norm_weight_sq *
1606  JxW[qp] * hess_u_h.norm_sq();
1607  }
1608 
1609  if (norm_type == W2_INF_SEMINORM)
1610  {
1611  Tensor hess_u_h;
1612  for (unsigned int i=0; i != n_sf; ++i)
1613  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1614  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1615  }
1616 #endif
1617  }
1618  }
1619  }
1620 
1621  if (using_hilbert_norm)
1622  {
1623  this->comm().sum(v_norm);
1624  v_norm = std::sqrt(v_norm);
1625  }
1626  else
1627  {
1628  this->comm().max(v_norm);
1629  }
1630 
1631  return v_norm;
1632 }
1633 
1634 
1635 
1636 std::string System::get_info() const
1637 {
1638  std::ostringstream oss;
1639 
1640 
1641  const std::string & sys_name = this->name();
1642 
1643  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1644  << " Type \"" << this->system_type() << "\"\n"
1645  << " Variables=";
1646 
1647  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1648  {
1649  const VariableGroup & vg_description (this->variable_group(vg));
1650 
1651  if (vg_description.n_variables() > 1) oss << "{ ";
1652  for (auto vn : IntRange<unsigned int>(0, vg_description.n_variables()))
1653  oss << "\"" << vg_description.name(vn) << "\" ";
1654  if (vg_description.n_variables() > 1) oss << "} ";
1655  }
1656 
1657  oss << '\n';
1658 
1659  oss << " Finite Element Types=";
1660 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1661  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1662  oss << "\""
1663  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1664  << "\" ";
1665 #else
1666  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1667  {
1668  oss << "\""
1669  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1670  << "\", \""
1671  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1672  << "\" ";
1673  }
1674 
1675  oss << '\n' << " Infinite Element Mapping=";
1676  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1677  oss << "\""
1678  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1679  << "\" ";
1680 #endif
1681 
1682  oss << '\n';
1683 
1684  oss << " Approximation Orders=";
1685  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1686  {
1687 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1688  oss << "\""
1689  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1690  << "\" ";
1691 #else
1692  oss << "\""
1693  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1694  << "\", \""
1695  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1696  << "\" ";
1697 #endif
1698  }
1699 
1700  oss << '\n';
1701 
1702  oss << " n_dofs()=" << this->n_dofs() << '\n';
1703  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1704 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1705  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1706  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1707 #endif
1708 
1709  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1710  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1711  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1712 
1713  oss << this->get_dof_map().get_info();
1714 
1715  return oss.str();
1716 }
1717 
1718 
1719 
1721  const std::string & name))
1722 {
1724 
1725  if (_init_system_object != nullptr)
1726  {
1727  libmesh_here();
1728  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1729  << std::endl;
1730 
1731  _init_system_object = nullptr;
1732  }
1733 
1735 }
1736 
1737 
1738 
1740 {
1741  if (_init_system_function != nullptr)
1742  {
1743  libmesh_here();
1744  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1745  << std::endl;
1746 
1747  _init_system_function = nullptr;
1748  }
1749 
1750  _init_system_object = &init_in;
1751 }
1752 
1753 
1754 
1756  const std::string & name))
1757 {
1759 
1760  if (_assemble_system_object != nullptr)
1761  {
1762  libmesh_here();
1763  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1764  << std::endl;
1765 
1766  _assemble_system_object = nullptr;
1767  }
1768 
1770 }
1771 
1772 
1773 
1775 {
1776  if (_assemble_system_function != nullptr)
1777  {
1778  libmesh_here();
1779  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1780  << std::endl;
1781 
1782  _assemble_system_function = nullptr;
1783  }
1784 
1785  _assemble_system_object = &assemble_in;
1786 }
1787 
1788 
1789 
1791  const std::string & name))
1792 {
1794 
1795  if (_constrain_system_object != nullptr)
1796  {
1797  libmesh_here();
1798  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1799  << std::endl;
1800 
1801  _constrain_system_object = nullptr;
1802  }
1803 
1805 }
1806 
1807 
1808 
1810 {
1811  if (_constrain_system_function != nullptr)
1812  {
1813  libmesh_here();
1814  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1815  << std::endl;
1816 
1817  _constrain_system_function = nullptr;
1818  }
1819 
1820  _constrain_system_object = &constrain;
1821 }
1822 
1823 
1824 
1826  const std::string &,
1827  const QoISet &))
1828 {
1830 
1831  if (_qoi_evaluate_object != nullptr)
1832  {
1833  libmesh_here();
1834  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1835  << std::endl;
1836 
1837  _qoi_evaluate_object = nullptr;
1838  }
1839 
1841 }
1842 
1843 
1844 
1846 {
1847  if (_qoi_evaluate_function != nullptr)
1848  {
1849  libmesh_here();
1850  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1851  << std::endl;
1852 
1853  _qoi_evaluate_function = nullptr;
1854  }
1855 
1856  _qoi_evaluate_object = &qoi_in;
1857 }
1858 
1859 
1860 
1861 void System::attach_QOI_derivative(void fptr(EquationSystems &, const std::string &,
1862  const QoISet &, bool, bool))
1863 {
1865 
1866  if (_qoi_evaluate_derivative_object != nullptr)
1867  {
1868  libmesh_here();
1869  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1870  << std::endl;
1871 
1873  }
1874 
1876 }
1877 
1878 
1879 
1881 {
1882  if (_qoi_evaluate_derivative_function != nullptr)
1883  {
1884  libmesh_here();
1885  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1886  << std::endl;
1887 
1889  }
1890 
1891  _qoi_evaluate_derivative_object = &qoi_derivative;
1892 }
1893 
1894 
1895 
1897 {
1898  // Call the user-provided initialization function,
1899  // if it was provided
1900  if (_init_system_function != nullptr)
1901  this->_init_system_function (_equation_systems, this->name());
1902 
1903  // ...or the user-provided initialization object.
1904  else if (_init_system_object != nullptr)
1906 }
1907 
1908 
1909 
1911 {
1912  // Call the user-provided assembly function,
1913  // if it was provided
1914  if (_assemble_system_function != nullptr)
1916 
1917  // ...or the user-provided assembly object.
1918  else if (_assemble_system_object != nullptr)
1920 }
1921 
1922 
1923 
1925 {
1926  // Call the user-provided constraint function,
1927  // if it was provided
1928  if (_constrain_system_function!= nullptr)
1930 
1931  // ...or the user-provided constraint object.
1932  else if (_constrain_system_object != nullptr)
1934 }
1935 
1936 
1937 
1938 void System::user_QOI (const QoISet & qoi_indices)
1939 {
1940  // Call the user-provided quantity of interest function,
1941  // if it was provided
1942  if (_qoi_evaluate_function != nullptr)
1943  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
1944 
1945  // ...or the user-provided QOI function object.
1946  else if (_qoi_evaluate_object != nullptr)
1947  this->_qoi_evaluate_object->qoi(qoi_indices);
1948 }
1949 
1950 
1951 
1952 void System::user_QOI_derivative(const QoISet & qoi_indices,
1953  bool include_liftfunc,
1954  bool apply_constraints)
1955 {
1956  // Call the user-provided quantity of interest derivative,
1957  // if it was provided
1958  if (_qoi_evaluate_derivative_function != nullptr)
1960  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
1961  apply_constraints);
1962 
1963  // ...or the user-provided QOI derivative function object.
1964  else if (_qoi_evaluate_derivative_object != nullptr)
1966  (qoi_indices, include_liftfunc, apply_constraints);
1967 }
1968 
1969 
1970 
1971 Number System::point_value(unsigned int var,
1972  const Point & p,
1973  const bool insist_on_success,
1974  const NumericVector<Number> *sol) const
1975 {
1976  // This function must be called on every processor; there's no
1977  // telling where in the partition p falls.
1978  parallel_object_only();
1979 
1980  // And every processor had better agree about which point we're
1981  // looking for
1982 #ifndef NDEBUG
1983  libmesh_assert(this->comm().verify(p(0)));
1984 #if LIBMESH_DIM > 1
1985  libmesh_assert(this->comm().verify(p(1)));
1986 #endif
1987 #if LIBMESH_DIM > 2
1988  libmesh_assert(this->comm().verify(p(2)));
1989 #endif
1990 #endif // NDEBUG
1991 
1992  // Get a reference to the mesh object associated with the system object that calls this function
1993  const MeshBase & mesh = this->get_mesh();
1994 
1995  // Use an existing PointLocator or create a new one
1996  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
1997  PointLocatorBase & locator = *locator_ptr;
1998 
1999  if (!insist_on_success || !mesh.is_serial())
2000  locator.enable_out_of_mesh_mode();
2001 
2002  // Get a pointer to an element that contains p and allows us to
2003  // evaluate var
2004  const std::set<subdomain_id_type> & raw_subdomains =
2005  this->variable(var).active_subdomains();
2006  const std::set<subdomain_id_type> * implicit_subdomains =
2007  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2008  const Elem * e = locator(p, implicit_subdomains);
2009 
2010  Number u = 0;
2011 
2012  if (e && this->get_dof_map().is_evaluable(*e, var))
2013  u = point_value(var, p, *e, sol);
2014 
2015  // If I have an element containing p, then let's let everyone know
2016  processor_id_type lowest_owner =
2017  (e && (e->processor_id() == this->processor_id())) ?
2018  this->processor_id() : this->n_processors();
2019  this->comm().min(lowest_owner);
2020 
2021  // Everybody should get their value from a processor that was able
2022  // to compute it.
2023  // If nobody admits owning the point, we have a problem.
2024  if (lowest_owner != this->n_processors())
2025  this->comm().broadcast(u, lowest_owner);
2026  else
2027  libmesh_assert(!insist_on_success);
2028 
2029  return u;
2030 }
2031 
2032 Number System::point_value(unsigned int var,
2033  const Point & p,
2034  const Elem & e,
2035  const NumericVector<Number> *sol) const
2036 {
2037  // Ensuring that the given point is really in the element is an
2038  // expensive assert, but as long as debugging is turned on we might
2039  // as well try to catch a particularly nasty potential error
2041 
2042  if (!sol)
2043  sol = this->current_local_solution.get();
2044 
2045  // Get the dof map to get the proper indices for our computation
2046  const DofMap & dof_map = this->get_dof_map();
2047 
2048  // Make sure we can evaluate on this element.
2049  libmesh_assert (dof_map.is_evaluable(e, var));
2050 
2051  // Need dof_indices for phi[i][j]
2052  std::vector<dof_id_type> dof_indices;
2053 
2054  // Fill in the dof_indices for our element
2055  dof_map.dof_indices (&e, dof_indices, var);
2056 
2057  // Get the no of dofs associated with this point
2058  const unsigned int num_dofs = cast_int<unsigned int>
2059  (dof_indices.size());
2060 
2061  FEType fe_type = dof_map.variable_type(var);
2062 
2063  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2064  Point coor = FEMap::inverse_map(e.dim(), &e, p);
2065 
2066  // get the shape function value via the FEInterface to also handle the case
2067  // of infinite elements correcly, the shape function is not fe->phi().
2068  FEComputeData fe_data(this->get_equation_systems(), coor);
2069  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2070 
2071  // Get ready to accumulate a value
2072  Number u = 0;
2073 
2074  for (unsigned int l=0; l<num_dofs; l++)
2075  {
2076  u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2077  }
2078 
2079  return u;
2080 }
2081 
2082 
2083 
2084 Number System::point_value(unsigned int var, const Point & p, const Elem * e) const
2085 {
2086  libmesh_assert(e);
2087  return this->point_value(var, p, *e);
2088 }
2089 
2090 
2091 
2092 Number System::point_value(unsigned int var, const Point & p, const NumericVector<Number> * sol) const
2093 {
2094  return this->point_value(var, p, true, sol);
2095 }
2096 
2097 
2098 
2099 
2101  const Point & p,
2102  const bool insist_on_success,
2103  const NumericVector<Number> *sol) const
2104 {
2105  // This function must be called on every processor; there's no
2106  // telling where in the partition p falls.
2107  parallel_object_only();
2108 
2109  // And every processor had better agree about which point we're
2110  // looking for
2111 #ifndef NDEBUG
2112  libmesh_assert(this->comm().verify(p(0)));
2113 #if LIBMESH_DIM > 1
2114  libmesh_assert(this->comm().verify(p(1)));
2115 #endif
2116 #if LIBMESH_DIM > 2
2117  libmesh_assert(this->comm().verify(p(2)));
2118 #endif
2119 #endif // NDEBUG
2120 
2121  // Get a reference to the mesh object associated with the system object that calls this function
2122  const MeshBase & mesh = this->get_mesh();
2123 
2124  // Use an existing PointLocator or create a new one
2125  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2126  PointLocatorBase & locator = *locator_ptr;
2127 
2128  if (!insist_on_success || !mesh.is_serial())
2129  locator.enable_out_of_mesh_mode();
2130 
2131  // Get a pointer to an element that contains p and allows us to
2132  // evaluate var
2133  const std::set<subdomain_id_type> & raw_subdomains =
2134  this->variable(var).active_subdomains();
2135  const std::set<subdomain_id_type> * implicit_subdomains =
2136  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2137  const Elem * e = locator(p, implicit_subdomains);
2138 
2139  Gradient grad_u;
2140 
2141  if (e && this->get_dof_map().is_evaluable(*e, var))
2142  grad_u = point_gradient(var, p, *e, sol);
2143 
2144  // If I have an element containing p, then let's let everyone know
2145  processor_id_type lowest_owner =
2146  (e && (e->processor_id() == this->processor_id())) ?
2147  this->processor_id() : this->n_processors();
2148  this->comm().min(lowest_owner);
2149 
2150  // Everybody should get their value from a processor that was able
2151  // to compute it.
2152  // If nobody admits owning the point, we may have a problem.
2153  if (lowest_owner != this->n_processors())
2154  this->comm().broadcast(grad_u, lowest_owner);
2155  else
2156  libmesh_assert(!insist_on_success);
2157 
2158  return grad_u;
2159 }
2160 
2161 
2163  const Point & p,
2164  const Elem & e,
2165  const NumericVector<Number> *sol) const
2166 {
2167  // Ensuring that the given point is really in the element is an
2168  // expensive assert, but as long as debugging is turned on we might
2169  // as well try to catch a particularly nasty potential error
2171 
2172  if (!sol)
2173  sol = this->current_local_solution.get();
2174 
2175  // Get the dof map to get the proper indices for our computation
2176  const DofMap & dof_map = this->get_dof_map();
2177 
2178  // write the element dimension into a separate variable.
2179  const unsigned int dim = e.dim();
2180 
2181  // Make sure we can evaluate on this element.
2182  libmesh_assert (dof_map.is_evaluable(e, var));
2183 
2184  // Need dof_indices for phi[i][j]
2185  std::vector<dof_id_type> dof_indices;
2186 
2187  // Fill in the dof_indices for our element
2188  dof_map.dof_indices (&e, dof_indices, var);
2189 
2190  // Get the no of dofs associated with this point
2191  const unsigned int num_dofs = cast_int<unsigned int>
2192  (dof_indices.size());
2193 
2194  FEType fe_type = dof_map.variable_type(var);
2195 
2196  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2197  Point coor = FEMap::inverse_map(dim, &e, p);
2198 
2199  // get the shape function value via the FEInterface to also handle the case
2200  // of infinite elements correcly, the shape function is not fe->phi().
2201  FEComputeData fe_data(this->get_equation_systems(), coor);
2202  fe_data.enable_derivative();
2203  FEInterface::compute_data(dim, fe_type, &e, fe_data);
2204 
2205  // Get ready to accumulate a gradient
2206  Gradient grad_u;
2207 
2208  for (unsigned int l=0; l<num_dofs; l++)
2209  {
2210  // Chartesian coordinates have allways LIBMESH_DIM entries,
2211  // local coordinates have as many coordinates as the element has.
2212  for (std::size_t v=0; v<dim; v++)
2213  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2214  {
2215  // FIXME: this needs better syntax: It is matrix-vector multiplication.
2216  grad_u(xyz) += fe_data.local_transform[v][xyz]
2217  * fe_data.dshape[l](v)
2218  * (*sol)(dof_indices[l]);
2219  }
2220  }
2221 
2222  return grad_u;
2223 }
2224 
2225 
2226 
2227 Gradient System::point_gradient(unsigned int var, const Point & p, const Elem * e) const
2228 {
2229  libmesh_assert(e);
2230  return this->point_gradient(var, p, *e);
2231 }
2232 
2233 
2234 
2235 Gradient System::point_gradient(unsigned int var, const Point & p, const NumericVector<Number> * sol) const
2236 {
2237  return this->point_gradient(var, p, true, sol);
2238 }
2239 
2240 
2241 
2242 // We can only accumulate a hessian with --enable-second
2243 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
2245  const Point & p,
2246  const bool insist_on_success,
2247  const NumericVector<Number> *sol) const
2248 {
2249  // This function must be called on every processor; there's no
2250  // telling where in the partition p falls.
2251  parallel_object_only();
2252 
2253  // And every processor had better agree about which point we're
2254  // looking for
2255 #ifndef NDEBUG
2256  libmesh_assert(this->comm().verify(p(0)));
2257 #if LIBMESH_DIM > 1
2258  libmesh_assert(this->comm().verify(p(1)));
2259 #endif
2260 #if LIBMESH_DIM > 2
2261  libmesh_assert(this->comm().verify(p(2)));
2262 #endif
2263 #endif // NDEBUG
2264 
2265  // Get a reference to the mesh object associated with the system object that calls this function
2266  const MeshBase & mesh = this->get_mesh();
2267 
2268  // Use an existing PointLocator or create a new one
2269  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2270  PointLocatorBase & locator = *locator_ptr;
2271 
2272  if (!insist_on_success || !mesh.is_serial())
2273  locator.enable_out_of_mesh_mode();
2274 
2275  // Get a pointer to an element that contains p and allows us to
2276  // evaluate var
2277  const std::set<subdomain_id_type> & raw_subdomains =
2278  this->variable(var).active_subdomains();
2279  const std::set<subdomain_id_type> * implicit_subdomains =
2280  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2281  const Elem * e = locator(p, implicit_subdomains);
2282 
2283  Tensor hess_u;
2284 
2285  if (e && this->get_dof_map().is_evaluable(*e, var))
2286  hess_u = point_hessian(var, p, *e, sol);
2287 
2288  // If I have an element containing p, then let's let everyone know
2289  processor_id_type lowest_owner =
2290  (e && (e->processor_id() == this->processor_id())) ?
2291  this->processor_id() : this->n_processors();
2292  this->comm().min(lowest_owner);
2293 
2294  // Everybody should get their value from a processor that was able
2295  // to compute it.
2296  // If nobody admits owning the point, we may have a problem.
2297  if (lowest_owner != this->n_processors())
2298  this->comm().broadcast(hess_u, lowest_owner);
2299  else
2300  libmesh_assert(!insist_on_success);
2301 
2302  return hess_u;
2303 }
2304 
2306  const Point & p,
2307  const Elem & e,
2308  const NumericVector<Number> *sol) const
2309 {
2310  // Ensuring that the given point is really in the element is an
2311  // expensive assert, but as long as debugging is turned on we might
2312  // as well try to catch a particularly nasty potential error
2314 
2315  if (!sol)
2316  sol = this->current_local_solution.get();
2317 
2318 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2319  if (e.infinite())
2320  libmesh_not_implemented();
2321 #endif
2322 
2323  // Get the dof map to get the proper indices for our computation
2324  const DofMap & dof_map = this->get_dof_map();
2325 
2326  // Make sure we can evaluate on this element.
2327  libmesh_assert (dof_map.is_evaluable(e, var));
2328 
2329  // Need dof_indices for phi[i][j]
2330  std::vector<dof_id_type> dof_indices;
2331 
2332  // Fill in the dof_indices for our element
2333  dof_map.dof_indices (&e, dof_indices, var);
2334 
2335  // Get the no of dofs associated with this point
2336  const unsigned int num_dofs = cast_int<unsigned int>
2337  (dof_indices.size());
2338 
2339  FEType fe_type = dof_map.variable_type(var);
2340 
2341  // Build a FE again so we can calculate u(p)
2342  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2343 
2344  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2345  // Build a vector of point co-ordinates to send to reinit
2346  std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2347 
2348  // Get the values of the shape function derivatives
2349  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2350 
2351  // Reinitialize the element and compute the shape function values at coor
2352  fe->reinit (&e, &coor);
2353 
2354  // Get ready to accumulate a hessian
2355  Tensor hess_u;
2356 
2357  for (unsigned int l=0; l<num_dofs; l++)
2358  {
2359  hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2360  }
2361 
2362  return hess_u;
2363 }
2364 
2365 
2366 
2367 Tensor System::point_hessian(unsigned int var, const Point & p, const Elem * e) const
2368 {
2369  libmesh_assert(e);
2370  return this->point_hessian(var, p, *e);
2371 }
2372 
2373 
2374 
2375 Tensor System::point_hessian(unsigned int var, const Point & p, const NumericVector<Number> * sol) const
2376 {
2377  return this->point_hessian(var, p, true, sol);
2378 }
2379 
2380 #else
2381 
2382 Tensor System::point_hessian(unsigned int, const Point &, const bool,
2383  const NumericVector<Number> *) const
2384 {
2385  libmesh_error_msg("We can only accumulate a hessian with --enable-second");
2386 
2387  // Avoid compiler warnings
2388  return Tensor();
2389 }
2390 
2391 Tensor System::point_hessian(unsigned int, const Point &, const Elem &,
2392  const NumericVector<Number> *) const
2393 {
2394  libmesh_error_msg("We can only accumulate a hessian with --enable-second");
2395 
2396  // Avoid compiler warnings
2397  return Tensor();
2398 }
2399 
2400 Tensor System::point_hessian(unsigned int, const Point &, const Elem *) const
2401 {
2402  libmesh_error_msg("We can only accumulate a hessian with --enable-second");
2403 
2404  // Avoid compiler warnings
2405  return Tensor();
2406 }
2407 
2408 Tensor System::point_hessian(unsigned int, const Point &, const NumericVector<Number> *) const
2409 {
2410  libmesh_error_msg("We can only accumulate a hessian with --enable-second");
2411 
2412  // Avoid compiler warnings
2413  return Tensor();
2414 }
2415 
2416 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
2417 
2418 } // namespace libMesh
libMesh::System::set_vector_preservation
void set_vector_preservation(const std::string &vec_name, bool preserve)
Allows one to set the boolean controlling whether the vector identified by vec_name should be "preser...
Definition: system.C:855
libMesh::ParameterVector::size
std::size_t size() const
Definition: parameter_vector.h:90
libMesh::DISCRETE_L_INF
Definition: enum_norm_type.h:54
libMesh::QBase
The QBase class provides the basic functionality from which various quadrature rules can be derived.
Definition: quadrature.h:61
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::System::_vector_projections
std::map< std::string, bool > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:1991
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::System::n_vars
unsigned int n_vars() const
Definition: system.h:2155
libMesh::System::have_vector
bool have_vector(const std::string &vec_name) const
Definition: system.h:2275
libMesh::DofMap::is_evaluable
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2553
libMesh::System::get_equation_systems
const EquationSystems & get_equation_systems() const
Definition: system.h:720
libMesh::System::project_vector
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
Definition: system_projection.C:991
libMesh::System::reinit
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
Definition: system.C:390
libMesh::System::get_sensitivity_rhs
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1049
libMesh::System::is_initialized
bool is_initialized()
Definition: system.h:2139
libMesh::System::_is_initialized
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition: system.h:2021
libMesh::FEComputeData
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
Definition: fe_compute_data.h:51
libMesh::DofMap::prepare_send_list
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1651
libMesh::System::_variable_groups
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:1966
libMesh::System::vectors_iterator
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:756
libMesh::System::_constrain_system_function
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:1896
libMesh::System::attach_QOI_function
void attach_QOI_function(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
Register a user function for evaluating the quantities of interest, whose values should be placed in ...
Definition: system.C:1825
libMesh::FEType::family
FEFamily family
The type of finite element.
Definition: fe_type.h:203
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::System::add_adjoint_solution
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
Definition: system.C:945
libMesh::System::compare
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
Definition: system.C:514
libMesh::L_INF
Definition: enum_norm_type.h:42
libMesh::PARALLEL
Definition: enum_parallel_type.h:36
libMesh::System::_dof_map
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:1934
libMesh::Elem::contains_point
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition: elem.C:2094
libMesh::System::add_variables
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 variable var to the list of variables for this system.
Definition: system.C:1160
libMesh::NumericVector::subset_linfty_norm
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:342
libMesh::System::init
void init()
Initializes degrees of freedom on the current mesh.
Definition: system.C:237
libMesh::System::_assemble_system_function
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:1885
libMesh::DofMap::get_info
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2843
libMesh::System::user_assembly
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
Definition: system.C:1910
libMesh::QBase::n_points
unsigned int n_points() const
Definition: quadrature.h:126
libMesh::DISCRETE_L2
Definition: enum_norm_type.h:53
libMesh::System::get_adjoint_solution
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:957
libMesh::System::system_type
virtual std::string system_type() const
Definition: system.h:495
libMesh::System::_vectors
std::map< std::string, NumericVector< Number > * > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:1985
libMesh::System::get_weighted_sensitivity_adjoint_solution
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:989
libMesh::System::_vector_types
std::map< std::string, ParallelType > _vector_types
Holds the type of a vector.
Definition: system.h:2002
libMesh::ReferenceCountedObject
This class implements reference counting.
Definition: reference_counted_object.h:65
libMesh::System::variable_name
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2203
libMesh::SERIAL
Definition: enum_parallel_type.h:35
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::Elem::dim
virtual unsigned short dim() const =0
libMesh::L1
Definition: enum_norm_type.h:41
libMesh::System::n_vectors
unsigned int n_vectors() const
Definition: system.h:2283
libMesh::System::add_sensitivity_solution
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:894
libMesh::System::restrict_vectors
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:324
libMesh::FEGenericBase
This class forms the foundation from which generic finite elements may be derived.
Definition: exact_error_estimator.h:39
libMesh::H1_SEMINORM
Definition: enum_norm_type.h:43
libMesh::System::identify_variable_groups
bool identify_variable_groups() const
Definition: system.h:2251
libMesh::Order
Order
Definition: enum_order.h:40
libMesh::VariableGroup::name
const std::string & name(unsigned int v) const
Definition: variable.h:246
libMesh::NumericVector::init
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
libMesh::Elem::infinite
virtual bool infinite() const =0
libMesh::FEAbstract::get_JxW
const std::vector< Real > & get_JxW() const
Definition: fe_abstract.h:244
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::FEGenericBase::get_d2phi
const std::vector< std::vector< OutputTensor > > & get_d2phi() const
Definition: fe_base.h:288
libMesh::System::get_adjoint_rhs
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1019
libMesh::GHOSTED
Definition: enum_parallel_type.h:37
libMesh::SensitivityData
Data structure for holding completed parameter sensitivity calculations.
Definition: sensitivity_data.h:46
libMesh::DofMap::process_constraints
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
Definition: dof_map_constraints.C:3334
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::Variable::type
const FEType & type() const
Definition: variable.h:119
libMesh::W2_INF_SEMINORM
Definition: enum_norm_type.h:50
libMesh::H2
Definition: enum_norm_type.h:38
libMesh::System::restrict_solve_to
virtual void restrict_solve_to(const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
After calling this method, any solve will be restricted to the given subdomain.
Definition: system.C:453
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::SystemNorm::weight
Real weight(unsigned int var) const
Definition: system_norm.C:133
libMesh::W1_INF_SEMINORM
Definition: enum_norm_type.h:49
libMesh::System::re_update
virtual void re_update()
Re-update the local values when the mesh has changed.
Definition: system.C:429
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::FEGenericBase::get_dphi
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition: fe_base.h:214
libMesh::System::variable
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2183
libMesh::System::Initialization
Abstract base class to be used for system initialization.
Definition: system.h:119
libMesh::Variable::active_subdomains
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:150
libMesh::System::operator=
System & operator=(const System &)
This isn't a copyable object, so let's make sure nobody tries.
Definition: system.C:114
libMesh::System::~System
virtual ~System()
Destructor.
Definition: system.C:120
libMesh::System::local_dof_indices
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:1259
libMesh::System::n_matrices
virtual unsigned int n_matrices() const
Definition: system.h:2289
libMesh::DofObject::processor_id
processor_id_type processor_id() const
Definition: dof_object.h:829
libMesh::System::QOI::qoi
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::NumericVector::build
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Definition: numeric_vector.C:49
libMesh::System::_init_system_function
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:1874
libMesh::System::attach_constraint_object
void attach_constraint_object(Constraint &constrain)
Register a user object for imposing constraints.
Definition: system.C:1809
libMesh::System::_qoi_evaluate_function
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:1907
libMesh::System::get_weighted_sensitivity_solution
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:931
libMesh::System::vector_name
const std::string & vector_name(const unsigned int vec_num) const
Definition: system.C:820
libMesh::System::assemble
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
Definition: system.C:462
libMesh::NumericVector::size
virtual numeric_index_type size() const =0
libMesh::VectorValue< Number >
libMesh::System::vector_is_adjoint
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:884
libMesh::System::QOIDerivative::qoi_derivative
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
libMesh::NumericVector
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Definition: vector_fe_ex5.C:43
libMesh::System::current_solution
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:194
libMesh::System::n_components
unsigned int n_components() const
Definition: system.h:2171
libMesh::System::_basic_system_only
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2015
libMesh::System::attach_QOI_derivative
void attach_QOI_derivative(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
Register a user function for evaluating derivatives of a quantity of interest with respect to test fu...
Definition: system.C:1861
libMesh::System::zero_variable
void zero_variable(NumericVector< Number > &v, unsigned int var_num) const
Zeroes all dofs in v that correspond to variable number var_num.
Definition: system.C:1300
libMesh::PointLocatorBase::enable_out_of_mesh_mode
virtual void enable_out_of_mesh_mode()=0
Enables out-of-mesh mode.
libMesh::System::add_adjoint_rhs
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1009
libMesh::System::_init_system_object
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:1880
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::IntRange
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition: int_range.h:53
libMesh::FEMNormType
FEMNormType
Definition: enum_norm_type.h:34
libMesh::System::attach_assemble_function
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:1755
libMesh::System::has_variable
bool has_variable(const std::string &var) const
Definition: system.C:1225
libMesh::System::n_variable_groups
unsigned int n_variable_groups() const
Definition: system.h:2163
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::System::QOIDerivative
Abstract base class to be used for derivatives of quantities of interest.
Definition: system.h:215
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::attach_init_object
void attach_init_object(Initialization &init)
Register a user class to use to initialize the system.
Definition: system.C:1739
libMesh::System::reinit_constraints
virtual void reinit_constraints()
Reinitializes the constraints for this system.
Definition: system.C:397
libMesh::System::vectors_end
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2307
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::NumericVector::subset_l2_norm
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:327
libMesh::System::vectors_begin
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2295
libMesh::FEMap::inverse_map
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_map.C:1622
libMesh::TypeVector::norm_sq
auto norm_sq() const -> decltype(std::norm(T()))
Definition: type_vector.h:986
libMesh::System::_mesh
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:1946
libMesh::System::user_QOI
virtual void user_QOI(const QoISet &qoi_indices)
Calls user's attached quantity of interest function, or is overridden by the user in derived classes.
Definition: system.C:1938
libMesh::System::_variables
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:1961
libMesh::ParallelObject::n_processors
processor_id_type n_processors() const
Definition: parallel_object.h:100
libMesh::System::n_local_dofs
dof_id_type n_local_dofs() const
Definition: system.C:187
libMesh::System::_qoi_evaluate_derivative_function
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:1919
libMesh::System::variable_group
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2193
libMesh::QoISet
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition: qoi_set.h:45
libMesh::TypeTensor::norm_sq
auto norm_sq() const -> decltype(std::norm(T()))
Definition: type_tensor.h:1390
libMesh::System::attach_QOI_object
void attach_QOI_object(QOI &qoi)
Register a user object for evaluating the quantities of interest, whose values should be placed in Sy...
Definition: system.C:1845
libMesh::System::get_info
std::string get_info() const
Definition: system.C:1636
libMesh::System::prolong_vectors
virtual void prolong_vectors()
Prolong vectors after the mesh has refined.
Definition: system.C:380
libMesh::System::set_vector_as_adjoint
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:873
libMesh::System::get_mesh
const MeshBase & get_mesh() const
Definition: system.h:2083
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::System::n_local_constrained_dofs
dof_id_type n_local_constrained_dofs() const
Definition: system.C:172
libMesh::System::update_global_solution
void update_global_solution(std::vector< Number > &global_soln) const
Fill the input vector global_soln so that it contains the global solution on all processors.
Definition: system.C:642
libMesh::FEGenericBase::build
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libMesh::System::add_variable
unsigned int add_variable(const std::string &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:1069
libMesh::System::current_local_solution
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:1551
libMesh::System::Constraint::constrain
virtual void constrain()=0
Constraint function.
libMesh::TensorValue
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
Definition: exact_solution.h:53
libMesh::System::get_sensitivity_solution
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:904
libMesh::System::QOI
Abstract base class to be used for quantities of interest.
Definition: system.h:191
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::System::System
System(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
Definition: system.C:61
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::ParameterVector
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
Definition: parameter_vector.h:44
libMesh::TypeVector::add_scaled
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:665
libMesh::MeshBase::elem_dimensions
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:225
libMesh::TypeTensor::add_scaled
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:869
libMesh::DofMap::variable_type
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1924
libMesh::FEType::default_quadrature_rule
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition: fe_type.C:31
libMesh::System::assemble_qoi
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
Definition: system.C:473
libMesh::SystemSubset
This is a base class for classes which represent subsets of the dofs of a System.
Definition: system_subset.h:42
libMesh::NumericVector::l1_norm
virtual Real l1_norm() const =0
libMesh::DofMap::get_send_list
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:496
libMesh::System::attach_QOI_derivative_object
void attach_QOI_derivative_object(QOIDerivative &qoi_derivative)
Register a user object for evaluating derivatives of a quantity of interest with respect to test func...
Definition: system.C:1880
libMesh::H2_SEMINORM
Definition: enum_norm_type.h:44
libMesh::System::qoi_parameter_sensitivity
virtual void qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
Definition: system.C:498
libMesh::System::Assembly
Abstract base class to be used for system assembly.
Definition: system.h:143
libMesh::System::Assembly::assemble
virtual void assemble()=0
Assembly function.
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::System::_assemble_system_object
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:1891
libMesh::DofMap::create_dof_constraints
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints.
Definition: dof_map_constraints.C:1206
libMesh::System::time
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1561
libMesh::System::Constraint
Abstract base class to be used for system constraints.
Definition: system.h:167
libMesh::NumericVector::linfty_norm
virtual Real linfty_norm() const =0
libMesh::System::variable_type
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2233
libMesh::System::discrete_var_norm
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.
Definition: system.C:1337
libMesh::System::_constrain_system_object
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:1902
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::TensorTools::norm_sq
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:85
libMesh::FEType
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
libMesh::System::point_value
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:1971
libMesh::libMeshPrivateData::_is_initialized
bool _is_initialized
Flag that tells if init() has been called.
Definition: libmesh.C:246
libMesh::DISCRETE_L1
Definition: enum_norm_type.h:52
libMesh::FEFamily
FEFamily
Definition: enum_fe_family.h:34
libMesh::NumericVector::set
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
libMesh::System::_qoi_evaluate_derivative_object
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:1928
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::System::init_data
virtual void init_data()
Initializes the data for the system.
Definition: system.C:262
libMesh::System::attach_constraint_function
void attach_constraint_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function for imposing constraints.
Definition: system.C:1790
libMesh::System::request_vector
const NumericVector< Number > * request_vector(const std::string &vec_name) const
Definition: system.C:716
libMesh::System::n_constrained_dofs
dof_id_type n_constrained_dofs() const
Definition: system.C:157
libMesh::System::attach_init_function
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in initializing the system.
Definition: system.C:1720
libMesh::SubsetSolveMode
SubsetSolveMode
Definition: enum_subset_solve_mode.h:35
libMesh::L2
Definition: enum_norm_type.h:36
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::System::variable_number
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1232
libMesh::NumericVector::l2_norm
virtual Real l2_norm() const =0
std::norm
MetaPhysicL::DualNumber< T, D > norm(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::assemble_qoi_derivative
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user qoi derivative function.
Definition: system.C:484
libMesh::System::_equation_systems
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:1940
libMesh::System::calculate_norm
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1356
libMesh::System::clear
virtual void clear()
Clear all the data structures associated with the system.
Definition: system.C:205
libMesh::System::forward_qoi_parameter_sensitivity
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition: system.h:2375
libMesh::System::add_vector
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:661
libMesh::SystemNorm
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
Definition: system_norm.h:51
libMesh::ParallelType
ParallelType
Defines an enum for parallel data structure types.
Definition: enum_parallel_type.h:33
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::System::n_dofs
dof_id_type n_dofs() const
Definition: system.C:150
libMesh::System::user_initialization
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition: system.C:1896
libMesh::System::attach_assemble_object
void attach_assemble_object(Assembly &assemble)
Register a user object to use in assembling the system matrix and RHS.
Definition: system.C:1774
libMesh::System::_qoi_evaluate_object
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:1914
libMesh::FEGenericBase::get_phi
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition: fe_base.h:206
libMesh::H1
Definition: enum_norm_type.h:37
libMesh::VariableGroup::n_variables
unsigned int n_variables() const
Definition: variable.h:217
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::FEAbstract::reinit
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)=0
This is at the core of this class.
libMesh::ParallelObject
An object whose state is distributed along a set of processors.
Definition: parallel_object.h:55
libMesh::System::user_constrain
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition: system.C:1924
libMesh::System::add_weighted_sensitivity_solution
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:924
libMesh::System::get_all_variable_numbers
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:1240
libMesh::Tensor
NumberTensorValue Tensor
Definition: exact_solution.h:56
libMesh::System::vector_preservation
bool vector_preservation(const std::string &vec_name) const
Definition: system.C:863
fptr
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libMesh::System::Initialization::initialize
virtual void initialize()=0
Initialization function.
libMesh::TypeVector::norm
auto norm() const -> decltype(std::norm(T()))
Definition: type_vector.h:955
libMesh::System::add_weighted_sensitivity_adjoint_solution
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:977
libMesh::System::remove_vector
void remove_vector(const std::string &vec_name)
Removes the additional vector vec_name from this system.
Definition: system.C:699
libMesh::VariableGroup
This class defines a logically grouped set of variables in the system.
Definition: variable.h:172
libMesh::out
OStreamProxy out
libMesh::System::user_QOI_derivative
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user's attached quantity of interest derivative function, or is overridden by the user in deriv...
Definition: system.C:1952
libMesh::NumericVector::subset_l1_norm
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:312
libMesh::PointLocatorBase
This is the base class for point locators.
Definition: point_locator_base.h:62
libMesh::System::get_vector
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
libMesh::System::_variable_numbers
std::map< std::string, unsigned short int > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition: system.h:1972
libMesh::TypeTensor::norm
auto norm() const -> decltype(std::norm(T()))
Definition: type_tensor.h:1310
libMesh::System::update
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:408
libMesh::System::add_sensitivity_rhs
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1039
libMesh::System::_solution_projection
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2009
libMesh::QoISet::size
std::size_t size(const System &sys) const
Definition: qoi_set.C:35
libMesh::System::point_gradient
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2100
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::System::point_hessian
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2244
libMesh::System::_sys_name
const std::string _sys_name
A name associated with this system.
Definition: system.h:1951
libMesh::System::const_vectors_iterator
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:757
libMesh::System::adjoint_qoi_parameter_sensitivity
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition: system.h:2366
libMesh::DofMap::variable_group
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1884
libMesh::closed
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:272
libMesh::FEComputeData::enable_derivative
void enable_derivative()
Enable the computation of shape gradients (dshape).
Definition: fe_compute_data.C:75
libMesh::FEComputeData::local_transform
std::vector< std::vector< Real > > local_transform
Storage for local to global mapping at p.
Definition: fe_compute_data.h:96
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692
libMesh::FEInterface::compute_data
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
Definition: fe_interface.C:1028
libMesh::FEComputeData::dshape
std::vector< Gradient > dshape
Storage for the computed shape derivative values.
Definition: fe_compute_data.h:86
libMesh::System::_vector_is_adjoint
std::map< std::string, int > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
Definition: system.h:1997