WaveSimPP 1.0
A C library for solving the wave equation and reconstructing the wave field
All Classes Namespaces Functions Modules Pages
computational.hpp
1//
2// Created by Yan Cheng on 11/28/22.
3//
4
5#ifndef WAVESIMC_COMPUTATIONAL_HPP
6#define WAVESIMC_COMPUTATIONAL_HPP
7
13namespace waveSimCore
14{
16 boost::multi_array<double, 2> get_profile(double xmin, double xmax, double zmin, double zmax, int nx, int nz, double r)
17 {
18 boost::multi_array<double, 2> c(boost::extents[nx][nz]);
19
20 boost::multi_array<double, 1> x = np::linspace(xmin, xmax, nx);
21 boost::multi_array<double, 1> z = np::linspace(zmin, zmax, nz);
22
23 const boost::multi_array<double, 1> axis[2] = {x, z};
24 std::vector<boost::multi_array<double, 2>> XZ = np::meshgrid(axis, false, np::ij);
25
26 double x_0 = xmax / 2.0;
27 double z_0 = zmax / 2.0;
28
29 for (int i = 0; i < nx; i++)
30 {
31 for (int j = 0; j < nz; j++)
32 {
33 if (np::pow(XZ[0][i][j] - x_0, 2.0) + np::pow(XZ[1][i][j] - z_0, 2.0) <= np::pow(r, 2.0))
34 c[i][j] = 3.0;
35 else
36 c[i][j] = 3.0;
37 }
38 }
39
40 return c;
41 }
42}
43#endif // WAVESIMC_COMPUTATIONAL_HPP
boost::multi_array< double, 2 > get_profile(double xmin, double xmax, double zmin, double zmax, int nx, int nz, double r)
Get the velocity profile of the model as a 2D Array.
::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
boost::multi_array< double, 1 > linspace(double start, double stop, long unsigned int num)
Implements the numpy linspace function.
Definition: np.hpp:161