From 600f04a660ac12ddf265243dfbd82adaf6d535b3 Mon Sep 17 00:00:00 2001 From: acrovato <a.crovato@uliege.be> Date: Fri, 11 Mar 2022 14:30:48 +0100 Subject: [PATCH] Revert MshDeform::msh to public (easier) --- tbox/_src/tboxw.i | 1 + tbox/src/wMshDeform.cpp | 5 +++-- tbox/src/wMshDeform.h | 3 ++- tbox/src/wUnitTest.cpp | 4 ++-- tbox/src/wUnitTest.h | 2 +- tbox/tests/meshDeformation.py | 2 +- tbox/tests/meshDeformation3.py | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tbox/_src/tboxw.i b/tbox/_src/tboxw.i index c058293..8f2c75b 100644 --- a/tbox/_src/tboxw.i +++ b/tbox/_src/tboxw.i @@ -142,6 +142,7 @@ namespace std { %include "wGroups.h" %warnfilter(+509); %shared_ptr(tbox::MshDeform); +%immutable tbox::MshDeform::msh; // read-only variable (no setter) %include "wMshDeform.h" // included after std templates because it needs them %shared_ptr(tbox::MshCrack); %include "wMshCrack.h" diff --git a/tbox/src/wMshDeform.cpp b/tbox/src/wMshDeform.cpp index 9e06c9c..e3f4e39 100644 --- a/tbox/src/wMshDeform.cpp +++ b/tbox/src/wMshDeform.cpp @@ -32,9 +32,10 @@ using namespace tbox; MshDeform::MshDeform(std::shared_ptr<MshData> _msh, std::shared_ptr<tbox::LinearSolver> _linsol, - int _nDim, int nthrds) : wSharedObject(), msh(_msh), linsol(_linsol), + int _nDim, int nthrds) : wSharedObject(), linsol(_linsol), nDim(_nDim), nthreads(nthrds), - field(false), fixed(false), moving(false) + field(false), fixed(false), + moving(false), msh(_msh) { // Check problem dimension if (nDim != 2 && nDim != 3) diff --git a/tbox/src/wMshDeform.h b/tbox/src/wMshDeform.h index 8f4a090..839001d 100644 --- a/tbox/src/wMshDeform.h +++ b/tbox/src/wMshDeform.h @@ -34,7 +34,6 @@ namespace tbox class TBOX_API MshDeform : public fwk::wSharedObject { private: - std::shared_ptr<MshData> msh; ///< mesh std::shared_ptr<tbox::LinearSolver> linsol; ///< linear (inner) solver size_t mshSize; ///< number of nodes in the mesh int nDim; ///< dimension of the problem (2 or 3) @@ -63,6 +62,8 @@ private: Eigen::MatrixXd buildK(tbox::Element const &e, Eigen::MatrixXd const &H); public: + std::shared_ptr<MshData> msh; ///< mesh + MshDeform(std::shared_ptr<MshData> _msh, std::shared_ptr<tbox::LinearSolver> _linsol, int _nDim, int nthrds = 1); virtual ~MshDeform() { std::cout << "~MshDeform()\n"; } diff --git a/tbox/src/wUnitTest.cpp b/tbox/src/wUnitTest.cpp index 4aa6794..7b886c2 100644 --- a/tbox/src/wUnitTest.cpp +++ b/tbox/src/wUnitTest.cpp @@ -78,10 +78,10 @@ void UnitTest::gmshIO(GmshExport *writer, GmshImport *reader) /** * @brief Deform a mesh of dimension d */ -void UnitTest::mshDeform(MshData *msh, MshDeform *mshDef, int d) +void UnitTest::mshDeform(MshDeform *mshDef, int d) { // Initialize memory (volume element only) - for (auto e : msh->elems) + for (auto e : mshDef->msh->elems) if ((d == 2 && e->type() == ELTYPE::TRI3) || (d == 3 && e->type() == ELTYPE::TETRA4)) e->initValues(true); // Call deform diff --git a/tbox/src/wUnitTest.h b/tbox/src/wUnitTest.h index 1170fd8..4a51567 100644 --- a/tbox/src/wUnitTest.h +++ b/tbox/src/wUnitTest.h @@ -36,7 +36,7 @@ public: virtual ~UnitTest() {} void gmshIO(GmshExport *writer, GmshImport *reader); - void mshDeform(MshData *msh, MshDeform *mshDef, int d); + void mshDeform(MshDeform *mshDef, int d); }; } // namespace tbox diff --git a/tbox/tests/meshDeformation.py b/tbox/tests/meshDeformation.py index 3de4d25..02c0c04 100644 --- a/tbox/tests/meshDeformation.py +++ b/tbox/tests/meshDeformation.py @@ -55,7 +55,7 @@ def main(): # deform the mesh test = tbox.UnitTest() tms["deform"].start() - test.mshDeform(msh, mshDef, 2) + test.mshDeform(mshDef, 2) tms["deform"].stop() gmshWriter.save("beam_def") diff --git a/tbox/tests/meshDeformation3.py b/tbox/tests/meshDeformation3.py index cebff8c..6153487 100644 --- a/tbox/tests/meshDeformation3.py +++ b/tbox/tests/meshDeformation3.py @@ -54,7 +54,7 @@ def main(): # deform the mesh test = tbox.UnitTest() tms["deform"].start() - test.mshDeform(msh, mshDef, 3) + test.mshDeform(mshDef, 3) tms["deform"].stop() gmshWriter.save(msh.name+"_def") -- GitLab