BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
LayerInterface.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Interface/LayerInterface.cpp
6 //! @brief Implements class LayerInterface.
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 #include "Base/Util/Assert.h"
18 
20  : m_topLayer(nullptr)
21  , m_bottomLayer(nullptr)
22 {
23 }
24 
26 
28 {
29  throw std::runtime_error("LayerInterface::clone() -> Not allowed to clone.");
30 }
31 
33  const Layer* bottom_layer)
34 {
35  auto* result = new LayerInterface();
36  result->setLayersTopBottom(top_layer, bottom_layer);
37  return result;
38 }
39 
41  const Layer* bottom_layer,
42  const LayerRoughness& roughness)
43 {
44  LayerInterface* result = createSmoothInterface(top_layer, bottom_layer);
45  result->setRoughness(roughness);
46  return result;
47 }
48 
50 {
51  m_roughness.reset(roughness.clone());
52 }
53 
54 std::vector<const INode*> LayerInterface::nodeChildren() const
55 {
56  return std::vector<const INode*>() << m_roughness;
57 }
58 
59 //! Sets links to the layers above and below the interface.
60 
61 void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer)
62 {
63  ASSERT(top_layer && bottom_layer);
64  m_topLayer = top_layer;
65  m_bottomLayer = bottom_layer;
66 }
Defines the macro ASSERT.
#define ASSERT(condition)
Definition: Assert.h:45
Defines class LayerInterface.
Defines class LayerRoughness.
Interface between two layers, possibly with roughness.
static LayerInterface * createRoughInterface(const Layer *top_layer, const Layer *bottom_layer, const LayerRoughness &roughness)
Creates rough interface between two layers.
~LayerInterface() override
const LayerRoughness * roughness() const
Returns roughness of the interface.
LayerInterface * clone() const override
Returns a clone of this ISampleNode object.
static LayerInterface * createSmoothInterface(const Layer *top_layer, const Layer *bottom_layer)
Creates smooth interface between two layers.
void setLayersTopBottom(const Layer *top_layer, const Layer *bottom_layer)
Sets links to the layers above and below the interface.
std::unique_ptr< LayerRoughness > m_roughness
roughness of the interface
const Layer * m_bottomLayer
pointer to the layer below interface
void setRoughness(const LayerRoughness &roughness)
Sets roughness of the interface.
std::vector< const INode * > nodeChildren() const override
Returns all children.
const Layer * m_topLayer
pointer to the layer above interface
A roughness of interface between two layers.
LayerRoughness * clone() const override
Returns a clone of this ISampleNode object.
A layer in a MultiLayer sample.
Definition: Layer.h:26