diff_system.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 #include "libmesh/diff_solver.h"
20 #include "libmesh/diff_system.h"
21 #include "libmesh/time_solver.h"
22 
23 namespace libMesh
24 {
25 
26 
27 
30  const std::string& name_in,
31  const unsigned int number_in) :
32  Parent (es, name_in, number_in),
33  time_solver (NULL),
34  deltat(1.),
35  print_solution_norms(false),
36  print_solutions(false),
37  print_residual_norms(false),
38  print_residuals(false),
39  print_jacobian_norms(false),
40  print_jacobians(false),
41  print_element_jacobians(false),
42  _diff_physics(this),
43  diff_qoi(this)
44 {
45 }
46 
47 
48 
50 {
51  this->clear();
52 }
53 
54 
55 
57 {
58  // If we had an attached Physics object, delete it.
59  if (this->_diff_physics != this)
60  {
61  delete this->_diff_physics;
62  this->_diff_physics = this;
63  }
64  // If we had no attached Physics object, clear our own Physics data
65  else
66  this->clear_physics();
67 
68  // If we had an attached QoI object, delete it.
69  if (this->diff_qoi != this)
70  {
71  delete this->diff_qoi;
72  this->diff_qoi = this;
73  }
74  // If we had no attached QoI object, clear our own QoI data
75  else
76  this->clear_qoi();
77 
78  use_fixed_solution = false;
79 }
80 
81 
82 
84 {
86 
88  libmesh_assert_equal_to (&(time_solver->system()), this);
89 
90  time_solver->reinit();
91 }
92 
93 
94 
96 {
97  // If it isn't a separate initialized-upon-attachment object, do any
98  // initialization our physics needs.
99  if (this->_diff_physics == this)
100  this->init_physics(*this);
101 
102  // Do any initialization our solvers need
104  libmesh_assert_equal_to (&(time_solver->system()), this);
105  time_solver->init();
106 
107  // Next initialize ImplicitSystem data
109 
110  time_solver->init_data();
111 }
112 
113 
114 
116 {
117  AutoPtr<DiffContext> ap(new DiffContext(*this));
118 
119  ap->set_deltat_pointer( &this->deltat );
120 
121  return ap;
122 }
123 
124 
126 {
127  this->assembly(true, true);
128 }
129 
130 
131 
133 {
134  // Get the time solver object associated with the system, and tell it that
135  // we are not solving the adjoint problem
136  this->get_time_solver().set_is_adjoint(false);
137 
138  libmesh_assert_equal_to (&(time_solver->system()), this);
139  time_solver->solve();
140 }
141 
142 
143 
144 std::pair<unsigned int, Real> DifferentiableSystem::adjoint_solve (const QoISet& qoi_indices)
145 {
146  // Get the time solver object associated with the system, and tell it that
147  // we are solving the adjoint problem
148  this->get_time_solver().set_is_adjoint(true);
149 
150  return this->ImplicitSystem::adjoint_solve(qoi_indices);
151 }
152 
153 
154 
156 {
158  libmesh_assert_equal_to (&(time_solver->system()), this);
159  return this->time_solver->linear_solver().get();
160 }
161 
162 
163 
164 std::pair<unsigned int, Real> DifferentiableSystem::get_linear_solve_parameters() const
165 {
167  libmesh_assert_equal_to (&(time_solver->system()), this);
168  return std::make_pair(this->time_solver->diff_solver()->max_linear_iterations,
169  this->time_solver->diff_solver()->relative_residual_tolerance);
170 }
171 
172 
173 
175 {
176 }
177 
178 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo