https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NonlinearSystemBase.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "SolverSystem.h"
13#include "ConstraintWarehouse.h"
16#include "PerfGraphInterface.h"
18#include "MooseHashing.h"
19
20#include "libmesh/transient_system.h"
21#include "libmesh/nonlinear_implicit_system.h"
22#include "libmesh/linear_solver.h"
23
24// Forward declarations
25class FEProblemBase;
27class JacobianBlock;
28class TimeIntegrator;
29class Predictor;
30class ElementDamper;
31class NodalDamper;
32class GeneralDamper;
35class NodalBCBase;
36class DirichletBCBase;
38class DGKernelBase;
41class DiracKernelBase;
42class NodalKernelBase;
43class Split;
44class KernelBase;
45class HDGKernel;
47class ResidualObject;
48class PenetrationInfo;
50class Convergence;
51
52// libMesh forward declarations
53namespace libMesh
54{
55template <typename T>
56class NumericVector;
57template <typename T>
58class SparseMatrix;
59template <typename T>
60class DiagonalMatrix;
61class DofMapBase;
62} // namespace libMesh
63
70{
71public:
72 NonlinearSystemBase(FEProblemBase & problem, libMesh::System & sys, const std::string & name);
74
75 virtual void preInit() override;
78
80
84 virtual void turnOffJacobian();
85
86 virtual void solve() override = 0;
87
89
90 virtual SNES getSNES() = 0;
91
92 virtual unsigned int getCurrentNonlinearIterationNumber() = 0;
93
99
100 // Setup Functions ////
101 virtual void initialSetup() override;
102 virtual void timestepSetup() override;
103 virtual void customSetup(const ExecFlagType & exec_type) override;
104 virtual void residualSetup() override;
105 virtual void jacobianSetup() override;
106
108
113 bool haveFieldSplitPreconditioner() const { return _fsp; }
114
121 virtual void addKernel(const std::string & kernel_name,
122 const std::string & name,
123 InputParameters & parameters);
124
131 virtual void addHDGKernel(const std::string & kernel_name,
132 const std::string & name,
133 InputParameters & parameters);
134
141 virtual void addNodalKernel(const std::string & kernel_name,
142 const std::string & name,
143 InputParameters & parameters);
144
151 void addScalarKernel(const std::string & kernel_name,
152 const std::string & name,
153 InputParameters & parameters);
154
161 void addBoundaryCondition(const std::string & bc_name,
162 const std::string & name,
163 InputParameters & parameters);
164
165#ifdef MOOSE_KOKKOS_ENABLED
172 virtual void addKokkosKernel(const std::string & kernel_name,
173 const std::string & name,
174 InputParameters & parameters);
175
182 virtual void addKokkosNodalKernel(const std::string & kernel_name,
183 const std::string & name,
184 InputParameters & parameters);
185
192 void addKokkosBoundaryCondition(const std::string & bc_name,
193 const std::string & name,
194 InputParameters & parameters);
195#endif
196
203 void
204 addConstraint(const std::string & c_name, const std::string & name, InputParameters & parameters);
205
212 void addDiracKernel(const std::string & kernel_name,
213 const std::string & name,
214 InputParameters & parameters);
215
222 void
223 addDGKernel(std::string dg_kernel_name, const std::string & name, InputParameters & parameters);
224
231 void addInterfaceKernel(std::string interface_kernel_name,
232 const std::string & name,
233 InputParameters & parameters);
234
241 void addDamper(const std::string & damper_name,
242 const std::string & name,
243 InputParameters & parameters);
244
251 void
252 addSplit(const std::string & split_name, const std::string & name, InputParameters & parameters);
253
258 std::shared_ptr<Split> getSplit(const std::string & name);
259
264
271 bool shouldEvaluatePreSMOResidual() const;
272
287 void setPreSMOResidual(bool use) { _use_pre_smo_residual = use; }
288
290 const bool & usePreSMOResidual() const { return _use_pre_smo_residual; }
291
293 Real referenceResidual() const;
294
296 Real preSMOResidual() const;
297
299 Real initialResidual() const;
300
302 void setInitialResidual(Real r);
303
304 void zeroVectorForResidual(const std::string & vector_name);
305
306 void setInitialSolution();
307
308#ifdef MOOSE_KOKKOS_ENABLED
310#endif
311
315 void setConstraintSecondaryValues(NumericVector<Number> & solution, bool displaced);
316
324 void constraintResiduals(NumericVector<Number> & residual, bool displaced);
325
331 void computeResidualTag(NumericVector<Number> & residual, TagID tag_id);
332
336 void computeResidualTags(const std::set<TagID> & tags);
337
341 void computeResidualAndJacobianTags(const std::set<TagID> & vector_tags,
342 const std::set<TagID> & matrix_tags);
343
348 void computeResidualAndJacobianInternal(const std::set<TagID> & vector_tags,
349 const std::set<TagID> & matrix_tags);
350
351#ifdef MOOSE_KOKKOS_ENABLED
352 void computeKokkosResidualAndJacobian(const std::set<TagID> & vector_tags,
353 const std::set<TagID> & matrix_tags);
354#endif
355
359 void computeResidual(NumericVector<Number> & residual, TagID tag_id);
360
367
374 void constraintJacobians(const SparseMatrix<Number> & jacobian_to_view, bool displaced);
375
379 void computeJacobianTags(const std::set<TagID> & tags);
380
385 bool computeScaling();
386
390 void computeJacobian(libMesh::SparseMatrix<Number> & jacobian, const std::set<TagID> & tags);
391
396
405 void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks);
406
407 void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks, const std::set<TagID> & tags);
408
415 Real computeDamping(const NumericVector<Number> & solution, const NumericVector<Number> & update);
416
420 void onTimestepBegin();
421
428 virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid);
429
434 void overwriteNodeFace(NumericVector<Number> & soln);
435
439 void updateActive(THREAD_ID tid);
440
447 virtual void setSolutionUDot(const NumericVector<Number> & udot);
448
455 virtual void setSolutionUDotDot(const NumericVector<Number> & udotdot);
456
460 NumericVector<Number> & getResidualTimeVector();
461
465 NumericVector<Number> & getResidualNonTimeVector();
466
470 NumericVector<Number> & residualVector(TagID tag);
471
472 virtual NumericVector<Number> & residualCopy() override;
473 virtual NumericVector<Number> & residualGhosted() override;
474
475 virtual NumericVector<Number> & RHS() = 0;
476
477 virtual void augmentSparsity(libMesh::SparsityPattern::Graph & sparsity,
478 std::vector<dof_id_type> & n_nz,
479 std::vector<dof_id_type> & n_oz) override;
480
485 void setPreconditioner(std::shared_ptr<MoosePreconditioner> pc);
487
496
501
507
520
526 void assembleConstraintsSeparately(bool separately = true)
527 {
529 }
530
535 virtual void attachPreconditioner(libMesh::Preconditioner<Number> * preconditioner) = 0;
536
540 void setupDampers();
546 void reinitIncrementAtQpsForDampers(THREAD_ID tid, const std::set<MooseVariable *> & damped_vars);
547
554 const std::set<MooseVariable *> & damped_vars);
555
558 void checkKernelCoverage(const std::set<SubdomainID> & mesh_subdomains) const;
559 virtual bool containsTimeKernel() override;
560 virtual std::vector<std::string> timeKernelVariableNames() override;
562
566 virtual unsigned int nNonlinearIterations() const { return _n_iters; }
567
571 virtual unsigned int nLinearIterations() const { return _n_linear_iters; }
572
576 unsigned int nResidualEvaluations() const { return _n_residual_evaluations; }
577
581 virtual Real finalNonlinearResidual() const { return _final_residual; }
582
587 Real nonlinearNorm() const { return _last_nl_rnorm; }
588
593 void printAllVariableNorms(bool state) { _print_all_var_norms = state; }
594
595 void debuggingResiduals(bool state) { _debugging_residuals = state; }
596
598
599 void setPredictor(std::shared_ptr<Predictor> predictor);
600 Predictor * getPredictor() { return _predictor.get(); }
601
606 bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
607
612 bool needInterfaceMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
613
618 bool needInternalNeighborSideMaterial(SubdomainID subdomain_id, THREAD_ID tid) const;
619
623 bool doingDG() const;
624
626
656
661
669
670#ifdef MOOSE_KOKKOS_ENABLED
687#endif
688
690
694 bool hasSaveIn() const { return _has_save_in || _has_nodalbc_save_in; }
695
700
701 virtual libMesh::System & system() override { return _sys; }
702 virtual const libMesh::System & system() const override { return _sys; }
703
704 virtual void setSolutionUDotOld(const NumericVector<Number> & u_dot_old);
705
706 virtual void setSolutionUDotDotOld(const NumericVector<Number> & u_dotdot_old);
707
708 virtual void setPreviousNewtonSolution(const NumericVector<Number> & soln);
709
710 TagID timeVectorTag() const override { return _Re_time_tag; }
711 TagID nonTimeVectorTag() const override { return _Re_non_time_tag; }
712 TagID residualVectorTag() const override { return _Re_tag; }
713 TagID systemMatrixTag() const override { return _Ke_system_tag; }
714
718 virtual void residualAndJacobianTogether() = 0;
719
721 void computeScalingOnce(bool compute_scaling_once)
722 {
723 _compute_scaling_once = compute_scaling_once;
724 }
725
731 void autoScalingParam(Real resid_vs_jac_scaling_param)
732 {
733 _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
734 }
735
736 void scalingGroupVariables(const std::vector<std::vector<std::string>> & scaling_group_variables)
737 {
738 _scaling_group_variables = scaling_group_variables;
739 }
740
741 void
742 ignoreVariablesForAutoscaling(const std::vector<std::string> & ignore_variables_for_autoscaling)
743 {
744 _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
745 }
746
748 void offDiagonalsInAutoScaling(bool off_diagonals_in_auto_scaling)
749 {
750 _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
751 }
752
754 // FIXME: make these protected and create getters/setters
756 std::vector<unsigned int> _current_l_its;
757 unsigned int _current_nl_its;
758
762 void setupDM();
763
765
771
775 void destroyColoring();
776
778 void setConvergenceName(const ConvergenceName & convergence_name)
779 {
780 _convergence_name = convergence_name;
781 }
782
785
786protected:
791 void computeResidualInternal(const std::set<TagID> & tags);
792
793#ifdef MOOSE_KOKKOS_ENABLED
797 void computeKokkosResidual(const std::set<TagID> & tags);
801 void computeKokkosNodalBCsResidual(const std::set<TagID> & tags);
802#endif
803
808 void computeNodalBCsResidual(NumericVector<Number> & residual);
809
813 void computeNodalBCsResidual(NumericVector<Number> & residual, const std::set<TagID> & tags);
814
818 void computeNodalBCsResidual(const std::set<TagID> & tags);
819
823 void computeNodalBCsJacobian(const std::set<TagID> & tags);
824
828 void computeNodalBCsResidualAndJacobian(const std::set<TagID> & vector_tags,
829 const std::set<TagID> & matrix_tags);
830
834 void computeJacobianInternal(const std::set<TagID> & tags);
835
839#ifdef MOOSE_KOKKOS_ENABLED
840 void computeKokkosJacobian(const std::set<TagID> & tags);
841#endif
842
843 void computeDiracContributions(const std::set<TagID> & vector_tags,
844 const std::set<TagID> & matrix_tags,
845 Moose::ComputeType compute_type);
846
847 void computeScalarKernelsJacobians(const std::set<TagID> & tags);
848
852 void enforceNodalConstraintsResidual(NumericVector<Number> & residual);
853
860 bool enforceNodalConstraintsJacobian(const SparseMatrix<Number> & jacobian);
861
865 void mortarConstraints(Moose::ComputeType compute_type,
866 const std::set<TagID> & vector_tags,
867 const std::set<TagID> & matrix_tags);
868
872 virtual void computeScalingJacobian() = 0;
873
877 virtual void computeScalingResidual() = 0;
878
884
890
895 void reinitNodeFace(const Node & secondary_node,
896 const BoundaryID secondary_boundary,
897 const PenetrationInfo & info,
898 const bool displaced);
899
909 bool preSolve();
910
912 NumericVector<Number> * _residual_ghosted;
913
915 std::unique_ptr<NumericVector<Number>> _residual_copy;
916
921
924
926 std::set<TagID> _nl_vector_tags;
927
929 std::set<TagID> _nl_matrix_tags;
930
932 NumericVector<Number> * _Re_time;
933
937 NumericVector<Number> * _Re_non_time;
938
941
944
947
956
964
965#ifdef MOOSE_KOKKOS_ENABLED
974#endif
975
978
981
984
987
990
992 MooseObjectWarehouseBase<Split> _splits; // use base b/c there are no setup methods
993
996
998 NumericVector<Number> * _increment_vec;
1000 std::shared_ptr<MoosePreconditioner> _preconditioner;
1001
1004
1005 MatFDColoring _fdcoloring;
1006
1009
1012
1015
1020
1023
1025 std::vector<std::string> _vecs_to_zero_for_residual;
1026
1027 unsigned int _n_iters;
1028 unsigned int _n_linear_iters;
1029
1032
1034
1036 std::shared_ptr<Predictor> _predictor;
1037
1039
1046
1048
1051
1054
1057
1060
1061 void getNodeDofs(dof_id_type node_id, std::vector<dof_id_type> & dofs);
1062
1065
1070
1075
1079 std::vector<std::vector<std::string>> _scaling_group_variables;
1080
1082 std::vector<bool> _variable_autoscaled;
1083
1085 std::vector<std::string> _ignore_variables_for_autoscaling;
1086
1089
1091 std::unique_ptr<libMesh::DiagonalMatrix<Number>> _scaling_matrix;
1092
1093private:
1100 std::vector<SetupInterface *> getFVSetupObjects(THREAD_ID tid);
1101
1106 GeometricSearchData & geom_search_data,
1107 std::unordered_map<dof_id_type, std::vector<dof_id_type>> & graph);
1108
1112 void setupScalingData();
1113
1115 std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
1117
1119 std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
1121
1123 std::vector<NumericVector<Number> *> _solution_state;
1124
1127
1129 std::unordered_map<unsigned int, unsigned int> _var_to_group_var;
1130
1133
1135 ConvergenceName _convergence_name;
1136};
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
char ** blocks
Base class for automatic differentiation Dirichlet BCs.
Base class for creating new types of boundary conditions.
Warehouse for storing constraints.
Base class for convergence criteria.
Definition Convergence.h:26
Serves as a base class for DGKernel and ADDGKernel.
DiracKernelBase is the base class for all DiracKernel type classes.
Base boundary condition of a Dirichlet type.
Base class for deriving element dampers.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Base interface for field split preconditioner.
Base class for deriving general dampers.
Base kernel for hybridized finite element formulations.
Definition HDGKernel.h:18
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Base class for deriving any boundary condition of a integrated type.
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
Helper class for holding the preconditioning blocks to fill.
This is the common base class for the three main kernel types implemented in MOOSE,...
Definition KernelBase.h:29
Class for containing MooseEnum item information.
A storage container for MooseObjects that inherit from SetupInterface.
A base storage container for MooseObjects.
A storage container for MooseObjects that inherit from SetupInterface.
Base class for MOOSE preconditioners.
Base class for deriving any boundary condition that works at nodes.
Definition NodalBCBase.h:28
Base class for deriving nodal dampers.
Definition NodalDamper.h:28
Base class for creating new types of nodal kernels.
Nonlinear system to be solved.
virtual void addKokkosKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a Kokkos kernel.
void computeDiracContributions(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags, Moose::ComputeType compute_type)
void addConstraint(const std::string &c_name, const std::string &name, InputParameters &parameters)
Adds a Constraint.
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs
MooseObjectTagWarehouse< ResidualObject > _kokkos_kernels
bool _debugging_residuals
true if debugging residuals
MoosePreconditioner const * getPreconditioner() const
bool preSolve()
Perform some steps to get ready for the solver.
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::size_t _num_scaling_groups
The number of scaling groups.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
void computeKokkosResidualAndJacobian(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
virtual std::vector< std::string > timeKernelVariableNames() override
Returns the names of the variables that have time derivative kernels in the system.
Real referenceResidual() const
The reference residual used in relative convergence check.
unsigned int _num_residual_evaluations
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual SNES getSNES()=0
virtual const libMesh::System & system() const override
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.
FieldSplitPreconditionerBase & getFieldSplitPreconditioner()
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_bcs
virtual void jacobianSetup() override
virtual void augmentSparsity(libMesh::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.
void computeScalingOnce(bool compute_scaling_once)
TagID _Ke_non_time_tag
Tag for non-time contribution Jacobian.
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...
void zeroVectorForResidual(const std::string &vector_name)
MooseObjectTagWarehouse< HDGKernel > & getHDGKernelWarehouse()
void onTimestepBegin()
Called at the beginning of the time step.
Convergence & convergence()
Retrieves the associated Convergence object.
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
void useFieldSplitPreconditioner(FieldSplitPreconditionerBase *fsp)
If called with a non-null object true this system will use a field split preconditioner matrix.
bool _use_finite_differenced_preconditioner
Whether or not to use a finite differenced preconditioner.
std::vector< std::string > _ignore_variables_for_autoscaling
A container for variables that do not partipate in autoscaling.
MooseObjectTagWarehouse< ResidualObject > & getKokkosKernelWarehouse()
virtual void subdomainSetup()
void reinitIncrementAtQpsForDampers(THREAD_ID tid, const std::set< MooseVariable * > &damped_vars)
Compute the incremental change in variables at QPs for dampers.
void computeKokkosResidual(const std::set< TagID > &tags)
Compute residual with Kokkos objects.
void setKokkosInitialSolution()
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...
void computeJacobian(libMesh::SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
MooseObjectTagWarehouse< ResidualObject > _kokkos_integrated_bcs
MooseObjectTagWarehouse< ResidualObject > & getKokkosNodalBCWarehouse()
NumericVector< Number > & residualVector(TagID tag)
Return a residual vector that is associated with the residual tag.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
bool haveFiniteDifferencedPreconditioner() const
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
NumericVector< Number > * _increment_vec
increment vector
bool needInterfaceMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const
Indicated whether this system needs material properties on interfaces.
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
void overwriteNodeFace(NumericVector< Number > &soln)
Called from explicit time stepping to overwrite boundary positions (explicit dynamics).
Real _pre_smo_residual
The pre-SMO residual, see setPreSMOResidual for a detailed explanation.
Real nonlinearNorm() const
Return the last nonlinear norm.
void updateActive(THREAD_ID tid)
Update active objects of Warehouses owned by NonlinearSystemBase.
void ignoreVariablesForAutoscaling(const std::vector< std::string > &ignore_variables_for_autoscaling)
NumericVector< Number > * _Re_time
residual vector for time contributions
virtual void setSolutionUDotDotOld(const NumericVector< Number > &u_dotdot_old)
MooseObjectTagWarehouse< ResidualObject > & getKokkosNodalKernelWarehouse()
bool computeScaling()
Method used to obtain scaling factors for variables.
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
void addSplit(const std::string &split_name, const std::string &name, InputParameters &parameters)
Adds a split.
virtual unsigned int nNonlinearIterations() const
Return the number of non-linear iterations.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
bool computingPreSMOResidual()
Returns true if this system is currently computing the pre-SMO residual for a solve.
bool shouldEvaluatePreSMOResidual() const
We offer the option to check convergence against the pre-SMO residual.
virtual NumericVector< Number > & residualGhosted() override
virtual void preInit() override
This is called prior to the libMesh system has been init'd.
virtual void turnOffJacobian()
Turn off the Jacobian (must be called before equation system initialization)
MooseObjectTagWarehouse< DiracKernelBase > & getDiracKernelWarehouse()
bool _auto_scaling_initd
Whether we've initialized the automatic scaling data structures.
TagID timeVectorTag() const override
Ideally, we should not need this API.
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.
virtual void setSolutionUDot(const NumericVector< Number > &udot)
Set transient term used by residual and Jacobian evaluation.
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
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 addNodalKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a NodalKernel.
MooseObjectWarehouse< ResidualObject > _kokkos_preset_nodal_bcs
void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
Adds a boundary condition.
void computeScalarKernelsJacobians(const std::set< TagID > &tags)
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.
void getNodeDofs(dof_id_type node_id, std::vector< dof_id_type > &dofs)
MooseObjectWarehouseBase< Split > & getSplits()
Retrieves all splits.
void scalingGroupVariables(const std::vector< std::vector< std::string > > &scaling_group_variables)
void offDiagonalsInAutoScaling(bool off_diagonals_in_auto_scaling)
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
virtual void addHDGKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a hybridized discontinuous Galerkin (HDG) kernel.
bool _doing_dg
true if DG is active (optimization reasons)
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.
virtual unsigned int getCurrentNonlinearIterationNumber()=0
void addDiracKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a Dirac kernel.
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.
const MooseObjectTagWarehouse< NodalKernelBase > & getNodalKernelWarehouse() const
std::shared_ptr< Split > getSplit(const std::string &name)
Retrieves a split by name.
void computeResidualTag(NumericVector< Number > &residual, TagID tag_id)
Computes residual for a given tag.
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.
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
virtual bool containsTimeKernel() override
If the system has a kernel that corresponds to a time derivative.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
void constraintJacobians(const SparseMatrix< Number > &jacobian_to_view, bool displaced)
Add jacobian contributions from Constraints.
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...
Real preSMOResidual() const
The pre-SMO residual.
const MooseObjectTagWarehouse< NodalBCBase > & getNodalBCWarehouse() const
Return the NodalBCBase warehouse.
void setInitialResidual(Real r)
Record the initial residual (for later relative convergence check)
std::vector< SetupInterface * > getFVSetupObjects(THREAD_ID tid)
Retrieve every finite volume object belonging to this system on thread tid, as SetupInterfaces,...
MooseObjectTagWarehouse< KernelBase > _kernels
MooseObjectTagWarehouse< InterfaceKernelBase > & getInterfaceKernelWarehouse()
virtual Real finalNonlinearResidual() const
Return the final nonlinear residual.
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
Real computeDamping(const NumericVector< Number > &solution, const NumericVector< Number > &update)
Compute damping.
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
void computeNodalBCsResidual(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual void potentiallySetupFiniteDifferencing()
Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of t...
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver()=0
virtual NumericVector< Number > & RHS()=0
void reinitIncrementAtNodeForDampers(THREAD_ID tid, const std::set< MooseVariable * > &damped_vars)
Compute the incremental change in variables at nodes for dampers.
bool doingDG() const
Getter for _doing_dg.
virtual void attachPreconditioner(libMesh::Preconditioner< Number > *preconditioner)=0
Attach a customized preconditioner that requires physics knowledge.
void autoScalingParam(Real resid_vs_jac_scaling_param)
Sets the param that indicates the weighting of the residual vs the Jacobian in determining variable s...
virtual void setPreviousNewtonSolution(const NumericVector< Number > &soln)
TagID _Re_time_tag
Tag for time contribution residual.
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
ConvergenceName _convergence_name
Associated convergence object name.
void addDGKernel(std::string dg_kernel_name, const std::string &name, InputParameters &parameters)
Adds a DG kernel.
const MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse() const
Return the IntegratedBCBase warehouse.
std::vector< NumericVector< Number > * > _solution_state
The current states of the solution (0 = current, 1 = old, etc)
void setupScalingData()
Setup group scaling containers.
void computeJacobianBlocks(std::vector< JacobianBlock * > &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...
void setPredictor(std::shared_ptr< Predictor > predictor)
void computeNodalBCsResidualAndJacobian(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Compute the residual and Jacobian together for nodal boundary conditions.
std::vector< unsigned int > _current_l_its
std::vector< std::vector< std::string > > _scaling_group_variables
A container of variable groupings that can be used in scaling calculations.
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse() const
MooseObjectTagWarehouse< ResidualObject > & getKokkosIntegratedBCWarehouse()
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
bool haveFieldSplitPreconditioner() const
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a scalar kernel.
bool offDiagonalsInAutoScaling() const
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
virtual void initialSetup() override
Setup Functions.
void addInterfaceKernel(std::string interface_kernel_name, const std::string &name, InputParameters &parameters)
Adds an interface kernel.
virtual void solve() override=0
Solve the system (using libMesh magic)
void addDamper(const std::string &damper_name, const std::string &name, InputParameters &parameters)
Adds a damper.
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
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.
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_kernels
bool _use_pre_smo_residual
Whether to use the pre-SMO initial residual in the relative convergence check.
void reinitMortarFunctors()
Update the mortar functors if the mesh has changed.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void assembleConstraintsSeparately(bool separately=true)
Indicates whether to assemble residual and Jacobian after each constraint application.
virtual void timestepSetup() override
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
const ConstraintWarehouse & getConstraintWarehouse() const
virtual void setupFiniteDifferencedPreconditioner()=0
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint.
void addKokkosBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
Adds a Kokkos boundary condition.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse()
virtual NumericVector< Number > & residualCopy() override
void computeKokkosJacobian(const std::set< TagID > &tags)
Compute Jacobian with Kokkos objects.
bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const
Indicated whether this system needs material properties on boundaries.
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
TagID _Re_tag
Used for the residual vector from PETSc.
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.
void printAllVariableNorms(bool state)
Force the printing of all variable norms after each solve.
void setPreconditioner(std::shared_ptr< MoosePreconditioner > pc)
Sets a preconditioner.
virtual ~NonlinearSystemBase()
void computeNodalBCsJacobian(const std::set< TagID > &tags)
Compute the Jacobian for nodal boundary conditions.
void checkKernelCoverage(const std::set< SubdomainID > &mesh_subdomains) const
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse()
Access functions to Warehouses from outside NonlinearSystemBase.
void computeResidual(NumericVector< Number > &residual, TagID tag_id)
Form a residual vector for a given tag.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.
TagID nonTimeVectorTag() const override
bool enforceNodalConstraintsJacobian(const SparseMatrix< Number > &jacobian)
Enforce nodal constraints in the Jacobian.
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
unsigned int nResidualEvaluations() const
Return the total number of residual evaluations done so far in this calculation.
Real _initial_residual
The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanatio...
virtual void residualSetup() override
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
void setConvergenceName(const ConvergenceName &convergence_name)
Sets the name of the associated Convergence object.
virtual unsigned int nLinearIterations() const
Return the number of linear iterations.
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.
void debuggingResiduals(bool state)
virtual void customSetup(const ExecFlagType &exec_type) override
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
virtual void setSolutionUDotOld(const NumericVector< Number > &u_dot_old)
virtual libMesh::System & system() override
Get the reference to the libMesh system.
void computeJacobianInternal(const std::set< TagID > &tags)
Form multiple matrices for all the tags.
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
TagID _Ke_system_tag
Tag for system contribution Jacobian.
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
bool needInternalNeighborSideMaterial(SubdomainID subdomain_id, THREAD_ID tid) const
Indicates whether this system needs material properties on internal sides.
void setupDM()
Setup the PETSc DM object (when appropriate)
void setupDampers()
Setup damping stuff (called before we actually start)
const bool & usePreSMOResidual() const
Whether we are using pre-SMO residual in relative convergence checks.
void computeKokkosNodalBCsResidual(const std::set< TagID > &tags)
Compute Kokkos nodal BCs.
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.
void useFiniteDifferencedPreconditioner(bool use=true)
If called with true this system will use a finite differenced form of the Jacobian as the preconditio...
virtual void setSolutionUDotDot(const NumericVector< Number > &udotdot)
Set transient term used by residual and Jacobian evaluation.
virtual void addKokkosNodalKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a Kokkos nodal kernel.
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a kernel.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
void computeResidualAndJacobianTags(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Form possibly multiple tag-associated vectors and matrices.
virtual void residualAndJacobianTogether()=0
Call this method if you want the residual and Jacobian to be computed simultaneously.
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse()
ConstraintWarehouse _constraints
Constraints storage object.
bool computedScalingJacobian() const
void setPreSMOResidual(bool use)
Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks...
MooseObjectTagWarehouse< HDGKernel > _hybridized_kernels
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
void destroyColoring()
Destroy the coloring object if it exists.
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse() const
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.
TagID residualVectorTag() const override
const MooseObjectTagWarehouse< ScalarKernelBase > & getScalarKernelWarehouse() const
const MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse() const
Real initialResidual() const
The initial residual.
Data structure used to hold penetration information.
Interface for objects interacting with the PerfGraph.
Base class for predictors.
Definition Predictor.h:29
This is the common base class for objects that give residual contributions.
Base class shared by AD and non-AD scalar kernels.
Base class for split-based preconditioners.
Definition Split.h:26
virtual void subdomainSetup()
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition SystemBase.C:409
virtual const std::string & name() const
NumericVector< Number > & solution()
Definition SystemBase.h:203
void update()
Update the system (doing libMesh magic)
Base class for time integrators.
ComputeType
The type of nonlinear computation being performed.
Definition MooseTypes.h:835
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...