NeoN
A framework for CFD software
Loading...
Searching...
No Matches
fixedValue.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
13
15{
16namespace detail
17{
18// Without this function the compiler warns that calling a __host__ function
19// from a __device__ function is not allowed
20template<typename ValueType>
22 Field<ValueType>& domainVector, std::pair<size_t, size_t> range, ValueType fixedValue
23)
24{
25 auto refValue = domainVector.boundaryData().refValue().view();
26 auto value = domainVector.boundaryData().value().view();
27
29 domainVector.exec(),
30 range,
31 NEON_LAMBDA(const localIdx i) {
32 refValue[i] = fixedValue;
33 value[i] = fixedValue;
34 },
35 "setFixedValueSurface"
36 );
37}
38}
39
40template<typename ValueType>
42 public SurfaceBoundaryFactory<ValueType>::template Register<FixedValue<ValueType>>
43{
45
46public:
47
48 FixedValue(const UnstructuredMesh& mesh, const Dictionary& dict, localIdx patchID)
49 : Base(mesh, dict, patchID), fixedValue_(dict.get<ValueType>("fixedValue"))
50 {}
51
52 virtual void correctBoundaryCondition(Field<ValueType>& domainVector) override
53 {
54 detail::setFixedValue(domainVector, this->range(), fixedValue_);
55 }
56
57 static std::string name() { return "fixedValue"; }
58
59 static std::string doc() { return "Set a fixed value on the boundary"; }
60
61 static std::string schema() { return "none"; }
62
63 virtual std::unique_ptr<SurfaceBoundaryFactory<ValueType>> clone() const override
64 {
65 return std::make_unique<FixedValue>(*this);
66 }
67
68private:
69
70 ValueType fixedValue_;
71};
72
73}
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
Represents an unstructured mesh in NeoN.
virtual std::unique_ptr< SurfaceBoundaryFactory< ValueType > > clone() const override
FixedValue(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID)
virtual void correctBoundaryCondition(Field< ValueType > &domainVector) override
A template class for registering derived classes with a base class.
void setFixedValue(Field< ValueType > &domainVector, std::pair< size_t, size_t > range, ValueType fixedValue)
int32_t localIdx
Definition label.hpp:50
void parallelFor(const ExecutorType &, std::pair< localIdx, localIdx > range, const Kernel &kernel, std::string name)
#define NEON_LAMBDA