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 document examples to actual examples
  • Loading branch information
bgunnar5 committed Jul 10, 2024
commit 46d0fcd68e3bb2695fbee51423272c78c96aa117
72 changes: 4 additions & 68 deletions src/axom/sina/docs/sphinx/documents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,8 @@ Assembling Documents
On the `Sina C++ User Guide <./index>`_ page, you can see an example of this
process. Below we will expand on this example to add a ``Relationship``:

.. code:: cpp

#include "axom/sina.hpp"

int main (void) {
// Create a new document
axom::sina::Document document;

// Create a record of this specific study
// This study has an ID of "study1", which has to be unique to this file
axom::sina::ID studyID{"study1", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> study{
new axom::sina::Record{studyID, "UQ study"}};

// 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"}};

// Create a relationship between the study and the run
// Here we're saying that the study contains the run
axom::sina::Relationship relationship{studyID, "contains", runID};

// Add the run, study record, and relationship to the document
document.add(std::move(run));
document.add(std::move(study));
document.add(relationship);

// Save the document directly to a file.
axom::sina::saveDocument(document, "MySinaData.json");
}
.. literalinclude:: ../../examples/sina_document_assembly.cpp
:language: cpp

After executing the above code, the resulting ``MySinaData.json`` file will
look like so:
Expand Down Expand Up @@ -146,42 +116,8 @@ objects that are associated with a ``Document``. The ``getRecords()`` and

Below is an example showcasing their usage:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Create a new document
axom::sina::Document document;

// Create a record of this specific study
// This study has an ID of "study1", which has to be unique to this file
axom::sina::ID studyID{"study1", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> study{
new axom::sina::Record{studyID, "UQ study"}};

// 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"}};

// Create a relationship between the study and the run
// Here we're saying that the study contains the run
axom::sina::Relationship relationship{studyID, "contains", runID};

// Add the run, study record, and relationship to the document
document.add(std::move(run));
document.add(std::move(study));
document.add(relationship);

// Query for a list of records and relationships
auto &records = document.getRecords();
auto &relationships = document.getRelationships();

std::cout << "Number of Records: " << records.size() << std::endl;
std::cout << "Number of Relationships: " << relationships.size() << std::endl;
}
.. literalinclude:: ../../examples/sina_query_records_relationships.cpp
:language: cpp

Running this will show that both records and the one relationship were
properly queried:
Expand Down
223 changes: 26 additions & 197 deletions src/axom/sina/docs/sphinx/records.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,26 @@ of doubles.
Below showcases an example of creating an instance of ``Datum`` with an array of
strings and adding it to a ``Record``:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Create the record
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Create the datum with an array of strings
std::vector<std::string> myTags{"input"};
axom::sina::Datum myDatum{12, myTags};

// Add the datum to the record
myRecord->add("my_scalar", std::move(myDatum));
std::cout << myRecord->toNode().to_json() << std::endl;
}
.. literalinclude:: ../../examples/sina_create_datum.cpp
:language: cpp

Once executed, this code will output:

.. code:: json

{
"local_id": "my_record",
"type": "my_type",
"data":
"data":
{
"my_scalar":
"my_scalar":
{
"tags": ["input"],
"value":12.0
"value":
[
"input"
]
}
}
},
"type": "my_type",
"local_id": "my_record"
}

.. _datum-type-label:
Expand All @@ -97,27 +84,8 @@ are tracked in an enumeration called ``ValueType``. The enumeration is as follow

Below is an example of this in action:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Define 3 different datums
axom::sina::Datum myDatum{12.34};
std::string value = "foobar";
axom::sina::Datum myOtherDatum{value};
std::vector<double> scalars = {1, 2, 20.0};
axom::sina::Datum myArrayDatum{scalars};

// Prints 0, corresponding to string
std::cout << static_cast<std::underlying_type<axom::sina::ValueType>::type>(myDatum.getType()) << std::endl;

// Prints 1, corresponding to scalar
std::cout << static_cast<std::underlying_type<axom::sina::ValueType>::type>(myOtherDatum.getType()) << std::endl;

// Prints 3, corresponding to scalar array
std::cout << static_cast<std::underlying_type<axom::sina::ValueType>::type>(myArrayDatum.getType()) << std::endl;
}
.. literalinclude:: ../../examples/sina_check_datum_type.cpp
:language: cpp

++++++++++++++++++++++
Setting Units and Tags
Expand All @@ -128,21 +96,8 @@ This can be accomplished with the ``setUnits()`` and ``setTags()`` methods respe

Below is an example of this functionality:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Define 2 different datums
axom::sina::Datum myDatum{12.34};
std::vector<double> scalars = {1, 2, 20.0};
axom::sina::Datum myArrayDatum{scalars};

// Set the units for one datum and the tags for the other
myDatum.setUnits("km/s");
std::vector<std::string> tags = {"input", "core"};
myArrayDatum.setTags(tags);
}
.. literalinclude:: ../../examples/sina_datum_units_tags.cpp
:language: cpp

+++++++++++++++++++++++++++++++++++++
Viewing Datum From an existing Record
Expand All @@ -154,35 +109,8 @@ This method will return an unordered map of ``Datum`` instances.

