BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleLayout.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Aggregate/ParticleLayout.h
6 //! @brief Defines class ParticleLayout.
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 
15 #ifndef BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
16 #define BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
17 
21 #include <memory>
22 
23 class IAbstractParticle;
25 class IParticle;
26 
27 //! Decorator class that adds particles to ISampleNode objects.
28 //! @ingroup samples
29 
30 class ParticleLayout : public ISampleNode {
31 public:
33  ParticleLayout(const IAbstractParticle& particle, double abundance = -1.0);
34  ~ParticleLayout() override;
35 
36  ParticleLayout* clone() const override;
37 
38  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
39 
40  void addParticle(const IAbstractParticle& particle, double abundance = -1.0,
41  const kvector_t position = {}, const IRotation& rotation = IdentityRotation());
42 
44 
46 
47  double getTotalAbundance() const;
48 
49  void setInterferenceFunction(const IInterferenceFunction& interference_function);
50 
51  double totalParticleSurfaceDensity() const;
52  void setTotalParticleSurfaceDensity(double particle_density);
53 
54  std::vector<const INode*> getChildren() const override;
55 
56  //! Returns the relative weight of this layout
57  double weight() const { return m_weight; }
58 
59  //! Sets the relative weight of this layout
60  void setWeight(double weight) { m_weight = weight; }
61 
62 private:
65 
66  void registerParticleDensity(bool make_registered = true);
67  void registerWeight();
68 
69  double m_weight;
71  SafePointerVector<IAbstractParticle> m_particles; //!< Vector of particle types
72  std::unique_ptr<IInterferenceFunction> m_interference_function;
73 };
74 
75 #endif // BORNAGAIN_SAMPLE_AGGREGATE_PARTICLELAYOUT_H
Defines interface class ISampleNode.
Defines IRotation classes.
Defines and implements template class SafePointerVector.
Interface for a generic particle.
Abstract base class of interference functions.
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151
Abstract base class for Particle, ParticleComposition, ParticleCoreShell, MesoCrystal.
Definition: IParticle.h:33
Abstract base class for rotations.
Definition: Rotations.h:28
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:28
The identity rotation, which leaves everything in place.
Definition: Rotations.h:57
Decorator class that adds particles to ISampleNode objects.
double weight() const
Returns the relative weight of this layout.
SafePointerVector< IAbstractParticle > m_particles
Vector of particle types.
std::unique_ptr< IInterferenceFunction > m_interference_function
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
void registerParticleDensity(bool make_registered=true)
void setTotalParticleSurfaceDensity(double particle_density)
Sets total particle surface density.
double getTotalAbundance() const
ParticleLayout * clone() const override
Returns a clone of this ISampleNode object.
~ParticleLayout() override
void setInterferenceFunction(const IInterferenceFunction &interference_function)
Adds interference functions.
const IInterferenceFunction * interferenceFunction() const
SafePointerVector< IParticle > particles() const
Returns information on all particles (type and abundance) and generates new particles if an IAbstract...
std::vector< const INode * > getChildren() const override
Returns a vector of children.
void setAndRegisterInterferenceFunction(IInterferenceFunction *child)
Sets interference function with simultaneous registration in parent class.
double m_total_particle_density
void addAndRegisterAbstractParticle(IAbstractParticle *child)
Adds particle information with simultaneous registration in parent class.
void setWeight(double weight)
Sets the relative weight of this layout.
void addParticle(const IAbstractParticle &particle, double abundance=-1.0, const kvector_t position={}, const IRotation &rotation=IdentityRotation())
Adds particle to the layout with abundance, position and the rotation defined.
double totalParticleSurfaceDensity() const
A vector of pointers, owned by *this, with methods to handle them safely.