BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
TruncatedCube.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/TruncatedCube.cpp
6 //! @brief Implements class TruncatedCube.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 
17 const ff::PolyhedralTopology TruncatedCube::topology = {{{{0, 1, 7, 6, 9, 10, 4, 3}, true},
18  {{0, 2, 1}, false},
19  {{3, 4, 5}, false},
20  {{9, 11, 10}, false},
21  {{6, 7, 8}, false},
22  {{0, 3, 5, 17, 15, 12, 14, 2}, true},
23  {{4, 10, 11, 23, 22, 16, 17, 5}, true},
24  {{1, 2, 14, 13, 19, 20, 8, 7}, true},
25  {{6, 8, 20, 18, 21, 23, 11, 9}, true},
26  {{15, 17, 16}, false},
27  {{12, 13, 14}, false},
28  {{18, 20, 19}, false},
29  {{21, 22, 23}, false},
30  {{12, 15, 16, 22, 21, 18, 19, 13}, true}},
31  true};
32 
33 TruncatedCube::TruncatedCube(const std::vector<double> P)
35  , m_length(m_P[0])
36  , m_removed_length(m_P[1])
37 {
38  checkNodeArgs();
39  if (m_removed_length > 0.5 * m_length) {
40  std::ostringstream ostr;
41  ostr << "::TruncatedCube() -> Error in class initialization ";
42  ostr << "with parameters 'length':" << m_length;
43  ostr << " 'removed_length':" << m_removed_length << "\n\n";
44  ostr << "Check for removed_length <= 0.5*length failed.";
45  throw std::runtime_error(ostr.str());
46  }
47 
48  double a = m_length / 2;
49  double c = a - m_removed_length;
50 
52  {{-c, -a, -a}, {-a, -c, -a}, {-a, -a, -c}, {c, -a, -a}, {a, -c, -a}, {a, -a, -c},
53  {-c, a, -a}, {-a, c, -a}, {-a, a, -c}, {c, a, -a}, {a, c, -a}, {a, a, -c},
54  {-c, -a, a}, {-a, -c, a}, {-a, -a, c}, {c, -a, a}, {a, -c, a}, {a, -a, c},
55  {-c, a, a}, {-a, c, a}, {-a, a, c}, {c, a, a}, {a, c, a}, {a, a, c}});
56 }
57 
58 TruncatedCube::TruncatedCube(double length, double removed_length)
59  : TruncatedCube(std::vector<double>{length, removed_length})
60 {
61 }
Defines class TruncatedCube.
A polyhedron, for form factor computation.
void setPolyhedron(const ff::PolyhedralTopology &topology, double z_bottom, const std::vector< R3 > &vertices)
Called by child classes to set faces and other internal variables.
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
A cube, with tetrahedral truncation of all corners.
Definition: TruncatedCube.h:23
const double & m_removed_length
Definition: TruncatedCube.h:44
static const ff::PolyhedralTopology topology
Definition: TruncatedCube.h:42
double length() const
Definition: TruncatedCube.h:38
TruncatedCube(double length, double removed_length)
const double & m_length
Definition: TruncatedCube.h:43