Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Types | List of all members
Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData > Class Template Reference

Advective trace flux for scalar transport, evaluated with a pluggable Riemann solver. More...

#include <ScalarTraceFluxOpImpl.hpp>

Inheritance diagram for Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >:
[legend]

Public Member Functions

 ScalarTraceFluxOpImpl (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
 Construct the operator and size its advection-velocity storage.
 

Static Public Member Functions

static std::unique_ptr< MultiRegions::Operator< TData > > Instantiate (const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
 Factory creator function.
 

Static Public Attributes

static std::string className
 Key this operator is registered under in the OperatorFactory. Defined by the generated factory boilerplate, not in this header.
 

Protected Member Functions

template<typename MemAccess , typename TField >
NEK_FORCE_INLINE void SyncTrailingBlocks (TField &field)
 Synchronise every block of field after the first.
 
void v_Apply (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &flux) override
 Evaluate the advective trace flux on the interior and boundary traces.
 
void v_ApplyParallel (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &flux) override
 Evaluate the advective trace flux on the partition-cut traces.
 
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void InteriorOp (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &flux)
 Evaluate the flux on every interior trace.
 
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void ParallelOp (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &flux)
 Evaluate the flux on every trace cut by the partitioner.
 
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void BoundaryOp (LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &flux)
 Evaluate the flux on every Dirichlet boundary trace.
 
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void SetTraceAdvVel (LibUtilities::Field< TData, FieldState::Phys > &AdvVel)
 Sample a volume advection velocity onto the global trace.
 
void v_SetTraceAdvVel (LibUtilities::Field< TData, FieldState::Phys > &AdvVel) override
 Keep a pointer to the caller's advection velocity.
 
void v_BeginParallelExchange (LibUtilities::Field< TData, FieldState::Phys > &trace, const unsigned chan) override
 Sample the advection velocity before any exchange is in flight.
 
void CheckTraceAdvVel ()
 Sample m_traceAdvVel onto the global trace if it has changed since the last sample, dispatching on the trace dimension. Cheap and does nothing when it has not. Called from v_BeginParallelExchange(), and from the applies for a caller that never starts an exchange.
 

Protected Attributes

LibUtilities::Field< TData, FieldState::Phys > * m_traceAdvVel = nullptr
 The caller's advection velocity on the local trace, not owned here. Set by v_SetTraceAdvVel(); the caller keeps it alive.
 
bool m_gloTraceAdvVelStale = false
 m_traceAdvVel has changed since m_gloTraceAdvVel was last sampled.
 
LibUtilities::Field< TData, FieldState::Phys > m_gloTraceAdvVel
 Advection velocity sampled on the global trace, one component per coordinate direction. Filled from m_traceAdvVel by CheckTraceAdvVel().
 
LibUtilities::MemoryRegion< TData > m_wsploc
 Backing allocation for m_advVel.
 
TData * m_advVel
 Scratch holding the advection velocity for the block currently being processed, in the same packed layout as SolverCore::detail::TraceFluxOpImpl::m_norms.
 

Private Types

using MemSpace = typename ExecSpace::memory_space
 

Detailed Description

template<template< typename > typename FluxKernel, typename ExecSpace, typename TData>
class Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >

Advective trace flux for scalar transport, evaluated with a pluggable Riemann solver.

Supplies the flux evaluation that SolverCore::detail::TraceFluxOpImpl leaves abstract. The base class owns the trace numbering and the gather/scatter between element-local and global-trace layouts; this class walks the resulting blocks and, for each one, assembles the advection velocity and normals the Riemann solver needs before handing the two trace states to FluxKernel.

Both InteriorOp() and BoundaryOp() follow the same three steps, marked in the code: gather both sides of the trace, evaluate the flux, scatter the result back. Whether the scatter overwrites or accumulates is controlled by SolverCore::TraceFluxOp::SetAppend.

The advection velocity is supplied through SolverCore::TraceFluxOp::SetTraceAdvVel before the operator is applied. The operator keeps a non-owning pointer to the caller's field, as the other operators do for the fields they are handed, and samples it onto the global trace in m_gloTraceAdvVel the first time it is applied after the pointer is set; the sample is reused until SetTraceAdvVel() is called again.

Template Parameters
FluxKernelRiemann solver, as a class template on the execution space. It must provide operator()(blksize, velComps, fluxComps, vel, norm, fwd, bwd, flux); see UpwindSolverKernel.
ExecSpaceExecution space the operator runs in.
TDataFloating-point representation used by the field data.
See also
SolverCore::detail::TraceFluxOpImpl for the trace numbering and the meaning of T0/T1.
FluxKernelLauncher in TraceFluxSolverKernels.hpp, which applies FluxKernel over a padded block.

Definition at line 82 of file ScalarTraceFluxOpImpl.hpp.

Member Typedef Documentation

◆ MemSpace

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
using Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::MemSpace = typename ExecSpace::memory_space
private

Definition at line 86 of file ScalarTraceFluxOpImpl.hpp.

Constructor & Destructor Documentation

◆ ScalarTraceFluxOpImpl()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::ScalarTraceFluxOpImpl ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components 
)
inline

Construct the operator and size its advection-velocity storage.

Delegates all trace numbering to SolverCore::detail::TraceFluxOpImpl, then allocates m_gloTraceAdvVel over the global trace and a scratch buffer large enough for the widest padded trace block found in either the interior or the Dirichlet boundary blocks.

Parameters
expansionList- Expansion list the operator acts on.
components- Names of the field components.

Definition at line 100 of file ScalarTraceFluxOpImpl.hpp.

102 : SolverCore::detail::TraceFluxOpImpl<ExecSpace, TData,
103 ScalarTraceFluxOp<TData>>(
104 std::move(expansionList), components),
105 m_gloTraceAdvVel(LibUtilities::Field<TData, FieldState::Phys>(
106 "Trace Advection Velocity",
107 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
108 expansionList->GetTrace()),
109 expansionList->GetExp(0)->GetShapeDimension(), 1))
110 {
111 // Initialise trace advection.
112 m_gloTraceAdvVel.template Initialize<MemSpace>(0.0);
113
114 size_t maxNTraceNPts = 0;
115 for (unsigned b = 0; b < this->m_intT0.size(); ++b)
116 {
117 maxNTraceNPts =
118 std::max(maxNTraceNPts, this->m_intT0[b].m_nTraceXnPtsPad);
119 }
120 for (unsigned b = 0; b < this->m_bndT0.size(); ++b)
121 {
122 maxNTraceNPts =
123 std::max(maxNTraceNPts, this->m_bndT0[b].m_nTraceXnPtsPad);
124 }
125 for (unsigned b = 0; b < this->m_parT0.size(); ++b)
126 {
127 maxNTraceNPts =
128 std::max(maxNTraceNPts, this->m_parT0[b].m_nTraceXnPtsPad);
129 }
130
131 auto maxTraceSizeDim = maxNTraceNPts * (this->m_traceDim + 1);
132
133 // Set up local workspace for advection velocity.
134 m_wsploc = LibUtilities::MemoryRegion<TData>(maxTraceSizeDim);
135 m_wsploc.template Initialize<MemSpace>(0.0);
136 m_advVel = m_wsploc.template GetPtr<MemSpace, ReadWrite>();
137 }
LibUtilities::Field< TData, FieldState::Phys > m_gloTraceAdvVel
Advection velocity sampled on the global trace, one component per coordinate direction....
LibUtilities::MemoryRegion< TData > m_wsploc
Backing allocation for m_advVel.
TData * m_advVel
Scratch holding the advection velocity for the block currently being processed, in the same packed la...

References Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_advVel, Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel, and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_wsploc.

Member Function Documentation

◆ BoundaryOp()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::BoundaryOp ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  flux 
)
inlineprotected

Evaluate the flux on every Dirichlet boundary trace.

As InteriorOp(), but the exterior state comes from the boundary condition operator rather than a neighbouring element, and the result is scattered to the interior element only.

Template Parameters
TRACEDIMTrace dimension; must equal m_traceDim.
Parameters
inPhysical-space scalar field.
fluxTrace-space output.

Definition at line 494 of file ScalarTraceFluxOpImpl.hpp.

497 {
498 auto numflux = flux.GetNumComponents();
499 constexpr unsigned NDIM = TRACEDIM + 1;
500
501 this->SetWorkSpace(numflux);
502
503 ASSERTL1(in.GetNumComponents() == numflux,
504 "Assumption that input components are the "
505 "same as the flux components");
506
507 // Get field pointers.
508 auto inPtr = in.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
509 this->m_opStreamID);
510 auto fluxPtr = flux.GetBlocks()[0].template GetPtr<MemSpace, WriteOnly>(
511 this->m_opStreamID);
512 auto normPtr = this->m_traceNormals;
513 auto advVelPtr =
514 m_gloTraceAdvVel.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
515 this->m_opStreamID);
516
517 // Synchronise all blocks in a field.
518 SyncTrailingBlocks<ReadOnly>(in);
519 SyncTrailingBlocks<WriteOnly>(flux);
520 SyncTrailingBlocks<ReadOnly>(m_gloTraceAdvVel);
521
522 for (unsigned b = 0; b < this->m_bndT0.size(); ++b)
523 {
524 // Step 1: Get global trace 't' and put into m_gloT0 and
525 // m_gloT1.
526 this->template SetBoundaryParams<TRACEDIM>(b);
527 this->template GetBoundaryTraces<TRACEDIM>(
528 b, numflux, inPtr, this->m_gloT0, this->m_gloT1,
529 this->LayoutFor(in));
530
531 // Step 2: Solve Riemann problem on close packed variables
532 // left and right traces (m_gloT0, m_gloT1).
533 auto numBlock = this->m_bndT0[b].offset.size();
534 auto npTBlock = this->m_bndT0[b].m_nTraceXnPtsPad;
535 // Gather normal advvel and normals.
536 const auto gather =
537 this->GetGloTraceOffsetView(this->m_bndGloTraceDev[b]);
538
539 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
540 numBlock, this->m_npTot, npTBlock, NDIM, advVelPtr, gather,
541 this->m_advVel, this->m_opStreamID);
542 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
543 numBlock, this->m_npTot, npTBlock, NDIM, normPtr, gather,
544 this->m_norms, this->m_opStreamID);
545
546 // Input close packed variables from both traces
547 // (m_gloT0, m_gloT1), apply flux Kernel and
548 // return flux.
549 FluxKernelLauncher<FluxKernel, ExecSpace>(
550 npTBlock, NDIM, numflux, this->m_advVel, this->m_norms,
551 this->m_gloT0, this->m_gloT1, this->m_flux, this->m_opStreamID);
552
553 // Step 3: Replace flux values from (m_gloT0,m_gloT1) into
554 // the local flux storage.
555 if (this->m_append)
556 {
557 this->template InterpBackDirichletFlux<TRACEDIM, true>(
558 b, numflux, fluxPtr, this->LayoutFor(flux));
559 }
560 else
561 {
562 this->template InterpBackDirichletFlux<TRACEDIM, false>(
563 b, numflux, fluxPtr, this->LayoutFor(flux));
564 }
565 }
566 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
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

