NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
solver.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023-2024 NeoFOAM authors
3#pragma once
4
5#include <iostream>
6#include <memory>
7#include <type_traits>
8#include <utility>
9#include <concepts>
10
16
17
18namespace NeoFOAM::dsl
19{
20
21/* @brief solve an expression
22 *
23 * @param exp - Expression which is to be solved/updated.
24 * @param solution - Solution field, where the solution will be 'written to'.
25 * @param t - the time at the start of the time step.
26 * @param dt - time step for the temporal integration
27 * @param fvSchemes - Dictionary containing spatial operator and time integration properties
28 * @param fvSolution - Dictionary containing linear solver properties
29 */
30template<typename FieldType>
31void solve(
32 Expression& exp,
33 FieldType& solution,
34 scalar t,
35 scalar dt,
36 [[maybe_unused]] const Dictionary& fvSchemes,
37 [[maybe_unused]] const Dictionary& fvSolution
38)
39{
40 if (exp.temporalOperators().size() == 0 && exp.implicitOperators().size() == 0)
41 {
42 NF_ERROR_EXIT("No temporal or implicit terms to solve.");
43 }
44 exp.build(fvSchemes);
45 if (exp.temporalOperators().size() > 0)
46 {
47 // integrate equations in time
48 timeIntegration::TimeIntegration<FieldType> timeIntegrator(fvSchemes.subDict("ddtSchemes"));
49 timeIntegrator.solve(exp, solution, t, dt);
50 }
51 else
52 {
53 NF_ERROR_EXIT("Not implemented.");
54 // solve sparse matrix system
55 }
56}
57
58} // namespace NeoFOAM::dsl
A class representing a dictionary that stores key-value pairs.
const std::vector< Operator > & temporalOperators() const
const std::vector< Operator > & implicitOperators() const
void build(const NeoFOAM::Dictionary &input)
void solve(Expression &eqn, SolutionFieldType &sol, scalar t, scalar dt)
#define NF_ERROR_EXIT(message)
Macro for printing an error message and aborting the program.
Definition error.hpp:108
void solve(Expression &exp, FieldType &solution, scalar t, scalar dt, const Dictionary &fvSchemes, const Dictionary &fvSolution)
Definition solver.hpp:31
float scalar
Definition scalar.hpp:11