7#include <Kokkos_Core.hpp>
36template<
typename ValueType>
40 std::pair<localIdx, localIdx> range,
48 auto [refGradV, valueV, valueFractionV, refValueV] =
views(
64 [[maybe_unused]]
const bool velocityKnown = hasVelocity;
68 const bool inflow = hasFlux && boundaryFlux[i] <
NeoN::scalar(0);
71 if constexpr (std::is_same<ValueType, NeoN::scalar>::value)
73 if (inflow && velocityKnown)
75 const Vec3 u = velocity[i];
76 const NeoN::scalar magSqrU = u[0] * u[0] + u[1] * u[1] + u[2] * u[2];
86 "setTotalPressureValue"
104template<
typename ValueType>
112 using Base::correctBoundaryCondition;
118 : Base(mesh, dict,
patchID, {.assignable =
true, .fixesValue =
true}), mesh_(mesh),
119 p0_(dict.get<ValueType>(
"p0")),
120 phiName_(dict.contains(
"phi") ? dict.get<std::string>(
"phi") : std::string(
"phi")),
121 uName_(dict.contains(
"U") ? dict.get<std::string>(
"U") : std::string(
"U"))
143 const bool hasFlux = ctx.hasSurfaceScalar(phiName_);
144 const bool hasVelocity = ctx.hasVector(uName_);
151 hasFlux ? ctx.surfaceScalarField(phiName_).boundaryData().value().view()
154 hasVelocity ? ctx.vectorFieldPtr(uName_).boundaryData().value().view()
160 static std::string
name() {
return "totalPressure"; }
166 return "Total-pressure patch: static pressure p0 on outflow, p0 minus the dynamic "
167 "head 0.5*magSqr(U) on inflow, so the entering stream carries total pressure "
168 "p0. Needs phi and U in the BoundaryContext; without them it is a fixedValue "
172 static std::string
schema() {
return "none"; }
174 std::unique_ptr<VolumeBoundaryFactory<ValueType>>
clone() const final
176 return std::make_unique<TotalPressure>(*
this);
183 std::string phiName_;
A class representing a dictionary that stores key-value pairs.
Represents the domain fields for a computational domain.
const BoundaryData< ValueType > & boundaryData() const
const Executor & exec() const
Represents an unstructured mesh in NeoN.
A class for the representation of a 3D Vec3.
Carries named field references for context-aware boundary conditions.
std::pair< localIdx, localIdx > range() const
VolumeBoundaryFactory(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID, BoundaryAttributes attributes)
static std::string name()
virtual void correctBoundaryCondition(Field< ValueType > &domainVector) final
static std::string schema()
virtual void correctBoundaryCondition(Field< ValueType > &domainVector, const BoundaryContext &ctx) final
TotalPressure(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID)
std::unique_ptr< VolumeBoundaryFactory< ValueType > > clone() const final
std::string getName() const override
A template class for registering derived classes with a base class.
void setTotalPressureValue(Field< ValueType > &domainVector, const UnstructuredMesh &mesh, std::pair< localIdx, localIdx > range, ValueType p0, View< const NeoN::scalar > boundaryFlux, bool hasFlux, View< const Vec3 > boundaryVelocity, bool hasVelocity)
KOKKOS_INLINE_FUNCTION T zero()
void parallelFor(const ExecutorType &, std::pair< localIdx, localIdx > range, const Kernel &kernel, std::string name)
auto views(Types &... args)
Unpacks all views of the passed classes.