initial upload

This commit is contained in:
张壹 2024-09-10 20:19:20 +08:00
parent c8b7eeea16
commit aa7f5cc6a3
116 changed files with 589974 additions and 34 deletions

37
.gitignore vendored
View File

@ -1,34 +1,3 @@
# ---> C++ .DS_Store
# Prerequisites build/
*.d .vscode/
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app

187
CMakeLists.txt Normal file
View File

@ -0,0 +1,187 @@
cmake_minimum_required(VERSION 3.15.2)
#
project(GCTL_EXAMPLES VERSION 1.0)
#
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} --std=c++11 -O3")
endif()
#
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
find_package(GCTL)
find_package(GCTL_MESH)
find_package(GCTL_POTENTIAL)
find_package(GCTL_SEISMIC)
find_package(GCTL_ELECMAG)
find_package(GCTL_GRAPHIC)
find_package(GCTL_OPTIMIZATION)
if(GCT_FOUND)
include_directories(${GCTL_INC_DIR})
endif()
if(GCTL_OPENMP)
message(STATUS "GCTL is compiled with OpenMP support.")
find_package(OpenMP REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
if(GCTL_MESH_FOUND)
include_directories(${GCTL_MESH_INC_DIR})
endif()
if(GCTL_POTENTIAL_FOUND)
include_directories(${GCTL_POTENTIAL_INC_DIR})
endif()
if(GCTL_SEISMIC_FOUND)
include_directories(${GCTL_SEISMIC_INC_DIR})
endif()
if(GCTL_ELECMAG_FOUND)
include_directories(${GCTL_ELECMAG_INC_DIR})
endif()
if(GCTL_GRAPHIC_FOUND)
include_directories(${GCTL_GRAPHIC_INC_DIR})
endif()
if(GCTL_OPTIMIZATION_FOUND)
include_directories(${GCTL_OPTIMIZATION_INC_DIR})
endif()
find_package(LibLCG)
if(LibLCG_FOUND)
include_directories(${LibLCG_INC_DIR})
endif()
macro(add_example name switch)
if(${switch})
#
add_executable(${name} examples/${name}.cpp)
#
set_target_properties(${name} PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
target_link_libraries(${name} PUBLIC OpenMP::OpenMP_CXX)
#
if(GCTL_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_LIB})
endif()
if(GCTL_MESH_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_MESH_LIB})
endif()
if(GCTL_POTENTIAL_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_POTENTIAL_LIB})
endif()
if(GCTL_SEISMIC_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_SEISMIC_LIB})
endif()
if(GCTL_ELECMAG_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_ELECMAG_LIB})
endif()
if(GCTL_GRAPHIC_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_GRAPHIC_LIB})
endif()
if(GCTL_OPTIMIZATION_FOUND)
target_link_libraries(${name} PUBLIC ${GCTL_OPTIMIZATION_LIB})
endif()
if(LibLCG_FOUND)
target_link_libraries(${name} PUBLIC ${LibLCG_LIB})
endif()
endif()
endmacro()
add_example(array_ex ON)
add_example(sparray_ex ON)
add_example(sparray2d_ex ON)
add_example(spmat_ex ON)
add_example(spmat_ex2 ON)
add_example(spmat_ex3 ON)
add_example(spmat_ex4 ON)
add_example(spmat_ex5 ON)
add_example(spmat_ex6 ON)
add_example(spmat_ex7 ON)
add_example(sptr_ex ON)
add_example(stream_ex ON)
add_example(stream_template_ex ON)
add_example(vector_ex ON)
add_example(spmat_inversion_ex ON)
add_example(find_index_ex ON)
add_example(difference_1d_ex ON)
add_example(dynamic_stddev_ex ON)
add_example(ellipse_filter_ex ON)
add_example(gaussian_hill_ex ON)
add_example(mat_inverse_ex ON)
add_example(svd_ex ON)
add_example(track_ellipse_ex ON)
add_example(frac_model_ex ON)
add_example(difference_2d_ex ON)
add_example(geometry2d_ex ON)
add_example(point2d_rotate_ex ON)
add_example(point_ex ON)
add_example(tensor_ex ON)
add_example(entity_ex ON)
add_example(cut_2d_tri_mesh_ex ON)
add_example(cut_3d_tri_mesh_ex ON)
add_example(tetra_neighbor_ex ON)
add_example(gobser_tri2d_ex ON)
add_example(gobser_rect2d_ex ON)
add_example(gobser_polygon_ex ON)
add_example(gobser_tricone_ex ON)
add_example(gobser_block_ex ON)
add_example(gobser_tesseroid_ex ON)
add_example(gobser_tetra_sph_ex ON)
add_example(mobser_tesseroid_ex ON)
add_example(rtp_ex ON)
add_example(drtp_ex ON)
add_example(gobser_sphere_ex ON)
add_example(grav_gradient_ex ON)
add_example(mobser_block_ex ON)
add_example(mobser_tetra_ex ON)
add_example(gobser_tri_ex ON)
add_example(gobser_tri_sph_ex ON)
add_example(gobser_tetra_ex ON)
add_example(getoption_ex ON)
add_example(heap_sort_ex ON)
add_example(flags_parser_ex ON)
add_example(progressbar_ex ON)
add_example(basic_io_ex ON)
add_example(gmsh_io_ex ON)
add_example(surfer_io_ex ON)
add_example(triangle_io_ex ON)
add_example(xyz_io_ex ON)
add_example(text_io_ex ON)
add_example(read_netcdf_ex ON)
add_example(save_netcdf_ex ON)
add_example(griding_ex ON)
add_example(mesh_sample1_ex ON)
add_example(mesh_sample4_ex ON)
add_example(mesh_sample6_ex ON)
add_example(mesh_sample7_ex ON)
add_example(mesh_sample8_ex ON)
add_example(mesh_sample9_ex ON)
add_example(mesh_sample10_ex ON)
add_example(mesh_sample2_ex ON)
add_example(mesh_sample3_ex ON)
add_example(mesh_sample5_ex ON)
add_example(wavelet_ex ON)
add_example(traveltime_tri2d_ex ON)
add_example(traveltime_tri2d_ex2 ON)
add_example(traveltime_tri2d_ex3 ON)
add_example(traveltime_tet3d_ex ON)
add_example(traveltime_tet3d_ex2 ON)
add_example(gmt_plot_grid_ex ON)
add_example(parse_string ON)

522
LICENSE Normal file
View File

@ -0,0 +1,522 @@
GCTL License
--------------
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. A copy of the GNU
Lesser General Public License is reproduced below.
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.
=====================================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; 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.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

11
config.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
cmd=${1}
if [[ ${cmd} == "configure" && ! -d "build/" ]]; then
mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
elif [[ ${cmd} == "configure" ]]; then
cd build && rm -rf * && cmake .. -DCMAKE_BUILD_TYPE=Release
elif [[ ${cmd} == "build" ]]; then
cd build && make
fi

24
data/cube/cube.geo Normal file
View File

@ -0,0 +1,24 @@
//+
Point(1) = {40, 40, -20, 5};
//+
Point(2) = {60, 40, -20, 5};
//+
Point(3) = {60, 60, -20, 5};
//+
Point(4) = {40, 60, -20, 5};
//+
Line(1) = {4, 1};
//+
Line(2) = {1, 2};
//+
Line(3) = {2, 3};
//+
Line(4) = {3, 4};
//+
Curve Loop(1) = {1, 2, 3, 4};
//+
Plane Surface(1) = {1};
//+
Extrude {0, 0, -40} {
Surface{1};
}

725
data/cube/cube.msh Normal file
View File

@ -0,0 +1,725 @@
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
216
1 40 40 -20
2 60 40 -20
3 60 60 -20
4 40 60 -20
5 40 60 -60
6 40 40 -60
7 60 40 -60
8 60 60 -60
9 40 55 -20
10 40 50 -20
11 40 45 -20
12 45 40 -20
13 50 40 -20
14 55 40 -20
15 60 45 -20
16 60 50 -20
17 60 55 -20
18 55 60 -20
19 50 60 -20
20 45 60 -20
21 40 55 -60
22 40 50 -60
23 40 45 -60
24 45 40 -60
25 50 40 -60
26 55 40 -60
27 60 45 -60
28 60 50 -60
29 60 55 -60
30 55 60 -60
31 50 60 -60
32 45 60 -60
33 40 60 -25
34 40 60 -30
35 40 60 -35
36 40 60 -40
37 40 60 -45
38 40 60 -50
39 40 60 -55
40 40 40 -25
41 40 40 -30
42 40 40 -35
43 40 40 -40
44 40 40 -45
45 40 40 -50
46 40 40 -55
47 60 40 -25
48 60 40 -30
49 60 40 -35
50 60 40 -40
51 60 40 -45
52 60 40 -50
53 60 40 -55
54 60 60 -25
55 60 60 -30
56 60 60 -35
57 60 60 -40
58 60 60 -45
59 60 60 -50
60 60 60 -55
61 44.33012701892219 52.5 -20
62 52.47881315359561 44.23386022527915 -20
63 55.90776374537427 52.7192820837686 -20
64 47.5198999874148 44.22801311682172 -20
65 49.99999999999999 48.66025403784437 -20
66 44.25171350736355 47.34142019875174 -20
67 49.59311491861806 54.16545355279478 -20
68 55.26848172135622 47.98009581137518 -20
69 46.20627653014991 56.4630216184953 -20
70 52.5 56.89419619426319 -20
71 56.33974596215563 43.66025403784438 -20
72 43.6602540378444 43.6602540378444 -20
73 56.43804438938708 56.50081586651419 -20
74 52.33556481836142 51.7680829920907 -20
75 42.91853012842775 57.0303908070383 -20
76 40 55.66987299394737 -32.50000000471823
77 40 55.66987300554797 -42.5
78 40 44.33012701892219 -37.5
79 40 44.28061564207835 -46.95381401949891
80 40 47.1646564400433 -24.04676791925302
81 40 52.64173424177071 -55.52838173624344
82 40 55.88256244894759 -27.64857958872926
83 40 51.69103170086368 -29.98028879029709
84 40 51.55648142627755 -35.0291993408116
85 40 47.00961894323343 -32.49999995441897
86 40 55.6945272771427 -37.50154334149975
87 40 51.52774062327615 -39.98544079704492
88 40 51.51954163111677 -44.80860071953228
89 40 47.05043578512948 -42.40161663732587
90 40 55.71493013374685 -47.40769188154377
91 40 51.20181102679781 -50.31013430041553
92 40 43.97444316881442 -52.20072988807124
93 40 52.1196001177427 -24.59321271221484
94 40 47.74246748223494 -54.97591875371555
95 40 55.95773343429519 -52.37793612776303
96 40 44.07198146385511 -27.90290659461775
97 40 47.05530885890934 -50.1705338945121
98 40 48.28075255656525 -37.49999999665486
99 40 43.05899356297641 -32.5
100 40 43.05899354713785 -42.5
101 40 48.21201035577964 -27.83535444102185
102 40 56.33974588991858 -56.33974599979055
103 40 43.52928566691691 -56.32866992217807
104 40 56.3397459891188 -23.66025403149145
105 40 43.57256574063302 -23.61422920812387
106 40 48.08334292753518 -46.92602593271548
107 44.33012700605263 40 -32.50000000471823
108 44.33012699445203 40 -42.5
109 55.66987298107781 40 -37.5
110 55.71938435792165 40 -46.95381401949891
111 52.8353435599567 40 -24.04676791925302
112 47.35826575822929 40 -55.52838173624344
113 44.11743755105241 40 -27.64857958872926
114 48.30896829913632 40 -29.98028879029709
115 48.44351857372245 40 -35.0291993408116
116 52.99038105676657 40 -32.49999995441897
117 44.3054727228573 40 -37.50154334149975
118 48.47225937672385 40 -39.98544079704492
119 48.48045836888323 40 -44.80860071953228
120 52.94956421487052 40 -42.40161663732587
121 44.28506986625315 40 -47.40769188154377
122 48.79818897320219 40 -50.31013430041553
123 56.02555683118558 40 -52.20072988807124
124 47.8803998822573 40 -24.59321271221484
125 52.25753251776506 40 -54.97591875371555
126 44.04226656570481 40 -52.37793612776303
127 55.92801853614489 40 -27.90290659461775
128 52.94469114109066 40 -50.1705338945121
129 51.71924744343475 40 -37.49999999665486
130 56.94100643702359 40 -32.5
131 56.94100645286215 40 -42.5
132 51.78798964422036 40 -27.83535444102185
133 43.66025411008142 40 -56.33974599979055
134 56.47071433308309 40 -56.32866992217807
135 43.6602540108812 40 -23.66025403149145
136 56.42743425936698 40 -23.61422920812387
137 51.91665707246482 40 -46.92602593271548
138 60 44.33012699815075 -32.5000000113757
139 60 44.37829129004609 -42.90931182020138
140 60 55.71938435694304 -36.95381400428283
141 60 55.66987301532021 -47.49999995820747
142 60 52.8353435599567 -24.04676791925302
143 60 47.16465644381281 -55.95323209459164
144 60 44.11743755008194 -27.64857961057699
145 60 48.30896831042488 -29.9802887870698
146 60 48.44164342774016 -34.81330442472456
147 60 52.95625840378454 -32.37826512039101
148 60 55.72313767061564 -42.44414598262877
149 60 51.29478995268745 -44.60371484044391
150 60 51.66168758431645 -49.95002364727866
151 60 47.00961894323341 -47.49999999999999
152 60 55.91455461300396 -52.33925909231164
153 60 44.33012699614927 -37.50000003944386
154 60 48.66025402645792 -40
155 60 52.11826364787132 -55.39941370770136
156 60 47.88039988292511 -24.59321271353804
157 60 44.0719814689928 -52.09709342192372
158 60 55.92805014414041 -27.88440185934383
159 60 52.61087942752256 -40
160 60 56.94100643702359 -32.5
161 60 43.05899354713782 -47.5
162 60 48.21015397133992 -52.15065348669999
163 60 51.77945187712652 -27.80171904995707
164 60 56.33974587422675 -56.33974592196372
165 60 43.6602540108812 -23.66025403149145
166 60 56.36520366887994 -23.63479631400501
167 60 43.57256575001217 -56.38577081329036
168 60 47.82745914694526 -43.75578226254463
169 60 51.82742975072789 -36.82230670823676
170 44.46206424749587 60 -32.48789080703315
171 44.33012701892219 60 -42.5
172 55.6199673212738 60 -37.89146707015256
173 55.66987298107781 60 -47.5
174 52.02088862391027 60 -24.95514565917194
175 47.97911138856856 60 -55.04485433888402
176 44.2966062193063 60 -47.44036854247502
177 48.52431380902681 60 -45.01579854858471
178 48.56890279381967 60 -40.14258303064003
179 52.99038105676658 60 -42.50000000000001
180 48.19074011671948 60 -49.82846375730144
181 55.66987298107781 60 -32.5
182 51.57493326491522 60 -34.74517167891557
183 51.82707365273258 60 -30.10345732057259
184 47.18753302798585 60 -24.16408364786284
185 44.22276174709118 60 -37.71218780888231
186 52.81246698787066 60 -55.83591635732334
187 43.95323898121627 60 -27.32379942312101
188 56.07724696086309 60 -52.66898975647958
189 44.03835678540032 60 -52.19999920591307
190 55.95850183821808 60 -27.77495325321397
191 48.64661910259962 60 -32.32408655934266
192 51.5879556047819 60 -47.38956127281753
193 56.9410064370236 60 -42.5
194 56.47467781803796 60 -23.65265408612403
195 43.52449106203885 60 -56.33991178118794
196 56.33974590004345 60 -56.33974600991542
197 43.66025409222772 60 -23.66025398859716
198 47.97979653840487 60 -28.47334348142905
199 52.06925431676402 60 -51.46187696894305
200 51.80899230528527 60 -38.49257909191297
201 48.04214553204288 60 -36.14555599380719
202 44.33012701892219 52.5 -60
203 52.47881315359561 44.23386022527915 -60
204 55.90776374537427 52.7192820837686 -60
205 47.5198999874148 44.22801311682172 -60
206 49.99999999999999 48.66025403784437 -60
207 44.25171350736355 47.34142019875174 -60
208 49.59311491861806 54.16545355279478 -60
209 55.26848172135622 47.98009581137518 -60
210 46.20627653014991 56.4630216184953 -60
211 52.5 56.89419619426319 -60
212 56.33974596215563 43.66025403784438 -60
213 43.6602540378444 43.6602540378444 -60
214 56.43804438938708 56.50081586651419 -60
215 52.33556481836142 51.7680829920907 -60
216 42.91853012842775 57.0303908070383 -60
$EndNodes
$Elements
500
1 15 2 0 1 1
2 15 2 0 2 2
3 15 2 0 3 3
4 15 2 0 4 4
5 15 2 0 5 5
6 15 2 0 6 6
7 15 2 0 10 7
8 15 2 0 14 8
9 1 2 0 1 4 9
10 1 2 0 1 9 10
11 1 2 0 1 10 11
12 1 2 0 1 11 1
13 1 2 0 2 1 12
14 1 2 0 2 12 13
15 1 2 0 2 13 14
16 1 2 0 2 14 2
17 1 2 0 3 2 15
18 1 2 0 3 15 16
19 1 2 0 3 16 17
20 1 2 0 3 17 3
21 1 2 0 4 3 18
22 1 2 0 4 18 19
23 1 2 0 4 19 20
24 1 2 0 4 20 4
25 1 2 0 6 5 21
26 1 2 0 6 21 22
27 1 2 0 6 22 23
28 1 2 0 6 23 6
29 1 2 0 7 6 24
30 1 2 0 7 24 25
31 1 2 0 7 25 26
32 1 2 0 7 26 7
33 1 2 0 8 7 27
34 1 2 0 8 27 28
35 1 2 0 8 28 29
36 1 2 0 8 29 8
37 1 2 0 9 8 30
38 1 2 0 9 30 31
39 1 2 0 9 31 32
40 1 2 0 9 32 5
41 1 2 0 11 4 33
42 1 2 0 11 33 34
43 1 2 0 11 34 35
44 1 2 0 11 35 36
45 1 2 0 11 36 37
46 1 2 0 11 37 38
47 1 2 0 11 38 39
48 1 2 0 11 39 5
49 1 2 0 12 1 40
50 1 2 0 12 40 41
51 1 2 0 12 41 42
52 1 2 0 12 42 43
53 1 2 0 12 43 44
54 1 2 0 12 44 45
55 1 2 0 12 45 46
56 1 2 0 12 46 6
57 1 2 0 16 2 47
58 1 2 0 16 47 48
59 1 2 0 16 48 49
60 1 2 0 16 49 50
61 1 2 0 16 50 51
62 1 2 0 16 51 52
63 1 2 0 16 52 53
64 1 2 0 16 53 7
65 1 2 0 20 3 54
66 1 2 0 20 54 55
67 1 2 0 20 55 56
68 1 2 0 20 56 57
69 1 2 0 20 57 58
70 1 2 0 20 58 59
71 1 2 0 20 59 60
72 1 2 0 20 60 8
73 2 2 0 1 61 65 67
74 2 2 0 1 65 61 66
75 2 2 0 1 65 62 68
76 2 2 0 1 64 65 66
77 2 2 0 1 67 19 69
78 2 2 0 1 65 68 74
79 2 2 0 1 19 67 70
80 2 2 0 1 9 10 61
81 2 2 0 1 13 14 62
82 2 2 0 1 16 17 63
83 2 2 0 1 64 62 65
84 2 2 0 1 12 13 64
85 2 2 0 1 13 62 64
86 2 2 0 1 19 20 69
87 2 2 0 1 63 70 74
88 2 2 0 1 10 11 66
89 2 2 0 1 15 16 68
90 2 2 0 1 61 10 66
91 2 2 0 1 16 63 68
92 2 2 0 1 67 65 74
93 2 2 0 1 61 67 69
94 2 2 0 1 11 1 72
95 2 2 0 1 1 12 72
96 2 2 0 1 14 2 71
97 2 2 0 1 2 15 71
98 2 2 0 1 17 3 73
99 2 2 0 1 3 18 73
100 2 2 0 1 68 63 74
101 2 2 0 1 70 63 73
102 2 2 0 1 9 61 75
103 2 2 0 1 70 67 74
104 2 2 0 1 15 68 71
105 2 2 0 1 66 11 72
106 2 2 0 1 18 19 70
107 2 2 0 1 63 17 73
108 2 2 0 1 62 14 71
109 2 2 0 1 12 64 72
110 2 2 0 1 61 69 75
111 2 2 0 1 20 4 75
112 2 2 0 1 4 9 75
113 2 2 0 1 68 62 71
114 2 2 0 1 64 66 72
115 2 2 0 1 18 70 73
116 2 2 0 1 69 20 75
117 2 2 0 13 91 94 81
118 2 2 0 13 91 97 94
119 2 2 0 13 93 101 83
120 2 2 0 13 82 93 83
121 2 2 0 13 81 95 91
122 2 2 0 13 80 101 93
123 2 2 0 13 96 99 85
124 2 2 0 13 94 97 92
125 2 2 0 13 78 98 85
126 2 2 0 13 89 98 78
127 2 2 0 13 85 99 78
128 2 2 0 13 89 100 79
129 2 2 0 13 78 100 89
130 2 2 0 13 85 101 96
131 2 2 0 13 88 91 90
132 2 2 0 13 88 90 77
133 2 2 0 13 84 87 86
134 2 2 0 13 11 80 10
135 2 2 0 13 21 81 22
136 2 2 0 13 84 86 76
137 2 2 0 13 82 83 76
138 2 2 0 13 83 84 76
139 2 2 0 13 34 76 35
140 2 2 0 13 35 86 36
141 2 2 0 13 76 86 35
142 2 2 0 13 36 77 37
143 2 2 0 13 43 78 42
144 2 2 0 13 45 79 44
145 2 2 0 13 46 92 45
146 2 2 0 13 86 87 77
147 2 2 0 13 87 89 88
148 2 2 0 13 36 86 77
149 2 2 0 13 45 92 79
150 2 2 0 13 87 88 77
151 2 2 0 13 83 85 84
152 2 2 0 13 34 82 76
153 2 2 0 13 33 82 34
154 2 2 0 13 77 90 37
155 2 2 0 13 37 90 38
156 2 2 0 13 79 106 89
157 2 2 0 13 38 95 39
158 2 2 0 13 22 94 23
159 2 2 0 13 10 93 9
160 2 2 0 13 91 95 90
161 2 2 0 13 81 94 22
162 2 2 0 13 80 93 10
163 2 2 0 13 90 95 38
164 2 2 0 13 41 96 40
165 2 2 0 13 85 98 84
166 2 2 0 13 78 99 42
167 2 2 0 13 79 100 44
168 2 2 0 13 43 100 78
169 2 2 0 13 87 98 89
170 2 2 0 13 39 102 5
171 2 2 0 13 6 103 46
172 2 2 0 13 5 102 21
173 2 2 0 13 9 104 4
174 2 2 0 13 23 103 6
175 2 2 0 13 4 104 33
176 2 2 0 13 88 106 91
177 2 2 0 13 40 105 1
178 2 2 0 13 1 105 11
179 2 2 0 13 41 99 96
180 2 2 0 13 91 106 97
181 2 2 0 13 83 101 85
182 2 2 0 13 93 104 9
183 2 2 0 13 95 102 39
184 2 2 0 13 94 103 23
185 2 2 0 13 92 97 79
186 2 2 0 13 42 99 41
187 2 2 0 13 44 100 43
188 2 2 0 13 84 98 87
189 2 2 0 13 11 105 80
190 2 2 0 13 46 103 92
191 2 2 0 13 21 102 81
192 2 2 0 13 33 104 82
193 2 2 0 13 89 106 88
194 2 2 0 13 82 104 93
195 2 2 0 13 92 103 94
196 2 2 0 13 81 102 95
197 2 2 0 13 96 101 80
198 2 2 0 13 80 105 96
199 2 2 0 13 96 105 40
200 2 2 0 13 97 106 79
201 2 2 0 17 122 125 112
202 2 2 0 17 122 128 125
203 2 2 0 17 124 132 114
204 2 2 0 17 113 124 114
205 2 2 0 17 112 126 122
206 2 2 0 17 111 132 124
207 2 2 0 17 127 130 116
208 2 2 0 17 125 128 123
209 2 2 0 17 109 129 116
210 2 2 0 17 120 129 109
211 2 2 0 17 116 130 109
212 2 2 0 17 120 131 110
213 2 2 0 17 109 131 120
214 2 2 0 17 116 132 127
215 2 2 0 17 119 122 121
216 2 2 0 17 119 121 108
217 2 2 0 17 115 118 117
218 2 2 0 17 14 111 13
219 2 2 0 17 24 112 25
220 2 2 0 17 115 117 107
221 2 2 0 17 113 114 107
222 2 2 0 17 114 115 107
223 2 2 0 17 41 107 42
224 2 2 0 17 42 117 43
225 2 2 0 17 107 117 42
226 2 2 0 17 43 108 44
227 2 2 0 17 50 109 49
228 2 2 0 17 52 110 51
229 2 2 0 17 53 123 52
230 2 2 0 17 117 118 108
231 2 2 0 17 118 120 119
232 2 2 0 17 43 117 108
233 2 2 0 17 52 123 110
234 2 2 0 17 118 119 108
235 2 2 0 17 114 116 115
236 2 2 0 17 41 113 107
237 2 2 0 17 40 113 41
238 2 2 0 17 108 121 44
239 2 2 0 17 44 121 45
240 2 2 0 17 110 137 120
241 2 2 0 17 45 126 46
242 2 2 0 17 25 125 26
243 2 2 0 17 13 124 12
244 2 2 0 17 122 126 121
245 2 2 0 17 112 125 25
246 2 2 0 17 111 124 13
247 2 2 0 17 121 126 45
248 2 2 0 17 48 127 47
249 2 2 0 17 116 129 115
250 2 2 0 17 109 130 49
251 2 2 0 17 110 131 51
252 2 2 0 17 50 131 109
253 2 2 0 17 118 129 120
254 2 2 0 17 46 133 6
255 2 2 0 17 7 134 53
256 2 2 0 17 6 133 24
257 2 2 0 17 12 135 1
258 2 2 0 17 26 134 7
259 2 2 0 17 1 135 40
260 2 2 0 17 119 137 122
261 2 2 0 17 47 136 2
262 2 2 0 17 2 136 14
263 2 2 0 17 48 130 127
264 2 2 0 17 122 137 128
265 2 2 0 17 114 132 116
266 2 2 0 17 124 135 12
267 2 2 0 17 126 133 46
268 2 2 0 17 125 134 26
269 2 2 0 17 123 128 110
270 2 2 0 17 49 130 48
271 2 2 0 17 51 131 50
272 2 2 0 17 115 129 118
273 2 2 0 17 14 136 111
274 2 2 0 17 53 134 123
275 2 2 0 17 24 133 112
276 2 2 0 17 40 135 113
277 2 2 0 17 120 137 119
278 2 2 0 17 113 135 124
279 2 2 0 17 123 134 125
280 2 2 0 17 112 133 126
281 2 2 0 17 127 132 111
282 2 2 0 17 111 136 127
283 2 2 0 17 127 136 47
284 2 2 0 17 128 137 110
285 2 2 0 21 155 162 150
286 2 2 0 21 156 163 145
287 2 2 0 21 144 156 145
288 2 2 0 21 152 155 150
289 2 2 0 21 143 162 155
290 2 2 0 21 142 163 156
291 2 2 0 21 157 161 151
292 2 2 0 21 158 160 147
293 2 2 0 21 147 160 140
294 2 2 0 21 154 159 149
295 2 2 0 21 151 161 139
296 2 2 0 21 151 162 157
297 2 2 0 21 147 163 158
298 2 2 0 21 146 153 138
299 2 2 0 21 146 154 153
300 2 2 0 21 17 142 16
301 2 2 0 21 27 143 28
302 2 2 0 21 138 153 49
303 2 2 0 21 150 151 149
304 2 2 0 21 141 150 149
305 2 2 0 21 144 145 138
306 2 2 0 21 145 146 138
307 2 2 0 21 48 138 49
308 2 2 0 21 50 139 51
309 2 2 0 21 57 140 56
310 2 2 0 21 58 148 57
311 2 2 0 21 59 141 58
312 2 2 0 21 141 148 58
313 2 2 0 21 141 149 148
314 2 2 0 21 57 148 140
315 2 2 0 21 145 147 146
316 2 2 0 21 48 144 138
317 2 2 0 21 49 153 50
318 2 2 0 21 47 144 48
319 2 2 0 21 153 154 139
320 2 2 0 21 50 153 139
321 2 2 0 21 141 152 150
322 2 2 0 21 60 152 59
323 2 2 0 21 59 152 141
324 2 2 0 21 140 169 147
325 2 2 0 21 139 168 151
326 2 2 0 21 149 168 154
327 2 2 0 21 28 155 29
328 2 2 0 21 16 156 15
329 2 2 0 21 143 155 28
330 2 2 0 21 142 156 16
331 2 2 0 21 55 158 54
332 2 2 0 21 52 157 53
333 2 2 0 21 140 160 56
334 2 2 0 21 149 159 148
335 2 2 0 21 139 161 51
336 2 2 0 21 8 164 60
337 2 2 0 21 29 164 8
338 2 2 0 21 15 165 2
339 2 2 0 21 2 165 47
340 2 2 0 21 146 169 154
341 2 2 0 21 53 167 7
342 2 2 0 21 54 166 3
343 2 2 0 21 3 166 17
344 2 2 0 21 7 167 27
345 2 2 0 21 55 160 158
346 2 2 0 21 52 161 157
347 2 2 0 21 154 169 159
348 2 2 0 21 150 162 151
349 2 2 0 21 145 163 147
350 2 2 0 21 156 165 15
351 2 2 0 21 155 164 29
352 2 2 0 21 56 160 55
353 2 2 0 21 148 159 140
354 2 2 0 21 51 161 52
355 2 2 0 21 17 166 142
356 2 2 0 21 27 167 143
357 2 2 0 21 60 164 152
358 2 2 0 21 47 165 144
359 2 2 0 21 154 168 139
360 2 2 0 21 147 169 146
361 2 2 0 21 151 168 149
362 2 2 0 21 144 165 156
363 2 2 0 21 152 164 155
364 2 2 0 21 157 162 143
365 2 2 0 21 158 163 142
366 2 2 0 21 143 167 157
367 2 2 0 21 142 166 158
368 2 2 0 21 157 167 53
369 2 2 0 21 158 166 54
370 2 2 0 21 159 169 140
371 2 2 0 25 174 198 183
372 2 2 0 25 175 199 180
373 2 2 0 25 183 190 174
374 2 2 0 25 180 189 175
375 2 2 0 25 184 198 174
376 2 2 0 25 186 199 175
377 2 2 0 25 179 192 173
378 2 2 0 25 179 193 172
379 2 2 0 25 173 193 179
380 2 2 0 25 19 174 18
381 2 2 0 25 31 175 32
382 2 2 0 25 35 185 170
383 2 2 0 25 36 185 35
384 2 2 0 25 176 180 177
385 2 2 0 25 35 170 34
386 2 2 0 25 37 171 36
387 2 2 0 25 38 176 37
388 2 2 0 25 55 181 56
389 2 2 0 25 56 172 57
390 2 2 0 25 58 173 59
391 2 2 0 25 176 177 171
392 2 2 0 25 181 182 172
393 2 2 0 25 177 179 178
394 2 2 0 25 37 176 171
395 2 2 0 25 56 181 172
396 2 2 0 25 177 178 171
397 2 2 0 25 171 185 36
398 2 2 0 25 178 185 171
399 2 2 0 25 181 183 182
400 2 2 0 25 31 186 175
401 2 2 0 25 19 184 174
402 2 2 0 25 30 186 31
403 2 2 0 25 20 184 19
404 2 2 0 25 170 198 187
405 2 2 0 25 173 199 188
406 2 2 0 25 192 199 173
407 2 2 0 25 191 198 170
408 2 2 0 25 172 200 179
409 2 2 0 25 59 188 60
410 2 2 0 25 176 189 180
411 2 2 0 25 39 189 38
412 2 2 0 25 34 187 33
413 2 2 0 25 181 190 183
414 2 2 0 25 54 190 55
415 2 2 0 25 173 188 59
416 2 2 0 25 170 187 34
417 2 2 0 25 38 189 176
418 2 2 0 25 55 190 181
419 2 2 0 25 172 193 57
420 2 2 0 25 58 193 173
421 2 2 0 25 177 192 179
422 2 2 0 25 5 195 39
423 2 2 0 25 3 194 54
424 2 2 0 25 60 196 8
425 2 2 0 25 33 197 4
426 2 2 0 25 18 194 3
427 2 2 0 25 32 195 5
428 2 2 0 25 8 196 30
429 2 2 0 25 4 197 20
430 2 2 0 25 185 201 170
431 2 2 0 25 170 201 191
432 2 2 0 25 39 195 189
433 2 2 0 25 188 196 60
434 2 2 0 25 54 194 190
435 2 2 0 25 187 197 33
436 2 2 0 25 183 191 182
437 2 2 0 25 57 193 58
438 2 2 0 25 180 192 177
439 2 2 0 25 174 194 18
440 2 2 0 25 175 195 32
441 2 2 0 25 30 196 186
442 2 2 0 25 20 197 184
443 2 2 0 25 179 200 178
444 2 2 0 25 182 200 172
445 2 2 0 25 178 201 185
446 2 2 0 25 184 197 187
447 2 2 0 25 190 194 174
448 2 2 0 25 186 196 188
449 2 2 0 25 189 195 175
450 2 2 0 25 182 201 200
451 2 2 0 25 200 201 178
452 2 2 0 25 187 198 184
453 2 2 0 25 188 199 186
454 2 2 0 25 183 198 191
455 2 2 0 25 180 199 192
456 2 2 0 25 191 201 182
457 2 2 0 26 202 206 208
458 2 2 0 26 206 202 207
459 2 2 0 26 206 203 209
460 2 2 0 26 205 206 207
461 2 2 0 26 208 31 210
462 2 2 0 26 206 209 215
463 2 2 0 26 31 208 211
464 2 2 0 26 21 22 202
465 2 2 0 26 25 26 203
466 2 2 0 26 28 29 204
467 2 2 0 26 205 203 206
468 2 2 0 26 24 25 205
469 2 2 0 26 25 203 205
470 2 2 0 26 31 32 210
471 2 2 0 26 204 211 215
472 2 2 0 26 22 23 207
473 2 2 0 26 27 28 209
474 2 2 0 26 202 22 207
475 2 2 0 26 28 204 209
476 2 2 0 26 208 206 215
477 2 2 0 26 202 208 210
478 2 2 0 26 23 6 213
479 2 2 0 26 6 24 213
480 2 2 0 26 26 7 212
481 2 2 0 26 7 27 212
482 2 2 0 26 29 8 214
483 2 2 0 26 8 30 214
484 2 2 0 26 209 204 215
485 2 2 0 26 211 204 214
486 2 2 0 26 21 202 216
487 2 2 0 26 211 208 215
488 2 2 0 26 27 209 212
489 2 2 0 26 207 23 213
490 2 2 0 26 30 31 211
491 2 2 0 26 204 29 214
492 2 2 0 26 203 26 212
493 2 2 0 26 24 205 213
494 2 2 0 26 202 210 216
495 2 2 0 26 32 5 216
496 2 2 0 26 5 21 216
497 2 2 0 26 209 203 212
498 2 2 0 26 205 207 213
499 2 2 0 26 30 211 214
500 2 2 0 26 210 32 216
$EndElements

