WaveSimPP 1.0
A C library for solving the wave equation and reconstructing the wave field
All Classes Namespaces Functions Modules Pages
source.hpp
1//
2// Created by Yan Cheng on 11/28/22.
3//
4
5#ifndef WAVESIMC_SOURCE_HPP
6#define WAVESIMC_SOURCE_HPP
11namespace waveSimCore
12{
14 boost::multi_array<double, 3> ricker(int i_s, int j_s, double f, double amp, double shift,
15 double tmin, double tmax, int nt, int nx, int nz)
16 {
17 const double pi = 3.141592654;
18
19 boost::multi_array<double, 1> t = np::linspace(tmin, tmax, nt);
20 boost::multi_array<double, 1> pft2 = np::pow(pi * f * (t - shift), 2.0);
21 boost::multi_array<double, 1> r = amp * (1.0 - 2.0 * pft2) * np::exp(-1.0 * pft2);
22
23 int dimensions_x[] = {nx};
24 boost::multi_array<double, 1> x = np::zeros<double>(dimensions_x);
25
26 int dimensions_z[] = {nz};
27 boost::multi_array<double, 1> z = np::zeros<double>(dimensions_z);
28
29 x[i_s] = 1.0;
30 z[j_s] = 1.0;
31
32 const boost::multi_array<double, 1> axis[3] = {r, x, z};
33 std::vector<boost::multi_array<double, 3>> RXZ = np::meshgrid(axis, false, np::ij);
34 boost::multi_array<double, 3> source = RXZ[0] * RXZ[1] * RXZ[2];
35
36 return source;
37 }
38}
39#endif // WAVESIMC_SOURCE_HPP
boost::multi_array< double, 3 > ricker(int i_s, int j_s, double f, double amp, double shift, double tmin, double tmax, int nt, int nx, int nz)
Get the Ricker wavelet as a 3D Array.
Definition: source.hpp:14
::value constexpr boost::multi_array< T, ND > pow(const boost::multi_array< T, ND > &input_array, const T exponent)
Implements the numpy pow function on multi arrays.
Definition: np.hpp:319
::value constexpr std::vector< boost::multi_array< T, ND > > meshgrid(const boost::multi_array< T, 1 >(&cinput)[ND], bool sparsing=false, indexing indexing_type=xy)
Definition: np.hpp:184
::value constexpr boost::multi_array< T, ND > exp(const boost::multi_array< T, ND > &input_array)
Implements the numpy exp function on multi arrays.
Definition: np.hpp:289
boost::multi_array< double, 1 > linspace(double start, double stop, long unsigned int num)
Implements the numpy linspace function.
Definition: np.hpp:161