GRINS-0.8.0
composite_qoi.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef GRINS_COMPOSITE_QOI_H
26 #define GRINS_COMPOSITE_QOI_H
27 
28 // C++
29 #include <vector>
30 #include <ostream>
31 
32 // libMesh
33 #include "libmesh/libmesh_common.h"
34 #include "libmesh/diff_qoi.h"
35 #include "libmesh/auto_ptr.h"
36 
37 // libMesh forward declarations
38 class GetPot;
39 namespace libMesh
40 {
41  class DiffContext;
42  class QoISet;
43  namespace Parallel
44  {
45  class Communicator;
46  }
47 }
48 
49 // GRINS
50 #include "grins/qoi_base.h"
51 
52 namespace GRINS
53 {
54  // GRINS forward declarations
55  class MultiphysicsSystem;
56 
57  class CompositeQoI : public libMesh::DifferentiableQoI
58  {
59  public:
60  CompositeQoI();
61 
62  virtual ~CompositeQoI();
63 
65 
67  virtual libMesh::UniquePtr<libMesh::DifferentiableQoI> clone();
68 
69  virtual void add_qoi( const QoIBase& qoi );
70 
71  unsigned int n_qois() const;
72 
74  // named in this call.
76  ( const std::string & param_name,
78  const;
79 
84  virtual void init( const GetPot& input, const MultiphysicsSystem& system );
85 
89  virtual void init_qoi( std::vector<libMesh::Number>& sys_qoi );
90 
91  virtual void init_context( libMesh::DiffContext& context );
92 
94  virtual void reinit(MultiphysicsSystem & system);
95 
97  virtual void element_qoi( libMesh::DiffContext& context,
98  const libMesh::QoISet& qoi_indices );
99 
101  virtual void element_qoi_derivative( libMesh::DiffContext &context,
102  const libMesh::QoISet &qoi_indices );
103 
105  virtual void side_qoi( libMesh::DiffContext& context, const libMesh::QoISet& qoi_indices );
106 
108  virtual void side_qoi_derivative( libMesh::DiffContext &context, const libMesh::QoISet &qois );
109 
111 
114  virtual void parallel_op( const libMesh::Parallel::Communicator& communicator,
115  std::vector<libMesh::Number>& sys_qoi,
116  std::vector<libMesh::Number>& local_qoi,
117  const libMesh::QoISet& qoi_indices );
118 
120 
123  virtual void thread_join( std::vector<libMesh::Number>& qoi,
124  const std::vector<libMesh::Number>& other_qoi,
125  const libMesh::QoISet& qoi_indices );
126 
128  void output_qoi( std::ostream& out ) const;
129 
131  libMesh::Number get_qoi_value( unsigned int qoi_index ) const;
132 
133  const QoIBase& get_qoi( unsigned int qoi_index ) const;
134 
136  QoIBase& get_qoi( unsigned int qoi_index );
137 
138  protected:
139 
140  std::vector<QoIBase*> _qois;
141 
142  };
143 
144  inline
145  unsigned int CompositeQoI::n_qois() const
146  {
147  return _qois.size();
148  }
149 
150  inline
151  const QoIBase& CompositeQoI::get_qoi( unsigned int qoi_index ) const
152  {
153  libmesh_assert_less( qoi_index, this->n_qois() );
154 
155  return (*_qois[qoi_index]);
156  }
157 
158  inline
159  QoIBase& CompositeQoI::get_qoi( unsigned int qoi_index )
160  {
161  libmesh_assert_less( qoi_index, this->n_qois() );
162 
163  return (*_qois[qoi_index]);
164  }
165 
166 } // end namespace GRINS
167 
168 #endif // GRINS_COMPOSITE_QOI_H
virtual void thread_join(std::vector< libMesh::Number > &qoi, const std::vector< libMesh::Number > &other_qoi, const libMesh::QoISet &qoi_indices)
Operation to accumulate the QoI from multiple MPI processes.
std::vector< QoIBase * > _qois
virtual void init_context(libMesh::DiffContext &context)
virtual void side_qoi_derivative(libMesh::DiffContext &context, const libMesh::QoISet &qois)
Compute the qoi derivative with respect to the solution on the domain boundary.
const QoIBase & get_qoi(unsigned int qoi_index) const
virtual ~CompositeQoI()
Definition: composite_qoi.C:47
void register_parameter(const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
Each QoI will register its copy(s) of an independent variable.
virtual libMesh::UniquePtr< libMesh::DifferentiableQoI > clone()
Required to provide clone for adding QoI object to libMesh objects.
Definition: composite_qoi.C:58
GRINS namespace.
virtual void side_qoi(libMesh::DiffContext &context, const libMesh::QoISet &qoi_indices)
Compute the qoi value on the domain boundary.
virtual void element_qoi(libMesh::DiffContext &context, const libMesh::QoISet &qoi_indices)
Compute the qoi value for element interiors.
virtual void init_qoi(std::vector< libMesh::Number > &sys_qoi)
Method to allow QoI to resize libMesh::System storage of QoI computations.
Definition: composite_qoi.C:87
virtual void parallel_op(const libMesh::Parallel::Communicator &communicator, std::vector< libMesh::Number > &sys_qoi, std::vector< libMesh::Number > &local_qoi, const libMesh::QoISet &qoi_indices)
Operation to accumulate the QoI from multiple MPI processes.
Interface with libMesh for solving Multiphysics problems.
virtual void add_qoi(const QoIBase &qoi)
Definition: composite_qoi.C:70
void output_qoi(std::ostream &out) const
Basic output for computed QoI's.
virtual void init(const GetPot &input, const MultiphysicsSystem &system)
Method to allow QoI to cache any system information needed for QoI calculation, for example...
Definition: composite_qoi.C:94
virtual void element_qoi_derivative(libMesh::DiffContext &context, const libMesh::QoISet &qoi_indices)
Compute the qoi derivative with respect to the solution on element interiors.
libMesh::Number get_qoi_value(unsigned int qoi_index) const
Accessor for value of QoI for given qoi_index.
virtual void reinit(MultiphysicsSystem &system)
Reinitialize qoi.
unsigned int n_qois() const

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1