Skip to content

Commit

Permalink
Merge branch 'main' of github.com:milliCoulomb/tetraSN
Browse files Browse the repository at this point in the history
  • Loading branch information
milliCoulomb committed Jan 5, 2025
2 parents c08c1dc + 771849e commit f70204f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 49 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ solver_parameters:
max_power_iterations: 500
rays_per_face: 10
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "../examples/cube/output/flux.dat"
Expand Down
4 changes: 2 additions & 2 deletions examples/cow/cow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ solver_parameters:
max_power_iterations: 5000
rays_per_face: 10
max_ray_length: 1000
use_half_hemisphere: false

output:
flux_output_file: "../examples/cow/output/flux.txt"
k_eff_output_file: "../examples/cow/output/k_eff.txt"

logging:
level: "ERROR"
log_file: "logs/solver.log"
level: "ERROR"
4 changes: 2 additions & 2 deletions examples/cube/cube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ solver_parameters:
max_power_iterations: 300
rays_per_face: 10
max_ray_length: 1000
use_half_hemisphere: false

output:
flux_output_file: "../examples/cube/output/flux.txt"
k_eff_output_file: "../examples/cube/output/k_eff.txt"

logging:
level: "RUNNING"
log_file: "logs/solver.log"
level: "RUNNING"
31 changes: 0 additions & 31 deletions examples/cylinder/cylinder.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/sphere/sphere.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ solver_parameters:
max_power_iterations: 500
rays_per_face: 8
max_ray_length: 5000
use_half_hemisphere: false

output:
flux_output_file: "../examples/sphere/output/flux.txt"
k_eff_output_file: "../examples/sphere/output/k_eff.txt"

logging:
level: "ERROR"
log_file: "logs/solver.log"
level: "ERROR"
2 changes: 1 addition & 1 deletion include/InputDeck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct SolverParameters {
int max_power_iterations;
int rays_per_face;
int max_ray_length;
bool use_half_hemisphere; // use only the upper hemisphere for ray tracing and symmetrize afterwards
};

// Structure to hold output settings
Expand All @@ -45,7 +46,6 @@ struct OutputSettings {
// Structure to hold logging settings
struct LoggingSettings {
std::string level;
std::string log_file;
};

// Main structure to hold the entire input deck
Expand Down
2 changes: 1 addition & 1 deletion src/InputDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ InputDeck InputDeckParser::parse(const std::string& filename) {
deck.solver_parameters.max_power_iterations = sp_node["max_power_iterations"].as<int>();
deck.solver_parameters.rays_per_face = sp_node["rays_per_face"].as<int>();
deck.solver_parameters.max_ray_length = sp_node["max_ray_length"].as<int>();
deck.solver_parameters.use_half_hemisphere = sp_node["use_half_hemisphere"].as<bool>();

// Parse output settings
YAML::Node out_node = config["output"];
Expand All @@ -57,7 +58,6 @@ InputDeck InputDeckParser::parse(const std::string& filename) {
YAML::Node log_node = config["logging"];
if (!log_node) throw std::runtime_error("Missing 'logging' section in YAML.");
deck.logging.level = log_node["level"].as<std::string>();
deck.logging.log_file = log_node["log_file"].as<std::string>();

} catch (const YAML::Exception& e) {
std::cerr << "YAML Parsing Error: " << e.what() << std::endl;
Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, char* argv[]) {
Field field;

bool constant_dir_bool = true;
bool use_half_quadrature_for_constant = false;
bool use_half_quadrature_for_constant = input_deck.solver_parameters.use_half_hemisphere;

// Initialize RayTracerManager and generate tracking data
RayTracerManager ray_tracer_manager(mesh_handler, field, angular_quadrature, constant_dir_bool,
Expand All @@ -76,6 +76,10 @@ int main(int argc, char* argv[]) {
int rays_per_face = input_deck.solver_parameters.rays_per_face;
int max_ray_length = input_deck.solver_parameters.max_ray_length;
ray_tracer_manager.generateTrackingData(rays_per_face, max_ray_length);
if (use_half_quadrature_for_constant) {
Logger::info("Using only the upper hemisphere for ray tracing, symmetrizing afterwards.");
ray_tracer_manager.doubleTrackingDataByReversing();
}

Logger::running("Tracking data generated.");

Expand Down
17 changes: 8 additions & 9 deletions tests/test_InputDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ TEST(InputDeckTest, ParseValidInputDeck) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -88,7 +88,6 @@ TEST(InputDeckTest, ParseValidInputDeck) {

// Verify logging settings
EXPECT_EQ(deck.logging.level, "INFO");
EXPECT_EQ(deck.logging.log_file, "logs/solver.log");

// Clean up
std::remove(filename.c_str());
Expand Down Expand Up @@ -116,14 +115,14 @@ TEST(InputDeckTest, ParseMissingMeshSection) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -158,14 +157,14 @@ TEST(InputDeckTest, ParseMissingCrossSectionsSection) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -204,14 +203,14 @@ TEST(InputDeckTest, ParseInvalidAngularQuadratureData) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -246,7 +245,6 @@ TEST(InputDeckTest, ParseMissingSolverParametersSection) {
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -285,14 +283,14 @@ TEST(InputDeckTest, ParseInvalidSolverParametersValues) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -331,10 +329,10 @@ TEST(InputDeckTest, ParseMissingOutputSection) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
logging:
level: "INFO"
log_file: "logs/solver.log"
)";

ASSERT_TRUE(createTempYAML(filename, yaml_content)) << "Failed to create temporary YAML file.";
Expand Down Expand Up @@ -373,6 +371,7 @@ TEST(InputDeckTest, ParseMissingLoggingSection) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
Expand Down Expand Up @@ -458,14 +457,14 @@ TEST(InputDeckTest, ParseWithExtraSections) {
max_power_iterations: 100
rays_per_face: 8
max_ray_length: 1000
use_half_hemisphere: false
output:
flux_output_file: "output/flux.dat"
k_eff_output_file: "output/k_eff.dat"
logging:
level: "INFO"
log_file: "logs/solver.log"
extra_section:
key: "value"
Expand Down

0 comments on commit f70204f

Please sign in to comment.