Commit 607302c0 authored by Nicole Marsaglia's avatar Nicole Marsaglia

Conduit Data Adaptor and small conduit multi-domain example.

parent 56debf87
###############################################################################
# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
# LLNL-CODE-716457
#
# All rights reserved.
#
# This file is part of Ascent.
#
# For details, see: http://ascent.readthedocs.io/.
#
# Please also read ascent/LICENSE
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
###############################################################################
#
# Setup Conduit
#
###############################################################################
#
# Expects CONDUIT_DIR to point to a Conduit installations.
#
# This file defines the following CMake variables:
# CONDUIT_FOUND - If Conduit was found
# CONDUIT_INCLUDE_DIRS - The Conduit include directories
#
# If found, the conduit CMake targets will also be imported.
# The main conduit library targets are:
# conduit
# conduit_relay
# conduit_relay_mpi (if conduit was built with mpi support)
# conduit_blueprint
#
###############################################################################
###############################################################################
# Check for CONDUIT_DIR
###############################################################################
if(NOT CONDUIT_DIR)
MESSAGE(FATAL_ERROR "Could not find Conduit. Conduit requires explicit CONDUIT_DIR.")
endif()
if(NOT EXISTS ${CONDUIT_DIR}/lib/cmake/conduit.cmake)
MESSAGE(FATAL_ERROR "Could not find Conduit CMake include file (${CONDUIT_DIR}/lib/cmake/conduit.cmake)")
endif()
###############################################################################
# Import Conduit's CMake targets
###############################################################################
include(${CONDUIT_DIR}/lib/cmake/conduit.cmake)
###############################################################################
# Set remaning CMake variables
###############################################################################
# we found Conduit
set(CONDUIT_FOUND TRUE)
# provide location of the headers in CONDUIT_INCLUDE_DIRS
set(CONDUIT_INCLUDE_DIRS ${CONDUIT_DIR}/include/conduit)
......@@ -31,6 +31,7 @@ set(ENABLE_CATALYST @ENABLE_CATALYST@)
set(ENABLE_CATALYST_PYTHON @ENABLE_CATALYST_PYTHON@)
set(ENABLE_LIBSIM @ENABLE_LIBSIM@)
set(ENABLE_ADIOS @ENABLE_ADIOS@)
set(ENABLE_CONDUIT @ENABLE_CONDUIT@)
set(ENABLE_VTK_GENERIC_ARRAYS @ENABLE_VTK_GENERIC_ARRAYS@)
set(ENABLE_VTK_MPI @ENABLE_VTK_MPI@)
set(ENABLE_VTK_IO @ENABLE_VTK_IO@)
......@@ -68,6 +69,9 @@ endif()
if(ENABLE_ADIOS)
include(adios)
endif()
if(ENABLE_CONDUIT)
include(sconduit)
endif()
include(senseiCore)
if(ENABLE_PYTHON)
include(python)
......
if(ENABLE_CONDUIT)
find_package(Conduit REQUIRED)
add_library(sconduit INTERFACE)
target_link_libraries(sconduit INTERFACE conduit conduit_relay conduit_blueprint)
target_include_directories(sconduit SYSTEM INTERFACE ${CONDUIT_INCLUDE_DIRS})
install(TARGETS sconduit EXPORT sconduit)
install(EXPORT sconduit DESTINATION lib/cmake EXPORT_LINK_INTERFACE_LIBRARIES)
endif()
......@@ -20,6 +20,10 @@ cmake_dependent_option(ENABLE_ADIOS
"Enable analysis methods that use ADIOS" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_CONDUIT
"Enable analysis methods that use Conduit" OFF
"ENABLE_SENSEI" OFF)
cmake_dependent_option(ENABLE_LIBSIM
"Enable analysis methods that use Libsim" OFF
"ENABLE_SENSEI" OFF)
......@@ -39,6 +43,7 @@ cmake_dependent_option(ENABLE_VTK_M
option(ENABLE_PARALLEL3D "Enable Parallel3D miniapp" ON)
option(ENABLE_OSCILLATORS "Enable Oscillators miniapp" ON)
option(ENABLE_CONDUITTEST "Enable Conduit miniapp" OFF)
message(STATUS "ENABLE_SENSEI=${ENABLE_SENSEI}")
message(STATUS "ENABLE_PYTHON=${ENABLE_PYTHON}")
......@@ -46,8 +51,10 @@ message(STATUS "ENABLE_VTK_GENERIC_ARRAYS=${ENABLE_VTK_GENERIC_ARRAYS}")
message(STATUS "ENABLE_CATALYST=${ENABLE_CATALYST}")
message(STATUS "ENABLE_CATALYST_PYTHON=${ENABLE_CATALYST}")
message(STATUS "ENABLE_ADIOS=${ENABLE_ADIOS}")
message(STATUS "ENABLE_CONDUIT=${ENABLE_CONDUIT}")
message(STATUS "ENABLE_LIBSIM=${ENABLE_LIBSIM}")
message(STATUS "ENABLE_VTK_IO=${ENABLE_VTK_IO}")
message(STATUS "ENABLE_VTK_MPI=${ENABLE_VTK_MPI}")
message(STATUS "ENABLE_PARALLEL3D=${ENABLE_PARALLEL3D}")
message(STATUS "ENABLE_OSCILLATORS=${ENABLE_OSCILLATORS}")
message(STATUS "ENABLE_CONDUITTEST=${ENABLE_CONDUITTEST}")
......@@ -12,6 +12,7 @@ include(adios)
include(vtk)
include(libsim)
include(catalyst)
include(conduit)
include(python)
include(version)
include(config)
......
......@@ -5,6 +5,13 @@ else()
message(STATUS "Disabled: Parallel3D miniapp.")
endif()
if(ENABLE_CONDUITTEST)
message(STATUS "Enabled: CONDUIT TEST miniapp.")
add_subdirectory(conduit_test)
else()
message(STATUS "Disabled: conduit_test miniapp.")
endif()
if(ENABLE_OSCILLATORS)
message(STATUS "Enabled: Oscillators miniapp.")
add_subdirectory(oscillators)
......
set(sources conduitTest.cpp bridge.cpp)
set(libs mpi diy grid opts thread timer util sconduit sensei)
add_executable(conduitTest ${sources})
target_link_libraries(conduitTest ${libs})
#include <conduit.hpp>
#include <ConduitDataAdaptor.h>
#include "bridge.h"
#include <Error.h>
#include <mpi.h>
#include <string>
#include <ConfigurableAnalysis.h>
#include <vtkNew.h>
#include <vtkSmartPointer.h>
#include <vtkDataObject.h>
#include <vtkObjectBase.h>
#include <iostream>
namespace BridgeGuts
{
static vtkSmartPointer<sensei::ConduitDataAdaptor> DataAdaptor;
static vtkSmartPointer<sensei::ConfigurableAnalysis> AnalysisAdaptor;
static MPI_Comm comm;
}
void initialize(MPI_Comm comm,
conduit::Node* node,
const std::string& config_file)
{
//setup communication
BridgeGuts::comm = comm;
//data adaptor
BridgeGuts::DataAdaptor = vtkSmartPointer<sensei::ConduitDataAdaptor>::New();
BridgeGuts::DataAdaptor->Initialize(node);
//analysis adaptor
BridgeGuts::AnalysisAdaptor = vtkSmartPointer<sensei::ConfigurableAnalysis>::New();
BridgeGuts::AnalysisAdaptor->Initialize(config_file);
}
void analyze(conduit::Node* node)
{
BridgeGuts::DataAdaptor->SetNode(node);
if(!BridgeGuts::AnalysisAdaptor->Execute(BridgeGuts::DataAdaptor))
{
SENSEI_ERROR("ERROR: Failed to execute analysis")
abort();
}
BridgeGuts::DataAdaptor->ReleaseData();
}
void finalize()
{
BridgeGuts::AnalysisAdaptor->Finalize();
BridgeGuts::AnalysisAdaptor = NULL;
BridgeGuts::DataAdaptor = NULL;
}
#ifndef _CONDUIT_SENSI_BRIDGE_H
#define _CONDUIT_SENSI_BRIDGE_H
#include <mpi.h>
#include <string>
#include <conduit.hpp>
//called before the simulation loops
void initialize(MPI_Comm world,
conduit::Node* node,
const std::string& config_file);
//called during simulation loop to update node
void analyze(conduit::Node* node);
//called for cleanup
void finalize();
#endif
#include <conduit.hpp>
#include <cstring>
#include <conduit_blueprint.hpp>
#include <mpi.h>
#include "bridge.h"
int main(int argc, char* argv[])
{
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
conduit::Node res;
conduit::blueprint::mesh::examples::spiral( 7, res);
initialize(MPI_COMM_WORLD, &res, argv[1]);
analyze(&res);
finalize();
MPI_Finalize();
return 0;
}
......@@ -10,6 +10,11 @@ if (ENABLE_SENSEI)
set(senseiCore_libs mpi pugixml vtk thread ArrayIO timer diy grid)
if(ENABLE_CONDUIT)
list(APPEND senseiCore_sources ConduitDataAdaptor.cxx)
list(APPEND senseiCore_libs sconduit)
endif()
if(ENABLE_CATALYST)
list(APPEND senseiCore_sources CatalystAnalysisAdaptor.cxx
CatalystSlice.cxx CatalystUtilities.cxx)
......
This diff is collapsed.
#ifndef CONDUIT_DATAADAPTOR_H
#define CONDUIT_DATAADAPTOR_H
#include <vector>
#include <vtkDataArray.h>
#include <vtkSmartPointer.h>
#include <vtkMultiBlockDataSet.h>
#include <sensei/DataAdaptor.h>
#include <conduit.hpp>
namespace sensei
{
class ConduitDataAdaptor : public sensei::DataAdaptor
{
public:
static ConduitDataAdaptor* New();
senseiTypeMacro(ConduitDataAdaptor, sensei::DataAdaptor);
/// @brief Initialize the data adaptor.
///
/// This initializes the data adaptor. This must be called once per simulation run.
/// @param node contains the current data that will be visualized.
void Initialize(conduit::Node* node);
void SetNode(conduit::Node* node);
int GetMeshName(unsigned int id, std::string &meshName) override;
int GetNumberOfMeshes(unsigned int &numMeshes) override;
int GetMesh(const std::string &meshName,
bool structureOnly,
vtkDataObject* &mesh) override;
int AddArray(vtkDataObject* mesh,
const std::string &meshName,
int association,
const std::string& arrayname) override;
int GetNumberOfArrays(const std::string &meshName,
int association,
unsigned int &numberOfArrays) override;
int GetArrayName(const std::string &meshName,
int association,
unsigned int index,
std::string &arrayName) override;
int ReleaseData() override;
void UpdateFields();
protected:
ConduitDataAdaptor();
~ConduitDataAdaptor();
typedef std::map<std::string, std::vector<std::string>> Fields;
Fields FieldNames;
int *GlobalBlockDistribution;
private:
ConduitDataAdaptor(const ConduitDataAdaptor&)=delete; // not implemented.
void operator=(const ConduitDataAdaptor&)=delete; // not implemented.
conduit::Node* Node;
};
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment