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 Sina as Axom component #1378

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
89413c6
establish directory structure and copy/paste headers/sources
bgunnar5 Apr 24, 2024
c8bdb57
add doxygen mainpage for sina
bgunnar5 Apr 24, 2024
4455cc7
first pass at the cmake file for sina component
bgunnar5 Apr 24, 2024
857a449
Merge branch 'LLNL:develop' into feature/bgunnar5/sina-integration
bgunnar5 Apr 29, 2024
d8d7a49
move sina to axom and add cmake files so it can be built
bgunnar5 May 8, 2024
39e5a2e
add doxygen mainpage for sina
bgunnar5 May 8, 2024
a370f6f
merge prior changes to this branch made on diff computer
bgunnar5 May 8, 2024
3c40f1a
Merge branch 'develop' of https://github.com/bgunnar5/axom into featu…
bgunnar5 May 8, 2024
a5fba8b
remove extra adiak list append and uncomment test addition
bgunnar5 May 29, 2024
44e6f74
add tests for sina
bgunnar5 May 29, 2024
f212627
initial add of examples
bgunnar5 May 30, 2024
45628bf
get doxygen docs up and running
bgunnar5 Jun 21, 2024
234e1eb
start work on sphinx docs
bgunnar5 Jun 21, 2024
c9b9cca
finish creating sina docs
bgunnar5 Jun 27, 2024
76c7c86
fix references to sina namespace in doxygen
bgunnar5 Jun 27, 2024
7d78852
add sina fortran interface
bgunnar5 Jul 3, 2024
2fbb425
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Jul 3, 2024
b23292f
fix small issues with docs
bgunnar5 Jul 9, 2024
d9de3ef
make ordering alphabetical for cmakedefines
bgunnar5 Jul 9, 2024
7bf7fc8
fix indentation on doxygen page
bgunnar5 Jul 9, 2024
f15a501
protect against GMOCK not available
bgunnar5 Jul 9, 2024
46d0fcd
move document examples to actual examples
bgunnar5 Jul 10, 2024
5c181c7
add copyright header to sina files
bgunnar5 Jul 10, 2024
4a635bf
move cpp/hpp files to same directory for core and tests
bgunnar5 Jul 11, 2024
820ce9f
remove CppBridge for C++<14
bgunnar5 Jul 11, 2024
10dccf7
replace AXOM_SINA_USE_ADIAK with AXOM_USE_ADIAK
bgunnar5 Jul 11, 2024
d998fac
change doxygen syntax to match axom's standard
bgunnar5 Jul 12, 2024
4d7c8c2
remove unused config file and reference to msub job in docs
bgunnar5 Jul 16, 2024
2860e09
fix issue with Maestro link
bgunnar5 Jul 16, 2024
c8e1f39
convert Datum to pass by reference
bgunnar5 Jul 16, 2024
6f271a3
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Jul 16, 2024
a57111a
run make style
bgunnar5 Jul 17, 2024
66c3163
Merge branch 'develop' into pr-from-fork/1376
bgunnar5 Jul 17, 2024
917aa27
disable sina for osx_gcc and windows azure tests
bgunnar5 Aug 1, 2024
b9b415b
add custom sina matchers so that blueos will build
bgunnar5 Aug 1, 2024
a516da9
Merge branch 'pr-from-fork/1376' of https://github.com/LLNL/axom into…
bgunnar5 Aug 1, 2024
48b311f
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 1, 2024
3ef59eb
remove code check call from Sina CMake and run make style
bgunnar5 Aug 5, 2024
5856843
add compiler flag for xl fortran builds
bgunnar5 Aug 7, 2024
5d39439
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 7, 2024
70b4716
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 7, 2024
f9285ca
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 8, 2024
64ce0ec
update sina description in doxygen mainpage
bgunnar5 Aug 8, 2024
0ee8cf9
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 12, 2024
4552083
add version for sina
bgunnar5 Aug 12, 2024
0c279e3
Merge branch 'develop' into pr-from-fork/1376
rhornung67 Aug 15, 2024
caab17d
Update src/axom/sina/core/ID.hpp
bgunnar5 Aug 30, 2024
bce3aaa
implementation -> header in hpp file brief statements
bgunnar5 Aug 30, 2024
274851f
make docs suggestions from PR
bgunnar5 Aug 30, 2024
528d0d9
modify code block comments for docs
bgunnar5 Aug 30, 2024
6246b2d
some final fixes for sina docs
bgunnar5 Aug 30, 2024
dbf9d5a
fix python interpreter package find to not use deprecated call
bgunnar5 Aug 30, 2024
ae026bf
move custom XL flag to just be used for sina fortran example executable
bgunnar5 Aug 30, 2024
cbcbce0
Merge branch 'develop' of https://github.com/LLNL/axom into feature/b…
bgunnar5 Aug 30, 2024
03aca6d
Merge branch 'pr-from-fork/1376' of https://github.com/LLNL/axom into…
bgunnar5 Aug 30, 2024
7289033
fix python executable variable name
bgunnar5 Sep 4, 2024
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
Prev Previous commit
Next Next commit
move sina to axom and add cmake files so it can be built
  • Loading branch information
