BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SpecularComputation Class Reference
Inheritance diagram for SpecularComputation:
Collaboration diagram for SpecularComputation:

Public Member Functions

 SpecularComputation (const MultiLayer &multilayer, const SimulationOptions &options, ProgressHandler &progress, SpecularElementIter begin_it, SpecularElementIter end_it)
 
 ~SpecularComputation () override
 
void run ()
 
bool isCompleted () const
 
std::string errorMessage () const
 

Protected Attributes

SimulationOptions m_sim_options
 
ProgressHandlermp_progress
 
ComputationStatus m_status
 
std::unique_ptr< ProcessedSamplemP_processed_sample
 

Private Types

using SpecularElementIter = std::vector< SpecularSimulationElement >::iterator
 

Private Member Functions

void runProtected () override
 

Private Attributes

SpecularElementIter m_begin_it
 
SpecularElementIter m_end_it
 
std::unique_ptr< SpecularComputationTermm_computation_term
 

Detailed Description

Performs a single-threaded specular computation with given sample.

Controlled by the multi-threading machinery in Simulation::runSingleSimulation().

Definition at line 30 of file SpecularComputation.h.

Member Typedef Documentation

◆ SpecularElementIter

Definition at line 32 of file SpecularComputation.h.

Constructor & Destructor Documentation

◆ SpecularComputation()

SpecularComputation::SpecularComputation ( const MultiLayer multilayer,
const SimulationOptions options,
ProgressHandler progress,
SpecularElementIter  begin_it,
SpecularElementIter  end_it 
)

Definition at line 27 of file SpecularComputation.cpp.

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 }
std::unique_ptr< ProcessedSample > mP_processed_sample
Definition: IComputation.h:50
IComputation(const MultiLayer &sample, const SimulationOptions &options, ProgressHandler &progress)
SpecularElementIter m_end_it
std::unique_ptr< SpecularComputationTerm > m_computation_term
SpecularElementIter m_begin_it
these iterators define the span of detector bins this simulation will work on
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)

References SpecularStrategyBuilder::build(), m_computation_term, and IComputation::mP_processed_sample.

Here is the call graph for this function:

◆ ~SpecularComputation()

SpecularComputation::~SpecularComputation ( )
overridedefault

Member Function Documentation

◆ runProtected()

void SpecularComputation::runProtected ( )
overrideprivatevirtual

Implements IComputation.

Definition at line 44 of file SpecularComputation.cpp.

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 }
ProgressHandler * mp_progress
Definition: IComputation.h:48

References ProgressHandler::alive(), m_begin_it, m_computation_term, m_end_it, IComputation::mP_processed_sample, and IComputation::mp_progress.

Here is the call graph for this function:

◆ run()

void IComputation::run ( )
inherited

Definition at line 30 of file IComputation.cpp.

31 {
33  try {
34  runProtected();
36  } catch (const std::exception& ex) {
37  m_status.setErrorMessage(std::string(ex.what()));
39  }
40 }
void setErrorMessage(const std::string &message)
virtual void runProtected()=0
ComputationStatus m_status
Definition: IComputation.h:49

References IComputation::m_status, IComputation::runProtected(), ComputationStatus::setCompleted(), ComputationStatus::setErrorMessage(), ComputationStatus::setFailed(), and ComputationStatus::setRunning().

Here is the call graph for this function:

◆ isCompleted()

bool IComputation::isCompleted ( ) const
inlineinherited

Definition at line 43 of file IComputation.h.

43 { return m_status.isCompleted(); }
bool isCompleted() const

References ComputationStatus::isCompleted(), and IComputation::m_status.

Here is the call graph for this function:

◆ errorMessage()

std::string IComputation::errorMessage ( ) const
inlineinherited

Definition at line 44 of file IComputation.h.

44 { return m_status.errorMessage(); }
std::string errorMessage() const

References ComputationStatus::errorMessage(), and IComputation::m_status.

Here is the call graph for this function:

Member Data Documentation

◆ m_begin_it

SpecularElementIter SpecularComputation::m_begin_it
private

these iterators define the span of detector bins this simulation will work on

Definition at line 44 of file SpecularComputation.h.

Referenced by runProtected().

◆ m_end_it

SpecularElementIter SpecularComputation::m_end_it
private

Definition at line 44 of file SpecularComputation.h.

Referenced by runProtected().

◆ m_computation_term

std::unique_ptr<SpecularComputationTerm> SpecularComputation::m_computation_term
private

Definition at line 45 of file SpecularComputation.h.

Referenced by runProtected(), and SpecularComputation().

◆ m_sim_options

SimulationOptions IComputation::m_sim_options
protectedinherited

Definition at line 47 of file IComputation.h.

Referenced by DWBAComputation::DWBAComputation().

◆ mp_progress

ProgressHandler* IComputation::mp_progress
protectedinherited

◆ m_status

ComputationStatus IComputation::m_status
protectedinherited

◆ mP_processed_sample

std::unique_ptr<ProcessedSample> IComputation::mP_processed_sample
protectedinherited

The documentation for this class was generated from the following files: