mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Apply clang-format on entire source
This commit is contained in:
parent
4c17061a1d
commit
1bc2bd8460
181 changed files with 7372 additions and 6952 deletions
|
|
@ -13,14 +13,12 @@
|
|||
#include "openmc/string_utils.h"
|
||||
#include "openmc/surface.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
|
||||
namespace model {
|
||||
|
||||
int root_universe {-1};
|
||||
|
|
@ -65,17 +63,21 @@ bool check_cell_overlap(Particle& p, bool error)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
int cell_instance_at_level(const Particle& p, int level) {
|
||||
int cell_instance_at_level(const Particle& p, int level)
|
||||
{
|
||||
// throw error if the requested level is too deep for the geometry
|
||||
if (level > model::n_coord_levels) {
|
||||
fatal_error(fmt::format("Cell instance at level {} requested, but only {} levels exist in the geometry.", level, p.n_coord()));
|
||||
fatal_error(fmt::format("Cell instance at level {} requested, but only {} "
|
||||
"levels exist in the geometry.",
|
||||
level, p.n_coord()));
|
||||
}
|
||||
|
||||
// determine the cell instance
|
||||
Cell& c {*model::cells[p.coord(level).cell]};
|
||||
|
||||
// quick exit if this cell doesn't have distribcell instances
|
||||
if (c.distribcell_index_ == C_NONE) return C_NONE;
|
||||
if (c.distribcell_index_ == C_NONE)
|
||||
return C_NONE;
|
||||
|
||||
// compute the cell's instance
|
||||
int instance = 0;
|
||||
|
|
@ -96,8 +98,7 @@ int cell_instance_at_level(const Particle& p, int level) {
|
|||
|
||||
//==============================================================================
|
||||
|
||||
bool
|
||||
find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
||||
bool find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
||||
{
|
||||
// Find which cell of this universe the particle is in. Use the neighbor list
|
||||
// to shorten the search if one was provided.
|
||||
|
|
@ -109,7 +110,8 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
|
||||
// Make sure the search cell is in the same universe.
|
||||
int i_universe = p.coord(p.n_coord() - 1).universe;
|
||||
if (model::cells[i_cell]->universe_ != i_universe) continue;
|
||||
if (model::cells[i_cell]->universe_ != i_universe)
|
||||
continue;
|
||||
|
||||
// Check if this cell contains the particle.
|
||||
Position r {p.r_local()};
|
||||
|
|
@ -132,7 +134,7 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
}
|
||||
|
||||
// Check successively lower coordinate levels until finding material fill
|
||||
for (;;++p.n_coord()) {
|
||||
for (;; ++p.n_coord()) {
|
||||
// If we did not attempt to use neighbor lists, i_cell is still C_NONE. In
|
||||
// that case, we should now do an exhaustive search to find the right value
|
||||
// of i_cell.
|
||||
|
|
@ -147,7 +149,9 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list)
|
|||
found = univ->find_cell(p);
|
||||
}
|
||||
|
||||
if (!found) { return found; }
|
||||
if (!found) {
|
||||
return found;
|
||||
}
|
||||
i_cell = p.coord(p.n_coord() - 1).cell;
|
||||
|
||||
// Announce the cell that the particle is entering.
|
||||
|
|
@ -299,16 +303,17 @@ bool exhaustive_find_cell(Particle& p)
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void
|
||||
cross_lattice(Particle& p, const BoundaryInfo& boundary)
|
||||
void cross_lattice(Particle& p, const BoundaryInfo& boundary)
|
||||
{
|
||||
auto& coord {p.coord(p.n_coord() - 1)};
|
||||
auto& lat {*model::lattices[coord.lattice]};
|
||||
|
||||
if (settings::verbosity >= 10 || p.trace()) {
|
||||
write_message(fmt::format(
|
||||
" Crossing lattice {}. Current position ({},{},{}). r={}",
|
||||
lat.id_, coord.lattice_i[0], coord.lattice_i[1], coord.lattice_i[2], p.r()), 1);
|
||||
write_message(
|
||||
fmt::format(" Crossing lattice {}. Current position ({},{},{}). r={}",
|
||||
lat.id_, coord.lattice_i[0], coord.lattice_i[1], coord.lattice_i[2],
|
||||
p.r()),
|
||||
1);
|
||||
}
|
||||
|
||||
// Set the lattice indices.
|
||||
|
|
@ -380,23 +385,23 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
// Find the distance to the next lattice tile crossing.
|
||||
if (coord.lattice != C_NONE) {
|
||||
auto& lat {*model::lattices[coord.lattice]};
|
||||
//TODO: refactor so both lattice use the same position argument (which
|
||||
//also means the lat.type attribute can be removed)
|
||||
// TODO: refactor so both lattice use the same position argument (which
|
||||
// also means the lat.type attribute can be removed)
|
||||
std::pair<double, array<int, 3>> lattice_distance;
|
||||
switch (lat.type_) {
|
||||
case LatticeType::rect:
|
||||
lattice_distance = lat.distance(r, u, coord.lattice_i);
|
||||
break;
|
||||
case LatticeType::hex:
|
||||
auto& cell_above {model::cells[p.coord(i - 1).cell]};
|
||||
Position r_hex {p.coord(i - 1).r};
|
||||
r_hex -= cell_above->translation_;
|
||||
if (coord.rotated) {
|
||||
r_hex = r_hex.rotate(cell_above->rotation_);
|
||||
}
|
||||
r_hex.z = coord.r.z;
|
||||
lattice_distance = lat.distance(r_hex, u, coord.lattice_i);
|
||||
break;
|
||||
case LatticeType::rect:
|
||||
lattice_distance = lat.distance(r, u, coord.lattice_i);
|
||||
break;
|
||||
case LatticeType::hex:
|
||||
auto& cell_above {model::cells[p.coord(i - 1).cell]};
|
||||
Position r_hex {p.coord(i - 1).r};
|
||||
r_hex -= cell_above->translation_;
|
||||
if (coord.rotated) {
|
||||
r_hex = r_hex.rotate(cell_above->rotation_);
|
||||
}
|
||||
r_hex.z = coord.r.z;
|
||||
lattice_distance = lat.distance(r_hex, u, coord.lattice_i);
|
||||
break;
|
||||
}
|
||||
d_lat = lattice_distance.first;
|
||||
level_lat_trans = lattice_distance.second;
|
||||
|
|
@ -412,7 +417,7 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
// is selected. This logic must consider floating point precision.
|
||||
double& d = info.distance;
|
||||
if (d_surf < d_lat - FP_COINCIDENT) {
|
||||
if (d == INFINITY || (d - d_surf)/d >= FP_REL_PRECISION) {
|
||||
if (d == INFINITY || (d - d_surf) / d >= FP_REL_PRECISION) {
|
||||
d = d_surf;
|
||||
|
||||
// If the cell is not simple, it is possible that both the negative and
|
||||
|
|
@ -423,7 +428,7 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
info.surface_index = level_surf_cross;
|
||||
} else {
|
||||
Position r_hit = r + d_surf * u;
|
||||
Surface& surf {*model::surfaces[std::abs(level_surf_cross)-1]};
|
||||
Surface& surf {*model::surfaces[std::abs(level_surf_cross) - 1]};
|
||||
Direction norm = surf.normal(r_hit);
|
||||
if (u.dot(norm) > 0) {
|
||||
info.surface_index = std::abs(level_surf_cross);
|
||||
|
|
@ -438,7 +443,7 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
info.coord_level = i + 1;
|
||||
}
|
||||
} else {
|
||||
if (d == INFINITY || (d - d_lat)/d >= FP_REL_PRECISION) {
|
||||
if (d == INFINITY || (d - d_lat) / d >= FP_REL_PRECISION) {
|
||||
d = d_lat;
|
||||
info.surface_index = 0;
|
||||
info.lattice_translation = level_lat_trans;
|
||||
|
|
@ -453,12 +458,12 @@ BoundaryInfo distance_to_boundary(Particle& p)
|
|||
// C API
|
||||
//==============================================================================
|
||||
|
||||
extern "C" int
|
||||
openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance)
|
||||
extern "C" int openmc_find_cell(
|
||||
const double* xyz, int32_t* index, int32_t* instance)
|
||||
{
|
||||
Particle p;
|
||||
|
||||
p.r() = Position{xyz};
|
||||
p.r() = Position {xyz};
|
||||
p.u() = {0.0, 0.0, 1.0};
|
||||
|
||||
if (!exhaustive_find_cell(p)) {
|
||||
|
|
@ -471,7 +476,8 @@ openmc_find_cell(const double* xyz, int32_t* index, int32_t* instance)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int openmc_global_bounding_box(double* llc, double* urc) {
|
||||
extern "C" int openmc_global_bounding_box(double* llc, double* urc)
|
||||
{
|
||||
auto bbox = model::universes.at(model::root_universe)->bounding_box();
|
||||
|
||||
// set lower left corner values
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue