Skip to content

Commit 374ab6e

Browse files
authored
Merge pull request #3 from RyanDavies19/line_perf_improvement
docs: add disable output to the docs and options list
2 parents aaadbc8 + 327c2be commit 374ab6e

File tree

3 files changed

+79
-55
lines changed

3 files changed

+79
-55
lines changed

docs/inputs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ The list of possible options is:
595595
If this is enabled initial conditions are calculated with scaled drag according to CdScaleIC.
596596
The new stationary solver in MoorDyn-C is more stable and more precise than the dynamic solver,
597597
but it can take longer to reach equilibrium.
598+
- disableOutput (0): Disables some console and file outputs to improve runtime.
599+
- disableOutTime (0): Disables the printing of the current timestep to the console, useful for the MATLAB wrapper
598600

599601
A note about time steps in MoorDyn-C: The internal time step is first taken from the dtM option. If
600602
no CFL factor is provided, then the user provided time step is used to calculate CFL and MoorDyn-C
@@ -629,6 +631,8 @@ The following MoorDyn-C options are not supported by MoorDyn-F:
629631
- FricDamp: Same as CV in MoorDyn-F.
630632
- StatDynFricScale: Same as MC in MoorDyn-F.
631633
- ICgenDynamic: MoorDyn-F does not have a stationary solver for initial conditions
634+
- disableOutput: MoorDyn-F output verbosity is controlled by OpenFAST
635+
- disableOutTime: MoorDyn-F output verbosity is controlled by OpenFAST
632636

633637
The following options from MoorDyn-F are not supported by MoorDyn-C:
634638

source/MoorDyn2.cpp

Lines changed: 72 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ moordyn::MoorDyn::Step(const double* x,
641641
LOGDBG << "t = " << t << "s \r";
642642
std::cout << std::defaultfloat << setprecision(default_precision);
643643

644-
cout << "\rt = " << t << " " << flush;
644+
if (!disableOutTime) cout << "\rt = " << t << " " << flush;
645645
}
646646

