/home/runner/work/kynema-sgf/kynema-sgf/src/utilities/integrals.H Source File

Kynema-SGF API: /home/runner/work/kynema-sgf/kynema-sgf/src/utilities/integrals.H Source File
Kynema-SGF API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
integrals.H
Go to the documentation of this file.
1#ifndef INTEGRALS_H
2#define INTEGRALS_H
3#include "AMReX_REAL.H"
4
5using namespace amrex::literals;
6
7namespace kynema_sgf::utils {
8
13template <typename Function>
14AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real trapz(
15 const amrex::Real xa, const amrex::Real xb, const int n, const Function& f)
16{
17
18 const amrex::Real dx = (xb - xa) / n;
19
20 // first and last terms
21 amrex::Real sum = 0.5_rt * (f(xa) + f(xb));
22
23 for (int i = 1; i < n; i++) {
24 sum += f(xa + (i * dx));
25 }
26 return dx * sum;
27}
28
29} // namespace kynema_sgf::utils
30#endif
Definition MultiParser.H:7
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real trapz(const amrex::Real xa, const amrex::Real xb, const int n, const Function &f)
Definition integrals.H:14