GRINS-0.8.0
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
GRINS::Solver Class Referenceabstract

#include <solver.h>

Inheritance diagram for GRINS::Solver:
Inheritance graph
[legend]

Public Member Functions

 Solver (const GetPot &input)
 
virtual ~Solver ()
 
virtual void initialize (const GetPot &input, SharedPtr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
 
virtual void solve (SolverContext &context)=0
 
virtual void adjoint_qoi_parameter_sensitivity (SolverContext &, const libMesh::QoISet &, const libMesh::ParameterVector &, libMesh::SensitivityData &) const
 
virtual void forward_qoi_parameter_sensitivity (SolverContext &, const libMesh::QoISet &, const libMesh::ParameterVector &, libMesh::SensitivityData &) const
 
void steady_adjoint_solve (SolverContext &context)
 Do steady version of adjoint solve. More...
 
void print_scalar_vars (SolverContext &context)
 
void print_qoi (SolverContext &context)
 

Protected Member Functions

void set_solver_options (libMesh::DiffSolver &solver)
 
virtual void init_time_solver (GRINS::MultiphysicsSystem *system)=0
 

Protected Attributes

unsigned int _max_nonlinear_iterations
 
double _relative_step_tolerance
 
double _absolute_step_tolerance
 
double _relative_residual_tolerance
 
double _absolute_residual_tolerance
 
double _initial_linear_tolerance
 
double _minimum_linear_tolerance
 
unsigned int _max_linear_iterations
 
bool _continue_after_backtrack_failure
 
bool _continue_after_max_iterations
 
bool _require_residual_reduction
 
bool _solver_quiet
 
bool _solver_verbose
 

Detailed Description

Definition at line 51 of file solver.h.

Constructor & Destructor Documentation

GRINS::Solver::Solver ( const GetPot &  input)

Definition at line 48 of file solver.C.

49  : _max_nonlinear_iterations( input("linear-nonlinear-solver/max_nonlinear_iterations", 10 ) ),
50  _relative_step_tolerance( input("linear-nonlinear-solver/relative_step_tolerance", 1.e-6 ) ),
51  _absolute_step_tolerance( input("linear-nonlinear-solver/absolute_step_tolerance", 0.0 ) ),
52  _relative_residual_tolerance( input("linear-nonlinear-solver/relative_residual_tolerance", 1.e-15 ) ),
53  _absolute_residual_tolerance( input("linear-nonlinear-solver/absolute_residual_tolerance", 0.0 ) ),
54  _initial_linear_tolerance( input("linear-nonlinear-solver/initial_linear_tolerance", 1.e-3 ) ),
55  _minimum_linear_tolerance( input("linear-nonlinear-solver/minimum_linear_tolerance", 1.e-3 ) ),
56  _max_linear_iterations( input("linear-nonlinear-solver/max_linear_iterations", 500 ) ),
57  _continue_after_backtrack_failure( input("linear-nonlinear-solver/continue_after_backtrack_failure", false ) ),
58  _continue_after_max_iterations( input("linear-nonlinear-solver/continue_after_max_iterations", false ) ),
59  _require_residual_reduction( input("linear-nonlinear-solver/require_residual_reduction", true ) ),
60  _solver_quiet( input("screen-options/solver_quiet", false ) ),
61  _solver_verbose( input("screen-options/solver_verbose", false ) )
62  {
63  return;
64  }
double _absolute_residual_tolerance
Definition: solver.h:100
bool _solver_verbose
Definition: solver.h:110
double _relative_residual_tolerance
Definition: solver.h:98
unsigned int _max_linear_iterations
Definition: solver.h:103
double _relative_step_tolerance
Definition: solver.h:92
bool _continue_after_backtrack_failure
Definition: solver.h:104
double _minimum_linear_tolerance
Definition: solver.h:102
double _absolute_step_tolerance
Definition: solver.h:93
bool _continue_after_max_iterations
Definition: solver.h:105
unsigned int _max_nonlinear_iterations
Definition: solver.h:91
bool _require_residual_reduction
Definition: solver.h:106
double _initial_linear_tolerance
Definition: solver.h:101
bool _solver_quiet
Definition: solver.h:109
GRINS::Solver::~Solver ( )
virtual

Definition at line 67 of file solver.C.

68  {
69  return;
70  }

Member Function Documentation

virtual void GRINS::Solver::adjoint_qoi_parameter_sensitivity ( SolverContext ,
const libMesh::QoISet &  ,
const libMesh::ParameterVector &  ,
libMesh::SensitivityData &   
) const
inlinevirtual

Reimplemented in GRINS::SteadyMeshAdaptiveSolver, and GRINS::SteadySolver.

Definition at line 64 of file solver.h.

69  { libmesh_not_implemented(); }
virtual void GRINS::Solver::forward_qoi_parameter_sensitivity ( SolverContext ,
const libMesh::QoISet &  ,
const libMesh::ParameterVector &  ,
libMesh::SensitivityData &   
) const
inlinevirtual

Reimplemented in GRINS::SteadyMeshAdaptiveSolver, and GRINS::SteadySolver.

Definition at line 72 of file solver.h.

77  { libmesh_not_implemented(); }
virtual void GRINS::Solver::init_time_solver ( GRINS::MultiphysicsSystem system)
protectedpure virtual
void GRINS::Solver::initialize ( const GetPot &  input,
SharedPtr< libMesh::EquationSystems >  equation_system,
GRINS::MultiphysicsSystem system 
)
virtual

Definition at line 72 of file solver.C.

References init_time_solver(), and set_solver_options().

75  {
76 
77  // Defined in subclasses depending on the solver used.
78  this->init_time_solver(system);
79 
80  // Initialize the system
81  equation_system->init();
82 
83  // Get diff solver to set options
84  libMesh::DiffSolver &solver = *(system->time_solver->diff_solver().get());
85 
86  // Set linear/nonlinear solver options
87  this->set_solver_options( solver );
88 
89  return;
90  }
virtual void init_time_solver(GRINS::MultiphysicsSystem *system)=0
void set_solver_options(libMesh::DiffSolver &solver)
Definition: solver.C:92
void GRINS::Solver::print_qoi ( SolverContext context)

Definition at line 155 of file solver.C.

References GRINS::SolverContext::qoi_output, and GRINS::SolverContext::system.

Referenced by GRINS::SteadyMeshAdaptiveSolver::solve(), and GRINS::UnsteadyMeshAdaptiveSolver::solve().

156  {
157  context.system->assemble_qoi();
158  const CompositeQoI* my_qoi = libMesh::cast_ptr<const CompositeQoI*>(context.system->get_qoi());
159  context.qoi_output->output_qois(*my_qoi, context.system->comm());
160  }
void GRINS::Solver::print_scalar_vars ( SolverContext context)

Definition at line 133 of file solver.C.

References GRINS::SolverContext::system.

Referenced by GRINS::SteadySolver::solve(), GRINS::UnsteadySolver::solve(), and GRINS::UnsteadyMeshAdaptiveSolver::solve().

134  {
135  for (unsigned int v=0; v != context.system->n_vars(); ++v)
136  if (context.system->variable(v).type().family ==
137  libMesh::SCALAR)
138  {
139  std::cout << context.system->variable_name(v) <<
140  " = {";
141  std::vector<libMesh::dof_id_type> scalar_indices;
142  context.system->get_dof_map().SCALAR_dof_indices
143  (scalar_indices, v);
144  if (scalar_indices.size())
145  std::cout <<
146  context.system->current_solution(scalar_indices[0]);
147  for (unsigned int i=1; i < scalar_indices.size();
148  ++i)
149  std::cout << ", " <<
150  context.system->current_solution(scalar_indices[i]);
151  std::cout << '}' << std::endl;
152  }
153  }
void GRINS::Solver::set_solver_options ( libMesh::DiffSolver &  solver)
protected

Definition at line 92 of file solver.C.

References _absolute_residual_tolerance, _absolute_step_tolerance, _continue_after_backtrack_failure, _continue_after_max_iterations, _initial_linear_tolerance, _max_linear_iterations, _max_nonlinear_iterations, _minimum_linear_tolerance, _relative_residual_tolerance, _relative_step_tolerance, _require_residual_reduction, _solver_quiet, and _solver_verbose.

Referenced by initialize().

93  {
94  solver.quiet = this->_solver_quiet;
95  solver.verbose = this->_solver_verbose;
96  solver.max_nonlinear_iterations = this->_max_nonlinear_iterations;
97  solver.relative_step_tolerance = this->_relative_step_tolerance;
98  solver.absolute_step_tolerance = this->_absolute_step_tolerance;
99  solver.relative_residual_tolerance = this->_relative_residual_tolerance;
100  solver.absolute_residual_tolerance = this->_absolute_residual_tolerance;
101  solver.max_linear_iterations = this->_max_linear_iterations;
102  solver.continue_after_backtrack_failure = this->_continue_after_backtrack_failure;
103  solver.initial_linear_tolerance = this->_initial_linear_tolerance;
104  solver.minimum_linear_tolerance = this->_minimum_linear_tolerance;
105  solver.continue_after_max_iterations = this->_continue_after_max_iterations;
106  if(dynamic_cast<libMesh::NewtonSolver*>(&solver))
107  {
108  dynamic_cast<libMesh::NewtonSolver&>(solver).require_residual_reduction = this->_require_residual_reduction;
109  }
110  else
111  {
112  // If the user tried to set require_residual_reduction flag to false
113  // despite not having a NewtonSolver spit out a warning
114  if(this->_require_residual_reduction == false)
115  {
116  libmesh_warning("GRINS can't change require_residual_reduction when not using NewtonSolver!");
117  }
118  }
119 
120  return;
121  }
double _absolute_residual_tolerance
Definition: solver.h:100
bool _solver_verbose
Definition: solver.h:110
double _relative_residual_tolerance
Definition: solver.h:98
unsigned int _max_linear_iterations
Definition: solver.h:103
double _relative_step_tolerance
Definition: solver.h:92
bool _continue_after_backtrack_failure
Definition: solver.h:104
double _minimum_linear_tolerance
Definition: solver.h:102
double _absolute_step_tolerance
Definition: solver.h:93
bool _continue_after_max_iterations
Definition: solver.h:105
unsigned int _max_nonlinear_iterations
Definition: solver.h:91
bool _require_residual_reduction
Definition: solver.h:106
double _initial_linear_tolerance
Definition: solver.h:101
bool _solver_quiet
Definition: solver.h:109
virtual void GRINS::Solver::solve ( SolverContext context)
pure virtual
void GRINS::Solver::steady_adjoint_solve ( SolverContext context)

Do steady version of adjoint solve.

We put this here since we may want to reuse this in multiple different steady solves.

Definition at line 123 of file solver.C.

References GRINS::SolverContext::system.

Referenced by GRINS::SteadySolver::solve(), and GRINS::SteadyMeshAdaptiveSolver::solve().

124  {
125  libMesh::out << "==========================================================" << std::endl
126  << "Solving adjoint problem." << std::endl
127  << "==========================================================" << std::endl;
128 
129  context.system->adjoint_solve();
130  context.system->set_adjoint_already_solved(true);
131  }

Member Data Documentation

double GRINS::Solver::_absolute_residual_tolerance
protected

Definition at line 100 of file solver.h.

Referenced by set_solver_options().

double GRINS::Solver::_absolute_step_tolerance
protected

Definition at line 93 of file solver.h.

Referenced by set_solver_options().

bool GRINS::Solver::_continue_after_backtrack_failure
protected

Definition at line 104 of file solver.h.

Referenced by set_solver_options().

bool GRINS::Solver::_continue_after_max_iterations
protected

Definition at line 105 of file solver.h.

Referenced by set_solver_options().

double GRINS::Solver::_initial_linear_tolerance
protected

Definition at line 101 of file solver.h.

Referenced by set_solver_options().

unsigned int GRINS::Solver::_max_linear_iterations
protected

Definition at line 103 of file solver.h.

Referenced by set_solver_options().

unsigned int GRINS::Solver::_max_nonlinear_iterations
protected

Definition at line 91 of file solver.h.

Referenced by set_solver_options().

double GRINS::Solver::_minimum_linear_tolerance
protected

Definition at line 102 of file solver.h.

Referenced by set_solver_options().

double GRINS::Solver::_relative_residual_tolerance
protected

Definition at line 98 of file solver.h.

Referenced by set_solver_options().

double GRINS::Solver::_relative_step_tolerance
protected

Definition at line 92 of file solver.h.

Referenced by set_solver_options().

bool GRINS::Solver::_require_residual_reduction
protected

Definition at line 106 of file solver.h.

Referenced by set_solver_options().

bool GRINS::Solver::_solver_quiet
protected

Definition at line 109 of file solver.h.

Referenced by set_solver_options().

bool GRINS::Solver::_solver_verbose
protected

Definition at line 110 of file solver.h.

Referenced by set_solver_options().


The documentation for this class was generated from the following files:

Generated on Tue Dec 19 2017 12:47:32 for GRINS-0.8.0 by  doxygen 1.8.9.1