https://mooseframework.inl.gov
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"
14 #include "MooseObjectWarehouse.h"
16 #include "PerfGraphInterface.h"
17 #include "ComputeMortarFunctor.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
25 class FEProblemBase;
27 class JacobianBlock;
28 class TimeIntegrator;
29 class Predictor;
30 class ElementDamper;
31 class NodalDamper;
32 class GeneralDamper;
34 class IntegratedBCBase;
35 class NodalBCBase;
36 class DirichletBCBase;
37 class ADDirichletBCBase;
38 class DGKernelBase;
40 class ScalarKernelBase;
41 class DiracKernelBase;
42 class NodalKernelBase;
43 class Split;
44 class KernelBase;
45 class HDGKernel;
46 class BoundaryCondition;
47 class ResidualObject;
48 class PenetrationInfo;
50 
51 // libMesh forward declarations
52 namespace libMesh
53 {
54 template <typename T>
55 class NumericVector;
56 template <typename T>
57 class SparseMatrix;
58 template <typename T>
59 class DiagonalMatrix;
60 class DofMapBase;
61 } // namespace libMesh
62 
69 {
70 public:
71  NonlinearSystemBase(FEProblemBase & problem, libMesh::System & sys, const std::string & name);
72  virtual ~NonlinearSystemBase();
73 
74  virtual void preInit() override;
76  void reinitMortarFunctors();
77 
78  bool computedScalingJacobian() const { return _computed_scaling; }
79 
83  virtual void turnOffJacobian();
84 
85  virtual void solve() override = 0;
86 
88 
89  virtual SNES getSNES() = 0;
90 
91  virtual unsigned int getCurrentNonlinearIterationNumber() = 0;
92 
98 
99  // Setup Functions ////
100  virtual void initialSetup() override;
101  virtual void timestepSetup() override;
102  virtual void customSetup(const ExecFlagType & exec_type) override;
103  virtual void residualSetup() override;
104  virtual void jacobianSetup() override;
105 
106  virtual void setupFiniteDifferencedPreconditioner() = 0;
107 
109  {
111  }
112  bool haveFieldSplitPreconditioner() const { return _fsp; }
113 
120  virtual void addKernel(const std::string & kernel_name,
121  const std::string & name,
122  InputParameters & parameters);
123 
130  virtual void addHDGKernel(const std::string & kernel_name,
131  const std::string & name,
132  InputParameters & parameters);
133 
140  virtual void addNodalKernel(const std::string & kernel_name,
141  const std::string & name,
142  InputParameters & parameters);
143 
150  void addScalarKernel(const std::string & kernel_name,
151  const std::string & name,
152  InputParameters & parameters);
153 
160  void addBoundaryCondition(const std::string & bc_name,
161  const std::string & name,
162  InputParameters & parameters);
163 
170  void
171  addConstraint(const std::string & c_name, const std::string & name, InputParameters & parameters);
172 
179  void addDiracKernel(const std::string & kernel_name,
180  const std::string & name,
181  InputParameters & parameters);
182 
189  void
190  addDGKernel(std::string dg_kernel_name, const std::string & name, InputParameters & parameters);
191 
198  void addInterfaceKernel(std::string interface_kernel_name,
199  const std::string & name,
200  InputParameters & parameters);
201 
208  void addDamper(const std::string & damper_name,
209  const std::string & name,
210  InputParameters & parameters);
211 
218  void
219  addSplit(const std::string & split_name, const std::string & name, InputParameters & parameters);
220 
225  std::shared_ptr<Split> getSplit(const std::string & name);
226 
231 
238  bool shouldEvaluatePreSMOResidual() const;
239 
254  void setPreSMOResidual(bool use) { _use_pre_smo_residual = use; }
255 
257  const bool & usePreSMOResidual() const { return _use_pre_smo_residual; }
258 
260  Real referenceResidual() const;
261 
263  Real preSMOResidual() const;
264 
266  Real initialResidual() const;
267 
269  void setInitialResidual(Real r);
270 
271  void zeroVectorForResidual(const std::string & vector_name);
272 
273  void setInitialSolution();
274 
279 
287  void constraintResiduals(NumericVector<Number> & residual, bool displaced);
288 
294  void computeResidualTag(NumericVector<Number> & residual, TagID tag_id);
295 
299  void computeResidualTags(const std::set<TagID> & tags);
300 
304  void computeResidualAndJacobianTags(const std::set<TagID> & vector_tags,
305  const std::set<TagID> & matrix_tags);
306 
311  void computeResidualAndJacobianInternal(const std::set<TagID> & vector_tags,
312  const std::set<TagID> & matrix_tags);
313 
317  void computeResidual(NumericVector<Number> & residual, TagID tag_id);
318 
325 
332  void constraintJacobians(const SparseMatrix<Number> & jacobian_to_view, bool displaced);
333 
337  void computeJacobianTags(const std::set<TagID> & tags);
338 
343  bool computeScaling();
344 
348  void computeJacobian(libMesh::SparseMatrix<Number> & jacobian, const std::set<TagID> & tags);
349 
354 
363  void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks);
364 
365  void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks, const std::set<TagID> & tags);
366 
374 
378  void onTimestepBegin();
379 
386  virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid);
387 
393 
397  void updateActive(THREAD_ID tid);
398 
405  virtual void setSolutionUDot(const NumericVector<Number> & udot);
406 
413  virtual void setSolutionUDotDot(const NumericVector<Number> & udotdot);
414 
419 
424 
429 
430  virtual NumericVector<Number> & residualCopy() override;
431  virtual NumericVector<Number> & residualGhosted() override;
432 
433  virtual NumericVector<Number> & RHS() = 0;
434 
435  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & sparsity,
436  std::vector<dof_id_type> & n_nz,
437  std::vector<dof_id_type> & n_oz) override;
438 
443  void setPreconditioner(std::shared_ptr<MoosePreconditioner> pc);
444  MoosePreconditioner const * getPreconditioner() const;
445 
451  {
453  }
454 
459 
465 
475  {
477  }
478 
484  void assembleConstraintsSeparately(bool separately = true)
485  {
487  }
488 
493  virtual void attachPreconditioner(libMesh::Preconditioner<Number> * preconditioner) = 0;
494 
498  void setupDampers();
504  void reinitIncrementAtQpsForDampers(THREAD_ID tid, const std::set<MooseVariable *> & damped_vars);
505 
512  const std::set<MooseVariable *> & damped_vars);
513 
516  void checkKernelCoverage(const std::set<SubdomainID> & mesh_subdomains) const;
517  virtual bool containsTimeKernel() override;
518  virtual std::vector<std::string> timeKernelVariableNames() override;
520 
524  unsigned int nNonlinearIterations() const { return _n_iters; }
525 
529  unsigned int nLinearIterations() const { return _n_linear_iters; }
530 
534  unsigned int nResidualEvaluations() const { return _n_residual_evaluations; }
535 
540 
545  Real nonlinearNorm() const { return _last_nl_rnorm; }
546 
551  void printAllVariableNorms(bool state) { _print_all_var_norms = state; }
552 
553  void debuggingResiduals(bool state) { _debugging_residuals = state; }
554 
556 
557  void setPredictor(std::shared_ptr<Predictor> predictor);
558  Predictor * getPredictor() { return _predictor.get(); }
559 
564  bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
565 
570  bool needInterfaceMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
571 
576  bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid) const;
577 
581  bool doingDG() const;
582 
584 
591  {
592  return _interface_kernels;
593  }
597  {
598  return _scalar_kernels;
599  }
601  {
602  return _nodal_kernels;
603  }
606  {
607  return _element_dampers;
608  }
610  {
611  return _nodal_dampers;
612  }
614 
619 
624  {
625  return _integrated_bcs;
626  }
627 
629 
633  bool hasSaveIn() const { return _has_save_in || _has_nodalbc_save_in; }
634 
639 
640  virtual libMesh::System & system() override { return _sys; }
641  virtual const libMesh::System & system() const override { return _sys; }
642 
643  virtual void setSolutionUDotOld(const NumericVector<Number> & u_dot_old);
644 
645  virtual void setSolutionUDotDotOld(const NumericVector<Number> & u_dotdot_old);
646 
647  virtual void setPreviousNewtonSolution(const NumericVector<Number> & soln);
648 
649  TagID timeVectorTag() const override { return _Re_time_tag; }
650  TagID nonTimeVectorTag() const override { return _Re_non_time_tag; }
651  TagID residualVectorTag() const override { return _Re_tag; }
652  TagID systemMatrixTag() const override { return _Ke_system_tag; }
653 
657  virtual void residualAndJacobianTogether() = 0;
658 
659  bool computeScalingOnce() const { return _compute_scaling_once; }
660  void computeScalingOnce(bool compute_scaling_once)
661  {
662  _compute_scaling_once = compute_scaling_once;
663  }
664 
670  void autoScalingParam(Real resid_vs_jac_scaling_param)
671  {
672  _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
673  }
674 
675  void scalingGroupVariables(const std::vector<std::vector<std::string>> & scaling_group_variables)
676  {
677  _scaling_group_variables = scaling_group_variables;
678  }
679 
680  void
681  ignoreVariablesForAutoscaling(const std::vector<std::string> & ignore_variables_for_autoscaling)
682  {
683  _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
684  }
685 
687  void offDiagonalsInAutoScaling(bool off_diagonals_in_auto_scaling)
688  {
689  _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
690  }
691 
693  // FIXME: make these protected and create getters/setters
695  std::vector<unsigned int> _current_l_its;
696  unsigned int _current_nl_its;
697 
701  void setupDM();
702 
704 
710 
714  void destroyColoring();
715 
716 protected:
721  void computeResidualInternal(const std::set<TagID> & tags);
722 
727  void computeNodalBCs(NumericVector<Number> & residual);
728 
732  void computeNodalBCs(NumericVector<Number> & residual, const std::set<TagID> & tags);
733 
737  void computeNodalBCs(const std::set<TagID> & tags);
738 
743 
747  void computeJacobianInternal(const std::set<TagID> & tags);
748 
749  void computeDiracContributions(const std::set<TagID> & tags, bool is_jacobian);
750 
751  void computeScalarKernelsJacobians(const std::set<TagID> & tags);
752 
758 
762  void mortarConstraints(Moose::ComputeType compute_type,
763  const std::set<TagID> & vector_tags,
764  const std::set<TagID> & matrix_tags);
765 
769  virtual void computeScalingJacobian() = 0;
770 
774  virtual void computeScalingResidual() = 0;
775 
780  void assembleScalingVector();
781 
787 
792  void reinitNodeFace(const Node & secondary_node,
793  const BoundaryID secondary_boundary,
794  const PenetrationInfo & info,
795  const bool displaced);
796 
806  bool preSolve();
807 
810 
812  std::unique_ptr<NumericVector<Number>> _residual_copy;
813 
818 
821 
823  std::set<TagID> _nl_vector_tags;
824 
826  std::set<TagID> _nl_matrix_tags;
827 
830 
835 
838 
841 
844 
852 
854 
862 
865 
868 
871 
874 
877 
879  MooseObjectWarehouseBase<Split> _splits; // use base b/c there are no setup methods
880 
883 
887  std::shared_ptr<MoosePreconditioner> _preconditioner;
888 
891 
892  MatFDColoring _fdcoloring;
893 
896 
899 
902 
907 
909  bool _doing_dg;
910 
912  std::vector<std::string> _vecs_to_zero_for_residual;
913 
914  unsigned int _n_iters;
915  unsigned int _n_linear_iters;
916 
919 
921 
923  std::shared_ptr<Predictor> _predictor;
924 
926 
933 
935 
938 
941 
944 
947 
948  void getNodeDofs(dof_id_type node_id, std::vector<dof_id_type> & dofs);
949 
952 
957 
962 
966  std::vector<std::vector<std::string>> _scaling_group_variables;
967 
969  std::vector<bool> _variable_autoscaled;
970 
972  std::vector<std::string> _ignore_variables_for_autoscaling;
973 
976 
978  std::unique_ptr<libMesh::DiagonalMatrix<Number>> _scaling_matrix;
979 
980 private:
985  GeometricSearchData & geom_search_data,
986  std::unordered_map<dof_id_type, std::vector<dof_id_type>> & graph);
987 
991  void setupScalingData();
992 
994  std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
996 
998  std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
1000 
1002  std::vector<NumericVector<Number> *> _solution_state;
1003 
1006 
1008  std::unordered_map<unsigned int, unsigned int> _var_to_group_var;
1009 
1011  std::size_t _num_scaling_groups;
1012 };
virtual void setSolutionUDotDotOld(const NumericVector< Number > &u_dotdot_old)
const ConstraintWarehouse & getConstraintWarehouse() const
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
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...
unsigned int nLinearIterations() const
Return the number of linear iterations.
Helper class for holding the preconditioning blocks to fill.
TagID _Re_time_tag
Tag for time contribution residual.
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a kernel.
virtual void setSolutionUDotDot(const NumericVector< Number > &udotdot)
Set transient term used by residual and Jacobian evaluation.
const MooseObjectTagWarehouse< NodalBCBase > & getNodalBCWarehouse() const
Return the NodalBCBase warehouse.
A kernel for hybridized finite element formulations.
Definition: HDGKernel.h:17
void reinitIncrementAtNodeForDampers(THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
Compute the incremental change in variables at nodes for dampers.
void overwriteNodeFace(NumericVector< Number > &soln)
Called from explicit time stepping to overwrite boundary positions (explicit dynamics).
Base class for deriving general dampers.
Definition: GeneralDamper.h:21
bool _use_pre_smo_residual
Whether to use the pre-SMO initial residual in the relative convergence check.
MoosePreconditioner const * getPreconditioner() const
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)
Real _initial_residual
The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanatio...
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
void zeroVectorForResidual(const std::string &vector_name)
Base class for split-based preconditioners.
Definition: Split.h:25
void computeNodalBCsResidualAndJacobian()
compute the residual and Jacobian for nodal boundary conditions
bool computeScalingOnce() const
bool _debugging_residuals
true if debugging residuals
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
unsigned int TagID
Definition: MooseTypes.h:210
Real computeDamping(const NumericVector< Number > &solution, const NumericVector< Number > &update)
Compute damping.
virtual void setPreviousNewtonSolution(const NumericVector< Number > &soln)
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse() const
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
MPI_Info info
NumericVector< Number > & solution()
Definition: SystemBase.h:196
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
char ** blocks
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...
virtual SNES getSNES()=0
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
bool haveFieldSplitPreconditioner() const
Base class for predictors.
Definition: Predictor.h:28
virtual void initialSetup() override
Setup Functions.
Data structure used to hold penetration information.
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
Base class for automatic differentiation Dirichlet BCs.
void setupDM()
Setup the PETSc DM object (when appropriate)
void checkKernelCoverage(const std::set< SubdomainID > &mesh_subdomains) const
void addDGKernel(std::string dg_kernel_name, const std::string &name, InputParameters &parameters)
Adds a DG kernel.
void computeJacobian(libMesh::SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
std::vector< NumericVector< Number > * > _solution_state
The current states of the solution (0 = current, 1 = old, etc)
const MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse() const
void getNodeDofs(dof_id_type node_id, std::vector< dof_id_type > &dofs)
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse()
Access functions to Warehouses from outside NonlinearSystemBase.
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.
TagID nonTimeVectorTag() const override
Base boundary condition of a Dirichlet type.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid) const
Indicates whether this system needs material properties on internal sides.
void debuggingResiduals(bool state)
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver()=0
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse()
Real preSMOResidual() const
The pre-SMO residual.
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
virtual void setSolutionUDotOld(const NumericVector< Number > &u_dot_old)
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
Real initialResidual() const
The initial residual.
virtual void attachPreconditioner(libMesh::Preconditioner< Number > *preconditioner)=0
Attach a customized preconditioner that requires physics knowledge.
void computeScalingOnce(bool compute_scaling_once)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
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.
const MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse() const
Return the IntegratedBCBase warehouse.
Real _pre_smo_residual
The pre-SMO residual, see setPreSMOResidual for a detailed explanation.
MooseObjectTagWarehouse< HDGKernel > & getHDGKernelWarehouse()
Real finalNonlinearResidual() const
Return the final nonlinear residual.
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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
TagID _Ke_non_time_tag
Tag for non-time contribution Jacobian.
TagID _Ke_system_tag
Tag for system contribution Jacobian.
Serves as a base class for DGKernel and ADDGKernel.
Definition: DGKernelBase.h:32
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
Base class for MOOSE preconditioners.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
const MooseObjectTagWarehouse< ScalarKernelBase > & getScalarKernelWarehouse() const
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1243
void addScalarKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a scalar kernel.
void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
Adds a boundary condition.
void computeResidual(NumericVector< Number > &residual, TagID tag_id)
Form a residual vector for a given tag.
MooseObjectTagWarehouse< InterfaceKernelBase > & getInterfaceKernelWarehouse()
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
Nonlinear system to be solved.
virtual const std::string & name() const
Definition: SystemBase.C:1340
virtual bool containsTimeKernel() override
If the system has a kernel that corresponds to a time derivative.
void onTimestepBegin()
Called at the beginning of the time step.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
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 setPredictor(std::shared_ptr< Predictor > predictor)
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&#39;ve initialized the automatic scaling data structures.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
virtual void setupFiniteDifferencedPreconditioner()=0
bool _doing_dg
true if DG is active (optimization reasons)
bool computedScalingJacobian() const
void useFiniteDifferencedPreconditioner(bool use=true)
If called with true this system will use a finite differenced form of the Jacobian as the preconditio...
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.
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
A map from variable index to group variable index and it&#39;s associated (inverse) scaling factor...
std::vector< unsigned int > _current_l_its
void offDiagonalsInAutoScaling(bool off_diagonals_in_auto_scaling)
void scalingGroupVariables(const std::vector< std::vector< std::string >> &scaling_group_variables)
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
Definition: KernelBase.h:23
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
void updateActive(THREAD_ID tid)
Update active objects of Warehouses owned by NonlinearSystemBase.
FieldSplitPreconditionerBase & getFieldSplitPreconditioner()
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.
boundary_id_type BoundaryID
Real referenceResidual() const
The reference residual used in relative convergence check.
void addSplit(const std::string &split_name, const std::string &name, InputParameters &parameters)
Adds a split.
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.
void ignoreVariablesForAutoscaling(const std::vector< std::string > &ignore_variables_for_autoscaling)
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
std::shared_ptr< Split > getSplit(const std::string &name)
Retrieves a split by name.
bool haveFiniteDifferencedPreconditioner() const
virtual const libMesh::System & system() const override
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
bool _use_finite_differenced_preconditioner
Whether or not to use a finite differenced preconditioner.
virtual void addHDGKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
Adds a hybridized discontinuous Galerkin (HDG) kernel.
MooseObjectTagWarehouse< KernelBase > _kernels
bool shouldEvaluatePreSMOResidual() const
We offer the option to check convergence against the pre-SMO residual.
Base class for deriving nodal dampers.
Definition: NodalDamper.h:27
bool computingPreSMOResidual()
Returns true if this system is currently computing the pre-SMO residual for a solve.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
void setupScalingData()
Setup group scaling containers.
const bool & usePreSMOResidual() const
Whether we are using pre-SMO residual in relative convergence checks.
MooseObjectTagWarehouse< HDGKernel > _hybridized_kernels
Base class for deriving any boundary condition that works at nodes.
Definition: NodalBCBase.h:26
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
bool computeScaling()
Method used to obtain scaling factors for variables.
Interface for objects interacting with the PerfGraph.
void destroyColoring()
Destroy the coloring object if it exists.
virtual void solve() override=0
Solve the system (using libMesh magic)
ConstraintWarehouse _constraints
Constraints storage object.
virtual void turnOffJacobian()
Turn off the Jacobian (must be called before equation system initialization)
TagID residualVectorTag() const override
MooseObjectTagWarehouse< DiracKernelBase > & getDiracKernelWarehouse()
virtual void customSetup(const ExecFlagType &exec_type) override
ComputeType
The type of nonlinear computation being performed.
Definition: MooseTypes.h:781
Base class for deriving element dampers.
Definition: ElementDamper.h:33
Base interface for field split preconditioner.
bool offDiagonalsInAutoScaling() const
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 &parameters)
Adds a NodalKernel.
Base class for creating new types of boundary conditions.
unsigned int nNonlinearIterations() const
Return the number of non-linear iterations.
void printAllVariableNorms(bool state)
Force the printing of all variable norms after each solve.
virtual NumericVector< Number > & RHS()=0
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
void addDiracKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
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
This is the common base class for objects that give residual contributions.
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.
virtual void subdomainSetup()
Definition: SystemBase.C:1592
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
TagID timeVectorTag() const override
Ideally, we should not need this API.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual std::vector< std::string > timeKernelVariableNames() override
Returns the names of the variables that have time derivative kernels in the system.
NonlinearSystemBase(FEProblemBase &problem, libMesh::System &sys, const std::string &name)
virtual unsigned int getCurrentNonlinearIterationNumber()=0
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual void setSolutionUDot(const NumericVector< Number > &udot)
Set transient term used by residual and Jacobian evaluation.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition: SystemBase.C:410
Real nonlinearNorm() const
Return the last nonlinear norm.
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 computeScalarKernelsJacobians(const std::set< TagID > &tags)
void setInitialResidual(Real r)
Record the initial residual (for later relative convergence check)
Base class shared by AD and non-AD scalar kernels.
void addDamper(const std::string &damper_name, const std::string &name, InputParameters &parameters)
Adds a damper.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void timestepSetup() override
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.
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
TagID _Re_tag
Used for the residual vector from PETSc.
MooseObjectWarehouseBase< Split > & getSplits()
Retrieves all splits.
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
libMesh::System & _sys
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.
bool doingDG() const
Getter for _doing_dg.
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 &parameters)
Adds a Constraint.
void constraintJacobians(const SparseMatrix< Number > &jacobian_to_view, bool displaced)
Add jacobian contributions from Constraints.
const MooseObjectTagWarehouse< NodalKernelBase > & getNodalKernelWarehouse() const
bool preSolve()
Perform some steps to get ready for the solver.
virtual void residualAndJacobianTogether()=0
Call this method if you want the residual and Jacobian to be computed simultaneously.
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.
void assembleConstraintsSeparately(bool separately=true)
Indicates whether to assemble residual and Jacobian after each constraint application.
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse() const
Real Number
unsigned int nResidualEvaluations() const
Return the total number of residual evaluations done so far in this calculation.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse()
NumericVector< Number > & residualVector(TagID tag)
Return a residual vector that is associated with the residual tag.
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...
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
unsigned int _num_residual_evaluations
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
virtual void potentiallySetupFiniteDifferencing()
Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of t...
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
void useFieldSplitPreconditioner(FieldSplitPreconditionerBase *fsp)
If called with a non-null object true this system will use a field split preconditioner matrix...
virtual void jacobianSetup() 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 &parameters)
Adds an interface kernel.
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.
virtual NumericVector< Number > & residualCopy() override
void reinitMortarFunctors()
Update the mortar functors if the mesh has changed.
virtual NumericVector< Number > & residualGhosted() override
DiracKernelBase is the base class for all DiracKernel type classes.
void setPreSMOResidual(bool use)
Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks...
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...
Warehouse for storing constraints.
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
uint8_t dof_id_type
virtual ~NonlinearSystemBase()
virtual void preInit() override
This is called prior to the libMesh system has been init&#39;d.
virtual void residualSetup() override
void setPreconditioner(std::shared_ptr< MoosePreconditioner > pc)
Sets a preconditioner.
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs
virtual libMesh::System & system() override
Get the reference to the libMesh system.