bgunnar5 committed May 8, 2024
commit d8d7a493511d9e46fc59c23123868cf7a1d0d487
1 change: 1 addition & 0 deletions src/axom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ endif()
# Add components so that later ones depend on earlier ones
# (i.e. quest depends on mint, so quest follows mint)
axom_add_component(COMPONENT_NAME slic DEFAULT_STATE ${AXOM_ENABLE_ALL_COMPONENTS})
axom_add_component(COMPONENT_NAME sina DEFAULT_STATE ${AXOM_ENABLE_ALL_COMPONENTS})
axom_add_component(COMPONENT_NAME slam DEFAULT_STATE ${AXOM_ENABLE_ALL_COMPONENTS})
axom_add_component(COMPONENT_NAME primal DEFAULT_STATE ${AXOM_ENABLE_ALL_COMPONENTS})
axom_add_component(COMPONENT_NAME sidre DEFAULT_STATE ${AXOM_ENABLE_ALL_COMPONENTS})
Expand Down
1 change: 1 addition & 0 deletions src/axom/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
#cmakedefine AXOM_USE_SLAM
#cmakedefine AXOM_USE_SLIC
#cmakedefine AXOM_USE_SPIN
#cmakedefine AXOM_USE_SINA

/*
* For gradual removal of types that have been deprecated in favor of
Expand Down
4 changes: 4 additions & 0 deletions src/axom/core/utilities/About.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ void about(std::ostream &oss)
comps.push_back("sidre");
#endif

#ifdef AXOM_USE_SINA
comps.push_back("sina");
#endif

#ifdef AXOM_USE_SLAM
comps.push_back("slam");
#endif
Expand Down
109 changes: 109 additions & 0 deletions src/axom/sina/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and
# other Axom Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: (BSD-3-Clause)
#------------------------------------------------------------------------------
# Sina -- API to write data to Sina's common file format
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Specify necessary dependencies
#
# Note: Sina also optionally depends on Adiak when AXOM_SINA_USE_ADIAK=ON
#------------------------------------------------------------------------------
axom_component_requires(NAME Sina
TPLS Conduit )

#------------------------------------------------------------------------------
# Add Sina options
#------------------------------------------------------------------------------
cmake_dependent_option( AXOM_SINA_USE_ADIAK "Enables Adiak support in Sina" ON
"AXOM_USE_ADIAK" OFF)

#------------------------------------------------------------------------------
# Generate Sina config
#------------------------------------------------------------------------------
axom_configure_file ( config.hpp.in ${PROJECT_BINARY_DIR}/include/axom/sina/config.hpp )

#------------------------------------------------------------------------------
# Specify the sina headers/sources
#------------------------------------------------------------------------------
set(sina_headers
include/ConduitUtil.hpp
include/CppBridge.hpp
include/Curve.hpp
include/CurveSet.hpp
include/DataHolder.hpp
include/Datum.hpp
include/Document.hpp
include/File.hpp
include/ID.hpp
include/Record.hpp
include/Relationship.hpp
include/Run.hpp
)

set(sina_sources
src/ConduitUtil.cpp
src/Curve.cpp
src/CurveSet.cpp
src/DataHolder.cpp
src/Datum.cpp
src/Document.cpp
src/File.cpp
src/ID.cpp
src/Record.cpp
src/Relationship.cpp
src/Run.cpp
)

# Add Adiak header and source
if (AXOM_SINA_USE_ADIAK)
list(APPEND sina_headers include/AdiakWriter.hpp)
list(APPEND sina_sources src/AdiakWriter.cpp)
endif()

blt_list_append( TO sina_headers ELEMENTS include/AdiakWriter.hpp IF AXOM_SINA_USE_ADIAK )
blt_list_append( TO sina_sources ELEMENTS src/AdiakWriter.cpp IF AXOM_SINA_USE_ADIAK )

#------------------------------------------------------------------------------
# Build and install the library
#------------------------------------------------------------------------------
set(sina_depends
core
conduit::conduit
)

blt_list_append( TO sina_depends ELEMENTS adiak::adiak IF AXOM_SINA_USE_ADIAK )

axom_add_library(NAME sina
SOURCES ${sina_sources}
HEADERS ${sina_headers}
DEPENDS_ON ${sina_depends}
FOLDER axom/sina)

axom_write_unified_header(NAME sina
HEADERS ${sina_headers})

axom_install_component(NAME sina
HEADERS ${sina_headers})

install(FILES ${PROJECT_BINARY_DIR}/include/axom/sina/config.hpp
DESTINATION include/axom/sina
)

#------------------------------------------------------------------------------
# Add tests and examples
#------------------------------------------------------------------------------
# if(AXOM_ENABLE_TESTS)
# add_subdirectory(tests)
# endif()

# if(AXOM_ENABLE_EXAMPLES)
# add_subdirectory(examples)
# endif()

#------------------------------------------------------------------------------
# Add code checks
#------------------------------------------------------------------------------
axom_add_code_checks(PREFIX sina)
9 changes: 9 additions & 0 deletions src/axom/sina/config.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef SINA_CONFIG_HPP_
#define SINA_CONFIG_HPP_

/// \file

#cmakedefine AXOM_SINA_USE_ADIAK

#endif // SINA_CONFIG_HPP_

50 changes: 50 additions & 0 deletions src/axom/sina/include/AdiakWriter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef SINA_ADIAK_HPP
#define SINA_ADIAK_HPP

/// @file

#include "axom/sina/config.hpp"
#ifdef AXOM_SINA_USE_ADIAK

#include <string>
#include <type_traits>

#include "axom/sina/include/ConduitUtil.hpp"
#include "axom/sina/include/Record.hpp"
#include "axom/sina/include/Run.hpp"

extern "C" {
#include "adiak_tool.h"
}

namespace axom
{
namespace sina
{

/**
* The callback function to pass to Adiak in order to write collected data to a Sina Record.
*
* To register this with Adiak, you should call adiak_register_cb, passing in
* a pointer to the record as the last value. Your code should look something
* like this:
*
* \code
* Record record{ID{"my_id", IDType::Local}, "my_record_type"};
* adiak_register_cb(1, adiak_category_all, adiakSinaCallback, 0, &record);
* \endcode
*
* Note that not everything that Sina can capture an be captured through the
* Adiak API. For example, there is currently no support in Adiak to capture
* anything like a CurveSet. As a result, to do that, you must hold on to
* the Record object passed here as the opaque value and manipulate it directly.
**/
void adiakSinaCallback(const char *name, adiak_category_t category, const char *subcategory, adiak_value_t *value, adiak_datatype_t *t, void *opaque_value);

} // end sina namespace
} // end axom namespace

