17template<
typename ValueType>
20 size_t nInternalFaces,
21 std::span<const int> neighbour,
22 std::span<const int> owner,
23 std::span<const int> faceCells,
24 std::span<const ValueType> flux,
25 std::span<const scalar> V,
26 std::span<ValueType> res,
30 size_t nCells {V.size()};
31 const size_t nBoundaryFaces = faceCells.size();
33 if (std::holds_alternative<SerialExecutor>(exec))
35 for (
size_t i = 0; i < nInternalFaces; i++)
37 res[
static_cast<size_t>(owner[i])] += flux[i];
38 res[
static_cast<size_t>(neighbour[i])] -= flux[i];
41 for (
size_t i = nInternalFaces; i < nInternalFaces + nBoundaryFaces; i++)
43 auto own =
static_cast<size_t>(faceCells[i - nInternalFaces]);
48 for (
size_t celli = 0; celli < nCells; celli++)
50 res[celli] *= operatorScaling[celli] / V[celli];
58 KOKKOS_LAMBDA(
const size_t i) {
59 Kokkos::atomic_add(&res[
static_cast<size_t>(owner[i])], flux[i]);
60 Kokkos::atomic_sub(&res[
static_cast<size_t>(neighbour[i])], flux[i]);
66 {nInternalFaces, nInternalFaces + nBoundaryFaces},
67 KOKKOS_LAMBDA(
const size_t i) {
68 auto own =
static_cast<size_t>(faceCells[i - nInternalFaces]);
69 Kokkos::atomic_add(&res[own], flux[i]);
76 KOKKOS_LAMBDA(
const size_t celli) { res[celli] *= operatorScaling[celli] / V[celli]; }
82template<
typename ValueType>
91 : flux_(flux), type_(
dsl::Operator::Type::Explicit), coeffs_(1.0) {};
109 const auto exec = flux_.exec();
112 surfaceIntegrate<ValueType>(
118 this->flux_.internalField().span(),
135 std::string
getName()
const {
return "SurfaceIntegrate"; }
const labelField & faceCells() const
Get the field of face cells.
A class to contain the data and executors for a field and define some basic operations.
size_t size() const
Gets the size of the field.
const Executor & exec() const
Gets the executor associated with the field.
std::span< ValueType > span() &&=delete
Represents an unstructured mesh in NeoFOAM.
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
const scalarField & cellVolumes() const
Get the field of cell volumes in the mesh.
size_t nInternalFaces() const
Get the number of internal faces in the mesh.
const labelField & faceOwner() const
Get the field of face owner cells.
const labelField & faceNeighbour() const
Get the field of face neighbour cells.
A class that represents a coefficient for the NeoFOAM dsl.
Represents a surface field in a finite volume method.
const dsl::Coeff & getCoefficient() const
dsl::Operator::Type getType() const
void explicitOperation(Field< ValueType > &source)
SurfaceIntegrate(const SurfaceIntegrate &surfaceIntegrate)
dsl::Coeff & getCoefficient()
void build(const Input &input)
std::string getName() const
const Executor & exec() const
SurfaceIntegrate(const SurfaceField< ValueType > &flux)
void surfaceIntegrate(const Executor &exec, size_t nInternalFaces, std::span< const int > neighbour, std::span< const int > owner, std::span< const int > faceCells, std::span< const ValueType > flux, std::span< const scalar > V, std::span< ValueType > res, const dsl::Coeff operatorScaling)
std::variant< Dictionary, TokenList > Input
void parallelFor(const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel)
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor