GRINS-0.7.0
grins_steady_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-2016 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 // This class
28 
29 // GRINS
30 #include "grins/multiphysics_sys.h"
31 #include "grins/solver_context.h"
32 
33 // libMesh
34 #include "libmesh/auto_ptr.h"
35 #include "libmesh/dof_map.h"
36 #include "libmesh/getpot.h"
37 #include "libmesh/steady_solver.h"
38 #include "libmesh/linear_solver.h"
39 
40 namespace GRINS
41 {
42 
43  SteadySolver::SteadySolver( const GetPot& input )
44  : Solver( input )
45  {
46  return;
47  }
48 
50  {
51  return;
52  }
53 
55  {
56  libMesh::SteadySolver* time_solver = new libMesh::SteadySolver( *(system) );
57 
58  system->time_solver = libMesh::UniquePtr<libMesh::TimeSolver>(time_solver);
59  return;
60  }
61 
63  {
64  libmesh_assert( context.system );
65 
66  if( context.output_vis )
67  {
68  context.postprocessing->update_quantities( *(context.equation_system) );
69  context.vis->output( context.equation_system );
70  }
71 
72  // GRVY timers contained in here (if enabled)
73  context.system->solve();
74 
75  if ( context.print_scalars )
76  this->print_scalar_vars(context);
77 
78  if( context.do_adjoint_solve )
79  {
80  // Get the linear solver
81  libMesh::LinearSolver<libMesh::Number> *linear_solver = context.system->get_linear_solver();
82 
83  // Set ourselves to reuse the preconditioner
84  linear_solver->reuse_preconditioner(true);
85 
86  // Solve the adjoint problem
87  this->steady_adjoint_solve(context);
88 
89  // Go back to not reusing the preconditioner
90  linear_solver->reuse_preconditioner(false);
91  }
92 
93  if( context.output_adjoint )
94  context.vis->output_adjoint( context.equation_system, context.system );
95 
96  if( context.output_vis )
97  {
98  context.postprocessing->update_quantities( *(context.equation_system) );
99  context.vis->output( context.equation_system );
100  }
101 
102  if( context.output_residual ) context.vis->output_residual( context.equation_system, context.system );
103 
104  return;
105  }
106 
108  (SolverContext& context,
109  const libMesh::QoISet& qoi_indices,
110  const libMesh::ParameterVector& parameters_in,
111  libMesh::SensitivityData& sensitivities) const
112  {
113  // Get the linear solver
114  libMesh::LinearSolver<libMesh::Number> *linear_solver = context.system->get_linear_solver();
115 
116  // Set ourselves to reuse the preconditioner
117  linear_solver->reuse_preconditioner(true);
118 
119  context.system->adjoint_qoi_parameter_sensitivity
120  (qoi_indices, parameters_in, sensitivities);
121 
122  // Go back to not reusing the preconditioner
123  linear_solver->reuse_preconditioner(false);
124  }
125 
127  (SolverContext& context,
128  const libMesh::QoISet& qoi_indices,
129  const libMesh::ParameterVector& parameters_in,
130  libMesh::SensitivityData& sensitivities) const
131  {
132  context.system->forward_qoi_parameter_sensitivity
133  (qoi_indices, parameters_in, sensitivities);
134 
135  if( context.output_residual_sensitivities )
136  context.vis->output_residual_sensitivities
137  ( context.equation_system, context.system, parameters_in );
138 
139  if( context.output_solution_sensitivities )
140  context.vis->output_solution_sensitivities
141  ( context.equation_system, context.system, parameters_in );
142  }
143 
144 } // namespace GRINS
virtual void init_time_solver(GRINS::MultiphysicsSystem *system)
SharedPtr< libMesh::EquationSystems > equation_system
virtual void solve(SolverContext &context)
SharedPtr< PostProcessedQuantities< libMesh::Real > > postprocessing
void steady_adjoint_solve(SolverContext &context)
Do steady version of adjoint solve.
Definition: grins_solver.C:123
GRINS namespace.
SteadySolver(const GetPot &input)
virtual void forward_qoi_parameter_sensitivity(SolverContext &context, const libMesh::QoISet &qoi_indices, const libMesh::ParameterVector &parameters_in, libMesh::SensitivityData &sensitivities) const
GRINS::MultiphysicsSystem * system
SharedPtr< GRINS::Visualization > vis
void print_scalar_vars(SolverContext &context)
Definition: grins_solver.C:133
Interface with libMesh for solving Multiphysics problems.
virtual void adjoint_qoi_parameter_sensitivity(SolverContext &context, const libMesh::QoISet &qoi_indices, const libMesh::ParameterVector &parameters_in, libMesh::SensitivityData &sensitivities) const
Simple class to hold objects passed to Solver::solve.

Generated on Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10