libMesh
coupled_system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 #include <memory>
29 
30 using namespace libMesh;
31 
32 // The Navier-Stokes system class.
33 // FEMSystem, TimeSolver and NewtonSolver will handle most tasks,
34 // but we must specify element residuals
35 class CoupledSystem : public FEMSystem
36 {
37 public:
38  // Constructor
40  const std::string & name_in,
41  const unsigned int number_in)
42  : FEMSystem(es, name_in, number_in), Peclet(1.) {this->init_qois(1);}
43 
44  // Function to get computed QoI values
45 
47  {
48  return computed_QoI;
49  }
50 
51  Number & get_parameter_value(unsigned int parameter_index)
52  {
53  return parameters[parameter_index];
54  }
55 
57  {
58  if (!parameter_vector.size())
59  for (std::size_t i = 0; i != parameters.size(); ++i)
60  parameter_vector.push_back(std::make_unique<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 () = default;
118 
119  virtual std::unique_ptr<FEMFunctionBase<Number>> clone () const
120  {
121  return std::make_unique<CoupledFEMFunctionsx>(*this);
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 () = default;
149 
150  virtual std::unique_ptr<FEMFunctionBase<Number>> clone () const
151  {
152  return std::make_unique<CoupledFEMFunctionsy>(*this);
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.
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
ParameterVector & get_parameter_vector()
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...
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
Number & get_parameter_value(unsigned int parameter_index)
std::vector< Number > parameters
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62
void push_back(std::unique_ptr< ParameterAccessor< Number >> new_accessor)
Adds an additional parameter accessor to the end of the vector.
ParameterVector parameter_vector
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
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:39
Real & get_Pe()