Nektar++
Loading...
Searching...
No Matches
PhysTraceExtractBndCond.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: PhysTraceExtractBndCond.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: Extraction of a volume field onto the points of a named
32// boundary region of a continuous field, built on PhysTraceExtractOp, for the
33// boundary conditions that need volume data on their points.
34//
35///////////////////////////////////////////////////////////////////////////////
36
37#pragma once
38
41
44
45#include <map>
46#include <set>
47#include <tuple>
48#include <utility>
49#include <vector>
50
52{
53
54/**
55 * @brief Extracts a volume field onto the points of a boundary region of a
56 * continuous field.
57 *
58 * @details
59 * PhysTraceExtractOp::ExtractTrace() extracts one local trace for every
60 * element of a block. A boundary region instead touches a subset of the
61 * elements, through different local traces and orientations. At
62 * construction this class
63 * - matches every element of the boundary expansion list to the volume
64 * element owning it, by geometry id: both lists come from one mesh graph;
65 * - sorts the matched elements into buckets of one shape, order, local
66 * trace, boundary block and volume block, and builds for every bucket a
67 * volume expansion list restricted to its elements, with its own
68 * PhysTraceExtractOp;
69 * - extracts onto the Gauss-Lobatto trace points where the boundary
70 * expansion carries them, on the collapsed direction of a face of a
71 * tetrahedron, prism or pyramid (see
72 * PhysTraceExtractOp::SetUseGLLTracePoints());
73 * - builds for every bucket the map from its extracted trace points to the
74 * boundary region's points, which reorients every face or edge.
75 *
76 * Apply() then gathers every bucket's elements from the volume field,
77 * extracts their trace and scatters it onto the boundary field.
78 *
79 * All work runs on stream #m_opStreamID, the stream of the first block of
80 * every bucket's PhysTraceExtractOp. Apply() does not synchronise the host:
81 * it orders that stream after the work queued on the streams of the volume
82 * and boundary blocks it reads and writes, and those streams after its own
83 * work, with events.
84 *
85 * @tparam ExecSpace Execution space of the kernels.
86 * @tparam TData Floating-point type of the field data.
87 */
88template <typename ExecSpace, typename TData> class PhysTraceExtractBndCond
89{
90public:
91 /**
92 * @param volumeExpList Expansion list of the volume field.
93 * @param components Variables of the field.
94 * @param bcExpList Expansion list of the boundary region.
95 * @param execStr Execution space of the PhysTraceExtractOps.
96 * @param graph Mesh graph holding the expansions of the volume
97 * elements. Defaults to that of @p volumeExpList,
98 * which an expansion list built from an
99 * ExpansionInfoMap does not have.
100 */
102 const MultiRegions::ExpListSharedPtr &volumeExpList,
103 const std::vector<std::string> &components,
104 const MultiRegions::ExpListSharedPtr &bcExpList,
105 const std::string &execStr = "",
107
108 /**
109 * @brief Extract the first components of @p in, as many as @p out has,
110 * onto @p out.
111 *
112 * @details
113 * Work queued on the stream of a block of @p in or @p out before the
114 * call runs before the extraction, and work queued on it after the call
115 * runs after the extraction, without the host waiting on either.
116 *
117 * @param in Volume field, laid out as
118 * MultiRegions::GetBlockAttributes(volumeExpList), with at
119 * least as many components as @p out.
120 * @param out Boundary field, laid out as
121 * MultiRegions::GetBlockAttributes(bcExpList), with at most
122 * as many components as the extraction was built for.
123 */
126
127protected:
128 using MemSpace = typename ExecSpace::memory_space;
129
130 /// Point of #Bucket::tracePhys and of the boundary block of every point
131 /// a bucket scatters.
137
138 /// Elements of one shape, order, local trace, boundary block and volume
139 /// block, with the operator and storage to extract their trace.
140 struct Bucket
141 {
142 std::shared_ptr<PhysTraceExtractOp<TData>> op;
143 unsigned int traceId = 0;
144 /// Block of the volume field the bucket gathers from.
145 unsigned int volumeBlock = 0;
146 /// Block of the boundary field the bucket scatters into.
147 unsigned int bcBlock = 0;
148 size_t nElmts = 0;
149 /// Number of trace points of one element.
150 size_t nDst = 0;
151 /// Number of volume points of one element.
152 size_t nVolume = 0;
153 /// Element of the volume block at every position of #volumePhys.
154 std::vector<size_t> volumeElmt;
155 /// Point of the boundary block of trace point q of position p, at
156 /// p * #nDst + q.
157 std::vector<size_t> boundaryPoint;
158 /// Point of the volume block of every point of #volumePhys, both
159 /// at the interleave width of the volume block, by that width, built
160 /// when a width is first seen and kept.
161 std::map<unsigned int, LibUtilities::MemoryRegion<size_t>> gatherIndex;
162 /// The points of #tracePhys, at the interleave width of the volume
163 /// block, and of the boundary block of every point scattered, by that
164 /// width, built when a width is first seen and kept.
165 std::map<unsigned int, ScatterIndices> scatterIndex;
166 /// The bucket's elements, laid out as the single block of the
167 /// restricted expansion list of #op at the interleave width of the
168 /// volume block, and their extracted trace.
171
177 };
178
179 /// Stream of the first block of every bucket's PhysTraceExtractOp, on
180 /// which all the work runs.
181 static constexpr unsigned int m_opStreamID = 1;
182
183 std::vector<Bucket> m_buckets;
184 /// Streams of the volume and boundary blocks Apply() reads and writes,
185 /// one per block index: block @em b runs on stream @em b + 1.
186 std::vector<unsigned int> m_blockStreams;
187
188 /// Add to @p bucket.gatherIndex the index for a volume block at
189 /// interleave width @p width.
190 static void BuildGatherIndex(Bucket &bucket, const unsigned int width);
191
192 /// Add to @p bucket.scatterIndex the indices for a trace block at
193 /// interleave width @p width.
194 static void BuildScatterIndex(Bucket &bucket, const unsigned int width);
195};
196
197template <typename ExecSpace, typename TData>
199 const MultiRegions::ExpListSharedPtr &volumeExpList,
200 const std::vector<std::string> &components,
201 const MultiRegions::ExpListSharedPtr &bcExpList, const std::string &execStr,
203{
204 // The volume element owning every trace, by trace geometry id.
205 struct VolumeFace
206 {
207 unsigned int block = 0;
208 size_t elmt = 0;
209 unsigned int trace = 0;
211 };
212 std::map<int, VolumeFace> faceOwner;
213
214 const auto volumeBlocks =
215 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
216 volumeExpList, MultiRegions::UnitInterleaveWidths(volumeExpList));
217 for (unsigned int blk = 0; blk < volumeBlocks.size(); ++blk)
218 {
219 auto collection = MultiRegions::GetCollection(volumeExpList, blk);
220 const auto &expansions = collection.GetExpVector();
221 for (unsigned int e = 0; e < expansions.size(); ++e)
222 {
223 for (unsigned int t = 0; t < expansions[e]->GetNtraces(); ++t)
224 {
225 faceOwner[expansions[e]->GetGeom()->GetTid(t)] = {
226 blk, e, t, expansions[e]};
227 }
228 }
229 }
230
231 // (shape, local trace, modes in the three directions, boundary block,
232 // volume block).
233 using BucketKey =
234 std::tuple<LibUtilities::ShapeType, unsigned int, unsigned int,
235 unsigned int, unsigned int, unsigned int, unsigned int>;
236 // One boundary element and the volume element owning it.
237 struct MatchedFace
238 {
239 unsigned int ownerBlock = 0;
240 size_t ownerElmt = 0;
241 int ownerGeomId = -1;
242 size_t bcElmtFlat = 0;
243 /// Boundary point of every extracted trace point.
244 std::vector<int> idmap;
245 };
246 struct BucketBuild
247 {
248 std::vector<MatchedFace> faces;
249 unsigned int traceId = 0;
250 unsigned int volumeBlock = 0;
251 unsigned int bcBlock = 0;
252 size_t nDst = 0;
253 bool useGLL = false;
254 };
255 std::map<BucketKey, BucketBuild> bucketBuild;
256
257 const auto bcBlocks =
258 bcExpList->GetNumElmts() == 0
259 ? std::vector<LibUtilities::BlockAttributes<FieldState::Phys>>{}
260 : MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
261 bcExpList, MultiRegions::UnitInterleaveWidths(bcExpList));
262 for (unsigned int blk = 0; blk < bcBlocks.size(); ++blk)
263 {
264 auto collection = MultiRegions::GetCollection(bcExpList, blk);
265 const auto &expansions = collection.GetExpVector();
266 for (unsigned int e = 0; e < expansions.size(); ++e)
267 {
268 const auto bcElmt = expansions[e];
269 const auto ownerIt =
270 faceOwner.find(bcElmt->GetGeom()->GetGlobalID());
271 if (ownerIt == faceOwner.end())
272 {
273 continue;
274 }
275 const auto &owner = ownerIt->second;
276 const auto orient = owner.expansion->GetTraceOrient(owner.trace);
277
278 // The boundary element carries Gauss-Lobatto points in every
279 // direction. The owner's own trace points, which
280 // GetLocTraceBlockAttributes() sizes the extraction for, are
281 // Gauss-Radau on a collapsed direction, so there the
282 // Gauss-Lobatto variant is extracted instead. The points are
283 // then the boundary element's, and only their order differs:
284 // a face is transposed or flipped as in
285 // Expansion3D::v_GetTracePhysVals(), an edge is reversed.
286 size_t nDst;
287 std::vector<int> idmap;
288 bool useGLL;
289 if (bcElmt->GetNumBases() > 1)
290 {
291 int id0 = 0, id1 = 1;
293 {
294 id0 = 1;
295 id1 = 0;
296 }
297 const int nq0 = bcElmt->GetNumPoints(id0);
298 const int nq1 = bcElmt->GetNumPoints(id1);
299 nDst = static_cast<size_t>(nq0) * static_cast<size_t>(nq1);
300
301 const int ownerNq0 =
302 owner.expansion->GetTraceBasisKey(owner.trace, 0)
303 .GetNumPoints();
304 const int ownerNq1 =
305 owner.expansion->GetTraceBasisKey(owner.trace, 1)
306 .GetNumPoints();
307 useGLL = ownerNq0 != nq0 || ownerNq1 != nq1;
308
309 // The backward map, local[q] = global[map[q]], gives the
310 // boundary point of every extracted point. The forward map
311 // is its inverse, which differs for a face rotated by 90
312 // degrees and for a transposed face with nq0 != nq1.
314 owner.expansion->ReOrientTracePhysMap(orient, map, nq0, nq1,
315 false);
316 idmap.assign(&map[0], &map[0] + nDst);
317 }
318 else
319 {
320 const int nq0 = bcElmt->GetNumPoints(0);
321 nDst = static_cast<size_t>(nq0);
322 useGLL = owner.expansion->GetTraceBasisKey(owner.trace)
323 .GetNumPoints() != nq0;
324
325 idmap.resize(nDst);
326 for (size_t q = 0; q < nDst; ++q)
327 {
328 idmap[q] = static_cast<int>(
329 orient == StdRegions::eBackwards ? nDst - 1 - q : q);
330 }
331 }
332
333 const unsigned int nm0 = owner.expansion->GetBasisNumModes(0);
334 const unsigned int nm1 = owner.expansion->GetNumBases() > 1
335 ? owner.expansion->GetBasisNumModes(1)
336 : 0;
337 const unsigned int nm2 = owner.expansion->GetNumBases() > 2
338 ? owner.expansion->GetBasisNumModes(2)
339 : 0;
340 BucketKey key{owner.expansion->DetShapeType(),
341 owner.trace,
342 nm0,
343 nm1,
344 nm2,
345 blk,
346 owner.block};
347 auto &build = bucketBuild[key];
348 build.traceId = owner.trace;
349 build.volumeBlock = owner.block;
350 build.bcBlock = blk;
351 build.nDst = nDst;
352 // The key fixes the shape, order and trace, and with them
353 // whether the Gauss-Lobatto variant is needed.
354 ASSERTL1(build.faces.empty() || build.useGLL == useGLL,
355 "Elements of one bucket disagree on the trace points "
356 "to extract onto.");
357 build.useGLL = useGLL;
358
359 MatchedFace face;
360 face.ownerBlock = owner.block;
361 face.ownerElmt = owner.elmt;
362 face.ownerGeomId = owner.expansion->GetGeom()->GetGlobalID();
363 face.bcElmtFlat = e;
364 face.idmap = std::move(idmap);
365 build.faces.push_back(std::move(face));
366 }
367 }
368
369 m_buckets.reserve(bucketBuild.size());
370 const auto meshGraph = graph ? graph : volumeExpList->GetGraph();
371 ASSERTL0(meshGraph, "PhysTraceExtractBndCond needs a mesh graph: pass "
372 "one when volumeExpList has none.");
373 const auto &volumeExpansionInfo =
374 meshGraph->GetExpansionInfo(components[0]);
375 // Each bucket's storage is one block, built as Field builds its blocks
376 // but belonging to no Field: its owner is null, and its memory region
377 // allocates its own storage on first use (see BlockAccessor::GetPtr()).
378 const unsigned int nComp = components.size();
379 const auto makeBlock =
380 [nComp](const std::string &name,
383 attr,
385 name, attr.CompSize() * nComp, eHostPageable,
387 nullptr, nComp, 1);
388 };
389 for (auto &[key, build] : bucketBuild)
390 {
391 // The volume expansion list restricted to the bucket's elements. It
392 // orders them by geometry id, not in the order they were matched.
394 for (const auto &face : build.faces)
395 {
396 const auto info = volumeExpansionInfo.find(face.ownerGeomId);
397 ASSERTL1(info != volumeExpansionInfo.end(),
398 "No expansion for a volume element of the boundary.");
399 restrictedInfo.emplace(*info);
400 }
401
402 auto restrictedExpList =
404 volumeExpList->GetSession(), restrictedInfo, false);
405 restrictedExpList->SetDataWarehouse();
406
407 const auto restrictedBlocks =
408 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
409 restrictedExpList,
410 MultiRegions::UnitInterleaveWidths(restrictedExpList));
411 // The bucket's elements come from one volume block, so they share
412 // what splits a collection (basis, deformation, MAXSIZE) and the
413 // restricted list is one block. Apply() relies on this.
414 ASSERTL0(restrictedBlocks.size() == 1,
415 "The elements of a bucket must form one block.");
416
417 // ExtractTrace() walks the element groups of the input block, which
418 // is padded to the largest vector width, so the output block is
419 // padded the same way.
420 const size_t nElmts = build.faces.size();
421 const auto vectorWidth = NektarSpaces::max_vector_width<TData>::value;
422 const size_t nElmtsWithPadding =
423 ((nElmts + vectorWidth - 1) / vectorWidth) * vectorWidth;
425 nElmts, nElmtsWithPadding, static_cast<unsigned int>(build.nDst),
426 1);
427
428 Bucket bucket(
429 makeBlock("PhysTraceExtractBndCondVolume", restrictedBlocks[0]),
430 makeBlock("PhysTraceExtractBndCondTrace", traceBlockAttr));
431 bucket.traceId = build.traceId;
432 bucket.volumeBlock = build.volumeBlock;
433 bucket.bcBlock = build.bcBlock;
434 bucket.nElmts = nElmts;
435 bucket.nDst = build.nDst;
436
437 bucket.op = PhysTraceExtractOp<TData>::Create(restrictedExpList,
438 components, execStr);
439 if (build.useGLL)
440 {
441 bucket.op->SetUseGLLTracePoints(true);
442 }
443
444 // Position of every element in the restricted expansion list.
445 std::map<int, size_t> geomIdToPos;
446 {
447 auto restrictedCollection =
448 MultiRegions::GetCollection(restrictedExpList, 0);
449 const auto &restrictedExpansions =
450 restrictedCollection.GetExpVector();
451 for (size_t p = 0; p < restrictedExpansions.size(); ++p)
452 {
453 geomIdToPos[restrictedExpansions[p]->GetGeom()->GetGlobalID()] =
454 p;
455 }
456 }
457
458 // The bucket's elements are those of one volume block, with the
459 // same points.
460 bucket.nVolume = restrictedBlocks[0].GetNumData();
461 ASSERTL1(volumeBlocks[bucket.volumeBlock].GetNumData() ==
462 bucket.nVolume,
463 "The elements of a bucket differ in their number of points "
464 "from those of their volume block.");
465
466 bucket.volumeElmt.resize(bucket.nElmts);
467 bucket.boundaryPoint.resize(bucket.nElmts * bucket.nDst);
468 for (const auto &face : build.faces)
469 {
470 const auto pos = geomIdToPos.at(face.ownerGeomId);
471 bucket.volumeElmt[pos] = face.ownerElmt;
472 for (size_t q = 0; q < bucket.nDst; ++q)
473 {
474 bucket.boundaryPoint[pos * bucket.nDst + q] =
475 face.bcElmtFlat * bucket.nDst +
476 static_cast<size_t>(face.idmap[q]);
477 }
478 }
479
480 m_buckets.push_back(std::move(bucket));
481 }
482
483 std::set<unsigned int> streamSet;
484 for (const auto &bucket : m_buckets)
485 {
486 streamSet.insert(bucket.volumeBlock + 1);
487 streamSet.insert(bucket.bcBlock + 1);
488 }
489 m_blockStreams.assign(streamSet.begin(), streamSet.end());
490}
491
492template <typename ExecSpace, typename TData>
496{
497 const unsigned int nComp = out.GetNumComponents();
498 ASSERTL0(in.GetNumHomoModes() == 1,
499 "PhysTraceExtractBndCond does not support homogeneous fields.");
500 ASSERTL0(in.GetNumComponents() >= nComp &&
501 (m_buckets.empty() ||
502 m_buckets[0].volumePhys.GetNumComponents() >= nComp),
503 "PhysTraceExtractBndCond: the input field must have at least "
504 "as many components as the output field, which has at most the "
505 "number it was built for.");
506
507 // Order #m_opStreamID after the work already queued on the streams of the
508 // blocks read and written, on the device rather than on the host.
509 JoinStreams<ExecSpace>(m_opStreamID, m_blockStreams);
510
511 for (auto &bucket : m_buckets)
512 {
513 // Every kernel below indexes only into the block whose pointer it
514 // takes: one block of in and out, volumePhys or tracePhys.
515 auto &srcBlock = in.GetBlocks()[bucket.volumeBlock];
516 // The interleave width of the input is known only here. The bucket's
517 // storage takes it, so that the gather reads and writes along element
518 // lanes and ExtractTrace() reshapes only where its own width differs.
519 // An index is built for every width seen and kept, so that none is
520 // overwritten while a kernel of an earlier call may still read it.
521 const unsigned int width = srcBlock.GetInterleaveWidth();
522 if (bucket.gatherIndex.count(width) == 0)
523 {
524 BuildGatherIndex(bucket, width);
525 BuildScatterIndex(bucket, width);
526 }
527 bucket.volumePhys.template SetInterleaveWidth<TData>(width);
528 bucket.tracePhys.template SetInterleaveWidth<TData>(width);
529
530 auto srcPtr =
531 srcBlock.template GetPtr<MemSpace, ReadOnly>(m_opStreamID);
532 auto volumePtr = bucket.volumePhys.template GetPtr<MemSpace, WriteOnly>(
533 m_opStreamID);
534 auto &gatherIndex = bucket.gatherIndex.at(width);
535 auto gatherIdx =
536 gatherIndex.template GetPtr<MemSpace, ReadOnly>(m_opStreamID);
537
538 for (unsigned int comp = 0; comp < nComp; ++comp)
539 {
540 CGBndCondGatherKernel<ExecSpace>(
541 gatherIndex.size(), gatherIdx,
542 srcPtr + comp * srcBlock.CompSize(),
543 volumePtr + comp * bucket.volumePhys.CompSize(), m_opStreamID);
544 }
545
546 // Block 0 of the operator is the restricted list's only block.
547 bucket.op->ExtractTrace(bucket.traceId, bucket.volumePhys,
548 bucket.tracePhys, 0, 0);
549
550 auto &outBlock = out.GetBlocks()[bucket.bcBlock];
551 // The scatter index addresses the boundary block at width 1.
552 ASSERTL0(outBlock.GetInterleaveWidth() == 1,
553 "PhysTraceExtractBndCond writes a boundary field at "
554 "interleave width 1 only.");
555 auto outPtr =
556 outBlock.template GetPtr<MemSpace, WriteOnly>(m_opStreamID);
557 auto tracePtr =
558 bucket.tracePhys.template GetPtr<MemSpace, ReadOnly>(m_opStreamID);
559 auto &scatterIndex = bucket.scatterIndex.at(width);
560 auto traceIdx = scatterIndex.trace.template GetPtr<MemSpace, ReadOnly>(
561 m_opStreamID);
562 auto boundaryIdx =
563 scatterIndex.boundary.template GetPtr<MemSpace, ReadOnly>(
564 m_opStreamID);
565
566 for (unsigned int comp = 0; comp < nComp; ++comp)
567 {
568 CGBndCondGatherScatterKernel<ExecSpace>(
569 scatterIndex.trace.size(), traceIdx, boundaryIdx,
570 tracePtr + comp * bucket.tracePhys.CompSize(),
571 outPtr + comp * outBlock.CompSize(), m_opStreamID);
572 }
573 }
574
575 // Order the work queued next on the streams of the blocks read and
576 // written after the extraction.
577 ReleaseStreams<ExecSpace>(m_opStreamID, m_blockStreams);
578}
579
580template <typename ExecSpace, typename TData>
582 Bucket &bucket, const unsigned int width)
583{
584 // Point q of element e lies at (e / width) * width * nVolume + q * width
585 // + e % width of a block at interleave width @p width. The index runs
586 // over the element groups of #volumePhys in its own order, lane fastest,
587 // so that consecutive threads write consecutive points. A padding lane
588 // of the last group reads the group's first element.
589 const size_t nVolume = bucket.nVolume;
590 const size_t nGroups = (bucket.nElmts + width - 1) / width;
591 std::vector<size_t> gatherIndex;
592 gatherIndex.reserve(nGroups * width * nVolume);
593 for (size_t group = 0; group < nGroups; ++group)
594 {
595 for (size_t q = 0; q < nVolume; ++q)
596 {
597 for (size_t lane = 0; lane < width; ++lane)
598 {
599 const size_t pos = group * width + lane < bucket.nElmts
600 ? group * width + lane
601 : group * width;
602 const size_t elmt = bucket.volumeElmt[pos];
603 gatherIndex.push_back((elmt / width) * width * nVolume +
604 q * width + elmt % width);
605 }
606 }
607 }
608 bucket.gatherIndex.emplace(
610 size_t>(
611 gatherIndex));
612}
613
614template <typename ExecSpace, typename TData>
616 Bucket &bucket, const unsigned int width)
617{
618 // Trace point q of position p lies at (p / width) * width * nDst
619 // + q * width + p % width of #tracePhys at interleave width @p width.
620 // The indices run over its element groups in its own order, lane
621 // fastest, so that consecutive threads read consecutive points, and skip
622 // the padding lanes of the last group.
623 const size_t nDst = bucket.nDst;
624 const size_t nGroups = (bucket.nElmts + width - 1) / width;
625 std::vector<size_t> traceIndex, boundaryIndex;
626 traceIndex.reserve(bucket.nElmts * nDst);
627 boundaryIndex.reserve(bucket.nElmts * nDst);
628 for (size_t group = 0; group < nGroups; ++group)
629 {
630 for (size_t q = 0; q < nDst; ++q)
631 {
632 for (size_t lane = 0;
633 lane < width && group * width + lane < bucket.nElmts; ++lane)
634 {
635 const size_t pos = group * width + lane;
636 traceIndex.push_back(group * width * nDst + q * width + lane);
637 boundaryIndex.push_back(bucket.boundaryPoint[pos * nDst + q]);
638 }
639 }
640 }
641 ScatterIndices indices;
643 MemSpace, size_t>(traceIndex);
645 MemSpace, size_t>(boundaryIndex);
646 bucket.scatterIndex.emplace(width, std::move(indices));
647}
648
649} // namespace Nektar::MultiRegions::detail
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Public interface of the PhysTraceExtract element operator, which interpolates a volume physical-space...
SpatialDomains::MeshGraphSharedPtr graph
Get the BlockAttributes for a given field state from an ExpList. This method basically captures ident...
Definition Block.hpp:144
A block means a group of elements of identical shape, basis and order. BlockAttributes stores the mos...
Definition Block.hpp:50
A Field represents expansion data to be operated on.
A MemoryRegion represents a memory region.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static std::shared_ptr< PhysTraceExtractOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create a trace extraction operator through the operator and block-operator factories.
Extracts a volume field onto the points of a boundary region of a continuous field.
std::vector< unsigned int > m_blockStreams
Streams of the volume and boundary blocks Apply() reads and writes, one per block index: block b runs...
static void BuildScatterIndex(Bucket &bucket, const unsigned int width)
Add to bucket.scatterIndex the indices for a trace block at interleave width width.
void Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)
Extract the first components of in, as many as out has, onto out.
static constexpr unsigned int m_opStreamID
Stream of the first block of every bucket's PhysTraceExtractOp, on which all the work runs.
static void BuildGatherIndex(Bucket &bucket, const unsigned int width)
Add to bucket.gatherIndex the index for a volume block at interleave width width.
PhysTraceExtractBndCond(const MultiRegions::ExpListSharedPtr &volumeExpList, const std::vector< std::string > &components, const MultiRegions::ExpListSharedPtr &bcExpList, const std::string &execStr="", const SpatialDomains::MeshGraphSharedPtr &graph=nullptr)
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT in
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT const TData *NEK_RESTRICT TData *NEK_RESTRICT out
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Collections::Collection GetCollection(MultiRegions::ExpListSharedPtr expansionList, unsigned int block_idx)
static constexpr size_t host_memory_alignment
Definition Backends.hpp:178
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:287
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
Definition MeshGraph.h:160
@ eHostPageable
STL namespace.
Elements of one shape, order, local trace, boundary block and volume block, with the operator and sto...
std::map< unsigned int, LibUtilities::MemoryRegion< size_t > > gatherIndex
Point of the volume block of every point of volumePhys, both at the interleave width of the volume bl...
std::vector< size_t > boundaryPoint
Point of the boundary block of trace point q of position p, at p * nDst + q.
unsigned int volumeBlock
Block of the volume field the bucket gathers from.
LibUtilities::BlockAccessor< TData, FieldState::Phys > tracePhys
unsigned int bcBlock
Block of the boundary field the bucket scatters into.
std::map< unsigned int, ScatterIndices > scatterIndex
The points of tracePhys, at the interleave width of the volume block, and of the boundary block of ev...
Bucket(LibUtilities::BlockAccessor< TData, FieldState::Phys > &&volume, LibUtilities::BlockAccessor< TData, FieldState::Phys > &&trace)
LibUtilities::BlockAccessor< TData, FieldState::Phys > volumePhys
The bucket's elements, laid out as the single block of the restricted expansion list of op at the int...
std::vector< size_t > volumeElmt
Element of the volume block at every position of volumePhys.
Point of Bucket::tracePhys and of the boundary block of every point a bucket scatters.