initial upload

This commit is contained in:
2024-09-10 20:25:18 +08:00
parent b8de03ee4f
commit f1cc876972
377 changed files with 2721267 additions and 34 deletions

47
gm3d/CMakeLists.txt Normal file
View File

@@ -0,0 +1,47 @@
#Uncomment the following two lines to compile the sources as an individual cmake porject. Change the <project_name> as you wanted.
#cmake_minimum_required(VERSION 3.15.2)
#project(<project_name>)
#Set executable name here
#set(name gm3d)
#aux_source_directory(. "${name}_src")
#add_executable(${name} ${${name}_src})
#set_target_properties(${name} PROPERTIES CXX_STANDARD 11)
#set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
#install(TARGETS ${name} RUNTIME DESTINATION sbin)
#Find and link openmp library
#find_package(OpenMP REQUIRED)
#if (OpenMP_CXX_FOUND)
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
#endif()
#target_link_libraries(${name} PUBLIC OpenMP::OpenMP_CXX)
set(TOOL_NAME gm3d)
set(BIN_DIR bin)
set(INSTALL_DIR sbin)
find_package(GCTL REQUIRED)
include_directories(${GCTL_INC_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${BIN_DIR})
aux_source_directory(. TOOL_SRC)
add_executable(${TOOL_NAME} ${TOOL_SRC})
set_target_properties(${TOOL_NAME} PROPERTIES INSTALL_RPATH /usr/local/lib)
set_target_properties(${TOOL_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
target_link_libraries(${TOOL_NAME} PUBLIC ${GCTL_LIB})
install(TARGETS ${TOOL_NAME} RUNTIME DESTINATION ${INSTALL_DIR})

130
gm3d/README.md Normal file
View File

@@ -0,0 +1,130 @@
## 3D forward modeling of gravity and magnetic data under the Cartesian coordinates.
### Introduction
3D model construction and forward modeling of gravity and magnetic data using the Cartesian coordinates. density or magnetic models are built using elements of rectangular blocks. The program can either build 3D models or forward calculating gravity and magnetic data from an input model file. Some typical source types are supported for fast 3D models construction. File format of the 3D model used in this program is the 2.0 .msh file of the [Gmsh](https://gmsh.info) software.
### Files and folders
1. **CMakeLists.txt** CMake project file;
2. **\*.h and \*.cpp** Source files;
3. **README.md** This file;
4. **doc** Example files.
#### Source file lists
```shell
add_interface_block.cpp
add_models.cpp
add_regular_block.cpp
add_sphere_block.cpp
add_tilted_block.cpp
build_regular_grid.cpp
disp_help.cpp
disp_help.h
forward_delta_t.cpp
forward_delta_tx.cpp
forward_delta_ty.cpp
forward_delta_tz.cpp
forward_hax.cpp
forward_hay.cpp
forward_vz.cpp
forward_vzx.cpp
forward_vzy.cpp
forward_vzz.cpp
forward_za.cpp
gm3d.h
head_func.cpp
head_func.h
init_obs.cpp
main.cpp
out_msh_file.cpp
out_neighbor_file.cpp
out_obs.cpp
progress_bar.cpp
progress_bar.h
read_model.cpp
registered_output.cpp
```
### Installation
This program is a toolkit of a [software collection](https://gitee.com/yizhangss/toolkits) that is developed and maintained by Dr. Yi Zhang (zhangyiss@icloud.com) , which could be compiled and installed using the [CMake](https://cmake.org) software. Follow the three step instructions bellow, if you want to compile this program out of the collection.
1. Uncomment the first two lines in the `CMakeLists.txt` file,
```cmake
cmake_minimum_required(VERSION 3.15.2)
project(<project_name>)
```
1. Compile the program as
```shell
mkdir build && cd build && make
```
3. Move or symlink the executable file to any directory included in your $PATH, for instance, `/usr/local/bin`.
### Usage
```bash
Usage: gm3d [-i<input-msh-file>] [-o<output-msh-file>] [-f<output-data-file>] [-d<xs>/<dx>/<xe>/<ys>/<dy>/<ye>/<zs>/<dz>/<ze>] [-m<model-parameters>] [-e<element-data-name>] [-p<observation-file>|<xs>/<dx>/<xe>/<ys>/<dy>/<ye>/<elevation>] [-tVz|Vzx|Vzy|Vzz|DT|DTx|DTy|DTz|Hax|Hay|Za] [-v<I0>/<D0>/<I>/<D>] [-n<noise-mean>/<noise-dev>] [-r] [-h]
```
#### Options
+ __-i__: Filename of the input Gmsh(.msh) model file for forward calculation.
+ __-o__: Filename of the output Gmsh(.msh) model file built with given parameters.
+ __-f__: Filename of the output observation file of gravity or magnetic data.
+ __-d__: 3D dimensions of the model space. the suffix 's' means the starting coordinate and 'e' represents the ending coordinate in axial directions. 'dx', 'dy' and 'dz' are step lengths. The default value is 10/20/990/10/20/990/10/20/490. The axial orientation adopted by the program is a right-hand Cartesian system with the z-axis point vertical downward.
+ __-m__: Model file that contains different types of model parameter. See instructions for formats of different model types.
+ __-e__: Element data name of the input/output Gmsh(.msh) file. Note that the name must be around by "".
+ __-p__: Observation locations. You can either initialize the observation points from parameters or a file. Each line of the file contain coordinates y(easting), x(northing) and z(elevation) of an observation point.
+ __-t__: Forward component Vz, Vzx, Vzy or Vzz for gravitational data and DeltaT, DeltaTx, DeltaTy, DeltaTz, Hax, Hay and Za for magnetic data.
+ __-v__: Inclination and declination of the geomagnetic field and magnetization.
+ __-n__: Add noise to the forward calculated data
+ __-r__: Remove model elements with no data in the output Gmsh(.msh) file.
+ __-h__: Display help information.
#### model parameters
There are four model types currently supported by the program, which are __regular block__, __tilted block__, __sphere__ and __interface__. The program use key words to specify a model's type and associated geometric and physical properties. Therefore, an entrance of model parameters has following parts:
<model_type> <value_type> <physical_property> <geometric_property>
Formats of these key words for different models will be discussed below. Subsequently, the model file are made up by individual entrances of model parameters. Note that any line starts with "#" will be skipped.
##### regular block
The <model_type> for a regular block is simply "regular_block". You can choose either "replace", "add" or "erase" for the block's value type. The "replace" type will replace the physical values of model cells within the block's dimensions. Correspondingly, the "add" and "erase" type will add or erase values of the model cells. The <physical_property> is a float value that represents the density or magnetism within the block's dimension. The <geometric_property> of a regular block has the format of \<xmin>/\<xmax>/\<ymin>/\<ymax>/\<zmin>/\<zmax> which limits the dimensions of the block.
regular_block replace|add|erase float-number \<xmin>/\<xmax>/\<ymin>/\<ymax>/\<zmin>/\<zmax>
##### tilted block
The <model_type> for a tilted block is simply "tilted_block". You can choose either "replace", "add" or "erase" for the block's value type. The "replace" type will replace the physical values of model cells within the block's dimensions. Correspondingly, the "add" and "erase" type will add or erase values of the model cells. The <physical_property> is a float value that represents the density or magnetism within the block's dimension. The <geometric_property> of a tilted block has the format of \<xmin_z>/\<xmax_z>/\\<ymin_z>/\\<ymax_z>/\<zmin>/\<xmin_Z>/\<xmax_Z>/\<ymin_Z>/\<ymax_Z>/\<zmax> which limits the dimensions of the block. The suffix z and Z indicate parameters of the shallow and deep facets of the tilted block.
tilted_block replace|add|erase float-number \<xmin_z>/\<xmax_z>/\<ymin_z>/\<ymax_z>/\<zmin>/\<xmin_Z>/\<xmax_Z>/\<ymin_Z>/\<ymax_Z>/\<zmax>
##### sphere
The <model_type> for a sphere or ellipsoid is simply "sphere". You can choose either "replace", "add" or "erase" for the block's value type. The "replace" type will replace the physical values of model cells within the block's dimensions. Correspondingly, the "add" and "erase" type will add or erase values of the model cells. The <physical_property> is a float value that represents the density or magnetism within the block's dimension. The <geometric_property> of a sphere has the format of \<x_c>/\<y_c>/\<z_c>/\<x_radius>/\<y_radius>/\<z_radius> which limits the dimensions of the sphere. The suffix c represents the center coordinates of the model and radius specify radii of the sphere or ellipsoid in corresponding axises.
sphere replace|add|erase float-number \<x_c>/\<y_c>/\<z_c>/\<x_radius>/\<y_radius>/\<z_radius>
##### interface
The <model_type> for a interface is simply "interface". You can choose either "replace", "add" or "erase" for the block's value type. The "replace" type will replace the physical values of model cells within the block's dimensions. Correspondingly, the "add" and "erase" type will add or erase values of the model cells. The <physical_property> is a float value that represents the density or magnetism within the block's dimension. The <geometric_property> of a interface is a filename of a regular grid that are used to specify the undulation of the interface. A line consist of "# range=\<xmin>/\<dx>/\<xmax>/\<ymin>/\<dy>/\<ymax>" must be given in the file head to provide necessary information about the grid data.
regular_block replace|add|erase float-number grid-filename
#### text file format
##### Input observation locations
Input locations of the observation (see command -p) specify the coordinates of observation point. Each line of the input text file contains the y (easting), x (northing) and z (elevation) positions of a point. Note that any line starts with '#' will be skipped.
##### Output observations
Output files of the observation contain positions and forward calculated data and their uncertainties. Each line of the input text file contains the y (easting), x (northing) and z (elevation) positions of a point and forward calculated data (mGal or nT) and associated uncertainties (mGal and nT).

View File

@@ -0,0 +1,145 @@
#include "gm3d.h"
//我们读入一个界面数据 插值计算每个块体中心位置的值 然后按情况赋值
int GM3D::AddInterfaceBlock(modelist para_list){
int m, n, xnum, ynum;
double xs,xe,xmin,xmax,dx;
double ys,ye,ymin,ymax,dy;
bool model_added = false;
string temp_str;
stringstream temp_ss;
cpoint temp_topo;
cpointArray face_topo;
ifstream infile;
char filename[1024];
if (1 == sscanf(para_list.mod_para,"%s",filename)){
if (open_infile(infile,filename)) return -1;
while (getline(infile,temp_str)){
//#range必须出现在数据之前
if (*(temp_str.begin()) == '#'){
if (6 == sscanf(temp_str.c_str(),"# range=%lf/%lf/%lf/%lf/%lf/%lf",&xs,&dx,&xe,&ys,&dy,&ye)){
xmin = MIN(xs,xe); xmax = MAX(xs,xe);
ymin = MIN(ys,ye); ymax = MAX(ys,ye);
dx = fabs(dx); dy = fabs(dy);
xnum = round((xmax - xmin)/dx) + 1;
ynum = round((ymax - ymin)/dy) + 1;
}
else continue;
}
else{
temp_ss = str2ss(temp_str);
temp_ss >> temp_topo.x >> temp_topo.y >> temp_topo.z;
face_topo.push_back(temp_topo);
}
}
infile.close();
if (!strcmp(para_list.val_type,"replace/top")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z >= temp_topo.z){
model_block_val_[i] = para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"replace/bot")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z <= temp_topo.z){
model_block_val_[i] = para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"add/top")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z >= temp_topo.z){
if (model_block_val_[i] == BDL_MAX)
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
else
model_block_val_[i] += para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"add/bot")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z <= temp_topo.z){
if (model_block_val_[i] == BDL_MAX)
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
else
model_block_val_[i] += para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"erase/top")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z >= temp_topo.z){
model_block_val_[i] = BDL_MAX;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"erase/bot")){
for (int i = 0; i < model_num_; i++){
m = floor((model_cube_[i].cen.x - xmin)/dx);
n = floor((model_cube_[i].cen.y - ymin)/dy);
temp_topo.z = grid_interpolate(xmin+dx*m,ymin+dy*n,dx,dy,model_cube_[i].cen.x,model_cube_[i].cen.y,
face_topo[xnum*n+m].z,face_topo[xnum*n+m+1].z,face_topo[xnum*(n+1)+m].z,face_topo[xnum*(n+1)+m+1].z);
if (model_cube_[i].cen.z <= temp_topo.z){
model_block_val_[i] = BDL_MAX;
model_added = true;
}
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "wrong value type: " << para_list.val_type << " of the model type: " << para_list.mod_type << endl;
return -1;
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "fail to add blocks with the parameter: " << para_list.mod_para << endl;
return -1;
}
if (!model_added){
cerr << BOLDYELLOW << "warning ==> " << RESET << "no block changed with the parameter: " << para_list.mod_para << endl;
return -1;
}
return 0;
}

45
gm3d/add_models.cpp Normal file
View File

@@ -0,0 +1,45 @@
#include "gm3d.h"
int GM3D::AddModels(char* filename){
string temp_str;
stringstream temp_ss;
modelist temp_list;
ifstream infile;
if (open_infile(infile,filename)) return -1;
while(getline(infile,temp_str)){
if (*(temp_str.begin()) == '#') continue;
else{
//按每行5个数据解析 初始化为含观测值与不确定度的观测点
if (4 == sscanf(temp_str.c_str(),"%s %s %lf %s",
temp_list.mod_type,temp_list.val_type,&temp_list.mod_value,temp_list.mod_para)){
model_list_.push_back(temp_list);
}
else{
cerr << BOLDYELLOW << "ignored ==> " << RESET << "wrong input: " << temp_str << endl;
continue;
}
}
}
infile.close();
for (int i = 0; i < model_list_.size(); i++){
if (!strcmp(model_list_[i].mod_type,"regular_block")){
AddRegularBlock(model_list_[i]);
}
else if (!strcmp(model_list_[i].mod_type,"tilted_block")){
AddTiltedBlock(model_list_[i]);
}
else if (!strcmp(model_list_[i].mod_type,"sphere")){
AddSphereBlock(model_list_[i]);
}
else if (!strcmp(model_list_[i].mod_type,"interface")){
AddInterfaceBlock(model_list_[i]);
}
else{
cerr << BOLDYELLOW << "ignored ==> " << RESET << "unknown model type: " << model_list_[i].mod_type << endl;
continue;
}
}
return 0;
}

View File

@@ -0,0 +1,62 @@
#include "gm3d.h"
int GM3D::AddRegularBlock(modelist para_list){
double xs,xe,xmin,xmax;
double ys,ye,ymin,ymax;
double zs,ze,zmin,zmax;
bool model_added = false;
if (6 == sscanf(para_list.mod_para,"%lf/%lf/%lf/%lf/%lf/%lf",&xs,&xe,&ys,&ye,&zs,&ze)){
xmin = MIN(xs,xe); xmax = MAX(xs,xe);
ymin = MIN(ys,ye); ymax = MAX(ys,ye);
zmin = MIN(zs,ze); zmax = MAX(zs,ze);
if (!strcmp(para_list.val_type,"replace")){
for (int i = 0; i < model_num_; i++){
if (model_cube_[i].cen.x >= xmin && model_cube_[i].cen.x <= xmax &&
model_cube_[i].cen.y >= ymin && model_cube_[i].cen.y <= ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"add")){
for (int i = 0; i < model_num_; i++){
if (model_cube_[i].cen.x >= xmin && model_cube_[i].cen.x <= xmax &&
model_cube_[i].cen.y >= ymin && model_cube_[i].cen.y <= ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
if (model_block_val_[i] == BDL_MAX)
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
else
model_block_val_[i] += para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"erase")){
for (int i = 0; i < model_num_; i++){
if (model_cube_[i].cen.x >= xmin && model_cube_[i].cen.x <= xmax &&
model_cube_[i].cen.y >= ymin && model_cube_[i].cen.y <= ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
model_block_val_[i] = BDL_MAX; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "wrong value type: " << para_list.val_type << " of the model type: " << para_list.mod_type << endl;
return -1;
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "fail to add blocks with the parameter: " << para_list.mod_para << endl;
return -1;
}
if (!model_added){
cerr << BOLDYELLOW << "warning ==> " << RESET << "no block changed with the parameter: " << para_list.mod_para << endl;
return -1;
}
return 0;
}

82
gm3d/add_sphere_block.cpp Normal file
View File

@@ -0,0 +1,82 @@
#include "gm3d.h"
int GM3D::AddSphereBlock(modelist para_list){
double xc,yc,zc,rad_x,rad_y,rad_z;
double dist,rad_limit;
double rel_x,rel_y,rel_z,theta,phi;
bool model_added = false;
if (6 == sscanf(para_list.mod_para,"%lf/%lf/%lf/%lf/%lf/%lf",&xc,&yc,&zc,&rad_x,&rad_y,&rad_z)){
if (!strcmp(para_list.val_type,"replace")){
for (int i = 0; i < model_num_; i++){
rel_x = model_cube_[i].cen.x - xc;
rel_y = model_cube_[i].cen.y - yc;
rel_z = model_cube_[i].cen.z - zc;
dist = sqrt(rel_x*rel_x + rel_y*rel_y + rel_z*rel_z);
theta = acos(rel_z/dist);
phi = atan2(rel_y,rel_x);
rad_limit = rad_x*rad_y*rad_z/sqrt(pow(rad_y*rad_z*sin(theta)*cos(phi),2) + pow(rad_x*rad_z*sin(theta)*sin(phi),2) + pow(rad_x*rad_y*cos(theta),2));
if (dist <= rad_limit){
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"add")){
for (int i = 0; i < model_num_; i++){
rel_x = model_cube_[i].cen.x - xc;
rel_y = model_cube_[i].cen.y - yc;
rel_z = model_cube_[i].cen.z - zc;
dist = sqrt(rel_x*rel_x + rel_y*rel_y + rel_z*rel_z);
theta = acos(rel_z/dist);
phi = atan2(rel_y,rel_x);
rad_limit = rad_x*rad_y*rad_z/sqrt(pow(rad_y*rad_z*sin(theta)*cos(phi),2) + pow(rad_x*rad_z*sin(theta)*sin(phi),2) + pow(rad_x*rad_y*cos(theta),2));
if (dist <= rad_limit){
if (model_block_val_[i] == BDL_MAX)
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
else
model_block_val_[i] += para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"erase")){
for (int i = 0; i < model_num_; i++){
rel_x = model_cube_[i].cen.x - xc;
rel_y = model_cube_[i].cen.y - yc;
rel_z = model_cube_[i].cen.z - zc;
dist = sqrt(rel_x*rel_x + rel_y*rel_y + rel_z*rel_z);
theta = acos(rel_z/dist);
phi = atan2(rel_y,rel_x);
rad_limit = rad_x*rad_y*rad_z/sqrt(pow(rad_y*rad_z*sin(theta)*cos(phi),2) + pow(rad_x*rad_z*sin(theta)*sin(phi),2) + pow(rad_x*rad_y*cos(theta),2));
if (dist <= rad_limit){
model_block_val_[i] = BDL_MAX; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "wrong value type: " << para_list.val_type << " of the model type: " << para_list.mod_type << endl;
return -1;
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "fail to add blocks with the parameter: " << para_list.mod_para << endl;
return -1;
}
if (!model_added){
cerr << BOLDYELLOW << "warning ==> " << RESET << "no block changed with the parameter: " << para_list.mod_para << endl;
return -1;
}
return 0;
}

86
gm3d/add_tilted_block.cpp Normal file
View File

@@ -0,0 +1,86 @@
#include "gm3d.h"
int GM3D::AddTiltedBlock(modelist para_list){
double xs_1,xe_1,xmin_1,xmax_1;
double xs_2,xe_2,xmin_2,xmax_2;
double ys_1,ye_1,ymin_1,ymax_1;
double ys_2,ye_2,ymin_2,ymax_2;
double layer_xmin,layer_xmax,layer_ymin,layer_ymax;
double zs,ze,zmin,zmax;
bool model_added = false;
if (10 == sscanf(para_list.mod_para,"%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf",
&xs_1,&xe_1,&ys_1,&ye_1,&zs,&xs_2,&xe_2,&ys_2,&ye_2,&ze)){
xmin_1 = MIN(xs_1,xe_1); xmax_1 = MAX(xs_1,xe_1);
ymin_1 = MIN(ys_1,ye_1); ymax_1 = MAX(ys_1,ye_1);
xmin_2 = MIN(xs_2,xe_2); xmax_2 = MAX(xs_2,xe_2);
ymin_2 = MIN(ys_2,ye_2); ymax_2 = MAX(ys_2,ye_2);
zmin = MIN(zs,ze); zmax = MAX(zs,ze);
if (!strcmp(para_list.val_type,"replace")){
for (int i = 0; i < model_num_; i++){
//计算当前层的x与y范围
layer_xmin = (model_cube_[i].cen.z - zmin)*(xmin_2 - xmin_1)/(zmax - zmin) + xmin_1;
layer_xmax = (model_cube_[i].cen.z - zmin)*(xmax_2 - xmax_1)/(zmax - zmin) + xmax_1;
layer_ymin = (model_cube_[i].cen.z - zmin)*(ymin_2 - ymin_1)/(zmax - zmin) + ymin_1;
layer_ymax = (model_cube_[i].cen.z - zmin)*(ymax_2 - ymax_1)/(zmax - zmin) + ymax_1;
if (model_cube_[i].cen.x >= layer_xmin && model_cube_[i].cen.x <= layer_xmax &&
model_cube_[i].cen.y >= layer_ymin && model_cube_[i].cen.y <= layer_ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"add")){
for (int i = 0; i < model_num_; i++){
//计算当前层的x与y范围
layer_xmin = (model_cube_[i].cen.z - zmin)*(xmin_2 - xmin_1)/(zmax - zmin) + xmin_1;
layer_xmax = (model_cube_[i].cen.z - zmin)*(xmax_2 - xmax_1)/(zmax - zmin) + xmax_1;
layer_ymin = (model_cube_[i].cen.z - zmin)*(ymin_2 - ymin_1)/(zmax - zmin) + ymin_1;
layer_ymax = (model_cube_[i].cen.z - zmin)*(ymax_2 - ymax_1)/(zmax - zmin) + ymax_1;
if (model_cube_[i].cen.x >= layer_xmin && model_cube_[i].cen.x <= layer_xmax &&
model_cube_[i].cen.y >= layer_ymin && model_cube_[i].cen.y <= layer_ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
if (model_block_val_[i] == BDL_MAX)
model_block_val_[i] = para_list.mod_value; //注意重复赋值的块体会覆盖
else
model_block_val_[i] += para_list.mod_value;
model_added = true;
}
}
}
else if (!strcmp(para_list.val_type,"erase")){
for (int i = 0; i < model_num_; i++){
//计算当前层的x与y范围
layer_xmin = (model_cube_[i].cen.z - zmin)*(xmin_2 - xmin_1)/(zmax - zmin) + xmin_1;
layer_xmax = (model_cube_[i].cen.z - zmin)*(xmax_2 - xmax_1)/(zmax - zmin) + xmax_1;
layer_ymin = (model_cube_[i].cen.z - zmin)*(ymin_2 - ymin_1)/(zmax - zmin) + ymin_1;
layer_ymax = (model_cube_[i].cen.z - zmin)*(ymax_2 - ymax_1)/(zmax - zmin) + ymax_1;
if (model_cube_[i].cen.x >= layer_xmin && model_cube_[i].cen.x <= layer_xmax &&
model_cube_[i].cen.y >= layer_ymin && model_cube_[i].cen.y <= layer_ymax &&
model_cube_[i].cen.z >= zmin && model_cube_[i].cen.z <= zmax){
model_block_val_[i] = BDL_MAX; //注意重复赋值的块体会覆盖
model_added = true;
}
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "wrong value type: " << para_list.val_type << " of the model type: " << para_list.mod_type << endl;
return -1;
}
}
else{
cerr << BOLDRED << "error ==> " << RESET << "fail to add blocks with the parameter: " << para_list.mod_para << endl;
return -1;
}
if (!model_added){
cerr << BOLDYELLOW << "warning ==> " << RESET << "no block changed with the parameter: " << para_list.mod_para << endl;
return -1;
}
return 0;
}

View File

@@ -0,0 +1,114 @@
//#ifdef _WINDOWS
//#include <windows.h>
//#else
//#include <sys/ioctl.h>
//#endif
#include "progress_bar.h"
ProgressBar::ProgressBar() {}
ProgressBar::ProgressBar(unsigned long n_, const char* description_, std::ostream& out_){
n = n_;
frequency_update = n_;
description = description_;
out = &out_;
unit_bar = "\u2588";
unit_space = "-";
desc_width = std::strlen(description); // character width of description field
}
void ProgressBar::SetFrequencyUpdate(unsigned long frequency_update_){
if(frequency_update_ > n){
frequency_update = n; // prevents crash if freq_updates_ > n_
}
else{
frequency_update = frequency_update_;
}
}
void ProgressBar::SetStyle(const char* unit_bar_, const char* unit_space_){
unit_bar = unit_bar_;
unit_space = unit_space_;
}
int ProgressBar::GetConsoleWidth(){
int width;
#ifdef _WINDOWS
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
width = csbi.srWindow.Right - csbi.srWindow.Left;
#else
struct winsize win;
//注意当我们使用pipe here-doc等通道获取程序参数时无法正确的获取窗口大小 此时我们将使用预定值
if (ioctl(0, TIOCGWINSZ, &win) != -1)
width = win.ws_col;
else width = 100;
#endif
return width;
}
int ProgressBar::GetBarLength(){
// get console width and according adjust the length of the progress bar
int bar_length = static_cast<int>((GetConsoleWidth() - desc_width - CHARACTER_WIDTH_PERCENTAGE) / 2.);
return bar_length;
}
void ProgressBar::ClearBarField(){
for(int i=0;i<GetConsoleWidth();++i){
*out << " ";
}
*out << "\r" << std::flush;
}
void ProgressBar::Progressed(unsigned long idx_)
{
try{
if(idx_ > n) throw idx_;
// determines whether to update the progress bar from frequency_update
if ((idx_ != n-1) && ((idx_+1) % (n/frequency_update) != 0)) return;
// calculate the size of the progress bar
int bar_size = GetBarLength();
// calculate percentage of progress
double progress_percent = idx_* TOTAL_PERCENTAGE/(n-1);
// calculate the percentage value of a unit bar
double percent_per_unit_bar = TOTAL_PERCENTAGE/bar_size;
// display progress bar
*out << " " << description << " |";
for(int bar_length=0;bar_length<=bar_size-1;++bar_length){
if(bar_length*percent_per_unit_bar<progress_percent){
*out << unit_bar;
}
else{
*out << unit_space;
}
}
if(idx_ == n-1)
*out << "|" << std::setw(CHARACTER_WIDTH_PERCENTAGE + 1) << std::setprecision(1) << std::fixed << progress_percent << "%\r" << std::flush << std::endl;
else *out << "|" << std::setw(CHARACTER_WIDTH_PERCENTAGE + 1) << std::setprecision(1) << std::fixed << progress_percent << "%\r" << std::flush;
}
catch(unsigned long e){
ClearBarField();
std::cerr << "PROGRESS_BAR_EXCEPTION: _idx (" << e << ") went out of bounds, greater than n (" << n << ")." << std::endl << std::flush;
}
}

View File

@@ -0,0 +1,41 @@
#ifndef _PROGRESS_BAR_
#define _PROGRESS_BAR_
#include <sys/ioctl.h>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <thread>
#include <chrono>
#define TOTAL_PERCENTAGE 100.0
#define CHARACTER_WIDTH_PERCENTAGE 4
class ProgressBar
{
public:
ProgressBar();
ProgressBar(unsigned long n_, const char *description_="", std::ostream& out_=std::cerr);
void SetFrequencyUpdate(unsigned long frequency_update_);
void SetStyle(const char* unit_bar_, const char* unit_space_);
void Progressed(unsigned long idx_);
private:
unsigned long n;
unsigned int desc_width;
unsigned long frequency_update;
std::ostream* out;
const char *description;
const char *unit_bar;
const char *unit_space;
void ClearBarField();
int GetConsoleWidth();
int GetBarLength();
};
#endif

View File

@@ -0,0 +1,70 @@
#include "gm3d.h"
int GM3D::BuildRegularGrid(char* space_para){
cpoint temp_cp;
cube temp_cu;
string temp_id_str;
double x,xs,dx,xe,xmin,xmax;
double y,ys,dy,ye,ymin,ymax;
double z,zs,dz,ze,zmin,zmax;
double sign[8][3] = {{-0.5,-0.5,-0.5},{0.5,-0.5,-0.5},{0.5,0.5,-0.5},{-0.5,0.5,-0.5},
{-0.5,-0.5,0.5},{0.5,-0.5,0.5},{0.5,0.5,0.5},{-0.5,0.5,0.5}};
_str2pointMap map_str_point;
_str2pointMap::iterator imsp;
if (9 == sscanf(space_para,"%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf",
&xs,&dx,&xe,&ys,&dy,&ye,&zs,&dz,&ze)){
xmin = MIN(xs,xe); xmax = MAX(xs,xe);
ymin = MIN(ys,ye); ymax = MAX(ys,ye);
zmin = MIN(zs,ze); zmax = MAX(zs,ze);
temp_cu.dx = fabs(dx); temp_cu.dy = fabs(dy); temp_cu.dz = fabs(dz);
y = ys;
while(y >= ymin && y <= ymax){
x = xs;
while(x >= xmin && x <= xmax){
z = zs;
while(z >= zmin && z <= zmax){
//添加denMod
temp_cu.cen.id = model_cube_.size();
temp_cu.cen.x = x; temp_cu.cen.y = y; temp_cu.cen.z = z;
//添加mshVert
for (int i = 0; i < 8; i++){
temp_cp.id = model_vert_.size(); //添加msh的顶点索引为mshVert的大小
temp_cp.x = temp_cu.cen.x - sign[i][0]*temp_cu.dx; //左下底角
temp_cp.y = temp_cu.cen.y - sign[i][1]*temp_cu.dy;
temp_cp.z = temp_cu.cen.z - sign[i][2]*temp_cu.dz;
temp_id_str = cpoint_id(temp_cp);
imsp = map_str_point.find(temp_id_str);
//利用map_vert查到当前顶点是否存在,这里需要注意,如果顶点已经存在则只需要将顶点索引置为已存在顶点的索引,不增加顶点计数
if(imsp!=map_str_point.end()){
temp_cu.ids[i] = imsp->second.id;
}
//若为新的顶点则将其增加到两个映射和一个链表中
else{
temp_cu.ids[i] = temp_cp.id;//新的顶点索引等于顶点集的数量
model_vert_.push_back(temp_cp);//将新产生的顶点保存到顶点链表中
map_str_point[temp_id_str] = temp_cp;//将新产生的顶点保存到顶点位置映射中
}
}
model_cube_.push_back(temp_cu);
z += dz;
}
x += dx;
}
y += dy;
}
}
if (model_cube_.empty()){
cerr << BOLDRED << "error ==> " << RESET << "fail to initial model space with the parameter: " << space_para << endl;
return -1;
}
else{
vert_num_ = model_vert_.size();
model_num_ = model_cube_.size();
model_block_val_.resize(model_num_,BDL_MAX); //初始化模型块体值为BDL_MAX
}
return 0;
}

329
gm3d/disp_help.cpp Normal file
View File

@@ -0,0 +1,329 @@
#include "disp_help.h"
void DispHelp_GM3D::addHeadInfo(string s1,string s2,string s3,string s4)
{
ex_name = s1; version = s2; descript = s3; author = s4;
return;
}
void DispHelp_GM3D::addUsage(string usg)
{
usages.push_back(usg);
return;
}
void DispHelp_GM3D::addOption(string msg,string sflag,string lflag)
{
option_gm3d tmp_option;
tmp_option.message = msg; tmp_option.flag_s = sflag; tmp_option.flag_l = lflag;
options.push_back(tmp_option);
return;
}
void DispHelp_GM3D::addOptionSec(string msg,int index)
{
if (index < 0)
{
options.back().sec_message.push_back(msg);
}
else options[index].sec_message.push_back(msg);
return;
}
void DispHelp_GM3D::addExample(string ex)
{
examples.push_back(ex);
return;
}
void DispHelp_GM3D::changeLayerOut(int left,int right)
{
front_space = left; back_space = right;
return;
}
void DispHelp_GM3D::show()
{
int line_length;
string segment,full_message;
stringstream ss_message;
//获取终端窗口的行列数
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
//显示头信息
full_message = ex_name + " " + version + " - " + descript;
ss_message.clear(); ss_message.str(full_message);
line_length = front_space + back_space;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space + back_space))
{
for (int i = 0; i < front_space; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+9+front_space+back_space);
}
}
clog << endl;
ss_message.clear(); ss_message.str(author);
line_length = front_space + back_space;;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space + back_space))
{
for (int i = 0; i < front_space; i++) clog << " ";
clog << "Author: " << segment << " ";
line_length += (segment.length()+9);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+9+front_space+back_space);
}
}
clog << endl;
if (!usages.empty())
{
for (int i = 0; i < front_space; i++) clog << " ";
clog << "Usage:" << endl;
for (int i = 0; i < usages.size(); i++)
{
ss_message.clear(); ss_message.str(usages[i]);
line_length = front_space + back_space + 4;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+4))
{
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+10+front_space+back_space);
}
}
clog << endl;
}
}
if (!options.empty())
{
for (int i = 0; i < front_space; i++) clog << " ";
clog << "Options:" << endl;
for (int i = 0; i < options.size(); i++)
{
if (options[i].flag_l == "")
{
full_message = options[i].flag_s+" : "+options[i].message;
ss_message.clear(); ss_message.str(full_message);
line_length = front_space + back_space + 4;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+4))
{
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+10+front_space+back_space);
}
}
clog << endl;
if (!options[i].sec_message.empty())
{
for (int j = 0; j < options[i].sec_message.size(); j++)
{
ss_message.clear(); ss_message.str(options[i].sec_message[j]);
line_length = front_space + back_space + 9;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+9))
{
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+13; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+14+front_space+back_space);
}
}
clog << endl;
}
}
}
else
{
full_message = options[i].flag_s+" | "+options[i].flag_l+" : "+options[i].message;
ss_message.clear(); ss_message.str(full_message);
line_length = front_space + back_space + 4;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+4))
{
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+10+front_space+back_space);
}
}
clog << endl;
if (!options[i].sec_message.empty())
{
for (int j = 0; j < options[i].sec_message.size(); j++)
{
ss_message.clear(); ss_message.str(options[i].sec_message[j]);
line_length = front_space + back_space + 9;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+9))
{
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+13; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+14+front_space+back_space);
}
}
clog << endl;
}
}
}
}
}
if (!examples.empty())
{
for (int i = 0; i < front_space; i++) clog << " ";
clog << "Examples:" << endl;
for (int i = 0; i < examples.size(); i++)
{
ss_message.clear(); ss_message.str(examples[i]);
line_length = front_space + back_space + 4;
while(ss_message >> segment)
{
if ((line_length+segment.length()+1) <= w.ws_col)
{
if (line_length == (front_space+back_space+4))
{
for (int i = 0; i < front_space+4; i++) clog << " ";
clog << segment << " ";
line_length += (segment.length()+1);
}
else
{
clog << segment << " ";
line_length += (segment.length()+1);
}
}
else
{
clog << endl;
for (int i = 0; i < front_space+9; i++) clog << " ";
clog << segment << " ";
line_length = (segment.length()+10+front_space+back_space);
}
}
clog << endl;
}
}
return;
}

