80 lines
3.0 KiB
C++
80 lines
3.0 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"
|
|
|
|
using namespace gctl;
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
try
|
|
{
|
|
// set up observation points
|
|
array<point3dc> obes;
|
|
gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0), point3dc(0, 0, 0), point3dc(0, 100, 0), 41, 41, obes);
|
|
// set up model element
|
|
array<grav_tetrahedron> onetetra(1);
|
|
array<gravtet_para> tet_gp;
|
|
onetetra[0].set(point3dc(20, 50, -30), point3dc(80, 20, -10), point3dc(50, 80, -15), point3dc(50, 50, -50), 0);
|
|
callink_gravity_para(onetetra, tet_gp);
|
|
|
|
array<double> rho(1, 1.0);
|
|
|
|
array<tensor> data_grad;
|
|
gobser(data_grad, onetetra, obes, rho);
|
|
|
|
array<double> data(data_grad.size());
|
|
for (int i = 0; i < data_grad.size(); ++i)
|
|
{
|
|
data[i] = data_grad[i].at(2,2) * 1e+4;
|
|
}
|
|
|
|
#ifdef GCTL_NETCDF
|
|
save_netcdf_grid("data/tetra_g", data, 41, 41, 0.0, 2.5, 0.0, 2.5);
|
|
|
|
gmshio fio;
|
|
fio.init_file("data/tetra_g", Output);
|
|
fio.set_packed(NotPacked, Output);
|
|
fio.save_mesh(onetetra);
|
|
#else
|
|
save_surfer6_grid("data/tetra_g", data, 41, 41, 0.0, 2.5*41, 0.0, 2.5*41, NAN, NAN, Surfer6Binary);
|
|
|
|
gmshio fio;
|
|
fio.init_file("data/tetra_g", Output);
|
|
fio.set_packed(NotPacked, Output);
|
|
fio.save_mesh(onetetra);
|
|
#endif // GCTL_NETCDF
|
|
|
|
}
|
|
catch (std::exception &e)
|
|
{
|
|
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
|
}
|
|
return 0;
|
|
} |