Nektar++
Loading...
Searching...
No Matches
MassBlockOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MassBlockOp.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 Mass element operator.
32///////////////////////////////////////////////////////////////////////////////
33
34/**
35 * @file MassBlockOp.hpp
36 * @brief Per-block interface of the Mass element operator.
37 *
38 * @details
39 * A MassBlockOp applies the element mass matrix to every element of one
40 * block (see ElmtBlockOp.hpp for the block scheme and MassOp.hpp for the
41 * mathematical action). It carries the family-specific state the
42 * whole-field MassOp forwards to every block -- the scale factor and the
43 * append flag. The
44 * per-implementation subclasses are the detail::MassBlockOpImpl definitions
45 * in Mass{SerialAVX,Device}{StdMat,SumFac}.hpp.
46 */
47
48#pragma once
49
51
53{
54
55/**
56 * @brief Base class of the per-block mass operators: applies the element
57 * mass matrix to every element of one block, coefficient space to
58 * coefficient space.
59 *
60 * @details
61 * Sets the block states accepted by Apply() at compile time -- coefficient
62 * space in and out -- and stores the two settings shared by every
63 * implementation: the scale factor #m_scale and the append flag
64 * #m_append. MassOp::SetScale and SetAppend forward to the setters here
65 * block by block; the implementations read the settings in their
66 * v_Apply(). The concrete implementations are the detail::MassBlockOpImpl
67 * definitions listed in MassOp.hpp.
68 *
69 * CMake generates one registration translation unit per execution space,
70 * implementation and data type (from ElmtOps/ElmtBlockOpFactoryDec.cpp.in)
71 * that includes exactly one detail::MassBlockOpImpl header and registers it
72 * under the matching execution-space/implementation key.
73 *
74 * @tparam TData Floating-point type of the field data.
75 */
76template <typename TData>
78 : public ElmtBlockOp<FieldState::Coeff, FieldState::Coeff, TData>
79{
80public:
81 /**
82 * @brief Create one Mass block operator through the block-operator
83 * factory.
84 *
85 * The factory key is #name + @p execStr + @p implStr; see
86 * ElmtBlockOp::Create for the lookup and fall-back rules.
87 *
88 * @param block_idx Index of the block within the expansion
89 * list's Collections.
90 * @param exp Representative expansion of the block.
91 * @param dataWarehouse Data warehouse shared with the other
92 * operators on the expansion list.
93 * @param execStr Execution-space part of the key.
94 * @param implStr Implementation part of the key.
95 *
96 * @return The newly created block operator.
97 */
98 static std::shared_ptr<MassBlockOp<TData>> Create(
99 const unsigned int block_idx,
102 const std::string &execStr, const std::string &implStr)
103 {
105 TData>::template Create<MassBlockOp>(block_idx, exp,
106 dataWarehouse,
107 execStr,
108 implStr);
109 }
110
111 /// Block-operator base name; Create() appends the execution space and
112 /// implementation to it to form the factory key.
113 static inline const std::string name = "BlockMass";
114
115 /// @brief Set overwrite (false, the default) or accumulate (true)
116 /// mode for subsequent Apply() calls; see MassOp::SetAppend().
117 void SetAppend(const bool &append)
118 {
119 m_append = append;
120 }
121
122 /// @brief Set the scalar factor applied to the result; see
123 /// MassOp::SetScale.
124 void SetScale(const TData &scale)
125 {
126 m_scale = scale;
127 }
128
129protected:
130 /// Scalar factor applied to the result (default 1).
131 TData m_scale = 1.0;
132 /// When true, Apply() adds the scaled result onto the output block's
133 /// existing values instead of overwriting them.
134 bool m_append = false;
135
136 /**
137 * @brief Construct the interface part of a concrete block operator;
138 * called by the factory-registered creator functions.
139 *
140 * @param block_idx Index of the block within the expansion
141 * list's Collections.
142 * @param exp Representative expansion of the block.
143 * @param dataWarehouse Data warehouse shared with the other
144 * operators on the expansion list.
145 */
146 MassBlockOp(const unsigned int block_idx,
150 block_idx, exp, dataWarehouse)
151 {
152 }
153
154 ~MassBlockOp() override = default;
155};
156
157} // namespace Nektar::MultiRegions
Block-level base class, implementation-strategy tags and device launch helpers shared by every elemen...
Base class of the per-family block operators: applies one element operation to every element of one b...
Base class of the per-block mass operators: applies the element mass matrix to every element of one b...
void SetScale(const TData &scale)
Set the scalar factor applied to the result; see MassOp::SetScale.
MassBlockOp(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< MassBlockOp< TData > > Create(const unsigned int block_idx, const LocalRegions::ExpansionSharedPtr &exp, LibUtilities::NekDataWarehouseSharedPtr dataWarehouse, const std::string &execStr, const std::string &implStr)
Create one Mass block operator through the block-operator factory.
TData m_scale
Scalar factor applied to the result (default 1).
static const std::string name
Block-operator base name; Create() appends the execution space and implementation to it to form the f...
void SetAppend(const bool &append)
Set overwrite (false, the default) or accumulate (true) mode for subsequent Apply() calls; see MassOp...
bool m_append
When true, Apply() adds the scaled result onto the output block's existing values instead of overwrit...
std::shared_ptr< NekDataWarehouse > NekDataWarehouseSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66
FieldState
Possible states for Field data.