56
gm3d/disp_help.h Normal file
View File

@@ -0,0 +1,56 @@
#ifndef _DISPHELP_H
#define _DISPHELP_H
#include <iostream>
#include <sstream>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <iomanip>
#include <sys/ioctl.h>
#include "vector"
using namespace std;
typedef vector<string> strArray;
struct option_gm3d
{
string flag_s,flag_l;
string message;
strArray sec_message;
option_gm3d()
{
flag_s = flag_l = message = "";
}
};
typedef vector<option_gm3d> opArray;
class DispHelp_GM3D
{
public:
DispHelp_GM3D(){
front_space = 0;
back_space = 10;
ex_name = "Execuable";
version = "0.0.1";
descript = "Brief information about this command.";
author = "Author's information.";
}
~DispHelp_GM3D(){}
void addHeadInfo(string,string,string,string);
void addUsage(string);
void addOption(string,string,string lflag = "");
void addOptionSec(string,int index = -1);
void addExample(string);
void changeLayerOut(int,int);
void show();
private:
string ex_name,version,descript,author;
int front_space,back_space;
opArray options;
strArray examples;
strArray usages;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
# model_type value_type model_value model_parameter
#regular_block add 1.0 300/700/300/700/100/400
#regular_block erase 0.0 400/600/400/600/200/300
#regular_block add -1.0 600/800/600/800/260/360
#tilted_block add 1.0 500/700/500/700/100/500/700/200/400/400
#tilted_block add -1.0 200/400/200/400/100/200/400/600/800/400
#sphere replace 1.0 500/500/250/300/200/150
interface replace/top 1.0 example_topography.txt
tilted_block replace 1.5 400/600/400/600/50/400/600/200/400/450
interface erase/bot 0.0 example_topography.txt

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@@ -0,0 +1,26 @@
#!/bin/bash
# set model parameters
cat <<- EOF > model_list.txt
regular_block add 0.5 200/800/200/300/50/150
tilted_block add 1.0 300/500/400/600/100/300/500/600/800/350
sphere add 0.8 700/700/250/100/250/100
EOF
# construct model
gm3d -o forward_model.msh -m model_list.txt -d 12.5/25/987.5/12.5/25/987.5/12.5/25/387.5 -e "density_model_(g/cm^3)"
# forward modeling of the model's gravity and gravity gradient data
gm3d -i forward_model.msh -f forward_g.txt -e "density_model_(g/cm^3)" -p 4/8/1020/4/8/1020/50 -t Vz
gm3d -i forward_model.msh -f forward_g_x.txt -e "density_model_(g/cm^3)" -p 4/8/1020/4/8/1020/50 -t Vzx
gm3d -i forward_model.msh -f forward_g_y.txt -e "density_model_(g/cm^3)" -p 4/8/1020/4/8/1020/50 -t Vzy
gm3d -i forward_model.msh -f forward_g_z.txt -e "density_model_(g/cm^3)" -p 4/8/1020/4/8/1020/50 -t Vzz
# mapping
xyz2grd forward_g.txt -Gforward_g.nc -R4/1020/4/1020 -I8/8 -i0,1,3
gmtxy-image -i forward_g.nc -u mGal -a "y (m);x (m)" -t 256,256
xyz2grd forward_g_x.txt -Gforward_g_x.nc -R4/1020/4/1020 -I8/8 -i0,1,3
gmtxy-image -i forward_g_x.nc -u Eo -a "y (m);x (m)" -t 256,256
xyz2grd forward_g_y.txt -Gforward_g_y.nc -R4/1020/4/1020 -I8/8 -i0,1,3
gmtxy-image -i forward_g_y.nc -u Eo -a "y (m);x (m)" -t 256,256
xyz2grd forward_g_z.txt -Gforward_g_z.nc -R4/1020/4/1020 -I8/8 -i0,1,3
gmtxy-image -i forward_g_z.nc -u Eo -a "y (m);x (m)" -t 256,256

View File

@@ -0,0 +1,3 @@
regular_block add 0.5 200/800/200/300/50/150
tilted_block add 1.0 300/500/400/600/100/300/500/600/800/350
sphere add 0.8 700/700/250/100/250/100

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@@ -0,0 +1,37 @@
#!/bin/bash
# set model parameters
cat <<- EOF > model_list.txt
regular_block add 0.1 200/400/250/750/100/200
regular_block add 0.1 600/800/250/750/100/200
EOF
# construct model
gm3d -o forward_model.msh -m model_list.txt -d 12.5/25/987.5/12.5/25/987.5/12.5/25/387.5 -e "magnetic_model_(SI(k))"
# forward modeling of the model's gravity and gravity gradient data
gm3d -i forward_model.msh -f forward_m.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t DT -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Tx.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t DTx -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Ty.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t DTy -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Tz.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t DTz -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Hax.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t Hax -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Hay.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t Hay -v 70/10/70/10
gm3d -i forward_model.msh -f forward_m_Za.txt -e "magnetic_model_(SI(k))" -p -500/10/1500/-500/10/1500/50 -t Za -v 70/10/70/10
# mapping
xyz2grd forward_m.txt -Gforward_m.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m.nc -u nT -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Tx.txt -Gforward_m_Tx.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Tx.nc -u Eo -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Ty.txt -Gforward_m_Ty.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Ty.nc -u Eo -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Tz.txt -Gforward_m_Tz.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Tz.nc -u Eo -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Hax.txt -Gforward_m_Hax.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Hax.nc -u nT -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Hay.txt -Gforward_m_Hay.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Hay.nc -u nT -a "y (m);x (m)" -t 500,500
xyz2grd forward_m_Za.txt -Gforward_m_Za.nc -R-500/1500/-500/1500 -I10/10 -i0,1,3
gmtxy-image -i forward_m_Za.nc -u nT -a "y (m);x (m)" -t 500,500

View File

@@ -0,0 +1,2 @@
regular_block add 0.1 200/400/250/750/100/200
regular_block add 0.1 600/800/250/750/100/200

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More