BornAgain  1.19.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 reflection and scattering
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, bool forcePolarized)
31  : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it)
32 {
33  if (m_processed_sample->containsMagneticMaterial()
34  || m_processed_sample->externalField() != kvector_t{}
35  || forcePolarized)
36 
37  m_computation_term.reset(
38  new SpecularMatrixTerm(SpecularStrategyBuilder::build(multilayer, true)));
39  else
40  m_computation_term.reset(
41  new SpecularScalarTerm(SpecularStrategyBuilder::build(multilayer, false)));
42 }
43 
45 
47 {
48  if (!m_progress->alive())
49  return;
50 
51  m_computation_term->setProgressHandler(m_progress);
52  auto& slices = m_processed_sample->averageSlices();
53  for (auto it = m_begin_it; it != m_end_it; ++it)
54  m_computation_term->computeIntensity(*it, slices);
55 }
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:39
ProgressHandler * m_progress
Definition: IComputation.h:52
std::unique_ptr< ProcessedSample > m_processed_sample
Definition: IComputation.h:54
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
Maintains information about progress of a computation.
Collect the different options for simulation.
std::unique_ptr< SpecularComputationTerm > m_computation_term
std::vector< SpecularSimulationElement >::iterator SpecularElementIter
void runProtected() override
const SpecularElementIter m_begin_it
these iterators define the span of detector bins this simulation will work on
const SpecularElementIter m_end_it
SpecularComputation(const MultiLayer &multilayer, const SimulationOptions &options, ProgressHandler &progress, SpecularElementIter begin_it, SpecularElementIter end_it, bool forcePolarized=false)
~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)