libMesh
Loading...
Searching...
No Matches
diff_qoi.C
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#include "libmesh/diff_qoi.h"
20#include "libmesh/int_range.h"
21#include "libmesh/parallel.h"
22
23namespace libMesh
24{
25
27 assemble_qoi_sides(false),
28 assemble_qoi_internal_sides(false),
29 assemble_qoi_elements(true)
30{
31}
32
33void DifferentiableQoI::thread_join( std::vector<Number> & qoi,
34 const std::vector<Number> & other_qoi,
35 const QoISet &)
36{
37 for (auto i : index_range(qoi))
38 qoi[i] += other_qoi[i];
39}
40
42 std::vector<Number> & sys_qoi,
43 std::vector<Number> & local_qoi,
44 const QoISet &)
45{
46 // Sum everything into local_qoi
47 communicator.sum(local_qoi);
48
49 // Now put into system qoi
50 sys_qoi = local_qoi;
51}
52
54{
55 // by default, do nothing
56}
57
58} // namespace libMesh
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
DifferentiableQoI()
Constructor.
Definition diff_qoi.C:26
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 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
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition qoi_set.h:46
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153