83 #include "libmesh/nonlinear_solver.h" 84 #include "libmesh/quadrature_gauss.h" 85 #include "libmesh/dense_vector.h" 86 #include "libmesh/boundary_info.h" 87 #include "libmesh/petsc_matrix.h" 88 #include "libmesh/petsc_vector.h" 89 #include "libmesh/petsc_nonlinear_solver.h" 90 #include "libmesh/numeric_vector.h" 91 #include "libmesh/mesh.h" 92 #include "libmesh/dense_subvector.h" 93 #include "libmesh/dense_submatrix.h" 94 #include "libmesh/dof_map.h" 95 #include "libmesh/sparse_matrix.h" 96 #include "libmesh/petsc_matrix.h" 97 #include "libmesh/default_coupling.h" 98 #include "libmesh/diagonal_matrix.h" 99 #include "libmesh/fe_interface.h" 103 #include "petscsnes.h" 111 const std::string & name)
114 _fe_problem(fe_problem),
117 _initial_residual_before_preset_bcs(0.),
118 _initial_residual_after_preset_bcs(0.),
120 _compute_initial_residual_before_preset_bcs(true),
121 _current_solution(NULL),
122 _residual_ghosted(NULL),
129 _Re_non_time_tag(-1),
131 _scalar_kernels(false),
133 _preset_nodal_bcs(false),
134 _ad_preset_nodal_bcs(false),
136 _increment_vec(NULL),
139 _use_finite_differenced_preconditioner(false),
140 _have_decomposition(false),
141 _use_field_split_preconditioner(false),
142 _add_implicit_geometric_coupling_entries_to_jacobian(false),
143 _assemble_constraints_separately(false),
144 _need_residual_ghosted(false),
145 _debugging_residuals(false),
149 _n_residual_evaluations(0),
151 _computing_initial_residual(false),
152 _print_all_var_norms(false),
154 _has_diag_save_in(false),
155 _has_nodalbc_save_in(false),
156 _has_nodalbc_diag_save_in(false),
157 _computed_scaling(false),
158 _compute_scaling_once(true),
159 _resid_vs_jac_scaling_param(0),
160 _off_diagonals_in_auto_scaling(false),
161 _auto_scaling_initd(false)
177 auto & dof_map =
_sys.get_dof_map();
178 dof_map.remove_algebraic_ghosting_functor(dof_map.default_algebraic_ghosting());
179 dof_map.set_implicit_neighbor_dofs(
false);
218 system().set_basic_system_only();
234 TIME_SECTION(
"nlInitialSetup", 2,
"Setting Up Nonlinear System");
239 TIME_SECTION(
"kernelsInitialSetup", 2,
"Setting Up Kernels/BCs/Constraints");
256 std::vector<FVElementalKernel *> fv_elemental_kernels;
259 .template condition<AttribSystem>(
"FVElementalKernel")
260 .
template condition<AttribThread>(tid)
263 for (
auto * fv_kernel : fv_elemental_kernels)
264 fv_kernel->initialSetup();
266 std::vector<FVFluxKernel *> fv_flux_kernels;
269 .template condition<AttribSystem>(
"FVFluxKernel")
270 .
template condition<AttribThread>(tid)
273 for (
auto * fv_kernel : fv_flux_kernels)
274 fv_kernel->initialSetup();
285 TIME_SECTION(
"mortarSetup", 2,
"Initializing Mortar Interfaces");
287 auto create_mortar_functors = [
this](
const bool displaced)
291 for (
const auto & mortar_interface : mortar_interfaces)
293 const auto primary_secondary_boundary_pair = mortar_interface.first;
297 const auto & mortar_generation_object = mortar_interface.second;
299 auto & mortar_constraints =
306 auto & mortar_functors =
309 mortar_functors.emplace(primary_secondary_boundary_pair,
311 mortar_generation_object,
319 create_mortar_functors(
false);
320 create_mortar_functors(
true);
351 std::vector<FVFluxBC *> bcs;
354 .template condition<AttribSystem>(
"FVFluxBC")
355 .
template condition<AttribThread>(tid)
358 std::vector<FVInterfaceKernel *> iks;
361 .template condition<AttribSystem>(
"FVInterfaceKernel")
362 .
template condition<AttribThread>(tid)
365 std::vector<FVFluxKernel *> kernels;
368 .template condition<AttribSystem>(
"FVFluxKernel")
369 .
template condition<AttribThread>(tid)
372 for (
auto * bc : bcs)
374 for (
auto * ik : iks)
376 for (
auto * kernel : kernels)
377 kernel->timestepSetup();
405 std::vector<FVFluxBC *> bcs;
408 .template condition<AttribSystem>(
"FVFluxBC")
409 .
template condition<AttribThread>(tid)
412 std::vector<FVInterfaceKernel *> iks;
415 .template condition<AttribSystem>(
"FVInterfaceKernel")
416 .
template condition<AttribThread>(tid)
419 std::vector<FVFluxKernel *> kernels;
422 .template condition<AttribSystem>(
"FVFluxKernel")
423 .
template condition<AttribThread>(tid)
426 for (
auto * bc : bcs)
427 bc->customSetup(exec_type);
428 for (
auto * ik : iks)
429 ik->customSetup(exec_type);
430 for (
auto * kernel : kernels)
431 kernel->customSetup(exec_type);
451 if (splits.size() && splits.size() != 1)
452 mooseError(
"Only a single top-level split is allowed in a Problem's decomposition.");
470 top_split->setup(*
this);
475 const std::string & name,
486 const std::string & name,
492 std::shared_ptr<KernelBase> kernel =
498 if (parameters.
get<std::vector<AuxVariableName>>(
"save_in").size() > 0)
500 if (parameters.
get<std::vector<AuxVariableName>>(
"diag_save_in").size() > 0)
506 const std::string & name,
512 std::shared_ptr<NodalKernelBase> kernel =
518 if (parameters.
get<std::vector<AuxVariableName>>(
"save_in").size() > 0)
520 if (parameters.
get<std::vector<AuxVariableName>>(
"diag_save_in").size() > 0)
526 const std::string & name,
529 std::shared_ptr<ScalarKernelBase> kernel =
537 const std::string & name,
544 std::shared_ptr<BoundaryCondition> bc =
549 const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
551 _vars[tid].addBoundaryVar(boundary_ids, bc_var);
560 if (nbc->checkNodalVar() && !nbc->variable().isNodal())
561 mooseError(
"Trying to use nodal boundary condition '",
563 "' on a non-nodal variable '",
564 nbc->variable().name(),
568 _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
570 if (parameters.get<std::vector<AuxVariableName>>(
"save_in").size() > 0)
572 if (parameters.get<std::vector<AuxVariableName>>(
"diag_save_in").size() > 0)
577 if (dbc && dbc->preset())
581 if (addbc && addbc->preset())
589 _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
591 if (parameters.get<std::vector<AuxVariableName>>(
"save_in").size() > 0)
593 if (parameters.get<std::vector<AuxVariableName>>(
"diag_save_in").size() > 0)
605 const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
606 _vars[tid].addBoundaryVar(boundary_ids, bc_var);
611 _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
616 mooseError(
"Unknown BoundaryCondition type for object named ", bc->name());
621 const std::string & name,
628 if (constraint && constraint->addCouplingEntriesToJacobian())
634 const std::string & name,
639 std::shared_ptr<DiracKernelBase> kernel =
648 const std::string & name,
660 if (parameters.
get<std::vector<AuxVariableName>>(
"save_in").size() > 0)
662 if (parameters.
get<std::vector<AuxVariableName>>(
"diag_save_in").size() > 0)
668 const std::string & name,
673 std::shared_ptr<InterfaceKernelBase> interface_kernel =
677 const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
679 _vars[tid].addBoundaryVar(boundary_ids, ik_var);
682 _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
688 const std::string & name,
716 const std::string & name,
723 std::shared_ptr<Split>
764 parallel_object_only();
766 TIME_SECTION(
"nl::computeResidualTags", 5);
771 bool required_residual = tags.find(
residualVectorTag()) == tags.end() ? false :
true;
794 if (required_residual)
840 const std::set<TagID> & matrix_tags)
842 const bool required_residual =
852 if (required_residual)
891 TIME_SECTION(
"applyPredictor", 2,
"Applying Predictor");
899 TIME_SECTION(
"initialBCs", 2,
"Applying BCs To Initial Condition");
902 for (
const auto & bnode : bnd_nodes)
905 Node * node = bnode->_node;
915 for (
const auto & preset_bc : preset_bcs)
916 preset_bc->computeValue(initial_solution);
921 for (
const auto & preset_bc : preset_bcs_res)
922 preset_bc->computeValue(initial_solution);
928 _sys.solution->close();
1014 mooseError(
"The required residual vector is not available");
1042 for (
const auto & nc : ncs)
1044 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1045 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1047 if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1051 nc->computeResidual(residual);
1071 for (
const auto & nc : ncs)
1073 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1074 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1076 if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1080 nc->computeJacobian(jacobian);
1092 const bool displaced)
1097 const Elem * primary_elem =
info._elem;
1098 unsigned int primary_side =
info._side_num;
1099 std::vector<Point> points;
1100 points.push_back(
info._closest_point);
1121 const Elem *
const undisplaced_primary_elem =
1122 displaced ?
_mesh.
elemPtr(primary_elem->id()) : primary_elem;
1123 const Point undisplaced_primary_physical_point =
1124 [&points, displaced, primary_elem, undisplaced_primary_elem]()
1128 const Point reference_point =
1129 FEMap::inverse_map(primary_elem->dim(), primary_elem, points[0]);
1130 return FEMap::map(primary_elem->dim(), undisplaced_primary_elem, reference_point);
1139 undisplaced_primary_elem, primary_side, {undisplaced_primary_physical_point}, 0);
1153 "If we're calling this method with displaced = true, then we better well have a " 1154 "displaced problem");
1159 bool constraints_applied =
false;
1161 for (
const auto & it : penetration_locators)
1172 const auto & constraints =
1174 std::unordered_set<unsigned int> needed_mat_props;
1175 for (
const auto & constraint : constraints)
1177 const auto & mp_deps = constraint->getMatPropDependencies();
1178 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
1182 for (
unsigned int i = 0; i < secondary_nodes.size(); i++)
1184 dof_id_type secondary_node_num = secondary_nodes[i];
1185 Node & secondary_node =
_mesh.
nodeRef(secondary_node_num);
1195 for (
const auto & nfc : constraints)
1197 if (nfc->isExplicitConstraint())
1203 if (nfc->secondaryBoundary() != secondary_boundary ||
1204 nfc->primaryBoundary() != primary_boundary)
1207 if (nfc->shouldApply())
1209 constraints_applied =
true;
1210 nfc->computeSecondaryValue(
solution);
1213 if (nfc->hasWritableCoupledVariables())
1215 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1216 for (
auto * var : nfc->getWritableCoupledVariables())
1218 if (var->isNodalDefined())
1230 std::set<dof_id_type> unique_secondary_node_ids;
1238 const auto & constraints =
1242 unique_secondary_node_ids.clear();
1244 for (
const auto & elem :
as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1245 meshhelper.active_subdomain_elements_end(secondary_id)))
1247 for (
auto & n : elem->node_ref_range())
1248 unique_secondary_node_ids.insert(n.id());
1251 for (
auto secondary_node_id : unique_secondary_node_ids)
1253 Node & secondary_node =
_mesh.
nodeRef(secondary_node_id);
1265 for (
const auto & nec : constraints)
1267 if (nec->shouldApply())
1269 constraints_applied =
true;
1270 nec->computeSecondaryValue(
solution);
1282 if (constraints_applied)
1297 "If we're calling this method with displaced = true, then we better well have a " 1298 "displaced problem");
1303 bool constraints_applied;
1304 bool residual_has_inserted_values =
false;
1306 constraints_applied =
false;
1307 for (
const auto & it : penetration_locators)
1313 constraints_applied =
false;
1322 bool has_writable_variables(
false);
1326 const auto & constraints =
1329 for (
unsigned int i = 0; i < secondary_nodes.size(); i++)
1331 dof_id_type secondary_node_num = secondary_nodes[i];
1332 Node & secondary_node =
_mesh.
nodeRef(secondary_node_num);
1342 for (
const auto & nfc : constraints)
1348 if (nfc->secondaryBoundary() != secondary_boundary ||
1349 nfc->primaryBoundary() != primary_boundary)
1352 if (nfc->shouldApply())
1354 constraints_applied =
true;
1355 nfc->computeResidual();
1357 if (nfc->overwriteSecondaryResidual())
1363 const auto & secondary_var = nfc->variable();
1364 const auto & secondary_dofs = secondary_var.dofIndices();
1365 mooseAssert(secondary_dofs.size() == secondary_var.count(),
1366 "We are on a node so there should only be one dof per variable (for " 1367 "an ArrayVariable we should have a number of dofs equal to the " 1368 "number of components");
1374 std::vector<Number> values = {nfc->secondaryResidual()};
1375 residual.
insert(values, secondary_dofs);
1376 residual_has_inserted_values =
true;
1382 if (nfc->hasWritableCoupledVariables())
1384 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1385 has_writable_variables =
true;
1386 for (
auto * var : nfc->getWritableCoupledVariables())
1388 if (var->isNodalDefined())
1399 if (has_writable_variables)
1417 if (constraints_applied)
1422 if (residual_has_inserted_values)
1425 residual_has_inserted_values =
false;
1439 if (constraints_applied)
1444 if (residual_has_inserted_values)
1458 for (
const auto & it : element_pair_locators)
1465 const auto & _element_constraints =
1469 const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1471 for (
const auto & pr : elem_pairs)
1473 const Elem * elem1 = pr.first;
1474 const Elem * elem2 = pr.second;
1482 for (
const auto & ec : _element_constraints)
1489 ec->prepareShapes(ec->variable().number());
1490 ec->prepareNeighborShapes(ec->variable().number());
1493 ec->computeResidual();
1503 std::set<dof_id_type> unique_secondary_node_ids;
1505 constraints_applied =
false;
1506 residual_has_inserted_values =
false;
1513 const auto & constraints =
1517 unique_secondary_node_ids.clear();
1519 for (
const auto & elem :
as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1520 meshhelper.active_subdomain_elements_end(secondary_id)))
1522 for (
auto & n : elem->node_ref_range())
1523 unique_secondary_node_ids.insert(n.id());
1526 for (
auto secondary_node_id : unique_secondary_node_ids)
1528 Node & secondary_node =
_mesh.
nodeRef(secondary_node_id);
1539 for (
const auto & nec : constraints)
1541 if (nec->shouldApply())
1543 constraints_applied =
true;
1544 nec->computeResidual();
1546 if (nec->overwriteSecondaryResidual())
1549 residual_has_inserted_values =
true;
1564 if (constraints_applied)
1569 if (residual_has_inserted_values)
1592 for (
const auto & it : penetration_locators)
1602 const auto & constraints =
1606 const auto secondary_node_num = secondary_nodes[i];
1607 const Node & secondary_node =
_mesh.
nodeRef(secondary_node_num);
1611 for (
const auto & nfc : constraints)
1613 if (!nfc->isExplicitConstraint())
1620 if (nfc->secondaryBoundary() != secondary_boundary ||
1621 nfc->primaryBoundary() != primary_boundary)
1624 nfc->overwriteBoundaryVariables(soln, secondary_node);
1635 TIME_SECTION(
"residualSetup", 3);
1665 parallel_object_only();
1667 TIME_SECTION(
"computeResidualInternal", 3);
1675 std::vector<UserObject *> uos;
1681 for (
auto & uo : uos)
1682 uo->residualSetup();
1683 for (
auto & uo : uos)
1697 TIME_SECTION(
"Kernels", 3 );
1702 Threads::parallel_reduce(elem_range, cr);
1708 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
1714 Threads::parallel_reduce(faces, fvr);
1717 displaced_problem && displaced_problem->haveFV())
1721 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1722 displaced_problem->mesh().ownedFaceInfoEnd());
1723 Threads::parallel_reduce(faces, fvr);
1739 TIME_SECTION(
"ScalarKernels", 3 );
1747 else if (tags.size() == 1)
1748 scalar_kernel_warehouse =
1754 bool have_scalar_contributions =
false;
1756 for (
const auto & scalar_kernel : scalars)
1758 scalar_kernel->reinit();
1759 const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1760 const DofMap & dof_map = scalar_kernel->variable().dofMap();
1761 const dof_id_type first_dof = dof_map.first_dof();
1765 if (dof >= first_dof && dof < end_dof)
1767 scalar_kernel->computeResidual();
1768 have_scalar_contributions =
true;
1773 if (have_scalar_contributions)
1784 TIME_SECTION(
"NodalKernels", 3 );
1790 if (range.begin() != range.end())
1794 Threads::parallel_reduce(range, cnk);
1816 TIME_SECTION(
"NodalKernelBCs", 3 );
1822 Threads::parallel_reduce(bnd_node_range, cnk);
1883 const std::set<TagID> & matrix_tags)
1885 TIME_SECTION(
"computeResidualAndJacobianInternal", 3);
1890 for (
auto tag : matrix_tags)
1897 if (
auto petsc_matrix =
dynamic_cast<PetscMatrix<Number> *
>(&jacobian))
1899 MatSetOption(petsc_matrix->mat(),
1900 MAT_KEEP_NONZERO_PATTERN,
1903 MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
1911 std::vector<UserObject *> uos;
1917 for (
auto & uo : uos)
1918 uo->residualSetup();
1919 for (
auto & uo : uos)
1933 TIME_SECTION(
"Kernels", 3 );
1938 Threads::parallel_reduce(elem_range, crj);
1940 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
1946 Threads::parallel_reduce(faces, fvrj);
1949 displaced_problem && displaced_problem->haveFV())
1953 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1954 displaced_problem->mesh().ownedFaceInfoEnd());
1955 Threads::parallel_reduce(faces, fvr);
1977 for (
const auto & residual_vector_tag : residual_vector_tags)
2007 if (!bnd_nodes.empty())
2009 TIME_SECTION(
"NodalBCs", 3 );
2016 else if (tags.size() == 1)
2021 for (
const auto & bnode : bnd_nodes)
2024 Node * node = bnode->_node;
2033 for (
const auto & nbc : bcs)
2034 if (nbc->shouldApply())
2035 nbc->computeResidual();
2055 if (!bnd_nodes.empty())
2057 TIME_SECTION(
"NodalBCs", 3 );
2059 for (
const auto & bnode : bnd_nodes)
2062 Node * node = bnode->_node;
2071 for (
const auto & nbc : bcs)
2072 if (nbc->shouldApply())
2073 nbc->computeResidualAndJacobian();
2089 unsigned int s =
number();
2090 if (node.has_dofs(s))
2092 for (
unsigned int v = 0; v <
nVariables(); v++)
2093 for (
unsigned int c = 0; c < node.n_comp(s, v); c++)
2094 dofs.push_back(node.dof_number(s, v, c));
2101 std::unordered_map<
dof_id_type, std::vector<dof_id_type>> & graph)
2105 for (
const auto & it : nearest_node_locators)
2107 std::vector<dof_id_type> & secondary_nodes = it.second->_secondary_nodes;
2109 for (
const auto & secondary_node : secondary_nodes)
2111 std::set<dof_id_type> unique_secondary_indices;
2112 std::set<dof_id_type> unique_primary_indices;
2114 auto node_to_elem_pair = node_to_elem_map.find(secondary_node);
2115 if (node_to_elem_pair != node_to_elem_map.end())
2117 const std::vector<dof_id_type> & elems = node_to_elem_pair->second;
2120 for (
const auto & cur_elem : elems)
2122 std::vector<dof_id_type> dof_indices;
2125 for (
const auto & dof : dof_indices)
2126 unique_secondary_indices.insert(dof);
2130 std::vector<dof_id_type> primary_nodes = it.second->_neighbor_nodes[secondary_node];
2132 for (
const auto & primary_node : primary_nodes)
2134 auto primary_node_to_elem_pair = node_to_elem_map.find(primary_node);
2135 mooseAssert(primary_node_to_elem_pair != node_to_elem_map.end(),
2136 "Missing entry in node to elem map");
2137 const std::vector<dof_id_type> & primary_node_elems = primary_node_to_elem_pair->second;
2140 for (
const auto & cur_elem : primary_node_elems)
2142 std::vector<dof_id_type> dof_indices;
2145 for (
const auto & dof : dof_indices)
2146 unique_primary_indices.insert(dof);
2150 for (
const auto & secondary_id : unique_secondary_indices)
2151 for (
const auto & primary_id : unique_primary_indices)
2153 graph[secondary_id].push_back(primary_id);
2154 graph[primary_id].push_back(secondary_id);
2161 for (
const auto & nc : ncs)
2163 std::vector<dof_id_type> primary_dofs;
2164 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
2165 for (
const auto & node_id : primary_node_ids)
2168 if (node && node->processor_id() == this->
processor_id())
2176 std::vector<dof_id_type> secondary_dofs;
2177 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
2178 for (
const auto & node_id : secondary_node_ids)
2181 if (node && node->processor_id() == this->
processor_id())
2189 for (
const auto & primary_id : primary_dofs)
2190 for (
const auto & secondary_id : secondary_dofs)
2192 graph[primary_id].push_back(secondary_id);
2193 graph[secondary_id].push_back(primary_id);
2198 for (
auto & it : graph)
2200 std::vector<dof_id_type> & row = it.second;
2201 std::sort(row.begin(), row.end());
2202 std::vector<dof_id_type>::iterator uit = std::unique(row.begin(), row.end());
2203 row.resize(uit - row.begin());
2217 std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
2221 for (
const auto & it : graph)
2224 const auto & row = it.second;
2226 for (
const auto & coupled_dof : row)
2227 jacobian.add(dof, coupled_dof, 0);
2240 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
2241 MAT_NEW_NONZERO_ALLOCATION_ERR,
2245 static_cast<PetscMatrix<Number> &
>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
2247 std::vector<numeric_index_type> zero_rows;
2251 "If we're calling this method with displaced = true, then we better well have a " 2252 "displaced problem");
2257 bool constraints_applied;
2259 constraints_applied =
false;
2260 for (
const auto & it : penetration_locators)
2266 constraints_applied =
false;
2278 const auto & constraints =
2281 for (
const auto & secondary_node_num : secondary_nodes)
2283 Node & secondary_node =
_mesh.
nodeRef(secondary_node_num);
2294 for (
const auto & nfc : constraints)
2296 if (nfc->isExplicitConstraint())
2302 if (nfc->secondaryBoundary() != secondary_boundary ||
2303 nfc->primaryBoundary() != primary_boundary)
2306 nfc->_jacobian = &jacobian;
2308 if (nfc->shouldApply())
2310 constraints_applied =
true;
2312 nfc->prepareShapes(nfc->variable().number());
2313 nfc->prepareNeighborShapes(nfc->variable().number());
2315 nfc->computeJacobian();
2317 if (nfc->overwriteSecondaryJacobian())
2320 zero_rows.push_back(nfc->variable().nodalDofIndex());
2323 std::vector<dof_id_type> secondary_dofs(1, nfc->variable().nodalDofIndex());
2329 Real scaling_factor =
2330 nfc->overwriteSecondaryJacobian() ? 1. : nfc->variable().scalingFactor();
2336 nfc->_connected_dof_indices,
2340 if (nfc->addCouplingEntriesToJacobian())
2347 nfc->primaryVariable().dofIndicesNeighbor(),
2353 nfc->primaryVariable().dofIndicesNeighbor(),
2354 nfc->_connected_dof_indices,
2355 nfc->variable().scalingFactor());
2362 const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
2363 for (
const auto & jvar : coupled_vars)
2371 if (nfc->variable().number() == jvar->number() ||
2373 nfc->variable().number(), jvar->number(), this->
number()))
2379 nfc->prepareShapes(nfc->variable().number());
2380 nfc->prepareNeighborShapes(jvar->number());
2382 nfc->computeOffDiagJacobian(jvar->number());
2388 nfc->_connected_dof_indices,
2392 if (nfc->addCouplingEntriesToJacobian())
2399 jvar->dofIndicesNeighbor(),
2405 nfc->variable().dofIndicesNeighbor(),
2406 nfc->_connected_dof_indices,
2407 nfc->variable().scalingFactor());
2424 if (constraints_applied)
2426 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
2427 MAT_KEEP_NONZERO_PATTERN,
2431 jacobian.zero_rows(zero_rows, 0.0);
2443 if (constraints_applied)
2445 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
2446 MAT_KEEP_NONZERO_PATTERN,
2450 jacobian.zero_rows(zero_rows, 0.0);
2460 for (
const auto & it : element_pair_locators)
2467 const auto & _element_constraints =
2471 const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
2473 for (
const auto & pr : elem_pairs)
2475 const Elem * elem1 = pr.first;
2476 const Elem * elem2 = pr.second;
2484 for (
const auto & ec : _element_constraints)
2491 ec->prepareShapes(ec->variable().number());
2492 ec->prepareNeighborShapes(ec->variable().number());
2495 ec->computeJacobian();
2505 std::set<dof_id_type> unique_secondary_node_ids;
2506 constraints_applied =
false;
2513 const auto & constraints =
2517 unique_secondary_node_ids.clear();
2519 for (
const auto & elem :
as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
2520 meshhelper.active_subdomain_elements_end(secondary_id)))
2522 for (
auto & n : elem->node_ref_range())
2523 unique_secondary_node_ids.insert(n.id());
2526 for (
auto secondary_node_id : unique_secondary_node_ids)
2528 const Node & secondary_node =
_mesh.
nodeRef(secondary_node_id);
2540 for (
const auto & nec : constraints)
2542 if (nec->shouldApply())
2544 constraints_applied =
true;
2546 nec->_jacobian = &jacobian;
2547 nec->prepareShapes(nec->variable().number());
2548 nec->prepareNeighborShapes(nec->variable().number());
2550 nec->computeJacobian();
2552 if (nec->overwriteSecondaryJacobian())
2555 zero_rows.push_back(nec->variable().nodalDofIndex());
2558 std::vector<dof_id_type> secondary_dofs(1, nec->variable().nodalDofIndex());
2564 nec->_connected_dof_indices,
2565 nec->variable().scalingFactor());
2570 nec->primaryVariable().dofIndicesNeighbor(),
2571 nec->_connected_dof_indices,
2572 nec->variable().scalingFactor());
2578 const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2579 for (
const auto & jvar : coupled_vars)
2587 if (nec->variable().number() == jvar->number() ||
2589 nec->variable().number(), jvar->number(), this->
number()))
2595 nec->prepareShapes(nec->variable().number());
2596 nec->prepareNeighborShapes(jvar->number());
2598 nec->computeOffDiagJacobian(jvar->number());
2604 nec->_connected_dof_indices,
2605 nec->variable().scalingFactor());
2610 nec->variable().dofIndicesNeighbor(),
2611 nec->_connected_dof_indices,
2612 nec->variable().scalingFactor());
2627 if (constraints_applied)
2629 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
2630 MAT_KEEP_NONZERO_PATTERN,
2634 jacobian.zero_rows(zero_rows, 0.0);
2648 else if (tags.size() == 1)
2662 bool have_scalar_contributions =
false;
2663 for (
const auto & kernel : scalars)
2666 const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2667 const DofMap & dof_map = kernel->variable().dofMap();
2668 const dof_id_type first_dof = dof_map.first_dof();
2672 if (dof >= first_dof && dof < end_dof)
2674 kernel->computeJacobian();
2676 have_scalar_contributions =
true;
2682 if (have_scalar_contributions)
2718 TIME_SECTION(
"computeJacobianInternal", 3);
2725 for (
auto tag : tags)
2732 if (
auto petsc_matrix =
dynamic_cast<PetscMatrix<Number> *
>(&jacobian))
2734 MatSetOption(petsc_matrix->mat(),
2735 MAT_KEEP_NONZERO_PATTERN,
2738 MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
2746 std::vector<UserObject *> uos;
2752 for (
auto & uo : uos)
2753 uo->jacobianSetup();
2754 for (
auto & uo : uos)
2777 Threads::parallel_reduce(range, cnkjt);
2785 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
2793 Threads::parallel_reduce(faces, fvj);
2796 displaced_problem && displaced_problem->haveFV())
2800 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
2801 displaced_problem->mesh().ownedFaceInfoEnd());
2802 Threads::parallel_reduce(faces, fvr);
2818 Threads::parallel_reduce(elem_range, cj);
2840 Threads::parallel_reduce(elem_range, cj);
2853 Threads::parallel_reduce(bnd_range, cnkjt);
2866 Threads::parallel_reduce(elem_range, cj);
2869 for (
unsigned int i = 0; i <
n_threads; i++)
2878 Threads::parallel_reduce(bnd_range, cnkjt);
2890 static bool first =
true;
2938 else if (tags.size() == 1)
2955 std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2957 for (
const auto & bid : all_boundary_ids)
2964 for (
const auto & bc : bcs)
2966 const std::vector<MooseVariableFEBase *> & coupled_moose_vars =
2967 bc->getCoupledMooseVars();
2971 std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2972 for (
const auto & coupled_var : coupled_moose_vars)
2974 var_set.insert(coupled_var->number());
2976 var_set.insert(bc->variable().number());
2996 for (
const auto & bnode : bnd_nodes)
2999 Node * node = bnode->_node;
3007 for (
const auto & bc : bcs)
3010 std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
3016 for (
const auto & it : coupling_entries)
3018 unsigned int ivar = it.first->number(), jvar = it.second->number();
3024 if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
3025 bc->computeOffDiagJacobian(jvar);
3028 const auto & coupled_scalar_vars = bc->getCoupledMooseScalarVars();
3029 for (
const auto & jvariable : coupled_scalar_vars)
3031 bc->computeOffDiagJacobianScalar(jvariable->number());
3064 for (
auto & tag : tags)
3083 TIME_SECTION(
"computeJacobianTags", 5);
3105 for (
auto & tag : tags)
3113 const std::set<TagID> & tags)
3115 TIME_SECTION(
"computeJacobianBlocks", 3);
3118 for (
unsigned int i = 0; i < blocks.size(); i++)
3122 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
3123 MAT_KEEP_NONZERO_PATTERN,
3126 MatSetOption(
static_cast<PetscMatrix<Number> &
>(jacobian).mat(),
3127 MAT_NEW_NONZERO_ALLOCATION_ERR,
3140 Threads::parallel_reduce(elem_range, cjb);
3144 for (
unsigned int i = 0; i < blocks.size(); i++)
3145 blocks[i]->_jacobian.close();
3147 for (
unsigned int i = 0; i < blocks.size(); i++)
3152 unsigned int ivar = blocks[i]->_ivar;
3153 unsigned int jvar = blocks[i]->_jvar;
3156 std::vector<numeric_index_type> zero_rows;
3160 for (
const auto & bnode : bnd_nodes)
3163 Node * node = bnode->_node;
3173 for (
const auto & bc : bcs)
3174 if (bc->variable().number() == ivar && bc->shouldApply())
3178 zero_rows.push_back(node->dof_number(precond_system.
number(), 0, 0));
3226 bool has_active_dampers =
false;
3234 TIME_SECTION(
"computeDampers", 3,
"Computing Dampers");
3235 has_active_dampers =
true;
3248 TIME_SECTION(
"computeDamping::element", 3,
"Computing Element Damping");
3250 has_active_dampers =
true;
3263 TIME_SECTION(
"computeDamping::general", 3,
"Computing General Damping");
3265 has_active_dampers =
true;
3267 for (
const auto & damper : gdampers)
3272 damper->checkMinDamping(gd_damping);
3278 damping =
std::min(gd_damping, damping);
3293 if (has_active_dampers && damping < 1.0)
3294 _console <<
" Damping factor: " << damping << std::endl;
3304 std::set<const Elem *> dirac_elements;
3308 TIME_SECTION(
"computeDirac", 3,
"Computing DiracKernels");
3314 for (
const auto & dkernel : dkernels)
3316 dkernel->clearPoints();
3317 dkernel->addPoints();
3325 DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
3374 std::vector<dof_id_type> & n_nz,
3375 std::vector<dof_id_type> & n_oz)
3381 std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
3396 for (
const auto & git : graph)
3401 if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
3404 const auto & row = git.second;
3406 SparsityPattern::Row & sparsity_row = sparsity[local_dof];
3408 unsigned int original_row_length = sparsity_row.size();
3410 sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
3412 SparsityPattern::sort_row(
3413 sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
3416 for (
const auto & coupled_dof : row)
3418 if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
3420 if (n_oz[local_dof] < n_dofs_not_on_proc)
3425 if (n_nz[local_dof] < n_dofs_on_proc)
3500 mooseError(
"More than one active Preconditioner detected");
3519 const std::set<MooseVariable *> & damped_vars)
3521 for (
const auto & var : damped_vars)
3527 const std::set<MooseVariable *> & damped_vars)
3529 for (
const auto & var : damped_vars)
3537 std::set<SubdomainID> input_subdomains;
3538 std::set<std::string> kernel_variables;
3540 bool global_kernels_exist =
false;
3552 std::vector<FVElementalKernel *> fv_elemental_kernels;
3555 .template condition<AttribSystem>(
"FVElementalKernel")
3556 .queryInto(fv_elemental_kernels);
3558 for (
auto fv_kernel : fv_elemental_kernels)
3560 if (fv_kernel->blockRestricted())
3561 for (
auto block_id : fv_kernel->blockIDs())
3562 input_subdomains.insert(block_id);
3564 global_kernels_exist =
true;
3565 kernel_variables.insert(fv_kernel->variable().name());
3568 if (dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel))
3569 kernel_variables.insert(dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel)
3574 std::vector<FVFluxKernel *> fv_flux_kernels;
3577 .template condition<AttribSystem>(
"FVFluxKernel")
3578 .queryInto(fv_flux_kernels);
3580 for (
auto fv_kernel : fv_flux_kernels)
3582 if (fv_kernel->blockRestricted())
3583 for (
auto block_id : fv_kernel->blockIDs())
3584 input_subdomains.insert(block_id);
3586 global_kernels_exist =
true;
3587 kernel_variables.insert(fv_kernel->variable().name());
3590 std::vector<FVInterfaceKernel *> fv_interface_kernels;
3593 .template condition<AttribSystem>(
"FVInterfaceKernel")
3594 .queryInto(fv_interface_kernels);
3596 for (
auto fvik : fv_interface_kernels)
3597 if (
auto scalar_fvik = dynamic_cast<FVScalarLagrangeMultiplierInterface *>(fvik))
3598 kernel_variables.insert(scalar_fvik->lambdaVariable().name());
3600 std::vector<FVFluxBC *> fv_flux_bcs;
3603 .template condition<AttribSystem>(
"FVFluxBC")
3604 .queryInto(fv_flux_bcs);
3606 for (
auto fvbc : fv_flux_bcs)
3607 if (
auto scalar_fvbc = dynamic_cast<FVBoundaryScalarLagrangeMultiplierConstraint *>(fvbc))
3608 kernel_variables.insert(scalar_fvbc->lambdaVariable().name());
3612 if (!global_kernels_exist)
3614 std::set<SubdomainID> difference;
3615 std::set_difference(mesh_subdomains.begin(),
3616 mesh_subdomains.end(),
3617 input_subdomains.begin(),
3618 input_subdomains.end(),
3619 std::inserter(difference, difference.end()));
3625 if (!difference.empty())
3627 std::vector<SubdomainID> difference_vec =
3628 std::vector<SubdomainID>(difference.begin(), difference.end());
3630 std::stringstream missing_block_names;
3631 std::copy(difference_names.begin(),
3632 difference_names.end(),
3633 std::ostream_iterator<std::string>(missing_block_names,
" "));
3634 std::stringstream missing_block_ids;
3635 std::copy(difference.begin(),
3637 std::ostream_iterator<unsigned int>(missing_block_ids,
" "));
3639 mooseError(
"Each subdomain must contain at least one Kernel.\nThe following block(s) lack an " 3641 missing_block_names.str(),
3643 missing_block_ids.str(),
3651 std::set<VariableName> difference;
3652 std::set_difference(variables.begin(),
3654 kernel_variables.begin(),
3655 kernel_variables.end(),
3656 std::inserter(difference, difference.end()));
3659 std::set<VariableName> vars(difference);
3660 for (
auto & var_name : vars)
3664 difference.erase(var_name);
3667 if (!difference.empty())
3669 std::stringstream missing_kernel_vars;
3670 std::copy(difference.begin(),
3672 std::ostream_iterator<std::string>(missing_kernel_vars,
" "));
3673 mooseError(
"Each variable must be referenced by at least one active Kernel.\nThe following " 3674 "variable(s) lack an active kernel: " +
3675 missing_kernel_vars.str());
3692 else if (pcs ==
"right")
3694 else if (pcs ==
"symmetric")
3696 else if (pcs ==
"default")
3705 if (kspnorm ==
"none")
3707 else if (kspnorm ==
"preconditioned")
3709 else if (kspnorm ==
"unpreconditioned")
3711 else if (kspnorm ==
"natural")
3713 else if (kspnorm ==
"default")
3716 mooseError(
"Unknown ksp norm type specified.");
3753 const std::set<TagID> & vector_tags,
3754 const std::set<TagID> & matrix_tags)
3756 parallel_object_only();
3761 map_pr.second(compute_type, vector_tags, matrix_tags);
3764 map_pr.second(compute_type, vector_tags, matrix_tags);
3766 catch (MetaPhysicL::LogicError &)
3769 "We caught a MetaPhysicL error in NonlinearSystemBase::mortarConstraints. This is very " 3770 "likely due to AD not having a sufficiently large derivative container size. Please run " 3771 "MOOSE configure with the '--with-derivative-size=<n>' option");
3794 std::set<unsigned int> var_numbers, var_numbers_covered, var_numbers_not_covered;
3796 var_numbers.insert(var_number);
3806 "', provided to the 'scaling_group_variables' parameter, does not exist in " 3807 "the nonlinear system.");
3814 if (!map_pair.second)
3815 mooseError(
"Variable ", var_name,
" is contained in multiple scaling grouplings");
3816 var_numbers_covered.insert(var.
number());
3819 std::set_difference(var_numbers.begin(),
3821 var_numbers_covered.begin(),
3822 var_numbers_covered.end(),
3823 std::inserter(var_numbers_not_covered, var_numbers_not_covered.begin()));
3828 for (
auto var_number : var_numbers_not_covered)
3833 const auto & number_to_var_map =
_vars[0].numberToVariableMap();
3839 libmesh_map_find(number_to_var_map, i)->name()) !=
3852 _console <<
"\nPerforming automatic scaling calculation\n" << std::endl;
3854 TIME_SECTION(
"computeScaling", 3,
"Computing Automatic Scaling");
3861 std::vector<dof_id_type> dof_indices;
3869 auto & dof_map =
dofMap();
3913 auto examine_dof_indices = [
this,
3917 &jac_inverse_scaling_factors,
3918 &resid_inverse_scaling_factors,
3919 &scaling_residual](
const auto & dof_indices,
const auto var_number)
3921 for (
auto dof_index : dof_indices)
3922 if (dof_map.local_index(dof_index))
3927 auto mat_value = (*_scaling_matrix)(dof_index, dof_index);
3933 auto vec_value = scaling_residual(dof_index);
3941 for (
const auto & elem : *
mesh().getActiveLocalElementRange())
3945 dof_map.dof_indices(elem, dof_indices, i);
3946 examine_dof_indices(dof_indices, i);
3952 dof_map.SCALAR_dof_indices(dof_indices, i);
3953 examine_dof_indices(dof_indices, i);
3961 if (jac_scaling && resid_scaling)
3962 for (MooseIndex(inverse_scaling_factors) i = 0; i < inverse_scaling_factors.size(); ++i)
3965 if (!resid_inverse_scaling_factors[i])
3967 if (!jac_inverse_scaling_factors[i])
3968 inverse_scaling_factors[i] = 1;
3970 inverse_scaling_factors[i] = jac_inverse_scaling_factors[i];
3972 else if (!jac_inverse_scaling_factors[i])
3974 inverse_scaling_factors[i] = resid_inverse_scaling_factors[i];
3976 inverse_scaling_factors[i] =
3980 else if (jac_scaling)
3981 inverse_scaling_factors = jac_inverse_scaling_factors;
3982 else if (resid_scaling)
3983 inverse_scaling_factors = resid_inverse_scaling_factors;
3985 mooseError(
"We shouldn't be calling this routine if we're not performing any scaling");
3988 for (
auto & scaling_factor : inverse_scaling_factors)
3989 if (scaling_factor == 0)
3993 std::vector<Real> flattened_inverse_scaling_factors(
system().
n_vars());
3994 for (
const auto i :
index_range(flattened_inverse_scaling_factors))
3995 flattened_inverse_scaling_factors[i] = inverse_scaling_factors[
_var_to_group_var[i]];
4000 displaced_problem->systemBaseNonlinear(
number()).applyScalingFactors(
4001 flattened_inverse_scaling_factors);
4014 auto & scaling_vector =
getVector(
"scaling_factors");
4017 const auto & dof_map =
dofMap();
4019 const auto & field_variables =
_vars[0].fieldVariables();
4020 const auto & scalar_variables =
_vars[0].scalars();
4022 std::vector<dof_id_type> dof_indices;
4024 for (
const Elem *
const elem :
4025 as_range(lm_mesh.active_local_elements_begin(), lm_mesh.active_local_elements_end()))
4026 for (
const auto *
const field_var : field_variables)
4028 const auto & factors = field_var->arrayScalingFactor();
4029 for (
const auto i :
make_range(field_var->count()))
4031 dof_map.dof_indices(elem, dof_indices, field_var->number() + i);
4032 for (
const auto dof : dof_indices)
4033 scaling_vector.set(dof, factors[i]);
4037 for (
const auto *
const scalar_var : scalar_variables)
4039 mooseAssert(scalar_var->count() == 1,
4040 "Scalar variables should always have only one component.");
4041 dof_map.SCALAR_dof_indices(dof_indices, scalar_var->number());
4042 for (
const auto dof : dof_indices)
4043 scaling_vector.set(dof, scalar_var->scalingFactor());
4047 scaling_vector.close();
4051 displaced_problem->systemBaseNonlinear(
number()).getVector(
"scaling_factors") = scaling_vector;
4069 if (!scaling_succeeded)
std::string name(const ElemQuality q)
virtual void setSolutionUDotDotOld(const NumericVector< Number > &u_dotdot_old)
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
virtual void residualSetup(THREAD_ID tid=0) const
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.
void setActiveMaterialProperties(const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
Record and set the material properties required by the current computing thread.
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
std::unique_ptr< DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
NumericVector< Number > * _Re_time
residual vector for time contributions
void computeJacobianBlocks(std::vector< JacobianBlock *> &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...
virtual void insert(const Number *v, const std::vector< numeric_index_type > &dof_indices)
TagID _Re_time_tag
Tag for time contribution residual.
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds a kernel.
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
virtual void setSolutionUDotDot(const NumericVector< Number > &udotdot)
Set transient term used by residual and Jacobian evaluation.
void reinitIncrementAtNodeForDampers(THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
Compute the incremental change in variables at nodes for dampers.
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
void overwriteNodeFace(NumericVector< Number > &soln)
Called from explicit time stepping to overwrite boundary positions (explicit dynamics).
Base class for deriving general dampers.
MoosePreconditioner const * getPreconditioner() const
virtual const char * what() const
Get out the error message.
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::unordered_map< dof_id_type, std::vector< dof_id_type >> &graph)
Finds the implicit sparsity graph between geometrically related dofs.
void setupDampers()
Setup damping stuff (called before we actually start)
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
void zeroVectorForResidual(const std::string &vector_name)
virtual void cacheResidualNeighbor(const THREAD_ID tid) override
bool identifyVariableGroupsInNL() const
Whether to identify variable groups in nonlinear systems.
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Base class for split-based preconditioners.
bool hasActiveBlockObjects(THREAD_ID tid=0) const
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
virtual void checkExceptionAndStopSolve(bool print_message=true)
Check to see if an exception has occurred on any processor and, if possible, force the solve to fail...
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
void computeNodalBCsResidualAndJacobian()
compute the residual and Jacobian for nodal boundary conditions
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored...
bool _debugging_residuals
true if debugging residuals
BoundaryID _secondary_boundary
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
virtual NonlinearSolver< Number > * nonlinearSolver()=0
Real computeDamping(const NumericVector< Number > &solution, const NumericVector< Number > &update)
Compute damping.
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
virtual void setPreviousNewtonSolution(const NumericVector< Number > &soln)
void enforceNodalConstraintsJacobian()
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters) override
Add a time integrator.
virtual Elem * elemPtr(const dof_id_type i)
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void petscSetupDM(NonlinearSystemBase &nl, const std::string &dm_name)
Setup the PETSc DM object.
NumericVector< Number > & solution()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
virtual void init() override
Initialize the system.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
void reinitIncrementAtQpsForDampers(THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
Compute the incremental change in variables at QPs for dampers.
void computeResidualAndJacobianInternal(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary c...
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
virtual void setSolution(const NumericVector< Number > &soln)
bool haveFieldSplitPreconditioner() const
bool areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
unsigned int number() const
Get variable number coming from libMesh.
virtual void initialSetup() override
Setup Functions.
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
virtual void init()
Initialize the system.
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
Base class for automatic differentiation Dirichlet BCs.
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
void setupDM()
Setup the PETSc DM object (when appropriate)
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
void setCurrentlyComputingResidual(bool currently_computing_residual) final
Set whether or not the problem is in the process of computing the residual.
void checkKernelCoverage(const std::set< SubdomainID > &mesh_subdomains) const
void addDGKernel(std::string dg_kernel_name, const std::string &name, InputParameters ¶meters)
Adds a DG kernel.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
void setupFieldDecomposition()
void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
void getNodeDofs(dof_id_type node_id, std::vector< dof_id_type > &dofs)
Base class for all Constraint types.
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
std::vector< std::string > _ignore_variables_for_autoscaling
A container for variables that do not partipate in autoscaling.
void residualSetup() override
Base boundary condition of a Dirichlet type.
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual void addJacobianOffDiagScalar(unsigned int ivar, const THREAD_ID tid=0)
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
void setDecomposition(const std::vector< std::string > &decomposition)
If called with a single string, it is used as the name of a the top-level decomposition split...
virtual void customSetup(const ExecFlagType &exec_type, THREAD_ID tid=0) const
const SubdomainID BOUNDARY_SIDE_LOWERD_ID
bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid) const
Indicates whether this system needs material properties on internal sides.
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
virtual const Node * queryNodePtr(const dof_id_type i) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
bool hasActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
const Parallel::Communicator & comm() const
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual void setSolutionUDotOld(const NumericVector< Number > &u_dot_old)
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
This class provides an interface for common operations on field variables of both FE and FV types wit...
const Parallel::Communicator & _communicator
void updateActive(THREAD_ID tid=0) override
Update the various active lists.
void setPCSide(MooseEnum pcs)
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
bool needInterfaceMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const
Indicated whether this system needs material properties on interfaces.
std::size_t _num_scaling_groups
The number of scaling groups.
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we're computing the scaling jacobian.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
Base class for a system (of equations)
void computeJacobian(SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
bool hasDampers()
Whether or not this system has dampers.
ConstNodeRange * getLocalNodeRange()
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.
virtual void cacheJacobianNeighbor(const THREAD_ID tid) override
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
void(* jacobian)(const NumericVector< Number > &X, SparseMatrix< Number > &J, sys_type &S)
virtual const Node & nodeRef(const dof_id_type i) const
TagID _Ke_system_tag
Tag for system contribution Jacobian.
bool _have_decomposition
Whether or not the system can be decomposed into splits.
Scope guard for starting and stopping Floating Point Exception Trapping.
auto max(const L &left, const R &right)
Serves as a base class for DGKernel and ADDGKernel.
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
Base class for MOOSE preconditioners.
virtual GeometricSearchData & geomSearchData() override
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
Specialization for filling multiple "small" preconditioning matrices simulatenously.
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds a scalar kernel.
void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters ¶meters)
Adds a boundary condition.
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
void computeResidual(NumericVector< Number > &residual, TagID tag_id)
Form a residual vector for a given tag.
virtual unsigned int nVariables() const
Get the number of variables in this system.
EXTERN_C_BEGIN PetscErrorCode DMCreate_Moose(DM)
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
virtual const std::string & name() const
virtual void jacobianSetup()
void onTimestepBegin()
Called at the beginning of the time step.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
virtual void deactiveAllMatrixTags()
Make matrices inactive.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
void solutionInvalidAccumulation()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
std::map< std::pair< BoundaryID, BoundaryID >, NearestNodeLocator * > _nearest_node_locators
void setPredictor(std::shared_ptr< Predictor > predictor)
virtual void addCachedResidualDirectly(NumericVector< Number > &residual, const THREAD_ID tid)
Allows for all the residual contributions that are currently cached to be added directly into the vec...
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...
bool _auto_scaling_initd
Whether we've initialized the automatic scaling data structures.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
bool _doing_dg
true if DG is active (optimization reasons)
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
Use whatever we have in PETSc.
unsigned int number() const
void computeResidualAndJacobianTags(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Form possibly multiple tag-associated vectors and matrices.
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const
Indicated whether this system needs material properties on boundaries.
FEProblemBase & _fe_problem
virtual void restoreSolutions() override
Restore current solutions (call after your solve failed)
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
virtual void setResidual(NumericVector< Number > &residual, const THREAD_ID tid) override
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
A map from variable index to group variable index and it's associated (inverse) scaling factor...
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
std::vector< unsigned int > _current_l_its
void computeTimeDerivatives(bool jacobian_calculation=false)
Computes the time derivative vector.
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void min(const T &r, T &o, Request &req) const
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
void updateActive(THREAD_ID tid)
Update active objects of Warehouses owned by NonlinearSystemBase.
TheWarehouse & theWarehouse() const
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase *> *reinit_mats=nullptr)
reinit materials on the neighboring element face
const ElementPairList & getElemPairs() const
Use whatever we have in PETSc.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.
unsigned int _current_nl_its
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
boundary_id_type BoundaryID
virtual void serializeSolution()
void addSplit(const std::string &split_name, const std::string &name, InputParameters ¶meters)
Adds a split.
bool _automatic_scaling
Whether to automatically scale the variables.
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.
virtual void timestepSetup(THREAD_ID tid=0) const
NonlinearSystemBase & currentNonlinearSystem()
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we're computing the scaling residual.
virtual void predictorCleanup(NumericVector< Number > &ghosted_solution)
Perform cleanup tasks after application of predictor to solution vector.
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
std::shared_ptr< Split > getSplit(const std::string &name)
Retrieves a split by name.
virtual void associateMatrixToTag(SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
void setInitialSolution()
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
virtual void zero_rows(std::vector< numeric_index_type > &rows, Number diag_value=0.0)
MooseObjectTagWarehouse< KernelBase > _kernels
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Base class for deriving nodal dampers.
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
virtual void cacheResidual(const THREAD_ID tid) override
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
virtual SubProblem & subproblem()
This is the ElementPairLocator class.
This is the ElementPairInfo class.
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
unsigned int number() const
Gets the number of this system.
void setupScalingData()
Setup group scaling containers.
virtual GeometricSearchData & geomSearchData()=0
bool containsTimeKernel()
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
AuxiliarySystem & getAuxiliarySystem()
virtual void initialSetup(THREAD_ID tid=0) const
Convenience methods for calling object setup methods.
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Base class for deriving any boundary condition that works at nodes.
NonlinearSystemBase(FEProblemBase &problem, System &sys, const std::string &name)
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
virtual void prepareAssembly(const THREAD_ID tid) override
bool computeScaling()
Method used to obtain scaling factors for variables.
Interface for objects interacting with the PerfGraph.
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the system, where a tag is represented by a map from name to ID...
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
virtual void jacobianSetup(THREAD_ID tid=0) const
ConstraintWarehouse _constraints
Constraints storage object.
virtual void turnOffJacobian()
Turn off the Jacobian (must be called before equation system initialization)
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
TagID residualVectorTag() const override
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
virtual void customSetup(const ExecFlagType &exec_type) override
ComputeType
The type of nonlinear computation being performed.
Base class for deriving element dampers.
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
virtual void addNodalKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds a NodalKernel.
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
virtual unsigned int numMatrixTags() const
The total number of tags.
Base class for creating new types of boundary conditions.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
ParallelType type() const
virtual NumericVector< Number > & RHS()=0
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Provides a way for users to bail out of the current solve.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
void addDiracKernel(const std::string &kernel_name, const std::string &name, InputParameters ¶meters)
Adds a Dirac kernel.
void computeJacobianInternal(const std::set< TagID > &tags)
Form multiple matrices for all the tags.
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
Base class for creating new types of nodal kernels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Base class for time integrators.
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
void constraintJacobians(bool displaced)
Add jacobian contributions from Constraints.
virtual void subdomainSetup()
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
Generic class for solving transient nonlinear problems.
StoredRange< std::set< const Elem * >::const_iterator, const Elem * > DistElemRange
TagID timeVectorTag() const override
Ideally, we should not need this API.
Class for containing MooseEnum item information.
bool hasActiveObjects(THREAD_ID tid=0) const
void max(const T &r, T &o, Request &req) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual System & system() override
Get the reference to the libMesh system.
virtual System & system() override
Get the reference to the libMesh system.
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true) override
Add Constraint object to the warehouse.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
virtual void setSolutionUDot(const NumericVector< Number > &udot)
Set transient term used by residual and Jacobian evaluation.
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Moose::PCSideType _pc_side
Preconditioning side.
const SubdomainID INTERNAL_SIDE_LOWERD_ID
const std::vector< std::shared_ptr< MortarConstraintBase > > & getActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
void computeScalarKernelsJacobians(const std::set< TagID > &tags)
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
virtual MooseMesh & mesh()
Base class for deriving dampers.
const NumericVector< Number > * _current_solution
solution vector from nonlinear solver
bool getFailNextNonlinearConvergenceCheck() const
Whether it will skip further residual evaluations and fail the next nonlinear convergence check...
Base class shared by AD and non-AD scalar kernels.
void addDamper(const std::string &damper_name, const std::string &name, InputParameters ¶meters)
Adds a damper.
IntRange< T > make_range(T beg, T end)
virtual MooseMesh & mesh() override
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
const std::vector< VariableName > & getVariableNames() const
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
virtual void timestepSetup() override
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
Base class for deriving any boundary condition of a integrated type.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
TagID _Re_tag
Used for the residual vector from PETSc.
virtual void customSetup(const ExecFlagType &exec_type)
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Moose::CouplingType coupling()
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.
bool ignoreZerosInJacobian() const
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...
const ExecFlagType EXEC_PRE_KERNELS
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
NumericVector< Number > * _increment_vec
increment vector
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
const TagName SOLUTION_TAG
bool doingDG() const
Getter for _doing_dg.
virtual NumericVector< Number > & serializedSolution() override
Returns a reference to a serialized version of the solution vector for this subproblem.
void computeResidualTag(NumericVector< Number > &residual, TagID tag_id)
Computes residual for a given tag.
void addConstraint(const std::string &c_name, const std::string &name, InputParameters ¶meters)
Adds a Constraint.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
face_info_iterator ownedFaceInfoEnd()
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
bool preSolve()
Perform some steps to get ready for the solver.
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, AutomaticMortarGeneration > & getMortarInterfaces(bool on_displaced) const
bool _has_constraints
Whether or not this system has any Constraints.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.
std::string _decomposition_split
Name of the top-level split of the decomposition.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void resetSolutionInvalidCurrentIteration()
Reset the number of solution invalid occurrences back to zero.
NumericVector< Number > & residualVector(TagID tag)
Return a residual vector that is associated with the residual tag.
NumericVector< Number > & solutionOld()
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.
virtual bool hasScalarVariable(const std::string &var_name) const
const TagName PREVIOUS_NL_SOLUTION_TAG
processor_id_type processor_id() const
Assembly & assembly(const THREAD_ID tid, const unsigned int nl_sys_num) override
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Update supplied subdomain and variable coverate containters.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
virtual void initialSetup()
Setup Functions.
bool defaultGhosting()
Whether or not the user has requested default ghosting ot be on.
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int nl_sys_num)=0
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
virtual void cacheJacobian(const THREAD_ID tid) override
auto min(const L &left, const R &right)
void jacobianSetup() override
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void residualSetup()
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
virtual void addResidualScalar(const THREAD_ID tid=0)
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void jacobianSetup() override
virtual void addCachedResidual(const THREAD_ID tid) override
std::vector< std::vector< std::string > > _scaling_group_variables
A container of variable groupings that can be used in scaling calculations.
void addInterfaceKernel(std::string interface_kernel_name, const std::string &name, InputParameters ¶meters)
Adds an interface kernel.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
auto index_range(const T &sizable)
virtual NumericVector< Number > & residualCopy() override
virtual NumericVector< Number > & residualGhosted() override
DiracKernelBase is the base class for all DiracKernel type classes.
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...
void setMooseKSPNormType(MooseEnum kspnorm)
BoundaryID _primary_boundary
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
virtual void residualEnd(THREAD_ID tid=0) const
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
virtual void addJacobianScalar(const THREAD_ID tid=0)
NearestNodeLocator & _nearest_node
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void addCachedJacobian(const THREAD_ID tid) override
virtual void timestepSetup()
virtual ~NonlinearSystemBase()
virtual void augmentSparsity(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz) override
Will modify the sparsity pattern to add logical geometric connections.
virtual void residualSetup() override
void setPreconditioner(std::shared_ptr< MoosePreconditioner > pc)
Sets a preconditioner.
virtual void localize(std::vector< Number > &v_local) const =0
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs
Key structure for APIs manipulating global vectors/matrices.