647647
if (dt <= 0) {
@@ -2128,91 +2128,108 @@ moordyn::MoorDyn::readOptionsLine(vector<string>& in_txt, int i)
21282128

21292129
LOGDBG << "\t" << entries[1] << " = " << entries[0] << endl;
21302130
const string value = entries[0];
2131-
const string name = entries[1];
2131+
const string name = str::lower(entries[1]);
21322132

21332133
// DT is old way, should phase out
2134-
if ((name == "dtM") || (name == "DT"))
2135-
dtM0 = atof(entries[0].c_str());
2136-
else if ((name == "CFL") || (name == "cfl"))
2137-
cfl = atof(entries[0].c_str());
2138-
else if (name == "writeLog") {
2134+
if ((name == "dtm") || (name == "dt"))
2135+
dtM0 = atof(value.c_str());
2136+
else if (name == "cfl")
2137+
cfl = atof(value.c_str());
2138+
else if (name == "writelog") {
21392139
// This was actually already did, so we do not need to do that again
21402140
// But we really want to have this if to avoid showing a warning for
21412141
// Unrecognized option writeLog
2142-
// env->writeLog = atoi(entries[0].c_str());
2143-
} else if (name == "tScheme") {
2142+
// env->writeLog = atoi(value.c_str());
2143+
} else if (name == "tscheme") {
21442144
moordyn::error_id err = MOORDYN_SUCCESS;
21452145
string err_msg;
21462146
try {
2147-
_t_integrator = create_time_scheme(entries[0], _log, waves);
2147+
_t_integrator = create_time_scheme(value, _log, waves);
21482148
}
21492149
MOORDYN_CATCHER(err, err_msg);
21502150
if (err != MOORDYN_SUCCESS) {
21512151
LOGWRN << "Defaulting to RK2 time integration";
21522152
LOGERR << err_msg << endl;
21532153
}
21542154
} else if ((name == "g") || (name == "gravity"))
2155-
env->g = atof(entries[0].c_str());
2156-
else if ((name == "Rho") || (name == "rho") || (name == "WtrDnsty"))
2157-
env->rho_w = atof(entries[0].c_str());
2158-
else if (name == "WtrDpth")
2159-
env->WtrDpth = atof(entries[0].c_str());
2160-
else if ((name == "kBot") || (name == "kbot") || (name == "kb"))
2161-
env->kb = atof(entries[0].c_str());
2162-
else if ((name == "cBot") || (name == "cbot") || (name == "cb"))
2163-
env->cb = atof(entries[0].c_str());
2164-
else if ((name == "dtIC") || (name == "ICdt"))
2165-
ICdt = atof(entries[0].c_str());
2166-
else if ((name == "TmaxIC") || (name == "ICTmax"))
2167-
ICTmax = atof(entries[0].c_str());
2168-
else if ((name == "CdScaleIC") || (name == "ICDfac"))
2169-
ICDfac = atof(entries[0].c_str());
2170-
else if ((name == "threshIC") || (name == "ICthresh"))
2171-
ICthresh = atof(entries[0].c_str());
2172-
else if ((name == "genDynamicIC") || (name == "ICgenDynamic"))
2173-
ICgenDynamic = bool(atof(entries[0].c_str()));
2174-
else if ((name == "fileIC") || (name == "ICfile"))
2175-
ICfile = entries[0];
2176-
else if (name == "WaveKin") {
2177-
WaveKinTemp = (waves::waves_settings)stoi(entries[0]);
2155+
env->g = atof(value.c_str());
2156+
else if ((name == "rho") || (name == "wtrdnsty"))
2157+
env->rho_w = atof(value.c_str());
2158+
else if (name == "wtrdpth")
2159+
env->WtrDpth = atof(value.c_str());
2160+
else if ((name == "kbot") || (name == "kb"))
2161+
env->kb = atof(value.c_str());
2162+
else if ((name == "cbot") || (name == "cb"))
2163+
env->cb = atof(value.c_str());
2164+
else if ((name == "dtic") || (name == "icdt"))
2165+
ICdt = atof(value.c_str());
2166+
else if ((name == "tmaxic") || (name == "ictmax"))
2167+
ICTmax = atof(value.c_str());
2168+
else if ((name == "cdscaleic") || (name == "icdfac"))
2169+
ICDfac = atof(value.c_str());
2170+
else if ((name == "threshic") || (name == "icthresh"))
2171+
ICthresh = atof(value.c_str());
2172+
else if ((name == "gendynamicic") || (name == "icgendynamic"))
2173+
ICgenDynamic = bool(atof(value.c_str()));
2174+
else if ((name == "fileic") || (name == "icfile"))
2175+
ICfile = value;
2176+
else if (name == "wavekin") {
2177+
WaveKinTemp = (waves::waves_settings)stoi(value);
21782178
if ((WaveKinTemp < waves::WAVES_NONE) ||
21792179
(WaveKinTemp > waves::WAVES_SUM_COMPONENTS_NODE))
21802180
LOGWRN << "Unknown WaveKin option value " << WaveKinTemp << endl;
2181-
} else if (name == "dtWave")
2182-
env->waterKinOptions.dtWave = stof(entries[0]);
2183-
else if (name == "Currents") {
2184-
auto current_mode = (waves::currents_settings)stoi(entries[0]);
2181+
} else if (name == "dtwave")
2182+
env->waterKinOptions.dtWave = stof(value);
2183+
else if (name == "currents") {
2184+
auto current_mode = (waves::currents_settings)stoi(value);
21852185
env->waterKinOptions.currentMode = current_mode;
21862186
if ((current_mode < waves::CURRENTS_NONE) ||
21872187
(current_mode > waves::CURRENTS_4D))
21882188
LOGWRN << "Unknown Currents option value " << current_mode << endl;
2189-
} else if (name == "UnifyCurrentGrid") {
2190-
if (entries[0] == "1") {
2189+
} else if (name == "unifycurrentgrid") {
2190+
if (value == "1") {
21912191
env->waterKinOptions.unifyCurrentGrid = true;
2192-
} else if (entries[0] == "0") {
2192+
} else if (value == "0") {
21932193
env->waterKinOptions.unifyCurrentGrid = false;
21942194
} else {
21952195
LOGWRN << "Unrecognized UnifyCurrentGrid value "
2196-
<< std::quoted(entries[1]) << ". Should be 0 or 1" << endl;
2196+
<< std::quoted(value) << ". Should be 0 or 1" << endl;
21972197
}
2198-
} else if (name == "WriteUnits")
2199-
env->WriteUnits = atoi(entries[0].c_str());
2200-
else if (name == "FrictionCoefficient")
2201-
env->FrictionCoefficient = atof(entries[0].c_str());
2202-
else if (name == "FricDamp")
2203-
env->FricDamp = atof(entries[0].c_str());
2204-
else if (name == "StatDynFricScale")
2205-
env->StatDynFricScale = atof(entries[0].c_str());
2198+
} else if (name == "writeunits")
2199+
env->WriteUnits = atoi(value.c_str());
2200+
else if (name == "frictioncoefficient")
2201+
env->FrictionCoefficient = atof(value.c_str());
2202+
else if (name == "fricdamp")
2203+
env->FricDamp = atof(value.c_str());
2204+
else if (name == "statdynfricscale")
2205+
env->StatDynFricScale = atof(value.c_str());
22062206
// output writing period (0 for at every call)
2207-
else if (name == "dtOut")
2208-
dtOut = atof(entries[0].c_str());
2209-
else if (name == "SeafloorFile") {
2207+
else if (name == "dtout")
2208+
dtOut = atof(value.c_str());
2209+
else if (name == "seafloorfile") {
22102210
env->SeafloorMode = seafloor_settings::SEAFLOOR_3D;
22112211
this->seafloor = make_shared<moordyn::Seafloor>(_log);
2212-
std::string filepath = entries[0];
2212+
std::string filepath = value;
22132213
this->seafloor->setup(env, filepath);
2214-
}
2215-
else
2214+
} else if (name == "disableoutput"){
2215+
if (value == "1") {
2216+
disableOutput = true;
2217+
} else if (value == "0") {
2218+
disableOutput = false;
2219+
} else {
2220+
LOGWRN << "Unrecognized disableOutput value "
2221+
<< std::quoted(value) << ". Should be 0 or 1" << endl;
2222+
}
2223+
} else if (name == "disableouttime"){
2224+
if (value == "1") {
2225+
disableOutTime = true;
2226+
} else if (value == "0") {
2227+
disableOutTime = false;
2228+
} else {
2229+
LOGWRN << "Unrecognized disableOutTime value "
2230+
<< std::quoted(value) << ". Should be 0 or 1" << endl;
2231+
}
2232+
} else
22162233
LOGWRN << "Warning: Unrecognized option '" << name << "'" << endl;
22172234
}
22182235

source/MoorDyn2.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,9 @@ class MoorDyn final : public io::IO
640640
/// Disabled writing to output files or console when running
641641
bool disableOutput = false;
642642

643+
/// Disabledtime updates to console when running (for MATLAB wrapper)
644+
bool disableOutTime = false;
645+
643646
/// main output file
644647
ofstream outfileMain;
645648

0 commit comments

Comments
 (0)