References ASSERTL1, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel.

◆ CheckTraceAdvVel()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::CheckTraceAdvVel ( )
inlineprotected

Sample m_traceAdvVel onto the global trace if it has changed since the last sample, dispatching on the trace dimension. Cheap and does nothing when it has not. Called from v_BeginParallelExchange(), and from the applies for a caller that never starts an exchange.

Definition at line 721 of file ScalarTraceFluxOpImpl.hpp.

722 {
724 {
725 return;
726 }
727
729 "The advection velocity was not set before the scalar trace "
730 "flux was applied.");
731
732 // The velocity is a local trace field, written on the element block
733 // streams.
734 this->JoinBlockStreams();
735
736 switch (this->m_traceDim)
737 {
738 case 0:
739 this->template SetTraceAdvVel<0>(*m_traceAdvVel);
740 break;
741 case 1:
742 this->template SetTraceAdvVel<1>(*m_traceAdvVel);
743 break;
744 case 2:
745 this->template SetTraceAdvVel<2>(*m_traceAdvVel);
746 break;
747 }
748
749 this->ReleaseBlockStreams();
750
751 m_gloTraceAdvVelStale = false;
752 }
#define ASSERTL0(condition, msg)
bool m_gloTraceAdvVelStale
m_traceAdvVel has changed since m_gloTraceAdvVel was last sampled.
LibUtilities::Field< TData, FieldState::Phys > * m_traceAdvVel
The caller's advection velocity on the local trace, not owned here. Set by v_SetTraceAdvVel(); the ca...

