BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
LayerInterface.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Slice/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 
17 
18 LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr)
19 {
20  setName("LayerInterface");
21 }
22 
24 
26 {
27  throw std::runtime_error("LayerInterface::clone() -> Not allowed to clone.");
28 }
29 
31  const Layer* bottom_layer)
32 {
33  LayerInterface* result = new LayerInterface();
34  result->setLayersTopBottom(top_layer, bottom_layer);
35  return result;
36 }
37 
39  const Layer* bottom_layer,
40  const LayerRoughness& roughness)
41 {
42  LayerInterface* result = createSmoothInterface(top_layer, bottom_layer);
43  result->setRoughness(roughness);
44  return result;
45 }
46 
48 {
49  m_roughness.reset(roughness.clone());
51 }
52 
53 std::vector<const INode*> LayerInterface::getChildren() const
54 {
55  return std::vector<const INode*>() << m_roughness;
56 }
57 
58 //! Sets links to the layers above and below the interface.
59 
60 void LayerInterface::setLayersTopBottom(const Layer* top_layer, const Layer* bottom_layer)
61 {
62  if (top_layer == nullptr || bottom_layer == nullptr)
63  throw std::runtime_error("LayerInterface::setLayersTopBottom() -> Error. "
64  "Attempt to set nullptr.");
65  m_topLayer = top_layer;
66  m_bottomLayer = bottom_layer;
67 }
Defines class LayerInterface.
Defines class LayerRoughness.
void registerChild(INode *node)
Definition: INode.cpp:57
void setName(const std::string &name)
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 * clone() const
Returns a clone of this ISampleNode object.
static LayerInterface * createSmoothInterface(const Layer *top_layer, const Layer *bottom_layer)
Creates smooth interface between two layers.
virtual ~LayerInterface()
void setLayersTopBottom(const Layer *top_layer, const Layer *bottom_layer)
Sets links to the layers above and below the interface.
std::vector< const INode * > getChildren() const
Returns a vector of children.
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.
const Layer * m_topLayer
pointer to the layer above interface
A roughness of interface between two layers.
LayerRoughness * clone() const
Returns a clone of this ISampleNode object.
A layer in a MultiLayer sample.
Definition: Layer.h:27