20 #include "libmesh/default_coupling.h" 21 #include "libmesh/dof_map.h" 22 #include "libmesh/eigen_system.h" 23 #include "libmesh/elem.h" 24 #include "libmesh/explicit_system.h" 25 #include "libmesh/fe_interface.h" 26 #include "libmesh/frequency_system.h" 27 #include "libmesh/int_range.h" 28 #include "libmesh/libmesh_logging.h" 29 #include "libmesh/linear_implicit_system.h" 30 #include "libmesh/mesh_base.h" 31 #include "libmesh/mesh_refinement.h" 32 #include "libmesh/newmark_system.h" 33 #include "libmesh/nonlinear_implicit_system.h" 34 #include "libmesh/parallel.h" 35 #include "libmesh/rb_construction.h" 36 #include "libmesh/remote_elem.h" 37 #include "libmesh/transient_rb_construction.h" 38 #include "libmesh/transient_system.h" 47 #include "libmesh/equation_systems.h" 55 _refine_in_reinit(true),
56 _enable_default_ghosting(true)
60 this->
parameters.
set<
unsigned int>(
"linear solver maximum iterations") = 5000;
104 const unsigned int n_sys = this->
n_systems();
106 libmesh_assert_not_equal_to (n_sys, 0);
110 for (
auto & node :
_mesh.node_ptr_range())
111 node->set_n_systems(n_sys);
117 for (
Elem * elem : range)
118 elem->set_n_systems(n_sys);
124 #ifdef LIBMESH_ENABLE_AMR 126 mesh_refine.clean_refinement_flags();
138 parallel_object_only();
140 const unsigned int n_sys = this->
n_systems();
141 libmesh_assert_not_equal_to (n_sys, 0);
144 for (
unsigned int i=0; i != n_sys; ++i)
157 for (
auto & node :
_mesh.node_ptr_range())
158 node->set_n_systems(n_sys);
165 for (
Elem * elem : range)
166 elem->set_n_systems(n_sys);
171 for (
unsigned int i=0; i != n_sys; ++i)
174 #ifdef LIBMESH_ENABLE_AMR 176 bool mesh_changed =
false;
182 for (
unsigned int i=0; i != n_sys; ++i)
260 #endif // #ifdef LIBMESH_ENABLE_AMR 281 const unsigned int n_sys = this->
n_systems();
283 libmesh_assert_not_equal_to (n_sys, 0);
290 for (
auto & node :
_mesh.node_ptr_range())
291 node->set_n_systems(n_sys);
297 for (
Elem * elem : range)
298 elem->set_n_systems(n_sys);
326 mesh.add_ghosting_functor(
mesh.default_ghosting());
328 mesh.remove_ghosting_functor(
mesh.default_ghosting());
344 LOG_SCOPE(
"update()",
"EquationSystems");
354 std::string_view
name)
365 else if (sys_type ==
"Basic")
366 this->add_system<System> (
name);
369 else if (sys_type ==
"Newmark")
370 this->add_system<NewmarkSystem> (
name);
373 else if ((sys_type ==
"Explicit"))
374 this->add_system<ExplicitSystem> (
name);
377 else if ((sys_type ==
"Implicit") ||
378 (sys_type ==
"Steady" ))
379 this->add_system<ImplicitSystem> (
name);
382 else if ((sys_type ==
"Transient") ||
383 (sys_type ==
"TransientImplicit") ||
384 (sys_type ==
"TransientLinearImplicit"))
385 this->add_system<TransientLinearImplicitSystem> (
name);
388 else if (sys_type ==
"TransientNonlinearImplicit")
389 this->add_system<TransientNonlinearImplicitSystem> (
name);
392 else if (sys_type ==
"TransientExplicit")
393 this->add_system<TransientExplicitSystem> (
name);
396 else if (sys_type ==
"LinearImplicit")
397 this->add_system<LinearImplicitSystem> (
name);
400 else if (sys_type ==
"NonlinearImplicit")
401 this->add_system<NonlinearImplicitSystem> (
name);
404 else if (sys_type ==
"RBConstruction")
405 this->add_system<RBConstruction> (
name);
408 else if (sys_type ==
"TransientRBConstruction")
409 this->add_system<TransientRBConstruction> (
name);
411 #ifdef LIBMESH_HAVE_SLEPC 413 else if (sys_type ==
"Eigen")
414 this->add_system<EigenSystem> (
name);
415 else if (sys_type ==
"TransientEigenSystem")
416 this->add_system<TransientEigenSystem> (
name);
419 #if defined(LIBMESH_USE_COMPLEX_NUMBERS) 421 else if (sys_type ==
"Frequency")
422 this->add_system<FrequencySystem> (
name);
426 libmesh_error_msg(
"ERROR: Unknown system type: " << sys_type);
450 this->
get_system(i).sensitivity_solve(parameters_in);
459 for (
unsigned int i=this->
n_systems(); i != 0; --i)
460 this->
get_system(i-1).adjoint_solve(qoi_indices);
467 const std::set<std::string> * system_names)
const 470 unsigned int var_num = var_names.size();
474 std::unordered_multiset<std::string> seen_names;
480 unsigned int n_scalar_vars = 0;
481 unsigned int n_vector_vars = 0;
483 for (
const auto & [sys_name, sys_ptr] :
_systems)
486 bool use_current_system = (system_names ==
nullptr);
487 if (!use_current_system)
488 use_current_system = system_names->count(sys_name);
489 if (!use_current_system || sys_ptr->hide_output())
492 seen_names.insert(sys_ptr->variable_name(vn));
498 seen_names.insert(sys_ptr->variable_name(vn));
509 unsigned int nv = n_scalar_vars +
dim*n_vector_vars;
513 libmesh_assert_less_equal ( nv, (
dim > 0 ?
dim : 1)*this->
n_vars() );
518 var_names.resize( nv );
521 for (
const auto & [sys_name, sys_ptr] :
_systems)
524 bool use_current_system = (system_names ==
nullptr);
525 if (!use_current_system)
526 use_current_system = system_names->count(sys_name);
527 if (!use_current_system || sys_ptr->hide_output())
532 const std::string & var_name = sys_ptr->variable_name(vn);
533 const FEType & fe_type = sys_ptr->variable_type(vn);
538 if (type ==
nullptr || (type && *type == fe_type))
546 var_names[var_num++] = var_name;
547 libmesh_error_msg_if(seen_names.count(var_name) > 1,
548 "Duplicate variable name "+var_name);
551 var_names[var_num++] = var_name+
"_x";
552 var_names[var_num++] = var_name+
"_y";
553 libmesh_error_msg_if(seen_names.count(var_name+
"_x"),
554 "Duplicate variable name "+var_name+
"_x");
555 libmesh_error_msg_if(seen_names.count(var_name+
"_y"),
556 "Duplicate variable name "+var_name+
"_y");
559 var_names[var_num++] = var_name+
"_x";
560 var_names[var_num++] = var_name+
"_y";
561 var_names[var_num++] = var_name+
"_z";
562 libmesh_error_msg_if(seen_names.count(var_name+
"_x"),
563 "Duplicate variable name "+var_name+
"_x");
564 libmesh_error_msg_if(seen_names.count(var_name+
"_y"),
565 "Duplicate variable name "+var_name+
"_y");
566 libmesh_error_msg_if(seen_names.count(var_name+
"_z"),
567 "Duplicate variable name "+var_name+
"_z");
570 libmesh_error_msg(
"Invalid dim in build_variable_names");
574 var_names[var_num++] = var_name;
579 var_names.resize(var_num);
586 std::string_view)
const 589 libmesh_not_implemented();
595 std::unique_ptr<NumericVector<Number>>
597 bool add_sides)
const 599 LOG_SCOPE(
"build_parallel_solution_vector()",
"EquationSystems");
602 parallel_object_only();
622 unsigned int n_scalar_vars = 0;
623 unsigned int n_vector_vars = 0;
624 for (
const auto & [sys_name, sys_ptr] :
_systems)
627 bool use_current_system = (system_names ==
nullptr);
628 if (!use_current_system)
629 use_current_system = system_names->count(sys_name);
630 if (!use_current_system || sys_ptr->hide_output())
643 nv = n_scalar_vars +
dim*n_vector_vars;
649 _mesh.local_nodes_end()));
660 const dof_id_type gaps_per_processor = n_gaps / n_proc;
661 const dof_id_type remainder_gaps = n_gaps % n_proc;
663 n_local_nodes = n_local_nodes +
665 (my_pid < remainder_gaps);
670 added_side_nodes = 0;
673 std::vector<dof_id_type> others_added_side_nodes;
677 std::map<std::tuple<dof_id_type, unsigned short, unsigned short>,
685 std::vector<dof_id_type> true_node_offsets;
687 std::vector<dof_id_type> added_node_offsets;
689 auto node_id_to_vec_id =
690 [&true_node_offsets, &added_node_offsets]
693 if (true_node_offsets.empty())
697 const auto lb = std::upper_bound(true_node_offsets.begin(),
698 true_node_offsets.end(), node_id);
702 return node_id + added_node_offsets[p];
707 true_node_offsets.resize(n_proc);
708 added_node_offsets.resize(n_proc);
711 for (
const auto & elem :
_mesh.active_element_ptr_range())
713 for (
auto s : elem->side_index_range())
718 const std::vector<unsigned int> side_nodes =
719 elem->nodes_on_side(s);
722 local_added_side_nodes += side_nodes.size();
726 others_added_side_nodes.resize(n_proc);
728 others_added_side_nodes);
730 added_side_nodes = std::accumulate(others_added_side_nodes.begin(),
731 others_added_side_nodes.end(), 0,
736 true_node_offsets[p+1] += true_node_offsets[p];
741 added_node_offsets[0] = 0;
743 added_node_offsets[p+1] =
744 added_node_offsets[p] + others_added_side_nodes[p];
749 dof_id_type node_counter = true_node_offsets[my_pid];
751 node_counter += others_added_side_nodes[p];
754 for (
const auto & elem :
_mesh.active_local_element_ptr_range())
756 for (
auto s : elem->side_index_range())
761 const std::vector<unsigned int> side_nodes =
762 elem->nodes_on_side(s);
765 discontinuous_node_indices
766 [std::make_tuple(elem->id(),s,n)] = node_counter++;
772 n_global_vals = (max_nn + added_side_nodes) * nv,
773 n_local_vals = (n_local_nodes + local_added_side_nodes) * nv;
778 parallel_soln.
init(n_global_vals, n_local_vals,
false,
PARALLEL);
784 repeat_count.
init(n_global_vals, n_local_vals,
false,
PARALLEL);
786 repeat_count.
close();
788 unsigned int var_num=0;
795 for (
const auto & [sys_name, sys_ptr] :
_systems)
798 bool use_current_system = (system_names ==
nullptr);
799 if (!use_current_system)
800 use_current_system = system_names->count(sys_name);
801 if (!use_current_system || sys_ptr->hide_output())
804 const System & system = *sys_ptr;
805 const unsigned int nv_sys = system.
n_vars();
806 const unsigned int sys_num = system.
number();
809 unsigned int n_scalar_vars = 0;
810 unsigned int n_vector_vars = 0;
821 unsigned int nv_sys_split = n_scalar_vars +
dim*n_vector_vars;
832 if (!non_const_sys.
solution->closed())
841 std::vector<Number> elem_soln;
842 std::vector<Number> nodal_soln;
843 std::vector<dof_id_type> dof_indices;
845 unsigned var_inc = 0;
846 for (
unsigned int var=0; var<nv_sys; var++)
853 for (
const auto & elem :
_mesh.active_local_element_ptr_range())
858 sys_soln.
get(dof_indices, elem_soln);
869 if (!elem->infinite())
871 libmesh_assert_equal_to (nodal_soln.size(), n_vec_dim*elem->n_nodes());
873 for (
auto n : elem->node_index_range())
875 const Node & node = elem->node_ref(n);
878 nv * node_id_to_vec_id(node.
id());
880 for (
unsigned int d=0; d < n_vec_dim; d++)
884 parallel_soln.
add(node_idx + (var_inc+d + var_num), nodal_soln[n_vec_dim*n+d]);
887 repeat_count.
add(node_idx + (var_inc+d + var_num), 1);
893 for (
auto s : elem->side_index_range())
901 (fe_type, elem, s, elem_soln,
902 nodal_soln, add_p_level, n_vec_dim);
905 const std::vector<unsigned int> side_nodes =
906 elem->nodes_on_side(s);
908 libmesh_assert_equal_to
916 std::size_t node_index =
917 nv * libmesh_map_find(discontinuous_node_indices,
918 std::make_tuple(elem->id(), s, n));
920 for (
unsigned int d=0; d < n_vec_dim; d++)
922 parallel_soln.
add(node_index + (var_inc+d + var_num), nodal_soln[n_vec_dim*n+d]);
923 repeat_count.
add(node_index + (var_inc+d + var_num), 1);
931 for (
auto n : elem->node_index_range())
933 const Node & node = elem->node_ref(n);
937 if (!node.
n_dofs(sys_num, var))
940 nv * node_id_to_vec_id(node.
id());
942 for (
unsigned int d=0; d < n_vec_dim; d++)
943 repeat_count.
add(node_idx + (var_inc+d + var_num), 1);
948 var_inc += n_vec_dim;
951 var_num += nv_sys_split;
955 parallel_soln.
close();
956 repeat_count.
close();
970 if (std::abs(repeat_count(i)) <
TOLERANCE)
971 repeat_count.
set(i, 1.);
976 repeat_count.
close();
980 parallel_soln /= repeat_count;
982 return parallel_soln_ptr;
988 const std::set<std::string> * system_names,
989 bool add_sides)
const 991 LOG_SCOPE(
"build_solution_vector()",
"EquationSystems");
994 std::unique_ptr<NumericVector<Number>> parallel_soln =
998 parallel_soln->localize_to_one(soln);
1004 std::vector<std::set<subdomain_id_type>> & vars_active_subdomains)
const 1006 vars_active_subdomains.clear();
1007 vars_active_subdomains.resize(names.size());
1011 const auto & sys_ptr = pr.second;
1012 for (
auto vn :
make_range(sys_ptr->n_vars()))
1014 const std::string & var_name = sys_ptr->variable_name(vn);
1016 auto names_it = std::find(names.begin(), names.end(), var_name);
1017 if(names_it != names.end())
1019 const Variable & variable = sys_ptr->variable(vn);
1020 const std::set<subdomain_id_type> & active_subdomains = variable.
active_subdomains();
1021 vars_active_subdomains[
std::distance(names.begin(), names_it)] = active_subdomains;
1031 std::vector<std::string> & names)
const 1034 std::unique_ptr<NumericVector<Number>> parallel_soln =
1044 parallel_soln->localize_to_one(soln);
1047 std::vector<std::pair<unsigned int, unsigned int>>
1049 (std::vector<std::string> & names,
const FEType * type,
const std::vector<FEType> * types)
const 1052 parallel_object_only();
1057 libmesh_assert_msg(!type || !types,
1058 "Input 'type', 'types', or neither in find_variable_numbers, but not both.");
1060 std::vector<FEType> type_filter;
1062 type_filter.push_back(*type);
1064 type_filter = *types;
1070 std::vector<std::string> name_filter = names;
1071 bool is_names_empty = name_filter.empty();
1078 const std::vector<std::string> component_suffix = {
"_x",
"_y",
"_z"};
1079 unsigned int dim = _mesh.spatial_dimension();
1080 libmesh_error_msg_if(
dim > 3,
"Invalid dim in find_variable_numbers");
1084 std::vector<std::pair<unsigned int, unsigned int>> var_nums;
1086 for (
const auto & pr : _systems)
1088 const System & system = *(pr.second);
1094 if (type_filter.size() &&
1095 std::find(type_filter.begin(), type_filter.end(), var_type) == type_filter.end())
1101 std::vector<std::string> component_names;
1102 for (
unsigned int comp = 0; comp <
dim; ++comp)
1105 if (is_names_empty ||
1106 (std::find(name_filter.begin(), name_filter.end(),
name) != name_filter.end()))
1107 component_names.push_back(
name);
1110 if (! component_names.empty())
1111 names.insert(names.end(), component_names.begin(), component_names.end());
1118 if (is_names_empty ||
1119 (std::find(name_filter.begin(), name_filter.end(),
name) != name_filter.end()))
1120 names.push_back(
name);
1126 var_nums.emplace_back(system.
number(), var);
1131 std::vector<unsigned int> sort_index(var_nums.size());
1132 std::iota(sort_index.begin(), sort_index.end(), 0);
1133 std::sort(sort_index.begin(), sort_index.end(),
1134 [&](
const unsigned int & lhs,
const unsigned int & rhs)
1135 {
return this->get_system(var_nums[lhs].first).variable_name(var_nums[lhs].second) <
1136 this->get_system(var_nums[rhs].first).variable_name(var_nums[rhs].second);});
1138 std::vector<std::pair<unsigned int, unsigned int>> var_nums_sorted(var_nums.size());
1141 var_nums_sorted[i].first = var_nums[sort_index[i]].first;
1142 var_nums_sorted[i].second = var_nums[sort_index[i]].second;
1146 std::sort(names.begin(), names.end());
1149 return var_nums_sorted;
1153 std::unique_ptr<NumericVector<Number>>
1160 std::vector<std::pair<unsigned int, unsigned int>> var_nums =
1163 const std::size_t nv = names.size();
1169 return std::unique_ptr<NumericVector<Number>>(
nullptr);
1183 parallel_soln_local_size = div+1;
1188 parallel_soln.
init(parallel_soln_global_size,
1189 parallel_soln_local_size,
1193 unsigned int sys_ctr = 0;
1194 unsigned int var_ctr = 0;
1197 std::pair<unsigned int, unsigned int> var_num = var_nums[i];
1201 if (sys_ctr != var_num.first)
1210 if (!non_const_sys.
solution->closed())
1213 sys_ctr = var_num.first;
1218 const unsigned int var = var_num.second;
1227 const unsigned int n_comps =
1233 [&dof_map, &variable, ne, var, var_ctr, n_comps,
1237 std::vector<dof_id_type> dof_indices;
1239 for (
const Elem * elem : range)
1241 if (variable.active_on_subdomain(elem->subdomain_id()))
1247 libmesh_assert_equal_to(dof_indices.size(), n_comps);
1249 for (
unsigned int comp = 0; comp < n_comps; comp++)
1250 parallel_soln.set(ne * (var_ctr + comp) + elem->id(), sys_soln(dof_indices[comp]));
1263 libmesh_assert_equal_to(names.size(), var_ctr);
1265 parallel_soln.
close();
1266 return parallel_soln_ptr;
1273 (std::vector<Number> & soln,
1274 const std::set<std::string> * system_names,
1275 const std::vector<std::string> * var_names,
1277 bool add_sides)
const 1279 LOG_SCOPE(
"build_discontinuous_solution_vector()",
"EquationSystems");
1285 unsigned int nv = 0;
1287 for (
const auto & [sys_name, sys_ptr] : _systems)
1290 bool use_current_system = (system_names ==
nullptr);
1291 if (!use_current_system)
1292 use_current_system = system_names->count(sys_name);
1293 if (!use_current_system || sys_ptr->hide_output())
1298 for (
auto var_id :
make_range(sys_ptr->n_vars()))
1300 bool use_current_var = (var_names ==
nullptr);
1301 if (!use_current_var)
1302 use_current_var = std::count(var_names->begin(),
1304 sys_ptr->variable_name(var_id));
1308 if (use_current_var)
1316 for (
const auto & elem : _mesh.active_element_ptr_range())
1318 tw += vertices_only ? elem->n_vertices() : elem->n_nodes();
1322 for (
auto s : elem->side_index_range())
1324 if (redundant_added_side(*elem,s))
1327 const std::vector<unsigned int> side_nodes =
1328 elem->nodes_on_side(s);
1331 tw += side_nodes.size();
1334 if (elem->is_vertex(side_nodes[n]))
1342 if (_mesh.processor_id() == 0)
1345 std::vector<Number> sys_soln;
1349 unsigned int var_offset = 0;
1356 for (
const auto & [sys_name, system] : _systems)
1359 bool use_current_system = (system_names ==
nullptr);
1360 if (!use_current_system)
1361 use_current_system = system_names->count(sys_name);
1362 if (!use_current_system || system->hide_output())
1365 const unsigned int nv_sys = system->n_vars();
1366 const auto & dof_map = system->get_dof_map();
1368 system->update_global_solution (sys_soln, 0);
1371 unsigned int n_vars_written_current_system = 0;
1373 if (_mesh.processor_id() == 0)
1375 std::vector<Number> soln_coeffs;
1376 std::vector<Number> nodal_soln;
1377 std::vector<dof_id_type> dof_indices;
1384 for (
unsigned int var=0; var<nv_sys; var++)
1386 bool use_current_var = (var_names ==
nullptr);
1387 if (!use_current_var)
1388 use_current_var = std::count(var_names->begin(),
1390 system->variable_name(var));
1394 if (!use_current_var)
1397 const FEType & fe_type = system->variable_type(var);
1398 const Variable & var_description = system->variable(var);
1403 for (
auto & elem : _mesh.active_element_ptr_range())
1407 dof_map.dof_indices (elem, dof_indices, var);
1409 soln_coeffs.resize(dof_indices.size());
1412 soln_coeffs[i] = sys_soln[dof_indices[i]];
1426 if (!elem->infinite())
1428 libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
1430 const unsigned int n_vals =
1431 vertices_only ? elem->n_vertices() : elem->n_nodes();
1433 for (
unsigned int n=0; n<n_vals; n++)
1437 nv * (nn++) + (n_vars_written_current_system + var_offset);
1439 soln[index] += nodal_soln[n];
1444 nn += vertices_only ? elem->n_vertices() : elem->n_nodes();
1455 std::vector<std::vector<const Elem *>>
1456 elems_by_pid(_mesh.n_processors());
1458 for (
const auto & elem : _mesh.active_element_ptr_range())
1459 elems_by_pid[elem->processor_id()].push_back(elem);
1462 for (
const Elem * elem : elems_by_pid[p])
1466 dof_map.dof_indices (elem, dof_indices, var);
1468 soln_coeffs.resize(dof_indices.size());
1471 soln_coeffs[i] = sys_soln[dof_indices[i]];
1473 for (
auto s : elem->side_index_range())
1475 if (redundant_added_side(*elem,s))
1478 const std::vector<unsigned int> side_nodes =
1479 elem->nodes_on_side(s);
1486 (fe_type, elem, s, soln_coeffs,
1487 nodal_soln, add_p_level,
1490 libmesh_assert_equal_to
1506 neigh->
level() == elem->level() &&
1509 std::vector<dof_id_type> neigh_indices;
1510 dof_map.dof_indices (neigh, neigh_indices, var);
1511 std::vector<Number> neigh_coeffs(neigh_indices.size());
1514 neigh_coeffs[i] = sys_soln[neigh_indices[i]];
1516 const unsigned int s_neigh =
1518 std::vector<Number> neigh_soln;
1520 (fe_type, neigh, s_neigh,
1521 neigh_coeffs, neigh_soln, add_p_level,
1524 const std::vector<unsigned int> neigh_nodes =
1528 if (neigh->
node_ptr(neigh_nodes[neigh_n])
1529 == elem->node_ptr(side_nodes[n]))
1531 nodal_soln[n] += neigh_soln[neigh_n];
1538 if (vertices_only &&
1539 !elem->is_vertex(n))
1544 nv * (nn++) + (n_vars_written_current_system + var_offset);
1546 soln[index] += nodal_soln[n];
1552 nn += vertices_only ? elem->n_vertices() : elem->n_nodes();
1554 for (
auto s : elem->side_index_range())
1556 if (redundant_added_side(*elem,s))
1559 const std::vector<unsigned int> side_nodes =
1560 elem->nodes_on_side(s);
1564 if (vertices_only &&
1565 !elem->is_vertex(n))
1575 n_vars_written_current_system++;
1581 var_offset += n_vars_written_current_system;
1602 if (!neigh->active())
1607 return (neigh->id() < elem.
id());
1613 const Real threshold,
1614 const bool verbose)
const 1618 std::vector<bool> os_result;
1624 libMesh::out <<
" Fatal difference. This system handles " 1625 << this->
n_systems() <<
" systems," << std::endl
1626 <<
" while the other system handles " 1628 <<
" systems." << std::endl
1629 <<
" Aborting comparison." << std::endl;
1636 for (
const auto & [sys_name, sys_ptr] :
_systems)
1641 os_result.push_back (sys_ptr->compare (other_system, threshold, verbose));
1649 if (os_result.size()==0)
1657 os_identical = os_result[n];
1660 while (os_identical && n<os_result.size());
1661 return os_identical;
1669 std::ostringstream oss;
1671 unsigned int n_hidden_sys = 0;
1673 n_hidden_sys += pr.second->hide_output();
1675 oss <<
" EquationSystems\n" 1677 << (n_hidden_sys ?
" (hidden: " + std::to_string(n_hidden_sys) +
")" :
"")
1682 if (!pr.second->hide_output())
1683 oss << pr.second->get_info();
1729 tot += pr.second->n_vars();
1741 tot += pr.second->n_dofs();
1754 tot += pr.second->n_active_dofs();
1763 for (
auto & node :
_mesh.node_ptr_range())
1771 for (
Elem * elem : range)
1778 this->
get_system(sys_num).get_dof_map().remove_default_ghosting();
EquationSystems(MeshBase &mesh)
Constructor.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
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.
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
bool p_refinement
Whether or not the finite elements for this type increase their p refinement level on geometric eleme...
This is the EquationSystems class.
unsigned int n_vars() const
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
A Node is like a Point, but with more information.
unsigned int n_systems() const
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
bool _enable_default_ghosting
Flag for whether to enable default ghosting on newly added Systems.
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
std::unique_ptr< NumericVector< Number > > build_parallel_elemental_solution_vector(std::vector< std::string > &names) const
Builds a parallel vector of CONSTANT MONOMIAL and/or components of CONSTANT MONOMIAL_VEC solution val...
std::size_t distribute_dofs(MeshBase &)
Distribute dofs on the current mesh.
static constexpr Real TOLERANCE
std::size_t n_dofs() const
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
void build_discontinuous_solution_vector(std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false, bool add_sides=false) const
Fill the input vector soln with solution values.
void add_default_ghosting()
Add the default functor(s) for coupling and algebraic ghosting.
bool refine_elements()
Only refines the user-requested elements.
bool reinit_solutions()
Handle any mesh changes and project any solutions onto the updated mesh.
virtual void clear()
Restores the data structure to a pristine state.
virtual void allgather()
Gathers all elements and nodes of the mesh onto every processor.
virtual ~EquationSystems()
Destructor.
This is the base class from which all geometric element types are derived.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
static FEFieldType field_type(const FEType &fe_type)
std::ostream & operator<<(std::ostream &os, const OrderWrapper &order)
Overload stream operators.
processor_id_type rank() const
const Parallel::Communicator & comm() const
virtual void enable_default_ghosting(bool enable)
Enable or disable default ghosting functors on the Mesh and on all Systems.
virtual void adjoint_solve(const QoISet &qoi_indices=QoISet())
Call adjoint_solve on all the individual equation systems.
The StoredRange class defines a contiguous, divisible set of objects.
const Parallel::Communicator & _communicator
The libMesh namespace provides an interface to certain functionality in the library.
const T_sys & get_system(std::string_view name) const
Real distance(const Point &p)
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.
static void side_nodal_soln(const FEType &fe_t, const Elem *elem, const unsigned int side, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln on one side from the (full) element soln.
uint8_t processor_id_type
This is the MeshBase class.
virtual std::string get_info() const
virtual void prolong_vectors()
Prolong vectors after the mesh has refined.
MeshBase & _mesh
The mesh data structure.
bool coarsen_elements()
Only coarsens the user-requested elements.
signed char & underrefined_boundary_limit()
If underrefined_boundary_limit is set to a nonnegative value, then refinement and coarsening will pro...
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
This class handles the numbering of degrees of freedom on a mesh.
void allgather()
Serializes a distributed mesh and its associated degree of freedom numbering for all systems...
void get_vars_active_subdomains(const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type >> &vars_active_subdomains) const
Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names...
processor_id_type size() const
virtual void sensitivity_solve(const ParameterVector ¶meters)
Call sensitivity_solve on all the individual equation systems.
virtual void reinit_systems()
Reinitialize all systems on the current mesh.
processor_id_type n_processors() const
virtual bool is_serial() const
unsigned int number() const
This class defines the notion of a variable in the system.
const std::set< subdomain_id_type > & active_subdomains() const
Implements (adaptive) mesh refinement algorithms for a MeshBase.
dof_id_type numeric_index_type
const ElemRange & element_stored_range()
unsigned int which_neighbor_am_i(const Elem *e) const
This function tells you which neighbor e is.
Manages consistently variables, degrees of freedom, and coefficient vectors.
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
virtual dof_id_type max_elem_id() const =0
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const ConstElemRange & active_local_element_stored_range() const
const std::string & variable_name(const unsigned int i) const
void build_solution_vector(std::vector< Number > &soln, std::string_view system_name, std::string_view variable_name="all_vars") const
Fill the input vector soln with the solution values for the system named name.
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
bool active_on_subdomain(subdomain_id_type sid) const
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
virtual void reinit_mesh()
Handle the association of a completely new mesh with the EquationSystem and all the Systems assigned ...
unsigned char & face_level_mismatch_limit()
If face_level_mismatch_limit is set to a nonzero value, then refinement and coarsening will produce m...
An object whose state is distributed along a set of processors.
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
virtual void reinit_constraints()
Reinitializes the constraints for this system.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order...
virtual void solve()
Call solve on all the individual equation systems.
virtual numeric_index_type first_local_index() const =0
const Elem * neighbor_ptr(unsigned int i) const
virtual void update()
Update the local values to reflect the solution on neighboring processors.
unsigned int level() const
const FEType & variable_type(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool contract()=0
Delete subactive (i.e.
subdomain_id_type subdomain_id() const
FEContinuity
defines an enum for finite element types to libmesh_assert a certain level (or type? Hcurl?) of continuity.
const Node * node_ptr(const unsigned int i) const
unsigned int spatial_dimension() const
T & set(const std::string &)
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector(const std::set< std::string > *system_names=nullptr, bool add_sides=false) const
A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis...
virtual void clear()
Clears internal data structures & frees any allocated memory.
signed char & overrefined_boundary_limit()
If overrefined_boundary_limit is set to a nonnegative value, then refinement and coarsening will prod...
void remove_default_ghosting()
Remove any default ghosting functor(s).
void _remove_default_ghosting(unsigned int sys_num)
This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap...
const MeshBase & get_mesh() const
std::size_t n_active_dofs() const
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...
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...
std::vector< std::pair< unsigned int, unsigned int > > find_variable_numbers(std::vector< std::string > &names, const FEType *type=nullptr, const std::vector< FEType > *types=nullptr) const
Finds system and variable numbers for any variables of 'type' or of 'types' corresponding to the entr...
Parameters parameters
Data structure holding arbitrary parameters.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual void init()
Initialize all the systems.
virtual bool compare(const EquationSystems &other_es, const Real threshold, const bool verbose) const
unsigned int n_vars() const
virtual dof_id_type max_node_id() const =0
virtual dof_id_type n_elem() const =0
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
processor_id_type processor_id() const
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln from the element soln.
void _add_system_to_nodes_and_elems()
This function is used in the implementation of add_system, it loops over the nodes and elements of th...
const DofMap & get_dof_map() const
virtual numeric_index_type last_local_index() const =0
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
void update()
Updates local values for all the systems.
virtual std::vector< unsigned int > nodes_on_side(const unsigned int) const =0
void build_elemental_solution_vector(std::vector< Number > &soln, std::vector< std::string > &names) const
Retrieve the solution data for CONSTANT MONOMIALs and/or components of CONSTANT MONOMIAL_VECs.
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.
static bool redundant_added_side(const Elem &elem, unsigned int side)
const RemoteElem * remote_elem