References ASSERTL0, Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVelStale, and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_traceAdvVel.

Referenced by Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_Apply(), Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_ApplyParallel(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_BeginParallelExchange().

◆ Instantiate()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
static std::unique_ptr< MultiRegions::Operator< TData > > Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::Instantiate ( const MultiRegions::ExpListSharedPtr &  expansionList,
const std::vector< std::string > &  components 
)
inlinestatic

Factory creator function.

Parameters
expansionList- Expansion list the operator acts on.
components- Names of the field components.
Returns
A new operator instance, owned by the caller.

Definition at line 153 of file ScalarTraceFluxOpImpl.hpp.

156 {
157 return std::make_unique<
158 ScalarTraceFluxOpImpl<FluxKernel, ExecSpace, TData>>(expansionList,
159 components);
160 }

◆ InteriorOp()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::InteriorOp ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  flux 
)
inlineprotected

Evaluate the flux on every interior trace.

For each interior block: gather the forward and backward trace states, gather the advection velocity and trace normals for the same points into m_advVel and SolverCore::detail::TraceFluxOpImpl::m_norms, apply FluxKernel, and scatter the single-valued result back to both elements.

Template Parameters
TRACEDIMTrace dimension; must equal m_traceDim.
Parameters
inPhysical-space scalar field.
fluxTrace-space output.
Note
The normals and velocity are read from the global trace using the block-component offsets, so m_gloTraceAdvVel must already be populated; it is not derived from in.

Definition at line 311 of file ScalarTraceFluxOpImpl.hpp.

314 {
315 auto numflux = flux.GetNumComponents();
316 constexpr unsigned NDIM = TRACEDIM + 1;
317
318 this->SetWorkSpace(numflux);
319
320 ASSERTL1(in.GetNumComponents() == numflux,
321 "Assumption that input components are the "
322 "same as the flux components");
323
324 // Get field pointers.
325 auto inPtr = in.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
326 this->m_opStreamID);
327 auto fluxPtr = flux.GetBlocks()[0].template GetPtr<MemSpace, WriteOnly>(
328 this->m_opStreamID);
329 auto normPtr = this->m_traceNormals;
330 auto advVelPtr =
331 m_gloTraceAdvVel.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
332 this->m_opStreamID);
333
334 // Synchronise all blocks in a field.
335 SyncTrailingBlocks<ReadOnly>(in);
336 SyncTrailingBlocks<WriteOnly>(flux);
337 SyncTrailingBlocks<ReadOnly>(m_gloTraceAdvVel);
338
339 for (unsigned b = 0; b < this->m_intT0.size(); ++b)
340 {
341 // Step 1: Get global traces associated with block b and put into
342 // m_gloT0 and m_gloT1.
343 this->template SetInteriorParams<TRACEDIM>(b);
344 this->template GetInteriorTraces<TRACEDIM>(
345 b, numflux, inPtr, this->m_gloT0, this->m_gloT1,
346 this->LayoutFor(in));
347
348 // Step 2: Solve Riemann problem on close packed variables
349 // left and right traces (m_gloT0, m_gloT1).
350 auto numBlock = this->m_intT0[b].offset.size();
351 auto npTBlock = this->m_intT0[b].m_nTraceXnPtsPad;
352
353 // Gather normal advvel and normals, which share a layout on the
354 // global trace and so a single set of offsets.
355 const auto gather =
356 this->GetGloTraceOffsetView(this->m_intGloTraceDev[b]);
357
358 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
359 numBlock, this->m_npTot, npTBlock, NDIM, advVelPtr, gather,
360 this->m_advVel, this->m_opStreamID);
361 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
362 numBlock, this->m_npTot, npTBlock, NDIM, normPtr, gather,
363 this->m_norms, this->m_opStreamID);
364
365 // Input close packed variables from both traces
366 // (m_gloT0, m_gloT1), apply flux Kernel and return flux.
367 FluxKernelLauncher<FluxKernel, ExecSpace>(
368 npTBlock, NDIM, numflux, this->m_advVel, this->m_norms,
369 this->m_gloT0, this->m_gloT1, this->m_flux, this->m_opStreamID);
370
371 // Step 3: Replace flux values from (m_gloT0,m_gloT1) into
372 // the local flux storage.
373 if (this->m_append)
374 {
375 this->template InterpBackInteriorFlux<TRACEDIM, true>(
376 b, numflux, fluxPtr, this->LayoutFor(flux));
377 }
378 else
379 {
380 this->template InterpBackInteriorFlux<TRACEDIM, false>(
381 b, numflux, fluxPtr, this->LayoutFor(flux));
382 }
383 }
384 }

