From fd2d7b38af7676d1b3df9176e5c4753b70f9e25a Mon Sep 17 00:00:00 2001 From: Lukas Riedel Date: Wed, 10 Nov 2021 10:49:27 +0100 Subject: [PATCH 1/3] Add examples to CMake configuration * Register examples as executables that are `EXCLUDED_FROM_ALL` (not built by default). * Add meta-target `examples` for building all examples. * Fix includes for all examples. --- CMakeLists.txt | 3 ++- examples/5thGKdV.cpp | 2 +- examples/7thorder.cpp | 2 +- examples/CMakeLists.txt | 26 ++++++++++++++++++++++++++ examples/Eckhaus.cpp | 2 +- examples/KS.cpp | 4 ++-- examples/KdVB.cpp | 2 +- examples/NLS.cpp | 2 +- examples/example1.cpp | 2 +- examples/example2.cpp | 2 +- examples/kerrNLS.cpp | 2 +- 11 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 examples/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eb0616..9665ec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,8 @@ IF(GINACDE_BUILD_STATIC_LIBS) set(testlibs ${CORELIBS} GiNaCDE_static) ENDIF() +add_subdirectory(examples EXCLUDE_FROM_ALL) + add_executable(test1 test/test1.cpp) target_link_libraries(test1 ${testlibs}) @@ -166,4 +168,3 @@ ENDIF() # Installing headers install (FILES ${GINACDE_HEADERS} DESTINATION include/GiNaCDE) install (FILES "${PROJECT_BINARY_DIR}/version.h" DESTINATION include/GiNaCDE) - diff --git a/examples/5thGKdV.cpp b/examples/5thGKdV.cpp index 174566f..68bed74 100644 --- a/examples/5thGKdV.cpp +++ b/examples/5thGKdV.cpp @@ -7,7 +7,7 @@ -#include +#include int main() diff --git a/examples/7thorder.cpp b/examples/7thorder.cpp index 187509b..6879404 100644 --- a/examples/7thorder.cpp +++ b/examples/7thorder.cpp @@ -7,7 +7,7 @@ -#include +#include int main() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..9f54d32 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,26 @@ +# Source files in this directory +set(SRC_FILES + 5thGKdV + 7thorder + Eckhaus + example1 + example2 + KdVB + kerrNLS + KS + NLS +) + +# Add executables and link to library +if(GINACDE_BUILD_SHARED_LIBS OR GINACDE_BUILD_STATIC_LIBS) + foreach(src ${SRC_FILES}) + add_executable(${src} ${src}.cpp) + target_link_libraries(${src} + PUBLIC $,GiNaCDE,GiNaCDE_static> + ) + endforeach() +endif() + +# Add meta-target to compile +add_custom_target(examples) +add_dependencies(examples ${SRC_FILES}) diff --git a/examples/Eckhaus.cpp b/examples/Eckhaus.cpp index 1439c03..a995678 100644 --- a/examples/Eckhaus.cpp +++ b/examples/Eckhaus.cpp @@ -7,7 +7,7 @@ -#include +#include int main() diff --git a/examples/KS.cpp b/examples/KS.cpp index 3cc5981..148212f 100644 --- a/examples/KS.cpp +++ b/examples/KS.cpp @@ -1,13 +1,13 @@ /** @file KS.cpp * - * This program solves the Kudryashov–Sinelshchikov equation: + * This program solves the Kudryashov<96>Sinelshchikov equation: {u_{3x}} + gu{u_x} - n{u_{2x}} - \left( {u{u_{2x}} + u_x^2} \right)d - k{u_x}{u_{2x}} - e\left( {u{u_{3x}} + {u_x}{u_{2x}}} \right) + {u_t} = 0, */ -#include +#include int main() diff --git a/examples/KdVB.cpp b/examples/KdVB.cpp index 8f9d218..b150fe0 100644 --- a/examples/KdVB.cpp +++ b/examples/KdVB.cpp @@ -7,7 +7,7 @@ -#include +#include int main() diff --git a/examples/NLS.cpp b/examples/NLS.cpp index 9d7a6df..5628e8e 100644 --- a/examples/NLS.cpp +++ b/examples/NLS.cpp @@ -7,7 +7,7 @@ -#include +#include int main() diff --git a/examples/example1.cpp b/examples/example1.cpp index 398f9cc..d9bc322 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -8,7 +8,7 @@ -#include +#include int main() diff --git a/examples/example2.cpp b/examples/example2.cpp index f2c9ec7..19b9170 100644 --- a/examples/example2.cpp +++ b/examples/example2.cpp @@ -19,7 +19,7 @@ xvi. Nonlinear Telegraph Equation */ -#include +#include //#include diff --git a/examples/kerrNLS.cpp b/examples/kerrNLS.cpp index 3e20a2c..4f7883f 100644 --- a/examples/kerrNLS.cpp +++ b/examples/kerrNLS.cpp @@ -7,7 +7,7 @@ -#include +#include int main() From efde89660b8e5a87a7d5d2760b7725fd260d057b Mon Sep 17 00:00:00 2001 From: Lukas Riedel Date: Wed, 10 Nov 2021 10:51:39 +0100 Subject: [PATCH 2/3] Update README.md Add instructions for building examples. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index afc11ff..a030c0d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,13 @@ Besides this, the solutions of the NLPDE are collected by a programming variable ## Examples The [`examples`](examples/) folder contains all the examples which solve some NLPDEs, such as, Eckhaus equation, Seventh-order SawadaKotara equations, Fifth-order Generalized KdV equation, Perturbed NLS Equation with Kerr Law Nonlinearity, KudryashovSinelshchikov Equation, etc. We have provided output text files after executing each example. - + +To compile the examples, move to the `build-dir` created earlier for building GiNaCDE, and execute +``` +$ make examples +``` +The executables will be placed into the `build-dir/bin` directory. + ### Additional notes Please note that one can obtain different results in output files compared to those provided by us in the [`examples`](examples/) folder for each example. This happens because of the GiNaC library. From 5623a23c27e2c1b68a30a0df631adb05d0104978 Mon Sep 17 00:00:00 2001 From: Lukas Riedel Date: Wed, 10 Nov 2021 11:04:58 +0100 Subject: [PATCH 3/3] Fix formatting issue in KS.cpp --- examples/KS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/KS.cpp b/examples/KS.cpp index 148212f..6d7c7d7 100644 --- a/examples/KS.cpp +++ b/examples/KS.cpp @@ -1,7 +1,7 @@ /** @file KS.cpp * - * This program solves the Kudryashov<96>Sinelshchikov equation: + * This program solves the Kudryashov-Sinelshchikov equation: {u_{3x}} + gu{u_x} - n{u_{2x}} - \left( {u{u_{2x}} + u_x^2} \right)d - k{u_x}{u_{2x}} - e\left( {u{u_{3x}} + {u_x}{u_{2x}}} \right) + {u_t} = 0, */