gctl_seismic/lib/seismic/fmm_data.h

310 lines
9.5 KiB
C
Raw Normal View History

2024-09-10 20:22:53 +08:00
/********************************************************
*
*
*
*
*
*
* 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_SEISMIC_FMM_DATA_H
#define _GCTL_SEISMIC_FMM_DATA_H
#include "gctl/geometry.h"
#include "algorithm"
namespace gctl
{
/**
* @brief 使
*
* Fast Marching Method (FMM)
*/
struct fmm_vertex2dc;
/**
* @brief 使
*/
struct fmm_triangle2d : public entity<fmm_vertex2dc, 3>
{
bool initialized; ///< whether the element is initialized or not
int tag; ///< 0 = not calculated, 1 = already calculated
double *slow_ptr; ///< pointer of element's slowness
double area; ///< element's area
double edge_len[3]; ///< element's edge length
/**
* Constructor
*/
fmm_triangle2d();
/**
* @brief
*/
void reset();
/**
* @brief
*/
void init();
/**
* @brief
*
*
* v_neighe_neigh和ve_order向量进行赋值
*
* @param index
* @param vec_p0 1
* @param vec_p1 2
* @param vec_p2 3
* @param slow_p
*/
void init(int index, fmm_vertex2dc *vec_p0, fmm_vertex2dc *vec_p1,
fmm_vertex2dc *vec_p2, double *slow_p);
};
struct fmm_vertex2dc : public vertex2dc
{
int tag; ///< 0 = far away from the wave front (WF), 1 = next to the WF, 2 = travel time fixed
int jn_id1, jn_id2, jn_ele; ///< 记录波前面路径的顶点索引值
double jn_grad; ///< 节点相对于元素慢度的梯度
double jn_ksi; ///< 节点更新时的ksi值
double *time_ptr; ///< Pointer of the node's travel time
///< Neighboring vertice of the current vertex
std::vector<fmm_vertex2dc*> v_neigh;
std::vector<fmm_triangle2d*> e_neigh;
std::vector<int> ve_order;
/**
* Constructor
*/
fmm_vertex2dc();
/**
* @brief
*/
void reset();
};
/**
* @brief
*/
struct seis_point2d : public vertex2dc
{
double time; ///< 自由点的走时
/**
* Constructor
*/
seis_point2d();
/**
* @brief Reset the object
*/
void reset();
};
struct seis_point2d_tri : public seis_point2d
{
fmm_triangle2d* host_ele; // 此顶点所在的三角形网格
/**
* Constructor
*/
seis_point2d_tri();
/**
* @brief Resets the object.
*/
void reset();
/**
* @brief
*
* @param in_tris
* @param[in] in_num
*/
void find_host_element(fmm_triangle2d *in_tris, int in_num);
};
/**
* @brief 使
*
* Fast Marching Method (FMM)
*/
struct fmm_vertex3dc;
/**
* @brief 使
*
* Fast Marching Method (FMM)
*
* Assuming the four nodes of the tetrahedron are 0, 1, 2 and 3.
* then the ordering of the tetrahedron's edges and faces are
* defined as:
* edges: [0](0->1) [1](0->2) [2](0->3)
* [3](1->2) [4](1->3) [5](2->3)
* faces: [0](0->1->2) [1](0->1->3)
* [2](0->2->3) [3](1->2->3)
*/
struct fmm_tetrahedron : public entity<fmm_vertex3dc, 4>
{
///< whether the element is initialized or not.
bool initialized;
///< 0 = not calculated, 1 = already calculated
int tag;
///< element's slowness
double *slow_ptr;
///< element's volume
double volume;
///< triangular facets' area of the element
double face_area[4];
///< edge lengths of the element
double edge_len[6];
/**
* Constructor
*/
fmm_tetrahedron();
/**
* @brief Resets the object.
*/
void reset();
/**
* @brief
*/
void init();
/**
* @brief
*
*
* v_neighe_neigh和ve_order向量进行赋值
*
* @param index
* @param vec_p0 1
* @param vec_p1 2
* @param vec_p2 3
* @param vec_p3 4
*/
void init(int index, fmm_vertex3dc *vec_p0, fmm_vertex3dc *vec_p1,
fmm_vertex3dc *vec_p2, fmm_vertex3dc *vec_p3);
/**
* @brief 0 1 23012345
*
* @param[in] v1d
* @param[in] v2d
*
* @return
*/
int vert2edge_id(int v1d, int v2d);
/**
* @brief 0 1 230123
*
* @param[in] v1d
* @param[in] v2d
* @param[in] v3d
*
* @return
*/
int vert2face_id(int v1d, int v2d, int v3d);
};
/**
* @brief FMM计算的顶点
*/
struct fmm_vertex3dc : public vertex3dc
{
int tag; ///< 0 = far away from the wave front (WF), 1 = next to the WF, 2 = travel time fixed
int jn_id1, jn_id2, jn_id3, jn_ele; ///< 记录波前面路径的顶点索引值
double jn_grad; ///< 节点相对于元素慢度的梯度
double jn_ksi, jn_zeta; ///< 节点更新时的ksi值
double *time_ptr; ///< Pointer of the node's travel time
///< neighboring vertice of the current vertex
std::vector<fmm_vertex3dc*> v_neigh;
std::vector<fmm_tetrahedron*> e_neigh;
std::vector<int> ve_order;
/**
* Constructor
*/
fmm_vertex3dc();
/**
* @brief Resets the object.
*/
void reset();
};
/**
* @brief
*/
struct seis_point3d : public vertex3dc
{
double time; //自由点的走时
/**
* Constructor
*/
seis_point3d();
/**
* @brief Resets the object.
*/
void reset();
};
struct seis_point3d_tet : public seis_point3d
{
fmm_tetrahedron *host_ele; ///< 此顶点所在的三角形网格
/**
* Constructor
*/
seis_point3d_tet();
/**
* @brief Resets the object.
*/
void reset();
/**
* @brief
*
* @param in_tris
* @param[in] in_num
*/
void find_host_element(fmm_tetrahedron *in_tris, int in_num);
};
/**
* @brief FMM正演网络
*
* @param[in] in_node
* @param[in] in_ele
* @param[in] in_time
* @param[in] in_slow
* @param out_node FMM顶点集
* @param out_ele
*/
void create_fmm_mesh(const array<vertex2dc> &in_node, const array<triangle2d> &in_ele,
const array<double> &in_time, const array<double> &in_slow, array<fmm_vertex2dc> &out_node,
array<fmm_triangle2d> &out_ele);
/**
* @brief FMM正演网络
*
* @param[in] in_node
* @param[in] in_ele
* @param[in] in_time
* @param[in] in_slow
* @param out_node FMM顶点集
* @param out_ele
*/
void create_fmm_mesh(const array<vertex3dc> &in_node, const array<tetrahedron> &in_ele, const array<double> &in_time,
const array<double> &in_slow, array<fmm_vertex3dc> &out_node, array<fmm_tetrahedron> &out_ele);
}
#endif // _GCTL_SEISMIC_FMM_DATA_H