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

Public Member Functions

 SimulationOptions ()
 
bool isIntegrate () const
 
size_t getMcPoints () const
 
void setMonteCarloIntegration (bool flag=true, size_t mc_points=50)
 
void setNumberOfThreads (int nthreads)
 
unsigned getNumberOfThreads () const
 
void setNumberOfBatches (int nbatches)
 
unsigned getNumberOfBatches () const
 
unsigned getCurrentBatch () const
 
void setThreadInfo (const ThreadInfo &thread_info)
 
unsigned getHardwareConcurrency () const
 
void setIncludeSpecular (bool include_specular)
 
bool includeSpecular () const
 
void setUseAvgMaterials (bool use_avg_materials)
 
bool useAvgMaterials () const
 

Private Attributes

bool m_mc_integration
 
bool m_include_specular
 
bool m_use_avg_materials
 
size_t m_mc_points
 
ThreadInfo m_thread_info
 

Detailed Description

Collect the different options for simulation.

SimulationOptions

Definition at line 27 of file SimulationOptions.h.

Constructor & Destructor Documentation

◆ SimulationOptions()

SimulationOptions::SimulationOptions ( )

Definition at line 19 of file SimulationOptions.cpp.

References getHardwareConcurrency(), m_thread_info, and ThreadInfo::n_threads.

Here is the call graph for this function:

Member Function Documentation

◆ isIntegrate()

bool SimulationOptions::isIntegrate ( ) const

◆ getMcPoints()

size_t SimulationOptions::getMcPoints ( ) const
inline

◆ setMonteCarloIntegration()

void SimulationOptions::setMonteCarloIntegration ( bool  flag = true,
size_t  mc_points = 50 
)

Enables/disables MonetCarlo integration.

Parameters
flagIf true, MonteCarlo integration will be used, otherwise analytical calculations
mc_pointsNumber of points for MonteCarlo integrator

Definition at line 30 of file SimulationOptions.cpp.

31 {
32  m_mc_integration = flag;
33  m_mc_points = mc_points;
34 }

References m_mc_integration, and m_mc_points.

Referenced by StandardSimulations::MiniGISASMonteCarlo().

◆ setNumberOfThreads()

void SimulationOptions::setNumberOfThreads ( int  nthreads)

Sets number of threads to use during the simulation (0 - take the default value from the hardware)

Definition at line 36 of file SimulationOptions.cpp.

37 {
38  if (nthreads == 0)
40  else if (nthreads > 0)
41  m_thread_info.n_threads = nthreads;
42  else
44 }

References getHardwareConcurrency(), m_thread_info, and ThreadInfo::n_threads.

Here is the call graph for this function:

◆ getNumberOfThreads()

unsigned SimulationOptions::getNumberOfThreads ( ) const

Definition at line 46 of file SimulationOptions.cpp.

47 {
48  if (m_thread_info.n_threads < 1)
49  throw std::runtime_error("Error in SimulationOptions::getNumberOfThreads: Number of "
50  "threads must be positive");
51  return m_thread_info.n_threads;
52 }

References m_thread_info, and ThreadInfo::n_threads.

Referenced by SimulationToPython::defineSimulationOptions(), and Simulation::runSingleSimulation().

◆ setNumberOfBatches()

void SimulationOptions::setNumberOfBatches ( int  nbatches)

Sets number of batches to split.

Definition at line 54 of file SimulationOptions.cpp.

55 {
56  if (nbatches < 1)
57  throw std::runtime_error("Error in SimulationOptions::setNumberOfBatches: Number of "
58  "batches must be positive");
59  m_thread_info.n_batches = nbatches;
60 }
unsigned n_batches
Definition: ThreadInfo.h:24

References m_thread_info, and ThreadInfo::n_batches.

◆ getNumberOfBatches()

unsigned SimulationOptions::getNumberOfBatches ( ) const

Definition at line 62 of file SimulationOptions.cpp.

63 {
64  if (m_thread_info.n_batches < 1)
65  throw std::runtime_error("Error in SimulationOptions::getNumberOfBatches: Number of "
66  "batches must be positive");
67  return m_thread_info.n_batches;
68 }

References m_thread_info, and ThreadInfo::n_batches.

Referenced by getCurrentBatch(), and Simulation::runSimulation().

◆ getCurrentBatch()

unsigned SimulationOptions::getCurrentBatch ( ) const

Definition at line 70 of file SimulationOptions.cpp.

71 {
73  throw std::runtime_error(
74  "Error in SimulationOptions::getCurrentBatch: current batch is out of range");
76 }
unsigned getNumberOfBatches() const
unsigned current_batch
Definition: ThreadInfo.h:25

References ThreadInfo::current_batch, getNumberOfBatches(), and m_thread_info.

Referenced by Simulation::runSimulation().

Here is the call graph for this function:

◆ setThreadInfo()

void SimulationOptions::setThreadInfo ( const ThreadInfo thread_info)
inline

Sets the batch and thread information to be used.

Definition at line 54 of file SimulationOptions.h.

54 { m_thread_info = thread_info; }

References m_thread_info.

◆ getHardwareConcurrency()

unsigned SimulationOptions::getHardwareConcurrency ( ) const

Definition at line 78 of file SimulationOptions.cpp.

79 {
80  return std::thread::hardware_concurrency();
81 }

Referenced by SimulationToPython::defineSimulationOptions(), setNumberOfThreads(), and SimulationOptions().

◆ setIncludeSpecular()

void SimulationOptions::setIncludeSpecular ( bool  include_specular)
inline

Definition at line 58 of file SimulationOptions.h.

58 { m_include_specular = include_specular; }

References m_include_specular.

Referenced by StandardSimulations::MiniGISASSpecularPeak().

◆ includeSpecular()

bool SimulationOptions::includeSpecular ( ) const
inline

◆ setUseAvgMaterials()

void SimulationOptions::setUseAvgMaterials ( bool  use_avg_materials)
inline

Definition at line 62 of file SimulationOptions.h.

62 { m_use_avg_materials = use_avg_materials; }

References m_use_avg_materials.

Referenced by DefaultMaterialProfileLimits(), and MaterialProfile().

◆ useAvgMaterials()

bool SimulationOptions::useAvgMaterials ( ) const
inline

Member Data Documentation

◆ m_mc_integration

bool SimulationOptions::m_mc_integration
private

Definition at line 67 of file SimulationOptions.h.

Referenced by isIntegrate(), and setMonteCarloIntegration().

◆ m_include_specular

bool SimulationOptions::m_include_specular
private

Definition at line 68 of file SimulationOptions.h.

Referenced by includeSpecular(), and setIncludeSpecular().

◆ m_use_avg_materials

bool SimulationOptions::m_use_avg_materials
private

Definition at line 69 of file SimulationOptions.h.

Referenced by setUseAvgMaterials(), and useAvgMaterials().

◆ m_mc_points

size_t SimulationOptions::m_mc_points
private

Definition at line 70 of file SimulationOptions.h.

Referenced by getMcPoints(), isIntegrate(), and setMonteCarloIntegration().

◆ m_thread_info


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