BIN
data/cube/cube_gravity.nc Normal file

Binary file not shown.

1091
data/cube/cube_sorted.msh Normal file

File diff suppressed because it is too large Load Diff

9666
data/fmm2d/sample_mesh.1.ele Normal file

File diff suppressed because it is too large Load Diff

34002
data/fmm2d/sample_mesh.1.msh Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,572 @@
0 2 1 1
564 1
0 1 4641 1
1 2 4676 1
2 3 2984 1
3 0 2198 1
4 5 480 0
5 704 309 0
6 7 602 0
7 1407 8 0
8 1368 1375 0
9 10 1807 0
10 1889 1811 0
11 12 3358 0
12 13 3142 0
13 14 3118 0
14 3089 15 0
15 2476 3073 0
16 2473 1920 0
17 1912 1710 0
18 1769 1754 0
19 2060 1270 0
20 21 716 0
21 22 545 0
22 405 201 0
23 870 23 0
24 24 458 0
25 511 478 0
26 27 390 0
27 28 274 0
28 219 258 0
29 212 29 0
30 31 134 0
31 71 32 0
32 804 33 0
33 109 34 0
34 35 847 0
35 36 295 0
36 875 37 0
37 954 38 0
38 39 981 0
39 39 980 0
40 1152 1195 0
41 1175 41 0
42 1245 1198 0
43 1242 1219 0
44 1642 45 0
45 46 1640 0
46 1657 47 0
47 1617 48 0
48 1590 1283 0
49 50 1224 0
50 1171 1530 0
51 1529 2310 0
52 1565 2311 0
53 53 3005 1
54 54 3242 1
55 55 2988 1
56 56 89 0
57 57 4140 1
58 58 3059 1
59 59 3810 1
60 60 1989 1
61 61 2162 1
62 62 2257 1
63 63 2730 1
64 64 3419 1
65 65 2314 1
66 67 528 0
67 68 86 0
68 71 68 0
69 75 80 0
70 76 803 0
71 80 32 0
72 85 101 0
73 86 31 0
74 89 76 0
75 101 56 0
76 109 85 0
77 110 131 0
78 111 183 0
79 131 135 0
80 134 111 0
81 135 34 0
82 175 110 0
83 183 30 0
84 222 205 0
85 201 300 0
86 205 30 0
87 212 197 0
88 219 228 0
89 222 197 0
90 228 29 0
91 312 866 0
92 253 451 0
93 258 28 0
94 896 290 0
95 305 27 0
96 274 262 0
97 285 308 0
98 290 36 0
99 294 323 0
100 295 318 0
101 300 342 0
102 305 262 0
103 308 249 0
104 309 313 0
105 312 891 0
106 313 661 0
107 318 294 0
108 323 35 0
109 342 23 0
110 346 978 0
111 885 37 0
112 385 1335 0
113 550 22 0
114 390 385 0
115 742 6 0
116 405 389 0
117 443 461 0
118 444 465 0
119 451 25 0
120 458 253 0
121 460 629 0
122 461 26 0
123 465 38 0
124 478 4 0
125 480 557 0
126 484 516 0
127 495 2919 1
128 511 25 0
129 512 525 0
130 516 618 0
131 518 651 0
132 525 4 0
133 528 512 0
134 545 518 0
135 550 389 0
136 557 67 0
137 597 1078 1
138 1091 346 0
139 602 601 0
140 618 7 0
141 620 994 0
142 628 21 0
143 629 628 0
144 635 3433 1
145 651 460 0
146 659 2843 1
147 661 5 0
148 673 1941 0
149 1012 6 0
150 704 688 0
151 716 673 0
152 734 2567 1
153 742 404 0
154 792 2246 1
155 803 33 0
156 804 75 0
157 829 837 0
158 837 20 0
159 847 175 0
160 860 1983 1
161 866 24 0
162 870 285 0
163 875 876 0
164 876 261 0
165 885 368 0
166 891 249 0
167 896 261 0
168 928 3441 1
169 954 368 0
170 978 404 0
171 980 443 0
172 981 444 0
173 994 484 0
174 2455 9 0
175 1012 688 0
176 1030 2602 1
177 1040 2176 1
178 1051 1062 1
179 1053 1058 1
180 1058 61 1
181 1062 1053 1
182 1063 1066 1
183 1066 1051 1
184 1078 1063 1
185 1080 1086 1
186 1086 1087 1
187 1087 597 1
188 1091 601 0
189 1152 1156 0
190 1155 1189 0
191 1156 41 0
192 1166 1207 0
193 1167 1179 0
194 1171 1166 0
195 1175 1155 0
196 1179 51 0
197 1189 42 0
198 1195 40 0
199 1198 1215 0
200 1207 50 0
201 1215 43 0
202 2651 44 0
203 1223 1236 0
204 1224 1229 0
205 1229 1223 0
206 1236 1569 0
207 1242 43 0
208 1245 42 0
209 1253 3238 1
210 1270 1931 0
211 1283 1284 0
212 1284 1574 0
213 1335 26 0
214 2039 1001 0
215 1375 8 0
216 1394 2045 0
217 1407 620 0
218 1440 1040 1
219 1480 2274 1
220 1500 2643 1
221 1529 2286 0
222 1530 51 0
223 1536 2647 1
224 2326 40 0
225 1569 49 0
226 1574 49 0
227 1588 48 0
228 1590 1588 0
229 1603 1656 0
230 1604 1636 0
231 1611 2338 0
232 1616 2347 0
233 1617 1616 0
234 1636 2348 0
235 2667 1604 0
236 1642 1611 0
237 1648 1650 0
238 1650 46 0
239 1656 47 0
240 1657 1648 0
241 1737 1760 0
242 1710 1733 0
243 1913 17 0
244 1733 1703 0
245 1775 1703 0
246 1844 19 0
247 1760 18 0
248 1762 2448 0
249 1766 1801 0
250 1782 18 0
251 1775 1737 0
252 1782 1769 0
253 1786 2462 0
254 1801 1762 0
255 1807 1766 0
256 1811 1860 0
257 1815 1826 0
258 1826 10 0
259 1830 1754 0
260 1833 2411 1
261 1844 1830 0
262 1852 3685 1
263 1860 1815 0
264 4942 11 0
265 1889 1886 0
266 1906 2468 0
267 1912 17 0
268 1913 1906 0
269 1920 1922 0
270 1922 1731 0
271 1931 829 0
272 1941 20 0
273 1955 2525 1
274 1962 1986 1
275 1963 1987 1
276 1974 860 1
277 1982 2540 1
278 1983 2537 1
279 1986 1974 1
280 1987 1962 1
281 1989 1963 1
282 2027 2036 1
283 2036 55 1
284 2039 1368 0
285 2045 1001 0
286 2060 19 0
287 2073 2114 1
288 2101 2128 1
289 2104 2140 1
290 2107 2104 1
291 2114 2107 1
292 2117 2126 1
293 2126 2073 1
294 2128 2117 1
295 2130 2101 1
296 2136 2264 1
297 2140 2136 1
298 2162 1440 1
299 2166 2172 1
300 2171 2191 1
301 2172 1030 1
302 2174 2171 1
303 2176 2166 1
304 2185 2605 1
305 2191 2197 1
306 2194 2185 1
307 2197 0 1
308 2198 2194 1
309 2225 2254 1
310 2228 3056 1
311 2233 792 1
312 2239 2244 1
313 2244 2228 1
314 2246 2239 1
315 2254 2233 1
316 2257 2258 1
317 2258 2225 1
318 2264 62 1
319 2274 1500 1
320 2286 1167 0
321 2289 2292 1
322 2292 54 1
323 2296 2302 1
324 2302 2312 1
325 2310 52 0
326 2311 52 0
327 2312 65 1
328 2313 2320 1
329 2314 2313 1
330 2320 1536 1
331 2326 1565 0
332 2338 44 0
333 2347 1603 0
334 2348 45 0
335 2398 2434 1
336 2405 2438 1
337 2411 2425 1
338 2424 3806 1
339 2425 2405 1
340 2432 2727 1
341 2434 2432 1
342 2435 2734 1
343 2438 2424 1
344 2448 1786 0
345 2455 1394 0
346 2462 9 0
347 2468 1731 0
348 2473 16 0
349 3081 15 0
350 2493 3240 1
351 2525 2528 1
352 2528 60 1
353 2532 2533 1
354 2533 1955 1
355 2537 1982 1
356 2540 64 1
357 2561 2895 1
358 2562 3445 1
359 2563 2562 1
360 2567 2570 1
361 2570 2027 1
362 2573 2993 1
363 2602 2174 1
364 2605 1480 1
365 2619 2628 1
366 2628 58 1
367 2643 659 1
368 2647 2289 1
369 2651 1219 0
370 2667 1640 0
371 2704 2476 0
372 2719 3378 1
373 2723 63 1
374 2727 1833 1
375 2730 2435 1
376 2734 2398 1
377 2759 3030 1
378 2781 3019 1
379 2843 3306 1
380 2889 2903 1
381 2895 2900 1
382 2900 2889 1
383 2903 3309 1
384 2912 2955 1
385 2916 2933 1
386 2919 2916 1
387 2933 2953 1
388 2938 3614 1
389 2951 2964 1
390 2953 2912 1
391 2955 2960 1
392 2960 2951 1
393 2964 3 1
394 2965 3456 1
395 2973 3457 1
396 2984 2973 1
397 2988 2563 1
398 2993 3323 1
399 3005 2130 1
400 3007 53 1
401 3019 3007 1
402 3021 2781 1
403 3030 3021 1
404 3033 3463 1
405 3035 2759 1
406 3056 2619 1
407 3059 3342 1
408 3073 16 0
409 3081 2704 0
410 3088 3099 0
411 3089 3088 0
412 3098 3110 0
413 3099 14 0
414 3109 3141 0
415 3110 13 0
416 3118 3098 0
417 3490 3350 0
418 3136 3474 0
419 3141 12 0
420 3142 3109 0
421 3174 4743 1
422 3231 3235 1
423 3235 1253 1
424 3238 2719 1
425 3240 3231 1
426 3242 2493 1
427 3253 3259 1
428 3259 2296 1
429 3269 3612 1
430 3271 3610 1
431 3276 3290 1
432 3287 3434 1
433 3290 3287 1
434 3292 3435 1
435 3302 928 1
436 3306 2573 1
437 3308 2561 1
438 3309 495 1
439 3323 734 1
440 3342 1080 1
441 3350 3628 0
442 3358 3136 0
443 3378 2723 1
444 3419 3253 1
445 3433 3271 1
446 3434 635 1
447 3435 3276 1
448 3441 2532 1
449 3445 3308 1
450 3452 4961 1
451 3456 3452 1
452 3457 2965 1
453 3463 3035 1
454 3474 3123 0
455 3490 3123 0
456 3544 4781 1
457 3610 3269 1
458 3612 3302 1
459 3614 3292 1
460 3618 3699 1
461 3628 11 0
462 3658 4064 1
463 3685 3618 1
464 3687 3837 1
465 3688 3689 1
466 3689 3817 1
467 3699 3033 1
468 3805 4170 1
469 3806 59 1
470 3808 4245 1
471 3809 4138 1
472 3810 3809 1
473 3817 1852 1
474 3837 3850 1
475 3850 3688 1
476 3856 3861 1
477 3861 3864 1
478 3864 3687 1
479 3871 3856 1
480 3916 4926 1
481 3966 4751 1
482 4048 4058 1
483 4054 4060 1
484 4058 4054 1
485 4060 3658 1
486 4062 4180 1
487 4063 4072 1
488 4064 4069 1
489 4069 4063 1
490 4072 4172 1
491 4080 4086 1
492 4086 57 1
493 4138 3808 1
494 4140 3871 1
495 4164 4818 1
496 4170 4256 1
497 4172 4062 1
498 4175 4516 1
499 4180 4297 1
500 4243 3805 1
501 4245 4243 1
502 4256 4048 1
503 4280 4672 1
504 4297 4175 1
505 4379 4973 1
506 4396 4422 1
507 4397 4788 1
508 4402 3544 1
509 4414 4776 1
510 4422 4402 1
511 4423 4426 1
512 4426 4396 1
513 4451 4810 1
514 4467 4805 1
515 4505 4881 1
516 4508 4975 1
517 4515 4508 1
518 4516 4675 1
519 4550 4576 1
520 4567 4575 1
521 4575 4747 1
522 4576 4567 1
523 4593 4777 1
524 4623 4625 1
525 4625 4379 1
526 4634 4643 1
527 4638 4649 1
528 4641 4644 1
529 4643 1 1
530 4644 4414 1
531 4649 4634 1
532 4652 4397 1
533 4672 4505 1
534 4675 2 1
535 4676 4515 1
536 4724 4737 1
537 4737 4738 1
538 4738 4550 1
539 4743 4724 1
540 4747 3966 1
541 4750 4855 1
542 4751 4750 1
543 4776 4623 1
544 4777 4638 1
545 4781 4652 1
546 4787 3916 1
547 4788 4787 1
548 4798 4164 1
549 4804 4822 1
550 4805 4451 1
551 4810 4819 1
552 4818 4467 1
553 4819 4804 1
554 4822 3174 1
555 4854 4593 1
556 4855 4854 1
557 4881 4798 1
558 4920 4080 1
559 4926 4920 1
560 4942 1886 0
561 4961 2938 1
562 4973 4423 1
563 4975 4280 1
0
3
0 103 40 1 1
1 62 58 2 2
2 130 73 3 3
# Generated by triangle -pq30a4ADn forward_mesh.poly

24328
data/fmm2d/sample_mesh.2.msh Normal file

File diff suppressed because it is too large Load Diff

117
data/fmm2d/sample_mesh.poly Normal file
View File

