BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Particle Class Reference
Inheritance diagram for Particle:
Collaboration diagram for Particle:

Public Member Functions

 Particle ()
 
 Particle (Material material)
 
 Particle (Material material, const IFormFactor &form_factor)
 
 Particle (Material material, const IFormFactor &form_factor, const IRotation &rotation)
 
Particleclone () const override final
 
void accept (INodeVisitor *visitor) const override final
 
SlicedParticle createSlicedParticle (ZLimits limits) const override final
 
void setMaterial (Material material)
 
const Materialmaterial () const override final
 
void setFormFactor (const IFormFactor &form_factor)
 
std::vector< const INode * > getChildren () const override final
 
virtual IFormFactorcreateFormFactor () const
 
kvector_t position () const
 
void setPosition (kvector_t position)
 
void setPosition (double x, double y, double z)
 
void translate (kvector_t translation) override final
 
const IRotationrotation () const
 
void setRotation (const IRotation &rotation)
 
void rotate (const IRotation &rotation) override final
 
void registerAbundance (bool make_registered=true)
 
void registerPosition (bool make_registered=true)
 
virtual SafePointerVector< IParticledecompose () const
 
virtual ParticleLimits bottomTopZ () const
 
double abundance () const
 
void setAbundance (double abundance)
 
std::vector< const Material * > containedMaterials () const
 
virtual void transferToCPP ()
 
virtual std::string treeToString () const
 
void registerChild (INode *node)
 
virtual void setParent (const INode *newParent)
 
const INodeparent () const
 
INodeparent ()
 
int copyNumber (const INode *node) const
 
std::string displayName () const
 
ParameterPoolcreateParameterTree () const
 
ParameterPoolparameterPool () const
 
std::string parametersToString () const
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void setParameterValue (const std::string &name, double value)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
RealParameterparameter (const std::string &name) const
 
virtual void onChange ()
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
const std::string & getName () const
 

Static Public Member Functions

static std::string XComponentName (const std::string &base_name)
 
static std::string YComponentName (const std::string &base_name)
 
static std::string ZComponentName (const std::string &base_name)
 

Protected Member Functions

IRotationcreateComposedRotation (const IRotation *p_rotation) const
 
kvector_t composedTranslation (const IRotation *p_rotation, kvector_t translation) const
 
void registerParticleProperties ()
 

Protected Attributes

Material m_material
 
std::unique_ptr< IFormFactormP_form_factor
 
kvector_t m_position
 
std::unique_ptr< IRotationmP_rotation
 
double m_abundance {1.0}
 
const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void initialize ()
 

Private Attributes

const INodem_parent {nullptr}
 
std::string m_name
 
std::unique_ptr< ParameterPoolm_pool
 

Detailed Description

A particle with a form factor and refractive index.

Definition at line 25 of file Particle.h.

Constructor & Destructor Documentation

◆ Particle() [1/4]

Particle::Particle ( )

Definition at line 20 of file Particle.cpp.

21 {
22  initialize();
23 }
void initialize()
Definition: Particle.cpp:97
Material m_material
Definition: Particle.h:47
Material HomogeneousMaterial(const std::string &name, complex_t refractive_index, kvector_t magnetization)
Constructs a material with name, refractive_index and magnetization (in A/m).

References initialize().

Referenced by clone().

Here is the call graph for this function:

◆ Particle() [2/4]

Particle::Particle ( Material  material)

Definition at line 25 of file Particle.cpp.

25  : m_material(std::move(material))
26 {
27  initialize();
28 }
const Material * material() const override final
Returns nullptr, unless overwritten to return a specific material.
Definition: Particle.h:40

References initialize().

Here is the call graph for this function:

◆ Particle() [3/4]

Particle::Particle ( Material  material,
const IFormFactor form_factor 
)

Definition at line 30 of file Particle.cpp.

31  : m_material(std::move(material)), mP_form_factor(form_factor.clone())
32 {
33  initialize();
35 }
IFormFactor * clone() const override=0
Returns a clone of this ISample object.
void registerChild(INode *node)
Definition: INode.cpp:58
std::unique_ptr< IFormFactor > mP_form_factor
Definition: Particle.h:48

References initialize(), mP_form_factor, and INode::registerChild().

