tmp
This commit is contained in:
parent
cd5b6f26fe
commit
4b369b25ea
32762
data/stt/mag_obs.csv
Normal file
32762
data/stt/mag_obs.csv
Normal file
File diff suppressed because it is too large
Load Diff
BIN
data/stt/mag_obs.nc
Normal file
BIN
data/stt/mag_obs.nc
Normal file
Binary file not shown.
BIN
data/stt/mag_obs_ren17.nc
Normal file
BIN
data/stt/mag_obs_ren17.nc
Normal file
Binary file not shown.
@ -17,7 +17,7 @@ add_example(mobser_block_ex OFF)
|
||||
add_example(mobser_block_gradient_ex OFF)
|
||||
add_example(mobser_tri_ex OFF)
|
||||
add_example(mobser_tri_sph_ex OFF)
|
||||
add_example(mobser_tricone_ex OFF)
|
||||
add_example(mobser_tricone_ex ON)
|
||||
add_example(mobser_tetra_ex OFF)
|
||||
add_example(mobser_tetra_ex2 OFF)
|
||||
add_example(mobser_tetra_sph_ex OFF)
|
||||
|
@ -31,17 +31,36 @@
|
||||
|
||||
using namespace gctl;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
bool clockwise(const triangle &t)
|
||||
{
|
||||
if (dot(cross(*t.vert[1] - *t.vert[0], *t.vert[2] - *t.vert[0]), *t.vert[0]) < 0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[]) try
|
||||
{
|
||||
array<vertex3dc> top_node, btm_node;
|
||||
array<mag_tricone> top_ele, btm_ele;
|
||||
array<magcone_ren17> top_ele, btm_ele;
|
||||
|
||||
gmshio fio;
|
||||
fio.init_file("data/stt/stt_1d_6371200_sph.msh", gctl::Input);
|
||||
fio.set_packed(gctl::Packed, gctl::Input);
|
||||
fio.init_file("data/stt/sph_rect.msh", gctl::Input);
|
||||
fio.set_packed(gctl::NotPacked, gctl::Input);
|
||||
fio.read_mesh(top_ele, top_node);
|
||||
fio.read_mesh(btm_ele, btm_node);
|
||||
|
||||
// 确定三角形顶点排序
|
||||
triangle t;
|
||||
vertex3dc *v = nullptr;
|
||||
for (size_t i = 0; i < top_ele.size(); i++)
|
||||
{
|
||||
t.set(*top_ele[i].vert[0], *top_ele[i].vert[1], *top_ele[i].vert[2]);
|
||||
if (clockwise(t))
|
||||
{
|
||||
v = top_ele[i].vert[0]; top_ele[i].vert[0] = top_ele[i].vert[1]; top_ele[i].vert[1] = v;
|
||||
v = btm_ele[i].vert[0]; btm_ele[i].vert[0] = btm_ele[i].vert[1]; btm_ele[i].vert[1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
vertex3dc origin(point3dc(0.0, 0.0, 0.0), top_node.size());
|
||||
for (size_t i = 0; i < top_ele.size(); i++)
|
||||
{
|
||||
@ -68,49 +87,31 @@ int main(int argc, char const *argv[])
|
||||
mag_B[i] = magkernel_single(md, cen_c);
|
||||
}
|
||||
|
||||
array<magcone_para> top_para, btm_para;
|
||||
// 计算磁体参数
|
||||
array<magcone_para_ren17> top_para, btm_para;
|
||||
array<double> sus(top_ele.size(), 0.01);
|
||||
callink_magnetic_para(top_ele, top_para, mag_B);
|
||||
callink_magnetic_para(btm_ele, btm_para, mag_B);
|
||||
|
||||
// 设置观测点位
|
||||
array<point3ds> obsp(top_ele.size());
|
||||
for (size_t i = 0; i < top_ele.size(); i++)
|
||||
{
|
||||
cen_c = 1.0/3.0*(*top_ele[i].vert[0] + *top_ele[i].vert[1] + *top_ele[i].vert[2]);
|
||||
|
||||
obsp[i] = cen_c.c2s();
|
||||
obsp[i].rad += 200000;
|
||||
}
|
||||
array<point3ds> obsp;
|
||||
grid_points_2d(obsp, 10.0, 55.0, 20.0, 65.0, 0.25, 0.25, 6371200.0 + 100000);
|
||||
|
||||
// 正演计算
|
||||
array<double> obsval(obsp.size());
|
||||
array<point3dc> obsgrad;
|
||||
|
||||
// 正演磁分量数据
|
||||
magobser(obsgrad, top_ele, btm_ele, obsp, sus, ShortMsg);
|
||||
|
||||
// 保存网格
|
||||
fio.init_file("data/stt/stt_1d_out.msh", gctl::Output);
|
||||
fio.set_packed(gctl::NotPacked, gctl::Output);
|
||||
fio.save_mesh(top_ele, top_node);
|
||||
|
||||
for (int i = 0; i < obsp.size(); ++i)
|
||||
{
|
||||
obsval[i] = obsgrad[i].x;
|
||||
}
|
||||
fio.save_data("Br", obsval, ElemData);
|
||||
|
||||
for (int i = 0; i < obsp.size(); ++i)
|
||||
{
|
||||
obsval[i] = obsgrad[i].y;
|
||||
}
|
||||
fio.save_data("Bt", obsval, ElemData);
|
||||
|
||||
for (int i = 0; i < obsp.size(); ++i)
|
||||
{
|
||||
obsval[i] = obsgrad[i].z;
|
||||
}
|
||||
fio.save_data("Bp", obsval, ElemData);
|
||||
geodsv_io fout;
|
||||
fout.init_table(obsp.size(), 6);
|
||||
fout.set_column_names({"rad", "lon", "lat", "Br", "Bt", "Bp"});
|
||||
fout.fill_column_point3ds(obsp, "rad", "lon", "lat");
|
||||
fout.fill_column_point3dc(obsgrad, "Br", "Bt", "Bp");
|
||||
fout.save_csv("data/stt/mag_obs");
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
||||
}
|
@ -48,6 +48,7 @@
|
||||
#include "potential/mkernel_block.h"
|
||||
#include "potential/mkernel_triangle.h"
|
||||
#include "potential/mkernel_tricone.h"
|
||||
#include "potential/mkernel_tricone_Ren2017.h"
|
||||
#include "potential/mkernel_tetrahedron.h"
|
||||
#include "potential/mkernel_tetrahedron_Ren2017.h"
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace gctl
|
||||
protected:
|
||||
array<grav_tetrahedron> grav_ele_;
|
||||
array<gravtet_para> grav_para_;
|
||||
array<mag_tetrahedron_ren17> mag_ele_;
|
||||
array<magtet_ren17> mag_ele_;
|
||||
array<magtet_para_ren17> mag_para_;
|
||||
|
||||
public:
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#define GCTL_MAG_TETRA_TOL 1e-16
|
||||
|
||||
void gctl::callink_magnetic_para_direct(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para, const array<point3dc> &magz)
|
||||
void gctl::callink_magnetic_para_direct(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para, const array<point3dc> &magz)
|
||||
{
|
||||
point3dc v1, v2, v3, ne, nf;
|
||||
|
||||
@ -66,7 +66,7 @@ void gctl::callink_magnetic_para_direct(array<mag_tetrahedron_ren17> &in_tet, ar
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::callink_magnetic_para_earth(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
void gctl::callink_magnetic_para_earth(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, double field_tense)
|
||||
{
|
||||
if (declina_deg < -180.0 || declina_deg > 180.0 ||
|
||||
@ -116,7 +116,7 @@ void gctl::callink_magnetic_para_earth(array<mag_tetrahedron_ren17> &in_tet, arr
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::callink_magnetic_para_earth_sph(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
void gctl::callink_magnetic_para_earth_sph(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec, double field_tense)
|
||||
{
|
||||
if (declina_deg < -180.0 || declina_deg > 180.0 ||
|
||||
@ -177,7 +177,7 @@ void gctl::callink_magnetic_para_earth_sph(array<mag_tetrahedron_ren17> &in_tet,
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::callink_magnetic_para_earth_sph(mag_tetrahedron_ren17 &in_tet, magtet_para_ren17 &out_para,
|
||||
void gctl::callink_magnetic_para_earth_sph(magtet_ren17 &in_tet, magtet_para_ren17 &out_para,
|
||||
double inclina_deg, double declina_deg, point3dc *mag_vec, double field_tense)
|
||||
{
|
||||
if (declina_deg < -180.0 || declina_deg > 180.0 || inclina_deg < -90 || inclina_deg > 90 || field_tense < 0.0)
|
||||
@ -232,12 +232,12 @@ void gctl::callink_magnetic_para_earth_sph(mag_tetrahedron_ren17 &in_tet, magtet
|
||||
}
|
||||
|
||||
// declare algorithm for individual element and observation point
|
||||
double magkernel_tetrahedron_potential_sig(const gctl::mag_tetrahedron_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
gctl::point3dc magkernel_tetrahedron_gradient_sig(const gctl::mag_tetrahedron_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
gctl::tensor magkernel_tetrahedron_tensor_sig(const gctl::mag_tetrahedron_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
double magkernel_tetrahedron_potential_sig(const gctl::magtet_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
gctl::point3dc magkernel_tetrahedron_gradient_sig(const gctl::magtet_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
gctl::tensor magkernel_tetrahedron_tensor_sig(const gctl::magtet_ren17 &ele_ptr, const gctl::point3dc &op_ptr);
|
||||
|
||||
// define functions
|
||||
void gctl::magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren17> &ele,
|
||||
void gctl::magkernel(matrix<double> &out_kernel, const array<magtet_ren17> &ele,
|
||||
const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -261,7 +261,7 @@ void gctl::magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_ren17> &ele,
|
||||
void gctl::magkernel(matrix<point3dc> &out_kernel, const array<magtet_ren17> &ele,
|
||||
const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -287,7 +287,7 @@ void gctl::magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_r
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren17> &ele,
|
||||
void gctl::magkernel(matrix<tensor> &out_kernel, const array<magtet_ren17> &ele,
|
||||
const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -311,7 +311,7 @@ void gctl::magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void gctl::magkernel(matrix<double> &out_kernel, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
double geo_declina, double geo_inclina, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -342,7 +342,7 @@ void gctl::magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_ren17> &ele,
|
||||
void gctl::magkernel(matrix<point3dc> &out_kernel, const array<magtet_ren17> &ele,
|
||||
const array<point3ds> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -391,7 +391,7 @@ void gctl::magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_r
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren17> &ele,
|
||||
void gctl::magkernel(matrix<tensor> &out_kernel, const array<magtet_ren17> &ele,
|
||||
const array<point3ds> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -446,7 +446,7 @@ void gctl::magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren
|
||||
return;
|
||||
}
|
||||
|
||||
gctl::point3dc gctl::magkernel_single(const mag_tetrahedron_ren17 &ele, const point3ds &obsp)
|
||||
gctl::point3dc gctl::magkernel_single(const magtet_ren17 &ele, const point3ds &obsp)
|
||||
{
|
||||
tensor R;
|
||||
R[0][0] = sin((0.5-obsp.lat/180.0)*M_PI)*cos((2.0+obsp.lon/180.0)*M_PI);
|
||||
@ -469,7 +469,7 @@ gctl::point3dc gctl::magkernel_single(const mag_tetrahedron_ren17 &ele, const po
|
||||
return out_k;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
void gctl::magobser(array<double> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
@ -492,7 +492,7 @@ void gctl::magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
@ -517,7 +517,7 @@ void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17>
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
@ -540,7 +540,7 @@ void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void gctl::magobser(array<double> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -564,7 +564,7 @@ void gctl::magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -590,7 +590,7 @@ void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17>
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -614,7 +614,7 @@ void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -660,7 +660,7 @@ void gctl::magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17>
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
int i, j;
|
||||
@ -712,7 +712,7 @@ void gctl::magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &
|
||||
return;
|
||||
}
|
||||
|
||||
double magkernel_tetrahedron_potential_sig(const gctl::mag_tetrahedron_ren17 &tet, const gctl::point3dc &site)
|
||||
double magkernel_tetrahedron_potential_sig(const gctl::magtet_ren17 &tet, const gctl::point3dc &site)
|
||||
{
|
||||
double Rij_minus, Rij_plus, Sij_plus, Sij_minus, Rij0, mij0, wi0;
|
||||
double part1, part2, k0, absw, beta;
|
||||
@ -767,7 +767,7 @@ double magkernel_tetrahedron_potential_sig(const gctl::mag_tetrahedron_ren17 &te
|
||||
return out_pot;
|
||||
}
|
||||
|
||||
gctl::point3dc magkernel_tetrahedron_gradient_sig(const gctl::mag_tetrahedron_ren17 &tet, const gctl::point3dc &site)
|
||||
gctl::point3dc magkernel_tetrahedron_gradient_sig(const gctl::magtet_ren17 &tet, const gctl::point3dc &site)
|
||||
{
|
||||
double Rij_minus, Rij_plus, Sij_plus, Sij_minus, Rij0, mij0, wi0;
|
||||
double beta, Aij, sig, absw;
|
||||
@ -835,7 +835,7 @@ gctl::point3dc magkernel_tetrahedron_gradient_sig(const gctl::mag_tetrahedron_re
|
||||
return out_grad;
|
||||
}
|
||||
|
||||
gctl::tensor magkernel_tetrahedron_tensor_sig(const gctl::mag_tetrahedron_ren17 &tet, const gctl::point3dc &site)
|
||||
gctl::tensor magkernel_tetrahedron_tensor_sig(const gctl::magtet_ren17 &tet, const gctl::point3dc &site)
|
||||
{
|
||||
double Rij_minus, Rij_plus, Sij_plus, Sij_minus, Rij0, mij0, wi0;
|
||||
double beta, sig, absw;
|
||||
|
@ -40,7 +40,7 @@ namespace gctl
|
||||
point3dc te[12]; // 四面体边切线矢量
|
||||
};
|
||||
|
||||
typedef type_tetrahedron<magtet_para_ren17> mag_tetrahedron_ren17; ///< 带magtet_para_ren17属性的四面体结构体
|
||||
typedef type_tetrahedron<magtet_para_ren17> magtet_ren17; ///< 带magtet_para_ren17属性的四面体结构体
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tetrahedral elements.
|
||||
@ -52,7 +52,7 @@ namespace gctl
|
||||
* @param out_para Output parameters
|
||||
* @param magz Magnetic magnetizations
|
||||
*/
|
||||
void callink_magnetic_para_direct(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para, const array<point3dc> &magz);
|
||||
void callink_magnetic_para_direct(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para, const array<point3dc> &magz);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tetrahedral elements.
|
||||
@ -66,7 +66,7 @@ namespace gctl
|
||||
* @param declina_deg declination angle
|
||||
* @param field_tense Tense of the magnetic field
|
||||
*/
|
||||
void callink_magnetic_para_earth(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
void callink_magnetic_para_earth(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, double field_tense = GCTL_T0);
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ namespace gctl
|
||||
* @param mag_vec Output magnetization vectors (This is useful for data visualization)
|
||||
* @param field_tense Tense of the Earth's magnetic field
|
||||
*/
|
||||
void callink_magnetic_para_earth_sph(array<mag_tetrahedron_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
void callink_magnetic_para_earth_sph(array<magtet_ren17> &in_tet, array<magtet_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec = nullptr, double field_tense = GCTL_T0);
|
||||
|
||||
/**
|
||||
@ -98,52 +98,52 @@ namespace gctl
|
||||
* @param mag_vec Output magnetization vectors (This is useful for data visualization)
|
||||
* @param field_tense Tense of the Earth's magnetic field
|
||||
*/
|
||||
void callink_magnetic_para_earth_sph(mag_tetrahedron_ren17 &in_tet, magtet_para_ren17 &out_para,
|
||||
void callink_magnetic_para_earth_sph(magtet_ren17 &in_tet, magtet_para_ren17 &out_para,
|
||||
double inclina_deg, double declina_deg, point3dc *mag_vec = nullptr, double field_tense = GCTL_T0);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the magnetic poential data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magkernel(matrix<double> &out_kernel, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the magnetic conponents data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix. Directional components are stored accordingly.
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magkernel(matrix<point3dc> &out_kernel, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the magnetic tensor data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix. Directional components are stored accordingly.
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magkernel(matrix<tensor> &out_kernel, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the deltaT anomaly data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -152,33 +152,33 @@ namespace gctl
|
||||
* @param geo_inclina Inclination angle of the geo-magnetic field.
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<double> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magkernel(matrix<double> &out_kernel, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
double geo_declina, double geo_inclina, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the magnetic conponents data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix. Directional components are stored accordingly.
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<point3dc> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void magkernel(matrix<point3dc> &out_kernel, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the kernel matrix of the magnetic tensor data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_kernel Output kernel matrix. Directional components are stored accordingly.
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magkernel(matrix<tensor> &out_kernel, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void magkernel(matrix<tensor> &out_kernel, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
@ -188,48 +188,48 @@ namespace gctl
|
||||
* @param obsp The observation point
|
||||
* @return point3dc The returned magnetic componments
|
||||
*/
|
||||
point3dc magkernel_single(const mag_tetrahedron_ren17 &ele, const point3ds &obsp);
|
||||
point3dc magkernel_single(const magtet_ren17 &ele, const point3ds &obsp);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic potential data.
|
||||
*
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
void magobser(array<double> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic component data.
|
||||
*
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional components are stored accordingly. Delta_T anomalies could be retrived using the function magnetic_components2deltaT().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
void magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic tensor data.
|
||||
*
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note The magnetic susceptibility is impliclity setted using the magnetic magnetization values. Use callink_magnetic_para_direct() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional components are stored accordingly. Delta_T gradient anomalies could be retrived using the function magnetic_tensors2deltaTs().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
* @param obsp Observation sites
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
void magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic potential data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -237,13 +237,13 @@ namespace gctl
|
||||
* @param sus Magnetic susceptibilities
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<double> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magobser(array<double> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic component data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional components are stored accordingly. Delta_T anomalies could be retrived using the function magnetic_components2deltaT().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -251,13 +251,13 @@ namespace gctl
|
||||
* @param sus Magnetic susceptibilities
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic tensor data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional tensors are stored accordingly. Delta_T gradient anomalies could be retrived using the function magnetic_tensors2deltaTs().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -265,13 +265,13 @@ namespace gctl
|
||||
* @param sus Magnetic susceptibilities
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3dc> &obsp,
|
||||
void magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3dc> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic component data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional components are stored accordingly. Delta_T anomalies could be retrived using the function magnetic_components2deltaT().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -279,13 +279,13 @@ namespace gctl
|
||||
* @param sus Magnetic susceptibilities
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<point3dc> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void magobser(array<point3dc> &out_obs, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate magnetic tensor data.
|
||||
*
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the mag_tetrahedron_ren17 elements.
|
||||
* @note Use callink_magnetic_para_earth_sph() to initialize the magtet_ren17 elements.
|
||||
*
|
||||
* @param out_obs Output magnetic field data. Directional tensors are stored accordingly. Delta_T gradient anomalies could be retrived using the function magnetic_tensors2deltaTs().
|
||||
* @param ele Magnetic tetrahedrons.
|
||||
@ -293,7 +293,7 @@ namespace gctl
|
||||
* @param sus Magnetic susceptibilities
|
||||
* @param verbose Output info level
|
||||
*/
|
||||
void magobser(array<tensor> &out_obs, const array<mag_tetrahedron_ren17> &ele, const array<point3ds> &obsp,
|
||||
void magobser(array<tensor> &out_obs, const array<magtet_ren17> &ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
}
|
||||
#endif // _GCTL_MAG_KERNEL_TETRAHEDRON_REN2017_H
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "mkernel_tricone.h"
|
||||
|
||||
void gctl::callink_magnetic_para(array<mag_tricone> &in_cone, array<magcone_para> &out_para, const array<point3dc> &mag_B)
|
||||
void gctl::callink_magnetic_para(array<magcone> &in_cone, array<magcone_para> &out_para, const array<point3dc> &mag_B)
|
||||
{
|
||||
point3dc v1, v2, v3, ne, nf, mag_z;
|
||||
|
||||
@ -63,7 +63,7 @@ void gctl::callink_magnetic_para(array<mag_tricone> &in_cone, array<magcone_para
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::callink_magnetic_para_earth_sph(array<mag_tricone> &in_tet, array<magcone_para> &out_para,
|
||||
void gctl::callink_magnetic_para_earth_sph(array<magcone> &in_tet, array<magcone_para> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec, double field_tense)
|
||||
{
|
||||
if (declina_deg < -180.0 || declina_deg > 180.0 ||
|
||||
@ -122,7 +122,7 @@ void gctl::callink_magnetic_para_earth_sph(array<mag_tricone> &in_tet, array<mag
|
||||
return;
|
||||
}
|
||||
|
||||
gctl::point3dc gctl::magkernel_single(const mag_tricone &a_ele, const point3ds &a_op, tensor *R_ptr)
|
||||
gctl::point3dc gctl::magkernel_single(const magcone &a_ele, const point3ds &a_op, tensor *R_ptr)
|
||||
{
|
||||
int f,e;
|
||||
double Le,wf;
|
||||
@ -175,8 +175,8 @@ gctl::point3dc gctl::magkernel_single(const mag_tricone &a_ele, const point3ds &
|
||||
return out_c;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<double> &kernel, const array<mag_tricone> &top_ele,
|
||||
const array<mag_tricone> &btm_ele, const array<point3ds> &obsp,
|
||||
void gctl::magkernel(matrix<double> &kernel, const array<magcone> &top_ele,
|
||||
const array<magcone> &btm_ele, const array<point3ds> &obsp,
|
||||
magnetic_field_type_e comp_type, verbose_type_e verbose)
|
||||
{
|
||||
if (comp_type != Bx && comp_type != By && comp_type != Bz)
|
||||
@ -237,7 +237,7 @@ void gctl::magkernel(matrix<double> &kernel, const array<mag_tricone> &top_ele,
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(spmat<double> &kernel, const array<mag_tricone> &top_ele, const array<mag_tricone> &btm_ele,
|
||||
void gctl::magkernel(spmat<double> &kernel, const array<magcone> &top_ele, const array<magcone> &btm_ele,
|
||||
const array<point3ds> &obsp, double cut_angle, magnetic_field_type_e comp_type, verbose_type_e verbose)
|
||||
{
|
||||
if (comp_type != Bx && comp_type != By && comp_type != Bz)
|
||||
@ -333,8 +333,8 @@ void gctl::magkernel(spmat<double> &kernel, const array<mag_tricone> &top_ele, c
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<mag_tricone> &top_ele,
|
||||
const array<mag_tricone> &btm_ele, const array<point3ds> &obsp, const array<double> &sus,
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<magcone> &top_ele,
|
||||
const array<magcone> &btm_ele, const array<point3ds> &obsp, const array<double> &sus,
|
||||
verbose_type_e verbose)
|
||||
{
|
||||
if (top_ele.size() != btm_ele.size())
|
||||
|
@ -40,7 +40,7 @@ namespace gctl
|
||||
double edglen[12]; ///< edge lengths of six edges
|
||||
};
|
||||
|
||||
typedef type_tricone<magcone_para> mag_tricone; ///< 带magcone_para属性的三角锥结构体
|
||||
typedef type_tricone<magcone_para> magcone; ///< 带magcone_para属性的三角锥结构体
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tricone elements.
|
||||
@ -49,7 +49,7 @@ namespace gctl
|
||||
* @param out_para Output parameters
|
||||
* @param mag_B magnetization vecrtors
|
||||
*/
|
||||
void callink_magnetic_para(array<mag_tricone> &in_cone, array<magcone_para> &out_para, const array<point3dc> &mag_B);
|
||||
void callink_magnetic_para(array<magcone> &in_cone, array<magcone_para> &out_para, const array<point3dc> &mag_B);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tricone elements wrt. the spherical coordinates.
|
||||
@ -64,18 +64,18 @@ namespace gctl
|
||||
* @param mag_vec Output magnetization vectors (This is useful for data visualization)
|
||||
* @param field_tense Tense of the Earth's magnetic field
|
||||
*/
|
||||
void callink_magnetic_para_earth_sph(array<mag_tricone> &in_tet, array<magcone_para> &out_para,
|
||||
void callink_magnetic_para_earth_sph(array<magcone> &in_tet, array<magcone_para> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec = nullptr, double field_tense = GCTL_T0);
|
||||
|
||||
point3dc magkernel_single(const mag_tricone &a_ele, const point3ds &a_op, tensor *R_ptr = nullptr);
|
||||
point3dc magkernel_single(const magcone &a_ele, const point3ds &a_op, tensor *R_ptr = nullptr);
|
||||
|
||||
void magkernel(matrix<double> &kernel, const array<mag_tricone> &top_ele, const array<mag_tricone> &btm_ele,
|
||||
void magkernel(matrix<double> &kernel, const array<magcone> &top_ele, const array<magcone> &btm_ele,
|
||||
const array<point3ds> &obsp, magnetic_field_type_e comp_type = Bz, verbose_type_e verbose = FullMsg);
|
||||
|
||||
void magkernel(spmat<double> &kernel, const array<mag_tricone> &top_ele, const array<mag_tricone> &btm_ele,
|
||||
void magkernel(spmat<double> &kernel, const array<magcone> &top_ele, const array<magcone> &btm_ele,
|
||||
const array<point3ds> &obsp, double cut_angle, magnetic_field_type_e comp_type = Bz, verbose_type_e verbose = FullMsg);
|
||||
|
||||
void magobser(array<point3dc> &out_obs, const array<mag_tricone> &top_ele, const array<mag_tricone> &btm_ele,
|
||||
void magobser(array<point3dc> &out_obs, const array<magcone> &top_ele, const array<magcone> &btm_ele,
|
||||
const array<point3ds> &obsp, const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
}
|
||||
|
||||
|
582
lib/potential/mkernel_tricone_Ren2017.cpp
Normal file
582
lib/potential/mkernel_tricone_Ren2017.cpp
Normal file
@ -0,0 +1,582 @@
|
||||
/********************************************************
|
||||
* ██████╗ ██████╗████████╗██╗
|
||||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||||
* ██║ ███╗██║ ██║ ██║
|
||||
* ██║ ██║██║ ██║ ██║
|
||||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
* 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 "mkernel_tricone_Ren2017.h"
|
||||
#include "cmath"
|
||||
|
||||
#define GCTL_MAG_TETRA_TOL 1e-16
|
||||
|
||||
void gctl::callink_magnetic_para(array<magcone_ren17> &in_cone, array<magcone_para_ren17> &out_para, const array<point3dc> &mag_B)
|
||||
{
|
||||
point3dc v1, v2, v3, ne, nf;
|
||||
|
||||
out_para.resize(in_cone.size());
|
||||
for (int i = 0; i < in_cone.size(); ++i)
|
||||
{
|
||||
if (in_cone[i].vert[0] == nullptr || in_cone[i].vert[1] == nullptr ||
|
||||
in_cone[i].vert[2] == nullptr || in_cone[i].vert[3] == nullptr)
|
||||
{
|
||||
throw runtime_error("Invalid vertex pointer. From callink_magnetic_para(...)");
|
||||
}
|
||||
|
||||
for (int f = 0; f < 4; ++f)
|
||||
{
|
||||
v1 = *in_cone[i].fget(f, 1) - *in_cone[i].fget(f, 0);
|
||||
v2 = *in_cone[i].fget(f, 2) - *in_cone[i].fget(f, 0);
|
||||
nf = cross(v1, v2).normal();
|
||||
out_para[i].nf[f] = nf;
|
||||
|
||||
for (int e = 0; e < 3; ++e)
|
||||
{
|
||||
v3 = *in_cone[i].fget(f, (e+1)%3) - *in_cone[i].fget(f, e);
|
||||
ne = cross(v3, nf).normal();
|
||||
out_para[i].ne[e+f*3] = ne;
|
||||
out_para[i].te[e+f*3] = cross(nf, ne).normal();
|
||||
}
|
||||
|
||||
out_para[i].mag_amp[f] = dot(mag_B[i], nf);
|
||||
}
|
||||
|
||||
in_cone[i].att = out_para.get(i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::callink_magnetic_para_earth_sph(array<magcone_ren17> &in_cone, array<magcone_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec, double field_tense)
|
||||
{
|
||||
if (declina_deg < -180.0 || declina_deg > 180.0 ||
|
||||
inclina_deg < -90 || inclina_deg > 90 || field_tense < 0.0)
|
||||
{
|
||||
throw invalid_argument("Invalid parameters. From gctl::callink_magnetic_para_earth_sph(...)");
|
||||
}
|
||||
|
||||
point3dc v1, v2, v3, ne, nf, mag_z, c;
|
||||
point3ds s;
|
||||
|
||||
double I = inclina_deg*M_PI/180.0;
|
||||
double A = declina_deg*M_PI/180.0;
|
||||
|
||||
if (mag_vec != nullptr) mag_vec->resize(in_cone.size());
|
||||
out_para.resize(in_cone.size());
|
||||
for (int i = 0; i < in_cone.size(); ++i)
|
||||
{
|
||||
if (in_cone[i].vert[0] == nullptr || in_cone[i].vert[1] == nullptr ||
|
||||
in_cone[i].vert[2] == nullptr || in_cone[i].vert[3] == nullptr)
|
||||
{
|
||||
throw runtime_error("Invalid vertex pointer. From callink_magnetic_para_earth_sph(...)");
|
||||
}
|
||||
|
||||
// magnetization vector at the local coordinates
|
||||
// note here the postive direction of the inclination angle is downward
|
||||
// note here the postive direction of the declination angle is clockwise
|
||||
mag_z.x = cos(I)*sin(A);
|
||||
mag_z.y = cos(I)*cos(A);
|
||||
mag_z.z = -1.0*sin(I);
|
||||
|
||||
c = 1.0/3.0*(*in_cone[i].vert[0] + *in_cone[i].vert[1] + *in_cone[i].vert[2]);
|
||||
s = c.c2s();
|
||||
// magnetic susceptibility is taken as one here
|
||||
// rotate the local coordinate system to the regular status
|
||||
mag_z = field_tense * mag_z.rotate((90.0 - s.lat)*M_PI/180.0, 0.0, (90.0 + s.lon)*M_PI/180.0).normal();
|
||||
if (mag_vec != nullptr) mag_vec->at(i) = mag_z;
|
||||
|
||||
for (int f = 0; f < 4; ++f)
|
||||
{
|
||||
v1 = *in_cone[i].fget(f, 1) - *in_cone[i].fget(f, 0);
|
||||
v2 = *in_cone[i].fget(f, 2) - *in_cone[i].fget(f, 0);
|
||||
nf = cross(v1, v2).normal();
|
||||
out_para[i].nf[f] = nf;
|
||||
|
||||
for (int e = 0; e < 3; ++e)
|
||||
{
|
||||
v3 = *in_cone[i].fget(f, (e+1)%3) - *in_cone[i].fget(f, e);
|
||||
ne = cross(v3, nf).normal();
|
||||
out_para[i].ne[e+f*3] = ne;
|
||||
out_para[i].te[e+f*3] = cross(nf, ne).normal();
|
||||
}
|
||||
|
||||
out_para[i].mag_amp[f] = dot(mag_z, nf);
|
||||
}
|
||||
|
||||
in_cone[i].att = out_para.get(i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gctl::point3dc gctl::magkernel_single(const magcone_ren17 &a_ele, const point3ds &a_op, tensor *R_ptr)
|
||||
{
|
||||
double Rij_minus, Rij_plus, Sij_plus, Sij_minus, Rij0, mij0, wi0;
|
||||
double beta, Aij, sig, absw;
|
||||
gctl::point3dc oi, k1, part1, part2;
|
||||
|
||||
// get attribute pointer
|
||||
if (a_ele.att == nullptr) throw gctl::runtime_error("[gctl_potential::magcone_ren17] Magnetization parameter not set.");
|
||||
gctl::magcone_para_ren17 *mpara = a_ele.att;
|
||||
|
||||
gctl::tensor R;
|
||||
if (R_ptr != nullptr) R = *R_ptr;
|
||||
else R = transform_matrix(a_op);
|
||||
|
||||
// get the observation site in the local coordinates
|
||||
gctl::point3dc site = a_op.s2c();
|
||||
gctl::point3dc out_grad(0.0, 0.0, 0.0);
|
||||
for (int f = 0; f < 4; ++f)
|
||||
{
|
||||
k1.set(0.0, 0.0, 0.0);
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
Rij_minus = (site - *a_ele.fget(f, j)).module();
|
||||
Rij_plus = (site - *a_ele.fget(f, (j+1)%3)).module();
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
wi0 = gctl::dot(site - *a_ele.fget(f, j), mpara->nf[f]);
|
||||
sig = gctl::sign(wi0);
|
||||
absw = std::abs(wi0);
|
||||
}
|
||||
|
||||
oi = site - wi0*mpara->nf[f];
|
||||
Sij_minus = gctl::dot(*a_ele.fget(f, j) - oi, mpara->te[3*f+j]);
|
||||
Sij_plus = gctl::dot(*a_ele.fget(f, (j+1)%3) - oi, mpara->te[3*f+j]);
|
||||
mij0 = gctl::dot(*a_ele.fget(f, j) - oi, mpara->ne[3*f+j]);
|
||||
Rij0 = std::sqrt(wi0*wi0 + mij0*mij0);
|
||||
|
||||
part2.set(0.0, 0.0, 0.0);
|
||||
if (absw > GCTL_MAG_TETRA_TOL)
|
||||
{
|
||||
beta = atan((mij0*Sij_plus)/(Rij0*Rij0 + absw*Rij_plus))
|
||||
- atan((mij0*Sij_minus)/(Rij0*Rij0 + absw*Rij_minus));
|
||||
|
||||
part2 = sig*beta*mpara->nf[f];
|
||||
}
|
||||
|
||||
if (std::abs(Rij0) > GCTL_MAG_TETRA_TOL)
|
||||
{
|
||||
Aij = std::log((long double)(Rij_plus+Sij_plus)) - std::log((long double)(Rij_minus+Sij_minus));
|
||||
}
|
||||
else if (Sij_plus > 0.0 && Sij_minus > 0.0)
|
||||
{
|
||||
Aij = std::log(Sij_plus) - std::log(Sij_minus);
|
||||
}
|
||||
else if (Sij_plus < 0.0 && Sij_minus < 0.0)
|
||||
{
|
||||
Aij = std::log(-1.0*Sij_minus) - std::log(-1.0*Sij_plus);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw gctl::runtime_error("[gctl_potential::magcone_ren17] Observation site on edge.");
|
||||
}
|
||||
|
||||
part1 = Aij * mpara->ne[3*f+j];
|
||||
k1 = k1 - (part1 + part2);
|
||||
}
|
||||
|
||||
// nT -> T 1e-9 / 4*pi*e-7 = 1/(400*pi)*100 = 1/(4*pi) -> A/m
|
||||
out_grad = out_grad - 1.0/(4.0*GCTL_Pi)*k1*mpara->mag_amp[f];
|
||||
}
|
||||
|
||||
out_grad = R*out_grad;
|
||||
out_grad.x *= -1.0;
|
||||
out_grad.y *= -1.0;
|
||||
return out_grad;
|
||||
}
|
||||
|
||||
gctl::tensor gctl::magkernel_single_tensor(const magcone_ren17 &a_ele, const point3ds &a_op, tensor *R_ptr)
|
||||
{
|
||||
double Rij_minus, Rij_plus, Sij_plus, Sij_minus, Rij0, mij0, wi0;
|
||||
double beta, sig, absw;
|
||||
double factor_n_mij, factor_tij;
|
||||
gctl::point3dc oi, grad_Aij;
|
||||
gctl::point3dc grad_Rij_plus, grad_Rij_minus, grad_Sij_plus, grad_Sij_minus;
|
||||
gctl::point3dc grad_mij0, grad_Rij0, grad_abs_wi0;
|
||||
gctl::point3dc grad_a_plus, grad_b_plus, grad_a_minus, grad_b_minus;
|
||||
gctl::point3dc grad_betaij_plus, grad_betaij_minus, grad_betaij;
|
||||
double a_plus, b_plus, a_minus, b_minus;
|
||||
double k3;
|
||||
gctl::tensor tmp_k, k2;
|
||||
|
||||
// get attribute pointer
|
||||
if (a_ele.att == nullptr) throw gctl::runtime_error("[gctl_potential::magcone_ren17] Magnetization parameter not set.");
|
||||
gctl::magcone_para_ren17 *mpara = a_ele.att;
|
||||
|
||||
gctl::tensor R, R_T;
|
||||
if (R_ptr != nullptr) R = *R_ptr;
|
||||
else R = transform_matrix(a_op);
|
||||
R_T = R.transpose();
|
||||
|
||||
// get the observation site in the local coordinates
|
||||
gctl::point3dc site = a_op.s2c();
|
||||
gctl::tensor out_tensor(0.0);
|
||||
for (int f = 0; f < 4; ++f)
|
||||
{
|
||||
k2.set(0.0);
|
||||
k3 = 0.0;
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
Rij_minus = (site - *a_ele.fget(f, j)).module();
|
||||
Rij_plus = (site - *a_ele.fget(f, (j+1)%3)).module();
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
wi0 = gctl::dot(site - *a_ele.fget(f, j), mpara->nf[f]);
|
||||
sig = gctl::sign(wi0);
|
||||
absw = std::abs(wi0);
|
||||
}
|
||||
|
||||
oi = site - wi0*mpara->nf[f];
|
||||
Sij_minus = gctl::dot(*a_ele.fget(f, j) - oi, mpara->te[3*f+j]);
|
||||
Sij_plus = gctl::dot(*a_ele.fget(f, (j+1)%3) - oi, mpara->te[3*f+j]);
|
||||
mij0 = gctl::dot(*a_ele.fget(f, j) - oi, mpara->ne[3*f+j]);
|
||||
Rij0 = std::sqrt(wi0*wi0 + mij0*mij0);
|
||||
|
||||
if (std::abs(Rij0) > GCTL_MAG_TETRA_TOL)
|
||||
{
|
||||
factor_n_mij = -1.0*(Sij_plus/(Rij0*Rij0*Rij_plus) - Sij_minus/(Rij0*Rij0*Rij_minus));
|
||||
factor_tij = -1.0/Rij_plus + 1.0/Rij_minus;
|
||||
grad_Aij = (wi0*factor_n_mij)*mpara->nf[f] + factor_tij*mpara->te[3*f+j]
|
||||
- (mij0*factor_n_mij)*mpara->ne[3*f+j];
|
||||
}
|
||||
else
|
||||
{
|
||||
factor_tij = -1.0/Rij_plus + 1.0/Rij_minus;
|
||||
grad_Aij = factor_tij*mpara->te[3*f+j];
|
||||
}
|
||||
|
||||
//tmp_k = gctl::kron(grad_Aij, ne_[e][3*f+j]);
|
||||
tmp_k = gctl::kron(mpara->ne[3*f+j], grad_Aij);
|
||||
k2 = k2 - tmp_k;
|
||||
|
||||
if (absw > GCTL_MAG_TETRA_TOL)
|
||||
{
|
||||
grad_Rij_plus = (1.0/Rij_plus)*(site - *a_ele.fget(f, (j+1)%3));
|
||||
grad_Rij_minus = (1.0/Rij_minus)*(site - *a_ele.fget(f, j));
|
||||
grad_Sij_plus = -1.0*mpara->te[3*f+j];
|
||||
grad_Sij_minus = -1.0*mpara->te[3*f+j];
|
||||
grad_mij0 = -1.0*mpara->ne[3*f+j];
|
||||
grad_Rij0 = (1.0/Rij0)*(wi0*mpara->nf[f] - mij0*mpara->ne[3*f+j]);
|
||||
grad_abs_wi0 = sig*mpara->nf[f];
|
||||
a_plus = Rij0*Rij0 + absw*Rij_plus;
|
||||
b_plus = mij0*Sij_plus;
|
||||
grad_a_plus = (2.0*Rij0)*grad_Rij0 + Rij_plus*grad_abs_wi0 + absw*grad_Rij_plus;
|
||||
grad_b_plus = Sij_plus*grad_mij0 + mij0*grad_Sij_plus;
|
||||
a_minus = Rij0*Rij0 + absw*Rij_minus;
|
||||
b_minus = mij0*Sij_minus;
|
||||
grad_a_minus = (2.0*Rij0)*grad_Rij0 + Rij_minus*grad_abs_wi0 + absw*grad_Rij_minus;
|
||||
grad_b_minus = Sij_minus*grad_mij0 + mij0*grad_Sij_minus;
|
||||
grad_betaij_plus = (1.0/(a_plus*a_plus + b_plus*b_plus))*(a_plus*grad_b_plus - b_plus*grad_a_plus);
|
||||
grad_betaij_minus = (1.0/(a_minus*a_minus + b_minus*b_minus))*(a_minus*grad_b_minus - b_minus*grad_a_minus);
|
||||
|
||||
grad_betaij = grad_betaij_plus - grad_betaij_minus;
|
||||
|
||||
tmp_k = gctl::kron(grad_betaij, mpara->nf[f]);
|
||||
k2 = k2 - sig*tmp_k;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::abs(mij0) > GCTL_MAG_TETRA_TOL)
|
||||
{
|
||||
k3 += (-1.0/mij0)*(Sij_plus/Rij_plus - Sij_minus/Rij_minus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k3 != 0.0)
|
||||
{
|
||||
tmp_k = gctl::kron(mpara->nf[f], mpara->nf[f]);
|
||||
k2 = k2 - k3*tmp_k;
|
||||
}
|
||||
|
||||
// nT -> T 1e-9 / 4*pi*e-7 = 1/(400*pi)*100 = 1/(4*pi) -> A/m
|
||||
out_tensor = out_tensor - 1.0/(4.0*GCTL_Pi)*k2*mpara->mag_amp[f];
|
||||
}
|
||||
|
||||
out_tensor = R*out_tensor*R_T;
|
||||
out_tensor[0][0] *= -1.0;
|
||||
out_tensor[0][1] *= -1.0;
|
||||
out_tensor[0][2] *= -1.0;
|
||||
out_tensor[1][0] *= -1.0;
|
||||
out_tensor[2][0] *= -1.0;
|
||||
return out_tensor;
|
||||
}
|
||||
|
||||
void gctl::magkernel(matrix<double> &kernel, const array<magcone_ren17> &top_ele,
|
||||
const array<magcone_ren17> &btm_ele, const array<point3ds> &obsp,
|
||||
magnetic_field_type_e comp_type, verbose_type_e verbose)
|
||||
{
|
||||
if (comp_type != Bx && comp_type != By && comp_type != Bz)
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Invalid magnetic componment type. Must be Bx, By or Bz.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (top_ele.size() != btm_ele.size())
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Elements' size don't equal.");
|
||||
return;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
int e_size = top_ele.size();
|
||||
kernel.resize(o_size, e_size);
|
||||
|
||||
array<tensor> Rs(o_size);
|
||||
#pragma omp parallel for private (i) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
Rs[i] = transform_matrix(obsp[i]);
|
||||
}
|
||||
|
||||
point3dc mag_b;
|
||||
gctl::progress_bar bar(o_size*2, "magkernel_componments");
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(i);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(i);
|
||||
|
||||
#pragma omp parallel for private (j, mag_b) shared(i) schedule(guided)
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
mag_b = magkernel_single(top_ele[j], obsp[i], Rs.get(i));
|
||||
if (comp_type == Bx) kernel[i][j] = mag_b.y;
|
||||
if (comp_type == By) kernel[i][j] = mag_b.z;
|
||||
if (comp_type == Bz) kernel[i][j] = mag_b.x;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(i + o_size);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(i + o_size);
|
||||
|
||||
#pragma omp parallel for private (j, mag_b) shared(i) schedule(guided)
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
mag_b = magkernel_single(btm_ele[j], obsp[i], Rs.get(i));
|
||||
if (comp_type == Bx) kernel[i][j] -= mag_b.y;
|
||||
if (comp_type == By) kernel[i][j] -= mag_b.z;
|
||||
if (comp_type == Bz) kernel[i][j] -= mag_b.x;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magkernel(spmat<double> &kernel, const array<magcone_ren17> &top_ele,
|
||||
const array<magcone_ren17> &btm_ele, const array<point3ds> &obsp,
|
||||
double cut_angle, magnetic_field_type_e comp_type, verbose_type_e verbose)
|
||||
{
|
||||
if (comp_type != Bx && comp_type != By && comp_type != Bz)
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Invalid magnetic componment type. Must be Bx, By or Bz.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (top_ele.size() != btm_ele.size())
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Elements' size don't equal.");
|
||||
return;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
int e_size = top_ele.size();
|
||||
|
||||
array<tensor> Rs(o_size);
|
||||
#pragma omp parallel for private (i) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
Rs[i] = transform_matrix(obsp[i]);
|
||||
}
|
||||
|
||||
point3dc cen, mag_b;
|
||||
mat_node<double> tmp_plt;
|
||||
std::map<int, int> tri_idx;
|
||||
std::vector<mat_node<double>> triplts;
|
||||
|
||||
gctl::progress_bar bar2(o_size, "initializing triplts");
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar2.progressed(i);
|
||||
else if (verbose == gctl::ShortMsg) bar2.progressed_simple(i);
|
||||
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
cen = 1.0/3.0*(*top_ele[j].vert[0] + *top_ele[j].vert[1] + *top_ele[j].vert[2]);
|
||||
if (geometry3d::angle(obsp[i].s2c(), cen) < cut_angle*GCTL_Pi/180.0)
|
||||
{
|
||||
tmp_plt.r_id = i;
|
||||
tmp_plt.c_id = j;
|
||||
tmp_plt.val = 1.0;
|
||||
|
||||
tri_idx[j + i*e_size] = triplts.size();
|
||||
triplts.push_back(tmp_plt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gctl::progress_bar bar(o_size*2, "magkernel_componments");
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(i);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(i);
|
||||
|
||||
#pragma omp parallel for private (j, mag_b, cen) shared(i, cut_angle) schedule(guided)
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
cen = 1.0/3.0*(*top_ele[j].vert[0] + *top_ele[j].vert[1] + *top_ele[j].vert[2]);
|
||||
if (geometry3d::angle(obsp[i].s2c(), cen) < cut_angle*GCTL_Pi/180.0)
|
||||
{
|
||||
mag_b = magkernel_single(top_ele[j], obsp[i], Rs.get(i));
|
||||
if (comp_type == Bx) triplts[tri_idx[j + i*e_size]].val = mag_b.y;
|
||||
if (comp_type == By) triplts[tri_idx[j + i*e_size]].val = mag_b.z;
|
||||
if (comp_type == Bz) triplts[tri_idx[j + i*e_size]].val = mag_b.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(i + o_size);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(i + o_size);
|
||||
|
||||
#pragma omp parallel for private (j, mag_b, cen) shared(i, cut_angle) schedule(guided)
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
cen = 1.0/3.0*(*btm_ele[j].vert[0] + *btm_ele[j].vert[1] + *btm_ele[j].vert[2]);
|
||||
if (geometry3d::angle(obsp[i].s2c(), cen) < cut_angle*GCTL_Pi/180.0)
|
||||
{
|
||||
mag_b = magkernel_single(btm_ele[j], obsp[i], Rs.get(i));
|
||||
if (comp_type == Bx) triplts[tri_idx[j + i*e_size]].val -= mag_b.y;
|
||||
if (comp_type == By) triplts[tri_idx[j + i*e_size]].val -= mag_b.z;
|
||||
if (comp_type == Bz) triplts[tri_idx[j + i*e_size]].val -= mag_b.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kernel.malloc(o_size, e_size, 0.0);
|
||||
kernel.set_triplts(triplts);
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<point3dc> &out_obs, const array<magcone_ren17> &top_ele,
|
||||
const array<magcone_ren17> &btm_ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
if (top_ele.size() != btm_ele.size())
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Elements' size don't equal.");
|
||||
return;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
int e_size = top_ele.size();
|
||||
|
||||
out_obs.resize(o_size, point3dc(0.0, 0.0, 0.0));
|
||||
array<tensor> Rs(o_size);
|
||||
#pragma omp parallel for private (i) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
Rs[i] = transform_matrix(obsp[i]);
|
||||
}
|
||||
|
||||
gctl::progress_bar bar(e_size*2, "magobser_componments");
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(j);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(j);
|
||||
|
||||
#pragma omp parallel for private (i) shared (j) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
out_obs[i] = out_obs[i] + sus[j] * magkernel_single(top_ele[j], obsp[i], Rs.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(j + e_size);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(j + e_size);
|
||||
|
||||
#pragma omp parallel for private (i) shared (j) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
out_obs[i] = out_obs[i] - sus[j] * magkernel_single(btm_ele[j], obsp[i], Rs.get(i));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::magobser(array<tensor> &out_obs, const array<magcone_ren17> &top_ele,
|
||||
const array<magcone_ren17> &btm_ele, const array<point3ds> &obsp,
|
||||
const array<double> &sus, verbose_type_e verbose)
|
||||
{
|
||||
if (top_ele.size() != btm_ele.size())
|
||||
{
|
||||
throw std::runtime_error("[gctl_potential::magcone_ren17] Elements' size don't equal.");
|
||||
return;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
int o_size = obsp.size();
|
||||
int e_size = top_ele.size();
|
||||
|
||||
out_obs.resize(o_size, tensor(0.0));
|
||||
array<tensor> Rs(o_size);
|
||||
#pragma omp parallel for private (i) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
Rs[i] = transform_matrix(obsp[i]);
|
||||
}
|
||||
|
||||
gctl::progress_bar bar(e_size*2, "magobser_componments");
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(j);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(j);
|
||||
|
||||
#pragma omp parallel for private (i) shared (j) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
out_obs[i] = out_obs[i] + sus[j] * magkernel_single_tensor(top_ele[j], obsp[i], Rs.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < e_size; j++)
|
||||
{
|
||||
if (verbose == gctl::FullMsg) bar.progressed(j + e_size);
|
||||
else if (verbose == gctl::ShortMsg) bar.progressed_simple(j + e_size);
|
||||
|
||||
#pragma omp parallel for private (i) shared (j) schedule(guided)
|
||||
for (i = 0; i < o_size; i++)
|
||||
{
|
||||
out_obs[i] = out_obs[i] - sus[j] * magkernel_single_tensor(btm_ele[j], obsp[i], Rs.get(i));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
135
lib/potential/mkernel_tricone_Ren2017.h
Normal file
135
lib/potential/mkernel_tricone_Ren2017.h
Normal file
@ -0,0 +1,135 @@
|
||||
/********************************************************
|
||||
* ██████╗ ██████╗████████╗██╗
|
||||
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
||||
* ██║ ███╗██║ ██║ ██║
|
||||
* ██║ ██║██║ ██║ ██║
|
||||
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
||||
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
||||
* 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.
|
||||
******************************************************/
|
||||
|
||||
#ifndef _GCTL_MAG_KERNEL_TRICONE_REN2017_H
|
||||
#define _GCTL_MAG_KERNEL_TRICONE_REN2017_H
|
||||
|
||||
#include "gm_data.h"
|
||||
|
||||
namespace gctl
|
||||
{
|
||||
struct magcone_para_ren17
|
||||
{
|
||||
double mag_amp[4]; // 四面体四个面的磁化强度
|
||||
point3dc nf[4]; // 四面体面外法线矢量
|
||||
point3dc ne[12]; // 四面体边外法线矢量
|
||||
point3dc te[12]; // 四面体边切线矢量
|
||||
};
|
||||
|
||||
typedef type_tricone<magcone_para_ren17> magcone_ren17; ///< 带magcone_para_ren17属性的三角锥结构体
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tricone elements.
|
||||
*
|
||||
* @param in_tet Input and output elements
|
||||
* @param out_para Output parameters
|
||||
* @param mag_B magnetization vecrtors
|
||||
*/
|
||||
void callink_magnetic_para(array<magcone_ren17> &in_cone, array<magcone_para_ren17> &out_para, const array<point3dc> &mag_B);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic parameters of given tricone elements wrt. the spherical coordinates.
|
||||
*
|
||||
* @note The value of magnetic susceptibility is taken as one here. This is usefull for calculating
|
||||
* kernel matrix of the magnetic anomalies.
|
||||
*
|
||||
* @param in_tet Input elements
|
||||
* @param out_para Output parameters
|
||||
* @param inclina_deg inclination angle of the magnetization vector wrt. the local Cartesian coordinates at every tricone elements
|
||||
* @param declina_deg declination angle of the magnetization vector wrt. the local Cartesian coordinates at every tricone elements
|
||||
* @param mag_vec Output magnetization vectors (This is useful for data visualization)
|
||||
* @param field_tense Tense of the Earth's magnetic field
|
||||
*/
|
||||
void callink_magnetic_para_earth_sph(array<magcone_ren17> &in_tet, array<magcone_para_ren17> &out_para,
|
||||
double inclina_deg, double declina_deg, array<point3dc> *mag_vec = nullptr, double field_tense = GCTL_T0);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
point3dc magkernel_single(const magcone_ren17 &a_ele, const point3ds &a_op, tensor *R_ptr = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
tensor magkernel_single_tensor(const magcone_ren17 &a_ele, const point3ds &a_op, tensor *R_ptr = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
void magkernel(matrix<double> &kernel, const array<magcone_ren17> &top_ele, const array<magcone_ren17> &btm_ele,
|
||||
const array<point3ds> &obsp, magnetic_field_type_e comp_type = Bz, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
void magkernel(spmat<double> &kernel, const array<magcone_ren17> &top_ele, const array<magcone_ren17> &btm_ele,
|
||||
const array<point3ds> &obsp, double cut_angle, magnetic_field_type_e comp_type = Bz, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
void magobser(array<point3dc> &out_obs, const array<magcone_ren17> &top_ele, const array<magcone_ren17> &btm_ele,
|
||||
const array<point3ds> &obsp, const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
|
||||
/**
|
||||
* @brief Calculate the magnetic field vector at a given observation point.
|
||||
*
|
||||
* @param a_ele Input element
|
||||
* @param a_op Input observation point
|
||||
* @param R_ptr Output rotation matrix
|
||||
* @return point3dc Magnetic field vector
|
||||
*/
|
||||
void magobser(array<tensor> &out_obs, const array<magcone_ren17> &top_ele, const array<magcone_ren17> &btm_ele,
|
||||
const array<point3ds> &obsp, const array<double> &sus, verbose_type_e verbose = FullMsg);
|
||||
}
|
||||
|
||||
#endif // _GCTL_MAG_KERNEL_TRICONE_REN2017_H
|
Loading…
Reference in New Issue
Block a user