BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
LayerInterface Class Reference

Description

Interface between two layers, possibly with roughness.

Definition at line 31 of file LayerInterface.h.

Inheritance diagram for LayerInterface:
[legend]
Collaboration diagram for LayerInterface:
[legend]

Public Member Functions

 ~LayerInterface () override
 
const LayerbottomLayer () const
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
LayerInterfaceclone () const override
 Returns a clone of this ISampleNode object. More...
 
std::vector< const Material * > containedMaterials () const
 Returns set of unique materials contained in this ISampleNode. More...
 
bool isMagnetic () const
 Returns true if there is any magnetic material in this ISampleNode. More...
 
virtual const Materialmaterial () const
 Returns nullptr, unless overwritten to return a specific material. More...
 
std::vector< const INode * > nodeChildren () const override
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
virtual std::vector< ParaMetaparDefs () const
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
const LayerRoughnessroughness () const
 Returns roughness of the interface. More...
 
void setRoughness (const LayerRoughness &roughness)
 Sets roughness of the interface. More...
 
const LayertopLayer () const
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 

Static Public Member Functions

static LayerInterfacecreateRoughInterface (const Layer *top_layer, const Layer *bottom_layer, const LayerRoughness &roughness)
 Creates rough interface between two layers. More...
 
static LayerInterfacecreateSmoothInterface (const Layer *top_layer, const Layer *bottom_layer)
 Creates smooth interface between two layers. More...
 

Protected Attributes

std::vector< double > m_P
 

Private Member Functions

 LayerInterface ()
 
void setLayersTopBottom (const Layer *top_layer, const Layer *bottom_layer)
 Sets links to the layers above and below the interface. More...
 

Private Attributes

const Layerm_bottomLayer
 pointer to the layer below interface More...
 
std::unique_ptr< LayerRoughnessm_roughness
 roughness of the interface More...
 
const Layerm_topLayer
 pointer to the layer above interface More...
 

Constructor & Destructor Documentation

◆ ~LayerInterface()

LayerInterface::~LayerInterface ( )
overridedefault

◆ LayerInterface()

LayerInterface::LayerInterface ( )
private

Definition at line 19 of file LayerInterface.cpp.

20  : m_topLayer(nullptr)
21  , m_bottomLayer(nullptr)
22 {
23 }
const Layer * m_bottomLayer
pointer to the layer below interface
const Layer * m_topLayer
pointer to the layer above interface

Referenced by createSmoothInterface().

Member Function Documentation

◆ bottomLayer()

const Layer * LayerInterface::bottomLayer ( ) const
inline

Definition at line 76 of file LayerInterface.h.

77 {
78  return m_bottomLayer;
79 }

References m_bottomLayer.

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
#define ASSERT(condition)
Definition: Assert.h:45
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
std::vector< double > m_P
Definition: INode.h:63
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string LayerInterface::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 36 of file LayerInterface.h.

36 { return "LayerInterface"; }

◆ clone()

LayerInterface * LayerInterface::clone ( ) const
overridevirtual

Returns a clone of this ISampleNode object.

Implements ISampleNode.

Definition at line 27 of file LayerInterface.cpp.

28 {
29  throw std::runtime_error("LayerInterface::clone() -> Not allowed to clone.");
30 }

◆ containedMaterials()

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

Returns set of unique materials contained in this ISampleNode.

Definition at line 25 of file ISampleNode.cpp.

26 {
27  std::vector<const Material*> result;
28  if (const Material* p_material = material())
29  result.push_back(p_material);
30  for (const auto* child : nodeChildren()) {
31  if (const auto* sample = dynamic_cast<const ISampleNode*>(child)) {
32  for (const Material* p_material : sample->containedMaterials())
33  result.push_back(p_material);
34  }
35  }
36  return result;
37 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISampleNode.h:36
A wrapper for underlying material implementation.
Definition: Material.h:35

References ISampleNode::material(), and INode::nodeChildren().

Referenced by SampleUtils::Multilayer::ContainsCompatibleMaterials(), SampleToPython::initLabels(), and ISampleNode::isMagnetic().

Here is the call graph for this function:

◆ createRoughInterface()

LayerInterface * LayerInterface::createRoughInterface ( const Layer top_layer,
const Layer bottom_layer,
const LayerRoughness roughness 
)
static

Creates rough interface between two layers.

Definition at line 40 of file LayerInterface.cpp.

43 {
44  LayerInterface* result = createSmoothInterface(top_layer, bottom_layer);
45  result->setRoughness(roughness);
46  return result;
47 }
Interface between two layers, possibly with roughness.
const LayerRoughness * roughness() const
Returns roughness of the interface.
static LayerInterface * createSmoothInterface(const Layer *top_layer, const Layer *bottom_layer)
Creates smooth interface between two layers.
void setRoughness(const LayerRoughness &roughness)
Sets roughness of the interface.

References createSmoothInterface(), roughness(), and setRoughness().

Referenced by MultiLayer::addLayerWithTopRoughness().

Here is the call graph for this function:

◆ createSmoothInterface()

LayerInterface * LayerInterface::createSmoothInterface ( const Layer top_layer,
const Layer bottom_layer 
)
static

Creates smooth interface between two layers.

Definition at line 32 of file LayerInterface.cpp.

34 {
35  auto* result = new LayerInterface();
36  result->setLayersTopBottom(top_layer, bottom_layer);
37  return result;
38 }

References LayerInterface().

Referenced by MultiLayer::addLayerWithTopRoughness(), and createRoughInterface().

Here is the call graph for this function:

◆ isMagnetic()

bool ISampleNode::isMagnetic ( ) const
inherited

Returns true if there is any magnetic material in this ISampleNode.

Definition at line 39 of file ISampleNode.cpp.

40 {
41  const auto materials = containedMaterials();
42  return std::any_of(materials.cbegin(), materials.cend(),
43  [](const Material* mat) { return mat->isMagneticMaterial(); });
44 }
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISampleNode.
Definition: ISampleNode.cpp:25

References ISampleNode::containedMaterials().

Referenced by reSample::make().

Here is the call graph for this function:

◆ material()

virtual const Material* ISampleNode::material ( ) const
inlinevirtualinherited

Returns nullptr, unless overwritten to return a specific material.

Reimplemented in Particle, and Layer.

Definition at line 36 of file ISampleNode.h.

36 { return nullptr; }

Referenced by ISampleNode::containedMaterials().

◆ nodeChildren()

std::vector< const INode * > LayerInterface::nodeChildren ( ) const
overridevirtual

Returns all children.

Reimplemented from INode.

Definition at line 54 of file LayerInterface.cpp.

55 {
56  return std::vector<const INode*>() << m_roughness;
57 }
std::unique_ptr< LayerRoughness > m_roughness
roughness of the interface

References m_roughness.

◆ nodeOffspring()

std::vector< const INode * > INode::nodeOffspring ( ) const
inherited

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }

