www.mooseframework.org
FEProblem.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "FEProblem.h"
11 
12 #include "Assembly.h"
13 #include "AuxiliarySystem.h"
14 #include "MooseEigenSystem.h"
15 #include "NonlinearSystem.h"
16 #include "LineSearch.h"
17 
18 registerMooseObject("MooseApp", FEProblem);
19 
20 template <>
23 {
25  return params;
26 }
27 
29  : FEProblemBase(parameters),
30  _use_nonlinear(getParam<bool>("use_nonlinear")),
31  _nl_sys(_use_nonlinear ? (std::make_shared<NonlinearSystem>(*this, "nl0"))
32  : (std::make_shared<MooseEigenSystem>(*this, "eigen0")))
33 {
34  _nl = _nl_sys;
35  _aux = std::make_shared<AuxiliarySystem>(*this, "aux0");
36 
38 
40 
41  _eq.parameters.set<FEProblem *>("_fe_problem") = this;
42 
43  // Create extra vectors and matrices if any
45 }
46 
47 void
49 {
50  // set _fe_problem
52  // set _fe_problem
53  parameters.set<FEProblem *>("_fe_problem") = this;
54 }
55 
56 void
58 {
59  MooseEnum line_search = parameters.get<MooseEnum>("line_search");
60  Moose::LineSearchType enum_line_search = Moose::stringToEnum<Moose::LineSearchType>(line_search);
61  if (enum_line_search == Moose::LS_CONTACT)
62  {
63 #ifdef LIBMESH_HAVE_PETSC
64 #if PETSC_VERSION_LESS_THAN(3, 6, 0)
65  mooseError("Shell line searches only became available in Petsc in version 3.6.0!");
66 #else
67  InputParameters ls_params = _factory.getValidParams("PetscContactLineSearch");
68 
69  bool affect_ltol = parameters.isParamValid("contact_line_search_ltol");
70  ls_params.set<bool>("affect_ltol") = affect_ltol;
71  ls_params.set<unsigned>("allowed_lambda_cuts") =
72  parameters.get<unsigned>("contact_line_search_allowed_lambda_cuts");
73  ls_params.set<Real>("contact_ltol") = affect_ltol
74  ? parameters.get<Real>("contact_line_search_ltol")
75  : parameters.get<Real>("l_tol");
76  ls_params.set<FEProblem *>("_fe_problem") = this;
77 
78  _line_search =
79  _factory.create<LineSearch>("PetscContactLineSearch", "contact_line_search", ls_params);
80 #endif
81 #else
82  mooseError("Currently contact line search requires use of Petsc.");
83 #endif
84  }
85 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
The Factory for building objects.
Definition: SubProblem.h:649
virtual void setInputParametersFEProblem(InputParameters &parameters) override
Definition: FEProblem.C:48
virtual void setInputParametersFEProblem(InputParameters &parameters)
std::shared_ptr< NonlinearSystemBase > _nl
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:24
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
Definition: Factory.C:67
virtual void initNullSpaceVectors(const InputParameters &parameters, NonlinearSystemBase &nl)
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
InputParameters validParams< FEProblem >()
Definition: FEProblem.C:22
FEProblem(const InputParameters &parameters)
Definition: FEProblem.C:28
virtual void newAssemblyArray(NonlinearSystemBase &nl)
LineSearchType
Type of the line search.
Definition: MooseTypes.h:671
void createTagVectors()
Create extra tagged vectors and matrices.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
virtual void addLineSearch(const InputParameters &parameters) override
add a MOOSE line search
Definition: FEProblem.C:57
std::shared_ptr< AuxiliarySystem > _aux
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
std::shared_ptr< NonlinearSystem > _nl_sys
Definition: FEProblem.h:40
Nonlinear system to be solved.
InputParameters validParams< FEProblemBase >()
EquationSystems _eq
registerMooseObject("MooseApp", FEProblem)
std::shared_ptr< LineSearch > _line_search
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.