@ -0,0 +1,117 @@
# vectice
53 2 1 1
0 0 0 0 1
1 240 0 0 1
2 240 100 0 1
3 0 100 0 1
4 41.9 27.5 1 0
5 56.4 27.1 1 0
6 71.4 27.5 1 0
7 86.8 28.8 1 0
8 101.4 30.1 1 0
9 117.6 32.2 1 0
10 135.6 34.4 1 0
11 155.3 36.1 1 0
12 171.1 39.1 1 0
13 178.9 44.6 1 0
14 179.7 51.9 1 0
15 171.1 54.9 1 0
16 159.2 52.4 1 0
17 143.8 47.6 1 0
18 127.1 42.9 1 0
19 113.4 45.5 1 0
20 103.1 51.5 1 0
21 94.5 48.1 1 0
22 82.5 40.8 1 0
23 68.4 36.1 1 0
24 53 35.2 1 0
25 43.2 33.9 1 0
26 28.6 58.8 2 0
27 36.7 54.9 2 0
28 46.6 53.6 2 0
29 56.9 51.9 2 0
30 68 51.5 2 0
31 77.4 56.6 2 0
32 85.5 60.9 2 0
33 92 66.1 2 0
34 77 67.3 2 0
35 62.4 65.6 2 0
36 52.2 62.6 2 0
37 40.2 63.1 2 0
38 29.9 65.6 2 0
39 22.2 62.6 2 0
40 96.7 82.3 3 0
41 106.5 79.3 3 0
42 115.1 76.3 3 0
43 122.8 69.9 3 0
44 130.9 64.8 3 0
45 141.2 66.9 3 0
46 152.3 70.8 3 0
47 154.9 78.5 3 0
48 143.3 78.5 3 0
49 128.8 79.7 3 0
50 117.2 83.2 3 0
51 106.9 87.9 3 0
52 94.5 89.2 3 0
# segments
53 1
0 0 1 1
1 1 2 1
2 2 3 1
3 3 0 1
4 4 5 0
5 5 6 0
6 6 7 0
7 7 8 0
8 8 9 0
9 9 10 0
10 10 11 0
11 11 12 0
12 12 13 0
13 13 14 0
14 14 15 0
15 15 16 0
16 16 17 0
17 17 18 0
18 18 19 0
19 19 20 0
20 20 21 0
21 21 22 0
22 22 23 0
23 23 24 0
24 24 25 0
25 25 4 0
26 26 27 0
27 27 28 0
28 28 29 0
29 29 30 0
30 30 31 0
31 31 32 0
32 32 33 0
33 33 34 0
34 34 35 0
35 35 36 0
36 36 37 0
37 37 38 0
38 38 39 0
39 39 26 0
40 40 41 0
41 41 42 0
42 42 43 0
43 43 44 0
44 44 45 0
45 45 46 0
46 46 47 0
47 47 48 0
48 48 49 0
49 49 50 0
50 50 51 0
51 51 52 0
52 52 40 0
# holes
0
# attributes
3
0 103 40 1
1 62 58 2
2 130 73 3

9665
data/fmm2d/sample_model.txt Normal file

File diff suppressed because it is too large Load Diff

514
data/fmm3d/cube.1.edge Normal file
View File

@ -0,0 +1,514 @@
512 1
0 281 408 -1
1 232 488 -1
2 277 402 -1
3 280 411 -1
4 84 413 -1
5 85 414 -1
6 10 458 -1
7 3 455 -1
8 23 375 -1
9 8 489 -1
10 18 371 -1
11 9 363 -1
12 21 374 -1
13 91 421 -1
14 17 370 -1
15 383 492 -1
16 20 373 -1
17 11 364 -1
18 16 369 -1
19 14 491 -1
20 19 372 -1
21 13 366 -1
22 15 368 -1
23 332 443 -1
24 22 246 -1
25 25 376 -1
26 24 248 -1
27 27 377 -1
28 26 250 -1
29 269 501 -1
30 28 252 -1
31 29 253 -1
32 30 254 -1
33 31 255 -1
34 32 256 -1
35 33 257 -1
36 34 258 -1
37 36 259 -1
38 35 116 -1
39 38 260 -1
40 37 118 -1
41 40 261 -1
42 39 120 -1
43 264 390 -1
44 41 122 -1
45 42 123 -1
46 43 124 -1
47 44 125 -1
48 45 126 -1
49 46 127 -1
50 47 128 -1
51 49 129 -1
52 48 61 -1
53 51 130 -1
54 50 63 -1
55 53 131 -1
56 52 65 -1
57 401 481 -1
58 54 67 -1
59 55 68 -1
60 56 69 -1
61 57 70 -1
62 58 71 -1
63 59 72 -1
64 60 73 -1
65 62 74 -1
66 61 2 -1
67 64 75 -1
68 63 0 -1
69 66 76 -1
70 65 6 -1
71 1 392 -1
72 67 4 -1
73 68 5 -1
74 69 0 -1
75 70 6 -1
76 71 7 -1
77 72 8 -1
78 73 1 -1
79 74 3 -1
80 75 5 -1
81 76 7 -1
82 394 477 -1
83 134 396 -1
84 283 404 -1
85 276 469 -1
86 353 436 -1
87 144 313 -1
88 86 415 -1
89 87 416 -1
90 286 417 -1
91 89 420 -1
92 150 319 -1
93 90 287 -1
94 93 422 -1
95 92 289 -1
96 95 423 -1
97 94 291 -1
98 307 424 -1
99 96 293 -1
100 97 294 -1
101 98 295 -1
102 99 296 -1
103 100 297 -1
104 101 298 -1
105 102 299 -1
106 104 300 -1
107 103 165 -1
108 106 301 -1
109 105 167 -1
110 108 302 -1
111 107 169 -1
112 7 303 -1
113 109 171 -1
114 110 172 -1
115 111 173 -1
116 112 174 -1
117 113 175 -1
118 114 176 -1
119 115 177 -1
120 117 178 -1
121 116 48 -1
122 119 179 -1
123 118 50 -1
124 121 180 -1
125 120 52 -1
126 142 435 -1
127 122 54 -1
128 123 55 -1
129 124 56 -1
130 125 57 -1
131 126 58 -1
132 127 59 -1
133 128 60 -1
134 129 62 -1
135 130 64 -1
136 131 66 -1
137 275 399 -1
138 348 466 -1
139 279 506 -1
140 397 479 -1
141 382 494 -1
142 398 504 -1
143 137 393 -1
144 262 388 -1
145 181 308 -1
146 143 312 -1
147 183 431 -1
148 145 314 -1
149 146 315 -1
150 147 316 -1
151 148 317 -1
152 149 318 -1
153 192 220 -1
154 151 320 -1
155 153 321 -1
156 152 196 -1
157 155 322 -1
158 154 198 -1
159 157 323 -1
160 156 200 -1
161 233 324 -1
162 158 202 -1
163 159 203 -1
164 160 204 -1
165 161 205 -1
166 162 206 -1
167 163 207 -1
168 164 208 -1
169 166 209 -1
170 165 35 -1
171 168 210 -1
172 167 37 -1
173 170 211 -1
174 169 39 -1
175 185 212 -1
176 171 41 -1
177 172 42 -1
178 173 43 -1
179 174 44 -1
180 175 45 -1
181 176 46 -1
182 177 47 -1
183 178 49 -1
184 179 51 -1
185 180 53 -1
186 140 309 -1
187 306 426 -1
188 305 428 -1
189 311 432 -1
190 186 213 -1
191 187 214 -1
192 188 215 -1
193 189 216 -1
194 190 217 -1
195 191 218 -1
196 0 219 -1
197 193 221 -1
198 194 222 -1
199 195 223 -1
200 197 224 -1
201 196 22 -1
202 199 225 -1
203 198 24 -1
204 201 226 -1
205 200 26 -1
206 236 459 -1
207 202 28 -1
208 203 29 -1
209 204 30 -1
210 205 31 -1
211 206 32 -1
212 207 33 -1
213 208 34 -1
214 209 36 -1
215 210 38 -1
216 211 40 -1
217 212 143 -1
218 213 83 -1
219 214 15 -1
220 215 16 -1
221 216 17 -1
222 217 18 -1
223 218 19 -1
224 219 192 -1
225 220 149 -1
226 221 88 -1
227 222 20 -1
228 223 21 -1
229 224 23 -1
230 225 25 -1
231 226 27 -1
232 330 456 -1
233 358 474 -1
234 327 447 -1
235 326 449 -1
236 325 451 -1
237 12 490 -1
238 328 453 -1
239 235 334 -1
240 238 460 -1
241 237 336 -1
242 351 461 -1
243 239 338 -1
244 240 339 -1
245 241 340 -1
246 242 341 -1
247 243 342 -1
248 244 343 -1
249 245 344 -1
250 247 345 -1
251 246 103 -1
252 249 346 -1
253 248 105 -1
254 251 347 -1
255 250 107 -1
256 273 468 -1
257 252 109 -1
258 253 110 -1
259 254 111 -1
260 255 112 -1
261 256 113 -1
262 257 114 -1
263 258 115 -1
264 259 117 -1
265 260 119 -1
266 261 121 -1
267 139 389 -1
268 5 387 -1
269 138 391 -1
270 263 386 -1
271 265 385 -1
272 266 384 -1
273 381 496 -1
274 380 498 -1
275 395 502 -1
276 270 379 -1
277 349 464 -1
278 337 439 -1
279 367 470 -1
280 79 400 -1
281 284 354 -1
282 77 403 -1
283 81 407 -1
284 83 412 -1
285 82 507 -1
286 278 406 -1
287 282 405 -1
288 288 355 -1
289 88 419 -1
290 285 418 -1
291 287 152 -1
292 290 356 -1
293 289 154 -1
294 292 357 -1
295 291 156 -1
296 136 476 -1
297 293 158 -1
298 294 159 -1
299 295 160 -1
300 296 161 -1
301 297 162 -1
302 298 163 -1
303 299 164 -1
304 300 166 -1
305 301 168 -1
306 302 170 -1
307 303 185 -1
308 184 430 -1
309 304 429 -1
310 182 427 -1
311 6 425 -1
312 308 13 -1
313 309 181 -1
314 141 434 -1
315 310 433 -1
316 312 186 -1
317 313 187 -1
318 314 188 -1
319 315 189 -1
320 316 190 -1
321 317 191 -1
322 318 193 -1
323 319 194 -1
324 320 195 -1
325 321 197 -1
326 322 199 -1
327 323 201 -1
328 324 90 -1
329 231 452 -1
330 230 450 -1
331 2 448 -1
332 229 454 -1
333 4 446 -1
334 227 457 -1
335 329 445 -1
336 331 444 -1
337 234 442 -1
338 334 92 -1
339 333 441 -1
340 336 94 -1
341 335 440 -1
342 338 96 -1
343 339 97 -1
344 340 98 -1
345 341 99 -1
346 342 100 -1
347 343 101 -1
348 344 102 -1
349 345 104 -1
350 346 106 -1
351 347 108 -1
352 4 467 -1
353 272 465 -1
354 132 463 -1
355 350 462 -1
356 274 438 -1
357 352 437 -1
358 354 148 -1
359 355 153 -1
360 356 155 -1
361 357 157 -1
362 228 475 -1
363 1 473 -1
364 3 487 -1
365 360 486 -1
366 361 485 -1
367 363 233 -1
368 364 235 -1
369 359 472 -1
370 366 237 -1
371 365 471 -1
372 368 239 -1
373 369 240 -1
374 370 241 -1
375 371 242 -1
376 372 243 -1
377 373 244 -1
378 374 245 -1
379 375 247 -1
380 376 249 -1
381 377 251 -1
382 271 500 -1
383 379 11 -1
384 378 499 -1
385 268 497 -1
386 2 495 -1
387 267 493 -1
388 384 9 -1
389 385 138 -1
390 386 139 -1
391 387 263 -1
392 388 81 -1
393 389 262 -1
394 390 77 -1
395 391 264 -1
396 392 265 -1
397 393 266 -1
398 133 478 -1
399 135 503 -1
400 396 270 -1
401 78 480 -1
402 80 505 -1
403 399 134 -1
404 400 275 -1
405 409 482 -1
406 402 137 -1
407 403 277 -1
408 404 147 -1
409 405 146 -1
410 406 140 -1
411 407 278 -1
412 408 145 -1
413 410 483 -1
414 362 484 -1
415 411 144 -1
416 412 280 -1
417 413 281 -1
418 414 282 -1
419 415 283 -1
420 416 284 -1
421 417 151 -1
422 418 150 -1
423 419 285 -1
424 420 286 -1
425 421 288 -1
426 422 290 -1
427 423 292 -1
428 424 182 -1
429 425 307 -1
430 426 141 -1
431 427 306 -1
432 428 82 -1
433 429 14 -1
434 430 304 -1
435 431 305 -1
436 432 184 -1
437 433 183 -1
438 434 310 -1
439 435 311 -1
440 436 135 -1
441 437 132 -1
442 438 352 -1
443 439 95 -1
444 440 93 -1
445 441 91 -1
446 442 333 -1
447 443 234 -1
448 444 227 -1
449 445 229 -1
450 446 329 -1
451 447 230 -1
452 448 327 -1
453 449 86 -1
454 450 326 -1
455 451 87 -1
456 452 325 -1
457 453 85 -1
458 454 328 -1
459 455 331 -1
460 456 79 -1
461 457 330 -1
462 458 332 -1
463 459 335 -1
464 460 337 -1
465 461 12 -1
466 462 273 -1
467 463 350 -1
468 464 133 -1
469 465 349 -1
470 466 272 -1
471 467 348 -1
472 468 351 -1
473 469 353 -1
474 470 238 -1
475 471 236 -1
476 472 228 -1
477 473 359 -1
478 474 84 -1
479 475 358 -1
480 476 394 -1
481 477 267 -1
482 478 397 -1
483 479 271 -1
484 480 401 -1
485 481 276 -1
486 482 142 -1
487 483 279 -1
488 484 232 -1
489 485 89 -1
490 486 231 -1
491 487 360 -1
492 488 361 -1
493 489 362 -1
494 490 365 -1
495 491 367 -1
496 492 78 -1
497 493 383 -1
498 494 268 -1
499 495 382 -1
500 496 136 -1
501 497 381 -1
502 498 10 -1
503 499 80 -1
504 500 378 -1
505 501 380 -1
506 502 269 -1
507 503 395 -1
508 504 274 -1
509 505 398 -1
510 506 409 -1
511 507 410 -1
# Generated by tetgen -pa4000 cube.poly

124671
data/fmm3d/cube.1.ele Normal file

File diff suppressed because it is too large Load Diff

15576
data/fmm3d/cube.1.face Normal file

File diff suppressed because it is too large Load Diff

295307
data/fmm3d/cube.1.msh Normal file

File diff suppressed because it is too large Load Diff

23512
data/fmm3d/cube.1.node Normal file

File diff suppressed because it is too large Load Diff

23
data/fmm3d/cube.poly Normal file
View File

@ -0,0 +1,23 @@
8 3 0 1
0 0 0 0 1
1 1000 0 0 1
2 1000 500 0 1
3 0 500 0 1
4 0 0 500 1
5 1000 0 500 1
6 1000 500 500 1
7 0 500 500 1
6 1
1
4 0 1 2 3 1
1
4 4 5 6 7 1
1
4 0 1 5 4 1
1
4 1 2 6 5 1
1
4 2 3 7 6 1
1
4 3 0 4 7 1
0

3
data/fmm3d/get_mesh.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
tetgen -pa4000 cube.poly

12
data/option_sample.txt Normal file
View File

@ -0,0 +1,12 @@
# this is an annotation
range = 100/1000/200/2000/full_range
interval = 10/10
weight = 120.12
model-file = test.txt
# you can insert empty lines too
model-tag = model1
model-tag = model2
model-tag = model3
out-model = example.msh

BIN
data/out/array_ex_out.mat Normal file

Binary file not shown.

129
data/out/difference_1d.txt Normal file
View File

@ -0,0 +1,129 @@
# ori o1 o2 o3 o4
0.198669 0.217042 -0.0103312 -0.0109239 0.000616416
0.406085 0.19779 -0.0192517 -0.0101277 0.00113673
0.59425 0.174078 -0.0281722 -0.0082527 0.00133559
0.754242 0.142114 -0.0357571 -0.00673732 0.00169517
0.878477 0.103412 -0.0416468 -0.00490254 0.00197439
0.961065 0.0598071 -0.0455622 -0.00283534 0.00216001
0.998091 0.0133673 -0.0473175 -0.000633718 0.00224323
0.9878 -0.0337062 -0.0468296 0.00159794 0.0022201
0.930679 -0.0791818 -0.0441216 0.00375385 0.00209172
0.829436 -0.120904 -0.0393219 0.00573179 0.00186417
0.688871 -0.156894 -0.032658 0.007438 0.00154825
0.515649 -0.185445 -0.0244459 0.0087916 0.00115893
0.317981 -0.205206 -0.0150748 0.00972839 0.000714667
0.105237 -0.215238 -0.00498909 0.010204 0.000236523
-0.112495 -0.215066 0.00533316 0.0101958 -0.000252834
-0.324894 -0.204698 0.0154026 0.00970431 -0.000730205
-0.521891 -0.184626 0.0247418 0.00875273 -0.00117296
-0.694145 -0.155801 0.032908 0.0073862 -0.0015601
-0.833492 -0.11959 0.0395142 0.0056695 -0.00187329
-0.933325 -0.077709 0.044247 0.00368403 -0.00209766
-0.98891 -0.0321444 0.0468822 0.0015239 -0.00222259
-0.997614 0.0149441 0.0472948 -0.000708472 -0.00224215
-0.959022 0.0613242 0.0454653 -0.00290726 -0.00215542
-0.874965 0.104797 0.0414803 -0.00496822 -0.0019665
-0.749428 0.143302 0.0355289 -0.00679364 -0.00168435
-0.588362 0.175013 0.027893 -0.00829699 -0.00132235
-0.399403 0.198427 0.0189349 -0.009407 -0.000897664
-0.191509 0.212434 0.00907904 -0.010071 -0.000430419
0.0254643 0.216369 -0.00120721 -0.0102576 5.72315e-05
0.24123 0.210048 -0.0114362 -0.00995794 0.000542169
0.44556 0.193768 -0.0211231 -0.00918615 0.0010014
0.628766 0.168302 -0.0298085 -0.00797887 0.00141316
0.782164 0.134858 -0.0370808 -0.00639332 0.00175793
0.898481 0.0950195 -0.0425952 -0.00450468 0.00201935
0.972203 0.0506768 -0.0460902 -0.00240249 0.00218504
0.999835 0.00393166 -0.0474002 -0.000186392 0.00224715
0.980067 -0.0429999 -0.046463 0.00203854 0.00220272
0.913835 -0.0878929 -0.0433231 0.00416683 0.00205386
0.804281 -0.128619 -0.0381293 0.00609757 0.00180763
0.656597 -0.163248 -0.0311279 0.00773925 0.00147571
0.477785 -0.190137 -0.0226508 0.00901402 0.00107383
0.276323 -0.208013 -0.0130999 0.00986146 0.00062104
0.0617601 -0.216026 -0.00292792 0.0102414 0.000138807
-0.15573 -0.213799 0.00738286 0.0101358 -0.000350007
-0.365838 -0.201436 0.0173436 0.00954966 -0.000822227
-0.558602 -0.179523 0.0264822 0.00851081 -0.00125547
-0.724883 -0.149099 0.0343653 0.00706849 -0.00162919
-0.8568 -0.111607 0.0406192 0.00529106 -0.00192567
-0.948097 -0.0688236 0.0449474 0.00326279 -0.00213086
-0.994447 -0.0227775 0.0471447 0.00107984 -0.00223504
-0.993652 0.0243484 0.0471071 -0.00115431 -0.00223325
-0.94575 0.0703199 0.0448361 -0.00333373 -0.00212559
-0.853012 0.112958 0.0404396 -0.0053551 -0.00191716
-0.719835 0.150241 0.0341259 -0.0071226 -0.00161784
-0.552531 0.180401 0.0261944 -0.00855243 -0.00124182
-0.359033 0.202008 0.017021 -0.00957681 -0.000806934
-0.148514 0.214039 0.00704077 -0.0101472 -0.000333789
0.0690453 0.215923 -0.0032733 -0.0102365 0.000155181
0.283332 0.20757 -0.0134322 -0.00984049 0.000636793
0.484186 0.189377 -0.0229543 -0.00897799 0.00108822
0.662086 0.162206 -0.0313882 -0.00768985 0.00148805
0.808598 0.127345 -0.038334 -0.00603716 0.00181734
0.916776 0.0864466 -0.0434625 -0.00409826 0.00206047
0.981491 0.0414501 -0.0465305 -0.00196506 0.00220592
0.999676 -0.00551149 -0.0473926 0.000261289 0.00224679
0.970468 -0.0522118 -0.0460079 0.00247525 0.00218114
0.895252 -0.0964368 -0.0424421 0.00457187 0.00201209
0.777594 -0.13609 -0.0368642 0.00645175 0.00174766
0.623072 -0.169291 -0.0295386 0.00802576 0.00140037
0.439012 -0.194467 -0.0208127 0.00921929 0.000986686
0.234138 -0.210423 -0.0111 0.00997574 0.00052623
0.0181652 -0.216404 -0.000861174 0.0102593 4.08265e-05
-0.198669 -0.212125 0.00941851 0.0100564 -0.000446513
-0.406085 -0.19779 0.0192517 0.00937683 -0.000912684
-0.59425 -0.174078 0.0281722 0.0082527 -0.00133559
-0.754242 -0.142114 0.0357571 0.00673732 -0.00169517
-0.878477 -0.103412 0.0416468 0.00490254 -0.00197439
-0.961065 -0.0598071 0.0455622 0.00283534 -0.00216001
-0.998091 -0.0133673 0.0473175 0.000633718 -0.00224323
-0.9878 0.0337062 0.0468296 -0.00159794 -0.0022201
-0.930679 0.0791818 0.0441216 -0.00375385 -0.00209172
-0.829436 0.120904 0.0393219 -0.00573179 -0.00186417
-0.688871 0.156894 0.032658 -0.007438 -0.00154825
-0.515649 0.185445 0.0244459 -0.0087916 -0.00115893
-0.317981 0.205206 0.0150748 -0.00972839 -0.000714667
-0.105237 0.215238 0.00498909 -0.010204 -0.000236523
0.112495 0.215066 -0.00533316 -0.0101958 0.000252834
0.324894 0.204698 -0.0154026 -0.00970431 0.000730205
0.521891 0.184626 -0.0247418 -0.00875273 0.00117296
0.694145 0.155801 -0.032908 -0.0073862 0.0015601
0.833492 0.11959 -0.0395142 -0.0056695 0.00187329
0.933325 0.077709 -0.044247 -0.00368403 0.00209766
0.98891 0.0321444 -0.0468822 -0.0015239 0.00222259
0.997614 -0.0149441 -0.0472948 0.000708472 0.00224215
0.959022 -0.0613242 -0.0454653 0.00290726 0.00215542
0.874965 -0.104797 -0.0414803 0.00496822 0.0019665
0.749428 -0.143302 -0.0355289 0.00679364 0.00168435
0.588362 -0.175013 -0.027893 0.00829699 0.00132235
0.399403 -0.198427 -0.0189349 0.009407 0.000897664
0.191509 -0.212434 -0.00907904 0.010071 0.000430419
-0.0254643 -0.216369 0.00120721 0.0102576 -5.72315e-05
-0.24123 -0.210048 0.0114362 0.00995794 -0.000542169
-0.44556 -0.193768 0.0211231 0.00918615 -0.0010014
-0.628766 -0.168302 0.0298085 0.00797887 -0.00141316
-0.782164 -0.134858 0.0370808 0.00639332 -0.00175793
-0.898481 -0.0950195 0.0425952 0.00450468 -0.00201935
-0.972203 -0.0506768 0.0460902 0.00240249 -0.00218504
-0.999835 -0.00393166 0.0474002 0.000186392 -0.00224715
-0.980067 0.0429999 0.046463 -0.00203854 -0.00220272
-0.913835 0.0878929 0.0433231 -0.00416683 -0.00205386
-0.804281 0.128619 0.0381293 -0.00609757 -0.00180763
-0.656597 0.163248 0.0311279 -0.00773925 -0.00147571
-0.477785 0.190137 0.0226508 -0.00901402 -0.00107383
-0.276323 0.208013 0.0130999 -0.00986146 -0.00062104
-0.0617601 0.216026 0.00292792 -0.0102414 -0.000138807
0.15573 0.213799 -0.00738286 -0.0101358 0.000350007
0.365838 0.201436 -0.0173436 -0.00954966 0.000822227
0.558602 0.179523 -0.0264822 -0.00851081 0.00125547
0.724883 0.149099 -0.0343653 -0.00706849 0.00162919
0.8568 0.111607 -0.0406192 -0.00529106 0.00192567
0.948097 0.0688236 -0.0449474 -0.00326279 0.00213086
0.994447 0.0227775 -0.0471447 -0.00107984 0.00223504
0.993652 -0.0243484 -0.0471071 0.00115431 0.00223325
0.94575 -0.0703199 -0.0448361 0.00333373 0.00212559
0.853012 -0.112958 -0.0404396 0.0053551 0.00191716
0.719835 -0.150241 -0.0341259 0.0071226 0.00161784
0.552531 -0.180401 -0.0261944 0.00918942 0.0015003
0.359033 -0.206595 -0.0182629 0.0103583 0.0010192

BIN
data/out/difference_2d.nc Normal file

Binary file not shown.

BIN
data/out/gmt_plot_ex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

