gctl_seismic/lib/seismic/fmm_kernel.h
2024-09-10 20:22:53 +08:00

191 lines
12 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/********************************************************
* ██████╗ ██████╗████████╗██╗
* ██╔════╝ ██╔════╝╚══██╔══╝██║
* ██║ ███╗██║ ██║ ██║
* ██║ ██║██║ ██║ ██║
* ╚██████╔╝╚██████╗ ██║ ███████╗
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
* 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_KERNEL_H
#define _GCTL_SEISMIC_FMM_KERNEL_H
#include "gctl/core.h"
#include "fmm_data.h"
namespace gctl
{
/**
* @brief 使用二维三角网络的快速进行法计算初至波到时
*
* @param fmm_nodes 二维三角网络顶点数组
* @param fmm_triangles 二维三角形网络元素数组
* @param end_node 用于判定计算是否结束的顶点指针向量
* @param front_node FMM波前面顶点指针的向量的指针
* @param record_node FMM行进顺序的顶点指针的向量的指针
* @param jn 网络顶点走时相对于元素慢度的梯度值的指针。
* 需提前开辟空间大小为fmm_nodes->size()
* @param temp_jn 计算jn_ptr时使用的临时梯度数组指针。
* 需提前开辟空间大小为fmm_triangles->size()
*/
void fmm2d_forward_triangle(array<fmm_vertex2dc> *fmm_nodes,
array<fmm_triangle2d> *fmm_triangles,
std::vector<fmm_vertex2dc*> *front_node,
std::vector<fmm_vertex2dc*> *record_node,
std::vector<fmm_vertex2dc*> *end_node = nullptr,
sparray2d<double> *jn = nullptr,
array<double> *temp_jn = nullptr);
/**
* @brief 计算从一个激发点至一个接收点的初至波走时(体波直达)以及走时相对的模型元素慢度的梯度值
*
* 此函数有5个默认参数
* 1. rece_ele_grad 当梯度数组不为空时,计算接收点走时相对于模型元素慢度的梯度值。
* 2. tmp_jn_ptr 梯度数组指针。若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 3. jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针,若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 4. close_node_ptr FMM计算中保存波前面顶点指针的向量若此指针为空函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 5. record_node_ptr FMM梯度计算中保存行进顺序的顶点指针的向量若此指针为空函数会使用
* 内部变量。在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
*
* @param fmm_nodes 三角网络顶点数组
* @param fmm_triangles 三角形网络元素数组
* @param in_source 源点位置指针,注意必须提前确定源点所在的三角形
* @param in_receiver 接收点位置指针,注意必须提前确定接收点所在的三角形
* @param rece_ele_grad 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针
* 需提前开辟空间大小为fmm_nodes->size()
* @param tmp_jn_ptr 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param close_node_ptr FMM波前面顶点指针的向量的指针
* @param record_node_ptr FMM行进顺序的顶点指针的向量的指针
*/
void source2receiver_direct(array<fmm_vertex2dc> *fmm_nodes,
array<fmm_triangle2d> *fmm_triangles,
seis_point2d_tri *in_source,
seis_point2d_tri *in_receiver,
array<double> *rece_ele_grad = nullptr,
std::vector<fmm_vertex2dc*> *close_node_ptr = nullptr,
std::vector<fmm_vertex2dc*> *record_node_ptr = nullptr,
sparray2d<double> *jn_ptr = nullptr,
array<double> *tmp_jn_ptr = nullptr);
/**
* @brief 计算从一个激发点至一个接收点的初至波走时(反射波)以及走时相对的模型元素慢度的梯度值
*
* 此函数有6个默认参数
* 1. rece_ele_grad 当梯度数组不为空时,计算接收点走时相对于模型元素慢度的梯度值。
* 2. tmp_jn_ptr 梯度数组指针。若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 3. jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针,若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 4. close_node_ptr FMM计算中保存波前面顶点指针的向量若此指针为空函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 5. record_node_ptr FMM梯度计算中保存行进顺序的顶点指针的向量若此指针为空函数会使用
* 内部变量。在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 6. reflect_index 记录反射面所在位置的向量。若此指针为空,函数会使用内部变量。在大规模计
* 算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
*
* @param fmm_nodes 三角网络顶点数组
* @param fmm_triangles 三角形网络元素数组
* @param in_source 源点位置指针,注意必须提前确定源点所在的三角形
* @param in_receiver 接收点位置指针,注意必须提前确定接收点所在的三角形
* @param reflect_node 反射面上的顶点指针向量
* @param rece_ele_grad 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param close_node_ptr FMM波前面顶点指针的向量的指针
* @param record_node_ptr FMM行进顺序的顶点指针的向量的指针
* @param jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针
* 需提前开辟空间大小为fmm_nodes->size()
* @param tmp_jn_ptr 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param reflect_index 反射面上的顶点标识
*/
void source2receiver_reflect(array<fmm_vertex2dc> *fmm_nodes,
array<fmm_triangle2d> *fmm_triangles,
seis_point2d_tri *in_source,
seis_point2d_tri *in_receiver,
std::vector<fmm_vertex2dc*> *reflect_node,
array<double> *rece_ele_grad = nullptr,
std::vector<fmm_vertex2dc*> *close_node_ptr = nullptr,
std::vector<fmm_vertex2dc*> *record_node_ptr = nullptr,
sparray2d<double> *jn_ptr = nullptr,
array<double> *tmp_jn_ptr = nullptr,
array<bool> *reflect_index = nullptr);
/**
* @brief 使用三维四面体网络的快速进行法计算初至波到时
*
* @param fmm_nodes 三维四面体网络顶点数组
* @param fmm_triangles 三维四面体网络元素数组
* @param end_node 用于判定计算是否结束的顶点指针向量
* @param close_node FMM波前面顶点指针的向量的指针
* @param record_node FMM行进顺序的顶点指针的向量的指针
* @param jn 网络顶点走时相对于元素慢度的梯度值的指针。
* 需提前开辟空间大小为fmm_nodes->size()
* @param tmp_jn 计算jn_ptr时使用的临时梯度数组指针。
* 需提前开辟空间大小为fmm_tetrahedrons->size()
*/
void fmm3d_forward_tetrahedron(array<fmm_vertex3dc> *fmm_nodes,
array<fmm_tetrahedron> *fmm_tetrahedrons,
std::vector<fmm_vertex3dc*> *front_node,
std::vector<fmm_vertex3dc*> *record_node,
std::vector<fmm_vertex3dc*> *end_node = nullptr,
sparray2d<double> *jn = nullptr,
array<double> *temp_jn =nullptr);
/**
* @brief 计算从一个激发点至一个接收点的初至波走时(体波直达)以及走时相对的模型元素慢度的梯度值
*
* 此函数有5个默认参数
* 1. rece_ele_grad 当梯度数组不为空时,计算接收点走时相对于模型元素慢度的梯度值。
* 2. tmp_jn_ptr 梯度数组指针。若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 3. jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针,若此指针为空,函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 4. close_node_ptr FMM计算中保存波前面顶点指针的向量若此指针为空函数会使用内部变量。
* 在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
* 5. record_node_ptr FMM梯度计算中保存行进顺序的顶点指针的向量若此指针为空函数会使用
* 内部变量。在大规模计算时最好提供一个外部向量指针,扩大生存域,避免在函数内部反复生成新的向量。
*
* @param fmm_nodes 四面体网络顶点数组
* @param fmm_tetrahedrons 四面体网络元素数组
* @param in_source 源点位置指针,注意必须提前确定源点所在的三角形
* @param in_receiver 接收点位置指针,注意必须提前确定接收点所在的三角形
* @param rece_ele_grad 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param jn_ptr 网络顶点走时相对于元素慢度的梯度值的指针
* 需提前开辟空间大小为fmm_nodes->size()
* @param tmp_jn_ptr 梯度数组指针。需提前开辟空间大小为fmm_triangles->size()
* @param close_node_ptr FMM波前面顶点指针的向量的指针
* @param record_node_ptr FMM行进顺序的顶点指针的向量的指针
*/
void source2receiver_direct(array<fmm_vertex3dc> *fmm_nodes,
array<fmm_tetrahedron> *fmm_tetrahedrons,
seis_point3d_tet *in_source,
seis_point3d_tet *in_receiver,
array<double> *rece_ele_grad = nullptr,
std::vector<fmm_vertex3dc*> *close_node_ptr = nullptr,
std::vector<fmm_vertex3dc*> *record_node_ptr = nullptr,
sparray2d<double> *jn_ptr = nullptr,
array<double> *tmp_jn_ptr = nullptr);
}
#endif //_GCTL_SEISMIC_FMM_KERNEL_H