libMesh
Loading...
Searching...
No Matches
coupled_system.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
30using 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
36{
37public:
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 {
59 for (std::size_t i = 0; i != parameters.size(); ++i)
61
62 return parameter_vector;
63 }
64
66 {
67 return Peclet;
68 }
69
70protected:
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
109{
110public:
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
134private:
135 unsigned int var;
136};
137
138
140{
141public:
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
165private:
166 unsigned int var;
167};
168
169#endif // COUPLED_SYSTEM_H
CoupledFEMFunctionsx(System &, unsigned int var_number)
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)
Evaluation function for time-dependent vector-valued functions.
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
virtual ~CoupledFEMFunctionsx()=default
virtual std::unique_ptr< FEMFunctionBase< Number > > clone() const
CoupledFEMFunctionsy(System &, unsigned int var_number)
virtual ~CoupledFEMFunctionsy()=default
virtual void operator()(const FEMContext &, const Point &, const Real, DenseVector< Number > &)
Evaluation function for time-dependent vector-valued functions.
virtual void init_context(DiffContext &context)
ParameterVector parameter_vector
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
unsigned int u_var
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Number & get_parameter_value(unsigned int parameter_index)
std::vector< Number > parameters
unsigned int p_var
Number & get_QoI_value()
virtual bool element_constraint(bool request_jacobian, DiffContext &context)
Adds the constraint contribution on elem to elem_residual.
CoupledSystem(EquationSystems &es, const std::string &name_in, const unsigned int number_in)
virtual void postprocess()
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
unsigned int v_var
unsigned int C_var
ParameterVector & get_parameter_vector()
Defines a dense vector for use in Finite Element-type computations.
This class provides all data required for a physics package (e.g.
This is the EquationSystems class.
This class provides all data required for a physics package (e.g.
Definition fem_context.h:63
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
This class provides a specific system class.
Definition fem_system.h:55
Accessor object allowing reading and modification of the independent variables in a parameter sensiti...
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
void push_back(std::unique_ptr< ParameterAccessor< Number > > new_accessor)
Adds an additional parameter accessor to the end of the vector.
std::size_t size() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
void init_qois(unsigned int n_qois)
Accessors for qoi and qoi_error_estimates vectors.
Definition system.C:2169
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real