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

Write and read mesh using ADIOS2 #3291

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8c2756f
Add basic write function
ampdes Jun 19, 2024
42487b3
Update CMakeLists and dolfinx_io
ampdes Jun 19, 2024
bf40802
Add checkpointing demo
ampdes Jun 19, 2024
e66b319
Update dolfinx/io CMakeLists
ampdes Jun 20, 2024
df6ed6d
Merge branch 'main' into checkpointing
ampdes Jun 30, 2024
bf78637
Add implementation of mesh write
ampdes Jul 4, 2024
339c1f0
Remove const and clean
ampdes Jul 4, 2024
6ebac6e
Add checkpointing demo to regression tests
ampdes Jul 4, 2024
5a4d190
clang formatting
ampdes Jul 4, 2024
e644b5e
Merge branch 'main' into checkpointing
ampdes Jul 4, 2024
1d97e78
Minor cahnges in layout
jorgensd Jul 5, 2024
1b2a243
Cast adios2 variable creation args to unsigned long int
ampdes Jul 5, 2024
f2d3115
Declare with uint instead of cast later
ampdes Jul 5, 2024
5dd47c6
Fix offset computations
ampdes Jul 9, 2024
0e1b770
Add ADIOS2Engine class adapted from ADIOS2Writer
ampdes Jul 9, 2024
b8ebd93
Update documentation
ampdes Jul 9, 2024
76f018f
Include headers in demo
ampdes Jul 9, 2024
7ae238a
Remove demo from tests
ampdes Jul 9, 2024
eb0e813
Update copyright text
ampdes Jul 10, 2024
d3a965b
Clean up
ampdes Jul 21, 2024
729846b
Rename variables
ampdes Jul 26, 2024
6025802
Merge branch 'main' into checkpointing
ampdes Jul 26, 2024
b2f4bd0
Pass ADIOS2Engine writer to write function
ampdes Jul 26, 2024
011027b
Merge branch 'update' into checkpointing
ampdes Jul 26, 2024
d7e8e3a
Update docs
ampdes Jul 26, 2024
ca94e17
Update from review
ampdes Jul 27, 2024
55b9288
Pass IO and Engine shared ptrs
ampdes Jul 27, 2024
241fbef
ADIOS IO and Engine without ptrs
ampdes Jul 27, 2024
43f6481
Pass mesh without shared ptr
ampdes Jul 27, 2024
4d71e4c
Add python demo
ampdes Jul 28, 2024
659281a
Rename nodes to vertices
ampdes Jul 30, 2024
38bb3d5
Scope into sections
ampdes Jul 31, 2024
f8d5701
Remove python demo
ampdes Jul 31, 2024
0940f59
Remove ADIOS_utils
ampdes Jul 31, 2024
2a4a986
Switch to pass by reference
ampdes Jul 31, 2024
cbc6fb2
WIP-buggy code dump for mesh_read
ampdes Jul 31, 2024
d82a412
Fix errors in read_mesh, add version, git_hash
ampdes Jul 31, 2024
5f4a50d
Add read_mesh of one type
ampdes Aug 1, 2024
d537461
Fix docs
ampdes Aug 1, 2024
4178385
Templated read_mesh
ampdes Aug 1, 2024
6d34167
Add python demo for ADIOS2 wrapper write
ampdes Aug 1, 2024
3f6ce60
isort and formatting
ampdes Aug 1, 2024
8162339
Fix docs
ampdes Aug 1, 2024
b93cc2e
Add missing has_adios2
ampdes Aug 1, 2024
73a2643
Update docs
ampdes Aug 1, 2024
c81221d
Rename to ADIOS2Wrapper and engine_type
ampdes Aug 2, 2024
20708f5
Add python API for write_mesh
ampdes Aug 2, 2024
5f7d505
Fix includes and docs
ampdes Aug 2, 2024
55b266c
Add read_mesh
ampdes Aug 3, 2024
1c548db
Update from review
ampdes Aug 6, 2024
ff0fb62
Update from review
ampdes Aug 12, 2024
a3fe473
Add config file input to ADIOS2 wrapper
ampdes Aug 12, 2024
dd524c7
Merge branch 'main' into checkpointing
ampdes Aug 12, 2024
636f742
Refactor and clean
ampdes Aug 14, 2024
77f059f
Parametrize ghost_mode; add cpp demo to doc
ampdes Aug 14, 2024
64480e2
Add test; add ufl_domain to the read_mesh
ampdes Aug 16, 2024
61a8288
Fix import errors
ampdes Aug 16, 2024
2611b1b
Merge branch 'main' into checkpointing
ampdes Aug 16, 2024
e988a0a
Add version compatibility check
ampdes Aug 17, 2024
2cfebf2
Reorganize namespaces
ampdes Aug 19, 2024
2688e51
Redesign ADIOS2Wrapper to hold multiple IO and Engine
ampdes Aug 22, 2024
fb39916
Clean up and update for the new wrapper
ampdes Aug 25, 2024
8bec1a1
Add time dependent mesh write
ampdes Aug 26, 2024
24bab34
Add read_timestamps in readrandomaccess mode
ampdes Aug 29, 2024
a0543eb
Replace basic loops with std::ranges::transform
ampdes Aug 30, 2024
80265ae
Merge branch 'main' into checkpointing
ampdes Aug 30, 2024
9583a3b
Add tests for time dependent mesh
ampdes Aug 30, 2024
473bba4
Merge branch 'main' into checkpointing
ampdes Sep 12, 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
64 changes: 57 additions & 7 deletions cpp/demo/checkpointing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ int main(int argc, char* argv[])
adios2::Engine engine = io.Open("mesh.bp", adios2::Mode::Append);

