-
Notifications
You must be signed in to change notification settings - Fork 9
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
adding Adios2 io support #113
base: master
Are you sure you want to change the base?
Changes from 1 commit
c786f61
788e45c
906c8bc
dcdfe09
a3fe049
ad95f00
a76e37a
cb35d7f
5627b34
1971fe0
aae867b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ template <typename T> | |
void read_value(adios2::IO &, adios2::Engine &reader, | ||
T *val, std::string &name, bool global=false); | ||
|
||
void write_adios2(filesystem::path const& path, | ||
std::map<Mesh*, std::string>& mesh_map); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this stored as a map? Instead of a list of pairs or struct that holds a name and a omega_h mesh pointer? |
||
void write_adios2(filesystem::path const& path, Mesh *mesh, std::string pref=""); | ||
|
||
Mesh read_adios2(filesystem::path const& path, Library* lib, std::string pref=""); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,39 +76,58 @@ int main(int argc, char *argv[]) | |
|
||
Omega_h::CmdLine cmdline; | ||
|
||
cmdline.add_arg<std::string>("input.osh"); | ||
cmdline.add_arg<std::string>("input1.osh"); | ||
cmdline.add_arg<std::string>("input2.osh"); | ||
cmdline.add_arg<std::string>("output.bp"); | ||
if (!cmdline.parse_final(world, &argc, argv)) return -1; | ||
Omega_h::filesystem::path inpath = cmdline.get<std::string>("input.osh"); | ||
Omega_h::filesystem::path inpath1 = cmdline.get<std::string>("input1.osh"); | ||
Omega_h::filesystem::path inpath2 = cmdline.get<std::string>("input2.osh"); | ||
Omega_h::filesystem::path outpath=cmdline.get<std::string>("output.bp"); | ||
|
||
Omega_h::Mesh mesh(&lib); | ||
Omega_h::binary::read(inpath, world, &mesh); | ||
cout<<"\n--- Mesh loaded from \""<<inpath<<"\" ---\n"; | ||
print_info(&lib, mesh); | ||
Omega_h::Mesh mesh1(&lib); | ||
Omega_h::binary::read(inpath1, world, &mesh1); | ||
Omega_h::Mesh mesh2(&lib); | ||
Omega_h::binary::read(inpath2, world, &mesh2); | ||
|
||
cout<<"\n--- Mesh loaded from \""<<inpath1<<"\" ---\n"; | ||
print_info(&lib, mesh1); | ||
cout<<"\n--- Mesh loaded from \""<<inpath2<<"\" ---\n"; | ||
print_info(&lib, mesh2); | ||
|
||
// Omega_h::Mesh mesh = build_box(world, OMEGA_H_SIMPLEX, 1., 1., 0., 2, 2, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. |
||
Omega_h::binary::write("omegah.osh", &mesh); | ||
Omega_h::vtk::write_parallel("omegah.vtk", &mesh); | ||
Omega_h::binary::write("omegah1.osh", &mesh1); | ||
Omega_h::binary::write("omegah2.osh", &mesh2); | ||
// Omega_h::vtk::write_parallel("omegah.vtk", &mesh); | ||
|
||
try | ||
{ | ||
write_adios2(outpath, &mesh, std::string("test")); | ||
Omega_h::Mesh mesh2 = read_adios2(outpath, &lib, std::string("test")); | ||
Omega_h::vtk::write_parallel("adios2.vtk", &mesh2); | ||
|
||
cout<<"\n\n--- Mesh loaded back from \""<<outpath<<"\" ---\n"; | ||
print_info(&lib, mesh2); | ||
map<Mesh*, std::string> mmap; | ||
mmap[&mesh1]="m1"; | ||
mmap[&mesh2]="m2"; | ||
write_adios2(outpath, mmap); | ||
Omega_h::Mesh mesh3 = read_adios2(outpath, &lib, std::string("m1")); | ||
Omega_h::Mesh mesh4 = read_adios2(outpath, &lib, std::string("m2")); | ||
//Omega_h::vtk::write_parallel("adios2.vtk", &mesh2); | ||
|
||
cout<<"\n\n--- Two meshes loaded back from \""<<outpath<<"\" ---\n"; | ||
print_info(&lib, mesh3); | ||
print_info(&lib, mesh4); | ||
|
||
double tol = 1e-6, floor = 0.0; | ||
bool allow_superset = false; | ||
auto opts = MeshCompareOpts::init( | ||
&mesh, VarCompareOpts{VarCompareOpts::RELATIVE, tol, floor}); | ||
auto res = compare_meshes(&mesh, &mesh2, opts, true); | ||
&mesh1, VarCompareOpts{VarCompareOpts::RELATIVE, tol, floor}); | ||
auto res = compare_meshes(&mesh1, &mesh3, opts, true); | ||
if (res == OMEGA_H_SAME || (allow_superset && res == OMEGA_H_MORE)) | ||
{ | ||
cout << "\nSUCCESS! Two meshes (.osh and .bp) are the same\n"; | ||
return 0; | ||
opts = MeshCompareOpts::init( | ||
&mesh2, VarCompareOpts{VarCompareOpts::RELATIVE, tol, floor}); | ||
res = compare_meshes(&mesh2, &mesh4, opts, true); | ||
if (res == OMEGA_H_SAME || (allow_superset && res == OMEGA_H_MORE)) | ||
{ | ||
cout << "\nSUCCESS! Meshes loaded from .osh and .bp are the same\n"; | ||
return 0; | ||
} | ||
} | ||
cout << "\nFAIL! Two meshes (.osh and .bp) are NOT the same\n"; | ||
return 2; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this named
_write_adios2
? We generally avoid having names that start with underscore or double underscore inC++
because depending on the second symbol it could be undefined behavior.see: https://en.cppreference.com/w/cpp/language/identifiers