NeoN
A framework for CFD software
Loading...
Searching...
No Matches
forwardEuler.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
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 explicit time integration method"; }
34
35 static std::string schema() { return "none"; }
36
37 void solve(
38 dsl::Expression<ValueType>& eqn, SolutionVectorType& solutionVector, scalar t, scalar dt
39 ) override
40 {
41 auto source = Vector<ValueType>(eqn.exec(), solutionVector.size(), zero<ValueType>());
42
43 // spatial explicit operators
44 eqn.explicitOperation(source);
45
46 // temporal explicit operators (ddt explicit evaluation)
47 eqn.explicitOperation(source, t, dt);
48
49 SolutionVectorType& oldSolutionVector =
51
52 solutionVector.internalVector() = oldSolutionVector.internalVector() - source * dt;
53 solutionVector.correctBoundaryConditions();
54
55 fence(eqn.exec());
56 };
57
58 std::unique_ptr<TimeIntegratorBase<SolutionVectorType>> clone() const override
59 {
60 return std::make_unique<ForwardEuler>(*this);
61 }
62};
63
64
65} // namespace NeoN
A class representing a dictionary that stores key-value pairs.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:27
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.
void fence(const Executor &exec)
Definition executor.hpp:23
float scalar
Definition scalar.hpp:17