References ASSERTL1, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel.

◆ ParallelOp()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::ParallelOp ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  flux 
)
inlineprotected

Evaluate the flux on every trace cut by the partitioner.

InteriorOp() for traces whose backward element is on another rank. The flux is the interior one throughout - the neighbouring state is a real state, not a boundary condition - and the only differences are that the backward side is read from the receive buffer, which SolverCore::detail::TraceFluxOpImpl::GetParallelTraces() handles, and that the result is scattered to the local element alone. The neighbour computes the same flux from the same two states and scatters it to the other element itself.

Returns immediately when there are no such traces, which is every case in serial.

Template Parameters
TRACEDIMTrace dimension; must equal m_traceDim.
Parameters
inPhysical-space scalar field.
fluxTrace-space output.

Definition at line 406 of file ScalarTraceFluxOpImpl.hpp.

409 {
410 if (this->m_parT0.empty())
411 {
412 return;
413 }
414
415 auto numflux = flux.GetNumComponents();
416 constexpr unsigned NDIM = TRACEDIM + 1;
417
418 this->SetWorkSpace(numflux);
419
420 ASSERTL1(in.GetNumComponents() == numflux,
421 "Assumption that input components are the "
422 "same as the flux components");
423
424 auto inPtr = in.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
425 this->m_opStreamID);
426 auto fluxPtr = flux.GetBlocks()[0].template GetPtr<MemSpace, ReadWrite>(
427 this->m_opStreamID);
428 auto normPtr = this->m_traceNormals;
429 auto advVelPtr =
430 m_gloTraceAdvVel.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
431 this->m_opStreamID);
432
433 // Synchronise all blocks in a field.
434 SyncTrailingBlocks<ReadOnly>(in);
435 SyncTrailingBlocks<ReadWrite>(flux);
436 SyncTrailingBlocks<ReadOnly>(m_gloTraceAdvVel);
437
438 for (unsigned b = 0; b < this->m_parT0.size(); ++b)
439 {
440 // Step 1: Get global traces associated with block b and put into
441 // m_gloT0 and m_gloT1.
442 this->template SetParallelParams<TRACEDIM>(b);
443 this->template GetParallelTraces<TRACEDIM>(
444 b, numflux, inPtr, this->m_gloT0, this->m_gloT1,
445 this->LayoutFor(in));
446
447 // Step 2: Solve Riemann problem on close packed variables
448 // left and right traces (m_gloT0, m_gloT1).
449 auto numBlock = this->m_parT0[b].offset.size();
450 auto npTBlock = this->m_parT0[b].m_nTraceXnPtsPad;
451
452 // Gather normal advvel and normals.
453 const auto gather =
454 this->GetGloTraceOffsetView(this->m_parGloTraceDev[b]);
455
456 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
457 numBlock, this->m_npTot, npTBlock, NDIM, advVelPtr, gather,
458 this->m_advVel, this->m_opStreamID);
459 SolverCore::detail::GatherGloTraceComponentsKernel<ExecSpace>(
460 numBlock, this->m_npTot, npTBlock, NDIM, normPtr, gather,
461 this->m_norms, this->m_opStreamID);
462
463 FluxKernelLauncher<FluxKernel, ExecSpace>(
464 npTBlock, NDIM, numflux, this->m_advVel, this->m_norms,
465 this->m_gloT0, this->m_gloT1, this->m_flux, this->m_opStreamID);
466
467 // Step 3: Replace flux values from (m_gloT0,m_gloT1) into
468 // the local flux storage.
469 if (this->m_append)
470 {
471 this->template InterpBackParallelFlux<TRACEDIM, true>(
472 b, numflux, fluxPtr, this->LayoutFor(flux));
473 }
474 else
475 {
476 this->template InterpBackParallelFlux<TRACEDIM, false>(
477 b, numflux, fluxPtr, this->LayoutFor(flux));
478 }
479 }
480 }