Here is the call graph for this function:

◆ Particle() [4/4]

Particle::Particle ( Material  material,
const IFormFactor form_factor,
const IRotation rotation 
)

Definition at line 37 of file Particle.cpp.

38  : m_material(std::move(material)), mP_form_factor(form_factor.clone())
39 {
40  initialize();
43 }
const IRotation * rotation() const
Returns rotation object.
Definition: IParticle.cpp:39
void setRotation(const IRotation &rotation)
Sets transformation.
Definition: IParticle.cpp:44

References initialize(), mP_form_factor, INode::registerChild(), IParticle::rotation(), and IParticle::setRotation().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

Particle * Particle::clone ( ) const
finaloverridevirtual

Returns a clone of this ISample object.

Implements IParticle.

Definition at line 45 of file Particle.cpp.

46 {
47  Particle* p_result = new Particle(m_material);
48  p_result->setAbundance(m_abundance);
49  if (mP_form_factor)
50  p_result->setFormFactor(*mP_form_factor);
51  if (mP_rotation)
52  p_result->setRotation(*mP_rotation);
53  p_result->setPosition(m_position);
54 
55  return p_result;
56 }
void setAbundance(double abundance)
Sets particle abundance.
void setPosition(kvector_t position)
Sets relative position of the particle's reference point in the coordinate system of parent.
Definition: IParticle.h:50
std::unique_ptr< IRotation > mP_rotation
Definition: IParticle.h:95
kvector_t m_position
Definition: IParticle.h:94
A particle with a form factor and refractive index.
Definition: Particle.h:26
Particle()
Definition: Particle.cpp:20
void setFormFactor(const IFormFactor &form_factor)
Definition: Particle.cpp:84

References IAbstractParticle::m_abundance, m_material, IParticle::m_position, mP_form_factor, IParticle::mP_rotation, Particle(), IAbstractParticle::setAbundance(), setFormFactor(), IParticle::setPosition(), and IParticle::setRotation().

Referenced by ParticleCoreShell::addAndRegisterCore(), and ParticleCoreShell::addAndRegisterShell().

Here is the call graph for this function:

◆ accept()

void Particle::accept ( INodeVisitor visitor) const
inlinefinaloverridevirtual

Calls the INodeVisitor's visit method.

Reimplemented from IAbstractParticle.

Definition at line 35 of file Particle.h.

35 { visitor->visit(this); }
virtual void visit(const BasicLattice *)
Definition: INodeVisitor.h:154

◆ createSlicedParticle()

SlicedParticle Particle::createSlicedParticle ( ZLimits  limits) const
finaloverridevirtual

Creates a sliced form factor for this particle.

Reimplemented from IParticle.

Definition at line 58 of file Particle.cpp.

59 {
60  if (!mP_form_factor)
61  return {};
62  std::unique_ptr<IRotation> P_rotation(IRotation::createIdentity());
63  if (mP_rotation)
64  P_rotation.reset(mP_rotation->clone());
65  std::unique_ptr<IFormFactor> P_temp_ff(
66  mP_form_factor->createSlicedFormFactor(limits, *P_rotation, m_position));
67  if (!P_temp_ff)
68  return {};
69  std::unique_ptr<FormFactorDecoratorMaterial> P_ff(new FormFactorDecoratorMaterial(*P_temp_ff));
70  double volume = P_temp_ff->volume();
71  Material transformed_material(m_material.rotatedMaterial(P_rotation->getTransform3D()));
72  P_ff->setMaterial(transformed_material);
73  SlicedParticle result;
74  result.m_regions.push_back({volume, transformed_material});
75  result.mP_slicedff = std::move(P_ff);
76  return result;
77 }
Decorates a scalar formfactor with the correct factor for the material's refractive index and that of...
static IRotation * createIdentity()
Definition: Rotations.cpp:53
A wrapper for underlying material implementation.
Definition: Material.h:29
Material rotatedMaterial(const Transform3D &transform) const
Definition: Material.cpp:104
Struct that contains information on a sliced particle.
std::vector< HomogeneousRegion > m_regions
std::unique_ptr< IFormFactor > mP_slicedff

References IRotation::createIdentity(), m_material, IParticle::m_position, SlicedParticle::m_regions, mP_form_factor, IParticle::mP_rotation, SlicedParticle::mP_slicedff, and Material::rotatedMaterial().

Here is the call graph for this function:

◆ setMaterial()

void Particle::setMaterial ( Material  material)

Definition at line 79 of file Particle.cpp.

80 {
81  m_material = std::move(material);
82 }

References m_material, and material().

Here is the call graph for this function:

◆ material()

const Material* Particle::material ( ) const
inlinefinaloverridevirtual

Returns nullptr, unless overwritten to return a specific material.

Reimplemented from ISample.

Definition at line 40 of file Particle.h.

40 { return &m_material; }

References m_material.

Referenced by SampleToPython::defineParticles(), and setMaterial().

◆ setFormFactor()

void Particle::setFormFactor ( const IFormFactor form_factor)

Definition at line 84 of file Particle.cpp.

85 {
86  if (&form_factor != mP_form_factor.get()) {
87  mP_form_factor.reset(form_factor.clone());
89  }
90 }

References IFormFactor::clone(), mP_form_factor, and INode::registerChild().

Referenced by clone().

Here is the call graph for this function:

◆ getChildren()

std::vector< const INode * > Particle::getChildren ( ) const
finaloverridevirtual

Returns a vector of children (const).

Reimplemented from IParticle.

Definition at line 92 of file Particle.cpp.

93 {
94  return std::vector<const INode*>() << IParticle::getChildren() << mP_form_factor;
95 }
std::vector< const INode * > getChildren() const override
Returns a vector of children (const).
Definition: IParticle.cpp:61

References IParticle::getChildren(), and mP_form_factor.

Here is the call graph for this function:

◆ initialize()

void Particle::initialize ( )
private

Definition at line 97 of file Particle.cpp.

98 {
99  setName("Particle");
101 }
void setName(const std::string &name)
void registerParticleProperties()
Registers abundance and position.
Definition: IParticle.cpp:125

References IParticle::registerParticleProperties(), and IParameterized::setName().

Referenced by Particle().

Here is the call graph for this function:

◆ createFormFactor()

IFormFactor * IParticle::createFormFactor ( ) const
virtualinherited

Creates a form factor for this particle.

Reimplemented in ParticleComposition.

Definition at line 23 of file IParticle.cpp.

24 {
25  return createSlicedParticle(ZLimits{}).mP_slicedff.release();
26 }
virtual SlicedParticle createSlicedParticle(ZLimits limits) const
Creates a sliced form factor for this particle.
Definition: IParticle.cpp:28
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:41

References IParticle::createSlicedParticle().

Referenced by IParticle::bottomTopZ().

Here is the call graph for this function:

◆ position()

kvector_t IParticle::position ( ) const
inlineinherited

◆ setPosition() [1/2]

void IParticle::setPosition ( kvector_t  position)
inlineinherited

Sets relative position of the particle's reference point in the coordinate system of parent.

Parameters
positionrelative position vector (components are in nanometers)

Definition at line 50 of file IParticle.h.

50 { m_position = position; }
kvector_t position() const
Returns particle position.
Definition: IParticle.h:45

References IParticle::m_position, and IParticle::position().

Referenced by BoxCompositionRotateXBuilder::buildSample(), BoxCompositionRotateYBuilder::buildSample(), BoxCompositionRotateZBuilder::buildSample(), BoxCompositionRotateZandYBuilder::buildSample(), BoxStackCompositionBuilder::buildSample(), CoreShellBoxRotateZandYBuilder::buildSample(), CustomMorphologyBuilder::buildSample(), LayersWithAbsorptionBuilder::buildSample(), LayersWithAbsorptionBySLDBuilder::buildSample(), SlicedCompositionBuilder::buildSample(), TransformBoxBuilder::buildSample(), MesoCrystal::clone(), clone(), ParticleComposition::clone(), and ParticleCoreShell::clone().

Here is the call graph for this function:

◆ setPosition() [2/2]

void IParticle::setPosition ( double  x,
double  y,
double  z 
)
inlineinherited

Sets relative position of the particle's reference point in the coordinate system of parent.

