Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline example #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 62 additions & 35 deletions Tutorial/gray-scott/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,82 @@ add_executable(pdf_calc analysis/pdf_calc.cpp)
target_link_libraries(pdf_calc adios2::adios2 MPI::MPI_C)

option(VTK "Build VTK apps")
if (VTK_ROOT)
if(VTK_ROOT)
set(VTK ON)
endif(VTK_ROOT)
endif()

if (VTK)
if(VTK)
message(STATUS "Configuring VTK apps")

find_package(VTK COMPONENTS
vtkFiltersCore
vtkIOImage
vtkIOXML
)

find_package(VTK COMPONENTS vtkFiltersCore vtkIOImage vtkIOXML)
if(VTK_FOUND)
message(STATUS "Adding isosurface")
add_executable(isosurface analysis/isosurface.cpp)
target_link_libraries(isosurface adios2::adios2 ${VTK_LIBRARIES}
MPI::MPI_C)
endif(VTK_FOUND)
target_include_directories(isosurface PRIVATE ${VTK_INCLUDE_DIRS})
target_link_libraries(isosurface
adios2::adios2 MPI::MPI_C ${VTK_LIBRARIES}
)
endif()

find_package(VTK COMPONENTS
vtkFiltersCore
vtkFiltersGeometry
vtkCommonCore vtkCommonDataModel vtkFiltersCore vtkFiltersGeneral
vtkIOImage vtkIOXML vtkIOParallelXML vtkParallelMPI
)

if(VTK_FOUND)
message(STATUS "Adding libisosurface")
add_library(libisosurface analysis/lib-isosurface.cpp)
target_include_directories(libisosurface
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/analysis
PRIVATE ${VTK_INCLUDE_DIRS}
)
target_link_libraries(libisosurface
PUBLIC adios2::adios2 MPI::MPI_C
PRIVATE ${VTK_LIBRARIES}
)

message(STATUS "Adding block-isosurface")
add_executable(block-isosurface analysis/block-isosurface.cpp)
target_link_libraries(block-isosurface
adios2::adios2 MPI::MPI_C libisosurface
)

message(STATUS "Adding gray-scott-iso")
add_executable(gray-scott-iso
simulation/main.cpp
simulation/gray-scott.cpp
simulation/settings.cpp
simulation/writer.cpp
)
target_link_libraries(gray-scott-iso
adios2::adios2 MPI::MPI_C libisosurface
)
target_compile_definitions(gray-scott-iso PRIVATE USE_INLINE_ISOSURFACE=1)
endif()

find_package(VTK COMPONENTS vtkFiltersCore vtkFiltersGeometry vtkIOXML)
if(VTK_FOUND)
add_executable(find_blobs analysis/find_blobs.cpp)
target_link_libraries(find_blobs adios2::adios2 ${VTK_LIBRARIES}
MPI::MPI_C)
endif(VTK_FOUND)

find_package(VTK COMPONENTS
vtkFiltersGeneral
)
target_include_directories(find_blobs PRIVATE ${VTK_INCLUDE_DIRS})
target_link_libraries(find_blobs
adios2::adios2 MPI::MPI_C ${VTK_LIBRARIES}
)
endif()

find_package(VTK COMPONENTS vtkFiltersGeneral)
if(VTK_FOUND)
add_executable(compute_curvature analysis/curvature.cpp)
target_link_libraries(compute_curvature adios2::adios2 ${VTK_LIBRARIES}
MPI::MPI_C)
endif(VTK_FOUND)


find_package(VTK COMPONENTS
vtkRenderingOpenGL2
vtkViewsInfovis
)
target_include_directories(compute_curvature PRIVATE ${VTK_INCLUDE_DIRS})
target_link_libraries(compute_curvature
adios2::adios2 MPI::MPI_C ${VTK_LIBRARIES}
)
endif()

find_package(VTK COMPONENTS vtkRenderingOpenGL2 vtkViewsInfovis)
if(VTK_FOUND)
add_executable(render_isosurface plot/render_isosurface.cpp)
target_link_libraries(render_isosurface adios2::adios2 ${VTK_LIBRARIES}
MPI::MPI_C)
endif(VTK_FOUND)
endif(VTK)
target_include_directories(render_isosurface PRIVATE ${VTK_INCLUDE_DIRS})
target_link_libraries(render_isosurface
adios2::adios2 MPI::MPI_C ${VTK_LIBRARIES}
)
endif()
endif()
59 changes: 59 additions & 0 deletions Tutorial/gray-scott/analysis/block-isosurface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <iostream>
#include <string>
#include <stdexcept>
#include <vector>

#include <mpi.h>
#include <adios2.h>

#ifdef ENABLE_TIMERS
#include "../common/timer.hpp"
#endif

#include <lib-isosurface.h>

int main(int argc, char **argv)
{
int mpiRank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);

if(argc < 4)
{
if(mpiRank == 0)
{
std::cerr << "Error: Too few arguments\n"
<< "Usage: " << argv[0] << " input output isovalues...\n";
}
MPI_Abort(MPI_COMM_WORLD, -1);
}

const std::string inputFName(argv[1]);
const std::string outputFName(argv[2]);

std::vector<double> isoValues;
for (int i = 3; i < argc; i++)
{
isoValues.push_back(std::stod(argv[i]));
}

try
{
adios2::ADIOS adios("adios2.xml", MPI_COMM_WORLD, adios2::DebugON);
adios2::IO io = adios.DeclareIO("SimulationOutput");

IsoSurface analysis(MPI_COMM_WORLD, io, inputFName, outputFName,
isoValues, false);

while(analysis.Step());
}
catch(const std::exception &ex)
{
std::cerr << "Error: " << ex.what() << "\n";
MPI_Abort(MPI_COMM_WORLD, -2);
}

MPI_Finalize();

return 0;
}
Loading