89 lines
3.9 KiB
C++
89 lines
3.9 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the GCTL, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#include "gctl/core.h"
|
|
#include "gctl/io.h"
|
|
#include "gctl/potential.h"
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
try
|
|
{
|
|
// set up observation parameters and block parameters
|
|
gctl::array<double> line_node, line_node2;
|
|
gctl::linespace(0.0, 150.0, 61, line_node);
|
|
gctl::linespace(0.0, 200.0, 101, line_node2);
|
|
gctl::array<gctl::point3dc> obes(line_node.size() * line_node2.size());
|
|
for (int i = 0; i < line_node2.size(); i++)
|
|
{
|
|
for (int j = 0; j < line_node.size(); j++)
|
|
{
|
|
obes[i*line_node.size()+j].x = line_node.at(j);
|
|
obes[i*line_node.size()+j].y = line_node2.at(i);
|
|
obes[i*line_node.size()+j].z = 0.0;
|
|
}
|
|
}
|
|
|
|
gctl::sphere a_body(gctl::point3dc(60, 120, -25), 15);
|
|
double rho = 1.0;
|
|
a_body.att = ρ
|
|
|
|
gctl::array<double> data_g, data_gx, data_gy, data_gz;
|
|
|
|
gobser_sphere(data_g, obes, a_body, gctl::Vz);
|
|
gobser_sphere(data_gx, obes, a_body, gctl::Tzx);
|
|
gobser_sphere(data_gy, obes, a_body, gctl::Tzy);
|
|
gobser_sphere(data_gz, obes, a_body, gctl::Tzz);
|
|
|
|
gctl::sphere t_body(gctl::point3dc(80, 100, -25), 10);
|
|
rho = 1.2;
|
|
t_body.att = ρ
|
|
|
|
gobser_sphere(data_g, obes, t_body, gctl::Vz, gctl::AppendVal);
|
|
gobser_sphere(data_gx, obes, t_body, gctl::Tzx, gctl::AppendVal);
|
|
gobser_sphere(data_gy, obes, t_body, gctl::Tzy, gctl::AppendVal);
|
|
gobser_sphere(data_gz, obes, t_body, gctl::Tzz, gctl::AppendVal);
|
|
|
|
#ifdef GCTL_NETCDF
|
|
gctl::save_netcdf_grid("data/sphere_g", data_g, 61, 101, 0.0, 2.5, 0.0, 2.0, "x", "y", "g");
|
|
gctl::append_netcdf_grid("data/sphere_g", data_gx, "x", "y", "gx");
|
|
gctl::append_netcdf_grid("data/sphere_g", data_gy, "x", "y", "gy");
|
|
gctl::append_netcdf_grid("data/sphere_g", data_gz, "x", "y", "gz");
|
|
#else
|
|
gctl::save_surfer6_grid("data/sphere_g", data_g, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
|
|
gctl::save_surfer6_grid("data/sphere_gx", data_gx, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
|
|
gctl::save_surfer6_grid("data/sphere_gy", data_gy, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
|
|
gctl::save_surfer6_grid("data/sphere_gz", data_gz, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
|
|
#endif // GCTL_NETCDF
|
|
|
|
}
|
|
catch (std::exception &e)
|
|
{
|
|
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
|
}
|
|
return 0;
|
|
} |