Parameters
xx-coordinate in nanometers
yy-coordinate in nanometers
zz-coordinate in nanometers

Definition at line 57 of file IParticle.h.

57 { m_position = kvector_t(x, y, z); }
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21

References IParticle::m_position.

◆ translate()

void IParticle::translate ( kvector_t  translation)
finaloverridevirtualinherited

Translates the particle.

Implements IAbstractParticle.

Definition at line 34 of file IParticle.cpp.

35 {
36  m_position += translation;
37 }

References IParticle::m_position.

Referenced by ParticleComposition::addParticle(), and SlicedFormFactorList::addParticle().

◆ rotation()

const IRotation * IParticle::rotation ( ) const
inherited

Returns rotation object.

Definition at line 39 of file IParticle.cpp.

40 {
41  return mP_rotation.get();
42 }

References IParticle::mP_rotation.

Referenced by ParticleComposition::decompose(), Particle(), IParticle::rotate(), IParticle::setRotation(), and SampleToPython::setRotationInformation().

◆ setRotation()

◆ rotate()

void IParticle::rotate ( const IRotation rotation)
finaloverridevirtualinherited

Rotates the particle.

Implements IAbstractParticle.

Definition at line 50 of file IParticle.cpp.

51 {
52  if (mP_rotation) {
54  } else {
55  mP_rotation.reset(rotation.clone());
56  }
59 }
IRotation * createProduct(const IRotation &left, const IRotation &right)
Returns concatenated rotation (first right, then left).
Definition: Rotations.cpp:75
kvector_t transformed(const kvector_t &v) const
Definition: Rotations.cpp:58

References IRotation::clone(), createProduct(), IParticle::m_position, IParticle::mP_rotation, INode::registerChild(), IParticle::rotation(), and IRotation::transformed().

Referenced by BoxCompositionRotateZandYBuilder::buildSample(), CoreShellBoxRotateZandYBuilder::buildSample(), LayersWithAbsorptionBuilder::buildSample(), LayersWithAbsorptionBySLDBuilder::buildSample(), and TransformBoxBuilder::buildSample().

Here is the call graph for this function:

◆ registerAbundance()

void IParticle::registerAbundance ( bool  make_registered = true)
inherited

Definition at line 66 of file IParticle.cpp.

67 {
68  if (make_registered) {
69  if (!parameter("Abundance"))
70  registerParameter("Abundance", &m_abundance);
71  } else {
72  removeParameter("Abundance");
73  }
74 }
RealParameter & registerParameter(const std::string &name, double *parpointer)
RealParameter * parameter(const std::string &name) const
Returns parameter with given 'name'.
void removeParameter(const std::string &name)

References IAbstractParticle::m_abundance, IParameterized::parameter(), IParameterized::registerParameter(), and IParameterized::removeParameter().

Referenced by ParticleComposition::addParticlePointer(), and IParticle::registerParticleProperties().

Here is the call graph for this function:

◆ registerPosition()

void IParticle::registerPosition ( bool  make_registered = true)
inherited

Registers the three components of its position.

Definition at line 76 of file IParticle.cpp.

77 {
78  if (make_registered) {
79  if (!parameter(XComponentName("Position"))) {
80  registerVector("Position", &m_position, "nm");
81  }
82  } else {
83  removeVector("Position");
84  }
85 }
static std::string XComponentName(const std::string &base_name)
void removeVector(const std::string &base_name)
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")

References IParticle::m_position, IParameterized::parameter(), IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::XComponentName().

Referenced by IParticle::registerParticleProperties().

Here is the call graph for this function:

◆ decompose()

SafePointerVector< IParticle > IParticle::decompose ( ) const
virtualinherited

Decompose in constituent IParticle objects.

Reimplemented in ParticleComposition.

Definition at line 87 of file IParticle.cpp.

88 {
90  result.push_back(this->clone());
91  return result;
92 }
IParticle * clone() const override=0
Returns a clone of this ISample object.
A vector of pointers, owned by *this, with methods to handle them safely.
void push_back(T *pointer)

References IParticle::clone(), and SafePointerVector< T >::push_back().

Referenced by SlicedFormFactorList::createSlicedFormFactors().

Here is the call graph for this function:

◆ bottomTopZ()

