BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MultiLayerUtils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Multilayer/MultiLayerUtils.cpp
6 //! @brief Implements helper functions for MultiLayer objects.
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 
20 
22 {
23  if (i == 0)
24  return nullptr;
25  return multilayer.layerInterface(i - 1)->getRoughness();
26 }
27 
28 size_t MultiLayerUtils::IndexOfLayer(const MultiLayer& multilayer, const Layer* p_layer)
29 {
30  for (size_t i = 0; i < multilayer.numberOfLayers(); ++i)
31  if (p_layer == multilayer.layer(i))
32  return i;
33  throw std::out_of_range("MultiLayerUtils::IndexOfLayer: layer not found");
34 }
35 
37 {
40 }
41 
43 {
44  for (size_t i = 0; i < sample.numberOfLayers() - 1; i++)
45  if (sample.layerInterface(i)->getRoughness())
46  return true;
47  return false;
48 }
Defines class LayerInterface.
Defines class Layer.
Declares functions in namespace MaterialUtils.
Defines helper functions for MultiLayer objects.
Defines class MultiLayer.
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISampleNode.
Definition: ISampleNode.cpp:26
const LayerRoughness * getRoughness() const
Returns roughness of the interface.
A roughness of interface between two layers.
A layer in a MultiLayer sample.
Definition: Layer.h:27
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
const LayerInterface * layerInterface(size_t i_interface) const
Returns interface with given index.
Definition: MultiLayer.cpp:96
const Layer * layer(size_t i_layer) const
Returns layer with given index.
Definition: MultiLayer.cpp:91
size_t numberOfLayers() const
Definition: MultiLayer.h:50
MATERIAL_TYPES checkMaterialTypes(const std::vector< const Material * > &materials)
Checks if all non-default materials in materials are of the same type and returns this type.
const LayerRoughness * LayerTopRoughness(const MultiLayer &multilayer, size_t i)
Returns top roughness of layer.
size_t IndexOfLayer(const MultiLayer &multilayer, const Layer *p_layer)
Returns the index of the given layer.
bool ContainsCompatibleMaterials(const MultiLayer &multilayer)
Returns true if the multilayer contains non-default materials of one type only.
bool hasRoughness(const MultiLayer &sample)