Skip to content

Commit

Permalink
Added extra safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ddement committed Mar 5, 2025
1 parent cae39c4 commit 3b66ccf
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/interfaces/cfd/interface_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ struct InterfaceBuilder {
}

InterfaceBuilder& SetTimeStep(double time_step) {
if (time_step < 0.) {
throw std::out_of_range("time_step must be positive");
}
interface_input.time_step = time_step;
return *this;
}

InterfaceBuilder& SetDampingFactor(double rho_inf) {
if (rho_inf < 0. || rho_inf > 1.) {
throw std::out_of_range("rho_inf must be in range [0., 1.]");
}
interface_input.rho_inf = rho_inf;
return *this;
}
Expand Down Expand Up @@ -61,11 +67,17 @@ struct InterfaceBuilder {
}

InterfaceBuilder& SetMooringLineStiffness(size_t line, double stiffness) {
if (stiffness < 0.) {
throw std::out_of_range("stiffness must be positive");
}
interface_input.turbine.floating_platform.mooring_lines.at(line).stiffness = stiffness;
return *this;
}

InterfaceBuilder& SetMooringLineUndeformedLength(size_t line, double length) {
if (length < 0.) {
throw std::out_of_range("undeformed length must be positive");
}
interface_input.turbine.floating_platform.mooring_lines.at(line).undeformed_length = length;
return *this;
}
Expand All @@ -90,11 +102,6 @@ struct InterfaceBuilder {
return *this;
}

InterfaceBuilder& SetTurbine(const TurbineInput& turbine_in) {
interface_input.turbine = turbine_in;
return *this;
}

[[nodiscard]] Interface Build() const { return Interface(interface_input); }

private:
Expand Down

0 comments on commit 3b66ccf

Please sign in to comment.