mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Make Source::sample() method const
This commit is contained in:
parent
b271399f63
commit
9af5541e88
7 changed files with 12 additions and 12 deletions
|
|
@ -196,7 +196,7 @@ below.
|
|||
|
||||
class CustomSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// weight
|
||||
|
|
@ -271,7 +271,7 @@ the source class when it is created:
|
|||
CustomSource(double energy) : energy_{energy} { }
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// weight
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
class RingSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// wgt
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class RingSource : public openmc::Source {
|
|||
}
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// wgt
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public:
|
|||
virtual ~Source() = default;
|
||||
|
||||
// Methods that must be implemented
|
||||
virtual Particle::Bank sample(uint64_t* seed) = 0;
|
||||
virtual Particle::Bank sample(uint64_t* seed) const = 0;
|
||||
|
||||
// Methods that can be overridden
|
||||
virtual double strength() const { return 1.0; }
|
||||
|
|
@ -55,7 +55,7 @@ public:
|
|||
//! Sample from the external source distribution
|
||||
//! \param[inout] seed Pseudorandom seed pointer
|
||||
//! \return Sampled site
|
||||
Particle::Bank sample(uint64_t* seed) override;
|
||||
Particle::Bank sample(uint64_t* seed) const override;
|
||||
|
||||
// Properties
|
||||
Particle::Type particle_type() const { return particle_; }
|
||||
|
|
@ -84,7 +84,7 @@ public:
|
|||
explicit FileSource(std::string path);
|
||||
|
||||
// Methods
|
||||
Particle::Bank sample(uint64_t* seed) override;
|
||||
Particle::Bank sample(uint64_t* seed) const override;
|
||||
|
||||
private:
|
||||
std::vector<Particle::Bank> sites_; //!< Source sites from a file
|
||||
|
|
@ -101,7 +101,7 @@ public:
|
|||
~CustomSourceWrapper();
|
||||
|
||||
// Defer implementation to custom source library
|
||||
Particle::Bank sample(uint64_t* seed) override
|
||||
Particle::Bank sample(uint64_t* seed) const override
|
||||
{
|
||||
return custom_source_->sample(seed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ IndependentSource::IndependentSource(pugi::xml_node node)
|
|||
}
|
||||
}
|
||||
|
||||
Particle::Bank IndependentSource::sample(uint64_t* seed)
|
||||
Particle::Bank IndependentSource::sample(uint64_t* seed) const
|
||||
{
|
||||
Particle::Bank site;
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ FileSource::FileSource(std::string path)
|
|||
file_close(file_id);
|
||||
}
|
||||
|
||||
Particle::Bank FileSource::sample(uint64_t* seed)
|
||||
Particle::Bank FileSource::sample(uint64_t* seed) const
|
||||
{
|
||||
size_t i_site = sites_.size()*prn(seed);
|
||||
return sites_[i_site];
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
class CustomSource : public openmc::Source
|
||||
{
|
||||
openmc::Particle::Bank sample(uint64_t *seed)
|
||||
openmc::Particle::Bank sample(uint64_t *seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// wgt
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class CustomSource : public openmc::Source {
|
|||
CustomSource(double energy) : energy_(energy) { }
|
||||
|
||||
// Samples from an instance of this class.
|
||||
openmc::Particle::Bank sample(uint64_t* seed)
|
||||
openmc::Particle::Bank sample(uint64_t* seed) const
|
||||
{
|
||||
openmc::Particle::Bank particle;
|
||||
// wgt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue