libMesh
coupled_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 #ifndef COUPLED_SYSTEM_H
19 #define COUPLED_SYSTEM_H
20 
21 // DiffSystem framework files
22 #include "libmesh/fem_function_base.h"
23 #include "libmesh/fem_system.h"
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/parameter_pointer.h"
26 #include "libmesh/parameter_vector.h"
27 #include "libmesh/auto_ptr.h" // libmesh_make_unique
28 
29 using namespace libMesh;
30 
31 // The Navier-Stokes system class.
32 // FEMSystem, TimeSolver and NewtonSolver will handle most tasks,
33 // but we must specify element residuals
34 class CoupledSystem : public FEMSystem
35 {
36 public:
37  // Constructor
39  const std::string & name_in,
40  const unsigned int number_in)
41  : FEMSystem(es, name_in, number_in), Peclet(1.) {qoi.resize(1);}
42 
43  // Function to get computed QoI values
44 
46  {
47  return computed_QoI;
48  }
49 
50  Number & get_parameter_value(unsigned int parameter_index)
51  {
52  return parameters[parameter_index];
53  }
54 
56  {
57  if (!parameter_vector.size())
58  for (std::size_t i = 0; i != parameters.size(); ++i)
59  parameter_vector.push_back(libmesh_make_unique<ParameterPointer<Number>>(&parameters[i]));
60 
61  return parameter_vector;
62  }
63 
65  {
66  return Peclet;
67  }
68 
69 protected:
70 
71  // System initialization
72  virtual void init_data ();
73 
74  // Context initialization
75  virtual void init_context(DiffContext & context);
76 
77  // Element residual and jacobian calculations
78  // Time dependent parts
79  virtual bool element_time_derivative (bool request_jacobian,
80  DiffContext & context);
81 
82  // Constraint parts
83  virtual bool element_constraint (bool request_jacobian,
84  DiffContext & context);
85 
86  // Postprocessed output
87  virtual void postprocess ();
88 
89  // Parameters associated with the system
90  std::vector<Number> parameters;
91 
92  // Indices for each variable;
93  unsigned int p_var, u_var, v_var, C_var;
94 
95  // The ParameterVector object that will contain pointers to
96  // the system parameters
98 
99  // The Peclet number for the species transport
101 
102  // The functionals to be computed as QoIs
104 };
105 
106 
107 class CoupledFEMFunctionsx : public FEMFunctionBase<Number>
108 {
109 public:
110  // Constructor
112  unsigned int var_number)
113  {var = var_number;}
114 
115  // Destructor
116  virtual ~CoupledFEMFunctionsx () {}
117 
118  virtual std::unique_ptr<FEMFunctionBase<Number>> clone () const
119  {
120  return libmesh_make_unique<CoupledFEMFunctionsx>(*this);
121  }
122 
123  virtual void operator() (const FEMContext &,
124  const Point &,
125  const Real,
127  { libmesh_not_implemented(); }
128 
129  virtual Number operator() (const FEMContext &,
130  const Point & p,
131  const Real time = 0.);
132 
133 private:
134  unsigned int var;
135 };
136 
137 
138 class CoupledFEMFunctionsy : public FEMFunctionBase<Number>
139 {
140 public:
141  // Constructor
143  unsigned int var_number)
144  { var = var_number; }
145 
146  // Destructor
147  virtual ~CoupledFEMFunctionsy () {}
148 
149  virtual std::unique_ptr<FEMFunctionBase<Number>> clone () const
150  {
151  return libmesh_make_unique<CoupledFEMFunctionsy>(*this);
152  }
153 
154  virtual void operator() (const FEMContext &,
155  const Point &,
156  const Real,
158  { libmesh_not_implemented(); }
159 
160  virtual Number operator() (const FEMContext &,
161  const Point & p,
162  const Real time = 0.);
163 
164 private:
165  unsigned int var;
166 };
167 
168 #endif // COUPLED_SYSTEM_H
libMesh::System
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:100
libMesh::Number
Real Number
Definition: libmesh_common.h:195
CoupledFEMFunctionsx::~CoupledFEMFunctionsx
virtual ~CoupledFEMFunctionsx()
Definition: coupled_system.h:116
libMesh::ParameterVector::push_back
void push_back(std::unique_ptr< ParameterAccessor< Number >> new_accessor)
Adds an additional parameter accessor to the end of the vector.
Definition: parameter_vector.h:183
CoupledFEMFunctionsy::clone
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
Definition: coupled_system.h:149
libMesh::FEMFunctionBase
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
Definition: dirichlet_boundaries.h:43
CoupledSystem::get_parameter_value
Number & get_parameter_value(unsigned int parameter_index)
Definition: coupled_system.h:50
CoupledSystem::get_Pe
Real & get_Pe()
Definition: coupled_system.h:64
CoupledSystem::parameters
std::vector< Number > parameters
Definition: coupled_system.h:90
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
CoupledSystem::v_var
unsigned int v_var
Definition: coupled_system.h:93
CoupledSystem::get_QoI_value
Number & get_QoI_value()
Definition: coupled_system.h:45
libMesh::FEMSystem
This class provides a specific system class.
Definition: fem_system.h:53
CoupledFEMFunctionsx::var
unsigned int var
Definition: coupled_system.h:134
CoupledFEMFunctionsy::~CoupledFEMFunctionsy
virtual ~CoupledFEMFunctionsy()
Definition: coupled_system.h:147
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::ParameterVector
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
Definition: parameter_vector.h:44
CoupledFEMFunctionsy::CoupledFEMFunctionsy
CoupledFEMFunctionsy(System &, unsigned int var_number)
Definition: coupled_system.h:142
CoupledSystem::CoupledSystem
CoupledSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
Definition: coupled_system.h:38
CoupledFEMFunctionsx::clone
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
Definition: coupled_system.h:118
CoupledSystem::computed_QoI
Number computed_QoI
Definition: coupled_system.h:103
libMesh::DiffContext
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
CoupledSystem::Peclet
Real Peclet
Definition: coupled_system.h:100
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
CoupledFEMFunctionsy::var
unsigned int var
Definition: coupled_system.h:165
CoupledFEMFunctionsy
Definition: coupled_system.h:138
libMesh::ParameterPointer
Accessor object allowing reading and modification of the independent variables in a parameter sensiti...
Definition: parameter_pointer.h:45
CoupledSystem::parameter_vector
ParameterVector parameter_vector
Definition: coupled_system.h:97
CoupledSystem::get_parameter_vector
ParameterVector & get_parameter_vector()
Definition: coupled_system.h:55
CoupledFEMFunctionsx::CoupledFEMFunctionsx
CoupledFEMFunctionsx(System &, unsigned int var_number)
Definition: coupled_system.h:111
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
CoupledSystem
Definition: coupled_system.h:34
libMesh::DenseVector< Number >
CoupledFEMFunctionsx
Definition: coupled_system.h:107
libMesh::FEMContext
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62