feat(cpp-object-oriented-modular-refactoring): step 3 - foundation-google-style
This commit is contained in:
@@ -147,10 +147,10 @@ public:
|
||||
finalizeModel();
|
||||
}
|
||||
if (failure_) {
|
||||
return Result<Domain>::failure(Status::failure(
|
||||
return Result<Domain>::Failure(Status::Failure(
|
||||
failure_->category, {std::move(failure_->diagnostic)}));
|
||||
}
|
||||
sortDiagnostics(definition_.warnings);
|
||||
SortDiagnostics(definition_.warnings);
|
||||
return Domain::create(std::move(definition_));
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
if (!failure_) {
|
||||
failure_ = MappingFailure{
|
||||
category,
|
||||
{Severity::error,
|
||||
{Severity::kError,
|
||||
std::move(code),
|
||||
location,
|
||||
std::move(keyword),
|
||||
@@ -194,7 +194,7 @@ private:
|
||||
std::string entityIdentity,
|
||||
std::string message) {
|
||||
return fail(
|
||||
FailureCategory::input,
|
||||
FailureCategory::kInput,
|
||||
std::move(code),
|
||||
location,
|
||||
std::move(keyword),
|
||||
@@ -209,7 +209,7 @@ private:
|
||||
std::string entityIdentity,
|
||||
std::string message) {
|
||||
return fail(
|
||||
FailureCategory::model,
|
||||
FailureCategory::kModel,
|
||||
std::move(code),
|
||||
location,
|
||||
std::move(keyword),
|
||||
@@ -1677,7 +1677,7 @@ private:
|
||||
// One warning per allowlisted keyword keeps no-op provenance stable;
|
||||
// subordinate variable rows remain attached to that keyword record.
|
||||
definition_.warnings.push_back({
|
||||
Severity::warning,
|
||||
Severity::kWarning,
|
||||
"ignored-input-keyword",
|
||||
block.location,
|
||||
block.canonicalName,
|
||||
@@ -1781,15 +1781,15 @@ private:
|
||||
definition_.nodes,
|
||||
definition_.shellElements,
|
||||
definition_.shellSections);
|
||||
if (!geometry.hasValue()) {
|
||||
const auto& status = geometry.status();
|
||||
if (!geometry.HasValue()) {
|
||||
const auto& status = geometry.GetStatus();
|
||||
failure_ = MappingFailure{
|
||||
status.failureCategory().value_or(FailureCategory::model),
|
||||
status.diagnostics().front()};
|
||||
status.Category().value_or(FailureCategory::kModel),
|
||||
status.Diagnostics().front()};
|
||||
return;
|
||||
}
|
||||
definition_.shellNodeInitialFrames =
|
||||
std::move(geometry.value().nodalFrames);
|
||||
std::move(geometry.Value().nodalFrames);
|
||||
}
|
||||
expandAssemblySets();
|
||||
if (failure_) {
|
||||
@@ -2357,7 +2357,7 @@ private:
|
||||
for (std::size_t index = 0U;
|
||||
index < definition_.nodes.size();
|
||||
++index) {
|
||||
if (definition_.nodes[index].sourceId.sourceLabel == label) {
|
||||
if (definition_.nodes[index].sourceId.source_label == label) {
|
||||
matchingNodes.push_back(static_cast<EntityIndex>(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ Result<ParsedInput> failure(
|
||||
std::string keyword,
|
||||
std::string message) {
|
||||
Diagnostic diagnostic{
|
||||
Severity::error,
|
||||
Severity::kError,
|
||||
std::move(code),
|
||||
{sourcePath, line},
|
||||
std::move(keyword),
|
||||
"",
|
||||
std::move(message)};
|
||||
return Result<ParsedInput>::failure(Status::failure(
|
||||
FailureCategory::input, {std::move(diagnostic)}));
|
||||
return Result<ParsedInput>::Failure(Status::Failure(
|
||||
FailureCategory::kInput, {std::move(diagnostic)}));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -210,7 +210,7 @@ Result<ParsedInput> AbaqusInputReader::read(
|
||||
++lineNumber;
|
||||
}
|
||||
|
||||
return Result<ParsedInput>::success(std::move(parsed));
|
||||
return Result<ParsedInput>::Success(std::move(parsed));
|
||||
}
|
||||
|
||||
} // namespace fesa
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "fesa/io/hdf5/hdf5_results_writer.hpp"
|
||||
|
||||
#include "fesa/analysis/analysis_model.hpp"
|
||||
#include "fesa/build_info.hpp"
|
||||
#include "fesa/build_info.h"
|
||||
#include "fesa/fem/dof_manager.hpp"
|
||||
|
||||
#include <hdf5.h>
|
||||
@@ -153,9 +153,9 @@ hid_t requireHdf5Id(const hid_t result, const char* message) {
|
||||
}
|
||||
|
||||
Status outputFailure(const std::string& code, const std::string& message) {
|
||||
return Status::failure(
|
||||
FailureCategory::output,
|
||||
{{Severity::error, code, {}, "", "", message}});
|
||||
return Status::Failure(
|
||||
FailureCategory::kOutput,
|
||||
{{Severity::kError, code, {}, "", "", message}});
|
||||
}
|
||||
|
||||
bool isFinite(const std::array<double, 3>& values) {
|
||||
@@ -217,9 +217,9 @@ bool isValidUtf8(const std::string& value) {
|
||||
}
|
||||
|
||||
bool sameIdentity(const SourceEntityId& left, const SourceEntityId& right) {
|
||||
return left.instanceName == right.instanceName &&
|
||||
left.sourceLabel == right.sourceLabel &&
|
||||
left.sourceLabelText == right.sourceLabelText;
|
||||
return left.instance_name == right.instance_name &&
|
||||
left.source_label == right.source_label &&
|
||||
left.source_label_text == right.source_label_text;
|
||||
}
|
||||
|
||||
using AxisSet = std::array<double, 9>;
|
||||
@@ -346,10 +346,10 @@ Status validateShellWriterInput(
|
||||
for (const auto& element : domain.shellElements()) {
|
||||
if ((element.sourceType != ShellSourceElementType::s4 &&
|
||||
element.sourceType != ShellSourceElementType::s4r) ||
|
||||
element.sourceId.sourceLabel <= 0 ||
|
||||
element.sourceId.sourceLabelText.empty() ||
|
||||
!isValidUtf8(element.sourceId.instanceName) ||
|
||||
!isValidUtf8(element.sourceId.sourceLabelText) ||
|
||||
element.sourceId.source_label <= 0 ||
|
||||
element.sourceId.source_label_text.empty() ||
|
||||
!isValidUtf8(element.sourceId.instance_name) ||
|
||||
!isValidUtf8(element.sourceId.source_label_text) ||
|
||||
element.materialIndex >= domain.materials().size() ||
|
||||
element.sectionIndex >= domain.shellSections().size() ||
|
||||
domain.shellSections()[element.sectionIndex].materialIndex !=
|
||||
@@ -444,7 +444,7 @@ Status validateShellWriterInput(
|
||||
"invalid-result-rows",
|
||||
"Shell energy, equilibrium, and verification metrics must be finite.");
|
||||
}
|
||||
return Status::ok();
|
||||
return Status::Ok();
|
||||
}
|
||||
|
||||
Status validateWriterInput(
|
||||
@@ -467,7 +467,7 @@ Status validateWriterInput(
|
||||
const bool shell = isShellDomain(domain);
|
||||
if (shell) {
|
||||
const Status shellValidation = validateShellWriterInput(domain, state);
|
||||
if (!shellValidation.isOk()) {
|
||||
if (!shellValidation.IsOk()) {
|
||||
return shellValidation;
|
||||
}
|
||||
} else if (!state.shellResults().empty()) {
|
||||
@@ -488,12 +488,12 @@ Status validateWriterInput(
|
||||
&state.residual(),
|
||||
&state.reaction()};
|
||||
for (const Vector* vector : vectors) {
|
||||
if (vector->size() != fullDofCount) {
|
||||
if (vector->Size() != fullDofCount) {
|
||||
return outputFailure(
|
||||
"invalid-result-state",
|
||||
"Every V0 analysis vector must have node_count*6 values.");
|
||||
}
|
||||
for (std::size_t index = 0U; index < vector->size(); ++index) {
|
||||
for (std::size_t index = 0U; index < vector->Size(); ++index) {
|
||||
if (!std::isfinite((*vector)[index])) {
|
||||
return outputFailure(
|
||||
"invalid-result-state",
|
||||
@@ -509,10 +509,10 @@ Status validateWriterInput(
|
||||
"Source path and UTF-8 content identity are required.");
|
||||
}
|
||||
for (const Node& node : domain.nodes()) {
|
||||
if (node.sourceId.sourceLabel <= 0 ||
|
||||
node.sourceId.sourceLabelText.empty() ||
|
||||
!isValidUtf8(node.sourceId.instanceName) ||
|
||||
!isValidUtf8(node.sourceId.sourceLabelText) ||
|
||||
if (node.sourceId.source_label <= 0 ||
|
||||
node.sourceId.source_label_text.empty() ||
|
||||
!isValidUtf8(node.sourceId.instance_name) ||
|
||||
!isValidUtf8(node.sourceId.source_label_text) ||
|
||||
!isFinite(node.coordinates)) {
|
||||
return outputFailure(
|
||||
"invalid-result-identity",
|
||||
@@ -524,10 +524,10 @@ Status validateWriterInput(
|
||||
modelData.beamLocalAxes.reserve(domain.elements().size());
|
||||
for (const EulerBeam3DDefinition& element : domain.elements()) {
|
||||
AxisSet axes{};
|
||||
if (element.sourceId.sourceLabel <= 0 ||
|
||||
element.sourceId.sourceLabelText.empty() ||
|
||||
!isValidUtf8(element.sourceId.instanceName) ||
|
||||
!isValidUtf8(element.sourceId.sourceLabelText) ||
|
||||
if (element.sourceId.source_label <= 0 ||
|
||||
element.sourceId.source_label_text.empty() ||
|
||||
!isValidUtf8(element.sourceId.instance_name) ||
|
||||
!isValidUtf8(element.sourceId.source_label_text) ||
|
||||
element.nodeIndices[0U] == element.nodeIndices[1U] ||
|
||||
element.materialIndex >= domain.materials().size() ||
|
||||
!computeLocalAxes(domain, element, axes)) {
|
||||
@@ -626,7 +626,7 @@ Status validateWriterInput(
|
||||
for (const Diagnostic& diagnostic : diagnostics) {
|
||||
if (!isValidUtf8(diagnostic.code) ||
|
||||
!isValidUtf8(diagnostic.keyword) ||
|
||||
!isValidUtf8(diagnostic.entityIdentity) ||
|
||||
!isValidUtf8(diagnostic.entity_identity) ||
|
||||
!isValidUtf8(diagnostic.message)) {
|
||||
return outputFailure(
|
||||
"invalid-result-diagnostic",
|
||||
@@ -636,23 +636,23 @@ Status validateWriterInput(
|
||||
|
||||
|
||||
auto analysisModelResult = AnalysisModel::create(domain);
|
||||
if (!analysisModelResult.hasValue()) {
|
||||
if (!analysisModelResult.HasValue()) {
|
||||
return outputFailure(
|
||||
"invalid-result-state",
|
||||
"The HDF5 writer could not reconstruct the active model view.");
|
||||
}
|
||||
const AnalysisModel analysisModel =
|
||||
std::move(analysisModelResult.value());
|
||||
std::move(analysisModelResult.Value());
|
||||
auto dofResult = DofManager::create(analysisModel);
|
||||
if (!dofResult.hasValue()) {
|
||||
if (!dofResult.HasValue()) {
|
||||
return outputFailure(
|
||||
"invalid-result-state",
|
||||
"The HDF5 writer could not reconstruct stable constraint identity.");
|
||||
}
|
||||
const DofManager dofs = std::move(dofResult.value());
|
||||
const DofManager dofs = std::move(dofResult.Value());
|
||||
modelData.constraintMask.assign(fullDofCount, 0U);
|
||||
modelData.prescribedDisplacement.assign(fullDofCount, 0.0);
|
||||
if (dofs.constrainedDofs().size() != dofs.prescribedValues().size()) {
|
||||
if (dofs.constrainedDofs().size() != dofs.prescribedValues().Size()) {
|
||||
return outputFailure(
|
||||
"invalid-result-state",
|
||||
"Constraint identities and prescribed values have inconsistent sizes.");
|
||||
@@ -670,7 +670,7 @@ Status validateWriterInput(
|
||||
modelData.constraintMask[fullDof] = 1U;
|
||||
modelData.prescribedDisplacement[fullDof] = prescribed;
|
||||
}
|
||||
return Status::ok();
|
||||
return Status::Ok();
|
||||
}
|
||||
|
||||
std::string normalizedPathString(const std::filesystem::path& path) {
|
||||
@@ -948,7 +948,7 @@ void writeMetadata(const hid_t file, const Domain& domain) {
|
||||
auto metadata = createGroup(file, "/metadata");
|
||||
writeUint64Attribute(metadata.get(), "schema_version", 0U);
|
||||
writeStringAttribute(
|
||||
metadata.get(), "solver_version", std::string{solverVersion()});
|
||||
metadata.get(), "solver_version", std::string{SolverVersion()});
|
||||
writeStringAttribute(
|
||||
metadata.get(), "source_input_identity", sourceInputIdentity(domain));
|
||||
writeStringAttribute(
|
||||
@@ -987,8 +987,8 @@ void writeNodes(const hid_t file, const Domain& domain) {
|
||||
const Node& node = domain.nodes()[index];
|
||||
rows.push_back({
|
||||
static_cast<std::uint64_t>(index),
|
||||
node.sourceId.instanceName.c_str(),
|
||||
node.sourceId.sourceLabelText.c_str(),
|
||||
node.sourceId.instance_name.c_str(),
|
||||
node.sourceId.source_label_text.c_str(),
|
||||
{node.coordinates[0U], node.coordinates[1U], node.coordinates[2U]}});
|
||||
}
|
||||
|
||||
@@ -1062,8 +1062,8 @@ void writeBeamElements(
|
||||
const auto& element = domain.elements()[index];
|
||||
ElementWriteRow row{
|
||||
static_cast<std::uint64_t>(index),
|
||||
element.sourceId.instanceName.c_str(),
|
||||
element.sourceId.sourceLabelText.c_str(),
|
||||
element.sourceId.instance_name.c_str(),
|
||||
element.sourceId.source_label_text.c_str(),
|
||||
{static_cast<std::uint64_t>(element.nodeIndices[0U]),
|
||||
static_cast<std::uint64_t>(element.nodeIndices[1U])},
|
||||
{}};
|
||||
@@ -1146,8 +1146,8 @@ void writeShellElements(const hid_t file, const Domain& domain) {
|
||||
const auto& element = domain.shellElements()[index];
|
||||
rows.push_back({
|
||||
static_cast<std::uint64_t>(index),
|
||||
element.sourceId.instanceName.c_str(),
|
||||
element.sourceId.sourceLabelText.c_str(),
|
||||
element.sourceId.instance_name.c_str(),
|
||||
element.sourceId.source_label_text.c_str(),
|
||||
shellSourceTypeName(element.sourceType),
|
||||
kMitc4InternalFormulation.data(),
|
||||
{static_cast<std::uint64_t>(element.nodeIndices[0U]),
|
||||
@@ -1660,7 +1660,7 @@ void writeShellResultDatasets(
|
||||
void writeDiagnostics(
|
||||
const hid_t file, const std::vector<Diagnostic>& inputDiagnostics) {
|
||||
std::vector<Diagnostic> diagnostics = inputDiagnostics;
|
||||
sortDiagnostics(diagnostics);
|
||||
SortDiagnostics(diagnostics);
|
||||
std::vector<std::string> files;
|
||||
files.reserve(diagnostics.size());
|
||||
for (const auto& diagnostic : diagnostics) {
|
||||
@@ -1671,12 +1671,12 @@ void writeDiagnostics(
|
||||
for (std::size_t index = 0U; index < diagnostics.size(); ++index) {
|
||||
const auto& diagnostic = diagnostics[index];
|
||||
rows.push_back({
|
||||
diagnostic.severity == Severity::warning ? "warning" : "error",
|
||||
diagnostic.severity == Severity::kWarning ? "warning" : "error",
|
||||
diagnostic.code.c_str(),
|
||||
files[index].c_str(),
|
||||
static_cast<std::uint64_t>(diagnostic.location.line),
|
||||
diagnostic.keyword.c_str(),
|
||||
diagnostic.entityIdentity.c_str(),
|
||||
diagnostic.entity_identity.c_str(),
|
||||
diagnostic.message.c_str()});
|
||||
}
|
||||
|
||||
@@ -1735,8 +1735,8 @@ void writeResultDatasets(
|
||||
file,
|
||||
std::string{kStepRoot} + "/nodal/displacement",
|
||||
nodalDimensions,
|
||||
state.displacement().data(),
|
||||
state.displacement().size(),
|
||||
state.displacement().Data(),
|
||||
state.displacement().Size(),
|
||||
"UX,UY,UZ,URX,URY,URZ",
|
||||
"length,length,length,radian,radian,radian",
|
||||
"global-cartesian",
|
||||
@@ -1745,8 +1745,8 @@ void writeResultDatasets(
|
||||
file,
|
||||
std::string{kStepRoot} + "/nodal/reaction",
|
||||
nodalDimensions,
|
||||
state.reaction().data(),
|
||||
state.reaction().size(),
|
||||
state.reaction().Data(),
|
||||
state.reaction().Size(),
|
||||
"RF1,RF2,RF3,RM1,RM2,RM3",
|
||||
"force,force,force,force*length,force*length,force*length",
|
||||
"global-cartesian",
|
||||
@@ -2253,7 +2253,7 @@ void selfCheckFile(
|
||||
H5Gclose};
|
||||
requireUint64Attribute(metadata.get(), "schema_version", 0U);
|
||||
requireStringAttribute(
|
||||
metadata.get(), "solver_version", std::string{solverVersion()});
|
||||
metadata.get(), "solver_version", std::string{SolverVersion()});
|
||||
requireStringAttribute(
|
||||
metadata.get(), "source_input_identity", sourceInputIdentity(domain));
|
||||
requireStringAttribute(
|
||||
@@ -2572,7 +2572,7 @@ Status Hdf5ResultsWriter::write(
|
||||
try {
|
||||
const Status validation = validateWriterInput(
|
||||
outputPath, domain, state, diagnostics, modelData);
|
||||
if (!validation.isOk()) {
|
||||
if (!validation.IsOk()) {
|
||||
return validation;
|
||||
}
|
||||
|
||||
@@ -2590,7 +2590,7 @@ Status Hdf5ResultsWriter::write(
|
||||
"The checked temporary HDF5 file could not replace the final output.");
|
||||
}
|
||||
cleanup.release();
|
||||
return Status::ok();
|
||||
return Status::Ok();
|
||||
} catch (const Hdf5Failure& failure) {
|
||||
return outputFailure("hdf5-write-failure", failure.what());
|
||||
} catch (const std::exception& failure) {
|
||||
|
||||
Reference in New Issue
Block a user