21#include "libmesh/dof_map.h"
22#include "libmesh/equation_systems.h"
23#include "libmesh/int_range.h"
24#include "libmesh/libmesh_logging.h"
25#include "libmesh/mesh_base.h"
26#include "libmesh/numeric_vector.h"
27#include "libmesh/parameter_vector.h"
28#include "libmesh/point.h"
29#include "libmesh/point_locator_base.h"
30#include "libmesh/qoi_set.h"
31#include "libmesh/enum_to_string.h"
32#include "libmesh/sparse_matrix.h"
33#include "libmesh/system.h"
34#include "libmesh/system_norm.h"
35#include "libmesh/utility.h"
36#include "libmesh/elem.h"
37#include "libmesh/fe_type.h"
38#include "libmesh/fe_interface.h"
39#include "libmesh/fe_compute_data.h"
40#include "libmesh/static_condensation.h"
41#include "libmesh/static_condensation_dof_map.h"
44#include "libmesh/fe_base.h"
45#include "libmesh/fe_interface.h"
46#include "libmesh/parallel.h"
47#include "libmesh/parallel_algebra.h"
48#include "libmesh/quadrature.h"
49#include "libmesh/tensor_value.h"
50#include "libmesh/vector_value.h"
51#include "libmesh/tensor_tools.h"
52#include "libmesh/enum_norm_type.h"
53#include "libmesh/enum_fe_family.h"
65 const std::string & name_in,
66 const unsigned int number_in) :
69 assemble_before_solve (true),
70 use_fixed_solution (false),
71 extra_quadrature_order (0),
75 _init_system_function (nullptr),
76 _init_system_object (nullptr),
77 _assemble_system_function (nullptr),
78 _assemble_system_object (nullptr),
79 _constrain_system_function (nullptr),
80 _constrain_system_object (nullptr),
81 _qoi_evaluate_function (nullptr),
82 _qoi_evaluate_object (nullptr),
83 _qoi_evaluate_derivative_function (nullptr),
84 _qoi_evaluate_derivative_object (nullptr),
85 _dof_map (
std::make_unique<
DofMap>(number_in, es.get_mesh())),
86 _equation_systems (es),
87 _mesh (es.get_mesh()),
89 _sys_number (number_in),
91 _matrices_initialized (false),
92 _solution_projection (true),
93 _basic_system_only (false),
94 _is_initialized (false),
95 _additional_data_written (false),
96 adjoint_already_solved (false),
98 project_with_constraints (true),
99 _prefer_hash_table_matrix_assembly(false),
100 _require_sparsity_pattern (false),
101 _prefix_with_name (false)
127#ifdef LIBMESH_ENABLE_CONSTRAINTS
129 return _dof_map->n_constrained_dofs();
142#ifdef LIBMESH_ENABLE_CONSTRAINTS
144 return _dof_map->n_local_constrained_dofs();
165 libmesh_assert_less (global_dof_number,
_dof_map->n_dofs());
209 parallel_object_only();
218 auto max_allowed_id =
solution->max_allowed_id();
219 libmesh_error_msg_if(total_dofs > max_allowed_id,
220 "Cannot allocate a NumericVector with " << total_dofs <<
" degrees of freedom. "
221 "The vector can only index up to " << max_allowed_id <<
" entries.");
232 _dof_map->reinit_static_condensation();
238#ifdef LIBMESH_ENABLE_GHOSTED
251 for (
auto & [vec_name, vec] :
_vectors)
258#ifdef LIBMESH_ENABLE_GHOSTED
263 libmesh_error_msg(
"Cannot initialize ghosted vectors when they are not enabled.");
268 vec->init (this->
n_dofs(),
false, type);
272 libmesh_assert_equal_to(type,
PARALLEL);
291 parallel_object_only();
313 parallel_object_only();
328 if (
_matrices.begin()->second->initialized())
349 const bool use_hash =
350 pr.second->use_hash_table() ||
352 pr.second->use_hash_table(use_hash);
354 if (pr.second->require_sparsity_pattern())
376 parallel_object_only();
378#ifdef LIBMESH_ENABLE_AMR
380 for (
auto & [vec_name, vec] :
_vectors)
394#ifdef LIBMESH_ENABLE_GHOSTED
399 libmesh_error_msg(
"Cannot initialize ghosted vectors when they are not enabled.");
407 const std::vector<dof_id_type> & send_list =
_dof_map->get_send_list ();
416#ifdef LIBMESH_ENABLE_GHOSTED
434#ifdef LIBMESH_ENABLE_AMR
444 parallel_object_only();
485 parallel_object_only();
487#ifdef LIBMESH_ENABLE_CONSTRAINTS
500 parallel_object_only();
504 const std::vector<dof_id_type> & send_list =
_dof_map->get_send_list ();
510 libmesh_assert_less_equal (send_list.size(),
solution->size());
523 parallel_object_only();
536 libmesh_assert_less_equal (send_list.size(),
solution->size());
548 if (subset !=
nullptr)
549 libmesh_not_implemented();
557 LOG_SCOPE(
"assemble()",
"System");
568 LOG_SCOPE(
"assemble_qoi()",
"System");
577 bool include_liftfunc,
578 bool apply_constraints)
581 LOG_SCOPE(
"assemble_qoi_derivative()",
"System");
595 if (qoi_indices.
size(*
this) > parameters_vec.
size())
607 const Real threshold,
608 const bool verbose)
const
617 libMesh::out <<
" comparing matrices not supported." << std::endl;
622 const int name_result =
_sys_name.compare(other_system.
name());
625 if (name_result == 0)
639 if (solu_result == -1)
640 libMesh::out <<
" identical up to threshold." << std::endl;
642 libMesh::out <<
" first difference occurred at index = "
643 << solu_result <<
"." << std::endl;
649 std::vector<int> ov_result;
655 libMesh::out <<
" Fatal difference. This system handles "
656 << this->
n_vectors() <<
" add'l vectors," << std::endl
657 <<
" while the other system handles "
659 <<
" add'l vectors." << std::endl
660 <<
" Aborting comparison." << std::endl;
672 for (
auto & [vec_name, vec] :
_vectors)
676 << vec_name <<
"\" ...";
682 ov_result.push_back(vec->compare(other_system_vector, threshold));
686 if (ov_result[ov_result.size()-1] == -1)
687 libMesh::out <<
" identical up to threshold." << std::endl;
689 libMesh::out <<
" first difference occurred at" << std::endl
690 <<
" index = " << ov_result[ov_result.size()-1] <<
"." << std::endl;
699 if ((name_result==0) && (solu_result==-1))
701 if (ov_result.size()==0)
702 overall_result =
true;
709 ov_identical = (ov_result[n]==-1);
712 while (ov_identical && n<ov_result.size());
713 overall_result = ov_identical;
717 overall_result =
false;
723 libMesh::out <<
"found no differences." << std::endl << std::endl;
725 libMesh::out <<
"found differences." << std::endl << std::endl;
728 return overall_result;
735 parallel_object_only();
737 global_soln.resize (
solution->size());
747 parallel_object_only();
749 global_soln.resize (
solution->size());
751 solution->localize_to_one (global_soln, dest_proc);
757 const bool projections,
760 parallel_object_only();
767 if (
auto it = this->
_vectors.find(vec_name);
784 libmesh_assert_equal_to(type ==
SERIAL,
802#ifdef LIBMESH_ENABLE_GHOSTED
807 libmesh_error_msg(
"Cannot initialize ghosted vectors when they are not enabled.");
835 auto buf = pr.first->second.
get();
846#ifdef LIBMESH_ENABLE_GHOSTED
851 libmesh_error_msg(
"Cannot initialize ghosted vectors when they are not enabled.");
863 parallel_object_only();
865 if (
const auto pos =
_vectors.find(vec_name);
881 if (
const auto pos =
_vectors.find(vec_name);
883 return pos->second.
get();
893 if (
auto pos =
_vectors.find(vec_name);
895 return pos->second.
get();
911 std::advance(it, vec_num);
912 return it->second.get();
925 std::advance(it, vec_num);
926 return it->second.get();
933 return *(libmesh_map_find(
_vectors, vec_name));
940 return *(libmesh_map_find(
_vectors, vec_name));
948 libmesh_assert_less(vec_num,
_vectors.size());
952 std::advance(it, vec_num);
953 return *(it->second);
961 libmesh_assert_less(vec_num,
_vectors.size());
965 std::advance(it, vec_num);
966 return *(it->second);
974 libmesh_assert_less(vec_num,
_vectors.size());
978 std::advance(it, vec_num);
986 [&vec_reference](
const decltype(
_vectors)::value_type & pr)
987 {
return &vec_reference == pr.second.
get(); });
1002 parallel_object_only();
1009 if (
auto it = this->
_matrices.find(mat_name);
1014 std::unique_ptr<SparseMatrix<Number>> matrix;
1019 "We do not currently support static condensation of the diagonal matrix type");
1020 matrix = std::make_unique<StaticCondensation>(this->
get_mesh(),
1027 auto & mat = *matrix;
1029 _matrices.emplace(mat_name, std::move(matrix));
1045 parallel_object_only();
1047 const std::string namestr{mat_name};
1078 parallel_object_only();
1080 if (
const auto pos =
_matrices.find(mat_name);
1089 if (
const auto pos =
_matrices.find(mat_name);
1091 return pos->second.get();
1101 if (
auto pos =
_matrices.find(mat_name);
1103 return pos->second.get();
1113 return *libmesh_map_find(
_matrices, mat_name);
1120 return *libmesh_map_find(
_matrices, mat_name);
1128 parallel_object_only();
1150 parallel_object_only();
1154 libmesh_assert_greater_equal(qoi_num, -2);
1171 std::ostringstream sensitivity_name;
1172 sensitivity_name <<
"sensitivity_solution" << i;
1174 return this->
add_vector(sensitivity_name.str());
1181 std::ostringstream sensitivity_name;
1182 sensitivity_name <<
"sensitivity_solution" << i;
1184 return this->
get_vector(sensitivity_name.str());
1191 std::ostringstream sensitivity_name;
1192 sensitivity_name <<
"sensitivity_solution" << i;
1194 return this->
get_vector(sensitivity_name.str());
1201 return this->
add_vector(
"weighted_sensitivity_solution");
1208 return this->
get_vector(
"weighted_sensitivity_solution");
1215 return this->
get_vector(
"weighted_sensitivity_solution");
1222 std::ostringstream adjoint_name;
1223 adjoint_name <<
"adjoint_solution" << i;
1234 std::ostringstream adjoint_name;
1235 adjoint_name <<
"adjoint_solution" << i;
1244 std::ostringstream adjoint_name;
1245 adjoint_name <<
"adjoint_solution" << i;
1254 std::ostringstream adjoint_name;
1255 adjoint_name <<
"weighted_sensitivity_adjoint_solution" << i;
1266 std::ostringstream adjoint_name;
1267 adjoint_name <<
"weighted_sensitivity_adjoint_solution" << i;
1276 std::ostringstream adjoint_name;
1277 adjoint_name <<
"weighted_sensitivity_adjoint_solution" << i;
1286 std::ostringstream adjoint_rhs_name;
1287 adjoint_rhs_name <<
"adjoint_rhs" << i;
1289 return this->
add_vector(adjoint_rhs_name.str(),
false);
1296 std::ostringstream adjoint_rhs_name;
1297 adjoint_rhs_name <<
"adjoint_rhs" << i;
1299 return this->
get_vector(adjoint_rhs_name.str());
1306 std::ostringstream adjoint_rhs_name;
1307 adjoint_rhs_name <<
"adjoint_rhs" << i;
1309 return this->
get_vector(adjoint_rhs_name.str());
1316 std::ostringstream sensitivity_rhs_name;
1317 sensitivity_rhs_name <<
"sensitivity_rhs" << i;
1319 return this->
add_vector(sensitivity_rhs_name.str(),
false);
1326 std::ostringstream sensitivity_rhs_name;
1327 sensitivity_rhs_name <<
"sensitivity_rhs" << i;
1329 return this->
get_vector(sensitivity_rhs_name.str());
1336 std::ostringstream sensitivity_rhs_name;
1337 sensitivity_rhs_name <<
"sensitivity_rhs" << i;
1339 return this->
get_vector(sensitivity_rhs_name.str());
1346 const std::set<subdomain_id_type> *
const active_subdomains)
1356 const std::set<subdomain_id_type> *
const active_subdomains,
1357 const bool p_refinement)
1360 FEType(order, family).set_p_refinement(p_refinement),
1368 const std::set<subdomain_id_type> *
const active_subdomains)
1378 const std::set<subdomain_id_type> *
const active_subdomains,
1379 const bool p_refinement)
1382 FEType(order, family).set_p_refinement(p_refinement),
1388 const std::set<subdomain_id_type> *
const active_subdomains)
1410 std::set<dof_id_type> & var_indices)
const
1413 var_indices.clear();
1415 std::vector<dof_id_type> dof_indices;
1422 for (
const auto & elem : this->
get_mesh().active_local_element_ptr_range())
1428 if (first_local <= dof && dof < end_local)
1429 var_indices.insert(dof);
1438 for (
const auto & node : this->
get_mesh().local_node_ptr_range())
1442 for (
auto dof : dof_indices)
1443 if (first_local <= dof && dof < end_local)
1444 var_indices.insert(dof);
1451 unsigned int var_num)
const
1454 libmesh_assert_less (var_num, this->
n_vars());
1460 const unsigned int sys_num = this->
number();
1463 for (
const auto & node :
mesh.local_node_ptr_range())
1465 unsigned int n_comp = node->n_comp(sys_num,var_num);
1466 for (
unsigned int i=0; i<n_comp; i++)
1468 const dof_id_type index = node->dof_number(sys_num,var_num,i);
1475 (
mesh.active_local_element_stored_range(),
1478 for (const Elem * elem : range)
1480 unsigned int n_comp = elem->n_comp(sys_num,var_num);
1481 for (unsigned int i=0; i<n_comp; i++)
1483 const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1496 std::set<dof_id_type> var_indices;
1497 local_dof_indices(var, var_indices);
1506 libmesh_error_msg(
"Invalid norm_type = " << Utility::enum_to_string(norm_type));
1514 std::set<unsigned int> * skip_dimensions)
const
1520 return discrete_var_norm(v,var,norm_type);
1523 std::vector<FEMNormType> norms(this->
n_vars(),
L2);
1524 std::vector<Real> weights(this->
n_vars(), 0.0);
1525 norms[var] = norm_type;
1527 Real val = this->calculate_norm(v,
SystemNorm(norms, weights), skip_dimensions);
1535 std::set<unsigned int> * skip_dimensions)
const
1538 parallel_object_only();
1540 LOG_SCOPE (
"calculate_norm()",
"System");
1545 if (norm.is_discrete())
1549 unsigned int check_var = 0, check_end = this->
n_vars();
1550 for (; check_var != check_end; ++check_var)
1551 if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1555 if (check_var == this->
n_vars())
1564 libmesh_error_msg(
"Invalid norm_type0 = " << Utility::enum_to_string(norm_type0));
1570 if (norm.
weight(var) == 0.0)
1573 v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1581 local_v->init(v.
size(), v.
local_size(), _dof_map->get_send_list(),
1583 v.
localize (*local_v, _dof_map->get_send_list());
1589 bool using_hilbert_norm =
true,
1590 using_nonhilbert_norm =
true;
1596 Real norm_weight_sq = norm.weight_sq(var);
1597 if (norm_weight_sq == 0.0)
1599 Real norm_weight = norm.weight(var);
1603 if ((norm_type==
H1) ||
1609 if (!using_hilbert_norm)
1610 libmesh_not_implemented();
1611 using_nonhilbert_norm =
false;
1613 else if ((norm_type==
L1) ||
1614 (norm_type==
L_INF) ||
1618 if (!using_nonhilbert_norm)
1619 libmesh_not_implemented();
1620 using_hilbert_norm =
false;
1623 libmesh_not_implemented();
1625 const FEType & fe_type = this->get_dof_map().variable_type(var);
1629 std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1630 std::vector<std::unique_ptr<FEVectorBase>> vec_fe_ptrs(4);
1631 std::vector<std::unique_ptr<QBase>> q_rules(4);
1633 const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1636 for (
const auto &
dim : elem_dims)
1638 if (skip_dimensions && skip_dimensions->find(
dim) != skip_dimensions->end())
1644 const FEFieldType field_type = FEInterface::field_type(fe_type);
1647 fe_ptrs[
dim] = FEBase::build(
dim, fe_type);
1648 fe_ptrs[
dim]->attach_quadrature_rule (q_rules[
dim].get());
1652 vec_fe_ptrs[
dim] = FEVectorBase::build(
dim, fe_type);
1653 vec_fe_ptrs[
dim]->attach_quadrature_rule (q_rules[
dim].get());
1659 std::vector<dof_id_type> dof_indices;
1662 for (
const auto & elem : this->get_mesh().active_local_element_ptr_range())
1664 const unsigned int dim = elem->dim();
1669 if (elem->infinite() )
1670 libmesh_not_implemented();
1672 if (skip_dimensions && skip_dimensions->find(
dim) != skip_dimensions->end())
1675 QBase * qrule = q_rules[
dim].get();
1678 this->get_dof_map().dof_indices (elem, dof_indices, var);
1680 auto element_calculation = [&dof_indices, &elem,
1681 norm_type, norm_weight, norm_weight_sq, &qrule,
1682 &local_v, &v_norm](
auto & fe) {
1683 typedef typename std::remove_reference<
decltype(fe)>::type::OutputShape OutputShape;
1685 typedef typename std::remove_reference<
decltype(fe)>::type::OutputGradient OutputGradient;
1688 const std::vector<Real> & JxW = fe.get_JxW();
1689 const std::vector<std::vector<OutputShape>> * phi =
nullptr;
1690 if (norm_type ==
H1 ||
1695 phi = &(fe.get_phi());
1697 const std::vector<std::vector<OutputGradient>> * dphi =
nullptr;
1698 if (norm_type ==
H1 ||
1702 dphi = &(fe.get_dphi());
1704#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1705 typedef typename std::remove_reference<
decltype(fe)>::type::OutputTensor OutputTensor;
1707 const std::vector<std::vector<OutputTensor>> * d2phi =
nullptr;
1708 if (norm_type ==
H2 ||
1711 d2phi = &(fe.get_d2phi());
1716 const unsigned int n_qp = qrule->
n_points();
1718 const unsigned int n_sf = cast_int<unsigned int>
1719 (dof_indices.size());
1722 for (
unsigned int qp=0; qp<n_qp; qp++)
1724 if (norm_type ==
L1)
1726 OutputNumberShape u_h = 0.;
1727 for (
unsigned int i=0; i != n_sf; ++i)
1728 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1729 v_norm += norm_weight *
1730 JxW[qp] * TensorTools::norm(u_h);
1733 if (norm_type ==
L_INF)
1735 OutputNumberShape u_h = 0.;
1736 for (
unsigned int i=0; i != n_sf; ++i)
1737 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1738 v_norm = std::max(v_norm, norm_weight * TensorTools::norm(u_h));
1741 if (norm_type ==
H1 ||
1745 OutputNumberShape u_h = 0.;
1746 for (
unsigned int i=0; i != n_sf; ++i)
1747 u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1748 v_norm += norm_weight_sq *
1749 JxW[qp] * TensorTools::norm_sq(u_h);
1752 if (norm_type ==
H1 ||
1756 OutputNumberGradient grad_u_h;
1757 for (
unsigned int i=0; i != n_sf; ++i)
1758 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1759 v_norm += norm_weight_sq *
1760 JxW[qp] * grad_u_h.norm_sq();
1765 OutputNumberGradient grad_u_h;
1766 for (
unsigned int i=0; i != n_sf; ++i)
1767 grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1768 v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1771#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1774 if (norm_type ==
H2 ||
1777 OutputNumberTensor hess_u_h;
1778 for (
unsigned int i=0; i != n_sf; ++i)
1779 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1780 v_norm += norm_weight_sq *
1781 JxW[qp] * hess_u_h.norm_sq();
1786 OutputNumberTensor hess_u_h;
1787 for (
unsigned int i=0; i != n_sf; ++i)
1788 hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1789 v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1795 FEBase * scalar_fe = fe_ptrs[
dim].get();
1801 element_calculation(*scalar_fe);
1807 element_calculation(*vec_fe);
1812 if (using_hilbert_norm)
1814 this->comm().sum(v_norm);
1815 v_norm = std::sqrt(v_norm);
1819 this->comm().max(v_norm);
1827std::string System::get_info()
const
1829 std::ostringstream oss;
1832 const std::string & sys_name = this->name();
1834 oss <<
" System #" << this->number() <<
", \"" << sys_name <<
"\"\n"
1835 <<
" Type \"" << this->system_type() <<
"\"\n"
1838 for (
auto vg :
make_range(this->n_variable_groups()))
1840 const VariableGroup & vg_description (this->variable_group(vg));
1842 if (vg_description.
n_variables() > 1) oss <<
"{ ";
1844 oss <<
"\"" << vg_description.
name(vn) <<
"\" ";
1845 if (vg_description.
n_variables() > 1) oss <<
"} ";
1850 oss <<
" Finite Element Types=";
1851#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1852 for (
auto vg :
make_range(this->n_variable_groups()))
1854 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1857 for (
auto vg :
make_range(this->n_variable_groups()))
1860 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1862 << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1866 oss <<
'\n' <<
" Infinite Element Mapping=";
1867 for (
auto vg :
make_range(this->n_variable_groups()))
1869 << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1875 oss <<
" Approximation Orders=";
1876 for (
auto vg :
make_range(this->n_variable_groups()))
1878#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1880 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1884 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1886 << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1893 if (this->is_initialized())
1895 oss <<
" n_dofs()=" << this->n_dofs() <<
'\n';
1897 oss <<
" n_local_dofs()=" << local_dofs <<
'\n';
1898 this->comm().max(local_dofs);
1899 oss <<
" max(n_local_dofs())=" << local_dofs <<
'\n';
1900#ifdef LIBMESH_ENABLE_CONSTRAINTS
1901 if (this->n_constrained_dofs())
1903 oss <<
" n_constrained_dofs()=" << this->n_constrained_dofs() <<
'\n';
1904 oss <<
" n_local_constrained_dofs()=" << this->n_local_constrained_dofs() <<
'\n';
1905 dof_id_type local_unconstrained_dofs = this->n_local_dofs() - this->n_local_constrained_dofs();
1906 this->comm().max(local_unconstrained_dofs);
1907 oss <<
" max(local unconstrained dofs)=" << local_unconstrained_dofs <<
'\n';
1910 if (this->has_static_condensation())
1911 oss <<
" n uncondensed dofs="
1912 << this->get_dof_map().get_static_condensation().n_dofs() <<
'\n';
1915 oss <<
" (still uninitialized)\n";
1917 oss <<
" " <<
"n_vectors()=" << this->n_vectors() <<
'\n';
1918 oss <<
" " <<
"n_matrices()=" << this->n_matrices() <<
'\n';
1921 oss << this->get_dof_map().get_info();
1929 const std::string & name))
1933 if (_init_system_object !=
nullptr)
1935 libmesh_warning(
"WARNING: Cannot specify both initialization function and object!");
1937 _init_system_object =
nullptr;
1940 _init_system_function =
fptr;
1947 if (_init_system_function !=
nullptr)
1949 libmesh_warning(
"WARNING: Cannot specify both initialization object and function!");
1951 _init_system_function =
nullptr;
1954 _init_system_object = &init_in;
1960 const std::string & name))
1964 if (_assemble_system_object !=
nullptr)
1966 libmesh_warning(
"WARNING: Cannot specify both assembly function and object!");
1968 _assemble_system_object =
nullptr;
1971 _assemble_system_function =
fptr;
1978 if (_assemble_system_function !=
nullptr)
1980 libmesh_warning(
"WARNING: Cannot specify both assembly object and function!");
1982 _assemble_system_function =
nullptr;
1985 _assemble_system_object = &assemble_in;
1991 const std::string & name))
1995 if (_constrain_system_object !=
nullptr)
1997 libmesh_warning(
"WARNING: Cannot specify both constraint function and object!");
1999 _constrain_system_object =
nullptr;
2002 _constrain_system_function =
fptr;
2009 if (_constrain_system_function !=
nullptr)
2011 libmesh_warning(
"WARNING: Cannot specify both constraint object and function!");
2013 _constrain_system_function =
nullptr;
2016 _constrain_system_object = &constrain;
2019bool System::has_constraint_object ()
const
2021 return _constrain_system_object !=
nullptr;
2026 libmesh_assert_msg(_constrain_system_object,
"No constraint object available.");
2027 return *_constrain_system_object;
2033 const std::string &,
2038 if (_qoi_evaluate_object !=
nullptr)
2040 libmesh_warning(
"WARNING: Cannot specify both QOI function and object!");
2042 _qoi_evaluate_object =
nullptr;
2045 _qoi_evaluate_function =
fptr;
2050void System::attach_QOI_object (
QOI & qoi_in)
2052 if (_qoi_evaluate_function !=
nullptr)
2054 libmesh_warning(
"WARNING: Cannot specify both QOI object and function!");
2056 _qoi_evaluate_function =
nullptr;
2059 _qoi_evaluate_object = &qoi_in;
2065 const QoISet &,
bool,
bool))
2069 if (_qoi_evaluate_derivative_object !=
nullptr)
2071 libmesh_warning(
"WARNING: Cannot specify both QOI derivative function and object!");
2073 _qoi_evaluate_derivative_object =
nullptr;
2076 _qoi_evaluate_derivative_function =
fptr;
2083 if (_qoi_evaluate_derivative_function !=
nullptr)
2085 libmesh_warning(
"WARNING: Cannot specify both QOI derivative object and function!");
2087 _qoi_evaluate_derivative_function =
nullptr;
2090 _qoi_evaluate_derivative_object = &qoi_derivative;
2095void System::user_initialization ()
2099 if (_init_system_function !=
nullptr)
2100 this->_init_system_function (_equation_systems, this->name());
2103 else if (_init_system_object !=
nullptr)
2104 this->_init_system_object->initialize();
2109void System::user_assembly ()
2113 if (_assemble_system_function !=
nullptr)
2114 this->_assemble_system_function (_equation_systems, this->name());
2117 else if (_assemble_system_object !=
nullptr)
2118 this->_assemble_system_object->assemble();
2123void System::user_constrain ()
2127 if (_constrain_system_function!=
nullptr)
2128 this->_constrain_system_function(_equation_systems, this->name());
2131 else if (_constrain_system_object !=
nullptr)
2132 this->_constrain_system_object->constrain();
2137void System::user_QOI (
const QoISet & qoi_indices)
2141 if (_qoi_evaluate_function !=
nullptr)
2142 this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2145 else if (_qoi_evaluate_object !=
nullptr)
2146 this->_qoi_evaluate_object->qoi(qoi_indices);
2151void System::user_QOI_derivative(
const QoISet & qoi_indices,
2152 bool include_liftfunc,
2153 bool apply_constraints)
2157 if (_qoi_evaluate_derivative_function !=
nullptr)
2158 this->_qoi_evaluate_derivative_function
2159 (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2163 else if (_qoi_evaluate_derivative_object !=
nullptr)
2164 this->_qoi_evaluate_derivative_object->qoi_derivative
2165 (qoi_indices, include_liftfunc, apply_constraints);
2169void System::init_qois(
unsigned int n_qois)
2171 _qoi.resize(n_qois);
2172 _qoi_error_estimates.resize(n_qois);
2176void System::set_qoi(
unsigned int qoi_index,
Number qoi_value)
2180 _qoi[qoi_index] = qoi_value;
2184Number System::get_qoi_value(
unsigned int qoi_index)
const
2187 return _qoi[qoi_index];
2191std::vector<Number> System::get_qoi_values()
const
2197void System::set_qoi(std::vector<Number> new_qoi)
2199 libmesh_assert_equal_to(this->_qoi.size(), new_qoi.size());
2200 this->_qoi = std::move(new_qoi);
2204void System::set_qoi_error_estimate(
unsigned int qoi_index,
Number qoi_error_estimate)
2208 _qoi_error_estimates[qoi_index] = qoi_error_estimate;
2211Number System::get_qoi_error_estimate_value(
unsigned int qoi_index)
const
2214 return _qoi_error_estimates[qoi_index];
2221 const bool insist_on_success,
2226 parallel_object_only();
2244 std::unique_ptr<PointLocatorBase> locator_ptr =
mesh.sub_point_locator();
2247 if (!insist_on_success || !
mesh.is_serial())
2252 const std::set<subdomain_id_type> & raw_subdomains =
2253 this->variable(var).active_subdomains();
2254 const std::set<subdomain_id_type> * implicit_subdomains =
2255 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2256 const Elem * e = locator(p, implicit_subdomains);
2260 if (e && this->get_dof_map().is_evaluable(*e, var))
2261 u = point_value(var, p, *e, sol);
2266 this->processor_id() : this->n_processors();
2267 this->comm().min(lowest_owner);
2272 if (lowest_owner != this->n_processors())
2273 this->comm().broadcast(u, lowest_owner);
2291 sol = this->current_local_solution.
get();
2294 const DofMap & dof_map = this->get_dof_map();
2300 std::vector<dof_id_type> dof_indices;
2306 const unsigned int num_dofs = cast_int<unsigned int>
2307 (dof_indices.size());
2312 Point coor = FEMap::inverse_map(e.
dim(), &e, p);
2317 FEInterface::compute_data(e.
dim(), fe_type, &e, fe_data);
2322 for (
unsigned int l=0; l<num_dofs; l++)
2324 u += fe_data.
shape[l] * (*sol)(dof_indices[l]);
2335 return this->point_value(var, p, *e);
2342 return this->point_value(var, p,
true, sol);
2350 const bool insist_on_success,
2355 parallel_object_only();
2373 std::unique_ptr<PointLocatorBase> locator_ptr =
mesh.sub_point_locator();
2376 if (!insist_on_success || !
mesh.is_serial())
2381 const std::set<subdomain_id_type> & raw_subdomains =
2382 this->variable(var).active_subdomains();
2383 const std::set<subdomain_id_type> * implicit_subdomains =
2384 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2385 const Elem * e = locator(p, implicit_subdomains);
2389 if (e && this->get_dof_map().is_evaluable(*e, var))
2390 grad_u = point_gradient(var, p, *e, sol);
2395 this->processor_id() : this->n_processors();
2396 this->comm().min(lowest_owner);
2401 if (lowest_owner != this->n_processors())
2402 this->comm().broadcast(grad_u, lowest_owner);
2421 sol = this->current_local_solution.
get();
2424 const DofMap & dof_map = this->get_dof_map();
2427 const unsigned int dim = e.
dim();
2433 std::vector<dof_id_type> dof_indices;
2439 const unsigned int num_dofs = cast_int<unsigned int>
2440 (dof_indices.size());
2445 Point coor = FEMap::inverse_map(
dim, &e, p);
2451 FEInterface::compute_data(
dim, fe_type, &e, fe_data);
2456 for (
unsigned int l=0; l<num_dofs; l++)
2460 for (std::size_t v=0; v<
dim; v++)
2461 for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2466 * (*sol)(dof_indices[l]);
2478 return this->point_gradient(var, p, *e);
2485 return this->point_gradient(var, p,
true, sol);
2491#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
2492Tensor System::point_hessian(
unsigned int var,
2494 const bool insist_on_success,
2499 parallel_object_only();
2517 std::unique_ptr<PointLocatorBase> locator_ptr =
mesh.sub_point_locator();
2520 if (!insist_on_success || !
mesh.is_serial())
2525 const std::set<subdomain_id_type> & raw_subdomains =
2526 this->variable(var).active_subdomains();
2527 const std::set<subdomain_id_type> * implicit_subdomains =
2528 raw_subdomains.empty() ? nullptr : &raw_subdomains;
2529 const Elem * e = locator(p, implicit_subdomains);
2533 if (e && this->get_dof_map().is_evaluable(*e, var))
2534 hess_u = point_hessian(var, p, *e, sol);
2539 this->processor_id() : this->n_processors();
2540 this->comm().min(lowest_owner);
2545 if (lowest_owner != this->n_processors())
2546 this->comm().broadcast(hess_u, lowest_owner);
2553Tensor System::point_hessian(
unsigned int var,
2564 sol = this->current_local_solution.
get();
2567 libmesh_not_implemented();
2570 const DofMap & dof_map = this->get_dof_map();
2576 std::vector<dof_id_type> dof_indices;
2582 const unsigned int num_dofs = cast_int<unsigned int>
2583 (dof_indices.size());
2588 std::unique_ptr<FEBase> fe (FEBase::build(e.
dim(), fe_type));
2592 std::vector<Point> coor(1, FEMap::inverse_map(e.
dim(), &e, p));
2595 const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2598 fe->reinit (&e, &coor);
2603 for (
unsigned int l=0; l<num_dofs; l++)
2605 hess_u.
add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2616 return this->point_hessian(var, p, *e);
2623 return this->point_hessian(var, p,
true, sol);
2628Tensor System::point_hessian(
unsigned int,
const Point &,
const bool,
2631 libmesh_error_msg(
"We can only accumulate a hessian with --enable-second");
2637Tensor System::point_hessian(
unsigned int,
const Point &,
const Elem &,
2638 const NumericVector<Number> *)
const
2640 libmesh_error_msg(
"We can only accumulate a hessian with --enable-second");
2646Tensor System::point_hessian(
unsigned int,
const Point &,
const Elem *)
const
2648 libmesh_error_msg(
"We can only accumulate a hessian with --enable-second");
2654Tensor System::point_hessian(
unsigned int,
const Point &,
const NumericVector<Number> *)
const
2656 libmesh_error_msg(
"We can only accumulate a hessian with --enable-second");
2664void System::create_static_condensation()
2666 this->get_dof_map().create_static_condensation(this->get_mesh(), *
this);
2669bool System::has_static_condensation()
const
2671 return this->get_dof_map().has_static_condensation();
2674unsigned int System::n_vars()
const
2676 return this->get_dof_map().n_vars();
2679const std::string & System::variable_name (
const unsigned int i)
const
2681 return this->get_dof_map().variable_name(i);
2684bool System::identify_variable_groups ()
const
2686 return this->get_dof_map().identify_variable_groups();
2689void System::identify_variable_groups (
const bool ivg)
2691 this->get_dof_map().identify_variable_groups(ivg);
2694unsigned int System::n_components()
const
2696 return this->get_dof_map().n_components(this->get_mesh());
2699unsigned int System::n_variable_groups()
const
2701 return this->get_dof_map().n_variable_groups();
2704const Variable & System::variable (
const unsigned int i)
const
2706 return this->get_dof_map().variable(i);
2711 return this->get_dof_map().variable_group(vg);
2715System::variable_scalar_number (
unsigned int var_num,
2716 unsigned int component)
const
2718 return this->get_dof_map().variable_scalar_number(var_num, component);
2721const FEType & System::variable_type (
const unsigned int i)
const
2723 return this->get_dof_map().variable_type(i);
2726const FEType & System::variable_type (std::string_view var)
const
2728 return this->get_dof_map().variable_type(var);
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const
This class handles the numbering of degrees of freedom on a mesh.
void reinit_static_condensation()
Calls reinit on the static condensation map if it exists.
const std::vector< dof_id_type > & get_send_list() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
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...
unsigned int add_variables(System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
void clear_sparsity()
Clears the sparsity pattern.
unsigned int add_variable_array(System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds variables vars to the list of variables for this system.
unsigned int add_variable(System &sys, std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
const FEType & variable_type(const unsigned int i) const
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
unsigned int variable_number(std::string_view var) const
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
bool has_variable(std::string_view var) const
processor_id_type processor_id() const
This is the base class from which all geometric element types are derived.
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
virtual unsigned short dim() const =0
virtual bool infinite() const =0
This is the EquationSystems class.
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
std::vector< Gradient > dshape
Storage for the computed shape derivative values.
std::vector< std::vector< Real > > local_transform
Storage for local to global mapping at p.
void enable_derivative()
Enable the computation of shape gradients (dshape).
std::vector< Number > shape
Storage for the computed shape function values.
This class forms the foundation from which generic finite elements may be derived.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
This is the MeshBase class.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
virtual Real l1_norm() const =0
ParallelType type() const
void set_type(ParallelType t)
Allow the user to change the ParallelType of the NumericVector under some circumstances.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
virtual bool initialized() const
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
virtual Real l2_norm() const =0
virtual numeric_index_type size() const =0
virtual Real linfty_norm() const =0
virtual bool closed() const
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
virtual numeric_index_type local_size() const =0
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
An object whose state is distributed along a set of processors.
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
This is the base class for point locators.
virtual void enable_out_of_mesh_mode()=0
Enables out-of-mesh mode.
A Point defines a location in LIBMESH_DIM dimensional Real space.
The QBase class provides the basic functionality from which various quadrature rules can be derived.
unsigned int n_points() const
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
std::size_t size(const System &sys) const
Data structure for holding completed parameter sensitivity calculations.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
virtual bool initialized() const
The StoredRange class defines a contiguous, divisible set of objects.
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
Real weight(unsigned int var) const
This is a base class for classes which represent subsets of the dofs of a System.
Abstract base class to be used for system assembly.
Abstract base class to be used for system constraints.
Abstract base class to be used for system initialization.
Abstract base class to be used for derivatives of quantities of interest.
Abstract base class to be used for quantities of interest.
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned int n_vectors() const
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...
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user qoi derivative function.
const std::string & name() const
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
Number current_solution(const dof_id_type global_dof_number) const
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
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.
vectors_iterator vectors_begin()
Beginning of vectors container.
void remove_matrix(std::string_view mat_name)
Removes the additional matrix mat_name from this system.
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...
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
bool prefix_with_name() const
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.
bool is_initialized() const
void remove_vector(std::string_view vec_name)
Removes the additional vector vec_name from this system.
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
virtual void create_static_condensation()
Request that static condensation be performed for this system.
virtual void qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
dof_id_type n_dofs() const
const std::string & vector_name(const unsigned int vec_num) const
virtual void reinit_mesh()
Reinitializes the system with a new mesh.
virtual void prolong_vectors()
Prolong vectors after the mesh has refined.
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
int vector_is_adjoint(std::string_view vec_name) const
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
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...
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds variables vars to the list of variables for this system.
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
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...
const NumericVector< Number > * request_vector(std::string_view vec_name) const
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 ...
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
virtual void assemble()
Prepares matrix and _dof_map for matrix assembly.
System(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
dof_id_type n_local_dofs() const
void zero_variable(NumericVector< Number > &v, unsigned int var_num) const
Zeroes all dofs in v that correspond to variable number var_num.
dof_id_type n_constrained_dofs() const
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
virtual void clear()
Clear all the data structures associated with the system.
vectors_iterator vectors_end()
End of vectors container.
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
virtual void re_update()
Re-update the local values when the mesh has changed.
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.
void init()
Initializes degrees of freedom on the current mesh.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
virtual void init_matrices()
Initializes the matrices associated with this system.
const std::string _sys_name
A name associated with this system.
virtual void init_data()
Initializes the data for the system.
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
bool vector_preservation(std::string_view vec_name) const
virtual void update()
Update the local values to reflect the solution on neighboring processors.
unsigned int variable_number(std::string_view var) const
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
bool has_static_condensation() const
dof_id_type n_local_constrained_dofs() const
bool has_variable(std::string_view var) const
virtual void reinit_constraints()
Reinitializes the constraints for this system.
NumericVector< Number > & get_weighted_sensitivity_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.
bool _require_sparsity_pattern
Whether any of our matrices require an initial sparsity pattern computation in order to determine pre...
NumericVector< Number > & add_weighted_sensitivity_solution()
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
unsigned int n_vars() const
const DofMap & get_dof_map() const
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
unsigned int number() const
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
const NumericVector< Number > & get_vector(std::string_view vec_name) const
const MeshBase & get_mesh() const
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
This class defines a logically grouped set of variables in the system.
unsigned int n_variables() const
const std::string & name(unsigned int v) const
This class defines the notion of a variable in the system.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
The libMesh namespace provides an interface to certain functionality in the library.
ParallelType
Defines an enum for parallel data structure types.
bool closed()
Checks that the library has been closed.
SubsetSolveMode
defines an enum for the question what happens to the dofs outside the given subset when a system is s...
void libmesh_ignore(const Args &...)
SolverPackage default_solver_package()
MatrixBuildType
Defines an enum for matrix build types.
bool on_command_line(std::string arg)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)