NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
surfaceIntegrate.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025 NeoN authors
3
4#pragma once
5
8#include "NeoN/core/input.hpp"
12
14{
15
16template<typename ValueType>
18 const Executor& exec,
19 localIdx nInternalFaces,
20 View<const int> neighbour,
21 View<const int> owner,
22 View<const int> faceCells,
26 const dsl::Coeff operatorScaling
27);
28
29template<typename ValueType>
31{
32
33public:
34
35 using VectorValueType = ValueType;
36
38 : flux_(flux), type_(dsl::Operator::Type::Explicit), coeffs_(1.0) {};
39
41 : flux_(surfaceIntegrate.flux_), type_(surfaceIntegrate.type_),
42 coeffs_(surfaceIntegrate.coeffs_) {};
43
44
45 void build(const Input&) {}
46
48 {
49 NeoN::Vector<ValueType> tmpsource(source.exec(), source.size(), zero<ValueType>());
50 const auto operatorScaling = this->getCoefficient();
51
52 const UnstructuredMesh& mesh = flux_.mesh();
53 const auto exec = flux_.exec();
54
55 auto nInternalFaces = mesh.nInternalFaces();
56 surfaceIntegrate<ValueType>(
57 exec,
58 nInternalFaces,
59 mesh.faceNeighbour().view(),
60 mesh.faceOwner().view(),
61 mesh.boundaryMesh().faceCells().view(),
62 this->flux_.internalVector().view(),
63 mesh.cellVolumes().view(),
64 tmpsource.view(),
65 operatorScaling
66 );
67 source += tmpsource;
68 }
69
70 const Executor& exec() const { return flux_.exec(); }
71
72 dsl::Coeff& getCoefficient() { return coeffs_; }
73
74 const dsl::Coeff& getCoefficient() const { return coeffs_; }
75
76 dsl::Operator::Type getType() const { return type_; }
77
78 std::string getName() const { return "SurfaceIntegrate"; }
79
80private:
81
82 const SurfaceField<ValueType>& flux_;
84 dsl::Coeff coeffs_;
85};
86
87
88} // namespace NeoN
const labelVector & faceCells() const
Get the field of face cells.
Represents an unstructured mesh in NeoN.
const scalarVector & cellVolumes() const
Get the field of cell volumes in the mesh.
localIdx nInternalFaces() const
Get the number of internal faces in the mesh.
const labelVector & faceNeighbour() const
Get the field of face neighbour cells.
const labelVector & faceOwner() const
Get the field of face owner cells.
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:53
View< ValueType > view() &&=delete
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:22
Represents a surface field in a finite volume method.
SurfaceIntegrate(const SurfaceField< ValueType > &flux)
void explicitOperation(Vector< ValueType > &source) const
SurfaceIntegrate(const SurfaceIntegrate &surfaceIntegrate)
void surfaceIntegrate(const Executor &exec, localIdx nInternalFaces, View< const int > neighbour, View< const int > owner, View< const int > faceCells, View< const ValueType > flux, View< const scalar > v, View< ValueType > res, const dsl::Coeff operatorScaling)
std::variant< Dictionary, TokenList > Input
Definition input.hpp:13
int32_t localIdx
Definition label.hpp:30
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16