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
run make style
  • Loading branch information
bgunnar5 committed Jul 17, 2024
commit a57111a8f02b28bd3098171dae340a59f8e8f965
435 changes: 243 additions & 192 deletions src/axom/sina/core/AdiakWriter.cpp

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions src/axom/sina/core/AdiakWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
// SPDX-License-Identifier: (BSD-3-Clause)


#ifndef SINA_ADIAK_HPP
#define SINA_ADIAK_HPP

Expand All @@ -20,15 +19,15 @@
#include "axom/config.hpp"
#ifdef AXOM_USE_ADIAK

#include <string>
#include <type_traits>
#include <string>
#include <type_traits>

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

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

namespace axom
Expand All @@ -53,12 +52,16 @@ namespace sina
* 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
void adiakSinaCallback(const char *name,
adiak_category_t category,
const char *subcategory,
adiak_value_t *value,
adiak_datatype_t *t,
void *opaque_value);

#endif // AXOM_USE_ADIAK
} // namespace sina
} // namespace axom

#endif // SINA_ADIAK_HPP
#endif // AXOM_USE_ADIAK

#endif // SINA_ADIAK_HPP
192 changes: 108 additions & 84 deletions src/axom/sina/core/ConduitUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
// SPDX-License-Identifier: (BSD-3-Clause)


/*!
******************************************************************************
*
Expand Down Expand Up @@ -42,120 +41,145 @@ namespace
* @throws std::invalid_argument if the field is not a string
*/
std::string getExpectedString(conduit::Node const &field,
std::string const &fieldName,
std::string const &parentType) {
if (!field.dtype().is_string()) {
std::ostringstream message;
message << "The field '" << fieldName
<< "' for objects of type '" << parentType
<< "' must be a string, was '"
<< field.dtype().name() << "'";
throw std::invalid_argument(message.str());
}
return field.as_string();
}
std::string const &fieldName,
std::string const &parentType)
{
if(!field.dtype().is_string())
{
std::ostringstream message;
message << "The field '" << fieldName << "' for objects of type '"
<< parentType << "' must be a string, was '" << field.dtype().name()
<< "'";
throw std::invalid_argument(message.str());
}
return field.as_string();
}
} // namespace

conduit::Node const &getRequiredField(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType) {
if (!parent.has_child(fieldName)) {
std::ostringstream message;
message << "The field '" << fieldName
<< "' is required for objects of type '" << parentType << "'";
throw std::invalid_argument(message.str());
}
return parent.child(fieldName);
conduit::Node const &parent,
std::string const &parentType)
{
if(!parent.has_child(fieldName))
{
std::ostringstream message;
message << "The field '" << fieldName
<< "' is required for objects of type '" << parentType << "'";
throw std::invalid_argument(message.str());
}
return parent.child(fieldName);
}

std::string getRequiredString(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType) {
conduit::Node const &field = getRequiredField(fieldName, parent, parentType);
return getExpectedString(field, fieldName, parentType);
conduit::Node const &parent,
std::string const &parentType)
{
conduit::Node const &field = getRequiredField(fieldName, parent, parentType);
return getExpectedString(field, fieldName, parentType);
}

std::string getOptionalString(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType) {
if (!parent.has_child(fieldName) || parent.child(fieldName).dtype().is_empty()) {
return "";
}
return getExpectedString(parent.child(fieldName), fieldName, parentType);
conduit::Node const &parent,
std::string const &parentType)
{
if(!parent.has_child(fieldName) || parent.child(fieldName).dtype().is_empty())
{
return "";
}
return getExpectedString(parent.child(fieldName), fieldName, parentType);
}

double getRequiredDouble(std::string const &fieldName,
conduit::Node const &parent, std::string const &parentType) {
auto &ref = getRequiredField(fieldName, parent, parentType);
if (!ref.dtype().is_number()) {
std::ostringstream message;
message << "The field '" << fieldName
<< "' for objects of type '" << parentType
<< "' must be a double";
throw std::invalid_argument(message.str());
}
return ref.as_double();
conduit::Node const &parent,
std::string const &parentType)
{
auto &ref = getRequiredField(fieldName, parent, parentType);
if(!ref.dtype().is_number())
{
std::ostringstream message;
message << "The field '" << fieldName << "' for objects of type '"
<< parentType << "' must be a double";
throw std::invalid_argument(message.str());
}
return ref.as_double();
}

