/home/runner/work/amr-wind/amr-wind/amr-wind/utilities/integrals.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/integrals.H Source File
AMR-Wind 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
5namespace amr_wind::utils {
6
11template <typename Function>
12AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real trapz(
13 const amrex::Real xa, const amrex::Real xb, const int n, const Function& f)
14{
15
16 const amrex::Real dx = (xb - xa) / n;
17
18 // first and last terms
19 amrex::Real sum = 0.5 * (f(xa) + f(xb));
20
21 for (int i = 1; i < n; i++) {
22 sum += f(xa + i * dx);
23 }
24 return dx * sum;
25};
26
27} // namespace amr_wind::utils
28#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:12