From aaf0a99631ba6fc0bed434cfdf34b28e3c05f82f Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 13 Dec 2022 12:48:56 +0100 Subject: [PATCH] Box -> ff --- Sample/HardParticle/Polyhedra.cpp | 29 +----- Sample/HardParticle/Polyhedra.h | 12 --- Tests/Unit/Sample/FormFactorBasicTest.cpp | 3 +- Tests/Unit/Sim/PythonFormattingTest.cpp | 13 --- auto/Wrap/libBornAgainSample.py | 16 ---- auto/Wrap/libBornAgainSample_wrap.cpp | 111 ---------------------- 6 files changed, 4 insertions(+), 180 deletions(-) diff --git a/Sample/HardParticle/Polyhedra.cpp b/Sample/HardParticle/Polyhedra.cpp index c97a65cb7d1..dcb9dacb3cc 100644 --- a/Sample/HardParticle/Polyhedra.cpp +++ b/Sample/HardParticle/Polyhedra.cpp @@ -29,7 +29,8 @@ Box::Box(const std::vector<double> P) , m_width(m_P[1]) , m_height(m_P[2]) { - validateOrThrow(); + pimpl.reset(ff::make::Box(m_length, m_width, m_height)); + m_validated = true; } Box::Box(double length, double width, double height) @@ -37,32 +38,6 @@ Box::Box(double length, double width, double height) { } -complex_t Box::formfactor(C3 q) const -{ - ASSERT(m_validated); - complex_t qzHdiv2 = m_height / 2 * q.z(); - return m_length * m_width * m_height * Math::sinc(m_length / 2 * q.x()) - * Math::sinc(m_width / 2 * q.y()) * Math::sinc(qzHdiv2) * exp_I(qzHdiv2); -} - -std::string Box::validate() const -{ - std::vector<std::string> errs; - requestGt0(errs, m_length, "length"); - requestGt0(errs, m_width, "width"); - requestGt0(errs, m_height, "height"); - if (!errs.empty()) - return jointError(errs); - - double a = m_length / 2; - double b = m_width / 2; - std::vector<R3> base_vertices{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}}; - setPrism(true, base_vertices); - - m_validated = true; - return ""; -} - Prism3::Prism3(const std::vector<double> P) : IFormFactorPrism(P) diff --git a/Sample/HardParticle/Polyhedra.h b/Sample/HardParticle/Polyhedra.h index d21cc5b349d..4179044e21f 100644 --- a/Sample/HardParticle/Polyhedra.h +++ b/Sample/HardParticle/Polyhedra.h @@ -58,18 +58,6 @@ public: return m_height; } - double volume() const override - { - return m_length * m_height * m_width; - } - double radialExtension() const override - { - return m_length / 2.0; - } - complex_t formfactor(C3 q) const override; - - std::string validate() const override; - private: const double& m_length; const double& m_width; diff --git a/Tests/Unit/Sample/FormFactorBasicTest.cpp b/Tests/Unit/Sample/FormFactorBasicTest.cpp index f7dbb896fe4..91a638902a7 100644 --- a/Tests/Unit/Sample/FormFactorBasicTest.cpp +++ b/Tests/Unit/Sample/FormFactorBasicTest.cpp @@ -157,7 +157,8 @@ TEST_F(FormFactorBasicTest, Box) double volume = length * height * width; Box particle(length, width, height); - EXPECT_EQ(3., particle.radialExtension()); + EXPECT_NEAR(sqrt(pow(length / 2, 2) + pow(height / 2, 2) + pow(width / 2, 2)), + particle.radialExtension(), 1e-14); EXPECT_DOUBLE_EQ(volume, particle.volume()); RotationZ rot(.42); diff --git a/Tests/Unit/Sim/PythonFormattingTest.cpp b/Tests/Unit/Sim/PythonFormattingTest.cpp index 4c2bb6367ae..96c0510f521 100644 --- a/Tests/Unit/Sim/PythonFormattingTest.cpp +++ b/Tests/Unit/Sim/PythonFormattingTest.cpp @@ -5,31 +5,18 @@ #include "Sample/Correlations/Profiles1D.h" #include "Sample/Correlations/Profiles2D.h" #include "Sample/HardParticle/Bar.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" #include "Sample/HardParticle/Cone.h" #include "Sample/HardParticle/CosineRipple.h" #include "Sample/HardParticle/Cylinder.h" -#include "Sample/HardParticle/Polyhedra.h" #include "Sample/HardParticle/EllipsoidalCylinder.h" #include "Sample/HardParticle/HemiEllipsoid.h" #include "Sample/HardParticle/HorizontalCylinder.h" -#include "Sample/HardParticle/Polyhedra.h" #include "Sample/HardParticle/LongBoxGauss.h" #include "Sample/HardParticle/LongBoxLorentz.h" #include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" -#include "Sample/HardParticle/Polyhedra.h" #include "Sample/HardParticle/SawtoothRipple.h" #include "Sample/HardParticle/Sphere.h" #include "Sample/HardParticle/Spheroid.h" -#include "Sample/HardParticle/Polyhedra.h" #include "Sample/HardParticle/TruncatedSphere.h" #include "Sample/HardParticle/TruncatedSpheroid.h" #include "Sample/Interface/LayerRoughness.h" diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py index 3e29a4ccabe..ae48a74ecfa 100644 --- a/auto/Wrap/libBornAgainSample.py +++ b/auto/Wrap/libBornAgainSample.py @@ -4846,22 +4846,6 @@ class Box(IFormFactorPrism): def height(self): r"""height(Box self) -> double""" return _libBornAgainSample.Box_height(self) - - def volume(self): - r"""volume(Box self) -> double""" - return _libBornAgainSample.Box_volume(self) - - def radialExtension(self): - r"""radialExtension(Box self) -> double""" - return _libBornAgainSample.Box_radialExtension(self) - - def formfactor(self, q): - r"""formfactor(Box self, C3 q) -> complex_t""" - return _libBornAgainSample.Box_formfactor(self, q) - - def validate(self): - r"""validate(Box self) -> std::string""" - return _libBornAgainSample.Box_validate(self) __swig_destroy__ = _libBornAgainSample.delete_Box # Register Box in _libBornAgainSample: diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp index f159f6c9f2e..c267d66b3c4 100644 --- a/auto/Wrap/libBornAgainSample_wrap.cpp +++ b/auto/Wrap/libBornAgainSample_wrap.cpp @@ -48778,113 +48778,6 @@ fail: } -SWIGINTERN PyObject *_wrap_Box_volume(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Box *arg1 = (Box *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - double result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Box, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Box_volume" "', argument " "1"" of type '" "Box const *""'"); - } - arg1 = reinterpret_cast< Box * >(argp1); - result = (double)((Box const *)arg1)->volume(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Box_radialExtension(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Box *arg1 = (Box *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - double result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Box, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Box_radialExtension" "', argument " "1"" of type '" "Box const *""'"); - } - arg1 = reinterpret_cast< Box * >(argp1); - result = (double)((Box const *)arg1)->radialExtension(); - resultobj = SWIG_From_double(static_cast< double >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Box_formfactor(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Box *arg1 = (Box *) 0 ; - C3 arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - complex_t result; - - if (!SWIG_Python_UnpackTuple(args, "Box_formfactor", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Box, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Box_formfactor" "', argument " "1"" of type '" "Box const *""'"); - } - arg1 = reinterpret_cast< Box * >(argp1); - { - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Vec3T_std__complexT_double_t_t, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Box_formfactor" "', argument " "2"" of type '" "C3""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Box_formfactor" "', argument " "2"" of type '" "C3""'"); - } else { - C3 * temp = reinterpret_cast< C3 * >(argp2); - arg2 = *temp; - if (SWIG_IsNewObj(res2)) delete temp; - } - } - result = ((Box const *)arg1)->formfactor(arg2); - resultobj = SWIG_From_std_complex_Sl_double_Sg_(static_cast< std::complex<double> >(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Box_validate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Box *arg1 = (Box *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - std::string result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Box, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Box_validate" "', argument " "1"" of type '" "Box const *""'"); - } - arg1 = reinterpret_cast< Box * >(argp1); - result = ((Box const *)arg1)->validate(); - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_delete_Box(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Box *arg1 = (Box *) 0 ; @@ -62023,10 +61916,6 @@ static PyMethodDef SwigMethods[] = { { "Box_length", _wrap_Box_length, METH_O, "Box_length(Box self) -> double"}, { "Box_width", _wrap_Box_width, METH_O, "Box_width(Box self) -> double"}, { "Box_height", _wrap_Box_height, METH_O, "Box_height(Box self) -> double"}, - { "Box_volume", _wrap_Box_volume, METH_O, "Box_volume(Box self) -> double"}, - { "Box_radialExtension", _wrap_Box_radialExtension, METH_O, "Box_radialExtension(Box self) -> double"}, - { "Box_formfactor", _wrap_Box_formfactor, METH_VARARGS, "Box_formfactor(Box self, C3 q) -> complex_t"}, - { "Box_validate", _wrap_Box_validate, METH_O, "Box_validate(Box self) -> std::string"}, { "delete_Box", _wrap_delete_Box, METH_O, "delete_Box(Box self)"}, { "Box_swigregister", Box_swigregister, METH_O, NULL}, { "Box_swiginit", Box_swiginit, METH_VARARGS, NULL}, -- GitLab