7#include <Kokkos_Core.hpp>
32template<
typename ValueType>
36 std::pair<localIdx, localIdx> range,
44 auto [refGradV, valueV, valueFractionV, refValueV, boundaryFaceOwnersV] =
views(
56 const localIdx owner = boundaryFaceOwnersV[i];
57 const auto internal = internalV[owner];
60 const NeoN::scalar valueFraction = (hasFlux && boundaryFlux[i] < 0.0) ? 1.0 : 0.0;
62 valueFractionV[i] = valueFraction;
63 refValueV[i] = inletValue;
64 refGradV[i] = NeoN::zero<ValueType>();
65 valueV[i] = inletValue * valueFraction + internal * (1.0 - valueFraction);
82template<
typename ValueType>
91 using Base::correctBoundaryCondition;
100 : Base(mesh, dict, patchID, {.assignable =
true, .fixesValue =
false}), mesh_(mesh),
101 inletValue_(dict.get<ValueType>(
"inletValue")),
102 phiName_(dict.contains(
"phi") ? dict.get<std::string>(
"phi") : std::string(
"phi"))
117 if (ctx.hasSurfaceScalar(phiName_))
119 const auto& phi = ctx.surfaceScalarField(phiName_);
125 phi.boundaryData().value().view(),
135 static std::string
name() {
return "inletOutlet"; }
141 return "Inlet/outlet: fixed inletValue on inflow faces, zero-gradient on outflow faces "
142 "(switched per face by the sign of the face flux phi).";
145 static std::string
schema() {
return "none"; }
147 virtual std::unique_ptr<VolumeBoundaryFactory<ValueType>>
clone() const final
149 return std::make_unique<InletOutlet>(*
this);
155 ValueType inletValue_;
156 std::string phiName_;
const labelVector & faceOwners() const
Get the list of labels of owner cells of boundary faces.
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
const Vector< ValueType > & internalVector() const
Represents an unstructured mesh in NeoN.
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
Carries named field references for context-aware boundary conditions.
std::string getName() const override
static std::string schema()
static std::string name()
virtual void correctBoundaryCondition(Field< ValueType > &domainVector) final
virtual void correctBoundaryCondition(Field< ValueType > &domainVector, const BoundaryContext &ctx) final
InletOutlet(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID)
virtual std::unique_ptr< VolumeBoundaryFactory< ValueType > > clone() const final
A template class for registering derived classes with a base class.
void setInletOutletValue(Field< ValueType > &domainVector, const UnstructuredMesh &mesh, std::pair< localIdx, localIdx > range, ValueType inletValue, View< const NeoN::scalar > boundaryFlux, bool hasFlux)
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.