/********************************************************
 *  ██████╗  ██████╗████████╗██╗
 * ██╔════╝ ██╔════╝╚══██╔══╝██║
 * ██║  ███╗██║        ██║   ██║
 * ██║   ██║██║        ██║   ██║
 * ╚██████╔╝╚██████╗   ██║   ███████╗
 *  ╚═════╝  ╚═════╝   ╚═╝   ╚══════╝
 * 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 "../lib/potential.h"

using namespace gctl;

int main(int argc, char const *argv[])
{
	// 设置块体模型
	array<mag_block> bk(1);
	bk[0].set(-50, 50, -50, 50, -50, 0);
	// 设置块体的磁化率与磁化参数
	array<double> sus(1, 0.1);
	array<magblock_para> mag_para(1);
	mag_para[0].inclina_deg = 20.0;
	mag_para[0].declina_deg = 2.0;
	bk[0].att = &mag_para[0];
	// 设置观测点位
	array<point3dc> obsp;
	gridspace(point3dc(-300, 0, 5), point3dc(300, 0, 5), point3dc(0, -300, 5), point3dc(0, 300, 5), 121, 121, obsp);

	// 正演计算
	array<double> hax, hay, za, obsval;
	magobser(hax, bk, obsp, sus, Hax, ShortMsg);
	// 保存网格
	gctl::save_netcdf_grid("out_magobser_block", hax, 121, 121, -300.0, 5.0, -300.0, 5.0, "x", "y", "Hax");

	magobser(hay, bk, obsp, sus, Hay, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", hay, "x", "y", "Hay");

	magobser(za, bk, obsp, sus, Za, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", za, "x", "y", "Za");

	magobser(obsval, bk, obsp, sus, 60.0, 30.0, DeltaT, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", obsval, "x", "y", "DeltaT");

	magobser(obsval, bk, obsp, sus, 60.0, 30.0, DeltaTx, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", obsval, "x", "y", "DeltaTx");

	magobser(obsval, bk, obsp, sus, 60.0, 30.0, DeltaTy, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", obsval, "x", "y", "DeltaTy");

	magobser(obsval, bk, obsp, sus, 60.0, 30.0, DeltaTz, ShortMsg);
	// 保存网格
	gctl::append_netcdf_grid("out_magobser_block", obsval, "x", "y", "DeltaTz");
	return 0;
}