ParticleLimits IParticle::bottomTopZ ( ) const
virtualinherited

Top and bottom z-coordinate.

Reimplemented in ParticleComposition.

Definition at line 94 of file IParticle.cpp.

95 {
96  std::unique_ptr<IFormFactor> P_ff(createFormFactor());
97  std::unique_ptr<IRotation> P_rot(IRotation::createIdentity());
98  return {P_ff->bottomZ(*P_rot), P_ff->topZ(*P_rot)};
99 }
virtual IFormFactor * createFormFactor() const
Creates a form factor for this particle.
Definition: IParticle.cpp:23

References IParticle::createFormFactor(), and IRotation::createIdentity().

Referenced by anonymous_namespace{SlicedFormFactorList.cpp}::SliceIndexSpan().

Here is the call graph for this function:

◆ createComposedRotation()

IRotation * IParticle::createComposedRotation ( const IRotation p_rotation) const
protectedinherited

Creates a composed IRotation object.

Definition at line 101 of file IParticle.cpp.

102 {
103  if (p_rotation) {
104  if (mP_rotation)
105  return createProduct(*p_rotation, *mP_rotation);
106  else
107  return p_rotation->clone();
108  } else {
109  if (mP_rotation)
110  return mP_rotation->clone();
111  else
112  return nullptr;
113  }
114 }

References IRotation::clone(), createProduct(), and IParticle::mP_rotation.

Here is the call graph for this function:

◆ composedTranslation()

kvector_t IParticle::composedTranslation ( const IRotation p_rotation,
kvector_t  translation 
) const
protectedinherited

Gets a composed translation vector.

Definition at line 116 of file IParticle.cpp.

117 {
118  if (p_rotation) {
119  return translation + p_rotation->transformed(m_position);
120  } else {
121  return translation + m_position;
122  }
123 }

References IParticle::m_position, and IRotation::transformed().

Here is the call graph for this function:

◆ registerParticleProperties()

void IParticle::registerParticleProperties ( )
protectedinherited

Registers abundance and position.

Definition at line 125 of file IParticle.cpp.

126 {
129 }
void registerAbundance(bool make_registered=true)
Definition: IParticle.cpp:66
void registerPosition(bool make_registered=true)
Registers the three components of its position.
Definition: IParticle.cpp:76

References IParticle::registerAbundance(), and IParticle::registerPosition().

Referenced by MesoCrystal::initialize(), initialize(), ParticleComposition::initialize(), and ParticleCoreShell::ParticleCoreShell().

Here is the call graph for this function:

◆ abundance()

double IAbstractParticle::abundance ( ) const
inlineinherited

◆ setAbundance()

void IAbstractParticle::setAbundance ( double  abundance)
inlineinherited

Sets particle abundance.

Parameters
abundanceproportion of this type of particles normalized to the total number of particles in the layout.

Definition at line 44 of file IAbstractParticle.h.

double abundance() const

References IAbstractParticle::abundance(), and IAbstractParticle::m_abundance.

Referenced by ParticleLayout::addParticle(), MesoCrystal::clone(), clone(), ParticleComposition::clone(), ParticleCoreShell::clone(), ParticleDistribution::clone(), and ParticleDistribution::generateParticles().

Here is the call graph for this function:

◆ containedMaterials()

std::vector< const Material * > ISample::containedMaterials ( ) const
inherited

Returns set of unique materials contained in this ISample.

Definition at line 23 of file ISample.cpp.

24 {
25  std::vector<const Material*> result;
26  if (const Material* p_material = material())
27  result.push_back(p_material);
28  for (auto child : getChildren()) {
29  if (const ISample* sample = dynamic_cast<const ISample*>(child)) {
30  for (const Material* p_material : sample->containedMaterials())
31  result.push_back(p_material);
32  }
33  }
34  return result;
35 }
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: INode.cpp:64
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISample.h:37

References INode::getChildren(), and ISample::material().

Referenced by MultiLayerUtils::ContainsCompatibleMaterials(), anonymous_namespace{ProcessedSample.cpp}::ContainsMagneticMaterial(), and SampleToPython::initLabels().

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 34 of file ICloneable.h.

◆ treeToString()

std::string INode::treeToString ( ) const
virtualinherited

