NeoN
A framework for CFD software
Loading...
Searching...
No Matches
extrapolated.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
16// TODO move to source file
17namespace detail
18{
19// Without this function the compiler warns that calling a __host__ function
20// from a __device__ function is not allowed
21// NOTE: patchID was removed since it was unused
22// I guess it was replaced by range
23template<typename ValueType>
25 Field<ValueType>& domainVector,
26 const UnstructuredMesh& mesh,
27 std::pair<localIdx, localIdx> range
28)
29{
30 const auto iVector = domainVector.internalVector().view();
31
32 auto [refGradient, value, valueFraction, refValue, boundaryFaceOwners] = views(
33 domainVector.boundaryData().refGrad(),
34 domainVector.boundaryData().value(),
35 domainVector.boundaryData().valueFraction(),
36 domainVector.boundaryData().refValue(),
38 );
39
40
42 domainVector.exec(),
43 range,
44 NEON_LAMBDA(const localIdx i) {
45 // operator / is not defined for all ValueTypes
46 ValueType internalCellValue = iVector[boundaryFaceOwners[i]];
47 value[i] = internalCellValue;
48 valueFraction[i] = 1.0; // only use refValue
49 refValue[i] = internalCellValue; // not used
50 refGradient[i] = zero<ValueType>();
51 },
52 "extrapolateValue"
53 );
54}
55}
56
57template<typename ValueType>
59 public VolumeBoundaryFactory<ValueType>::template Register<Extrapolated<ValueType>>
60{
62
63public:
64
65 using Base::correctBoundaryCondition;
66
68
69 Extrapolated(const UnstructuredMesh& mesh, const Dictionary& dict, localIdx patchID)
70 : Base(mesh, dict, patchID, {.assignable = true, .fixesValue = false}), mesh_(mesh)
71 {}
72
73 virtual void correctBoundaryCondition([[maybe_unused]] Field<ValueType>& domainVector) final
74 {
75 detail::extrapolateValue(domainVector, mesh_, this->range());
76 }
77
78 static std::string name() { return "extrapolated"; }
79
80 std::string getName() const override { return name(); }
81
82 static std::string doc() { return "TBD"; }
83
84 static std::string schema() { return "none"; }
85
86 virtual std::unique_ptr<VolumeBoundaryFactory<ValueType>> clone() const final
87 {
88 return std::make_unique<Extrapolated>(*this);
89 }
90
91private:
92
93 const UnstructuredMesh& mesh_;
94};
95}
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.
Definition field.hpp:34
const BoundaryData< ValueType > & boundaryData() const
Definition field.hpp:96
const Executor & exec() const
Definition field.hpp:101
const Vector< ValueType > & internalVector() const
Definition field.hpp:90
Represents an unstructured mesh in NeoN.
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
virtual void correctBoundaryCondition(Field< ValueType > &domainVector) final
Extrapolated(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 extrapolateValue(Field< ValueType > &domainVector, const UnstructuredMesh &mesh, std::pair< localIdx, localIdx > range)
int32_t localIdx
Definition label.hpp:50
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.
Definition view.hpp:107
#define NEON_LAMBDA