File: SimulationOptions.h

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (77 lines) | stat: -rw-r--r-- 2,737 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Resample/Option/SimulationOptions.h
//! @brief     Defines class SimulationOptions.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_RESAMPLE_OPTION_SIMULATIONOPTIONS_H
#define BORNAGAIN_RESAMPLE_OPTION_SIMULATIONOPTIONS_H

#include <cstddef>

using std::size_t;

//! Options to compute mesocrystal formfactors.

struct MesoOptions {
    bool use_reciprocal_sum{false}; //!< If true, use approximative but faster algorithm
    double radius_factor{2.1};      //!< Cutoff for fast (reciprocal-sum) algorithm
};

//! Collect the different options for simulation.
//! @ref SimulationOptions

class SimulationOptions {
public:
    SimulationOptions();

    //! Enables/disables MonteCarlo integration
    //! @param flag If true, MonteCarlo integration will be used, otherwise analytical calculations
    //! @param mc_points Number of points for MonteCarlo integrator
    void setMonteCarloIntegration(bool flag = true, size_t mc_points = 50);

    //! Sets number of threads to use during the simulation (0 - take default value from hardware)
    void setNumberOfThreads(int nthreads);

    //! Sets number of batches to split
    void setNumberOfBatches(int nbatches); // TODO: undocumented, probably useless

    void setIncludeSpecular(bool include_specular) { m_include_specular = include_specular; }

    void setUseAvgMaterials(bool use_avg_materials) { m_use_avg_materials = use_avg_materials; }

    void setMesoOptions(bool use_rec_sum, double rad_factor);

#ifndef SWIG

    bool isIntegrate() const;
    size_t getMcPoints() const { return m_mc_points; }
    unsigned getNumberOfThreads() const;
    unsigned getNumberOfBatches() const;
    unsigned getCurrentBatch() const;
    unsigned getHardwareConcurrency() const;
    bool includeSpecular() const { return m_include_specular; }
    bool useAvgMaterials() const { return m_use_avg_materials; }
    MesoOptions mesoOptions() const { return m_meso_options; }

private:
    bool m_mc_integration;
    bool m_include_specular;
    bool m_use_avg_materials;
    MesoOptions m_meso_options;
    size_t m_mc_points;
    unsigned m_n_threads{0};
    unsigned m_n_batches{1};
    unsigned m_current_batch{0};
#endif // SWIG
};

#endif // BORNAGAIN_RESAMPLE_OPTION_SIMULATIONOPTIONS_H