libMesh
diff_qoi.C
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 #include "libmesh/diff_qoi.h"
20 
21 namespace libMesh
22 {
23 
25  assemble_qoi_sides(false),
26  assemble_qoi_internal_sides(false),
27  assemble_qoi_elements(true)
28 {
29 }
30 
31 void DifferentiableQoI::thread_join( std::vector<Number> & qoi,
32  const std::vector<Number> & other_qoi,
33  const QoISet &)
34 {
35  for (std::size_t i=0; i != qoi.size(); ++i)
36  qoi[i] += other_qoi[i];
37 }
38 
40  std::vector<Number> & sys_qoi,
41  std::vector<Number> & local_qoi,
42  const QoISet &)
43 {
44  // Sum everything into local_qoi
45  communicator.sum(local_qoi);
46 
47  // Now put into system qoi
48  sys_qoi = local_qoi;
49 }
50 
52 {
53  // by default, do nothing
54 }
55 
56 } // namespace libMesh
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
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition: qoi_set.h:45
MPI_Comm communicator
Communicator object for talking with subsets of processors.
Definition: parallel.h:181
The libMesh namespace provides an interface to certain functionality in the library.
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
DifferentiableQoI()
Constructor.
Definition: diff_qoi.C:24
void sum(T &r) const
Take a local variable and replace it with the sum of it&#39;s values on all processors.
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