68template <
typename ExecSpace,
typename TData>
class HOutflowBndCondOpImpl;
79template <
typename ExecSpace,
typename TData>
84 const std::vector<std::string> &components)
85 : MultiRegions::
DirBndCondOp<TData>(expansionList, components)
109 return m_owner->GetNumPressureBndDofs();
128template <
typename ExecSpace,
typename TData>
133 const std::vector<std::string> &components)
134 : MultiRegions::
NeuBndCondOp<TData>(expansionList, components)
159 return m_owner->GetNumVelocityBndDofs();
165 m_owner->AddVelocitySurfaceIntegral(data);
169 [[maybe_unused]]
const std::string &userDefinedType)
override
172 "only its own regions; it has no default "
173 "regions to exclude.");
196template <
typename ExecSpace,
typename TData>
206 const std::vector<std::string> &pressureComponents)
209 ASSERTL1(pressureComponents.size() == 1,
210 "HOutflow expects one pressure component.");
211 ASSERTL1(std::dynamic_pointer_cast<MultiRegions::ContField>(
212 pressureExpansionList),
213 "HOutflow requires a continuous pressure field.");
214 m_coordDim = pressureExpansionList->GetCoordim(0);
216 auto session = pressureExpansionList->GetSession();
220 session->LoadParameter(
"U0_HighOrderBC",
m_U0, TData(1));
221 session->LoadParameter(
"Delta_HighOrderBC",
m_delta, TData(1.0 / 20.0));
223 "HOutflow requires positive U0_HighOrderBC and "
224 "Delta_HighOrderBC.");
228 std::make_shared<HOutflowPressureAdapter<ExecSpace, TData>>(
229 pressureExpansionList, pressureComponents);
230 std::dynamic_pointer_cast<HOutflowPressureAdapter<ExecSpace, TData>>(
237 static std::unique_ptr<MultiRegions::Operator<TData>>
Instantiate(
239 const std::vector<std::string> &components)
241 return std::make_unique<HOutflowBndCondOpImpl<ExecSpace, TData>>(
242 expansionList, components);
332 std::vector<LibUtilities::Field<TData, FieldState::Coeff>>
335 std::vector<LibUtilities::Field<TData, FieldState::Coeff>>
340 std::vector<LibUtilities::Field<TData, FieldState::Phys>>
m_fbPhys;
341 std::vector<LibUtilities::Field<TData, FieldState::Phys>>
m_normals;
343 std::vector<LibUtilities::Field<TData, FieldState::Phys>>
m_divergence;
344 std::vector<std::shared_ptr<MultiRegions::FwdTransBCOp<TData>>>
346 std::vector<std::shared_ptr<MultiRegions::IProductWRTBaseOp<TData>>>
348 std::vector<std::shared_ptr<MultiRegions::ExpressionOp<TData>>>
357 std::vector<std::shared_ptr<
363 std::vector<std::shared_ptr<
369 std::vector<std::shared_ptr<
432 const std::vector<std::string> &velocityComponents)
override
435 "Insufficient velocity components for HOutflow.");
436 const std::vector<std::string> components(velocityComponents.begin(),
437 velocityComponents.begin() +
444 std::make_shared<HOutflowVelocityAdapter<ExecSpace, TData>>(
445 velocityExpansionList, components);
446 std::dynamic_pointer_cast<HOutflowVelocityAdapter<ExecSpace, TData>>(
455 "SetVelocityContext must be called before UpdatePressure.");
457 "HOutflow requires a positive kinematic viscosity, set by "
467 const unsigned int interleaveWidth =
469 .GetInterleaveWidth();
478 m_pressureUpdated =
true;
488 for (
unsigned int blk = 0; blk < out.GetBlocks().size(); ++blk)
490 const unsigned int streamID = blk + 1;
492 auto &outBlock = out.GetBlocks()[blk];
493 const unsigned int interleaveWidth = outBlock.GetInterleaveWidth();
495 outBlock.template GetPtr<MemSpace, ReadWrite>(streamID);
503 interleaveWidth, streamID)
504 .template GetPtr<MemSpace, ReadOnly>(streamID) +
508 .template GetPtr<MemSpace, ReadOnly>(streamID) +
516 MultiRegions::detail::DirBndCondKernel<ExecSpace>(
517 count, signPtr, mapPtr, coeffPtr, outPtr, streamID);
521 MultiRegions::detail::DirBndCondKernel<ExecSpace>(
522 count, mapPtr, coeffPtr, outPtr, streamID);
537 "UpdatePressure must precede the velocity solve.");
539 "SetPressure must be called before the velocity solve.");
541 "HOutflow requires a positive kinematic viscosity, set by "
559 const auto &bndExpansions =
564 this->m_expansionList->GetGraph());
566 for (
const auto &[regionId, region] : bregions)
571 "Boundary region and expansion counts differ.");
573 std::vector<std::vector<bool>> isTypeByRegion(bndExpansions.size());
574 std::vector<size_t> numBcExpCoeffs(bndExpansions.size());
575 for (
unsigned int n = 0; n < bndExpansions.size(); ++n)
577 const bool match =
IsHOutflow(bndConditions[n]);
578 ASSERTL0(!match || bndConditions[n]->GetBoundaryConditionType() ==
580 "HOutflow pressure conditions must be Dirichlet.");
581 isTypeByRegion[n] = {match};
582 numBcExpCoeffs[n] = bndExpansions[n]->GetNcoeffs();
588 auto bndExp = bndExpansions[n];
589 bndExp->SetDataWarehouse();
595 const auto physBlocks =
596 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
597 bndExp, MultiRegions::UnitInterleaveWidths(bndExp));
598 const auto coeffBlocks =
599 MultiRegions::GetBlockAttributes<TData, FieldState::Coeff>(
600 bndExp, MultiRegions::UnitInterleaveWidths(bndExp));
604 "HOutflow pressure boundary coeffs", coeffBlocks,
606 m_pressureBndPhys.back().template Initialize<MemSpace>(0.0);
619 "HOutflow is implemented for two and three dimensions.");
621 MultiRegions::detail::BuildCGBndCondCoeffMaps<ExecSpace, TData>(
625 [](
unsigned int,
const auto &,
const auto &,
const auto &) {});
649 const std::vector<std::string> &components)
653 this->m_expansionList->GetGraph());
656 const auto &velocityExp =
659 "Pressure and velocity boundary region counts differ.");
663 std::vector<std::vector<bool>> isTypeByRegion(
m_regionIds.size());
664 std::vector<size_t> numBcExpCoeffs(
m_regionIds.size());
667 std::vector<std::vector<bool>> velocityIsComp;
669 for (
unsigned int n = 0; n <
m_regionIds.size(); ++n)
671 const auto conditionIt = conditions.find(
m_regionIds[n]);
672 ASSERTL0(conditionIt != conditions.end(),
673 "Unable to locate HOutflow boundary region.");
674 bool anyVelocityTag =
false;
675 bool allVelocityHOutflow =
true;
676 bool isTimeDependent =
false;
677 std::vector<LibUtilities::EquationSharedPtr> equations;
678 std::vector<bool> componentMatches(
m_coordDim,
false);
681 const auto componentIt =
682 conditionIt->second->find(components[d]);
683 ASSERTL0(componentIt != conditionIt->second->end(),
684 "Unable to locate HOutflow velocity component.");
685 const bool tagged =
IsHOutflow(componentIt->second);
687 tagged && componentIt->second->GetBoundaryConditionType() ==
689 anyVelocityTag = anyVelocityTag || tagged;
690 allVelocityHOutflow = allVelocityHOutflow && valid;
691 componentMatches[d] = valid;
692 equations.push_back(componentIt->second->GetEquation());
695 isTimeDependent = isTimeDependent || variables.count(
"t") != 0;
698 const bool pressureSelected = selected.count(n) != 0;
699 ASSERTL0(!anyVelocityTag || pressureSelected,
700 "HOutflow velocity conditions require a paired "
701 "HOutflow pressure Dirichlet condition.");
702 ASSERTL0(!pressureSelected || allVelocityHOutflow,
703 "HOutflow pressure conditions require HOutflow Neumann "
704 "conditions on every velocity component.");
705 isTypeByRegion[n] = pressureSelected
708 numBcExpCoeffs[n] = velocityExp[n]->GetNcoeffs();
709 if (!pressureSelected)
715 auto bndExp = velocityExp[n];
716 bndExp->SetDataWarehouse();
722 ASSERTL0(bndExp->SameQuadratureLayout(pressureBndExp),
723 "HOutflow requires the velocity and pressure boundary "
724 "expansions to share their quadrature points.");
726 velocityIsComp.push_back(componentMatches);
730 const auto physBlocks =
731 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
732 bndExp, MultiRegions::UnitInterleaveWidths(bndExp));
733 const auto coeffBlocks =
734 MultiRegions::GetBlockAttributes<TData, FieldState::Coeff>(
735 bndExp, MultiRegions::UnitInterleaveWidths(bndExp));
737 physBlocks, components, 1);
739 "HOutflow velocity boundary coeffs", coeffBlocks, components,
741 m_fbPhys.emplace_back(
"HOutflow f_b", physBlocks, components, 1);
742 m_normals.emplace_back(
"HOutflow normals", physBlocks, components,
746 m_divergence.emplace_back(
"HOutflow divergence", physBlocks,
748 m_velocityBndPhys.back().template Initialize<MemSpace>(0.0);
750 m_fbPhys.back().template Initialize<MemSpace>(0.0);
751 m_normals.back().template Initialize<MemSpace>(0.0);
756 bndExp, components, ExecSpace::name);
757 expression->SetExpressions(equations);
762 bndExp, components, ExecSpace::name));
766 for (
unsigned int blk = 0;
767 blk <
m_normals.back().GetBlocks().size(); ++blk)
769 auto &normalBlock =
m_normals.back().GetBlocks()[blk];
772 .template GetPtr<NektarSpaces::HostSpace, WriteOnly>();
774 const auto &expansions = collection.GetExpVector();
775 for (
unsigned int e = 0; e < expansions.size(); ++e)
778 bndExp->GetPhys_Offset(expansions[e]->GetElmtId());
781 for (
unsigned int p = 0; p < normalBlock.GetNumData();
784 ptr[d * normalBlock.CompSize() +
785 e * normalBlock.GetNumData() + p] =
786 static_cast<TData
>(normals[d][offset + p]);
794 "HOutflow pressure and velocity region sets differ.");
803 this->
m_expansionList->GetSession()->GetComm()->GetRowComm()->AllReduce(
805 if (hasAnyVelocityBndCoeff == 0)
811 MultiRegions::detail::BuildCGBndCondCoeffMaps<ExecSpace, TData>(
815 [](
unsigned int,
const auto &,
const auto &,
const auto &) {});
850 const size_t nDomainBlocks,
853 size_t nUpdateStreams = nDomainBlocks;
854 for (
auto &field : fields)
856 nUpdateStreams = std::max(nUpdateStreams, field.GetBlocks().size());
858 std::vector<unsigned int> streams;
859 for (
unsigned int id = 1;
id <= nUpdateStreams; ++
id)
861 streams.push_back(
id);
874 const auto coeffBlocks =
875 MultiRegions::GetBlockAttributes<TData, FieldState::Coeff>(
877 MultiRegions::UnitInterleaveWidths(expansionList));
878 std::vector<CoeffTargets> targets(unitWidthIndex.size());
879 for (
unsigned int blk = 0; blk < unitWidthIndex.size(); ++blk)
881 targets[blk].nCoeffs = coeffBlocks[blk].GetNumData();
882 const size_t nTargets = unitWidthIndex[blk].size();
887 .template GetPtr<NektarSpaces::HostSpace, ReadOnly>();
888 targets[blk].elmtCoeff.assign(elmtCoeff, elmtCoeff + nTargets);
900 struct VolumeLocation
908 auto &locations,
auto &owners) {
910 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
911 list, MultiRegions::UnitInterleaveWidths(list));
912 for (
unsigned int blk = 0; blk < blocks.size(); ++blk)
915 const auto &expansions = collection.GetExpVector();
916 for (
unsigned int e = 0; e < expansions.size(); ++e)
919 expansions[e]->GetGeom()->GetGlobalID();
920 locations[geometry] = {blk, e, expansions[e]};
921 for (
unsigned int f = 0; f < expansions[e]->GetNtraces();
924 owners[expansions[e]->GetGeom()->GetTid(f)] = {geometry,
931 std::map<int, VolumeLocation> velocityLocations;
932 std::map<int, std::pair<int, unsigned int>> velocityOwners;
940 std::set<int> selectedVelocityGeometry;
944 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
946 MultiRegions::UnitInterleaveWidths(
948 for (
unsigned int blk = 0; blk < blocks.size(); ++blk)
952 const auto &expansions = collection.GetExpVector();
953 for (
unsigned int e = 0; e < expansions.size(); ++e)
955 const auto owner = velocityOwners.find(
956 expansions[e]->GetGeom()->GetGlobalID());
957 ASSERTL1(owner != velocityOwners.end(),
958 "Unable to locate an element adjacent to "
960 selectedVelocityGeometry.insert(owner->second.first);
966 const auto &velocityInfo =
969 for (
const auto geometry : selectedVelocityGeometry)
971 const auto it = velocityInfo.find(geometry);
973 "Unable to locate HOutflow velocity expansion data.");
974 restrictedInfo.emplace(*it);
980 const auto restrictedBlocks =
981 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
983 MultiRegions::UnitInterleaveWidths(
986 "HOutflow restricted velocity", restrictedBlocks, components, 1);
993 "d" + components[d] +
"d" + std::to_string(j);
997 "HOutflow restricted velocity gradient", restrictedBlocks,
998 gradientComponents, 1);
1002 std::map<int, VolumeLocation> restrictedLocations;
1003 std::map<int, std::pair<int, unsigned int>> unusedOwners;
1009 std::map<std::pair<unsigned int, unsigned int>,
1010 std::map<size_t, size_t>>
1012 for (
const int geometry : selectedVelocityGeometry)
1014 const auto &src = velocityLocations.at(geometry);
1015 const auto &dst = restrictedLocations.at(geometry);
1016 gathers[{src.block, dst.block}][dst.element] = src.element;
1018 for (
auto &[blocks, map] : gathers)
1023 gather.
nData = restrictedBlocks[blocks.second].GetNumData();
1024 for (
const auto &[dstElmt, srcElmt] : map)
1026 gather.
dstElmt.push_back(dstElmt);
1027 gather.
srcElmt.push_back(srcElmt);
1045 const auto bndPhysBlocks =
1046 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
1048 MultiRegions::UnitInterleaveWidths(
1057 bndPhysBlocks, components, 1);
1066 m_bndGradient.emplace_back(
"HOutflow boundary velocity gradient",
1067 bndPhysBlocks, gradientComponents, 1);
1074 m_pressureBndExpLists[n], ExecSpace::name));
1089 const std::vector<size_t> &elmts,
1090 const unsigned int interleaveWidth,
1091 const unsigned int dstInterleaveWidth)
1093 std::vector<size_t> index;
1094 index.reserve(elmts.size() * gather.
nData);
1097 for (
size_t first = 0; first < elmts.size();)
1099 const size_t dstGroup = gather.
dstElmt[first] / dstInterleaveWidth;
1100 size_t last = first + 1;
1101 while (last < elmts.size() &&
1102 gather.
dstElmt[last] / dstInterleaveWidth == dstGroup)
1106 for (
size_t q = 0; q < gather.
nData; ++q)
1108 for (
size_t k = first; k < last; ++k)
1110 const size_t group = elmts[k] / interleaveWidth;
1111 const size_t lane = elmts[k] % interleaveWidth;
1112 index.push_back(group * interleaveWidth * gather.
nData +
1113 q * interleaveWidth + lane);
1126 const unsigned int interleaveWidth)
1128 std::vector<size_t> index(targets.
elmtCoeff.size());
1129 for (
size_t k = 0; k < index.size(); ++k)
1133 const size_t group = elmt / interleaveWidth;
1134 const size_t lane = elmt % interleaveWidth;
1135 index[k] = group * interleaveWidth * targets.
nCoeffs +
1136 coeff * interleaveWidth + lane;
1144 template <
typename BuildIndexFn>
1147 const unsigned int streamID, BuildIndexFn &&buildIndex)
1150 "HOutflow takes fields at interleave width 1 or at the "
1151 "interleave width of its execution space.");
1152 const bool isUnitWidth = interleaveWidth == 1u;
1159 MemSpace,
size_t>(buildIndex(interleaveWidth), streamID);
1169 VolumeGather &gather,
const unsigned int srcInterleaveWidth,
1170 const unsigned int dstInterleaveWidth,
const unsigned int streamID)
1172 ASSERTL0((srcInterleaveWidth == 1u ||
1174 (dstInterleaveWidth == 1u ||
1176 "HOutflow takes fields at interleave width 1 or at the "
1177 "interleave width of its execution space.");
1178 auto [it, isNew] = gather.
indices.try_emplace(
1179 std::make_pair(srcInterleaveWidth, dstInterleaveWidth));
1182 it->second.srcIndex =
1186 dstInterleaveWidth),
1188 it->second.dstIndex =
1192 dstInterleaveWidth),
1205 const unsigned int interleaveWidth)
1208 "HOutflow takes fields at interleave width 1 or at the "
1209 "interleave width of its execution space.");
1210 bool isAtWidth =
true;
1211 for (
auto &block : field.GetBlocks())
1214 isAtWidth && block.GetInterleaveWidth() == interleaveWidth;
1218 Math::zero<ExecSpace>(field);
1219 field.SetInterleaveWidth(interleaveWidth);
1226 CoeffTargets &targets,
const unsigned int interleaveWidth,
1227 const unsigned int streamID)
1230 targets.
indices, interleaveWidth, streamID,
1231 [&targets](
const unsigned int blockInterleaveWidth) {
1232 return TargetIndex(targets, blockInterleaveWidth);
1245 const unsigned int srcStreamID = gather.srcBlock + 1;
1246 const unsigned int streamID = gather.dstBlock + 1;
1247 auto &srcBlock = velocity.
GetBlocks()[gather.srcBlock];
1250 RecordStreamEvent<ExecSpace>(srcStreamID);
1251 SetStreamDependencies<ExecSpace>(streamID, srcStreamID);
1254 gather, srcBlock.GetInterleaveWidth(),
1255 dstBlock.GetInterleaveWidth(), streamID);
1256 auto src = srcBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1259 auto dst = dstBlock.template GetPtr<MemSpace, ReadWrite>(streamID);
1261 indices.srcIndex.template GetPtr<MemSpace, ReadOnly>(streamID);
1263 indices.dstIndex.template GetPtr<MemSpace, ReadOnly>(streamID);
1264 const size_t nsize = gather.srcElmt.size() * gather.nData;
1267 HOutflowVolumeGatherKernel<ExecSpace, 2>(
1268 nsize, srcBlock.CompSize(), dstBlock.CompSize(), srcIdx,
1269 dstIdx, src, dst, streamID);
1273 HOutflowVolumeGatherKernel<ExecSpace, 3>(
1274 nsize, srcBlock.CompSize(), dstBlock.CompSize(), srcIdx,
1275 dstIdx, src, dst, streamID);
1277 RecordStreamEvent<ExecSpace>(streamID);
1282 const unsigned int srcStreamID = gather.srcBlock + 1;
1283 const unsigned int streamID = gather.dstBlock + 1;
1284 SetStreamDependencies<ExecSpace>(srcStreamID, streamID);
1292 for (
unsigned int n = 0; n <
m_fbPhys.size(); ++n)
1307 const TData kinvis,
const TData scale)
1315 for (
unsigned int blk = 0;
1320 const unsigned int streamID = blk + 1;
1324 auto &normalBlock =
m_normals[n].GetBlocks()[blk];
1325 auto &fbBlock =
m_fbPhys[n].GetBlocks()[blk];
1329 const size_t nPoints =
1330 pressureBlock.GetNumElementsWithPadding() *
1331 pressureBlock.GetNumData();
1332 const size_t compSize = velocityBlock.CompSize();
1335 velocityBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1337 gradientBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1339 normalBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1341 fbBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1343 pressureBlock.template GetPtr<MemSpace, WriteOnly>(
1346 energyBlock.template GetPtr<MemSpace, WriteOnly>(streamID);
1348 divBlock.template GetPtr<MemSpace, WriteOnly>(streamID);
1351 HOutflowPressureKernel<ExecSpace, 2>(
1352 nPoints, compSize, velocityPtr, gradientPtr, normalPtr,
1354 m_delta, pressurePtr, energyPtr, divPtr, streamID);
1358 HOutflowPressureKernel<ExecSpace, 3>(
1359 nPoints, compSize, velocityPtr, gradientPtr, normalPtr,
1361 m_delta, pressurePtr, energyPtr, divPtr, streamID);
1387 m_pressureBndPhys[n]);
1389 for (
unsigned int blk = 0;
1394 const unsigned int streamID = blk + 1;
1397 auto &normalBlock =
m_normals[n].GetBlocks()[blk];
1401 const size_t nPoints = outBlock.GetNumElementsWithPadding() *
1402 outBlock.GetNumData();
1403 const size_t compSize = outBlock.CompSize();
1406 pressureBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1408 normalBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1410 energyBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1412 divBlock.template GetPtr<MemSpace, ReadOnly>(streamID);
1414 outBlock.template GetPtr<MemSpace, WriteOnly>(streamID);
1417 HOutflowVelocityKernel<ExecSpace, 2>(
1418 nPoints, compSize, pressurePtr, normalPtr, energyPtr,
1419 divPtr, this->
m_kinvis, outPtr, streamID);
1423 HOutflowVelocityKernel<ExecSpace, 3>(
1424 nPoints, compSize, pressurePtr, normalPtr, energyPtr,
1425 divPtr, this->
m_kinvis, outPtr, streamID);
1438 [
this](
unsigned int n) {
1450 template <
typename ProjectFn>
1453 const std::vector<size_t> &offsets,
const size_t compSize,
1459 const std::vector<unsigned int> &updateStreams, ProjectFn &&project)
1465 const unsigned int nComp = fields[0].GetNumComponents();
1467 compact.template GetPtr<MemSpace, WriteOnly>(
m_opStreamID);
1469 for (
unsigned int n = 0; n < fields.size(); ++n)
1473 size_t regionOffset = 0;
1474 for (
unsigned int blk = 0; blk < fields[n].GetBlocks().size();
1477 const unsigned int streamID = blk + 1;
1478 auto &block = fields[n].GetBlocks()[blk];
1479 auto src = block.template GetPtr<MemSpace, ReadOnly>(streamID);
1480 const size_t blockLength =
1481 block.GetNumElements() * block.GetNumData();
1484 for (
unsigned int c = 0; c < nComp; ++c)
1486 Math::copyKernel<ExecSpace>(
1487 blockLength, src + c * block.CompSize(),
1488 compactPtr + c * compSize + offsets[n] + regionOffset,
1491 regionOffset += blockLength;
1500 ReleaseStreams<ExecSpace>(
m_opStreamID, updateStreams);
1502 for (
unsigned int blk = 0; blk < mappedCoefficients.size(); ++blk)
1504 const unsigned int streamID = blk + 1;
1506 MultiRegions::detail::CGBndCondGatherKernel<ExecSpace>(
1507 coefficientSources[blk].size(),
1508 coefficientSources[blk].
template GetPtr<MemSpace, ReadOnly>(
1511 mappedCoefficients[blk].
template GetPtr<MemSpace, WriteOnly>(
1516 MultiRegions::detail::CGBndCondGatherKernel<ExecSpace>(
1517 (*groupSources)[blk].size(),
1518 (*groupSources)[blk].
template GetPtr<MemSpace, ReadOnly>(
1521 (*groupValues)[blk].
template GetPtr<MemSpace, WriteOnly>(
1530 ReleaseStreams<ExecSpace>(
m_opStreamID, updateStreams);
1535 for (
unsigned int blk = 0; blk < inout.
GetBlocks().size(); ++blk)
1537 const unsigned int streamID = blk + 1;
1541 const unsigned int interleaveWidth = block.GetInterleaveWidth();
1542 auto ptr = block.template GetPtr<MemSpace, ReadWrite>(streamID);
1544 interleaveWidth, streamID)
1545 .template GetPtr<MemSpace, ReadOnly>(streamID);
1554 for (
unsigned int d = 0; d <
m_coordDim; ++d)
1562 MultiRegions::detail::NeuBndCondKernel<ExecSpace>(
1563 count,
sign + offset, map + offset, coeff + offset,
1564 ptr + d * block.CompSize(), streamID);
1568 MultiRegions::detail::NeuBndCondKernel<ExecSpace>(
1569 count, map + offset, coeff + offset,
1570 ptr + d * block.CompSize(), streamID);
1577 const size_t groupOffset =
1581 .template GetPtr<MemSpace, ReadOnly>(streamID) +
1585 interleaveWidth, streamID)
1586 .template GetPtr<MemSpace, ReadOnly>(streamID) +
1590 .template GetPtr<MemSpace, ReadOnly>(streamID);
1595 .template GetPtr<MemSpace, ReadOnly>(streamID);
1596 MultiRegions::detail::NeuBndCondGroupKernel<ExecSpace>(
1597 groupCount, groupOffsets, groupTargets, groupSigns,
1598 groupValues, ptr + d * block.CompSize(), streamID);
1602 MultiRegions::detail::NeuBndCondGroupKernel<ExecSpace>(
1603 groupCount, groupOffsets, groupTargets, groupValues,
1604 ptr + d * block.CompSize(), streamID);
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Per-block interface of the Expression operator, holding the evaluation settings shared by all back-en...
Public interface of the Expression operator, which evaluates analytical expressions at the quadrature...
Whole-field interface of the IProductWRTBase element operator, which takes a physical-space field to ...
Public interface of the physical-space derivative (PhysDeriv) element operator, which maps a field at...
#define sign(a, b)
return the sign(b)*a
LibUtilities::SessionReaderSharedPtr session
Dong's high-order outflow boundary condition, a pressure Dirichlet condition coupled with a velocity ...
std::shared_ptr< MultiRegions::NeuBndCondOp< TData > > m_velocityAdapter
std::shared_ptr< MultiRegions::DirBndCondOp< TData > > m_pressureAdapter
LibUtilities::Field< TData, FieldState::Phys > * m_pressure
Solved pressure, set by SetPressure(); not owned.
TData m_kinvis
Kinematic viscosity, set by SetKinvis().
TData m_scale
Scale of the velocity passed to UpdatePressure(), set by SetScale().
TData m_time
Time of the Neumann value f_b, set by SetTime().
A Field represents expansion data to be operated on.
std::vector< BlockAccessor< TData, TState > > & GetBlocks()
Get BlockAccessors for the field.
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::set< std::string > GetExpressionVariables(const std::string &expr)
The variables an expression uses: every name in expr that is not called as a function,...
static std::shared_ptr< ExpressionOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create an Expression operator through the two-stage element-operator factory and initialise its defau...
Whole-field interface of the inner product with the basis: integrates a physical-space field against ...
std::vector< std::string > m_components
Names of the field components the operator was built for.
MultiRegions::ExpListSharedPtr m_expansionList
Expansion list the operator acts on.
static std::shared_ptr< PhysDerivOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="", const std::string &implStr="")
Create a physical-derivative operator, its per-block operators and, for a multi-plane 3DH1 expansion,...
Adds the surface integral of boundary fields, per component and homogeneous plane,...
const BoundaryRegionCollection & GetBoundaryRegions(void) const
const BoundaryConditionCollection & GetBoundaryConditions(void) const
Implementation of HOutflowBndCondOp.
std::vector< std::shared_ptr< MultiRegions::detail::PhysTraceExtractBndCond< ExecSpace, TData > > > m_bndPressureExtractOps
std::vector< LibUtilities::MemoryRegion< size_t > > m_velocityGroupOffset
LibUtilities::Field< TData, FieldState::Phys > m_restrictedGradient
size_t GetNumVelocityBndDofs() const
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_bndGradient
void EvaluatePressure(LibUtilities::Field< TData, FieldState::Phys > &velocity, const TData kinvis, const TData scale)
static void SetRestrictedInterleaveWidth(LibUtilities::Field< TData, FieldState::Phys > &field, const unsigned int interleaveWidth)
std::vector< LibUtilities::Field< TData, FieldState::Coeff > > m_pressureBndCoeffs
static LibUtilities::MemoryRegion< size_t > & TargetsAtInterleaveWidth(CoeffTargets &targets, const unsigned int interleaveWidth, const unsigned int streamID)
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_divergence
size_t m_velocityNumBndCoeffCompSize
void v_UpdatePressure(LibUtilities::Field< TData, FieldState::Phys > &velocity) override
std::vector< unsigned int > m_pressureUpdateStreams
MultiRegions::detail::CGBndCondSurfaceIntegral< ExecSpace, TData > m_velocitySurfaceIntegral
std::vector< CoeffTargets > m_pressureMap
static std::vector< size_t > PointIndex(const VolumeGather &gather, const std::vector< size_t > &elmts, const unsigned int interleaveWidth, const unsigned int dstInterleaveWidth)
static GatherIndices & GatherIndicesAtInterleaveWidths(VolumeGather &gather, const unsigned int srcInterleaveWidth, const unsigned int dstInterleaveWidth, const unsigned int streamID)
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_fbPhys
std::vector< LibUtilities::MemoryRegion< size_t > > m_velocityGroupSrc
static LibUtilities::MemoryRegion< size_t > & IndexAtInterleaveWidth(InterleaveWidthIndices &indices, const unsigned int interleaveWidth, const unsigned int streamID, BuildIndexFn &&buildIndex)
MultiRegions::ExpListSharedPtr m_velocityExpansionList
std::vector< LibUtilities::MemoryRegion< TData > > m_velocityGroupValue
void ApplyVelocity(LibUtilities::Field< TData, FieldState::Coeff > &inout)
void ProjectAndGatherCoeffs(std::vector< LibUtilities::Field< TData, FieldState::Coeff > > &fields, const std::vector< size_t > &offsets, const size_t compSize, LibUtilities::MemoryRegion< TData > &compact, std::vector< LibUtilities::MemoryRegion< size_t > > &coefficientSources, std::vector< LibUtilities::MemoryRegion< TData > > &mappedCoefficients, std::vector< LibUtilities::MemoryRegion< size_t > > *groupSources, std::vector< LibUtilities::MemoryRegion< TData > > *groupValues, const std::vector< unsigned int > &updateStreams, ProjectFn &&project)
void ApplyNeumannMaps(LibUtilities::Field< TData, FieldState::Coeff > &inout)
std::vector< std::shared_ptr< MultiRegions::ExpressionOp< TData > > > m_fbExpressionOps
void ApplyPressure(LibUtilities::Field< TData, FieldState::Coeff > &out)
std::vector< LibUtilities::MemoryRegion< size_t > > m_pressureCoeffSrc
std::vector< unsigned int > m_pressureConditionIndices
static constexpr unsigned int m_opStreamID
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_pressureBndPhys
static constexpr unsigned int m_interleaveWidth
std::vector< LibUtilities::MemoryRegion< size_t > > m_velocityCoeffSrc
std::vector< LibUtilities::Field< TData, FieldState::Coeff > > m_velocityBndCoeffs
std::vector< std::vector< size_t > > m_velocityCompGroupOffsets
std::vector< std::shared_ptr< MultiRegions::FwdTransBCOp< TData > > > m_pressureFwdTransOps
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_bndVelocity
size_t m_pressureNumBndCoeffCompSize
void EvaluateFb(const TData time)
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_velocityBndPhys
std::vector< std::shared_ptr< MultiRegions::IProductWRTBaseOp< TData > > > m_velocityIProductOps
static std::vector< unsigned int > UpdateStreams(const size_t nDomainBlocks, std::vector< LibUtilities::Field< TData, FieldState::Coeff > > &fields)
std::vector< std::vector< size_t > > m_velocityCompCounts
size_t GetNumPressureBndDofs() const
static std::vector< size_t > TargetIndex(const CoeffTargets &targets, const unsigned int interleaveWidth)
std::vector< LibUtilities::MemoryRegion< TData > > m_velocityMappedCoeff
std::vector< bool > m_fbIsTimeDependent
std::vector< std::shared_ptr< MultiRegions::detail::PhysTraceExtractBndCond< ExecSpace, TData > > > m_bndGradientExtractOps
std::vector< MultiRegions::ExpListSharedPtr > m_velocityBndExpLists
static std::string className
std::vector< std::vector< size_t > > m_velocityCompOffsets
std::vector< bool > m_velocitySignChange
std::vector< CoeffTargets > BuildCoeffTargets(std::vector< LibUtilities::MemoryRegion< size_t > > &unitWidthIndex, const MultiRegions::ExpListSharedPtr &expansionList)
void BuildBoundaryElementData(const std::vector< std::string > &components)
LibUtilities::MemoryRegion< TData > m_velocityCompactCoeff
std::vector< size_t > m_pressureCounts
HOutflowBndCondOpImpl(const MultiRegions::ExpListSharedPtr &pressureExpansionList, const std::vector< std::string > &pressureComponents)
static std::unique_ptr< MultiRegions::Operator< TData > > Instantiate(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
LibUtilities::Field< TData, FieldState::Phys > m_restrictedVelocity
std::shared_ptr< MultiRegions::PhysDerivOp< TData > > m_physDerivOp
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_energyMinusFb
std::vector< CoeffTargets > m_velocityMap
std::vector< CoeffTargets > m_velocityGroupTarget
void BuildPressureBoundaryData()
void AddVelocitySurfaceIntegral(LibUtilities::MemoryRegion< TData > &data)
std::vector< size_t > m_velocityCoeffOffsets
static bool IsHOutflow(const SpatialDomains::BoundaryConditionShPtr &condition)
std::vector< std::vector< size_t > > m_velocityCompGroupCounts
bool m_pressureSignChange
std::vector< MultiRegions::ExpListSharedPtr > m_pressureBndExpLists
LibUtilities::MemoryRegion< TData > m_pressureCompactCoeff
std::vector< LibUtilities::MemoryRegion< TData > > m_pressureMappedCoeff
std::vector< LibUtilities::MemoryRegion< TData > > m_velocityGroupSign
std::vector< size_t > m_pressureOffsets
std::vector< VolumeGather > m_volumeGathers
std::vector< unsigned int > m_velocityUpdateStreams
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_normals
bool m_velocityAnySignChange
std::vector< unsigned int > m_regionIds
std::vector< LibUtilities::MemoryRegion< TData > > m_velocitySign
void GatherVelocity(LibUtilities::Field< TData, FieldState::Phys > &velocity)
typename ExecSpace::memory_space MemSpace
void ValidateAndBuildVelocityBoundaryData(const std::vector< std::string > &components)
std::vector< LibUtilities::MemoryRegion< TData > > m_pressureSign
std::vector< std::shared_ptr< MultiRegions::detail::PhysTraceExtractBndCond< ExecSpace, TData > > > m_bndVelocityExtractOps
void v_SetVelocityContext(const MultiRegions::ExpListSharedPtr &velocityExpansionList, const std::vector< std::string > &velocityComponents) override
MultiRegions::ExpListSharedPtr m_restrictedVelocityExpansionList
std::vector< size_t > m_pressureCoeffOffsets
The Dirichlet condition of the pressure system, which applies the pressure of the HOutflowBndCondOpIm...
void SetOwner(HOutflowBndCondOpImpl< ExecSpace, TData > *owner)
Set the operator whose pressure Apply() applies, which must outlive this one.
size_t v_GetNumBndDofs() const override
HOutflowBndCondOpImpl< ExecSpace, TData > * m_owner
void v_Apply(LibUtilities::Field< TData, FieldState::Coeff > &out) override
void v_UpdateBndCoeffs(const TData &time) override
HOutflowPressureAdapter(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
The Neumann condition of the velocity system, which applies the velocity flux of the HOutflowBndCondO...
HOutflowVelocityAdapter(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
void v_UpdateBndCoeffs(const TData &time) override
size_t v_GetNumBndDofs() override
void v_Apply(LibUtilities::Field< TData, FieldState::Coeff > &inout) override
void v_ExcludeUserDefinedType(const std::string &userDefinedType) override
void v_AddNeumannSurfaceIntegral(LibUtilities::MemoryRegion< TData > &data) override
HOutflowBndCondOpImpl< ExecSpace, TData > * m_owner
void SetOwner(HOutflowBndCondOpImpl< ExecSpace, TData > *owner)
Set the operator whose velocity flux Apply() applies, which must outlive this one.
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Collections::Collection GetCollection(MultiRegions::ExpListSharedPtr expansionList, unsigned int block_idx)
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
bool IEquals(std::string_view a, std::string_view b)
InterleaveWidthIndices indices
std::vector< size_t > elmtCoeff
LibUtilities::MemoryRegion< size_t > srcIndex
LibUtilities::MemoryRegion< size_t > dstIndex
LibUtilities::MemoryRegion< size_t > index
bool isBuiltInterleavedIndex
LibUtilities::MemoryRegion< size_t > interleavedIndex
std::vector< size_t > dstElmt
VolumeGather & operator=(const VolumeGather &)=delete
std::vector< size_t > srcElmt
VolumeGather & operator=(VolumeGather &&)=default
std::map< std::pair< unsigned int, unsigned int >, GatherIndices > indices
VolumeGather(VolumeGather &&)=default
VolumeGather(const VolumeGather &)=delete