libMesh
diff_qoi.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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_QOI_H
21 #define LIBMESH_DIFF_QOI_H
22 
23 // Local Includes
24 #include "libmesh/auto_ptr.h"
25 #include "libmesh/parallel.h"
26 #include "libmesh/diff_context.h"
27 
28 // C++ includes
29 
30 namespace libMesh
31 {
32 
33 // Forward declarations
34 class DiffContext;
35 class QoISet;
36 
50 {
51 public:
52 
58 
62  virtual ~DifferentiableQoI () {}
63 
68  virtual void init_qoi( std::vector<Number> & /*sys_qoi*/){}
69 
74  virtual void clear_qoi () {}
75 
83 
91 
99 
107  virtual void element_qoi (DiffContext &,
108  const QoISet &)
109  {}
110 
120  const QoISet &)
121  {}
122 
130  virtual void side_qoi (DiffContext &,
131  const QoISet &)
132  {}
133 
143  const QoISet &)
144  {}
145 
152  virtual void init_context(DiffContext &) {}
153 
157  virtual UniquePtr<DifferentiableQoI> clone() =0;
158 
162  virtual void thread_join(std::vector<Number> & qoi,
163  const std::vector<Number> & other_qoi,
164  const QoISet & qoi_indices);
165 
170  virtual void parallel_op(const Parallel::Communicator & communicator,
171  std::vector<Number> & sys_qoi,
172  std::vector<Number> & local_qoi,
173  const QoISet & qoi_indices);
174 
179  virtual void finalize_derivative(NumericVector<Number> & derivatives, std::size_t qoi_index);
180 };
181 
182 } // namespace libMesh
183 
184 
185 #endif // LIBMESH_DIFF_QOI_H
virtual void parallel_op(const Parallel::Communicator &communicator, std::vector< Number > &sys_qoi, std::vector< Number > &local_qoi, const QoISet &qoi_indices)
Method to populate system qoi data structure with process-local qoi.
Definition: diff_qoi.C:39
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:54
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition: qoi_set.h:45
virtual void init_context(DiffContext &)
Prepares the result of a build_context() call for use.
Definition: diff_qoi.h:152
MPI_Comm communicator
Communicator object for talking with subsets of processors.
Definition: parallel.h:181
bool assemble_qoi_elements
If assemble_qoi_elements is false (it is true by default), the assembly loop for a quantity of intere...
Definition: diff_qoi.h:98
virtual void element_qoi(DiffContext &, const QoISet &)
Does any work that needs to be done on elem in a quantity of interest assembly loop, outputting to elem_qoi.
Definition: diff_qoi.h:107
The libMesh namespace provides an interface to certain functionality in the library.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual UniquePtr< DifferentiableQoI > clone()=0
Copy of this object.
virtual void clear_qoi()
Clear all the data structures associated with the QoI.
Definition: diff_qoi.h:74
virtual void side_qoi(DiffContext &, const QoISet &)
Does any work that needs to be done on side of elem in a quantity of interest assembly loop...
Definition: diff_qoi.h:130
virtual void thread_join(std::vector< Number > &qoi, const std::vector< Number > &other_qoi, const QoISet &qoi_indices)
Method to combine thread-local qois.
Definition: diff_qoi.C:31
virtual void side_qoi_derivative(DiffContext &, const QoISet &)
Does any work that needs to be done on side of elem in a quantity of interest derivative assembly loo...
Definition: diff_qoi.h:142
This class provides a specific system class.
Definition: diff_qoi.h:49
bool assemble_qoi_internal_sides
If assemble_qoi_internal_sides is true (it is false by default), the assembly loop for a quantity of ...
Definition: diff_qoi.h:90
DifferentiableQoI()
Constructor.
Definition: diff_qoi.C:24
bool assemble_qoi_sides
If assemble_qoi_sides is true (it is false by default), the assembly loop for a quantity of interest ...
Definition: diff_qoi.h:82
virtual ~DifferentiableQoI()
Destructor.
Definition: diff_qoi.h:62
virtual void element_qoi_derivative(DiffContext &, const QoISet &)
Does any work that needs to be done on elem in a quantity of interest derivative assembly loop...
Definition: diff_qoi.h:119
virtual void finalize_derivative(NumericVector< Number > &derivatives, std::size_t qoi_index)
Method to finalize qoi derivatives which require more than just a simple sum of element contributions...
Definition: diff_qoi.C:51
virtual void init_qoi(std::vector< Number > &)
Initialize system qoi.
Definition: diff_qoi.h:68