Nektar++
Loading...
Searching...
No Matches
CurlCurlOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: CurlCurlOp.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:
32//
33///////////////////////////////////////////////////////////////////////////////
34
35/**
36 * @file CurlCurlOp.hpp
37 * @brief Whole-field interface of the curl-curl element operator, which
38 * evaluates curl(curl u) at the quadrature points.
39 *
40 * @details
41 * CurlCurl is a physical-space to physical-space element operator: it maps
42 * a vector field given by its values at the quadrature points to the
43 * values of curl(curl u) at the same points, element by element, by
44 * differentiating the elemental interpolant twice. It is the strong,
45 * collocation form of the operator; no integration against test functions
46 * is involved.
47 *
48 * CurlCurlOp is the whole-field interface class of the family (see
49 * ElmtOp.hpp for the two-level element-operator structure); the per-block
50 * interface is CurlCurlBlockOp (CurlCurlBlockOp.hpp). The numerical work
51 * lives in the detail::CurlCurlBlockOpImpl definitions --
52 * CurlCurlBlockOpSerialAVXStdMat.hpp and CurlCurlBlockOpSerialAVXSumFac.hpp for
53 * the Serial and AVX execution spaces, CurlCurlBlockOpDeviceStdMat.hpp and
54 * CurlCurlBlockOpDeviceSumFac.hpp for the Device execution space -- registered
55 * with the block-operator factory by CMake-generated translation units.
56 * On a multi-plane 3DH1 expansion the block operators take only the plane
57 * part of one curl, and detail::CurlCurlOpImpl (CurlCurlOpImpl.hpp)
58 * completes the double curl through v_ApplyFFT().
59 */
60
61#pragma once
62
64
66
68{
69
70/**
71 * @brief Whole-field interface of the curl-curl element operator: replaces
72 * the quadrature-point values of a vector field u by those of
73 * curl(curl u), element by element.
74 *
75 * @details
76 * Writing the input components as (u0, u1, u2) along the Cartesian
77 * directions (x0, x1, x2):
78 * - In three dimensions the vorticity w = curl u is formed first,
79 * w0 = d(u2)/dx1 - d(u1)/dx2,
80 * w1 = d(u0)/dx2 - d(u2)/dx0,
81 * w2 = d(u1)/dx0 - d(u0)/dx1,
82 * and the output is q = curl w by the same formulae.
83 * - In two dimensions the field is treated as (u0, u1, 0), whose curl has
84 * the single out-of-plane component
85 * w = d(u1)/dx0 - d(u0)/dx1,
86 * and the output is the in-plane vector
87 * q = ( d(w)/dx1, -d(w)/dx0 ).
88 * Every output component therefore couples all input components. All
89 * derivatives are collocation derivatives of the elemental interpolant,
90 * formed with the same standard-region derivative matrices, or
91 * one-dimensional derivative matrices and sum factorisation, as
92 * PhysDeriv.
93 *
94 * The operator is defined for two- and three-dimensional expansions whose
95 * coordinate dimension equals the shape dimension (both asserted by the
96 * block-implementation constructors); embedded manifolds are not
97 * supported. The input field must carry at least as many components as
98 * the shape dimension: the block implementations read the first two (2D)
99 * or three (3D) and write the same number of output components. A
100 * multi-plane 3DH1 field must carry exactly three components (asserted).
101 *
102 * As with the other element-operator families, this class sets the
103 * Apply() field states at compile time -- physical space in and out --
104 * and drives one CurlCurlBlockOp per element block, followed by
105 * v_ApplyFFT(). On a multi-plane 3DH1 field each block operator forms
106 * only the plane part of one curl, and detail::CurlCurlOpImpl adds the
107 * z parts and runs the block operators again for the second curl;
108 * everywhere else the block operators take both curls and v_ApplyFFT()
109 * does nothing. See ElmtOp for the block decomposition and factory
110 * scheme.
111 *
112 * @tparam TData Floating-point type of the field data.
113 */
114template <typename TData>
115class CurlCurlOp : public ElmtOp<FieldState::Phys, FieldState::Phys, TData>
116{
117 friend class ElmtOp<FieldState::Phys, FieldState::Phys, TData>;
118
119public:
120 /**
121 * @brief Build a complete curl-curl operator through the operator and
122 * block-operator factories.
123 *
124 * See ElmtOp::Create for the two-stage construction and the
125 * execution-space/implementation lookup rules.
126 *
127 * @param expansionList Expansion list the operator acts on.
128 * @param components Names of the field components.
129 * @param execStr Execution space ("Serial", "AVX" or
130 * "Device"); the session's setting is used
131 * if empty.
132 * @param implStr Implementation ("StdMat", "SumFac" or, on
133 * Device, "SumFacTOP"); the session's
134 * setting is used if empty.
135 *
136 * @return The fully assembled operator, ready to Apply().
137 */
138 static std::shared_ptr<CurlCurlOp<TData>> Create(
139 const MultiRegions::ExpListSharedPtr &expansionList,
140 const std::vector<std::string> &components,
141 const std::string &execStr = "", const std::string &implStr = "")
142 {
144 template Create<CurlCurlOp, CurlCurlBlockOp>(
145 expansionList, components, execStr, implStr);
146 }
147
148 /// Operator base name; Create() appends the execution space to it
149 /// to form the operator-factory key.
150 static inline const std::string name = "CurlCurl";
151
152protected:
153 /// One block operator per element block, filled by Create().
154 std::vector<std::shared_ptr<CurlCurlBlockOp<TData>>> m_blockOp;
155
156 /**
157 * @brief Construct the interface part of a concrete operator; called
158 * by the factory-registered creator functions.
159 *
160 * @param expansionList Expansion list the operator acts on.
161 * @param components Component names the operator is set up
162 * for.
163 */
165 const std::vector<std::string> &components)
166 : ElmtOp<FieldState::Phys, FieldState::Phys, TData>(expansionList,
167 components)
168 {
169 }
170
171 ~CurlCurlOp() override = default;
172
173 /**
174 * @brief Apply the curl-curl operator block by block.
175 *
176 * Checks that the two fields agree in their number of homogeneous
177 * modes, hands each input/output block pair to the corresponding
178 * entry of #m_blockOp, then calls v_ApplyFFT().
179 *
180 * @param in Physical-space input field holding the components
181 * of u.
182 * @param out Physical-space output field receiving the
183 * components of curl(curl u).
184 */
187 {
188 ASSERTL1(in.GetNumHomoModes() == out.GetNumHomoModes(),
189 "Number of input and output homogeneous modes differ");
190
191 // Loop over the blocks.
192 for (unsigned int blk = 0; blk < this->m_blockOp.size(); ++blk)
193 {
194 // Block dependent.
195 auto &inblock = in.GetBlocks()[blk];
196 auto &outblock = out.GetBlocks()[blk];
197
198 this->m_blockOp[blk]->Apply(inblock, outblock);
199 }
200
201 // Apply FFT.
202 v_ApplyFFT(in, out);
203 }
204
205 /// Complete the double curl of a multi-plane 3DH1 field, of which the
206 /// block operators have left the plane part of the first curl in
207 /// @p out; does nothing on any other expansion.
208 virtual void v_ApplyFFT(
211};
212
213} // namespace Nektar::MultiRegions
Per-block interface of the curl-curl element operator.
Whole-field base class and factory machinery shared by every element-operator family in the MultiRegi...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
A Field represents expansion data to be operated on.
Whole-field interface of the curl-curl element operator: replaces the quadrature-point values of a ve...
static const std::string name
Operator base name; Create() appends the execution space to it to form the operator-factory key.
std::vector< std::shared_ptr< CurlCurlBlockOp< TData > > > m_blockOp
One block operator per element block, filled by Create().
~CurlCurlOp() override=default
void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out) override
Apply the curl-curl operator block by block.
CurlCurlOp(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
Construct the interface part of a concrete operator; called by the factory-registered creator functio...
static std::shared_ptr< CurlCurlOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Build a complete curl-curl operator through the operator and block-operator factories.
virtual void v_ApplyFFT(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)=0
Complete the double curl of a multi-plane 3DH1 field, of which the block operators have left the plan...
Common base class of the element-operator interfaces: an operator applied independently to every elem...
Definition ElmtOp.hpp:111
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
FieldState
Possible states for Field data.