5
data/prism/griding.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/zsh
xyz2nc -t prism_mag_pot.txt -o prism_V -r -30/30/-30/30 -i 0.75/0.75 -c 0,1,3 -l x,y,V
xyz2nc -t prism_mag_grad.txt -o prism_B -r -30/30/-30/30 -i 0.75/0.75 -c 0,1,3,4,5 -l x,y,Bx,By,Bz
xyz2nc -t prism_mag_tensor.txt -o prism_T -r -30/30/-30/30 -i 0.75/0.75 -c 0,1,3,4,5,6,7,8,9,10,11 -l x,y,Txx,Txy,Txz,Tyx,Tyy,Tyz,Tzx,Tzy,Tzz

14
data/prism/prism.1.edge Normal file
View File

@ -0,0 +1,14 @@
12 1
0 0 1 -1
1 1 2 -1
2 2 3 -1
3 3 0 -1
4 4 5 -1
5 5 6 -1
6 6 7 -1
7 7 4 -1
8 0 4 -1
9 5 1 -1
10 6 2 -1
11 7 3 -1
# Generated by tetgen -pq prism.poly

8
data/prism/prism.1.ele Normal file
View File

@ -0,0 +1,8 @@
6 4 0
0 2 0 3 7
1 2 0 7 6
2 5 4 0 6
3 0 4 7 6
4 0 2 1 6
5 5 0 1 6
# Generated by tetgen -pq prism.poly

14
data/prism/prism.1.face Normal file
View File

@ -0,0 +1,14 @@
12 1
0 0 2 1 -1
1 6 4 5 -1
2 2 0 3 -1
3 0 5 4 -1
4 4 6 7 -1
5 1 6 5 -1
6 5 0 1 -1
7 2 7 6 -1
8 6 1 2 -1
9 7 0 4 -1
10 7 2 3 -1
11 0 7 3 -1
# Generated by tetgen -pq prism.poly

10
data/prism/prism.1.node Normal file
View File

@ -0,0 +1,10 @@
8 3 0 0
0 -5 5 0
1 -5 -5 0
2 5 -5 0
3 5 5 0
4 -5 5 -10
5 -5 -5 -10
6 5 -5 -10
7 5 5 -10
# Generated by tetgen -pq prism.poly

32
data/prism/prism.poly Normal file
View File

@ -0,0 +1,32 @@
# Part 1 - the node list.
# A bar with 8 nodes in 3d, no attributes, no boundary marker.
8 3 0 0
0 -5 5 0
1 -5 -5 0
2 5 -5 0
3 5 5 0
4 -5 5 -10
5 -5 -5 -10
6 5 -5 -10
7 5 5 -10
# Part 2 - the facet list.
# Six facets without boundary markers.
6 0
1
4 0 1 2 3
1
4 4 5 6 7
1
4 0 4 5 1
1
4 1 5 6 2
1
4 2 6 7 3
1
4 3 7 4 0
# Part 3 - the hole list.
# There is no hole in bar.
0
# Part 4 - the region list.
# There is no region defined.
0

5005
data/random_topo.txt Normal file

File diff suppressed because it is too large Load Diff

65
data/sample.msh Normal file
View File

@ -0,0 +1,65 @@
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
24
1 -0.9 -0.9 -0
2 -0 -1 0
3 0.2 -0.8 0
4 0.4 -0.6 0
5 0.4 -0.3 0
6 0.2 -0.1 0
7 -0.1 -0.1 0
8 -0.3 -0 0
9 -0.6 -0 -0
10 -0.8 -0.3 -0
11 -1 -0.4 -0
12 -0.7 -0.5 -0
13 -0.4 -0.6 -0
14 -0.6 -0.8 -0
15 0.05000000000000002 -0.3192990707943443 0
16 -0.3234241541417823 -0.2328534994349195 0
17 -0.5506180658400093 -0.2582432415759687 0
18 -0.1258025445242781 -0.6785469613365849 0
19 0.1514088145278976 -0.5514088145278978 0
20 -0.4656780986675711 -0.4168904058736227 0
21 -0.05422077983979526 -0.4758537298998016 0
22 -0.2480354552006746 -0.4463582505235376 0
23 -0.4435105549954478 -0.122774185252722 0
24 -0.1351360778364504 -0.3148729101305205 0
$EndNodes
$Elements
32
1 2 0 5 15 19
2 2 0 10 12 17
3 2 0 12 13 20
4 2 0 5 6 15
5 2 0 16 17 20
6 2 0 4 5 19
7 2 0 6 7 15
8 2 0 16 20 22
9 2 0 17 12 20
10 2 0 8 9 23
11 2 0 18 3 19
12 2 0 13 18 22
13 2 0 18 21 22
14 2 0 7 8 16
15 2 0 15 7 24
16 2 0 17 16 23
17 2 0 3 4 19
18 2 0 18 19 21
19 2 0 2 3 18
20 2 0 9 17 23
21 2 0 19 15 21
22 2 0 20 13 22
23 2 0 22 21 24
24 2 0 16 8 23
25 2 0 7 16 24
26 2 0 21 15 24
27 2 0 16 22 24
28 2 0 2 14 1
29 2 0 14 2 18
30 2 0 9 10 17
31 2 0 12 10 11
32 2 0 13 14 18
$EndElements

903
data/sample3d.msh Normal file
View File

@ -0,0 +1,903 @@
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
354
0 313.926183 8243.35375 174.61
1 311.351438 8244.494357 174.61
2 309.423145 8245.025100000001 174.61
3 307.494853 8245.555843 174.61
4 305.56656 8246.086585999999 174.61
5 303.638268 8246.617329000001 174.61
6 301.681003 8247.028560999999 174.61
7 299.723737 8247.439793 174.61
8 297.766471 8247.851025 174.61
9 295.809206 8248.262257 174.61
10 293.85194 8248.673489000001 174.61
11 291.894675 8249.084720999999 174.61
12 289.937409 8249.495953 174.61
13 287.980144 8249.907185 174.61
14 286.022878 8250.318417 174.61
15 284.065613 8250.729649000001 174.61
16 282.146435 8251.292459 174.61
17 280.227256 8251.855269 174.61
18 278.308078 8252.418078000001 174.61
19 276.3889 8252.980888 174.61
20 274.469722 8253.543697999999 174.61
21 272.550544 8254.106508000001 174.61
22 270.631365 8254.669318 174.61
23 268.712187 8255.232128 174.61
24 266.793009 8255.794937999999 174.61
25 264.793706 8255.847739999999 174.61
26 262.794403 8255.900541999999 174.61
27 260.795101 8255.953344 174.61
28 258.795798 8256.006146 174.61
29 256.796495 8256.058949 174.61
30 254.797192 8256.111751 174.61
31 252.797889 8256.164553000001 174.61
32 250.798586 8256.217355000001 174.61
33 250.115306 8254.337692999999 174.61
34 249.432026 8252.458031 174.61
35 248.748746 8250.578369999999 174.61
36 248.065465 8248.698708 174.61
37 247.382185 8246.819046000001 174.61
38 246.698905 8244.939383999999 174.61
39 246.015625 8243.059723 174.61
40 245.332345 8241.180060999999 174.61
41 243.50226 8240.373345 174.61
42 241.672176 8239.566629000001 174.61
43 239.842091 8238.759913 174.61
44 238.012007 8237.953197000001 174.61
45 236.181922 8237.146481 174.61
46 234.351838 8236.339765000001 174.61
47 232.521753 8235.533049 174.61
48 230.931851 8234.319702000001 174.61
49 229.341948 8233.106355 174.61
50 227.752046 8231.893008999999 174.61
51 226.162143 8230.679662 174.61
52 224.572241 8229.466315 174.61
53 222.982338 8228.252968999999 174.61
54 221.392436 8227.039622 174.61
55 219.802533 8225.826276 174.61
56 218.212631 8224.612929000001 174.61
57 216.622728 8223.399582 174.61
58 215.032826 8222.186236 174.61
59 213.442923 8220.972889000001 174.61
60 211.853021 8219.759542 174.61
61 210.263118 8218.546195999999 174.61
62 209.064308 8216.945304000001 174.61
63 207.865498 8215.344413000001 174.61
64 206.666687 8213.743521 174.61
65 205.467877 8212.142629 174.61
66 204.269067 8210.541738 174.61
67 203.070256 8208.940846 174.61
68 201.871446 8207.339954999999 174.61
69 199.473825 8204.138172000001 174.61
70 194.464261 8238.589733000001 145.66
71 195.890157 8239.992167 145.66
72 197.316053 8241.394601 145.66
73 198.741949 8242.797035 145.66
74 200.167845 8244.199468999999 145.66
75 201.59374 8245.601903000001 145.66
76 203.019636 8247.004337 145.66
77 204.445532 8248.406771 145.66
78 206.285084 8249.191659 145.66
79 208.124636 8249.976547 145.66
80 209.964188 8250.761434 145.66
81 211.80374 8251.546322 145.66
82 213.643291 8252.33121 145.66
83 215.482843 8253.116098 145.66
84 217.322395 8253.900986000001 145.66
85 217.960095 8255.796596 145.66
86 218.597795 8257.692207 145.66
87 219.235494 8259.587817 145.66
88 219.873194 8261.483428 145.66
89 220.510894 8263.379037999999 145.66
90 222.359262 8264.142934 145.66
91 224.20763 8264.906829 145.66
92 226.055998 8265.670724 145.66
93 227.904366 8266.43462 145.66
94 229.752733 8267.198515 145.66
95 231.601101 8267.96241 145.66
96 233.449469 8268.726306 145.66
97 235.297837 8269.490201000001 145.66
98 237.018434 8268.470619 145.66
99 238.73903 8267.451037000001 145.66
100 240.459627 8266.431455 145.66
101 242.180224 8265.411872999999 145.66
102 243.90082 8264.392292 145.66
103 245.621417 8263.37271 145.66
104 247.601823 8263.093441000001 145.66
105 249.582229 8262.814172 145.66
106 251.562636 8262.534903 145.66
107 253.543042 8262.255635 145.66
108 255.523448 8261.976366000001 145.66
109 257.503854 8261.697097 145.66
110 259.484261 8261.417829 145.66
111 261.464667 8261.138559999999 145.66
112 263.445073 8260.859291000001 145.66
113 265.363134 8260.292684 145.66
114 267.281194 8259.726076999999 145.66
115 269.199255 8259.159470000001 145.66
116 271.117315 8258.592862 145.66
117 273.035376 8258.026255000001 145.66
118 274.953437 8257.459648 145.66
119 276.881907 8257.989743 145.66
120 278.810378 8258.519838 145.66
121 280.738849 8259.049933 145.66
122 282.667319 8259.580028 145.66
123 283.883839 8261.167503999999 145.66
124 285.100358 8262.754981 145.66
125 286.316877 8264.342457000001 145.66
126 287.533397 8265.929932999999 145.66
127 288.749916 8267.517409 145.66
128 289.966435 8269.104885999999 145.66
129 291.949883 8269.36166 145.66
130 293.933331 8269.618435 145.66
131 295.91678 8269.87521 145.66
132 297.900228 8270.131984 145.66
133 299.883676 8270.388758999999 145.66
134 301.867124 8270.645533999999 145.66
135 303.850572 8270.902308000001 145.66
136 304.927279 8269.21687 145.66
137 306.003985 8267.531430999999 145.66
138 307.080691 8265.845992 145.66
139 308.157398 8264.160554 145.66
140 308.080255 8262.162042 145.66
141 308.003113 8260.16353 145.66
142 307.925971 8258.165018 145.66
143 307.848828 8256.166507 145.66
144 307.771686 8254.167995 145.66
145 307.694544 8252.169483 145.66
146 307.617401 8250.170972 145.66
147 307.540259 8248.17246 145.66
148 309.13674 8246.967782 145.66
149 310.733221 8245.763105 145.66
150 312.329702 8244.558427 145.66
151 313.011881313963 8243.758783858966 174.61
152 197.1714950382996 8219.971657931641 167.1326825363388
153 313.127942326152 8243.956088631183 145.66
154 312.1816596569819 8244.126570429482 174.61
155 198.3226600191497 8212.054914965822 171.511706200758
156 311.5314614999995 8245.160766000001 145.66
157 311.766548828491 8244.310463714741 174.61
158 312.7288221630755 8244.257257815592 145.66
159 310.3872914999997 8244.759728500001 174.61
160 202.0305338890445 8213.467342918595 172.8094853580749
161 205.6269648890445 8218.270017918596 172.4736790876283
162 213.676849263398 8225.611366645451 171.8260766878229
163 226.396069263398 8235.318139645451 171.0487149742466
164 237.4969640778441 8241.600789073307 170.7492766615007
165 222.2770380948837 8257.50954759273 148.6470887700369
166 222.274113329071 8261.730806429581 147.0775379066513
167 245.7582655823208 8252.729467446003 167.5701427137334
168 246.1165531039372 8259.722361989483 154.9707564940292
169 198.898242509575 8208.09654348291 172.9655190022536
170 236.0712943824225 8264.910685946632 148.9794557326485
171 235.1379787866611 8267.258843141719 147.2434974556395
172 278.1225256679723 8255.338942399028 160.5568337874227
173 284.1037308696277 8254.413227157265 163.746463012873
174 274.0266093132985 8255.586283465878 161.3579692445111
175 261.8614257854493 8258.451488142155 160.1545176599392
176 270.1894300182401 8256.715919431155 160.8363594930652
177 305.175334236154 8248.433487558827 161.6641334996602
178 297.5168393909073 8251.526331901341 166.4179553244652
179 265.7248578889732 8257.987398845493 159.6887053347512
180 254.1182495922608 8259.173105314845 159.7573530580744
181 290.9558135167043 8264.567118409723 150.0459593802406
182 304.9284567128553 8263.28444697108 148.8113997826581
183 210.4970424906732 8223.184673145452 172.0142834422122
184 216.8566524906765 8228.038060145451 171.6238845218464
185 229.5758724906765 8237.744833145451 170.7778055986207
186 214.1149053997695 8248.677749547322 149.0796672981306
187 223.2162624906732 8232.891446145451 171.2392832006383
188 241.1571330778441 8243.214221073307 170.8326683350127
189 233.8367950778441 8239.987357073307 170.7631837987159
190 221.0016385948837 8253.718324820007 149.3345873237841
191 226.4859891020328 8262.012129938634 148.5151545150298
192 223.963769700017 8262.878727831298 147.0381160334391
193 248.28541631274 8260.77951696444 152.4898134362761
194 241.2330861551472 8261.851940446631 151.1784104213179
195 200.8089539423332 8209.384894229866 173.6305121571324
196 232.0310921020328 8264.303815938634 148.7787492268117
197 279.8081435522726 8253.979697880626 166.3247893678882
198 282.4145498328289 8256.726688751096 155.5300146002253
199 285.471401416754 8252.557088125586 168.8251491052046
200 275.9175367823709 8254.927139361223 163.792297292365
201 268.2408893943114 8257.178603097462 161.4906657898475
202 304.9942219086736 8251.272971705994 155.7451797752991
203 303.0487185759312 8248.6747918568 166.6743147206707
204 304.3445908190449 8257.302515757838 151.9243399785707
205 293.6023083909041 8252.348795901342 167.0179052599145
206 256.2356785635421 8259.865519940555 155.472406712622
207 252.2748676582121 8260.424058144819 154.1567152780841
208 293.318656438655 8266.577544510996 148.8737200794329
209 288.5227745167043 8261.392166409723 151.8222114213268
210 301.3305912394036 8267.001040362667 148.5454383834011
211 220.0364574906765 8230.46475314545 171.4279641120949
212 203.366921097577 8242.372967521527 148.7257097985029
213 210.4358001270448 8247.107972274596 148.8339484911673
214 243.6451594869822 8244.985437366791 171.1246075530364
215 229.667230729892 8264.78724317028 147.5697738103074
216 289.6877773909073 8253.171259901341 166.5288184498691
217 291.2122578718165 8267.270488998878 147.7708154155297
218 299.1738655043491 8268.082742149889 147.7857639788016
219 297.1371642831866 8268.237313103005 147.5177713752924
220 204.3096622292636 8214.259248831437 173.5052739655773
221 207.9060932292637 8219.061923831438 173.2358193674899
222 212.9057404543121 8223.325117494278 173.0245707919301
223 216.0855456392754 8225.751810251912 172.8935786508372
224 228.8047656392754 8235.458583251911 172.3897480931193
225 225.6249604543121 8233.031890494278 172.519751841196
226 236.2112707600957 8239.559089873903 172.2351882023952
227 220.3601373623933 8256.044270318287 147.6542405973609
228 221.2425720613906 8259.967687921255 147.0644541436803
229 247.7099844981616 8254.148035327213 169.0054729826114
230 244.3917028095993 8248.970143946002 169.2435156613031
231 246.3434245006209 8250.388713242462 170.5746523974396
232 238.4799287108291 8265.052201353226 148.2644353029432
233 233.1937475173908 8266.726906506154 147.2312850695726
234 272.0791801987115 8256.052759943424 161.7072910956356
235 259.8444674876201 8257.83576957677 164.488868547548
236 299.1965957573373 8249.794292029326 168.6500474157657
237 263.9038935566198 8258.882691822029 156.1429491331224
238 304.8011203130221 8265.57637250056 147.7260164521207
239 305.9770326615911 8261.242480959823 148.4249971803805
240 209.7259366288135 8220.898423893903 173.1267279994175
241 217.7940088997695 8250.247523774597 149.5270435796658
242 215.4247957738045 8250.70400929998 147.7789391031023
243 211.7456930232013 8249.134232715465 147.6289750595905
244 222.4451566288135 8230.605196893903 172.6410458911713
245 239.8714397600957 8241.172521873903 172.172675850896
246 232.5511017600957 8237.945657873903 172.2399700831135
247 224.4854580313409 8260.293354733078 148.7562784497157
248 243.6417193146052 8261.993457372129 150.0205005281902
249 202.2604160107508 8210.796590542444 173.8102649425752
250 281.6768586990891 8253.244806309865 168.2039288870571
251 280.2784563673854 8256.951919034915 153.6082752933255
252 287.3635519318007 8251.835941238165 170.106041404697
253 305.8395402708042 8253.241830450919 151.5059340698077
254 301.0599021214895 8248.935857475493 168.8672169768372
255 295.2820647573377 8250.616756029327 169.6022020909191
256 255.8437965364 8257.863186948094 165.7414154087156
257 258.2498577278492 8259.825739572449 154.6872900174976
258 250.3282319264178 8260.942814590098 152.1255332146419
259 251.8515666761752 8258.210218079283 164.8970216222584
260 288.6680273616915 8263.800577338501 149.1169086831441
261 286.2349899379212 8260.625625953009 150.4795867150306
262 219.2653516288138 8228.178503893902 172.7651140204012
263 206.2187125975738 8245.177833748803 148.4541047626427
264 203.8464206784078 8244.737628385272 147.4252800490487
265 200.9946304746424 8241.932759575715 147.4812360903842
266 208.0665888042696 8247.564458228579 147.4850677327471
267 243.5786499122906 8242.679238118901 172.4720606239788
268 245.1959706720016 8246.549740204444 171.7603190764186
269 227.6604395683543 8264.40668050233 147.1678516350345
270 291.3675337573373 8251.439220029326 169.6662647926144
271 287.2272800713428 8255.282827334266 161.9446587473132
272 295.1475154232627 8268.02843904236 147.5617448049912
273 297.8815032348254 8264.54951821877 150.9991722135544
274 205.8404799584432 8215.611521836026 173.6671975118965
275 248.7830858959678 8255.885992507574 168.5974992515517
276 240.411976213827 8264.389452939055 148.1560724931977
277 303.9832304774628 8267.427150570767 147.2679730871997
278 302.2432263665554 8264.284759154523 150.0080183789812
279 306.2067820637887 8259.232123038184 148.5364942133951
280 200.2778651293144 8211.382965308912 172.7459088262896
281 306.072495396461 8255.234328108178 149.9229067848555
282 301.9266376769696 8253.755917339577 158.3732906523234
283 257.8418912496609 8257.764600891482 165.585617588144
284 249.4812034886728 8258.679720110491 161.0814206205042
285 284.6892452860924 8259.290440450286 150.6172965527058
286 206.0527538675582 8247.188039366587 147.0185421112836
287 199.2778843553139 8240.82604146805 147.1323529296793
288 243.0090867936295 8247.16689348573 169.1832062623778
289 229.1170689100535 8262.206959920337 149.3772637998786
290 296.3495243321339 8266.159321477237 149.5438512857817
291 203.4645709476748 8216.758524720712 172.1192291777782
292 245.701093897865 8256.588696262086 161.9001026438997
293 238.6566475821676 8262.419841598368 151.022478836895
294 302.4435311888182 8260.71819392587 152.0323715939707
295 302.2884848721959 8256.106761253357 155.4414015387319
296 304.0100983678824 8254.465588663066 154.4018490759173
297 301.0754341021852 8251.421021980936 163.1354580286252
298 287.129121281438 8258.028142559975 156.0267135907007
299 197.818120583935 8239.458041829837 147.1347617785995
300 202.0981633135229 8238.336083244893 151.233530687906
301 241.3952172988316 8245.512857028158 169.1655320897779
302 294.4141484259911 8262.783649342746 152.7559137669651
303 240.5037291917727 8250.519515494871 164.6209150512442
304 304.3500667064324 8260.038239511079 150.6349563451401
305 197.7470775287246 8216.013286448731 169.5840761175503
306 195.8178780191498 8229.280695465821 158.5862528259621
307 199.9049346836927 8238.694087694144 149.2338724051603
308 238.3303130060812 8244.668660573485 168.2451889317608
309 240.5559372392456 8247.946113043732 166.7807704982223
310 302.7888209866092 8258.673497179356 152.9795554915347
311 199.9041950419229 8213.4762322721 171.7929861807117
312 298.9914928192845 8259.083741994984 155.4553463414398
313 200.9774497953317 8215.884204722212 171.3003887711282
314 195.1410695095747 8233.935214232912 152.3633822701954
315 200.3669058714845 8234.627096146927 154.0774754614462
316 197.8835955937096 8236.404749463667 150.1261787470227
317 196.3917525628544 8238.056087747587 147.2767348264982
318 194.8026652547874 8236.262473616456 148.6575676390163
319 205.3626983359229 8222.706236687283 169.6578735636612
320 230.8898676831124 8240.417426985407 168.8392761188105
321 208.815668643367 8245.075789272367 149.8294237752952
322 228.0974826031021 8258.112842129814 151.8518362986938
323 242.6375531092147 8258.516118199594 156.383447404928
324 299.352308260146 8253.371804396282 161.7817777882186
325 290.6480569221984 8256.779549712814 159.7504221475794
326 235.9679005849229 8249.140263803578 163.153875842859
327 201.0195572172153 8219.739060254797 169.2703677902785
328 207.9460419057149 8222.771910433821 171.024322425639
329 207.3614676018552 8241.1637764813 152.3971714787335
330 213.22823423714 8243.219834592768 154.0662719678526
331 239.2670085463485 8259.060601734442 154.9069666833876
332 296.1454035207044 8254.72582970576 161.9552443127924
333 208.4898277778386 8227.500512091408 167.4340257143654
334 206.5886669152632 8225.323575930755 168.2677462298901
335 234.1891286088608 8244.146441370447 166.7816894650607
336 225.4950984875067 8241.410481054489 164.4951534037054
337 203.6801400772652 8229.782277754017 162.0894723612487
338 202.3291183615592 8225.722966592532 165.4159744695053
339 234.6204253049797 8260.817621124561 152.3056667863168
340 242.3171865978215 8254.60852823558 161.8078967904619
341 214.1446977447509 8234.888323709078 163.6328505651941
342 217.7354071986266 8245.288597207242 154.7730826939639
343 196.4946865287248 8224.62617669873 163.4134059585095
344 218.9620915548466 8235.16921042608 166.5216637340015
345 212.602480526767 8230.315824019077 167.2543475459644
346 225.5514188205176 8254.297879149928 152.7900725810471
347 236.8607050084175 8254.352097430679 158.9810045979034
348 223.9153702249035 8247.807917997332 156.8171455135806
349 205.4196086619233 8234.527173853638 157.8866814666313
350 222.6451681302684 8236.936446448326 167.1656484337931
351 231.2110824163707 8253.277771520552 157.0890331633047
352 218.7750446547908 8240.280579848028 161.0171844123911
353 229.0178444146641 8245.397731906243 162.7279983304483
$EndNodes
$Elements
540
0 2 1 0 169 68 69
1 2 1 0 128 217 127
2 2 1 0 65 220 64
3 2 1 0 279 239 141
4 2 1 0 258 105 106
5 2 1 0 65 66 160
6 2 1 0 280 169 155
7 2 1 0 301 309 288
8 2 1 0 160 291 220
9 2 1 0 207 106 107
10 2 1 0 5 203 177
11 2 1 0 161 62 63
12 2 1 0 168 284 292
13 2 1 0 220 65 160
14 2 1 0 200 119 172
15 2 1 0 222 58 59
16 2 1 0 240 221 328
17 2 1 0 287 265 307
18 2 1 0 181 127 217
19 2 1 0 265 287 73
20 2 1 0 161 221 62
21 2 1 0 341 344 211
22 2 1 0 222 162 58
23 2 1 0 140 239 182
24 2 1 0 287 72 73
25 2 1 0 212 265 74
26 2 1 0 47 246 46
27 2 1 0 184 55 56
28 2 1 0 250 16 17
29 2 1 0 183 59 60
30 2 1 0 300 265 212
31 2 1 0 131 132 219
32 2 1 0 60 61 240
33 2 1 0 167 231 230
34 2 1 0 329 263 321
35 2 1 0 266 78 79
36 2 1 0 53 54 211
37 2 1 0 261 123 124
38 2 1 0 132 133 218
39 2 1 0 244 187 52
40 2 1 0 187 51 52
41 2 1 0 171 170 233
42 2 1 0 48 49 224
43 2 1 0 321 330 329
44 2 1 0 296 253 202
45 2 1 0 48 185 47
46 2 1 0 13 14 252
47 2 1 0 225 50 51
48 2 1 0 261 298 285
49 2 1 0 225 163 50
50 2 1 0 189 46 246
51 2 1 0 23 176 22
52 2 1 0 226 164 44
53 2 1 0 113 237 112
54 2 1 0 67 249 66
55 2 1 0 42 245 188
56 2 1 0 55 262 54
57 2 1 0 45 226 44
58 2 1 0 40 41 267
59 2 1 0 256 30 180
60 2 1 0 61 62 221
61 2 1 0 149 159 2
62 2 1 0 39 214 38
63 2 1 0 267 214 39
64 2 1 0 8 178 236
65 2 1 0 42 188 41
66 2 1 0 74 265 73
67 2 1 0 45 46 189
68 2 1 0 252 199 271
69 2 1 0 54 262 211
70 2 1 0 185 224 163
71 2 1 0 188 267 41
72 2 1 0 187 225 51
73 2 1 0 266 213 321
74 2 1 0 162 222 183
75 2 1 0 75 76 264
76 2 1 0 186 243 81
77 2 1 0 164 226 189
78 2 1 0 52 53 244
79 2 1 0 264 212 75
80 2 1 0 336 320 185
81 2 1 0 81 82 186
82 2 1 0 176 201 115
83 2 1 0 278 238 182
84 2 1 0 78 286 77
85 2 1 0 31 32 259
86 2 1 0 242 82 83
87 2 1 0 219 132 218
88 2 1 0 164 308 245
89 2 1 0 190 241 84
90 2 1 0 88 166 228
91 2 1 0 87 165 86
92 2 1 0 284 193 258
93 2 1 0 173 298 271
94 2 1 0 190 84 85
95 2 1 0 165 227 86
96 2 1 0 85 227 190
97 2 1 0 88 89 166
98 2 1 0 269 92 93
99 2 1 0 166 89 90
100 2 1 0 90 91 192
101 2 1 0 272 130 131
102 2 1 0 90 192 166
103 2 1 0 183 222 59
104 2 1 0 163 224 49
105 2 1 0 230 36 37
106 2 1 0 57 162 223
107 2 1 0 189 226 45
108 2 1 0 232 170 99
109 2 1 0 157 1 156
110 2 1 0 33 34 229
111 2 1 0 167 34 35
112 2 1 0 64 220 274
113 2 1 0 103 104 168
114 2 1 0 193 104 105
115 2 1 0 151 153 0
116 2 1 0 106 207 258
117 2 1 0 168 104 193
118 2 1 0 180 259 207
119 2 1 0 14 15 199
120 2 1 0 151 158 153
121 2 1 0 33 229 275
122 2 1 0 169 195 68
123 2 1 0 129 130 208
124 2 1 0 214 268 38
125 2 1 0 98 171 97
126 2 1 0 171 96 97
127 2 1 0 171 233 96
128 2 1 0 121 251 120
129 2 1 0 87 228 165
130 2 1 0 196 94 95
131 2 1 0 219 218 290
132 2 1 0 170 171 98
133 2 1 0 194 293 276
134 2 1 0 115 116 176
135 2 1 0 98 99 170
136 2 1 0 93 215 269
137 2 1 0 21 174 20
138 2 1 0 221 161 319
139 2 1 0 232 100 276
140 2 1 0 194 101 102
141 2 1 0 80 213 79
142 2 1 0 260 209 125
143 2 1 0 167 35 231
144 2 1 0 231 35 36
145 2 1 0 190 227 165
146 2 1 0 99 100 232
147 2 1 0 163 225 187
148 2 1 0 172 18 19
149 2 1 0 16 173 199
150 2 1 0 174 200 20
151 2 1 0 215 94 196
152 2 1 0 18 172 197
153 2 1 0 103 248 102
154 2 1 0 216 12 13
155 2 1 0 76 286 264
156 2 1 0 15 16 199
157 2 1 0 27 175 26
158 2 1 0 24 25 179
159 2 1 0 121 122 198
160 2 1 0 17 197 250
161 2 1 0 210 273 218
162 2 1 0 197 17 18
163 2 1 0 19 20 200
164 2 1 0 27 235 175
165 2 1 0 160 280 311
166 2 1 0 156 150 157
167 2 1 0 150 154 157
168 2 1 0 206 257 283
169 2 1 0 108 109 206
170 2 1 0 235 110 111
171 2 1 0 151 154 158
172 2 1 0 21 234 174
173 2 1 0 242 186 82
174 2 1 0 57 223 56
175 2 1 0 44 164 43
176 2 1 0 21 22 234
177 2 1 0 26 237 25
178 2 1 0 176 23 201
179 2 1 0 228 87 88
180 2 1 0 248 194 102
181 2 1 0 201 24 179
182 2 1 0 12 216 270
183 2 1 0 202 145 146
184 2 1 0 147 3 4
185 2 1 0 247 322 165
186 2 1 0 148 3 147
187 2 1 0 147 4 177
188 2 1 0 3 148 2
189 2 1 0 19 200 172
190 2 1 0 158 154 150
191 2 1 0 214 301 288
192 2 1 0 156 1 159
193 2 1 0 159 149 156
194 2 1 0 250 197 198
195 2 1 0 2 148 149
196 2 1 0 273 302 290
197 2 1 0 191 192 91
198 2 1 0 215 93 94
199 2 1 0 229 167 292
200 2 1 0 236 7 8
201 2 1 0 177 203 202
202 2 1 0 9 10 255
203 2 1 0 247 166 192
204 2 1 0 169 280 195
205 2 1 0 10 205 255
206 2 1 0 203 6 254
207 2 1 0 11 12 270
208 2 1 0 177 4 5
209 2 1 0 177 146 147
210 2 1 0 202 146 177
211 2 1 0 341 330 352
212 2 1 0 253 144 145
213 2 1 0 281 144 253
214 2 1 0 164 189 335
215 2 1 0 203 5 6
216 2 1 0 236 297 254
217 2 1 0 205 10 11
218 2 1 0 210 218 133
219 2 1 0 38 268 37
220 2 1 0 249 67 195
221 2 1 0 145 202 253
222 2 1 0 23 24 201
223 2 1 0 116 234 176
224 2 1 0 229 34 167
225 2 1 0 201 179 114
226 2 1 0 227 85 86
227 2 1 0 114 179 113
228 2 1 0 240 183 60
229 2 1 0 119 200 118
230 2 1 0 289 215 196
231 2 1 0 198 251 121
232 2 1 0 198 197 251
233 2 1 0 191 247 192
234 2 1 0 118 200 174
235 2 1 0 50 163 49
236 2 1 0 116 117 234
237 2 1 0 58 162 57
238 2 1 0 184 162 345
239 2 1 0 257 206 109
240 2 1 0 107 108 180
241 2 1 0 29 30 256
242 2 1 0 84 241 83
243 2 1 0 196 170 339
244 2 1 0 80 81 243
245 2 1 0 206 180 108
246 2 1 0 117 118 174
247 2 1 0 235 27 28
248 2 1 0 141 239 140
249 2 1 0 233 95 96
250 2 1 0 285 122 123
251 2 1 0 31 180 30
252 2 1 0 91 92 191
253 2 1 0 111 112 175
254 2 1 0 113 179 237
255 2 1 0 42 43 245
256 2 1 0 209 261 124
257 2 1 0 180 207 107
258 2 1 0 127 181 126
259 2 1 0 126 260 125
260 2 1 0 120 172 119
261 2 1 0 312 295 324
262 2 1 0 238 137 138
263 2 1 0 179 25 237
264 2 1 0 209 124 125
265 2 1 0 75 212 74
266 2 1 0 220 291 274
267 2 1 0 332 205 325
268 2 1 0 139 182 138
269 2 1 0 139 140 182
270 2 1 0 48 224 185
271 2 1 0 178 8 9
272 2 1 0 252 14 199
273 2 1 0 274 63 64
274 2 1 0 324 178 332
275 2 1 0 208 181 217
276 2 1 0 219 272 131
277 2 1 0 128 129 217
278 2 1 0 215 289 269
279 2 1 0 181 302 209
280 2 1 0 208 217 129
281 2 1 0 330 321 213
282 2 1 0 184 223 162
283 2 1 0 210 134 277
284 2 1 0 133 134 210
285 2 1 0 134 135 136
286 2 1 0 56 223 184
287 2 1 0 290 272 219
288 2 1 0 275 32 33
289 2 1 0 182 238 138
290 2 1 0 238 277 137
291 2 1 0 201 114 115
292 2 1 0 229 292 275
293 2 1 0 195 67 68
294 2 1 0 143 204 142
295 2 1 0 320 246 185
296 2 1 0 168 292 323
297 2 1 0 29 256 283
298 2 1 0 268 214 288
299 2 1 0 247 165 228
300 2 1 0 230 231 36
301 2 1 0 293 170 232
302 2 1 0 100 101 276
303 2 1 0 95 233 196
304 2 1 0 170 196 233
305 2 1 0 117 174 234
306 2 1 0 176 234 22
307 2 1 0 111 175 235
308 2 1 0 257 109 110
309 2 1 0 6 7 254
310 2 1 0 297 202 203
311 2 1 0 112 237 175
312 2 1 0 26 175 237
313 2 1 0 277 136 137
314 2 1 0 238 278 277
315 2 1 0 294 278 182
316 2 1 0 141 142 279
317 2 1 0 328 183 240
318 2 1 0 221 240 61
319 2 1 0 186 342 330
320 2 1 0 163 336 185
321 2 1 0 186 242 241
322 2 1 0 241 242 83
323 2 1 0 80 243 213
324 2 1 0 213 243 186
325 2 1 0 187 244 211
326 2 1 0 211 244 53
327 2 1 0 308 188 245
328 2 1 0 164 245 43
329 2 1 0 320 189 246
330 2 1 0 185 246 47
331 2 1 0 228 166 247
332 2 1 0 346 190 165
333 2 1 0 248 323 194
334 2 1 0 168 248 103
335 2 1 0 66 249 160
336 2 1 0 311 313 160
337 2 1 0 16 250 173
338 2 1 0 198 173 250
339 2 1 0 120 251 172
340 2 1 0 197 172 251
341 2 1 0 13 252 216
342 2 1 0 271 216 252
343 2 1 0 281 143 144
344 2 1 0 253 296 281
345 2 1 0 297 282 202
346 2 1 0 236 254 7
347 2 1 0 9 255 178
348 2 1 0 332 178 255
349 2 1 0 29 283 28
350 2 1 0 180 206 256
351 2 1 0 283 256 206
352 2 1 0 235 257 110
353 2 1 0 105 258 193
354 2 1 0 284 258 259
355 2 1 0 180 31 259
356 2 1 0 258 207 259
357 2 1 0 209 260 181
358 2 1 0 181 260 126
359 2 1 0 261 285 123
360 2 1 0 271 199 173
361 2 1 0 211 262 184
362 2 1 0 184 262 55
363 2 1 0 300 212 329
364 2 1 0 266 79 213
365 2 1 0 212 264 263
366 2 1 0 286 263 264
367 2 1 0 299 71 72
368 2 1 0 302 332 325
369 2 1 0 286 78 266
370 2 1 0 321 263 266
371 2 1 0 39 40 267
372 2 1 0 188 214 267
373 2 1 0 37 268 230
374 2 1 0 288 230 268
375 2 1 0 92 269 191
376 2 1 0 289 191 269
377 2 1 0 11 270 205
378 2 1 0 205 270 216
379 2 1 0 325 271 298
380 2 1 0 285 298 173
381 2 1 0 130 272 208
382 2 1 0 290 218 273
383 2 1 0 208 290 302
384 2 1 0 294 182 304
385 2 1 0 63 274 161
386 2 1 0 291 161 274
387 2 1 0 32 284 259
388 2 1 0 275 292 284
389 2 1 0 293 232 276
390 2 1 0 194 276 101
391 2 1 0 134 136 277
392 2 1 0 278 210 277
393 2 1 0 210 278 273
394 2 1 0 204 304 279
395 2 1 0 304 239 279
396 2 1 0 204 279 142
397 2 1 0 195 280 249
398 2 1 0 160 249 280
399 2 1 0 143 281 204
400 2 1 0 204 296 295
401 2 1 0 296 282 295
402 2 1 0 297 236 178
403 2 1 0 28 283 235
404 2 1 0 257 235 283
405 2 1 0 168 193 284
406 2 1 0 32 275 284
407 2 1 0 122 285 198
408 2 1 0 285 173 198
409 2 1 0 76 77 286
410 2 1 0 266 263 286
411 2 1 0 72 287 299
412 2 1 0 307 299 287
413 2 1 0 323 292 340
414 2 1 0 188 301 214
415 2 1 0 322 247 191
416 2 1 0 167 230 303
417 2 1 0 272 290 208
418 2 1 0 302 181 208
419 2 1 0 327 319 161
420 2 1 0 310 312 294
421 2 1 0 323 248 168
422 2 1 0 331 194 323
423 2 1 0 351 346 322
424 2 1 0 288 309 230
425 2 1 0 278 294 273
426 2 1 0 312 302 273
427 2 1 0 305 327 313
428 2 1 0 155 311 280
429 2 1 0 204 281 296
430 2 1 0 202 282 296
431 2 1 0 203 254 297
432 2 1 0 297 324 282
433 2 1 0 325 216 271
434 2 1 0 209 298 261
435 2 1 0 307 265 300
436 2 1 0 315 307 300
437 2 1 0 317 71 299
438 2 1 0 349 315 300
439 2 1 0 303 230 309
440 2 1 0 188 308 301
441 2 1 0 209 325 298
442 2 1 0 324 297 178
443 2 1 0 339 293 331
444 2 1 0 191 289 322
445 2 1 0 182 239 304
446 2 1 0 304 310 294
447 2 1 0 304 204 310
448 2 1 0 152 327 305
449 2 1 0 299 307 316
450 2 1 0 70 71 317
451 2 1 0 316 318 317
452 2 1 0 309 308 326
453 2 1 0 164 335 308
454 2 1 0 326 303 309
455 2 1 0 308 309 301
456 2 1 0 294 312 273
457 2 1 0 295 310 204
458 2 1 0 313 291 160
459 2 1 0 305 311 155
460 2 1 0 295 312 310
461 2 1 0 313 327 291
462 2 1 0 305 313 311
463 2 1 0 314 315 306
464 2 1 0 316 307 315
465 2 1 0 334 328 319
466 2 1 0 183 334 333
467 2 1 0 314 316 315
468 2 1 0 316 314 318
469 2 1 0 316 317 299
470 2 1 0 334 183 328
471 2 1 0 317 318 70
472 2 1 0 319 327 338
473 2 1 0 335 326 308
474 2 1 0 241 348 342
475 2 1 0 212 263 329
476 2 1 0 186 330 213
477 2 1 0 351 326 353
478 2 1 0 347 303 326
479 2 1 0 331 293 194
480 2 1 0 292 167 340
481 2 1 0 295 282 324
482 2 1 0 332 255 205
483 2 1 0 205 216 325
484 2 1 0 209 302 325
485 2 1 0 331 340 347
486 2 1 0 322 346 165
487 2 1 0 161 291 327
488 2 1 0 334 319 338
489 2 1 0 183 333 162
490 2 1 0 221 319 328
491 2 1 0 337 315 349
492 2 1 0 187 211 344
493 2 1 0 341 211 184
494 2 1 0 187 344 350
495 2 1 0 170 293 339
496 2 1 0 347 340 303
497 2 1 0 324 332 312
498 2 1 0 332 302 312
499 2 1 0 184 345 341
500 2 1 0 338 343 306
501 2 1 0 333 349 345
502 2 1 0 334 338 337
503 2 1 0 353 348 351
504 2 1 0 320 335 189
505 2 1 0 320 353 335
506 2 1 0 342 186 241
507 2 1 0 306 315 337
508 2 1 0 334 337 333
509 2 1 0 337 338 306
510 2 1 0 343 338 327
511 2 1 0 196 339 289
512 2 1 0 322 289 339
513 2 1 0 331 323 340
514 2 1 0 303 340 167
515 2 1 0 330 341 329
516 2 1 0 329 349 300
517 2 1 0 352 344 341
518 2 1 0 348 336 342
519 2 1 0 190 348 241
520 2 1 0 152 343 327
521 2 1 0 350 163 187
522 2 1 0 350 352 336
523 2 1 0 345 349 341
524 2 1 0 333 345 162
525 2 1 0 351 339 347
526 2 1 0 331 347 339
527 2 1 0 351 322 339
528 2 1 0 353 320 336
529 2 1 0 346 348 190
530 2 1 0 349 333 337
531 2 1 0 341 349 329
532 2 1 0 163 350 336
533 2 1 0 352 342 336
534 2 1 0 348 346 351
535 2 1 0 326 351 347
536 2 1 0 330 342 352
537 2 1 0 344 352 350
538 2 1 0 353 326 335
539 2 1 0 348 353 336
$EndElements

