www.mooseframework.org
MoosePreconditioner.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "MoosePreconditioner.h"
17 #include "FEProblem.h"
18 #include "PetscSupport.h"
19 #include "NonlinearSystem.h"
20 
21 #include "libmesh/numeric_vector.h"
22 
23 template <>
26 {
28  params.addPrivateParam<FEProblemBase *>("_fe_problem_base");
29 
30  MooseEnum pc_side("left right symmetric default", "default");
31  params.addParam<MooseEnum>("pc_side", pc_side, "Preconditioning side");
32  MooseEnum ksp_norm("none preconditioned unpreconditioned natural default", "unpreconditioned");
33  params.addParam<MooseEnum>(
34  "ksp_norm", ksp_norm, "Sets the norm that is used for convergence testing");
35  params.registerBase("MoosePreconditioner");
36 
37 #ifdef LIBMESH_HAVE_PETSC
39 #endif // LIBMESH_HAVE_PETSC
40 
41  return params;
42 }
43 
45  : MooseObject(params),
46  Restartable(params, "Preconditioners"),
47  _fe_problem(*params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"))
48 {
49  _fe_problem.getNonlinearSystemBase().setPCSide(getParam<MooseEnum>("pc_side"));
50 
51  _fe_problem.getNonlinearSystemBase().setMooseKSPNormType(getParam<MooseEnum>("ksp_norm"));
52 }
53 
54 void
56  const unsigned int from_system,
57  const unsigned int from_var,
58  const NumericVector<Number> & from_vector,
59  const unsigned int to_system,
60  const unsigned int to_var,
61  NumericVector<Number> & to_vector)
62 {
63  {
64  MeshBase::node_iterator it = mesh.local_nodes_begin();
65  MeshBase::node_iterator it_end = mesh.local_nodes_end();
66 
67  for (; it != it_end; ++it)
68  {
69  Node * node = *it;
70 
71  unsigned int n_comp = node->n_comp(from_system, from_var);
72 
73  mooseAssert(node->n_comp(from_system, from_var) == node->n_comp(to_system, to_var),
74  "Number of components does not match in each system");
75 
76  for (unsigned int i = 0; i < n_comp; i++)
77  {
78  dof_id_type from_dof = node->dof_number(from_system, from_var, i);
79  dof_id_type to_dof = node->dof_number(to_system, to_var, i);
80 
81  to_vector.set(to_dof, from_vector(from_dof));
82  }
83  }
84  }
85  {
86  MeshBase::element_iterator it = mesh.local_elements_begin();
87  MeshBase::element_iterator it_end = mesh.local_elements_end();
88 
89  for (; it != it_end; ++it)
90  {
91  Elem * elem = *it;
92 
93  unsigned int n_comp = elem->n_comp(from_system, from_var);
94 
95  mooseAssert(elem->n_comp(from_system, from_var) == elem->n_comp(to_system, to_var),
96  "Number of components does not match in each system");
97 
98  for (unsigned int i = 0; i < n_comp; i++)
99  {
100  dof_id_type from_dof = elem->dof_number(from_system, from_var, i);
101  dof_id_type to_dof = elem->dof_number(to_system, to_var, i);
102 
103  to_vector.set(to_dof, from_vector(from_dof));
104  }
105  }
106  }
107 }
static void copyVarValues(MeshBase &mesh, const unsigned int from_system, const unsigned int from_var, const NumericVector< Number > &from_vector, const unsigned int to_system, const unsigned int to_var, NumericVector< Number > &to_vector)
Helper function for copying values associated with variables in vectors from two different systems...
A class for creating restricted objects.
Definition: Restartable.h:31
NonlinearSystemBase & getNonlinearSystemBase()
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
FEProblemBase & _fe_problem
Subproblem this preconditioner is part of.
void setPCSide(MooseEnum pcs)
InputParameters validParams< MoosePreconditioner >()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
MoosePreconditioner(const InputParameters &params)
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
InputParameters getPetscValidParams()
Returns the PETSc options that are common between Executioners and Preconditioners.
Definition: PetscSupport.C:738
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void setMooseKSPNormType(MooseEnum kspnorm)