feat(cpp-object-oriented-modular-refactoring): step 3 - foundation-google-style

This commit is contained in:
KOKO\Mimi
2026-08-16 04:26:14 +09:00
parent 2628ed3488
commit 042edadffb
93 changed files with 3144 additions and 3175 deletions
+68 -68
View File
@@ -34,9 +34,9 @@ Status recoveryFailure(const std::string& code,
const SourceLocation& location,
const std::string& identity,
const std::string& message) {
return Status::failure(
FailureCategory::model,
{{Severity::error,
return Status::Failure(
FailureCategory::kModel,
{{Severity::kError,
code,
location,
"RESULT_RECOVERY",
@@ -49,15 +49,15 @@ Result<T> recoveryResultFailure(const std::string& code,
const SourceLocation& location,
const std::string& identity,
const std::string& message) {
return Result<T>::failure(
return Result<T>::Failure(
recoveryFailure(code, location, identity, message));
}
bool sameSourceIdentity(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;
}
template<std::size_t Size>
@@ -68,7 +68,7 @@ bool finite(const std::array<double, Size>& values) {
}
bool finite(const Vector& values) {
for (std::size_t index = 0U; index < values.size(); ++index) {
for (std::size_t index = 0U; index < values.Size(); ++index) {
if (!std::isfinite(values[index])) {
return false;
}
@@ -99,12 +99,12 @@ std::array<double, 2> freeEquationInternalTermNorms(
for (const std::size_t row : dofs.freeDofs()) {
double freeTerm = 0.0;
double constrainedTerm = 0.0;
for (std::size_t position = stiffness.rowOffsets()[row];
position < stiffness.rowOffsets()[row + 1U];
for (std::size_t position = stiffness.RowOffsets()[row];
position < stiffness.RowOffsets()[row + 1U];
++position) {
const std::size_t column = stiffness.columnIndices()[position];
const std::size_t column = stiffness.ColumnIndices()[position];
const double contribution =
stiffness.values()[position] * displacement[column];
stiffness.Values()[position] * displacement[column];
if (freeColumn[column] != 0U) {
freeTerm += contribution;
} else {
@@ -141,21 +141,21 @@ Status validateRecoveryInputs(const AnalysisModel& model,
}
const std::size_t fullCount = domain.nodes().size() * kDofsPerNode;
if (dofs.fullDofCount() != fullCount ||
fullStiffness.rows() != fullCount ||
fullStiffness.columns() != fullCount ||
state.displacement().size() != fullCount ||
state.externalForce().size() != fullCount ||
state.internalForce().size() != fullCount ||
state.residual().size() != fullCount ||
state.reaction().size() != fullCount) {
fullStiffness.Rows() != fullCount ||
fullStiffness.Columns() != fullCount ||
state.displacement().Size() != fullCount ||
state.externalForce().Size() != fullCount ||
state.internalForce().Size() != fullCount ||
state.residual().Size() != fullCount ||
state.reaction().Size() != fullCount) {
return recoveryFailure(
"invalid-recovery-dimensions",
{domain.sourcePath(), 0U},
domain.sourceContentIdentity(),
"Model, DOF, stiffness, and AnalysisState full-space dimensions must agree.");
}
const Status matrixStatus = fullStiffness.validate();
if (!matrixStatus.isOk()) {
const Status matrixStatus = fullStiffness.Validate();
if (!matrixStatus.IsOk()) {
return matrixStatus;
}
if (!finite(state.displacement()) || !finite(state.externalForce())) {
@@ -170,7 +170,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
const auto& constrainedDofs = dofs.constrainedDofs();
if (freeDofs.size() != dofs.freeDofCount() ||
constrainedDofs.size() != dofs.constrainedDofCount() ||
dofs.prescribedValues().size() != constrainedDofs.size() ||
dofs.prescribedValues().Size() != constrainedDofs.size() ||
freeDofs.size() + constrainedDofs.size() != fullCount ||
!strictlyIncreasing(freeDofs) ||
!strictlyIncreasing(constrainedDofs)) {
@@ -253,7 +253,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Active beam references must resolve before recovery.");
}
try {
@@ -271,7 +271,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-order",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Element scatter must preserve endpoint/component full-DOF order.");
}
}
@@ -280,7 +280,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Every active element requires one twelve-DOF scatter map.");
}
}
@@ -310,7 +310,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Active shell material and section references must resolve before recovery.");
}
try {
@@ -324,7 +324,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Active shell node references must resolve before recovery.");
}
for (std::size_t component = 0U;
@@ -339,7 +339,7 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-order",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Shell scatter must preserve node/component full-DOF order.");
}
}
@@ -348,11 +348,11 @@ Status validateRecoveryInputs(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Every active shell requires one twenty-four-DOF scatter map.");
}
}
return Status::ok();
return Status::Ok();
}
char asciiLower(const char value) {
@@ -390,7 +390,7 @@ Result<std::vector<EntityIndex>> resolveLoadTarget(const Domain& domain,
std::int64_t sourceLabel = 0;
if (tryPositiveInteger(load.target, sourceLabel)) {
for (std::size_t node = 0U; node < domain.nodes().size(); ++node) {
if (domain.nodes()[node].sourceId.sourceLabel == sourceLabel) {
if (domain.nodes()[node].sourceId.source_label == sourceLabel) {
nodes.push_back(static_cast<EntityIndex>(node));
}
}
@@ -415,11 +415,11 @@ Result<std::vector<EntityIndex>> resolveLoadTarget(const Domain& domain,
}
seen[node] = 1U;
}
return Result<std::vector<EntityIndex>>::success(
return Result<std::vector<EntityIndex>>::Success(
sets.front()->nodeIndices);
}
if (!nodes.empty()) {
return Result<std::vector<EntityIndex>>::success(std::move(nodes));
return Result<std::vector<EntityIndex>>::Success(std::move(nodes));
}
return recoveryResultFailure<std::vector<EntityIndex>>(
"invalid-node-station-entity",
@@ -542,7 +542,7 @@ Status populateShellGlobalEvidence(
return recoveryFailure(
"nonfinite-recovery-value",
domain.nodes()[node].location,
domain.nodes()[node].sourceId.sourceLabelText,
domain.nodes()[node].sourceId.source_label_text,
"Global force and moment evidence must remain finite in source-node order.");
}
}
@@ -581,7 +581,7 @@ Status populateShellGlobalEvidence(
"global-equilibrium",
"Normalized global force or moment balance exceeds 1e-10.");
}
return Status::ok();
return Status::Ok();
}
std::optional<AxisSet> localAxes(const Domain& domain,
@@ -646,11 +646,11 @@ Status ResultRecovery::recover(const AnalysisModel& model,
AnalysisState& state) {
const Status inputStatus =
validateRecoveryInputs(model, dofs, fullStiffness, state);
if (!inputStatus.isOk()) {
if (!inputStatus.IsOk()) {
return inputStatus;
}
Vector internalForce = fullStiffness.multiply(state.displacement());
Vector internalForce = fullStiffness.Multiply(state.displacement());
if (!finite(internalForce)) {
return recoveryFailure(
"nonfinite-recovery-value",
@@ -659,7 +659,7 @@ Status ResultRecovery::recover(const AnalysisModel& model,
"Full stiffness multiplication must produce finite internal force.");
}
Vector residual{dofs.fullDofCount()};
for (std::size_t fullDof = 0U; fullDof < residual.size(); ++fullDof) {
for (std::size_t fullDof = 0U; fullDof < residual.Size(); ++fullDof) {
residual[fullDof] =
internalForce[fullDof] - state.externalForce()[fullDof];
if (!std::isfinite(residual[fullDof])) {
@@ -722,8 +722,8 @@ Status ResultRecovery::recover(const AnalysisModel& model,
domain.nodes()[definition.nodeIndices[1U]],
domain.sections()[definition.sectionIndex],
domain.materials()[definition.materialIndex]);
if (!beam.hasValue()) {
return beam.status();
if (!beam.HasValue()) {
return beam.GetStatus();
}
Vector elementDisplacement{kElementDofCount};
@@ -735,14 +735,14 @@ Status ResultRecovery::recover(const AnalysisModel& model,
state.displacement()[scatter[localDof]];
}
const BeamRecovery recovered =
beam.value().recover(elementDisplacement);
beam.Value().recover(elementDisplacement);
for (std::size_t endpoint = 0U; endpoint < 2U; ++endpoint) {
if (!finite(recovered.equilibriumEndActions[endpoint]) ||
!finite(recovered.endpointSectionResultants[endpoint])) {
return recoveryFailure(
"nonfinite-recovery-value",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Endpoint recovery values must be finite.");
}
endpointRows.push_back({
@@ -758,7 +758,7 @@ Status ResultRecovery::recover(const AnalysisModel& model,
return recoveryFailure(
"nonfinite-recovery-value",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Gauss recovery values must be finite.");
}
gaussRows.push_back({
@@ -774,7 +774,7 @@ Status ResultRecovery::recover(const AnalysisModel& model,
return recoveryFailure(
"nonfinite-recovery-value",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Stress recovery identity and values must be finite and ordered.");
}
stressRows.push_back({
@@ -844,7 +844,7 @@ Status ResultRecovery::recover(const AnalysisModel& model,
return recoveryFailure(
"invalid-recovery-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Shell recovery requires one initial director per element node.");
}
nodes[nodePosition] = &domain.nodes()[node];
@@ -856,8 +856,8 @@ Status ResultRecovery::recover(const AnalysisModel& model,
directors,
domain.shellSections()[definition.sectionIndex],
domain.materials()[definition.materialIndex]);
if (!shell.hasValue()) {
return shell.status();
if (!shell.HasValue()) {
return shell.GetStatus();
}
Vector elementDisplacement{kShellElementDofCount};
const auto& scatter = dofs.shellElementScatter(elementIndex);
@@ -867,28 +867,28 @@ Status ResultRecovery::recover(const AnalysisModel& model,
elementDisplacement[localDof] =
state.displacement()[scatter[localDof]];
}
auto recovered = shell.value().recoverPhysical(
auto recovered = shell.Value().recoverPhysical(
elementDisplacement);
if (!recovered.hasValue()) {
return recovered.status();
if (!recovered.HasValue()) {
return recovered.GetStatus();
}
const double accumulatedEnergy =
shellCandidate.physicalStrainEnergy +
recovered.value().strainEnergy;
recovered.Value().strainEnergy;
if (!std::isfinite(accumulatedEnergy)) {
return recoveryFailure(
"nonfinite-recovery-value",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Source-order physical shell energy reduction must remain finite.");
}
shellCandidate.physicalStrainEnergy = accumulatedEnergy;
expectedShellElements.push_back(elementIndex);
for (std::size_t point = 0U;
point < recovered.value().points.size();
point < recovered.Value().points.size();
++point) {
const auto& physicalPoint = recovered.value().points[point];
const auto& physicalPoint = recovered.Value().points[point];
ShellResultRow row{};
row.element = elementIndex;
row.location = locations[point];
@@ -917,7 +917,7 @@ Status ResultRecovery::recover(const AnalysisModel& model,
residual,
normalizedResidual,
shellCandidate);
if (!evidenceStatus.isOk()) {
if (!evidenceStatus.IsOk()) {
return evidenceStatus;
}
}
@@ -934,11 +934,11 @@ Status ResultRecovery::recover(const AnalysisModel& model,
candidateState.stressResults() = std::move(stressRows);
const Status shellCommitStatus = candidateState.commitShellResults(
expectedShellElements, std::move(shellCandidate));
if (!shellCommitStatus.isOk()) {
if (!shellCommitStatus.IsOk()) {
return shellCommitStatus;
}
state = std::move(candidateState);
return Status::ok();
return Status::Ok();
}
Result<std::vector<NodeStationResultRow>>
@@ -990,14 +990,14 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"invalid-node-station-entity",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Endpoint rows must preserve active element, endpoint, and source-node order.");
}
if (!finite(row.sectionResultant)) {
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"nonfinite-node-station-value",
definition.location,
definition.sourceId.sourceLabelText,
definition.sourceId.source_label_text,
"Node-station section resultants must be finite.");
}
rowsByNode[nodeIndex].push_back(&row);
@@ -1030,12 +1030,12 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
"Station eligibility requires finite concentrated loads.");
}
auto targets = resolveLoadTarget(domain, load);
if (!targets.hasValue()) {
return Result<std::vector<NodeStationResultRow>>::failure(
targets.status());
if (!targets.HasValue()) {
return Result<std::vector<NodeStationResultRow>>::Failure(
targets.GetStatus());
}
if (load.magnitude != 0.0) {
for (const EntityIndex node : targets.value()) {
for (const EntityIndex node : targets.Value()) {
loadedNodes[node] = 1U;
}
}
@@ -1061,7 +1061,7 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"ineligible-node-station",
domain.nodes()[nodeIndex].location,
domain.nodes()[nodeIndex].sourceId.sourceLabelText,
domain.nodes()[nodeIndex].sourceId.source_label_text,
"Interior station collapse requires exactly two unloaded endpoints.");
}
@@ -1080,7 +1080,7 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"ineligible-node-station",
domain.nodes()[nodeIndex].location,
domain.nodes()[nodeIndex].sourceId.sourceLabelText,
domain.nodes()[nodeIndex].sourceId.source_label_text,
"Interior station endpoints require one consistent section and local-axis chain.");
}
@@ -1097,14 +1097,14 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"nonfinite-node-station-value",
domain.nodes()[nodeIndex].location,
domain.nodes()[nodeIndex].sourceId.sourceLabelText,
domain.nodes()[nodeIndex].sourceId.source_label_text,
"Endpoint comparison must produce a finite difference.");
}
if (difference > componentTolerances[component]) {
return recoveryResultFailure<std::vector<NodeStationResultRow>>(
"node-station-tolerance-failure",
domain.nodes()[nodeIndex].location,
domain.nodes()[nodeIndex].sourceId.sourceLabelText,
domain.nodes()[nodeIndex].sourceId.source_label_text,
"Interior endpoint resultants disagree beyond component tolerance.");
}
}
@@ -1118,7 +1118,7 @@ ResultRecovery::normalizeSectionResultantsToNodeStations(
representative->element,
representative->sectionResultant});
}
return Result<std::vector<NodeStationResultRow>>::success(
return Result<std::vector<NodeStationResultRow>>::Success(
std::move(stations));
}