/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * 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 . * * 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 { 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_neigh、e_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 v_neigh; std::vector e_neigh; std::vector 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 { ///< 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_neigh、e_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, 2,3)返回对应的边长的序号(0,1,2,3,4,5) * * @param[in] v1d 第一个顶点序号 * @param[in] v2d 第二个顶点序号 * * @return 两个顶点组成的边的序号 */ int vert2edge_id(int v1d, int v2d); /** * @brief 由面的三个顶点的序号(0, 1, 2,3)返回对应的面的面积的序号(0,1,2,3) * * @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 v_neigh; std::vector e_neigh; std::vector 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 &in_node, const array &in_ele, const array &in_time, const array &in_slow, array &out_node, array &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 &in_node, const array &in_ele, const array &in_time, const array &in_slow, array &out_node, array &out_ele); } #endif // _GCTL_SEISMIC_FMM_DATA_H