void addStringsToNode(conduit::Node &parent, std::string const &child_name,
std::vector<std::string> const &string_values){
void addStringsToNode(conduit::Node &parent,
std::string const &child_name,
std::vector<std::string> const &string_values)
{
// If the child already exists, add_child returns it
conduit::Node &child_node = parent.add_child(child_name);
for(auto &value : string_values)
{
auto &list_entry = child_node.append();
list_entry.set(value);
auto &list_entry = child_node.append();
list_entry.set(value);
}

// If there were no children, this will be a null node rather than a list.
// We prefer empty lists to null values in our serialized JSON, so force
// this to be a list
if (child_node.number_of_children() == 0) {
child_node.set_dtype(conduit::DataType::list());
if(child_node.number_of_children() == 0)
{
child_node.set_dtype(conduit::DataType::list());
}
}

std::vector<double> toDoubleVector(conduit::Node const &node,
std::string const &name) {
if (node.dtype().is_list() && node.dtype().number_of_elements() == 0) {
return std::vector<double>{};
}
conduit::Node asDoubles;
try {
node.to_double_array(asDoubles);
} catch (conduit::Error const &err) {
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of doubles" << err.what();
throw std::invalid_argument(errStream.str());
}
double const *start = asDoubles.as_double_ptr();
auto count = static_cast<std::vector<double>::size_type>(
asDoubles.dtype().number_of_elements());
return std::vector<double>{start, start + count};
std::string const &name)
{
if(node.dtype().is_list() && node.dtype().number_of_elements() == 0)
{
return std::vector<double> {};
}
conduit::Node asDoubles;
try
{
node.to_double_array(asDoubles);
}
catch(conduit::Error const &err)
{
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of doubles" << err.what();
throw std::invalid_argument(errStream.str());
}
double const *start = asDoubles.as_double_ptr();
auto count = static_cast<std::vector<double>::size_type>(
asDoubles.dtype().number_of_elements());
return std::vector<double> {start, start + count};
}

std::vector<std::string> toStringVector(conduit::Node const &node,
std::string const &name) {
std::vector<std::string> converted;
if (!node.dtype().is_list()) {
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of strings. It is not a list. "
<< node.to_json_default();
throw std::invalid_argument(errStream.str());
std::string const &name)
{
std::vector<std::string> converted;
if(!node.dtype().is_list())
{
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of strings. It is not a list. "
<< node.to_json_default();
throw std::invalid_argument(errStream.str());
}
for(auto iter = node.children(); iter.has_next();)
{
auto &child = iter.next();
if(child.dtype().is_string())
{
converted.emplace_back(child.as_string());
}
for (auto iter = node.children(); iter.has_next(); ) {
auto &child = iter.next();
if (child.dtype().is_string()) {
converted.emplace_back(child.as_string());
} else {
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of strings. A value is not a string. "
<< node.to_json_default();
throw std::invalid_argument(errStream.str());
}
else
{
std::ostringstream errStream;
errStream << "Error trying to convert node \"" << name
<< "\" into a list of strings. A value is not a string. "
<< node.to_json_default();
throw std::invalid_argument(errStream.str());
}
return converted;
}
return converted;
}

} // end sina namespace
} // end axom namespace
} // namespace sina
} // namespace axom
24 changes: 14 additions & 10 deletions src/axom/sina/core/ConduitUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//
// SPDX-License-Identifier: (BSD-3-Clause)


#ifndef SINA_JSONUTIL_HPP
#define SINA_JSONUTIL_HPP

Expand Down Expand Up @@ -38,7 +37,8 @@ namespace sina
* \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);
conduit::Node const &parent,
std::string const &parentType);

/**
* \brief Get the value of a required field from a conduit Node. The field value
Expand All @@ -52,7 +52,8 @@ conduit::Node const &getRequiredField(std::string const &fieldName,
* \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);
conduit::Node const &parent,
std::string const &parentType);

/**
* \brief Get the value of a required field from a conduit Node. The field value
Expand All @@ -66,7 +67,8 @@ std::string getRequiredString(std::string const &fieldName,
* \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);
conduit::Node const &parent,
std::string const &parentType);

/**
* \brief Get the value of an optional field from a conduit Node. The field value
Expand All @@ -81,7 +83,8 @@ double getRequiredDouble(std::string const &fieldName,
* \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);
conduit::Node const &parent,
std::string const &parentType);

/**
* \brief Convert the given node to a vector of doubles.
Expand All @@ -92,7 +95,7 @@ std::string getOptionalString(std::string const &fieldName,
* \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);
std::string const &name);

/**
* \brief Convert the given node to a vector of strings.
Expand All @@ -103,7 +106,7 @@ std::vector<double> toDoubleVector(conduit::Node const &node,
* \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);
std::string const &name);

/**
* \brief Add a vector of strings to a Node. This operation's not natively
Expand All @@ -113,10 +116,11 @@ std::vector<std::string> toStringVector(conduit::Node const &node,
* \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);
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
#endif //SINA_JSONUTIL_HPP
Loading
Loading