Below is an example of this process:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Define 3 different datums
axom::sina::Datum myDatum{12.34};
std::string value = "foobar";
axom::sina::Datum myOtherDatum{value};
std::vector<double> scalars = {1, 2, 20.0};
axom::sina::Datum myArrayDatum{scalars};

// Create a record to store the datum
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Add the datum instances to the record
myRecord->add("datum1", std::move(myDatum));
myRecord->add("datum2", std::move(myOtherDatum));
myRecord->add("datum3", std::move(myArrayDatum));

// Query the datum
auto &data = myRecord->getData();

// Print the keys and type of datum
for (const auto& pair : data) {
std::cout << pair.first << " is type: " << static_cast<std::underlying_type<axom::sina::ValueType>::type>(pair.second.getType()) << std::endl;
}
}
.. literalinclude:: ../../examples/sina_view_datum_types.cpp
:language: cpp

Executing this code will print out:

Expand All @@ -197,39 +125,8 @@ datum1 is a scalar, datum2 is a string, and datum3 is an array of scalars.

Using this knowledge we can modify our code to show us the current datum values:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Define 3 different datums
axom::sina::Datum myDatum{12.34};
std::string value = "foobar";
axom::sina::Datum myOtherDatum{value};
std::vector<double> scalars = {1, 2, 20.0};
axom::sina::Datum myArrayDatum{scalars};

// Create a record to store the datum
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Add the datum instances to the record
myRecord->add("datum1", std::move(myDatum));
myRecord->add("datum2", std::move(myOtherDatum));
myRecord->add("datum3", std::move(myArrayDatum));

// Query the datum
auto &data = myRecord->getData();

// Print the datum values
std::cout << "datum1: " << data.at("datum1").getScalar() << std::endl;
std::cout << "datum2: " << data.at("datum2").getValue() << std::endl;
std::cout << "datum3: ";
for (const auto& value : data.at("datum3").getScalarArray()) {
std::cout << value << " ";
}
std::cout << std::endl;
}
.. literalinclude:: ../../examples/sina_view_datum_values.cpp
:language: cpp

This will provide the following output:

Expand All @@ -251,27 +148,8 @@ Every ``File`` must have a URI, while mimetype and tags are optional.

Below is an example showcasing how to create a file and add it to a record:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Create 2 different files
axom::sina::File myFile{"/path/to/file.png"};
myFile.setMimeType("image/png");
axom::sina::File myOtherFile{"/path/to/other/file.txt"};
myOtherFile.setTags({"these", "are", "tags"});

// Create a record to store the files
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Add the files to the record
myRecord->add(myFile);
myRecord->add(myOtherFile);

std::cout << myRecord->toNode().to_json() << std::endl;
}
.. literalinclude:: ../../examples/sina_file_object_creation.cpp
:language: cpp

This code will produce the following output:

Expand All @@ -282,7 +160,7 @@ This code will produce the following output:
"local_id": "my_record",
"files":
{
"/path/to/other/file.txt":
"/path/to/other/file.txt":
{
"tags":
[
Expand All @@ -300,30 +178,8 @@ This code will produce the following output:

Similarly, files can be removed from a ``Record`` with the ``remove()`` method:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Create 2 different files
axom::sina::File myFile{"/path/to/file.png"};
myFile.setMimeType("image/png");
axom::sina::File myOtherFile{"/path/to/other/file.txt"};
myOtherFile.setTags({"these", "are", "tags"});

// Create a record to store the files
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Add the files to the record
myRecord->add(myFile);
myRecord->add(myOtherFile);

// Remove a file from the record
myRecord->remove(myFile);

std::cout << std::cout << myRecord->toNode().to_json() << std::endl;
}
.. literalinclude:: ../../examples/sina_file_object_removal.cpp
:language: cpp

As we see from the output, the contents of ``myFile`` are no longer in the
``Record`` instance:
Expand Down Expand Up @@ -358,35 +214,8 @@ method which returns an unordered map of ``File`` instances.
Below is an expansion of the previous example where we query the ``Record`` instance
for files:

.. code:: cpp

#include "axom/sina.hpp"

int main(void) {
// Create 2 different files
axom::sina::File myFile{"/path/to/file.png"};
myFile.setMimeType("image/png");
axom::sina::File myOtherFile{"/path/to/other/file.txt"};
myOtherFile.setTags({"these", "are", "tags"});

// Create a record to store the files
axom::sina::ID myID{"my_record", axom::sina::IDType::Local};
std::unique_ptr<axom::sina::Record> myRecord{new axom::sina::Record{myID, "my_type"}};

// Add the files to the record
myRecord->add(myFile);
myRecord->add(myOtherFile);

// Query the record for files
auto &files = myRecord->getFiles();
for (const auto& file : files) {
std::cout << "File with URI '" << file.getUri() << "' has mimetype '" << file.getMimeType() << "' and tags '";
for (const auto& tag : file.getTags()) {
std::cout << tag << " ";
}
std::cout << "'" << std::endl;
}
}
.. literalinclude:: ../../examples/sina_query_record_for_files.cpp
:language: cpp

The above code will output:

Expand Down
Loading