#endif // AXOM_SINA_USE_ADIAK

#endif // SINA_ADIAK_HPP

106 changes: 106 additions & 0 deletions src/axom/sina/include/ConduitUtil.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef SINA_JSONUTIL_HPP
#define SINA_JSONUTIL_HPP

#include <string>
#include <vector>

#include "conduit.hpp"

namespace axom
{
namespace sina
{

/**
* Get a required field from a conduit Node.
*
* @param fieldName the name of the field to get
* @param parent the parent object from which to get the field
* @param parentType a user-friendly name of the type of the parent to use
* in an error message if the field doesn't exist.
* @return the requested field as a Node
* @throws std::invalid_argument if the field does not exist
*/
conduit::Node const &getRequiredField(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType);

/**
* Get the value of a required field from a conduit Node. The field value
* must be a string.
*
* @param fieldName the name of the field to get
* @param parent the parent object from which to get the field
* @param parentType a user-friendly name of the type of the parent to use
* in an error message if the field doesn't exist.
* @return the value of the requested field
* @throws std::invalid_argument if the field does not exist or is not a string
*/
std::string getRequiredString(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType);

/**
* Get the value of a required field from a conduit Node. The field value
* must be a double.
*
* @param fieldName the name of the field to get
* @param parent the parent object from which to get the field
* @param parentType a user-friendly name of the type of the parent to use
* in an error message if the field doesn't exist.
* @return the value of the requested field
* @throws std::invalid_argument if the field does not exist or is not a double
*/
double getRequiredDouble(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType);

/**
* Get the value of an optional field from a conduit Node. The field value
* must be a string if it is present.
*
* @param fieldName the name of the field to get
* @param parent the parent object from which to get the field
* @param parentType a user-friendly name of the type of the parent to use
* in an error message if the field doesn't exist.
* @return the value of the requested field, or an empty string if it
* does not exist
* @throws std::invalid_argument if the field exists but is not a string
*/
std::string getOptionalString(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType);

/**
* Convert the given node to a vector of doubles.
*
* @param node the node to convert
* @param name the name of the node, used in error reporting
* @return the node as a list of doubles
* @throws std::invalid_argument if the node is not a list of doubles
*/
std::vector<double> toDoubleVector(conduit::Node const &node,
std::string const &name);

/**
* Convert the given node to a vector of strings.
*
* @param node the node to convert
* @param name the name of the node, used in error reporting
* @return the node as a list of strings
* @throws std::invalid_argument if the node is not a list of strings
*/
std::vector<std::string> toStringVector(conduit::Node const &node,
std::string const &name);

/**
* Add a vector of strings to a Node. This operation's not natively
* part of Conduit.
*
* @param parent the node to add the strings to
* @param child_name the name of the child (aka the name of the field)
* @param string_values the data values for the field
*/
void addStringsToNode(conduit::Node &parent, const std::string &child_name,
std::vector<std::string> const &string_values);

} // end namespace sina
} // end namespace axom

#endif //SINA_JSONUTIL_HPP
40 changes: 40 additions & 0 deletions src/axom/sina/include/CppBridge.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef SINA_CPPBRIDGE_HPP
#define SINA_CPPBRIDGE_HPP

/**
* @file
*
* This file contains functions which can go away once this library is
* migrated to C++14 or later.
*/

#include <memory>
#include <utility>

namespace axom
{
namespace sina
{
namespace internal
{

/**
* Make a unique pointer pointing to a new object.
*
* Delete when switch to C++14 in favor of std::make_unique.
*
* @tparam T the type of the object
* @tparam ParamTypes the types of the parameters
* @param params the parameters to the constructor
* @return a unique_ptr to the newly-constructed object
*/
template<typename T, typename... ParamTypes>
std::unique_ptr<T> make_unique(ParamTypes &&... params) {
return std::unique_ptr<T>(new T(std::forward<ParamTypes>(params)...));
};

} // end internal namespace
} // end sina namespace
} // end axom namespace

#endif //SINA_CPPBRIDGE_HPP
Loading