GRINS-0.6.0
displacement_continuation_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 // This class
27 
28 // GRINS
29 #include "grins/multiphysics_sys.h"
30 #include "grins/solver_context.h"
31 
32 // libMesh
33 #include "libmesh/auto_ptr.h"
34 #include "libmesh/dof_map.h"
35 #include "libmesh/getpot.h"
36 #include "libmesh/dirichlet_boundaries.h"
37 #include "libmesh/const_function.h"
38 
39 namespace GRINS
40 {
41 
43  : SteadySolver(input),
44  _bc_id( input("SolverOptions/DisplacementContinuation/boundary", -1) )
45  {
46  if( !input.have_variable("SolverOptions/DisplacementContinuation/boundary") )
47  {
48  std::cerr << "Error: Did not find boundary id for DisplacementContinuationSolver" << std::endl
49  << " Must specify SolverOptions/DisplacementContinuation/boundary in input." << std::endl;
50  libmesh_error();
51  }
52 
53  if( !input.have_variable("SolverOptions/DisplacementContinuation/final_displacement") )
54  {
55  std::cerr << "Error: Did not find final_displacement value for DisplacementContinuationSolver" << std::endl
56  << " Must specify SolverOptions/DisplacementContinuation/final_displacement" << std::endl;
57  libmesh_error();
58  }
59  libMesh::Real disp_value = input("SolverOptions/DisplacementContinuation/final_displacement", 0.0);
60 
61 
62  if( !input.have_variable("SolverOptions/DisplacementContinuation/n_increments") )
63  {
64  std::cerr << "Error: Did not find final_displacement value for DisplacementContinuationSolver" << std::endl
65  << " Must specify SolverOptions/DisplacementContinuation/n_increments" << std::endl;
66  libmesh_error();
67  }
68  unsigned int n_increments = input("SolverOptions/DisplacementContinuation/n_increments", 1);
69 
70  _displacements.resize(n_increments);
71 
72  libMesh::Real increment = disp_value/n_increments;
73 
74  for( unsigned int i = 0; i < n_increments; i++ )
75  {
76  _displacements[i] = (i+1)*increment;
77  }
78 
79  return;
80  }
81 
83  {
84  return;
85  }
86 
87  void DisplacementContinuationSolver::initialize( const GetPot& input,
88  std::tr1::shared_ptr<libMesh::EquationSystems> equation_system,
90  {
91  // First init everything on the base class side, which will reinit equation_system
92  Solver::initialize(input,equation_system,system);
93 
94  // Now search for the index for the DirichletBoundary we want to increment
95  libMesh::DirichletBoundaries* d_vector = system->get_dof_map().get_dirichlet_boundaries();
96 
97  bool found_bc_id = false;
98  for( libMesh::DirichletBoundaries::const_iterator it = d_vector->begin(); it != d_vector->end(); ++it )
99  {
100  if( (*it)->b.find(_bc_id) != (*it)->b.end() )
101  {
102  found_bc_id = true;
103  _bc_index = it - d_vector->begin();
104  // We're assuming that there's only one boundary
105  break;
106  }
107  }
108 
109  if( !found_bc_id )
110  {
111  std::cerr << "Error: Did not find prescribed boundary for DisplacementContinuationSolver" << std::endl
112  << " Was searching for bc_id = " << _bc_id << std::endl;
113  libmesh_error();
114  }
115 
116  return;
117  }
118 
120  {
121  for( unsigned int s = 0; s < _displacements.size(); s++ )
122  {
123 
124  libMesh::Real disp = _displacements[s];
125 
126  std::cout << "==========================================================" << std::endl
127  << " Displacement step " << s << ", displacement = " << disp << std::endl
128  << "==========================================================" << std::endl;
129 
130  this->increment_displacement(*(context.system), *(context.equation_system), disp);
131 
132  context.system->solve();
133 
134  if( context.output_vis )
135  {
136  context.postprocessing->update_quantities( *(context.equation_system) );
137  context.vis->output( context.equation_system, s, disp );
138  }
139  }
140 
141  return;
142  }
143 
145  libMesh::EquationSystems& equation_system,
146  const libMesh::Real displacement )
147  {
148  // Get DirichetBoundaries vector.
149  libMesh::DirichletBoundaries* d_vector = system.get_dof_map().get_dirichlet_boundaries();
150 
151  // Get the DirichletBoundary we want
152  libMesh::DirichletBoundary* dirichlet = (*d_vector)[_bc_index];
153 
154  // Kill the old FunctionBase object and put in our new one.
155  dirichlet->f.reset( new libMesh::ConstFunction<libMesh::Real>( displacement ) );
156 
157  // Need to reinit system
158  equation_system.reinit();
159 
160  return;
161  }
162 
163 
164 } // end namespace GRINS
unsigned int _bc_index
Cache index into libMesh::DirichletBoundaries.
virtual void initialize(const GetPot &input, std::tr1::shared_ptr< libMesh::EquationSystems > equation_system, GRINS::MultiphysicsSystem *system)
std::tr1::shared_ptr< libMesh::EquationSystems > equation_system
GRINS namespace.
GRINS::MultiphysicsSystem * system
Interface with libMesh for solving Multiphysics problems.
std::tr1::shared_ptr< PostProcessedQuantities< libMesh::Real > > postprocessing
void increment_displacement(GRINS::MultiphysicsSystem &system, libMesh::EquationSystems &equation_system, const libMesh::Real displacement)
std::tr1::shared_ptr< GRINS::Visualization > vis
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.
libMesh::boundary_id_type _bc_id
Boundary on which we want to increment the displacement.

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