/********************************************************
 *  ██████╗  ██████╗████████╗██╗
 * ██╔════╝ ██╔════╝╚══██╔══╝██║
 * ██║  ███╗██║        ██║   ██║
 * ██║   ██║██║        ██║   ██║
 * ╚██████╔╝╚██████╗   ██║   ███████╗
 *  ╚═════╝  ╚═════╝   ╚═╝   ╚══════╝
 * 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[])
{
	// set up observation parameters and block parameters
	array<point3dc> obes;
	gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0), 
		point3dc(0, 0, 0), point3dc(0, 100, 0), 51, 51, obes);

	array<block> model(2);
	model[0].set(20, 35, 20, 40, -40, -10);
	model[1].set(50, 60, 40, 70, -32, -5);

	array<double> rho(2, 1.0);
	array<double> g, gx, gy, gz;
	gobser(g, model, obes, rho, Vz, ShortMsg);

#ifdef GCTL_NETCDF
	gobser(gx, model, obes, rho, Tzx, ShortMsg);
	gobser(gy, model, obes, rho, Tzy, ShortMsg);
	gobser(gz, model, obes, rho, Tzz, ShortMsg);

	save_netcdf_grid("data/block_g", g, 51, 51, 0.0, 2.0, 0.0, 2.0, "x", "y", "g");
	append_netcdf_grid("data/block_g", gx, "x", "y", "gx");
	append_netcdf_grid("data/block_g", gy, "x", "y", "gy");
	append_netcdf_grid("data/block_g", gz, "x", "y", "gz");
#else
	save_surfer6_grid("data/block_g", g, 51, 51, 0.0, 2.0*51, 0.0, 2.0*51);
#endif // GCTL_NETCDF

	return 0;
}