20#include <fhsim_environment/hydrodynamics/PanelLoadLaw.h>
21#include <fhsim_environment/hydrodynamics/PanelLoadLawSetup.h>
22#include "NetElement3NForces.h"
23#include "NetElementDef.h"
24#include <fhsim_environment/hydrodynamics/NetSolidity.h>
27#include <fhsim/ISimObjectLogger.h>
28#include <fhsim/simobject/ISimObjectCreator.h>
35namespace net_panel_setup
41 hydrodynamics::PanelLoadLaw
law;
54inline PanelHydrodynamics ReadPanelHydrodynamics(ISimObjectCreator* creator,
const std::string& structureName)
56 PanelHydrodynamics hydrodynamics {hydrodynamics::ReadPanelLoadLaw(creator), hydrodynamics::ReadFluid(creator)};
57 if (!hydrodynamics::Accepts(hydrodynamics.law, net_element_forces::kFlowReference)) {
58 const std::string message =
"The HydroModel does not accept the free-stream velocity that " + structureName +
" supplies.";
59 creator->ReportParameterError(
"HydroModel", message);
60 throw std::invalid_argument(message);
75inline net_solidity::PanelSolidity ReadSolidityRule(ISimObjectCreator* creator,
double& solidityParameter)
77 net_solidity::PanelSolidity rule;
78 std::string modelName;
79 creator->GetStringParam(
"SolidityModel", modelName,
"MeshOpening");
80 if (!net_solidity::ParseSolidityModel(modelName, rule.model)) {
81 const std::string message =
"Unknown SolidityModel \"" + modelName +
"\"; expected Fixed or MeshOpening.";
82 creator->ReportParameterError(
"SolidityModel", message);
83 throw std::invalid_argument(message);
85 creator->GetDoubleParam(
"KnotFactor", &rule.knotFactor, net_solidity::kDefaultKnotFactor);
86 creator->GetDoubleParam(
"Solidity", &solidityParameter, 0.0);
87 if (!(rule.knotFactor > 0.0)) {
88 const std::string message =
"KnotFactor must be positive, not " + std::to_string(rule.knotFactor) +
"; the mesh opening solidity would be negative.";
89 creator->ReportParameterError(
"KnotFactor", message);
90 throw std::invalid_argument(message);
92 if (!(solidityParameter >= 0.0 && solidityParameter < 1.0)) {
93 const std::string message =
"Solidity must be in (0, 1), or absent, not " + std::to_string(solidityParameter) +
".";
94 creator->ReportParameterError(
"Solidity", message);
95 throw std::invalid_argument(message);
111inline net_solidity::PanelSolidity ElementSolidityRule(
const net_solidity::PanelSolidity& rule,
112 double solidityParameter,
const NetElementDef& panel,
int element, ISimObjectCreator* creator)
114 net_solidity::PanelSolidity elementRule = rule;
115 if (elementRule.model != net_solidity::SolidityModel::Fixed) {
118 const bool fromSn = panel.
solidity > 0;
119 elementRule.fixed = fromSn ? panel.
solidity : solidityParameter;
120 if (!(elementRule.fixed > 0 && elementRule.fixed < 1)) {
121 const std::string element1 =
"element " + std::to_string(element + 1);
122 const std::string found = fromSn ? element1 +
" has Sn = " + std::to_string(elementRule.fixed) +
", outside (0, 1)."
123 : (solidityParameter > 0 ? element1 +
" has no Sn, and Solidity = " + std::to_string(solidityParameter) +
" is outside (0, 1)."
124 : element1 +
" has neither.");
125 const std::string message =
"SolidityModel Fixed needs the Solidity parameter or an Sn attribute in (0, 1) on every net element; " + found;
126 creator->ReportParameterError(
"Solidity", message);
127 throw std::invalid_argument(message);
144inline void RequireBarDirections(
bool hasBarDirections,
int element, ISimObjectCreator* creator)
146 if (hasBarDirections) {
149 const std::string message =
"Net panel " + std::to_string(element + 1) +
" has collinear mesh coordinates (zero mesh determinant), so it has no bar directions; every HydroModel needs them.";
150 creator->ReportParameterError(
"HydroModel", message);
151 throw std::invalid_argument(message);
160inline void WarnIfSolidityOutsideFitRange(
const hydrodynamics::PanelLoadLaw& law,
161 std::vector<double> solidities, ISimObjectLogger& logger)
163 std::sort(solidities.begin(), solidities.end());
164 solidities.erase(std::unique(solidities.begin(), solidities.end()), solidities.end());
165 for (
const double solidity : solidities)
166 hydrodynamics::WarnIfOutsideFitRange(law, solidity, logger);
176inline void WarnIfSolidityExtremesOutsideFitRange(
const hydrodynamics::PanelLoadLaw& law,
177 const std::vector<double>& solidities, ISimObjectLogger& logger)
179 if (solidities.empty()) {
182 const auto extremes = std::minmax_element(solidities.begin(), solidities.end());
183 WarnIfSolidityOutsideFitRange(law, {*extremes.first, *extremes.second}, logger);
196inline void WarnIfLegacyDampingRatio(
double dampingRatio, ISimObjectLogger& logger)
198 constexpr double kLargestUsualRatio = 2.0;
199 if (dampingRatio <= kLargestUsualRatio) {
202 std::ostringstream message;
203 message <<
"Warning: NetDampingRatio = " << dampingRatio
204 <<
". Its meaning changed in fhsim_marine_elements 3.1.4: it now is the damping ratio of the panel's stiffest stretch mode (1 = critical), "
205 "so values above 2 overdamp the net and shorten the time step. Inputs written for the old meaning (often 5) should use 1.";
206 logger.LogInfo(message.str());
Class containing the description of a net panel and methods necessary for taking this over to triangu...
Definition NetElementDef.h:24
double solidity
The net file's optional Sn attribute, for SolidityModel Fixed; 0 when absent. Refinement copies it to...
Definition NetElementDef.h:35
The panel load law and the fluid shared by all panels of a structure.
Definition NetPanelSetup.h:40
hydrodynamics::Fluid fluid
From Rho and Nu.
Definition NetPanelSetup.h:42
hydrodynamics::PanelLoadLaw law
From HydroModel and the law's parameters.
Definition NetPanelSetup.h:41