From 607703d259ac8e64c1dfaccf1488d42e286a6bc2 Mon Sep 17 00:00:00 2001 From: Mark Messner Date: Thu, 10 Nov 2022 12:02:40 -0500 Subject: [PATCH] Need a way to get active orientations back out of models --- include/cp/batch.h | 3 +++ include/cp/polycrystal.h | 1 + src/cp/batch.cxx | 12 ++++++++++++ src/cp/polycrystal.cxx | 9 +++++++++ src/cp/polycrystal_wrap.cxx | 7 ++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/cp/batch.h b/include/cp/batch.h index 498b5edc..351af660 100644 --- a/include/cp/batch.h +++ b/include/cp/batch.h @@ -27,6 +27,9 @@ NEML_EXPORT void set_orientation_passive_batch(SingleCrystalModel & model, size_ NEML_EXPORT void get_orientation_passive_batch(SingleCrystalModel & model, size_t n, double * const hist, std::vector & orientations); +NEML_EXPORT void get_orientation_active_batch(SingleCrystalModel & model, size_t n, + double * const hist, + std::vector & orientations); } // namespace neml diff --git a/include/cp/polycrystal.h b/include/cp/polycrystal.h index 6244d5e5..dc17b1ff 100644 --- a/include/cp/polycrystal.h +++ b/include/cp/polycrystal.h @@ -33,6 +33,7 @@ class NEML_EXPORT PolycrystalModel: public NEMLModel_ldi const double * w(const double * const store, size_t i) const; virtual std::vector orientations(double * const store) const; + virtual std::vector orientations_active(double * const store) const; protected: std::shared_ptr model_; diff --git a/src/cp/batch.cxx b/src/cp/batch.cxx index ab3d8ee3..09923470 100644 --- a/src/cp/batch.cxx +++ b/src/cp/batch.cxx @@ -70,4 +70,16 @@ void get_orientation_passive_batch(SingleCrystalModel & model, size_t n, } } +void get_orientation_active_batch(SingleCrystalModel & model, size_t n, + double * const hist, + std::vector & orientations) +{ + orientations.resize(n); + size_t nh = model.nstore(); + + for (size_t i=0; i PolycrystalModel::orientations(double * const store) co return res; } +std::vector PolycrystalModel::orientations_active(double * const store) const +{ + std::vector res; + + get_orientation_active_batch(*model_, n(), + history(store, 0), res); + return res; +} + TaylorModel::TaylorModel(ParameterSet & params) : PolycrystalModel(params) { diff --git a/src/cp/polycrystal_wrap.cxx b/src/cp/polycrystal_wrap.cxx index 8c39a3e7..b89932f9 100644 --- a/src/cp/polycrystal_wrap.cxx +++ b/src/cp/polycrystal_wrap.cxx @@ -21,7 +21,12 @@ PYBIND11_MODULE(polycrystal, m) { [](PolycrystalModel & m, py::array_t h) -> std::vector { return m.orientations(arr2ptr(h)); - }, "Return the current vector of orientations") + }, "Return the current vector of orientations in the passive convention") + .def("orientations_active", + [](PolycrystalModel & m, py::array_t h) -> std::vector + { + return m.orientations_active(arr2ptr(h)); + }, "Return the current vector of orientations in the active convention") ; py::class_>(m, "TaylorModel")