77 using MemSpace =
typename ExecSpace::memory_space;
93 const std::vector<MultiRegions::ExpListSharedPtr> &bndExpLists,
94 const std::vector<std::vector<bool>> &isComp)
98 for (
unsigned int n = 0; n < bndExpLists.size(); ++n)
100 const bool isPoint = (bndExpLists[n]->GetShapeDimension() == 0);
102 m_masks[n].resize(collections.size());
103 for (
auto &collection : collections)
112 const auto exp = collection.GetExpVector()[0];
113 const auto basisType = exp->GetBasisType(0);
116 for (
int k = 0; k < exp->GetNverts(); ++k)
125 "The surface integral of a boundary field needs "
126 "a Modified_A or a Lagrange basis.");
137 const auto blockAttributes =
138 MultiRegions::GetBlockAttributes<TData, FieldState::Coeff>(
140 MultiRegions::UnitInterleaveWidths(bndExpLists[n]));
141 for (
unsigned int blk = 0; blk < blockAttributes.size(); ++blk)
143 const unsigned int streamID = blk + 1;
146 BuildMask(n, blk, blockAttributes[blk], streamID);
164 auto dataPtr = data.template GetPtr<MemSpace, ReadWrite>(
m_opStreamID);
165 std::vector<unsigned int> blockStreams;
166 for (
auto &field : coeffs)
168 for (
unsigned int blk = blockStreams.size();
169 blk < field.GetBlocks().size(); ++blk)
171 blockStreams.push_back(blk + 1);
176 for (
unsigned int n = 0; n < coeffs.size(); ++n)
178 const unsigned int nHomo = coeffs[n].GetNumHomoModes();
179 ASSERTL1(coeffs[n].GetNumComponents() * nHomo <= data.
size(),
180 "The surface integral holds one value per component "
181 "and homogeneous plane.");
183 for (
unsigned int blk = 0; blk < coeffs[n].GetBlocks().size();
186 const unsigned int streamID = blk + 1;
187 auto &block = coeffs[n].GetBlocks()[blk];
188 const uint8_t *maskPtr =
GetMask(n, blk, block, streamID);
190 block.template GetPtr<MemSpace, ReadOnly>(streamID);
191 const unsigned int nComp = coeffs[n].GetNumComponents();
192 for (
unsigned int i = 0; i < nComp * nHomo; ++i)
199 if (maskPtr !=
nullptr)
201 Math::reduceSumKernel<ExecSpace, false>(
202 block.CompSize(), maskPtr,
203 srcPtr + i * block.CompSize(), dataPtr + i,
208 Math::reduceSumKernel<ExecSpace, false>(
209 block.CompSize(), srcPtr + i * block.CompSize(),
210 dataPtr + i, streamID);
229 std::vector<std::vector<std::array<LibUtilities::MemoryRegion<uint8_t>, 2>>>
235 static unsigned int MaskIndex(
const unsigned int interleaveWidth)
238 "The surface integral takes fields at interleave width 1 or "
239 "at the interleave width of its execution space.");
240 return (interleaveWidth == 1u) ? 0u : 1u;
250 const unsigned int n,
const unsigned int blk,
252 const unsigned int streamID)
260 if (mask.size() == 0)
265 return mask.template GetPtr<MemSpace, ReadOnly>(streamID);
274 const unsigned int n,
const unsigned int blk,
276 const unsigned int streamID)
284 std::vector<uint8_t> hostMask(block.
CompSize(), 0);
287 const size_t ilane =
e % interleaveWidth;
288 const size_t iwarp =
e / interleaveWidth;
291 hostMask[(iwarp * nData + mode) * interleaveWidth + ilane] = 1;
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
A block means a group of elements of identical shape, basis and order. BlockAttributes stores the mos...
unsigned int GetInterleaveWidth(void) const
size_t CompSize(void) const
unsigned int GetNumData(void) const
size_t GetNumElements(void) const
A Field represents expansion data to be operated on.
A MemoryRegion represents a memory region.
size_t size() const
Get the storage size.
Adds the surface integral of boundary fields, per component and homogeneous plane,...
CGBndCondSurfaceIntegral()=default
std::vector< std::vector< std::vector< size_t > > > m_vertexModes
void BuildMask(const unsigned int n, const unsigned int blk, const LibUtilities::BlockAttributes< FieldState::Coeff > &block, const unsigned int streamID)
Build the mask of the Modified_A block blk of field n at the interleave width of block,...
std::vector< std::vector< bool > > m_isComp
static constexpr unsigned int m_interleaveWidth
CGBndCondSurfaceIntegral(const std::vector< MultiRegions::ExpListSharedPtr > &bndExpLists, const std::vector< std::vector< bool > > &isComp)
Build the sum of the surface integrals of the fields on the boundary expansion lists bndExpLists,...
static unsigned int MaskIndex(const unsigned int interleaveWidth)
The index into m_masks of interleave width interleaveWidth.
const uint8_t * GetMask(const unsigned int n, const unsigned int blk, const LibUtilities::BlockAttributes< FieldState::Coeff > &block, const unsigned int streamID)
The mask of block blk of field n at the interleave width of block, in the memory space of the executi...
void Add(std::vector< LibUtilities::Field< TData, FieldState::Coeff > > &coeffs, LibUtilities::MemoryRegion< TData > &data)
Add the surface integral of component nc of every field coeffs[n], the fields of the boundary expansi...
typename ExecSpace::memory_space MemSpace
static constexpr unsigned int m_opStreamID
std::vector< std::vector< std::array< LibUtilities::MemoryRegion< uint8_t >, 2 > > > m_masks
@ eGauss_Lagrange
Lagrange Polynomials using the Gauss points.
@ eGLL_Lagrange
Lagrange for SEM basis .
@ eModified_A
Principle Modified Functions .
Collections::CollectionVector GetCollections(MultiRegions::ExpListSharedPtr expansionList)