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