NeoN
A framework for CFD software
Loading...
Searching...
No Matches
boundedDiv.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8#include "NeoN/core/input.hpp"
10#include "NeoN/fields/field.hpp"
14
16{
17
18/* @brief Bounded convection div scheme wrapper.
19 *
20 * Mirrors OpenFOAM's Foam::fv::boundedConvectionScheme: wraps an inner div
21 * scheme and adds an Sp-style correction proportional to the local
22 * continuity error, -fvc::surfaceIntegrate(faceFlux) * psi (explicit) or
23 * -fvm::Sp(fvc::surfaceIntegrate(faceFlux), psi) (implicit).
24 *
25 * Reads as `bounded <innerScheme...>`, e.g. `bounded Gauss upwind`.
26 */
27template<typename FieldValueType, typename AssemblyType = FieldValueType>
29 public DivOperatorFactory<FieldValueType, AssemblyType>::template Register<
30 BoundedDiv<FieldValueType, AssemblyType>>
31{
34
35public:
36
37 static std::string name() { return "bounded"; }
38
39 static std::string doc()
40 {
41 return "Bounded convection scheme wrapper. Reads `bounded <inner>` "
42 "and adds -fvm::Sp(surfaceIntegrate(faceFlux), psi) to the inner "
43 "scheme's discretisation so continuity-error noise can't push "
44 "ψ negative cell-to-cell.";
45 }
46
47 static std::string schema() { return "none"; }
48
49 BoundedDiv(const Executor& exec, const UnstructuredMesh& mesh, const Input& inputs);
50
51 void
53 const SurfaceField<scalar>& faceFlux,
55 const dsl::Coeff operatorScaling) const override;
56
57 void
59 const SurfaceField<scalar>& faceFlux,
61 const dsl::Coeff operatorScaling) const override;
62
63 void
65 const SurfaceField<scalar>& faceFlux,
67 const dsl::Coeff operatorScaling) const override;
68
70 div(const SurfaceField<scalar>& faceFlux,
72 const dsl::Coeff operatorScaling) const override;
73
74 std::unique_ptr<DivOperatorFactory<FieldValueType, AssemblyType>> clone() const override;
75
76private:
77
78 /* @brief Wraps an already-built inner div scheme, used by clone(). */
80 const Executor& exec,
81 const UnstructuredMesh& mesh,
83 );
84
85 std::unique_ptr<DivOperatorFactory<FieldValueType, AssemblyType>> inner_;
86};
87
88/* @brief Applies the bounded-convection Sp diagonal correction,
89 * A[i,i] -= (sum of faceFlux over cell i) * scaling[i], over internal,
90 * physical-boundary and processor-boundary faces to an already-assembled
91 * linear system.
92 */
93template<typename FieldValueType, typename AssemblyType = FieldValueType>
96 const SurfaceField<scalar>& faceFlux,
97 const UnstructuredMesh& mesh,
98 const dsl::Coeff scaling
99);
100
101extern template class BoundedDiv<scalar>;
102extern template class BoundedDiv<Vec3>;
103extern template class BoundedDiv<Vec3, scalar>;
104
105} // namespace NeoN::finiteVolume::cellCentred
Represents an unstructured mesh in NeoN.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:27
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:24
void div(VolumeField< FieldValueType > &divPhi, const SurfaceField< scalar > &faceFlux, const VolumeField< FieldValueType > &phi, const dsl::Coeff operatorScaling) const override
std::unique_ptr< DivOperatorFactory< FieldValueType, AssemblyType > > clone() const override
void div(la::LinearSystem< AssemblyType, FieldValueType > &ls, const SurfaceField< scalar > &faceFlux, const VolumeField< FieldValueType > &phi, const dsl::Coeff operatorScaling) const override
BoundedDiv(const Executor &exec, const UnstructuredMesh &mesh, const Input &inputs)
VolumeField< FieldValueType > div(const SurfaceField< scalar > &faceFlux, const VolumeField< FieldValueType > &phi, const dsl::Coeff operatorScaling) const override
void div(Vector< FieldValueType > &divPhi, const SurfaceField< scalar > &faceFlux, const VolumeField< FieldValueType > &phi, const dsl::Coeff operatorScaling) const override
Represents a surface field in a finite volume method.
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
A template class for registering derived classes with a base class.
void applyBoundedDivDiagonal(la::LinearSystem< AssemblyType, FieldValueType > &ls, const SurfaceField< scalar > &faceFlux, const UnstructuredMesh &mesh, const dsl::Coeff scaling)
std::variant< Dictionary, TokenList > Input
Definition input.hpp:15
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:20