• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 23916574395

02 Apr 2026 06:50PM UTC coverage: 81.336% (+0.01%) from 81.324%
23916574395

Pull #3734

github

web-flow
Merge 3420117d8 into d9b30bbbd
Pull Request #3734: Specify temperature from a field (structured mesh only)

17720 of 25601 branches covered (69.22%)

Branch coverage included in aggregate %.

183 of 204 new or added lines in 15 files covered. (89.71%)

69 existing lines in 3 files now uncovered.

58284 of 67843 relevant lines covered (85.91%)

44753955.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/include/openmc/field.h
1
#ifndef OPENMC_FIELD_H
2
#define OPENMC_FIELD_H
3

4
#include "openmc/mesh.h"
5
#include "openmc/vector.h"
6

7
namespace openmc {
8

9
class ScalarField {
8,350✔
10
public:
11
  //----------------------------------------------------------------------------
12
  // Constructors
13
  ScalarField() = default;
8,335✔
14
  ScalarField(
15
    Mesh* mesh_ptr, vector<double> values, const std::string& field_name);
16
  ScalarField(Mesh* mesh_ptr, vector<double> values)
17
    : ScalarField(mesh_ptr, values, "ScalarField") {};
18

19
  //----------------------------------------------------------------------------
20
  // Methods
21

22
  //! Returns the distance to the next mesh boundary gien a particle position
23
  //! and direction. If the particle is initially outside, the distance will
24
  //! correspond to the nearest distance to the outer boundaries of the mesh.
25
  //
26
  //! \param[in] r Position of the particle
27
  //! \param[in] u Direction of the particle
28
  //! \return The distance in cm to the next mesh boundary
29
  double distance_to_next_boundary(const Position& r, const Direction& d);
30

31
  //----------------------------------------------------------------------------
32
  // Accessors
33

34
  // Field type
35
  const std::string& field_type() const { return this->field_type_; }
36

37
  // Mesh pointer
38
  Mesh* mesh_ptr() const
2,027,157✔
39
  {
40
    if (this->mesh_ptr_ == nullptr) {
2,027,157!
NEW
41
      fatal_error(fmt::format("No mesh found for {}!", this->field_type_));
×
42
    } else {
43
      return this->mesh_ptr_;
2,027,157✔
44
    }
45
  }
46

47
  // Values
48
  double& value(int i) { return values_[i]; }
663,080✔
49
  const double& value(int i) const { return values_[i]; }
50
  const vector<double>& values() const { return values_; }
663,080!
51

52
private:
53
  //----------------------------------------------------------------------------
54
  // Data members
55
  std::string field_type_; //! Name of field type
56
  Mesh* mesh_ptr_;         //!< Pointer to the geometric mesh
57
  vector<double> values_;  //!< Values associated with each mesh cell
58
};
59

60
class TemperatureField : public ScalarField {
16,700✔
61
public:
62
  //----------------------------------------------------------------------------
63
  // Constructors
64
  TemperatureField() = default;
8,335✔
65
  TemperatureField(Mesh* mesh_ptr, vector<double> values)
15✔
66
    : ScalarField(mesh_ptr, values, "TemperatureField") {};
30✔
67

68
  //----------------------------------------------------------------------------
69
  // Methods
70

71
  //! Returns the temperature in Kelvin corresponding to the given position.
72
  //
73
  //! \param[in] r Position of the particle
74
  //! \return Temperature in Kelvin
75
  double get_temperature(const Position& r);
76

77
  //! Returns the square root of the temperature multiplied by the Boltzmann
78
  //! constant in eV for the given position.
79
  //
80
  //! \param[in] r Position of the particle
81
  //! \return Sqrt(k_Boltzmann * temperature) in eV
82
  double get_sqrtkT(const Position& r);
83

84
  //! Update the temperature of a particle based on its position and direction.
85
  //! If the particle is inside the temperature field, its temperature is
86
  //! updated. If outside, the particle takes the temperature value
87
  //! associated with the current cell instance.
88
  //
89
  //! \param[inout] p Particle
90
  void update_particle_temperature(Particle& p);
91
};
92

93
} //  namespace openmc
94
#endif // OPENMC_FIELD_H
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc