Nektar++
ForcingSyntheticEddy.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ForcingSyntheticEddy.h
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: Derived base class - Synthetic turbulence generation.
32// This code implements the Synthetic Eddy Method (SEM).
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef NEKTAR_SOLVERUTILS_FORCINGSYNTHETICEDDY
37#define NEKTAR_SOLVERUTILS_FORCINGSYNTHETICEDDY
38
40#include <string>
41
42namespace Nektar::SolverUtils
43{
44
46{
47public:
49
50 /// Creates an instance of this class
53 const std::weak_ptr<EquationSystem> &pEquation,
55 const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
56 {
59 pEquation);
60 p->InitObject(pFields, pNumForcingFields, pForce);
61 return p;
62 }
63
64 /// Name of the class
65 SOLVER_UTILS_EXPORT static std::string className;
66
67protected:
68 // Initial object
71 const unsigned int &pNumForcingFields,
72 const TiXmlElement *pForce) override;
73 // Apply forcing term
76 const Array<OneD, Array<OneD, NekDouble>> &inarray,
78 const NekDouble &time) override;
79 // Apply forcing term
82 const Array<OneD, Array<OneD, NekDouble>> &inarray,
84 const NekDouble &time) override;
85 // Set Cholesky decomposition of the Reynolds Stresses in the domain
88 /// Set the Number of the Eddies in the box
90 /// Set reference lengths
92 /// Set Xi max
94 /// Compute Random 1 or -1 value
96 /// Compute Constant C
98 /// Compute Gaussian
100 NekDouble xiMaxVal,
101 NekDouble constC = 1.0);
102 /// Check if point is inside the box of eddies
104 NekDouble coord1,
105 NekDouble coord2);
106 /// Compute Stochastic Signal
109 /// Compute Velocity Fluctuation
113 Array<OneD, Array<OneD, NekDouble>> stochasticSignal);
114 /// Compute Characteristic Convective Turbulent Time
117 /// Compute Smoothing Factor
121 /// Set box of eddies mask
124 /// Initialise forcing term for each eddy
127 /// Compute the initial position of the eddies inside the box
129 /// Update positions of the eddies inside the box
131 /// Remove eddy from forcing term
134 /// Compute the initial location of the eddies for the test case
136
137 // Members
138 // Expressions (functions) of the prescribed Reynolds stresses
139 std::map<int, LibUtilities::EquationSharedPtr> m_R;
140 /// Cholesky decomposition of the Reynolds Stresses
141 /// for all points in the mesh
143 /// Bulk velocity
145 /// Standard deviation
147 /// Inlet length in the y-direction and z-direction
149 /// Center of the inlet plane
151 /// Number of eddies in the box
152 int m_N;
153 /// Characteristic lenght scales
155 /// Reference lenghts
157 /// Xi max
159 // XiMaxMin - Value form Giangaspero et al. 2022
161 /// Space dimension
163 /// Ration of specific heats
165 /// Box of eddies mask
167 /// Eddy position
169 /// Check when the forcing should be applied
170 bool m_calcForcing{true};
171 /// Eddies that add to the domain
172 std::vector<unsigned int> m_eddiesIDForcing;
173 /// Current time
175 /// Check for test case
177 /// Forcing for each eddy
179
182 const std::weak_ptr<EquationSystem> &pEquation);
184};
185
186} // namespace Nektar::SolverUtils
187
188#endif
#define SOLVER_UTILS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Defines a forcing term to be explicitly applied.
Definition: Forcing.h:71
SOLVER_UTILS_EXPORT void SetBoxOfEddiesMask(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Set box of eddies mask.
std::map< int, LibUtilities::EquationSharedPtr > m_R
Array< OneD, NekDouble > m_lyz
Inlet length in the y-direction and z-direction.
Array< OneD, NekDouble > m_lref
Reference lenghts.
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > ComputeSmoothingFactor(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, Array< OneD, NekDouble > > convTurb)
Compute Smoothing Factor.
SOLVER_UTILS_EXPORT ~ForcingSyntheticEddy(void) override=default
SOLVER_UTILS_EXPORT void v_ApplyCoeff(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
Apply forcing term if an eddy left the box of eddies and update the eddies positions.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_ForcingEddy
Forcing for each eddy.
SOLVER_UTILS_EXPORT ForcingSyntheticEddy(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
SOLVER_UTILS_EXPORT NekDouble ComputeConstantC(int row, int col)
Compute Constant C.
Array< OneD, NekDouble > m_l
Characteristic lenght scales.
static SOLVER_UTILS_EXPORT std::string className
Name of the class.
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > ComputeStochasticSignal(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Compute Stochastic Signal.
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, int > > GenerateRandomOneOrMinusOne()
Compute Random 1 or -1 value.
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > ComputeVelocityFluctuation(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, Array< OneD, NekDouble > > stochasticSignal)
Compute Velocity Fluctuation.
SOLVER_UTILS_EXPORT void UpdateEddiesPositions()
Update positions of the eddies inside the box.
SOLVER_UTILS_EXPORT NekDouble ComputeGaussian(NekDouble coord, NekDouble xiMaxVal, NekDouble constC=1.0)
Compute Gaussian.
std::vector< unsigned int > m_eddiesIDForcing
Eddies that add to the domain.
SOLVER_UTILS_EXPORT void SetNumberOfEddies()
Set the Number of the Eddies in the box.
SOLVER_UTILS_EXPORT void InitialiseForcingEddy(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Initialise forcing term for each eddy.
Array< OneD, NekDouble > m_rc
Center of the inlet plane.
SOLVER_UTILS_EXPORT void v_Apply(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
Apply forcing term if an eddy left the box of eddies and update the eddies positions.
SOLVER_UTILS_EXPORT void ComputeInitialLocationTestCase()
Compute the initial location of the eddies for the test case.
bool m_calcForcing
Check when the forcing should be applied.
SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
Read input from xml file and initialise the class members. The main parameters are the characteristic...
static SOLVER_UTILS_EXPORT ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
SOLVER_UTILS_EXPORT void ComputeInitialRandomLocationOfEddies()
Compute the initial position of the eddies inside the box.
SOLVER_UTILS_EXPORT void ComputeXiMax()
Set Xi max.
Array< OneD, NekDouble > m_xiMax
Xi max.
SOLVER_UTILS_EXPORT void RemoveEddiesFromForcing(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Remove eddy from forcing term.
Array< OneD, Array< OneD, NekDouble > > m_Cholesky
Cholesky decomposition of the Reynolds Stresses for all points in the mesh.
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > ComputeCharConvTurbTime(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Compute Characteristic Convective Turbulent Time.
SOLVER_UTILS_EXPORT void ComputeRefLenghts()
Set reference lengths.
Array< OneD, int > m_mask
Box of eddies mask.
SOLVER_UTILS_EXPORT bool InsideBoxOfEddies(NekDouble coord0, NekDouble coord1, NekDouble coord2)
Check if point is inside the box of eddies.
SOLVER_UTILS_EXPORT void SetCholeskyReyStresses(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Calculates the Cholesky decomposition of the Reynolds Stresses in each degree of freedom of the mesh.
Array< OneD, Array< OneD, NekDouble > > m_eddyPos
Eddy position.
NekDouble m_gamma
Ration of specific heats.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
Definition: Forcing.h:53
double NekDouble