BIN
data/sample_DeltaT.nc Normal file

Binary file not shown.

146
data/sample_tet.msh Normal file
View File

@ -0,0 +1,146 @@
$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
1
3 1 "cube"
$EndPhysicalNames
$Nodes
41
1 0 0 0
2 1 0 0
3 1 1 0
4 0 1 0
5 0 1 1
6 0 0 1
7 1 0 1
8 1 1 1
9 0.499999999998694 0 0
10 1 0.499999999998694 0
11 0.5000000000020591 1 0
12 0 0.5000000000020591 0
13 0 0.5000000000020591 1
14 0.499999999998694 0 1
15 1 0.499999999998694 1
16 0.5000000000020591 1 1
17 0 1 0.499999999998694
18 0 0 0.499999999998694
19 1 0 0.499999999998694
20 1 1 0.499999999998694
21 0.5000000000001412 0.5000000000001882 0
22 0.2500000000010295 0.7500000000010295 0
23 0.7500000000005501 0.7499999999997204 0
24 0.7499999999997088 0.2499999999997206 0
25 0.2499999999997088 0.2500000000005618 0
26 0 0.6470588231134449 0.2794117661033739
27 0 0.4852941155641359 0.6470588305188285
28 0 0.2500000000010296 0.249999999999347
29 0.5000000000000239 0 0.2857142860029753
30 0.4999999999997863 0 0.7142857143333939
31 1 0.5000000000000239 0.2857142860029753
32 1 0.4999999999997863 0.7142857143333939
33 0.7500000000010296 1 0.249999999999347
34 0.6427777777785997 1 0.6452267573690922
35 0.3566666666674795 1 0.3713605442171652
36 0.2500000000010296 1 0.749999999999347
37 0.5 0.4999999999999999 1
38 0.2500000000008419 0.7500000000008418 1
39 0.7500000000010295 0.7499999999993469 1
40 0.7499999999993471 0.249999999999347 1
41 0.2499999999996735 0.2500000000005148 1
$EndNodes
$Elements
92
1 4 2 1 1 21 35 37 34
2 4 2 1 1 34 37 21 31
3 4 2 1 1 21 35 27 37
4 4 2 1 1 31 37 21 29
5 4 2 1 1 34 32 37 31
6 4 2 1 1 37 27 21 29
7 4 2 1 1 32 30 37 31
8 4 2 1 1 31 30 37 29
9 4 2 1 1 21 35 26 27
10 4 2 1 1 27 37 30 29
11 4 2 1 1 22 21 35 26
12 4 2 1 1 24 31 21 29
13 4 2 1 1 37 41 27 30
14 4 2 1 1 30 37 40 32
15 4 2 1 1 39 32 37 34
16 4 2 1 1 32 30 31 19
17 4 2 1 1 29 31 30 19
18 4 2 1 1 26 35 17 36
19 4 2 1 1 30 18 28 29
20 4 2 1 1 30 28 27 29
21 4 2 1 1 11 33 35 23
22 4 2 1 1 27 18 28 30
23 4 2 1 1 34 31 33 20
24 4 2 1 1 29 24 31 19
25 4 2 1 1 16 38 36 34
26 4 2 1 1 11 21 35 22
27 4 2 1 1 11 21 23 35
28 4 2 1 1 37 16 34 38
29 4 2 1 1 36 26 35 27
30 4 2 1 1 36 17 26 27
31 4 2 1 1 21 12 26 22
32 4 2 1 1 12 21 26 25
33 4 2 1 1 18 27 41 30
34 4 2 1 1 40 30 32 19
35 4 2 1 1 12 28 25 26
36 4 2 1 1 31 34 32 20
37 4 2 1 1 16 37 34 39
38 4 2 1 1 38 5 36 27
39 4 2 1 1 31 33 3 23
40 4 2 1 1 19 24 31 2
41 4 2 1 1 19 29 24 2
42 4 2 1 1 4 22 35 26
43 4 2 1 1 27 38 13 37
44 4 2 1 1 41 27 13 37
45 4 2 1 1 41 6 18 30
46 4 2 1 1 28 1 25 29
47 4 2 1 1 27 6 18 41
48 4 2 1 1 39 32 34 20
49 4 2 1 1 21 9 24 29
50 4 2 1 1 21 9 29 25
51 4 2 1 1 23 31 21 10
52 4 2 1 1 10 31 21 24
53 4 2 1 1 14 41 37 30
54 4 2 1 1 31 33 20 3
55 4 2 1 1 5 38 13 27
56 4 2 1 1 17 36 5 27
57 4 2 1 1 22 4 35 11
58 4 2 1 1 7 40 32 19
59 4 2 1 1 30 40 7 19
60 4 2 1 1 32 39 8 20
61 4 2 1 1 18 1 28 29
62 4 2 1 1 34 8 39 20
63 4 2 1 1 13 6 27 41
64 4 2 1 1 23 3 31 10
65 4 2 1 1 24 10 31 2
66 4 2 1 1 9 24 29 2
67 4 2 1 1 25 1 9 29
68 4 2 1 1 35 17 4 26
69 4 2 1 1 41 14 6 30
70 4 2 1 1 12 22 4 26
71 4 2 1 1 40 39 32 37
72 4 2 1 1 37 40 14 30
73 4 2 1 1 39 40 32 15
74 4 2 1 1 11 3 33 23
75 4 2 1 1 30 40 14 7
76 4 2 1 1 39 15 32 8
77 4 2 1 1 7 32 40 15
78 4 2 1 1 36 5 38 16
79 4 2 1 1 28 25 1 12
80 4 2 1 1 39 16 8 34
81 4 2 1 1 38 34 35 36
82 4 2 1 1 35 34 38 37
83 4 2 1 1 35 27 38 36
84 4 2 1 1 38 27 35 37
85 4 2 1 1 25 26 27 21
86 4 2 1 1 27 26 25 28
87 4 2 1 1 27 29 25 21
88 4 2 1 1 25 29 27 28
89 4 2 1 1 23 31 34 21
90 4 2 1 1 34 31 23 33
91 4 2 1 1 34 35 23 21
92 4 2 1 1 23 35 34 33
$EndElements

4
data/table_sample.txt Normal file
View File

@ -0,0 +1,4 @@
# name age gender weight
ZhangYi 23 Man 78.2
WangSaiXin 21 Woman 55.0
Little 12 Unknown 45.1

44
data/tess/tess.geo Normal file
View File