References ASSERTL1, Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel.

◆ SetTraceAdvVel()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
template<unsigned TRACEDIM>
NEK_FORCE_INLINE void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::SetTraceAdvVel ( LibUtilities::Field< TData, FieldState::Phys > &  AdvVel)
inlineprotected

Sample a volume advection velocity onto the global trace.

Populates m_gloTraceAdvVel, which InteriorOp() and BoundaryOp() then read. On interior traces the two sides are averaged, so that both elements see the same velocity and the flux stays single-valued. On boundary traces the interior value is taken unchanged, since the boundary condition operator does not generally carry advection velocity data.

Template Parameters
TRACEDIMTrace dimension; must equal m_traceDim.
Parameters
AdvVelPhysical-space advection velocity, one component per coordinate direction.

Definition at line 582 of file ScalarTraceFluxOpImpl.hpp.

584 {
585 auto numComp = AdvVel.GetNumComponents();
586 this->SetWorkSpace(numComp);
587
588 // Get field pointers.
589 auto inPtr = AdvVel.GetBlocks()[0].template GetPtr<MemSpace, ReadOnly>(
590 this->m_opStreamID);
591 auto advVelPtr =
593 .template GetPtr<MemSpace, WriteOnly>(this->m_opStreamID);
594
595 for (unsigned b = 0; b < this->m_intT0.size(); ++b)
596 {
597 // Step 1: Get global trace 't' and put into m_gloT0 and
598 // m_gloT1.
599 this->template SetInteriorParams<TRACEDIM>(b);
600 this->template GetInteriorTraces<TRACEDIM>(
601 b, numComp, inPtr, this->m_gloT0, this->m_gloT1,
602 this->LayoutFor(AdvVel));
603
604 unsigned npT = 0;
605 if constexpr (TRACEDIM == 0)
606 {
607 npT = 1;
608 }
609 else if constexpr (TRACEDIM == 1)
610 {
611 npT = this->m_npT[0];
612 }
613 else if constexpr (TRACEDIM == 2)
614 {
615 npT = this->m_npT[0] * this->m_npT[1];
616 }
617
618 auto numBlock = this->m_intT0[b].offset.size();
619 auto npTBlock = this->m_intT0[b].m_nTraceXnPtsPad;
620
621 // Step 2: store the average of the two sides on the global trace.
622 SolverCore::detail::ScatterGloTraceComponentsKernel<ExecSpace,
623 true>(
624 numBlock, npT, npTBlock, numComp, this->m_gloT0, this->m_gloT1,
625 this->GetGloTraceOffsetView(this->m_intGloTraceDev[b]),
626 advVelPtr, this->m_opStreamID);
627 }
628
629 // A trace cut by the partitioner takes the same average as any other
630 // interior trace, so the neighbour's half of it has to be fetched. It
631 // is fetched once, here, rather than every apply: the sample is held
632 // until the velocity is set again.
633 this->ExchangeParallelTracesBlocking(0, inPtr, numComp,
634 this->LayoutFor(AdvVel));
635
636 for (unsigned b = 0; b < this->m_parT0.size(); ++b)
637 {
638 this->template SetParallelParams<TRACEDIM>(b);
639 this->template GetParallelTraces<TRACEDIM>(
640 b, numComp, inPtr, this->m_gloT0, this->m_gloT1,
641 this->LayoutFor(AdvVel));
642
643 auto numBlock = this->m_parT0[b].offset.size();
644 auto npTBlock = this->m_parT0[b].m_nTraceXnPtsPad;
645
646 SolverCore::detail::ScatterGloTraceComponentsKernel<ExecSpace,
647 true>(
648 numBlock, this->m_npTot, npTBlock, numComp, this->m_gloT0,
649 this->m_gloT1,
650 this->GetGloTraceOffsetView(this->m_parGloTraceDev[b]),
651 advVelPtr, this->m_opStreamID);
652 }
653
654 // Just take interior points rather than average since
655 // do not typically have boundary conditions for
656 // advection velocity.
657 for (unsigned b = 0; b < this->m_bndT0.size(); ++b)
658 {
659 // Step 1: Get global trace 't' and put into m_gloT0 and
660 // m_gloT1.
661 this->template SetBoundaryParams<TRACEDIM>(b);
662 this->template GetBoundaryTraces<TRACEDIM, false>(
663 b, numComp, inPtr, this->m_gloT0, this->m_gloT1,
664 this->LayoutFor(AdvVel));
665
666 auto numBlock = this->m_bndT0[b].offset.size();
667 auto npTBlock = this->m_bndT0[b].m_nTraceXnPtsPad;
668
669 // Step 2: take the interior point; no averaging, since advection
670 // velocity typically has no boundary condition of its own.
671 SolverCore::detail::ScatterGloTraceComponentsKernel<ExecSpace,
672 false>(
673 numBlock, this->m_npTot, npTBlock, numComp, this->m_gloT0,
674 static_cast<const TData *>(nullptr),
675 this->GetGloTraceOffsetView(this->m_bndGloTraceDev[b]),
676 advVelPtr, this->m_opStreamID);
677 }
678 }

