GRINS-0.6.0
grins_solver.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // C++
27 #include <iostream>
28 
29 // This class
30 #include "grins/grins_solver.h"
31 
32 // GRINS
33 #include "grins/multiphysics_sys.h"
34 #include "grins/solver_context.h"
35 
36 // libMesh
37 #include "libmesh/getpot.h"
38 #include "libmesh/fem_system.h"
39 #include "libmesh/diff_solver.h"
40 
41 namespace GRINS
42 {
43 
44  Solver::Solver( const GetPot& input )
45  : _max_nonlinear_iterations( input("linear-nonlinear-solver/max_nonlinear_iterations", 10 ) ),
46  _relative_step_tolerance( input("linear-nonlinear-solver/relative_step_tolerance", 1.e-6 ) ),
47  _absolute_step_tolerance( input("linear-nonlinear-solver/absolute_step_tolerance", 0.0 ) ),
48  _relative_residual_tolerance( input("linear-nonlinear-solver/relative_residual_tolerance", 1.e-15 ) ),
49  _absolute_residual_tolerance( input("linear-nonlinear-solver/absolute_residual_tolerance", 0.0 ) ),
50  _initial_linear_tolerance( input("linear-nonlinear-solver/initial_linear_tolerance", 1.e-3 ) ),
51  _minimum_linear_tolerance( input("linear-nonlinear-solver/minimum_linear_tolerance", 1.e-3 ) ),
52  _max_linear_iterations( input("linear-nonlinear-solver/max_linear_iterations", 500 ) ),
53  _continue_after_backtrack_failure( input("linear-nonlinear-solver/continue_after_backtrack_failure", false ) ),
54  _continue_after_max_iterations( input("linear-nonlinear-solver/continue_after_max_iterations", false ) ),
55  _solver_quiet( input("screen-options/solver_quiet", false ) ),
56  _solver_verbose( input("screen-options/solver_verbose", false ) )
57  {
58  return;
59  }
60 
61 
63  {
64  return;
65  }
66 
67  void Solver::initialize( const GetPot& /*input*/,
68  std::tr1::shared_ptr<libMesh::EquationSystems> equation_system,
69  MultiphysicsSystem* system )
70  {
71 
72  // Defined in subclasses depending on the solver used.
73  this->init_time_solver(system);
74 
75  // Initialize the system
76  equation_system->init();
77 
78  // Get diff solver to set options
79  libMesh::DiffSolver &solver = *(system->time_solver->diff_solver().get());
80 
81  // Set linear/nonlinear solver options
82  this->set_solver_options( solver );
83 
84  return;
85  }
86 
87  void Solver::set_solver_options( libMesh::DiffSolver& solver )
88  {
89  solver.quiet = this->_solver_quiet;
90  solver.verbose = this->_solver_verbose;
91  solver.max_nonlinear_iterations = this->_max_nonlinear_iterations;
92  solver.relative_step_tolerance = this->_relative_step_tolerance;
93  solver.absolute_step_tolerance = this->_absolute_step_tolerance;
94  solver.relative_residual_tolerance = this->_relative_residual_tolerance;
95  solver.absolute_residual_tolerance = this->_absolute_residual_tolerance;
96  solver.max_linear_iterations = this->_max_linear_iterations;
97  solver.continue_after_backtrack_failure = this->_continue_after_backtrack_failure;
98  solver.initial_linear_tolerance = this->_initial_linear_tolerance;
99  solver.minimum_linear_tolerance = this->_minimum_linear_tolerance;
100  solver.continue_after_max_iterations = this->_continue_after_max_iterations;
101 
102  return;
103  }
104 
106  {
107  libMesh::out << "==========================================================" << std::endl
108  << "Solving adjoint problem." << std::endl
109  << "==========================================================" << std::endl;
110 
111  context.system->adjoint_solve();
112  context.system->set_adjoint_already_solved(true);
113  }
114 
115 } // namespace GRINS
double _absolute_residual_tolerance
Definition: grins_solver.h:103
bool _solver_verbose
Definition: grins_solver.h:112
virtual void init_time_solver(GRINS::MultiphysicsSystem *system)=0
double _relative_residual_tolerance
Definition: grins_solver.h:101
Solver(const GetPot &input)
Definition: grins_solver.C:44
unsigned int _max_linear_iterations
Definition: grins_solver.h:106
void set_solver_options(libMesh::DiffSolver &solver)
Definition: grins_solver.C:87
double _relative_step_tolerance
Definition: grins_solver.h:95
void steady_adjoint_solve(SolverContext &context)
Do steady version of adjoint solve.
Definition: grins_solver.C:105
bool _continue_after_backtrack_failure
Definition: grins_solver.h:107
GRINS namespace.
double _minimum_linear_tolerance
Definition: grins_solver.h:105
double _absolute_step_tolerance
Definition: grins_solver.h:96
GRINS::MultiphysicsSystem * system
Interface with libMesh for solving Multiphysics problems.
bool _continue_after_max_iterations
Definition: grins_solver.h:108
virtual ~Solver()
Definition: grins_solver.C:62
virtual void initialize(const GetPot &input, std::tr1::shared_ptr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
Definition: grins_solver.C:67
Simple class to hold objects passed to Solver::solve.
unsigned int _max_nonlinear_iterations
Definition: grins_solver.h:94
double _initial_linear_tolerance
Definition: grins_solver.h:104

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1