Returns multiline string representing tree structure below the node.

Definition at line 53 of file INode.cpp.

54 {
55  return NodeUtils::nodeToString(*this);
56 }
std::string nodeToString(const INode &node)
Returns multiline string representing tree structure starting from given node.
Definition: NodeUtils.cpp:67

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 58 of file INode.cpp.

59 {
60  ASSERT(node);
61  node->setParent(this);
62 }
#define ASSERT(condition)
Definition: Assert.h:26
virtual void setParent(const INode *newParent)
Definition: INode.cpp:69

References ASSERT, and INode::setParent().

Referenced by ParticleLayout::addAndRegisterAbstractParticle(), ParticleCoreShell::addAndRegisterCore(), MultiLayer::addAndRegisterInterface(), MultiLayer::addAndRegisterLayer(), ParticleCoreShell::addAndRegisterShell(), Layer::addLayout(), ParticleComposition::addParticlePointer(), Beam::Beam(), Crystal::Crystal(), IDetector::IDetector(), Simulation::initialize(), MesoCrystal::initialize(), Instrument::Instrument(), Beam::operator=(), Instrument::operator=(), Particle(), ParticleDistribution::ParticleDistribution(), IParticle::rotate(), ParticleLayout::setAndRegisterInterferenceFunction(), Simulation::setBackground(), InterferenceFunction1DLattice::setDecayFunction(), InterferenceFunction2DLattice::setDecayFunction(), Instrument::setDetector(), IDetector::setDetectorResolution(), Beam::setFootprintFactor(), setFormFactor(), InterferenceFunctionFinite3DLattice::setLattice(), InterferenceFunction2DLattice::setLattice(), InterferenceFunction2DParaCrystal::setLattice(), InterferenceFunction2DSuperLattice::setLattice(), InterferenceFunctionFinite2DLattice::setLattice(), InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(), InterferenceFunction2DParaCrystal::setProbabilityDistributions(), ConvolutionDetectorResolution::setResolutionFunction(), IParticle::setRotation(), LayerInterface::setRoughness(), and InterferenceFunction2DSuperLattice::setSubstructureIFF().

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 69 of file INode.cpp.

70 {
71  m_parent = newParent;
72 }
const INode * m_parent
Definition: INode.h:81

References INode::m_parent.

Referenced by INode::registerChild(), SampleProvider::setBuilder(), and SampleProvider::setParent().

◆ parent() [1/2]

const INode * INode::parent ( ) const
inherited

◆ parent() [2/2]

INode * INode::parent ( )
inherited

Definition at line 79 of file INode.cpp.

80 {
81  return const_cast<INode*>(m_parent);
82 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49

References INode::m_parent.

◆ copyNumber()

int INode::copyNumber ( const INode node) const
inherited

Returns copyNumber of child, which takes into account existence of children with same name.

Definition at line 84 of file INode.cpp.

85 {
86  if (node->parent() != this)
87  return -1;
88 
89  int result(-1), count(0);
90  for (auto child : getChildren()) {
91 
92  if (child == nullptr)
93  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
94 
95  if (child == node)
96  result = count;
97 
98  if (child->getName() == node->getName())
99  ++count;
100  }
101 
102  return count > 1 ? result : -1;
103 }
const INode * parent() const
Definition: INode.cpp:74
const std::string & getName() const

References INode::getChildren(), IParameterized::getName(), and INode::parent().

Referenced by INode::displayName().

Here is the call graph for this function:

◆ displayName()

std::string INode::displayName ( ) const
inherited

Returns display name, composed from the name of node and it's copy number.

Definition at line 105 of file INode.cpp.

106 {
107  std::string result = getName();
108  if (m_parent) {
109  int index = m_parent->copyNumber(this);
110  if (index >= 0)
111  result = result + std::to_string(index);
112  }
113  return result;
114 }
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:84

References INode::copyNumber(), IParameterized::getName(), and INode::m_parent.

Referenced by NodeUtils::nodePath(), and anonymous_namespace{NodeUtils.cpp}::nodeString().

Here is the call graph for this function:

◆ createParameterTree()

ParameterPool * INode::createParameterTree ( ) const
virtualinherited

Creates new parameter pool, with all local parameters and those of its children.

Reimplemented from IParameterized.

Definition at line 116 of file INode.cpp.

117 {
118  std::unique_ptr<ParameterPool> result(new ParameterPool);
119 
121  it.first();
122  while (!it.isDone()) {
123  const INode* child = it.getCurrent();
124  const std::string path = NodeUtils::nodePath(*child, this->parent()) + "/";
125  child->parameterPool()->copyToExternalPool(path, result.get());
126  it.next();
127  }
128 
129  return result.release();
130 }
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
Iterator through INode tree of objects.
Definition: NodeIterator.h:90
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
std::string nodePath(const INode &node, const INode *root=nullptr)
Returns path composed of node's displayName, with respect to root node.
Definition: NodeUtils.cpp:82

References ParameterPool::copyToExternalPool(), NodeIterator< Strategy >::first(), NodeIterator< Strategy >::getCurrent(), NodeIterator< Strategy >::isDone(), NodeIterator< Strategy >::next(), NodeUtils::nodePath(), IParameterized::parameterPool(), and INode::parent().

Referenced by ParticleDistribution::generateParticles(), Simulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParameterized::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 38 of file IParameterized.h.

38 { return m_pool.get(); } // has non-const usages!
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)