References INode::nodeChildren().

Here is the call graph for this function:

◆ parDefs()

virtual std::vector<ParaMeta> INode::parDefs ( ) const
inlinevirtualinherited

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented in ConstantBackground, GaussSphere, FuzzySphere, RotationEuler, RotationZ, RotationY, RotationX, Crystal, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, LayerRoughness, TruncatedSpheroid, TruncatedSphere, TruncatedCube, Spheroid, Sphere, SawtoothRippleLorentz, SawtoothRippleGauss, SawtoothRippleBox, Pyramid6, Pyramid4, Pyramid3, Pyramid2, Prism6, Prism3, PlatonicTetrahedron, PlatonicOctahedron, LongBoxLorentz, LongBoxGauss, Icosahedron, HorizontalCylinder, HollowSphere, HemiEllipsoid, EllipsoidalCylinder, Dodecahedron, Cylinder, CosineRippleLorentz, CosineRippleGauss, CosineRippleBox, Cone, CantellatedCube, Box, Bipyramid4, BarLorentz, BarGauss, Profile2DVoigt, Profile2DCone, Profile2DGate, Profile2DGauss, Profile2DCauchy, Profile1DVoigt, Profile1DCosine, Profile1DTriangle, Profile1DGate, Profile1DGauss, Profile1DCauchy, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceTwin, InterferenceRadialParaCrystal, InterferenceHardDisk, Interference2DSuperLattice, Interference2DParaCrystal, Interference1DLattice, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, PolFilter, FootprintSquare, and FootprintGauss.

Definition at line 51 of file INode.h.

51 { return {}; }

Referenced by INode::checkNodeArgs(), and IFormFactor::pythonConstructor().

◆ roughness()

const LayerRoughness * LayerInterface::roughness ( ) const
inline

◆ setLayersTopBottom()

void LayerInterface::setLayersTopBottom ( const Layer top_layer,
const Layer bottom_layer 
)
private

Sets links to the layers above and below the interface.

Definition at line 61 of file LayerInterface.cpp.

62 {
63  ASSERT(top_layer && bottom_layer);
64  m_topLayer = top_layer;
65  m_bottomLayer = bottom_layer;
66 }

References ASSERT, m_bottomLayer, and m_topLayer.

◆ setRoughness()

void LayerInterface::setRoughness ( const LayerRoughness roughness)

Sets roughness of the interface.

Definition at line 49 of file LayerInterface.cpp.

50 {
51  m_roughness.reset(roughness.clone());
52 }
LayerRoughness * clone() const override
Returns a clone of this ISampleNode object.

References LayerRoughness::clone(), m_roughness, and roughness().

Referenced by createRoughInterface().

Here is the call graph for this function:

◆ topLayer()

const Layer * LayerInterface::topLayer ( ) const
inline

Definition at line 71 of file LayerInterface.h.

72 {
73  return m_topLayer;
74 }

References m_topLayer.

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 32 of file ICloneable.h.

Member Data Documentation

◆ m_bottomLayer

const Layer* LayerInterface::m_bottomLayer
private

pointer to the layer below interface

Definition at line 62 of file LayerInterface.h.

Referenced by bottomLayer(), and setLayersTopBottom().

◆ m_P

◆ m_roughness

std::unique_ptr<LayerRoughness> LayerInterface::m_roughness
private

roughness of the interface

Definition at line 63 of file LayerInterface.h.

Referenced by nodeChildren(), roughness(), and setRoughness().

◆ m_topLayer

const Layer* LayerInterface::m_topLayer
private

pointer to the layer above interface

Definition at line 61 of file LayerInterface.h.

Referenced by setLayersTopBottom(), and topLayer().


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