feat(cpp-object-oriented-modular-refactoring): step 3 - foundation-google-style
This commit is contained in:
@@ -71,9 +71,9 @@ private:
|
||||
|
||||
Status comparisonFailureStatus(
|
||||
const std::string& code, const std::string& message) {
|
||||
return Status::failure(
|
||||
FailureCategory::model,
|
||||
{{Severity::error, code, {}, "", kModelId, message}});
|
||||
return Status::Failure(
|
||||
FailureCategory::kModel,
|
||||
{{Severity::kError, code, {}, "", kModelId, message}});
|
||||
}
|
||||
|
||||
std::string trim(const std::string& value) {
|
||||
@@ -256,17 +256,17 @@ void requireExactArtifactInventory(
|
||||
Domain readApprovedDomain(const std::filesystem::path& inputPath) {
|
||||
AbaqusInputReader reader;
|
||||
auto parsed = reader.read(inputPath);
|
||||
if (!parsed.hasValue()) {
|
||||
if (!parsed.HasValue()) {
|
||||
fail("needs-reference-artifacts", "The approved reference input cannot be parsed.");
|
||||
}
|
||||
AbaqusDomainMapper mapper;
|
||||
auto domain = mapper.map(parsed.value());
|
||||
if (!domain.hasValue()) {
|
||||
auto domain = mapper.map(parsed.Value());
|
||||
if (!domain.HasValue()) {
|
||||
fail(
|
||||
"needs-reference-artifacts",
|
||||
"The approved reference input is not the required B33 model.");
|
||||
}
|
||||
return std::move(domain.value());
|
||||
return std::move(domain.Value());
|
||||
}
|
||||
|
||||
class Hdf5Handle {
|
||||
@@ -878,9 +878,9 @@ HdfProjection readHdfProjection(
|
||||
const auto& actual = projection.nodes[node];
|
||||
const auto& expected = domain.nodes()[node];
|
||||
if (actual.internalNodeId != node ||
|
||||
actual.instanceName != expected.sourceId.instanceName ||
|
||||
actual.sourceNodeLabel != expected.sourceId.sourceLabel ||
|
||||
actual.sourceNodeLabelText != expected.sourceId.sourceLabelText ||
|
||||
actual.instanceName != expected.sourceId.instance_name ||
|
||||
actual.sourceNodeLabel != expected.sourceId.source_label ||
|
||||
actual.sourceNodeLabelText != expected.sourceId.source_label_text ||
|
||||
actual.coordinates != expected.coordinates) {
|
||||
fail("schema-mismatch", "An HDF5 node identity does not match the input.");
|
||||
}
|
||||
@@ -889,9 +889,9 @@ HdfProjection readHdfProjection(
|
||||
const auto& actual = projection.elements[element];
|
||||
const auto& expected = domain.elements()[element];
|
||||
if (actual.internalElementId != element ||
|
||||
actual.instanceName != expected.sourceId.instanceName ||
|
||||
actual.sourceElementLabel != expected.sourceId.sourceLabel ||
|
||||
actual.sourceElementLabelText != expected.sourceId.sourceLabelText ||
|
||||
actual.instanceName != expected.sourceId.instance_name ||
|
||||
actual.sourceElementLabel != expected.sourceId.source_label ||
|
||||
actual.sourceElementLabelText != expected.sourceId.source_label_text ||
|
||||
actual.nodeInternalIds[0U] != expected.nodeIndices[0U] ||
|
||||
actual.nodeInternalIds[1U] != expected.nodeIndices[1U]) {
|
||||
fail("schema-mismatch", "An HDF5 element identity does not match the input.");
|
||||
@@ -963,10 +963,10 @@ std::vector<NodeStationResultRow> normalizeStations(
|
||||
const HdfProjection& hdf,
|
||||
const ReferenceTable& sectionTable) {
|
||||
auto modelResult = AnalysisModel::create(domain);
|
||||
if (!modelResult.hasValue()) {
|
||||
if (!modelResult.HasValue()) {
|
||||
fail("schema-mismatch", "The approved input cannot create an analysis view.");
|
||||
}
|
||||
const AnalysisModel model = std::move(modelResult.value());
|
||||
const AnalysisModel model = std::move(modelResult.Value());
|
||||
const std::array<double, 4> tolerances = {
|
||||
kForceMomentFloor + kRelativeCoefficient * tableScale(sectionTable, 0U),
|
||||
kForceMomentFloor + kRelativeCoefficient * tableScale(sectionTable, 3U),
|
||||
@@ -993,15 +993,15 @@ std::vector<NodeStationResultRow> normalizeStations(
|
||||
}
|
||||
auto normalized = ResultRecovery::normalizeSectionResultantsToNodeStations(
|
||||
model, endpoints, tolerances);
|
||||
if (!normalized.hasValue()) {
|
||||
const auto& diagnostics = normalized.status().diagnostics();
|
||||
if (!normalized.HasValue()) {
|
||||
const auto& diagnostics = normalized.GetStatus().Diagnostics();
|
||||
const std::string code = diagnostics.empty() ? std::string{} : diagnostics[0U].code;
|
||||
if (code == "node-station-tolerance-failure") {
|
||||
fail("tolerance-failure", "Interior endpoint section resultants disagree.");
|
||||
}
|
||||
fail("schema-mismatch", "A node station is not eligible for legacy projection.");
|
||||
}
|
||||
return std::move(normalized.value());
|
||||
return std::move(normalized.Value());
|
||||
}
|
||||
|
||||
const NodeStationResultRow& findStation(
|
||||
@@ -1009,8 +1009,8 @@ const NodeStationResultRow& findStation(
|
||||
const HdfNode& node) {
|
||||
const auto found = std::find_if(
|
||||
stations.begin(), stations.end(), [&](const NodeStationResultRow& row) {
|
||||
return row.node.instanceName == node.instanceName &&
|
||||
row.node.sourceLabel == node.sourceNodeLabel;
|
||||
return row.node.instance_name == node.instanceName &&
|
||||
row.node.source_label == node.sourceNodeLabel;
|
||||
});
|
||||
if (found == stations.end()) {
|
||||
fail("schema-mismatch", "A projected HDF5 node station is missing.");
|
||||
@@ -1165,21 +1165,21 @@ PhysicsEvidence makePhysicsEvidence(
|
||||
const Domain& domain,
|
||||
const HdfProjection& hdf) {
|
||||
auto modelResult = AnalysisModel::create(domain);
|
||||
if (!modelResult.hasValue()) {
|
||||
if (!modelResult.HasValue()) {
|
||||
fail("schema-mismatch", "The approved input cannot create physics evidence.");
|
||||
}
|
||||
const AnalysisModel model = std::move(modelResult.value());
|
||||
const AnalysisModel model = std::move(modelResult.Value());
|
||||
auto dofsResult = DofManager::create(model);
|
||||
if (!dofsResult.hasValue()) {
|
||||
if (!dofsResult.HasValue()) {
|
||||
fail("schema-mismatch", "The approved input cannot create a DOF map.");
|
||||
}
|
||||
const DofManager dofs = std::move(dofsResult.value());
|
||||
const DofManager dofs = std::move(dofsResult.Value());
|
||||
auto loadResult = LoadAssembler::assembleFullNodalLoad(model, dofs);
|
||||
if (!loadResult.hasValue()) {
|
||||
if (!loadResult.HasValue()) {
|
||||
fail("schema-mismatch", "The approved input load cannot be assembled.");
|
||||
}
|
||||
const Vector load = std::move(loadResult.value());
|
||||
if (load.size() != hdf.reaction.size()) {
|
||||
const Vector load = std::move(loadResult.Value());
|
||||
if (load.Size() != hdf.reaction.size()) {
|
||||
fail("schema-mismatch", "The load and reaction spaces are inconsistent.");
|
||||
}
|
||||
|
||||
@@ -1407,12 +1407,12 @@ Result<ComparisonReport> ReferenceComparison::compare(
|
||||
report.stressComparisonReason =
|
||||
"Abaqus beam stress comparison is N/A; analytical/unit and HDF5 "
|
||||
"schema tests provide stress evidence.";
|
||||
return Result<ComparisonReport>::success(std::move(report));
|
||||
return Result<ComparisonReport>::Success(std::move(report));
|
||||
} catch (const ComparisonFailure& failure) {
|
||||
return Result<ComparisonReport>::failure(
|
||||
return Result<ComparisonReport>::Failure(
|
||||
comparisonFailureStatus(failure.code(), failure.what()));
|
||||
} catch (const std::exception& failure) {
|
||||
return Result<ComparisonReport>::failure(comparisonFailureStatus(
|
||||
return Result<ComparisonReport>::Failure(comparisonFailureStatus(
|
||||
"schema-mismatch", failure.what()));
|
||||
}
|
||||
}
|
||||
@@ -1422,9 +1422,9 @@ Status ReferenceComparison::writeDeterministicJson(
|
||||
const std::filesystem::path& outputJson) {
|
||||
if (outputJson.empty() || outputJson.filename().empty() ||
|
||||
!finiteReport(report)) {
|
||||
return Status::failure(
|
||||
FailureCategory::output,
|
||||
{{Severity::error,
|
||||
return Status::Failure(
|
||||
FailureCategory::kOutput,
|
||||
{{Severity::kError,
|
||||
"comparison-json-write-failure",
|
||||
{},
|
||||
"",
|
||||
@@ -1433,9 +1433,9 @@ Status ReferenceComparison::writeDeterministicJson(
|
||||
}
|
||||
std::ofstream stream{outputJson, std::ios::binary | std::ios::trunc};
|
||||
if (!stream) {
|
||||
return Status::failure(
|
||||
FailureCategory::output,
|
||||
{{Severity::error,
|
||||
return Status::Failure(
|
||||
FailureCategory::kOutput,
|
||||
{{Severity::kError,
|
||||
"comparison-json-write-failure",
|
||||
{},
|
||||
"",
|
||||
@@ -1495,16 +1495,16 @@ Status ReferenceComparison::writeDeterministicJson(
|
||||
writeJsonString(stream, report.stressComparisonReason);
|
||||
stream << ",\"passed\":" << (report.passed ? "true" : "false") << "}\n";
|
||||
if (!stream) {
|
||||
return Status::failure(
|
||||
FailureCategory::output,
|
||||
{{Severity::error,
|
||||
return Status::Failure(
|
||||
FailureCategory::kOutput,
|
||||
{{Severity::kError,
|
||||
"comparison-json-write-failure",
|
||||
{},
|
||||
"",
|
||||
kModelId,
|
||||
"The deterministic comparison JSON write failed."}});
|
||||
}
|
||||
return Status::ok();
|
||||
return Status::Ok();
|
||||
}
|
||||
|
||||
} // namespace fesa::test
|
||||
|
||||
Reference in New Issue
Block a user