NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
timeIntegration.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
7#include <functional>
8
12
14{
15
16/* @class Factory class to create time integration method by a given name
17 * using NeoFOAMs runTimeFactory mechanism
18 */
19template<typename SolutionType>
21 public RuntimeSelectionFactory<TimeIntegratorBase<SolutionType>, Parameters<const Dictionary&>>
22{
23
24public:
25
27
28 static std::string name() { return "timeIntegrationFactory"; }
29
30 TimeIntegratorBase(const Dictionary& dict) : dict_(dict) {}
31
33
34 virtual void solve(
35 Expression& eqn, SolutionType& sol, scalar t, scalar dt
36 ) = 0; // Pure virtual function for solving
37
38 // Pure virtual function for cloning
39 virtual std::unique_ptr<TimeIntegratorBase> clone() const = 0;
40
41protected:
42
44};
45
52template<typename SolutionFieldType>
54{
55
56public:
57
59
60 TimeIntegration(const TimeIntegration& timeIntegrator)
61 : timeIntegratorStrategy_(timeIntegrator.timeIntegratorStrategy_->clone()) {};
62
64 : timeIntegratorStrategy_(std::move(timeIntegrator.timeIntegratorStrategy_)) {};
65
67 : timeIntegratorStrategy_(
68 TimeIntegratorBase<SolutionFieldType>::create(dict.get<std::string>("type"), dict)
69 ) {};
70
71 void solve(Expression& eqn, SolutionFieldType& sol, scalar t, scalar dt)
72 {
73 timeIntegratorStrategy_->solve(eqn, sol, t, dt);
74 }
75
76private:
77
78 std::unique_ptr<TimeIntegratorBase<SolutionFieldType>> timeIntegratorStrategy_;
79};
80
81
82} // namespace NeoFOAM::dsl
A class representing a dictionary that stores key-value pairs.
A factory class for runtime selection of derived classes.
TimeIntegration(TimeIntegration &&timeIntegrator)
TimeIntegration(const TimeIntegration &timeIntegrator)
void solve(Expression &eqn, SolutionFieldType &sol, scalar t, scalar dt)
virtual std::unique_ptr< TimeIntegratorBase > clone() const =0
virtual void solve(Expression &eqn, SolutionType &sol, scalar t, scalar dt)=0
float scalar
Definition scalar.hpp:11