Nektar++
Loading...
Searching...
No Matches
AdvectionBlockOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: AdvectionBlockOp.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: Per-block interface of the advection element operator.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35/**
36 * @file AdvectionBlockOp.hpp
37 * @brief Per-block interface of the advection element operator.
38 *
39 * @details
40 * An AdvectionBlockOp applies scale * (V . grad u) to the elements of one
41 * block (see ElmtBlockOp.hpp for the block scheme); on a 3DH1 expansion
42 * only the in-plane terms, the homogeneous one being added by AdvectionOp
43 * after the blocks. It carries the family-specific state the whole-field
44 * AdvectionOp forwards to every block -- the scale factor, the append flag
45 * and the per-block view of the advection velocity. The per-implementation
46 * subclasses are the detail::AdvectionBlockOpImpl definitions in
47 * Advection{SerialAVX,Device}{StdMat,SumFac}.hpp.
48 */
49
50#pragma once
51
53
55{
56
57/**
58 * @brief Base class of the per-block advection operators: evaluates
59 * scale * (V . grad u) on every element of one block.
60 *
61 * @details
62 * Besides setting the block states (physical space in and out), this class
63 * stores the three settings shared by every implementation -- the scale
64 * factor #m_scale, the accumulate flag #m_append and the pointer #m_advVel
65 * to the block's advection velocity. AdvectionOp::SetScale, SetAppend and
66 * SetAdvVel forward to the setters here block by block; the
67 * implementations read the settings in their v_Apply().
68 *
69 * @tparam TData Floating-point type of the field data.
70 */
71template <typename TData>
73 : public ElmtBlockOp<FieldState::Phys, FieldState::Phys, TData>
74{
75public:
76 /**
77 * @brief Create one advection block operator through the
78 * block-operator factory.
79 *
80 * The factory key is #name + @p execStr + @p implStr; see
81 * ElmtBlockOp::Create for the lookup and fall-back rules.
82 *
83 * @param block_idx Index of the block within the expansion
84 * list's Collections.
85 * @param exp Representative expansion of the block.
86 * @param dataWarehouse Data warehouse shared with the other
87 * operators on the expansion list.
88 * @param execStr Execution-space part of the key.
89 * @param implStr Implementation part of the key.
90 *
91 * @return The newly created block operator.
92 */
93 static std::shared_ptr<AdvectionBlockOp<TData>> Create(
94 const unsigned int block_idx,
97 const std::string &execStr, const std::string &implStr)
98 {
100 template Create<AdvectionBlockOp>(block_idx, exp, dataWarehouse,
101 execStr, implStr);
102 }
103
104 /// Block-operator base name used in the factory key.
105 static inline const std::string name = "BlockAdvection";
106
107 /// @brief Set the scalar factor applied to the advection term.
108 void SetScale(const TData &scale)
109 {
110 m_scale = scale;
111 }
112
113 /// @brief Accumulate onto (true) or overwrite (false) the output.
114 void SetAppend(const bool &append)
115 {
116 this->m_append = append;
117 }
118
119 /**
120 * @brief Register the block's advection velocity.
121 *
122 * Stores a non-owning pointer to @p Vel, so the accessor must outlive
123 * the operator. The implementations reshape its storage in place to
124 * their interleave width when Apply() first finds it at another
125 * width.
126 *
127 * @param Vel Velocity block accessor with one component per
128 * coordinate dimension (three on 3DH1, the last
129 * unused here).
130 */
135
136protected:
137 /// Scalar factor applied to the advection term (default 1).
138 TData m_scale = 1.0;
139 /// If true, Apply() accumulates onto the output block.
140 bool m_append = false;
141 /// Advection velocity of the block, registered by SetAdvVel(); not
142 /// owned.
144
145 /**
146 * @brief Construct the interface part of a concrete block operator;
147 * called by the factory-registered creator functions.
148 *
149 * @param block_idx Index of the block within the expansion
150 * list's Collections.
151 * @param exp Representative expansion of the block.
152 * @param dataWarehouse Data warehouse shared with the other
153 * operators on the expansion list.
154 */
155 AdvectionBlockOp(const unsigned int block_idx,
158 : ElmtBlockOp<FieldState::Phys, FieldState::Phys, TData>(block_idx, exp,
159 dataWarehouse)
160 {
161 }
162
163 ~AdvectionBlockOp() override = default;
164};
165
166} // namespace Nektar::MultiRegions
Block-level base class, implementation-strategy tags and device launch helpers shared by every elemen...
Get the BlockAttributes for a given field state from an ExpList. This method basically captures ident...
Definition Block.hpp:144
Base class of the per-block advection operators: evaluates scale * (V . grad u) on every element of o...
LibUtilities::BlockAccessor< TData, FieldState::Phys > * m_advVel
Advection velocity of the block, registered by SetAdvVel(); not owned.
void SetAdvVel(LibUtilities::BlockAccessor< TData, FieldState::Phys > &Vel)
Register the block's advection velocity.
TData m_scale
Scalar factor applied to the advection term (default 1).
void SetScale(const TData &scale)
Set the scalar factor applied to the advection term.
static const std::string name
Block-operator base name used in the factory key.
AdvectionBlockOp(const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse)
Construct the interface part of a concrete block operator; called by the factory-registered creator f...
static std::shared_ptr< AdvectionBlockOp< TData > > Create(const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr)
Create one advection block operator through the block-operator factory.
void SetAppend(const bool &append)
Accumulate onto (true) or overwrite (false) the output.
bool m_append
If true, Apply() accumulates onto the output block.
Base class of the per-family block operators: applies one element operation to every element of one b...
std::shared_ptr< NekDataWarehouse > NekDataWarehouseSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66
FieldState
Possible states for Field data.