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;
49 
50 // libMesh forward declarations
51 namespace libMesh
52 {
53 template <typename T>
54 class NumericVector;
55 template <typename T>
56 class SparseMatrix;
57 template <typename T>
58 class DiagonalMatrix;
59 } // namespace libMesh
60 
67 {
68 public:
69  NonlinearSystemBase(FEProblemBase & problem, libMesh::System & sys, const std::string & name);
70  virtual ~NonlinearSystemBase();
71 
72  virtual void preInit() override;
73 
74  bool computedScalingJacobian() const { return _computed_scaling; }
75 
79  virtual void turnOffJacobian();
80 
81  virtual void solve() override = 0;
82 
84 
85  virtual SNES getSNES() = 0;
86 
87  virtual unsigned int getCurrentNonlinearIterationNumber() = 0;
88 
94 
95  // Setup Functions ////
96  virtual void initialSetup() override;
97  virtual void timestepSetup() override;
98  virtual void customSetup(const ExecFlagType & exec_type) override;
99  virtual void residualSetup() override;
100  virtual void jacobianSetup() override;
101 
102  virtual void setupFiniteDifferencedPreconditioner() = 0;
104 
106  {
108  }
110 
117  virtual void addKernel(const std::string & kernel_name,
118  const std::string & name,
119  InputParameters & parameters);
120 
127  virtual void addHDGKernel(const std::string & kernel_name,
128  const std::string & name,
129  InputParameters & parameters);
130 
137  virtual void addNodalKernel(const std::string & kernel_name,
138  const std::string & name,
139  InputParameters & parameters);
140 
147  void addScalarKernel(const std::string & kernel_name,
148  const std::string & name,
149  InputParameters & parameters);
150 
157  void addBoundaryCondition(const std::string & bc_name,
158  const std::string & name,
159  InputParameters & parameters);
160 
167  void
168  addConstraint(const std::string & c_name, const std::string & name, InputParameters & parameters);
169 
176  void addDiracKernel(const std::string & kernel_name,
177  const std::string & name,
178  InputParameters & parameters);
179 
186  void
187  addDGKernel(std::string dg_kernel_name, const std::string & name, InputParameters & parameters);
188 
195  void addInterfaceKernel(std::string interface_kernel_name,
196  const std::string & name,
197  InputParameters & parameters);
198 
205  void addDamper(const std::string & damper_name,
206  const std::string & name,
207  InputParameters & parameters);
208 
215  void
216  addSplit(const std::string & split_name, const std::string & name, InputParameters & parameters);
217 
222  std::shared_ptr<Split> getSplit(const std::string & name);
223 
228 
235  bool shouldEvaluatePreSMOResidual() const;
236 
251  void setPreSMOResidual(bool use) { _use_pre_smo_residual = use; }
252 
254  const bool & usePreSMOResidual() const { return _use_pre_smo_residual; }
255 
257  Real referenceResidual() const;
258 
260  Real preSMOResidual() const;
261 
263  Real initialResidual() const;
264 
266  void setInitialResidual(Real r);
267 
268  void zeroVectorForResidual(const std::string & vector_name);
269 
270  void setInitialSolution();
271 
276 
284  void constraintResiduals(NumericVector<Number> & residual, bool displaced);
285 
291  void computeResidualTag(NumericVector<Number> & residual, TagID tag_id);
292 
296  void computeResidualTags(const std::set<TagID> & tags);
297 
301  void computeResidualAndJacobianTags(const std::set<TagID> & vector_tags,
302  const std::set<TagID> & matrix_tags);
303 
308  void computeResidualAndJacobianInternal(const std::set<TagID> & vector_tags,
309  const std::set<TagID> & matrix_tags);
310 
314  void computeResidual(NumericVector<Number> & residual, TagID tag_id);
315 
322 
329  void constraintJacobians(const SparseMatrix<Number> & jacobian_to_view, bool displaced);
330 
334  void computeJacobianTags(const std::set<TagID> & tags);
335 
340  bool computeScaling();
341 
345  void computeJacobian(libMesh::SparseMatrix<Number> & jacobian, const std::set<TagID> & tags);
346 
351 
360  void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks);
361 
362  void computeJacobianBlocks(std::vector<JacobianBlock *> & blocks, const std::set<TagID> & tags);
363 
371 
375  void onTimestepBegin();
376 
383  virtual void subdomainSetup(SubdomainID subdomain, THREAD_ID tid);
384 
390 
394  void updateActive(THREAD_ID tid);
395 
402  virtual void setSolutionUDot(const NumericVector<Number> & udot);
403 
410  virtual void setSolutionUDotDot(const NumericVector<Number> & udotdot);
411 
416 
421 
426 
427  virtual NumericVector<Number> & residualCopy() override;
428  virtual NumericVector<Number> & residualGhosted() override;
429 
430  virtual NumericVector<Number> & RHS() = 0;
431 
432  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & sparsity,
433  std::vector<dof_id_type> & n_nz,
434  std::vector<dof_id_type> & n_oz) override;
435 
440  void setPreconditioner(std::shared_ptr<MoosePreconditioner> pc);
441  MoosePreconditioner const * getPreconditioner() const;
442 
448  {
450  }
451 
457  void setDecomposition(const std::vector<std::string> & decomposition);
458 
463 
473  {
475  }
476 
482  void assembleConstraintsSeparately(bool separately = true)
483  {
485  }
486 
491  virtual void attachPreconditioner(libMesh::Preconditioner<Number> * preconditioner) = 0;
492 
496  void setupDampers();
502  void reinitIncrementAtQpsForDampers(THREAD_ID tid, const std::set<MooseVariable *> & damped_vars);
503 
510  const std::set<MooseVariable *> & damped_vars);
511 
514  void checkKernelCoverage(const std::set<SubdomainID> & mesh_subdomains) const;
515  virtual bool containsTimeKernel() override;
516  virtual std::vector<std::string> timeKernelVariableNames() override;
518 
522  unsigned int nNonlinearIterations() const { return _n_iters; }
523 
527  unsigned int nLinearIterations() const { return _n_linear_iters; }
528 
532  unsigned int nResidualEvaluations() const { return _n_residual_evaluations; }
533 
538 
543  Real nonlinearNorm() const { return _last_nl_rnorm; }
544 
549  void printAllVariableNorms(bool state) { _print_all_var_norms = state; }
550 
551  void debuggingResiduals(bool state) { _debugging_residuals = state; }
552 
554 
555  void setPredictor(std::shared_ptr<Predictor> predictor);
556  Predictor * getPredictor() { return _predictor.get(); }
557 
562  bool needBoundaryMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
563 
568  bool needInterfaceMaterialOnSide(BoundaryID bnd_id, THREAD_ID tid) const;
569 
574  bool needSubdomainMaterialOnSide(SubdomainID subdomain_id, THREAD_ID tid) const;
575 
579  bool doingDG() const;
580 
582 
589  {
590  return _interface_kernels;
591  }
595  {
596  return _scalar_kernels;
597  }
599  {
600  return _nodal_kernels;
601  }
604  {
605  return _element_dampers;
606  }
608  {
609  return _nodal_dampers;
610  }
612 
617 
622  {
623  return _integrated_bcs;
624  }
625 
627 
631  bool hasSaveIn() const { return _has_save_in || _has_nodalbc_save_in; }
632 
637 
638  virtual libMesh::System & system() override { return _sys; }
639  virtual const libMesh::System & system() const override { return _sys; }
640 
641  virtual void setSolutionUDotOld(const NumericVector<Number> & u_dot_old);
642 
643  virtual void setSolutionUDotDotOld(const NumericVector<Number> & u_dotdot_old);
644 
645  virtual void setPreviousNewtonSolution(const NumericVector<Number> & soln);
646 
647  TagID timeVectorTag() const override { return _Re_time_tag; }
648  TagID nonTimeVectorTag() const override { return _Re_non_time_tag; }
649  TagID residualVectorTag() const override { return _Re_tag; }
650  TagID systemMatrixTag() const override { return _Ke_system_tag; }
651 
655  virtual void residualAndJacobianTogether() = 0;
656 
657  bool computeScalingOnce() const { return _compute_scaling_once; }
658  void computeScalingOnce(bool compute_scaling_once)
659  {
660  _compute_scaling_once = compute_scaling_once;
661  }
662 
668  void autoScalingParam(Real resid_vs_jac_scaling_param)
669  {
670  _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
671  }
672 
673  void scalingGroupVariables(const std::vector<std::vector<std::string>> & scaling_group_variables)
674  {
675  _scaling_group_variables = scaling_group_variables;
676  }
677 
678  void
679  ignoreVariablesForAutoscaling(const std::vector<std::string> & ignore_variables_for_autoscaling)
680  {
681  _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
682  }
683 
685  void offDiagonalsInAutoScaling(bool off_diagonals_in_auto_scaling)
686  {
687  _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
688  }
689 
691  // FIXME: make these protected and create getters/setters
693  std::vector<unsigned int> _current_l_its;
694  unsigned int _current_nl_its;
695 
699  void setupDM();
700 
702 
708 
712  void destroyColoring();
713 
714 protected:
719  void computeResidualInternal(const std::set<TagID> & tags);
720 
725  void computeNodalBCs(NumericVector<Number> & residual);
726 
730  void computeNodalBCs(NumericVector<Number> & residual, const std::set<TagID> & tags);
731 
735  void computeNodalBCs(const std::set<TagID> & tags);
736 
741 
745  void computeJacobianInternal(const std::set<TagID> & tags);
746 
747  void computeDiracContributions(const std::set<TagID> & tags, bool is_jacobian);
748 
749  void computeScalarKernelsJacobians(const std::set<TagID> & tags);
750 
756 
760  void mortarConstraints(Moose::ComputeType compute_type,
761  const std::set<TagID> & vector_tags,
762  const std::set<TagID> & matrix_tags);
763 
767  virtual void computeScalingJacobian() = 0;
768 
772  virtual void computeScalingResidual() = 0;
773 
778  void assembleScalingVector();
779 
785 
790  void reinitNodeFace(const Node & secondary_node,
791  const BoundaryID secondary_boundary,
792  const PenetrationInfo & info,
793  const bool displaced);
794 
804  bool preSolve();
805 
808 
810  std::unique_ptr<NumericVector<Number>> _residual_copy;
811 
816 
819 
821  std::set<TagID> _nl_vector_tags;
822 
824  std::set<TagID> _nl_matrix_tags;
825 
828 
833 
836 
839 
842 
850 
852 
860 
863 
866 
869 
872 
875 
877  MooseObjectWarehouseBase<Split> _splits; // use base b/c there are no setup methods
878 
881 
885  std::shared_ptr<MoosePreconditioner> _preconditioner;
886 
889 
890  MatFDColoring _fdcoloring;
891 
895  std::string _decomposition_split;
898 
901 
904 
909 
911  bool _doing_dg;
912 
914  std::vector<std::string> _vecs_to_zero_for_residual;
915 
916  unsigned int _n_iters;
917  unsigned int _n_linear_iters;
918 
921 
923 
925  std::shared_ptr<Predictor> _predictor;
926 
928 
935 
937 
940 
943 
946 
949 
950  void getNodeDofs(dof_id_type node_id, std::vector<dof_id_type> & dofs);
951 
954 
959 
964 
968  std::vector<std::vector<std::string>> _scaling_group_variables;
969 
971  std::vector<bool> _variable_autoscaled;
972 
974  std::vector<std::string> _ignore_variables_for_autoscaling;
975 
978 
980  std::unique_ptr<libMesh::DiagonalMatrix<Number>> _scaling_matrix;
981 
982 private:
987  GeometricSearchData & geom_search_data,
988  std::unordered_map<dof_id_type, std::vector<dof_id_type>> & graph);
989 
993  void setupScalingData();
994 
996  std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
998 
1000  std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor>
1002 
1004  std::vector<NumericVector<Number> *> _solution_state;
1005 
1008 
1010  std::unordered_map<unsigned int, unsigned int> _var_to_group_var;
1011 
1013  std::size_t _num_scaling_groups;
1014 };
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:195
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
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...
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
void useFieldSplitPreconditioner(bool use=true)
If called with true this system will use a field split preconditioner matrix.
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.
bool _have_decomposition
Whether or not the system can be decomposed into splits.
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:1245
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:1330
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.
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:780
Base class for deriving element dampers.
Definition: ElementDamper.h:33
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:1559
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:402
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.
bool _use_field_split_preconditioner
Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition.
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.
std::string _decomposition_split
Name of the top-level split of the decomposition.
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
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.
virtual NumericVector< Number > & residualCopy() override
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.