This commit is contained in:
张壹 2025-07-06 17:49:00 +08:00
parent b92f48a4f8
commit 31bcd2d2bf
2 changed files with 29 additions and 16 deletions

View File

@ -44,7 +44,7 @@ if(GCTL_POTENTIAL_FOUND)
message(STATUS "GCTL_POTENTIAL Version: " ${GCTL_POTENTIAL_VERSION})
endif()
macro(add_toolkit ex_dir name lib1 lib2 lib3 lib4)
macro(add_example ex_dir name lib1 lib2 lib3 lib4)
#aux_source_directory(${name} src/${ex_dir}/${name}.cpp)
add_executable(${name} src/${ex_dir}/${name}.cpp)
set_target_properties(${name} PROPERTIES INSTALL_RPATH /usr/local/lib)
@ -67,9 +67,13 @@ macro(add_toolkit ex_dir name lib1 lib2 lib3 lib4)
endif()
endmacro()
if(GCTL_FOUND AND GCTL_MESH_FOUND)
add_toolkit(mesh create_tin_ex1 ON ON OFF OFF)
add_toolkit(mesh create_tin_ex2 ON ON OFF OFF)
add_toolkit(mesh create_tin_ex3 ON ON OFF OFF)
add_toolkit(mesh create_tin_ex4 ON ON OFF OFF)
endif()
if(GCTL_FOUND)
add_example(core spmat_ex ON OFF OFF OFF)
endif()
#if(GCTL_FOUND AND GCTL_MESH_FOUND)
# add_example(mesh create_tin_ex1 ON ON OFF OFF)
# add_example(mesh create_tin_ex2 ON ON OFF OFF)
# add_example(mesh create_tin_ex3 ON ON OFF OFF)
# add_example(mesh create_tin_ex4 ON ON OFF OFF)
#endif()

View File

@ -25,7 +25,7 @@
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
#include "../lib/core.h"
#include "gctl/core/spmat.h"
using namespace gctl;
@ -34,17 +34,26 @@ int main(int argc, char const *argv[]) try
spmat<double> mat(5, 5, 0.0);
std::vector<mat_node<double> > triplts;
triplts.push_back(mat_node(0, 1, 0.23));
triplts.push_back(mat_node(1, 2, 0.52));
triplts.push_back(mat_node(2, 3, 0.31));
triplts.push_back(mat_node(2, 3, 0.19));
triplts.push_back(mat_node(3, 2, 0.65));
triplts.push_back(mat_node(3, 4, 0.8));
triplts.push_back(mat_node(4, 3, 1.6));
triplts.push_back(mat_node(4, 3, 0.4));
triplts.push_back(mat_node<double>(0, 1, 0.23));
triplts.push_back(mat_node<double>(1, 2, 0.52));
triplts.push_back(mat_node<double>(2, 3, 0.31));
triplts.push_back(mat_node<double>(2, 3, 0.19));
triplts.push_back(mat_node<double>(3, 2, 0.65));
triplts.push_back(mat_node<double>(3, 4, 0.8));
triplts.push_back(mat_node<double>(4, 3, 1.6));
triplts.push_back(mat_node<double>(4, 3, 0.4));
mat.set_triplts(triplts, ReplaceVal);
mat.init_pattern();
mat_node<double> n;
for (size_t i = 0; i < mat.ele_size(); i++)
{
n = mat.get_valid_element_copy(i);
std::cout << n.r_id << "," << n.c_id << "," << n.val << "\n";
}
std::cout << "=====\n";
mat.show_matrix();
std::cout << "=====\n";