-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I need to read in a MultiFab so added this. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2ed3ba2
commit 6c2dc4f
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ foreach(D IN LISTS AMReX_SPACEDIM) | |
Utility.cpp | ||
Vector.cpp | ||
Version.cpp | ||
VisMF.cpp | ||
) | ||
|
||
if (AMReX_MPI) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Copyright 2024 The AMReX Community | ||
* | ||
* Authors: David Grote | ||
* License: BSD-3-Clause-LBNL | ||
*/ | ||
#include "pyAMReX.H" | ||
|
||
#include <AMReX_VisMF.H> | ||
#include <AMReX_MultiFab.H> | ||
|
||
void init_VisMF(py::module &m) | ||
{ | ||
py::class_< amrex::VisMF > py_VisMF(m, "VisMF"); | ||
|
||
py_VisMF | ||
.def_static("Write", | ||
[](const amrex::FabArray<amrex::FArrayBox> &mf, const std::string& name) { | ||
return amrex::VisMF::Write(mf, name); | ||
}, | ||
py::arg("mf"), py::arg("name"), | ||
"Writes a Multifab to the specified file") | ||
.def_static("Read", | ||
[](const std::string &name) { | ||
amrex::MultiFab mf; | ||
if (amrex::VisMF::Exist(name)) { | ||
amrex::VisMF::Read(mf, name); | ||
} else { | ||
throw std::runtime_error("MultiFab file " + name + " couldn't be found!"); | ||
} | ||
return mf; | ||
}, | ||
py::return_value_policy::move, | ||
py::arg("name"), | ||
"Reads a MultiFab from the specified file") | ||
.def_static("Read", | ||
[](const std::string &name, amrex::MultiFab &mf) { | ||
if (amrex::VisMF::Exist(name)) { | ||
amrex::VisMF::Read(mf, name); | ||
} else { | ||
throw std::runtime_error("MultiFab file " + name + " couldn't be found!"); | ||
} | ||
}, | ||
py::arg("name"), py::arg("mf"), | ||
"Reads a MultiFab from the specified file into the given MultiFab. The BoxArray on the disk must match the BoxArray * in mf") | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters