Nektar++
Loading...
Searching...
No Matches
ReynoldsStressOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ReynoldsStressOp.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: Device-portable velocity-product operator.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
37#include <string>
38#include <vector>
39
41
42namespace Nektar
43{
44
45/**
46 * @brief Accumulate the scaled pairwise products of the velocity components.
47 *
48 * For the \f$ d \f$ velocity components \f$ u_a \f$ selected with
49 * Configure(), Apply() adds \f$ s \, u_a u_b \f$, \f$ a \le b \f$,
50 * pointwise to the \f$ d(d+1)/2 \f$ components of a product field, ordered
51 * \f$ (a,b) = (0,0), (0,1), \ldots, (0,d-1), (1,1), \ldots, (d-1,d-1) \f$,
52 * i.e. \f$ uu, uv, uw, vv, vw, ww \f$ in three dimensions, which include a
53 * 3DH1 expansion, its products formed on every local plane. The scale
54 * \f$ s \f$ is one unless changed with SetScale().
55 *
56 * The velocity field may carry further components, such as passive scalars;
57 * only the selected ones are read. The product field has the operator's block
58 * attributes. A product block at another interleave width than the velocity's
59 * is reshaped to it, keeping its content, so that the products leave Apply()
60 * laid out like the velocity. Block \f$ b \f$ executes on stream
61 * \f$ b+1 \f$.
62 */
63template <typename TData>
65{
66public:
67 static std::shared_ptr<ReynoldsStressOp<TData>> Create(
68 const MultiRegions::ExpListSharedPtr &expansionList,
69 const std::vector<std::string> &components,
70 const std::string &execStr = "")
71 {
72 return MultiRegions::Operator<TData>::template Create<ReynoldsStressOp>(
73 expansionList, components, execStr);
74 }
75
76 static inline const std::string name = "ReynoldsStress";
77
78 /// Names of the product components, e.g. uu, uv, uw, vv, vw, ww, formed
79 /// from the names of the selected velocity components.
80 static std::vector<std::string> ProductNames(
81 const std::vector<std::string> &velocityNames)
82 {
83 std::vector<std::string> names;
84 for (unsigned int a = 0; a < velocityNames.size(); ++a)
85 {
86 for (unsigned int b = a; b < velocityNames.size(); ++b)
87 {
88 names.push_back(velocityNames[a] + velocityNames[b]);
89 }
90 }
91 return names;
92 }
93
94 /// @p velocityComponents are the indices of the velocity components in
95 /// the velocity field, which may hold further components.
96 void Configure(const std::vector<unsigned int> &velocityComponents)
97 {
98 v_Configure(velocityComponents);
99 }
100
101 /// Set the factor applied to the products before they are added.
102 void SetScale(const TData scale)
103 {
104 m_scale = scale;
105 }
106
107 /// Add the scaled products of @p velocity to @p products, which leave
108 /// at the interleave width of @p velocity.
111 {
112 v_Apply(velocity, products);
113 }
114
115 /// As Apply().
118 {
119 v_Apply(velocity, products);
120 }
121
122protected:
123 /// Factor applied to the products before they are added.
124 TData m_scale = TData{1};
125
127 const std::vector<std::string> &components)
128 : MultiRegions::Operator<TData>(expansionList, components)
129 {
130 }
131
132 ~ReynoldsStressOp() override = default;
133
134 virtual void v_Configure(
135 const std::vector<unsigned int> &velocityComponents) = 0;
136
137 virtual void v_Apply(
140};
141
142} // namespace Nektar
Whole-field operator base class and factory machinery shared by every operator family in the MultiReg...
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
Accumulate the scaled pairwise products of the velocity components.
virtual void v_Configure(const std::vector< unsigned int > &velocityComponents)=0
void operator()(LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &products)
As Apply().
static std::shared_ptr< ReynoldsStressOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
void Configure(const std::vector< unsigned int > &velocityComponents)
velocityComponents are the indices of the velocity components in the velocity field,...
TData m_scale
Factor applied to the products before they are added.
virtual void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &products)=0
ReynoldsStressOp(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
static const std::string name
static std::vector< std::string > ProductNames(const std::vector< std::string > &velocityNames)
Names of the product components, e.g. uu, uv, uw, vv, vw, ww, formed from the names of the selected v...
~ReynoldsStressOp() override=default
void Apply(LibUtilities::Field< TData, FieldState::Phys > &velocity, LibUtilities::Field< TData, FieldState::Phys > &products)
Add the scaled products of velocity to products, which leave at the interleave width of velocity.
void SetScale(const TData scale)
Set the factor applied to the products before they are added.
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.