diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bea0c5d..09f470ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,9 +50,9 @@ endif() find_package(MPI REQUIRED) -add_executable(preciceMap src/preciceMap.cpp src/common.cpp src/mesh.cpp src/configreader.cpp src/modes.cpp src/utilities.cpp src/logger.cpp) -target_include_directories(preciceMap PRIVATE src thirdparty) -target_link_libraries(preciceMap +add_executable(precice-aste-run src/precice-aste-run.cpp src/common.cpp src/mesh.cpp src/configreader.cpp src/modes.cpp src/utilities.cpp src/logger.cpp) +target_include_directories(precice-aste-run PRIVATE src thirdparty) +target_link_libraries(precice-aste-run precice::precice Threads::Threads MPI::MPI_CXX @@ -61,15 +61,15 @@ target_link_libraries(preciceMap ) if(ASTE_SET_MESH_BLOCK) - target_compile_definitions(preciceMap PRIVATE ASTE_SET_MESH_BLOCK) + target_compile_definitions(precice-aste-run PRIVATE ASTE_SET_MESH_BLOCK) endif() if(ASTE_NN_GRADIENT_MAPPING_AND_TETRA) - target_compile_definitions(preciceMap PRIVATE ASTE_NN_GRADIENT_MAPPING_AND_TETRA) + target_compile_definitions(precice-aste-run PRIVATE ASTE_NN_GRADIENT_MAPPING_AND_TETRA) endif() if(METIS_FOUND) - target_link_libraries(preciceMap metisAPI) + target_link_libraries(precice-aste-run metisAPI) endif() @@ -87,21 +87,21 @@ if (VTK_VERSION VERSION_LESS "8.90.0") else () # vtk_module_autoinit is needed vtk_module_autoinit( - TARGETS preciceMap testing + TARGETS precice-aste-run testing MODULES ${VTK_LIBRARIES} ) endif() -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/partition_mesh.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/join_mesh.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/vtk_calculator.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-partition DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-join DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-evaluate DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) include(GNUInstallDirs) -install(TARGETS preciceMap DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS precice-aste-run DESTINATION ${CMAKE_INSTALL_BINDIR}) if(METIS_FOUND) install(TARGETS metisAPI DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/partition_mesh.py ${CMAKE_CURRENT_SOURCE_DIR}/src/join_mesh.py ${CMAKE_CURRENT_SOURCE_DIR}/src/vtk_calculator.py DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-partition ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-join ${CMAKE_CURRENT_SOURCE_DIR}/src/precice-aste-evaluate DESTINATION ${CMAKE_INSTALL_BINDIR}) enable_testing() diff --git a/src/common.cpp b/src/common.cpp index eee6666c..f1d22df4 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -19,7 +19,7 @@ OptionMap getOptions(int argc, char *argv[]) "mesh", po::value(), "Mesh prefix (i.e. mesh name without the format extension such as '.vtk' or '.vtu'). " "Example: solution.vtk has the prefix 'solution'. " - "preciceMap will look for timeseries as well as distributed meshes (e.g. from preCICE exports) " + "precice-aste-run will look for timeseries as well as distributed meshes (e.g. from preCICE exports) " "automatically and load them if required.")( "output", po::value(), "Output file name.")( diff --git a/src/vtk_calculator.py b/src/precice-aste-evaluate similarity index 99% rename from src/vtk_calculator.py rename to src/precice-aste-evaluate index 77a3dcfc..f647bd26 100755 --- a/src/vtk_calculator.py +++ b/src/precice-aste-evaluate @@ -26,7 +26,7 @@ def __init__(self) -> None: @staticmethod def create_logger(level): - logger = logging.getLogger("---[ASTE-Calculator]") + logger = logging.getLogger("---[ASTE-Evaluate]") logger.setLevel(getattr(logging, level)) ch = logging.StreamHandler() ch.setLevel(getattr(logging, level)) diff --git a/src/join_mesh.py b/src/precice-aste-join similarity index 99% rename from src/join_mesh.py rename to src/precice-aste-join index f2ced055..96f24dff 100755 --- a/src/join_mesh.py +++ b/src/precice-aste-join @@ -74,7 +74,7 @@ def parse_args(): @staticmethod def create_logger(args): - logger = logging.getLogger("---[ASTE-Joiner]") + logger = logging.getLogger("---[ASTE-Join]") logger.setLevel(getattr(logging, args.logging)) ch = logging.StreamHandler() ch.setLevel(getattr(logging, args.logging)) diff --git a/src/partition_mesh.py b/src/precice-aste-partition similarity index 99% rename from src/partition_mesh.py rename to src/precice-aste-partition index 9f0fcc29..00755290 100755 --- a/src/partition_mesh.py +++ b/src/precice-aste-partition @@ -167,7 +167,7 @@ def parse_arguments(): @staticmethod def create_logger(args): - logger = logging.getLogger("---[ASTE-Partitioner]") + logger = logging.getLogger("---[ASTE-Partition]") logger.setLevel(getattr(logging, args.logging)) ch = logging.StreamHandler() ch.setLevel(getattr(logging, args.logging)) diff --git a/src/preciceMap.cpp b/src/precice-aste-run.cpp similarity index 100% rename from src/preciceMap.cpp rename to src/precice-aste-run.cpp diff --git a/tests/example/lci_2d/run.sh b/tests/example/lci_2d/run.sh index 0e97a56a..7220b687 100755 --- a/tests/example/lci_2d/run.sh +++ b/tests/example/lci_2d/run.sh @@ -2,11 +2,11 @@ set -e -x # Calculate franke function on fine mesh -vtk_calculator.py -m ./fine_mesh.vtk -f "franke2d(xy)" -d "Franke Function" -o "fine_mesh_lci.vtk" +precice-aste-evaluate -m ./fine_mesh.vtk -f "franke2d(xy)" -d "Franke Function" -o "fine_mesh_lci.vtk" # Map from the finer mesh to coarser mesh -preciceMap -v -p A --mesh fine_mesh_lci --data "Franke Function" & -preciceMap -v -p B --mesh ./coarse_mesh --output map_nn --data "InterpolatedData" +precice-aste-run -v -p A --mesh fine_mesh_lci --data "Franke Function" & +precice-aste-run -v -p B --mesh ./coarse_mesh --output map_nn --data "InterpolatedData" # Calculate statistics -vtk_calculator.py -m map_nn.vtk -f "franke2d(xy)" -d difference --diffdata "InterpolatedData" --diff +precice-aste-evaluate -m map_nn.vtk -f "franke2d(xy)" -d difference --diffdata "InterpolatedData" --diff diff --git a/tests/example/lci_3d/run.sh b/tests/example/lci_3d/run.sh index 79f95954..ac3057da 100755 --- a/tests/example/lci_3d/run.sh +++ b/tests/example/lci_3d/run.sh @@ -2,11 +2,11 @@ set -e -x # Calculate franke function on fine mesh -vtk_calculator.py -m ./fine_mesh.vtk -f "franke3d" -d "Franke Function" -o "fine_mesh_lci.vtk" +precice-aste-evaluate -m ./fine_mesh.vtk -f "franke3d" -d "Franke Function" -o "fine_mesh_lci.vtk" # Map from the finer mesh to coarser mesh -preciceMap -v -p A --mesh fine_mesh_lci --data "Franke Function" & -preciceMap -v -p B --mesh ./coarse_mesh --output map_nn --data "InterpolatedData" +precice-aste-run -v -p A --mesh fine_mesh_lci --data "Franke Function" & +precice-aste-run -v -p B --mesh ./coarse_mesh --output map_nn --data "InterpolatedData" # Calculate statistics -vtk_calculator.py -m map_nn.vtk -f "franke3d" -d difference --diffdata "InterpolatedData" --diff +precice-aste-evaluate -m map_nn.vtk -f "franke3d" -d difference --diffdata "InterpolatedData" --diff diff --git a/tests/example/nn/run.sh b/tests/example/nn/run.sh index 7893e8a5..b7cb0296 100755 --- a/tests/example/nn/run.sh +++ b/tests/example/nn/run.sh @@ -2,11 +2,11 @@ set -e -x # Calculate franke function on fine mesh -vtk_calculator.py -m ../fine_mesh.vtk -f "franke3d" -d "Franke Function" -o "fine_mesh_nn.vtk" +precice-aste-evaluate -m ../fine_mesh.vtk -f "franke3d" -d "Franke Function" -o "fine_mesh_nn.vtk" # Map from the finer mesh to coarser mesh -preciceMap -v -p A --mesh fine_mesh_nn --data "Franke Function" & -preciceMap -v -p B --mesh ../coarse_mesh --output map_nn --data "InterpolatedData" +precice-aste-run -v -p A --mesh fine_mesh_nn --data "Franke Function" & +precice-aste-run -v -p B --mesh ../coarse_mesh --output map_nn --data "InterpolatedData" # Calculate statistics -vtk_calculator.py -m map_nn.vtk -f "franke3d" -d difference --diffdata "InterpolatedData" --diff +precice-aste-evaluate -m map_nn.vtk -f "franke3d" -d difference --diffdata "InterpolatedData" --diff diff --git a/tests/example/nng_scalar/precice-config.xml b/tests/example/nng_scalar/precice-config.xml index 3a3f9c26..5e730150 100644 --- a/tests/example/nng_scalar/precice-config.xml +++ b/tests/example/nng_scalar/precice-config.xml @@ -8,7 +8,7 @@ - + diff --git a/tests/example/nng_scalar/run.sh b/tests/example/nng_scalar/run.sh index 2fd59871..e141f93c 100755 --- a/tests/example/nng_scalar/run.sh +++ b/tests/example/nng_scalar/run.sh @@ -2,11 +2,11 @@ set -e -x # Calculate distance from origin on fine mesh -vtk_calculator.py -m ../fine_mesh.vtk -f "sqrt(x^2+y^2+z^2)" -d "Distance" -o "fine_mesh_nng.vtk" --gradient +precice-aste-evaluate -m ../fine_mesh.vtk -f "sqrt(x^2+y^2+z^2)" -d "Distance" -o "fine_mesh_nng.vtk" --gradient # Map from the finer mesh to coarser mesh -preciceMap -v -p A --mesh fine_mesh_nng --data "Distance" & -preciceMap -v -p B --mesh ../coarse_mesh --output map_nng --data "InterpolatedData" +precice-aste-run -v -p A --mesh fine_mesh_nng --data "Distance" & +precice-aste-run -v -p B --mesh ../coarse_mesh --output map_nng --data "InterpolatedData" # Calculate statistics -vtk_calculator.py -m map_nng.vtk -f "sqrt(x^2+y^2+z^2)" -d difference --diffdata "InterpolatedData" --diff +precice-aste-evaluate -m map_nng.vtk -f "sqrt(x^2+y^2+z^2)" -d difference --diffdata "InterpolatedData" --diff diff --git a/tests/example/nng_vector/precice-config.xml b/tests/example/nng_vector/precice-config.xml index f2be1412..2a05e7a1 100644 --- a/tests/example/nng_vector/precice-config.xml +++ b/tests/example/nng_vector/precice-config.xml @@ -8,7 +8,7 @@ - + diff --git a/tests/example/nng_vector/run.sh b/tests/example/nng_vector/run.sh index 2c3386d4..d652f531 100755 --- a/tests/example/nng_vector/run.sh +++ b/tests/example/nng_vector/run.sh @@ -2,11 +2,11 @@ set -e -x # Calculate distance from origin on fine mesh -vtk_calculator.py -m ../fine_mesh.vtk -f "sin(x)*iHat+cos(y)*jHat+z^2*kHat" -d "MyFunction" -o "fine_mesh_nng.vtk" --gradient +precice-aste-evaluate -m ../fine_mesh.vtk -f "sin(x)*iHat+cos(y)*jHat+z^2*kHat" -d "MyFunction" -o "fine_mesh_nng.vtk" --gradient # Map from the finer mesh to coarser mesh -preciceMap -v -p A --mesh fine_mesh_nng --data "MyFunction" --vector & -preciceMap -v -p B --mesh ../coarse_mesh --output map_nng --data "InterpolatedData" --vector +precice-aste-run -v -p A --mesh fine_mesh_nng --data "MyFunction" --vector & +precice-aste-run -v -p B --mesh ../coarse_mesh --output map_nng --data "InterpolatedData" --vector # Calculate statistics -vtk_calculator.py -m map_nng.vtk -f "sin(x)*iHat+cos(y)*jHat+z^2*kHat" -d difference --diffdata "InterpolatedData" --diff +precice-aste-evaluate -m map_nng.vtk -f "sin(x)*iHat+cos(y)*jHat+z^2*kHat" -d difference --diffdata "InterpolatedData" --diff diff --git a/tests/example/run-all.sh b/tests/example/run-all.sh index 6d73cb03..f73ab420 100755 --- a/tests/example/run-all.sh +++ b/tests/example/run-all.sh @@ -1,6 +1,33 @@ -#!/bin/sh +#!/bin/bash set -e -u +# Print the problmatic case and increase error count +detect_error(){ + echo "Error while running case ${array[1]}" + err_count=$((err_count + 1)) +} + echo "- Running all examples cases..." +test_cases=$(find . -maxdepth 2 -mindepth 2 -name run.sh) +number_of_cases=$(echo "$test_cases" | wc -w) +echo "- There are $number_of_cases case(s) found..." + +# Initial directory and error count +run_all_dir=$(pwd) +err_count=0 + +# Run all cases +for testcase in $test_cases; do + array=($(echo "$testcase" | tr "/" "\n")) + cd "${array[1]}" + echo "- Running test case ${array[1]}..." + ./run.sh || detect_error + cd "$run_all_dir" +done -find . -maxdepth 2 -mindepth 2 -name run.sh -execdir sh -c './run.sh' \; +if [ $err_count -eq 0 ]; then + echo "All tests passed" +else + echo "$err_count out of $number_of_cases failed" + exit 1 +fi diff --git a/tools/mapping-tester/generate.py b/tools/mapping-tester/generate.py index 6d9763d5..d66d9fb1 100755 --- a/tools/mapping-tester/generate.py +++ b/tools/mapping-tester/generate.py @@ -144,7 +144,7 @@ def createRunScript(outdir, path, case): ) # Generate runner script - acmd = '/usr/bin/time -f %M -a -o memory-A.log preciceMap -v -p A --data "{}" --mesh {} || kill 0 &'.format( + acmd = '/usr/bin/time -f %M -a -o memory-A.log precice-aste-run -v -p A --data "{}" --mesh {} || kill 0 &'.format( case["function"], ameshLocation ) if aranks > 1: @@ -156,7 +156,7 @@ def createRunScript(outdir, path, case): os.path.join(outdir, "meshes", bmesh, str(branks), bmesh), path ) mapped_data_name = case["function"] + "(mapped)" - bcmd = '/usr/bin/time -f %M -a -o memory-B.log preciceMap -v -p B --data "{}" --mesh {} --output mapped || kill 0 &'.format( + bcmd = '/usr/bin/time -f %M -a -o memory-B.log precice-aste-run -v -p B --data "{}" --mesh {} --output mapped || kill 0 &'.format( mapped_data_name, bmeshLocation ) if branks > 1: @@ -213,7 +213,7 @@ def createRunScript(outdir, path, case): ] if branks == 1: joincmd = "[ ! -f mapped.vtu ] || mv --update mapped.vtu mapped.vtk" - diffcmd = 'vtk_calculator.py --data error --diffdata "{1}" --diff --stats --mesh mapped.vtk --function "{0}" | tee diff.log'.format( + diffcmd = 'precice-aste-evaluate --data error --diffdata "{1}" --diff --stats --mesh mapped.vtk --function "{0}" | tee diff.log'.format( case["function"], mapped_data_name ) post_content += [joincmd, diffcmd] @@ -222,10 +222,10 @@ def createRunScript(outdir, path, case): os.path.normpath(bmeshLocation) ) tmprecoveryFile = recoveryFileLocation + "/{}_recovery.json".format(bmesh) - joincmd = "join_mesh.py --mesh mapped -r {} -o result.vtk".format( + joincmd = "precice-aste-join --mesh mapped -r {} -o result.vtk".format( tmprecoveryFile ) - diffcmd = 'vtk_calculator.py --data error --diffdata "{1}" --diff --stats --mesh result.vtk --function "{0}" | tee diff.log'.format( + diffcmd = 'precice-aste-evaluate --data error --diffdata "{1}" --diff --stats --mesh result.vtk --function "{0}" | tee diff.log'.format( case["function"], mapped_data_name ) post_content += [joincmd, diffcmd] diff --git a/tools/mapping-tester/plotstats.py b/tools/mapping-tester/plotstats.py deleted file mode 100755 index 530f8bef..00000000 --- a/tools/mapping-tester/plotstats.py +++ /dev/null @@ -1,52 +0,0 @@ -#! python3 - -import argparse - -import matplotlib.pyplot as plt -import numpy as np -import pandas - - -def parseArguments(args): - parser = argparse.ArgumentParser( - description="Creates convergence plots from gathered stats" - ) - parser.add_argument( - "-f", - "--file", - type=argparse.FileType("r"), - default="stats.csv", - help="The CSV file containing the gathered stats.", - ) - return parser.parse_args(args) - - -def main(argv): - args = parseArguments(argv[1:]) - - df = pandas.read_csv(args.file) - df.sort_values("count", inplace=True) - grouped = df.groupby(["mapping", "constraint"]) - - ncols = 2 - nrows = int(np.ceil(grouped.ngroups / ncols)) - - fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(12, 4), sharey=True) - - for (key, ax) in zip(grouped.groups.keys(), axes.flatten()): - grouped.get_group(key).plot( - ax=ax, x="count", y=["relative-l2", "median"], loglog=True, title=str(key) - ) - ax.set_xlabel("vertex count of mesh A") - ax.set_ylabel("mapping error to mesh B") - ax.legend() - - plt.show() - - return 0 - - -if __name__ == "__main__": - import sys - - sys.exit(main(sys.argv)) diff --git a/tools/mapping-tester/preparemeshes.py b/tools/mapping-tester/preparemeshes.py index 9fdd77b8..78e77d99 100755 --- a/tools/mapping-tester/preparemeshes.py +++ b/tools/mapping-tester/preparemeshes.py @@ -49,7 +49,7 @@ def prepareMainMesh(meshdir, name, file, function, force=False): [pathName, tmpfilename] = os.path.split(os.path.normpath(mainMesh)) subprocess.run( [ - "vtk_calculator.py", + "precice-aste-evaluate", "--mesh", os.path.expandvars(file), "--function", @@ -87,7 +87,7 @@ def preparePartMesh(meshdir, name, p, force=False): [pathName, tmpfilename] = os.path.split(os.path.normpath(partMesh)) subprocess.run( [ - "partition_mesh.py", + "precice-aste-partition", "--mesh", mainMesh, "--algorithm",