NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
include
NeoFOAM
finiteVolume
cellCentred
boundary
volume
fixedValue.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// SPDX-FileCopyrightText: 2023 NeoFOAM authors
3
4
#pragma once
5
6
#include <Kokkos_Core.hpp>
7
8
#include "
NeoFOAM/fields/field.hpp
"
9
#include "
NeoFOAM/finiteVolume/cellCentred/boundary/volumeBoundaryFactory.hpp
"
10
#include "
NeoFOAM/mesh/unstructured.hpp
"
11
#include "
NeoFOAM/core/parallelAlgorithms.hpp
"
12
13
namespace
NeoFOAM::finiteVolume::cellCentred::volumeBoundary
14
{
15
16
namespace
detail
17
{
18
// Without this function the compiler warns that calling a __host__ function
19
// from a __device__ function is not allowed
20
template
<
typename
ValueType>
21
void
setFixedValue
(
22
DomainField<ValueType>
& domainField, std::pair<size_t, size_t> range, ValueType fixedValue
23
)
24
{
25
auto
refValue = domainField.
boundaryField
().
refValue
().span();
26
auto
value = domainField.
boundaryField
().
value
().span();
27
28
NeoFOAM::parallelFor
(
29
domainField.
exec
(),
30
range,
31
KOKKOS_LAMBDA(
const
size_t
i) {
32
refValue[i] = fixedValue;
33
value[i] = fixedValue;
34
}
35
);
36
}
37
38
}
39
40
template
<
typename
ValueType>
41
class
FixedValue
:
public
VolumeBoundaryFactory
<ValueType>::template
Register
<FixedValue<ValueType>>
42
{
43
using
Base =
VolumeBoundaryFactory<ValueType>::template
Register<FixedValue<ValueType>
>;
44
45
public
:
46
47
FixedValue
(
const
UnstructuredMesh
& mesh,
const
Dictionary
& dict, std::size_t patchID)
48
: Base(mesh, dict, patchID), fixedValue_(dict.get<ValueType>(
"fixedValue"
))
49
{}
50
51
virtual
void
correctBoundaryCondition
(
DomainField<ValueType>
& domainField)
final
52
{
53
detail::setFixedValue
(domainField, this->range(), fixedValue_);
54
}
55
56
static
std::string
name
() {
return
"fixedValue"
; }
57
58
static
std::string
doc
() {
return
"Set a fixed value on the boundary"
; }
59
60
static
std::string
schema
() {
return
"none"
; }
61
62
virtual
std::unique_ptr<VolumeBoundaryFactory<ValueType>>
clone
() const final
63
{
64
return
std::make_unique<FixedValue>(*
this
);
65
}
66
67
private
:
68
69
ValueType fixedValue_;
70
};
71
72
}
NeoFOAM::BoundaryFields::value
const NeoFOAM::Field< T > & value() const
Get the view storing the computed values from the boundary condition.
Definition
boundaryFields.hpp:68
NeoFOAM::BoundaryFields::refValue
const NeoFOAM::Field< T > & refValue() const
Get the view storing the Dirichlet boundary values.
Definition
boundaryFields.hpp:78
NeoFOAM::Dictionary
A class representing a dictionary that stores key-value pairs.
Definition
dictionary.hpp:33
NeoFOAM::DomainField
Represents the domain fields for a computational domain.
Definition
domainField.hpp:32
NeoFOAM::DomainField::exec
const Executor & exec() const
Definition
domainField.hpp:106
NeoFOAM::DomainField::boundaryField
const BoundaryFields< ValueType > & boundaryField() const
Definition
domainField.hpp:101
NeoFOAM::UnstructuredMesh
Represents an unstructured mesh in NeoFOAM.
Definition
unstructuredMesh.hpp:27
NeoFOAM::finiteVolume::cellCentred::VolumeBoundaryFactory
Definition
volumeBoundaryFactory.hpp:21
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue
Definition
fixedValue.hpp:42
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::schema
static std::string schema()
Definition
fixedValue.hpp:60
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::doc
static std::string doc()
Definition
fixedValue.hpp:58
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::name
static std::string name()
Definition
fixedValue.hpp:56
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::clone
virtual std::unique_ptr< VolumeBoundaryFactory< ValueType > > clone() const final
Definition
fixedValue.hpp:62
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::correctBoundaryCondition
virtual void correctBoundaryCondition(DomainField< ValueType > &domainField) final
Definition
fixedValue.hpp:51
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::FixedValue::FixedValue
FixedValue(const UnstructuredMesh &mesh, const Dictionary &dict, std::size_t patchID)
Definition
fixedValue.hpp:47
Register
A template class for registering derived classes with a base class.
field.hpp
NeoFOAM::finiteVolume::cellCentred::volumeBoundary::detail::setFixedValue
void setFixedValue(DomainField< ValueType > &domainField, std::pair< size_t, size_t > range, ValueType fixedValue)
Definition
fixedValue.hpp:21
NeoFOAM::finiteVolume::cellCentred::volumeBoundary
Definition
calculated.hpp:13
NeoFOAM::parallelFor
void parallelFor(const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, std::string name="parallelFor")
Definition
parallelAlgorithms.hpp:27
parallelAlgorithms.hpp
unstructured.hpp
volumeBoundaryFactory.hpp
Generated by
1.9.8