NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
forwardEuler.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2//
3// SPDX-FileCopyrightText: 2023 NeoN authors
4
5#pragma once
6
11
13{
14
15template<typename SolutionVectorType>
17 public TimeIntegratorBase<SolutionVectorType>::template Register<
18 ForwardEuler<SolutionVectorType>>
19{
20
21public:
22
23 using ValueType = typename SolutionVectorType::VectorValueType;
24 using Base =
26
27 ForwardEuler(const Dictionary& schemeDict, const Dictionary& solutionDict)
28 : Base(schemeDict, solutionDict)
29 {}
30
31 static std::string name() { return "forwardEuler"; }
32
33 static std::string doc() { return "first order time integration method"; }
34
35 static std::string schema() { return "none"; }
36
37 void solve(
39 SolutionVectorType& solutionVector,
40 [[maybe_unused]] scalar t,
41 scalar dt
42 ) override
43 {
44 auto source = eqn.explicitOperation(solutionVector.size());
45 SolutionVectorType& oldSolutionVector =
47
48 solutionVector.internalVector() = oldSolutionVector.internalVector() - source * dt;
49 solutionVector.correctBoundaryConditions();
50
51 // check if executor is GPU
52 if (std::holds_alternative<NeoN::GPUExecutor>(eqn.exec()))
53 {
54 Kokkos::fence();
55 }
56 oldSolutionVector.internalVector() = solutionVector.internalVector();
57 };
58
59 std::unique_ptr<TimeIntegratorBase<SolutionVectorType>> clone() const override
60 {
61 return std::make_unique<ForwardEuler>(*this);
62 }
63};
64
65
66} // namespace NeoN
A class representing a dictionary that stores key-value pairs.
Vector< ValueType > explicitOperation(localIdx nCells) const
const Executor & exec() const
ForwardEuler(const Dictionary &schemeDict, const Dictionary &solutionDict)
std::unique_ptr< TimeIntegratorBase< SolutionVectorType > > clone() const override
void solve(dsl::Expression< ValueType > &eqn, SolutionVectorType &solutionVector, scalar t, scalar dt) override
TimeIntegratorBase< SolutionVectorType >::template Register< ForwardEuler< SolutionVectorType > > Base
typename SolutionVectorType::VectorValueType ValueType
A template class for registering derived classes with a base class.
VectorType & oldTime(VectorType &field)
Retrieves the old time field of a given field.
float scalar
Definition scalar.hpp:14