libMesh
diff_qoi.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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/diff_context.h"
25 
26 // C++ includes
27 #include <memory>
28 
29 namespace libMesh
30 {
31 
32 // Forward declarations
33 class DiffContext;
34 class QoISet;
35 
36 namespace Parallel {
37  class Communicator;
38 }
39 
53 {
54 public:
55 
61 
65  virtual ~DifferentiableQoI () = default;
66 
67 #ifdef LIBMESH_ENABLE_DEPRECATED
68 
72  virtual void init_qoi( std::vector<Number> & /*sys_qoi*/){}
73 #else
74 
78  void init_qoi( std::vector<Number> & /*sys_qoi*/){}
79 #endif
80 
85  virtual void init_qoi_count( System & /*sys*/){}
86 
91  virtual void clear_qoi () {}
92 
100 
108 
116 
124  virtual void element_qoi (DiffContext &,
125  const QoISet &)
126  {}
127 
137  const QoISet &)
138  {}
139 
147  virtual void side_qoi (DiffContext &,
148  const QoISet &)
149  {}
150 
160  const QoISet &)
161  {}
162 
171  virtual void init_context(DiffContext &) { libmesh_deprecated(); }
172 
176  virtual std::unique_ptr<DifferentiableQoI> clone() =0;
177 
181  virtual void thread_join(std::vector<Number> & qoi,
182  const std::vector<Number> & other_qoi,
183  const QoISet & qoi_indices);
184 
189  virtual void parallel_op(const Parallel::Communicator & communicator,
190  std::vector<Number> & sys_qoi,
191  std::vector<Number> & local_qoi,
192  const QoISet & qoi_indices);
193 
198  virtual void finalize_derivative(NumericVector<Number> & derivatives, std::size_t qoi_index);
199 };
200 
201 } // namespace libMesh
202 
203 
204 #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:41
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
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:171
virtual ~DifferentiableQoI()=default
Destructor.
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:115
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:124
The libMesh namespace provides an interface to certain functionality in the library.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual void clear_qoi()
Clear all the data structures associated with the QoI.
Definition: diff_qoi.h:91
void init_qoi(std::vector< Number > &)
Non-virtual, to try to help deprecated user code catch this change at compile time (if they specified...
Definition: diff_qoi.h:78
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:147
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:33
virtual std::unique_ptr< DifferentiableQoI > clone()=0
Copy of this object.
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:159
This class provides a specific system class.
Definition: diff_qoi.h:52
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:107
DifferentiableQoI()
Constructor.
Definition: diff_qoi.C:26
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:99
virtual void init_qoi_count(System &)
Initialize system qoi.
Definition: diff_qoi.h:85
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:136
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:53
virtual void init_qoi(std::vector< Number > &)
Initialize system qoi.
Definition: diff_qoi.h:72