References IParameterized::m_pool.

Referenced by pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), INode::createParameterTree(), INode::INode(), IParameterized::IParameterized(), anonymous_namespace{NodeUtils.cpp}::poolToString(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

std::string IParameterized::parametersToString ( ) const
inherited

Returns multiline string representing available parameters.

Definition at line 40 of file IParameterized.cpp.

41 {
42  std::ostringstream result;
43  std::unique_ptr<ParameterPool> P_pool(createParameterTree());
44  result << *P_pool << "\n";
45  return result.str();
46 }
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.

References IParameterized::createParameterTree().

Here is the call graph for this function:

◆ registerParameter()

RealParameter & IParameterized::registerParameter ( const std::string &  name,
double *  parpointer 
)
inherited

Definition at line 48 of file IParameterized.cpp.

49 {
50  return m_pool->addParameter(
51  new RealParameter(name, data, getName(), [&]() -> void { onChange(); }));
52 }
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
Wraps a parameter of type double.
Definition: RealParameter.h:32

References IParameterized::getName(), IParameterized::m_pool, and IParameterized::onChange().

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), CylindersInBABuilder::CylindersInBABuilder(), DetectionProperties::DetectionProperties(), HexagonalLattice::HexagonalLattice(), IInterferenceFunction::IInterferenceFunction(), INode::INode(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), Lattice2D::Lattice2D(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleDistribution::ParticleDistribution(), PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParameterized::registerVector(), ParticleLayout::registerWeight(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), ResonatorBuilder::ResonatorBuilder(), Lattice2D::setRotationEnabled(), SquareLattice::SquareLattice(), and TriangularRippleBuilder::TriangularRippleBuilder().

Here is the call graph for this function:

◆ registerVector()

void IParameterized::registerVector ( const std::string &  base_name,
kvector_t p_vec,
const std::string &  units = "nm" 
)
inherited

Definition at line 54 of file IParameterized.cpp.

56 {
57  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
58  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
59  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
60 }
static std::string YComponentName(const std::string &base_name)
static std::string ZComponentName(const std::string &base_name)
RealParameter & setUnit(const std::string &name)

References IParameterized::registerParameter(), RealParameter::setUnit(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer::MultiLayer(), Lattice::registerBasisVectors(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ setParameterValue()

void IParameterized::setParameterValue ( const std::string &  name,
double  value 
)
inherited

Definition at line 62 of file IParameterized.cpp.

63 {
64  if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
65  m_pool->setParameterValue(name, value);
66  } else {
67  std::unique_ptr<ParameterPool> P_pool{createParameterTree()};
68  if (name.find('*') != std::string::npos)
69  P_pool->setMatchedParametersValue(name, value);
70  else
71  P_pool->setParameterValue(name, value);
72  }
73 }
int setMatchedParametersValue(const std::string &wildcards, double value)
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.

References IParameterized::createParameterTree(), IParameterized::m_pool, and ParameterPool::setMatchedParametersValue().

Referenced by AsymRippleBuilder::buildSample(), and IParameterized::setVectorValue().

Here is the call graph for this function:

◆ setVectorValue()

void IParameterized::setVectorValue ( const std::string &  base_name,
kvector_t  value 
)
inherited

Definition at line 75 of file IParameterized.cpp.

76 {
77  setParameterValue(XComponentName(base_name), value.x());
78  setParameterValue(YComponentName(base_name), value.y());
79  setParameterValue(ZComponentName(base_name), value.z());
80 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
void setParameterValue(const std::string &name, double value)

References IParameterized::setParameterValue(), BasicVector3D< T >::x(), IParameterized::XComponentName(), BasicVector3D< T >::y(), IParameterized::YComponentName(), BasicVector3D< T >::z(), and IParameterized::ZComponentName().

Here is the call graph for this function:

◆ parameter()

RealParameter * IParameterized::parameter ( const std::string &  name) const
inherited

◆ onChange()

◆ removeParameter()

void IParameterized::removeParameter ( const std::string &  name)
inherited

◆ removeVector()

void IParameterized::removeVector ( const std::string &  base_name)
inherited

Definition at line 93 of file IParameterized.cpp.

94 {
95  removeParameter(XComponentName(base_name));
96  removeParameter(YComponentName(base_name));
97  removeParameter(ZComponentName(base_name));
98 }

References IParameterized::removeParameter(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ XComponentName()

std::string IParameterized::XComponentName ( const std::string &  base_name)
staticinherited

◆ YComponentName()

std::string IParameterized::YComponentName ( const std::string &  base_name)
staticinherited

Definition at line 105 of file IParameterized.cpp.

106 {
107  return base_name + "Y";
108 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ ZComponentName()

std::string IParameterized::ZComponentName ( const std::string &  base_name)
staticinherited

Definition at line 110 of file IParameterized.cpp.

111 {
112  return base_name + "Z";
113 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ setName()

void IParameterized::setName ( const std::string &  name)
inlineinherited

Definition at line 68 of file IParameterized.h.

68 { m_name = name; }
std::string m_name

References IParameterized::m_name.

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), Layer::clone(), ConvolutionDetectorResolution::ConvolutionDetectorResolution(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorBAPol::FormFactorBAPol(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorDWBA::FormFactorDWBA(), FormFactorDWBAPol::FormFactorDWBAPol(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice::HexagonalLattice(), IDetector::IDetector(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), initialize(), ParticleComposition::initialize(), INode::INode(), Instrument::Instrument(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DLattice::InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunction3DLattice::InterferenceFunction3DLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionNone::InterferenceFunctionNone(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), ISampleBuilder::ISampleBuilder(), IsGISAXSDetector::IsGISAXSDetector(), Lattice::Lattice(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), Beam::operator=(), SampleBuilderNode::operator=(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), SampleBuilderNode::reset(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SampleBuilderNode::setSBN(), SphericalDetector::SphericalDetector(), and SquareLattice::SquareLattice().

◆ getName()

Member Data Documentation

◆ m_material

Material Particle::m_material
protected

Definition at line 47 of file Particle.h.

Referenced by clone(), createSlicedParticle(), material(), and setMaterial().

◆ mP_form_factor

std::unique_ptr<IFormFactor> Particle::mP_form_factor
protected

Definition at line 48 of file Particle.h.

Referenced by clone(), createSlicedParticle(), getChildren(), Particle(), and setFormFactor().

◆ m_position

◆ mP_rotation

◆ m_abundance

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 81 of file INode.h.

Referenced by INode::displayName(), INode::parent(), and INode::setParent().

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 86 of file INode.h.

Referenced by INode::INode().

◆ m_P

std::vector<double> INode::m_P
protectedinherited

Definition at line 87 of file INode.h.

Referenced by INode::INode(), and IFootprintFactor::setWidthRatio().

◆ m_name

std::string IParameterized::m_name
privateinherited

Definition at line 72 of file IParameterized.h.

Referenced by IParameterized::getName(), and IParameterized::setName().

◆ m_pool

std::unique_ptr<ParameterPool> IParameterized::m_pool
privateinherited

The documentation for this class was generated from the following files: