diff_context.h
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 
20 #ifndef LIBMESH_DIFF_CONTEXT_H
21 #define LIBMESH_DIFF_CONTEXT_H
22 
23 // Local Includes
24 #include "libmesh/dense_matrix.h"
27 #include "libmesh/dense_vector.h"
28 #include "libmesh/id_types.h"
29 
30 // C++ includes
31 #include <cstddef>
32 #include <map>
33 #include <vector>
34 
35 namespace libMesh
36 {
37 
38 // Forward declarations
39 template <typename T> class NumericVector;
40 class System;
41 
54 // ------------------------------------------------------------
55 // DifferentiableSystem class definition
56 
58 {
59 public:
60 
65  explicit
66  DiffContext (const System &);
67 
71  virtual ~DiffContext ();
72 
78  virtual void elem_reinit(Real) {}
79 
84  virtual void elem_side_reinit(Real) {}
85 
90  virtual void elem_edge_reinit(Real) {}
91 
95  unsigned int n_vars() const
96  { return libmesh_cast_int<unsigned int>(dof_indices_var.size()); }
97 
101  const System& get_system() const
102  { return _system; }
103 
108  { return elem_solution; }
109 
114  { return elem_solution; }
115 
120  const DenseSubVector<Number>& get_elem_solution( unsigned int var ) const
121  { return *(elem_subsolutions[var]); }
122 
127  { return elem_fixed_solution; }
128 
133  { return elem_fixed_solution; }
134 
139  const DenseSubVector<Number>& get_elem_fixed_solution( unsigned int var ) const
140  { return *(elem_fixed_subsolutions[var]); }
141 
146  { return elem_residual; }
147 
152  { return elem_residual; }
153 
158  const DenseSubVector<Number>& get_elem_residual( unsigned int var ) const
159  { return *(elem_subresiduals[var]); }
160 
166  { return *(elem_subresiduals[var]); }
167 
172  { return elem_jacobian; }
173 
178  { return elem_jacobian; }
179 
184  const DenseSubMatrix<Number>& get_elem_jacobian( unsigned int var1, unsigned int var2 ) const
185  { return *(elem_subjacobians[var1][var2]); }
186 
191  DenseSubMatrix<Number>& get_elem_jacobian( unsigned int var1, unsigned int var2 )
192  { return *(elem_subjacobians[var1][var2]); }
193 
197  const std::vector<Number>& get_qois() const
198  { return elem_qoi; }
199 
203  std::vector<Number>& get_qois()
204  { return elem_qoi; }
205 
209  const std::vector<DenseVector<Number> > & get_qoi_derivatives() const
210  { return elem_qoi_derivative; }
211 
215  std::vector<DenseVector<Number> > & get_qoi_derivatives()
216  { return elem_qoi_derivative; }
217 
222  const DenseSubVector<Number>& get_qoi_derivatives( unsigned int qoi, unsigned int var ) const
223  { return *(elem_qoi_subderivatives[qoi][var]); }
224 
229  DenseSubVector<Number>& get_qoi_derivatives( unsigned int qoi, unsigned int var )
230  { return *(elem_qoi_subderivatives[qoi][var]); }
231 
235  const std::vector<dof_id_type>& get_dof_indices() const
236  { return dof_indices; }
237 
241  std::vector<dof_id_type>& get_dof_indices()
242  { return dof_indices; }
243 
248  const std::vector<dof_id_type>& get_dof_indices( unsigned int var ) const
249  { return dof_indices_var[var]; }
250 
255  { return system_time; }
256 
260  Real get_time() const
261  { return time; }
262 
266  void set_time( Real time_in )
267  { time = time_in; }
268 
270  { return elem_solution_derivative; }
271 
273  { return fixed_solution_derivative; }
274 
279  bool is_adjoint() const
280  { return _is_adjoint; }
281 
286  bool& is_adjoint()
287  { return _is_adjoint; }
288 
295 
304 
311 
318 
323  void set_deltat_pointer(Real* dt);
324 
330 
335  void add_localized_vector (NumericVector<Number> & _localized_vector, const System & _sys);
336 
340  typedef std::map<const NumericVector<Number>*, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number>*> > >::iterator localized_vectors_iterator;
341 
346  DenseVector<Number> & get_localized_vector (const NumericVector<Number> & _localized_vector);
347 
351  const DenseVector<Number> & get_localized_vector (const NumericVector<Number> & _localized_vector) const;
352 
357  DenseSubVector<Number> & get_localized_subvector (const NumericVector<Number> & _localized_vector, unsigned int _var);
358 
362  const DenseSubVector<Number> & get_localized_subvector (const NumericVector<Number> & _localized_vector, unsigned int _var) const;
363 
364  protected:
365 
371  std::map<const NumericVector<Number>*, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number>*> > > localized_vectors;
372 
378  std::vector<DenseSubVector<Number> *> elem_subsolutions;
379 
386  std::vector<DenseSubVector<Number> *> elem_fixed_subsolutions;
387 
392 
398 
402  std::vector<Number> elem_qoi;
403 
407  std::vector<DenseVector<Number> > elem_qoi_derivative;
408  std::vector<std::vector<DenseSubVector<Number> *> > elem_qoi_subderivatives;
409 
413  std::vector<DenseSubVector<Number> *> elem_subresiduals;
414  std::vector<std::vector<DenseSubMatrix<Number> *> > elem_subjacobians;
415 
419  std::vector<dof_id_type> dof_indices;
420  std::vector<std::vector<dof_id_type> > dof_indices_var;
421 
422 private:
423 
436 
440  const System& _system;
441 
446 
447 };
448 
449 } // namespace libMesh
450 
451 
452 #endif // LIBMESH_DIFF_CONTEXT_H

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

Hosted By:
SourceForge.net Logo