@ -0,0 +1,44 @@
//this file is created by Tesseroid_creater
//longitude: 40-50
//latitude: 30-40
//radius: 800-1000
lc = 1.0;
Point(1) = {0, 0, 0, lc};
Point(2) = {530.7311585351508, 445.3363193811355, 399.9999999999999, lc*10.69599819922607};
Point(3) = {0, 0, 399.9999999999999, lc*10.69599819922607};
Point(4) = {445.3363193811358, 530.7311585351506, 399.9999999999999, lc*10.69599819922607};
Point(5) = {663.4139481689385, 556.6703992264194, 499.9999999999999, lc*10.69599819922607};
Point(6) = {0, 0, 499.9999999999999, lc*10.69599819922607};
Point(7) = {556.6703992264197, 663.4139481689382, 499.9999999999999, lc*10.69599819922607};
Point(8) = {469.4592710667722, 393.9231012048832, 514.2300877492315, lc*10.69599819922607};
Point(9) = {0, 0, 514.2300877492315, lc*10.69599819922607};
Point(10) = {393.9231012048835, 469.459271066772, 514.2300877492315, lc*10.69599819922607};
Point(11) = {586.8240888334652, 492.403876506104, 642.7876096865393, lc*10.69599819922607};
Point(12) = {0, 0, 642.7876096865393, lc*10.69599819922607};
Point(13) = {492.4038765061043, 586.824088833465, 642.7876096865393, lc*10.69599819922607};
Circle(1) = {13, 12, 11};
Circle(2) = {10, 9, 8};
Circle(3) = {7, 6, 5};
Circle(4) = {4, 3, 2};
Circle(5) = {8, 1, 2};
Circle(6) = {11, 1, 5};
Circle(7) = {10, 1, 4};
Circle(8) = {13, 1, 7};
Line(9) = {5, 2};
Line(10) = {7, 4};
Line(11) = {11, 8};
Line(12) = {13, 10};
Line Loop(13) = {1, 6, -3, -8};
Ruled Surface(14) = {13};
Line Loop(15) = {2, 5, -4, -7};
Ruled Surface(16) = {15};
Line Loop(17) = {1, 11, -2, -12};
Ruled Surface(18) = {17};
Line Loop(19) = {3, 9, -4, -10};
Ruled Surface(20) = {19};
Line Loop(21) = {6, 9, -5, -11};
Plane Surface(22) = {21};
Line Loop(23) = {8, 10, -7, -12};
Plane Surface(24) = {23};
Surface Loop(25) = {24, 18, 14, 22, 16, 20};
Volume(26) = {25};

5461
data/tess/tess.msh Normal file

File diff suppressed because it is too large Load Diff

BIN
data/tess/tess_gravity.nc Normal file

Binary file not shown.

8766
data/tess/tess_sorted.msh Normal file

File diff suppressed because it is too large Load Diff

8766
data/tess/tmp.msh Normal file

File diff suppressed because it is too large Load Diff

103
examples/array_ex.cpp Normal file
View File

@ -0,0 +1,103 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/io.h"
int main(int argc, char const *argv[])
{
try
{
// create a new array and give initial values
gctl::array<double> A;
gctl::linespace(1.1, 2.9, 10, A);
// show values
std::cout << "A = " << std::endl;
for (int i = 0; i < A.size(); i++)
{
std::cout << A[i] << std::endl;
}
// copy A to a new array
gctl::array<double> B = A;
gctl::normalize(B);
B.show();
gctl::array<double> S = A;
std::cout << "B + A = " << std::endl;
for (int i = 0; i < S.size(); i++)
{
S[i] += B[i];
}
S.show();
gctl::normalize(S);
S.show();
// create a new 2D array
gctl::matrix<int> C(5, 5, 1);
std::cout << "C = " << std::endl;
for (int i = 0; i < C.row_size(); i++)
{
for (int j = 0; j < C.col_size(); j++)
{
C[i][j] += i*10 + j;
std::cout << C.at(i,j) << " ";
}
std::cout << std::endl;
}
// access row elements
std::cout << "C[3][:] = " << std::endl;
for (int i = 0; i < C.col_size(); i++)
{
std::cout << C.get(3)[i] << " ";
}
std::cout << std::endl;
// save array to a binary file
gctl::save_matrix2binary("data/out/array_ex_out", C, "Int");
// import 2D array to a new object
gctl::matrix<int> D;
gctl::read_binary2matrix("data/out/array_ex_out", D);
std::cout << "D = " << std::endl;
for (int i = 0; i < D.row_size(); i++)
{
for (int j = 0; j < D.col_size(); j++)
{
std::cout << D[i][j] << " ";
}
std::cout << std::endl;
}
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

67
examples/basic_io_ex.cpp Normal file
View File

@ -0,0 +1,67 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "cmath"
using namespace gctl;
typedef std::vector<std::vector<double> > _2d_vector;
int main(int argc, char const *argv[])
{
_2d_vector input_table2;
try
{
gctl::text_descriptor desc;
gctl::read_text2vector2d("data/point_height.txt", input_table2, desc);
for (int i = 0; i < input_table2.size(); i++)
{
for (int j = 0; j < input_table2.at(i).size(); j++)
{
if (std::isnan(input_table2.at(i).at(j)))
{
std::cout << input_table2.at(i).at(j) << " is nan";
}
else if (std::isinf(input_table2.at(i).at(j)))
{
std::cout << input_table2.at(i).at(j) << " is inf";
}
else std::cout << input_table2.at(i).at(j) << " ";
}
std::cout << std::endl;
}
}
catch (const char* err_str)
{
GCTL_ShowWhatError(err_str, GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,55 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/geometry.h"
#include "gctl/io.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
array<vertex2dc> nodes;
array<triangle2d> eles;
gmshio fio;
fio.init_file("data/sample", Input);
fio.set_packed(NotPacked, Input);
fio.read_mesh(eles, nodes);
// 使用一条直线进行切割 我们需要直线上的一个点和直线的方向向量 直线“左侧”的网络将被保留 右侧的网络将被删除
point2dc p1(0.05, -1.0), p2(-0.65, 0.0);
array<vertex2dc> out_nodes;
array<triangle2d> out_eles;
geometry2d::cut_triangular_mesh_2d(eles, p1, p2, out_nodes, out_eles);
fio.init_file("data/out/sample_out", Output);
fio.set_packed(NotPacked, Output);
fio.save_mesh(out_eles, out_nodes);
return 0;
}

View File

@ -0,0 +1,52 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/geometry.h"
#include "gctl/io.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
array<vertex3dc> nodes;
array<triangle> eles;
gmshio fio;
fio.init_file("data/sample3d", Input);
fio.read_mesh(eles, nodes);
array<vertex3dc> out_nodes;
array<triangle> out_eles;
point3dc nor(0, 0, -1), surf(254, 8240, 150);
geometry3d::cut_triangular_mesh(eles, nor, surf, out_nodes, out_eles);
fio.init_file("data/out/sample3d_out", Output);
fio.save_mesh(out_eles, out_nodes);
return 0;
}

View File

@ -0,0 +1,52 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/io.h"
int main(int argc, char const *argv[])
{
gctl::array<double> o1, o2, o3, o4;
gctl::array<double> in(128, 0.0);
for (int i = 0; i < in.size(); i++)
{
in[i] = sin(25.0*GCTL_Pi*i/360.0 + 0.2);
}
gctl::difference_1d(in, o1, 1.0, 1);
gctl::difference_1d(in, o2, 1.0, 2);
gctl::difference_1d(in, o3, 1.0, 3);
gctl::difference_1d(in, o4, 1.0, 4);
std::vector<std::string> head_info(1);
head_info[0] = "ori o1 o2 o3 o4";
gctl::save_arrays2text("data/out/difference_1d.txt", ' ', '#',
&head_info, nullptr, in, o1, o2, o3, o4);
return 0;
}

View File

@ -0,0 +1,84 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/io.h"
int main(int argc, char const *argv[])
{
gctl::matrix<double> diff;
gctl::matrix<double> in(128, 128, 0.0);
double dist;
for (int i = 0; i < in.row_size(); i++)
{
for (int j = 0; j < in.col_size(); j++)
{
dist = sqrt((i-25.0)*(i-25.0) + (j-40.0)*(j-40.0));
in[i][j] = cos(25.0*GCTL_Pi*dist/360.0);
}
}
gctl::array<double> out_data(in.row_size()*in.col_size());
for (int i = 0; i < in.row_size(); i++)
{
for (int j = 0; j < in.col_size(); j++)
{
out_data[j + i*in.col_size()] = in[in.row_size()-1-i][j];
}
}
gctl::save_netcdf_grid("data/out/difference_2d", out_data, in.col_size(), in.row_size(), 0, 1, 0, 1, "x", "y", "z");
for (int d = 0; d < 4; d++)
{
gctl::difference_2d(in, diff, 1.0, gctl::Dx, d+1);
for (int i = 0; i < in.row_size(); i++)
{
for (int j = 0; j < in.col_size(); j++)
{
out_data[j + i*in.col_size()] = diff[in.row_size()-1-i][j];
}
}
gctl::append_netcdf_grid("data/out/difference_2d", out_data, "x", "y", "dx_"+std::to_string(d+1));
}
for (int d = 0; d < 4; d++)
{
gctl::difference_2d(in, diff, 1.0, gctl::Dy, d+1);
for (int i = 0; i < in.row_size(); i++)
{
for (int j = 0; j < in.col_size(); j++)
{
out_data[j + i*in.col_size()] = diff[in.row_size()-1-i][j];
}
}
gctl::append_netcdf_grid("data/out/difference_2d", out_data, "x", "y", "dy_"+std::to_string(d+1));
}
return 0;
}

49
examples/drtp_ex.cpp Normal file
View File

@ -0,0 +1,49 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
#include "iostream"
int main(int argc, char const *argv[])
{
try
{
gctl::gm_regular_grid mag_rg;
mag_rg.load_netcdf_grid("../data/emag2_cut", gctl::NodeData,
"longitude", "latitude");
mag_rg.drtp("delta_t", "inclination", "declination", "drtp", 3);
mag_rg.save_netcdf_grid("../data/emag2_DRTP", gctl::NodeData);
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,81 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
int main(int argc, char const *argv[])
{
gctl::array<double> all_data(1000);
gctl::random(all_data, 0.0, 2.0);
// 计算均值和方差
double mean = 0, stddev = 0;
for (int i = 0; i < all_data.size(); i++)
{
mean += all_data[i];
}
mean /= all_data.size();
for (int i = 0; i < all_data.size(); i++)
{
stddev += pow(all_data[i] - mean, 2.0);
}
stddev = sqrt(stddev/all_data.size());
std::cout << "mean = " << mean << ", stddev = " << stddev << std::endl;
// 计算前900个的均值和方差 然后动态计算最后100次
mean = 0;
stddev = 0;
for (int i = 0; i < 900; i++)
{
mean += all_data[i];
}
mean /= 900;
for (int i = 0; i < 900; i++)
{
stddev += pow(all_data[i] - mean, 2.0);
}
stddev = sqrt(stddev/900);
std::cout << "mean = " << mean << ", stddev = " << stddev << std::endl;
double new_mean;
int count = 900;
for (int i = 0; i < 100; i++)
{
stddev = gctl::dynamic_stddev(stddev, count, mean, all_data[900 + i], new_mean);
mean = new_mean;
std::cout << i << " mean = " << mean << ", stddev = " << stddev << std::endl;
count++;
}
return 0;
}

View File

@ -0,0 +1,45 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
int main(int argc, char const *argv[])
{
gctl::ellipse_filter_para self_para =
{500, 500, 100, 0, 1, 0.5, 1.0, 0.1};
for (double i = 0; i <= 1000.0; i += 10.0)
{
for (double j = 0; j <= 1000.0; j += 10.0)
{
std::cout << i << " " << j << " "
<< ellipse_filter(i, j, self_para) << std::endl;
}
}
return 0;
}

56
examples/entity_ex.cpp Normal file
View File

@ -0,0 +1,56 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/geometry.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
array<vertex3dc> v(8);
v[0].set(point3dc(0,0,0), 1);
v[1].set(point3dc(10,0,0),2);
v[2].set(point3dc(10,8,0),3);
v[3].set(point3dc(0,8,0), 4);
v[4].set(point3dc(0,0,6), 5);
v[5].set(point3dc(10,0,6),6);
v[6].set(point3dc(10,8,6),7);
v[7].set(point3dc(0,8,6), 8);
for (int i = 0; i < 8; ++i)
{
std::cout << v[i] << std::endl;
}
edge ee(v[1], v[0], 10);
std::cout << ee << std::endl;
block bk(v, 0, 1, 2, 3, 4, 5, 6, 7, 100);
std::cout << bk << std::endl;
return 0;
}

View File

@ -0,0 +1,57 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "iostream"
int main(int argc, char const *argv[])
{
int a_size = 12;
double *t_array = new double [a_size];
for (int i = 0; i < a_size; i++)
{
t_array[i] = i*1.0;
}
for (int i = 0; i < a_size; i++)
{
std::cout << t_array[i] << " ";
}
std::cout << std::endl;
double target = 0.5;
int l_index;
if (gctl::find_index(t_array, a_size, target, l_index))
{
std::cout << "not found!" << std::endl;
}
else
{
std::cout << "found " << target << " between " << l_index << " and " << l_index+1 << std::endl;
}
return 0;
}

View File

@ -0,0 +1,70 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/utility.h"
int main(int argc, char *argv[])
{
try{
int on_screen = 0;
// 配置命令行参数与相关信息
gctl::flags_parser fp;
fp.set_proname("Test_Pro");
fp.set_proinfo("This is an example of the flags_parser class.");
fp.add_opt('i', "infile", required_argument, NULL, "Input file name.", "<filename>", true);
fp.add_opt('o', "outfile", required_argument, NULL, "Output file name.", "<filename>", true);
fp.add_opt('r', "range", required_argument, NULL, "Griding range.", "<xmin>/<xmax>/<ymin>/<ymax>", false);
fp.add_opt('f', "filter", optional_argument, NULL, "Applying filter. A name may attached to the option", "[filer-name]", false);
fp.add_opt(1, "screen", no_argument, &on_screen, "Show screen.", 0, false); // 不需要特别去拾取 只要触发getopt_long就会自动被识别
fp.add_opt('h', "help", no_argument, NULL, "Show help information.", 0, false);
fp.configure(argc, argv);
if(argc == 1 || fp.set_opt("help"))
{
fp.show_help_page();
return 0;
}
std::string in_name, out_name, range, filter;
fp.get_argv({'i', 'o', 'r', 'f'}, {&in_name, &out_name, &range, &filter});
if (filter == "NO_ARG") filter = "Gaussian";
// 查看是否通过强制参数检查
if (!fp.pass_mandatory()) return 0;
std::cout << in_name << std::endl;
std::cout << out_name << std::endl;
std::cout << range << std::endl;
std::cout << filter << std::endl;
if (on_screen) std::cout << "-s option is set." << std::endl;
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,63 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/io.h"
#include "iostream"
int main(int argc, char const *argv[])
{
try
{
// test for 1D fractal model
gctl::array<double> model_1d;
gctl::fractal_model_1d(model_1d, 250, 0, 0, 200.0, 0.8);
std::ofstream outfile;
gctl::open_outfile(outfile, "data/out/frac_1d", ".txt");
for (int i = 0; i < model_1d.size(); i++)
{
outfile << i+1 << " " << model_1d[i] << std::endl;
}
outfile.close();
// test for 2D fractal model
gctl::matrix<double> model_2d;
gctl::fractal_model_2d(model_2d, 251, 251, 0, 0, 0, 0, 200.0, 0.5);
gctl::save_netcdf_grid("data/out/frac_2d", model_2d, 0.0, 5.0, 0.0, 5.0);
gctl::fractal_model_2d(model_2d, 251, 251, 0, 0, 0, 0, 100.0, 1.0);
gctl::append_netcdf_grid("data/out/frac_2d", model_2d, "x", "y", "z2");
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,84 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/utility.h"
int main(int argc, char const *argv[])
{
gctl::gaussian_para2d p, q;
p.mu_x = 50.0;
p.mu_y = 40.0;
p.sigma_x = 15.0;
p.sigma_y = 10.0;
p.rho = 0.2;
q.mu_x = 60.0;
q.mu_y = 70.0;
q.sigma_x = 10.0;
q.sigma_y = 20.0;
q.rho = 0.0;
int m = 101, n = 101;
gctl::array<double> d(m*n, 0.0);
gctl::array<double> dx(m*n, 0.0);
gctl::array<double> dy(m*n, 0.0);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
d[j + i*m] = gctl::gaussian_dist2d(1.0*j, 1.0*i, p);
dx[j + i*m] = gctl::gaussian_dist2d(1.0*j, 1.0*i, p, gctl::Dx);
dy[j + i*m] = gctl::gaussian_dist2d(1.0*j, 1.0*i, p, gctl::Dy);
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
d[j + i*m] += gctl::gaussian_dist2d(1.0*j, 1.0*i, q);
dx[j + i*m] += gctl::gaussian_dist2d(1.0*j, 1.0*i, q, gctl::Dx);
dy[j + i*m] += gctl::gaussian_dist2d(1.0*j, 1.0*i, q, gctl::Dy);
}
}
std::ofstream outfile;
gctl::open_outfile(outfile, "data/out/gauss_hill", ".txt");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
outfile << j << " " << i << " " << -1.0e+4*d[j + i*m] << " " << -1.0e+4*dx[j + i*m] << " " << -1.0e+4*dy[j + i*m] << std::endl;
}
}
outfile.close();
return 0;
}

View File

@ -0,0 +1,82 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/geometry.h"
int main(int argc, char const *argv[])
{
gctl::point2dc a, b, c, d;
a.set(0.0, 0.0);
b.set(10.0, 0.0);
c.set(5.0, 7.0);
d.set(5.0, 5.0);
if (gctl::geometry2d::node_in_triangle(d, a, b, c))
{
std::cout << "d is in triangle" << std::endl;
}
else std::cout << "d is not in triangle" << std::endl;
d.set(5.0, 7.0);
if (gctl::geometry2d::node_in_triangle(d, a, b, c, false))
{
std::cout << "d is in triangle" << std::endl;
}
else std::cout << "d is not in triangle" << std::endl;
d.set(5.0, 8.0);
if (gctl::geometry2d::node_in_triangle(d, a, b, c))
{
std::cout << "d is in triangle" << std::endl;
}
else std::cout << "d is not in triangle" << std::endl;
std::cout << "---------------------" << std::endl;
gctl::point2dc *c2, *d2;
c2 = new gctl::point2dc;
d2 = new gctl::point2dc;
a.set(0.0, 0.0);
b.set(10.0, 0.0);
c2->set(5.0, 7.0);
d2->set(5.0, 5.0);
gctl::point2dc nor = d2->normal();
std::cout << "nor(d) = (" << nor.x << ", " << nor.y << ")" << std::endl;
gctl::point2dc e = a - b;
std::cout << "a - b = (" << e.x << ", " << e.y << ")" << std::endl;
double dist = gctl::distance(*c2, *d2);
std::cout << "dist(c, d) = " << dist << std::endl;
delete c2;
delete d2;
return 0;
}

79
examples/getoption_ex.cpp Normal file
View File

@ -0,0 +1,79 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/utility.h"
using namespace gctl;
int main(int argc, char const *argv[]) try
{
getoption gopt;
gopt.add_options({"range", "interval", "weight", "model-file", "model-tag", "out-model", "save-model"},
{true, true, true, true, true, true, false});
gopt.set_group(1, {"out-model", "save-model"});
gopt.read_options("option_sample");
gopt.check_mandatory();
gopt.check_group(1);
// 显示所有读入的键值与参数值
gopt.show_options();
// 通过键值获取参数值
std::cout << gopt.get_value("model-file") << std::endl;
// 查找不存在的命令 返回警告信息与默认值NULL
std::cout << gopt.get_value("model-tag") << std::endl;
std::cout << "---------------------" << std::endl;
double weight;
// 通过选项的标签值来获取参数值 需要匹配的字符串只需要包含标签值即可
gctl::str2type(gopt.get_value("weight|Weight"), weight);
std::cout << weight << std::endl;
double xmin, xmax, ymin, ymax;
std::string cover_str;
parse_string_to_value(gopt.get_value("range|Range"), '/', true, xmin, xmax, ymin, ymax, cover_str);
std::cout << xmin << " " << xmax << " " << ymin << " " << ymax << " " << cover_str << std::endl;
std::vector<std::string> tags;
parse_string_to_vector(gopt.get_value("model-tag"), ',', tags);
for (int i = 0; i < tags.size(); i++)
{
std::cout << tags[i] << " ";
}
std::cout << std::endl;
return 0;
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}

56
examples/gmsh_io_ex.cpp Normal file
View File

@ -0,0 +1,56 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/io.h"
#include "iostream"
#include "fstream"
int main(int argc, char const *argv[])
{
try
{
gctl::array<gctl::vertex2dc> mesh_node;
gctl::array<gctl::triangle2d> mesh_triangle;
gctl::array<double> mesh_data;
gctl::gmshio mshio;
mshio.init_file("data/fmm2d/sample_mesh.1", gctl::Input);
mshio.init_file("data/fmm2d/sample_mesh.2", gctl::Output);
mshio.read_data(mesh_data, "Elements' gradient");
mshio.set_packed(gctl::NotPacked, gctl::Input);
mshio.read_mesh(mesh_triangle, mesh_node);
mshio.save_mesh(mesh_triangle, mesh_node);
mshio.save_data("Test Data", mesh_data, gctl::ElemData);
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,49 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/graphic.h"
int main(int argc, char const *argv[])
{
gctl::array<double> data(51*41);
double dist;
for (int i = 0; i < 51; ++i)
{
for (int j = 0; j < 41; ++j)
{
dist = sqrt((j-20)*(j-20) + (i-25)*(i-25));
data[j+i*41] = sin(dist/GCTL_Pi);
}
}
gctl::gmt_JX_single pic;
pic.show_command();
pic.set_command("psconvert", "-A -TG -E300");
pic.plot("data/out/gmt_plot_ex", data, 0, 40, 0, 50, 41, 51);
return 0;
}

View File

@ -0,0 +1,63 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
// set up observation parameters and block parameters
array<point3dc> obes;
gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0),
point3dc(0, 0, 0), point3dc(0, 100, 0), 51, 51, obes);
array<block> model(2);
model[0].set(20, 35, 20, 40, -40, -10);
model[1].set(50, 60, 40, 70, -32, -5);
array<double> rho(2, 1.0);
array<double> g, gx, gy, gz;
gobser(g, model, obes, rho, Vz, ShortMsg);
#ifdef GCTL_NETCDF
gobser(gx, model, obes, rho, Tzx, ShortMsg);
gobser(gy, model, obes, rho, Tzy, ShortMsg);
gobser(gz, model, obes, rho, Tzz, ShortMsg);
save_netcdf_grid("data/block_g", g, 51, 51, 0.0, 2.0, 0.0, 2.0, "x", "y", "g");
append_netcdf_grid("data/block_g", gx, "x", "y", "gx");
append_netcdf_grid("data/block_g", gy, "x", "y", "gy");
append_netcdf_grid("data/block_g", gz, "x", "y", "gz");
#else
save_surfer6_grid("data/block_g", g, 51, 51, 0.0, 2.0*51, 0.0, 2.0*51);
#endif // GCTL_NETCDF
return 0;
}

View File

@ -0,0 +1,58 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
// set up observation parameters and polygon parameters
array<point2dc> obes;
linespace(point2dc(0.0, 0.0), point2dc(200.0, 0.0), 201, obes);
array<vertex2dc> polygon(5);
polygon[0].set(point2dc(80, -50), 0);
polygon[1].set(point2dc(120, -50), 1);
polygon[2].set(point2dc(120, -10), 2);
polygon[3].set(point2dc(100, -30), 3);
polygon[4].set(point2dc(80, -10), 4);
array<double> g, gx, gz;
gobser(g, polygon, obes, 1.0, Vz);
gobser(gx, polygon, obes, 1.0, Tzx);
gobser(gz, polygon, obes, 1.0, Tzz);
for (int i = 0; i < obes.size(); i++)
{
std::cout << obes[i].x << " " << obes[i].y << " " << g[i] << " " << gx[i] << " " << gz[i] << std::endl;
}
return 0;
}

View File

@ -0,0 +1,56 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
// set up observation parameters and block parameters
array<point2dc> obes;
linespace(point2dc(0.0, 0.0), point2dc(200.0, 0.0), 201, obes);
array<rectangle2d> model(2);
model[0].set(60, 80, -30, -10);
model[1].set(110, 120, -80, -20);
array<double> rho(2, 0.5);
rho[1] = 0.6;
array<double> obs_val;
gobser(obs_val, model, obes, rho, Vz, ShortMsg);
for (int i = 0; i < obes.size(); i++)
{
std::cout << obes[i].x << " " << obes[i].y << " " << obs_val[i] << std::endl;
}
return 0;
}

View File

@ -0,0 +1,89 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
int main(int argc, char const *argv[])
{
try
{
// set up observation parameters and block parameters
gctl::array<double> line_node, line_node2;
gctl::linespace(0.0, 150.0, 61, line_node);
gctl::linespace(0.0, 200.0, 101, line_node2);
gctl::array<gctl::point3dc> obes(line_node.size() * line_node2.size());
for (int i = 0; i < line_node2.size(); i++)
{
for (int j = 0; j < line_node.size(); j++)
{
obes[i*line_node.size()+j].x = line_node.at(j);
obes[i*line_node.size()+j].y = line_node2.at(i);
obes[i*line_node.size()+j].z = 0.0;
}
}
gctl::sphere a_body(gctl::point3dc(60, 120, -25), 15);
double rho = 1.0;
a_body.att = &rho;
gctl::array<double> data_g, data_gx, data_gy, data_gz;
gobser_sphere(data_g, obes, a_body, gctl::Vz);
gobser_sphere(data_gx, obes, a_body, gctl::Tzx);
gobser_sphere(data_gy, obes, a_body, gctl::Tzy);
gobser_sphere(data_gz, obes, a_body, gctl::Tzz);
gctl::sphere t_body(gctl::point3dc(80, 100, -25), 10);
rho = 1.2;
t_body.att = &rho;
gobser_sphere(data_g, obes, t_body, gctl::Vz, gctl::AppendVal);
gobser_sphere(data_gx, obes, t_body, gctl::Tzx, gctl::AppendVal);
gobser_sphere(data_gy, obes, t_body, gctl::Tzy, gctl::AppendVal);
gobser_sphere(data_gz, obes, t_body, gctl::Tzz, gctl::AppendVal);
#ifdef GCTL_NETCDF
gctl::save_netcdf_grid("data/sphere_g", data_g, 61, 101, 0.0, 2.5, 0.0, 2.0, "x", "y", "g");
gctl::append_netcdf_grid("data/sphere_g", data_gx, "x", "y", "gx");
gctl::append_netcdf_grid("data/sphere_g", data_gy, "x", "y", "gy");
gctl::append_netcdf_grid("data/sphere_g", data_gz, "x", "y", "gz");
#else
gctl::save_surfer6_grid("data/sphere_g", data_g, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
gctl::save_surfer6_grid("data/sphere_gx", data_gx, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
gctl::save_surfer6_grid("data/sphere_gy", data_gy, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
gctl::save_surfer6_grid("data/sphere_gz", data_gz, 61, 101, 0.0, 2.5*60, 0.0, 2.0*100, NAN, NAN, gctl::Surfer6Binary);
#endif // GCTL_NETCDF
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,77 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
int main(int argc, char const *argv[])
{
try
{
// set up observation parameters and block parameters
gctl::array<double> line_node;
gctl::linespace(-25.0, 25.0, 201, line_node);
gctl::array<gctl::point3ds> obes(line_node.size() * line_node.size());
for (int i = 0; i < line_node.size(); i++)
{
for (int j = 0; j < line_node.size(); j++)
{
obes[i*line_node.size()+j].lon = line_node.at(j);
obes[i*line_node.size()+j].lat = line_node.at(i);
obes[i*line_node.size()+j].rad = GCTL_Earth_Radius + 100000.0;
}
}
gctl::array<gctl::tesseroid> tesses(1);
tesses[0].set(GCTL_Earth_Radius - 10000.0, GCTL_Earth_Radius - 1000.0, -2, 2, -2, 2);
gctl::array<double> rho(1, 1.0);
gctl::array<double> data;
#ifdef GCTL_NETCDF
gctl::gobser(data, tesses, obes, rho, gctl::Vz, gctl::ShortMsg);
gctl::save_netcdf_grid("data/tesseroid_gr", data, 201, 201, -25.0, 0.25, -25.0, 0.25, "x", "y", "Vr");
gctl::gobser(data, tesses, obes, rho, gctl::Tzx, gctl::ShortMsg);
gctl::append_netcdf_grid("data/tesseroid_gr", data, "x", "y", "Vrp");
gctl::gobser(data, tesses, obes, rho, gctl::Tzy, gctl::ShortMsg);
gctl::append_netcdf_grid("data/tesseroid_gr", data, "x", "y", "Vrt");
#else
gctl::gobser(data, tesses, obes, rho, gctl::Tr, gctl::ShortMsg);
gctl::save_surfer6_grid("data/tesseroid_gr", data, 201, 201, -25.0, 25.0, -25.0, 25.0, NAN, NAN, gctl::Surfer6Binary);
#endif // GCTL_NETCDF
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,80 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
try
{
// set up observation points
array<point3dc> obes;
gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0), point3dc(0, 0, 0), point3dc(0, 100, 0), 41, 41, obes);
// set up model element
array<grav_tetrahedron> onetetra(1);
array<gravtet_para> tet_gp;
onetetra[0].set(point3dc(20, 50, -30), point3dc(80, 20, -10), point3dc(50, 80, -15), point3dc(50, 50, -50), 0);
callink_gravity_para(onetetra, tet_gp);
array<double> rho(1, 1.0);
array<tensor> data_grad;
gobser(data_grad, onetetra, obes, rho);
array<double> data(data_grad.size());
for (int i = 0; i < data_grad.size(); ++i)
{
data[i] = data_grad[i].at(2,2) * 1e+4;
}
#ifdef GCTL_NETCDF
save_netcdf_grid("data/tetra_g", data, 41, 41, 0.0, 2.5, 0.0, 2.5);
gmshio fio;
fio.init_file("data/tetra_g", Output);
fio.set_packed(NotPacked, Output);
fio.save_mesh(onetetra);
#else
save_surfer6_grid("data/tetra_g", data, 41, 41, 0.0, 2.5*41, 0.0, 2.5*41, NAN, NAN, Surfer6Binary);
gmshio fio;
fio.init_file("data/tetra_g", Output);
fio.set_packed(NotPacked, Output);
fio.save_mesh(onetetra);
#endif // GCTL_NETCDF
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,58 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
// set up observation parameters and block parameters
array<point3ds> obes;
gridspace(point3ds(5e+3, 30, 0), point3ds(5e+3, 50, 0),
point3ds(5e+3, 0, 20), point3ds(5e+3, 0, 40), 81, 81, obes);
array<grav_tetrahedron> onetetra(1);
array<gravtet_para> tet_gp(1);
onetetra[0].set(point3ds(9900.0, 35.0, 25.0), point3ds(9900.0, 45.0, 30.0),
point3ds(9900.0, 40.0, 35.0), point3ds(9800.0, 40.0, 30.0));
callink_gravity_para(onetetra, tet_gp);
// set up observation array
array<double> rho(1, 1.0);
array<point3dc> obsval;
gobser(obsval, onetetra, obes, rho);
array<double> out_data(obsval.size());
for (int i = 0; i < obsval.size(); ++i)
{
out_data[i] = obsval[i].x; // 球坐标下矢量第一个分量为径向分量
}
save_netcdf_grid("data/tetra_gr_sph", out_data, 81, 81, 30.0, 0.25, 20.0, 0.25, "longitude", "latitude", "gr");
return 0;
}

View File

@ -0,0 +1,75 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
try
{
int obs_num = 101;
// set up observation points
array<point2dc> obs_loc;
linespace(point2dc(0.0, 0.0), point2dc(200.0, 0.0), obs_num, obs_loc);
// set nodes locations
array<vertex2dc> node_vert(3);
node_vert[0].set(point2dc(80.0, -30.0));
node_vert[1].set(point2dc(105.0, -60.0));
node_vert[2].set(point2dc(106.0, -10.0));
// set triangular elements
array<double> rho(2, 1.0);
array<triangle2d> tri(2);
// anti-clock wise
tri[0].set(node_vert[0], node_vert[1], node_vert[2]); // set triangle's vertex from existing vertex
tri[1].set(point2dc(135.0, -5.0), point2dc(141.0, -40.0), point2dc(145.0, -15.0)); // set triangle's vertex from parameters
// forward modeling
array<double> g(obs_num);
array<double> gx(obs_num);
array<double> gz(obs_num);
gobser(g, tri, obs_loc, rho, gctl::Vz);
gobser(gx, tri, obs_loc, rho, gctl::Tzx);
gobser(gz, tri, obs_loc, rho, gctl::Tzz);
for (int i = 0; i < obs_num; ++i)
{
std::cout << obs_loc[i] << " " << g[i] << " " << gx[i] << " " << gz[i] << std::endl;
}
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

139
examples/gobser_tri_ex.cpp Normal file
View File

@ -0,0 +1,139 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
try
{
// set up observation points
array<point3dc> obes;
gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0), point3dc(0, 0, 0), point3dc(0, 100, 0), 41, 41, obes);
gmshio fio("data/cube/cube_sorted", Input);
array<vertex3dc> nodes;
array<grav_triangle> eles;
fio.read_mesh(eles, nodes);
array<gravtri_para> gpara(eles.size());
callink_gravity_para(eles, gpara);
array<double> out_data;
array<point3dc> out_grad;
array<tensor> out_tens;
gobser(out_data, eles, obes, 1.0, ShortMsg);
save_netcdf_grid("data/cube/cube_gravity", out_data, 41, 41, 0.0, 2.5, 0.0, 2.5, "easting", "northing", "potential");
gobser(out_grad, eles, obes, 1.0, ShortMsg);
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].x;
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "gravity_x");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].y;
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "gravity_y");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].z;
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "gravity_z");
gobser(out_tens, eles, obes, 1.0, ShortMsg);
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 0);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_xx");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 1);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_xy");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 2);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_xz");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 0);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_yx");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 1);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_yy");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 2);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_yz");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 0);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_zx");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 1);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_zy");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 2);
}
append_netcdf_grid("data/cube/cube_gravity", out_data, "easting", "northing", "tensor_zz");
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,140 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
try
{
// set up observation points
array<point3ds> obes;
gridspace(point3ds(550, 20, 0), point3ds(550, 70, 0),
point3ds(550, 0, 10), point3ds(550, 0, 60), 101, 101, obes);
gmshio fio("data/tess/tess_sorted", Input);
array<vertex3dc> nodes;
array<grav_triangle> eles;
fio.read_mesh(eles, nodes);
array<gravtri_para> gpara(eles.size());
callink_gravity_para(eles, gpara);
array<double> out_data;
array<point3dc> out_grad;
array<tensor> out_tens;
gobser(out_data, eles, obes, 1.0, ShortMsg);
save_netcdf_grid("data/tess/tess_gravity", out_data, 101, 101, 20.0, 0.5, 10.0, 0.5, "easting", "northing", "potential");
gobser(out_grad, eles, obes, 1.0, ShortMsg);
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].x;
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "gravity_r");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].y;
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "gravity_t");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_grad[i].z;
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "gravity_p");
gobser(out_tens, eles, obes, 1.0, ShortMsg);
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 0);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_rr");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 1);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_rt");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(0, 2);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_rp");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 0);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_tr");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 1);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_tt");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(1, 2);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_tp");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 0);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_pr");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 1);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_pt");
for (int i = 0; i < obes.size(); ++i)
{
out_data[i] = out_tens[i].at(2, 2);
}
append_netcdf_grid("data/tess/tess_gravity", out_data, "easting", "northing", "tensor_pp");
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

