From bca511e5c2a73e469733fba021ab07453d8c4e99 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 24 Aug 2023 14:18:17 +0200 Subject: [PATCH 001/113] enable vtk output and set timestep accordingly --- alpine/ChargedParticles.hpp | 2 +- alpine/PenningTrap.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 3ed092def..a3b7176ee 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -381,7 +381,7 @@ class ChargedParticles : public ippl::ParticleBase { rhoNorm_m = norm(rho_m); IpplTimings::stopTimer(sumTimer); - // dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); + dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); // rho = rho_e - rho_i double size = 1; diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index e1e14da08..c94aa481a 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -198,7 +198,8 @@ int main(int argc, char* argv[]) { Vector_t origin = rmin; unsigned int nrMax = 2048; // Max grid size in our studies double dxFinest = rmax[0] / nrMax; - const double dt = 0.5 * dxFinest; // size of timestep + //const double dt = 0.5 * dxFinest; // size of timestep + const double dt = 0.05; // size of timestep const bool isAllPeriodic = true; Mesh_t mesh(domain, hr, origin); From 34a80a7dac082aea3c88889dfa8bb94b6b03a564 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 25 Aug 2023 13:45:32 +0200 Subject: [PATCH 002/113] uncomment unused variable dxFines, nrMax to allow build --- alpine/PenningTrap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index c94aa481a..0a9a87f18 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -196,8 +196,8 @@ int main(int argc, char* argv[]) { Vector_t hr = rmax / nr; Vector_t origin = rmin; - unsigned int nrMax = 2048; // Max grid size in our studies - double dxFinest = rmax[0] / nrMax; + // unsigned int nrMax = 2048; // Max grid size in our studies + // double dxFinest = rmax[0] / nrMax; //const double dt = 0.5 * dxFinest; // size of timestep const double dt = 0.05; // size of timestep From 4081d418303e60e7c662f456f2c6e4ead961b123 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 28 Aug 2023 11:06:46 +0200 Subject: [PATCH 003/113] add CatalystAdaptor.h from CxxMultiChannelInputExample of ParaView --- alpine/CMakeLists.txt | 3 +- alpine/CatalystAdaptor.h | 154 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 alpine/CatalystAdaptor.h diff --git a/alpine/CMakeLists.txt b/alpine/CMakeLists.txt index 68dc41f4b..75e3625ba 100644 --- a/alpine/CMakeLists.txt +++ b/alpine/CMakeLists.txt @@ -13,7 +13,8 @@ link_directories ( set (IPPL_LIBS ippl ${MPI_CXX_LIBRARIES}) set (COMPILE_FLAGS ${OPAL_CXX_FLAGS}) -add_executable (PenningTrap PenningTrap.cpp) +add_executable (PenningTrap PenningTrap.cpp + CatalystAdaptor.h) target_link_libraries (PenningTrap ${IPPL_LIBS}) add_executable (UniformPlasmaTest UniformPlasmaTest.cpp) diff --git a/alpine/CatalystAdaptor.h b/alpine/CatalystAdaptor.h new file mode 100644 index 000000000..f378b0660 --- /dev/null +++ b/alpine/CatalystAdaptor.h @@ -0,0 +1,154 @@ +// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. +// SPDX-License-Identifier: BSD-3-Clause +#ifndef CatalystAdaptor_h +#define CatalystAdaptor_h + +#include "ChargedParticles.hpp" +#include + +#include +#include +#include +#include + +namespace CatalystAdaptor +{ + +/** + * In this example, we show how we can use Catalysts's C++ + * wrapper around conduit's C API to create Conduit nodes. + * This is not required. A C++ adaptor can just as + * conveniently use the Conduit C API to setup the + * `conduit_node`. However, this example shows that one can + * indeed use Catalyst's C++ API, if the developer so chooses. + */ + void Initialize(int argc, char* argv[]) + { + conduit_cpp::Node node; + for (int cc = 1; cc < argc; ++cc) + { + node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); + } + node["catalyst_load/implementation"] = "paraview"; + node["catalyst_load/search_paths/paraview"] = PARAVIEW_IMPL_DIR; + catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to initialize Catalyst: " << err << std::endl; + } + } + + void Execute(int cycle, double time, Grid& grid, Attributes& attribs, Particles& particles) + { + conduit_cpp::Node exec_params; + + // add time/cycle information + auto state = exec_params["catalyst/state"]; + state["timestep"].set(cycle); + state["time"].set(time); + + // Add channels. + // We have 2 channels here. First once is called 'grid'. + auto channel_grid = exec_params["catalyst/channels/grid"]; + + // Since this example is using Conduit Mesh Blueprint to define the mesh, + // we set the channel_grid's type to "mesh". + channel_grid["type"].set_string("mesh"); + + // now create the mesh. + auto mesh_grid = channel_grid["data"]; + + // start with coordsets (of course, the sequence is not important, just make + // it easier to think in this order). + mesh_grid["coordsets/coords/type"].set_string("explicit"); + + // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep + // copies. For zero-copy, we use the set_.._ptr(..) API. + mesh_grid["coordsets/coords/values/x"].set_external( + grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); + mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), + grid.GetNumberOfPoints(), + /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); + mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), + grid.GetNumberOfPoints(), + /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); + + // Next, add topology + mesh_grid["topologies/mesh/type"].set_string("unstructured"); + mesh_grid["topologies/mesh/coordset"].set_string("coords"); + mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); + mesh_grid["topologies/mesh/elements/connectivity"].set( + grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); + + // Finally, add fields. + auto fields_grid = mesh_grid["fields"]; + fields_grid["velocity/association"].set_string("vertex"); + fields_grid["velocity/topology"].set_string("mesh"); + fields_grid["velocity/volume_dependent"].set_string("false"); + + // velocity is stored in non-interlaced form (unlike points). + fields_grid["velocity/values/x"].set_external( + attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); + fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), + grid.GetNumberOfPoints(), + /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); + fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), + grid.GetNumberOfPoints(), + /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); + + // pressure is cell-data. + fields_grid["pressure/association"].set_string("element"); + fields_grid["pressure/topology"].set_string("mesh"); + fields_grid["pressure/volume_dependent"].set_string("false"); + fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); + + // Now add the second channel, called "particles". + auto channel_particles = exec_params["catalyst/channels/particles"]; + + // make the particles' time update every other step of the mesh's + channel_particles["state/cycle"].set(cycle - (cycle % 2)); + channel_particles["state/time"].set(time - (cycle % 2) * 0.1); + channel_particles["state/multiblock"].set(1); + + // Since this example is using Conduit Mesh Blueprint to define the mesh, + // we set the channel_particles's type to "mesh". + channel_particles["type"].set_string("mesh"); + + // now create the mesh. + auto mesh_particles = channel_particles["data"]; + mesh_particles["coordsets/coords/type"].set_string("explicit"); + mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); + mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); + mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); + + // now, the topology. + mesh_particles["topologies/mesh/type"].set_string("unstructured"); + mesh_particles["topologies/mesh/coordset"].set_string("coords"); + mesh_particles["topologies/mesh/elements/shape"].set_string("point"); + std::vector connectivity(particles.GetNumberOfPoints()); + std::iota(connectivity.begin(), connectivity.end(), 0); + mesh_particles["topologies/mesh/elements/connectivity"].set_external( + &connectivity[0], particles.GetNumberOfPoints()); + + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to execute Catalyst: " << err << std::endl; + } + } + + void Finalize() + { + conduit_cpp::Node node; + catalyst_status err = catalyst_finalize(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to finalize Catalyst: " << err << std::endl; + } + } +} + +#endif From b1b0474f2a008be363472c8d80dc4dfe92253845 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 28 Aug 2023 14:07:06 +0200 Subject: [PATCH 004/113] update CMakeLists to include catalyst and print message about C compiler --- CMakeLists.txt | 9 +++++++++ alpine/CMakeLists.txt | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c87050f3c..ac532422a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,10 @@ endif () set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules") find_package (MPI REQUIRED) +message (STATUS "The C compiler identification is: ${CMAKE_C_COMPILER_ID}") message (STATUS "The C++ compiler identification is: ${CMAKE_CXX_COMPILER_ID}") message (STATUS "The C++ compiler version is: ${CMAKE_CXX_COMPILER_VERSION}") +message (STATUS "The MPI C compiler is: ${MPI_C_COMPILER}") message (STATUS "The MPI C++ compiler is: ${MPI_CXX_COMPILER}") message (STATUS "The underlying C++ compiler is: ${CMAKE_CXX_COMPILER}") @@ -83,6 +85,13 @@ if (ENABLE_ALPINE) add_subdirectory (alpine) endif () +option(ENABLE_CATALYST "Build example with Catalyst enabled" ON) +if (ENABLE_CATALYST) + find_package(catalyst REQUIRED + PATHS "${ParaView_DIR}/catalyst") +endif () + + option (ENABLE_UNIT_TESTS "Enable unit tests" OFF) if (ENABLE_UNIT_TESTS) find_package (GTest REQUIRED HINT $ENV{GTEST_PREFIX}) diff --git a/alpine/CMakeLists.txt b/alpine/CMakeLists.txt index 75e3625ba..2c7c64aac 100644 --- a/alpine/CMakeLists.txt +++ b/alpine/CMakeLists.txt @@ -15,7 +15,17 @@ set (COMPILE_FLAGS ${OPAL_CXX_FLAGS}) add_executable (PenningTrap PenningTrap.cpp CatalystAdaptor.h) -target_link_libraries (PenningTrap ${IPPL_LIBS}) + +target_compile_definitions(PenningTrap + PRIVATE + "PARAVIEW_IMPL_DIR=\"${ParaView_CATALYST_DIR}\"" + ENABLE_CATALYST=1) + # target_link_libraries(PenningTrap + # PRIVATE + # catalyst::catalyst + # ${IPPL_LIBS}) + +target_link_libraries (PenningTrap ${IPPL_LIBS} catalyst::catalyst) add_executable (UniformPlasmaTest UniformPlasmaTest.cpp) target_link_libraries (UniformPlasmaTest ${IPPL_LIBS}) From 9407ff3e283b2a804876780598df430b9d29b7c4 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 29 Aug 2023 10:55:31 +0200 Subject: [PATCH 005/113] add C as a language in IPPL to have the C compiler available --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac532422a..a54aec1dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.1) -project (IPPL CXX) +project (IPPL LANGUAGES C CXX) set (IPPL_VERSION_MAJOR 3) set (IPPL_VERSION_MINOR 0.1) From 7b6e9de3fc33eff9b10893ecaa5dfb654dfd2bf3 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 29 Aug 2023 12:13:47 +0200 Subject: [PATCH 006/113] clean up import of target to have them better debuggable with Jens * adding mesage of imported targets from catalyst * link catalyst against IPPL (need to put that in an if clause) * include "catalyst.hpp" in ChargedParticles --- CMakeLists.txt | 10 ++++++++-- alpine/CMakeLists.txt | 15 ++------------- alpine/ChargedParticles.hpp | 1 + src/CMakeLists.txt | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a54aec1dc..04b685446 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,8 +87,14 @@ endif () option(ENABLE_CATALYST "Build example with Catalyst enabled" ON) if (ENABLE_CATALYST) - find_package(catalyst REQUIRED - PATHS "${ParaView_DIR}/catalyst") + get_property(importTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) + + find_package(catalyst REQUIRED) + get_property(importTargetsAfter DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) + list(REMOVE_ITEM importTargetsAfter ${importTargets}) + + message("Imported Targets from catalyst:\n ${importTargetsAfter}") + # PATHS "${ParaView_DIR}/catalyst") endif () diff --git a/alpine/CMakeLists.txt b/alpine/CMakeLists.txt index 2c7c64aac..89b48bb03 100644 --- a/alpine/CMakeLists.txt +++ b/alpine/CMakeLists.txt @@ -13,19 +13,8 @@ link_directories ( set (IPPL_LIBS ippl ${MPI_CXX_LIBRARIES}) set (COMPILE_FLAGS ${OPAL_CXX_FLAGS}) -add_executable (PenningTrap PenningTrap.cpp - CatalystAdaptor.h) - -target_compile_definitions(PenningTrap - PRIVATE - "PARAVIEW_IMPL_DIR=\"${ParaView_CATALYST_DIR}\"" - ENABLE_CATALYST=1) - # target_link_libraries(PenningTrap - # PRIVATE - # catalyst::catalyst - # ${IPPL_LIBS}) - -target_link_libraries (PenningTrap ${IPPL_LIBS} catalyst::catalyst) +add_executable (PenningTrap PenningTrap.cpp) +target_link_libraries (PenningTrap PUBLIC ${IPPL_LIBS}) add_executable (UniformPlasmaTest UniformPlasmaTest.cpp) target_link_libraries (UniformPlasmaTest ${IPPL_LIBS}) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index a3b7176ee..7bba3494b 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -17,6 +17,7 @@ // #include "Ippl.h" +#include #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 955a0317a..ecf7500fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,7 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY}) +target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst::catalyst) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From dec963d539d0e46af265b691a7b433ae9eacbccb Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 29 Aug 2023 16:07:10 +0200 Subject: [PATCH 007/113] update CMakeLists to "work" with Catalyst * error if find_path imports to GLOBAL * link error if catalyst::catalyst --- CMakeLists.txt | 59 +++++++++++++++++++++---------------- alpine/ChargedParticles.hpp | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04b685446..1edfa9b58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,17 @@ set (IPPL_VERSION_NAME "V${IPPL_VERSION_MAJOR}.${IPPL_VERSION_MINOR}") set (IPPL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +include(CMakePrintHelpers) + if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE - ) + set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE + ) endif () if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - add_definitions (-DNOPAssert) + add_definitions (-DNOPAssert) endif () add_compile_options (-Wall) @@ -39,7 +41,7 @@ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") # Compile using C++20 for CPU builds if (${CMAKE_CXX_COMPILER} MATCHES ".*mpicxx") - set (CMAKE_CXX_STANDARD 20) + set (CMAKE_CXX_STANDARD 20) endif () @@ -59,9 +61,9 @@ find_package(Kokkos REQUIRED) option (ENABLE_FFT "Enable FFT transform" OFF) if (ENABLE_FFT) - add_definitions (-DENABLE_FFT) - find_package(Heffte 2.2.0 REQUIRED) - message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") + add_definitions (-DENABLE_FFT) + find_package(Heffte 2.2.0 REQUIRED) + message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") endif () option (ENABLE_SOLVERS "Enable IPPL solvers" OFF) @@ -70,26 +72,31 @@ add_subdirectory (src) option (ENABLE_TESTS "Enable IPPL tests" OFF) if (ENABLE_TESTS) - add_subdirectory (test) + add_subdirectory (test) endif () option (ENABLE_ALPINE, "Enable Alpine" OFF) if (ENABLE_ALPINE) - if (NOT ENABLE_SOLVERS) - message (FATAL_ERROR "Cannot enable Alpine since Solver not enabled (-DENABLE_SOLVERS=ON)!") - endif () - if (NOT ENABLE_FFT) - message (FATAL_ERROR "Cannot enable Alpine since FFT not enabled (-DENABLE_FFT=ON)!") - endif () - message (STATUS "Enable Alpine") - add_subdirectory (alpine) + if (NOT ENABLE_SOLVERS) + message (FATAL_ERROR "Cannot enable Alpine since Solver not enabled (-DENABLE_SOLVERS=ON)!") + endif () + if (NOT ENABLE_FFT) + message (FATAL_ERROR "Cannot enable Alpine since FFT not enabled (-DENABLE_FFT=ON)!") + endif () + message (STATUS "Enable Alpine") + add_subdirectory (alpine) endif () option(ENABLE_CATALYST "Build example with Catalyst enabled" ON) if (ENABLE_CATALYST) get_property(importTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) - find_package(catalyst REQUIRED) + find_package(catalyst 2.0 REQUIRED) + + cmake_print_properties( + TARGETS catalyst::catalyst + PROPERTIES POSITION_INDEPENDENT_CODE + ) get_property(importTargetsAfter DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) list(REMOVE_ITEM importTargetsAfter ${importTargets}) @@ -100,18 +107,18 @@ endif () option (ENABLE_UNIT_TESTS "Enable unit tests" OFF) if (ENABLE_UNIT_TESTS) - find_package (GTest REQUIRED HINT $ENV{GTEST_PREFIX}) - add_subdirectory (unit_tests) + find_package (GTest REQUIRED HINT $ENV{GTEST_PREFIX}) + add_subdirectory (unit_tests) endif () configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake ) + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake ) install ( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME}" - RENAME ${PROJECT_NAME}Config.cmake - ) + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME}" + RENAME ${PROJECT_NAME}Config.cmake + ) # vi: set et ts=4 sw=4 sts=4: diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 7bba3494b..33f5819af 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -17,7 +17,7 @@ // #include "Ippl.h" -#include +#include #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecf7500fa..a01b05900 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,7 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst::catalyst) +target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From 90a93cd8e643c565cfa18fcba391a61acf64e2da Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 10:55:22 +0200 Subject: [PATCH 008/113] resolve import problem of Catalyst 2.0 API In order to link against catalyst::catalyst, the find_package needs to provide the GLOBAL keyword. Then linkage, is working as well as the headers are found properly. However the GLOBAL keyword is only available by CMake>=3.24 therefore also the bump up in the cmake_minimum_required. --- CMakeLists.txt | 4 ++-- alpine/ChargedParticles.hpp | 2 +- src/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1edfa9b58..9e857d912 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.24) project (IPPL LANGUAGES C CXX) set (IPPL_VERSION_MAJOR 3) set (IPPL_VERSION_MINOR 0.1) @@ -91,7 +91,7 @@ option(ENABLE_CATALYST "Build example with Catalyst enabled" ON) if (ENABLE_CATALYST) get_property(importTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) - find_package(catalyst 2.0 REQUIRED) + find_package(catalyst 2.0 GLOBAL REQUIRED) cmake_print_properties( TARGETS catalyst::catalyst diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 33f5819af..7bba3494b 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -17,7 +17,7 @@ // #include "Ippl.h" -#include +#include #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a01b05900..ecf7500fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,7 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst) +target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst::catalyst) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From 4ef47d5dbe26438a96a4965f8aa991da8017ffe0 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 12:07:00 +0200 Subject: [PATCH 009/113] cleanup CMake files for catalyst install * add preprocessor macro to enable the catalyst.hpp only when ENABLE_CATALYST is set * add condition to linkage against IPPL which is only performed if ENABLE_CATALYST * some messages added about catalyst direction if it is found --- CMakeLists.txt | 16 +++------------- alpine/ChargedParticles.hpp | 5 ++++- src/CMakeLists.txt | 7 ++++++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e857d912..bea3dd4ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,21 +87,11 @@ if (ENABLE_ALPINE) add_subdirectory (alpine) endif () -option(ENABLE_CATALYST "Build example with Catalyst enabled" ON) +option(ENABLE_CATALYST "Build example with Catalyst enabled" OFF) if (ENABLE_CATALYST) - get_property(importTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) - find_package(catalyst 2.0 GLOBAL REQUIRED) - - cmake_print_properties( - TARGETS catalyst::catalyst - PROPERTIES POSITION_INDEPENDENT_CODE - ) - get_property(importTargetsAfter DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS) - list(REMOVE_ITEM importTargetsAfter ${importTargets}) - - message("Imported Targets from catalyst:\n ${importTargetsAfter}") - # PATHS "${ParaView_DIR}/catalyst") + message (STATUS "Enable Catalyst In-Situ Visualization") + message (STATUS "Found catalyst_DIR: ${catalyst_DIR}") endif () diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 7bba3494b..04076b5db 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -17,7 +17,10 @@ // #include "Ippl.h" -#include + +#ifdef ENABLE_CATALYST + #include +#endif #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecf7500fa..5d3e3fe26 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,12 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} catalyst::catalyst) +if (ENABLE_CATALYST) + # define preprocessor macro to enable catalyst header file + target_compile_definitions(ippl PUBLIC -D ENABLE_CATALYST) +endif() + +target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} $<$:catalyst::catalyst>) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From 053e3b9e3039fca3a8cebb42c1402014abaeee10 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 14:42:06 +0200 Subject: [PATCH 010/113] update CMakeLists to follow scheme similar to ENABLE_HEFFTE, reindent --- CMakeLists.txt | 58 +++++++++++++++++++++++----------------------- src/CMakeLists.txt | 8 ++++--- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bea3dd4ee..77bc98b1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,14 +10,14 @@ set (IPPL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) include(CMakePrintHelpers) if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." - FORCE - ) + set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE + ) endif () if (${CMAKE_BUILD_TYPE} STREQUAL "Release") - add_definitions (-DNOPAssert) + add_definitions (-DNOPAssert) endif () add_compile_options (-Wall) @@ -41,7 +41,7 @@ set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") # Compile using C++20 for CPU builds if (${CMAKE_CXX_COMPILER} MATCHES ".*mpicxx") - set (CMAKE_CXX_STANDARD 20) + set (CMAKE_CXX_STANDARD 20) endif () @@ -61,9 +61,9 @@ find_package(Kokkos REQUIRED) option (ENABLE_FFT "Enable FFT transform" OFF) if (ENABLE_FFT) - add_definitions (-DENABLE_FFT) - find_package(Heffte 2.2.0 REQUIRED) - message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") + add_definitions (-DENABLE_FFT) + find_package(Heffte 2.2.0 REQUIRED) + message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") endif () option (ENABLE_SOLVERS "Enable IPPL solvers" OFF) @@ -72,45 +72,45 @@ add_subdirectory (src) option (ENABLE_TESTS "Enable IPPL tests" OFF) if (ENABLE_TESTS) - add_subdirectory (test) + add_subdirectory (test) endif () option (ENABLE_ALPINE, "Enable Alpine" OFF) if (ENABLE_ALPINE) - if (NOT ENABLE_SOLVERS) - message (FATAL_ERROR "Cannot enable Alpine since Solver not enabled (-DENABLE_SOLVERS=ON)!") - endif () - if (NOT ENABLE_FFT) - message (FATAL_ERROR "Cannot enable Alpine since FFT not enabled (-DENABLE_FFT=ON)!") - endif () - message (STATUS "Enable Alpine") - add_subdirectory (alpine) + if (NOT ENABLE_SOLVERS) + message (FATAL_ERROR "Cannot enable Alpine since Solver not enabled (-DENABLE_SOLVERS=ON)!") + endif () + if (NOT ENABLE_FFT) + message (FATAL_ERROR "Cannot enable Alpine since FFT not enabled (-DENABLE_FFT=ON)!") + endif () + message (STATUS "Enable Alpine") + add_subdirectory (alpine) endif () option(ENABLE_CATALYST "Build example with Catalyst enabled" OFF) if (ENABLE_CATALYST) - find_package(catalyst 2.0 GLOBAL REQUIRED) - message (STATUS "Enable Catalyst In-Situ Visualization") - message (STATUS "Found catalyst_DIR: ${catalyst_DIR}") + find_package(catalyst 2.0 GLOBAL REQUIRED) + message (STATUS "Enable Catalyst") + message (STATUS "Found catalyst_DIR: ${catalyst_DIR}") endif () option (ENABLE_UNIT_TESTS "Enable unit tests" OFF) if (ENABLE_UNIT_TESTS) - find_package (GTest REQUIRED HINT $ENV{GTEST_PREFIX}) - add_subdirectory (unit_tests) + find_package (GTest REQUIRED HINT $ENV{GTEST_PREFIX}) + add_subdirectory (unit_tests) endif () configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake ) + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake ) install ( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME}" - RENAME ${PROJECT_NAME}Config.cmake - ) + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config_install.cmake + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME}" + RENAME ${PROJECT_NAME}Config.cmake + ) -# vi: set et ts=4 sw=4 sts=4: +# vim: set et ts=4 sw=4 sts=4: # Local Variables: # mode: cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d3e3fe26..32144b411 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,11 +96,13 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) if (ENABLE_CATALYST) - # define preprocessor macro to enable catalyst header file - target_compile_definitions(ippl PUBLIC -D ENABLE_CATALYST) + set (CATALYST_LIBRARY catalyst::catalyst) + target_compile_definitions(ippl PUBLIC -D ENABLE_CATALYST) +else() + set (CATALYST_LIBRARY "") endif() -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} $<$:catalyst::catalyst>) +target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} ${CATALYST_LIBRARY}) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From 6504e3c5e71ec22963810a5f1b770ce43b71bc6f Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 16:17:15 +0200 Subject: [PATCH 011/113] add basic folder structure and CMakeLists for in-situ stream * following CMakeLists pattern similar to cbb9de5199b346040a2afcf1fa6421a93a538a0b --- src/CMakeLists.txt | 2 ++ src/Stream/CMakeLists.txt | 24 ++++++++++++++++++++++++ src/Stream/InSitu/CMakeLists.txt | 24 ++++++++++++++++++++++++ src/Stream/InSitu/CatalystAdaptor.h | 8 ++++++++ 4 files changed, 58 insertions(+) create mode 100644 src/Stream/CMakeLists.txt create mode 100644 src/Stream/InSitu/CMakeLists.txt create mode 100644 src/Stream/InSitu/CatalystAdaptor.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 32144b411..6e17ca512 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,6 +79,8 @@ add_subdirectory (Utility) add_subdirectory (Expression) add_subdirectory (Types) add_subdirectory (Partition) +add_subdirectory (Stream) +add_subdirectory (Stream/InSitu) if (ENABLE_SOLVERS) message (STATUS "Adding Solver subdirectory") diff --git a/src/Stream/CMakeLists.txt b/src/Stream/CMakeLists.txt new file mode 100644 index 000000000..cf5c3b671 --- /dev/null +++ b/src/Stream/CMakeLists.txt @@ -0,0 +1,24 @@ +set (_SRCS +) + +set (_HDRS +) + +include_DIRECTORIES ( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_ippl_sources (${_SRCS}) +add_ippl_headers (${_HDRS}) + +install (FILES ${_HDRS} DESTINATION include/Stream) + + +# vi: set et ts=4 sw=4 sts=4: + +# Local Variables: +# mode: cmake +# cmake-tab-width: 4 +# indent-tabs-mode: nil +# require-final-newline: nil +# End: \ No newline at end of file diff --git a/src/Stream/InSitu/CMakeLists.txt b/src/Stream/InSitu/CMakeLists.txt new file mode 100644 index 000000000..6b3ddbcfc --- /dev/null +++ b/src/Stream/InSitu/CMakeLists.txt @@ -0,0 +1,24 @@ +set (_SRCS +) + +set (_HDRS + CatalystAdaptor.h +) + +include_DIRECTORIES ( + ${CMAKE_CURRENT_SOURCE_DIR} +) + +add_ippl_sources (${_SRCS}) +add_ippl_headers (${_HDRS}) + +install (FILES ${_HDRS} DESTINATION include/Stream/InSitu) + +# vi: set et ts=4 sw=4 sts=4: + +# Local Variables: +# mode: cmake +# cmake-tab-width: 4 +# indent-tabs-mode: nil +# require-final-newline: nil +# End: \ No newline at end of file diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h new file mode 100644 index 000000000..2c2e00885 --- /dev/null +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -0,0 +1,8 @@ +// +// Created by felix on 8/30/23. +// + +#ifndef IPPL_CATALYSTADAPTOR_H +#define IPPL_CATALYSTADAPTOR_H + +#endif //IPPL_CATALYSTADAPTOR_H From 394a06ccd99e4cf2da0ccb1c56d386f391614062 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 16:23:00 +0200 Subject: [PATCH 012/113] add build, .cache, .idea and CMakeFiles folder to .gitignore --- .gitignore | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 938d62463..ace312436 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,12 @@ manual/*.toc manual/*.idx manual/*.lof manual/*.lot -manual/ippl_user_guide.pdf \ No newline at end of file +manual/ippl_user_guide.pdf + +# CMake and Build folder +CMakeFiles/ +build* + +# temporary folder +.cache/ +.idea/ From 1c094bdb7f0b73aedea3e9bcd19acd0f68d89a1f Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 16:56:48 +0200 Subject: [PATCH 013/113] add TestCatalystAdaptor copied from TestFieldBC As a starting point the TestFieldBC structure will be used to write the adaptor and have a hopefully working executable --- test/CMakeLists.txt | 4 ++ test/stream/CMakeLists.txt | 30 ++++++++ test/stream/TestCatalystAdaptor.cpp | 104 ++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 test/stream/CMakeLists.txt create mode 100644 test/stream/TestCatalystAdaptor.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d2aad5b13..4da72f611 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,6 +24,10 @@ add_subdirectory (particle) add_subdirectory (region) add_subdirectory (serialization) +if (ENABLE_CATALYST) + add_subdirectory (stream) +endif () + # vi: set et ts=4 sw=4 sts=4: # Local Variables: diff --git a/test/stream/CMakeLists.txt b/test/stream/CMakeLists.txt new file mode 100644 index 000000000..7248e5f5f --- /dev/null +++ b/test/stream/CMakeLists.txt @@ -0,0 +1,30 @@ +file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") +message (STATUS "Adding index test found in ${_relPath}") + +include_directories ( + ${CMAKE_SOURCE_DIR}/src +) + +link_directories ( + ${CMAKE_CURRENT_SOURCE_DIR} + ${Kokkos_DIR}/.. +) + +set (IPPL_LIBS ippl) +set (COMPILE_FLAGS ${OPAL_CXX_FLAGS}) + +add_executable (TestCatalystAdaptor TestCatalystAdaptor.cpp) +target_link_libraries ( + TestCatalystAdaptor + ${IPPL_LIBS} + ${MPI_CXX_LIBRARIES} +) + +# vi: set et ts=4 sw=4 sts=4: + +# Local Variables: +# mode: cmake +# cmake-tab-width: 4 +# indent-tabs-mode: nil +# require-final-newline: nil +# End: diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp new file mode 100644 index 000000000..6b2dea8aa --- /dev/null +++ b/test/stream/TestCatalystAdaptor.cpp @@ -0,0 +1,104 @@ +// Tests the application of various kinds of boundary conditions on fields +#include "Ippl.h" + +#include +#include +#include + +int main(int argc, char* argv[]) { + Ippl ippl(argc, argv); + + constexpr unsigned int dim = 3; + + int pt = 4; + ippl::Index I(pt); + ippl::NDIndex owned(I, I, I); + + ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims + for (unsigned int d = 0; d < dim; d++) + allParallel[d] = ippl::PARALLEL; + + ippl::FieldLayout layout(owned, allParallel); + + double dx = 1.0 / double(pt); + ippl::Vector hx = {dx, dx, dx}; + ippl::Vector origin = {0, 0, 0}; + + using Mesh_t = ippl::UniformCartesian; + using Centering_t = Mesh_t::DefaultCentering; + + Mesh_t mesh(owned, hx, origin); + + typedef ippl::Field field_type; + + typedef ippl::BConds bc_type; + + bc_type bcField; + + // X direction periodic BC + for (unsigned int i = 0; i < 2; ++i) { + bcField[i] = std::make_shared>(i); + } + ////Lower Y face + bcField[2] = std::make_shared>(2); + ////Higher Y face + bcField[3] = std::make_shared>(3, 7.0); + ////Lower Z face + bcField[4] = std::make_shared>(4); + ////Higher Z face + bcField[5] = + std::make_shared>(5, 0.0, 1.0); + + // std::cout << bcField << std::endl; + std::cout << layout << std::endl; + + field_type field(mesh, layout, 1); + + field = 1.0; + + const ippl::NDIndex& lDom = layout.getLocalNDIndex(); + const int nghost = field.getNghost(); + using mdrange_type = Kokkos::MDRangePolicy>; + typename field_type::view_type& view = field.getView(); + + Kokkos::parallel_for( + "Assign field", + mdrange_type({nghost, nghost, nghost}, + {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), + KOKKOS_LAMBDA(const int i, const int j, const int k) { + // local to global index conversion + const size_t ig = i + lDom[0].first() - nghost; + // const size_t jg = j + lDom[1].first() - nghost; + // const size_t kg = k + lDom[2].first() - nghost; + double x = (ig + 0.5) * hx[0] + origin[0]; + // double y = (jg + 0.5) * hx[1]; + // double z = (kg + 0.5) * hx[2]; + + // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); + // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); + // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); + view(i, j, k) = x; + }); + + // field = field * 10.0; + + bcField.findBCNeighbors(field); + + unsigned int niter = 5; + + for (unsigned int i = 0; i < niter; ++i) { + bcField.apply(field); + } + + int nRanks = Ippl::Comm->size(); + for (int rank = 0; rank < nRanks; ++rank) { + if (rank == Ippl::Comm->rank()) { + std::string fname = "field_AllBC_" + std::to_string(rank) + ".dat"; + Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); + field.write(out); + } + Ippl::Comm->barrier(); + } + + return 0; +} From fe5d3c24ca458f7a5e01cd607d71eec9f4a12461 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 30 Aug 2023 17:14:09 +0200 Subject: [PATCH 014/113] move CatalystAdaptor to Stream folder --- alpine/CatalystAdaptor.h | 154 --------------------------- alpine/ChargedParticles.hpp | 4 - src/Stream/InSitu/CatalystAdaptor.h | 157 ++++++++++++++++++++++++++-- test/stream/TestCatalystAdaptor.cpp | 1 + 4 files changed, 152 insertions(+), 164 deletions(-) delete mode 100644 alpine/CatalystAdaptor.h diff --git a/alpine/CatalystAdaptor.h b/alpine/CatalystAdaptor.h deleted file mode 100644 index f378b0660..000000000 --- a/alpine/CatalystAdaptor.h +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. -// SPDX-License-Identifier: BSD-3-Clause -#ifndef CatalystAdaptor_h -#define CatalystAdaptor_h - -#include "ChargedParticles.hpp" -#include - -#include -#include -#include -#include - -namespace CatalystAdaptor -{ - -/** - * In this example, we show how we can use Catalysts's C++ - * wrapper around conduit's C API to create Conduit nodes. - * This is not required. A C++ adaptor can just as - * conveniently use the Conduit C API to setup the - * `conduit_node`. However, this example shows that one can - * indeed use Catalyst's C++ API, if the developer so chooses. - */ - void Initialize(int argc, char* argv[]) - { - conduit_cpp::Node node; - for (int cc = 1; cc < argc; ++cc) - { - node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); - } - node["catalyst_load/implementation"] = "paraview"; - node["catalyst_load/search_paths/paraview"] = PARAVIEW_IMPL_DIR; - catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) - { - std::cerr << "Failed to initialize Catalyst: " << err << std::endl; - } - } - - void Execute(int cycle, double time, Grid& grid, Attributes& attribs, Particles& particles) - { - conduit_cpp::Node exec_params; - - // add time/cycle information - auto state = exec_params["catalyst/state"]; - state["timestep"].set(cycle); - state["time"].set(time); - - // Add channels. - // We have 2 channels here. First once is called 'grid'. - auto channel_grid = exec_params["catalyst/channels/grid"]; - - // Since this example is using Conduit Mesh Blueprint to define the mesh, - // we set the channel_grid's type to "mesh". - channel_grid["type"].set_string("mesh"); - - // now create the mesh. - auto mesh_grid = channel_grid["data"]; - - // start with coordsets (of course, the sequence is not important, just make - // it easier to think in this order). - mesh_grid["coordsets/coords/type"].set_string("explicit"); - - // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep - // copies. For zero-copy, we use the set_.._ptr(..) API. - mesh_grid["coordsets/coords/values/x"].set_external( - grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); - mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), - grid.GetNumberOfPoints(), - /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); - mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), - grid.GetNumberOfPoints(), - /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); - - // Next, add topology - mesh_grid["topologies/mesh/type"].set_string("unstructured"); - mesh_grid["topologies/mesh/coordset"].set_string("coords"); - mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); - mesh_grid["topologies/mesh/elements/connectivity"].set( - grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); - - // Finally, add fields. - auto fields_grid = mesh_grid["fields"]; - fields_grid["velocity/association"].set_string("vertex"); - fields_grid["velocity/topology"].set_string("mesh"); - fields_grid["velocity/volume_dependent"].set_string("false"); - - // velocity is stored in non-interlaced form (unlike points). - fields_grid["velocity/values/x"].set_external( - attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); - fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), - grid.GetNumberOfPoints(), - /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); - fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), - grid.GetNumberOfPoints(), - /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); - - // pressure is cell-data. - fields_grid["pressure/association"].set_string("element"); - fields_grid["pressure/topology"].set_string("mesh"); - fields_grid["pressure/volume_dependent"].set_string("false"); - fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); - - // Now add the second channel, called "particles". - auto channel_particles = exec_params["catalyst/channels/particles"]; - - // make the particles' time update every other step of the mesh's - channel_particles["state/cycle"].set(cycle - (cycle % 2)); - channel_particles["state/time"].set(time - (cycle % 2) * 0.1); - channel_particles["state/multiblock"].set(1); - - // Since this example is using Conduit Mesh Blueprint to define the mesh, - // we set the channel_particles's type to "mesh". - channel_particles["type"].set_string("mesh"); - - // now create the mesh. - auto mesh_particles = channel_particles["data"]; - mesh_particles["coordsets/coords/type"].set_string("explicit"); - mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); - mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); - mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); - - // now, the topology. - mesh_particles["topologies/mesh/type"].set_string("unstructured"); - mesh_particles["topologies/mesh/coordset"].set_string("coords"); - mesh_particles["topologies/mesh/elements/shape"].set_string("point"); - std::vector connectivity(particles.GetNumberOfPoints()); - std::iota(connectivity.begin(), connectivity.end(), 0); - mesh_particles["topologies/mesh/elements/connectivity"].set_external( - &connectivity[0], particles.GetNumberOfPoints()); - - catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); - if (err != catalyst_status_ok) - { - std::cerr << "Failed to execute Catalyst: " << err << std::endl; - } - } - - void Finalize() - { - conduit_cpp::Node node; - catalyst_status err = catalyst_finalize(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) - { - std::cerr << "Failed to finalize Catalyst: " << err << std::endl; - } - } -} - -#endif diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 04076b5db..a3b7176ee 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -18,10 +18,6 @@ #include "Ippl.h" -#ifdef ENABLE_CATALYST - #include -#endif - #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 2c2e00885..e57f7844a 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -1,8 +1,153 @@ -// -// Created by felix on 8/30/23. -// +// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. +// SPDX-License-Identifier: BSD-3-Clause +#ifndef CatalystAdaptor_h +#define CatalystAdaptor_h -#ifndef IPPL_CATALYSTADAPTOR_H -#define IPPL_CATALYSTADAPTOR_H +#include -#endif //IPPL_CATALYSTADAPTOR_H +#include +#include +#include +#include + +namespace CatalystAdaptor +{ + +/** + * In this example, we show how we can use Catalysts's C++ + * wrapper around conduit's C API to create Conduit nodes. + * This is not required. A C++ adaptor can just as + * conveniently use the Conduit C API to setup the + * `conduit_node`. However, this example shows that one can + * indeed use Catalyst's C++ API, if the developer so chooses. + */ + void Initialize(int argc, char* argv[]) + { + conduit_cpp::Node node; + for (int cc = 1; cc < argc; ++cc) + { + node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); + } + node["catalyst_load/implementation"] = "paraview"; + node["catalyst_load/search_paths/paraview"] = PARAVIEW_IMPL_DIR; + catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to initialize Catalyst: " << err << std::endl; + } + } + + void Execute(int cycle, double time, Grid& grid, Attributes& attribs, Particles& particles) + { + conduit_cpp::Node exec_params; + + // add time/cycle information + auto state = exec_params["catalyst/state"]; + state["timestep"].set(cycle); + state["time"].set(time); + + // Add channels. + // We have 2 channels here. First once is called 'grid'. + auto channel_grid = exec_params["catalyst/channels/grid"]; + + // Since this example is using Conduit Mesh Blueprint to define the mesh, + // we set the channel_grid's type to "mesh". + channel_grid["type"].set_string("mesh"); + + // now create the mesh. + auto mesh_grid = channel_grid["data"]; + + // start with coordsets (of course, the sequence is not important, just make + // it easier to think in this order). + mesh_grid["coordsets/coords/type"].set_string("explicit"); + + // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep + // copies. For zero-copy, we use the set_.._ptr(..) API. + mesh_grid["coordsets/coords/values/x"].set_external( + grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); + mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), + grid.GetNumberOfPoints(), + /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); + mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), + grid.GetNumberOfPoints(), + /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); + + // Next, add topology + mesh_grid["topologies/mesh/type"].set_string("unstructured"); + mesh_grid["topologies/mesh/coordset"].set_string("coords"); + mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); + mesh_grid["topologies/mesh/elements/connectivity"].set( + grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); + + // Finally, add fields. + auto fields_grid = mesh_grid["fields"]; + fields_grid["velocity/association"].set_string("vertex"); + fields_grid["velocity/topology"].set_string("mesh"); + fields_grid["velocity/volume_dependent"].set_string("false"); + + // velocity is stored in non-interlaced form (unlike points). + fields_grid["velocity/values/x"].set_external( + attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); + fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), + grid.GetNumberOfPoints(), + /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); + fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), + grid.GetNumberOfPoints(), + /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); + + // pressure is cell-data. + fields_grid["pressure/association"].set_string("element"); + fields_grid["pressure/topology"].set_string("mesh"); + fields_grid["pressure/volume_dependent"].set_string("false"); + fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); + + // Now add the second channel, called "particles". + auto channel_particles = exec_params["catalyst/channels/particles"]; + + // make the particles' time update every other step of the mesh's + channel_particles["state/cycle"].set(cycle - (cycle % 2)); + channel_particles["state/time"].set(time - (cycle % 2) * 0.1); + channel_particles["state/multiblock"].set(1); + + // Since this example is using Conduit Mesh Blueprint to define the mesh, + // we set the channel_particles's type to "mesh". + channel_particles["type"].set_string("mesh"); + + // now create the mesh. + auto mesh_particles = channel_particles["data"]; + mesh_particles["coordsets/coords/type"].set_string("explicit"); + mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); + mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); + mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), + particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); + + // now, the topology. + mesh_particles["topologies/mesh/type"].set_string("unstructured"); + mesh_particles["topologies/mesh/coordset"].set_string("coords"); + mesh_particles["topologies/mesh/elements/shape"].set_string("point"); + std::vector connectivity(particles.GetNumberOfPoints()); + std::iota(connectivity.begin(), connectivity.end(), 0); + mesh_particles["topologies/mesh/elements/connectivity"].set_external( + &connectivity[0], particles.GetNumberOfPoints()); + + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to execute Catalyst: " << err << std::endl; + } + } + + void Finalize() + { + conduit_cpp::Node node; + catalyst_status err = catalyst_finalize(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to finalize Catalyst: " << err << std::endl; + } + } +} + +#endif diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 6b2dea8aa..0f40885f5 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -1,5 +1,6 @@ // Tests the application of various kinds of boundary conditions on fields #include "Ippl.h" +#include "Stream/InSitu/CatalystAdaptor.h" #include #include From fdb39335ab6f8d1430135ca26749ee04612e2707 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 09:53:14 +0200 Subject: [PATCH 015/113] comment out whole CatalystAdaptorExecute --- src/Stream/InSitu/CatalystAdaptor.h | 200 ++++++++++++++-------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index e57f7844a..ed5555772 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -29,7 +29,7 @@ namespace CatalystAdaptor node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); } node["catalyst_load/implementation"] = "paraview"; - node["catalyst_load/search_paths/paraview"] = PARAVIEW_IMPL_DIR; + //node["catalyst_load/search_paths/paraview"] = "$PATH"; catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { @@ -37,106 +37,106 @@ namespace CatalystAdaptor } } - void Execute(int cycle, double time, Grid& grid, Attributes& attribs, Particles& particles) + void Execute() //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) { - conduit_cpp::Node exec_params; - - // add time/cycle information - auto state = exec_params["catalyst/state"]; - state["timestep"].set(cycle); - state["time"].set(time); - - // Add channels. - // We have 2 channels here. First once is called 'grid'. - auto channel_grid = exec_params["catalyst/channels/grid"]; - - // Since this example is using Conduit Mesh Blueprint to define the mesh, - // we set the channel_grid's type to "mesh". - channel_grid["type"].set_string("mesh"); - - // now create the mesh. - auto mesh_grid = channel_grid["data"]; - - // start with coordsets (of course, the sequence is not important, just make - // it easier to think in this order). - mesh_grid["coordsets/coords/type"].set_string("explicit"); - - // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep - // copies. For zero-copy, we use the set_.._ptr(..) API. - mesh_grid["coordsets/coords/values/x"].set_external( - grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); - mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), - grid.GetNumberOfPoints(), - /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); - mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), - grid.GetNumberOfPoints(), - /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); - - // Next, add topology - mesh_grid["topologies/mesh/type"].set_string("unstructured"); - mesh_grid["topologies/mesh/coordset"].set_string("coords"); - mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); - mesh_grid["topologies/mesh/elements/connectivity"].set( - grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); - - // Finally, add fields. - auto fields_grid = mesh_grid["fields"]; - fields_grid["velocity/association"].set_string("vertex"); - fields_grid["velocity/topology"].set_string("mesh"); - fields_grid["velocity/volume_dependent"].set_string("false"); - - // velocity is stored in non-interlaced form (unlike points). - fields_grid["velocity/values/x"].set_external( - attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); - fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), - grid.GetNumberOfPoints(), - /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); - fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), - grid.GetNumberOfPoints(), - /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); - - // pressure is cell-data. - fields_grid["pressure/association"].set_string("element"); - fields_grid["pressure/topology"].set_string("mesh"); - fields_grid["pressure/volume_dependent"].set_string("false"); - fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); - - // Now add the second channel, called "particles". - auto channel_particles = exec_params["catalyst/channels/particles"]; - - // make the particles' time update every other step of the mesh's - channel_particles["state/cycle"].set(cycle - (cycle % 2)); - channel_particles["state/time"].set(time - (cycle % 2) * 0.1); - channel_particles["state/multiblock"].set(1); - - // Since this example is using Conduit Mesh Blueprint to define the mesh, - // we set the channel_particles's type to "mesh". - channel_particles["type"].set_string("mesh"); - - // now create the mesh. - auto mesh_particles = channel_particles["data"]; - mesh_particles["coordsets/coords/type"].set_string("explicit"); - mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); - mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); - mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), - particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); - - // now, the topology. - mesh_particles["topologies/mesh/type"].set_string("unstructured"); - mesh_particles["topologies/mesh/coordset"].set_string("coords"); - mesh_particles["topologies/mesh/elements/shape"].set_string("point"); - std::vector connectivity(particles.GetNumberOfPoints()); - std::iota(connectivity.begin(), connectivity.end(), 0); - mesh_particles["topologies/mesh/elements/connectivity"].set_external( - &connectivity[0], particles.GetNumberOfPoints()); - - catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); - if (err != catalyst_status_ok) - { - std::cerr << "Failed to execute Catalyst: " << err << std::endl; - } +// conduit_cpp::Node exec_params; +// +// // add time/cycle information +// auto state = exec_params["catalyst/state"]; +// state["timestep"].set(cycle); +// state["time"].set(time); +// +// // Add channels. +// // We have 2 channels here. First once is called 'grid'. +// auto channel_grid = exec_params["catalyst/channels/grid"]; +// +// // Since this example is using Conduit Mesh Blueprint to define the mesh, +// // we set the channel_grid's type to "mesh". +// channel_grid["type"].set_string("mesh"); +// +// // now create the mesh. +// auto mesh_grid = channel_grid["data"]; +// +// // start with coordsets (of course, the sequence is not important, just make +// // it easier to think in this order). +// mesh_grid["coordsets/coords/type"].set_string("explicit"); +// +// // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep +// // copies. For zero-copy, we use the set_.._ptr(..) API. +// mesh_grid["coordsets/coords/values/x"].set_external( +// grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); +// mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), +// grid.GetNumberOfPoints(), +// /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); +// mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), +// grid.GetNumberOfPoints(), +// /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); +// +// // Next, add topology +// mesh_grid["topologies/mesh/type"].set_string("unstructured"); +// mesh_grid["topologies/mesh/coordset"].set_string("coords"); +// mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); +// mesh_grid["topologies/mesh/elements/connectivity"].set( +// grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); +// +// // Finally, add fields. +// auto fields_grid = mesh_grid["fields"]; +// fields_grid["velocity/association"].set_string("vertex"); +// fields_grid["velocity/topology"].set_string("mesh"); +// fields_grid["velocity/volume_dependent"].set_string("false"); +// +// // velocity is stored in non-interlaced form (unlike points). +// fields_grid["velocity/values/x"].set_external( +// attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); +// fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), +// grid.GetNumberOfPoints(), +// /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); +// fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), +// grid.GetNumberOfPoints(), +// /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); +// +// // pressure is cell-data. +// fields_grid["pressure/association"].set_string("element"); +// fields_grid["pressure/topology"].set_string("mesh"); +// fields_grid["pressure/volume_dependent"].set_string("false"); +// fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); +// +// // Now add the second channel, called "particles". +// auto channel_particles = exec_params["catalyst/channels/particles"]; +// +// // make the particles' time update every other step of the mesh's +// channel_particles["state/cycle"].set(cycle - (cycle % 2)); +// channel_particles["state/time"].set(time - (cycle % 2) * 0.1); +// channel_particles["state/multiblock"].set(1); +// +// // Since this example is using Conduit Mesh Blueprint to define the mesh, +// // we set the channel_particles's type to "mesh". +// channel_particles["type"].set_string("mesh"); +// +// // now create the mesh. +// auto mesh_particles = channel_particles["data"]; +// mesh_particles["coordsets/coords/type"].set_string("explicit"); +// mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), +// particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); +// mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), +// particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); +// mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), +// particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); +// +// // now, the topology. +// mesh_particles["topologies/mesh/type"].set_string("unstructured"); +// mesh_particles["topologies/mesh/coordset"].set_string("coords"); +// mesh_particles["topologies/mesh/elements/shape"].set_string("point"); +// std::vector connectivity(particles.GetNumberOfPoints()); +// std::iota(connectivity.begin(), connectivity.end(), 0); +// mesh_particles["topologies/mesh/elements/connectivity"].set_external( +// &connectivity[0], particles.GetNumberOfPoints()); + +// catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); +// if (err != catalyst_status_ok) +// { +// std::cerr << "Failed to execute Catalyst: " << err << std::endl; +// } } void Finalize() From 17c11ab895320b29902ab18660e3b4018d26c3ca Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 10:22:17 +0200 Subject: [PATCH 016/113] move find_package(catalyst) to lower src/CMakeList In order to not require the GLOBAL keyword and keep the imported targets local find_package(catalyst) is moved to the lower list. Then catalyst::catalyst is available and can be used for linkage. Using cmake-generator-expression [0] to only include compile definition as well as linkage if the ENABLE_CATALYST flag is set, otherwise the return an empy string. This prevents from tidious IF .. ELSEIF .. ENDIF construct for linkage. [0] : https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html --- CMakeLists.txt | 10 +--------- src/CMakeLists.txt | 16 +++++++++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77bc98b1f..7465e9d04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,6 @@ set (IPPL_VERSION_NAME "V${IPPL_VERSION_MAJOR}.${IPPL_VERSION_MINOR}") set (IPPL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -include(CMakePrintHelpers) - if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." @@ -75,7 +73,7 @@ if (ENABLE_TESTS) add_subdirectory (test) endif () -option (ENABLE_ALPINE, "Enable Alpine" OFF) +option (ENABLE_ALPINE "Enable Alpine" OFF) if (ENABLE_ALPINE) if (NOT ENABLE_SOLVERS) message (FATAL_ERROR "Cannot enable Alpine since Solver not enabled (-DENABLE_SOLVERS=ON)!") @@ -88,12 +86,6 @@ if (ENABLE_ALPINE) endif () option(ENABLE_CATALYST "Build example with Catalyst enabled" OFF) -if (ENABLE_CATALYST) - find_package(catalyst 2.0 GLOBAL REQUIRED) - message (STATUS "Enable Catalyst") - message (STATUS "Found catalyst_DIR: ${catalyst_DIR}") -endif () - option (ENABLE_UNIT_TESTS "Enable unit tests" OFF) if (ENABLE_UNIT_TESTS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e17ca512..6e090172b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,13 +98,19 @@ include_directories ( add_library ( ippl ${IPPL_SRCS} ${IPPL_SRCS_FORT} ) if (ENABLE_CATALYST) - set (CATALYST_LIBRARY catalyst::catalyst) - target_compile_definitions(ippl PUBLIC -D ENABLE_CATALYST) -else() - set (CATALYST_LIBRARY "") + find_package(catalyst 2.0 REQUIRED) + message (STATUS "Enable Catalyst") + message (STATUS "Found catalyst_DIR: ${catalyst_DIR}") endif() -target_link_libraries(ippl PUBLIC Kokkos::kokkos ${HEFFTE_LIBRARY} ${CATALYST_LIBRARY}) +target_compile_definitions(ippl PUBLIC + $<$:-DENABLE_CATALYST> + ) + +target_link_libraries(ippl PUBLIC + Kokkos::kokkos + ${HEFFTE_LIBRARY} + $<$:catalyst::catalyst>) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From d6e30fd9fd7fa8b181c28293583e6cbb83bc2957 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 10:54:27 +0200 Subject: [PATCH 017/113] move Heffte find_packge in sub directory No need for manually defining empty string in the link process, as that is handled by the CMake generator expression. --- CMakeLists.txt | 8 +------- src/CMakeLists.txt | 13 +++++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7465e9d04..39e4e6f05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,13 +58,8 @@ message (STATUS "The underlying C++ compiler is: ${CMAKE_CXX_COMPILER}") find_package(Kokkos REQUIRED) option (ENABLE_FFT "Enable FFT transform" OFF) -if (ENABLE_FFT) - add_definitions (-DENABLE_FFT) - find_package(Heffte 2.2.0 REQUIRED) - message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") -endif () - option (ENABLE_SOLVERS "Enable IPPL solvers" OFF) +option (ENABLE_CATALYST "Build example with Catalyst enabled" OFF) add_subdirectory (src) @@ -85,7 +80,6 @@ if (ENABLE_ALPINE) add_subdirectory (alpine) endif () -option(ENABLE_CATALYST "Build example with Catalyst enabled" OFF) option (ENABLE_UNIT_TESTS "Enable unit tests" OFF) if (ENABLE_UNIT_TESTS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e090172b..e30a99101 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,10 +63,9 @@ add_ippl_sources (Ippl.cpp) add_subdirectory (Communicate) if (ENABLE_FFT) - set (HEFFTE_LIBRARY Heffte::Heffte) + find_package(Heffte 2.2.0 REQUIRED) + message (STATUS "Found Heffte_DIR: ${Heffte_DIR}") add_subdirectory (FFT) -else() - set (HEFFTE_LIBRARY "") endif() add_subdirectory (Field) add_subdirectory (FieldLayout) @@ -104,13 +103,15 @@ if (ENABLE_CATALYST) endif() target_compile_definitions(ippl PUBLIC + $<$:-DENABLE_FFT> $<$:-DENABLE_CATALYST> - ) +) target_link_libraries(ippl PUBLIC Kokkos::kokkos - ${HEFFTE_LIBRARY} - $<$:catalyst::catalyst>) + $<$:Heffte::Heffte> + $<$:catalyst::catalyst> + ) install (TARGETS ippl DESTINATION lib) install (FILES ${IPPL_BASEDIR_HDRS} DESTINATION include) From 74f5a255aea3d60ca58c93fa7a0ce872ce3f878a Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 13:15:15 +0200 Subject: [PATCH 018/113] read in environmental variables with getenv --- src/Stream/InSitu/CatalystAdaptor.h | 4 ++-- test/stream/TestCatalystAdaptor.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index ed5555772..94abadb95 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -28,8 +28,8 @@ namespace CatalystAdaptor { node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); } - node["catalyst_load/implementation"] = "paraview"; - //node["catalyst_load/search_paths/paraview"] = "$PATH"; + node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); + node["catalyst_load/search_paths/paraview"] = getenv("PARAVIEW_CATALYST_DIR"); catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 0f40885f5..7c3ffe214 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -1,4 +1,9 @@ -// Tests the application of various kinds of boundary conditions on fields +// Tests the application for the Catalyst In-Situ Adaptor +// following environment variables do need to be exported +// export CATALYST_IMPLEMENTATION_PATHS=/lib/catalyst +// export CATALYST_IMPLEMENTATION_NAME=paraview +// export PARARVIEW_CATALYST_DIR=/lib/catalyst + #include "Ippl.h" #include "Stream/InSitu/CatalystAdaptor.h" From 5070b58e5554c9993bab051eba0ed959fedce12e Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 15:25:25 +0200 Subject: [PATCH 019/113] add catalyst_pipeline python script to have test environment --- test/stream/TestCatalystAdaptor.cpp | 16 ++++++++++++++++ test/stream/catalyst_pipeline.py | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/stream/catalyst_pipeline.py diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 7c3ffe214..6bed75b9f 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -1,8 +1,18 @@ // Tests the application for the Catalyst In-Situ Adaptor // following environment variables do need to be exported +// // export CATALYST_IMPLEMENTATION_PATHS=/lib/catalyst // export CATALYST_IMPLEMENTATION_NAME=paraview +// +// on juwels these both are direclty set! +// // export PARARVIEW_CATALYST_DIR=/lib/catalyst +// +// RUN +// ./TestCatalystAdaptor ./.py +// +// eg. +// ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py #include "Ippl.h" #include "Stream/InSitu/CatalystAdaptor.h" @@ -14,6 +24,11 @@ int main(int argc, char* argv[]) { Ippl ippl(argc, argv); + CatalystAdaptor::Initialize(argc, argv); + + CatalystAdaptor::Execute(); + + constexpr unsigned int dim = 3; int pt = 4; @@ -106,5 +121,6 @@ int main(int argc, char* argv[]) { Ippl::Comm->barrier(); } + CatalystAdaptor::Finalize(); return 0; } diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py new file mode 100644 index 000000000..7451835fb --- /dev/null +++ b/test/stream/catalyst_pipeline.py @@ -0,0 +1,17 @@ +from paraview.simple import * + +# Greeting to ensure that ctest knows this script is being imported +print("executing catalyst_pipeline") + +# registrationName must match the channel name used in the +# 'CatalystAdaptor'. +producer = TrivialProducer(registrationName="grid") + +def catalyst_execute(info): + global producer + producer.UpdatePipeline() + print("-----------------------------------") + print("executing (cycle={}, time={})".format(info.cycle, info.time)) + print("bounds:", producer.GetDataInformation().GetBounds()) + print("velocity-magnitude-range:", producer.PointData["velocity"].GetRange(-1)) + print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 28cd65397742466d91fe4ccd100b76096510e202 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 21:01:15 +0200 Subject: [PATCH 020/113] include IpplException to take care of possible getenv failures --- src/Stream/InSitu/CatalystAdaptor.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 94abadb95..8abb76530 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -9,6 +9,7 @@ #include #include #include +#include "Utility/IpplException.h" namespace CatalystAdaptor { @@ -28,8 +29,13 @@ namespace CatalystAdaptor { node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); } - node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); - node["catalyst_load/search_paths/paraview"] = getenv("PARAVIEW_CATALYST_DIR"); + try { + node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); + node["catalyst_load/search_paths/paraview"] = getenv("PARAVIEW_CATALYST_DIR"); + } catch (...){ + throw IpplException("CatalystAdaptor::Initialize", "no environmental variable for CATALYST_IMPLEMENTATION_NAME or PARAVIEW_CATALYST_DIR found"); + } + // TODO: catch catalyst error also with IpplException catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { From f843c2940be01e06684b52c31dc3a925ce2eb885 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 21:05:34 +0200 Subject: [PATCH 021/113] add catalyst node to print out time and cycle Able to print time and cycle over in-situ catalyst script. --- src/Stream/InSitu/CatalystAdaptor.h | 25 +++++---- test/stream/TestCatalystAdaptor.cpp | 86 +++++++++++------------------ test/stream/catalyst_pipeline.py | 6 +- 3 files changed, 49 insertions(+), 68 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 8abb76530..2a7604ba1 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,14 +43,15 @@ namespace CatalystAdaptor } } - void Execute() //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) + void Execute(int cycle, double time) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) { -// conduit_cpp::Node exec_params; -// -// // add time/cycle information -// auto state = exec_params["catalyst/state"]; -// state["timestep"].set(cycle); -// state["time"].set(time); + //conduit_cpp::Node exec_params; + conduit_cpp::Node node; + + // add time/cycle information + auto state = node["catalyst/state"]; + state["cycle"].set(cycle); + state["time"].set(time); // // // Add channels. // // We have 2 channels here. First once is called 'grid'. @@ -138,11 +139,11 @@ namespace CatalystAdaptor // mesh_particles["topologies/mesh/elements/connectivity"].set_external( // &connectivity[0], particles.GetNumberOfPoints()); -// catalyst_status err = catalyst_execute(conduit_cpp::c_node(&exec_params)); -// if (err != catalyst_status_ok) -// { -// std::cerr << "Failed to execute Catalyst: " << err << std::endl; -// } + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to execute Catalyst: " << err << std::endl; + } } void Finalize() diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 6bed75b9f..8428d7285 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -22,16 +22,13 @@ #include int main(int argc, char* argv[]) { - Ippl ippl(argc, argv); + Ippl ippl(argc, argv); CatalystAdaptor::Initialize(argc, argv); - CatalystAdaptor::Execute(); - + constexpr unsigned int dim {3}; - constexpr unsigned int dim = 3; - - int pt = 4; + const int pt {4}; ippl::Index I(pt); ippl::NDIndex owned(I, I, I); @@ -41,7 +38,7 @@ int main(int argc, char* argv[]) { ippl::FieldLayout layout(owned, allParallel); - double dx = 1.0 / double(pt); + constexpr double dx = {1.0 / double(pt)}; ippl::Vector hx = {dx, dx, dx}; ippl::Vector origin = {0, 0, 0}; @@ -52,28 +49,9 @@ int main(int argc, char* argv[]) { typedef ippl::Field field_type; - typedef ippl::BConds bc_type; - - bc_type bcField; - - // X direction periodic BC - for (unsigned int i = 0; i < 2; ++i) { - bcField[i] = std::make_shared>(i); - } - ////Lower Y face - bcField[2] = std::make_shared>(2); - ////Higher Y face - bcField[3] = std::make_shared>(3, 7.0); - ////Lower Z face - bcField[4] = std::make_shared>(4); - ////Higher Z face - bcField[5] = - std::make_shared>(5, 0.0, 1.0); - - // std::cout << bcField << std::endl; std::cout << layout << std::endl; - field_type field(mesh, layout, 1); + field_type field(mesh, layout); field = 1.0; @@ -82,33 +60,35 @@ int main(int argc, char* argv[]) { using mdrange_type = Kokkos::MDRangePolicy>; typename field_type::view_type& view = field.getView(); + + double time = {0.0}; + const double dt = {0.05}; + const unsigned int nt = {10}; + for (unsigned int it = 0; it < nt; it++) { + Kokkos::parallel_for( - "Assign field", - mdrange_type({nghost, nghost, nghost}, - {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), - KOKKOS_LAMBDA(const int i, const int j, const int k) { - // local to global index conversion - const size_t ig = i + lDom[0].first() - nghost; - // const size_t jg = j + lDom[1].first() - nghost; - // const size_t kg = k + lDom[2].first() - nghost; - double x = (ig + 0.5) * hx[0] + origin[0]; - // double y = (jg + 0.5) * hx[1]; - // double z = (kg + 0.5) * hx[2]; - - // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); - // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); - // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); - view(i, j, k) = x; - }); - - // field = field * 10.0; - - bcField.findBCNeighbors(field); - - unsigned int niter = 5; - - for (unsigned int i = 0; i < niter; ++i) { - bcField.apply(field); + "Assign field", + mdrange_type({nghost, nghost, nghost}, + {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), + KOKKOS_LAMBDA(const int i, const int j, const int k) { + // local to global index conversion + //const size_t ig = i + lDom[0].first() - nghost; + const size_t jg = j + lDom[1].first() - nghost; + // const size_t kg = k + lDom[2].first() - nghost; + //double x = (ig + 0.5) * hx[0] + origin[0]; + double y = (jg + 0.5) * hx[1] + origin[1]; + // double z = (kg + 0.5) * hx[2]; + + // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); + // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); + // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); + view(i, j, k) = y * time; + }); + + CatalystAdaptor::Execute(it, time); //field + // print should be same as field data + time += dt; + } int nRanks = Ippl::Comm->size(); diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 7451835fb..abeaffb22 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -12,6 +12,6 @@ def catalyst_execute(info): producer.UpdatePipeline() print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) - print("bounds:", producer.GetDataInformation().GetBounds()) - print("velocity-magnitude-range:", producer.PointData["velocity"].GetRange(-1)) - print("pressure-range:", producer.CellData["pressure"].GetRange(0)) +# print("bounds:", producer.GetDataInformation().GetBounds()) +# print("velocity-magnitude-range:", producer.PointData["velocity"].GetRange(-1)) +# print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 87f05937e87825abb4d6b028f39bad410e44498b Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 31 Aug 2023 21:16:00 +0200 Subject: [PATCH 022/113] include varios temporary files into the gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ace312436..70758138a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,11 @@ manual/ippl_user_guide.pdf # CMake and Build folder CMakeFiles/ build* +tags +compile_commands.json # temporary folder .cache/ .idea/ +*.dat +__pycache__ From 5bca76287ccc42ecbf05fa23881ae32763c90e44 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 1 Sep 2023 10:16:02 +0200 Subject: [PATCH 023/113] add function call to export node information --- src/Stream/InSitu/CatalystAdaptor.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 2a7604ba1..d1a1738ab 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -52,6 +52,12 @@ namespace CatalystAdaptor auto state = node["catalyst/state"]; state["cycle"].set(cycle); state["time"].set(time); + + // include information about catalyst, conduit implementation + catalyst_about(conduit_cpp::c_node(&node)); + + // print node to see what I write there + if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); // // // Add channels. // // We have 2 channels here. First once is called 'grid'. From c2156c265e1a8848386d21981cf03df764afc592 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 1 Sep 2023 11:56:08 +0200 Subject: [PATCH 024/113] add coords for three dimensional mesh Hard coded three dimensional mesh topology. --- src/Stream/InSitu/CatalystAdaptor.h | 54 ++++++++++++++++++++++------- test/stream/TestCatalystAdaptor.cpp | 12 ++++--- test/stream/catalyst_pipeline.py | 2 +- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index d1a1738ab..a401c2e5e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -4,15 +4,20 @@ #define CatalystAdaptor_h #include - #include #include #include #include + #include "Utility/IpplException.h" +#include "Ippl.h" namespace CatalystAdaptor { + constexpr unsigned int dim {3}; + using Mesh_t = ippl::UniformCartesian; + using Centering_t = Mesh_t::DefaultCentering; + typedef ippl::Field field_type; /** * In this example, we show how we can use Catalysts's C++ @@ -43,31 +48,53 @@ namespace CatalystAdaptor } } - void Execute(int cycle, double time) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) + void Execute(int cycle, double time, int rank, field_type &field) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) { //conduit_cpp::Node exec_params; conduit_cpp::Node node; + + // include information about catalyst, conduit implementation + catalyst_about(conduit_cpp::c_node(&node)); // add time/cycle information auto state = node["catalyst/state"]; state["cycle"].set(cycle); state["time"].set(time); - - // include information about catalyst, conduit implementation - catalyst_about(conduit_cpp::c_node(&node)); - - // print node to see what I write there - if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + state["domain_id"].set(rank); + + // // // Add channels. // // We have 2 channels here. First once is called 'grid'. -// auto channel_grid = exec_params["catalyst/channels/grid"]; + // auto field_node = node["catalyst/channels/field"]; + auto field_node = node["catalyst/field/coordsets/coords"]; + // field_node["type"].set_string("mesh"); + field_node["type"].set_string("uniform"); + + // number of points in specific dimension + auto test = field.get_mesh().getGridsize(); + + // number of points in specific dimension + field_node["dims/i"].set_string(std::to_string(field.get_mesh().getGridsize(0))); + field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); + field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); + + // origin + auto origin = field.get_mesh().getOrigin(); + field_node["origin/x"].set_string(std::to_string(origin(0))); + field_node["origin/y"].set_string(std::to_string(origin(1))); + field_node["origin/z"].set_string(std::to_string(origin(2))); + + // spacing + field_node["spacing/dx"].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); + field_node["spacing/dy"].set_string(std::to_string(field.get_mesh().getMeshSpacing(1))); + field_node["spacing/dz"].set_string(std::to_string(field.get_mesh().getMeshSpacing(2))); + // // // Since this example is using Conduit Mesh Blueprint to define the mesh, // // we set the channel_grid's type to "mesh". -// channel_grid["type"].set_string("mesh"); -// -// // now create the mesh. + + // now create the mesh. // auto mesh_grid = channel_grid["data"]; // // // start with coordsets (of course, the sequence is not important, just make @@ -145,6 +172,9 @@ namespace CatalystAdaptor // mesh_particles["topologies/mesh/elements/connectivity"].set_external( // &connectivity[0], particles.GetNumberOfPoints()); + // print node to see what I write there + if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 8428d7285..18dfb4b2a 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -39,7 +39,9 @@ int main(int argc, char* argv[]) { ippl::FieldLayout layout(owned, allParallel); constexpr double dx = {1.0 / double(pt)}; - ippl::Vector hx = {dx, dx, dx}; + constexpr double dy = {1.0 / double(pt)}; + constexpr double dz = {1.0 / double(pt)}; + ippl::Vector hx = {dx, dy, dz}; ippl::Vector origin = {0, 0, 0}; using Mesh_t = ippl::UniformCartesian; @@ -62,9 +64,9 @@ int main(int argc, char* argv[]) { double time = {0.0}; - const double dt = {0.05}; - const unsigned int nt = {10}; - for (unsigned int it = 0; it < nt; it++) { + const double dt = {0.05}; + const unsigned int nt = {5}; + for (unsigned int it = 0; it < nt; ++it) { Kokkos::parallel_for( "Assign field", @@ -85,7 +87,7 @@ int main(int argc, char* argv[]) { view(i, j, k) = y * time; }); - CatalystAdaptor::Execute(it, time); //field + CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); //field // print should be same as field data time += dt; diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index abeaffb22..1871a68ec 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -5,7 +5,7 @@ # registrationName must match the channel name used in the # 'CatalystAdaptor'. -producer = TrivialProducer(registrationName="grid") +producer = TrivialProducer(registrationName="field") def catalyst_execute(info): global producer From ba12d51782b76508472d4476e8265ca817073d63 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 1 Sep 2023 12:27:41 +0200 Subject: [PATCH 025/113] set topological definition based on loop over strings --- src/Stream/InSitu/CatalystAdaptor.h | 48 ++++++++++++++++++----------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index a401c2e5e..064b64765 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -52,7 +52,7 @@ namespace CatalystAdaptor { //conduit_cpp::Node exec_params; conduit_cpp::Node node; - + // include information about catalyst, conduit implementation catalyst_about(conduit_cpp::c_node(&node)); @@ -61,8 +61,8 @@ namespace CatalystAdaptor state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); - - + + // // // Add channels. // // We have 2 channels here. First once is called 'grid'. @@ -70,26 +70,38 @@ namespace CatalystAdaptor auto field_node = node["catalyst/field/coordsets/coords"]; // field_node["type"].set_string("mesh"); field_node["type"].set_string("uniform"); - + // number of points in specific dimension auto test = field.get_mesh().getGridsize(); // number of points in specific dimension - field_node["dims/i"].set_string(std::to_string(field.get_mesh().getGridsize(0))); - field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); - field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); - - // origin + std::string field_node_dim {"dims/i"}; + std::string field_node_origin {"origin/x"}; + std::string field_node_spacing {"spacing/dx"}; auto origin = field.get_mesh().getOrigin(); - field_node["origin/x"].set_string(std::to_string(origin(0))); - field_node["origin/y"].set_string(std::to_string(origin(1))); - field_node["origin/z"].set_string(std::to_string(origin(2))); - + + for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ + field_node[field_node_dim].set_string(std::to_string(field.get_mesh().getGridsize(iDim))); + field_node[field_node_origin].set_string(std::to_string(origin(iDim))); + field_node[field_node_spacing].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); + + field_node_dim.back()++; + field_node_origin.back()++; + field_node_spacing.back()++; + } +// field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); // field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); + + // origin +// auto origin = field.get_mesh().getOrigin(); +// field_node["origin/x"].set_string(std::to_string(origin(0))); +// field_node["origin/y"].set_string(std::to_string(origin(1))); +// field_node["origin/z"].set_string(std::to_string(origin(2))); + // spacing - field_node["spacing/dx"].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); - field_node["spacing/dy"].set_string(std::to_string(field.get_mesh().getMeshSpacing(1))); - field_node["spacing/dz"].set_string(std::to_string(field.get_mesh().getMeshSpacing(2))); - +// field_node["spacing/dx"].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); +// field_node["spacing/dy"].set_string(std::to_string(field.get_mesh().getMeshSpacing(1))); +// field_node["spacing/dz"].set_string(std::to_string(field.get_mesh().getMeshSpacing(2))); + // // // Since this example is using Conduit Mesh Blueprint to define the mesh, // // we set the channel_grid's type to "mesh". @@ -174,7 +186,7 @@ namespace CatalystAdaptor // print node to see what I write there if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { From 31991ba2e39a780b4592d8d8abbb3ac5b1a2a3ba Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 1 Sep 2023 12:58:49 +0200 Subject: [PATCH 026/113] fix index in spacing, check with different index dimensions --- src/Stream/InSitu/CatalystAdaptor.h | 2 +- test/stream/TestCatalystAdaptor.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 064b64765..a7de5f973 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -83,7 +83,7 @@ namespace CatalystAdaptor for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ field_node[field_node_dim].set_string(std::to_string(field.get_mesh().getGridsize(iDim))); field_node[field_node_origin].set_string(std::to_string(origin(iDim))); - field_node[field_node_spacing].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); + field_node[field_node_spacing].set_string(std::to_string(field.get_mesh().getMeshSpacing(iDim))); field_node_dim.back()++; field_node_origin.back()++; diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 18dfb4b2a..14b11a1fe 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -29,8 +29,10 @@ int main(int argc, char* argv[]) { constexpr unsigned int dim {3}; const int pt {4}; - ippl::Index I(pt); - ippl::NDIndex owned(I, I, I); + ippl::Index Ix(pt); + ippl::Index Iy {pt+1}; + ippl::Index Iz {pt+2}; + ippl::NDIndex owned(Ix, Iy, Iz); ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims for (unsigned int d = 0; d < dim; d++) @@ -39,8 +41,8 @@ int main(int argc, char* argv[]) { ippl::FieldLayout layout(owned, allParallel); constexpr double dx = {1.0 / double(pt)}; - constexpr double dy = {1.0 / double(pt)}; - constexpr double dz = {1.0 / double(pt)}; + constexpr double dy = {2.0 / double(pt)}; + constexpr double dz = {3.0 / double(pt)}; ippl::Vector hx = {dx, dy, dz}; ippl::Vector origin = {0, 0, 0}; From b0215bbe911bfecb3973be366c692a03614cdcbe Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 1 Sep 2023 13:21:06 +0200 Subject: [PATCH 027/113] describe topology and add fields as subscription, not yet working --- src/Stream/InSitu/CatalystAdaptor.h | 19 +++++++++---------- test/stream/TestCatalystAdaptor.cpp | 8 ++++---- test/stream/catalyst_pipeline.py | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index a7de5f973..b555b693c 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -89,20 +89,19 @@ namespace CatalystAdaptor field_node_origin.back()++; field_node_spacing.back()++; } + + auto field_node_topology = node["catalyst/field/topologies/mesh"]; + field_node_topology["type"].set_string("uniform"); + field_node_topology["coordset"].set_string("coords"); // field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); // field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); - // origin -// auto origin = field.get_mesh().getOrigin(); -// field_node["origin/x"].set_string(std::to_string(origin(0))); -// field_node["origin/y"].set_string(std::to_string(origin(1))); -// field_node["origin/z"].set_string(std::to_string(origin(2))); + auto field_node_fields = node["catalyst/field/fields/field"]; + field_node_fields["association"].set_string("element"); + field_node_fields["topology"].set_string("mesh"); + field_node_fields["values"].set_external(field.getView().data()); - // spacing -// field_node["spacing/dx"].set_string(std::to_string(field.get_mesh().getMeshSpacing(0))); -// field_node["spacing/dy"].set_string(std::to_string(field.get_mesh().getMeshSpacing(1))); -// field_node["spacing/dz"].set_string(std::to_string(field.get_mesh().getMeshSpacing(2))); + // origin -// // // Since this example is using Conduit Mesh Blueprint to define the mesh, // // we set the channel_grid's type to "mesh". diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 14b11a1fe..4dbd2f0a1 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -30,8 +30,8 @@ int main(int argc, char* argv[]) { const int pt {4}; ippl::Index Ix(pt); - ippl::Index Iy {pt+1}; - ippl::Index Iz {pt+2}; + ippl::Index Iy {pt}; + ippl::Index Iz {pt}; ippl::NDIndex owned(Ix, Iy, Iz); ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims @@ -41,8 +41,8 @@ int main(int argc, char* argv[]) { ippl::FieldLayout layout(owned, allParallel); constexpr double dx = {1.0 / double(pt)}; - constexpr double dy = {2.0 / double(pt)}; - constexpr double dz = {3.0 / double(pt)}; + constexpr double dy = {1.0 / double(pt)}; + constexpr double dz = {1.0 / double(pt)}; ippl::Vector hx = {dx, dy, dz}; ippl::Vector origin = {0, 0, 0}; diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 1871a68ec..ff41d2c88 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -13,5 +13,5 @@ def catalyst_execute(info): print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) # print("bounds:", producer.GetDataInformation().GetBounds()) -# print("velocity-magnitude-range:", producer.PointData["velocity"].GetRange(-1)) + print("field:", producer.CellData["field"]) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 757798d03d17972e6828b5943ef20891ca8c803a Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 13:55:05 +0200 Subject: [PATCH 028/113] include values to catalyst node --- src/Stream/InSitu/CatalystAdaptor.h | 49 +++++++++++++++++++---------- test/stream/TestCatalystAdaptor.cpp | 2 +- test/stream/catalyst_pipeline.py | 2 +- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index b555b693c..3715b0e65 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -62,18 +62,13 @@ namespace CatalystAdaptor state["time"].set(time); state["domain_id"].set(rank); - -// // // Add channels. // // We have 2 channels here. First once is called 'grid'. // auto field_node = node["catalyst/channels/field"]; - auto field_node = node["catalyst/field/coordsets/coords"]; + auto field_node = node["catalyst/channel/field/coordsets/coords"]; // field_node["type"].set_string("mesh"); field_node["type"].set_string("uniform"); - // number of points in specific dimension - auto test = field.get_mesh().getGridsize(); - // number of points in specific dimension std::string field_node_dim {"dims/i"}; std::string field_node_origin {"origin/x"}; @@ -81,24 +76,46 @@ namespace CatalystAdaptor auto origin = field.get_mesh().getOrigin(); for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ - field_node[field_node_dim].set_string(std::to_string(field.get_mesh().getGridsize(iDim))); - field_node[field_node_origin].set_string(std::to_string(origin(iDim))); - field_node[field_node_spacing].set_string(std::to_string(field.get_mesh().getMeshSpacing(iDim))); - - field_node_dim.back()++; - field_node_origin.back()++; - field_node_spacing.back()++; + // include ghost cells to the "left" and "right" + field_node[field_node_dim].set_string( + std::to_string(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); + // shift origin by one ghost cell + field_node[field_node_origin].set_string( + std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); + field_node[field_node_spacing].set_string( + std::to_string(field.get_mesh().getMeshSpacing(iDim))); + + ++field_node_dim.back(); + ++field_node_origin.back(); + ++field_node_spacing.back(); } - auto field_node_topology = node["catalyst/field/topologies/mesh"]; + auto field_node_topology = node["catalyst/channel/field/topologies/mesh"]; field_node_topology["type"].set_string("uniform"); field_node_topology["coordset"].set_string("coords"); // field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); // field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); - auto field_node_fields = node["catalyst/field/fields/field"]; + auto field_node_fields = node["catalyst/channel/field/fields/density"]; field_node_fields["association"].set_string("element"); + field_node_fields["volume_dependent"].set_string("false"); field_node_fields["topology"].set_string("mesh"); - field_node_fields["values"].set_external(field.getView().data()); + + auto & layout = field.getLayout(); + auto & view = field.getView(); + + field_node_fields["values"].set_external( + field.getView().data(), + field.getOwned().size(), + field.getLayout().getLocalNDIndex(rank)[1].first()); + // field.getLayout().getLocalNDIndex(rank)[1].first()); // + field.getNghost()); + +// std::string field_node_values {"values/x"}; +// for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { +// field_node_fields[field_node_values].set_external( +// field.getView().data(), field.getOwned()[iDim].length(), +// field.getLayout().getLocalNDIndex(rank)[iDim].first()); // + field.getNghost()); +// ++field_node_values.back(); +// } // origin diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 4dbd2f0a1..3b1f17bd1 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { double time = {0.0}; const double dt = {0.05}; - const unsigned int nt = {5}; + const unsigned int nt = {2}; for (unsigned int it = 0; it < nt; ++it) { Kokkos::parallel_for( diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index ff41d2c88..feb23e4e5 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -13,5 +13,5 @@ def catalyst_execute(info): print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) # print("bounds:", producer.GetDataInformation().GetBounds()) - print("field:", producer.CellData["field"]) + print("field:", producer.CellData["density"].GetRange(0)) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From e4cf68170a693fecafae04d688f5c79d73ad703d Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 14:26:19 +0200 Subject: [PATCH 029/113] change channel names and blueprint according to CxxFullExample --- src/Stream/InSitu/CatalystAdaptor.h | 44 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 3715b0e65..c082ca65e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -64,25 +64,27 @@ namespace CatalystAdaptor // // Add channels. // // We have 2 channels here. First once is called 'grid'. - // auto field_node = node["catalyst/channels/field"]; - auto field_node = node["catalyst/channel/field/coordsets/coords"]; - // field_node["type"].set_string("mesh"); - field_node["type"].set_string("uniform"); + auto channel_field = node["catalyst/channels/field"]; // /coordsets/coords"]; + channel_field["type"].set("mesh"); + + auto field_channel_mesh = channel_field["data"]; + + field_channel_mesh["coordsets/coords/type"].set("uniform"); // number of points in specific dimension - std::string field_node_dim {"dims/i"}; - std::string field_node_origin {"origin/x"}; - std::string field_node_spacing {"spacing/dx"}; + std::string field_node_dim {"coordsets/coords/dims/i"}; + std::string field_node_origin {"coordsets/coords/origin/x"}; + std::string field_node_spacing {"coordsets/coords/spacing/dx"}; auto origin = field.get_mesh().getOrigin(); for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // include ghost cells to the "left" and "right" - field_node[field_node_dim].set_string( + field_channel_mesh[field_node_dim].set( std::to_string(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); // shift origin by one ghost cell - field_node[field_node_origin].set_string( + field_channel_mesh[field_node_origin].set( std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); - field_node[field_node_spacing].set_string( + field_channel_mesh[field_node_spacing].set( std::to_string(field.get_mesh().getMeshSpacing(iDim))); ++field_node_dim.back(); @@ -90,20 +92,16 @@ namespace CatalystAdaptor ++field_node_spacing.back(); } - auto field_node_topology = node["catalyst/channel/field/topologies/mesh"]; - field_node_topology["type"].set_string("uniform"); - field_node_topology["coordset"].set_string("coords"); -// field_node["dims/j"].set_string(std::to_string(field.get_mesh().getGridsize(1))); // field_node["dims/k"].set_string(std::to_string(field.get_mesh().getGridsize(2))); + auto field_channel_topology = channel_field["data"]; + field_channel_topology["type"].set("uniform"); + field_channel_topology["coordset"].set("coords"); - auto field_node_fields = node["catalyst/channel/field/fields/density"]; - field_node_fields["association"].set_string("element"); - field_node_fields["volume_dependent"].set_string("false"); - field_node_fields["topology"].set_string("mesh"); + auto field_channel_fields = channel_field["data/fields/density"]; + field_channel_fields["association"].set("element"); + field_channel_fields["volume_dependent"].set("false"); + field_channel_fields["topology"].set("mesh"); - auto & layout = field.getLayout(); - auto & view = field.getView(); - - field_node_fields["values"].set_external( + field_channel_fields["values"].set_external( field.getView().data(), field.getOwned().size(), field.getLayout().getLocalNDIndex(rank)[1].first()); @@ -111,7 +109,7 @@ namespace CatalystAdaptor // std::string field_node_values {"values/x"}; // for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { -// field_node_fields[field_node_values].set_external( +// field_channel_fields[field_node_values].set_external( // field.getView().data(), field.getOwned()[iDim].length(), // field.getLayout().getLocalNDIndex(rank)[iDim].first()); // + field.getNghost()); // ++field_node_values.back(); From efffac83b5b018bcb32d3c0ef30106984d4f96c3 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 14:28:20 +0200 Subject: [PATCH 030/113] remove commented out sections --- src/Stream/InSitu/CatalystAdaptor.h | 92 ----------------------------- 1 file changed, 92 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index c082ca65e..fd43593ac 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -105,98 +105,6 @@ namespace CatalystAdaptor field.getView().data(), field.getOwned().size(), field.getLayout().getLocalNDIndex(rank)[1].first()); - // field.getLayout().getLocalNDIndex(rank)[1].first()); // + field.getNghost()); - -// std::string field_node_values {"values/x"}; -// for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { -// field_channel_fields[field_node_values].set_external( -// field.getView().data(), field.getOwned()[iDim].length(), -// field.getLayout().getLocalNDIndex(rank)[iDim].first()); // + field.getNghost()); -// ++field_node_values.back(); -// } - - // origin - -// // Since this example is using Conduit Mesh Blueprint to define the mesh, -// // we set the channel_grid's type to "mesh". - - // now create the mesh. -// auto mesh_grid = channel_grid["data"]; -// -// // start with coordsets (of course, the sequence is not important, just make -// // it easier to think in this order). -// mesh_grid["coordsets/coords/type"].set_string("explicit"); -// -// // We don't use the conduit_cpp::Node::set(std::vector<..>) API since that deep -// // copies. For zero-copy, we use the set_.._ptr(..) API. -// mesh_grid["coordsets/coords/values/x"].set_external( -// grid.GetPointsArray(), grid.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); -// mesh_grid["coordsets/coords/values/y"].set_external(grid.GetPointsArray(), -// grid.GetNumberOfPoints(), -// /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); -// mesh_grid["coordsets/coords/values/z"].set_external(grid.GetPointsArray(), -// grid.GetNumberOfPoints(), -// /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); -// -// // Next, add topology -// mesh_grid["topologies/mesh/type"].set_string("unstructured"); -// mesh_grid["topologies/mesh/coordset"].set_string("coords"); -// mesh_grid["topologies/mesh/elements/shape"].set_string("hex"); -// mesh_grid["topologies/mesh/elements/connectivity"].set( -// grid.GetCellPoints(0), grid.GetNumberOfCells() * 8); -// -// // Finally, add fields. -// auto fields_grid = mesh_grid["fields"]; -// fields_grid["velocity/association"].set_string("vertex"); -// fields_grid["velocity/topology"].set_string("mesh"); -// fields_grid["velocity/volume_dependent"].set_string("false"); -// -// // velocity is stored in non-interlaced form (unlike points). -// fields_grid["velocity/values/x"].set_external( -// attribs.GetVelocityArray(), grid.GetNumberOfPoints(), /*offset=*/0); -// fields_grid["velocity/values/y"].set_external(attribs.GetVelocityArray(), -// grid.GetNumberOfPoints(), -// /*offset=*/grid.GetNumberOfPoints() * sizeof(double)); -// fields_grid["velocity/values/z"].set_external(attribs.GetVelocityArray(), -// grid.GetNumberOfPoints(), -// /*offset=*/grid.GetNumberOfPoints() * sizeof(double) * 2); -// -// // pressure is cell-data. -// fields_grid["pressure/association"].set_string("element"); -// fields_grid["pressure/topology"].set_string("mesh"); -// fields_grid["pressure/volume_dependent"].set_string("false"); -// fields_grid["pressure/values"].set_external(attribs.GetPressureArray(), grid.GetNumberOfCells()); -// -// // Now add the second channel, called "particles". -// auto channel_particles = exec_params["catalyst/channels/particles"]; -// -// // make the particles' time update every other step of the mesh's -// channel_particles["state/cycle"].set(cycle - (cycle % 2)); -// channel_particles["state/time"].set(time - (cycle % 2) * 0.1); -// channel_particles["state/multiblock"].set(1); -// -// // Since this example is using Conduit Mesh Blueprint to define the mesh, -// // we set the channel_particles's type to "mesh". -// channel_particles["type"].set_string("mesh"); -// -// // now create the mesh. -// auto mesh_particles = channel_particles["data"]; -// mesh_particles["coordsets/coords/type"].set_string("explicit"); -// mesh_particles["coordsets/coords/values/x"].set_external(particles.GetPointsArray(), -// particles.GetNumberOfPoints(), /*offset=*/0, /*stride=*/3 * sizeof(double)); -// mesh_particles["coordsets/coords/values/y"].set_external(particles.GetPointsArray(), -// particles.GetNumberOfPoints(), /*offset=*/sizeof(double), /*stride=*/3 * sizeof(double)); -// mesh_particles["coordsets/coords/values/z"].set_external(particles.GetPointsArray(), -// particles.GetNumberOfPoints(), /*offset=*/2 * sizeof(double), /*stride=*/3 * sizeof(double)); -// -// // now, the topology. -// mesh_particles["topologies/mesh/type"].set_string("unstructured"); -// mesh_particles["topologies/mesh/coordset"].set_string("coords"); -// mesh_particles["topologies/mesh/elements/shape"].set_string("point"); -// std::vector connectivity(particles.GetNumberOfPoints()); -// std::iota(connectivity.begin(), connectivity.end(), 0); -// mesh_particles["topologies/mesh/elements/connectivity"].set_external( -// &connectivity[0], particles.GetNumberOfPoints()); // print node to see what I write there if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); From bf91622441709c9442fc6ff55c9a299213082a01 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 15:25:13 +0200 Subject: [PATCH 031/113] conduit nodes according to conduit schemas, not working with catalyst --- src/Stream/InSitu/CatalystAdaptor.h | 58 ++++++++++++++++------------- test/stream/TestCatalystAdaptor.cpp | 2 +- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index fd43593ac..5b8ad1897 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -54,22 +54,20 @@ namespace CatalystAdaptor conduit_cpp::Node node; // include information about catalyst, conduit implementation - catalyst_about(conduit_cpp::c_node(&node)); +// catalyst_about(conduit_cpp::c_node(&node)); // add time/cycle information - auto state = node["catalyst/state"]; - state["cycle"].set(cycle); - state["time"].set(time); - state["domain_id"].set(rank); - -// // Add channels. -// // We have 2 channels here. First once is called 'grid'. - auto channel_field = node["catalyst/channels/field"]; // /coordsets/coords"]; - channel_field["type"].set("mesh"); + node["state/cycle"].set(cycle); + node["state/time"].set(time); + node["state/domain_id"].set(rank); + +// Add channels. +// auto channel_field = node["catalyst/field"]; // /coordsets/coords"]; +// channel_field["type"].set("mesh"); +// +// auto field_channel_mesh = channel_field["data"]; - auto field_channel_mesh = channel_field["data"]; - - field_channel_mesh["coordsets/coords/type"].set("uniform"); + node["coordsets/coords/type"].set("uniform"); // number of points in specific dimension std::string field_node_dim {"coordsets/coords/dims/i"}; @@ -79,12 +77,12 @@ namespace CatalystAdaptor for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // include ghost cells to the "left" and "right" - field_channel_mesh[field_node_dim].set( + node[field_node_dim].set( std::to_string(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); // shift origin by one ghost cell - field_channel_mesh[field_node_origin].set( + node[field_node_origin].set( std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); - field_channel_mesh[field_node_spacing].set( + node[field_node_spacing].set( std::to_string(field.get_mesh().getMeshSpacing(iDim))); ++field_node_dim.back(); @@ -92,23 +90,31 @@ namespace CatalystAdaptor ++field_node_spacing.back(); } - auto field_channel_topology = channel_field["data"]; - field_channel_topology["type"].set("uniform"); - field_channel_topology["coordset"].set("coords"); + node["topologies/topo/type"].set("uniform"); + node["topologies/topo/coordset"].set("coords"); + + field_node_origin = "topologies/topo/origin/x"; + for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ + // shift origin by one ghost cell + node[field_node_origin].set( + std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); + + ++field_node_origin.back(); + } - auto field_channel_fields = channel_field["data/fields/density"]; - field_channel_fields["association"].set("element"); - field_channel_fields["volume_dependent"].set("false"); - field_channel_fields["topology"].set("mesh"); + node["fields/field/association"].set("element"); + node["fields/field/volume_dependent"].set("false"); + node["fields/field/topology"].set("topo"); - field_channel_fields["values"].set_external( + node["fields/field/values"].set_external( field.getView().data(), - field.getOwned().size(), - field.getLayout().getLocalNDIndex(rank)[1].first()); + field.getOwned().size()); // print node to see what I write there if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + std::cout << node.number_of_children() << std::endl; + std::cout << node.number_of_elements() << std::endl; catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 3b1f17bd1..66fe9e64b 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -28,7 +28,7 @@ int main(int argc, char* argv[]) { constexpr unsigned int dim {3}; - const int pt {4}; + const int pt {2}; ippl::Index Ix(pt); ippl::Index Iy {pt}; ippl::Index Iz {pt}; From a67839e096954436bb812d7a5f5dd6dbf38ed337 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 15:29:38 +0200 Subject: [PATCH 032/113] prefix every node with catalyst, pipeline can now be connected --- src/Stream/InSitu/CatalystAdaptor.h | 32 ++++++++++++++--------------- test/stream/catalyst_pipeline.py | 15 +++++++++++--- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 5b8ad1897..929e21029 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -57,9 +57,9 @@ namespace CatalystAdaptor // catalyst_about(conduit_cpp::c_node(&node)); // add time/cycle information - node["state/cycle"].set(cycle); - node["state/time"].set(time); - node["state/domain_id"].set(rank); + node["catalyst/state/cycle"].set(cycle); + node["catalyst/state/time"].set(time); + node["catalyst/state/domain_id"].set(rank); // Add channels. // auto channel_field = node["catalyst/field"]; // /coordsets/coords"]; @@ -67,12 +67,12 @@ namespace CatalystAdaptor // // auto field_channel_mesh = channel_field["data"]; - node["coordsets/coords/type"].set("uniform"); + node["catalyst/coordsets/coords/type"].set("uniform"); // number of points in specific dimension - std::string field_node_dim {"coordsets/coords/dims/i"}; - std::string field_node_origin {"coordsets/coords/origin/x"}; - std::string field_node_spacing {"coordsets/coords/spacing/dx"}; + std::string field_node_dim {"catalyst/coordsets/coords/dims/i"}; + std::string field_node_origin {"catalyst/coordsets/coords/origin/x"}; + std::string field_node_spacing {"catalyst/coordsets/coords/spacing/dx"}; auto origin = field.get_mesh().getOrigin(); for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ @@ -90,10 +90,10 @@ namespace CatalystAdaptor ++field_node_spacing.back(); } - node["topologies/topo/type"].set("uniform"); - node["topologies/topo/coordset"].set("coords"); + node["catalyst/topologies/topo/type"].set("uniform"); + node["catalyst/topologies/topo/coordset"].set("coords"); - field_node_origin = "topologies/topo/origin/x"; + field_node_origin = "catalyst/topologies/topo/origin/x"; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // shift origin by one ghost cell node[field_node_origin].set( @@ -102,19 +102,19 @@ namespace CatalystAdaptor ++field_node_origin.back(); } - node["fields/field/association"].set("element"); - node["fields/field/volume_dependent"].set("false"); - node["fields/field/topology"].set("topo"); + node["catalyst/fields/field/association"].set("element"); + node["catalyst/fields/field/volume_dependent"].set("false"); + node["catalyst/fields/field/topology"].set("topo"); - node["fields/field/values"].set_external( + node["catalyst/fields/field/values"].set_external( field.getView().data(), field.getOwned().size()); // print node to see what I write there if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - std::cout << node.number_of_children() << std::endl; - std::cout << node.number_of_elements() << std::endl; + std::cout << node["catalyst"].number_of_children() << std::endl; + std::cout << node["catalyst"].number_of_elements() << std::endl; catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index feb23e4e5..788a4afc7 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -1,17 +1,26 @@ from paraview.simple import * +from paraview.catalyst import get_args # Greeting to ensure that ctest knows this script is being imported print("executing catalyst_pipeline") +print("executing catalyst_pipeline") +print("===================================") +print("pipeline args={}".format(get_args())) +print("===================================") + # registrationName must match the channel name used in the # 'CatalystAdaptor'. -producer = TrivialProducer(registrationName="field") +producer = TrivialProducer() def catalyst_execute(info): global producer producer.UpdatePipeline() print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) -# print("bounds:", producer.GetDataInformation().GetBounds()) - print("field:", producer.CellData["density"].GetRange(0)) + print("getcelldatainformation", producer.GetCellDataInformation()) + print("getdatainformation", producer.GetDataInformation()) + print("getpoint data information", producer.GetPointDataInformation()) + print("getpoint data information", producer.ListProperties()) + print("field:", producer.CellData["density"]) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 52748a22fb231fecd950a6d22882194ce0e36b4e Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 16:44:13 +0200 Subject: [PATCH 033/113] change naming according to catalyst documentation and examples --- src/Stream/InSitu/CatalystAdaptor.h | 57 +++++++++++++++-------------- test/stream/catalyst_pipeline.py | 9 +---- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 929e21029..eb26dce96 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -57,64 +57,67 @@ namespace CatalystAdaptor // catalyst_about(conduit_cpp::c_node(&node)); // add time/cycle information - node["catalyst/state/cycle"].set(cycle); - node["catalyst/state/time"].set(time); - node["catalyst/state/domain_id"].set(rank); + auto state = node["catalyst/state"]; + state["cycle"].set(cycle); + state["time"].set(time); + state["domain_id"].set(rank); // Add channels. // auto channel_field = node["catalyst/field"]; // /coordsets/coords"]; // channel_field["type"].set("mesh"); -// +// // auto field_channel_mesh = channel_field["data"]; + + auto channel = node["catalyst/channels/grid"]; + channel["type"].set_string("mesh"); - node["catalyst/coordsets/coords/type"].set("uniform"); + auto mesh = channel["data"]; + mesh["coordsets/coords/type"].set("uniform"); // number of points in specific dimension - std::string field_node_dim {"catalyst/coordsets/coords/dims/i"}; - std::string field_node_origin {"catalyst/coordsets/coords/origin/x"}; - std::string field_node_spacing {"catalyst/coordsets/coords/spacing/dx"}; + std::string field_node_dim {"coordsets/coords/dims/i"}; + std::string field_node_origin {"coordsets/coords/origin/x"}; + std::string field_node_spacing {"coordsets/coords/spacing/dx"}; auto origin = field.get_mesh().getOrigin(); for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // include ghost cells to the "left" and "right" - node[field_node_dim].set( - std::to_string(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); + mesh[field_node_dim].set( + field.get_mesh().getGridsize(iDim) + 2 * field.getNghost()); // shift origin by one ghost cell - node[field_node_origin].set( - std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); - node[field_node_spacing].set( - std::to_string(field.get_mesh().getMeshSpacing(iDim))); + mesh[field_node_origin].set( + origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); + mesh[field_node_spacing].set( + field.get_mesh().getMeshSpacing(iDim)); ++field_node_dim.back(); ++field_node_origin.back(); ++field_node_spacing.back(); } - - node["catalyst/topologies/topo/type"].set("uniform"); - node["catalyst/topologies/topo/coordset"].set("coords"); - - field_node_origin = "catalyst/topologies/topo/origin/x"; + mesh["topologies/mesh/type"].set("uniform"); + mesh["topologies/mesh/coordset"].set("coords"); + field_node_origin = "topologies/mesh/origin/x"; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // shift origin by one ghost cell - node[field_node_origin].set( - std::to_string(origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost())); + mesh[field_node_origin].set( + origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); ++field_node_origin.back(); } - node["catalyst/fields/field/association"].set("element"); - node["catalyst/fields/field/volume_dependent"].set("false"); - node["catalyst/fields/field/topology"].set("topo"); + auto fields = mesh["fields"]; + + fields["density/association"].set("element"); + fields["density/topology"].set("mesh"); + fields["density/volume_dependent"].set("false"); - node["catalyst/fields/field/values"].set_external( + fields["density/values"].set( field.getView().data(), field.getOwned().size()); // print node to see what I write there if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - std::cout << node["catalyst"].number_of_children() << std::endl; - std::cout << node["catalyst"].number_of_elements() << std::endl; catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 788a4afc7..64a8ed5e4 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -1,17 +1,12 @@ from paraview.simple import * -from paraview.catalyst import get_args -# Greeting to ensure that ctest knows this script is being imported print("executing catalyst_pipeline") -print("executing catalyst_pipeline") -print("===================================") -print("pipeline args={}".format(get_args())) -print("===================================") + # registrationName must match the channel name used in the # 'CatalystAdaptor'. -producer = TrivialProducer() +producer = TrivialProducer(registrationName="grid") def catalyst_execute(info): global producer From 186b200bbea46f044c6b21a9b70d654408f985ed Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 4 Sep 2023 18:37:03 +0200 Subject: [PATCH 034/113] fix problem with wrong node Return type of the dimension was not int, fixed now with casting of the whole result to int. For debugging of ParaView nightly build is needed and can be obtained from the website. --- src/Stream/InSitu/CatalystAdaptor.h | 6 +++--- test/stream/TestCatalystAdaptor.cpp | 2 +- test/stream/catalyst_pipeline.py | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index eb26dce96..3fe6fd5ae 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -83,7 +83,7 @@ namespace CatalystAdaptor for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // include ghost cells to the "left" and "right" mesh[field_node_dim].set( - field.get_mesh().getGridsize(iDim) + 2 * field.getNghost()); + int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); // shift origin by one ghost cell mesh[field_node_origin].set( origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); @@ -111,12 +111,12 @@ namespace CatalystAdaptor fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set( + fields["density/values"].set_external( field.getView().data(), field.getOwned().size()); // print node to see what I write there - if (cycle == 1) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 66fe9e64b..f8f27d164 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { double time = {0.0}; const double dt = {0.05}; - const unsigned int nt = {2}; + const unsigned int nt = {1}; for (unsigned int it = 0; it < nt; ++it) { Kokkos::parallel_for( diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 64a8ed5e4..d6261f3f2 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -13,9 +13,5 @@ def catalyst_execute(info): producer.UpdatePipeline() print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) - print("getcelldatainformation", producer.GetCellDataInformation()) - print("getdatainformation", producer.GetDataInformation()) - print("getpoint data information", producer.GetPointDataInformation()) - print("getpoint data information", producer.ListProperties()) - print("field:", producer.CellData["density"]) + #print("field:", producer.CellData["density"]) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 4cf450841c10b94216e0053a49a896a02efadf09 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 09:43:10 +0200 Subject: [PATCH 035/113] fix tuple missmatch in CatalystAdaptor Added missing +1 coordinate points. --- src/Stream/InSitu/CatalystAdaptor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 3fe6fd5ae..03b51532f 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -83,7 +83,7 @@ namespace CatalystAdaptor for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ // include ghost cells to the "left" and "right" mesh[field_node_dim].set( - int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost())); + int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost()+1)); // shift origin by one ghost cell mesh[field_node_origin].set( origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); @@ -113,7 +113,7 @@ namespace CatalystAdaptor fields["density/values"].set_external( field.getView().data(), - field.getOwned().size()); + field.getView().size()); // print node to see what I write there if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); From 0c62fd9d7afa8359b7351c01b25da753a0c29fe8 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 09:46:18 +0200 Subject: [PATCH 036/113] add 2D catalyst adaptor test --- src/Stream/InSitu/CatalystAdaptor.h | 6 +- test/stream/CMakeLists.txt | 7 ++ test/stream/TestCatalystAdaptor_2D.cpp | 109 +++++++++++++++++++++++++ test/stream/catalyst_pipeline.py | 14 ++-- 4 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 test/stream/TestCatalystAdaptor_2D.cpp diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 03b51532f..12509e7dc 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -14,8 +14,8 @@ namespace CatalystAdaptor { - constexpr unsigned int dim {3}; - using Mesh_t = ippl::UniformCartesian; + constexpr unsigned int dim {2}; + using Mesh_t = ippl::UniformCartesian; using Centering_t = Mesh_t::DefaultCentering; typedef ippl::Field field_type; @@ -68,7 +68,7 @@ namespace CatalystAdaptor // // auto field_channel_mesh = channel_field["data"]; - auto channel = node["catalyst/channels/grid"]; + auto channel = node["catalyst/channels/ippl_field"]; channel["type"].set_string("mesh"); auto mesh = channel["data"]; diff --git a/test/stream/CMakeLists.txt b/test/stream/CMakeLists.txt index 7248e5f5f..0e4939810 100644 --- a/test/stream/CMakeLists.txt +++ b/test/stream/CMakeLists.txt @@ -20,6 +20,13 @@ target_link_libraries ( ${MPI_CXX_LIBRARIES} ) +add_executable (TestCatalystAdaptor-2D TestCatalystAdaptor_2D.cpp) +target_link_libraries ( + TestCatalystAdaptor-2D + ${IPPL_LIBS} + ${MPI_CXX_LIBRARIES} +) + # vi: set et ts=4 sw=4 sts=4: # Local Variables: diff --git a/test/stream/TestCatalystAdaptor_2D.cpp b/test/stream/TestCatalystAdaptor_2D.cpp new file mode 100644 index 000000000..611d4674b --- /dev/null +++ b/test/stream/TestCatalystAdaptor_2D.cpp @@ -0,0 +1,109 @@ +// Tests the application for the Catalyst In-Situ Adaptor +// following environment variables do need to be exported +// +// export CATALYST_IMPLEMENTATION_PATHS=/lib/catalyst +// export CATALYST_IMPLEMENTATION_NAME=paraview +// +// on juwels these both are direclty set! +// +// export PARARVIEW_CATALYST_DIR=/lib/catalyst +// +// RUN +// ./TestCatalystAdaptor ./.py +// +// eg. +// ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py + +#include "Ippl.h" +#include "Stream/InSitu/CatalystAdaptor.h" + +#include +#include +#include + +int main(int argc, char* argv[]) { + + Ippl ippl(argc, argv); + CatalystAdaptor::Initialize(argc, argv); + + constexpr unsigned int dim {2}; + + const int pt {2}; + ippl::Index Ix(pt); + ippl::Index Iy {pt}; + ippl::NDIndex owned(Ix, Iy); + + ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims + for (unsigned int d = 0; d < dim; d++) + allParallel[d] = ippl::PARALLEL; + + ippl::FieldLayout layout(owned, allParallel); + + constexpr double dx = {1.0 / double(pt)}; + constexpr double dy = {1.0 / double(pt)}; + ippl::Vector hx = {dx, dy}; + ippl::Vector origin = {0, 0}; + + using Mesh_t = ippl::UniformCartesian; + using Centering_t = Mesh_t::DefaultCentering; + + Mesh_t mesh(owned, hx, origin); + + typedef ippl::Field field_type; + + std::cout << layout << std::endl; + + field_type field(mesh, layout, 1); + + field = 1.0; + + const ippl::NDIndex& lDom = layout.getLocalNDIndex(); + const int nghost = field.getNghost(); + using mdrange_type = Kokkos::MDRangePolicy>; + typename field_type::view_type& view = field.getView(); + + + double time = {0.0}; + const double dt = {0.05}; + const unsigned int nt = {5}; + for (unsigned int it = 0; it < nt; ++it) { + + Kokkos::parallel_for( + "Assign field", + mdrange_type({nghost, nghost}, + {view.extent(0) - nghost, view.extent(1) - nghost}), + KOKKOS_LAMBDA(const int i, const int j) { + // local to global index conversion + //const size_t ig = i + lDom[0].first() - nghost; + const size_t jg = j + lDom[1].first() - nghost; + // const size_t kg = k + lDom[2].first() - nghost; + //double x = (ig + 0.5) * hx[0] + origin[0]; + double y = (jg + 0.5) * hx[1] + origin[1]; + // double z = (kg + 0.5) * hx[2]; + + // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); + // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); + // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); + view(i, j) = y * time; + // std::cout << view(i,j) << std::endl; + }); + + CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); //field + // print should be same as field data + time += dt; + + } + + int nRanks = Ippl::Comm->size(); + for (int rank = 0; rank < nRanks; ++rank) { + if (rank == Ippl::Comm->rank()) { + std::string fname = "field_AllBC_" + std::to_string(rank) + ".dat"; + Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); + field.write(out); + } + Ippl::Comm->barrier(); + } + + CatalystAdaptor::Finalize(); + return 0; +} diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index d6261f3f2..6a080768a 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -1,17 +1,19 @@ from paraview.simple import * print("executing catalyst_pipeline") - +import pdb # registrationName must match the channel name used in the # 'CatalystAdaptor'. -producer = TrivialProducer(registrationName="grid") - +producer = TrivialProducer(registrationName="ippl_field") +pdb.set_trace() def catalyst_execute(info): global producer - producer.UpdatePipeline() - print("-----------------------------------") + #SaveExtractsUsingCatalystOptions(options) +# global producer + producer.UpdatePipeline(info.time) +# print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) - #print("field:", producer.CellData["density"]) + print("field:", producer.CellData["density"].GetRange(-1)) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 2125e42c249663454e863235b0975c534cfc5465 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 09:55:42 +0200 Subject: [PATCH 037/113] cleanup CatalystAdaptor and add small comments to functions --- src/Stream/InSitu/CatalystAdaptor.h | 41 +++++++++++------------------ test/stream/catalyst_pipeline.py | 2 -- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 12509e7dc..61ea28103 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -17,16 +17,8 @@ namespace CatalystAdaptor constexpr unsigned int dim {2}; using Mesh_t = ippl::UniformCartesian; using Centering_t = Mesh_t::DefaultCentering; - typedef ippl::Field field_type; - -/** - * In this example, we show how we can use Catalysts's C++ - * wrapper around conduit's C API to create Conduit nodes. - * This is not required. A C++ adaptor can just as - * conveniently use the Conduit C API to setup the - * `conduit_node`. However, this example shows that one can - * indeed use Catalyst's C++ API, if the developer so chooses. - */ + using field_type = ippl::Field; + void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; @@ -50,27 +42,24 @@ namespace CatalystAdaptor void Execute(int cycle, double time, int rank, field_type &field) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) { - //conduit_cpp::Node exec_params; + // catalyst blueprint definition + // https://docs.paraview.org/en/latest/Catalyst/blueprints.html + // + // conduit blueprint definition (v.8.3) + // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html conduit_cpp::Node node; - // include information about catalyst, conduit implementation -// catalyst_about(conduit_cpp::c_node(&node)); - // add time/cycle information auto state = node["catalyst/state"]; state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); -// Add channels. -// auto channel_field = node["catalyst/field"]; // /coordsets/coords"]; -// channel_field["type"].set("mesh"); -// -// auto field_channel_mesh = channel_field["data"]; - + // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; channel["type"].set_string("mesh"); - + + // in data channel now we adhere to conduits mesh blueprint definition auto mesh = channel["data"]; mesh["coordsets/coords/type"].set("uniform"); @@ -81,7 +70,7 @@ namespace CatalystAdaptor auto origin = field.get_mesh().getOrigin(); for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ - // include ghost cells to the "left" and "right" + // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost()+1)); // shift origin by one ghost cell @@ -90,10 +79,13 @@ namespace CatalystAdaptor mesh[field_node_spacing].set( field.get_mesh().getMeshSpacing(iDim)); + // increment last char in string ++field_node_dim.back(); ++field_node_origin.back(); ++field_node_spacing.back(); } + + // add topology mesh["topologies/mesh/type"].set("uniform"); mesh["topologies/mesh/coordset"].set("coords"); field_node_origin = "topologies/mesh/origin/x"; @@ -105,17 +97,16 @@ namespace CatalystAdaptor ++field_node_origin.back(); } + // add values and subscribe to data auto fields = mesh["fields"]; - fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external( field.getView().data(), field.getView().size()); - // print node to see what I write there + // print node to have visual representation if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 6a080768a..cb37651a8 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -1,13 +1,11 @@ from paraview.simple import * print("executing catalyst_pipeline") -import pdb # registrationName must match the channel name used in the # 'CatalystAdaptor'. producer = TrivialProducer(registrationName="ippl_field") -pdb.set_trace() def catalyst_execute(info): global producer #SaveExtractsUsingCatalystOptions(options) From a64d32ef97fb8a5d22a8c87fb9711be834d5c578 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 10:36:14 +0200 Subject: [PATCH 038/113] adapt daming of field_type to ippl conventions --- src/Stream/InSitu/CatalystAdaptor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 61ea28103..6aae78487 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -17,7 +17,7 @@ namespace CatalystAdaptor constexpr unsigned int dim {2}; using Mesh_t = ippl::UniformCartesian; using Centering_t = Mesh_t::DefaultCentering; - using field_type = ippl::Field; + using Field_t = ippl::Field; void Initialize(int argc, char* argv[]) { @@ -40,7 +40,8 @@ namespace CatalystAdaptor } } - void Execute(int cycle, double time, int rank, field_type &field) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) + + void Execute(int cycle, double time, int rank, Field_t &field) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) { // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html From f28ff106ef6462aa8e02dc9e1ccefcd6d1a011d7 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 11:38:42 +0200 Subject: [PATCH 039/113] add Field_t as template argument to be able to compile both 2D and 3D without changing code --- src/Stream/InSitu/CatalystAdaptor.h | 66 ++++++++++++++--------------- test/stream/catalyst_pipeline.py | 2 +- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 6aae78487..5f5d10ff2 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -3,6 +3,8 @@ #ifndef CatalystAdaptor_h #define CatalystAdaptor_h +#include "Ippl.h" + #include #include #include @@ -10,38 +12,37 @@ #include #include "Utility/IpplException.h" -#include "Ippl.h" -namespace CatalystAdaptor -{ - constexpr unsigned int dim {2}; +namespace CatalystAdaptor { + constexpr unsigned int dim{2}; using Mesh_t = ippl::UniformCartesian; using Centering_t = Mesh_t::DefaultCentering; - using Field_t = ippl::Field; + using Field_t = ippl::Field; - void Initialize(int argc, char* argv[]) - { + void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; - for (int cc = 1; cc < argc; ++cc) - { + for (int cc = 1; cc < argc; ++cc) { node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); } try { - node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); + node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); node["catalyst_load/search_paths/paraview"] = getenv("PARAVIEW_CATALYST_DIR"); - } catch (...){ - throw IpplException("CatalystAdaptor::Initialize", "no environmental variable for CATALYST_IMPLEMENTATION_NAME or PARAVIEW_CATALYST_DIR found"); + } catch (...) { + throw IpplException("CatalystAdaptor::Initialize", + "no environmental variable for CATALYST_IMPLEMENTATION_NAME or " + "PARAVIEW_CATALYST_DIR found"); } // TODO: catch catalyst error also with IpplException catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) - { + if (err != catalyst_status_ok) { std::cerr << "Failed to initialize Catalyst: " << err << std::endl; } } - - void Execute(int cycle, double time, int rank, Field_t &field) //int cycle, double time) //, Grid& grid, Attributes& attribs, Particles& particles) + template + void Execute(int cycle, double time, int rank, + Field_t& field) // int cycle, double time) //, Grid& grid, Attributes& attribs, + // Particles& particles) { // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html @@ -65,20 +66,19 @@ namespace CatalystAdaptor mesh["coordsets/coords/type"].set("uniform"); // number of points in specific dimension - std::string field_node_dim {"coordsets/coords/dims/i"}; - std::string field_node_origin {"coordsets/coords/origin/x"}; - std::string field_node_spacing {"coordsets/coords/spacing/dx"}; + std::string field_node_dim{"coordsets/coords/dims/i"}; + std::string field_node_origin{"coordsets/coords/origin/x"}; + std::string field_node_spacing{"coordsets/coords/spacing/dx"}; auto origin = field.get_mesh().getOrigin(); - for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ + for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( - int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost()+1)); + int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost() + 1)); // shift origin by one ghost cell mesh[field_node_origin].set( origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); - mesh[field_node_spacing].set( - field.get_mesh().getMeshSpacing(iDim)); + mesh[field_node_spacing].set(field.get_mesh().getMeshSpacing(iDim)); // increment last char in string ++field_node_dim.back(); @@ -90,7 +90,7 @@ namespace CatalystAdaptor mesh["topologies/mesh/type"].set("uniform"); mesh["topologies/mesh/coordset"].set("coords"); field_node_origin = "topologies/mesh/origin/x"; - for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim){ + for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // shift origin by one ghost cell mesh[field_node_origin].set( origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); @@ -103,29 +103,25 @@ namespace CatalystAdaptor fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external( - field.getView().data(), - field.getView().size()); + fields["density/values"].set_external(field.getView().data(), field.getView().size()); // print node to have visual representation - if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + if (cycle == 0) + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) - { + if (err != catalyst_status_ok) { std::cerr << "Failed to execute Catalyst: " << err << std::endl; } } - void Finalize() - { + void Finalize() { conduit_cpp::Node node; catalyst_status err = catalyst_finalize(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) - { + if (err != catalyst_status_ok) { std::cerr << "Failed to finalize Catalyst: " << err << std::endl; } } -} +} // namespace CatalystAdaptor #endif diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index cb37651a8..cc2cf76e3 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -13,5 +13,5 @@ def catalyst_execute(info): producer.UpdatePipeline(info.time) # print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) - print("field:", producer.CellData["density"].GetRange(-1)) + print("field:", producer.CellData["density"].GetRange(0)) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From cf868982839721757bbc638ae3c3eb0ce92d61bb Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 14:29:27 +0200 Subject: [PATCH 040/113] include dumpVTK to TestCatalystAdaptor --- test/stream/TestCatalystAdaptor.cpp | 119 +++++++++++++++++++--------- 1 file changed, 83 insertions(+), 36 deletions(-) diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index f8f27d164..540ab8953 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -15,23 +15,69 @@ // ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py #include "Ippl.h" -#include "Stream/InSitu/CatalystAdaptor.h" #include #include #include -int main(int argc, char* argv[]) { +#include "Stream/InSitu/CatalystAdaptor.h" +constexpr unsigned int dim{3}; +using Mesh_t = ippl::UniformCartesian; +using Centering_t = Mesh_t::DefaultCentering; +using Field_t = ippl::Field; +const char* TestName = "CatalystAdaptor"; + +void dumpVTK(Field_t& rho, int nx, int ny, int nz, int iteration, double dx, double dy, double dz) { + typename Field_t::view_type::host_mirror_type host_view = rho.getHostMirror(); + // auto view = rho.getHostMirror(); + + std::stringstream fname; + fname << "data/scalar_"; + fname << std::setw(4) << std::setfill('0') << iteration; + fname << ".vtk"; + + Kokkos::deep_copy(host_view, rho.getView()); + + Inform vtkout(NULL, fname.str().c_str(), Inform::OVERWRITE); + vtkout.precision(10); + vtkout.setf(std::ios::scientific, std::ios::floatfield); + + if (vtkout.openedSuccessfully()) { + // start with header + vtkout << "# vtk DataFile Version 2.0" << endl; + vtkout << TestName << endl; + vtkout << "ASCII" << endl; + vtkout << "DATASET STRUCTURED_POINTS" << endl; + vtkout << "DIMENSIONS " << nx + 3 << " " << ny + 3 << " " << nz + 3 << endl; + vtkout << "ORIGIN " << -dx << " " << -dy << " " << -dz << endl; + vtkout << "SPACING " << dx << " " << dy << " " << dz << endl; + vtkout << "CELL_DATA " << (nx + 2) * (ny + 2) * (nz + 2) << endl; + + vtkout << "SCALARS Rho float" << endl; + vtkout << "LOOKUP_TABLE default" << endl; + for (int z = 0; z < nz + 2; z++) { + for (int y = 0; y < ny + 2; y++) { + for (int x = 0; x < nx + 2; x++) { + vtkout << host_view(x, y, z) << endl; + } + } + } + } else { + IpplException("TestCatalystAdaptor::dumpVTK", "opening of file was not successful"); + } +} + +int main(int argc, char* argv[]) { Ippl ippl(argc, argv); CatalystAdaptor::Initialize(argc, argv); - constexpr unsigned int dim {3}; + // constexpr unsigned int dim {3}; - const int pt {2}; + const int pt{2}; ippl::Index Ix(pt); - ippl::Index Iy {pt}; - ippl::Index Iz {pt}; + ippl::Index Iy{pt}; + ippl::Index Iz{pt}; ippl::NDIndex owned(Ix, Iy, Iz); ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims @@ -46,8 +92,8 @@ int main(int argc, char* argv[]) { ippl::Vector hx = {dx, dy, dz}; ippl::Vector origin = {0, 0, 0}; - using Mesh_t = ippl::UniformCartesian; - using Centering_t = Mesh_t::DefaultCentering; + // using Mesh_t = ippl::UniformCartesian; + // using Centering_t = Mesh_t::DefaultCentering; Mesh_t mesh(owned, hx, origin); @@ -64,35 +110,36 @@ int main(int argc, char* argv[]) { using mdrange_type = Kokkos::MDRangePolicy>; typename field_type::view_type& view = field.getView(); - - double time = {0.0}; - const double dt = {0.05}; - const unsigned int nt = {1}; + double time = {0.0}; + const double dt = {0.05}; + const unsigned int nt = {10}; for (unsigned int it = 0; it < nt; ++it) { - - Kokkos::parallel_for( - "Assign field", - mdrange_type({nghost, nghost, nghost}, - {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), - KOKKOS_LAMBDA(const int i, const int j, const int k) { - // local to global index conversion - //const size_t ig = i + lDom[0].first() - nghost; - const size_t jg = j + lDom[1].first() - nghost; - // const size_t kg = k + lDom[2].first() - nghost; - //double x = (ig + 0.5) * hx[0] + origin[0]; - double y = (jg + 0.5) * hx[1] + origin[1]; - // double z = (kg + 0.5) * hx[2]; - - // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); - // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); - // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); - view(i, j, k) = y * time; - }); - - CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); //field - // print should be same as field data - time += dt; - + Kokkos::parallel_for( + "Assign field", + mdrange_type( + {nghost, nghost, nghost}, + {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), + KOKKOS_LAMBDA(const int i, const int j, const int k) { + // local to global index conversion + // const size_t ig = i + lDom[0].first() - nghost; + const size_t jg = j + lDom[1].first() - nghost; + // const size_t kg = k + lDom[2].first() - nghost; + // double x = (ig + 0.5) * hx[0] + origin[0]; + double y = (jg + 0.5) * hx[1] + origin[1]; + // double z = (kg + 0.5) * hx[2]; + + // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); + // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); + // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); + view(i, j, k) = y * time; + }); + + CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); + // print should be same as field data + time += dt; + dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), + field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), + field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); } int nRanks = Ippl::Comm->size(); From e89be9be3875b24279caed911659b5b5e7c5b264 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 5 Sep 2023 14:31:27 +0200 Subject: [PATCH 041/113] add script which would create pictures of our output --- .gitignore | 3 + test/stream/TestCatalystAdaptor.cpp | 4 +- test/stream/catalyst2_pipeline.py | 176 ++++++++++++++++++++++++++++ 3 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 test/stream/catalyst2_pipeline.py diff --git a/.gitignore b/.gitignore index 70758138a..3dbfbb665 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ manual/*.lof manual/*.lot manual/ippl_user_guide.pdf +# ignure vtk dump stuff +*.vtk + # CMake and Build folder CMakeFiles/ build* diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 540ab8953..6b7f31720 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -12,7 +12,9 @@ // ./TestCatalystAdaptor ./.py // // eg. -// ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py +// ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py --info 5 +// +// when dumping of the vtk is required also --info 5 is needed #include "Ippl.h" diff --git a/test/stream/catalyst2_pipeline.py b/test/stream/catalyst2_pipeline.py new file mode 100644 index 000000000..bd4aaed44 --- /dev/null +++ b/test/stream/catalyst2_pipeline.py @@ -0,0 +1,176 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [862, 839] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [0.5, 0.5, 0.5] +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [-8.321539336674517, 5.118013528880978, 10.826590265546251] +renderView1.CameraFocalPoint = [0.5, 0.5, 0.5] +renderView1.CameraViewUp = [0.24312654349512303, 0.9458058854041994, -0.21526892711883117] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 1.7320508075688772 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(862, 839) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'Legacy VTK Reader' +scalar_0000vtk = LegacyVTKReader(registrationName='scalar_0000.vtk*', FileNames=['/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0000.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0001.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0002.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0003.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0004.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0005.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0006.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0007.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0008.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0009.vtk']) + +# create a new 'Cell Data to Point Data' +cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=scalar_0000vtk) +cellDatatoPointData1.CellDataArraytoprocess = ['Rho'] + +# create a new 'Contour' +contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) +contour1.ContourBy = ['POINTS', 'Rho'] +contour1.Isosurfaces = [0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444, 0.5555555555555556, 0.6666666666666666, 0.7777777777777777, 0.8888888888888888, 1.0] +contour1.PointMergeMethod = 'Uniform Binning' + +# create a new 'Clip' +clip1 = Clip(registrationName='Clip1', Input=contour1) +clip1.ClipType = 'Plane' +clip1.HyperTreeGridClipper = 'Plane' +clip1.Scalars = ['POINTS', 'Rho'] +clip1.Value = 0.5555555559694767 + +# init the 'Plane' selected for 'ClipType' +clip1.ClipType.Origin = [0.5, 0.5, 0.5] +clip1.ClipType.Normal = [0.0, 0.0, 1.0] + +# init the 'Plane' selected for 'HyperTreeGridClipper' +clip1.HyperTreeGridClipper.Origin = [0.5, 0.5, 0.5] + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from clip1 +clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'Rho' +rhoTF2D = GetTransferFunction2D('Rho') + +# get color transfer function/color map for 'Rho' +rhoLUT = GetColorTransferFunction('Rho') +rhoLUT.TransferFunction2D = rhoTF2D +rhoLUT.RGBPoints = [0.1111111119389534, 0.231373, 0.298039, 0.752941, 0.5555555559694767, 0.865003, 0.865003, 0.865003, 1.0, 0.705882, 0.0156863, 0.14902] +rhoLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'Rho' +rhoPWF = GetOpacityTransferFunction('Rho') +rhoPWF.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] +rhoPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +clip1Display.Representation = 'Surface' +clip1Display.ColorArrayName = ['POINTS', 'Rho'] +clip1Display.LookupTable = rhoLUT +clip1Display.SelectTCoordArray = 'None' +clip1Display.SelectNormalArray = 'Normals' +clip1Display.SelectTangentArray = 'None' +clip1Display.OSPRayScaleArray = 'Rho' +clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' +clip1Display.SelectOrientationVectors = 'None' +clip1Display.ScaleFactor = 0.2 +clip1Display.SelectScaleArray = 'Rho' +clip1Display.GlyphType = 'Arrow' +clip1Display.GlyphTableIndexArray = 'Rho' +clip1Display.GaussianRadius = 0.01 +clip1Display.SetScaleArray = ['POINTS', 'Rho'] +clip1Display.ScaleTransferFunction = 'PiecewiseFunction' +clip1Display.OpacityArray = ['POINTS', 'Rho'] +clip1Display.OpacityTransferFunction = 'PiecewiseFunction' +clip1Display.DataAxesGrid = 'GridAxesRepresentation' +clip1Display.PolarAxes = 'PolarAxesRepresentation' +clip1Display.ScalarOpacityFunction = rhoPWF +clip1Display.ScalarOpacityUnitDistance = 0.49106951261706133 +clip1Display.OpacityArrayName = ['POINTS', 'Rho'] +clip1Display.SelectInputVectors = ['POINTS', 'Normals'] +clip1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +clip1Display.ScaleTransferFunction.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +clip1Display.OpacityTransferFunction.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for rhoLUT in view renderView1 +rhoLUTColorBar = GetScalarBar(rhoLUT, renderView1) +rhoLUTColorBar.Title = 'Rho' +rhoLUTColorBar.ComponentTitle = '' + +# set color bar visibility +rhoLUTColorBar.Visibility = 1 + +# show color legend +clip1Display.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='ippl_field') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [862, 839] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(pNG1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From 0587081b7a6ac18db9f53d2b6f8e24a23efadd6c Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 6 Sep 2023 11:22:29 +0200 Subject: [PATCH 042/113] add shifting of origin to local values to allow execution with MPI --- src/Stream/InSitu/CatalystAdaptor.h | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 5f5d10ff2..9bfaafe04 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -56,6 +56,7 @@ namespace CatalystAdaptor { state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); + state["domain_id"].set(rank); // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; @@ -69,15 +70,23 @@ namespace CatalystAdaptor { std::string field_node_dim{"coordsets/coords/dims/i"}; std::string field_node_origin{"coordsets/coords/origin/x"}; std::string field_node_spacing{"coordsets/coords/spacing/dx"}; - auto origin = field.get_mesh().getOrigin(); + // auto origin = field.get_mesh().getOrigin()[0]; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( - int(field.get_mesh().getGridsize(iDim) + 2 * field.getNghost() + 1)); + int(field.getLayout().getLocalNDIndex(rank).last()[iDim] + + field.getNghost() // last field point including ghost cell + - field.getLayout().getLocalNDIndex(rank).first()[iDim] // local origin + + 2 * field.getNghost() + 1)); // ghost cells to left and right + // shift origin by one ghost cell mesh[field_node_origin].set( - origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); + field.get_mesh().getOrigin()[iDim] // global origin + + field.getLayout().getLocalNDIndex(rank)[iDim].first() + * field.get_mesh().getMeshSpacing(iDim) // shift to local index + - field.get_mesh().getMeshSpacing(iDim) + * field.getNghost()); // move index according to ghost cells mesh[field_node_spacing].set(field.get_mesh().getMeshSpacing(iDim)); // increment last char in string @@ -89,13 +98,16 @@ namespace CatalystAdaptor { // add topology mesh["topologies/mesh/type"].set("uniform"); mesh["topologies/mesh/coordset"].set("coords"); - field_node_origin = "topologies/mesh/origin/x"; + std::string field_node_origin_topo = "topologies/mesh/origin/x"; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // shift origin by one ghost cell - mesh[field_node_origin].set( - origin(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); + mesh[field_node_origin_topo].set(field.get_mesh().getOrigin()[iDim] + + field.getLayout().getLocalNDIndex(rank)[iDim].first() + * field.get_mesh().getMeshSpacing(iDim) + - field.get_mesh().getMeshSpacing(iDim) + * field.getNghost()); - ++field_node_origin.back(); + ++field_node_origin_topo.back(); } // add values and subscribe to data From bca1f02d8923770e9eec7e543444d26edd45e6c3 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 6 Sep 2023 11:28:35 +0200 Subject: [PATCH 043/113] remove duplicated for domain_id --- src/Stream/InSitu/CatalystAdaptor.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 9bfaafe04..df2168278 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -56,7 +56,6 @@ namespace CatalystAdaptor { state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); - state["domain_id"].set(rank); // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; From c02f34c1f1d9aaba66e14ab01cf67a350d18d9d1 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 6 Sep 2023 13:39:21 +0200 Subject: [PATCH 044/113] fix indexing by spacing with usage of length function --- src/Stream/InSitu/CatalystAdaptor.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index df2168278..b4cf608db 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -69,20 +69,18 @@ namespace CatalystAdaptor { std::string field_node_dim{"coordsets/coords/dims/i"}; std::string field_node_origin{"coordsets/coords/origin/x"}; std::string field_node_spacing{"coordsets/coords/spacing/dx"}; - // auto origin = field.get_mesh().getOrigin()[0]; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( - int(field.getLayout().getLocalNDIndex(rank).last()[iDim] - + field.getNghost() // last field point including ghost cell - - field.getLayout().getLocalNDIndex(rank).first()[iDim] // local origin + int(field.getLayout().getLocalNDIndex()[iDim].length() // last field point + // including ghost cell + 2 * field.getNghost() + 1)); // ghost cells to left and right // shift origin by one ghost cell mesh[field_node_origin].set( field.get_mesh().getOrigin()[iDim] // global origin - + field.getLayout().getLocalNDIndex(rank)[iDim].first() + + field.getLayout().getLocalNDIndex()[iDim].first() * field.get_mesh().getMeshSpacing(iDim) // shift to local index - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); // move index according to ghost cells @@ -101,7 +99,7 @@ namespace CatalystAdaptor { for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // shift origin by one ghost cell mesh[field_node_origin_topo].set(field.get_mesh().getOrigin()[iDim] - + field.getLayout().getLocalNDIndex(rank)[iDim].first() + + field.getLayout().getLocalNDIndex()[iDim].first() * field.get_mesh().getMeshSpacing(iDim) - field.get_mesh().getMeshSpacing(iDim) * field.getNghost()); From 4384e88cd18d7b53dfa0bf026f81a1cec60fd1bc Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 6 Sep 2023 15:44:51 +0200 Subject: [PATCH 045/113] cleanup in TestCatalystAdaptor Remove commented out lines, update comments at top --- src/Stream/InSitu/CatalystAdaptor.h | 9 ++-- test/stream/TestCatalystAdaptor.cpp | 37 +++++-------- test/stream/TestCatalystAdaptor_2D.cpp | 74 ++++++++++++-------------- 3 files changed, 51 insertions(+), 69 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index b4cf608db..948c2a56d 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -26,11 +26,11 @@ namespace CatalystAdaptor { } try { node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); - node["catalyst_load/search_paths/paraview"] = getenv("PARAVIEW_CATALYST_DIR"); + node["catalyst_load/search_paths/paraview"] = getenv("CATALYST_IMPLEMENTATION_PATHS"); } catch (...) { throw IpplException("CatalystAdaptor::Initialize", "no environmental variable for CATALYST_IMPLEMENTATION_NAME or " - "PARAVIEW_CATALYST_DIR found"); + "CATALYST_IMPLEMENTATION_PATHS found"); } // TODO: catch catalyst error also with IpplException catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); @@ -40,10 +40,7 @@ namespace CatalystAdaptor { } template - void Execute(int cycle, double time, int rank, - Field_t& field) // int cycle, double time) //, Grid& grid, Attributes& attribs, - // Particles& particles) - { + void Execute(int cycle, double time, int rank, Field_t& field) { // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html // diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 6b7f31720..3d2559268 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -1,38 +1,31 @@ // Tests the application for the Catalyst In-Situ Adaptor -// following environment variables do need to be exported +// following environment variables do need to be set // // export CATALYST_IMPLEMENTATION_PATHS=/lib/catalyst // export CATALYST_IMPLEMENTATION_NAME=paraview // // on juwels these both are direclty set! // -// export PARARVIEW_CATALYST_DIR=/lib/catalyst -// // RUN // ./TestCatalystAdaptor ./.py // -// eg. +// for dumping vtk files // ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py --info 5 // -// when dumping of the vtk is required also --info 5 is needed #include "Ippl.h" -#include #include -#include #include "Stream/InSitu/CatalystAdaptor.h" constexpr unsigned int dim{3}; -using Mesh_t = ippl::UniformCartesian; -using Centering_t = Mesh_t::DefaultCentering; -using Field_t = ippl::Field; -const char* TestName = "CatalystAdaptor"; +using Mesh_t = ippl::UniformCartesian; +using Centering_t = Mesh_t::DefaultCentering; +using Field_t = ippl::Field; void dumpVTK(Field_t& rho, int nx, int ny, int nz, int iteration, double dx, double dy, double dz) { typename Field_t::view_type::host_mirror_type host_view = rho.getHostMirror(); - // auto view = rho.getHostMirror(); std::stringstream fname; fname << "data/scalar_"; @@ -41,14 +34,14 @@ void dumpVTK(Field_t& rho, int nx, int ny, int nz, int iteration, double dx, dou Kokkos::deep_copy(host_view, rho.getView()); - Inform vtkout(NULL, fname.str().c_str(), Inform::OVERWRITE); + Inform vtkout(nullptr, fname.str().c_str(), Inform::OVERWRITE); vtkout.precision(10); vtkout.setf(std::ios::scientific, std::ios::floatfield); if (vtkout.openedSuccessfully()) { // start with header vtkout << "# vtk DataFile Version 2.0" << endl; - vtkout << TestName << endl; + vtkout << "CatalystAdaptor" << endl; vtkout << "ASCII" << endl; vtkout << "DATASET STRUCTURED_POINTS" << endl; vtkout << "DIMENSIONS " << nx + 3 << " " << ny + 3 << " " << nz + 3 << endl; @@ -74,8 +67,6 @@ int main(int argc, char* argv[]) { Ippl ippl(argc, argv); CatalystAdaptor::Initialize(argc, argv); - // constexpr unsigned int dim {3}; - const int pt{2}; ippl::Index Ix(pt); ippl::Index Iy{pt}; @@ -83,8 +74,8 @@ int main(int argc, char* argv[]) { ippl::NDIndex owned(Ix, Iy, Iz); ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims - for (unsigned int d = 0; d < dim; d++) - allParallel[d] = ippl::PARALLEL; + for (auto& d : allParallel) + d = ippl::PARALLEL; ippl::FieldLayout layout(owned, allParallel); @@ -94,12 +85,9 @@ int main(int argc, char* argv[]) { ippl::Vector hx = {dx, dy, dz}; ippl::Vector origin = {0, 0, 0}; - // using Mesh_t = ippl::UniformCartesian; - // using Centering_t = Mesh_t::DefaultCentering; - Mesh_t mesh(owned, hx, origin); - typedef ippl::Field field_type; + using field_type = ippl::Field; std::cout << layout << std::endl; @@ -126,6 +114,7 @@ int main(int argc, char* argv[]) { // const size_t ig = i + lDom[0].first() - nghost; const size_t jg = j + lDom[1].first() - nghost; // const size_t kg = k + lDom[2].first() - nghost; + // double x = (ig + 0.5) * hx[0] + origin[0]; double y = (jg + 0.5) * hx[1] + origin[1]; // double z = (kg + 0.5) * hx[2]; @@ -136,9 +125,11 @@ int main(int argc, char* argv[]) { view(i, j, k) = y * time; }); - CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); + CatalystAdaptor::Execute(it, time, Ippl::Comm->rank(), field); // print should be same as field data time += dt; + + // dumpVTK only works with --info 5 and higher dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); diff --git a/test/stream/TestCatalystAdaptor_2D.cpp b/test/stream/TestCatalystAdaptor_2D.cpp index 611d4674b..ed3f15759 100644 --- a/test/stream/TestCatalystAdaptor_2D.cpp +++ b/test/stream/TestCatalystAdaptor_2D.cpp @@ -15,32 +15,30 @@ // ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py #include "Ippl.h" -#include "Stream/InSitu/CatalystAdaptor.h" -#include #include -#include -int main(int argc, char* argv[]) { +#include "Stream/InSitu/CatalystAdaptor.h" +int main(int argc, char* argv[]) { Ippl ippl(argc, argv); CatalystAdaptor::Initialize(argc, argv); - constexpr unsigned int dim {2}; + constexpr unsigned int dim{2}; - const int pt {2}; + const int pt{2}; ippl::Index Ix(pt); - ippl::Index Iy {pt}; + ippl::Index Iy{pt}; ippl::NDIndex owned(Ix, Iy); ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims - for (unsigned int d = 0; d < dim; d++) - allParallel[d] = ippl::PARALLEL; + for (auto& d : allParallel) + d = ippl::PARALLEL; ippl::FieldLayout layout(owned, allParallel); - constexpr double dx = {1.0 / double(pt)}; - constexpr double dy = {1.0 / double(pt)}; + constexpr double dx = {1.0 / double(pt)}; + constexpr double dy = {1.0 / double(pt)}; ippl::Vector hx = {dx, dy}; ippl::Vector origin = {0, 0}; @@ -62,36 +60,32 @@ int main(int argc, char* argv[]) { using mdrange_type = Kokkos::MDRangePolicy>; typename field_type::view_type& view = field.getView(); - - double time = {0.0}; - const double dt = {0.05}; - const unsigned int nt = {5}; + double time = {0.0}; + const double dt = {0.05}; + const unsigned int nt = {5}; for (unsigned int it = 0; it < nt; ++it) { - - Kokkos::parallel_for( - "Assign field", - mdrange_type({nghost, nghost}, - {view.extent(0) - nghost, view.extent(1) - nghost}), - KOKKOS_LAMBDA(const int i, const int j) { - // local to global index conversion - //const size_t ig = i + lDom[0].first() - nghost; - const size_t jg = j + lDom[1].first() - nghost; - // const size_t kg = k + lDom[2].first() - nghost; - //double x = (ig + 0.5) * hx[0] + origin[0]; - double y = (jg + 0.5) * hx[1] + origin[1]; - // double z = (kg + 0.5) * hx[2]; - - // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); - // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); - // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); - view(i, j) = y * time; - // std::cout << view(i,j) << std::endl; - }); - - CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); //field - // print should be same as field data - time += dt; - + Kokkos::parallel_for( + "Assign field", + mdrange_type({nghost, nghost}, {view.extent(0) - nghost, view.extent(1) - nghost}), + KOKKOS_LAMBDA(const int i, const int j) { + // local to global index conversion + // const size_t ig = i + lDom[0].first() - nghost; + const size_t jg = j + lDom[1].first() - nghost; + // const size_t kg = k + lDom[2].first() - nghost; + // double x = (ig + 0.5) * hx[0] + origin[0]; + double y = (jg + 0.5) * hx[1] + origin[1]; + // double z = (kg + 0.5) * hx[2]; + + // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); + // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); + // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); + view(i, j) = y * time; + // std::cout << view(i,j) << std::endl; + }); + + CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); // field + // print should be same as field data + time += dt; } int nRanks = Ippl::Comm->size(); From 8038ed23709010dfda102ffbf40fd2637eb5193a Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 7 Sep 2023 09:51:35 +0200 Subject: [PATCH 046/113] add copy to cpu for cuda --- src/Stream/InSitu/CatalystAdaptor.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 948c2a56d..7a8d60de4 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -46,6 +46,9 @@ namespace CatalystAdaptor { // // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html + typename Field_t::view_type::host_mirror_type host_view = field.getHostMirror(); + + Kokkos::deep_copy(host_view, field.getView()); conduit_cpp::Node node; // add time/cycle information @@ -109,7 +112,7 @@ namespace CatalystAdaptor { fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external(field.getView().data(), field.getView().size()); + fields["density/values"].set_external(host_view.data(), host_view.size()); // print node to have visual representation if (cycle == 0) From c9ddd5b57a96fc0e40297f0e95786d3e91811b47 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 7 Sep 2023 11:48:02 +0200 Subject: [PATCH 047/113] change pipeline to produce pictures for TestCatalystAdaptor fixing the pipeline to now produce the data after catalyst live connection --- test/stream/catalyst2_pipeline.py | 170 ++++++++++++++++++------------ 1 file changed, 100 insertions(+), 70 deletions(-) diff --git a/test/stream/catalyst2_pipeline.py b/test/stream/catalyst2_pipeline.py index bd4aaed44..ba378c355 100644 --- a/test/stream/catalyst2_pipeline.py +++ b/test/stream/catalyst2_pipeline.py @@ -10,17 +10,22 @@ # setup views used in the visualization # ---------------------------------------------------------------- +# get the material library +materialLibrary1 = GetMaterialLibrary() + # Create a new 'Render View' -renderView1 = CreateView('RenderView') -renderView1.ViewSize = [862, 839] -renderView1.AxesGrid = 'GridAxes3DActor' -renderView1.CenterOfRotation = [0.5, 0.5, 0.5] -renderView1.StereoType = 'Crystal Eyes' -renderView1.CameraPosition = [-8.321539336674517, 5.118013528880978, 10.826590265546251] -renderView1.CameraFocalPoint = [0.5, 0.5, 0.5] -renderView1.CameraViewUp = [0.24312654349512303, 0.9458058854041994, -0.21526892711883117] -renderView1.CameraFocalDisk = 1.0 -renderView1.CameraParallelScale = 1.7320508075688772 +renderView3 = CreateView('RenderView') +renderView3.ViewSize = [936, 893] +renderView3.AxesGrid = 'GridAxes3DActor' +renderView3.CenterOfRotation = [0.5, 0.5, 0.5] +renderView3.StereoType = 'Crystal Eyes' +renderView3.CameraPosition = [5.357750529134775, 4.872085250907219, 5.280823925206746] +renderView3.CameraFocalPoint = [0.5, 0.5, 0.5] +renderView3.CameraViewUp = [-0.11343363691620603, 0.7878938103825996, -0.6052736187681985] +renderView3.CameraFocalDisk = 1.0 +renderView3.CameraParallelScale = 1.7320508075688772 +renderView3.BackEnd = 'OSPRay raycaster' +renderView3.OSPRayMaterialLibrary = materialLibrary1 SetActiveView(None) @@ -30,111 +35,136 @@ # create new layout object 'Layout #1' layout1 = CreateLayout(name='Layout #1') -layout1.AssignView(0, renderView1) -layout1.SetSize(862, 839) +layout1.SplitHorizontal(0, 0.500000) +layout1.AssignView(2, renderView3) +layout1.SetSize(1873, 893) # ---------------------------------------------------------------- # restore active view -SetActiveView(renderView1) +SetActiveView(renderView3) # ---------------------------------------------------------------- # ---------------------------------------------------------------- # setup the data processing pipelines # ---------------------------------------------------------------- -# create a new 'Legacy VTK Reader' -scalar_0000vtk = LegacyVTKReader(registrationName='scalar_0000.vtk*', FileNames=['/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0000.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0001.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0002.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0003.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0004.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0005.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0006.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0007.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0008.vtk', '/home/felix/data/juelich/ippl_toolchain/ippl/data/scalar_0009.vtk']) - -# create a new 'Cell Data to Point Data' -cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=scalar_0000vtk) -cellDatatoPointData1.CellDataArraytoprocess = ['Rho'] - -# create a new 'Contour' -contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) -contour1.ContourBy = ['POINTS', 'Rho'] -contour1.Isosurfaces = [0.0, 0.1111111111111111, 0.2222222222222222, 0.3333333333333333, 0.4444444444444444, 0.5555555555555556, 0.6666666666666666, 0.7777777777777777, 0.8888888888888888, 1.0] -contour1.PointMergeMethod = 'Uniform Binning' +# create a new 'PVTrivialProducer' +# extractippl_field = PVTrivialProducer(registrationName='Extract: ippl_field') +extractippl_field = PVTrivialProducer(registrationName='ippl_field') # create a new 'Clip' -clip1 = Clip(registrationName='Clip1', Input=contour1) +clip1 = Clip(registrationName='Clip1', Input=extractippl_field) clip1.ClipType = 'Plane' clip1.HyperTreeGridClipper = 'Plane' -clip1.Scalars = ['POINTS', 'Rho'] -clip1.Value = 0.5555555559694767 +clip1.Scalars = ['CELLS', 'density'] +clip1.Value = 0.5 # init the 'Plane' selected for 'ClipType' clip1.ClipType.Origin = [0.5, 0.5, 0.5] -clip1.ClipType.Normal = [0.0, 0.0, 1.0] # init the 'Plane' selected for 'HyperTreeGridClipper' clip1.HyperTreeGridClipper.Origin = [0.5, 0.5, 0.5] # ---------------------------------------------------------------- -# setup the visualization in view 'renderView1' +# setup the visualization in view 'renderView3' # ---------------------------------------------------------------- -# show data from clip1 -clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') +# show data from extractippl_field +extractippl_fieldDisplay = Show(extractippl_field, renderView3, 'UniformGridRepresentation') + +# get 2D transfer function for 'density' +densityTF2D = GetTransferFunction2D('density') +densityTF2D.ScalarRangeInitialized = 1 + +# get color transfer function/color map for 'density' +densityLUT = GetColorTransferFunction('density') +densityLUT.TransferFunction2D = densityTF2D +densityLUT.ScalarRangeInitialized = 1.0 -# get 2D transfer function for 'Rho' -rhoTF2D = GetTransferFunction2D('Rho') +# get opacity transfer function/opacity map for 'density' +densityPWF = GetOpacityTransferFunction('density') +densityPWF.ScalarRangeInitialized = 1 -# get color transfer function/color map for 'Rho' -rhoLUT = GetColorTransferFunction('Rho') -rhoLUT.TransferFunction2D = rhoTF2D -rhoLUT.RGBPoints = [0.1111111119389534, 0.231373, 0.298039, 0.752941, 0.5555555559694767, 0.865003, 0.865003, 0.865003, 1.0, 0.705882, 0.0156863, 0.14902] -rhoLUT.ScalarRangeInitialized = 1.0 +# trace defaults for the display properties. +extractippl_fieldDisplay.Representation = 'Outline' +extractippl_fieldDisplay.ColorArrayName = ['CELLS', 'density'] +extractippl_fieldDisplay.LookupTable = densityLUT +extractippl_fieldDisplay.SelectTCoordArray = 'None' +extractippl_fieldDisplay.SelectNormalArray = 'None' +extractippl_fieldDisplay.SelectTangentArray = 'None' +extractippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +extractippl_fieldDisplay.SelectOrientationVectors = 'None' +extractippl_fieldDisplay.ScaleFactor = 0.2 +extractippl_fieldDisplay.SelectScaleArray = 'None' +extractippl_fieldDisplay.GlyphType = 'Arrow' +extractippl_fieldDisplay.GlyphTableIndexArray = 'None' +extractippl_fieldDisplay.GaussianRadius = 0.01 +extractippl_fieldDisplay.SetScaleArray = [None, ''] +extractippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' +extractippl_fieldDisplay.OpacityArray = [None, ''] +extractippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' +extractippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' +extractippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' +extractippl_fieldDisplay.ScalarOpacityUnitDistance = 0.8660254037844386 +extractippl_fieldDisplay.ScalarOpacityFunction = densityPWF +extractippl_fieldDisplay.TransferFunction2D = densityTF2D +extractippl_fieldDisplay.OpacityArrayName = ['CELLS', 'density'] +extractippl_fieldDisplay.ColorArray2Name = ['CELLS', 'density'] +extractippl_fieldDisplay.SliceFunction = 'Plane' +extractippl_fieldDisplay.Slice = 2 +extractippl_fieldDisplay.SelectInputVectors = [None, ''] +extractippl_fieldDisplay.WriteLog = '' + +# init the 'Plane' selected for 'SliceFunction' +extractippl_fieldDisplay.SliceFunction.Origin = [0.5, 0.5, 0.5] -# get opacity transfer function/opacity map for 'Rho' -rhoPWF = GetOpacityTransferFunction('Rho') -rhoPWF.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] -rhoPWF.ScalarRangeInitialized = 1 +# show data from clip1 +clip1Display = Show(clip1, renderView3, 'UnstructuredGridRepresentation') # trace defaults for the display properties. clip1Display.Representation = 'Surface' -clip1Display.ColorArrayName = ['POINTS', 'Rho'] -clip1Display.LookupTable = rhoLUT +clip1Display.ColorArrayName = ['CELLS', 'density'] +clip1Display.LookupTable = densityLUT clip1Display.SelectTCoordArray = 'None' -clip1Display.SelectNormalArray = 'Normals' +clip1Display.SelectNormalArray = 'None' clip1Display.SelectTangentArray = 'None' -clip1Display.OSPRayScaleArray = 'Rho' clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' clip1Display.SelectOrientationVectors = 'None' clip1Display.ScaleFactor = 0.2 -clip1Display.SelectScaleArray = 'Rho' +clip1Display.SelectScaleArray = 'None' clip1Display.GlyphType = 'Arrow' -clip1Display.GlyphTableIndexArray = 'Rho' +clip1Display.GlyphTableIndexArray = 'None' clip1Display.GaussianRadius = 0.01 -clip1Display.SetScaleArray = ['POINTS', 'Rho'] +clip1Display.SetScaleArray = [None, ''] clip1Display.ScaleTransferFunction = 'PiecewiseFunction' -clip1Display.OpacityArray = ['POINTS', 'Rho'] +clip1Display.OpacityArray = [None, ''] clip1Display.OpacityTransferFunction = 'PiecewiseFunction' clip1Display.DataAxesGrid = 'GridAxesRepresentation' clip1Display.PolarAxes = 'PolarAxesRepresentation' -clip1Display.ScalarOpacityFunction = rhoPWF -clip1Display.ScalarOpacityUnitDistance = 0.49106951261706133 -clip1Display.OpacityArrayName = ['POINTS', 'Rho'] -clip1Display.SelectInputVectors = ['POINTS', 'Normals'] +clip1Display.ScalarOpacityFunction = densityPWF +clip1Display.ScalarOpacityUnitDistance = 0.9449407874211548 +clip1Display.OpacityArrayName = ['CELLS', 'density'] +clip1Display.SelectInputVectors = [None, ''] clip1Display.WriteLog = '' -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -clip1Display.ScaleTransferFunction.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -clip1Display.OpacityTransferFunction.Points = [0.1111111119389534, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] - # setup the color legend parameters for each legend in this view -# get color legend/bar for rhoLUT in view renderView1 -rhoLUTColorBar = GetScalarBar(rhoLUT, renderView1) -rhoLUTColorBar.Title = 'Rho' -rhoLUTColorBar.ComponentTitle = '' +# get color legend/bar for densityLUT in view renderView3 +densityLUTColorBar = GetScalarBar(densityLUT, renderView3) +densityLUTColorBar.WindowLocation = 'Any Location' +densityLUTColorBar.Position = [0.8376068376068376, 0.027995520716685318] +densityLUTColorBar.Title = 'density' +densityLUTColorBar.ComponentTitle = '' +densityLUTColorBar.ScalarBarLength = 0.32999999999999996 # set color bar visibility -rhoLUTColorBar.Visibility = 1 +densityLUTColorBar.Visibility = 1 + +# show color legend +extractippl_fieldDisplay.SetScalarBarVisibility(renderView3, True) # show color legend -clip1Display.SetScalarBarVisibility(renderView1, True) +clip1Display.SetScalarBarVisibility(renderView3, True) # ---------------------------------------------------------------- # setup color maps and opacity mapes used in the visualization @@ -146,13 +176,13 @@ # ---------------------------------------------------------------- # create extractor -pNG1 = CreateExtractor('PNG', renderView1, registrationName='ippl_field') +pNG1 = CreateExtractor('PNG', renderView3, registrationName='PNG1') # trace defaults for the extractor. pNG1.Trigger = 'TimeStep' # init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [862, 839] +pNG1.Writer.FileName = 'RenderView3_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [936, 893] pNG1.Writer.Format = 'PNG' # ---------------------------------------------------------------- From 3642453353fd1e964133a6cdf5556997fdd4d67f Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 7 Sep 2023 12:59:37 +0200 Subject: [PATCH 048/113] change PenningTrap to use Catalyst Including Initialize, Execute and Finalize call the PenningTrap and corresponding also ChargedParticles. catalyst2_pipeline might be used for extracting the pictures. Currently only working on MPI rank, by multiple the data is not properly distributed. --- alpine/ChargedParticles.hpp | 4 +++- alpine/PenningTrap.cpp | 7 +++++-- src/Stream/InSitu/CatalystAdaptor.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index a3b7176ee..b2ef8cc07 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -20,6 +20,7 @@ #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" +#include "Stream/InSitu/CatalystAdaptor.h" // some typedefs template @@ -381,7 +382,8 @@ class ChargedParticles : public ippl::ParticleBase { rhoNorm_m = norm(rho_m); IpplTimings::stopTimer(sumTimer); - dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); + CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), rho_m); + // dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); // rho = rho_e - rho_i double size = 1; diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 0a9a87f18..896b1745c 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -44,6 +44,7 @@ #include "Utility/IpplTimings.h" #include "ChargedParticles.hpp" +#include "Stream/InSitu/CatalystAdaptor.h" constexpr unsigned Dim = 3; @@ -153,6 +154,7 @@ const char* TestName = "PenningTrap"; int main(int argc, char* argv[]) { static_assert(Dim == 3, "Penning trap must be 3D"); Ippl ippl(argc, argv); + CatalystAdaptor::Initialize(argc, argv); Inform msg("PenningTrap"); Inform msg2all("PenningTrap", INFORM_ALL_NODES); @@ -198,8 +200,8 @@ int main(int argc, char* argv[]) { Vector_t origin = rmin; // unsigned int nrMax = 2048; // Max grid size in our studies // double dxFinest = rmax[0] / nrMax; - //const double dt = 0.5 * dxFinest; // size of timestep - const double dt = 0.05; // size of timestep + // const double dt = 0.5 * dxFinest; // size of timestep + const double dt = 0.05; // size of timestep const bool isAllPeriodic = true; Mesh_t mesh(domain, hr, origin); @@ -443,5 +445,6 @@ int main(int argc, char* argv[]) { std::chrono::duration_cast>(end - start); std::cout << "Elapsed time: " << time_chrono.count() << std::endl; + CatalystAdaptor::Finalize(); return 0; } diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 7a8d60de4..a1a69d232 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -56,6 +56,7 @@ namespace CatalystAdaptor { state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); + state["multiblock"].set(1); // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; From 237854f27e9bc305555f57550e18ee4e806c96ae Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 13:47:04 +0200 Subject: [PATCH 049/113] change template from typename to class in Execute function and adhere to naming convention --- src/Stream/InSitu/CatalystAdaptor.h | 4 ++-- test/stream/catalyst_pipeline.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index a1a69d232..d252ba5b7 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -39,8 +39,8 @@ namespace CatalystAdaptor { } } - template - void Execute(int cycle, double time, int rank, Field_t& field) { + template + void Execute(int cycle, double time, int rank, Field& field) { // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html // diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index cc2cf76e3..581826b7a 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -1,4 +1,6 @@ from paraview.simple import * +from paraview import catalyst +options = catalyst.Options() print("executing catalyst_pipeline") @@ -13,5 +15,7 @@ def catalyst_execute(info): producer.UpdatePipeline(info.time) # print("-----------------------------------") print("executing (cycle={}, time={})".format(info.cycle, info.time)) - print("field:", producer.CellData["density"].GetRange(0)) + arrayInfo = producer.CellData["density"] + arrayInfo.GetNumberOfComponents() + print("field:", producer.CellData["density"].GetRange(-1)) # .GetRange(0)) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From fad90fb380196f9582308869a49e5374f401cb7e Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 14:00:01 +0200 Subject: [PATCH 050/113] add python script for dumping csv of density Adding a catalyst script to pipe output of the density field into a csv. This script already scales up with multiple ranks and the output is in one file per timestep. --- test/stream/dump_csv.py | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/stream/dump_csv.py diff --git a/test/stream/dump_csv.py b/test/stream/dump_csv.py new file mode 100644 index 000000000..995c1274c --- /dev/null +++ b/test/stream/dump_csv.py @@ -0,0 +1,45 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +cSV1 = CreateExtractor('CSV', ippl_field, registrationName='CSV1') +# trace defaults for the extractor. +cSV1.Trigger = 'TimeStep' + +# init the 'CSV' selected for 'Writer' +cSV1.Writer.FieldAssociation = 'Cell Data' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(cSV1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GlobalTrigger = 'TimeStep' +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From 5f813660e2e19e43a3fcc32c8961eed7239759e4 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 16:20:40 +0200 Subject: [PATCH 051/113] fix overlooked rename of Field_t to Field --- src/Stream/InSitu/CatalystAdaptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index d252ba5b7..377fef7b1 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -46,7 +46,7 @@ namespace CatalystAdaptor { // // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - typename Field_t::view_type::host_mirror_type host_view = field.getHostMirror(); + typename Field::view_type::host_mirror_type host_view = field.getHostMirror(); Kokkos::deep_copy(host_view, field.getView()); conduit_cpp::Node node; From 257ab27baf973e89b2db60b7b221a636e130ab19 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 16:40:49 +0200 Subject: [PATCH 052/113] change templation to Field class Remove local typedef and use Field class as an template argument. --- src/Stream/InSitu/CatalystAdaptor.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 377fef7b1..ff533d074 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -14,10 +14,6 @@ #include "Utility/IpplException.h" namespace CatalystAdaptor { - constexpr unsigned int dim{2}; - using Mesh_t = ippl::UniformCartesian; - using Centering_t = Mesh_t::DefaultCentering; - using Field_t = ippl::Field; void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; @@ -46,6 +42,8 @@ namespace CatalystAdaptor { // // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html + + auto tempFieldf = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); typename Field::view_type::host_mirror_type host_view = field.getHostMirror(); Kokkos::deep_copy(host_view, field.getView()); From 8e1adef8e2d874be525d4d2924f7eed19af1356b Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 16:50:38 +0200 Subject: [PATCH 053/113] add shrinkview call to catalyst adaptor --- src/Stream/InSitu/CatalystAdaptor.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index ff533d074..bfd3e1c41 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -46,7 +46,14 @@ namespace CatalystAdaptor { auto tempFieldf = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); typename Field::view_type::host_mirror_type host_view = field.getHostMirror(); - Kokkos::deep_copy(host_view, field.getView()); + using index_array_type = typename ippl::RangePolicy::index_array_type; + ippl::parallel_for( + "copy from Kokkos f field in FFT", ippl::getRangePolicy(field.getView(), field.getNghost()), + KOKKOS_LAMBDA(const index_array_type& args) { + ippl::apply(tempFieldf, args - field.getNghost()) = ippl::apply(field.getView(), args); + }); + +// Kokkos::deep_copy(host_view, tempFieldf); conduit_cpp::Node node; // add time/cycle information From 93c40b2d1823d6ba815f65c77144f2e653b2301d Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Mon, 11 Sep 2023 17:56:05 +0200 Subject: [PATCH 054/113] remove ghost cells from dimensions --- src/Stream/InSitu/CatalystAdaptor.h | 22 +++++++++------------- test/stream/TestCatalystAdaptor.cpp | 8 ++++---- test/stream/TestCatalystAdaptor_2D.cpp | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index bfd3e1c41..159583125 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,17 +43,18 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - auto tempFieldf = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); - typename Field::view_type::host_mirror_type host_view = field.getHostMirror(); + auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); using index_array_type = typename ippl::RangePolicy::index_array_type; ippl::parallel_for( "copy from Kokkos f field in FFT", ippl::getRangePolicy(field.getView(), field.getNghost()), KOKKOS_LAMBDA(const index_array_type& args) { - ippl::apply(tempFieldf, args - field.getNghost()) = ippl::apply(field.getView(), args); + ippl::apply(host_view, args - field.getNghost()) = ippl::apply(field.getView(), args); }); -// Kokkos::deep_copy(host_view, tempFieldf); +// typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror(host_view); +// Kokkos::deep_copy(host_view, host_view); + conduit_cpp::Node node; // add time/cycle information @@ -61,7 +62,7 @@ namespace CatalystAdaptor { state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); - state["multiblock"].set(1); + // state["multiblock"].set(1); // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; @@ -79,17 +80,14 @@ namespace CatalystAdaptor { for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( - int(field.getLayout().getLocalNDIndex()[iDim].length() // last field point + int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); // last field point // including ghost cell - + 2 * field.getNghost() + 1)); // ghost cells to left and right // shift origin by one ghost cell mesh[field_node_origin].set( field.get_mesh().getOrigin()[iDim] // global origin + field.getLayout().getLocalNDIndex()[iDim].first() - * field.get_mesh().getMeshSpacing(iDim) // shift to local index - - field.get_mesh().getMeshSpacing(iDim) - * field.getNghost()); // move index according to ghost cells + * field.get_mesh().getMeshSpacing(iDim)); // shift to local index mesh[field_node_spacing].set(field.get_mesh().getMeshSpacing(iDim)); // increment last char in string @@ -106,9 +104,7 @@ namespace CatalystAdaptor { // shift origin by one ghost cell mesh[field_node_origin_topo].set(field.get_mesh().getOrigin()[iDim] + field.getLayout().getLocalNDIndex()[iDim].first() - * field.get_mesh().getMeshSpacing(iDim) - - field.get_mesh().getMeshSpacing(iDim) - * field.getNghost()); + * field.get_mesh().getMeshSpacing(iDim)); ++field_node_origin_topo.back(); } diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 3d2559268..7d12cb7d5 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -101,7 +101,7 @@ int main(int argc, char* argv[]) { typename field_type::view_type& view = field.getView(); double time = {0.0}; - const double dt = {0.05}; + const double dt = {1}; const unsigned int nt = {10}; for (unsigned int it = 0; it < nt; ++it) { Kokkos::parallel_for( @@ -130,9 +130,9 @@ int main(int argc, char* argv[]) { time += dt; // dumpVTK only works with --info 5 and higher - dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), - field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), - field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); +// dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), +// field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), +// field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); } int nRanks = Ippl::Comm->size(); diff --git a/test/stream/TestCatalystAdaptor_2D.cpp b/test/stream/TestCatalystAdaptor_2D.cpp index ed3f15759..794fb9390 100644 --- a/test/stream/TestCatalystAdaptor_2D.cpp +++ b/test/stream/TestCatalystAdaptor_2D.cpp @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) { typename field_type::view_type& view = field.getView(); double time = {0.0}; - const double dt = {0.05}; + const double dt = {1}; const unsigned int nt = {5}; for (unsigned int it = 0; it < nt; ++it) { Kokkos::parallel_for( From f580ba2ec97f9ae3c987f15468ddc9c75556cb61 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 10:13:43 +0200 Subject: [PATCH 055/113] add script for extracting penningtrap pictures for paraview --- test/stream/extract_penningtrap.py | 222 +++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 test/stream/extract_penningtrap.py diff --git a/test/stream/extract_penningtrap.py b/test/stream/extract_penningtrap.py new file mode 100644 index 000000000..1eeed8203 --- /dev/null +++ b/test/stream/extract_penningtrap.py @@ -0,0 +1,222 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [2063, 1171] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [10.0, 10.0, 10.0] +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [-21.623965181354365, 42.965642632594324, 58.960885283594834] +renderView1.CameraFocalPoint = [7.896395855623616, 9.547405579666743, 9.058674053996977] +renderView1.CameraViewUp = [0.24207621386012068, 0.8663046993049328, -0.43693852501849645] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 17.320508075688775 +renderView1.BackEnd = 'OSPRay raycaster' +renderView1.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(2063, 1171) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# create a new 'Cell Data to Point Data' +cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ippl_field) +cellDatatoPointData1.CellDataArraytoprocess = ['density'] + +# create a new 'Contour' +contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) +contour1.ContourBy = ['POINTS', 'density'] +contour1.ComputeGradients = 1 +contour1.Isosurfaces = [-5.934963740949476, -5.331078880843979, -4.727194020738481, -4.123309160632983, -3.5194243005274863, -2.915539440421989, -2.3116545803164916, -1.7077697202109938, -1.103884860105497, -0.5] +contour1.PointMergeMethod = 'Uniform Binning' + +# create a new 'Clip' +clip1 = Clip(registrationName='Clip1', Input=contour1) +clip1.ClipType = 'Plane' +clip1.HyperTreeGridClipper = 'Plane' +clip1.Scalars = ['POINTS', 'density'] +clip1.Value = -2.915539503097534 + +# init the 'Plane' selected for 'ClipType' +clip1.ClipType.Origin = [9.836756944656372, 10.002045154571533, 9.74355699121952] +clip1.ClipType.Normal = [0.0, 0.0, 1.0] + +# init the 'Plane' selected for 'HyperTreeGridClipper' +clip1.HyperTreeGridClipper.Origin = [9.836756944656372, 10.002045154571533, 9.74355699121952] + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from cellDatatoPointData1 +cellDatatoPointData1Display = Show(cellDatatoPointData1, renderView1, 'UniformGridRepresentation') + +# trace defaults for the display properties. +cellDatatoPointData1Display.Representation = 'Outline' +cellDatatoPointData1Display.ColorArrayName = [None, ''] +cellDatatoPointData1Display.SelectTCoordArray = 'None' +cellDatatoPointData1Display.SelectNormalArray = 'None' +cellDatatoPointData1Display.SelectTangentArray = 'None' +cellDatatoPointData1Display.OSPRayScaleArray = 'density' +cellDatatoPointData1Display.OSPRayScaleFunction = 'PiecewiseFunction' +cellDatatoPointData1Display.SelectOrientationVectors = 'None' +cellDatatoPointData1Display.ScaleFactor = 2.0 +cellDatatoPointData1Display.SelectScaleArray = 'None' +cellDatatoPointData1Display.GlyphType = 'Arrow' +cellDatatoPointData1Display.GlyphTableIndexArray = 'None' +cellDatatoPointData1Display.GaussianRadius = 0.1 +cellDatatoPointData1Display.SetScaleArray = ['POINTS', 'density'] +cellDatatoPointData1Display.ScaleTransferFunction = 'PiecewiseFunction' +cellDatatoPointData1Display.OpacityArray = ['POINTS', 'density'] +cellDatatoPointData1Display.OpacityTransferFunction = 'PiecewiseFunction' +cellDatatoPointData1Display.DataAxesGrid = 'GridAxesRepresentation' +cellDatatoPointData1Display.PolarAxes = 'PolarAxesRepresentation' +cellDatatoPointData1Display.ScalarOpacityUnitDistance = 2.165063509461097 +cellDatatoPointData1Display.OpacityArrayName = ['POINTS', 'density'] +cellDatatoPointData1Display.ColorArray2Name = ['POINTS', 'density'] +cellDatatoPointData1Display.SliceFunction = 'Plane' +cellDatatoPointData1Display.Slice = 8 +cellDatatoPointData1Display.SelectInputVectors = [None, ''] +cellDatatoPointData1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +cellDatatoPointData1Display.ScaleTransferFunction.Points = [-5.934963740949476, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +cellDatatoPointData1Display.OpacityTransferFunction.Points = [-5.934963740949476, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] + +# init the 'Plane' selected for 'SliceFunction' +cellDatatoPointData1Display.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from clip1 +clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'density' +densityTF2D = GetTransferFunction2D('density') + +# get color transfer function/color map for 'density' +densityLUT = GetColorTransferFunction('density') +densityLUT.TransferFunction2D = densityTF2D +densityLUT.RGBPoints = [-5.331079006195068, 0.231373, 0.298039, 0.752941, -2.915539503097534, 0.865003, 0.865003, 0.865003, -0.5, 0.705882, 0.0156863, 0.14902] +densityLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'density' +densityPWF = GetOpacityTransferFunction('density') +densityPWF.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +densityPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +clip1Display.Representation = 'Surface' +clip1Display.ColorArrayName = ['POINTS', 'density'] +clip1Display.LookupTable = densityLUT +clip1Display.SelectTCoordArray = 'None' +clip1Display.SelectNormalArray = 'Normals' +clip1Display.SelectTangentArray = 'None' +clip1Display.OSPRayScaleArray = 'density' +clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' +clip1Display.SelectOrientationVectors = 'Gradients' +clip1Display.ScaleFactor = 1.4166247844696045 +clip1Display.SelectScaleArray = 'density' +clip1Display.GlyphType = 'Arrow' +clip1Display.GlyphTableIndexArray = 'density' +clip1Display.GaussianRadius = 0.07083123922348022 +clip1Display.SetScaleArray = ['POINTS', 'density'] +clip1Display.ScaleTransferFunction = 'PiecewiseFunction' +clip1Display.OpacityArray = ['POINTS', 'density'] +clip1Display.OpacityTransferFunction = 'PiecewiseFunction' +clip1Display.DataAxesGrid = 'GridAxesRepresentation' +clip1Display.PolarAxes = 'PolarAxesRepresentation' +clip1Display.ScalarOpacityFunction = densityPWF +clip1Display.ScalarOpacityUnitDistance = 1.5823964723664046 +clip1Display.OpacityArrayName = ['POINTS', 'density'] +clip1Display.SelectInputVectors = ['POINTS', 'Gradients'] +clip1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +clip1Display.ScaleTransferFunction.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +clip1Display.OpacityTransferFunction.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for densityLUT in view renderView1 +densityLUTColorBar = GetScalarBar(densityLUT, renderView1) +densityLUTColorBar.Title = 'density' +densityLUTColorBar.ComponentTitle = '' + +# set color bar visibility +densityLUTColorBar.Visibility = 1 + +# show color legend +clip1Display.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [2063, 1171] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(ippl_field) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From e5ebc183ed4c334efc672fed4313b4bc7adceff6 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 11:59:41 +0200 Subject: [PATCH 056/113] add data and datasets folder to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3dbfbb665..b9c4e8e55 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ manual/*.lot manual/ippl_user_guide.pdf # ignure vtk dump stuff +data/ +datasets/ *.vtk # CMake and Build folder From de8f4b7a2e7ecd7f9800a874d77170b500a093f6 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 13:24:21 +0200 Subject: [PATCH 057/113] add copy from GPU to CPU and then apply the striping of the ghost cells --- src/Stream/InSitu/CatalystAdaptor.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 159583125..0c611172e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,17 +43,24 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); + //auto h_view_tmp; + typename Field::view_type::host_mirror_type h_view = Kokkos::create_mirror(field.getView()); + Kokkos::deep_copy(h_view, field.getView()); + + //auto my_host_view = Kokkos::create_mirror_view_and_copy(field.getView()); +// typename Field::view_type::host_mirror_type host_view_full = Kokkos::create_mirror(field.getView()); +// Kokkos::deep_copy(host_view, field.getView()); + + //auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); + auto host_view = ippl::detail::shrinkView("tempFieldf", h_view, field.getNghost()); using index_array_type = typename ippl::RangePolicy::index_array_type; ippl::parallel_for( - "copy from Kokkos f field in FFT", ippl::getRangePolicy(field.getView(), field.getNghost()), + "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), KOKKOS_LAMBDA(const index_array_type& args) { - ippl::apply(host_view, args - field.getNghost()) = ippl::apply(field.getView(), args); + ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); }); -// typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror(host_view); -// Kokkos::deep_copy(host_view, host_view); conduit_cpp::Node node; @@ -62,7 +69,6 @@ namespace CatalystAdaptor { state["cycle"].set(cycle); state["time"].set(time); state["domain_id"].set(rank); - // state["multiblock"].set(1); // add catalyst channel named ippl_field, as fields is reserved auto channel = node["catalyst/channels/ippl_field"]; @@ -78,10 +84,8 @@ namespace CatalystAdaptor { std::string field_node_spacing{"coordsets/coords/spacing/dx"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { - // include ghost cells to the "left" and "right" + 1 point mesh[field_node_dim].set( - int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); // last field point - // including ghost cell + int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); // shift origin by one ghost cell mesh[field_node_origin].set( @@ -101,7 +105,7 @@ namespace CatalystAdaptor { mesh["topologies/mesh/coordset"].set("coords"); std::string field_node_origin_topo = "topologies/mesh/origin/x"; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { - // shift origin by one ghost cell + // shift origin mesh[field_node_origin_topo].set(field.get_mesh().getOrigin()[iDim] + field.getLayout().getLocalNDIndex()[iDim].first() * field.get_mesh().getMeshSpacing(iDim)); From 23078ae9dcc0106b0484613bf52dcd4c00884b29 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 14:36:36 +0200 Subject: [PATCH 058/113] change from create_mirror_view to create_mirror_view_and_copy --- src/Stream/InSitu/CatalystAdaptor.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 0c611172e..2989b8673 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,24 +43,24 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - //auto h_view_tmp; - typename Field::view_type::host_mirror_type h_view = Kokkos::create_mirror(field.getView()); - Kokkos::deep_copy(h_view, field.getView()); + auto host_view_with_ghost_cells = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); +// typename Field::view_type::host_mirror_type h_view = Kokkos::create_mirror(field.getView()); +// Kokkos::deep_copy(h_view, field.getView()); //auto my_host_view = Kokkos::create_mirror_view_and_copy(field.getView()); // typename Field::view_type::host_mirror_type host_view_full = Kokkos::create_mirror(field.getView()); // Kokkos::deep_copy(host_view, field.getView()); //auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); - auto host_view = ippl::detail::shrinkView("tempFieldf", h_view, field.getNghost()); - - using index_array_type = typename ippl::RangePolicy::index_array_type; - ippl::parallel_for( - "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), - KOKKOS_LAMBDA(const index_array_type& args) { - ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); - }); - +// auto host_view = ippl::detail::shrinkView("tempFieldf", h_view, field.getNghost()); + +// using index_array_type = typename ippl::RangePolicy::index_array_type; +// ippl::parallel_for( +// "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), +// KOKKOS_LAMBDA(const index_array_type& args) { +// ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); +// }); +// conduit_cpp::Node node; From 2dcb3cf8887bfd3a169ea1e48aa2abbd2b2ffc29 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 16:14:38 +0200 Subject: [PATCH 059/113] change to subview to kickout ghost cells --- src/Stream/InSitu/CatalystAdaptor.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 2989b8673..98e6f5459 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,16 +43,31 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - auto host_view_with_ghost_cells = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); -// typename Field::view_type::host_mirror_type h_view = Kokkos::create_mirror(field.getView()); -// Kokkos::deep_copy(h_view, field.getView()); + //auto h_view_tmp; + auto nGhost = field.getNghost(); + auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); + + auto host_view_striped = Kokkos::subview(host_view, + Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[0].length() + 1)), + Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[1].length() + 1)), + Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[2].length() + 1))); + + //Kokkos::resize(host_view, Kokkos::LayoutLeft{}, field.getLayout().getLocalNDIndex()[0].length() + 1); + //Kokkos::deep_copy(h_view, field.getView()); //auto my_host_view = Kokkos::create_mirror_view_and_copy(field.getView()); // typename Field::view_type::host_mirror_type host_view_full = Kokkos::create_mirror(field.getView()); // Kokkos::deep_copy(host_view, field.getView()); //auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); -// auto host_view = ippl::detail::shrinkView("tempFieldf", h_view, field.getNghost()); +// auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); +// +// using index_array_type = typename ippl::RangePolicy::index_array_type; +// ippl::parallel_for( +// "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), +// KOKKOS_LAMBDA(const index_array_type& args) { +// ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); +// }); // using index_array_type = typename ippl::RangePolicy::index_array_type; // ippl::parallel_for( @@ -118,7 +133,7 @@ namespace CatalystAdaptor { fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external(host_view.data(), host_view.size()); + fields["density/values"].set_external(host_view_striped.data(), host_view_striped.size()); // print node to have visual representation if (cycle == 0) From 4b51599de42fa06ef4a585f8b9509aa2f1f666f5 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 18:45:32 +0200 Subject: [PATCH 060/113] remove ghost cells by loops on the host device --- src/Stream/InSitu/CatalystAdaptor.h | 42 ++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 98e6f5459..82ce3669d 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -44,20 +44,44 @@ namespace CatalystAdaptor { // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html //auto h_view_tmp; - auto nGhost = field.getNghost(); - auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); + unsigned int nGhost = field.getNghost(); + + typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view(field.getView()); + Kokkos::deep_copy(host_view, field.getView()); + + Kokkos::View host_view_layout_left("host_view_layout_left", + field.getLayout().getLocalNDIndex()[0].length(), + field.getLayout().getLocalNDIndex()[1].length(), + field.getLayout().getLocalNDIndex()[2].length()); + + for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) + { + for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) + { + for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) + { + host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); + } + } + } + + + //Kokkos::deep_copy(host_view, field.getView()); + //auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); + //Kokkos::create_mirror_view_and_copy(host_view, field.getView()); - auto host_view_striped = Kokkos::subview(host_view, - Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[0].length() + 1)), - Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[1].length() + 1)), - Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[2].length() + 1))); +// auto host_view_striped = Kokkos::subview(host_view, +// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[0].length() + 1)), +// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[1].length() + 1)), +// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[2].length() + 1))); + + // Kokkos::realloc(host_view_striped, Kokkos::LayoutLeft(), Kokkos::ALL, Kokkos::ALL, Kokkos::ALL); //Kokkos::resize(host_view, Kokkos::LayoutLeft{}, field.getLayout().getLocalNDIndex()[0].length() + 1); //Kokkos::deep_copy(h_view, field.getView()); //auto my_host_view = Kokkos::create_mirror_view_and_copy(field.getView()); -// typename Field::view_type::host_mirror_type host_view_full = Kokkos::create_mirror(field.getView()); -// Kokkos::deep_copy(host_view, field.getView()); + //auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); // auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); @@ -133,7 +157,7 @@ namespace CatalystAdaptor { fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external(host_view_striped.data(), host_view_striped.size()); + fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); // print node to have visual representation if (cycle == 0) From 2870f697ec4bd933f634539757edcfa3bb0b3829 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Sep 2023 20:23:40 +0200 Subject: [PATCH 061/113] minor cleanup --- src/Stream/InSitu/CatalystAdaptor.h | 43 ++--------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 82ce3669d..709d58a0e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,11 +43,10 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - //auto h_view_tmp; - unsigned int nGhost = field.getNghost(); + auto nGhost = field.getNghost(); - typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view(field.getView()); - Kokkos::deep_copy(host_view, field.getView()); + typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, field.getView()); + //Kokkos::deep_copy(host_view, field.getView()); Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), @@ -65,42 +64,6 @@ namespace CatalystAdaptor { } } - - //Kokkos::deep_copy(host_view, field.getView()); - //auto host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); - //Kokkos::create_mirror_view_and_copy(host_view, field.getView()); - -// auto host_view_striped = Kokkos::subview(host_view, -// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[0].length() + 1)), -// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[1].length() + 1)), -// Kokkos::make_pair(nGhost, int(field.getLayout().getLocalNDIndex()[2].length() + 1))); - - // Kokkos::realloc(host_view_striped, Kokkos::LayoutLeft(), Kokkos::ALL, Kokkos::ALL, Kokkos::ALL); - - //Kokkos::resize(host_view, Kokkos::LayoutLeft{}, field.getLayout().getLocalNDIndex()[0].length() + 1); - //Kokkos::deep_copy(h_view, field.getView()); - - //auto my_host_view = Kokkos::create_mirror_view_and_copy(field.getView()); - - - //auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); -// auto host_view = ippl::detail::shrinkView("tempFieldf", field.getView(), field.getNghost()); -// -// using index_array_type = typename ippl::RangePolicy::index_array_type; -// ippl::parallel_for( -// "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), -// KOKKOS_LAMBDA(const index_array_type& args) { -// ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); -// }); - -// using index_array_type = typename ippl::RangePolicy::index_array_type; -// ippl::parallel_for( -// "copy from Kokkos f field in FFT", ippl::getRangePolicy(h_view, field.getNghost()), -// KOKKOS_LAMBDA(const index_array_type& args) { -// ippl::apply(host_view, args - field.getNghost()) = ippl::apply(h_view, args); -// }); -// - conduit_cpp::Node node; // add time/cycle information From 0731d4bc460e0b410e13eb84703413ba0c085342 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 14 Sep 2023 10:37:38 +0200 Subject: [PATCH 062/113] add static assertion for dimension3 --- src/Stream/InSitu/CatalystAdaptor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 709d58a0e..b842e5c2a 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -37,6 +37,7 @@ namespace CatalystAdaptor { template void Execute(int cycle, double time, int rank, Field& field) { + static_assert(Field::dimension == 3, "CatalystAdaptor only supports 3D"); // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html // @@ -45,7 +46,7 @@ namespace CatalystAdaptor { auto nGhost = field.getNghost(); - typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, field.getView()); + typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); //Kokkos::deep_copy(host_view, field.getView()); Kokkos::View host_view_layout_left("host_view_layout_left", From 06d603ece5baf9e998326fea0cdeb9991e0a46fd Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 14 Sep 2023 11:03:47 +0200 Subject: [PATCH 063/113] update extract script which does not have glitches --- test/stream/extract_penningtrap.py | 57 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/test/stream/extract_penningtrap.py b/test/stream/extract_penningtrap.py index 1eeed8203..d127129a6 100644 --- a/test/stream/extract_penningtrap.py +++ b/test/stream/extract_penningtrap.py @@ -15,15 +15,15 @@ # Create a new 'Render View' renderView1 = CreateView('RenderView') -renderView1.ViewSize = [2063, 1171] +renderView1.ViewSize = [1199, 917] renderView1.AxesGrid = 'GridAxes3DActor' renderView1.CenterOfRotation = [10.0, 10.0, 10.0] renderView1.StereoType = 'Crystal Eyes' -renderView1.CameraPosition = [-21.623965181354365, 42.965642632594324, 58.960885283594834] -renderView1.CameraFocalPoint = [7.896395855623616, 9.547405579666743, 9.058674053996977] -renderView1.CameraViewUp = [0.24207621386012068, 0.8663046993049328, -0.43693852501849645] +renderView1.CameraPosition = [-36.185896294276546, 67.84051131760981, 79.13441790882564] +renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] +renderView1.CameraViewUp = [0.2886814022290065, 0.8204174596703359, -0.49353646255891515] renderView1.CameraFocalDisk = 1.0 -renderView1.CameraParallelScale = 17.320508075688775 +renderView1.CameraParallelScale = 26.738898830650854 renderView1.BackEnd = 'OSPRay raycaster' renderView1.OSPRayMaterialLibrary = materialLibrary1 @@ -36,7 +36,7 @@ # create new layout object 'Layout #1' layout1 = CreateLayout(name='Layout #1') layout1.AssignView(0, renderView1) -layout1.SetSize(2063, 1171) +layout1.SetSize(1199, 917) # ---------------------------------------------------------------- # restore active view @@ -57,8 +57,7 @@ # create a new 'Contour' contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) contour1.ContourBy = ['POINTS', 'density'] -contour1.ComputeGradients = 1 -contour1.Isosurfaces = [-5.934963740949476, -5.331078880843979, -4.727194020738481, -4.123309160632983, -3.5194243005274863, -2.915539440421989, -2.3116545803164916, -1.7077697202109938, -1.103884860105497, -0.5] +contour1.Isosurfaces = [-2.953365099609886, -5.906730199219772, -5.305982399306464, -4.705234599393156, -4.104486799479848, -3.50373899956654, -2.902991199653232, -2.302243399739924, -1.7014955998266164, -1.1007477999133082, -0.5] contour1.PointMergeMethod = 'Uniform Binning' # create a new 'Clip' @@ -66,14 +65,14 @@ clip1.ClipType = 'Plane' clip1.HyperTreeGridClipper = 'Plane' clip1.Scalars = ['POINTS', 'density'] -clip1.Value = -2.915539503097534 +clip1.Value = -2.90299129486084 # init the 'Plane' selected for 'ClipType' -clip1.ClipType.Origin = [9.836756944656372, 10.002045154571533, 9.74355699121952] +clip1.ClipType.Origin = [9.766819953918457, 9.9811110496521, 10.671213865280151] clip1.ClipType.Normal = [0.0, 0.0, 1.0] # init the 'Plane' selected for 'HyperTreeGridClipper' -clip1.HyperTreeGridClipper.Origin = [9.836756944656372, 10.002045154571533, 9.74355699121952] +clip1.HyperTreeGridClipper.Origin = [9.766819953918457, 9.9811110496521, 10.671213865280151] # ---------------------------------------------------------------- # setup the visualization in view 'renderView1' @@ -111,10 +110,10 @@ cellDatatoPointData1Display.WriteLog = '' # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -cellDatatoPointData1Display.ScaleTransferFunction.Points = [-5.934963740949476, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] +cellDatatoPointData1Display.ScaleTransferFunction.Points = [-5.906730199219772, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -cellDatatoPointData1Display.OpacityTransferFunction.Points = [-5.934963740949476, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] +cellDatatoPointData1Display.OpacityTransferFunction.Points = [-5.906730199219772, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] # init the 'Plane' selected for 'SliceFunction' cellDatatoPointData1Display.SliceFunction.Origin = [10.0, 10.0, 10.0] @@ -124,16 +123,18 @@ # get 2D transfer function for 'density' densityTF2D = GetTransferFunction2D('density') +densityTF2D.ScalarRangeInitialized = 1 +densityTF2D.Range = [-7.111382323777126, 0.0, 0.0, 1.0] # get color transfer function/color map for 'density' densityLUT = GetColorTransferFunction('density') densityLUT.TransferFunction2D = densityTF2D -densityLUT.RGBPoints = [-5.331079006195068, 0.231373, 0.298039, 0.752941, -2.915539503097534, 0.865003, 0.865003, 0.865003, -0.5, 0.705882, 0.0156863, 0.14902] +densityLUT.RGBPoints = [-5.30598258972168, 0.231373, 0.298039, 0.752941, -2.90299129486084, 0.865003, 0.865003, 0.865003, -0.5, 0.705882, 0.0156863, 0.14902] densityLUT.ScalarRangeInitialized = 1.0 # get opacity transfer function/opacity map for 'density' densityPWF = GetOpacityTransferFunction('density') -densityPWF.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +densityPWF.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] densityPWF.ScalarRangeInitialized = 1 # trace defaults for the display properties. @@ -145,12 +146,12 @@ clip1Display.SelectTangentArray = 'None' clip1Display.OSPRayScaleArray = 'density' clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' -clip1Display.SelectOrientationVectors = 'Gradients' -clip1Display.ScaleFactor = 1.4166247844696045 +clip1Display.SelectOrientationVectors = 'None' +clip1Display.ScaleFactor = 1.5288142442703248 clip1Display.SelectScaleArray = 'density' clip1Display.GlyphType = 'Arrow' clip1Display.GlyphTableIndexArray = 'density' -clip1Display.GaussianRadius = 0.07083123922348022 +clip1Display.GaussianRadius = 0.07644071221351624 clip1Display.SetScaleArray = ['POINTS', 'density'] clip1Display.ScaleTransferFunction = 'PiecewiseFunction' clip1Display.OpacityArray = ['POINTS', 'density'] @@ -158,16 +159,16 @@ clip1Display.DataAxesGrid = 'GridAxesRepresentation' clip1Display.PolarAxes = 'PolarAxesRepresentation' clip1Display.ScalarOpacityFunction = densityPWF -clip1Display.ScalarOpacityUnitDistance = 1.5823964723664046 +clip1Display.ScalarOpacityUnitDistance = 1.5107155620204928 clip1Display.OpacityArrayName = ['POINTS', 'density'] -clip1Display.SelectInputVectors = ['POINTS', 'Gradients'] +clip1Display.SelectInputVectors = ['POINTS', 'Normals'] clip1Display.WriteLog = '' # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -clip1Display.ScaleTransferFunction.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +clip1Display.ScaleTransferFunction.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -clip1Display.OpacityTransferFunction.Points = [-5.331079006195068, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +clip1Display.OpacityTransferFunction.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] # setup the color legend parameters for each legend in this view @@ -191,6 +192,14 @@ # setup extractors # ---------------------------------------------------------------- +# create extractor +vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') +# trace defaults for the extractor. +vTPD1.Trigger = 'TimeStep' + +# init the 'VTPD' selected for 'Writer' +vTPD1.Writer.FileName = 'ippl_field_{timestep:06d}.vtpd' + # create extractor pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') # trace defaults for the extractor. @@ -198,12 +207,12 @@ # init the 'PNG' selected for 'Writer' pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [2063, 1171] +pNG1.Writer.ImageResolution = [1199, 917] pNG1.Writer.Format = 'PNG' # ---------------------------------------------------------------- # restore active source -SetActiveSource(ippl_field) +SetActiveSource(pNG1) # ---------------------------------------------------------------- # ------------------------------------------------------------------------------ From 3f49b8c23666be444efc2451a84e998c0bffb2b2 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 14 Sep 2023 12:22:00 +0200 Subject: [PATCH 064/113] update extract catalyst to include ghost cells In order to have a smooth representation at the boundaries, we include the ghost cells generator for before the contour. Further png not includes the Reset Display property to hopefully eliminate the rendering glitches. --- test/stream/extract_penningtrap.py | 148 +++++++++++++++-------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/test/stream/extract_penningtrap.py b/test/stream/extract_penningtrap.py index d127129a6..df4d7a624 100644 --- a/test/stream/extract_penningtrap.py +++ b/test/stream/extract_penningtrap.py @@ -15,15 +15,15 @@ # Create a new 'Render View' renderView1 = CreateView('RenderView') -renderView1.ViewSize = [1199, 917] +renderView1.ViewSize = [1877, 1171] renderView1.AxesGrid = 'GridAxes3DActor' renderView1.CenterOfRotation = [10.0, 10.0, 10.0] renderView1.StereoType = 'Crystal Eyes' -renderView1.CameraPosition = [-36.185896294276546, 67.84051131760981, 79.13441790882564] -renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] -renderView1.CameraViewUp = [0.2886814022290065, 0.8204174596703359, -0.49353646255891515] +renderView1.CameraPosition = [-29.281150563975967, 38.91994832117599, 65.77495370861955] +renderView1.CameraFocalPoint = [14.933355093656326, 7.465538329176106, 5.669943215819909] +renderView1.CameraViewUp = [0.22018111884477137, 0.9214003427041039, -0.3202213037401241] renderView1.CameraFocalDisk = 1.0 -renderView1.CameraParallelScale = 26.738898830650854 +renderView1.CameraParallelScale = 17.320508075688775 renderView1.BackEnd = 'OSPRay raycaster' renderView1.OSPRayMaterialLibrary = materialLibrary1 @@ -36,7 +36,7 @@ # create new layout object 'Layout #1' layout1 = CreateLayout(name='Layout #1') layout1.AssignView(0, renderView1) -layout1.SetSize(1199, 917) +layout1.SetSize(1877, 1171) # ---------------------------------------------------------------- # restore active view @@ -47,17 +47,20 @@ # setup the data processing pipelines # ---------------------------------------------------------------- -# create a new 'PVTrivialProducer' -ippl_field = PVTrivialProducer(registrationName='ippl_field') +# create a new 'XML Partitioned Dataset Reader' +ippl_field = XMLPartitionedDatasetReader(registrationName='ippl_field', FileName=['/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000000.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000001.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000002.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000003.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000004.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000005.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000006.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000007.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000008.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000009.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000010.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000011.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000012.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000013.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000014.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000015.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000016.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000017.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000018.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000019.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000020.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000021.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000022.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000023.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000024.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000025.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000026.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000027.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000028.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000029.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000030.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000031.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000032.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000033.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000034.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000035.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000036.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000037.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000038.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000039.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000040.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000041.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000042.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000043.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000044.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000045.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000046.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000047.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000048.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000049.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000050.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000051.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000052.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000053.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000054.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000055.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000056.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000057.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000058.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000059.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000060.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000061.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000062.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000063.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000064.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000065.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000066.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000067.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000068.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000069.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000070.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000071.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000072.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000073.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000074.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000075.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000076.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000077.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000078.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000079.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000080.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000081.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000082.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000083.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000084.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000085.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000086.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000087.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000088.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000089.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000090.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000091.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000092.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000093.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000094.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000095.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000096.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000097.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000098.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000099.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000100.vtpd']) + +# create a new 'Ghost Cells Generator' +ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) # create a new 'Cell Data to Point Data' -cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ippl_field) +cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ghostCellsGenerator1) cellDatatoPointData1.CellDataArraytoprocess = ['density'] # create a new 'Contour' contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) contour1.ContourBy = ['POINTS', 'density'] -contour1.Isosurfaces = [-2.953365099609886, -5.906730199219772, -5.305982399306464, -4.705234599393156, -4.104486799479848, -3.50373899956654, -2.902991199653232, -2.302243399739924, -1.7014955998266164, -1.1007477999133082, -0.5] +contour1.Isosurfaces = [-10.925284203191916, -9.766919291726147, -8.60855438026038, -7.450189468794611, -6.291824557328843, -5.133459645863074, -3.975094734397306, -2.8167298229315367, -1.6583649114657693, -0.5000000000000018] contour1.PointMergeMethod = 'Uniform Binning' # create a new 'Clip' @@ -65,78 +68,74 @@ clip1.ClipType = 'Plane' clip1.HyperTreeGridClipper = 'Plane' clip1.Scalars = ['POINTS', 'density'] -clip1.Value = -2.90299129486084 +clip1.Value = -5.133459568023682 # init the 'Plane' selected for 'ClipType' -clip1.ClipType.Origin = [9.766819953918457, 9.9811110496521, 10.671213865280151] +clip1.ClipType.Origin = [9.98001554608345, 10.002425193786621, 9.999979734420776] clip1.ClipType.Normal = [0.0, 0.0, 1.0] # init the 'Plane' selected for 'HyperTreeGridClipper' -clip1.HyperTreeGridClipper.Origin = [9.766819953918457, 9.9811110496521, 10.671213865280151] +clip1.HyperTreeGridClipper.Origin = [9.98001554608345, 10.002425193786621, 9.999979734420776] # ---------------------------------------------------------------- # setup the visualization in view 'renderView1' # ---------------------------------------------------------------- -# show data from cellDatatoPointData1 -cellDatatoPointData1Display = Show(cellDatatoPointData1, renderView1, 'UniformGridRepresentation') - -# trace defaults for the display properties. -cellDatatoPointData1Display.Representation = 'Outline' -cellDatatoPointData1Display.ColorArrayName = [None, ''] -cellDatatoPointData1Display.SelectTCoordArray = 'None' -cellDatatoPointData1Display.SelectNormalArray = 'None' -cellDatatoPointData1Display.SelectTangentArray = 'None' -cellDatatoPointData1Display.OSPRayScaleArray = 'density' -cellDatatoPointData1Display.OSPRayScaleFunction = 'PiecewiseFunction' -cellDatatoPointData1Display.SelectOrientationVectors = 'None' -cellDatatoPointData1Display.ScaleFactor = 2.0 -cellDatatoPointData1Display.SelectScaleArray = 'None' -cellDatatoPointData1Display.GlyphType = 'Arrow' -cellDatatoPointData1Display.GlyphTableIndexArray = 'None' -cellDatatoPointData1Display.GaussianRadius = 0.1 -cellDatatoPointData1Display.SetScaleArray = ['POINTS', 'density'] -cellDatatoPointData1Display.ScaleTransferFunction = 'PiecewiseFunction' -cellDatatoPointData1Display.OpacityArray = ['POINTS', 'density'] -cellDatatoPointData1Display.OpacityTransferFunction = 'PiecewiseFunction' -cellDatatoPointData1Display.DataAxesGrid = 'GridAxesRepresentation' -cellDatatoPointData1Display.PolarAxes = 'PolarAxesRepresentation' -cellDatatoPointData1Display.ScalarOpacityUnitDistance = 2.165063509461097 -cellDatatoPointData1Display.OpacityArrayName = ['POINTS', 'density'] -cellDatatoPointData1Display.ColorArray2Name = ['POINTS', 'density'] -cellDatatoPointData1Display.SliceFunction = 'Plane' -cellDatatoPointData1Display.Slice = 8 -cellDatatoPointData1Display.SelectInputVectors = [None, ''] -cellDatatoPointData1Display.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -cellDatatoPointData1Display.ScaleTransferFunction.Points = [-5.906730199219772, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -cellDatatoPointData1Display.OpacityTransferFunction.Points = [-5.906730199219772, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] - -# init the 'Plane' selected for 'SliceFunction' -cellDatatoPointData1Display.SliceFunction.Origin = [10.0, 10.0, 10.0] - -# show data from clip1 -clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') +# show data from ippl_field +ippl_fieldDisplay = Show(ippl_field, renderView1, 'UniformGridRepresentation') # get 2D transfer function for 'density' densityTF2D = GetTransferFunction2D('density') densityTF2D.ScalarRangeInitialized = 1 -densityTF2D.Range = [-7.111382323777126, 0.0, 0.0, 1.0] +densityTF2D.Range = [-16.259595698935676, 0.0, 0.0, 1.0] # get color transfer function/color map for 'density' densityLUT = GetColorTransferFunction('density') densityLUT.TransferFunction2D = densityTF2D -densityLUT.RGBPoints = [-5.30598258972168, 0.231373, 0.298039, 0.752941, -2.90299129486084, 0.865003, 0.865003, 0.865003, -0.5, 0.705882, 0.0156863, 0.14902] +densityLUT.RGBPoints = [-16.259595698935676, 0.231373, 0.298039, 0.752941, -8.129797849467838, 0.865003, 0.865003, 0.865003, 0.0, 0.705882, 0.0156863, 0.14902] densityLUT.ScalarRangeInitialized = 1.0 # get opacity transfer function/opacity map for 'density' densityPWF = GetOpacityTransferFunction('density') -densityPWF.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +densityPWF.Points = [-16.259595698935676, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] densityPWF.ScalarRangeInitialized = 1 +# trace defaults for the display properties. +ippl_fieldDisplay.Representation = 'Outline' +ippl_fieldDisplay.ColorArrayName = ['CELLS', 'density'] +ippl_fieldDisplay.LookupTable = densityLUT +ippl_fieldDisplay.SelectTCoordArray = 'None' +ippl_fieldDisplay.SelectNormalArray = 'None' +ippl_fieldDisplay.SelectTangentArray = 'None' +ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_fieldDisplay.SelectOrientationVectors = 'None' +ippl_fieldDisplay.ScaleFactor = 2.0 +ippl_fieldDisplay.SelectScaleArray = 'None' +ippl_fieldDisplay.GlyphType = 'Arrow' +ippl_fieldDisplay.GlyphTableIndexArray = 'None' +ippl_fieldDisplay.GaussianRadius = 0.1 +ippl_fieldDisplay.SetScaleArray = [None, ''] +ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.OpacityArray = [None, ''] +ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_fieldDisplay.ScalarOpacityUnitDistance = 0.5412658773652742 +ippl_fieldDisplay.ScalarOpacityFunction = densityPWF +ippl_fieldDisplay.TransferFunction2D = densityTF2D +ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'density'] +ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'density'] +ippl_fieldDisplay.SliceFunction = 'Plane' +ippl_fieldDisplay.Slice = 32 +ippl_fieldDisplay.SelectInputVectors = [None, ''] +ippl_fieldDisplay.WriteLog = '' + +# init the 'Plane' selected for 'SliceFunction' +ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from clip1 +clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') + # trace defaults for the display properties. clip1Display.Representation = 'Surface' clip1Display.ColorArrayName = ['POINTS', 'density'] @@ -147,11 +146,11 @@ clip1Display.OSPRayScaleArray = 'density' clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' clip1Display.SelectOrientationVectors = 'None' -clip1Display.ScaleFactor = 1.5288142442703248 +clip1Display.ScaleFactor = 1.8501425802707674 clip1Display.SelectScaleArray = 'density' clip1Display.GlyphType = 'Arrow' clip1Display.GlyphTableIndexArray = 'density' -clip1Display.GaussianRadius = 0.07644071221351624 +clip1Display.GaussianRadius = 0.09250712901353836 clip1Display.SetScaleArray = ['POINTS', 'density'] clip1Display.ScaleTransferFunction = 'PiecewiseFunction' clip1Display.OpacityArray = ['POINTS', 'density'] @@ -159,27 +158,31 @@ clip1Display.DataAxesGrid = 'GridAxesRepresentation' clip1Display.PolarAxes = 'PolarAxesRepresentation' clip1Display.ScalarOpacityFunction = densityPWF -clip1Display.ScalarOpacityUnitDistance = 1.5107155620204928 +clip1Display.ScalarOpacityUnitDistance = 0.7274508700056125 clip1Display.OpacityArrayName = ['POINTS', 'density'] clip1Display.SelectInputVectors = ['POINTS', 'Normals'] clip1Display.WriteLog = '' # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -clip1Display.ScaleTransferFunction.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +clip1Display.ScaleTransferFunction.Points = [-9.766919136047363, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -clip1Display.OpacityTransferFunction.Points = [-5.30598258972168, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] +clip1Display.OpacityTransferFunction.Points = [-9.766919136047363, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] # setup the color legend parameters for each legend in this view # get color legend/bar for densityLUT in view renderView1 densityLUTColorBar = GetScalarBar(densityLUT, renderView1) +densityLUTColorBar.WindowLocation = 'Upper Right Corner' densityLUTColorBar.Title = 'density' densityLUTColorBar.ComponentTitle = '' # set color bar visibility densityLUTColorBar.Visibility = 1 +# show color legend +ippl_fieldDisplay.SetScalarBarVisibility(renderView1, True) + # show color legend clip1Display.SetScalarBarVisibility(renderView1, True) @@ -192,14 +195,6 @@ # setup extractors # ---------------------------------------------------------------- -# create extractor -vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') -# trace defaults for the extractor. -vTPD1.Trigger = 'TimeStep' - -# init the 'VTPD' selected for 'Writer' -vTPD1.Writer.FileName = 'ippl_field_{timestep:06d}.vtpd' - # create extractor pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') # trace defaults for the extractor. @@ -207,8 +202,17 @@ # init the 'PNG' selected for 'Writer' pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [1199, 917] +pNG1.Writer.ImageResolution = [1877, 1171] pNG1.Writer.Format = 'PNG' +pNG1.Writer.ResetDisplay = 1 + +# create extractor +vTPD1 = CreateExtractor('VTPD', clip1, registrationName='VTPD1') +# trace defaults for the extractor. +vTPD1.Trigger = 'TimeStep' + +# init the 'VTPD' selected for 'Writer' +vTPD1.Writer.FileName = 'Clip1_{timestep:06d}.vtpd' # ---------------------------------------------------------------- # restore active source From e79ab79f12690b39ef43f61a9373f44d06d7d309 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 14 Sep 2023 13:36:48 +0200 Subject: [PATCH 065/113] kick out files and only subscripbe to registration name.. --- test/stream/extract_penningtrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/stream/extract_penningtrap.py b/test/stream/extract_penningtrap.py index df4d7a624..cb1846dae 100644 --- a/test/stream/extract_penningtrap.py +++ b/test/stream/extract_penningtrap.py @@ -48,7 +48,7 @@ # ---------------------------------------------------------------- # create a new 'XML Partitioned Dataset Reader' -ippl_field = XMLPartitionedDatasetReader(registrationName='ippl_field', FileName=['/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000000.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000001.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000002.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000003.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000004.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000005.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000006.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000007.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000008.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000009.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000010.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000011.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000012.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000013.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000014.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000015.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000016.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000017.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000018.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000019.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000020.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000021.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000022.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000023.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000024.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000025.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000026.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000027.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000028.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000029.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000030.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000031.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000032.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000033.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000034.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000035.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000036.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000037.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000038.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000039.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000040.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000041.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000042.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000043.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000044.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000045.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000046.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000047.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000048.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000049.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000050.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000051.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000052.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000053.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000054.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000055.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000056.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000057.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000058.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000059.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000060.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000061.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000062.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000063.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000064.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000065.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000066.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000067.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000068.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000069.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000070.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000071.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000072.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000073.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000074.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000075.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000076.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000077.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000078.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000079.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000080.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000081.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000082.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000083.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000084.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000085.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000086.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000087.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000088.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000089.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000090.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000091.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000092.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000093.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000094.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000095.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000096.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000097.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000098.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000099.vtpd', '/p/project/ccstma/schurk1/in-situ/ippl_cuda/ippl/datasets-fine/ippl_field_000100.vtpd']) +ippl_field = XMLPartitionedDatasetReader(registrationName='ippl_field') # create a new 'Ghost Cells Generator' ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) From a0382c7cc6f6584e5a9ff012c65b4807cd663af8 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 09:18:51 +0200 Subject: [PATCH 066/113] add super messy extension for vector field This commit will not compile as we cannot pass in a Vector to conduit. --- alpine/ChargedParticles.hpp | 1 + src/Stream/InSitu/CatalystAdaptor.h | 67 ++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index b2ef8cc07..38e6382b0 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -382,6 +382,7 @@ class ChargedParticles : public ippl::ParticleBase { rhoNorm_m = norm(rho_m); IpplTimings::stopTimer(sumTimer); + // CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), E_m); CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), rho_m); // dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index b842e5c2a..92b303cba 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -5,6 +5,7 @@ #include "Ippl.h" +#include #include #include #include @@ -13,6 +14,31 @@ #include "Utility/IpplException.h" + template + using Vector = ippl::Vector; + + template + using Mesh_t = ippl::UniformCartesian; + + template + using Centering_t = typename Mesh_t::DefaultCentering; + + template + using Field = ippl::Field, Centering_t>; + + template + using ParticleAttrib = ippl::ParticleAttrib; + + template + using Vector_t = Vector; + + template + using Field_t = Field; + + template + using VField_t = Field, Dim>; + + namespace CatalystAdaptor { void Initialize(int argc, char* argv[]) { @@ -46,8 +72,30 @@ namespace CatalystAdaptor { auto nGhost = field.getNghost(); +// typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); +// Kokkos::View vhost_view_layout_left("vhost_view_layout_left", field.getLayout().getLocalNDIndex()[0].length()+ +// field.getLayout().getLocalNDIndex()[1].length()+ +// field.getLayout().getLocalNDIndex()[2].length()); +// +// auto y_offset = field.getLayout().getLocalNDIndex()[1].length(); +// auto z_offset = field.getLayout().getLocalNDIndex()[2].length(); + +// for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) +// { +// for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) +// { +// for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) +// { +// host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); +// } +// } +// } + // vhost_view_layout_left(i) = vhost_view.data()[i+nGhost][0]; + // vhost_view_layout_left(i + y_offset) = vhost_view.data()[i+nGhost][1]; + // vhost_view_layout_left(i + y_offset + z_offset) = + // vhost_view.data()[i+nGhost][2]; + typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); - //Kokkos::deep_copy(host_view, field.getView()); Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), @@ -123,6 +171,23 @@ namespace CatalystAdaptor { fields["density/volume_dependent"].set("false"); fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); + fields["electrostatic/association"].set("element"); + fields["electrostatic/topology"].set("mesh"); + fields["electrostatic/volume_dependent"].set("false"); +// fields["electrostatic/values/x"].set_external( +// vhost_view_layout_left.data(), +// field.getLayout().getLocalNDIndex()[0].length()); +// +// fields["electrostatic/values/y"].set_external( +// vhost_view_layout_left.data(), +// field.getLayout().getLocalNDIndex()[1].length(), +// y_offset); + +// fields["electrostatic/values/y"].set_external( +// &vhost_view_layout_left.data()[1][0], +// field.getLayout().getLocalNDIndex()[2].length(), +// y_offset+z_offset); + // print node to have visual representation if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); From f7654c3e46b7da0b67b920f5f60fc69ba438bfd3 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 10:08:56 +0200 Subject: [PATCH 067/113] try setting data with stride and offset --- alpine/ChargedParticles.hpp | 4 ++-- src/Stream/InSitu/CatalystAdaptor.h | 27 ++++++++++----------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 38e6382b0..5bd57e6f4 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -382,8 +382,8 @@ class ChargedParticles : public ippl::ParticleBase { rhoNorm_m = norm(rho_m); IpplTimings::stopTimer(sumTimer); - // CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), E_m); - CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), rho_m); + CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), E_m); + //CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), rho_m); // dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); // rho = rho_e - rho_i diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 92b303cba..97b58942c 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -72,7 +72,8 @@ namespace CatalystAdaptor { auto nGhost = field.getNghost(); -// typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + // Kokkos::View vhost_view_layout_left("vhost_view_layout_left", field.getLayout().getLocalNDIndex()[0].length()+ // field.getLayout().getLocalNDIndex()[1].length()+ // field.getLayout().getLocalNDIndex()[2].length()); @@ -97,8 +98,7 @@ namespace CatalystAdaptor { typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); - Kokkos::View host_view_layout_left("host_view_layout_left", - field.getLayout().getLocalNDIndex()[0].length(), + Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), field.getLayout().getLocalNDIndex()[1].length(), field.getLayout().getLocalNDIndex()[2].length()); @@ -169,27 +169,20 @@ namespace CatalystAdaptor { fields["density/association"].set("element"); fields["density/topology"].set("mesh"); fields["density/volume_dependent"].set("false"); - fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); + //fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); fields["electrostatic/association"].set("element"); fields["electrostatic/topology"].set("mesh"); fields["electrostatic/volume_dependent"].set("false"); -// fields["electrostatic/values/x"].set_external( -// vhost_view_layout_left.data(), -// field.getLayout().getLocalNDIndex()[0].length()); -// -// fields["electrostatic/values/y"].set_external( -// vhost_view_layout_left.data(), -// field.getLayout().getLocalNDIndex()[1].length(), -// y_offset); -// fields["electrostatic/values/y"].set_external( -// &vhost_view_layout_left.data()[1][0], -// field.getLayout().getLocalNDIndex()[2].length(), -// y_offset+z_offset); + + //auto offset = sizeof(double); + fields["electrostatic/values/x"].set_external(&vhost_view.data()[0][0], 0, 1); //, field.getLayout().getLocalNDIndex()[0].length(), 0, 3*offset); + fields["electrostatic/values/y"].set_external(&vhost_view.data()[0][1], 0, 1); //, field.getLayout().getLocalNDIndex()[1].length(), offset, 3*offset); + fields["electrostatic/values/z"].set_external(&vhost_view.data()[0][2], 0, 1); //, field.getLayout().getLocalNDIndex()[2].length(), 2*offset, 3*offset); // print node to have visual representation - if (cycle == 0) + // if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); From 8150ae65195913d4f223a5441f66def83cd8ad7c Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 10:50:22 +0200 Subject: [PATCH 068/113] update assignment, however that is now empty but 'runs' --- src/Stream/InSitu/CatalystAdaptor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 97b58942c..b3ba5bbe7 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -166,9 +166,9 @@ namespace CatalystAdaptor { // add values and subscribe to data auto fields = mesh["fields"]; - fields["density/association"].set("element"); - fields["density/topology"].set("mesh"); - fields["density/volume_dependent"].set("false"); +// fields["density/association"].set("element"); +// fields["density/topology"].set("mesh"); +// fields["density/volume_dependent"].set("false"); //fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); fields["electrostatic/association"].set("element"); From 62d76f4e0ec58c9289e577d8da5e0236209cf259 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 11:25:10 +0200 Subject: [PATCH 069/113] change subscription to data for vector field Data is now passed to the node, however we still have a tuple missmatch, meaning we do not pass in the right number of points --- src/Stream/InSitu/CatalystAdaptor.h | 11 ++++++----- test/stream/catalyst_pipeline.py | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index b3ba5bbe7..d2b8aa918 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -108,7 +108,8 @@ namespace CatalystAdaptor { { for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) { - host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); + // host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); + host_view_layout_left(i,j,k) = vhost_view(i+nGhost, j+nGhost, k+nGhost); } } } @@ -177,12 +178,12 @@ namespace CatalystAdaptor { //auto offset = sizeof(double); - fields["electrostatic/values/x"].set_external(&vhost_view.data()[0][0], 0, 1); //, field.getLayout().getLocalNDIndex()[0].length(), 0, 3*offset); - fields["electrostatic/values/y"].set_external(&vhost_view.data()[0][1], 0, 1); //, field.getLayout().getLocalNDIndex()[1].length(), offset, 3*offset); - fields["electrostatic/values/z"].set_external(&vhost_view.data()[0][2], 0, 1); //, field.getLayout().getLocalNDIndex()[2].length(), 2*offset, 3*offset); + fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], field.getLayout().getLocalNDIndex()[0].length(), 0, 1); + fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], field.getLayout().getLocalNDIndex()[1].length(), 0, 1); + fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], field.getLayout().getLocalNDIndex()[2].length(), 0, 1); // print node to have visual representation - // if (cycle == 0) + if (cycle == 0) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); diff --git a/test/stream/catalyst_pipeline.py b/test/stream/catalyst_pipeline.py index 581826b7a..43e1d3cb8 100644 --- a/test/stream/catalyst_pipeline.py +++ b/test/stream/catalyst_pipeline.py @@ -18,4 +18,7 @@ def catalyst_execute(info): arrayInfo = producer.CellData["density"] arrayInfo.GetNumberOfComponents() print("field:", producer.CellData["density"].GetRange(-1)) # .GetRange(0)) + arrayInfo = producer.CellData["electrostatic"] + arrayInfo.GetNumberOfComponents() + print("field:", producer.CellData["electrostatic"].GetRange(-1)) # .GetRange(0)) # print("pressure-range:", producer.CellData["pressure"].GetRange(0)) From 365b526bbfb398c5e1dec471d7f3f3297de0fe29 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 13:11:00 +0200 Subject: [PATCH 070/113] fix lenght of vfield conduit node --- src/Stream/InSitu/CatalystAdaptor.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index d2b8aa918..3de8e563b 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -177,10 +177,12 @@ namespace CatalystAdaptor { fields["electrostatic/volume_dependent"].set("false"); - //auto offset = sizeof(double); - fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], field.getLayout().getLocalNDIndex()[0].length(), 0, 1); - fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], field.getLayout().getLocalNDIndex()[1].length(), 0, 1); - fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], field.getLayout().getLocalNDIndex()[2].length(), 0, 1); + auto length = host_view_layout_left.size(); + // offset is zero as we start without the ghost cells + // stried is 1 as we have every index of the array + fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], length, 0, 1); + fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], length, 0, 1); + fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], length, 0, 1); // print node to have visual representation if (cycle == 0) From dc7f9cc51a4ec666cab01525f7e3d446296475ce Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 14:23:48 +0200 Subject: [PATCH 071/113] remove unused lines of code from testing --- src/Stream/InSitu/CatalystAdaptor.h | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 3de8e563b..7cec1fab0 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -72,32 +72,10 @@ namespace CatalystAdaptor { auto nGhost = field.getNghost(); - typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); - -// Kokkos::View vhost_view_layout_left("vhost_view_layout_left", field.getLayout().getLocalNDIndex()[0].length()+ -// field.getLayout().getLocalNDIndex()[1].length()+ -// field.getLayout().getLocalNDIndex()[2].length()); -// -// auto y_offset = field.getLayout().getLocalNDIndex()[1].length(); -// auto z_offset = field.getLayout().getLocalNDIndex()[2].length(); - -// for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) -// { -// for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) -// { -// for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) -// { -// host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); -// } -// } -// } - // vhost_view_layout_left(i) = vhost_view.data()[i+nGhost][0]; - // vhost_view_layout_left(i + y_offset) = vhost_view.data()[i+nGhost][1]; - // vhost_view_layout_left(i + y_offset + z_offset) = - // vhost_view.data()[i+nGhost][2]; - typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), field.getLayout().getLocalNDIndex()[1].length(), field.getLayout().getLocalNDIndex()[2].length()); @@ -179,7 +157,7 @@ namespace CatalystAdaptor { auto length = host_view_layout_left.size(); // offset is zero as we start without the ghost cells - // stried is 1 as we have every index of the array + // stride is 1 as we have every index of the array fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], length, 0, 1); fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], length, 0, 1); fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], length, 0, 1); From 5c0b0b010337a73c26eb2988d5e6bf02987ba4ae Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 16:34:41 +0200 Subject: [PATCH 072/113] cleanup CatalystAdaptor * remove template typedefinitions bevore header * remove doubled vhost_view --- src/Stream/InSitu/CatalystAdaptor.h | 75 +++++++++-------------------- 1 file changed, 24 insertions(+), 51 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 7cec1fab0..1e4f5272a 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -5,7 +5,6 @@ #include "Ippl.h" -#include #include #include #include @@ -14,31 +13,6 @@ #include "Utility/IpplException.h" - template - using Vector = ippl::Vector; - - template - using Mesh_t = ippl::UniformCartesian; - - template - using Centering_t = typename Mesh_t::DefaultCentering; - - template - using Field = ippl::Field, Centering_t>; - - template - using ParticleAttrib = ippl::ParticleAttrib; - - template - using Vector_t = Vector; - - template - using Field_t = Field; - - template - using VField_t = Field, Dim>; - - namespace CatalystAdaptor { void Initialize(int argc, char* argv[]) { @@ -70,24 +44,21 @@ namespace CatalystAdaptor { // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html - auto nGhost = field.getNghost(); + auto nGhost = field.getNghost(); - typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + typename Field::view_type::host_mirror_type host_view = + Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); - typename VField_t<3>::view_type::host_mirror_type vhost_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),field.getView()); + Kokkos::View + host_view_layout_left("host_view_layout_left", + field.getLayout().getLocalNDIndex()[0].length(), + field.getLayout().getLocalNDIndex()[1].length(), + field.getLayout().getLocalNDIndex()[2].length()); - Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), - field.getLayout().getLocalNDIndex()[1].length(), - field.getLayout().getLocalNDIndex()[2].length()); - - for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) - { - for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) - { - for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) - { - // host_view_layout_left(i,j,k) = host_view(i+nGhost, j+nGhost, k+nGhost); - host_view_layout_left(i,j,k) = vhost_view(i+nGhost, j+nGhost, k+nGhost); + for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) { + for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) { + for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) { + host_view_layout_left(i, j, k) = host_view(i + nGhost, j + nGhost, k + nGhost); } } } @@ -114,8 +85,7 @@ namespace CatalystAdaptor { std::string field_node_spacing{"coordsets/coords/spacing/dx"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { - mesh[field_node_dim].set( - int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); + mesh[field_node_dim].set(int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); // shift origin by one ghost cell mesh[field_node_origin].set( @@ -145,22 +115,25 @@ namespace CatalystAdaptor { // add values and subscribe to data auto fields = mesh["fields"]; -// fields["density/association"].set("element"); -// fields["density/topology"].set("mesh"); -// fields["density/volume_dependent"].set("false"); - //fields["density/values"].set_external(host_view_layout_left.data(), host_view_layout_left.size()); + // fields["density/association"].set("element"); + // fields["density/topology"].set("mesh"); + // fields["density/volume_dependent"].set("false"); + // fields["density/values"].set_external(host_view_layout_left.data(), + // host_view_layout_left.size()); fields["electrostatic/association"].set("element"); fields["electrostatic/topology"].set("mesh"); fields["electrostatic/volume_dependent"].set("false"); - auto length = host_view_layout_left.size(); // offset is zero as we start without the ghost cells // stride is 1 as we have every index of the array - fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], length, 0, 1); - fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], length, 0, 1); - fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], length, 0, 1); + fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], length, + 0, 1); + fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], length, + 0, 1); + fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], length, + 0, 1); // print node to have visual representation if (cycle == 0) From 2321ce130027abb0a2226f4671430c58a49d6da1 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 18:03:20 +0200 Subject: [PATCH 073/113] move assignment of data values to separate function In order to overload or better specify the right setting of the values, this is moved out into a smaller function. Other values should stay same, so that should ease maintainability. --- src/Stream/InSitu/CatalystAdaptor.h | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 1e4f5272a..8c2ee10b9 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -15,6 +15,21 @@ namespace CatalystAdaptor { + template + void setData(conduit_cpp::Node& node, Field& field) { + node["electrostatic/association"].set("element"); + node["electrostatic/topology"].set("mesh"); + node["electrostatic/volume_dependent"].set("false"); + + auto length = std::size(field); + + // offset is zero as we start without the ghost cells + // stride is 1 as we have every index of the array + node["electrostatic/values/x"].set_external(&field.data()[0][0], length, 0, 1); + node["electrostatic/values/y"].set_external(&field.data()[0][1], length, 0, 1); + node["electrostatic/values/z"].set_external(&field.data()[0][2], length, 0, 1); + } + void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; for (int cc = 1; cc < argc; ++cc) { @@ -114,6 +129,7 @@ namespace CatalystAdaptor { } // add values and subscribe to data + auto fields = mesh["fields"]; // fields["density/association"].set("element"); // fields["density/topology"].set("mesh"); @@ -121,19 +137,7 @@ namespace CatalystAdaptor { // fields["density/values"].set_external(host_view_layout_left.data(), // host_view_layout_left.size()); - fields["electrostatic/association"].set("element"); - fields["electrostatic/topology"].set("mesh"); - fields["electrostatic/volume_dependent"].set("false"); - - auto length = host_view_layout_left.size(); - // offset is zero as we start without the ghost cells - // stride is 1 as we have every index of the array - fields["electrostatic/values/x"].set_external(&host_view_layout_left.data()[0][0], length, - 0, 1); - fields["electrostatic/values/y"].set_external(&host_view_layout_left.data()[0][1], length, - 0, 1); - fields["electrostatic/values/z"].set_external(&host_view_layout_left.data()[0][2], length, - 0, 1); + setData(fields, host_view_layout_left); // print node to have visual representation if (cycle == 0) From 4360f8abd97a30ba64d7b3b3c28104b86b1eb1b4 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 19 Sep 2023 18:08:40 +0200 Subject: [PATCH 074/113] add simple extract script for vector field values --- test/stream/extract3_penningtrap.py | 204 ++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 test/stream/extract3_penningtrap.py diff --git a/test/stream/extract3_penningtrap.py b/test/stream/extract3_penningtrap.py new file mode 100644 index 000000000..12860c4fa --- /dev/null +++ b/test/stream/extract3_penningtrap.py @@ -0,0 +1,204 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView2 = CreateView('RenderView') +renderView2.ViewSize = [371, 530] +renderView2.AxesGrid = 'GridAxes3DActor' +renderView2.CenterOfRotation = [10.0, 10.0, 10.0] +renderView2.StereoType = 'Crystal Eyes' +renderView2.CameraPosition = [-42.55244880849627, 53.0225730665183, 75.27577212134747] +renderView2.CameraFocalPoint = [10.0, 10.0, 10.0] +renderView2.CameraViewUp = [0.3331761994480328, 0.8879714244143248, -0.3170179325289973] +renderView2.CameraFocalDisk = 1.0 +renderView2.CameraParallelScale = 24.810457513824463 +renderView2.BackEnd = 'OSPRay raycaster' +renderView2.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.SplitHorizontal(0, 0.500000) +layout1.AssignView(1, renderView2) +layout1.SetSize(742, 530) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView2) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# create a new 'Clip' +clip1 = Clip(registrationName='Clip1', Input=ippl_field) +clip1.ClipType = 'Plane' +clip1.HyperTreeGridClipper = 'Plane' +clip1.Scalars = ['POINTS', ''] + +# init the 'Plane' selected for 'ClipType' +clip1.ClipType.Origin = [10.0, 10.0, 10.0] +clip1.ClipType.Normal = [0.0, 0.0, 1.0] + +# init the 'Plane' selected for 'HyperTreeGridClipper' +clip1.HyperTreeGridClipper.Origin = [10.0, 10.0, 10.0] + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView2' +# ---------------------------------------------------------------- + +# show data from ippl_field +ippl_fieldDisplay = Show(ippl_field, renderView2, 'UniformGridRepresentation') + +# get 2D transfer function for 'electrostatic' +electrostaticTF2D = GetTransferFunction2D('electrostatic') +electrostaticTF2D.ScalarRangeInitialized = 1 +electrostaticTF2D.Range = [0.0, 1.1757813367477812e-38, 0.0, 1.0] + +# get color transfer function/color map for 'electrostatic' +electrostaticLUT = GetColorTransferFunction('electrostatic') +electrostaticLUT.TransferFunction2D = electrostaticTF2D +electrostaticLUT.RGBPoints = [0.07470709971953278, 0.231373, 0.298039, 0.752941, 3.33273624725058, 0.865003, 0.865003, 0.865003, 6.590765394781628, 0.705882, 0.0156863, 0.14902] +electrostaticLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'electrostatic' +electrostaticPWF = GetOpacityTransferFunction('electrostatic') +electrostaticPWF.Points = [0.07470709971953278, 0.0, 0.5, 0.0, 6.590765394781628, 1.0, 0.5, 0.0] +electrostaticPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_fieldDisplay.Representation = 'Outline' +ippl_fieldDisplay.ColorArrayName = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.LookupTable = electrostaticLUT +ippl_fieldDisplay.SelectTCoordArray = 'None' +ippl_fieldDisplay.SelectNormalArray = 'None' +ippl_fieldDisplay.SelectTangentArray = 'None' +ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_fieldDisplay.SelectOrientationVectors = 'None' +ippl_fieldDisplay.ScaleFactor = 2.0 +ippl_fieldDisplay.SelectScaleArray = 'None' +ippl_fieldDisplay.GlyphType = 'Arrow' +ippl_fieldDisplay.GlyphTableIndexArray = 'None' +ippl_fieldDisplay.GaussianRadius = 0.1 +ippl_fieldDisplay.SetScaleArray = [None, ''] +ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.OpacityArray = [None, ''] +ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_fieldDisplay.ScalarOpacityUnitDistance = 2.165063509461097 +ippl_fieldDisplay.ScalarOpacityFunction = electrostaticPWF +ippl_fieldDisplay.TransferFunction2D = electrostaticTF2D +ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.SliceFunction = 'Plane' +ippl_fieldDisplay.Slice = 8 +ippl_fieldDisplay.SelectInputVectors = [None, ''] +ippl_fieldDisplay.WriteLog = '' + +# init the 'Plane' selected for 'SliceFunction' +ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from clip1 +clip1Display = Show(clip1, renderView2, 'UnstructuredGridRepresentation') + +# trace defaults for the display properties. +clip1Display.Representation = 'Surface' +clip1Display.ColorArrayName = ['CELLS', 'electrostatic'] +clip1Display.LookupTable = electrostaticLUT +clip1Display.SelectTCoordArray = 'None' +clip1Display.SelectNormalArray = 'None' +clip1Display.SelectTangentArray = 'None' +clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' +clip1Display.SelectOrientationVectors = 'None' +clip1Display.ScaleFactor = 1.7627550836865113 +clip1Display.SelectScaleArray = 'None' +clip1Display.GlyphType = 'Arrow' +clip1Display.GlyphTableIndexArray = 'None' +clip1Display.GaussianRadius = 0.08813775418432555 +clip1Display.SetScaleArray = [None, ''] +clip1Display.ScaleTransferFunction = 'PiecewiseFunction' +clip1Display.OpacityArray = [None, ''] +clip1Display.OpacityTransferFunction = 'PiecewiseFunction' +clip1Display.DataAxesGrid = 'GridAxesRepresentation' +clip1Display.PolarAxes = 'PolarAxesRepresentation' +clip1Display.ScalarOpacityFunction = electrostaticPWF +clip1Display.ScalarOpacityUnitDistance = 2.054619857832192 +clip1Display.OpacityArrayName = ['CELLS', 'electrostatic'] +clip1Display.SelectInputVectors = [None, ''] +clip1Display.WriteLog = '' + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for electrostaticLUT in view renderView2 +electrostaticLUTColorBar = GetScalarBar(electrostaticLUT, renderView2) +electrostaticLUTColorBar.Title = 'electrostatic' +electrostaticLUTColorBar.ComponentTitle = 'Magnitude' + +# set color bar visibility +electrostaticLUTColorBar.Visibility = 1 + +# show color legend +ippl_fieldDisplay.SetScalarBarVisibility(renderView2, True) + +# show color legend +clip1Display.SetScalarBarVisibility(renderView2, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [371, 530] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(pNG1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GlobalTrigger = 'TimeStep' +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From 9e49b7f04952e05ca83389074b3ab970579e4199 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 20 Sep 2023 10:18:02 +0200 Subject: [PATCH 075/113] add changes from #6788218f5f93cdeb751947d2c1e2a56876868d23 --- alpine/PenningTrap.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 896b1745c..45ba291b9 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -357,13 +357,13 @@ int main(int argc, char* argv[]) { double Eext_y = -(Rview(j)[1] - 0.5 * rmax[1]) * (V0 / (2 * std::pow(rmax[2], 2))); double Eext_z = (Rview(j)[2] - 0.5 * rmax[2]) * (V0 / (std::pow(rmax[2], 2))); - Eview(j)[0] += Eext_x; - Eview(j)[1] += Eext_y; - Eview(j)[2] += Eext_z; + Eext_x += Eview(j)[0]; + Eext_y += Eview(j)[1]; + Eext_z += Eview(j)[2]; - Pview(j)[0] += alpha * (Eview(j)[0] + Pview(j)[1] * Bext); - Pview(j)[1] += alpha * (Eview(j)[1] - Pview(j)[0] * Bext); - Pview(j)[2] += alpha * Eview(j)[2]; + Pview(j)[0] += alpha * (Eext_x + Pview(j)[1] * Bext); + Pview(j)[1] += alpha * (Eext_y - Pview(j)[0] * Bext); + Pview(j)[2] += alpha * Eext_z; }); IpplTimings::stopTimer(PTimer); @@ -410,20 +410,17 @@ int main(int argc, char* argv[]) { double Eext_y = -(R2view(j)[1] - 0.5 * rmax[1]) * (V0 / (2 * std::pow(rmax[2], 2))); double Eext_z = (R2view(j)[2] - 0.5 * rmax[2]) * (V0 / (std::pow(rmax[2], 2))); - E2view(j)[0] += Eext_x; - E2view(j)[1] += Eext_y; - E2view(j)[2] += Eext_z; - P2view(j)[0] = - DrInv - * (P2view(j)[0] - + alpha - * (E2view(j)[0] + P2view(j)[1] * Bext + alpha * Bext * E2view(j)[1])); - P2view(j)[1] = - DrInv - * (P2view(j)[1] - + alpha - * (E2view(j)[1] - P2view(j)[0] * Bext - alpha * Bext * E2view(j)[0])); - P2view(j)[2] += alpha * E2view(j)[2]; + Eext_x += E2view(j)[0]; + Eext_y += E2view(j)[1]; + Eext_z += E2view(j)[2]; + + P2view(j)[0] = DrInv + * (P2view(j)[0] + + alpha * (Eext_x + P2view(j)[1] * Bext + alpha * Bext * Eext_y)); + P2view(j)[1] = DrInv + * (P2view(j)[1] + + alpha * (Eext_y - P2view(j)[0] * Bext - alpha * Bext * Eext_x)); + P2view(j)[2] += alpha * Eext_z; }); IpplTimings::stopTimer(PTimer); From ce6fe89fb256f4a9aceeb514da4fbded9ee3caf0 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 20 Sep 2023 12:00:48 +0200 Subject: [PATCH 076/113] add overload of setData function for scalar and vector field --- src/Stream/InSitu/CatalystAdaptor.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 8c2ee10b9..6c41bb81e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -15,19 +15,28 @@ namespace CatalystAdaptor { - template - void setData(conduit_cpp::Node& node, Field& field) { + using View_vector = + Kokkos::View***, Kokkos::LayoutLeft, Kokkos::HostSpace>; + void setData(conduit_cpp::Node& node, const View_vector& view) { node["electrostatic/association"].set("element"); node["electrostatic/topology"].set("mesh"); node["electrostatic/volume_dependent"].set("false"); - auto length = std::size(field); + auto length = std::size(view); // offset is zero as we start without the ghost cells // stride is 1 as we have every index of the array - node["electrostatic/values/x"].set_external(&field.data()[0][0], length, 0, 1); - node["electrostatic/values/y"].set_external(&field.data()[0][1], length, 0, 1); - node["electrostatic/values/z"].set_external(&field.data()[0][2], length, 0, 1); + node["electrostatic/values/x"].set_external(&view.data()[0][0], length, 0, 1); + node["electrostatic/values/y"].set_external(&view.data()[0][1], length, 0, 1); + node["electrostatic/values/z"].set_external(&view.data()[0][2], length, 0, 1); + } + + using View_scalar = Kokkos::View; + void setData(conduit_cpp::Node& node, const View_scalar& view) { + node["density/association"].set("element"); + node["density/topology"].set("mesh"); + node["density/volume_dependent"].set("false"); + node["density/values"].set_external(view.data(), view.size()); } void Initialize(int argc, char* argv[]) { @@ -129,13 +138,7 @@ namespace CatalystAdaptor { } // add values and subscribe to data - auto fields = mesh["fields"]; - // fields["density/association"].set("element"); - // fields["density/topology"].set("mesh"); - // fields["density/volume_dependent"].set("false"); - // fields["density/values"].set_external(host_view_layout_left.data(), - // host_view_layout_left.size()); setData(fields, host_view_layout_left); From 5a3d4bddde8080d5fb162291fde61a6b187bbbcb Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 21 Sep 2023 15:14:49 +0200 Subject: [PATCH 077/113] fix shock that went thru rendering when updating the field Passing in the old data with the updated mesh lead to problems in the visualization such that a "shock" was going thru the borders of the boundary domains. Fix pointed out by Sriram. --- alpine/ChargedParticles.hpp | 4 +--- alpine/PenningTrap.cpp | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 5bd57e6f4..651fb5860 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -382,9 +382,7 @@ class ChargedParticles : public ippl::ParticleBase { rhoNorm_m = norm(rho_m); IpplTimings::stopTimer(sumTimer); - CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), E_m); - //CatalystAdaptor::Execute(iteration, time_m, Ippl::Comm->rank(), rho_m); - // dumpVTK(rho_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); + // dumpVTK(E_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); // rho = rho_e - rho_i double size = 1; diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 45ba291b9..00be4f4d5 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -396,6 +396,8 @@ int main(int argc, char* argv[]) { P->runSolver(); IpplTimings::stopTimer(SolveTimer); + CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->E_m); + // gather E field P->gatherCIC(); From 04921b3e27c04e0c177857b648301f8aed08d679 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 22 Sep 2023 14:58:43 +0200 Subject: [PATCH 078/113] remove cast to in, as there is no longer an error thrown --- src/Stream/InSitu/CatalystAdaptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 6c41bb81e..57793d26e 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -109,7 +109,7 @@ namespace CatalystAdaptor { std::string field_node_spacing{"coordsets/coords/spacing/dx"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { - mesh[field_node_dim].set(int(field.getLayout().getLocalNDIndex()[iDim].length() + 1)); + mesh[field_node_dim].set(field.getLayout().getLocalNDIndex()[iDim].length() + 1); // shift origin by one ghost cell mesh[field_node_origin].set( From ab0a994057f1d02753d92123f3b6e06256f7ffa2 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 09:48:50 +0200 Subject: [PATCH 079/113] add first draft of catalyst adaptor passing in the particles Currently the connectivity is not right, as I only retriever there one value. Coordest x,y,z should be right, however currently hardcoded to dimension 3. --- alpine/PenningTrap.cpp | 3 +- src/Stream/InSitu/CatalystAdaptor.h | 72 +++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 00be4f4d5..1e42a018a 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -396,7 +396,8 @@ int main(int argc, char* argv[]) { P->runSolver(); IpplTimings::stopTimer(SolveTimer); - CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->E_m); + // CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->rho_m); + CatalystAdaptor::Execute_Particle(it, P->time_m, Ippl::Comm->rank(), P); // gather E field P->gatherCIC(); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 57793d26e..78bd0c690 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -152,6 +152,78 @@ namespace CatalystAdaptor { } } + template + void Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle) { + + auto particle_view = particle->q.getView(); + auto layout_view = particle->R.getView(); + +// typename ChargedParticles::view_type::host_mirror_type host_view = +// Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), particle_view); + +// Kokkos::View +// host_view_layout_left("host_view_layout_left", +// field.getLayout().getLocalNDIndex()[0].length(), +// field.getLayout().getLocalNDIndex()[1].length(), +// field.getLayout().getLocalNDIndex()[2].length()); +// +// for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) { +// for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) { +// for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) { +// host_view_layout_left(i, j, k) = host_view(i + nGhost, j + nGhost, k + nGhost); +// } +// } +// } + + conduit_cpp::Node node; + + // add time/cycle information + auto state = node["catalyst/state"]; + state["cycle"].set(cycle); + state["time"].set(time); + state["domain_id"].set(rank); + + // add catalyst channel named ippl_field, as fields is reserved + auto channel = node["catalyst/channels/ippl_particles"]; + channel["type"].set_string("mesh"); + + // in data channel now we adhere to conduits mesh blueprint definition + auto mesh = channel["data"]; + mesh["coordsets/coords/type"].set("explicit"); + + // number of points in specific dimension + std::string particle_node_dim{"coordsets/coords/values/x"}; + + for (unsigned int iDim = 0; iDim < 3; ++iDim) { + mesh[particle_node_dim].set_external(&layout_view.data()[0][iDim], std::size(layout_view), 0, 1); + + // increment last char in string + ++particle_node_dim.back(); + } + + // auto test = particle->ID; + // add topology + mesh["topologies/mesh/type"].set("unstructured"); + mesh["topologies/mesh/coordset"].set("coords"); + mesh["topologies/mesh/elements/shape"].set("point"); + mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data()); +// +// // add values and subscribe to data +// auto fields = mesh["fields"]; +// +// setData(fields, host_view_layout_left); + + // print node to have visual representation + if (cycle == 0) + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) { + std::cerr << "Failed to execute Catalyst: " << err << std::endl; + } + + } + void Finalize() { conduit_cpp::Node node; catalyst_status err = catalyst_finalize(conduit_cpp::c_node(&node)); From 18716b63cb0d94f32cb3a127a9e025b25ff62e34 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 10:02:06 +0200 Subject: [PATCH 080/113] add lenght of description for connectivity an extractor fields Sure without a sizue how should it know how many it does need. --- src/Stream/InSitu/CatalystAdaptor.h | 5 ++- test/stream/dump_field_vtpd.py | 47 +++++++++++++++++++++++++++++ test/stream/dump_particle_vtpd.py | 47 +++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 test/stream/dump_field_vtpd.py create mode 100644 test/stream/dump_particle_vtpd.py diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 78bd0c690..265fc9180 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -183,8 +183,7 @@ namespace CatalystAdaptor { state["time"].set(time); state["domain_id"].set(rank); - // add catalyst channel named ippl_field, as fields is reserved - auto channel = node["catalyst/channels/ippl_particles"]; + auto channel = node["catalyst/channels/ippl_particle"]; channel["type"].set_string("mesh"); // in data channel now we adhere to conduits mesh blueprint definition @@ -206,7 +205,7 @@ namespace CatalystAdaptor { mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); - mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data()); + mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),std::size(layout_view)); // // // add values and subscribe to data // auto fields = mesh["fields"]; diff --git a/test/stream/dump_field_vtpd.py b/test/stream/dump_field_vtpd.py new file mode 100644 index 000000000..be6e859b5 --- /dev/null +++ b/test/stream/dump_field_vtpd.py @@ -0,0 +1,47 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') +# trace defaults for the extractor. +vTPD1.Trigger = 'TimeStep' + +# init the 'VTPD' selected for 'Writer' +vTPD1.Writer.FileName = 'ippl_field_{timestep:06d}.vtpd' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(vTPD1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) diff --git a/test/stream/dump_particle_vtpd.py b/test/stream/dump_particle_vtpd.py new file mode 100644 index 000000000..41970224d --- /dev/null +++ b/test/stream/dump_particle_vtpd.py @@ -0,0 +1,47 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_particle') + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +# vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') +# # trace defaults for the extractor. +# vTPD1.Trigger = 'TimeStep' +# +# # init the 'VTPD' selected for 'Writer' +# vTPD1.Writer.FileName = 'ippl_field_{timestep:06d}.vtpd' +# +# # ---------------------------------------------------------------- +# # restore active source +# SetActiveSource(vTPD1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From 8628bb70f3d285d4225bb3a780a128ec303881e6 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 10:44:51 +0200 Subject: [PATCH 081/113] add particle extractor --- src/Stream/InSitu/CatalystAdaptor.h | 31 ++---- test/stream/dump_particle_vtpd.py | 145 +++++++++++++++++++++++++--- 2 files changed, 141 insertions(+), 35 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 265fc9180..af4d12cc8 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -158,23 +158,6 @@ namespace CatalystAdaptor { auto particle_view = particle->q.getView(); auto layout_view = particle->R.getView(); -// typename ChargedParticles::view_type::host_mirror_type host_view = -// Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), particle_view); - -// Kokkos::View -// host_view_layout_left("host_view_layout_left", -// field.getLayout().getLocalNDIndex()[0].length(), -// field.getLayout().getLocalNDIndex()[1].length(), -// field.getLayout().getLocalNDIndex()[2].length()); -// -// for (size_t i = 0; i < field.getLayout().getLocalNDIndex()[0].length(); ++i) { -// for (size_t j = 0; j < field.getLayout().getLocalNDIndex()[1].length(); ++j) { -// for (size_t k = 0; k < field.getLayout().getLocalNDIndex()[2].length(); ++k) { -// host_view_layout_left(i, j, k) = host_view(i + nGhost, j + nGhost, k + nGhost); -// } -// } -// } - conduit_cpp::Node node; // add time/cycle information @@ -200,17 +183,17 @@ namespace CatalystAdaptor { ++particle_node_dim.back(); } - // auto test = particle->ID; - // add topology mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),std::size(layout_view)); -// -// // add values and subscribe to data -// auto fields = mesh["fields"]; -// -// setData(fields, host_view_layout_left); + + // add values and subscribe to data + auto fields = mesh["fields"]; + fields["charge/association"].set("vertex"); + fields["charge/topology"].set("mesh"); + fields["charge/volume_dependent"].set("false"); + fields["charge/values"].set_external(particle_view.data(), particle_view.size()); // print node to have visual representation if (cycle == 0) diff --git a/test/stream/dump_particle_vtpd.py b/test/stream/dump_particle_vtpd.py index 41970224d..6a734b9ce 100644 --- a/test/stream/dump_particle_vtpd.py +++ b/test/stream/dump_particle_vtpd.py @@ -6,28 +6,151 @@ #### disable automatic camera reset on 'Show' paraview.simple._DisableFirstRenderCameraReset() +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView2 = CreateView('RenderView') +renderView2.ViewSize = [1720, 1139] +renderView2.InteractionMode = 'Selection' +renderView2.AxesGrid = 'GridAxes3DActor' +renderView2.CenterOfRotation = [9.804884923241747, 10.012704247151916, 10.01700792908101] +renderView2.StereoType = 'Crystal Eyes' +renderView2.CameraPosition = [40.819301732806345, 33.78514219032403, 34.48114089650258] +renderView2.CameraFocalPoint = [9.804884923241747, 10.012704247151914, 10.017007929081009] +renderView2.CameraViewUp = [-0.4004377803427935, 0.8567874131175701, -0.3249075449992492] +renderView2.CameraFocalDisk = 1.0 +renderView2.CameraParallelScale = 14.43822672570447 +renderView2.BackEnd = 'OSPRay raycaster' +renderView2.OSPRayMaterialLibrary = materialLibrary1 + +# init the 'GridAxes3DActor' selected for 'AxesGrid' +renderView2.AxesGrid.Visibility = 1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView2) +layout1.SetSize(1720, 1139) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView2) +# ---------------------------------------------------------------- + # ---------------------------------------------------------------- # setup the data processing pipelines # ---------------------------------------------------------------- # create a new 'PVTrivialProducer' -ippl_field = PVTrivialProducer(registrationName='ippl_particle') +ippl_particle = PVTrivialProducer(registrationName='ippl_particle') + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView2' +# ---------------------------------------------------------------- + +# show data from ippl_particle +ippl_particleDisplay = Show(ippl_particle, renderView2, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'charge' +chargeTF2D = GetTransferFunction2D('charge') + +# get color transfer function/color map for 'charge' +chargeLUT = GetColorTransferFunction('charge') +chargeLUT.TransferFunction2D = chargeTF2D +chargeLUT.RGBPoints = [-0.15625, 0.231373, 0.298039, 0.752941, -0.1562347412109375, 0.865003, 0.865003, 0.865003, -0.156219482421875, 0.705882, 0.0156863, 0.14902] +chargeLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'charge' +chargePWF = GetOpacityTransferFunction('charge') +chargePWF.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] +chargePWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_particleDisplay.Representation = 'Point Gaussian' +ippl_particleDisplay.ColorArrayName = ['POINTS', 'charge'] +ippl_particleDisplay.LookupTable = chargeLUT +ippl_particleDisplay.SelectTCoordArray = 'None' +ippl_particleDisplay.SelectNormalArray = 'None' +ippl_particleDisplay.SelectTangentArray = 'None' +ippl_particleDisplay.OSPRayScaleArray = 'charge' +ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_particleDisplay.SelectOrientationVectors = 'None' +ippl_particleDisplay.ScaleFactor = 1.9956522745753908 +ippl_particleDisplay.SelectScaleArray = 'None' +ippl_particleDisplay.GlyphType = 'Arrow' +ippl_particleDisplay.GlyphTableIndexArray = 'None' +ippl_particleDisplay.GaussianRadius = 0.09978261372876954 +ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] +ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] +ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_particleDisplay.ScalarOpacityFunction = chargePWF +ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 +ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] +ippl_particleDisplay.SelectInputVectors = [None, ''] +ippl_particleDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for chargeLUT in view renderView2 +chargeLUTColorBar = GetScalarBar(chargeLUT, renderView2) +chargeLUTColorBar.Title = 'charge' +chargeLUTColorBar.ComponentTitle = '' + +# set color bar visibility +chargeLUTColorBar.Visibility = 1 + +# show color legend +ippl_particleDisplay.SetScalarBarVisibility(renderView2, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- # ---------------------------------------------------------------- # setup extractors # ---------------------------------------------------------------- # create extractor -# vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') -# # trace defaults for the extractor. -# vTPD1.Trigger = 'TimeStep' -# -# # init the 'VTPD' selected for 'Writer' -# vTPD1.Writer.FileName = 'ippl_field_{timestep:06d}.vtpd' -# -# # ---------------------------------------------------------------- -# # restore active source -# SetActiveSource(vTPD1) +vTM1 = CreateExtractor('VTM', ippl_particle, registrationName='VTM1') +# trace defaults for the extractor. +vTM1.Trigger = 'TimeStep' + +# init the 'VTM' selected for 'Writer' +vTM1.Writer.FileName = 'ippl_particle_{timestep:06d}.vtm' + +# create extractor +pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [1720, 1139] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(vTM1) # ---------------------------------------------------------------- # ------------------------------------------------------------------------------ From 2ef303f64c6b3aeea7de7c1eb8b96347a530ee3f Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 11:02:23 +0200 Subject: [PATCH 082/113] update extractor as vtm dump fails --- test/stream/dump_particle_vtpd.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test/stream/dump_particle_vtpd.py b/test/stream/dump_particle_vtpd.py index 6a734b9ce..5eb0d3b3c 100644 --- a/test/stream/dump_particle_vtpd.py +++ b/test/stream/dump_particle_vtpd.py @@ -15,21 +15,23 @@ # Create a new 'Render View' renderView2 = CreateView('RenderView') -renderView2.ViewSize = [1720, 1139] +renderView2.ViewSize = [1280, 824] renderView2.InteractionMode = 'Selection' renderView2.AxesGrid = 'GridAxes3DActor' -renderView2.CenterOfRotation = [9.804884923241747, 10.012704247151916, 10.01700792908101] +renderView2.CenterOfRotation = [10.002041462808847, 9.978474140167236, 10.046973206102848] +renderView2.HiddenLineRemoval = 1 renderView2.StereoType = 'Crystal Eyes' -renderView2.CameraPosition = [40.819301732806345, 33.78514219032403, 34.48114089650258] -renderView2.CameraFocalPoint = [9.804884923241747, 10.012704247151914, 10.017007929081009] -renderView2.CameraViewUp = [-0.4004377803427935, 0.8567874131175701, -0.3249075449992492] +renderView2.CameraPosition = [42.41949355014824, 42.39592622750662, 42.46442529344225] +renderView2.CameraFocalPoint = [10.002041462808847, 9.978474140167236, 10.046973206102848] +renderView2.CameraViewUp = [-0.4082482904638631, 0.816496580927726, -0.40824829046386296] renderView2.CameraFocalDisk = 1.0 -renderView2.CameraParallelScale = 14.43822672570447 +renderView2.CameraParallelScale = 14.53234620584578 renderView2.BackEnd = 'OSPRay raycaster' renderView2.OSPRayMaterialLibrary = materialLibrary1 # init the 'GridAxes3DActor' selected for 'AxesGrid' renderView2.AxesGrid.Visibility = 1 +renderView2.AxesGrid.ShowGrid = 1 SetActiveView(None) @@ -40,7 +42,7 @@ # create new layout object 'Layout #1' layout1 = CreateLayout(name='Layout #1') layout1.AssignView(0, renderView2) -layout1.SetSize(1720, 1139) +layout1.SetSize(1280, 824) # ---------------------------------------------------------------- # restore active view @@ -130,14 +132,6 @@ # setup extractors # ---------------------------------------------------------------- -# create extractor -vTM1 = CreateExtractor('VTM', ippl_particle, registrationName='VTM1') -# trace defaults for the extractor. -vTM1.Trigger = 'TimeStep' - -# init the 'VTM' selected for 'Writer' -vTM1.Writer.FileName = 'ippl_particle_{timestep:06d}.vtm' - # create extractor pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') # trace defaults for the extractor. @@ -147,10 +141,11 @@ pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' pNG1.Writer.ImageResolution = [1720, 1139] pNG1.Writer.Format = 'PNG' +pNG1.Writer.ResetDisplay = 1 # ---------------------------------------------------------------- # restore active source -SetActiveSource(vTM1) +SetActiveSource(pNG1) # ---------------------------------------------------------------- # ------------------------------------------------------------------------------ From 07665abfe7df44bd729ee7fc5c8e41844f0f7910 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 12:19:24 +0200 Subject: [PATCH 083/113] add particle velocity to data description --- src/Stream/InSitu/CatalystAdaptor.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index af4d12cc8..390b35eca 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -186,14 +186,25 @@ namespace CatalystAdaptor { mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); - mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),std::size(layout_view)); + mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum(),0); + std::cout << "Size of layout view from rank: " << rank << " " << particle->getLocalNum() << std::endl; + std::cout << "Size of particle view from rank: " << rank << " " << particle->getLocalNum() << std::endl; + auto charge_view = particle->q.getView(); // add values and subscribe to data auto fields = mesh["fields"]; fields["charge/association"].set("vertex"); fields["charge/topology"].set("mesh"); fields["charge/volume_dependent"].set("false"); - fields["charge/values"].set_external(particle_view.data(), particle_view.size()); + fields["charge/values"].set_external(charge_view.data(), particle->getLocalNum()); + + auto velocity_view = particle->P.getView(); + fields["velocity/association"].set("vertex"); + fields["velocity/topology"].set("mesh"); + fields["velocity/volume_dependent"].set("false"); + fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,1); + fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,1); + fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,1); // print node to have visual representation if (cycle == 0) From e8a0afece111b7f5e29d505dbd3a47064d07b46a Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 14:58:49 +0200 Subject: [PATCH 084/113] add padding to fit the memory layout As the layout on the CPU is in LayoutRight, the memory access was taking the false next index. Fixing that by adding the offset of sizeof(double)*3. --- src/Stream/InSitu/CatalystAdaptor.h | 41 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 390b35eca..6fe81188d 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -38,7 +38,6 @@ namespace CatalystAdaptor { node["density/volume_dependent"].set("false"); node["density/values"].set_external(view.data(), view.size()); } - void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; for (int cc = 1; cc < argc; ++cc) { @@ -155,9 +154,20 @@ namespace CatalystAdaptor { template void Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle) { - auto particle_view = particle->q.getView(); auto layout_view = particle->R.getView(); +// std::cout << "layout_view" << std::endl; +// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { +// std::cout << "i " << i << " data " << layout_view.data()[i][0] << " " +// << layout_view.data()[i][1] << " " << layout_view.data()[i][2] << std::endl; +// } +// +// std::cout << "velocity_view" << std::endl; +// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { +// std::cout << "i " << i << " data " << velocity_view.data()[i][0] << " " +// << velocity_view.data()[i][1] << " " << velocity_view.data()[i][2] << std::endl; +// } + conduit_cpp::Node node; // add time/cycle information @@ -174,21 +184,18 @@ namespace CatalystAdaptor { mesh["coordsets/coords/type"].set("explicit"); // number of points in specific dimension - std::string particle_node_dim{"coordsets/coords/values/x"}; - - for (unsigned int iDim = 0; iDim < 3; ++iDim) { - mesh[particle_node_dim].set_external(&layout_view.data()[0][iDim], std::size(layout_view), 0, 1); + // std::string particle_node_dim{"coordsets/coords/values/x"}; - // increment last char in string - ++particle_node_dim.back(); - } + mesh["coordsets/coords/values/x"].set(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/y"].set(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/z"].set(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum(),0); - std::cout << "Size of layout view from rank: " << rank << " " << particle->getLocalNum() << std::endl; - std::cout << "Size of particle view from rank: " << rank << " " << particle->getLocalNum() << std::endl; +// std::cout << "Size of layout view from rank: " << rank << " " << particle->getLocalNum() << std::endl; +// std::cout << "Size of particle view from rank: " << rank << " " << particle->getLocalNum() << std::endl; auto charge_view = particle->q.getView(); // add values and subscribe to data @@ -202,9 +209,15 @@ namespace CatalystAdaptor { fields["velocity/association"].set("vertex"); fields["velocity/topology"].set("mesh"); fields["velocity/volume_dependent"].set("false"); - fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,1); - fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,1); - fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,1); + fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,sizeof(double)*3); + +// std::cout << "velocity_view" << std::endl; +// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { +// std::cout << "i " << i << " data " << &velocity_view.data()[i][0] << " " +// << &velocity_view.data()[i][1] << " " << &velocity_view.data()[i][2] << std::endl; +// } // print node to have visual representation if (cycle == 0) From 23b3bcd28f9b26aedb146da5142a9aa79fd5c2e7 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 15:30:51 +0200 Subject: [PATCH 085/113] add adios_initialize function copied from example --- src/Stream/InSitu/CatalystAdaptor.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 6fe81188d..f03599880 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -58,6 +58,29 @@ namespace CatalystAdaptor { } } + void Initialize_Adios(int argc, char* argv[]) + { + conduit_cpp::Node node; + for (int cc = 1; cc < argc; ++cc) + { + if (strstr(argv[cc], "xml")) + { + node["adios/config_filepath"].set_string(argv[cc]); + } + else + { + node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); + } + } + node["catalyst_load/implementation"] = "adios"; + catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) + { + std::cerr << "Failed to initialize Catalyst: " << err << std::endl; + } + } + + template void Execute(int cycle, double time, int rank, Field& field) { static_assert(Field::dimension == 3, "CatalystAdaptor only supports 3D"); @@ -193,7 +216,7 @@ namespace CatalystAdaptor { mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); - mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum(),0); + mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum()); // std::cout << "Size of layout view from rank: " << rank << " " << particle->getLocalNum() << std::endl; // std::cout << "Size of particle view from rank: " << rank << " " << particle->getLocalNum() << std::endl; From ee3e4767fda179d839f1cda87e5121c16b748c90 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 15:40:34 +0200 Subject: [PATCH 086/113] change set to set_external for coordset to have zero copy access --- src/Stream/InSitu/CatalystAdaptor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index f03599880..11e37e5dd 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -209,9 +209,9 @@ namespace CatalystAdaptor { // number of points in specific dimension // std::string particle_node_dim{"coordsets/coords/values/x"}; - mesh["coordsets/coords/values/x"].set(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/y"].set(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/z"].set(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); mesh["topologies/mesh/type"].set("unstructured"); mesh["topologies/mesh/coordset"].set("coords"); From b8e7d408bcfd947ba76cd88fa9a7eb551a1a60be Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 17:07:54 +0200 Subject: [PATCH 087/113] include adios file and minor changes From now on it might be possible to start PenningTrap with Adio. Further adaption of the different scripts might be needed. --- adios2.xml | 37 +++++++++++++++++++++++++++++ alpine/PenningTrap.cpp | 3 ++- src/Stream/InSitu/CatalystAdaptor.h | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 adios2.xml diff --git a/adios2.xml b/adios2.xml new file mode 100644 index 000000000..06d67f53d --- /dev/null +++ b/adios2.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 1e42a018a..e6dc7aef6 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -154,7 +154,8 @@ const char* TestName = "PenningTrap"; int main(int argc, char* argv[]) { static_assert(Dim == 3, "Penning trap must be 3D"); Ippl ippl(argc, argv); - CatalystAdaptor::Initialize(argc, argv); + //CatalystAdaptor::Initialize(argc, argv); + CatalystAdaptor::Initialize_Adios(argc, argv); Inform msg("PenningTrap"); Inform msg2all("PenningTrap", INFORM_ALL_NODES); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 11e37e5dd..6e772d178 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -72,7 +72,7 @@ namespace CatalystAdaptor { node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); } } - node["catalyst_load/implementation"] = "adios"; + node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { From 00e5c5cf78377af06bb7974918826f01cc41e79c Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 17:10:14 +0200 Subject: [PATCH 088/113] add dump particle script --- test/stream/dump_particle.py | 159 +++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 test/stream/dump_particle.py diff --git a/test/stream/dump_particle.py b/test/stream/dump_particle.py new file mode 100644 index 000000000..03b7e92ae --- /dev/null +++ b/test/stream/dump_particle.py @@ -0,0 +1,159 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView2 = CreateView('RenderView') +renderView2.ViewSize = [1720, 1139] +renderView2.AxesGrid = 'GridAxes3DActor' +renderView2.CenterOfRotation = [9.804884923241747, 10.012704247151916, 10.01700792908101] +renderView2.StereoType = 'Crystal Eyes' +renderView2.CameraPosition = [9.833472138391965, 45.641676508112624, 45.111379125579965] +renderView2.CameraFocalPoint = [9.80488492324174, 10.012704247151918, 10.017007929080998] +renderView2.CameraViewUp = [0.17019906212718153, 0.6914337430282927, -0.7021051618190204] +renderView2.CameraFocalDisk = 1.0 +renderView2.CameraParallelScale = 19.234082152722095 +renderView2.BackEnd = 'OSPRay raycaster' +renderView2.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView2) +layout1.SetSize(1720, 1139) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView2) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_particle = PVTrivialProducer(registrationName='ippl_particle') + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView2' +# ---------------------------------------------------------------- + +# show data from ippl_particle +ippl_particleDisplay = Show(ippl_particle, renderView2, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'velocity' +velocityTF2D = GetTransferFunction2D('velocity') + +# get color transfer function/color map for 'velocity' +velocityLUT = GetColorTransferFunction('velocity') +velocityLUT.TransferFunction2D = velocityTF2D +velocityLUT.RGBPoints = [0.05045547731616287, 0.231373, 0.298039, 0.752941, 2.390862497557854, 0.865003, 0.865003, 0.865003, 4.731269517799545, 0.705882, 0.0156863, 0.14902] +velocityLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'velocity' +velocityPWF = GetOpacityTransferFunction('velocity') +velocityPWF.Points = [0.05045547731616287, 0.0, 0.5, 0.0, 4.731269517799545, 1.0, 0.5, 0.0] +velocityPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_particleDisplay.Representation = 'Point Gaussian' +ippl_particleDisplay.ColorArrayName = ['POINTS', 'velocity'] +ippl_particleDisplay.LookupTable = velocityLUT +ippl_particleDisplay.SelectTCoordArray = 'None' +ippl_particleDisplay.SelectNormalArray = 'None' +ippl_particleDisplay.SelectTangentArray = 'None' +ippl_particleDisplay.OSPRayScaleArray = 'charge' +ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_particleDisplay.SelectOrientationVectors = 'None' +ippl_particleDisplay.ScaleFactor = 1.9956522745753908 +ippl_particleDisplay.SelectScaleArray = 'None' +ippl_particleDisplay.GlyphType = 'Arrow' +ippl_particleDisplay.GlyphTableIndexArray = 'None' +ippl_particleDisplay.GaussianRadius = 0.09978261372876954 +ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] +ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] +ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_particleDisplay.ScalarOpacityFunction = velocityPWF +ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 +ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] +ippl_particleDisplay.SelectInputVectors = ['POINTS', 'velocity'] +ippl_particleDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for velocityLUT in view renderView2 +velocityLUTColorBar = GetScalarBar(velocityLUT, renderView2) +velocityLUTColorBar.Title = 'velocity' +velocityLUTColorBar.ComponentTitle = 'Magnitude' + +# set color bar visibility +velocityLUTColorBar.Visibility = 1 + +# show color legend +ippl_particleDisplay.SetScalarBarVisibility(renderView2, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [1720, 1139] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(ippl_particle) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) + print("yeah") From 895df6a1e2424fa5d289227252c51c60e7fa6ebd Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 19:27:05 +0200 Subject: [PATCH 089/113] add upper method to call both field and particle at once * still work in progress first version that compiles and produces some output --- alpine/PenningTrap.cpp | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 59 ++++++++++++++++++++--------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index e6dc7aef6..efb15d678 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -398,7 +398,7 @@ int main(int argc, char* argv[]) { IpplTimings::stopTimer(SolveTimer); // CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->rho_m); - CatalystAdaptor::Execute_Particle(it, P->time_m, Ippl::Comm->rank(), P); + CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); // gather E field P->gatherCIC(); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 6e772d178..0e74e3d4d 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "Utility/IpplException.h" @@ -38,6 +39,18 @@ namespace CatalystAdaptor { node["density/volume_dependent"].set("false"); node["density/values"].set_external(view.data(), view.size()); } + + void callCatalystExecute(conduit_cpp::Node& node) { + // print node to have visual representation + // if (cycle == 0) + //catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); + if (err != catalyst_status_ok) { + std::cerr << "Failed to execute Catalyst: " << err << std::endl; + } + } + void Initialize(int argc, char* argv[]) { conduit_cpp::Node node; for (int cc = 1; cc < argc; ++cc) { @@ -58,6 +71,7 @@ namespace CatalystAdaptor { } } + void Initialize_Adios(int argc, char* argv[]) { conduit_cpp::Node node; @@ -69,7 +83,7 @@ namespace CatalystAdaptor { } else { - node["catalyst/scripts/script" + std::to_string(cc - 1)].set_string(argv[cc]); + node["catalyst/scripts/script" +std::to_string(cc - 1)].set_string(argv[cc]); } } node["catalyst_load/implementation"] = getenv("CATALYST_IMPLEMENTATION_NAME"); @@ -82,13 +96,16 @@ namespace CatalystAdaptor { template - void Execute(int cycle, double time, int rank, Field& field) { + std::optional Execute(int cycle, double time, int rank, Field& field, std::optional& node_in) { static_assert(Field::dimension == 3, "CatalystAdaptor only supports 3D"); // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html // // conduit blueprint definition (v.8.3) // https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html + conduit_cpp::Node node; + if (node_in) + node = node_in.value(); auto nGhost = field.getNghost(); @@ -109,7 +126,6 @@ namespace CatalystAdaptor { } } - conduit_cpp::Node node; // add time/cycle information auto state = node["catalyst/state"]; @@ -164,18 +180,19 @@ namespace CatalystAdaptor { setData(fields, host_view_layout_left); - // print node to have visual representation - if (cycle == 0) - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - - catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) { - std::cerr << "Failed to execute Catalyst: " << err << std::endl; + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + if (node_in == std::nullopt) + { + callCatalystExecute(node); + return {}; } + else + return node; + } template - void Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle) { + void Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle, std::optional& node_in) { auto layout_view = particle->R.getView(); @@ -192,6 +209,8 @@ namespace CatalystAdaptor { // } conduit_cpp::Node node; + if (node_in) + node = node_in.value(); // add time/cycle information auto state = node["catalyst/state"]; @@ -242,14 +261,20 @@ namespace CatalystAdaptor { // << &velocity_view.data()[i][1] << " " << &velocity_view.data()[i][2] << std::endl; // } - // print node to have visual representation - if (cycle == 0) + // if (node_in == std::nullopt) catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + callCatalystExecute(node); - catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); - if (err != catalyst_status_ok) { - std::cerr << "Failed to execute Catalyst: " << err << std::endl; - } + } + + + template + void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ChargedParticles& particle) { + //conduit_cpp::Node node; + auto node = std::make_optional(); + auto node_1 = CatalystAdaptor::Execute(cycle, time, rank, field, node); + CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node_1); + //callCatalystExecute(node.value()); } From ed58383d3593986a90004697b9f1a3d3221f9bd0 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 19:44:18 +0200 Subject: [PATCH 090/113] update script to extract both particles and field --- alpine/PenningTrap.cpp | 2 +- test/stream/dump_field_vtpd.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index efb15d678..b6ce4545d 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -398,7 +398,7 @@ int main(int argc, char* argv[]) { IpplTimings::stopTimer(SolveTimer); // CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->rho_m); - CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); + CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->E_m, P); // gather E field P->gatherCIC(); diff --git a/test/stream/dump_field_vtpd.py b/test/stream/dump_field_vtpd.py index be6e859b5..ad462db50 100644 --- a/test/stream/dump_field_vtpd.py +++ b/test/stream/dump_field_vtpd.py @@ -12,12 +12,12 @@ # create a new 'PVTrivialProducer' ippl_field = PVTrivialProducer(registrationName='ippl_field') +ippl_particle = PVTrivialProducer(registrationName='ippl_particle') # ---------------------------------------------------------------- # setup extractors # ---------------------------------------------------------------- -# create extractor vTPD1 = CreateExtractor('VTPD', ippl_field, registrationName='VTPD1') # trace defaults for the extractor. vTPD1.Trigger = 'TimeStep' @@ -30,6 +30,22 @@ SetActiveSource(vTPD1) # ---------------------------------------------------------------- +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +vTPD2 = CreateExtractor('VTPD', ippl_particle, registrationName='VTPD2') +# trace defaults for the extractor. +vTPD2.Trigger = 'TimeStep' + +# init the 'VTPD' selected for 'Writer' +vTPD2.Writer.FileName = 'ippl_particle_{timestep:06d}.vtpd' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(vTPD1) +# ---------------------------------------------------------------- + # ------------------------------------------------------------------------------ # Catalyst options from paraview import catalyst From ef82ad21b9082c9aec289c766191cbd5fe71e83a Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 20:28:58 +0200 Subject: [PATCH 091/113] add optional return of node to catalyst execute functions * further reorder the execute parameter as the field uses only a local memory this one is called last --- src/Stream/InSitu/CatalystAdaptor.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 0e74e3d4d..4bd0f188a 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,7 +43,7 @@ namespace CatalystAdaptor { void callCatalystExecute(conduit_cpp::Node& node) { // print node to have visual representation // if (cycle == 0) - //catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { @@ -180,7 +180,7 @@ namespace CatalystAdaptor { setData(fields, host_view_layout_left); - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); if (node_in == std::nullopt) { callCatalystExecute(node); @@ -192,7 +192,7 @@ namespace CatalystAdaptor { } template - void Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle, std::optional& node_in) { + std::optional Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle, std::optional& node_in) { auto layout_view = particle->R.getView(); @@ -260,11 +260,14 @@ namespace CatalystAdaptor { // std::cout << "i " << i << " data " << &velocity_view.data()[i][0] << " " // << &velocity_view.data()[i][1] << " " << &velocity_view.data()[i][2] << std::endl; // } - - // if (node_in == std::nullopt) - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + if (node_in == std::nullopt) + { callCatalystExecute(node); - + return {}; + } + else + return node; } @@ -272,8 +275,8 @@ namespace CatalystAdaptor { void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ChargedParticles& particle) { //conduit_cpp::Node node; auto node = std::make_optional(); - auto node_1 = CatalystAdaptor::Execute(cycle, time, rank, field, node); - CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node_1); + auto node_1 = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); + CatalystAdaptor::Execute(cycle, time, rank, field, node_1); //callCatalystExecute(node.value()); } From db6d5982a6406f7e8ab327c17ad09a940dd3c796 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 28 Sep 2023 20:32:00 +0200 Subject: [PATCH 092/113] rename Execute to Execute_Field to have it better clarified --- alpine/PenningTrap.cpp | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 4 ++-- test/stream/TestCatalystAdaptor.cpp | 2 +- test/stream/TestCatalystAdaptor_2D.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index b6ce4545d..b00eee566 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -397,7 +397,7 @@ int main(int argc, char* argv[]) { P->runSolver(); IpplTimings::stopTimer(SolveTimer); - // CatalystAdaptor::Execute(it, P->time_m, Ippl::Comm->rank(), P->rho_m); + // CatalystAdaptor::Execute_Field(it, P->time_m, Ippl::Comm->rank(), P->rho_m); CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->E_m, P); // gather E field diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 4bd0f188a..30ad04249 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -96,7 +96,7 @@ namespace CatalystAdaptor { template - std::optional Execute(int cycle, double time, int rank, Field& field, std::optional& node_in) { + std::optional Execute_Field(int cycle, double time, int rank, Field& field, std::optional& node_in) { static_assert(Field::dimension == 3, "CatalystAdaptor only supports 3D"); // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html @@ -276,7 +276,7 @@ namespace CatalystAdaptor { //conduit_cpp::Node node; auto node = std::make_optional(); auto node_1 = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); - CatalystAdaptor::Execute(cycle, time, rank, field, node_1); + CatalystAdaptor::Execute_Field(cycle, time, rank, field, node_1); //callCatalystExecute(node.value()); } diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 7d12cb7d5..13ed21d10 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) { view(i, j, k) = y * time; }); - CatalystAdaptor::Execute(it, time, Ippl::Comm->rank(), field); + CatalystAdaptor::Execute_Field(it, time, Ippl::Comm->rank(), field); // print should be same as field data time += dt; diff --git a/test/stream/TestCatalystAdaptor_2D.cpp b/test/stream/TestCatalystAdaptor_2D.cpp index 794fb9390..aaaf2c52c 100644 --- a/test/stream/TestCatalystAdaptor_2D.cpp +++ b/test/stream/TestCatalystAdaptor_2D.cpp @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { // std::cout << view(i,j) << std::endl; }); - CatalystAdaptor::Execute(it, time, ippl.Comm.get()->rank(), field); // field + CatalystAdaptor::Execute_Field(it, time, ippl.Comm.get()->rank(), field); // field // print should be same as field data time += dt; } From 13887f7054cfcf9390f21f27d1e934fdc13d6345 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 29 Sep 2023 11:04:36 +0200 Subject: [PATCH 093/113] change position of catalyst adaptor to extract both density field and particles --- alpine/ChargedParticles.hpp | 2 ++ alpine/PenningTrap.cpp | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 651fb5860..c4b1c8397 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -383,10 +383,12 @@ class ChargedParticles : public ippl::ParticleBase { IpplTimings::stopTimer(sumTimer); // dumpVTK(E_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); + //CatalystAdaptor::Execute_Field_Particle(iteration, time_m, Ippl::Comm->rank(), rho_m, this); // rho = rho_e - rho_i double size = 1; for (unsigned d = 0; d < Dim; d++) { + size *= rmax_m[d] - rmin_m[d]; } rho_m = rho_m - (Q_m / size); diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index b00eee566..b487df9ef 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -392,13 +392,13 @@ int main(int argc, char* argv[]) { // scatter the charge onto the underlying grid P->scatterCIC(totalP, it + 1, hr); + CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); // Field solve IpplTimings::startTimer(SolveTimer); P->runSolver(); IpplTimings::stopTimer(SolveTimer); // CatalystAdaptor::Execute_Field(it, P->time_m, Ippl::Comm->rank(), P->rho_m); - CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->E_m, P); // gather E field P->gatherCIC(); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 30ad04249..9dd855224 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,7 +43,7 @@ namespace CatalystAdaptor { void callCatalystExecute(conduit_cpp::Node& node) { // print node to have visual representation // if (cycle == 0) - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { @@ -181,7 +181,7 @@ namespace CatalystAdaptor { setData(fields, host_view_layout_left); // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - if (node_in == std::nullopt) + if (node_in != std::nullopt) { callCatalystExecute(node); return {}; @@ -275,8 +275,8 @@ namespace CatalystAdaptor { void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ChargedParticles& particle) { //conduit_cpp::Node node; auto node = std::make_optional(); - auto node_1 = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); - CatalystAdaptor::Execute_Field(cycle, time, rank, field, node_1); + node = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); + node = CatalystAdaptor::Execute_Field(cycle, time, rank, field, node); //callCatalystExecute(node.value()); } From a61ef6437f5f60d68939120aa87ce1f43b8fe2b6 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 29 Sep 2023 13:47:37 +0200 Subject: [PATCH 094/113] cleanup CatalystAdaptor * remove commented out code * add positions for rho_m and E_m to penning trap * add minor comments about why it is done like that --- alpine/ChargedParticles.hpp | 1 - alpine/PenningTrap.cpp | 5 ++- src/Stream/InSitu/CatalystAdaptor.h | 61 +++++++++++------------------ 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index c4b1c8397..ff945b369 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -383,7 +383,6 @@ class ChargedParticles : public ippl::ParticleBase { IpplTimings::stopTimer(sumTimer); // dumpVTK(E_m,nr_m[0],nr_m[1],nr_m[2],iteration,hrField[0],hrField[1],hrField[2]); - //CatalystAdaptor::Execute_Field_Particle(iteration, time_m, Ippl::Comm->rank(), rho_m, this); // rho = rho_e - rho_i double size = 1; diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index b487df9ef..72dfaa4eb 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -392,13 +392,16 @@ int main(int argc, char* argv[]) { // scatter the charge onto the underlying grid P->scatterCIC(totalP, it + 1, hr); + // here is the position where we can access the density field CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); + // Field solve IpplTimings::startTimer(SolveTimer); P->runSolver(); IpplTimings::stopTimer(SolveTimer); - // CatalystAdaptor::Execute_Field(it, P->time_m, Ippl::Comm->rank(), P->rho_m); + // here is the position where we can access the electrostatic field + // CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->E_m, P); // gather E field P->gatherCIC(); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 9dd855224..c7c528ed3 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -37,14 +37,13 @@ namespace CatalystAdaptor { node["density/association"].set("element"); node["density/topology"].set("mesh"); node["density/volume_dependent"].set("false"); + node["density/values"].set_external(view.data(), view.size()); } - void callCatalystExecute(conduit_cpp::Node& node) { - // print node to have visual representation - // if (cycle == 0) - // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + void callCatalystExecute(const conduit_cpp::Node& node) { + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { std::cerr << "Failed to execute Catalyst: " << err << std::endl; @@ -147,13 +146,15 @@ namespace CatalystAdaptor { std::string field_node_spacing{"coordsets/coords/spacing/dx"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { + // add dimension mesh[field_node_dim].set(field.getLayout().getLocalNDIndex()[iDim].length() + 1); - // shift origin by one ghost cell + // add origin mesh[field_node_origin].set( - field.get_mesh().getOrigin()[iDim] // global origin - + field.getLayout().getLocalNDIndex()[iDim].first() - * field.get_mesh().getMeshSpacing(iDim)); // shift to local index + field.get_mesh().getOrigin()[iDim] + field.getLayout().getLocalNDIndex()[iDim].first() + * field.get_mesh().getMeshSpacing(iDim)); + + // add spacing mesh[field_node_spacing].set(field.get_mesh().getMeshSpacing(iDim)); // increment last char in string @@ -165,22 +166,23 @@ namespace CatalystAdaptor { // add topology mesh["topologies/mesh/type"].set("uniform"); mesh["topologies/mesh/coordset"].set("coords"); - std::string field_node_origin_topo = "topologies/mesh/origin/x"; + std::string field_node_origin_topo{"topologies/mesh/origin/x"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // shift origin mesh[field_node_origin_topo].set(field.get_mesh().getOrigin()[iDim] + field.getLayout().getLocalNDIndex()[iDim].first() * field.get_mesh().getMeshSpacing(iDim)); + // increment last char in string ++field_node_origin_topo.back(); } // add values and subscribe to data auto fields = mesh["fields"]; - setData(fields, host_view_layout_left); - // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // as we have a local copy of the field, the catalyst_execute needs to be called + // within this scope otherwise the memory location might be already overwritten if (node_in != std::nullopt) { callCatalystExecute(node); @@ -196,18 +198,7 @@ namespace CatalystAdaptor { auto layout_view = particle->R.getView(); -// std::cout << "layout_view" << std::endl; -// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { -// std::cout << "i " << i << " data " << layout_view.data()[i][0] << " " -// << layout_view.data()[i][1] << " " << layout_view.data()[i][2] << std::endl; -// } -// -// std::cout << "velocity_view" << std::endl; -// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { -// std::cout << "i " << i << " data " << velocity_view.data()[i][0] << " " -// << velocity_view.data()[i][1] << " " << velocity_view.data()[i][2] << std::endl; -// } - + // if node is passed in, append data to it conduit_cpp::Node node; if (node_in) node = node_in.value(); @@ -218,6 +209,7 @@ namespace CatalystAdaptor { state["time"].set(time); state["domain_id"].set(rank); + // channel for particles auto channel = node["catalyst/channels/ippl_particle"]; channel["type"].set_string("mesh"); @@ -225,9 +217,6 @@ namespace CatalystAdaptor { auto mesh = channel["data"]; mesh["coordsets/coords/type"].set("explicit"); - // number of points in specific dimension - // std::string particle_node_dim{"coordsets/coords/values/x"}; - mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); @@ -236,31 +225,28 @@ namespace CatalystAdaptor { mesh["topologies/mesh/coordset"].set("coords"); mesh["topologies/mesh/elements/shape"].set("point"); mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum()); -// std::cout << "Size of layout view from rank: " << rank << " " << particle->getLocalNum() << std::endl; -// std::cout << "Size of particle view from rank: " << rank << " " << particle->getLocalNum() << std::endl; auto charge_view = particle->q.getView(); - // add values and subscribe to data + + // add values for scalar charge field auto fields = mesh["fields"]; fields["charge/association"].set("vertex"); fields["charge/topology"].set("mesh"); fields["charge/volume_dependent"].set("false"); + fields["charge/values"].set_external(charge_view.data(), particle->getLocalNum()); + // add values for vector velocity field auto velocity_view = particle->P.getView(); fields["velocity/association"].set("vertex"); fields["velocity/topology"].set("mesh"); fields["velocity/volume_dependent"].set("false"); + fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,sizeof(double)*3); fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,sizeof(double)*3); fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,sizeof(double)*3); -// std::cout << "velocity_view" << std::endl; -// for (long unsigned int i = 0; i < particle->getLocalNum(); ++i) { -// std::cout << "i " << i << " data " << &velocity_view.data()[i][0] << " " -// << &velocity_view.data()[i][1] << " " << &velocity_view.data()[i][2] << std::endl; -// } - // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // this node we can return as the pointer to velocity and charge is globally valid if (node_in == std::nullopt) { callCatalystExecute(node); @@ -273,11 +259,10 @@ namespace CatalystAdaptor { template void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ChargedParticles& particle) { - //conduit_cpp::Node node; + auto node = std::make_optional(); node = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); - node = CatalystAdaptor::Execute_Field(cycle, time, rank, field, node); - //callCatalystExecute(node.value()); + CatalystAdaptor::Execute_Field(cycle, time, rank, field, node); } From 6bc5d8f7c66f5f5a059a4ef28c1c92a09a56374e Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 29 Sep 2023 14:04:39 +0200 Subject: [PATCH 095/113] add guard to print node information only once --- src/Stream/InSitu/CatalystAdaptor.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index c7c528ed3..d4f3bebd6 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -43,7 +43,11 @@ namespace CatalystAdaptor { void callCatalystExecute(const conduit_cpp::Node& node) { - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + // TODO: we should add here this IPPL-INFO stuff + if ( static auto called {false}; !std::exchange(called, true) ) { + catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + } + catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { std::cerr << "Failed to execute Catalyst: " << err << std::endl; From 012fe6da07ec5bca9fe0b2dbc67bdb3ee41df79d Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 29 Sep 2023 14:17:58 +0200 Subject: [PATCH 096/113] add test script for running ont he cluster and extracting field as particles --- test2_png.py | 276 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 test2_png.py diff --git a/test2_png.py b/test2_png.py new file mode 100644 index 000000000..7372cd98c --- /dev/null +++ b/test2_png.py @@ -0,0 +1,276 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [2169, 1139] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [10.0, 10.0, 10.0] +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [47.29585541750492, 44.99428098019204, 53.161098647260886] +renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] +renderView1.CameraViewUp = [-0.33836890260180724, 0.8523744266916093, -0.3987033013083779] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 17.320508075688775 +renderView1.BackEnd = 'OSPRay raycaster' +renderView1.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(2169, 1139) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_particle = PVTrivialProducer(registrationName='ippl_particle') + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# create a new 'Ghost Cells Generator' +ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) + +# create a new 'Cell Data to Point Data' +cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ghostCellsGenerator1) +cellDatatoPointData1.CellDataArraytoprocess = ['vtkGhostType', 'density', 'vtkGhostType'] + +# create a new 'Contour' +contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) +contour1.ContourBy = ['POINTS', 'density'] +contour1.Isosurfaces = [-2.598547365298835, -5.39240723059767, -4.771549482753485, -4.150691734909299, -3.5298339870651136, -2.908976239220928, -2.2881184913767423, -1.667260743532557, -1.0464029956883714, -0.4255452478441857, 0.1953125] +contour1.PointMergeMethod = 'Uniform Binning' + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from ippl_particle +ippl_particleDisplay = Show(ippl_particle, renderView1, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'velocity' +velocityTF2D = GetTransferFunction2D('velocity') + +# get color transfer function/color map for 'velocity' +velocityLUT = GetColorTransferFunction('velocity') +velocityLUT.TransferFunction2D = velocityTF2D +velocityLUT.RGBPoints = [0.05045547731616287, 0.231373, 0.298039, 0.752941, 2.8507787375282088, 0.865003, 0.865003, 0.865003, 5.651101997740255, 0.705882, 0.0156863, 0.14902] +velocityLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'velocity' +velocityPWF = GetOpacityTransferFunction('velocity') +velocityPWF.Points = [0.05045547731616287, 0.0, 0.5, 0.0, 5.651101997740255, 1.0, 0.5, 0.0] +velocityPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_particleDisplay.Representation = 'Point Gaussian' +ippl_particleDisplay.ColorArrayName = ['POINTS', 'velocity'] +ippl_particleDisplay.LookupTable = velocityLUT +ippl_particleDisplay.SelectTCoordArray = 'None' +ippl_particleDisplay.SelectNormalArray = 'None' +ippl_particleDisplay.SelectTangentArray = 'None' +ippl_particleDisplay.OSPRayScaleArray = 'charge' +ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_particleDisplay.SelectOrientationVectors = 'None' +ippl_particleDisplay.ScaleFactor = 1.9956522745753908 +ippl_particleDisplay.SelectScaleArray = 'None' +ippl_particleDisplay.GlyphType = 'Arrow' +ippl_particleDisplay.GlyphTableIndexArray = 'None' +ippl_particleDisplay.GaussianRadius = 0.15 +ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] +ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] +ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_particleDisplay.ScalarOpacityFunction = velocityPWF +ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 +ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] +ippl_particleDisplay.SelectInputVectors = ['POINTS', 'velocity'] +ippl_particleDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# show data from ghostCellsGenerator1 +ghostCellsGenerator1Display = Show(ghostCellsGenerator1, renderView1, 'UniformGridRepresentation') + +# trace defaults for the display properties. +ghostCellsGenerator1Display.Representation = 'Outline' +ghostCellsGenerator1Display.ColorArrayName = [None, ''] +ghostCellsGenerator1Display.SelectTCoordArray = 'None' +ghostCellsGenerator1Display.SelectNormalArray = 'None' +ghostCellsGenerator1Display.SelectTangentArray = 'None' +ghostCellsGenerator1Display.OSPRayScaleArray = 'vtkGhostType' +ghostCellsGenerator1Display.OSPRayScaleFunction = 'PiecewiseFunction' +ghostCellsGenerator1Display.SelectOrientationVectors = 'None' +ghostCellsGenerator1Display.ScaleFactor = 2.0 +ghostCellsGenerator1Display.SelectScaleArray = 'None' +ghostCellsGenerator1Display.GlyphType = 'Arrow' +ghostCellsGenerator1Display.GlyphTableIndexArray = 'None' +ghostCellsGenerator1Display.GaussianRadius = 0.1 +ghostCellsGenerator1Display.SetScaleArray = ['POINTS', 'vtkGhostType'] +ghostCellsGenerator1Display.ScaleTransferFunction = 'PiecewiseFunction' +ghostCellsGenerator1Display.OpacityArray = ['POINTS', 'vtkGhostType'] +ghostCellsGenerator1Display.OpacityTransferFunction = 'PiecewiseFunction' +ghostCellsGenerator1Display.DataAxesGrid = 'GridAxesRepresentation' +ghostCellsGenerator1Display.PolarAxes = 'PolarAxesRepresentation' +ghostCellsGenerator1Display.ScalarOpacityUnitDistance = 2.165063509461097 +ghostCellsGenerator1Display.OpacityArrayName = ['POINTS', 'vtkGhostType'] +ghostCellsGenerator1Display.ColorArray2Name = ['POINTS', 'vtkGhostType'] +ghostCellsGenerator1Display.SliceFunction = 'Plane' +ghostCellsGenerator1Display.Slice = 8 +ghostCellsGenerator1Display.SelectInputVectors = [None, ''] +ghostCellsGenerator1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ghostCellsGenerator1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ghostCellsGenerator1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0] + +# init the 'Plane' selected for 'SliceFunction' +ghostCellsGenerator1Display.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from contour1 +contour1Display = Show(contour1, renderView1, 'GeometryRepresentation') + +# get 2D transfer function for 'density' +densityTF2D = GetTransferFunction2D('density') +densityTF2D.ScalarRangeInitialized = 1 +densityTF2D.Range = [-5.39240723059767, 0.1953125, 0.0, 1.0] + +# get color transfer function/color map for 'density' +densityLUT = GetColorTransferFunction('density') +densityLUT.TransferFunction2D = densityTF2D +densityLUT.RGBPoints = [-5.962676343529195, 0.231373, 0.298039, 0.752941, -2.8836819217645977, 0.865003, 0.865003, 0.865003, 0.1953125, 0.705882, 0.0156863, 0.14902] +densityLUT.ScalarRangeInitialized = 1.0 + +# trace defaults for the display properties. +contour1Display.Representation = 'Surface' +contour1Display.ColorArrayName = ['POINTS', 'density'] +contour1Display.LookupTable = densityLUT +contour1Display.Opacity = 0.5 +contour1Display.SelectTCoordArray = 'None' +contour1Display.SelectNormalArray = 'Normals' +contour1Display.SelectTangentArray = 'None' +contour1Display.OSPRayScaleArray = 'density' +contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' +contour1Display.SelectOrientationVectors = 'None' +contour1Display.ScaleFactor = 0.9665217399597168 +contour1Display.SelectScaleArray = 'density' +contour1Display.GlyphType = 'Arrow' +contour1Display.GlyphTableIndexArray = 'density' +contour1Display.GaussianRadius = 0.048326086997985844 +contour1Display.SetScaleArray = ['POINTS', 'density'] +contour1Display.ScaleTransferFunction = 'PiecewiseFunction' +contour1Display.OpacityArray = ['POINTS', 'density'] +contour1Display.OpacityTransferFunction = 'PiecewiseFunction' +contour1Display.DataAxesGrid = 'GridAxesRepresentation' +contour1Display.PolarAxes = 'PolarAxesRepresentation' +contour1Display.SelectInputVectors = ['POINTS', 'Normals'] +contour1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +contour1Display.ScaleTransferFunction.Points = [-2.5985474586486816, 0.0, 0.5, 0.0, -2.5980591773986816, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +contour1Display.OpacityTransferFunction.Points = [-2.5985474586486816, 0.0, 0.5, 0.0, -2.5980591773986816, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for densityLUT in view renderView1 +densityLUTColorBar = GetScalarBar(densityLUT, renderView1) +densityLUTColorBar.Title = 'density' +densityLUTColorBar.ComponentTitle = '' + +# set color bar visibility +densityLUTColorBar.Visibility = 1 + +# get color legend/bar for velocityLUT in view renderView1 +velocityLUTColorBar = GetScalarBar(velocityLUT, renderView1) +velocityLUTColorBar.WindowLocation = 'Upper Right Corner' +velocityLUTColorBar.Title = 'velocity' +velocityLUTColorBar.ComponentTitle = 'Magnitude' + +# set color bar visibility +velocityLUTColorBar.Visibility = 1 + +# show color legend +ippl_particleDisplay.SetScalarBarVisibility(renderView1, True) + +# show color legend +contour1Display.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# get opacity transfer function/opacity map for 'density' +densityPWF = GetOpacityTransferFunction('density') +densityPWF.Points = [-5.962676343529195, 0.0, 0.5, 0.0, 0.1953125, 1.0, 0.5, 0.0] +densityPWF.ScalarRangeInitialized = 1 + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [1920, 1080] +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(contour1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From e58961796441003784346eebba80fe6aad6e418b Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 4 Oct 2023 14:43:09 +0200 Subject: [PATCH 097/113] change est to set_string to allow the constant reference --- src/Stream/InSitu/CatalystAdaptor.h | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index d4f3bebd6..d5276431c 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -19,9 +19,9 @@ namespace CatalystAdaptor { using View_vector = Kokkos::View***, Kokkos::LayoutLeft, Kokkos::HostSpace>; void setData(conduit_cpp::Node& node, const View_vector& view) { - node["electrostatic/association"].set("element"); - node["electrostatic/topology"].set("mesh"); - node["electrostatic/volume_dependent"].set("false"); + node["electrostatic/association"].set_string("element"); + node["electrostatic/topology"].set_string("mesh"); + node["electrostatic/volume_dependent"].set_string("false"); auto length = std::size(view); @@ -34,9 +34,9 @@ namespace CatalystAdaptor { using View_scalar = Kokkos::View; void setData(conduit_cpp::Node& node, const View_scalar& view) { - node["density/association"].set("element"); - node["density/topology"].set("mesh"); - node["density/volume_dependent"].set("false"); + node["density/association"].set_string("element"); + node["density/topology"].set_string("mesh"); + node["density/volume_dependent"].set_string("false"); node["density/values"].set_external(view.data(), view.size()); } @@ -142,7 +142,7 @@ namespace CatalystAdaptor { // in data channel now we adhere to conduits mesh blueprint definition auto mesh = channel["data"]; - mesh["coordsets/coords/type"].set("uniform"); + mesh["coordsets/coords/type"].set_string("uniform"); // number of points in specific dimension std::string field_node_dim{"coordsets/coords/dims/i"}; @@ -168,8 +168,8 @@ namespace CatalystAdaptor { } // add topology - mesh["topologies/mesh/type"].set("uniform"); - mesh["topologies/mesh/coordset"].set("coords"); + mesh["topologies/mesh/type"].set_string("uniform"); + mesh["topologies/mesh/coordset"].set_string("coords"); std::string field_node_origin_topo{"topologies/mesh/origin/x"}; for (unsigned int iDim = 0; iDim < field.get_mesh().getGridsize().dim; ++iDim) { // shift origin @@ -219,32 +219,32 @@ namespace CatalystAdaptor { // in data channel now we adhere to conduits mesh blueprint definition auto mesh = channel["data"]; - mesh["coordsets/coords/type"].set("explicit"); + mesh["coordsets/coords/type"].set_string("explicit"); mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); - mesh["topologies/mesh/type"].set("unstructured"); - mesh["topologies/mesh/coordset"].set("coords"); - mesh["topologies/mesh/elements/shape"].set("point"); + mesh["topologies/mesh/type"].set_string("unstructured"); + mesh["topologies/mesh/coordset"].set_string("coords"); + mesh["topologies/mesh/elements/shape"].set_string("point"); mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum()); auto charge_view = particle->q.getView(); // add values for scalar charge field auto fields = mesh["fields"]; - fields["charge/association"].set("vertex"); - fields["charge/topology"].set("mesh"); - fields["charge/volume_dependent"].set("false"); + fields["charge/association"].set_string("vertex"); + fields["charge/topology"].set_string("mesh"); + fields["charge/volume_dependent"].set_string("false"); fields["charge/values"].set_external(charge_view.data(), particle->getLocalNum()); // add values for vector velocity field auto velocity_view = particle->P.getView(); - fields["velocity/association"].set("vertex"); - fields["velocity/topology"].set("mesh"); - fields["velocity/volume_dependent"].set("false"); + fields["velocity/association"].set_string("vertex"); + fields["velocity/topology"].set_string("mesh"); + fields["velocity/volume_dependent"].set_string("false"); fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,sizeof(double)*3); fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,sizeof(double)*3); From 6ae7a197a2bc1e079c5c4262437badb7be68e28c Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 5 Oct 2023 16:19:27 +0200 Subject: [PATCH 098/113] add position as a value for the adaptor for the particles --- src/Stream/InSitu/CatalystAdaptor.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index d5276431c..759bd7ceb 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -250,6 +250,15 @@ namespace CatalystAdaptor { fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,sizeof(double)*3); fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,sizeof(double)*3); + + fields["position/association"].set_string("vertex"); + fields["position/topology"].set_string("mesh"); + fields["position/volume_dependent"].set_string("false"); + + fields["position/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); + // this node we can return as the pointer to velocity and charge is globally valid if (node_in == std::nullopt) { From f869bd7cadf48cf5b199bc4b4ce975fd2a9000a2 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 10 Oct 2023 09:14:37 +0200 Subject: [PATCH 099/113] add pragma guard around CatalystCalls, cleanup header --- alpine/ChargedParticles.hpp | 1 - alpine/PenningTrap.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index ff945b369..401efbcf5 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -20,7 +20,6 @@ #include "Solver/ElectrostaticsCG.h" #include "Solver/FFTPeriodicPoissonSolver.h" -#include "Stream/InSitu/CatalystAdaptor.h" // some typedefs template diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 72dfaa4eb..fa5241d2b 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -36,15 +36,15 @@ #include #include #include -#include -#include #include -#include #include "Utility/IpplTimings.h" #include "ChargedParticles.hpp" + +#ifdef ENABLE_CATALYST #include "Stream/InSitu/CatalystAdaptor.h" +#endif constexpr unsigned Dim = 3; @@ -154,8 +154,10 @@ const char* TestName = "PenningTrap"; int main(int argc, char* argv[]) { static_assert(Dim == 3, "Penning trap must be 3D"); Ippl ippl(argc, argv); +#ifdef ENABLE_CATALYST //CatalystAdaptor::Initialize(argc, argv); CatalystAdaptor::Initialize_Adios(argc, argv); +#endif Inform msg("PenningTrap"); Inform msg2all("PenningTrap", INFORM_ALL_NODES); @@ -393,7 +395,9 @@ int main(int argc, char* argv[]) { P->scatterCIC(totalP, it + 1, hr); // here is the position where we can access the density field +#ifdef ENABLE_CATALYST CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); +#endif // Field solve IpplTimings::startTimer(SolveTimer); @@ -449,6 +453,8 @@ int main(int argc, char* argv[]) { std::chrono::duration_cast>(end - start); std::cout << "Elapsed time: " << time_chrono.count() << std::endl; +#ifdef ENABLE_CATALYST CatalystAdaptor::Finalize(); +#endif return 0; } From e2042ecc770235e6e986bf03d20a782118e7f232 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 17 Oct 2023 08:50:59 +0200 Subject: [PATCH 100/113] remove extractor scripts --- test/stream/dump_csv.py | 45 --- ...ld_vtpd.py => dump_field_particle_vtpd.py} | 0 test/stream/dump_particle.py | 159 ---------- test/stream/dump_particle_vtpd.py | 165 ----------- test/stream/extract3_penningtrap.py | 204 ------------- test/stream/extract_penningtrap.py | 235 --------------- test2_png.py | 276 ------------------ 7 files changed, 1084 deletions(-) delete mode 100644 test/stream/dump_csv.py rename test/stream/{dump_field_vtpd.py => dump_field_particle_vtpd.py} (100%) delete mode 100644 test/stream/dump_particle.py delete mode 100644 test/stream/dump_particle_vtpd.py delete mode 100644 test/stream/extract3_penningtrap.py delete mode 100644 test/stream/extract_penningtrap.py delete mode 100644 test2_png.py diff --git a/test/stream/dump_csv.py b/test/stream/dump_csv.py deleted file mode 100644 index 995c1274c..000000000 --- a/test/stream/dump_csv.py +++ /dev/null @@ -1,45 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'PVTrivialProducer' -ippl_field = PVTrivialProducer(registrationName='ippl_field') - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -cSV1 = CreateExtractor('CSV', ippl_field, registrationName='CSV1') -# trace defaults for the extractor. -cSV1.Trigger = 'TimeStep' - -# init the 'CSV' selected for 'Writer' -cSV1.Writer.FieldAssociation = 'Cell Data' - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(cSV1) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GlobalTrigger = 'TimeStep' -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) diff --git a/test/stream/dump_field_vtpd.py b/test/stream/dump_field_particle_vtpd.py similarity index 100% rename from test/stream/dump_field_vtpd.py rename to test/stream/dump_field_particle_vtpd.py diff --git a/test/stream/dump_particle.py b/test/stream/dump_particle.py deleted file mode 100644 index 03b7e92ae..000000000 --- a/test/stream/dump_particle.py +++ /dev/null @@ -1,159 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup views used in the visualization -# ---------------------------------------------------------------- - -# get the material library -materialLibrary1 = GetMaterialLibrary() - -# Create a new 'Render View' -renderView2 = CreateView('RenderView') -renderView2.ViewSize = [1720, 1139] -renderView2.AxesGrid = 'GridAxes3DActor' -renderView2.CenterOfRotation = [9.804884923241747, 10.012704247151916, 10.01700792908101] -renderView2.StereoType = 'Crystal Eyes' -renderView2.CameraPosition = [9.833472138391965, 45.641676508112624, 45.111379125579965] -renderView2.CameraFocalPoint = [9.80488492324174, 10.012704247151918, 10.017007929080998] -renderView2.CameraViewUp = [0.17019906212718153, 0.6914337430282927, -0.7021051618190204] -renderView2.CameraFocalDisk = 1.0 -renderView2.CameraParallelScale = 19.234082152722095 -renderView2.BackEnd = 'OSPRay raycaster' -renderView2.OSPRayMaterialLibrary = materialLibrary1 - -SetActiveView(None) - -# ---------------------------------------------------------------- -# setup view layouts -# ---------------------------------------------------------------- - -# create new layout object 'Layout #1' -layout1 = CreateLayout(name='Layout #1') -layout1.AssignView(0, renderView2) -layout1.SetSize(1720, 1139) - -# ---------------------------------------------------------------- -# restore active view -SetActiveView(renderView2) -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'PVTrivialProducer' -ippl_particle = PVTrivialProducer(registrationName='ippl_particle') - -# ---------------------------------------------------------------- -# setup the visualization in view 'renderView2' -# ---------------------------------------------------------------- - -# show data from ippl_particle -ippl_particleDisplay = Show(ippl_particle, renderView2, 'UnstructuredGridRepresentation') - -# get 2D transfer function for 'velocity' -velocityTF2D = GetTransferFunction2D('velocity') - -# get color transfer function/color map for 'velocity' -velocityLUT = GetColorTransferFunction('velocity') -velocityLUT.TransferFunction2D = velocityTF2D -velocityLUT.RGBPoints = [0.05045547731616287, 0.231373, 0.298039, 0.752941, 2.390862497557854, 0.865003, 0.865003, 0.865003, 4.731269517799545, 0.705882, 0.0156863, 0.14902] -velocityLUT.ScalarRangeInitialized = 1.0 - -# get opacity transfer function/opacity map for 'velocity' -velocityPWF = GetOpacityTransferFunction('velocity') -velocityPWF.Points = [0.05045547731616287, 0.0, 0.5, 0.0, 4.731269517799545, 1.0, 0.5, 0.0] -velocityPWF.ScalarRangeInitialized = 1 - -# trace defaults for the display properties. -ippl_particleDisplay.Representation = 'Point Gaussian' -ippl_particleDisplay.ColorArrayName = ['POINTS', 'velocity'] -ippl_particleDisplay.LookupTable = velocityLUT -ippl_particleDisplay.SelectTCoordArray = 'None' -ippl_particleDisplay.SelectNormalArray = 'None' -ippl_particleDisplay.SelectTangentArray = 'None' -ippl_particleDisplay.OSPRayScaleArray = 'charge' -ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' -ippl_particleDisplay.SelectOrientationVectors = 'None' -ippl_particleDisplay.ScaleFactor = 1.9956522745753908 -ippl_particleDisplay.SelectScaleArray = 'None' -ippl_particleDisplay.GlyphType = 'Arrow' -ippl_particleDisplay.GlyphTableIndexArray = 'None' -ippl_particleDisplay.GaussianRadius = 0.09978261372876954 -ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] -ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] -ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' -ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' -ippl_particleDisplay.ScalarOpacityFunction = velocityPWF -ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 -ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] -ippl_particleDisplay.SelectInputVectors = ['POINTS', 'velocity'] -ippl_particleDisplay.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# setup the color legend parameters for each legend in this view - -# get color legend/bar for velocityLUT in view renderView2 -velocityLUTColorBar = GetScalarBar(velocityLUT, renderView2) -velocityLUTColorBar.Title = 'velocity' -velocityLUTColorBar.ComponentTitle = 'Magnitude' - -# set color bar visibility -velocityLUTColorBar.Visibility = 1 - -# show color legend -ippl_particleDisplay.SetScalarBarVisibility(renderView2, True) - -# ---------------------------------------------------------------- -# setup color maps and opacity mapes used in the visualization -# note: the Get..() functions create a new object, if needed -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') -# trace defaults for the extractor. -pNG1.Trigger = 'TimeStep' - -# init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [1720, 1139] -pNG1.Writer.Format = 'PNG' - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(ippl_particle) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GenerateCinemaSpecification = 1 -options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) - print("yeah") diff --git a/test/stream/dump_particle_vtpd.py b/test/stream/dump_particle_vtpd.py deleted file mode 100644 index 5eb0d3b3c..000000000 --- a/test/stream/dump_particle_vtpd.py +++ /dev/null @@ -1,165 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup views used in the visualization -# ---------------------------------------------------------------- - -# get the material library -materialLibrary1 = GetMaterialLibrary() - -# Create a new 'Render View' -renderView2 = CreateView('RenderView') -renderView2.ViewSize = [1280, 824] -renderView2.InteractionMode = 'Selection' -renderView2.AxesGrid = 'GridAxes3DActor' -renderView2.CenterOfRotation = [10.002041462808847, 9.978474140167236, 10.046973206102848] -renderView2.HiddenLineRemoval = 1 -renderView2.StereoType = 'Crystal Eyes' -renderView2.CameraPosition = [42.41949355014824, 42.39592622750662, 42.46442529344225] -renderView2.CameraFocalPoint = [10.002041462808847, 9.978474140167236, 10.046973206102848] -renderView2.CameraViewUp = [-0.4082482904638631, 0.816496580927726, -0.40824829046386296] -renderView2.CameraFocalDisk = 1.0 -renderView2.CameraParallelScale = 14.53234620584578 -renderView2.BackEnd = 'OSPRay raycaster' -renderView2.OSPRayMaterialLibrary = materialLibrary1 - -# init the 'GridAxes3DActor' selected for 'AxesGrid' -renderView2.AxesGrid.Visibility = 1 -renderView2.AxesGrid.ShowGrid = 1 - -SetActiveView(None) - -# ---------------------------------------------------------------- -# setup view layouts -# ---------------------------------------------------------------- - -# create new layout object 'Layout #1' -layout1 = CreateLayout(name='Layout #1') -layout1.AssignView(0, renderView2) -layout1.SetSize(1280, 824) - -# ---------------------------------------------------------------- -# restore active view -SetActiveView(renderView2) -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'PVTrivialProducer' -ippl_particle = PVTrivialProducer(registrationName='ippl_particle') - -# ---------------------------------------------------------------- -# setup the visualization in view 'renderView2' -# ---------------------------------------------------------------- - -# show data from ippl_particle -ippl_particleDisplay = Show(ippl_particle, renderView2, 'UnstructuredGridRepresentation') - -# get 2D transfer function for 'charge' -chargeTF2D = GetTransferFunction2D('charge') - -# get color transfer function/color map for 'charge' -chargeLUT = GetColorTransferFunction('charge') -chargeLUT.TransferFunction2D = chargeTF2D -chargeLUT.RGBPoints = [-0.15625, 0.231373, 0.298039, 0.752941, -0.1562347412109375, 0.865003, 0.865003, 0.865003, -0.156219482421875, 0.705882, 0.0156863, 0.14902] -chargeLUT.ScalarRangeInitialized = 1.0 - -# get opacity transfer function/opacity map for 'charge' -chargePWF = GetOpacityTransferFunction('charge') -chargePWF.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] -chargePWF.ScalarRangeInitialized = 1 - -# trace defaults for the display properties. -ippl_particleDisplay.Representation = 'Point Gaussian' -ippl_particleDisplay.ColorArrayName = ['POINTS', 'charge'] -ippl_particleDisplay.LookupTable = chargeLUT -ippl_particleDisplay.SelectTCoordArray = 'None' -ippl_particleDisplay.SelectNormalArray = 'None' -ippl_particleDisplay.SelectTangentArray = 'None' -ippl_particleDisplay.OSPRayScaleArray = 'charge' -ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' -ippl_particleDisplay.SelectOrientationVectors = 'None' -ippl_particleDisplay.ScaleFactor = 1.9956522745753908 -ippl_particleDisplay.SelectScaleArray = 'None' -ippl_particleDisplay.GlyphType = 'Arrow' -ippl_particleDisplay.GlyphTableIndexArray = 'None' -ippl_particleDisplay.GaussianRadius = 0.09978261372876954 -ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] -ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] -ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' -ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' -ippl_particleDisplay.ScalarOpacityFunction = chargePWF -ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 -ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] -ippl_particleDisplay.SelectInputVectors = [None, ''] -ippl_particleDisplay.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# setup the color legend parameters for each legend in this view - -# get color legend/bar for chargeLUT in view renderView2 -chargeLUTColorBar = GetScalarBar(chargeLUT, renderView2) -chargeLUTColorBar.Title = 'charge' -chargeLUTColorBar.ComponentTitle = '' - -# set color bar visibility -chargeLUTColorBar.Visibility = 1 - -# show color legend -ippl_particleDisplay.SetScalarBarVisibility(renderView2, True) - -# ---------------------------------------------------------------- -# setup color maps and opacity mapes used in the visualization -# note: the Get..() functions create a new object, if needed -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') -# trace defaults for the extractor. -pNG1.Trigger = 'TimeStep' - -# init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [1720, 1139] -pNG1.Writer.Format = 'PNG' -pNG1.Writer.ResetDisplay = 1 - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(pNG1) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GenerateCinemaSpecification = 1 -options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) diff --git a/test/stream/extract3_penningtrap.py b/test/stream/extract3_penningtrap.py deleted file mode 100644 index 12860c4fa..000000000 --- a/test/stream/extract3_penningtrap.py +++ /dev/null @@ -1,204 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup views used in the visualization -# ---------------------------------------------------------------- - -# get the material library -materialLibrary1 = GetMaterialLibrary() - -# Create a new 'Render View' -renderView2 = CreateView('RenderView') -renderView2.ViewSize = [371, 530] -renderView2.AxesGrid = 'GridAxes3DActor' -renderView2.CenterOfRotation = [10.0, 10.0, 10.0] -renderView2.StereoType = 'Crystal Eyes' -renderView2.CameraPosition = [-42.55244880849627, 53.0225730665183, 75.27577212134747] -renderView2.CameraFocalPoint = [10.0, 10.0, 10.0] -renderView2.CameraViewUp = [0.3331761994480328, 0.8879714244143248, -0.3170179325289973] -renderView2.CameraFocalDisk = 1.0 -renderView2.CameraParallelScale = 24.810457513824463 -renderView2.BackEnd = 'OSPRay raycaster' -renderView2.OSPRayMaterialLibrary = materialLibrary1 - -SetActiveView(None) - -# ---------------------------------------------------------------- -# setup view layouts -# ---------------------------------------------------------------- - -# create new layout object 'Layout #1' -layout1 = CreateLayout(name='Layout #1') -layout1.SplitHorizontal(0, 0.500000) -layout1.AssignView(1, renderView2) -layout1.SetSize(742, 530) - -# ---------------------------------------------------------------- -# restore active view -SetActiveView(renderView2) -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'PVTrivialProducer' -ippl_field = PVTrivialProducer(registrationName='ippl_field') - -# create a new 'Clip' -clip1 = Clip(registrationName='Clip1', Input=ippl_field) -clip1.ClipType = 'Plane' -clip1.HyperTreeGridClipper = 'Plane' -clip1.Scalars = ['POINTS', ''] - -# init the 'Plane' selected for 'ClipType' -clip1.ClipType.Origin = [10.0, 10.0, 10.0] -clip1.ClipType.Normal = [0.0, 0.0, 1.0] - -# init the 'Plane' selected for 'HyperTreeGridClipper' -clip1.HyperTreeGridClipper.Origin = [10.0, 10.0, 10.0] - -# ---------------------------------------------------------------- -# setup the visualization in view 'renderView2' -# ---------------------------------------------------------------- - -# show data from ippl_field -ippl_fieldDisplay = Show(ippl_field, renderView2, 'UniformGridRepresentation') - -# get 2D transfer function for 'electrostatic' -electrostaticTF2D = GetTransferFunction2D('electrostatic') -electrostaticTF2D.ScalarRangeInitialized = 1 -electrostaticTF2D.Range = [0.0, 1.1757813367477812e-38, 0.0, 1.0] - -# get color transfer function/color map for 'electrostatic' -electrostaticLUT = GetColorTransferFunction('electrostatic') -electrostaticLUT.TransferFunction2D = electrostaticTF2D -electrostaticLUT.RGBPoints = [0.07470709971953278, 0.231373, 0.298039, 0.752941, 3.33273624725058, 0.865003, 0.865003, 0.865003, 6.590765394781628, 0.705882, 0.0156863, 0.14902] -electrostaticLUT.ScalarRangeInitialized = 1.0 - -# get opacity transfer function/opacity map for 'electrostatic' -electrostaticPWF = GetOpacityTransferFunction('electrostatic') -electrostaticPWF.Points = [0.07470709971953278, 0.0, 0.5, 0.0, 6.590765394781628, 1.0, 0.5, 0.0] -electrostaticPWF.ScalarRangeInitialized = 1 - -# trace defaults for the display properties. -ippl_fieldDisplay.Representation = 'Outline' -ippl_fieldDisplay.ColorArrayName = ['CELLS', 'electrostatic'] -ippl_fieldDisplay.LookupTable = electrostaticLUT -ippl_fieldDisplay.SelectTCoordArray = 'None' -ippl_fieldDisplay.SelectNormalArray = 'None' -ippl_fieldDisplay.SelectTangentArray = 'None' -ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' -ippl_fieldDisplay.SelectOrientationVectors = 'None' -ippl_fieldDisplay.ScaleFactor = 2.0 -ippl_fieldDisplay.SelectScaleArray = 'None' -ippl_fieldDisplay.GlyphType = 'Arrow' -ippl_fieldDisplay.GlyphTableIndexArray = 'None' -ippl_fieldDisplay.GaussianRadius = 0.1 -ippl_fieldDisplay.SetScaleArray = [None, ''] -ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' -ippl_fieldDisplay.OpacityArray = [None, ''] -ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' -ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' -ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' -ippl_fieldDisplay.ScalarOpacityUnitDistance = 2.165063509461097 -ippl_fieldDisplay.ScalarOpacityFunction = electrostaticPWF -ippl_fieldDisplay.TransferFunction2D = electrostaticTF2D -ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'electrostatic'] -ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'electrostatic'] -ippl_fieldDisplay.SliceFunction = 'Plane' -ippl_fieldDisplay.Slice = 8 -ippl_fieldDisplay.SelectInputVectors = [None, ''] -ippl_fieldDisplay.WriteLog = '' - -# init the 'Plane' selected for 'SliceFunction' -ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] - -# show data from clip1 -clip1Display = Show(clip1, renderView2, 'UnstructuredGridRepresentation') - -# trace defaults for the display properties. -clip1Display.Representation = 'Surface' -clip1Display.ColorArrayName = ['CELLS', 'electrostatic'] -clip1Display.LookupTable = electrostaticLUT -clip1Display.SelectTCoordArray = 'None' -clip1Display.SelectNormalArray = 'None' -clip1Display.SelectTangentArray = 'None' -clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' -clip1Display.SelectOrientationVectors = 'None' -clip1Display.ScaleFactor = 1.7627550836865113 -clip1Display.SelectScaleArray = 'None' -clip1Display.GlyphType = 'Arrow' -clip1Display.GlyphTableIndexArray = 'None' -clip1Display.GaussianRadius = 0.08813775418432555 -clip1Display.SetScaleArray = [None, ''] -clip1Display.ScaleTransferFunction = 'PiecewiseFunction' -clip1Display.OpacityArray = [None, ''] -clip1Display.OpacityTransferFunction = 'PiecewiseFunction' -clip1Display.DataAxesGrid = 'GridAxesRepresentation' -clip1Display.PolarAxes = 'PolarAxesRepresentation' -clip1Display.ScalarOpacityFunction = electrostaticPWF -clip1Display.ScalarOpacityUnitDistance = 2.054619857832192 -clip1Display.OpacityArrayName = ['CELLS', 'electrostatic'] -clip1Display.SelectInputVectors = [None, ''] -clip1Display.WriteLog = '' - -# setup the color legend parameters for each legend in this view - -# get color legend/bar for electrostaticLUT in view renderView2 -electrostaticLUTColorBar = GetScalarBar(electrostaticLUT, renderView2) -electrostaticLUTColorBar.Title = 'electrostatic' -electrostaticLUTColorBar.ComponentTitle = 'Magnitude' - -# set color bar visibility -electrostaticLUTColorBar.Visibility = 1 - -# show color legend -ippl_fieldDisplay.SetScalarBarVisibility(renderView2, True) - -# show color legend -clip1Display.SetScalarBarVisibility(renderView2, True) - -# ---------------------------------------------------------------- -# setup color maps and opacity mapes used in the visualization -# note: the Get..() functions create a new object, if needed -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -pNG1 = CreateExtractor('PNG', renderView2, registrationName='PNG1') -# trace defaults for the extractor. -pNG1.Trigger = 'TimeStep' - -# init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView2_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [371, 530] -pNG1.Writer.Format = 'PNG' - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(pNG1) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GlobalTrigger = 'TimeStep' -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) diff --git a/test/stream/extract_penningtrap.py b/test/stream/extract_penningtrap.py deleted file mode 100644 index cb1846dae..000000000 --- a/test/stream/extract_penningtrap.py +++ /dev/null @@ -1,235 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup views used in the visualization -# ---------------------------------------------------------------- - -# get the material library -materialLibrary1 = GetMaterialLibrary() - -# Create a new 'Render View' -renderView1 = CreateView('RenderView') -renderView1.ViewSize = [1877, 1171] -renderView1.AxesGrid = 'GridAxes3DActor' -renderView1.CenterOfRotation = [10.0, 10.0, 10.0] -renderView1.StereoType = 'Crystal Eyes' -renderView1.CameraPosition = [-29.281150563975967, 38.91994832117599, 65.77495370861955] -renderView1.CameraFocalPoint = [14.933355093656326, 7.465538329176106, 5.669943215819909] -renderView1.CameraViewUp = [0.22018111884477137, 0.9214003427041039, -0.3202213037401241] -renderView1.CameraFocalDisk = 1.0 -renderView1.CameraParallelScale = 17.320508075688775 -renderView1.BackEnd = 'OSPRay raycaster' -renderView1.OSPRayMaterialLibrary = materialLibrary1 - -SetActiveView(None) - -# ---------------------------------------------------------------- -# setup view layouts -# ---------------------------------------------------------------- - -# create new layout object 'Layout #1' -layout1 = CreateLayout(name='Layout #1') -layout1.AssignView(0, renderView1) -layout1.SetSize(1877, 1171) - -# ---------------------------------------------------------------- -# restore active view -SetActiveView(renderView1) -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'XML Partitioned Dataset Reader' -ippl_field = XMLPartitionedDatasetReader(registrationName='ippl_field') - -# create a new 'Ghost Cells Generator' -ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) - -# create a new 'Cell Data to Point Data' -cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ghostCellsGenerator1) -cellDatatoPointData1.CellDataArraytoprocess = ['density'] - -# create a new 'Contour' -contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) -contour1.ContourBy = ['POINTS', 'density'] -contour1.Isosurfaces = [-10.925284203191916, -9.766919291726147, -8.60855438026038, -7.450189468794611, -6.291824557328843, -5.133459645863074, -3.975094734397306, -2.8167298229315367, -1.6583649114657693, -0.5000000000000018] -contour1.PointMergeMethod = 'Uniform Binning' - -# create a new 'Clip' -clip1 = Clip(registrationName='Clip1', Input=contour1) -clip1.ClipType = 'Plane' -clip1.HyperTreeGridClipper = 'Plane' -clip1.Scalars = ['POINTS', 'density'] -clip1.Value = -5.133459568023682 - -# init the 'Plane' selected for 'ClipType' -clip1.ClipType.Origin = [9.98001554608345, 10.002425193786621, 9.999979734420776] -clip1.ClipType.Normal = [0.0, 0.0, 1.0] - -# init the 'Plane' selected for 'HyperTreeGridClipper' -clip1.HyperTreeGridClipper.Origin = [9.98001554608345, 10.002425193786621, 9.999979734420776] - -# ---------------------------------------------------------------- -# setup the visualization in view 'renderView1' -# ---------------------------------------------------------------- - -# show data from ippl_field -ippl_fieldDisplay = Show(ippl_field, renderView1, 'UniformGridRepresentation') - -# get 2D transfer function for 'density' -densityTF2D = GetTransferFunction2D('density') -densityTF2D.ScalarRangeInitialized = 1 -densityTF2D.Range = [-16.259595698935676, 0.0, 0.0, 1.0] - -# get color transfer function/color map for 'density' -densityLUT = GetColorTransferFunction('density') -densityLUT.TransferFunction2D = densityTF2D -densityLUT.RGBPoints = [-16.259595698935676, 0.231373, 0.298039, 0.752941, -8.129797849467838, 0.865003, 0.865003, 0.865003, 0.0, 0.705882, 0.0156863, 0.14902] -densityLUT.ScalarRangeInitialized = 1.0 - -# get opacity transfer function/opacity map for 'density' -densityPWF = GetOpacityTransferFunction('density') -densityPWF.Points = [-16.259595698935676, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] -densityPWF.ScalarRangeInitialized = 1 - -# trace defaults for the display properties. -ippl_fieldDisplay.Representation = 'Outline' -ippl_fieldDisplay.ColorArrayName = ['CELLS', 'density'] -ippl_fieldDisplay.LookupTable = densityLUT -ippl_fieldDisplay.SelectTCoordArray = 'None' -ippl_fieldDisplay.SelectNormalArray = 'None' -ippl_fieldDisplay.SelectTangentArray = 'None' -ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' -ippl_fieldDisplay.SelectOrientationVectors = 'None' -ippl_fieldDisplay.ScaleFactor = 2.0 -ippl_fieldDisplay.SelectScaleArray = 'None' -ippl_fieldDisplay.GlyphType = 'Arrow' -ippl_fieldDisplay.GlyphTableIndexArray = 'None' -ippl_fieldDisplay.GaussianRadius = 0.1 -ippl_fieldDisplay.SetScaleArray = [None, ''] -ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' -ippl_fieldDisplay.OpacityArray = [None, ''] -ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' -ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' -ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' -ippl_fieldDisplay.ScalarOpacityUnitDistance = 0.5412658773652742 -ippl_fieldDisplay.ScalarOpacityFunction = densityPWF -ippl_fieldDisplay.TransferFunction2D = densityTF2D -ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'density'] -ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'density'] -ippl_fieldDisplay.SliceFunction = 'Plane' -ippl_fieldDisplay.Slice = 32 -ippl_fieldDisplay.SelectInputVectors = [None, ''] -ippl_fieldDisplay.WriteLog = '' - -# init the 'Plane' selected for 'SliceFunction' -ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] - -# show data from clip1 -clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') - -# trace defaults for the display properties. -clip1Display.Representation = 'Surface' -clip1Display.ColorArrayName = ['POINTS', 'density'] -clip1Display.LookupTable = densityLUT -clip1Display.SelectTCoordArray = 'None' -clip1Display.SelectNormalArray = 'Normals' -clip1Display.SelectTangentArray = 'None' -clip1Display.OSPRayScaleArray = 'density' -clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' -clip1Display.SelectOrientationVectors = 'None' -clip1Display.ScaleFactor = 1.8501425802707674 -clip1Display.SelectScaleArray = 'density' -clip1Display.GlyphType = 'Arrow' -clip1Display.GlyphTableIndexArray = 'density' -clip1Display.GaussianRadius = 0.09250712901353836 -clip1Display.SetScaleArray = ['POINTS', 'density'] -clip1Display.ScaleTransferFunction = 'PiecewiseFunction' -clip1Display.OpacityArray = ['POINTS', 'density'] -clip1Display.OpacityTransferFunction = 'PiecewiseFunction' -clip1Display.DataAxesGrid = 'GridAxesRepresentation' -clip1Display.PolarAxes = 'PolarAxesRepresentation' -clip1Display.ScalarOpacityFunction = densityPWF -clip1Display.ScalarOpacityUnitDistance = 0.7274508700056125 -clip1Display.OpacityArrayName = ['POINTS', 'density'] -clip1Display.SelectInputVectors = ['POINTS', 'Normals'] -clip1Display.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -clip1Display.ScaleTransferFunction.Points = [-9.766919136047363, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -clip1Display.OpacityTransferFunction.Points = [-9.766919136047363, 0.0, 0.5, 0.0, -0.5, 1.0, 0.5, 0.0] - -# setup the color legend parameters for each legend in this view - -# get color legend/bar for densityLUT in view renderView1 -densityLUTColorBar = GetScalarBar(densityLUT, renderView1) -densityLUTColorBar.WindowLocation = 'Upper Right Corner' -densityLUTColorBar.Title = 'density' -densityLUTColorBar.ComponentTitle = '' - -# set color bar visibility -densityLUTColorBar.Visibility = 1 - -# show color legend -ippl_fieldDisplay.SetScalarBarVisibility(renderView1, True) - -# show color legend -clip1Display.SetScalarBarVisibility(renderView1, True) - -# ---------------------------------------------------------------- -# setup color maps and opacity mapes used in the visualization -# note: the Get..() functions create a new object, if needed -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') -# trace defaults for the extractor. -pNG1.Trigger = 'TimeStep' - -# init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [1877, 1171] -pNG1.Writer.Format = 'PNG' -pNG1.Writer.ResetDisplay = 1 - -# create extractor -vTPD1 = CreateExtractor('VTPD', clip1, registrationName='VTPD1') -# trace defaults for the extractor. -vTPD1.Trigger = 'TimeStep' - -# init the 'VTPD' selected for 'Writer' -vTPD1.Writer.FileName = 'Clip1_{timestep:06d}.vtpd' - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(pNG1) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) diff --git a/test2_png.py b/test2_png.py deleted file mode 100644 index 7372cd98c..000000000 --- a/test2_png.py +++ /dev/null @@ -1,276 +0,0 @@ -# script-version: 2.0 -# Catalyst state generated using paraview version 5.11.1 - -#### import the simple module from the paraview -from paraview.simple import * -#### disable automatic camera reset on 'Show' -paraview.simple._DisableFirstRenderCameraReset() - -# ---------------------------------------------------------------- -# setup views used in the visualization -# ---------------------------------------------------------------- - -# get the material library -materialLibrary1 = GetMaterialLibrary() - -# Create a new 'Render View' -renderView1 = CreateView('RenderView') -renderView1.ViewSize = [2169, 1139] -renderView1.AxesGrid = 'GridAxes3DActor' -renderView1.CenterOfRotation = [10.0, 10.0, 10.0] -renderView1.StereoType = 'Crystal Eyes' -renderView1.CameraPosition = [47.29585541750492, 44.99428098019204, 53.161098647260886] -renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] -renderView1.CameraViewUp = [-0.33836890260180724, 0.8523744266916093, -0.3987033013083779] -renderView1.CameraFocalDisk = 1.0 -renderView1.CameraParallelScale = 17.320508075688775 -renderView1.BackEnd = 'OSPRay raycaster' -renderView1.OSPRayMaterialLibrary = materialLibrary1 - -SetActiveView(None) - -# ---------------------------------------------------------------- -# setup view layouts -# ---------------------------------------------------------------- - -# create new layout object 'Layout #1' -layout1 = CreateLayout(name='Layout #1') -layout1.AssignView(0, renderView1) -layout1.SetSize(2169, 1139) - -# ---------------------------------------------------------------- -# restore active view -SetActiveView(renderView1) -# ---------------------------------------------------------------- - -# ---------------------------------------------------------------- -# setup the data processing pipelines -# ---------------------------------------------------------------- - -# create a new 'PVTrivialProducer' -ippl_particle = PVTrivialProducer(registrationName='ippl_particle') - -# create a new 'PVTrivialProducer' -ippl_field = PVTrivialProducer(registrationName='ippl_field') - -# create a new 'Ghost Cells Generator' -ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) - -# create a new 'Cell Data to Point Data' -cellDatatoPointData1 = CellDatatoPointData(registrationName='CellDatatoPointData1', Input=ghostCellsGenerator1) -cellDatatoPointData1.CellDataArraytoprocess = ['vtkGhostType', 'density', 'vtkGhostType'] - -# create a new 'Contour' -contour1 = Contour(registrationName='Contour1', Input=cellDatatoPointData1) -contour1.ContourBy = ['POINTS', 'density'] -contour1.Isosurfaces = [-2.598547365298835, -5.39240723059767, -4.771549482753485, -4.150691734909299, -3.5298339870651136, -2.908976239220928, -2.2881184913767423, -1.667260743532557, -1.0464029956883714, -0.4255452478441857, 0.1953125] -contour1.PointMergeMethod = 'Uniform Binning' - -# ---------------------------------------------------------------- -# setup the visualization in view 'renderView1' -# ---------------------------------------------------------------- - -# show data from ippl_particle -ippl_particleDisplay = Show(ippl_particle, renderView1, 'UnstructuredGridRepresentation') - -# get 2D transfer function for 'velocity' -velocityTF2D = GetTransferFunction2D('velocity') - -# get color transfer function/color map for 'velocity' -velocityLUT = GetColorTransferFunction('velocity') -velocityLUT.TransferFunction2D = velocityTF2D -velocityLUT.RGBPoints = [0.05045547731616287, 0.231373, 0.298039, 0.752941, 2.8507787375282088, 0.865003, 0.865003, 0.865003, 5.651101997740255, 0.705882, 0.0156863, 0.14902] -velocityLUT.ScalarRangeInitialized = 1.0 - -# get opacity transfer function/opacity map for 'velocity' -velocityPWF = GetOpacityTransferFunction('velocity') -velocityPWF.Points = [0.05045547731616287, 0.0, 0.5, 0.0, 5.651101997740255, 1.0, 0.5, 0.0] -velocityPWF.ScalarRangeInitialized = 1 - -# trace defaults for the display properties. -ippl_particleDisplay.Representation = 'Point Gaussian' -ippl_particleDisplay.ColorArrayName = ['POINTS', 'velocity'] -ippl_particleDisplay.LookupTable = velocityLUT -ippl_particleDisplay.SelectTCoordArray = 'None' -ippl_particleDisplay.SelectNormalArray = 'None' -ippl_particleDisplay.SelectTangentArray = 'None' -ippl_particleDisplay.OSPRayScaleArray = 'charge' -ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' -ippl_particleDisplay.SelectOrientationVectors = 'None' -ippl_particleDisplay.ScaleFactor = 1.9956522745753908 -ippl_particleDisplay.SelectScaleArray = 'None' -ippl_particleDisplay.GlyphType = 'Arrow' -ippl_particleDisplay.GlyphTableIndexArray = 'None' -ippl_particleDisplay.GaussianRadius = 0.15 -ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] -ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] -ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' -ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' -ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' -ippl_particleDisplay.ScalarOpacityFunction = velocityPWF -ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403262389439892 -ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] -ippl_particleDisplay.SelectInputVectors = ['POINTS', 'velocity'] -ippl_particleDisplay.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] - -# show data from ghostCellsGenerator1 -ghostCellsGenerator1Display = Show(ghostCellsGenerator1, renderView1, 'UniformGridRepresentation') - -# trace defaults for the display properties. -ghostCellsGenerator1Display.Representation = 'Outline' -ghostCellsGenerator1Display.ColorArrayName = [None, ''] -ghostCellsGenerator1Display.SelectTCoordArray = 'None' -ghostCellsGenerator1Display.SelectNormalArray = 'None' -ghostCellsGenerator1Display.SelectTangentArray = 'None' -ghostCellsGenerator1Display.OSPRayScaleArray = 'vtkGhostType' -ghostCellsGenerator1Display.OSPRayScaleFunction = 'PiecewiseFunction' -ghostCellsGenerator1Display.SelectOrientationVectors = 'None' -ghostCellsGenerator1Display.ScaleFactor = 2.0 -ghostCellsGenerator1Display.SelectScaleArray = 'None' -ghostCellsGenerator1Display.GlyphType = 'Arrow' -ghostCellsGenerator1Display.GlyphTableIndexArray = 'None' -ghostCellsGenerator1Display.GaussianRadius = 0.1 -ghostCellsGenerator1Display.SetScaleArray = ['POINTS', 'vtkGhostType'] -ghostCellsGenerator1Display.ScaleTransferFunction = 'PiecewiseFunction' -ghostCellsGenerator1Display.OpacityArray = ['POINTS', 'vtkGhostType'] -ghostCellsGenerator1Display.OpacityTransferFunction = 'PiecewiseFunction' -ghostCellsGenerator1Display.DataAxesGrid = 'GridAxesRepresentation' -ghostCellsGenerator1Display.PolarAxes = 'PolarAxesRepresentation' -ghostCellsGenerator1Display.ScalarOpacityUnitDistance = 2.165063509461097 -ghostCellsGenerator1Display.OpacityArrayName = ['POINTS', 'vtkGhostType'] -ghostCellsGenerator1Display.ColorArray2Name = ['POINTS', 'vtkGhostType'] -ghostCellsGenerator1Display.SliceFunction = 'Plane' -ghostCellsGenerator1Display.Slice = 8 -ghostCellsGenerator1Display.SelectInputVectors = [None, ''] -ghostCellsGenerator1Display.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -ghostCellsGenerator1Display.ScaleTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -ghostCellsGenerator1Display.OpacityTransferFunction.Points = [0.0, 0.0, 0.5, 0.0, 1.1757813367477812e-38, 1.0, 0.5, 0.0] - -# init the 'Plane' selected for 'SliceFunction' -ghostCellsGenerator1Display.SliceFunction.Origin = [10.0, 10.0, 10.0] - -# show data from contour1 -contour1Display = Show(contour1, renderView1, 'GeometryRepresentation') - -# get 2D transfer function for 'density' -densityTF2D = GetTransferFunction2D('density') -densityTF2D.ScalarRangeInitialized = 1 -densityTF2D.Range = [-5.39240723059767, 0.1953125, 0.0, 1.0] - -# get color transfer function/color map for 'density' -densityLUT = GetColorTransferFunction('density') -densityLUT.TransferFunction2D = densityTF2D -densityLUT.RGBPoints = [-5.962676343529195, 0.231373, 0.298039, 0.752941, -2.8836819217645977, 0.865003, 0.865003, 0.865003, 0.1953125, 0.705882, 0.0156863, 0.14902] -densityLUT.ScalarRangeInitialized = 1.0 - -# trace defaults for the display properties. -contour1Display.Representation = 'Surface' -contour1Display.ColorArrayName = ['POINTS', 'density'] -contour1Display.LookupTable = densityLUT -contour1Display.Opacity = 0.5 -contour1Display.SelectTCoordArray = 'None' -contour1Display.SelectNormalArray = 'Normals' -contour1Display.SelectTangentArray = 'None' -contour1Display.OSPRayScaleArray = 'density' -contour1Display.OSPRayScaleFunction = 'PiecewiseFunction' -contour1Display.SelectOrientationVectors = 'None' -contour1Display.ScaleFactor = 0.9665217399597168 -contour1Display.SelectScaleArray = 'density' -contour1Display.GlyphType = 'Arrow' -contour1Display.GlyphTableIndexArray = 'density' -contour1Display.GaussianRadius = 0.048326086997985844 -contour1Display.SetScaleArray = ['POINTS', 'density'] -contour1Display.ScaleTransferFunction = 'PiecewiseFunction' -contour1Display.OpacityArray = ['POINTS', 'density'] -contour1Display.OpacityTransferFunction = 'PiecewiseFunction' -contour1Display.DataAxesGrid = 'GridAxesRepresentation' -contour1Display.PolarAxes = 'PolarAxesRepresentation' -contour1Display.SelectInputVectors = ['POINTS', 'Normals'] -contour1Display.WriteLog = '' - -# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' -contour1Display.ScaleTransferFunction.Points = [-2.5985474586486816, 0.0, 0.5, 0.0, -2.5980591773986816, 1.0, 0.5, 0.0] - -# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' -contour1Display.OpacityTransferFunction.Points = [-2.5985474586486816, 0.0, 0.5, 0.0, -2.5980591773986816, 1.0, 0.5, 0.0] - -# setup the color legend parameters for each legend in this view - -# get color legend/bar for densityLUT in view renderView1 -densityLUTColorBar = GetScalarBar(densityLUT, renderView1) -densityLUTColorBar.Title = 'density' -densityLUTColorBar.ComponentTitle = '' - -# set color bar visibility -densityLUTColorBar.Visibility = 1 - -# get color legend/bar for velocityLUT in view renderView1 -velocityLUTColorBar = GetScalarBar(velocityLUT, renderView1) -velocityLUTColorBar.WindowLocation = 'Upper Right Corner' -velocityLUTColorBar.Title = 'velocity' -velocityLUTColorBar.ComponentTitle = 'Magnitude' - -# set color bar visibility -velocityLUTColorBar.Visibility = 1 - -# show color legend -ippl_particleDisplay.SetScalarBarVisibility(renderView1, True) - -# show color legend -contour1Display.SetScalarBarVisibility(renderView1, True) - -# ---------------------------------------------------------------- -# setup color maps and opacity mapes used in the visualization -# note: the Get..() functions create a new object, if needed -# ---------------------------------------------------------------- - -# get opacity transfer function/opacity map for 'density' -densityPWF = GetOpacityTransferFunction('density') -densityPWF.Points = [-5.962676343529195, 0.0, 0.5, 0.0, 0.1953125, 1.0, 0.5, 0.0] -densityPWF.ScalarRangeInitialized = 1 - -# ---------------------------------------------------------------- -# setup extractors -# ---------------------------------------------------------------- - -# create extractor -pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') -# trace defaults for the extractor. -pNG1.Trigger = 'TimeStep' - -# init the 'PNG' selected for 'Writer' -pNG1.Writer.FileName = 'RenderView1_{timestep:06d}{camera}.png' -pNG1.Writer.ImageResolution = [1920, 1080] -pNG1.Writer.Format = 'PNG' - -# ---------------------------------------------------------------- -# restore active source -SetActiveSource(contour1) -# ---------------------------------------------------------------- - -# ------------------------------------------------------------------------------ -# Catalyst options -from paraview import catalyst -options = catalyst.Options() -options.GenerateCinemaSpecification = 1 -options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' - -# ------------------------------------------------------------------------------ -if __name__ == '__main__': - from paraview.simple import SaveExtractsUsingCatalystOptions - # Code for non in-situ environments; if executing in post-processing - # i.e. non-Catalyst mode, let's generate extracts using Catalyst options - SaveExtractsUsingCatalystOptions(options) From 9e0960eb43d747a66e5811a7a7cfe21d4f794068 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 17 Oct 2023 09:00:25 +0200 Subject: [PATCH 101/113] add extractor script for density field and particles --- .gitignore | 2 +- test/stream/dump_density_field.py | 224 ++++++++++++++++++++++++++++++ test/stream/dump_particles.py | 161 +++++++++++++++++++++ 3 files changed, 386 insertions(+), 1 deletion(-) create mode 100644 test/stream/dump_density_field.py create mode 100644 test/stream/dump_particles.py diff --git a/.gitignore b/.gitignore index b9c4e8e55..1ae90d254 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,7 @@ manual/ippl_user_guide.pdf # ignure vtk dump stuff data/ -datasets/ +datasets*/ *.vtk # CMake and Build folder diff --git a/test/stream/dump_density_field.py b/test/stream/dump_density_field.py new file mode 100644 index 000000000..84c2eb07d --- /dev/null +++ b/test/stream/dump_density_field.py @@ -0,0 +1,224 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [795, 749] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [10.0, 10.0, 10.0] +renderView1.HiddenLineRemoval = 1 +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [48.63703305156274, 48.63703305156273, 48.637033051562746] +renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] +renderView1.CameraViewUp = [-0.4082482904638631, 0.816496580927726, -0.40824829046386296] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 17.320508075688775 +renderView1.BackEnd = 'OSPRay raycaster' +renderView1.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(795, 749) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'XML Partitioned Dataset Reader' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# create a new 'Ghost Cells Generator' +ghostCellsGenerator1 = GhostCellsGenerator(registrationName='GhostCellsGenerator1', Input=ippl_field) + +# create a new 'Contour' +contour1 = Contour(registrationName='Contour1', Input=ghostCellsGenerator1) +contour1.ContourBy = ['POINTS', 'density'] +contour1.Isosurfaces = [0.0, -9.560476096448486, -9.057293144003829, -8.554110191559172, -8.050927239114515, -7.547744286669857, -7.0445613342252, -6.541378381780543, -6.038195429335886, -5.535012476891229, -5.031829524446572, -4.5286465720019144, -4.025463619557257, -3.5222806671126, -3.019097714667943, -2.515914762223286, -2.0127318097786286, -1.5095488573339715, -1.0063659048893143, -0.5031829524446572, 0.0] +contour1.PointMergeMethod = 'Uniform Binning' + +# create a new 'Clip' +clip1 = Clip(registrationName='Clip1', Input=contour1) +clip1.ClipType = 'Plane' +clip1.HyperTreeGridClipper = 'Plane' +clip1.Scalars = ['POINTS', 'density'] +clip1.Value = -3.773872137069702 + +# init the 'Plane' selected for 'ClipType' +clip1.ClipType.Origin = [10.619441449642181, 10.038045406341553, 10.0] +clip1.ClipType.Normal = [0.0, 0.0, 1.0] + +# init the 'Plane' selected for 'HyperTreeGridClipper' +clip1.HyperTreeGridClipper.Origin = [10.619441449642181, 10.038045406341553, 10.0] + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from ippl_field +ippl_fieldDisplay = Show(ippl_field, renderView1, 'UniformGridRepresentation') + +# trace defaults for the display properties. +ippl_fieldDisplay.Representation = 'Outline' +ippl_fieldDisplay.ColorArrayName = [None, ''] +ippl_fieldDisplay.SelectTCoordArray = 'None' +ippl_fieldDisplay.SelectNormalArray = 'None' +ippl_fieldDisplay.SelectTangentArray = 'None' +ippl_fieldDisplay.OSPRayScaleArray = 'density' +ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_fieldDisplay.SelectOrientationVectors = 'None' +ippl_fieldDisplay.ScaleFactor = 2.0 +ippl_fieldDisplay.SelectScaleArray = 'None' +ippl_fieldDisplay.GlyphType = 'Arrow' +ippl_fieldDisplay.GlyphTableIndexArray = 'None' +ippl_fieldDisplay.GaussianRadius = 0.1 +ippl_fieldDisplay.SetScaleArray = ['POINTS', 'density'] +ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.OpacityArray = ['POINTS', 'density'] +ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_fieldDisplay.ScalarOpacityUnitDistance = 1.0825317547305484 +ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'density'] +ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'density'] +ippl_fieldDisplay.SliceFunction = 'Plane' +ippl_fieldDisplay.Slice = 16 +ippl_fieldDisplay.SelectInputVectors = [None, ''] +ippl_fieldDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_fieldDisplay.ScaleTransferFunction.Points = [-9.560476096448486, 0.0, 0.5, 0.0, 0.1953125, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_fieldDisplay.OpacityTransferFunction.Points = [-9.560476096448486, 0.0, 0.5, 0.0, 0.1953125, 1.0, 0.5, 0.0] + +# init the 'Plane' selected for 'SliceFunction' +ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from clip1 +clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'density' +densityTF2D = GetTransferFunction2D('density') + +# get color transfer function/color map for 'density' +densityLUT = GetColorTransferFunction('density') +densityLUT.TransferFunction2D = densityTF2D +densityLUT.RGBPoints = [-7.547744274139404, 0.231373, 0.298039, 0.752941, -3.773872137069702, 0.865003, 0.865003, 0.865003, 0.0, 0.705882, 0.0156863, 0.14902] +densityLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'density' +densityPWF = GetOpacityTransferFunction('density') +densityPWF.Points = [-7.547744274139404, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] +densityPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +clip1Display.Representation = 'Surface' +clip1Display.ColorArrayName = ['POINTS', 'density'] +clip1Display.LookupTable = densityLUT +clip1Display.SelectTCoordArray = 'None' +clip1Display.SelectNormalArray = 'Normals' +clip1Display.SelectTangentArray = 'None' +clip1Display.OSPRayScaleArray = 'density' +clip1Display.OSPRayScaleFunction = 'PiecewiseFunction' +clip1Display.SelectOrientationVectors = 'None' +clip1Display.ScaleFactor = 1.851871407032013 +clip1Display.SelectScaleArray = 'density' +clip1Display.GlyphType = 'Arrow' +clip1Display.GlyphTableIndexArray = 'density' +clip1Display.GaussianRadius = 0.09259357035160065 +clip1Display.SetScaleArray = ['POINTS', 'density'] +clip1Display.ScaleTransferFunction = 'PiecewiseFunction' +clip1Display.OpacityArray = ['POINTS', 'density'] +clip1Display.OpacityTransferFunction = 'PiecewiseFunction' +clip1Display.DataAxesGrid = 'GridAxesRepresentation' +clip1Display.PolarAxes = 'PolarAxesRepresentation' +clip1Display.ScalarOpacityFunction = densityPWF +clip1Display.ScalarOpacityUnitDistance = 0.9212026380832151 +clip1Display.OpacityArrayName = ['POINTS', 'density'] +clip1Display.SelectInputVectors = ['POINTS', 'Normals'] +clip1Display.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +clip1Display.ScaleTransferFunction.Points = [-7.547744274139404, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +clip1Display.OpacityTransferFunction.Points = [-7.547744274139404, 0.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for densityLUT in view renderView1 +densityLUTColorBar = GetScalarBar(densityLUT, renderView1) +densityLUTColorBar.Title = 'density' +densityLUTColorBar.ComponentTitle = '' + +# set color bar visibility +densityLUTColorBar.Visibility = 1 + +# show color legend +clip1Display.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'Density_Field_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [3840, 2160] +pNG1.Writer.TransparentBackground = 1 +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(pNG1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.ExtractsOutputDirectory = 'datasets_density' +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) diff --git a/test/stream/dump_particles.py b/test/stream/dump_particles.py new file mode 100644 index 000000000..62cedfc67 --- /dev/null +++ b/test/stream/dump_particles.py @@ -0,0 +1,161 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [877, 811] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [9.804888932121028, 10.012698468217557, 10.017046030145888] +renderView1.HiddenLineRemoval = 1 +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [42.01243955103898, 42.22024908713551, 42.224596649063855] +renderView1.CameraFocalPoint = [9.804888932121028, 10.012698468217557, 10.017046030145888] +renderView1.CameraViewUp = [-0.4082482904638631, 0.816496580927726, -0.40824829046386296] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 14.438249951766423 +renderView1.BackEnd = 'OSPRay raycaster' +renderView1.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(877, 811) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'XML Partitioned Dataset Reader' +ippl_particle = PVTrivialProducer(registrationName='ippl_particle') + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from ippl_particle +ippl_particleDisplay = Show(ippl_particle, renderView1, 'UnstructuredGridRepresentation') + +# get 2D transfer function for 'velocity' +velocityTF2D = GetTransferFunction2D('velocity') + +# get color transfer function/color map for 'velocity' +velocityLUT = GetColorTransferFunction('velocity') +velocityLUT.TransferFunction2D = velocityTF2D +velocityLUT.RGBPoints = [0.050641224585373915, 0.231373, 0.298039, 0.752941, 2.3924284143906274, 0.865003, 0.865003, 0.865003, 4.734215604195881, 0.705882, 0.0156863, 0.14902] +velocityLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'velocity' +velocityPWF = GetOpacityTransferFunction('velocity') +velocityPWF.Points = [0.050641224585373915, 0.0, 0.5, 0.0, 4.734215604195881, 1.0, 0.5, 0.0] +velocityPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_particleDisplay.Representation = 'Point Gaussian' +ippl_particleDisplay.ColorArrayName = ['POINTS', 'velocity'] +ippl_particleDisplay.LookupTable = velocityLUT +ippl_particleDisplay.SelectTCoordArray = 'None' +ippl_particleDisplay.SelectNormalArray = 'None' +ippl_particleDisplay.SelectTangentArray = 'None' +ippl_particleDisplay.OSPRayScaleArray = 'charge' +ippl_particleDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_particleDisplay.SelectOrientationVectors = 'None' +ippl_particleDisplay.ScaleFactor = 1.9956595386576226 +ippl_particleDisplay.SelectScaleArray = 'None' +ippl_particleDisplay.GlyphType = 'Arrow' +ippl_particleDisplay.GlyphTableIndexArray = 'None' +ippl_particleDisplay.GaussianRadius = 0.09978297693288113 +ippl_particleDisplay.SetScaleArray = ['POINTS', 'charge'] +ippl_particleDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.OpacityArray = ['POINTS', 'charge'] +ippl_particleDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_particleDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_particleDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_particleDisplay.ScalarOpacityFunction = velocityPWF +ippl_particleDisplay.ScalarOpacityUnitDistance = 1.3403283950605853 +ippl_particleDisplay.OpacityArrayName = ['POINTS', 'charge'] +ippl_particleDisplay.SelectInputVectors = ['POINTS', 'position'] +ippl_particleDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_particleDisplay.ScaleTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_particleDisplay.OpacityTransferFunction.Points = [-0.15625, 0.0, 0.5, 0.0, -0.156219482421875, 1.0, 0.5, 0.0] + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for velocityLUT in view renderView1 +velocityLUTColorBar = GetScalarBar(velocityLUT, renderView1) +velocityLUTColorBar.Title = 'velocity' +velocityLUTColorBar.ComponentTitle = 'Magnitude' + +# set color bar visibility +velocityLUTColorBar.Visibility = 1 + +# show color legend +ippl_particleDisplay.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'Particles_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [3840, 2160] +pNG1.Writer.TransparentBackground = 1 +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(pNG1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.ExtractsOutputDirectory = 'datasets_particles' +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From 1d711378a3132a2694b284906fa5631bfda3f29e Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 17 Oct 2023 09:17:43 +0200 Subject: [PATCH 102/113] add extractor for electric field --- test/stream/dump_electric_field.py | 207 +++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 test/stream/dump_electric_field.py diff --git a/test/stream/dump_electric_field.py b/test/stream/dump_electric_field.py new file mode 100644 index 000000000..e54cfd3b2 --- /dev/null +++ b/test/stream/dump_electric_field.py @@ -0,0 +1,207 @@ +# script-version: 2.0 +# Catalyst state generated using paraview version 5.11.1 + +#### import the simple module from the paraview +from paraview.simple import * +#### disable automatic camera reset on 'Show' +paraview.simple._DisableFirstRenderCameraReset() + +# ---------------------------------------------------------------- +# setup views used in the visualization +# ---------------------------------------------------------------- + +# get the material library +materialLibrary1 = GetMaterialLibrary() + +# Create a new 'Render View' +renderView1 = CreateView('RenderView') +renderView1.ViewSize = [637, 749] +renderView1.AxesGrid = 'GridAxes3DActor' +renderView1.CenterOfRotation = [10.0, 10.0, 10.0] +renderView1.HiddenLineRemoval = 1 +renderView1.StereoType = 'Crystal Eyes' +renderView1.CameraPosition = [55.0073453709904, 55.00734537099039, 55.00734537099041] +renderView1.CameraFocalPoint = [10.0, 10.0, 10.0] +renderView1.CameraViewUp = [-0.4082482904638631, 0.816496580927726, -0.40824829046386296] +renderView1.CameraFocalDisk = 1.0 +renderView1.CameraParallelScale = 20.365872132952735 +renderView1.BackEnd = 'OSPRay raycaster' +renderView1.OSPRayMaterialLibrary = materialLibrary1 + +SetActiveView(None) + +# ---------------------------------------------------------------- +# setup view layouts +# ---------------------------------------------------------------- + +# create new layout object 'Layout #1' +layout1 = CreateLayout(name='Layout #1') +layout1.AssignView(0, renderView1) +layout1.SetSize(637, 749) + +# ---------------------------------------------------------------- +# restore active view +SetActiveView(renderView1) +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup the data processing pipelines +# ---------------------------------------------------------------- + +# create a new 'PVTrivialProducer' +ippl_field = PVTrivialProducer(registrationName='ippl_field') + +# create a new 'Glyph' +glyph1 = Glyph(registrationName='Glyph1', Input=ippl_field, + GlyphType='Arrow') +glyph1.OrientationArray = ['CELLS', 'electrostatic'] +glyph1.ScaleArray = ['POINTS', 'No scale array'] +glyph1.ScaleFactor = 1.1 +glyph1.GlyphTransform = 'Transform2' + +# ---------------------------------------------------------------- +# setup the visualization in view 'renderView1' +# ---------------------------------------------------------------- + +# show data from ippl_field +ippl_fieldDisplay = Show(ippl_field, renderView1, 'UniformGridRepresentation') + +# get 2D transfer function for 'electrostatic' +electrostaticTF2D = GetTransferFunction2D('electrostatic') +electrostaticTF2D.ScalarRangeInitialized = 1 +electrostaticTF2D.Range = [0.034176988881870436, 5.3579889614424, 0.0, 1.0] + +# get color transfer function/color map for 'electrostatic' +electrostaticLUT = GetColorTransferFunction('electrostatic') +electrostaticLUT.TransferFunction2D = electrostaticTF2D +electrostaticLUT.RGBPoints = [0.034176988881870436, 0.231373, 0.298039, 0.752941, 2.6960829751621356, 0.865003, 0.865003, 0.865003, 5.3579889614424, 0.705882, 0.0156863, 0.14902] +electrostaticLUT.ScalarRangeInitialized = 1.0 + +# get opacity transfer function/opacity map for 'electrostatic' +electrostaticPWF = GetOpacityTransferFunction('electrostatic') +electrostaticPWF.Points = [0.034176988881870436, 0.0, 0.5, 0.0, 5.3579889614424, 1.0, 0.5, 0.0] +electrostaticPWF.ScalarRangeInitialized = 1 + +# trace defaults for the display properties. +ippl_fieldDisplay.Representation = 'Outline' +ippl_fieldDisplay.ColorArrayName = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.LookupTable = electrostaticLUT +ippl_fieldDisplay.SelectTCoordArray = 'None' +ippl_fieldDisplay.SelectNormalArray = 'None' +ippl_fieldDisplay.SelectTangentArray = 'None' +ippl_fieldDisplay.OSPRayScaleArray = 'electrostatic' +ippl_fieldDisplay.OSPRayScaleFunction = 'PiecewiseFunction' +ippl_fieldDisplay.SelectOrientationVectors = 'None' +ippl_fieldDisplay.ScaleFactor = 2.0 +ippl_fieldDisplay.SelectScaleArray = 'None' +ippl_fieldDisplay.GlyphType = 'Arrow' +ippl_fieldDisplay.GlyphTableIndexArray = 'None' +ippl_fieldDisplay.GaussianRadius = 0.1 +ippl_fieldDisplay.SetScaleArray = ['POINTS', 'electrostatic'] +ippl_fieldDisplay.ScaleTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.OpacityArray = ['POINTS', 'electrostatic'] +ippl_fieldDisplay.OpacityTransferFunction = 'PiecewiseFunction' +ippl_fieldDisplay.DataAxesGrid = 'GridAxesRepresentation' +ippl_fieldDisplay.PolarAxes = 'PolarAxesRepresentation' +ippl_fieldDisplay.ScalarOpacityUnitDistance = 1.0825317547305484 +ippl_fieldDisplay.ScalarOpacityFunction = electrostaticPWF +ippl_fieldDisplay.TransferFunction2D = electrostaticTF2D +ippl_fieldDisplay.OpacityArrayName = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.ColorArray2Name = ['CELLS', 'electrostatic'] +ippl_fieldDisplay.SliceFunction = 'Plane' +ippl_fieldDisplay.Slice = 16 +ippl_fieldDisplay.SelectInputVectors = ['POINTS', 'electrostatic'] +ippl_fieldDisplay.WriteLog = '' + +# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' +ippl_fieldDisplay.ScaleTransferFunction.Points = [-3.4982625412984754, 0.0, 0.5, 0.0, 3.5997197159102856, 1.0, 0.5, 0.0] + +# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' +ippl_fieldDisplay.OpacityTransferFunction.Points = [-3.4982625412984754, 0.0, 0.5, 0.0, 3.5997197159102856, 1.0, 0.5, 0.0] + +# init the 'Plane' selected for 'SliceFunction' +ippl_fieldDisplay.SliceFunction.Origin = [10.0, 10.0, 10.0] + +# show data from glyph1 +glyph1Display = Show(glyph1, renderView1, 'GeometryRepresentation') + +# trace defaults for the display properties. +glyph1Display.Representation = 'Surface' +glyph1Display.ColorArrayName = ['POINTS', 'electrostatic'] +glyph1Display.LookupTable = electrostaticLUT +glyph1Display.SelectTCoordArray = 'None' +glyph1Display.SelectNormalArray = 'None' +glyph1Display.SelectTangentArray = 'None' +glyph1Display.OSPRayScaleFunction = 'PiecewiseFunction' +glyph1Display.SelectOrientationVectors = 'None' +glyph1Display.ScaleFactor = 2.2 +glyph1Display.SelectScaleArray = 'None' +glyph1Display.GlyphType = 'Arrow' +glyph1Display.GlyphTableIndexArray = 'None' +glyph1Display.GaussianRadius = 0.11 +glyph1Display.SetScaleArray = [None, ''] +glyph1Display.ScaleTransferFunction = 'PiecewiseFunction' +glyph1Display.OpacityArray = [None, ''] +glyph1Display.OpacityTransferFunction = 'PiecewiseFunction' +glyph1Display.DataAxesGrid = 'GridAxesRepresentation' +glyph1Display.PolarAxes = 'PolarAxesRepresentation' +glyph1Display.SelectInputVectors = [None, ''] +glyph1Display.WriteLog = '' + +# setup the color legend parameters for each legend in this view + +# get color legend/bar for electrostaticLUT in view renderView1 +electrostaticLUTColorBar = GetScalarBar(electrostaticLUT, renderView1) +electrostaticLUTColorBar.Title = 'electrostatic' +electrostaticLUTColorBar.ComponentTitle = 'Magnitude' + +# set color bar visibility +electrostaticLUTColorBar.Visibility = 1 + +# show color legend +ippl_fieldDisplay.SetScalarBarVisibility(renderView1, True) + +# show color legend +glyph1Display.SetScalarBarVisibility(renderView1, True) + +# ---------------------------------------------------------------- +# setup color maps and opacity mapes used in the visualization +# note: the Get..() functions create a new object, if needed +# ---------------------------------------------------------------- + +# ---------------------------------------------------------------- +# setup extractors +# ---------------------------------------------------------------- + +# create extractor +pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1') +# trace defaults for the extractor. +pNG1.Trigger = 'TimeStep' + +# init the 'PNG' selected for 'Writer' +pNG1.Writer.FileName = 'Electric_Field_{timestep:06d}{camera}.png' +pNG1.Writer.ImageResolution = [3840, 2160] +pNG1.Writer.TransparentBackground = 1 +pNG1.Writer.Format = 'PNG' + +# ---------------------------------------------------------------- +# restore active source +SetActiveSource(pNG1) +# ---------------------------------------------------------------- + +# ------------------------------------------------------------------------------ +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.ExtractsOutputDirectory = 'datasets_electric' +options.GenerateCinemaSpecification = 1 +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + from paraview.simple import SaveExtractsUsingCatalystOptions + # Code for non in-situ environments; if executing in post-processing + # i.e. non-Catalyst mode, let's generate extracts using Catalyst options + SaveExtractsUsingCatalystOptions(options) From cd9600910159a07d98952e6d39f73fd5c00df855 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Tue, 17 Oct 2023 10:40:58 +0200 Subject: [PATCH 103/113] update adaptor and testcatalyst to try out adios catalyst --- src/Stream/InSitu/CatalystAdaptor.h | 2 +- test/stream/TestCatalystAdaptor.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 759bd7ceb..b00d766dc 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -187,7 +187,7 @@ namespace CatalystAdaptor { // as we have a local copy of the field, the catalyst_execute needs to be called // within this scope otherwise the memory location might be already overwritten - if (node_in != std::nullopt) + if (node_in == std::nullopt) { callCatalystExecute(node); return {}; diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 13ed21d10..f3c77d51f 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -65,7 +65,7 @@ void dumpVTK(Field_t& rho, int nx, int ny, int nz, int iteration, double dx, dou int main(int argc, char* argv[]) { Ippl ippl(argc, argv); - CatalystAdaptor::Initialize(argc, argv); + CatalystAdaptor::Initialize_Adios(argc, argv); const int pt{2}; ippl::Index Ix(pt); @@ -125,7 +125,10 @@ int main(int argc, char* argv[]) { view(i, j, k) = y * time; }); - CatalystAdaptor::Execute_Field(it, time, Ippl::Comm->rank(), field); + // call catalyst execute with 5th argument as nullopt or not specified + + std::optional node = std::nullopt; + CatalystAdaptor::Execute_Field(it, time, Ippl::Comm->rank(), field, node); // print should be same as field data time += dt; From 274d4e6c15b085424af44f3cf984f6aed83f684b Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Sun, 29 Oct 2023 17:32:30 +0100 Subject: [PATCH 104/113] fix particles with only using the particle catalyst execute function --- alpine/PenningTrap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index fa5241d2b..ea0dc5ef6 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -395,8 +395,9 @@ int main(int argc, char* argv[]) { P->scatterCIC(totalP, it + 1, hr); // here is the position where we can access the density field + std::optional node_in; #ifdef ENABLE_CATALYST - CatalystAdaptor::Execute_Field_Particle(it, P->time_m, Ippl::Comm->rank(), P->rho_m, P); + CatalystAdaptor::Execute_Particle(it, P->time_m, Ippl::Comm->rank(), P, node_in); #endif // Field solve From 0840647c61d30f37a844484b282cb7c259b8f5a3 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 8 Dec 2023 11:31:33 +0100 Subject: [PATCH 105/113] remove spurious sutff created by merge --- alpine/PenningTrap.cpp | 4 ++-- src/CMakeLists.txt | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 8d54def9d..802548ea7 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -12,7 +12,7 @@ // lbthres = Load balancing threshold i.e., lbthres*100 is the maximum load imbalance // percentage which can be tolerated and beyond which // particle load balancing occurs. A value of 0.01 is good for many typical -// simulations.>>>>>>> dev-3.2.0 +// simulations. // ovfactor = Over-allocation factor for the buffers used in the communication. Typical // values are 1.0, 2.0. Value 1.0 means no over-allocation. // Example: @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) { // Create an instance of a manger for the considered application PenningTrapManager manager(totalP, nt, nr, lbt, solver, step_method); - // Perf>>>>>>> dev-3.2.0orm pre-run operations, including creating mesh, particles,... + // Perform pre-run operations, including creating mesh, particles,... manager.pre_run(); manager.setTime(0.0); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 219e1b1d7..1825244c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,13 +39,7 @@ macro (add_ippl_sources) endif () endmacro () -macro (add_ippl_headers)​ -85 -#ifdef ENABLE_CATALYST -86 - CatalystAdaptor::Finalize(); -87 -#endif +macro (add_ippl_headers) file (RELATIVE_PATH _relPath "${IPPL_SRC_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") foreach (_hdr ${ARGN}) if (_relPath) From b9857ec80ea1bd1ebb38e2c29d5d94def7c4d149 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Fri, 8 Dec 2023 12:44:55 +0100 Subject: [PATCH 106/113] rework files to work with new classes * remove TestCatalystAdaptor_2D * update PenningTrap --- alpine/ChargedParticles.hpp | 6 + alpine/PenningTrap.cpp | 15 +- alpine/PenningTrapManager.h | 9 ++ src/Stream/InSitu/CatalystAdaptor.h | 7 +- test/stream/CMakeLists.txt | 7 - test/stream/TestCatalystAdaptor.cpp | 201 ++++++++++--------------- test/stream/TestCatalystAdaptor_2D.cpp | 103 ------------- 7 files changed, 108 insertions(+), 240 deletions(-) delete mode 100644 test/stream/TestCatalystAdaptor_2D.cpp diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index a9b835c01..5a4b2c45d 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -14,6 +14,10 @@ #include "PoissonSolvers/P3MSolver.h" #include "PoissonSolvers/PoissonCG.h" +#ifdef ENABLE_CATALYST +#include "Stream/InSitu/CatalystAdaptor.h" +#endif + unsigned LoggingPeriod = 1; // some typedefs @@ -413,6 +417,8 @@ class ChargedParticles : public ippl::ParticleBase { } // dumpVTK(rho_m, nr_m[0], nr_m[1], nr_m[2], iteration, hrField[0], hrField[1], hrField[2]); + //CatalystAdaptor::Execute_Field(iteration, ); + // rho = rho_e - rho_i (only if periodic BCs) if (stype_m != "OPEN") { diff --git a/alpine/PenningTrap.cpp b/alpine/PenningTrap.cpp index 802548ea7..8d739fbaa 100644 --- a/alpine/PenningTrap.cpp +++ b/alpine/PenningTrap.cpp @@ -46,9 +46,18 @@ #include "datatypes.h" #include "PenningTrapManager.h" +#ifdef ENABLE_CATALYST +#include "Stream/InSitu/CatalystAdaptor.h" +#endif + int main(int argc, char* argv[]) { ippl::initialize(argc, argv); { + +#ifdef ENABLE_CATALYST + CatalystAdaptor::Initialize(argc, argv); +#endif + Inform msg("PenningTrap"); Inform msg2all("PenningTrap", INFORM_ALL_NODES); @@ -79,11 +88,11 @@ int main(int argc, char* argv[]) { manager.run(manager.getNt()); msg << "End." << endl; +#ifdef ENABLE_CATALYST + CatalystAdaptor::Finalize(); +#endif } ippl::finalize(); -#ifdef ENABLE_CATALYST - CatalystAdaptor::Finalize(); -#endif return 0; } diff --git a/alpine/PenningTrapManager.h b/alpine/PenningTrapManager.h index 524ce6b5e..45b2c534d 100644 --- a/alpine/PenningTrapManager.h +++ b/alpine/PenningTrapManager.h @@ -13,6 +13,11 @@ #include "Random/NormalDistribution.h" #include "Random/Randn.h" +#ifdef ENABLE_CATALYST +#include +#include "Stream/InSitu/CatalystAdaptor.h" +#endif + using view_type = typename ippl::detail::ViewType, 1>::view_type; const char* TestName = "PenningTrap"; @@ -330,6 +335,10 @@ class PenningTrapManager // scatter the charge onto the underlying grid this->par2grid(); +#ifdef ENABLE_CATALYST + std::optional node = std::nullopt; + CatalystAdaptor::Execute_Field(it, time_m, ippl::Comm->rank(), fc->getRho(),node); +#endif // Field solve this->fsolver_m->runSolver(); diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index b00d766dc..1950d71df 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -8,12 +8,13 @@ #include #include #include +#include #include #include -#include #include "Utility/IpplException.h" + namespace CatalystAdaptor { using View_vector = @@ -100,7 +101,7 @@ namespace CatalystAdaptor { template std::optional Execute_Field(int cycle, double time, int rank, Field& field, std::optional& node_in) { - static_assert(Field::dimension == 3, "CatalystAdaptor only supports 3D"); + static_assert(Field::dim == 3, "CatalystAdaptor only supports 3D"); // catalyst blueprint definition // https://docs.paraview.org/en/latest/Catalyst/blueprints.html // @@ -115,7 +116,7 @@ namespace CatalystAdaptor { typename Field::view_type::host_mirror_type host_view = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), field.getView()); - Kokkos::View + Kokkos::View host_view_layout_left("host_view_layout_left", field.getLayout().getLocalNDIndex()[0].length(), field.getLayout().getLocalNDIndex()[1].length(), diff --git a/test/stream/CMakeLists.txt b/test/stream/CMakeLists.txt index 0e4939810..7248e5f5f 100644 --- a/test/stream/CMakeLists.txt +++ b/test/stream/CMakeLists.txt @@ -20,13 +20,6 @@ target_link_libraries ( ${MPI_CXX_LIBRARIES} ) -add_executable (TestCatalystAdaptor-2D TestCatalystAdaptor_2D.cpp) -target_link_libraries ( - TestCatalystAdaptor-2D - ${IPPL_LIBS} - ${MPI_CXX_LIBRARIES} -) - # vi: set et ts=4 sw=4 sts=4: # Local Variables: diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index f3c77d51f..68ec3bc61 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -19,135 +19,88 @@ #include "Stream/InSitu/CatalystAdaptor.h" -constexpr unsigned int dim{3}; -using Mesh_t = ippl::UniformCartesian; -using Centering_t = Mesh_t::DefaultCentering; -using Field_t = ippl::Field; - -void dumpVTK(Field_t& rho, int nx, int ny, int nz, int iteration, double dx, double dy, double dz) { - typename Field_t::view_type::host_mirror_type host_view = rho.getHostMirror(); - - std::stringstream fname; - fname << "data/scalar_"; - fname << std::setw(4) << std::setfill('0') << iteration; - fname << ".vtk"; - - Kokkos::deep_copy(host_view, rho.getView()); - - Inform vtkout(nullptr, fname.str().c_str(), Inform::OVERWRITE); - vtkout.precision(10); - vtkout.setf(std::ios::scientific, std::ios::floatfield); - - if (vtkout.openedSuccessfully()) { - // start with header - vtkout << "# vtk DataFile Version 2.0" << endl; - vtkout << "CatalystAdaptor" << endl; - vtkout << "ASCII" << endl; - vtkout << "DATASET STRUCTURED_POINTS" << endl; - vtkout << "DIMENSIONS " << nx + 3 << " " << ny + 3 << " " << nz + 3 << endl; - vtkout << "ORIGIN " << -dx << " " << -dy << " " << -dz << endl; - vtkout << "SPACING " << dx << " " << dy << " " << dz << endl; - vtkout << "CELL_DATA " << (nx + 2) * (ny + 2) * (nz + 2) << endl; - - vtkout << "SCALARS Rho float" << endl; - vtkout << "LOOKUP_TABLE default" << endl; - for (int z = 0; z < nz + 2; z++) { - for (int y = 0; y < ny + 2; y++) { - for (int x = 0; x < nx + 2; x++) { - vtkout << host_view(x, y, z) << endl; - } - } - } - } else { - IpplException("TestCatalystAdaptor::dumpVTK", "opening of file was not successful"); - } -} int main(int argc, char* argv[]) { - Ippl ippl(argc, argv); - CatalystAdaptor::Initialize_Adios(argc, argv); - - const int pt{2}; - ippl::Index Ix(pt); - ippl::Index Iy{pt}; - ippl::Index Iz{pt}; - ippl::NDIndex owned(Ix, Iy, Iz); - - ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims - for (auto& d : allParallel) - d = ippl::PARALLEL; - - ippl::FieldLayout layout(owned, allParallel); - - constexpr double dx = {1.0 / double(pt)}; - constexpr double dy = {1.0 / double(pt)}; - constexpr double dz = {1.0 / double(pt)}; - ippl::Vector hx = {dx, dy, dz}; - ippl::Vector origin = {0, 0, 0}; - - Mesh_t mesh(owned, hx, origin); - - using field_type = ippl::Field; - - std::cout << layout << std::endl; - - field_type field(mesh, layout); - - field = 1.0; - - const ippl::NDIndex& lDom = layout.getLocalNDIndex(); - const int nghost = field.getNghost(); - using mdrange_type = Kokkos::MDRangePolicy>; - typename field_type::view_type& view = field.getView(); - - double time = {0.0}; - const double dt = {1}; - const unsigned int nt = {10}; - for (unsigned int it = 0; it < nt; ++it) { - Kokkos::parallel_for( - "Assign field", - mdrange_type( - {nghost, nghost, nghost}, - {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), - KOKKOS_LAMBDA(const int i, const int j, const int k) { - // local to global index conversion - // const size_t ig = i + lDom[0].first() - nghost; - const size_t jg = j + lDom[1].first() - nghost; - // const size_t kg = k + lDom[2].first() - nghost; - - // double x = (ig + 0.5) * hx[0] + origin[0]; - double y = (jg + 0.5) * hx[1] + origin[1]; - // double z = (kg + 0.5) * hx[2]; - - // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); - // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); - // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); - view(i, j, k) = y * time; - }); - - // call catalyst execute with 5th argument as nullopt or not specified - - std::optional node = std::nullopt; - CatalystAdaptor::Execute_Field(it, time, Ippl::Comm->rank(), field, node); - // print should be same as field data - time += dt; - - // dumpVTK only works with --info 5 and higher -// dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), -// field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), -// field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); - } + ippl::initialize(argc, argv); + { + constexpr unsigned int dim {3}; + + CatalystAdaptor::Initialize_Adios(argc, argv); + + const int pt{2}; + ippl::Index Ix(pt); + ippl::Index Iy{pt}; + ippl::Index Iz{pt}; + ippl::NDIndex owned(Ix, Iy, Iz); + + std::array isParallel{true}; // Specifies SERIAL, PARALLEL dims + + ippl::FieldLayout layout(MPI_COMM_WORLD, owned, isParallel); + + constexpr double dx = {1.0 / double(pt)}; + constexpr double dy = {1.0 / double(pt)}; + constexpr double dz = {1.0 / double(pt)}; + ippl::Vector hx = {dx, dy, dz}; + ippl::Vector origin = {0, 0, 0}; + + using Mesh_t = ippl::UniformCartesian; + using Centering_t = Mesh_t::DefaultCentering; + using field_type = ippl::Field; + + Mesh_t mesh(owned, hx, origin); + + std::cout << layout << std::endl; + + field_type field(mesh, layout); + + field = 1.0; + + const ippl::NDIndex& lDom = layout.getLocalNDIndex(); + const int nghost = field.getNghost(); + using mdrange_type = Kokkos::MDRangePolicy>; + const typename field_type::view_type& view = field.getView(); + + double time = {0.0}; + const double dt = {1}; + const unsigned int nt = {10}; + for (unsigned int it = 0; it < nt; ++it) { + Kokkos::parallel_for( + "Assign field", + mdrange_type( + {nghost, nghost, nghost}, + {view.extent(0) - nghost, view.extent(1) - nghost, view.extent(2) - nghost}), + KOKKOS_LAMBDA(const int i, const int j, const int k) { + // local to global index conversion + // const size_t ig = i + lDom[0].first() - nghost; + const size_t jg = j + lDom[1].first() - nghost; + double y = (jg + 0.5) * hx[1] + origin[1]; + view(i, j, k) = y * time; + }); + + // call catalyst execute with 5th argument as nullopt or not specified + + std::optional node = std::nullopt; + CatalystAdaptor::Execute_Field(it, time, ippl::Comm->rank(), field, node); + // print should be same as field data + time += dt; + + // dumpVTK only works with --info 5 and higher + // dumpVTK(field, field.get_mesh().getGridsize(0), field.get_mesh().getGridsize(1), + // field.get_mesh().getGridsize(2), it, field.get_mesh().getMeshSpacing(0), + // field.get_mesh().getMeshSpacing(1), field.get_mesh().getMeshSpacing(2)); + } - int nRanks = Ippl::Comm->size(); - for (int rank = 0; rank < nRanks; ++rank) { - if (rank == Ippl::Comm->rank()) { - std::string fname = "field_AllBC_" + std::to_string(rank) + ".dat"; - Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); - field.write(out); + int nRanks = ippl::Comm->size(); + for (int rank = 0; rank < nRanks; ++rank) { + if (rank == ippl::Comm->rank()) { + std::string fname = std::format("field_AllBC_{}.dat", std::to_string(rank)); + Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); + field.write(out); + } + ippl::Comm->barrier(); } - Ippl::Comm->barrier(); } - CatalystAdaptor::Finalize(); + ippl::finalize(); return 0; } diff --git a/test/stream/TestCatalystAdaptor_2D.cpp b/test/stream/TestCatalystAdaptor_2D.cpp deleted file mode 100644 index aaaf2c52c..000000000 --- a/test/stream/TestCatalystAdaptor_2D.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Tests the application for the Catalyst In-Situ Adaptor -// following environment variables do need to be exported -// -// export CATALYST_IMPLEMENTATION_PATHS=/lib/catalyst -// export CATALYST_IMPLEMENTATION_NAME=paraview -// -// on juwels these both are direclty set! -// -// export PARARVIEW_CATALYST_DIR=/lib/catalyst -// -// RUN -// ./TestCatalystAdaptor ./.py -// -// eg. -// ./build/test/stream/TestCatalystAdaptor ./test/stream/catalyst_pipeline.py - -#include "Ippl.h" - -#include - -#include "Stream/InSitu/CatalystAdaptor.h" - -int main(int argc, char* argv[]) { - Ippl ippl(argc, argv); - CatalystAdaptor::Initialize(argc, argv); - - constexpr unsigned int dim{2}; - - const int pt{2}; - ippl::Index Ix(pt); - ippl::Index Iy{pt}; - ippl::NDIndex owned(Ix, Iy); - - ippl::e_dim_tag allParallel[dim]; // Specifies SERIAL, PARALLEL dims - for (auto& d : allParallel) - d = ippl::PARALLEL; - - ippl::FieldLayout layout(owned, allParallel); - - constexpr double dx = {1.0 / double(pt)}; - constexpr double dy = {1.0 / double(pt)}; - ippl::Vector hx = {dx, dy}; - ippl::Vector origin = {0, 0}; - - using Mesh_t = ippl::UniformCartesian; - using Centering_t = Mesh_t::DefaultCentering; - - Mesh_t mesh(owned, hx, origin); - - typedef ippl::Field field_type; - - std::cout << layout << std::endl; - - field_type field(mesh, layout, 1); - - field = 1.0; - - const ippl::NDIndex& lDom = layout.getLocalNDIndex(); - const int nghost = field.getNghost(); - using mdrange_type = Kokkos::MDRangePolicy>; - typename field_type::view_type& view = field.getView(); - - double time = {0.0}; - const double dt = {1}; - const unsigned int nt = {5}; - for (unsigned int it = 0; it < nt; ++it) { - Kokkos::parallel_for( - "Assign field", - mdrange_type({nghost, nghost}, {view.extent(0) - nghost, view.extent(1) - nghost}), - KOKKOS_LAMBDA(const int i, const int j) { - // local to global index conversion - // const size_t ig = i + lDom[0].first() - nghost; - const size_t jg = j + lDom[1].first() - nghost; - // const size_t kg = k + lDom[2].first() - nghost; - // double x = (ig + 0.5) * hx[0] + origin[0]; - double y = (jg + 0.5) * hx[1] + origin[1]; - // double z = (kg + 0.5) * hx[2]; - - // view(i, j, k) = 3.0*pow(x,1) + 4.0*pow(y,1) + 5.0*pow(z,1); - // view(i, j, k) = sin(pi * x) * cos(pi * y) * exp(z); - // view(i, j, k) = sin(pi * x) * sin(pi * y) * sin(pi * z); - view(i, j) = y * time; - // std::cout << view(i,j) << std::endl; - }); - - CatalystAdaptor::Execute_Field(it, time, ippl.Comm.get()->rank(), field); // field - // print should be same as field data - time += dt; - } - - int nRanks = Ippl::Comm->size(); - for (int rank = 0; rank < nRanks; ++rank) { - if (rank == Ippl::Comm->rank()) { - std::string fname = "field_AllBC_" + std::to_string(rank) + ".dat"; - Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); - field.write(out); - } - Ippl::Comm->barrier(); - } - - CatalystAdaptor::Finalize(); - return 0; -} From 26367d02710a2e7166154e62de7294d026f1b2cc Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Dec 2023 23:24:52 +0100 Subject: [PATCH 107/113] add DefaultExecution space to ParticleContainer --- alpine/ParticleContainer.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpine/ParticleContainer.hpp b/alpine/ParticleContainer.hpp index 1ebf37509..2e3ece47a 100644 --- a/alpine/ParticleContainer.hpp +++ b/alpine/ParticleContainer.hpp @@ -6,8 +6,8 @@ // Define the ParticlesContainer class template -class ParticleContainer : public ippl::ParticleBase>{ - using Base = ippl::ParticleBase>; +class ParticleContainer : public ippl::ParticleBase,Kokkos::DefaultExecutionSpace>{ + using Base = ippl::ParticleBase, Kokkos::DefaultExecutionSpace>; private: ippl::ParticleAttrib q_m; // charge From 444277a5dfd2981586bb286e21bf59d3b13e4442 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 13 Dec 2023 23:26:10 +0100 Subject: [PATCH 108/113] update catalyst adaptor to work with new particlecontainer --- alpine/PenningTrapManager.h | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 46 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/alpine/PenningTrapManager.h b/alpine/PenningTrapManager.h index 45b2c534d..f713b84fe 100644 --- a/alpine/PenningTrapManager.h +++ b/alpine/PenningTrapManager.h @@ -337,7 +337,7 @@ class PenningTrapManager this->par2grid(); #ifdef ENABLE_CATALYST std::optional node = std::nullopt; - CatalystAdaptor::Execute_Field(it, time_m, ippl::Comm->rank(), fc->getRho(),node); + CatalystAdaptor::Execute_Particle(it, time_m, ippl::Comm->rank(), pc, node); #endif // Field solve diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 1950d71df..2d38615fb 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace CatalystAdaptor { using View_vector = Kokkos::View***, Kokkos::LayoutLeft, Kokkos::HostSpace>; - void setData(conduit_cpp::Node& node, const View_vector& view) { + inline void setData(conduit_cpp::Node& node, const View_vector& view) { node["electrostatic/association"].set_string("element"); node["electrostatic/topology"].set_string("mesh"); node["electrostatic/volume_dependent"].set_string("false"); @@ -34,7 +33,7 @@ namespace CatalystAdaptor { } using View_scalar = Kokkos::View; - void setData(conduit_cpp::Node& node, const View_scalar& view) { + inline void setData(conduit_cpp::Node& node, const View_scalar& view) { node["density/association"].set_string("element"); node["density/topology"].set_string("mesh"); node["density/volume_dependent"].set_string("false"); @@ -42,7 +41,7 @@ namespace CatalystAdaptor { node["density/values"].set_external(view.data(), view.size()); } - void callCatalystExecute(const conduit_cpp::Node& node) { + inline void callCatalystExecute(const conduit_cpp::Node& node) { // TODO: we should add here this IPPL-INFO stuff if ( static auto called {false}; !std::exchange(called, true) ) { @@ -198,10 +197,11 @@ namespace CatalystAdaptor { } - template - std::optional Execute_Particle(int cycle, double time, int rank, ChargedParticles& particle, std::optional& node_in) { + template + std::optional Execute_Particle(int cycle, double time, int rank, ParticleContainer& particleContainer, std::optional& node_in) { + assert((particleContainer->ID.getView().data() != nullptr) && "ID view should not be nullptr, might be missing the right execution space"); - auto layout_view = particle->R.getView(); + auto layout_view = particleContainer->R.getView(); // if node is passed in, append data to it conduit_cpp::Node node; @@ -222,16 +222,16 @@ namespace CatalystAdaptor { auto mesh = channel["data"]; mesh["coordsets/coords/type"].set_string("explicit"); - mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); mesh["topologies/mesh/type"].set_string("unstructured"); mesh["topologies/mesh/coordset"].set_string("coords"); mesh["topologies/mesh/elements/shape"].set_string("point"); - mesh["topologies/mesh/elements/connectivity"].set_external(particle->ID.getView().data(),particle->getLocalNum()); + mesh["topologies/mesh/elements/connectivity"].set_external(particleContainer->ID.getView().data(),particleContainer->getLocalNum()); - auto charge_view = particle->q.getView(); + //auto charge_view = particleContainer->getQ().getView(); // add values for scalar charge field auto fields = mesh["fields"]; @@ -239,26 +239,25 @@ namespace CatalystAdaptor { fields["charge/topology"].set_string("mesh"); fields["charge/volume_dependent"].set_string("false"); - fields["charge/values"].set_external(charge_view.data(), particle->getLocalNum()); + fields["charge/values"].set_external(particleContainer->getQ().getView().data(), particleContainer->getLocalNum()); // add values for vector velocity field - auto velocity_view = particle->P.getView(); + auto velocity_view = particleContainer->getP().getView(); fields["velocity/association"].set_string("vertex"); fields["velocity/topology"].set_string("mesh"); fields["velocity/volume_dependent"].set_string("false"); - fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particle->getLocalNum(),0 ,sizeof(double)*3); - fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particle->getLocalNum(),0 ,sizeof(double)*3); - fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particle->getLocalNum(),0 ,sizeof(double)*3); - + fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particleContainer->getLocalNum(),0 ,sizeof(double)*3); fields["position/association"].set_string("vertex"); fields["position/topology"].set_string("mesh"); fields["position/volume_dependent"].set_string("false"); - fields["position/values/x"].set_external(&layout_view.data()[0][0], particle->getLocalNum(), 0, sizeof(double)*3); - fields["position/values/y"].set_external(&layout_view.data()[0][1], particle->getLocalNum(), 0, sizeof(double)*3); - fields["position/values/z"].set_external(&layout_view.data()[0][2], particle->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); // this node we can return as the pointer to velocity and charge is globally valid if (node_in == std::nullopt) @@ -271,13 +270,12 @@ namespace CatalystAdaptor { } - template - void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ChargedParticles& particle) { + template + void Execute_Field_Particle(int cycle, double time, int rank, Field& field, ParticleContainer& particle) { auto node = std::make_optional(); node = CatalystAdaptor::Execute_Particle(cycle, time, rank, particle, node); CatalystAdaptor::Execute_Field(cycle, time, rank, field, node); - } void Finalize() { From d4dc69a1ed3eeb0f3b6d5d14f64b956ab8efa76c Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 14 Dec 2023 15:28:52 +0100 Subject: [PATCH 109/113] fix deletion of lines from merge commit In #e414f19 the lines from https://github.com/IPPL-framework/ippl/blob/3c74adc1056c94827a960ba535a9a0839c6ef6d2/alpine/ChargedParticles.hpp#L415-L419 where deleted, as they should be there this commit reverts that. --- alpine/ChargedParticles.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/alpine/ChargedParticles.hpp b/alpine/ChargedParticles.hpp index 5a4b2c45d..f79b96234 100644 --- a/alpine/ChargedParticles.hpp +++ b/alpine/ChargedParticles.hpp @@ -14,10 +14,6 @@ #include "PoissonSolvers/P3MSolver.h" #include "PoissonSolvers/PoissonCG.h" -#ifdef ENABLE_CATALYST -#include "Stream/InSitu/CatalystAdaptor.h" -#endif - unsigned LoggingPeriod = 1; // some typedefs @@ -416,9 +412,14 @@ class ChargedParticles : public ippl::ParticleBase { } } - // dumpVTK(rho_m, nr_m[0], nr_m[1], nr_m[2], iteration, hrField[0], hrField[1], hrField[2]); - //CatalystAdaptor::Execute_Field(iteration, ); + double cellVolume = + std::reduce(hrField.begin(), hrField.end(), 1., std::multiplies()); + rho_m = rho_m / cellVolume; + rhoNorm_m = norm(rho_m); + IpplTimings::stopTimer(sumTimer); + + // dumpVTK(rho_m, nr_m[0], nr_m[1], nr_m[2], iteration, hrField[0], hrField[1], hrField[2]); // rho = rho_e - rho_i (only if periodic BCs) if (stype_m != "OPEN") { From ba5b00dbb0e1263e962b92fe0fa1b206c77b53db Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Wed, 10 Jan 2024 08:52:58 +0200 Subject: [PATCH 110/113] add initial draft for IN-SITU documentation --- IN-SITU.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 IN-SITU.md diff --git a/IN-SITU.md b/IN-SITU.md new file mode 100644 index 000000000..24423cb08 --- /dev/null +++ b/IN-SITU.md @@ -0,0 +1,90 @@ +# In Situ Visualization with Catalyst +If Catalyst is not available as a module on the machine, this is the first to build. +For a more indepth documentation on how to build catalyst check the documentation, here are only minimal steps described. +## Build and Install Catalyst +### Requirements for Catalyst +* MPI + +1. Configuration +```sh +git clone https://gitlab.kitware.com/paraview/catalyst.git +cd catalyst +git checkout v2.0.0-rc4 +cmake -S . \ + -B build \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCATALYST_USE_MPI=ON \ + -DCMAKE_INSTALL_PREFIX=../catalyst_install +``` +2. Build and Test +`-j` flag is for parallel build and parallel test +```sh +cmake --build build -j 4 +cmake --install build +ctest --test-dir build/tests -j 4 +``` +The tests should all pass, however for some of them you need to export the `catalyst_DIR` path. +So inspect the output of the failed ones why they failed! + +## Build IPPL with Catalyst +I would recommend to use the install script from IPPL for building IPPL and then after that setting `ENABLE_CATALYST` to `ON`, this procedure would then be: +```sh +./ippl-build-scripts/999-build-everything -t serial -i +cmake ippl/build_serial +``` +Now in order you need to pass the `Catalyst_Dir` path to the install script. +You can do that in the cli over: +```sh +cmake build_serial\ + -DENABLE_CATALYST=ON \ + -DCATALYST_DIR= +``` +or using the cmake gui over: +```sh +ccmake build_serial +``` + +Now build again and you will have catalyst enabled. + + +## Starting a simulation with Catalyst +An general set for examples can be seen on [https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Catalyst2](https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/Catalyst2). +Generally the setup is always similar and starting a simulation is usually as: +```sh +./some-program ./ +``` +Some sample scripts for ippl do lay under the `./test/stream/` directory. +For all scripts the `CATALYST_IMPLEMENTATION_NAME` should be set to `paraview` and `CATALYST_IMPLEMENTATION_PATHS` should be set to the proper library in the ParaView folder. +```sh +export CATALYST_IMPLEMENTATION_PATHS="/ParaView-5.11.1-MPI-Linux-Python3.9-x86_64/lib/catalyst" +export CATALYST_IMPLEMENTATION_NAME="ParaView" +``` + +I assume that you are familiar with the examples and manage to start them with catalyst. + +# Tips and Tricks +## ParaView Live +In order to use the ParaView live feature with an existing Catalyst script the following options need to be set +```python +# Catalyst options +from paraview import catalyst +options = catalyst.Options() +options.GlobalTrigger = 'TimeStep' +options.EnableCatalystLive = 1 +options.CatalystLiveTrigger = 'TimeStep' +``` +After these settings you can start `ParaView -> Catalyst -> Connect`, accept the port and then ParaView is waiting for catalyst to connect. +Now also set the simulation to pause over `ParaView -> Catalyst -> Pause Simulation`, then start the simulation. +Now when it worked out you can see on Pipeline Browser of ParaView a small symbol left from catalyst stuff, this needs to be activated to then access the catalyst data. + +## Creating a new script +Using ParaView Live you can quite easy get the data into the position and angle that you like for the simulation and depending on that you can then create different filter to exporting data. +Some choices do include dumping a csv, creating a vtp or also dumping images. + +General workflow would be: +1. Add `CatalystAdaptor::Initialize()` directly after the MPI/IPPL initialize +2. Add `CatalystAdaptor::Execute.....()` where you want your data to be extracted +3. Add `CatalystAdaptor::Finalize()` directly before the MPI/IPPL finalize +4. Start simulation with matching channel names in live mode +5. Generate extraction / dump script +6. Pass the script as argument to the program executable From 593b5f993c379fd17f3a9b38e0f461f9e317f876 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Thu, 23 May 2024 12:05:42 +0200 Subject: [PATCH 111/113] update catalyst call arguments --- alpine/PenningTrapManager.h | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alpine/PenningTrapManager.h b/alpine/PenningTrapManager.h index ab0d45811..5244c76f6 100644 --- a/alpine/PenningTrapManager.h +++ b/alpine/PenningTrapManager.h @@ -286,7 +286,7 @@ class PenningTrapManager : public AlpineManager { this->par2grid(); #ifdef ENABLE_CATALYST std::optional node = std::nullopt; - CatalystAdaptor::Execute_Particle(it, time_m, ippl::Comm->rank(), pc, node); + CatalystAdaptor::Execute_Particle(it, this->time_m, ippl::Comm->rank(), pc, node); #endif // Field solve diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 2d38615fb..78a02ef62 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -239,10 +239,10 @@ namespace CatalystAdaptor { fields["charge/topology"].set_string("mesh"); fields["charge/volume_dependent"].set_string("false"); - fields["charge/values"].set_external(particleContainer->getQ().getView().data(), particleContainer->getLocalNum()); + fields["charge/values"].set_external(particleContainer->q.getView().data(), particleContainer->getLocalNum()); // add values for vector velocity field - auto velocity_view = particleContainer->getP().getView(); + auto velocity_view = particleContainer->P.getView(); fields["velocity/association"].set_string("vertex"); fields["velocity/topology"].set_string("mesh"); fields["velocity/volume_dependent"].set_string("false"); From 73af46b80378d18e4840b76ccdde253c420ae4ca Mon Sep 17 00:00:00 2001 From: Sriramkrishnan Muralikrishnan Date: Tue, 26 Nov 2024 14:28:34 +0100 Subject: [PATCH 112/113] Density field and particles made working again --- alpine/PenningTrapManager.h | 9 +++-- src/CMakeLists.txt | 2 +- src/Stream/InSitu/CatalystAdaptor.h | 51 ++++++++++++++++++++--------- test/stream/TestCatalystAdaptor.cpp | 9 +++-- test/stream/dump_density_field.py | 4 +-- test/stream/dump_electric_field.py | 4 +-- test/stream/dump_particles.py | 4 +-- 7 files changed, 56 insertions(+), 27 deletions(-) diff --git a/alpine/PenningTrapManager.h b/alpine/PenningTrapManager.h index 5244c76f6..0a899704a 100644 --- a/alpine/PenningTrapManager.h +++ b/alpine/PenningTrapManager.h @@ -64,7 +64,7 @@ class PenningTrapManager : public AlpineManager { nrMax_m = 2048; // Max grid size in our studies dxFinest_m = length_m[0] / nrMax_m; - this->dt_m = 0.5 * dxFinest_m; // size of timestep + this->dt_m = 0.05;//0.5 * dxFinest_m; // size of timestep this->it_m = 0; this->time_m = 0.0; @@ -286,7 +286,12 @@ class PenningTrapManager : public AlpineManager { this->par2grid(); #ifdef ENABLE_CATALYST std::optional node = std::nullopt; - CatalystAdaptor::Execute_Particle(it, this->time_m, ippl::Comm->rank(), pc, node); + //CatalystAdaptor::Execute_Particle(it, this->time_m, ippl::Comm->rank(), pc, node); + //auto *rho = &this->fcontainer_m->getRho(); + //CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *rho, node); + auto *E = &this->fcontainer_m->getE(); + CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *E, node); + //CatalystAdaptor::Execute_Field_Particle(it, this->time_m, ippl::Comm->rank(), *E, pc); #endif // Field solve diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c8cf24b6..b5fd3eb26 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,7 +124,7 @@ target_compile_definitions(ippl PUBLIC target_link_libraries(ippl PUBLIC Kokkos::kokkos - $<$:Heffte::Heffte> + $<$:Heffte> $<$:catalyst::catalyst> ) diff --git a/src/Stream/InSitu/CatalystAdaptor.h b/src/Stream/InSitu/CatalystAdaptor.h index 78a02ef62..514df25c2 100644 --- a/src/Stream/InSitu/CatalystAdaptor.h +++ b/src/Stream/InSitu/CatalystAdaptor.h @@ -44,9 +44,9 @@ namespace CatalystAdaptor { inline void callCatalystExecute(const conduit_cpp::Node& node) { // TODO: we should add here this IPPL-INFO stuff - if ( static auto called {false}; !std::exchange(called, true) ) { - catalyst_conduit_node_print(conduit_cpp::c_node(&node)); - } + //if ( static auto called {false}; !std::exchange(called, true) ) { + // catalyst_conduit_node_print(conduit_cpp::c_node(&node)); + //} catalyst_status err = catalyst_execute(conduit_cpp::c_node(&node)); if (err != catalyst_status_ok) { @@ -201,7 +201,15 @@ namespace CatalystAdaptor { std::optional Execute_Particle(int cycle, double time, int rank, ParticleContainer& particleContainer, std::optional& node_in) { assert((particleContainer->ID.getView().data() != nullptr) && "ID view should not be nullptr, might be missing the right execution space"); - auto layout_view = particleContainer->R.getView(); + //auto layout_view = particleContainer->R.getView(); + typename ippl::ParticleAttrib>::HostMirror R_host = particleContainer->R.getHostMirror(); + typename ippl::ParticleAttrib>::HostMirror P_host = particleContainer->P.getHostMirror(); + typename ippl::ParticleAttrib::HostMirror q_host = particleContainer->q.getHostMirror(); + typename ippl::ParticleAttrib::HostMirror ID_host = particleContainer->ID.getHostMirror(); + Kokkos::deep_copy(R_host, particleContainer->R.getView()); + Kokkos::deep_copy(P_host, particleContainer->P.getView()); + Kokkos::deep_copy(q_host, particleContainer->q.getView()); + Kokkos::deep_copy(ID_host, particleContainer->ID.getView()); // if node is passed in, append data to it conduit_cpp::Node node; @@ -222,14 +230,18 @@ namespace CatalystAdaptor { auto mesh = channel["data"]; mesh["coordsets/coords/type"].set_string("explicit"); - mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); - mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //mesh["coordsets/coords/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //mesh["coordsets/coords/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //mesh["coordsets/coords/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/x"].set_external(&R_host.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/y"].set_external(&R_host.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + mesh["coordsets/coords/values/z"].set_external(&R_host.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); mesh["topologies/mesh/type"].set_string("unstructured"); mesh["topologies/mesh/coordset"].set_string("coords"); mesh["topologies/mesh/elements/shape"].set_string("point"); - mesh["topologies/mesh/elements/connectivity"].set_external(particleContainer->ID.getView().data(),particleContainer->getLocalNum()); + //mesh["topologies/mesh/elements/connectivity"].set_external(particleContainer->ID.getView().data(),particleContainer->getLocalNum()); + mesh["topologies/mesh/elements/connectivity"].set_external(ID_host.data(),particleContainer->getLocalNum()); //auto charge_view = particleContainer->getQ().getView(); @@ -239,25 +251,32 @@ namespace CatalystAdaptor { fields["charge/topology"].set_string("mesh"); fields["charge/volume_dependent"].set_string("false"); - fields["charge/values"].set_external(particleContainer->q.getView().data(), particleContainer->getLocalNum()); + //fields["charge/values"].set_external(particleContainer->q.getView().data(), particleContainer->getLocalNum()); + fields["charge/values"].set_external(q_host.data(), particleContainer->getLocalNum()); // add values for vector velocity field - auto velocity_view = particleContainer->P.getView(); + //auto velocity_view = particleContainer->P.getView(); fields["velocity/association"].set_string("vertex"); fields["velocity/topology"].set_string("mesh"); fields["velocity/volume_dependent"].set_string("false"); - fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particleContainer->getLocalNum(),0 ,sizeof(double)*3); - fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particleContainer->getLocalNum(),0 ,sizeof(double)*3); - fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + //fields["velocity/values/x"].set_external(&velocity_view.data()[0][0], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + //fields["velocity/values/y"].set_external(&velocity_view.data()[0][1], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + //fields["velocity/values/z"].set_external(&velocity_view.data()[0][2], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/x"].set_external(&P_host.data()[0][0], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/y"].set_external(&P_host.data()[0][1], particleContainer->getLocalNum(),0 ,sizeof(double)*3); + fields["velocity/values/z"].set_external(&P_host.data()[0][2], particleContainer->getLocalNum(),0 ,sizeof(double)*3); fields["position/association"].set_string("vertex"); fields["position/topology"].set_string("mesh"); fields["position/volume_dependent"].set_string("false"); - fields["position/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); - fields["position/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); - fields["position/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //fields["position/values/x"].set_external(&layout_view.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //fields["position/values/y"].set_external(&layout_view.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + //fields["position/values/z"].set_external(&layout_view.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/x"].set_external(&R_host.data()[0][0], particleContainer->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/y"].set_external(&R_host.data()[0][1], particleContainer->getLocalNum(), 0, sizeof(double)*3); + fields["position/values/z"].set_external(&R_host.data()[0][2], particleContainer->getLocalNum(), 0, sizeof(double)*3); // this node we can return as the pointer to velocity and charge is globally valid if (node_in == std::nullopt) diff --git a/test/stream/TestCatalystAdaptor.cpp b/test/stream/TestCatalystAdaptor.cpp index 68ec3bc61..6641253c1 100644 --- a/test/stream/TestCatalystAdaptor.cpp +++ b/test/stream/TestCatalystAdaptor.cpp @@ -16,6 +16,7 @@ #include "Ippl.h" #include +//#include #include "Stream/InSitu/CatalystAdaptor.h" @@ -93,8 +94,12 @@ int main(int argc, char* argv[]) { int nRanks = ippl::Comm->size(); for (int rank = 0; rank < nRanks; ++rank) { if (rank == ippl::Comm->rank()) { - std::string fname = std::format("field_AllBC_{}.dat", std::to_string(rank)); - Inform out("Output", fname.c_str(), Inform::OVERWRITE, rank); + std::stringstream fname; + fname << "field_AllBC_"; + fname << ippl::Comm->rank(); + fname << ".dat"; + //std::string fname = std::format("field_AllBC_{}.dat", std::to_string(rank)); + Inform out("Output", fname.str().c_str(), Inform::OVERWRITE, rank); field.write(out); } ippl::Comm->barrier(); diff --git a/test/stream/dump_density_field.py b/test/stream/dump_density_field.py index 84c2eb07d..94bb74553 100644 --- a/test/stream/dump_density_field.py +++ b/test/stream/dump_density_field.py @@ -213,8 +213,8 @@ options.ExtractsOutputDirectory = 'datasets_density' options.GenerateCinemaSpecification = 1 options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' +#options.EnableCatalystLive = 1 +#options.CatalystLiveTrigger = 'TimeStep' # ------------------------------------------------------------------------------ if __name__ == '__main__': diff --git a/test/stream/dump_electric_field.py b/test/stream/dump_electric_field.py index e54cfd3b2..4ec2006a8 100644 --- a/test/stream/dump_electric_field.py +++ b/test/stream/dump_electric_field.py @@ -196,8 +196,8 @@ options.ExtractsOutputDirectory = 'datasets_electric' options.GenerateCinemaSpecification = 1 options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' +#options.EnableCatalystLive = 1 +#options.CatalystLiveTrigger = 'TimeStep' # ------------------------------------------------------------------------------ if __name__ == '__main__': diff --git a/test/stream/dump_particles.py b/test/stream/dump_particles.py index 62cedfc67..b6200ccd9 100644 --- a/test/stream/dump_particles.py +++ b/test/stream/dump_particles.py @@ -150,8 +150,8 @@ options.ExtractsOutputDirectory = 'datasets_particles' options.GenerateCinemaSpecification = 1 options.GlobalTrigger = 'TimeStep' -options.EnableCatalystLive = 1 -options.CatalystLiveTrigger = 'TimeStep' +#options.EnableCatalystLive = 1 +#options.CatalystLiveTrigger = 'TimeStep' # ------------------------------------------------------------------------------ if __name__ == '__main__': From 5a0a0c471f3bf3c1d3afa2d5e237414d2d458f12 Mon Sep 17 00:00:00 2001 From: Sriramkrishnan Muralikrishnan Date: Wed, 27 Nov 2024 10:51:22 +0100 Subject: [PATCH 113/113] Efield plotting to rho field changed --- alpine/PenningTrapManager.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alpine/PenningTrapManager.h b/alpine/PenningTrapManager.h index 0a899704a..08fe37f99 100644 --- a/alpine/PenningTrapManager.h +++ b/alpine/PenningTrapManager.h @@ -287,10 +287,10 @@ class PenningTrapManager : public AlpineManager { #ifdef ENABLE_CATALYST std::optional node = std::nullopt; //CatalystAdaptor::Execute_Particle(it, this->time_m, ippl::Comm->rank(), pc, node); - //auto *rho = &this->fcontainer_m->getRho(); - //CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *rho, node); - auto *E = &this->fcontainer_m->getE(); - CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *E, node); + auto *rho = &this->fcontainer_m->getRho(); + CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *rho, node); + //auto *E = &this->fcontainer_m->getE(); + //CatalystAdaptor::Execute_Field(it, this->time_m, ippl::Comm->rank(), *E, node); //CatalystAdaptor::Execute_Field_Particle(it, this->time_m, ippl::Comm->rank(), *E, pc); #endif