Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Nektar::LocalRegions::GeometricDataCreator Class Reference

#include <GeometricDataWarehouse.hpp>

Inheritance diagram for Nektar::LocalRegions::GeometricDataCreator:
[legend]

Public Member Functions

 ~GeometricDataCreator () override=default
 
 GeometricDataCreator (const Collections::CollectionVector collections)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const WeightsKey< TData > &weightsKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const JacobianKey< TData > &jacobianKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const QuadratureMetricKey< TData > &quadratureMetricKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const DerivFactorKey< TData > &derivFactorKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const CoordKey< TData > &coordKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Create (const OrientKey< TData > &orientKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Create (const TraceToElmtMapKey< TData > &traceToElmtMapKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< int > Create (const TraceToElmtSignKey< TData > &traceToElmtSignKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Create (const InteriorMapKey< TData > &interiorMapKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const JacobianTraceKey< TData > &jacobianTraceKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const JacobianLocTraceKey< TData > &jacobianLocTraceKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const JacNormGeomFactorLocTraceKey< TData > &jacnormgeomfacLocTraceKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Create (const ElmtInvMassKey< TData > &elmtInvMassKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Create (const OrientKey< TData > &orientKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Create (const TraceToElmtMapKey< TData > &traceToElmtMapKey)
 
template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Create (const InteriorMapKey< TData > &interiorMapKey)
 
- Public Member Functions inherited from Nektar::LibUtilities::DataCreatorClass
virtual ~DataCreatorClass ()=default
 

Static Public Attributes

static const std::string m_name = "GeometricDataCreator"
 

Private Attributes

Collections::CollectionVector m_collections
 

Detailed Description

Definition at line 401 of file GeometricDataWarehouse.hpp.

Constructor & Destructor Documentation

◆ ~GeometricDataCreator()

Nektar::LocalRegions::GeometricDataCreator::~GeometricDataCreator ( )
overridedefault

◆ GeometricDataCreator()

Nektar::LocalRegions::GeometricDataCreator::GeometricDataCreator ( const Collections::CollectionVector  collections)
inline

Definition at line 405 of file GeometricDataWarehouse.hpp.

406 : m_collections(collections)
407 {
408 }

Member Function Documentation

◆ Create() [1/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const CoordKey< TData > &  coordKey)

Definition at line 391 of file GeometricDataWarehouseDef.hpp.

393{
394 // Use maximum vector width for back-ends interoperability.
395 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
396
397 // Fetch data from key.
398 const auto block_idx = coordKey.m_block_idx;
399 const auto interleave_width = coordKey.m_interleave_width;
400 const auto transpose = coordKey.m_transpose;
401
402 // Fetch expansion.
403 auto coll = m_collections[block_idx].GetExpVector();
404 auto expPtr = coll[0];
405 const auto num_elements = coll.size();
406 const auto num_elmt_groups =
407 ((num_elements + vector_width - 1) / vector_width) * vector_width /
408 interleave_width;
409
410 const auto nDim = expPtr->GetCoordim();
411 const auto range1 = transpose ? nDim : expPtr->GetTotPoints();
412 const auto range2 = transpose ? expPtr->GetTotPoints() : nDim;
413
414 // Allocate memory and get pointer.
415 const auto memsize =
416 num_elmt_groups * interleave_width * expPtr->GetTotPoints() * nDim;
417 auto crds = LibUtilities::MemoryRegion<TData>(memsize);
418 auto crdptr = crds.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
419
420 // Loop over chunks.
421 for (size_t chunk = 0, el = 0, crd_id = 0; chunk < num_elmt_groups; ++chunk)
422 {
423 // Loop over component or points
424 for (unsigned index1 = 0; index1 < range1; ++index1)
425 {
426 // Loop over points or components
427 for (unsigned index2 = 0; index2 < range2; ++index2)
428 {
429 // Loop over interleave width
430 for (unsigned i = 0; i < interleave_width; ++i, ++crd_id)
431 {
432 // Check for padding
433 if (el + i < num_elements)
434 {
435 const auto d = transpose ? index1 : index2;
436 const auto pt = transpose ? index2 : index1;
437
438 auto tmp = coll[el + i]->GetCoords();
439 crdptr[crd_id] = tmp[d][pt];
440 }
441 else
442 {
443 crdptr[crd_id] = 0.0;
444 }
445 }
446 }
447 }
448
449 el += interleave_width;
450 }
451
452 return crds;
453}
SpatialDomains::Geometry * el
std::vector< double > d(NPUPPER *NPUPPER)
static constexpr unsigned int value
Definition Backends.hpp:213

References el, Nektar::LocalRegions::CoordKey< TData >::m_block_idx, m_collections, Nektar::LocalRegions::CoordKey< TData >::m_interleave_width, and Nektar::LocalRegions::CoordKey< TData >::m_transpose.

◆ Create() [2/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const DerivFactorKey< TData > &  derivFactorKey)

Definition at line 284 of file GeometricDataWarehouseDef.hpp.

286{
287 // Use maximum vector width for back-ends interoperability.
288 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
289
290 // Fetch data from key.
291 const auto block_idx = derivFactorKey.m_block_idx;
292 const auto interleave_width = derivFactorKey.m_interleave_width;
293 const auto transpose = derivFactorKey.m_transpose;
294
295 // Fetch expansion.
296 auto coll = m_collections[block_idx].GetExpVector();
297 auto expPtr = coll[0];
298 const auto num_elements = coll.size();
299 const bool isDeformed =
300 (expPtr->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed);
301 const auto nDim = expPtr->GetShapeDimension();
302 const auto nCoord = expPtr->GetCoordim();
303 const auto num_elmt_groups =
304 ((num_elements + vector_width - 1) / vector_width) * vector_width /
305 interleave_width;
306
307 const auto range1 = transpose ? nDim * nCoord : expPtr->GetTotPoints();
308 const auto range2 = transpose ? expPtr->GetTotPoints() : nDim * nCoord;
309
310 // Allocate memory and get pointer.
311 const auto memsize =
312 (isDeformed) ? num_elmt_groups * interleave_width *
313 expPtr->GetTotPoints() * nDim * nCoord
314 : num_elmt_groups * interleave_width * nDim * nCoord;
315 auto df = LibUtilities::MemoryRegion<TData>(memsize);
316 auto dfptr = df.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
317
318 // Deformed geometry.
319 if (isDeformed)
320 {
321 // Loop over chunks.
322 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
323 {
324 // Loop over component 1.
325 for (unsigned int index1 = 0; index1 < range1; ++index1)
326 {
327 // Loop over component 2.
328 for (unsigned int index2 = 0; index2 < range2; ++index2)
329 {
330 // Loop over interleave width.
331 for (unsigned int i = 0; i < interleave_width; ++i)
332 {
333 // Check for padding.
334 if (el + i < num_elements)
335 {
336 const auto d = transpose ? index1 : index2;
337 const auto pt = transpose ? index2 : index1;
338
339 auto &tmp = coll[el + i]
340 ->GetGeomFactors()
341 ->GetDerivFactors();
342 *(dfptr++) = tmp[d][pt];
343 }
344 else
345 {
346 *(dfptr++) = 0.0;
347 }
348 }
349 }
350 }
351
352 el += interleave_width;
353 }
354
355 return df;
356 }
357 // Regular geometry.
358 else
359 {
360 // Loop over chunks.
361 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
362 {
363 // Loop over component.
364 for (unsigned int d = 0; d < nDim * nCoord; ++d)
365 {
366 // Loop over interleave width.
367 for (unsigned int i = 0; i < interleave_width; ++i)
368 {
369 // Check for padding.
370 if (el + i < num_elements)
371 {
372 auto &tmp =
373 coll[el + i]->GetGeomFactors()->GetDerivFactors();
374 *(dfptr++) = tmp[d][0];
375 }
376 else
377 {
378 *(dfptr++) = 0.0;
379 }
380 }
381 }
382
383 el += interleave_width;
384 }
385
386 return df;
387 }
388}
@ eDeformed
Geometry is curved or has non-constant factors.

References Nektar::SpatialDomains::eDeformed, el, Nektar::LocalRegions::DerivFactorKey< TData >::m_block_idx, m_collections, Nektar::LocalRegions::DerivFactorKey< TData >::m_interleave_width, and Nektar::LocalRegions::DerivFactorKey< TData >::m_transpose.

◆ Create() [3/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const ElmtInvMassKey< TData > &  elmtInvMassKey)

Definition at line 1410 of file GeometricDataWarehouseDef.hpp.

1412{
1413 // Use maximum vector width for back-ends interoperability.
1414 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
1415
1416 // Fetch data from key.
1417 const auto block_idx = elmtInvMassKey.m_block_idx;
1418
1419 // Fetch expansion.
1420 auto coll = m_collections[block_idx].GetExpVector();
1421 const auto num_elements = coll.size();
1422 const auto nmTot = coll[0]->GetNcoeffs();
1423 const auto num_elements_with_padding =
1424 ((num_elements + vector_width - 1) / vector_width) * vector_width;
1425
1426 ASSERTL1(coll[0]->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed,
1427 "ElmtInvMassKey requires a block of deformed elements.");
1428
1429 // Allocate memory and get pointer.
1430 auto invmass = LibUtilities::MemoryRegion<TData>(num_elements_with_padding *
1431 nmTot * nmTot);
1432 auto invmassptr =
1433 invmass.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
1434
1435 // Loop over elements; the padded elements are zero.
1436 for (size_t el = 0; el < num_elements_with_padding; ++el)
1437 {
1438 if (el < num_elements)
1439 {
1440 const auto &InvMass = coll[el]->GetLocMatrix(StdRegions::eInvMass);
1441 std::copy_n(InvMass->GetRawPtr(), nmTot * nmTot, invmassptr);
1442 }
1443 else
1444 {
1445 std::fill_n(invmassptr, nmTot * nmTot, 0.0);
1446 }
1447 invmassptr += nmTot * nmTot;
1448 }
1449
1450 return invmass;
1451}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....

References ASSERTL1, Nektar::SpatialDomains::eDeformed, Nektar::StdRegions::eInvMass, el, Nektar::LocalRegions::ElmtInvMassKey< TData >::m_block_idx, and m_collections.

◆ Create() [4/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Nektar::LocalRegions::GeometricDataCreator::Create ( const InteriorMapKey< TData > &  interiorMapKey)

◆ Create() [5/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Nektar::LocalRegions::GeometricDataCreator::Create ( const InteriorMapKey< TData > &  interiorMapKey)

Definition at line 606 of file GeometricDataWarehouseDef.hpp.

608{
609 // Fetch data from key.
610 const auto block_idx = interiorMapKey.m_block_idx;
611
612 // Get the reference element.
613 // Note the interior map is equivalent for all elements within a block.
614 auto coll = m_collections[block_idx].GetExpVector();
615 auto expPtr = coll[0];
616
617 // Get size of interior map
618 auto numInteriorCoeffs = expPtr->GetNcoeffs() - expPtr->NumBndryCoeffs();
619
620 // Allocate memory and get pointer.
621 const auto memsize = numInteriorCoeffs;
622 auto map = LibUtilities::MemoryRegion<unsigned>(memsize);
623 auto mapptr = map.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
624
625 // Allocate temporary arrays for map and sign
626 Array<OneD, unsigned> tmpMap(numInteriorCoeffs);
627
628 // Extract map
629 expPtr->GetInteriorMap(tmpMap);
630
631 // Assign map to memory region
632 for (unsigned nm = 0; nm < numInteriorCoeffs; ++nm)
633 {
634 *(mapptr++) = tmpMap[nm];
635 }
636
637 return map;
638}

References Nektar::LocalRegions::InteriorMapKey< TData >::m_block_idx, and m_collections.

◆ Create() [6/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const JacNormGeomFactorLocTraceKey< TData > &  jacnormgeomfacLocTraceKey)

Definition at line 1052 of file GeometricDataWarehouseDef.hpp.

1054{
1055 // Use maximum vector width for back-ends interoperability.
1056 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
1057
1058 const auto block_idx = jacnormgeomfacLocTraceKey.m_block_idx;
1059 const auto interleave_width = jacnormgeomfacLocTraceKey.m_interleave_width;
1060 const auto facDir = jacnormgeomfacLocTraceKey.m_dir;
1061
1062 auto collVec = m_collections[block_idx].GetExpVector();
1063 auto locExpPtr = collVec[0];
1064 const auto nDim = locExpPtr->GetShapeDimension();
1065 LibUtilities::ShapeType shape = locExpPtr->DetShapeType();
1066
1067 const auto num_elements = collVec.size();
1068 const auto num_elmt_groups =
1069 ((num_elements + vector_width - 1) / vector_width) * vector_width /
1070 interleave_width;
1071
1072 // A collapsed shape needs a factor per trace point whatever its geometry
1073 // type: eta_0 varies along edge 0 of a triangle, so the regular part of
1074 // the chain rule varies with it. The operator makes the same decision, so
1075 // the two agree on the layout of this array.
1076 bool isDeformed = TraceDerivFactorsArePointwise(
1077 shape,
1078 locExpPtr->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed);
1079
1080 // A segment is handled on its own. Its traces are the two vertices, and
1081 // a 0D trace is a point: no trace quadrature, no orientation, and a unit
1082 // trace jacobian. None of the trace expansion machinery below applies -
1083 // GetStdTraceExp does not even exist for a Seg - and all that is left is
1084 // the normal derivative factor at each vertex, which
1085 // Expansion1D::v_NormalTraceDerivFactors returns as factors[trace][0].
1086 if (nDim == 1)
1087 {
1088 const auto nTrace = LibUtilities::ShapeTypeNumTraces[shape];
1089 const auto memsize = num_elmt_groups * interleave_width * nTrace;
1090
1091 auto jacngf = LibUtilities::MemoryRegion<TData>(memsize);
1092 auto ptr = jacngf.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
1093
1094 Array<OneD, Array<OneD, Array<OneD, double>>> dfac(3);
1095
1096 // No collapsed direction in 1D, so eta is only here to satisfy the
1097 // shared signature; the Seg branch of CollCoordDfactor ignores it.
1098 const double eta[3] = {-1.0, -1.0, -1.0};
1099
1100 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
1101 {
1102 for (unsigned i = 0; i < interleave_width; ++i, ++el)
1103 {
1104 if (el < num_elements)
1105 {
1106 auto Exp = collVec[el];
1107 if (facDir < 0)
1108 {
1109 Exp->NormalTraceDerivFactors(dfac[0], dfac[1], dfac[2]);
1110 }
1111 else
1112 {
1113 Exp->TraceDerivFactors(facDir, dfac[0], dfac[1],
1114 dfac[2]);
1115 }
1116
1117 for (unsigned n = 0; n < nTrace; ++n)
1118 {
1119 ptr[n * interleave_width + i] = static_cast<TData>(
1120 CollCoordDfactor(dfac, shape, n, eta, 0, 0));
1121 }
1122 }
1123 else
1124 {
1125 // Padding lane.
1126 for (unsigned n = 0; n < nTrace; ++n)
1127 {
1128 ptr[n * interleave_width + i] = 0.0;
1129 }
1130 }
1131 }
1132 ptr += interleave_width * nTrace;
1133 }
1134
1135 return jacngf;
1136 }
1137
1138 // caculate the total number of quadrature points
1139 std::vector<unsigned> nTracePts;
1140 unsigned nTraceJacPoints = 0;
1141 for (unsigned dir = 0; dir < nDim; ++dir)
1142 {
1143 auto ntraces = LibUtilities::ShapeTypeNumTraceInDir[shape][dir];
1144
1145 // first trace id
1146 auto traceId = LibUtilities::ShapeTypeTraceIDInDir[shape][dir][0];
1147
1148 auto npts = locExpPtr->GetStdTraceExp(traceId)->GetTotPoints();
1149 nTracePts.push_back(npts);
1150
1151 if (isDeformed)
1152 {
1153 nTraceJacPoints += npts * ntraces;
1154 }
1155 else
1156 {
1157 nTraceJacPoints += ntraces;
1158 }
1159 }
1160
1161 // The nDim components are stored one whole component after the other,
1162 // so the stride from one component to the next is the size of a single
1163 // component and not the size of the entire region.
1164 const auto compStride =
1165 num_elmt_groups * interleave_width * nTraceJacPoints;
1166 const auto memsize = compStride * nDim;
1167 auto jacngf = LibUtilities::MemoryRegion<TData>(memsize);
1168 auto jacngfptr =
1169 jacngf.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
1170
1171 Array<OneD, Array<OneD, Array<OneD, double>>> dfactors(3);
1172
1173 // Collapsed coordinates along each trace, taken from the trace's own
1174 // expansion. These are not in general the element's abscissae: a
1175 // modified triangle carries Gauss-Radau points in direction 1 but hands
1176 // its edges 1 and 2 a Gauss-Lobatto basis with one extra point, so
1177 // indexing the element's array by a trace point index reads both the
1178 // wrong values and, on the last point, off the end.
1179 //
1180 // Indexed by legacy trace id, then by trace direction.
1181 std::vector<std::vector<Array<OneD, const double>>> ztr(
1183
1184 for (unsigned dir = 0; dir < nDim; ++dir)
1185 {
1186 auto ntraces = LibUtilities::ShapeTypeNumTraceInDir[shape][dir];
1187 for (unsigned n = 0; n < ntraces; ++n)
1188 {
1189 auto traceId = LibUtilities::ShapeTypeTraceIDInDir[shape][dir][n];
1190 auto stdExp = locExpPtr->GetStdTraceExp(traceId);
1191
1192 for (unsigned k = 0; k + 1 < nDim; ++k)
1193 {
1194 ztr[traceId].push_back(stdExp->GetBasis(k)->GetZ());
1195 }
1196 }
1197 }
1198
1199 // Fill the collapsed coordinates of trace point pt on trace traceId,
1200 // whose normal direction is normDir and which sits at eta = +/- 1 there.
1201 auto SetEta = [&](const LocalRegions::ExpansionSharedPtr &Exp,
1202 const unsigned traceId, const unsigned normDir,
1203 const bool atPlusOne, const unsigned pt, double *eta) {
1204 eta[0] = eta[1] = eta[2] = -1.0;
1205 eta[normDir] = atPlusOne ? 1.0 : -1.0;
1206
1207 if (nDim == 2)
1208 {
1209 eta[Exp->GetGeom()->GetDir(traceId, 0)] = ztr[traceId][0][pt];
1210 }
1211 else if (nDim == 3)
1212 {
1213 const auto n0 = ztr[traceId][0].size();
1214 eta[Exp->GetGeom()->GetDir(traceId, 0)] = ztr[traceId][0][pt % n0];
1215 eta[Exp->GetGeom()->GetDir(traceId, 1)] = ztr[traceId][1][pt / n0];
1216 }
1217 };
1218
1219 // Loop over chunks.
1220 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
1221 {
1222 for (unsigned i = 0; i < interleave_width; ++i, ++el)
1223 {
1224 // The deriv factors are element dependent, so they have to be
1225 // regenerated for every element in the chunk rather than once
1226 // per chunk from the chunk's first element.
1227 if (el < num_elements)
1228 {
1229 auto Exp = collVec[el];
1230
1231 // get hold of d0factors dxi_0/dx nx + dxi_0/dy ny ,
1232 // d1factors = dxi_1/dx nx + dxi_1/dy ny etc on traces in
1233 // legacy format - or, for facDir >= 0, the uncontracted
1234 // dxi_e/dx_facDir of that one Cartesian direction, feeding
1235 // the vector-input lift. The chain-rule combination and the
1236 // trace Jacobian below are direction-blind, so everything
1237 // downstream is shared.
1238 if (facDir < 0)
1239 {
1240 Exp->NormalTraceDerivFactors(dfactors[0], dfactors[1],
1241 dfactors[2]);
1242 }
1243 else
1244 {
1245 Exp->TraceDerivFactors(facDir, dfactors[0], dfactors[1],
1246 dfactors[2]);
1247 }
1248 }
1249
1250 unsigned offset = 0;
1251 for (unsigned dir = 0; dir < nDim; ++dir)
1252 {
1253 auto ntraces = LibUtilities::ShapeTypeNumTraceInDir[shape][dir];
1254
1255 // Loop over traces
1256 for (unsigned n = 0; n < ntraces; ++n)
1257 {
1258 auto traceId =
1260
1261 // Index for edge id
1262 if (el < num_elements)
1263 {
1264 auto Exp = collVec[el];
1265
1266 // Trace geometry comes from the aligned expansion, so
1267 // it is laid out in the global trace frame; the
1268 // standard trace expansion supplies the element local
1269 // extents.
1270 auto alignedExp = Exp->GetAlignedTraceExp(traceId);
1271 auto stdExp = Exp->GetStdTraceExp(traceId);
1272
1273 // Get trace Jacobian
1274 auto jacArray = alignedExp->GetGeomFactors()->GetJac();
1275
1276 if (isDeformed)
1277 {
1278 auto TraceDeformed =
1279 (alignedExp->GetGeomFactors()->GetGtype() ==
1281
1282 if (TraceDeformed)
1283 {
1284 // The deriv factors are already in the element
1285 // local frame, so scatter the Jacobian into
1286 // the same frame before combining the two
1287 // (global -> local, hence Forwards = false).
1288 //
1289 // A 2D element needs this just as much as a
1290 // 3D one: its edges 2 and 3 run against the
1291 // local coordinate, so a backwards oriented
1292 // edge has to be reversed.
1293 Array<OneD, double> jacLoc;
1294 const auto orient =
1295 Exp->GetTraceOrient(traceId);
1296 const auto identity =
1297 (nDim == 3)
1299 : StdRegions::eForwards;
1300
1301 if (orient != identity)
1302 {
1303 jacLoc =
1304 Array<OneD, double>(nTracePts[dir]);
1305 Exp->ReOrientTracePhysVals(
1306 orient, jacArray, jacLoc,
1307 stdExp->GetNumPoints(0),
1308 (nDim == 3) ? stdExp->GetNumPoints(1)
1309 : 1,
1310 false);
1311 }
1312 else
1313 {
1314 jacLoc = jacArray;
1315 }
1316
1317 for (unsigned pt = 0; pt < nTracePts[dir]; ++pt)
1318 {
1319 double eta[3];
1320 SetEta(Exp, traceId, dir, n == 1, pt, eta);
1321
1322 for (unsigned d = 0; d < nDim; ++d)
1323 {
1324 double fac = CollCoordDfactor(
1325 dfactors, shape, traceId, eta, d,
1326 pt);
1327
1328 jacngfptr[(offset + pt) *
1329 interleave_width +
1330 i + d * compStride] =
1331 jacLoc[pt] * fac;
1332 }
1333 }
1334 }
1335 else
1336 {
1337 for (unsigned pt = 0; pt < nTracePts[dir]; ++pt)
1338 {
1339 double eta[3];
1340 SetEta(Exp, traceId, dir, n == 1, pt, eta);
1341
1342 for (unsigned d = 0; d < nDim; ++d)
1343 {
1344 double fac = CollCoordDfactor(
1345 dfactors, shape, traceId, eta, d,
1346 pt);
1347
1348 jacngfptr[(offset + pt) *
1349 interleave_width +
1350 i + d * compStride] =
1351 jacArray[0] * fac;
1352 }
1353 }
1354 }
1355 offset += nTracePts[dir];
1356 }
1357 else
1358 {
1359 // A regular trace carries one factor, so the
1360 // collapsed correction is evaluated at the first
1361 // trace point.
1362 double eta[3];
1363 SetEta(Exp, traceId, dir, n == 1, 0, eta);
1364
1365 for (unsigned d = 0; d < nDim; ++d)
1366 {
1367 double fac = CollCoordDfactor(
1368 dfactors, shape, traceId, eta, d, 0);
1369 jacngfptr[offset * interleave_width + i +
1370 d * compStride] = jacArray[0] * fac;
1371 }
1372 offset++;
1373 }
1374 }
1375 else
1376 {
1377 if (isDeformed)
1378 {
1379 for (unsigned pt = 0; pt < nTracePts[dir]; ++pt)
1380 {
1381 for (unsigned d = 0; d < nDim; ++d)
1382 {
1383 jacngfptr[(offset + pt) * interleave_width +
1384 i + d * compStride] = 0.0;
1385 }
1386 }
1387 offset += nTracePts[dir];
1388 }
1389 else
1390 {
1391 for (unsigned d = 0; d < nDim; ++d)
1392 {
1393 jacngfptr[offset * interleave_width + i +
1394 d * compStride] = 0.0;
1395 }
1396 offset++;
1397 }
1398 }
1399 }
1400 }
1401 ASSERTL1(offset == nTraceJacPoints,
1402 "Tot Jacobian points not correct");
1403 }
1404 jacngfptr += interleave_width * nTraceJacPoints;
1405 }
1406 return jacngf;
1407}
constexpr unsigned int ShapeTypeNumTraceInDir[SIZE_ShapeType][3]
constexpr unsigned int ShapeTypeTraceIDInDir[SIZE_ShapeType][3][2]
constexpr unsigned int ShapeTypeNumTraces[SIZE_ShapeType]
double CollCoordDfactor(Array< OneD, Array< OneD, Array< OneD, double > > > &dfactors, LibUtilities::ShapeType shape, const unsigned traceId, const double *eta, const unsigned d, const unsigned pt)
bool TraceDerivFactorsArePointwise(LibUtilities::ShapeType shape, bool isDeformed)
std::shared_ptr< Expansion > ExpansionSharedPtr
Definition Expansion.h:66

References ASSERTL1, Nektar::LocalRegions::CollCoordDfactor(), Nektar::SpatialDomains::eDeformed, Nektar::StdRegions::eDir1FwdDir1_Dir2FwdDir2, Nektar::StdRegions::eForwards, el, Nektar::LocalRegions::JacNormGeomFactorLocTraceKey< TData >::m_block_idx, m_collections, Nektar::LocalRegions::JacNormGeomFactorLocTraceKey< TData >::m_dir, Nektar::LocalRegions::JacNormGeomFactorLocTraceKey< TData >::m_interleave_width, Nektar::LibUtilities::ShapeTypeNumTraceInDir, Nektar::LibUtilities::ShapeTypeNumTraces, Nektar::LibUtilities::ShapeTypeTraceIDInDir, and Nektar::LocalRegions::TraceDerivFactorsArePointwise().

◆ Create() [7/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const JacobianKey< TData > &  jacobianKey)

Definition at line 131 of file GeometricDataWarehouseDef.hpp.

133{
134 // Use maximum vector width for back-ends interoperability.
135 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
136
137 // Fetch data from key.
138 const auto block_idx = jacobianKey.m_block_idx;
139 const auto interleave_width = jacobianKey.m_interleave_width;
140
141 // Fetch expansion.
142 auto coll = m_collections[block_idx].GetExpVector();
143 auto expPtr = coll[0];
144 const auto num_elements = coll.size();
145 const bool isDeformed =
146 (expPtr->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed);
147 const auto num_elmt_groups =
148 ((num_elements + vector_width - 1) / vector_width) * vector_width /
149 interleave_width;
150
151 // Allocate memory and get pointer.
152 const auto memsize = (isDeformed) ? num_elmt_groups * interleave_width *
153 expPtr->GetTotPoints()
154 : num_elmt_groups * interleave_width;
155 auto jac = LibUtilities::MemoryRegion<TData>(memsize);
156 auto jacptr = jac.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
157
158 // Deformed geometry.
159 if (isDeformed)
160 {
161 Array<OneD, Array<OneD, double>> jacArray(interleave_width);
162
163 // Loop over chunks.
164 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
165 {
166 // Loop over interleave width
167 for (unsigned int i = 0; i < interleave_width; ++i, ++el)
168 {
169 // Check for padding
170 if (el < num_elements)
171 {
172 jacArray[i] = coll[el]->GetGeomFactors()->GetJac();
173 }
174 else
175 {
176 jacArray[i] =
177 Array<OneD, double>(expPtr->GetTotPoints(), 0.0);
178 }
179 }
180
181 // Save interleaved data.
182 for (unsigned int pt = 0; pt < expPtr->GetTotPoints(); ++pt)
183 {
184 for (unsigned i = 0; i < interleave_width; ++i)
185 {
186 *(jacptr++) = jacArray[i][pt];
187 }
188 }
189 }
190
191 return jac;
192 }
193 // Regular geometry.
194 else
195 {
196 auto jac = LibUtilities::MemoryRegion<TData>(num_elmt_groups *
197 interleave_width);
198 auto jacptr = jac.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
199
200 // Loop over chunks.
201 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
202 {
203 // Loop over interleave width
204 for (unsigned int i = 0; i < interleave_width; ++i, ++el)
205 {
206 // Check for padding
207 if (el < num_elements)
208 {
209 auto &auxJac = coll[el]->GetGeomFactors()->GetJac();
210 jacptr[el] = auxJac[0];
211 }
212 else
213 {
214 jacptr[el] = 0.0;
215 }
216 }
217 }
218
219 return jac;
220 }
221}
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 jac

References Nektar::SpatialDomains::eDeformed, el, Nektar::LocalRegions::JacobianKey< TData >::m_block_idx, m_collections, and Nektar::LocalRegions::JacobianKey< TData >::m_interleave_width.

◆ Create() [8/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const JacobianLocTraceKey< TData > &  jacobianLocTraceKey)

Definition at line 756 of file GeometricDataWarehouseDef.hpp.

758{
759 // Use maximum vector width for back-ends interoperability.
760 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
761
762 const auto block_idx = jacobianLocTraceKey.m_block_idx;
763 const auto interleave_width = jacobianLocTraceKey.m_interleave_width;
764
765 auto coll = m_collections[block_idx].GetExpVector();
766 auto expPtr = coll[0];
767 const auto nDim = expPtr->GetShapeDimension();
768
769 const auto num_elements = coll.size();
770 const auto num_elmt_groups =
771 ((num_elements + vector_width - 1) / vector_width) * vector_width /
772 interleave_width;
773
774 // get total trace size
775 LibUtilities::ShapeType shape = expPtr->DetShapeType();
776
777 // if element deformed treat trace group as deformed.
778 bool isDeformed =
779 (expPtr->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed);
780
781 // caculate the total number of quadrature points
782 std::vector<unsigned> nTracePts;
783 unsigned nTraceJacPoints = 0;
784 for (unsigned dir = 0; dir < nDim; ++dir)
785 {
786 auto ntraces = LibUtilities::ShapeTypeNumTraceInDir[shape][dir];
787
788 // first trace id
789 auto traceId = LibUtilities::ShapeTypeTraceIDInDir[shape][dir][0];
790
791 auto npts = expPtr->GetStdTraceExp(traceId)->GetTotPoints();
792 nTracePts.push_back(npts);
793
794 if (isDeformed)
795 {
796 nTraceJacPoints += npts * ntraces;
797 }
798 else
799 {
800 nTraceJacPoints += ntraces;
801 }
802 }
803
804 const auto memsize = num_elmt_groups * interleave_width * nTraceJacPoints;
805 auto jac = LibUtilities::MemoryRegion<TData>(memsize);
806 auto jacptr = jac.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
807
808 // Loop over chunks.
809 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
810 {
811 for (unsigned i = 0; i < interleave_width; ++i, ++el)
812 {
813 unsigned offset = 0;
814 for (unsigned dir = 0; dir < nDim; ++dir)
815 {
816 auto ntraces = LibUtilities::ShapeTypeNumTraceInDir[shape][dir];
817
818 // Loop over traces
819 for (unsigned n = 0; n < ntraces; ++n)
820 {
821 auto traceId =
823
824 // Index for edge id
825 if (el < num_elements)
826 {
827 auto elExp = coll[el];
828
829 // Trace geometry comes from the aligned expansion, so
830 // it is laid out in the global trace frame; the
831 // standard trace expansion supplies the element local
832 // extents.
833 auto alignedExp = elExp->GetAlignedTraceExp(traceId);
834 auto stdExp = elExp->GetStdTraceExp(traceId);
835
836 // Get trace Jacobian
837 auto jacArray = alignedExp->GetGeomFactors()->GetJac();
838
839 if (isDeformed)
840 {
841 auto TraceDeformed =
842 (alignedExp->GetGeomFactors()->GetGtype() ==
844
845 if (TraceDeformed)
846 {
847 // This operator consumes the element local
848 // trace, so scatter the Jacobian into the
849 // local frame (global -> local, hence
850 // Forwards = false, with local extents).
851 //
852 // A 2D element needs this just as much as a
853 // 3D one: its edges 2 and 3 run against the
854 // local coordinate, so a backwards oriented
855 // edge has to be reversed.
856 const auto orient =
857 elExp->GetTraceOrient(traceId);
858 const auto identity =
859 (nDim == 3)
861 : StdRegions::eForwards;
862
863 if (orient != identity)
864 {
865 Array<OneD, double> jacLoc(nTracePts[dir]);
866 elExp->ReOrientTracePhysVals(
867 orient, jacArray, jacLoc,
868 stdExp->GetNumPoints(0),
869 (nDim == 3) ? stdExp->GetNumPoints(1)
870 : 1,
871 false);
872
873 for (unsigned pt = 0; pt < nTracePts[dir];
874 ++pt)
875 {
876 jacptr[(offset + pt) *
877 interleave_width +
878 i] = jacLoc[pt];
879 }
880 }
881 else
882 {
883 for (unsigned pt = 0; pt < nTracePts[dir];
884 ++pt)
885 {
886 jacptr[(offset + pt) *
887 interleave_width +
888 i] = jacArray[pt];
889 }
890 }
891 }
892 else
893 {
894 for (unsigned pt = 0; pt < nTracePts[dir]; ++pt)
895 {
896 jacptr[(offset + pt) * interleave_width +
897 i] = jacArray[0];
898 }
899 }
900 offset += nTracePts[dir];
901 }
902 else
903 {
904 jacptr[offset * interleave_width + i] = jacArray[0];
905 offset++;
906 }
907 }
908 else
909 {
910 if (isDeformed)
911 {
912 for (unsigned pt = 0; pt < nTracePts[dir]; ++pt)
913 {
914 jacptr[(offset + pt) * interleave_width + i] =
915 0.0;
916 }
917 offset += nTracePts[dir];
918 }
919 else
920 {
921 jacptr[offset * interleave_width + i] = 0.0;
922 offset++;
923 }
924 }
925 }
926 }
927 ASSERTL1(offset == nTraceJacPoints,
928 "Tot Jacobian points not correct");
929 }
930 jacptr += interleave_width * nTraceJacPoints;
931 }
932 return jac;
933}

References ASSERTL1, Nektar::SpatialDomains::eDeformed, Nektar::StdRegions::eDir1FwdDir1_Dir2FwdDir2, Nektar::StdRegions::eForwards, el, Nektar::LocalRegions::JacobianLocTraceKey< TData >::m_block_idx, m_collections, Nektar::LocalRegions::JacobianLocTraceKey< TData >::m_interleave_width, Nektar::LibUtilities::ShapeTypeNumTraceInDir, and Nektar::LibUtilities::ShapeTypeTraceIDInDir.

◆ Create() [9/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const JacobianTraceKey< TData > &  jacobianTraceKey)

Definition at line 641 of file GeometricDataWarehouseDef.hpp.

643{
644 // Use maximum vector width for back-ends interoperability.
645 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
646
647 // Fetch data from key.
648 const auto block_idx = jacobianTraceKey.m_block_idx;
649 const auto interleave_width = jacobianTraceKey.m_interleave_width;
650
651 auto coll = m_collections[block_idx].GetExpVector();
652 auto expPtr = coll[0];
653 const auto num_elements = coll.size();
654 // Assume non-deformed edge for now.
655 const bool isDeformed = false;
656 // const bool isDeformed =
657 // (expPtr->GetGeomFactors()->GetGtype() == SpatialDomains::eDeformed);
658 const auto nedge = expPtr->GetGeom()->GetNumEdges();
659 const auto num_elmt_groups =
660 ((num_elements + vector_width - 1) / vector_width) * vector_width /
661 interleave_width;
662
663 // Allocate memory.
664 auto nTraceJacPoints = 0;
665 for (int ed = 0; ed < nedge; ed++)
666 {
667 nTraceJacPoints += expPtr->GetTraceExp(ed)->GetTotPoints();
668 }
669
670 const auto memsize =
671 (isDeformed) ? num_elmt_groups * interleave_width * nTraceJacPoints
672 : num_elmt_groups * interleave_width * nedge;
673 auto jac = LibUtilities::MemoryRegion<TData>(memsize);
674 auto jacptr = jac.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
675
676 // Deformed geometry.
677 if (isDeformed)
678 {
679 Array<OneD, Array<OneD, double>> jacArray(interleave_width);
680
681 // Loop over chunks.
682 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
683 {
684 // Loop over edges.
685 for (unsigned int ed = 0; ed < nedge; ++ed)
686 {
687 for (unsigned int i = 0; i < interleave_width; ++i)
688 {
689 // Check for padding.
690 if (el + i < num_elements)
691 {
692 // Get trace expansion.
693 auto traceExp = coll[el + i]->GetTraceExp(ed);
694
695 // Get trace Jacobian.
696 jacArray[i] = traceExp->GetGeomFactors()->GetJac();
697 }
698 else
699 {
700 jacArray[i] = Array<OneD, double>(
701 expPtr->GetTraceExp(ed)->GetTotPoints(), 0.0);
702 }
703 }
704
705 // Save interleaved data.
706 for (unsigned int pt = 0;
707 pt < expPtr->GetTraceExp(ed)->GetTotPoints(); ++pt)
708 {
709 for (unsigned int i = 0; i < interleave_width; ++i)
710 {
711 *(jacptr++) = jacArray[i][pt];
712 }
713 }
714 }
715
716 el += interleave_width;
717 }
718
719 return jac;
720 }
721 // Regular geometry.
722 else
723 {
724 // Loop over chunks.
725 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
726 {
727 // Loop over edges.
728 for (unsigned int ed = 0; ed < nedge; ++ed)
729 {
730 for (unsigned int i = 0; i < interleave_width; ++i)
731 {
732 if (el + i < num_elements)
733 {
734 // Get trace expansion.
735 auto traceExp = coll[el + i]->GetTraceExp(ed);
736
737 // Get trace Jacobian.
738 auto &auxJac = traceExp->GetGeomFactors()->GetJac();
739 *(jacptr++) = auxJac[0];
740 }
741 else
742 {
743 *(jacptr++) = 0.0;
744 }
745 }
746 }
747
748 el += interleave_width;
749 }
750
751 return jac;
752 }
753}

References el, Nektar::LocalRegions::JacobianTraceKey< TData >::m_block_idx, m_collections, and Nektar::LocalRegions::JacobianTraceKey< TData >::m_interleave_width.

◆ Create() [10/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Nektar::LocalRegions::GeometricDataCreator::Create ( const OrientKey< TData > &  orientKey)

◆ Create() [11/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Nektar::LocalRegions::GeometricDataCreator::Create ( const OrientKey< TData > &  orientKey)

Definition at line 456 of file GeometricDataWarehouseDef.hpp.

458{
459 // Use maximum vector width for back-ends interoperability.
460 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
461
462 // Fetch data from key.
463 const auto block_idx = orientKey.m_block_idx;
464 const auto interleave_width = orientKey.m_interleave_width;
465
466 // Fetch expansion.
467 auto coll = m_collections[block_idx].GetExpVector();
468 auto expPtr = coll[0];
469 const auto num_elements = coll.size();
470 const auto nedge = expPtr->GetGeom()->GetNumEdges();
471 const auto num_elmt_groups =
472 ((num_elements + vector_width - 1) / vector_width) * vector_width /
473 interleave_width;
474
475 // Allocate memory and get pointer.
476 const auto memsize = num_elmt_groups * interleave_width * nedge;
477 auto orients = LibUtilities::MemoryRegion<unsigned int>(memsize);
478 auto orientptr =
479 orients.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
480
481 // Loop over chunks.
482 for (size_t chunk = 0, el = 0, orient_id = 0; chunk < num_elmt_groups;
483 ++chunk)
484 {
485 // Loop over component or points
486 for (unsigned int ed = 0; ed < nedge; ++ed)
487 {
488 // Loop over interleave width
489 for (unsigned i = 0; i < interleave_width; ++i, ++orient_id)
490 {
491 // Check for padding
492 if (el + i < num_elements)
493 {
494 auto orient = coll[el + i]->GetTraceOrient(ed);
495 orientptr[orient_id] = static_cast<unsigned int>(orient);
496 }
497 else
498 {
499 orientptr[orient_id] =
500 static_cast<unsigned>(StdRegions::eForwards);
501 }
502 }
503 }
504
505 el += interleave_width;
506 }
507
508 return orients;
509}

References Nektar::StdRegions::eForwards, el, Nektar::LocalRegions::OrientKey< TData >::m_block_idx, m_collections, and Nektar::LocalRegions::OrientKey< TData >::m_interleave_width.

◆ Create() [12/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const QuadratureMetricKey< TData > &  quadratureMetricKey)

Definition at line 224 of file GeometricDataWarehouseDef.hpp.

226{
227 // Use maximum vector width for back-ends interoperability.
228 const auto vector_width = NektarSpaces::max_vector_width<TData>::value;
229
230 // Fetch data from key.
231 const auto block_idx = quadratureMetricKey.m_block_idx;
232 const auto interleave_width = quadratureMetricKey.m_interleave_width;
233
234 // Fetch expansion.
235 auto coll = m_collections[block_idx].GetExpVector();
236 const auto num_elements = coll.size();
237 const auto num_points = coll[0]->GetTotPoints();
238 const auto num_elmt_groups =
239 ((num_elements + vector_width - 1) / vector_width) * vector_width /
240 interleave_width;
241
242 // Allocate memory and get pointer.
243 auto metric = LibUtilities::MemoryRegion<TData>(
244 num_elmt_groups * interleave_width * num_points);
245 auto metricptr =
246 metric.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
247
248 // The metric of each element is its quadrature metric applied to one.
249 Array<OneD, NekDouble> one(num_points, 1.0);
250 Array<OneD, NekDouble> elementMetric(num_points, 0.0);
251
252 // Loop over chunks.
253 for (size_t chunk = 0, el = 0; chunk < num_elmt_groups; ++chunk)
254 {
255 // Loop over interleave width
256 for (unsigned int i = 0; i < interleave_width; ++i, ++el)
257 {
258 // Check for padding
259 if (el < num_elements)
260 {
261 coll[el]->MultiplyByQuadratureMetric(one, elementMetric);
262 }
263 else
264 {
265 for (unsigned int pt = 0; pt < num_points; ++pt)
266 {
267 elementMetric[pt] = 0.0;
268 }
269 }
270
271 // Save interleaved data.
272 for (unsigned int pt = 0; pt < num_points; ++pt)
273 {
274 metricptr[(chunk * num_points + pt) * interleave_width + i] =
275 elementMetric[pt];
276 }
277 }
278 }
279
280 return metric;
281}

References el, Nektar::LocalRegions::QuadratureMetricKey< TData >::m_block_idx, m_collections, and Nektar::LocalRegions::QuadratureMetricKey< TData >::m_interleave_width.

◆ Create() [13/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned int > Nektar::LocalRegions::GeometricDataCreator::Create ( const TraceToElmtMapKey< TData > &  traceToElmtMapKey)

◆ Create() [14/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< unsigned > Nektar::LocalRegions::GeometricDataCreator::Create ( const TraceToElmtMapKey< TData > &  traceToElmtMapKey)

Definition at line 512 of file GeometricDataWarehouseDef.hpp.

514{
515 // Fetch data from key.
516 const auto block_idx = traceToElmtMapKey.m_block_idx;
517
518 // Get the reference element.
519 // Note the traceToElemtMap is equivalent for all elements within a block.
520 auto coll = m_collections[block_idx].GetExpVector();
521 auto expPtr = coll[0];
522 const auto nedge = expPtr->GetGeom()->GetNumEdges();
523
524 // Total nummodes for trace
525 auto nmTrace = 0;
526 std::vector<unsigned int> nmEdge;
527 for (int i = 0; i < nedge; i++)
528 {
529 nmTrace += expPtr->GetTraceNcoeffs(i);
530 nmEdge.push_back(expPtr->GetTraceNcoeffs(i));
531 }
532
533 // Allocate memory and get pointer.
534 const auto memsize = nmTrace;
535 auto map = LibUtilities::MemoryRegion<unsigned>(memsize);
536 auto mapptr = map.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
537
538 // Loop over component or points
539 for (unsigned int ed = 0; ed < nedge; ++ed)
540 {
541 // Allocate temporary arrays for map and sign
542 Array<OneD, unsigned> tmpMap(nmEdge[ed], (unsigned)0);
543 Array<OneD, int> tmpSign(nmEdge[ed], 1);
544
545 // Extract map and sign
546 expPtr->GetTraceToElementMap(ed, tmpMap, tmpSign);
547
548 // Assign map to memory region
549 for (unsigned nm = 0; nm < nmEdge[ed]; ++nm)
550 {
551 *(mapptr++) = tmpMap[nm];
552 }
553 }
554
555 return map;
556}

References Nektar::LocalRegions::TraceToElmtMapKey< TData >::m_block_idx, and m_collections.

◆ Create() [15/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< int > Nektar::LocalRegions::GeometricDataCreator::Create ( const TraceToElmtSignKey< TData > &  traceToElmtSignKey)

Definition at line 559 of file GeometricDataWarehouseDef.hpp.

561{
562 // Fetch data from key.
563 const auto block_idx = traceToElmtSignKey.m_block_idx;
564
565 // Get the reference element.
566 // Note the sign is equivalent for all elements within a block.
567 auto coll = m_collections[block_idx].GetExpVector();
568 auto expPtr = coll[0];
569 const auto nedge = expPtr->GetGeom()->GetNumEdges();
570
571 // Total nummodes for trace
572 auto nmTrace = 0;
573 for (int ed = 0; ed < nedge; ed++)
574 {
575 nmTrace += expPtr->GetTraceNcoeffs(ed);
576 }
577
578 // Allocate memory and get pointer.
579 const auto memsize = nmTrace;
580 auto sign = LibUtilities::MemoryRegion<int>(memsize);
581 auto signptr = sign.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
582
583 // Loop over number of edges
584
585 for (unsigned int ed = 0; ed < nedge; ++ed)
586 {
587 // Allocate temporary arrays for map and sign
588 Array<OneD, unsigned int> tmpMap(expPtr->GetTraceNcoeffs(ed),
589 (unsigned)0);
590 Array<OneD, int> tmpSign(expPtr->GetTraceNcoeffs(ed), 1);
591
592 // Extract map and sign
593 expPtr->GetTraceToElementMap(ed, tmpMap, tmpSign);
594
595 // Assign map to memory region
596 for (unsigned int nm = 0; nm < expPtr->GetTraceNcoeffs(ed); ++nm)
597 {
598 *(signptr++) = tmpSign[nm];
599 }
600 }
601
602 return sign;
603}
#define sign(a, b)
return the sign(b)*a
Definition Polylib.cpp:47

References Nektar::LocalRegions::TraceToElmtSignKey< TData >::m_block_idx, m_collections, and sign.

◆ Create() [16/16]

template<typename MemSpace , typename TData >
LibUtilities::MemoryRegion< TData > Nektar::LocalRegions::GeometricDataCreator::Create ( const WeightsKey< TData > &  weightsKey)

Definition at line 48 of file GeometricDataWarehouseDef.hpp.

50{
51 // Fetch data from key.
52 const auto block_idx = weightsKey.m_block_idx;
53 const auto interleave_width = weightsKey.m_interleave_width;
54
55 // Fetch expansion.
56 auto coll = m_collections[block_idx].GetExpVector();
57 auto expPtr = coll[0];
58
59 // Allocate memory and get pointer.
60 const auto memsize = interleave_width * expPtr->GetTotPoints();
61 auto weights = LibUtilities::MemoryRegion<TData>(memsize);
62
63 auto wptr = weights.template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
64
65 auto dimension = expPtr->GetShapeDimension();
66
67 auto W = expPtr->GetQuadratureWeights();
68
69 switch (dimension)
70 {
71 case 1:
72 {
73 auto nq0 = expPtr->GetNumPoints(0);
74 for (unsigned i = 0; i < nq0; ++i)
75 {
76 for (unsigned wd = 0; wd < interleave_width; ++wd)
77 {
78 wptr[i * interleave_width + wd] = W[0][i];
79 }
80 }
81 }
82 break;
83 case 2:
84 {
85 auto nq0 = expPtr->GetNumPoints(0);
86 auto nq1 = expPtr->GetNumPoints(1);
87
88 for (unsigned j = 0; j < nq1; ++j)
89 {
90 for (unsigned i = 0; i < nq0; ++i)
91 {
92 auto offset = (j * nq0 + i) * interleave_width;
93 for (unsigned wd = 0; wd < interleave_width; ++wd)
94 {
95 wptr[offset + wd] = W[1][j] * W[0][i];
96 }
97 }
98 }
99 }
100 break;
101 case 3:
102 {
103 auto nq0 = expPtr->GetNumPoints(0);
104 auto nq1 = expPtr->GetNumPoints(1);
105 auto nq2 = expPtr->GetNumPoints(2);
106 auto nq01 = nq0 * nq1;
107
108 for (unsigned k = 0; k < nq2; ++k)
109 {
110 for (unsigned j = 0; j < nq1; ++j)
111 {
112 auto w12 = W[1][j] * W[2][k];
113 for (unsigned i = 0; i < nq0; ++i)
114 {
115 auto offset =
116 (k * nq01 + j * nq0 + i) * interleave_width;
117 for (unsigned wd = 0; wd < interleave_width; ++wd)
118 {
119 wptr[offset + wd] = w12 * W[0][i];
120 }
121 }
122 }
123 }
124 }
125 break;
126 }
127 return weights;
128}

References Nektar::LocalRegions::WeightsKey< TData >::m_block_idx, m_collections, and Nektar::LocalRegions::WeightsKey< TData >::m_interleave_width.

Member Data Documentation

◆ m_collections

Collections::CollectionVector Nektar::LocalRegions::GeometricDataCreator::m_collections
private

◆ m_name

const std::string Nektar::LocalRegions::GeometricDataCreator::m_name = "GeometricDataCreator"
inlinestatic

Definition at line 461 of file GeometricDataWarehouse.hpp.