mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Remove the old Surface::bc_ attribute
This commit is contained in:
parent
2fa449de5a
commit
593a4addcf
4 changed files with 29 additions and 55 deletions
|
|
@ -9,12 +9,6 @@ namespace openmc {
|
|||
// Global variables
|
||||
//==============================================================================
|
||||
|
||||
//class BoundaryCondition;
|
||||
//
|
||||
//namespace model {
|
||||
// extern std::vector<std::unique_ptr<BoundaryCondition>> boundary_conditions;
|
||||
//} // namespace model
|
||||
|
||||
class Particle;
|
||||
class Surface;
|
||||
|
||||
|
|
@ -23,6 +17,8 @@ class BoundaryCondition
|
|||
public:
|
||||
virtual void
|
||||
handle_particle(Particle& p, const Surface& surf) const = 0;
|
||||
|
||||
virtual std::string type() const = 0;
|
||||
};
|
||||
|
||||
class VacuumBC : public BoundaryCondition
|
||||
|
|
@ -30,6 +26,8 @@ class VacuumBC : public BoundaryCondition
|
|||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "vacuum";}
|
||||
};
|
||||
|
||||
class ReflectiveBC : public BoundaryCondition
|
||||
|
|
@ -37,6 +35,8 @@ class ReflectiveBC : public BoundaryCondition
|
|||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "reflective";}
|
||||
};
|
||||
|
||||
class WhiteBC : public BoundaryCondition
|
||||
|
|
@ -44,6 +44,8 @@ class WhiteBC : public BoundaryCondition
|
|||
public:
|
||||
void
|
||||
handle_particle(Particle& p, const Surface& surf) const override;
|
||||
|
||||
std::string type() const override {return "white";}
|
||||
};
|
||||
|
||||
class PeriodicBC : public BoundaryCondition
|
||||
|
|
@ -53,6 +55,8 @@ public:
|
|||
: i_surf_(i_surf), j_surf_(j_surf)
|
||||
{};
|
||||
|
||||
std::string type() const override {return "periodic";}
|
||||
|
||||
protected:
|
||||
int i_surf_;
|
||||
int j_surf_;
|
||||
|
|
|
|||
|
|
@ -85,19 +85,9 @@ class Surface
|
|||
{
|
||||
public:
|
||||
|
||||
// Types of available boundary conditions on a surface
|
||||
enum class BoundaryType {
|
||||
TRANSMIT,
|
||||
VACUUM,
|
||||
REFLECT,
|
||||
PERIODIC,
|
||||
WHITE
|
||||
};
|
||||
|
||||
int id_; //!< Unique ID
|
||||
BoundaryType bc_; //!< Boundary condition
|
||||
std::shared_ptr<BoundaryCondition> new_bc_ {nullptr};
|
||||
std::string name_; //!< User-defined name
|
||||
int id_; //!< Unique ID
|
||||
std::string name_; //!< User-defined name
|
||||
std::shared_ptr<BoundaryCondition> bc_ {nullptr}; //!< Boundary condition
|
||||
|
||||
explicit Surface(pugi::xml_node surf_node);
|
||||
Surface();
|
||||
|
|
|
|||
|
|
@ -414,8 +414,8 @@ Particle::cross_surface()
|
|||
}
|
||||
|
||||
// Handle any applicable boundary conditions.
|
||||
if (surf->new_bc_ && settings::run_mode != RunMode::PLOTTING) {
|
||||
surf->new_bc_->handle_particle(*this, *surf);
|
||||
if (surf->bc_ && settings::run_mode != RunMode::PLOTTING) {
|
||||
surf->bc_->handle_particle(*this, *surf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,28 +126,20 @@ Surface::Surface(pugi::xml_node surf_node)
|
|||
std::string surf_bc = get_node_value(surf_node, "boundary", true, true);
|
||||
|
||||
if (surf_bc == "transmission" || surf_bc == "transmit" ||surf_bc.empty()) {
|
||||
bc_ = BoundaryType::TRANSMIT;
|
||||
|
||||
// Leave the bc_ a nullptr
|
||||
} else if (surf_bc == "vacuum") {
|
||||
bc_ = BoundaryType::VACUUM;
|
||||
new_bc_ = std::make_shared<VacuumBC>();
|
||||
|
||||
bc_ = std::make_shared<VacuumBC>();
|
||||
} else if (surf_bc == "reflective" || surf_bc == "reflect"
|
||||
|| surf_bc == "reflecting") {
|
||||
bc_ = BoundaryType::REFLECT;
|
||||
new_bc_ = std::make_shared<ReflectiveBC>();
|
||||
bc_ = std::make_shared<ReflectiveBC>();
|
||||
} else if (surf_bc == "white") {
|
||||
bc_ = BoundaryType::WHITE;
|
||||
new_bc_ = std::make_shared<WhiteBC>();
|
||||
bc_ = std::make_shared<WhiteBC>();
|
||||
} else if (surf_bc == "periodic") {
|
||||
bc_ = BoundaryType::PERIODIC;
|
||||
// periodic BC's are handled separately
|
||||
} else {
|
||||
fatal_error(fmt::format("Unknown boundary condition \"{}\" specified "
|
||||
"on surface {}", surf_bc, id_));
|
||||
}
|
||||
|
||||
} else {
|
||||
bc_ = BoundaryType::TRANSMIT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -212,22 +204,10 @@ CSGSurface::to_hdf5(hid_t group_id) const
|
|||
|
||||
hid_t surf_group = create_group(group_id, group_name);
|
||||
|
||||
switch(bc_) {
|
||||
case BoundaryType::TRANSMIT :
|
||||
write_string(surf_group, "boundary_type", "transmission", false);
|
||||
break;
|
||||
case BoundaryType::VACUUM :
|
||||
write_string(surf_group, "boundary_type", "vacuum", false);
|
||||
break;
|
||||
case BoundaryType::REFLECT :
|
||||
write_string(surf_group, "boundary_type", "reflective", false);
|
||||
break;
|
||||
case BoundaryType::WHITE :
|
||||
write_string(surf_group, "boundary_type", "white", false);
|
||||
break;
|
||||
case BoundaryType::PERIODIC :
|
||||
write_string(surf_group, "boundary_type", "periodic", false);
|
||||
break;
|
||||
if (bc_) {
|
||||
write_string(surf_group, "boundary_type", bc_->type(), false);
|
||||
} else {
|
||||
write_string(surf_group, "boundary_type", "transmission", false);
|
||||
}
|
||||
|
||||
if (!name_.empty()) {
|
||||
|
|
@ -1173,11 +1153,11 @@ void read_surfaces(pugi::xml_node node)
|
|||
double dot_prod = norm1.dot(norm2);
|
||||
|
||||
if (std::abs(1.0 - dot_prod) < FP_PRECISION) {
|
||||
surf1.new_bc_ = std::make_shared<TranslationalPeriodicBC>(i_surf, j_surf);
|
||||
surf2.new_bc_ = surf1.new_bc_;
|
||||
surf1.bc_ = std::make_shared<TranslationalPeriodicBC>(i_surf, j_surf);
|
||||
surf2.bc_ = surf1.bc_;
|
||||
} else {
|
||||
surf1.new_bc_ = std::make_shared<RotationalPeriodicBC>(i_surf, j_surf);
|
||||
surf2.new_bc_ = surf1.new_bc_;
|
||||
surf1.bc_ = std::make_shared<RotationalPeriodicBC>(i_surf, j_surf);
|
||||
surf2.bc_ = surf1.bc_;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1185,7 +1165,7 @@ void read_surfaces(pugi::xml_node node)
|
|||
// surface
|
||||
bool boundary_exists = false;
|
||||
for (const auto& surf : model::surfaces) {
|
||||
if (surf->bc_ != Surface::BoundaryType::TRANSMIT) {
|
||||
if (surf->bc_) {
|
||||
boundary_exists = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue