From 970474fc7afc980ceef5e37cd4f886b29be5a8bc Mon Sep 17 00:00:00 2001 From: "Martin D. Weinberg" Date: Tue, 15 Apr 2025 19:15:13 -0400 Subject: [PATCH 01/10] Expose coefctr from Basis to client classes --- expui/BasisFactory.H | 2 ++ 1 file changed, 2 insertions(+) diff --git a/expui/BasisFactory.H b/expui/BasisFactory.H index a9167396d..19b2fe6e6 100644 --- a/expui/BasisFactory.H +++ b/expui/BasisFactory.H @@ -263,6 +263,8 @@ namespace BasisClasses std::vector getFieldLabels(void) { return getFieldLabels(coordinates); } + //! Get the basis expansion center + std::vector getCenter() { return coefctr; } }; using BasisPtr = std::shared_ptr; From ec05fd98bff3452d512e5ecbc3c9203b458b09b6 Mon Sep 17 00:00:00 2001 From: "Martin D. Weinberg" Date: Tue, 15 Apr 2025 19:15:20 -0400 Subject: [PATCH 02/10] Add omitted center subtraction for getFields evaluation in evalaccel() --- expui/BiorthBasis.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/expui/BiorthBasis.cc b/expui/BiorthBasis.cc index f9237bc65..e6eab3a2d 100644 --- a/expui/BiorthBasis.cc +++ b/expui/BiorthBasis.cc @@ -3685,11 +3685,17 @@ namespace BasisClasses // auto basis = std::get<0>(mod); + // Get expansion center + // + auto ctr = basis->getCenter(); + // Get fields // int rows = accel.rows(); for (int n=0; ngetFields(ps(n, 0), ps(n, 1), ps(n, 2)); + auto v = basis->getFields(ps(n, 0) - ctr[0], + ps(n, 1) - ctr[1], + ps(n, 2) - ctr[2]); // First 6 fields are density and potential, follewed by acceleration for (int k=0; k<3; k++) accel(n, k) += v[6+k] - basis->pseudo(k); } @@ -3899,10 +3905,14 @@ namespace BasisClasses // int numT = floor( (tfinal - tinit)/h ); - // Compute output step + // Number of output steps. Will attempt to find the best stride... + // + int stride = std::ceil(static_cast(numT)/static_cast(nout)); + if (stride>1) numT = nout * stride; + + // Compute the interval-matching step // - nout = std::min(numT, nout); - double H = (tfinal - tinit)/nout; + h = (tfinal - tinit)/(numT - 1); // Return data // @@ -3934,9 +3944,11 @@ namespace BasisClasses for (int k=0; k<6; k++) ret(n, k, 0) = ps(n, k); double tnow = tinit; - for (int s=1, cnt=1; s= H*cnt-h*1.0e-8) { + if (s++ % stride == 0) { times(cnt) = tnow; for (int n=0; n Date: Tue, 15 Apr 2025 19:23:14 -0400 Subject: [PATCH 03/10] Restore BiorthBasis.cc to pre tfinalFix condition for this branch --- expui/BiorthBasis.cc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/expui/BiorthBasis.cc b/expui/BiorthBasis.cc index e6eab3a2d..5397b3f2b 100644 --- a/expui/BiorthBasis.cc +++ b/expui/BiorthBasis.cc @@ -3905,14 +3905,10 @@ namespace BasisClasses // int numT = floor( (tfinal - tinit)/h ); - // Number of output steps. Will attempt to find the best stride... + // Compute output step // - int stride = std::ceil(static_cast(numT)/static_cast(nout)); - if (stride>1) numT = nout * stride; - - // Compute the interval-matching step - // - h = (tfinal - tinit)/(numT - 1); + nout = std::min(numT, nout); + double H = (tfinal - tinit)/nout; // Return data // @@ -3944,11 +3940,9 @@ namespace BasisClasses for (int k=0; k<6; k++) ret(n, k, 0) = ps(n, k); double tnow = tinit; - int s = 0, cnt = 0; - while (s < numT) { - if (tfinal - tnow < h) h = tfinal - tnow; + for (int s=1, cnt=1; s= H*cnt-h*1.0e-8) { times(cnt) = tnow; for (int n=0; n Date: Sat, 19 Apr 2025 21:47:51 +0100 Subject: [PATCH 04/10] Expose expansion center in pyEXP --- pyEXP/CoefWrappers.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyEXP/CoefWrappers.cc b/pyEXP/CoefWrappers.cc index 97c394db0..765db774b 100644 --- a/pyEXP/CoefWrappers.cc +++ b/pyEXP/CoefWrappers.cc @@ -717,6 +717,11 @@ void CoefficientClasses(py::module &m) { float data's time stamp )") + .def_readwrite("center", &CoefStruct::ctr, + R"( + array of floats + the expansion center + )") .def("getCoefs", &CoefStruct::getCoefs, R"( Read-only access to the underlying data store From 09e6c2955734b3f5df00e3bf2884725e435ee8ca Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Sun, 20 Apr 2025 14:05:28 +0100 Subject: [PATCH 05/10] add getCenter/setCenter members --- expui/CoefStruct.H | 11 +++++++++++ pyEXP/CoefWrappers.cc | 43 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/expui/CoefStruct.H b/expui/CoefStruct.H index 4afca4cf9..3f662e8c3 100644 --- a/expui/CoefStruct.H +++ b/expui/CoefStruct.H @@ -62,6 +62,17 @@ namespace CoefClasses //! Read-only access to coefficient data (no copy) Eigen::Ref getCoefs() { return store; } + //! Set new center data (no copy) + void setCenter(std::vector& STORE) + { + if (STORE.size() != ctr.size()) + throw std::invalid_argument("CoefStruct::setCenter: center vector size does not match"); + ctr = STORE; + } + + //! Read-only access to center (no copy) + std::vector getCenter() { return ctr; } + }; //! Specialization of CoefStruct for spheres diff --git a/pyEXP/CoefWrappers.cc b/pyEXP/CoefWrappers.cc index 765db774b..8dd17b178 100644 --- a/pyEXP/CoefWrappers.cc +++ b/pyEXP/CoefWrappers.cc @@ -717,11 +717,46 @@ void CoefficientClasses(py::module &m) { float data's time stamp )") - .def_readwrite("center", &CoefStruct::ctr, + .def_readonly("center", &CoefStruct::ctr, R"( - array of floats - the expansion center - )") + array of floats + the expansion center + )") + .def("getCenter", &CoefStruct::getCenter, + R"( + Read-only access to the center data + + Returns + ------- + numpy.ndarray + vector of center data + + See also + -------- + setCenter : read-write access to the center data + )") + .def("setCenter", + static_cast&)>(&CoefStruct::setCenter), + py::arg("mat"), + R"( + Set the center vector + + Parameters + ---------- + mat : numpy.ndarray + center vector + + Returns + ------- + None + + Notes + ----- + + See also + -------- + getCenter : read-only access to center data + )") .def("getCoefs", &CoefStruct::getCoefs, R"( Read-only access to the underlying data store From 093818c9487974c095bc93ba72e547909e287302 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Mon, 21 Apr 2025 10:56:13 +0100 Subject: [PATCH 06/10] change center member names; create time members --- expui/CoefStruct.H | 9 +++++++++ pyEXP/CoefWrappers.cc | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/expui/CoefStruct.H b/expui/CoefStruct.H index 3f662e8c3..4276cb95e 100644 --- a/expui/CoefStruct.H +++ b/expui/CoefStruct.H @@ -73,6 +73,15 @@ namespace CoefClasses //! Read-only access to center (no copy) std::vector getCenter() { return ctr; } + //! Set coefficient time (no copy) + void setTime(double& STORE) + { + time = STORE; + } + + //! Read-only access to center (no copy) + double getTime() { return time; } + }; //! Specialization of CoefStruct for spheres diff --git a/pyEXP/CoefWrappers.cc b/pyEXP/CoefWrappers.cc index 8dd17b178..d8e62127c 100644 --- a/pyEXP/CoefWrappers.cc +++ b/pyEXP/CoefWrappers.cc @@ -717,12 +717,42 @@ void CoefficientClasses(py::module &m) { float data's time stamp )") - .def_readonly("center", &CoefStruct::ctr, - R"( - array of floats - the expansion center + .def("getCoefTime", &CoefStruct::getTime, + R"( + Read-only access to the coefficient time + + Returns + ------- + numpy.ndarray + vector of center data + + See also + -------- + setCenter : read-write access to the coefficient time + )") + .def("setCoefTime", + static_cast(&CoefStruct::setTime), + py::arg("tval"), + R"( + Set the coefficien time + + Parameters + ---------- + tval : float + time value + + Returns + ------- + None + + Notes + ----- + + See also + -------- + getCenter : read-only access to coefficient time )") - .def("getCenter", &CoefStruct::getCenter, + .def("getCoefCenter", &CoefStruct::getCenter, R"( Read-only access to the center data @@ -735,7 +765,7 @@ void CoefficientClasses(py::module &m) { -------- setCenter : read-write access to the center data )") - .def("setCenter", + .def("setCoefCenter", static_cast&)>(&CoefStruct::setCenter), py::arg("mat"), R"( From 08957f38e4f2d3b5382b7373575d0a7a0025fcc7 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Mon, 21 Apr 2025 10:59:34 +0100 Subject: [PATCH 07/10] version bump only [no CI] --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffba0d1b6..dbf34eaf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) # Needed for CUDA, MPI, and CTest features project( EXP - VERSION "7.8.1" + VERSION "7.8.2" HOMEPAGE_URL https://github.com/EXP-code/EXP LANGUAGES C CXX Fortran) From 9fe6efa40b841ae6d9874626aee5b44b5c09c81f Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Mon, 21 Apr 2025 19:57:51 +0100 Subject: [PATCH 08/10] add readonly attributes --- pyEXP/CoefWrappers.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyEXP/CoefWrappers.cc b/pyEXP/CoefWrappers.cc index d8e62127c..d01718371 100644 --- a/pyEXP/CoefWrappers.cc +++ b/pyEXP/CoefWrappers.cc @@ -712,11 +712,16 @@ void CoefficientClasses(py::module &m) { str geometry type )") - .def_readwrite("time", &CoefStruct::time, + .def_readonly("time", &CoefStruct::time, R"( float data's time stamp )") + .def_readonly("center", &CoefStruct::ctr, + R"( + float + data's center value + )") .def("getCoefTime", &CoefStruct::getTime, R"( Read-only access to the coefficient time From fbc25a4d9f9e148f26f231cece55ca14f54ea8e2 Mon Sep 17 00:00:00 2001 From: michael-petersen Date: Tue, 22 Apr 2025 11:05:04 +0100 Subject: [PATCH 09/10] add default center --- expui/CoefStruct.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expui/CoefStruct.H b/expui/CoefStruct.H index 4276cb95e..26d011e28 100644 --- a/expui/CoefStruct.H +++ b/expui/CoefStruct.H @@ -27,7 +27,7 @@ namespace CoefClasses Eigen::VectorXcd store; //! Center data - std::vector ctr; + std::vector ctr= {0.0, 0.0, 0.0}; //! Destructor virtual ~CoefStruct() {} From aafec0f3920d20135de85213fb841f499ffbc8c1 Mon Sep 17 00:00:00 2001 From: Michael Petersen Date: Tue, 22 Apr 2025 13:47:51 +0100 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pyEXP/CoefWrappers.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyEXP/CoefWrappers.cc b/pyEXP/CoefWrappers.cc index d01718371..fc4fa42dd 100644 --- a/pyEXP/CoefWrappers.cc +++ b/pyEXP/CoefWrappers.cc @@ -733,13 +733,13 @@ void CoefficientClasses(py::module &m) { See also -------- - setCenter : read-write access to the coefficient time + setCoefTime : read-write access to the coefficient time )") .def("setCoefTime", static_cast(&CoefStruct::setTime), py::arg("tval"), R"( - Set the coefficien time + Set the coefficient time Parameters ----------