View File

@ -0,0 +1,139 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
#include "iostream"
int main(int argc, char *argv[])
{
gctl::array<gctl::vertex3dc> msh_vert;
gctl::array<gctl::grav_tri_cone> msh_cone;
gctl::array<gctl::gravcone_para> cone_para;
// read element from Gmsh file
std::ifstream infile;
gctl::open_infile(infile, "data/gobser_tricone/template", ".msh");
gctl::read_gmsh_node(infile, msh_vert, gctl::Packed);
gctl::read_gmsh_element(infile, msh_cone, msh_vert, gctl::Packed, nullptr);
infile.close();
// set origin for the cone
gctl::vertex3dc ori_vert(gctl::point3dc(0.0, 0.0, 0.0), msh_vert.size());
// create grav_tri_cone
for (int i = 0; i < msh_cone.size(); i++)
{
msh_cone[i].set_origin(ori_vert);
}
//initialize the tensors
gctl::callink_gravity_para(msh_cone, cone_para);
// read topography data
gctl::_2d_vector txt_content;
gctl::array<gctl::point3ds> topo_sph;
gctl::text_descriptor desc;
gctl::read_text2vector2d("data/gobser_tricone/topo.txt", txt_content, desc);
topo_sph.resize(txt_content.size());
for (int i = 0; i < txt_content.size(); i++)
{
topo_sph[i].rad = 1e+5 + txt_content[i][2];
topo_sph[i].lon = txt_content[i][0];
topo_sph[i].lat = txt_content[i][1];
}
// initiate observation points
double xmin = 30, xmax = 50, dx = 0.25;
double ymin = 30, ymax = 50, dy = 0.25;
int xnum = round((xmax - xmin)/dx) + 1;
int ynum = round((ymax - ymin)/dy) + 1;
gctl::array<gctl::point3ds> obs_ps(xnum*ynum);
for (int j = 0; j < ynum; j++)
{
for (int i = 0; i < xnum; i++)
{
obs_ps[i + j*xnum].rad = 1e+5 + 200.0;
obs_ps[i + j*xnum].lon = xmin + i*dx;
obs_ps[i + j*xnum].lat = ymin + j*dy;
}
}
// calculate base gravity
gctl::array<double> out_obs;
gctl::array<double> rho(msh_cone.size(), 1.0);
gctl::gobser(out_obs, msh_cone, obs_ps, rho, gctl::Vz);
// interpolate topography
int m, n;
double colat1, colat2, lon1, lon2;
gctl::point3ds tmp_p;
gctl::point3dc tmp_c;
gctl::array<double> out_topo(msh_vert.size());
for (int i = 0; i < msh_vert.size(); i++)
{
tmp_p = msh_vert[i].c2s();
m = floor(tmp_p.lon - 28.0)/0.5;
n = floor(tmp_p.lat - 28.0)/0.5;
colat1 = 90.0 - (28.0 + n*0.5);
colat2 = 90.0 - (28.0 + (n+1)*0.5);
lon1 = 28.0 + m*0.5;
lon2 = 28.0 + (m+1)*0.5;
tmp_p.rad = gctl::sph_linear_interpolate_deg(colat1, colat2, lon1, lon2,
90.0-tmp_p.lat, tmp_p.lon,
topo_sph[m + 49*n].rad,
topo_sph[m + 1 + 49*n].rad,
topo_sph[m + 49*(n+1)].rad,
topo_sph[m + 1 + 49*(n+1)].rad);
out_topo[i] = tmp_p.rad - 1e+5;
tmp_c = tmp_p.s2c();
msh_vert[i].set(tmp_c);
}
// recalculate tensors
gctl::callink_gravity_para(msh_cone, cone_para);
gctl::array<double> out_obs2;
gctl::gobser(out_obs2, msh_cone, obs_ps, rho, gctl::Vz);
for (int i = 0; i < out_obs.size(); i++)
{
out_obs2[i] -= out_obs[i];
}
for (int i = 0; i < out_obs.size(); i++)
{
std::cout << obs_ps[i].lon << " " << obs_ps[i].lat << " " << out_obs2[i] << std::endl;
}
return 0;
}

View File

@ -0,0 +1,58 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
#include "iostream"
int main(int argc, char const *argv[])
{
try
{
gctl::gm_regular_grid grav_rg;
#ifdef GCTL_NETCDF
grav_rg.load_netcdf_grid("data/sphere_g", gctl::NodeData,
"x", "y");
grav_rg.gradient("g", "gx2", gctl::Tzx, 1);
grav_rg.gradient("g", "gy2", gctl::Tzy, 1);
grav_rg.gradient("g", "gz2", gctl::Tzz, 1);
grav_rg.conti("g", "g2", -50);
grav_rg.save_netcdf_grid("data/sphere_g2", gctl::NodeData);
#else
grav_rg.load_surfer_grid("data/sphere_g", "g", gctl::NodeData, gctl::Surfer6Binary);
grav_rg.gradient("g", "gx", gctl::Tzx, 1);
grav_rg.save_surfer_grid("data/sphere_gx_out", "gx", gctl::Surfer6Binary);
#endif // GCTL_NETCDF
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

82
examples/griding_ex.cpp Normal file
View File

@ -0,0 +1,82 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/mesh.h"
#include "vector"
int main(int argc, char const *argv[])
{
try
{
// read topography data
gctl::_2d_vector xyz_content;
gctl::text_descriptor desc;
gctl::read_text2vector2d("data/random_topo.xyz", xyz_content, desc);
// convert to 2D points and values
gctl::array<gctl::point2dc> topo_posi(xyz_content.size());
gctl::array<double> topo_val(xyz_content.size());
for (int i = 0; i < xyz_content.size(); i++)
{
topo_posi[i].x = xyz_content.at(i).at(0);
topo_posi[i].y = xyz_content.at(i).at(1);
topo_val[i] = xyz_content.at(i).at(2);
}
// destroy vector
gctl::destroy_vector(xyz_content);
// griding
double s_xlen = 15, s_ylen = 20;
gctl::regular_grid topo_grid("Topography", "null", 101, 101, 0, 0, 10, 10);
topo_grid.load_data_cloud(topo_posi, topo_val, 15, 20, 0, "random_topo", gctl::ElemData);
topo_grid.load_data_cloud(topo_posi, topo_val, 25, 25, 0, "random_topo_node", gctl::NodeData);
topo_grid.gradient("random_topo", "random_topo_dx", gctl::Dx);
topo_grid.gradient("random_topo", "random_topo_dx2", gctl::Dx, 2);
topo_grid.gradient("random_topo_node", "random_topo_node_dx", gctl::Dx);
topo_grid.gradient("random_topo_node", "random_topo_node_dy", gctl::Dy);
topo_grid.save_gmsh("../data/random_topo_out", gctl::ElemData, gctl::OverWrite, gctl::NotPacked);
topo_grid.save_gmsh("../data/random_topo_out", gctl::NodeData, gctl::Append, gctl::NotPacked);
gctl::point2dc sp(20, 20), ep(980, 960);
gctl::array<gctl::point2dc> profile_posi;
gctl::array<double> profile_val;
topo_grid.extract_profile("random_topo", sp, ep, 201, profile_posi, profile_val);
std::vector<std::string> head_info(1);
head_info[0] = "x,y,data";
gctl::save_arrays2text("../data/random_topo_profile.csv", ',', '#', &head_info, nullptr, profile_posi, profile_val);
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

85
examples/heap_sort_ex.cpp Normal file
View File

@ -0,0 +1,85 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "gctl/geometry.h"
#include "gctl/utility.h"
#include "iostream"
int main(int argc, char const *argv[])
{
// declare a sort operator for double
gctl::heap_sort<double> double_sorter;
// test double_sorter
int a_size = 10;
double *A = new double [a_size];
for (int i = 0; i < 10; i++)
{
A[i] = i + 1.0;
std::cout << A[i] << " ";
}
std::cout << std::endl;
// sort as a descending array
double_sorter.execute(A, a_size, [](double *a, int l_id, int r_id)->bool{
if (a[l_id] > a[r_id]) return true;
else return false;
});
for (int i = 0; i < 10; i++)
std::cout << A[i] << " ";
std::cout << std::endl;
delete[] A;
// declare a sort operator for point3dc
gctl::heap_sort<gctl::point3dc> p3d_sorter;
gctl::array<gctl::point3dc> line_ps;
gctl::linespace(gctl::point3dc(10,11,12), gctl::point3dc(0,0,0), 11, line_ps);
for (int i = 0; i < line_ps.size(); i++)
{
std::cout << line_ps.at(i).x << " " << line_ps.at(i).y << " " << line_ps.at(i).z << std::endl;
}
// sort as an ascending array according y values
p3d_sorter.execute(line_ps, [](gctl::array<gctl::point3dc> &a, int l_id, int r_id)->bool
{
if (a[l_id].y < a[r_id].y) return true;
else return false;
});
for (int i = 0; i < line_ps.size(); i++)
{
std::cout << line_ps.at(i).x << " " << line_ps.at(i).y << " " << line_ps.at(i).z << std::endl;
}
return 0;
}

104
examples/mat_inverse_ex.cpp Normal file
View File

@ -0,0 +1,104 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "iostream"
int main(int argc, char const *argv[])
{
int n_size = 5;
gctl::matrix<double> B;
// A=[10,1,2,0,1;
//2,20,1,0,1;
//1,3,30,2,0;
//2,3,0,40,1;
//5,6,1,0,50]
/*
gctl::array2d<double> A(n_size, n_size, 0.0);
A[0][0] = 10.0; A[0][1] = 1.0; A[0][2] = 2.0; A[0][3] = 0.0; A[0][4] = 1.0;
A[1][0] = 2.0; A[1][1] = 20.0; A[1][2] = 1.0; A[1][3] = 0.0; A[1][4] = 1.0;
A[2][0] = 1.0; A[2][1] = 3.0; A[2][2] = 30.0; A[2][3] = 2.0; A[2][4] = 0.0;
A[3][0] = 2.0; A[3][1] = 3.0; A[3][2] = 0.0; A[3][3] = 40.0; A[3][4] = 1.0;
A[4][0] = 5.0; A[4][1] = 6.0; A[4][2] = 1.0; A[4][3] = 0.0; A[4][4] = 50.0;
*/
gctl::spmat<double> A(n_size, n_size, 0.0);
A.insert(0, 0, 10.0);
A.insert(1, 1, 20.0);
A.insert(2, 2, 30.0);
A.insert(3, 3, 40.0);
A.insert(4, 4, 10.0);
A.insert(0, 3, 1.0);
A.insert(1, 2, 2.0);
A.insert(2, 4, 5.0);
A.insert(3, 0, 3.0);
A.insert(4, 1, 4.0);
std::cout << "epsilon = " << gctl::newton_inverse(A, B, 1e-12) << std::endl;
std::cout << "A = " << std::endl;
A.show_matrix();
std::cout << "A^-1 = " << std::endl;
for (int i = 0; i < n_size; i++)
{
for (int j = 0; j < n_size; j++)
{
std::cout << B[i][j] << " ";
}
std::cout << std::endl;
}
double ele;
std::cout << "A * A^-1 = " << std::endl;
gctl::array<double> tmp_arr(n_size);
for (int i = 0; i < n_size; i++)
{
for (int j = 0; j < n_size; j++)
{
//ele = 0.0;
//for (int k = 0; k < n_size; k++)
//{
// ele += A[i][k] * B[k][j];
//}
for (int k = 0; k < n_size; k++)
{
tmp_arr[k] = B[k][j];
}
ele = A.multiply_vector(tmp_arr, i);
if (fabs(ele) < 1e-12)
ele = 0.0;
std::cout << ele << " ";
}
std::cout << std::endl;
}
return 0;
}

View File

@ -0,0 +1,68 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
// 设置块体模型
array<mag_block> bk(1);
bk[0].set(45, 55, 45, 55, 20, 40);
// 设置块体的磁化率与磁化参数
array<double> sus(1, 0.1);
array<magblock_para> mag_para(1);
mag_para[0].inclina_deg = 60;
mag_para[0].declina_deg = 10;
bk[0].att = &mag_para[0];
// 设置观测点位
array<point3dc> obsp;
gridspace(point3dc(0, 0, 0), point3dc(100, 0, 0),
point3dc(0, 0, 0), point3dc(0, 100, 0), 51, 51, obsp);
// 正演计算
array<double> obsval;
magobser(obsval, bk, obsp, sus, Hax, ShortMsg);
// 保存网格
gctl::save_netcdf_grid("out", obsval, 51, 51, 0, 2, 0, 2, "x", "y", "Hax");
magobser(obsval, bk, obsp, sus, Hay, ShortMsg);
// 保存网格
gctl::append_netcdf_grid("out", obsval, "x", "y", "Hay");
magobser(obsval, bk, obsp, sus, Za, ShortMsg);
// 保存网格
gctl::append_netcdf_grid("out", obsval, "x", "y", "Za");
gridspace(point3dc(0, 0, -5), point3dc(100, 0, -5),
point3dc(0, 0, -5), point3dc(0, 100, -5), 51, 51, obsp);
magobser(obsval, bk, obsp, sus, Za, ShortMsg);
// 保存网格
gctl::append_netcdf_grid("out", obsval, "x", "y", "Za-10");
return 0;
}

View File

@ -0,0 +1,82 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
#include "iostream"
int main(int argc, char const *argv[]) try
{
// set up observation parameters and block parameters
double lon, lat;
gctl::array<gctl::point3ds> obes(201*201);
for (int i = 0; i < 201; i++)
{
lat = 20.0 + 0.25*i;
for (int j = 0; j < 201; j++)
{
lon = 65.0 + 0.25*j;
obes[i*201+j].lon = lon;
obes[i*201+j].lat = lat;
obes[i*201+j].rad = GCTL_Earth_Radius + 40000.0;
}
}
gctl::array<gctl::mag_tesseroid> tesses(1);
gctl::array<gctl::magtess_para> mtess(1);
tesses[0].set(GCTL_Earth_Radius - 11650.0, GCTL_Earth_Radius - 1000.0, 89, 91, 44, 46);
mtess[0].bx = 23458.6;
mtess[0].by = 840.2;
mtess[0].bz = 53040.0;
gctl::link_entity_attribute(tesses, mtess);
gctl::array<double> rho(1, 1.0);
gctl::array<double> sus(1, 1.0);
gctl::array<double> data;
#ifdef GCTL_NETCDF
magobser(data, tesses, obes, rho, sus, gctl::Za, gctl::ShortMsg);
gctl::save_netcdf_grid("data/tesseroid_mag", data, 201, 201, -25.0, 0.25, -25.0, 0.25, "x", "y", "Za");
magobser(data, tesses, obes, rho, sus, gctl::Hax, gctl::ShortMsg);
gctl::append_netcdf_grid("data/tesseroid_mag", data, "x", "y", "Hax");
magobser(data, tesses, obes, rho, sus, gctl::Hay, gctl::ShortMsg);
gctl::append_netcdf_grid("data/tesseroid_mag", data, "x", "y", "Hay");
#else
magobser(data, tesses, obes, rho, sus, gctl::Za, gctl::ShortMsg);
gctl::save_surfer6_grid("data/tesseroid_mag", data, 201, 201, -25.0, 25.0, -25.0, 25.0, NAN, NAN, gctl::Surfer6Binary);
#endif // GCTL_NETCDF
return 0;
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}

View File

@ -0,0 +1,115 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/io.h"
#include "gctl/potential.h"
using namespace gctl;
int main(int argc, char const *argv[])
{
array<vertex3dc> node;
array<mag_tetrahedron_ren17> ele;
read_Tetgen_node("data/prism/prism.1", node);
read_Tetgen_element("data/prism/prism.1", ele, node);
array<point3dc> magz(ele.size(), point3dc(0,0,200));
array<magtet_para_ren17> mag_para;
callink_magnetic_para_direct(ele, mag_para, magz);
// 设置观测点位
array<point3dc> obsp;
gridspace(point3dc(-30, 0, 5), point3dc(30, 0, 5),
point3dc(0, -30, 5), point3dc(0, 30, 5), 81, 81, obsp);
// 正演计算
array<double> obsval;
array<point3dc> obsgrad;
array<tensor> obstensor;
magobser(obsval, ele, obsp, ShortMsg);
// 保存网格
gctl::save_netcdf_grid("out", obsval, 81, 81, -30.0, 0.75, -30.0, 0.75, "x", "y", "Potential");
magobser(obsgrad, ele, obsp, ShortMsg);
// 保存网格
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obsgrad[i].x;
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Bx");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obsgrad[i].y;
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "By");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obsgrad[i].z;
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Bz");
magobser(obstensor, ele, obsp, ShortMsg);
// 保存网格
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(0, 0);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Txx");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(0, 1);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Txy");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(0, 2);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Txz");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(1, 1);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Tyy");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(1, 2);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Tyz");
for (int i = 0; i < obsp.size(); ++i)
{
obsval[i] = obstensor[i].at(2, 2);
}
gctl::append_netcdf_grid("out", obsval, "x", "y", "Tzz");
return 0;
}

46
examples/parse_string.cpp Normal file
View File

@ -0,0 +1,46 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/utility.h"
int main(int argc, char const *argv[])
{
std::string t = "2/3/4/6/ssd";
int a[5];
int ret = gctl::parse_string_to_value(t, '/', false, a[0], a[1], a[2], a[3], a[4]);
std::cout << "num = " << ret << std::endl;
for (size_t i = 0; i < 5; i++)
{
std::cout << a[i] << std::endl;
}
return 0;
}

View File

@ -0,0 +1,48 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/geometry.h"
#include "iostream"
int main(int argc, char const *argv[])
{
gctl::point2dc a(1.0, 1.0);
gctl::point2dc o1(2.0, 2.0);
gctl::point2dc o2(1.0, 0.0);
gctl::point2dc b = a.rotate(0.5*GCTL_Pi);
gctl::point2dc c = a.rotate(-0.25*GCTL_Pi);
gctl::point2dc d = a.rotate(0.5*GCTL_Pi, o1);
gctl::point2dc e = a.rotate(-0.5*GCTL_Pi, o2);
std::cout << "a (" << a.x << ", " << a.y << ")" << std::endl;
std::cout << "b (" << b.x << ", " << b.y << ")" << std::endl;
std::cout << "c (" << c.x << ", " << c.y << ")" << std::endl;
std::cout << "d (" << d.x << ", " << d.y << ")" << std::endl;
std::cout << "e (" << e.x << ", " << e.y << ")" << std::endl;
return 0;
}

59
examples/point_ex.cpp Normal file
View File

@ -0,0 +1,59 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/geometry.h"
#include "iostream"
using namespace gctl;
using std::cout;
using std::endl;
int main(int argc, char const *argv[])
{
// 二维实点的测试
point2dc p, q;
p.set(4.3, 5.9);
q.set(1.2, 3.0);
cout << (p+q).x << endl;
cout << (p-q).y << endl;
cout << (5*p).x << endl;
// 以下为三维实点的测试
point3dc a, b;
a.set(3,2,5);
b.set(4,1,7);
point3dc c = a + b;
point3dc d = a - b;
point3dc e = 0.5*a;
cout << a.x << " " << a.y << " " << a.z << endl;
cout << b.x << " " << b.y << " " << b.z << endl;
cout << c.x << " " << c.y << " " << c.z << endl;
cout << d.x << " " << d.y << " " << d.z << endl;
cout << e.x << " " << e.y << " " << e.z << endl;
return 0;
}

View File

@ -0,0 +1,65 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/utility.h"
int main(int argc, char const *argv[])
{
// declare a progress bar with the size of p_size
int p_size = 10;
gctl::progress_bar bar(p_size, "Sample");
// do something and show the progress
for (int i = 0; i < p_size; ++i)
{
bar.progressed(i);
sleep(1);
}
// reset the progress bar to the size of 2*p_size
bar.reset(2*p_size, "Sample-2");
// set customized styles for the progress bar
bar.set_style(">", " ");
// do something and show the progress
for (int i = 0; i < 2*p_size; ++i)
{
bar.progressed(i);
sleep(1);
}
// reset the progress bar
bar.reset(p_size, "Sample-3");
// do something and show the simple progress
for (int i = 0; i < p_size; ++i)
{
bar.progressed_simple(i);
sleep(1);
}
return 0;
}

View File

@ -0,0 +1,60 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "iostream"
int main(int argc, char const *argv[])
{
gctl::array<int> xs, ys;
gctl::array<double> data;
gctl::read_netcdf_axis("data/out/nc_example", xs, "x");
gctl::read_netcdf_axis("data/out/nc_example", xs, "y");
gctl::read_netcdf_grid("data/out/nc_example", data, "x", "y", "z");
gctl::show_netcdf_info("data/out/nc_example");
for (int i = 0; i < xs.size(); ++i)
{
std::cout << xs[i] << " ";
}
std::cout << std::endl;
for (int i = 0; i < ys.size(); ++i)
{
std::cout << ys[i] << " ";
}
std::cout << std::endl;
for (int i = 0; i < 10; ++i)
{
std::cout << data[i] << " ";
}
std::cout << std::endl;
return 0;
}

17
examples/rtp_ex.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "gctl/core.h"
#include "gctl/io.h"
#include "gctl/potential.h"
#include "iostream"
int main(int argc, char const *argv[]) try
{
gctl::gm_regular_grid mag_rg;
mag_rg.load_netcdf_grid("data/sample_DeltaT", gctl::NodeData, "x", "y");
mag_rg.rtp("z", "rtp", 50, 3);
mag_rg.save_netcdf_grid("data/sample_RTP", gctl::NodeData);
return 0;
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}

View File

@ -0,0 +1,49 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
#include "iostream"
int main(int argc, char const *argv[])
{
int xnum = 101, ynum = 91;
int xmin = 100, ymin = 50;
int dx = 5, dy = 5;
gctl::array<double> data(xnum*ynum);
for (int j = 0; j < ynum; j++)
{
for (int i = 0; i < xnum; i++)
{
data[i + j*xnum] = 1.0*i + 0.5;
}
}
gctl::save_netcdf_grid("data/out/nc_example", data, xnum, ynum, xmin, dx, ymin, dy);
return 0;
}

43
examples/sparray2d_ex.cpp Normal file
View File

@ -0,0 +1,43 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::sparray2d<double> M(10, 10, 0.0);
M.at(4)->set(4, 5);
M.at(2)->set(3, 8);
M.at(6)->set(8, 2);
for (int i = 0; i < M.size(); i++)
{
M.at(i)->show_full();
}
return 0;
}

109
examples/sparray_ex.cpp Normal file
View File

@ -0,0 +1,109 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
int main(int argc, char const *argv[])
{
srand(time(0));
gctl::sparray<double> M(50, 0.0);
int tmp_id[13] = {4, 2, 6, 7, 8, 12, 23, 43, 33, 47, 38, 15, 1};
int tmp_size = 13;
for (int i = 0; i < tmp_size; i++)
{
M.set(tmp_id[i], gctl::random(10.0, 20.0));
}
M.show_list();
M.set(18, 100);
M.set(38, 100);
M.remove(12);
std::cout << "************" << std::endl;
M.show_list();
gctl::array<double> C(50, -1.0);
M.export_dense(C, 1.0, gctl::AppendVal);
for (int i = 0; i < C.size(); i++)
{
std::cout << C.at(i) << " ";
}
std::cout << std::endl;
gctl::sparray<double> N(C, -1, 1e-10);
N.show_list();
std::cout << "Test 2" << std::endl;
M.clear();
M.malloc(20, 0.0);
M.set(5, 6.5);
M.set(9, 9.1);
M.set(3, 4.3);
M.set(17, 1.4);
M.set(10, 3.5);
M.set(7, 7.4);
M.show_list();
M.remove(17);
M.remove(9);
std::cout << "**********" << std::endl;
M.show_list();
std::cout << "Test 3" << std::endl;
int test_size = 500000;
M.clear();
M.malloc(test_size, 0.0);
clock_t start = clock();
for (int i = 0; i < 300000; i++)
{
M.set(i, gctl::random(10.0, 20.0));
}
for (int i = 300001; i < test_size; i++)
{
M.set(i, gctl::random(10.0, 20.0));
}
M.set(300000, 15.8888);
clock_t end = clock();
std::cout << "sparray set() time: " << 1000.0*(end - start)/(double)CLOCKS_PER_SEC << " ms" << std::endl;
std::cout << "M.at(300000) = " << M.value(300000) << std::endl;
M.show_list(299995, 300005);
return 0;
}

86
examples/spmat_ex.cpp Normal file
View File

@ -0,0 +1,86 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::spmat<double> M(10, 10, 0.0);
M.insert(3, 3, 1.3);
M.insert(8, 1, 2.8);
M.insert(2, 6, 4.2);
M.insert(5, 6, 4.6);
M.insert(2, 3, 7.2);
M.insert(5, 9, 2.2);
M.insert(2, 9, 5.4);
M.insert(7, 4, 8.5);
M.insert(0, 4, 0.0);
M.insert(7, 6, 0.0);
M.show_matrix();
M.show_list();
std::cout << "M.at(4, 4) = " << M.at(4, 4) << std::endl;
std::cout << "M.at(5, 9) = " << M.at(5, 9) << std::endl;
gctl::spmat<double> N = M; // 等效语句 gctl::spmat<double> N(M);
N.remove(2, 3);
N.remove(3, 3);
N.show_matrix();
for (int i = 0; i < N.row_size(); i++)
{
std::cout << "row size " << i << " = " << N.ele_size(i) << std::endl;
}
for (int i = 0; i < N.col_size(); i++)
{
std::cout << "col size " << i << " = " << N.ele_size(i, gctl::ColMajor) << std::endl;
}
N.minus_sparse_matrix(M);
N.show_matrix();
for (int i = 0; i < N.row_size(); i++)
{
std::cout << "row size " << i << " = " << N.ele_size(i) << std::endl;
}
for (int i = 0; i < N.col_size(); i++)
{
std::cout << "col size " << i << " = " << N.ele_size(i, gctl::ColMajor) << std::endl;
}
//for (int i = 0; i < N.col_size(); i++)
//{
// std::cout << "col size " << i << " = " << N.ele_size(i, gctl::SpMatColMajor) << std::endl;
//}
//N.show_full();
return 0;
}

115
examples/spmat_ex2.cpp Normal file
View File

@ -0,0 +1,115 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::spmat<double> M(6, 5, 0.0);
M.insert(3, 3, 0.1);
M.insert(2, 3, 0.2);
M.insert(2, 0, 0.3);
M.insert(1, 4, 0.4);
M.insert(0, 1, 0.5);
M.insert(4, 2, 0.6);
M.insert(5, 1, 0.7);
std::cout << "M = " << std::endl;
M.show_matrix();
gctl::spmat<double> N(5, 6, 0.0);
N.insert(3, 3, 0.1);
N.insert(3, 2, 0.2);
N.insert(0, 2, 0.3);
N.insert(4, 1, 0.4);
N.insert(1, 0, 0.5);
N.insert(2, 4, 0.6);
N.insert(1, 5, 0.7);
std::cout << "N = " << std::endl;
N.show_matrix();
gctl::spmat<double> Product;
M.multiply_sparse_matrix(N, Product);
std::cout << "M*N = " << std::endl;
Product.show_matrix();
std::cout << "N (list) = " << std::endl;
Product.show_list();
gctl::array<double> V(6, 1.0);
V[3] = 2.0;
std::cout << "V = " << std::endl;
for (int i = 0; i < V.size(); i++)
{
std::cout << V.at(i) << " ";
}
std::cout << std::endl;
gctl::array<double> MxV;
M.multiply_vector(V, MxV, gctl::Trans);
std::cout << "M^T*V = " << std::endl;
for (int i = 0; i < MxV.size(); i++)
{
std::cout << MxV.at(i) << " ";
}
std::cout << std::endl;
gctl::spmat<double> L;
M.transpose(L);
std::cout << "L = M^T = " << std::endl;
L.show_matrix();
gctl::matrix<double> P(5, 6);
std::cout << "P = " << std::endl;
for (int i = 0; i < P.row_size(); i++)
{
for (int j = 0; j < P.col_size(); j++)
{
P.at(i, j) = i + 0.1*j;
std::cout << P.at(i, j) << " ";
}
std::cout << std::endl;
}
gctl::matrix<double> Product2;
M.multiply_matrix(P, Product2);
std::cout << "M*P = " << std::endl;
for (int i = 0; i < Product2.row_size(); i++)
{
for (int j = 0; j < Product2.col_size(); j++)
{
std::cout << Product2.at(i, j) << " ";
}
std::cout << std::endl;
}
return 0;
}

63
examples/spmat_ex3.cpp Normal file
View File

@ -0,0 +1,63 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
int main(int argc, char const *argv[])
{
try
{
gctl::spmat<double> M(6, 5, 0.0);
M.insert(3, 3, 0.5);
M.insert(2, 3, 0.5);
M.insert(2, 0, 0.5);
M.insert(1, 4, 0.5);
M.insert(0, 1, 0.5);
M.insert(4, 2, 0.5);
M.insert(5, 1, 0.5);
M.insert(4, 4, 0.5);
std::cout << "M.ele_size() = " << M.ele_size() << std::endl;
std::cout << "M = " << std::endl;
M.show_matrix();
gctl::save_spmat2binary("data/out/spmat_M", M);
gctl::spmat<double> N;
gctl::read_binary2spmat("data/out/spmat_M", N);
std::cout << "N = " << std::endl;
N.show_matrix();
}
catch(std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

61
examples/spmat_ex4.cpp Normal file
View File

@ -0,0 +1,61 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::spmat<double> M(10, 10, 0.0);
M.insert(3, 3, 1.3);
M.insert(5, 6, 4.6);
M.insert(8, 1, 2.8);
M.insert(2, 3, 7.2);
M.insert(5, 9, 2.2);
M.insert(2, 9, 5.4);
M.insert(7, 4, 8.5);
M.show_matrix();
M.show_list();
M.map(5, 0, 2.0);
M.map(2, 0, 1.0);
M.map(3, 0, 1.0, gctl::ColMajor);
M.show_matrix();
M.show_list();
gctl::array<double> in(10, 0.2), out(10);
M.multiply_vector(0, in.get(), 10, out.get());
for (int i = 0; i < 10; i++)
{
std::cout << out[i] << " ";
}
std::cout << std::endl;
return 0;
}

59
examples/spmat_ex5.cpp Normal file
View File

@ -0,0 +1,59 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::_2d_vector A(10);
for (int i = 0; i < 10; i++)
{
A[i].resize(10, 0.0);
}
A[3][3] = 1.3;
A[5][6] = 4.6;
A[8][1] = 2.8;
A[2][3] = 7.2;
A[5][9] = 2.2;
A[2][9] = 5.4;
A[7][4] = 8.5;
A[0][4] = 0.0;
A[7][6] = 0.0;
gctl::spmat<double> M(10, 10, 0.0);
M.set_2d_vector(A, 1e-20);
M.show_matrix();
M.show_list();
std::cout << "##########" << std::endl;
M.show_list(gctl::ColMajor, ' ');
gctl::spmat<double> N(M);
N.show_matrix();
return 0;
}

101
examples/spmat_ex6.cpp Normal file
View File

@ -0,0 +1,101 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::spmat<double> A(10, 10, 0.0);
A.insert(3, 3, 1.3);
A.insert(5, 6, 4.6);
A.insert(8, 1, 2.8);
A.insert(2, 3, 7.2);
A.insert(5, 9, 2.2);
A.insert(2, 9, 5.4);
A.insert(7, 4, 8.5);
A.insert(0, 1, 8.5);
A.insert(0, 7, 5.3);
A.insert(1, 2, 8.1);
A.insert(1, 5, 1.2);
A.insert(1, 6, 3.4);
gctl::spmat<double> B(A);
A.show_matrix();
std::cout << "#########" << std::endl;
std::cout << A.sum() << std::endl;
for (int i = 0; i < A.row_size(); i++)
{
std::cout << A.sum(i) << std::endl;
}
/*
double sum;
gctl::mat_node<double> *node_ptr;
for (int i = 0; i < A.row_size(); i++)
{
sum = 0.0;
node_ptr = A.row_head(i);
while (node_ptr != nullptr)
{
sum += node_ptr->value();
node_ptr = A.next(node_ptr);
}
node_ptr = A.row_head(i);
while (node_ptr != nullptr)
{
node_ptr->value(node_ptr->value()/sum);
node_ptr = A.next(node_ptr);
}
}
*/
std::cout << A.sum() << std::endl;
for (int i = 0; i < A.row_size(); i++)
{
std::cout << A.sum(i) << std::endl;
}
A.show_matrix();
std::cout << "#########" << std::endl;
for (int i = 0; i < B.row_size(); i++)
{
B.normalize(i, 1.0);
}
B.show_matrix();
B.clear(1);
B.clear(3, gctl::ColMajor);
std::cout << "#########" << std::endl;
B.show_matrix();
B.show_list(gctl::ColMajor, ',');
return 0;
}

65
examples/spmat_ex7.cpp Normal file
View File

@ -0,0 +1,65 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
int main(int argc, char const *argv[])
{
gctl::spmat<double> A(10, 10, 0.0), B;
A.insert(3, 3, 1.3);
A.insert(5, 6, 4.6);
A.insert(8, 1, 2.8);
A.insert(2, 3, 7.2);
A.insert(5, 9, 2.2);
A.insert(2, 9, 5.4);
A.insert(7, 4, 8.5);
A.insert(0, 1, 8.5);
A.insert(0, 7, 5.3);
A.insert(1, 2, 8.1);
A.insert(1, 5, 1.2);
A.insert(1, 6, 3.4);
A.show_matrix();
std::cout << "#########" << std::endl;
gctl::array<double> a(10);
for (int i = 0; i < 10; i++)
{
a[i] = i+1.0;
}
A.multiply_diagonal_matrix(a, B, false);
B.show_matrix();
std::cout << "#########" << std::endl;
A.multiply_diagonal_matrix(a, B);
B.show_matrix();
std::cout << "#########" << std::endl;
return 0;
}

View File

@ -0,0 +1,160 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/algorithm.h"
#include "lcg/lcg.h"
#include "ctime"
#define M 100
#define N 80
// 普通二维数组做核矩阵
gctl::matrix<double> kernel(M, N, 0.0);
// 稀疏矩阵为核矩阵
gctl::spmat<double> sp_kernel(M, N, 0.0);
// 中间结果数组
gctl::array<double> tmp_arr(M, 0.0);
// 计算核矩阵乘向量的乘积
void CalAx(void* instance, const lcg_float* x, lcg_float* prod_Ax, const int n_s)
{
for (int i = 0; i < M; i++)
{
tmp_arr[i] = 0.0;
for (int j = 0; j < n_s; j++)
{
tmp_arr[i] += kernel[i][j] * x[j];
}
}
for (int j = 0; j < n_s; j++)
{
prod_Ax[j] = 0.0;
for (int i = 0; i < M; i++)
{
prod_Ax[j] += kernel[i][j] * tmp_arr[i];
}
}
return;
}
// 计算核矩阵乘向量的乘积
void CalAx_Spmat(void* instance, const lcg_float* x, lcg_float* prod_Ax, const int n_s)
{
// 直接调用稀疏矩阵与向量的乘法
// 注意第二次为向量乘矩阵 相当于矩阵的转置与向量相乘
sp_kernel.multiply_vector(x, n_s, tmp_arr.get(), M);
sp_kernel.multiply_vector(tmp_arr.get(), M, prod_Ax, n_s, gctl::Trans);
return;
}
//定义共轭梯度监控函数
int Prog(void* instance, const lcg_float* m, const lcg_float converge, const lcg_para* param, const int n_s, const int k)
{
std::clog << "Iteration-times: " << k << "\tconvergence: " << converge << std::endl;
if (converge > param->epsilon) std::clog << "\033[1A\033[K";
return 0;
}
int main(int argc, char const *argv[])
{
srand(time(0));
// 添加一些大数
int tmp_id, tmp_size;
double tmp_val;
for (int i = 0; i < M; i++)
{
tmp_size = gctl::random(25, 35);
for (int j = 0; j < tmp_size; j++)
{
tmp_id = gctl::random(0, N);
tmp_val = gctl::random(-10.0, 10.0);
kernel[i][tmp_id] = tmp_val;
sp_kernel.insert(i, tmp_id, tmp_val);
}
}
// 生成一组正演解
gctl::array<double> fm(N);
for (int i = 0; i < N; i++)
{
fm[i] = gctl::random(1.0, 2.0);
}
// 计算共轭梯度B项
gctl::array<double> B(N);
sp_kernel.multiply_vector(fm.get(), N, tmp_arr.get(), M);
sp_kernel.multiply_vector(tmp_arr.get(), M, B.get(), N, gctl::Trans);
/*
for (int i = 0; i < M; i++)
{
tmp_arr[i] = 0.0;
for (int j = 0; j < N; j++)
{
tmp_arr[i] += kernel[i][j]*fm[j];
}
}
for (int j = 0; j < N; j++)
{
B[j] = 0.0;
for (int i = 0; i < M; i++)
{
B[j] += kernel[i][j]*tmp_arr[i];
}
}
*/
/********************准备工作完成************************/
lcg_para self_para = lcg_default_parameters();
self_para.max_iterations = 1000;
self_para.epsilon = 1e-10;
// 声明两组解
gctl::array<double> m(N, 0.0);
gctl::array<double> m_sp(N, 0.0);
clock_t start = clock();
int ret = lcg_solver(CalAx, Prog, m.get(), B.get(), N, &self_para, NULL, LCG_CG);
clock_t end = clock();
if (ret < 0) lcg_error_str(ret);
std::cout << "array2d's time: " << 1000.0*(end - start)/(double)CLOCKS_PER_SEC << " ms" << std::endl;
start = clock();
ret = lcg_solver(CalAx_Spmat, Prog, m_sp.get(), B.get(), N, &self_para, NULL, LCG_CG);
if (ret < 0) lcg_error_str(ret);
end = clock();
std::cout << "spmat's time: " << 1000.0*(end - start)/(double)CLOCKS_PER_SEC << " ms" << std::endl;
for (int i = 0; i < N; i++)
{
std::cout << fm[i] << " " << m[i] << " " << m_sp[i] << std::endl;
}
return 0;
}

47
examples/sptr_ex.cpp Normal file
View File

@ -0,0 +1,47 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "iostream"
#include "memory"
int main(int argc, char const *argv[])
{
gctl::smart_ptr<gctl::array<double>> a_ptr = new gctl::array<double>(10, 1.0);
for (int i = 0; i < a_ptr->size(); ++i)
{
std::cout << a_ptr->at(i) << std::endl;
}
std::unique_ptr<gctl::array<double>> b_ptr(new gctl::array<double>(10, 2.0));
for (int i = 0; i < b_ptr->size(); ++i)
{
std::cout << b_ptr->at(i) << std::endl;
}
return 0;
}

67
examples/stream_ex.cpp Normal file
View File

@ -0,0 +1,67 @@
/********************************************************
*
*
*
*
*
*
* 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 "gctl/core.h"
#include "gctl/io.h"
struct people
{
std::string name, gender;
int age;
double weight;
friend std::istream &operator >>(std::istream & os, people &p)
{
os >> p.name >> p.age >> p.gender >> p.weight;
return os;
}
friend std::ostream &operator <<(std::ostream & os, people &p)
{
os << p.name << p.age << p.gender << p.weight;
return os;
}
};
int main(int argc, char const *argv[])
{
try
{
std::vector<people> group;
gctl::read_text2vector("data/out/table_sample.txt", group);
for (int i = 0; i < group.size(); ++i)
{
std::cout << group[i] << std::endl;
}
}
catch (std::exception &e)
{
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}
return 0;
}

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