References Nektar::LibUtilities::Field< TData, TState >::GetBlocks(), Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel.

◆ SyncTrailingBlocks()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
template<typename MemAccess , typename TField >
NEK_FORCE_INLINE void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::SyncTrailingBlocks ( TField &  field)
inlineprotected

Synchronise every block of field after the first.

Memory is synchronised a block at a time, while the kernels below walk a field from its first block's pointer; taking that pointer therefore leaves every later block unsynchronised. Each field is walked to its own length, since they do not share a block count: the trace normals are built as a single block.

Definition at line 189 of file ScalarTraceFluxOpImpl.hpp.

190 {
191 for (unsigned blk = 1; blk < field.GetBlocks().size(); ++blk)
192 {
193 field.GetBlocks()[blk].template GetPtr<MemSpace, MemAccess>(
194 this->m_opStreamID);
195 }
196 }

◆ v_Apply()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_Apply ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  flux 
)
inlineoverrideprotected

Evaluate the advective trace flux on the interior and boundary traces.

Zeroes flux, then dispatches to InteriorOp() and BoundaryOp() for the trace dimension determined at construction. Neither needs anything from another rank, so a caller may run this between BeginParallelExchange() and EndParallelExchange(); the partition traces are v_ApplyParallel()'s, afterwards.

Parameters
in- Physical-space scalar field to take trace values from.
flux- Trace-space output.

Definition at line 215 of file ScalarTraceFluxOpImpl.hpp.

