NeoN
A framework for CFD software
Loading...
Searching...
No Matches
processor.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <Kokkos_Core.hpp>
8
12
14{
15
16namespace detail
17{
18// One-time (set): zero the unused mixed-BC coefficients (refGrad / valueFraction / refValue) on
19// the processor patch. Unlike the volume BC there is no per-iteration owner-cell -> face seed
20// (see processor.cpp), so this is all the surface proc BC does besides the halo exchange.
21template<typename ValueType>
23 Field<ValueType>& domainVector, std::pair<localIdx, localIdx> range
24);
25
26extern template void
27setProcBoundaryCoefficients<scalar>(Field<scalar>&, std::pair<localIdx, localIdx>);
28extern template void setProcBoundaryCoefficients<Vec3>(Field<Vec3>&, std::pair<localIdx, localIdx>);
29}
30
31template<typename ValueType>
33{
35
36public:
37
38 Processor(const UnstructuredMesh& mesh, const Dictionary& dict, localIdx patchID)
39 : Base(mesh, dict, patchID), mesh_(mesh)
40 {}
41
42 // One-time initialisation: the unused mixed-BC coefficients never change after construction.
43 virtual void set(Field<ValueType>& domainVector) final
44 {
45 detail::setProcBoundaryCoefficients(domainVector, this->range());
46 }
47
48 // Per iteration: NO-OP. The proc-tail already holds the LOCAL face value (written by the
49 // operator that produced the field — flux() / updateFaceVelocity() / interpolation — or by
50 // constructFrom() at construction), and that LOCAL value is exactly what every consumer needs
51 // (computeDivProcBoundImpl, surfaceIntegrate, upwind weights all use the owner-rank outward
52 // flux). Crucially, a face flux is ANTISYMMETRIC across a processor interface — the neighbour
53 // rank's value for the shared face is -F (opposite Sf orientation). A symmetric halo exchange
54 // (BoundaryData::communicate does send AND receive-overwrite, as needed for cell/volume data)
55 // would therefore OVERWRITE the correct local +F with the neighbour's -F, sign-flipping the
56 // proc-face flux. That injects a spurious local divergence at every processor-boundary cell
57 // (cancels globally so conservation holds, but inflates the per-cell divergence and the
58 // distributed momentum/pressure residual). Surface processor patches must keep their local
59 // value, so this update is intentionally empty.
60 virtual void update([[maybe_unused]] Field<ValueType>& domainVector) final {}
61
62 // Full correction = one-time set() + per-iteration update(). Kept for any direct caller; the
63 // field's correctBoundaryConditions() calls set()/update() separately.
64 virtual void correctBoundaryCondition([[maybe_unused]] Field<ValueType>& domainVector) final
65 {
66 set(domainVector);
67 update(domainVector);
68 }
69
70
71 static std::string name() { return "processor"; }
72
73 static std::string doc()
74 {
75 return "Set processor boundary values from the corresponding processor-neighbour data.";
76 }
77
78 static std::string schema() { return "none"; }
79
80 virtual std::unique_ptr<SurfaceBoundaryFactory<ValueType>> clone() const override
81 {
82 return std::make_unique<Processor>(*this);
83 }
84
85private:
86
87 const UnstructuredMesh& mesh_;
88};
89
90}
A class representing a dictionary that stores key-value pairs.
Represents the domain fields for a computational domain.
Definition field.hpp:34
Represents an unstructured mesh in NeoN.
virtual void set(Field< ValueType > &domainVector) final
Definition processor.hpp:43
virtual void update(Field< ValueType > &domainVector) final
Definition processor.hpp:60
virtual std::unique_ptr< SurfaceBoundaryFactory< ValueType > > clone() const override
Definition processor.hpp:80
virtual void correctBoundaryCondition(Field< ValueType > &domainVector) final
Definition processor.hpp:64
Processor(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID)
Definition processor.hpp:38
A template class for registering derived classes with a base class.
void setProcBoundaryCoefficients(Field< ValueType > &domainVector, std::pair< localIdx, localIdx > range)
template void setProcBoundaryCoefficients< Vec3 >(Field< Vec3 > &, std::pair< localIdx, localIdx >)
template void setProcBoundaryCoefficients< scalar >(Field< scalar > &, std::pair< localIdx, localIdx >)
int32_t localIdx
Definition label.hpp:50