BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SpecularComputation.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Core/Computation/SpecularComputation.cpp
6 //! @brief Implements class SpecularComputation.
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 
21 
22 static_assert(std::is_copy_constructible<SpecularComputation>::value == false,
23  "SpecularComputation should not be copy constructible");
24 static_assert(std::is_copy_assignable<SpecularComputation>::value == false,
25  "SpecularComputation should not be copy assignable");
26 
28  const SimulationOptions& options,
29  ProgressHandler& progress, SpecularElementIter begin_it,
30  SpecularElementIter end_it)
31  : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it)
32 {
33  if (mP_processed_sample->containsMagneticMaterial()
34  || mP_processed_sample->externalField() != kvector_t{})
35  m_computation_term.reset(
36  new SpecularMatrixTerm(SpecularStrategyBuilder::build(multilayer, true)));
37  else
38  m_computation_term.reset(
39  new SpecularScalarTerm(SpecularStrategyBuilder::build(multilayer, false)));
40 }
41 
43 
45 {
46  if (!mp_progress->alive())
47  return;
48 
49  m_computation_term->setProgressHandler(mp_progress);
50  auto& slices = mP_processed_sample->averageSlices();
51  for (auto it = m_begin_it; it != m_end_it; ++it)
52  m_computation_term->computeIntensity(*it, slices);
53 }
Defines class ProcessedSample.
Defines class ProgressHandler.
Defines classes SpecularComputationTerm, SpecularScalarTerm, SpecularMatrixTerm.
Defines class SpecularComputation.
Declares the class SpecularSimulationElement.
Defines class SpecularStrategyBuilder.
Interface for a single-threaded computation with given range of SimulationElements and ProgressHandle...
Definition: IComputation.h:35
std::unique_ptr< ProcessedSample > mP_processed_sample
Definition: IComputation.h:50
ProgressHandler * mp_progress
Definition: IComputation.h:48
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:42
Maintains information about progress of a computation.
Collect the different options for simulation.
SpecularElementIter m_end_it
std::unique_ptr< SpecularComputationTerm > m_computation_term
std::vector< SpecularSimulationElement >::iterator SpecularElementIter
SpecularElementIter m_begin_it
these iterators define the span of detector bins this simulation will work on
void runProtected() override
SpecularComputation(const MultiLayer &multilayer, const SimulationOptions &options, ProgressHandler &progress, SpecularElementIter begin_it, SpecularElementIter end_it)
~SpecularComputation() override
Computes the specular scattering for a magnetic sample Used by SpecularComputation.
Computes the specular scattering for a scalar sample Used by SpecularComputation.
static std::unique_ptr< ISpecularStrategy > build(const MultiLayer &sample, const bool magnetic)