libMesh
diff_qoi.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2026 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 
71  virtual void init_qoi_count( System & /*sys*/){}
72 
77  virtual void clear_qoi () {}
78 
86 
94 
102 
110  virtual void element_qoi (DiffContext &,
111  const QoISet &)
112  {}
113 
123  const QoISet &)
124  {}
125 
133  virtual void side_qoi (DiffContext &,
134  const QoISet &)
135  {}
136 
146  const QoISet &)
147  {}
148 
157  virtual void init_context(DiffContext &) { libmesh_deprecated(); }
158 
162  virtual std::unique_ptr<DifferentiableQoI> clone() =0;
163 
167  virtual void thread_join(std::vector<Number> & qoi,
168  const std::vector<Number> & other_qoi,
169  const QoISet & qoi_indices);
170 
175  virtual void parallel_op(const Parallel::Communicator & communicator,
176  std::vector<Number> & sys_qoi,
177  std::vector<Number> & local_qoi,
178  const QoISet & qoi_indices);
179 
184  virtual void finalize_derivative(NumericVector<Number> & derivatives, std::size_t qoi_index);
185 };
186 
187 } // namespace libMesh
188 
189 
190 #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:157
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:101
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:110
The libMesh namespace provides an interface to certain functionality in the library.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:98
virtual void clear_qoi()
Clear all the data structures associated with the QoI.
Definition: diff_qoi.h:77
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:133
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:145
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:93
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:85
virtual void init_qoi_count(System &)
Initialize system qoi.
Definition: diff_qoi.h:71
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:122
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