217 {
219
220 this->JoinBlockStreams();
221
222 // The flux is written in the layout of the state traces.
223 flux.SetInterleaveWidth(in);
224
225 // Primarily here to ensure all blocks are intialised since
226 // the GetPtr() below will only intiialise first block. On the trace
227 // stream, which the kernels writing the flux run on.
228 flux.template Initialize<MemSpace>(0, this->m_opStreamID);
229
230 switch (this->m_traceDim)
231 {
232 case 0:
233 // Loop over interior and boundary traces and evaluate flux
234 // using the Op methods defined below.
235 this->template InteriorOp<0>(in, flux);
236 this->template BoundaryOp<0>(in, flux);
237 break;
238 case 1:
239 this->template InteriorOp<1>(in, flux);
240 this->template BoundaryOp<1>(in, flux);
241 break;
242 case 2:
243 this->template InteriorOp<2>(in, flux);
244 this->template BoundaryOp<2>(in, flux);
245 break;
246 default:
247 NEKERROR(ErrorUtil::efatal, "Unknown value of m_traceDim");
248 break;
249 }
250
251 this->ReleaseBlockStreams();
252 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
void CheckTraceAdvVel()
Sample m_traceAdvVel onto the global trace if it has changed since the last sample,...

References Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::CheckTraceAdvVel(), Nektar::ErrorUtil::efatal, NEKERROR, and Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth().

◆ v_ApplyParallel()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_ApplyParallel ( LibUtilities::Field< TData, FieldState::Phys > &  in,
LibUtilities::Field< TData, FieldState::Phys > &  flux 
)
inlineoverrideprotected

Evaluate the advective trace flux on the partition-cut traces.

Reads what BeginParallelExchange() / EndParallelExchange() delivered, so it must follow the wait; flux must be the field v_Apply() wrote, whose partition slots this fills. Does nothing at all in serial.

Definition at line 261 of file ScalarTraceFluxOpImpl.hpp.

264 {
265 if (this->m_parT0.empty())
266 {
267 return;
268 }
269
271
272 this->JoinBlockStreams();
273
274 switch (this->m_traceDim)
275 {
276 case 0:
277 this->template ParallelOp<0>(in, flux);
278 break;
279 case 1:
280 this->template ParallelOp<1>(in, flux);
281 break;
282 case 2:
283 this->template ParallelOp<2>(in, flux);
284 break;
285 default:
286 NEKERROR(ErrorUtil::efatal, "Unknown value of m_traceDim");
287 break;
288 }
289
290 this->ReleaseBlockStreams();
291 }

References Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::CheckTraceAdvVel(), Nektar::ErrorUtil::efatal, and NEKERROR.

◆ v_BeginParallelExchange()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_BeginParallelExchange ( LibUtilities::Field< TData, FieldState::Phys > &  trace,
const unsigned  chan 
)
inlineoverrideprotected

Sample the advection velocity before any exchange is in flight.

The sampling averages each interior trace, so a trace the partitioner cut needs its neighbour's half and performs an exchange of its own on the same channel. Doing that from Apply() would resize a channel the caller had already started an exchange on - the solution carries a different number of components - so it happens here instead, at the one entry point that runs before anything is in flight.

Definition at line 706 of file ScalarTraceFluxOpImpl.hpp.

709 {
711
712 SolverCore::detail::TraceFluxOpImpl<
713 ExecSpace, TData,
714 ScalarTraceFluxOp<TData>>::v_BeginParallelExchange(trace, chan);
715 }
void v_BeginParallelExchange(LibUtilities::Field< TData, FieldState::Phys > &trace, const unsigned chan) override
Sample the advection velocity before any exchange is in flight.

References Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::CheckTraceAdvVel(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_BeginParallelExchange().

Referenced by Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_BeginParallelExchange().

◆ v_SetTraceAdvVel()

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
void Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_SetTraceAdvVel ( LibUtilities::Field< TData, FieldState::Phys > &  AdvVel)
inlineoverrideprotected

Keep a pointer to the caller's advection velocity.

Nothing is read here: the field is sampled onto the global trace by CheckTraceAdvVel() on the next apply, so the caller must keep it alive for as long as this operator may be applied.

Parameters
AdvVel- Physical-space advection velocity on the local trace.

Definition at line 689 of file ScalarTraceFluxOpImpl.hpp.

691 {
692 m_traceAdvVel = &AdvVel;
694 }

References Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVelStale, and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_traceAdvVel.

Member Data Documentation

◆ className

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
std::string Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::className
static

Key this operator is registered under in the OperatorFactory. Defined by the generated factory boilerplate, not in this header.

Definition at line 142 of file ScalarTraceFluxOpImpl.hpp.

◆ m_advVel

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
TData* Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_advVel
protected

Scratch holding the advection velocity for the block currently being processed, in the same packed layout as SolverCore::detail::TraceFluxOpImpl::m_norms.

Definition at line 177 of file ScalarTraceFluxOpImpl.hpp.

Referenced by Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::ScalarTraceFluxOpImpl().

◆ m_gloTraceAdvVel

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
LibUtilities::Field<TData, FieldState::Phys> Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVel
protected

◆ m_gloTraceAdvVelStale

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
bool Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_gloTraceAdvVelStale = false
protected

◆ m_traceAdvVel

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
LibUtilities::Field<TData, FieldState::Phys>* Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_traceAdvVel = nullptr
protected

The caller's advection velocity on the local trace, not owned here. Set by v_SetTraceAdvVel(); the caller keeps it alive.

Definition at line 165 of file ScalarTraceFluxOpImpl.hpp.

Referenced by Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::CheckTraceAdvVel(), and Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::v_SetTraceAdvVel().

◆ m_wsploc

template<template< typename > typename FluxKernel, typename ExecSpace , typename TData >
LibUtilities::MemoryRegion<TData> Nektar::detail::ScalarTraceFluxOpImpl< FluxKernel, ExecSpace, TData >::m_wsploc
protected