NeoFOAM
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 NeoFOAM authors
4
5#pragma once
6
11
13{
14
15template<typename SolutionFieldType>
17 public TimeIntegratorBase<SolutionFieldType>::template Register<ForwardEuler<SolutionFieldType>>
18{
19
20public:
21
23 using Base =
25
26 ForwardEuler(const Dictionary& dict) : Base(dict) {}
27
28 static std::string name() { return "forwardEuler"; }
29
30 static std::string doc() { return "first order time integration method"; }
31
32 static std::string schema() { return "none"; }
33
34 void solve(
35 Expression& eqn, SolutionFieldType& solutionField, [[maybe_unused]] scalar t, scalar dt
36 ) override
37 {
38 auto source = eqn.explicitOperation(solutionField.size());
39 SolutionFieldType& oldSolutionField =
41
42 solutionField.internalField() = oldSolutionField.internalField() - source * dt;
43 solutionField.correctBoundaryConditions();
44
45 // check if executor is GPU
46 if (std::holds_alternative<NeoFOAM::GPUExecutor>(eqn.exec()))
47 {
48 Kokkos::fence();
49 }
50 oldSolutionField.internalField() = solutionField.internalField();
51 };
52
53 std::unique_ptr<TimeIntegratorBase<SolutionFieldType>> clone() const override
54 {
55 return std::make_unique<ForwardEuler>(*this);
56 }
57};
58
59
60} // namespace NeoFOAM
A class representing a dictionary that stores key-value pairs.
Field< scalar > explicitOperation(size_t nCells)
const Executor & exec() const
TimeIntegratorBase< SolutionFieldType >::template Register< ForwardEuler< SolutionFieldType > > Base
void solve(Expression &eqn, SolutionFieldType &solutionField, scalar t, scalar dt) override
std::unique_ptr< TimeIntegratorBase< SolutionFieldType > > clone() const override
A template class for registering derived classes with a base class.
FieldType & oldTime(FieldType &field)
Retrieves the old time field of a given field.
float scalar
Definition scalar.hpp:11