Skip to content

Commit

Permalink
wrapper for concatenate function in amrex (#145)
Browse files Browse the repository at this point in the history
* wrapper for concatenate function in amrex

* add test for concatenate function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* alphabetical order

Co-authored-by: Axel Huebl <[email protected]>

* alphabetical order

* user-facing function with py::arg

Co-authored-by: Axel Huebl <[email protected]>

* Cleaning

* Cleaning

* Cleaning

* Add Authors

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel Huebl <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2023
1 parent 09855cf commit 9cdc6ce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ foreach(D IN LISTS AMReX_SPACEDIM)
ParmParse.cpp
Periodicity.cpp
PODVector.cpp
Utility.cpp
Vector.cpp
)
endforeach()
20 changes: 20 additions & 0 deletions src/Base/Utility.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Copyright 2021-2022 The AMReX Community
*
* License: BSD-3-Clause-LBNL
* Authors: Revathi Jambunathan, Axel Huebl
*/
#include <AMReX_Utility.H>
#include <pybind11/pybind11.h>
#include <sstream>

namespace py = pybind11;
using namespace amrex;

void init_Utility(py::module& m)
{
m.def("concatenate",
&amrex::Concatenate,
"Builds plotfile name",
py::arg("root"), py::arg("num"), py::arg("mindigits")=5
);
}
5 changes: 5 additions & 0 deletions src/pyAMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void init_ParticleTile(py::module &);
void init_ParticleContainer(py::module &);
void init_Periodicity(py::module &);
void init_PODVector(py::module &);
void init_Utility(py::module &);
void init_Vector(py::module &);


Expand Down Expand Up @@ -82,6 +83,7 @@ PYBIND11_MODULE(amrex_3d_pybind, m) {
Periodicity
PODVector
StructOfArrays
Utility
Vector
)pbdoc";

Expand Down Expand Up @@ -114,6 +116,9 @@ PYBIND11_MODULE(amrex_3d_pybind, m) {
init_ParticleContainer(m);
init_AmrMesh(m);

// Wrappers around standalone functions
init_Utility(m);

// API runtime version
// note PEP-440 syntax: x.y.zaN but x.y.z.devN
#ifdef PYAMReX_VERSION_INFO
Expand Down
8 changes: 8 additions & 0 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-

import amrex.space3d as amr


def test_concatenate():
pltname = amr.concatenate("plt", 1000, 5)
assert pltname == "plt01000"

0 comments on commit 9cdc6ce

Please sign in to comment.