Skip to content
Snippets Groups Projects
Commit bc6f2cb7 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[jw1] Adapt to libformfactor!32 ()

Merging branch 'jw1'  into 'main'.

See merge request !1153
parents 48291f91 db051c6f
No related branches found
No related tags found
1 merge request!1153Adapt to libformfactor!32
Pipeline #81535 passed
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "Sample/HardParticle/Dodecahedron.h" #include "Sample/HardParticle/Dodecahedron.h"
#include <ff/Platonic.h> #include <ff/Make.h>
Dodecahedron::Dodecahedron(const std::vector<double> P) Dodecahedron::Dodecahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P) : IFormFactorPolyhedron(P)
...@@ -32,8 +32,8 @@ std::string Dodecahedron::validate() const ...@@ -32,8 +32,8 @@ std::string Dodecahedron::validate() const
if (m_edge <= 0) if (m_edge <= 0)
return jointError({"nonpositive edge=" + std::to_string(m_edge)}); return jointError({"nonpositive edge=" + std::to_string(m_edge)});
setPolyhedron(ff::platonic::Dodecahedron::topology(), -1.113516364411607 * m_edge, pimpl.reset(ff::make::Dodecahedron(m_edge));
ff::platonic::Dodecahedron::vertices(m_edge)); shift(1.113516364411607 * m_edge);
assert_platonic(); assert_platonic();
m_validated = true; m_validated = true;
......
...@@ -19,17 +19,8 @@ ...@@ -19,17 +19,8 @@
#include "Sample/HardParticle/IFormFactorPolyhedron.h" #include "Sample/HardParticle/IFormFactorPolyhedron.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Sample/Particle/PolyhedralUtil.h" #include "Sample/Particle/PolyhedralUtil.h"
#include <ff/Face.h>
#include <ff/Polyhedron.h> #include <ff/Polyhedron.h>
// #ifdef ALGORITHM_DIAGNOSTIC // TODO restore
// void IFormFactorPolyhedron::setLimits(double _q, int _n)
// {
// q_limit_series = _q;
// n_limit_series = _n;
// }
// #endif
IFormFactorPolyhedron::IFormFactorPolyhedron(const std::vector<double>& PValues) IFormFactorPolyhedron::IFormFactorPolyhedron(const std::vector<double>& PValues)
: IFormFactor(PValues) : IFormFactor(PValues)
{ {
...@@ -51,6 +42,14 @@ void IFormFactorPolyhedron::setPolyhedron(const ff::Topology& topology, double z ...@@ -51,6 +42,14 @@ void IFormFactorPolyhedron::setPolyhedron(const ff::Topology& topology, double z
pimpl = std::make_unique<ff::Polyhedron>(topology, vertices); pimpl = std::make_unique<ff::Polyhedron>(topology, vertices);
} }
void IFormFactorPolyhedron::shift(double z_center) const
{
m_z_bottom = -z_center;
m_vertices.clear();
for (const R3& vertex : pimpl->vertices())
m_vertices.push_back(vertex + R3{0, 0, z_center});
}
double IFormFactorPolyhedron::bottomZ(const IRotation* rotation) const double IFormFactorPolyhedron::bottomZ(const IRotation* rotation) const
{ {
ASSERT(m_validated); ASSERT(m_validated);
......
...@@ -17,22 +17,19 @@ ...@@ -17,22 +17,19 @@
#define BORNAGAIN_SAMPLE_HARDPARTICLE_IFORMFACTORPOLYHEDRON_H #define BORNAGAIN_SAMPLE_HARDPARTICLE_IFORMFACTORPOLYHEDRON_H
#include "Sample/Particle/IFormFactor.h" #include "Sample/Particle/IFormFactor.h"
#include <ff/Topology.h> #include <ff/Topology.h> // needed by all child classes
#include <memory> #include <memory>
namespace ff { namespace ff {
class Polyhedron; class Polyhedron;
} }
//! A polyhedron, for form factor computation. //! A polyhedron, for form factor computation.
class IFormFactorPolyhedron : public IFormFactor { class IFormFactorPolyhedron : public IFormFactor {
public: public:
// #ifdef ALGORITHM_DIAGNOSTIC
// static void setLimits(double _q, int _n);
// #endif
IFormFactorPolyhedron(const std::vector<double>& PValues); IFormFactorPolyhedron(const std::vector<double>& PValues);
~IFormFactorPolyhedron() override; ~IFormFactorPolyhedron() override;
...@@ -48,8 +45,9 @@ public: ...@@ -48,8 +45,9 @@ public:
protected: protected:
void setPolyhedron(const ff::Topology& topology, double z_bottom, void setPolyhedron(const ff::Topology& topology, double z_bottom,
const std::vector<R3>& vertices) const; const std::vector<R3>& vertices) const;
void shift(double z_center) const;
private: // private:
mutable std::unique_ptr<ff::Polyhedron> pimpl; mutable std::unique_ptr<ff::Polyhedron> pimpl;
mutable std::vector<R3> m_vertices; //! for topZ, bottomZ computation only mutable std::vector<R3> m_vertices; //! for topZ, bottomZ computation only
mutable double m_z_bottom; mutable double m_z_bottom;
......
...@@ -51,13 +51,13 @@ double IFormFactorPrism::topZ(const IRotation* rotation) const ...@@ -51,13 +51,13 @@ double IFormFactorPrism::topZ(const IRotation* rotation) const
double IFormFactorPrism::volume() const double IFormFactorPrism::volume() const
{ {
ASSERT(m_validated); ASSERT(m_validated);
return height() * pimpl->area(); return pimpl->volume();
} }
double IFormFactorPrism::radialExtension() const double IFormFactorPrism::radialExtension() const
{ {
ASSERT(m_validated); ASSERT(m_validated);
return std::sqrt(pimpl->area()); return pimpl->radius();
} }
//! Returns the form factor F(q) of this polyhedron, respecting the offset height/2. //! Returns the form factor F(q) of this polyhedron, respecting the offset height/2.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// ************************************************************************************************ // ************************************************************************************************
#include "Sample/HardParticle/Icosahedron.h" #include "Sample/HardParticle/Icosahedron.h"
#include <ff/Platonic.h> #include <ff/Make.h>
Icosahedron::Icosahedron(const std::vector<double> P) Icosahedron::Icosahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P) : IFormFactorPolyhedron(P)
...@@ -32,8 +32,8 @@ std::string Icosahedron::validate() const ...@@ -32,8 +32,8 @@ std::string Icosahedron::validate() const
if (m_edge <= 0) if (m_edge <= 0)
return jointError({"nonpositive edge=" + std::to_string(m_edge)}); return jointError({"nonpositive edge=" + std::to_string(m_edge)});
setPolyhedron(ff::platonic::Icosahedron::topology(), -0.7557613140761708 * m_edge, pimpl.reset(ff::make::Icosahedron(m_edge));
ff::platonic::Icosahedron::vertices(m_edge)); shift(0.7557613140761708 * m_edge);
assert_platonic(); assert_platonic();
m_validated = true; m_validated = true;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "Sample/HardParticle/PlatonicOctahedron.h" #include "Sample/HardParticle/PlatonicOctahedron.h"
#include "Base/Math/Constants.h" #include "Base/Math/Constants.h"
#include "Base/Math/Functions.h" #include "Base/Math/Functions.h"
#include <ff/Platonic.h> #include <ff/Make.h>
PlatonicOctahedron::PlatonicOctahedron(const std::vector<double> P) PlatonicOctahedron::PlatonicOctahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P) : IFormFactorPolyhedron(P)
...@@ -35,8 +35,8 @@ std::string PlatonicOctahedron::validate() const ...@@ -35,8 +35,8 @@ std::string PlatonicOctahedron::validate() const
if (m_edge <= 0) if (m_edge <= 0)
return jointError({"nonpositive edge=" + std::to_string(m_edge)}); return jointError({"nonpositive edge=" + std::to_string(m_edge)});
setPolyhedron(ff::platonic::Octahedron::topology(), -m_edge / sqrt(2), pimpl.reset(ff::make::Octahedron(m_edge));
ff::platonic::Octahedron::vertices(m_edge)); shift(m_edge / sqrt(2));
assert_platonic(); assert_platonic();
m_validated = true; m_validated = true;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "Sample/HardParticle/PlatonicTetrahedron.h" #include "Sample/HardParticle/PlatonicTetrahedron.h"
#include "Base/Math/Constants.h" #include "Base/Math/Constants.h"
#include "Base/Math/Functions.h" #include "Base/Math/Functions.h"
#include <ff/Platonic.h> #include <ff/Make.h>
PlatonicTetrahedron::PlatonicTetrahedron(const std::vector<double> P) PlatonicTetrahedron::PlatonicTetrahedron(const std::vector<double> P)
: IFormFactorPolyhedron(P) : IFormFactorPolyhedron(P)
...@@ -34,8 +34,8 @@ std::string PlatonicTetrahedron::validate() const ...@@ -34,8 +34,8 @@ std::string PlatonicTetrahedron::validate() const
if (m_edge <= 0) if (m_edge <= 0)
return jointError({"nonpositive edge=" + std::to_string(m_edge)}); return jointError({"nonpositive edge=" + std::to_string(m_edge)});
setPolyhedron(ff::platonic::Tetrahedron::topology(), -height() / 4, pimpl.reset(ff::make::Tetrahedron(m_edge));
ff::platonic::Tetrahedron::vertices(m_edge)); shift(sqrt(2. / 3) / 4 * m_edge);
assert_platonic(); assert_platonic();
m_validated = true; m_validated = true;
......
...@@ -45,12 +45,11 @@ std::string Pyramid2::validate() const ...@@ -45,12 +45,11 @@ std::string Pyramid2::validate() const
requestGt0(errs, m_length, "length"); requestGt0(errs, m_length, "length");
requestGt0(errs, m_width, "width"); requestGt0(errs, m_width, "width");
requestGt0(errs, m_height, "height"); requestGt0(errs, m_height, "height");
const double cot_alpha = Math::cot(m_alpha); requestIn(errs, m_alpha, "alpha", 0, M_PI_2);
if (m_alpha <= 0 || !std::isfinite(cot_alpha) || cot_alpha < 0)
errs.push_back("pyramid angle alpha " + std::to_string(m_alpha) + " out of bounds");
if (!errs.empty()) if (!errs.empty())
return jointError(errs); return jointError(errs);
const double cot_alpha = Math::cot(m_alpha);
double r = cot_alpha * 2 * m_height / m_length; double r = cot_alpha * 2 * m_height / m_length;
double s = cot_alpha * 2 * m_height / m_width; double s = cot_alpha * 2 * m_height / m_width;
if (r > 1) if (r > 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment