From 80a479ce7945e774a741758b50d04e1082dd5f1c Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Mon, 19 Jul 2021 20:13:11 +0200 Subject: [PATCH] rm ComputeBA* --- Resample/FFCompute/ComputeBA.cpp | 28 ------- Resample/FFCompute/ComputeBA.h | 37 --------- Resample/FFCompute/ComputeBAPol.cpp | 33 -------- Resample/FFCompute/ComputeBAPol.h | 37 --------- Resample/FFCompute/ComputeDWBA.cpp | 6 ++ Resample/FFCompute/ComputeDWBA.h | 1 + Resample/FFCompute/ComputeDWBAPol.cpp | 13 ++++ Resample/FFCompute/ComputeDWBAPol.h | 1 + Resample/FFCompute/IComputeFF.cpp | 4 + Resample/FFCompute/IComputeFF.h | 3 + Resample/Processed/ProcessedLayout.cpp | 15 ++-- .../Core/Sample/FormFactorCoherentSumTest.cpp | 4 +- auto/Wrap/doxygenResample.i | 78 ++++--------------- 13 files changed, 52 insertions(+), 208 deletions(-) delete mode 100644 Resample/FFCompute/ComputeBA.cpp delete mode 100644 Resample/FFCompute/ComputeBA.h delete mode 100644 Resample/FFCompute/ComputeBAPol.cpp delete mode 100644 Resample/FFCompute/ComputeBAPol.h diff --git a/Resample/FFCompute/ComputeBA.cpp b/Resample/FFCompute/ComputeBA.cpp deleted file mode 100644 index 24578afc807..00000000000 --- a/Resample/FFCompute/ComputeBA.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Resample/FFCompute/ComputeBA.cpp -//! @brief Implements class ComputeBA. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Resample/FFCompute/ComputeBA.h" -#include "Base/Vector/WavevectorInfo.h" -#include "Resample/Element/DiffuseElement.h" -#include "Sample/Scattering/IFormFactor.h" - -ComputeBA::ComputeBA(const IFormFactor& ff, size_t i_layer) : IComputeScalar(ff, i_layer) {} - -ComputeBA::~ComputeBA() = default; - -complex_t ComputeBA::coherentFF(const DiffuseElement& ele) const -{ - const WavevectorInfo& wavevectors = ele.wavevectorInfo(); - return m_ff->theFF(wavevectors); -} diff --git a/Resample/FFCompute/ComputeBA.h b/Resample/FFCompute/ComputeBA.h deleted file mode 100644 index fe6329346d7..00000000000 --- a/Resample/FFCompute/ComputeBA.h +++ /dev/null @@ -1,37 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Resample/FFCompute/ComputeBA.h -//! @brief Defines class ComputeBA. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif - -#ifndef USER_API -#ifndef BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBA_H -#define BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBA_H - -#include "Resample/FFCompute/IComputeFF.h" - -//! Provides scalar form factor evaluation in Born Approximation for given IFormFactor. - -class ComputeBA : public IComputeScalar { -public: - ComputeBA(const IFormFactor& ff, size_t i_layer); - ~ComputeBA() override; - - //! Calculates and returns a form factor calculation in BA - complex_t coherentFF(const DiffuseElement& ele) const override; -}; - -#endif // BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBA_H -#endif // USER_API diff --git a/Resample/FFCompute/ComputeBAPol.cpp b/Resample/FFCompute/ComputeBAPol.cpp deleted file mode 100644 index da67f82e18e..00000000000 --- a/Resample/FFCompute/ComputeBAPol.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Resample/FFCompute/ComputeBAPol.cpp -//! @brief Defines class ComputeBAPol. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "Resample/FFCompute/ComputeBAPol.h" -#include "Base/Vector/WavevectorInfo.h" -#include "Resample/Element/DiffuseElement.h" -#include "Sample/Scattering/IFormFactor.h" - -ComputeBAPol::ComputeBAPol(const IFormFactor& ff, size_t i_layer) : IComputePol(ff, i_layer) {} - -ComputeBAPol::~ComputeBAPol() = default; - -Eigen::Matrix2cd ComputeBAPol::coherentPolFF(const DiffuseElement& ele) const -{ - Eigen::Matrix2cd ff_BA = m_ff->thePolFF(ele.wavevectorInfo()); - Eigen::Matrix2cd result; - result(0, 0) = -ff_BA(1, 0); - result(0, 1) = ff_BA(0, 0); - result(1, 0) = -ff_BA(1, 1); - result(1, 1) = ff_BA(0, 1); - return result; -} diff --git a/Resample/FFCompute/ComputeBAPol.h b/Resample/FFCompute/ComputeBAPol.h deleted file mode 100644 index f98d8222d66..00000000000 --- a/Resample/FFCompute/ComputeBAPol.h +++ /dev/null @@ -1,37 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file Resample/FFCompute/ComputeBAPol.h -//! @brief Defines class ComputeBAPol. -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifdef SWIG -#error no need to expose this header to Swig -#endif - -#ifndef USER_API -#ifndef BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBAPOL_H -#define BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBAPOL_H - -#include "Resample/FFCompute/IComputeFF.h" - -//! Provides polarized form factor evaluation in Born Approximation for given IFormFactor. - -class ComputeBAPol : public IComputePol { -public: - ComputeBAPol(const IFormFactor& ff, size_t i_layer); - ~ComputeBAPol() override; - - //! Calculates and returns a polarized form factor calculation in BA - Eigen::Matrix2cd coherentPolFF(const DiffuseElement& ele) const override; -}; - -#endif // BORNAGAIN_RESAMPLE_FFCOMPUTE_COMPUTEBAPOL_H -#endif // USER_API diff --git a/Resample/FFCompute/ComputeDWBA.cpp b/Resample/FFCompute/ComputeDWBA.cpp index 5489707f865..23f5e3dea3c 100644 --- a/Resample/FFCompute/ComputeDWBA.cpp +++ b/Resample/FFCompute/ComputeDWBA.cpp @@ -19,12 +19,18 @@ #include "Sample/Scattering/IFormFactor.h" ComputeDWBA::ComputeDWBA(const IFormFactor& ff, size_t i_layer) : IComputeScalar(ff, i_layer) {} +ComputeDWBA::ComputeDWBA(const IFormFactor& ff) : IComputeScalar(ff) {} ComputeDWBA::~ComputeDWBA() = default; complex_t ComputeDWBA::coherentFF(const DiffuseElement& ele) const { const WavevectorInfo& wavevectors = ele.wavevectorInfo(); + + if (!m_i_layer.has_value()) + // no slicing, pure Born approximation + return m_ff->theFF(wavevectors); + const IFlux* inFlux = ele.fluxIn(iLayer()); const IFlux* outFlux = ele.fluxOut(iLayer()); diff --git a/Resample/FFCompute/ComputeDWBA.h b/Resample/FFCompute/ComputeDWBA.h index d56adb62712..4111a749316 100644 --- a/Resample/FFCompute/ComputeDWBA.h +++ b/Resample/FFCompute/ComputeDWBA.h @@ -29,6 +29,7 @@ class IFlux; class ComputeDWBA : public IComputeScalar { public: ComputeDWBA(const IFormFactor& ff, size_t i_layer); + ComputeDWBA(const IFormFactor& ff); ~ComputeDWBA() override; //! Returns the coherent sum of the four DWBA terms for scalar scattering. diff --git a/Resample/FFCompute/ComputeDWBAPol.cpp b/Resample/FFCompute/ComputeDWBAPol.cpp index 912feb32fea..b4f07d1ed3a 100644 --- a/Resample/FFCompute/ComputeDWBAPol.cpp +++ b/Resample/FFCompute/ComputeDWBAPol.cpp @@ -30,12 +30,25 @@ complex_t VecMatVecProduct(const Eigen::Vector2cd& vec1, const Eigen::Matrix2cd& ComputeDWBAPol::ComputeDWBAPol(const IFormFactor& ff, size_t i_layer) : IComputePol(ff, i_layer) {} +ComputeDWBAPol::ComputeDWBAPol(const IFormFactor& ff) : IComputePol(ff) {} ComputeDWBAPol::~ComputeDWBAPol() = default; Eigen::Matrix2cd ComputeDWBAPol::coherentPolFF(const DiffuseElement& ele) const { const WavevectorInfo& wavevectors = ele.wavevectorInfo(); + + if (!m_i_layer.has_value()) { + // no slicing, pure Born approximation + Eigen::Matrix2cd ff_BA = m_ff->thePolFF(wavevectors); + Eigen::Matrix2cd result; + result(0, 0) = -ff_BA(1, 0); + result(0, 1) = ff_BA(0, 0); + result(1, 0) = -ff_BA(1, 1); + result(1, 1) = ff_BA(0, 1); + return result; + } + const IFlux* inFlux = ele.fluxIn(iLayer()); const IFlux* outFlux = ele.fluxOut(iLayer()); diff --git a/Resample/FFCompute/ComputeDWBAPol.h b/Resample/FFCompute/ComputeDWBAPol.h index 94ee8553539..bd7c9ae6c77 100644 --- a/Resample/FFCompute/ComputeDWBAPol.h +++ b/Resample/FFCompute/ComputeDWBAPol.h @@ -27,6 +27,7 @@ class ComputeDWBAPol : public IComputePol { public: ComputeDWBAPol(const IFormFactor& ff, size_t i_layer); + ComputeDWBAPol(const IFormFactor& ff); ~ComputeDWBAPol() override; //! Returns the coherent sum of the four DWBA terms for polarized scattering. diff --git a/Resample/FFCompute/IComputeFF.cpp b/Resample/FFCompute/IComputeFF.cpp index f05bc35fa43..d9e249bd290 100644 --- a/Resample/FFCompute/IComputeFF.cpp +++ b/Resample/FFCompute/IComputeFF.cpp @@ -20,6 +20,10 @@ IComputeFF::IComputeFF(const IFormFactor& ff, size_t i_layer) : m_ff(ff.clone()) { } +IComputeFF::IComputeFF(const IFormFactor& ff) : m_ff(ff.clone()), m_i_layer() +{ +} + IComputeFF::~IComputeFF() = default; size_t IComputeFF::iLayer() const { diff --git a/Resample/FFCompute/IComputeFF.h b/Resample/FFCompute/IComputeFF.h index bfa84e47891..189e30687ff 100644 --- a/Resample/FFCompute/IComputeFF.h +++ b/Resample/FFCompute/IComputeFF.h @@ -46,6 +46,7 @@ public: protected: IComputeFF(const IFormFactor& ff, size_t i_layer); + IComputeFF(const IFormFactor& ff); const std::unique_ptr<const IFormFactor> m_ff; const std::optional<size_t> m_i_layer; @@ -61,6 +62,7 @@ public: protected: IComputeScalar(const IFormFactor& ff, size_t i_layer) : IComputeFF(ff, i_layer) {} + IComputeScalar(const IFormFactor& ff) : IComputeFF(ff) {} }; @@ -74,6 +76,7 @@ public: protected: IComputePol(const IFormFactor& ff, size_t i_layer) : IComputeFF(ff, i_layer) {} + IComputePol(const IFormFactor& ff) : IComputeFF(ff) {} }; #endif // BORNAGAIN_RESAMPLE_FFCOMPUTE_ICOMPUTEFF_H diff --git a/Resample/Processed/ProcessedLayout.cpp b/Resample/Processed/ProcessedLayout.cpp index 6c1b1557e27..4b233a3e221 100644 --- a/Resample/Processed/ProcessedLayout.cpp +++ b/Resample/Processed/ProcessedLayout.cpp @@ -15,8 +15,6 @@ #include "Resample/Processed/ProcessedLayout.h" #include "Base/Utils/Assert.h" #include "Resample/Coherence/FFSum.h" -#include "Resample/FFCompute/ComputeBA.h" -#include "Resample/FFCompute/ComputeBAPol.h" #include "Resample/FFCompute/ComputeDWBA.h" #include "Resample/FFCompute/ComputeDWBAPol.h" #include "Resample/Slice/Slice.h" @@ -196,17 +194,16 @@ ProcessedLayout::processParticle(const IParticle& particle, const SliceStack& sl ff->setAmbientMaterial(material); std::unique_ptr<IComputeFF> computer; - if (slices.size() > 1) { - if (m_polarized) + if (m_polarized) { + if (slices.size() > 1) computer = std::make_unique<ComputeDWBAPol>(*ff, i_layer); else - computer = std::make_unique<ComputeDWBA>(*ff, i_layer); + computer = std::make_unique<ComputeDWBAPol>(*ff, i_layer); } else { - // no need for DWBA, use BA - if (m_polarized) - computer = std::make_unique<ComputeBAPol>(*ff, i_layer); + if (slices.size() > 1) + computer = std::make_unique<ComputeDWBA>(*ff, i_layer); else - computer = std::make_unique<ComputeBA>(*ff, i_layer); + computer = std::make_unique<ComputeDWBA>(*ff); } terms.emplace_back(computer.release()); } diff --git a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp index f23e580023a..cc57dc611a9 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp +++ b/Tests/UnitTests/Core/Sample/FormFactorCoherentSumTest.cpp @@ -1,5 +1,5 @@ #include "Resample/Coherence/FFSum.h" -#include "Resample/FFCompute/ComputeBA.h" +#include "Resample/FFCompute/ComputeDWBA.h" #include "Sample/HardParticle/FormFactorFullSphere.h" #include "Tests/GTestWrapper/google_test.h" @@ -9,7 +9,7 @@ class CoherentFFSumTest : public ::testing::Test { TEST_F(CoherentFFSumTest, RelAbundance) { FormFactorFullSphere ff(5.0); - std::shared_ptr<const IComputeFF> part(new ComputeBA(ff, 0)); + std::shared_ptr<const IComputeFF> part(new ComputeDWBA(ff)); CoherentFFSum ffw(1.0, {part}); EXPECT_EQ(1.0, ffw.relativeAbundance()); EXPECT_EQ(5.0, ffw.radialExtension()); diff --git a/auto/Wrap/doxygenResample.i b/auto/Wrap/doxygenResample.i index bd2516c1a36..6619163ef6f 100644 --- a/auto/Wrap/doxygenResample.i +++ b/auto/Wrap/doxygenResample.i @@ -25,46 +25,6 @@ C++ includes: FFSum.h "; -// File: classComputeBA.xml -%feature("docstring") ComputeBA " - -Provides scalar form factor evaluation in Born Approximation for given IFormFactor. - -C++ includes: ComputeBA.h -"; - -%feature("docstring") ComputeBA::ComputeBA "ComputeBA::ComputeBA(const IFormFactor &ff, size_t i_layer) -"; - -%feature("docstring") ComputeBA::~ComputeBA "ComputeBA::~ComputeBA() override -"; - -%feature("docstring") ComputeBA::coherentFF "complex_t ComputeBA::coherentFF(const DiffuseElement &ele) const override - -Calculates and returns a form factor calculation in BA. -"; - - -// File: classComputeBAPol.xml -%feature("docstring") ComputeBAPol " - -Provides polarized form factor evaluation in Born Approximation for given IFormFactor. - -C++ includes: ComputeBAPol.h -"; - -%feature("docstring") ComputeBAPol::ComputeBAPol "ComputeBAPol::ComputeBAPol(const IFormFactor &ff, size_t i_layer) -"; - -%feature("docstring") ComputeBAPol::~ComputeBAPol "ComputeBAPol::~ComputeBAPol() override -"; - -%feature("docstring") ComputeBAPol::coherentPolFF "Eigen::Matrix2cd ComputeBAPol::coherentPolFF(const DiffuseElement &ele) const override - -Calculates and returns a polarized form factor calculation in BA. -"; - - // File: classComputeDWBA.xml %feature("docstring") ComputeDWBA " @@ -76,6 +36,9 @@ C++ includes: ComputeDWBA.h %feature("docstring") ComputeDWBA::ComputeDWBA "ComputeDWBA::ComputeDWBA(const IFormFactor &ff, size_t i_layer) "; +%feature("docstring") ComputeDWBA::ComputeDWBA "ComputeDWBA::ComputeDWBA(const IFormFactor &ff) +"; + %feature("docstring") ComputeDWBA::~ComputeDWBA "ComputeDWBA::~ComputeDWBA() override "; @@ -96,6 +59,9 @@ C++ includes: ComputeDWBAPol.h %feature("docstring") ComputeDWBAPol::ComputeDWBAPol "ComputeDWBAPol::ComputeDWBAPol(const IFormFactor &ff, size_t i_layer) "; +%feature("docstring") ComputeDWBAPol::ComputeDWBAPol "ComputeDWBAPol::ComputeDWBAPol(const IFormFactor &ff) +"; + %feature("docstring") ComputeDWBAPol::~ComputeDWBAPol "ComputeDWBAPol::~ComputeDWBAPol() override "; @@ -239,7 +205,7 @@ C++ includes: IComputeFF.h // File: classIComputePol.xml %feature("docstring") IComputePol " -Provides polarized form factor evaluation for given IFormFactor. Inherited by ComputeBAPol and ComputeDWBAPol. +Provides polarized form factor evaluation for given IFormFactor. Inherited by ComputeBAPol and ComputeDWBAPol. C++ includes: IComputeFF.h "; @@ -253,7 +219,7 @@ Returns scattering amplitude for matrix interactions. // File: classIComputeScalar.xml %feature("docstring") IComputeScalar " -Provides scalar form factor evaluation for given IFormFactor. Inherited by ComputeBA and ComputeDWBA. +Provides scalar form factor evaluation for given IFormFactor. Inherited by ComputeBA and ComputeDWBA. C++ includes: IComputeFF.h "; @@ -896,15 +862,18 @@ C++ includes: SSCAStrategy.h "; -// File: namespace_0d10.xml +// File: namespace_0d11.xml -// File: namespace_0d15.xml +// File: namespace_0d19.xml // File: namespace_0d23.xml +// File: namespace_0d25.xml + + // File: namespace_0d27.xml @@ -914,16 +883,13 @@ C++ includes: SSCAStrategy.h // File: namespace_0d31.xml -// File: namespace_0d33.xml +// File: namespace_0d38.xml -// File: namespace_0d35.xml +// File: namespace_0d40.xml -// File: namespace_0d42.xml - - -// File: namespace_0d44.xml +// File: namespace_0d6.xml // File: namespaceSampleUtils.xml @@ -985,18 +951,6 @@ Get default z limits for generating a material profile. // File: DiffuseElement_8h.xml -// File: ComputeBA_8cpp.xml - - -// File: ComputeBA_8h.xml - - -// File: ComputeBAPol_8cpp.xml - - -// File: ComputeBAPol_8h.xml - - // File: ComputeDWBA_8cpp.xml -- GitLab