Nektar++
Loading...
Searching...
No Matches
HOutflowBndCondOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: HOutflowBndCondOp.hpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Coupled Dong high-order outflow boundary condition.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
40
41namespace Nektar
42{
43
44/**
45 * @brief Dong's high-order outflow boundary condition, a pressure Dirichlet
46 * condition coupled with a velocity Neumann condition.
47 *
48 * @details
49 * It applies to the boundary regions whose pressure condition is Dirichlet
50 * and whose velocity conditions are Neumann, all with
51 * USERDEFINEDTYPE="HOutflow". The operator holds the boundary data both
52 * conditions share and is not itself a boundary condition operator:
53 * ApplyPressure() sets the Dirichlet pressure coefficients and
54 * ApplyVelocity() adds the velocity flux. GetPressureDirichletOp() and
55 * GetVelocityNeumannOp() return the Dirichlet condition of the pressure
56 * system and the Neumann condition of the velocity system, which forward
57 * their Apply() to them. UpdatePressure() sets the pressure from the
58 * extrapolated velocity before the pressure solve. ApplyVelocity() computes
59 * the velocity flux from the solved pressure set by SetPressure() and the
60 * boundary data of the last UpdatePressure(), so the flux always reflects
61 * the pressure as it stands when the velocity system applies it. Both
62 * UpdatePressure() and ApplyVelocity() take the kinematic viscosity set by
63 * SetKinvis(), and UpdatePressure() the time set by SetTime() and the
64 * velocity scale set by SetScale().
65 */
66template <typename TData>
68{
69public:
70 static std::shared_ptr<HOutflowBndCondOp<TData>> Create(
71 const MultiRegions::ExpListSharedPtr &pressureExpansionList,
72 const std::vector<std::string> &pressureComponents,
73 const std::string &execStr = "")
74 {
76 HOutflowBndCondOp>(pressureExpansionList, pressureComponents,
77 execStr);
78 }
79
80 static inline const std::string name = "HOutflowBndCond";
81
82 /// USERDEFINEDTYPE of the pressure Dirichlet and velocity Neumann
83 /// conditions the operator applies.
84 static inline const std::string userDefinedType = "HOutflow";
85
86 /**
87 * @brief Set the velocity expansion list and the names of the velocity
88 * components, and build the velocity boundary data.
89 */
91 const MultiRegions::ExpListSharedPtr &velocityExpansionList,
92 const std::vector<std::string> &velocityComponents)
93 {
94 v_SetVelocityContext(velocityExpansionList, velocityComponents);
95 }
96
97 /**
98 * @brief Set the kinematic viscosity UpdatePressure() and the velocity
99 * Neumann condition use.
100 */
101 void SetKinvis(const TData &kinvis)
102 {
103 m_kinvis = kinvis;
104 }
105
106 /**
107 * @brief Set the time at which UpdatePressure() evaluates the Neumann
108 * value f_b of the velocity conditions (default 0). A region whose f_b
109 * does not use t is evaluated only by the first UpdatePressure().
110 */
111 void SetTime(const TData &time)
112 {
113 m_time = time;
114 }
115
116 /**
117 * @brief Set the scale by which UpdatePressure() multiplies the velocity
118 * it is passed, and its gradient, to give the velocity u* (default 1).
119 */
120 void SetScale(const TData &scale)
121 {
122 m_scale = scale;
123 }
124
125 /**
126 * @brief Set the pressure boundary values from the extrapolated velocity.
127 *
128 * @param velocity IMEX-extrapolated velocity at the scale of the time
129 * integrator; the scale set by SetScale() converts it,
130 * and its gradient, to the velocity u*.
131 */
136
137 /**
138 * @brief Set the solved pressure, in physical space, from which the
139 * velocity Neumann condition computes the velocity flux when it is
140 * applied.
141 *
142 * @details
143 * The operator does not take ownership of @p pressure, which must
144 * outlive it. The flux is computed from the values @p pressure holds
145 * when the velocity Neumann condition is applied, so a pressure
146 * refilled in place need not be set again.
147 */
149 {
150 m_pressure = &pressure;
151 }
152
153 /**
154 * @brief The Dirichlet condition of the pressure system, whose Apply()
155 * is ApplyPressure().
156 *
157 * @details
158 * It sets only the pressure coefficients of the regions, and is added
159 * to the pressure system with LinearSystemOp::AddDirichletBCOp(op),
160 * after the default Dirichlet operator of the system, whose values for
161 * the regions it overwrites.
162 */
163 std::shared_ptr<MultiRegions::DirBndCondOp<TData>> GetPressureDirichletOp()
164 {
165 return m_pressureAdapter;
166 }
167
168 /**
169 * @brief The Neumann condition of the velocity system, whose Apply() is
170 * ApplyVelocity(), available once SetVelocityContext() has been called.
171 *
172 * @details
173 * It applies the whole velocity flux of the regions, and is added to
174 * the velocity system with LinearSystemOp::AddNeumannBCOp(op,
175 * userDefinedType), so that the default Neumann operator of the system
176 * leaves them out.
177 */
178 std::shared_ptr<MultiRegions::NeuBndCondOp<TData>> GetVelocityNeumannOp()
179 {
181 "SetVelocityContext must be called before requesting the "
182 "HOutflow velocity adapter.");
183 return m_velocityAdapter;
184 }
185
186protected:
187 std::shared_ptr<MultiRegions::DirBndCondOp<TData>> m_pressureAdapter =
188 nullptr;
189 std::shared_ptr<MultiRegions::NeuBndCondOp<TData>> m_velocityAdapter =
190 nullptr;
191 /// Kinematic viscosity, set by SetKinvis().
192 TData m_kinvis = 0.0;
193 /// Time of the Neumann value f_b, set by SetTime().
194 TData m_time = 0.0;
195 /// Scale of the velocity passed to UpdatePressure(), set by SetScale().
196 TData m_scale = 1.0;
197 /// Solved pressure, set by SetPressure(); not owned.
199
201 const MultiRegions::ExpListSharedPtr &pressureExpansionList,
202 const std::vector<std::string> &pressureComponents)
203 : MultiRegions::Operator<TData>(pressureExpansionList,
204 pressureComponents)
205 {
206 }
207
208 ~HOutflowBndCondOp() override = default;
209
211 const MultiRegions::ExpListSharedPtr &velocityExpansionList,
212 const std::vector<std::string> &velocityComponents) = 0;
213
214 virtual void v_UpdatePressure(
216};
217
218} // namespace Nektar
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Whole-field operator base class and factory machinery shared by every operator family in the MultiReg...
Dong's high-order outflow boundary condition, a pressure Dirichlet condition coupled with a velocity ...
void SetPressure(LibUtilities::Field< TData, FieldState::Phys > &pressure)
Set the solved pressure, in physical space, from which the velocity Neumann condition computes the ve...
std::shared_ptr< MultiRegions::NeuBndCondOp< TData > > m_velocityAdapter
std::shared_ptr< MultiRegions::DirBndCondOp< TData > > m_pressureAdapter
LibUtilities::Field< TData, FieldState::Phys > * m_pressure
Solved pressure, set by SetPressure(); not owned.
void UpdatePressure(LibUtilities::Field< TData, FieldState::Phys > &velocity)
Set the pressure boundary values from the extrapolated velocity.
static std::shared_ptr< HOutflowBndCondOp< TData > > Create(const MultiRegions::ExpListSharedPtr &pressureExpansionList, const std::vector< std::string > &pressureComponents, const std::string &execStr="")
static const std::string name
virtual void v_UpdatePressure(LibUtilities::Field< TData, FieldState::Phys > &velocity)=0
TData m_kinvis
Kinematic viscosity, set by SetKinvis().
void SetKinvis(const TData &kinvis)
Set the kinematic viscosity UpdatePressure() and the velocity Neumann condition use.
TData m_scale
Scale of the velocity passed to UpdatePressure(), set by SetScale().
virtual void v_SetVelocityContext(const MultiRegions::ExpListSharedPtr &velocityExpansionList, const std::vector< std::string > &velocityComponents)=0
void SetTime(const TData &time)
Set the time at which UpdatePressure() evaluates the Neumann value f_b of the velocity conditions (de...
~HOutflowBndCondOp() override=default
std::shared_ptr< MultiRegions::NeuBndCondOp< TData > > GetVelocityNeumannOp()
The Neumann condition of the velocity system, whose Apply() is ApplyVelocity(), available once SetVel...
std::shared_ptr< MultiRegions::DirBndCondOp< TData > > GetPressureDirichletOp()
The Dirichlet condition of the pressure system, whose Apply() is ApplyPressure().
static const std::string userDefinedType
USERDEFINEDTYPE of the pressure Dirichlet and velocity Neumann conditions the operator applies.
TData m_time
Time of the Neumann value f_b, set by SetTime().
HOutflowBndCondOp(const MultiRegions::ExpListSharedPtr &pressureExpansionList, const std::vector< std::string > &pressureComponents)
void SetVelocityContext(const MultiRegions::ExpListSharedPtr &velocityExpansionList, const std::vector< std::string > &velocityComponents)
Set the velocity expansion list and the names of the velocity components, and build the velocity boun...
void SetScale(const TData &scale)
Set the scale by which UpdatePressure() multiplies the velocity it is passed, and its gradient,...
A Field represents expansion data to be operated on.
Common base class of the operator family interfaces: holds the expansion list, component names and da...
Definition Operator.hpp:100
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.