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
initial add of examples
  • Loading branch information
bgunnar5 committed May 30, 2024
commit f21262763b1eafb40438ccb4dbf89f02dfedb1c6
6 changes: 3 additions & 3 deletions src/axom/sina/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ if(AXOM_ENABLE_TESTS)
add_subdirectory(tests)
endif()

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

#------------------------------------------------------------------------------
# Add code checks
Expand Down
31 changes: 31 additions & 0 deletions src/axom/sina/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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 examples
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# List of single source file examples
#------------------------------------------------------------------------------
set(sina_example_sources
sina_basic.cpp
sina_tutorial.cpp
)

set(sina_example_depends sina conduit::conduit)

#------------------------------------------------------------------------------
# Add targets and tests for Sina examples
#------------------------------------------------------------------------------
foreach(src ${sina_example_sources})
get_filename_component(exe_name ${src} NAME_WE)
axom_add_executable(
NAME ${exe_name}_ex
SOURCES ${src}
OUTPUT_DIR ${EXAMPLE_OUTPUT_DIRECTORY}
DEPENDS_ON ${sina_example_depends}
FOLDER axom/sina/examples
)
endforeach()
15 changes: 15 additions & 0 deletions src/axom/sina/examples/sina_basic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "axom/sina.hpp"

int main (void) {
// Create a new document
axom::sina::Document document;
// Create a run of "My Sim Code" version "1.2.3", which was run by "jdoe".
// The run has an ID of "run1", which has to be unique to this file.
axom::sina::ID runID{"run1", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> run{
new axom::sina::Run{runID, "My Sim Code", "1.2.3", "jdoe"}};
// Add the run to the document
document.add(std::move(run));
// Save the document directly to a file.
saveDocument(document, "MySinaData.json");
}
160 changes: 160 additions & 0 deletions src/axom/sina/examples/sina_tutorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#include "axom/sina.hpp"

#include <utility>
#include <memory>

namespace {

//! [create record]
void createRecord() {
axom::sina::ID id{"some_record_id", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> record{new axom::sina::Record{id, "my_record_type"}};

// Add the record to a document
axom::sina::Document doc;
doc.add(std::move(record));
}
//! [create record]

//! [create run]
void createRun() {
axom::sina::ID id{"some_run_id", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> run{new axom::sina::Run{id, "My Sim Code", "1.2.3", "jdoe"}};

// Add the record to a document
axom::sina::Document doc;
doc.add(std::move(run));
}
//! [create run]

//! [adding data]
void addData(axom::sina::Record &record) {
// Add a scalar named "my_scalar" with the value 123.456
record.add("my_scalar", axom::sina::Datum{123.456});

// Add a string named "my_string" with the value "abc"
record.add("my_string", axom::sina::Datum{"abc"});

// Add a list of scalars named "my_scalar_list"
std::vector<double> scalarList = {1.2, -3.4, 5.6};
record.add("my_scalar_list", axom::sina::Datum{scalarList});

// Add a list of strings named "my_string_list"
std::vector<std::string> stringList = {"hi", "hello", "howdy"};
record.add("my_string_list", axom::sina::Datum{stringList});
}
//! [adding data]

//! [curve sets]
void addCurveSets(axom::sina::Record &record) {
axom::sina::CurveSet timePlots{"time_plots"};

// Add the independent variable
timePlots.addIndependentCurve(
axom::sina::Curve{"time", {0.0, 0.1, 0.25, 0.3}});

// Add some dependent variables.
// The length of each must be the same as the length of the independent.
timePlots.addDependentCurve(
axom::sina::Curve{"temperature", {300.0, 310.0, 350.0, 400.0}});

timePlots.addDependentCurve(
axom::sina::Curve{"energy", {0.0, 10.0, 20.0, 30.0}});

// Associate the curve sets with the record
record.add(timePlots);
}

//! [curve sets]


//! [file add_and_remove]
void addAndRemoveFileToRecord(axom::sina::Record &run) {
axom::sina::File my_file{"some/path.txt"};
// Adds the file to the record's file list
run.add(my_file);
// Removes the file from the record's file list
run.remove(my_file);
}

//! [file add_and_remove]

//! [relationships]
void associateRunToStudy(axom::sina::Document &doc, axom::sina::Record const &uqStudy, axom::sina::Record const &run) {
doc.add(axom::sina::Relationship{uqStudy.getId(), "contains", run.getId()});
}
//! [relationships]


//! [library data foo]
void foo_collectData(axom::sina::DataHolder &fooData) {
fooData.add("temperature", axom::sina::Datum{500});
fooData.add("energy", axom::sina::Datum{1.2e10});
}
//! [library data foo]

//! [library data bar]
void bar_gatherData(axom::sina::DataHolder &barData) {
barData.add("temperature", axom::sina::Datum{400});
barData.add("mass", axom::sina::Datum{15});
}
//! [library data bar]

//! [library data host]
void gatherAllData(axom::sina::Record &record) {
auto fooData = record.addLibraryData("foo");
auto barData = record.addLibraryData("bar");

foo_collectData(*fooData);
bar_gatherData(*barData);

record.add("temperature", axom::sina::Datum{450});
}
//! [library data host]

//! [io write]
void save(axom::sina::Document const &doc) {
axom::sina::saveDocument(doc, "my_output.json");
}
//! [io write]

//! [io read]
void load() {
axom::sina::Document doc = axom::sina::loadDocument("my_output.json");
}
//! [io read]

//! [user defined]
void addUserDefined(axom::sina::Record &record) {
conduit::Node &userDefined = record.getUserDefinedContent();
userDefined["var_1"] = "a";
userDefined["var_2"] = "b";

conduit::Node subNode;
subNode["sub_1"] = 10;
subNode["sub_2"] = 20;
userDefined["sub_structure"] = subNode;
}
//! [user defined]

}

int main() {
// Call everything to keep the compiler from complaining about unused functions
axom::sina::Record run{axom::sina::ID{"my_record", axom::sina::IDType::Global}, "my_record_type"};
axom::sina::Record study{axom::sina::ID{"my_run", axom::sina::IDType::Global}, "UQ study"};
axom::sina::Document doc;
addData(run);
createRecord();
createRun();
associateRunToStudy(doc, study, run);
gatherAllData(run);
addCurveSets(run);
addAndRemoveFileToRecord(run);
addUserDefined(run);
// TODO
// - Add Record to doc
// - Check output file to see if record shows up
save(doc);
load();
}