feat(nonlinear-static-newton-raphson): step 0 - cli-output-lease-and-derived-names
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "fesa/analysis/analysis.h"
|
||||
#include "fesa/analysis/linear_static_analysis.h"
|
||||
#include "fesa/app/output_paths.h"
|
||||
#include "fesa/assembly/parallel_for.h"
|
||||
#include "fesa/core/diagnostic.h"
|
||||
#include "fesa/io/hdf5/hdf5_results_writer.h"
|
||||
@@ -23,19 +24,6 @@ constexpr int kModelExitCode = 4;
|
||||
constexpr int kSolverExitCode = 5;
|
||||
constexpr int kOutputExitCode = 6;
|
||||
|
||||
bool StartsWithOption(const std::string& argument) {
|
||||
return !argument.empty() && argument.front() == '-';
|
||||
}
|
||||
|
||||
Diagnostic UsageDiagnostic() {
|
||||
return {Severity::kError,
|
||||
"cli-usage",
|
||||
{{}, 0U},
|
||||
"",
|
||||
"",
|
||||
"Usage: fesa.exe <model.inp> [--output <results.h5>]."};
|
||||
}
|
||||
|
||||
const char* SeverityName(const Severity severity) {
|
||||
return severity == Severity::kWarning ? "warning" : "error";
|
||||
}
|
||||
@@ -72,23 +60,23 @@ int ExitCodeFor(const Status& status) {
|
||||
} // namespace
|
||||
|
||||
int FesaApplication::Run(const std::vector<std::string>& arguments) {
|
||||
const bool default_output_form = arguments.size() == 1U &&
|
||||
!arguments[0U].empty() &&
|
||||
!StartsWithOption(arguments[0U]);
|
||||
const bool explicit_output_form =
|
||||
arguments.size() == 3U && !arguments[0U].empty() &&
|
||||
!StartsWithOption(arguments[0U]) && arguments[1U] == "--output" &&
|
||||
!arguments[2U].empty() && !StartsWithOption(arguments[2U]);
|
||||
if (!default_output_form && !explicit_output_form) {
|
||||
WriteDiagnostics({UsageDiagnostic()});
|
||||
const auto paths = DeriveSingleInputOutputPaths(
|
||||
arguments, std::filesystem::current_path());
|
||||
if (!paths.HasValue()) {
|
||||
WriteDiagnostics(paths.GetStatus().Diagnostics());
|
||||
return kUsageExitCode;
|
||||
}
|
||||
|
||||
auto lease = AcquireOutputWriteLease(paths.Value());
|
||||
if (!lease.HasValue()) {
|
||||
WriteDiagnostics(lease.GetStatus().Diagnostics());
|
||||
return kOutputExitCode;
|
||||
}
|
||||
|
||||
AnalysisRequest request;
|
||||
request.input_path = arguments[0U];
|
||||
request.output_path = explicit_output_form
|
||||
? std::filesystem::path{arguments[2U]}
|
||||
: std::filesystem::current_path() / "results.h5";
|
||||
request.input_path = paths.Value().input_path;
|
||||
request.output_path = paths.Value().results_path;
|
||||
request.log_path = paths.Value().log_path;
|
||||
|
||||
TbbParallelFor parallel_for;
|
||||
MklPardisoSolver linear_solver;
|
||||
|
||||
Reference in New Issue
Block a user