io::native::write_mesh(io, engine, *mesh);
std::span<float> x = mesh->geometry().x();
for (std::size_t i = 0; i < x.size(); ++i)
{
x[i] *= 4;
}
Copy link
Member

@jorgensd jorgensd Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use std::for_each to illustrate good coding practices, see:
https://godbolt.org/z/97osavhb6


io::native::write_mesh(io, engine, *mesh, 0.5);

engine.Close();
}
Expand All @@ -51,28 +58,71 @@ int main(int argc, char* argv[])

try
{
// Set up ADIOS2 IO and Engine
// Read mode : set up ADIOS2 IO and Engine
adios2::ADIOS adios_read(MPI_COMM_WORLD);
adios2::IO io_read = adios_read.DeclareIO("mesh-read");
io_read.SetEngine("BP5");
adios2::Engine engine_read = io_read.Open("mesh.bp", adios2::Mode::Read);

// ReadRandomAccess mode : set up ADIOS2 IO and Engine
adios2::IO io_rra = adios_read.DeclareIO("mesh-rra");
io_rra.SetEngine("BP5");
adios2::Engine engine_rra
= io_rra.Open("mesh.bp", adios2::Mode::ReadRandomAccess);

// Write mode : set up ADIOS2 IO and Engine
adios2::IO io_write = adios_read.DeclareIO("mesh-write");
io_write.SetEngine("BP5");
adios2::Engine engine_write
= io_write.Open("mesh2.bp", adios2::Mode::Write);

// Find the time stamps array
auto var_time = io_rra.InquireVariable<double>("time");
const std::vector<std::vector<adios2::Variable<double>::Info>> timestepsinfo
= var_time.AllStepsBlocksInfo();

std::size_t num_steps = timestepsinfo.size();
std::vector<double> times(num_steps);

for (std::size_t step = 0; step < num_steps; ++step)
{
var_time.SetStepSelection({step, 1});
engine_rra.Get(var_time, times[step]);
}
engine_rra.Close();

// Read mesh
engine_read.BeginStep();
auto mesh_read
= io::native::read_mesh<float>(io_read, engine_read, MPI_COMM_WORLD);
if (engine_read.BetweenStepPairs())
{
engine_read.EndStep();
}
// Write mesh
io::native::write_mesh(io_write, engine_write, mesh_read);

engine_read.Close();
// Update mesh
double time = 0.5;
std::size_t querystep;
auto pos = std::ranges::find(times, time);
if (pos != times.end())
{
querystep = std::ranges::distance(times.begin(), pos);
std::cout << "Query step is : " << querystep << "\n";
}
else
{
throw std::runtime_error("Step corresponding to time : "
+ std::to_string(time) + " not found");
}

adios2::IO io_write = adios_read.DeclareIO("mesh-write");
io_write.SetEngine("BP5");
adios2::Engine engine_write
= io_write.Open("mesh2.bp", adios2::Mode::Write);
io::native::update_mesh<float>(io_read, engine_read, mesh_read, querystep);

io::native::write_mesh(io_write, engine_write, mesh_read);
// Write updated mesh
io::native::write_mesh(io_write, engine_write, mesh_read, time);

engine_read.Close();
engine_write.Close();
}
catch (std::exception& e)
Expand Down
Loading
Loading