Skip to content

Commit 6678d97

Browse files
author
skywalker_cn
committed
refactor(CLSCell): Optimizing code structure and formatting adjustment
1 parent d3033e5 commit 6678d97

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

include/openmc/cell.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,12 @@ class CLSCell : public CSGCell {
424424
// Set the translation vector for the filled universe
425425
void set_translation(const vector<double>& trans) { translation_ = trans; }
426426
// Using base class methods without modifying
427+
using CSGCell::bounding_box;
428+
using CSGCell::contains;
427429
using CSGCell::distance;
430+
using CSGCell::is_simple;
428431
using CSGCell::surfaces;
429-
using CSGCell::contains;
430-
using CSGCell::bounding_box;
431432
using CSGCell::to_hdf5_inner;
432-
using CSGCell::is_simple;
433433

434434
private:
435435
Region region_;

src/cell.cpp

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -425,24 +425,26 @@ CLSCell::CLSCell()
425425
}
426426

427427
CLSCell::CLSCell(pugi::xml_node cell_node)
428-
: CSGCell(cell_node) // Initialize base Cell properties (id, material, etc.)
429-
{geom_type() = GeometryType::CLS;
430-
// --- Parse CLS-Specific Parameters ---
431-
auto dispersion_node = cell_node.child("dispersion");
432-
433-
// Boolean flag to enable/disable CLS for this cell
434-
bool is_dispersed = dispersion_node.attribute("enable").as_bool(false);
435-
436-
// Particle parameters (conditional parsing)
437-
if (is_dispersed) {
438-
particle_radius_ = dispersion_node.attribute("particle_radius").as_double();
439-
fill_ratio_ = dispersion_node.attribute("fill_ratio").as_double();
440-
441-
validate_parameters(); // Ensure 0 < fill_ratio < 1 and radius > 0
442-
}
428+
: CSGCell(cell_node) // Initialize base Cell properties (id, material, etc.)
429+
{
430+
geom_type() = GeometryType::CLS;
431+
// --- Parse CLS-Specific Parameters ---
432+
auto dispersion_node = cell_node.child("dispersion");
433+
434+
// Boolean flag to enable/disable CLS for this cell
435+
bool is_dispersed = dispersion_node.attribute("enable").as_bool(false);
436+
437+
// Particle parameters (conditional parsing)
438+
if (is_dispersed) {
439+
particle_radius_ = dispersion_node.attribute("particle_radius").as_double();
440+
fill_ratio_ = dispersion_node.attribute("fill_ratio").as_double();
441+
442+
validate_parameters(); // Ensure 0 < fill_ratio < 1 and radius > 0
443443
}
444+
}
444445

445-
void CLSCell::validate_parameters() const {
446+
void CLSCell::validate_parameters() const
447+
{
446448
// Check that fill_ratio is between 0 and 1
447449
if (fill_ratio_ <= 0 || fill_ratio_ >= 1) {
448450
throw std::runtime_error("CLSCell: fill_ratio must be beteween (0, 1)");
@@ -452,20 +454,12 @@ void CLSCell::validate_parameters() const {
452454
throw std::runtime_error("CLSCell: particle_radius must be positive");
453455
}
454456
// Check that the cell is filled with a sphere universe
455-
if (type_!= Fill::UNIVERSE){
456-
throw std::runtime_error("CLSCell: cell must be filled with a sphere universe");
457+
if (type_ != Fill::UNIVERSE) {
458+
throw std::runtime_error(
459+
"CLSCell: cell must be filled with a sphere universe");
457460
}
458461
}
459462

460-
461-
462-
463-
464-
465-
466-
467-
468-
469463
//==============================================================================
470464
// Region implementation
471465
//==============================================================================
@@ -1034,12 +1028,11 @@ void read_cells(pugi::xml_node node)
10341028
bool is_dispersed = dispersion_node;
10351029

10361030
if (is_dispersed) {
1037-
auto cell=make_unique<CLSCell>(cell_node);
1031+
auto cell = make_unique<CLSCell>(cell_node);
10381032
model::cells.push_back(std::move(cell));
10391033
} else {
10401034
model::cells.push_back(make_unique<CSGCell>(cell_node));
10411035
}
1042-
10431036
}
10441037

10451038
// Fill the cell map.

0 commit comments

Comments
 (0)