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

openmc-dev / openmc / 25930342666

15 May 2026 04:56PM UTC coverage: 81.414% (+0.09%) from 81.324%
25930342666

Pull #3734

github

web-flow
Merge 0af48acaf into d56cda254
Pull Request #3734: Specify temperature from a field (structured mesh only)

17919 of 25855 branches covered (69.31%)

Branch coverage included in aggregate %.

275 of 305 new or added lines in 18 files covered. (90.16%)

1321 existing lines in 29 files now uncovered.

58986 of 68607 relevant lines covered (85.98%)

47884537.9 hits per line

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

61.29
/src/field.cpp
1
#include "openmc/field.h"
2
#include "openmc/cell.h"
3
#include "openmc/constants.h"
4
#include "openmc/mesh.h"
5
#include "openmc/simulation.h"
6
#include "openmc/vector.h"
7

8
namespace openmc {
9

10
ScalarField::ScalarField(
101✔
11
  Mesh* mesh_ptr, vector<double> values, const std::string& field_type)
101✔
12
{
13
  this->field_type_ = field_type;
101✔
14

15
  if (mesh_ptr != nullptr) {
101!
16
    this->mesh_ptr_ = mesh_ptr;
101✔
17
  } else {
NEW
18
    fatal_error(fmt::format("No mesh found for {}!", field_type));
×
19
  }
20

21
  if (this->mesh_ptr_->n_bins() != values.size()) {
101!
NEW
22
    fatal_error(
×
NEW
23
      fmt::format("The number of bins in the mesh is not consistent with the "
×
24
                  "number of values declared in {}!",
25
        field_type));
26
  }
27

28
  for (double v : values) {
909✔
29
    this->values_.push_back(v);
808✔
30
  }
31
}
101✔
32

33
double ScalarField::distance_to_next_boundary(
5,372,081✔
34
  int current_bin, const Position& r, const Direction& u, int& bin_next)
35
{
36
  return this->mesh_ptr()->distance_to_next_boundary(
5,372,081✔
37
    current_bin, r, u, bin_next);
5,372,081✔
38
}
39

40
double TemperatureField::get_temperature(int bin)
1,476,200✔
41
{
42
  if (bin >= 0 && bin < values().size()) {
1,476,200!
43
    return this->value(bin);
1,476,189✔
44
  }
45
  return -1.0;
46
}
47

48
double TemperatureField::get_sqrtkT(int bin)
1,476,134✔
49
{
50
  double temperature = get_temperature(bin);
1,476,134✔
51
  if (temperature >= 0) {
1,476,134!
52
    return sqrt(temperature * K_BOLTZMANN);
1,476,134✔
53
  }
54
  return -1.0;
55
}
56

57
int TemperatureField::get_bin(const Position& r)
677,402✔
58
{
59
  int bin = mesh_ptr()->get_bin(r);
677,402✔
60
  if (bin >= 0 && bin < values().size()) {
677,402!
61
    return bin;
62
  } else {
63
    return C_NONE;
232,221✔
64
  }
65
}
66

67
//==============================================================================
68
// C API
69
//==============================================================================
70

NEW
71
extern "C" int openmc_temperature_field_set_temperature(
×
72
  int32_t index, double temperature)
73
{
NEW
74
  if (index < 0 || index >= simulation::temperature_field.values().size()) {
×
NEW
75
    set_errmsg("Index in temperature field is out of bounds.");
×
NEW
76
    return OPENMC_E_OUT_OF_BOUNDS;
×
77
  }
78

NEW
79
  simulation::temperature_field.value(index) = temperature;
×
NEW
80
  return 0;
×
81
}
82

83
} // namespace openmc
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