https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosLinearFVBoundaryCondition.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://www.mooseframework.org
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "KokkosDispatcher.h"
13#include "KokkosDatum.h"
14#include "KokkosMesh.h"
15#include "KokkosSystem.h"
16#include "KokkosVariable.h"
17
19#include "FunctionInterface.h"
21#include "MooseObject.h"
23#include "Restartable.h"
24#include "SetupInterface.h"
25#include "TransientInterface.h"
26#include "UserObjectInterface.h"
28
29class FEProblemBase;
30class InputParameters;
31
32namespace Moose::Kokkos
33{
34
41 public SetupInterface,
42 public FunctionInterface,
44 public TransientInterface,
47 public Restartable,
50 public MeshHolder,
51 public SystemHolder
52{
53public:
55
58
61 {
62 };
65 {
66 };
67
73 {
74 Real coefficient = 0;
75 Real source = 0;
76 };
77
84
91
92 virtual void initialSetup() override;
93
98 Variable variable() const { return _var; }
99
103 const BoundaryData & boundaryData() const { return _boundary_data; }
104
106 MOOSE_KOKKOS_INDEX_TYPE numBoundaryFaces() const;
107
110 boundaryFaceID(const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const;
111
113 bool hasBoundaryValue() const;
116
121
126 template <typename Derived>
127 KOKKOS_FUNCTION BoundaryRelation computeBoundaryValue(const FVDatum &) const
128 {
129 ::Kokkos::abort("Default computeBoundaryValue() should never be called. Make sure you "
130 "properly redefined this method in your class without typos.");
131
132 return {};
133 }
134
139 template <typename Derived>
141 {
142 ::Kokkos::abort("Default computeBoundaryNormalGradient() should never be called. Make sure "
143 "you properly redefined this method in your class without typos.");
144
145 return {};
146 }
147
152 template <typename Derived>
154 {
155 return &LinearFVBoundaryCondition::computeBoundaryValue<Derived>;
156 }
157
158 template <typename Derived>
160 {
161 return &LinearFVBoundaryCondition::computeBoundaryNormalGradient<Derived>;
162 }
164
170 template <typename Derived>
171 KOKKOS_FUNCTION void operator()(BoundaryValueLoop, const ThreadID tid, const Derived & bc) const;
172
179 template <typename Derived>
180 KOKKOS_FUNCTION void
181 operator()(BoundaryNormalGradientLoop, const ThreadID tid, const Derived & bc) const;
182
183protected:
186
189
192
194 std::unique_ptr<DispatcherBase> _boundary_value_dispatcher;
196 std::unique_ptr<DispatcherBase> _boundary_normal_gradient_dispatcher;
197
213};
214
215template <typename Derived>
216KOKKOS_FUNCTION void
218 const ThreadID tid,
219 const Derived & bc) const
220{
221 const auto [elem, side] = kokkosBoundaryElementSideID(tid);
222 FVDatum datum(elem, side, kokkosMesh());
223 const auto relation = bc.template computeBoundaryValue<Derived>(datum);
224 _boundary_data.value.coefficient[tid] = relation.coefficient;
225 _boundary_data.value.source[tid] = relation.source;
226}
227
228template <typename Derived>
229KOKKOS_FUNCTION void
231 const ThreadID tid,
232 const Derived & bc) const
233{
234 const auto [elem, side] = kokkosBoundaryElementSideID(tid);
235 FVDatum datum(elem, side, kokkosMesh());
236 const auto relation = bc.template computeBoundaryNormalGradient<Derived>(datum);
237 _boundary_data.normal_gradient.coefficient[tid] = relation.coefficient;
238 _boundary_data.normal_gradient.source[tid] = relation.source;
239}
240
241} // namespace Moose::Kokkos
A class for requiring an object to be boundary restricted.
KOKKOS_FUNCTION auto kokkosBoundaryElementSideID(Moose::Kokkos::ThreadID tid) const
Get the contiguous element ID - side index pair this Kokkos thread is operating on.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Interface for objects that need to use functions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Interface for notifications that the mesh has changed.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
The Kokkos array class.
Device-side geometric context for finite volume kernels and boundary conditions.
Base class for Kokkos linear finite volume boundary conditions.
BoundaryData _boundary_data
Boundary relation arrays owned by this boundary condition.
static InputParameters validParams()
bool hasBoundaryValue() const
Whether this boundary condition overrides the boundary value relation hook.
KOKKOS_FUNCTION void operator()(BoundaryValueLoop, const ThreadID tid, const Derived &bc) const
Boundary value dispatch loop body; writes the per-face boundary value relation.
Scalar< const Real > _t_old
Old (previous time step) time.
KOKKOS_FUNCTION BoundaryRelation computeBoundaryValue(const FVDatum &) const
Default boundary value relation hook.
bool hasBoundaryNormalGradient() const
Whether this boundary condition overrides the boundary normal gradient relation hook.
KOKKOS_FUNCTION BoundaryRelation computeBoundaryNormalGradient(const FVDatum &) const
Default boundary normal gradient relation hook.
static auto defaultBoundaryValue()
Functions used to check whether derived boundary conditions override the boundary data hooks.
void computeBoundaryValueData()
Dispatch boundary value relation computation.
std::unique_ptr< DispatcherBase > _boundary_normal_gradient_dispatcher
Dispatcher for boundary normal gradient computation.
FEProblemBase & _fe_problem
Reference to the finite element problem.
LinearFVBoundaryCondition(const LinearFVBoundaryCondition &object)
void computeBoundaryNormalGradientData()
Dispatch boundary normal gradient relation computation.
MOOSE_KOKKOS_INDEX_TYPE numBoundaryFaces() const
Number of faces in this boundary condition's existing worklist.
std::unique_ptr< DispatcherBase > _boundary_value_dispatcher
Dispatcher for boundary value computation.
Pair< ContiguousElementID, unsigned int > boundaryFaceID(const MOOSE_KOKKOS_INDEX_TYPE bc_face_index) const
Face at a BC-local worklist index.
const BoundaryData & boundaryData() const
Get the boundary data relation arrays owned by this boundary condition.
Scalar< Real > _t
TODO: Move to TransientInterface.
Variable variable() const
Get the Kokkos variable this boundary condition supplies data for.
LinearFVBoundaryCondition(const InputParameters &parameters)
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
The Kokkos interface that holds the host reference of the Kokkos mesh and copies it to device during ...
Definition KokkosMesh.h:630
KOKKOS_FUNCTION const Mesh & kokkosMesh() const
Get the const reference of the Kokkos mesh.
Definition KokkosMesh.h:651
The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.
The Kokkos variable object that carries the coupled variable and tag information.
Interface class for classes which interact with Postprocessors.
A class for creating restricted objects.
Definition Restartable.h:29
Interface for objects that needs transient capabilities.
Interface for objects that need to use UserObjects.
MOOSE_KOKKOS_INDEX_TYPE ThreadID
Boundary relation data indexed by relation type and BC-local boundary face.
Tag dispatch type for boundary normal gradient relation computation.
Boundary relation coefficient/source arrays indexed by BC-local boundary face.
Affine boundary relation used by Kokkos linear FV kernels: boundary_quantity = coefficient * cell_unk...
Tag dispatch type for boundary value relation computation.