feat(cpp-object-oriented-modular-refactoring): step 3 - foundation-google-style
This commit is contained in:
@@ -40,18 +40,18 @@ bool isFinite(const Vector3& value) {
|
||||
}
|
||||
|
||||
std::string elementIdentity(const Node& firstNode, const Node& secondNode) {
|
||||
return firstNode.sourceId.instanceName + ":" +
|
||||
firstNode.sourceId.sourceLabelText + "-" +
|
||||
secondNode.sourceId.sourceLabelText;
|
||||
return firstNode.sourceId.instance_name + ":" +
|
||||
firstNode.sourceId.source_label_text + "-" +
|
||||
secondNode.sourceId.source_label_text;
|
||||
}
|
||||
|
||||
Result<EulerBeam3D> modelFailure(const std::string& code,
|
||||
const SourceLocation& location,
|
||||
const std::string& identity,
|
||||
const std::string& message) {
|
||||
return Result<EulerBeam3D>::failure(Status::failure(
|
||||
FailureCategory::model,
|
||||
{{Severity::error, code, location, "*ELEMENT", identity, message}}));
|
||||
return Result<EulerBeam3D>::Failure(Status::Failure(
|
||||
FailureCategory::kModel,
|
||||
{{Severity::kError, code, location, "*ELEMENT", identity, message}}));
|
||||
}
|
||||
|
||||
Matrix transformation(const std::array<double, 9>& rotation) {
|
||||
@@ -148,8 +148,8 @@ Matrix closedStiffness(double length,
|
||||
double normalizedMatrixError(const Matrix& lhs, const Matrix& rhs) {
|
||||
double maximumDifference = 0.0;
|
||||
double scale = 1.0;
|
||||
for (std::size_t row = 0; row < lhs.rows(); ++row) {
|
||||
for (std::size_t column = 0; column < lhs.columns(); ++column) {
|
||||
for (std::size_t row = 0; row < lhs.Rows(); ++row) {
|
||||
for (std::size_t column = 0; column < lhs.Columns(); ++column) {
|
||||
const double lhsValue = lhs(row, column);
|
||||
const double rhsValue = rhs(row, column);
|
||||
if (!std::isfinite(lhsValue) || !std::isfinite(rhsValue)) {
|
||||
@@ -181,7 +181,7 @@ std::array<double, kGeneralizedComponentCount> generalizedStrain(
|
||||
const Vector& localDisplacement) {
|
||||
std::array<double, kGeneralizedComponentCount> strain{};
|
||||
for (std::size_t component = 0; component < strain.size(); ++component) {
|
||||
for (std::size_t dof = 0; dof < localDisplacement.size(); ++dof) {
|
||||
for (std::size_t dof = 0; dof < localDisplacement.Size(); ++dof) {
|
||||
strain[component] += b(component, dof) * localDisplacement[dof];
|
||||
}
|
||||
}
|
||||
@@ -356,7 +356,7 @@ Result<EulerBeam3D> EulerBeam3D::create(
|
||||
ey[0], ey[1], ey[2],
|
||||
ez[0], ez[1], ez[2]};
|
||||
|
||||
return Result<EulerBeam3D>::success(EulerBeam3D{
|
||||
return Result<EulerBeam3D>::Success(EulerBeam3D{
|
||||
length,
|
||||
material.youngsModulus,
|
||||
shearModulus,
|
||||
@@ -401,7 +401,7 @@ Matrix EulerBeam3D::localStiffness() const {
|
||||
Matrix EulerBeam3D::globalStiffness() const {
|
||||
const Matrix local = localStiffness();
|
||||
const Matrix transform = transformation(rotation_);
|
||||
const Matrix localTimesTransform = local.multiply(transform);
|
||||
const Matrix localTimesTransform = local.Multiply(transform);
|
||||
Matrix global{kElementDofCount, kElementDofCount};
|
||||
// Kg=T^T*Kl*T while dl=T*dg.
|
||||
for (std::size_t row = 0; row < kElementDofCount; ++row) {
|
||||
@@ -423,7 +423,7 @@ Vector EulerBeam3D::localEquivalentLoad(const ConstantLocalLineLoad& load) const
|
||||
const double jacobian = 0.5 * length_;
|
||||
for (const double xi : gaussPoints) {
|
||||
const Matrix interpolation = kinematicInterpolation(xi, length_);
|
||||
for (std::size_t dof = 0; dof < equivalent.size(); ++dof) {
|
||||
for (std::size_t dof = 0; dof < equivalent.Size(); ++dof) {
|
||||
for (std::size_t component = 0; component < components.size(); ++component) {
|
||||
equivalent[dof] +=
|
||||
interpolation(component, dof) * components[component] * jacobian;
|
||||
@@ -435,13 +435,13 @@ Vector EulerBeam3D::localEquivalentLoad(const ConstantLocalLineLoad& load) const
|
||||
|
||||
BeamRecovery EulerBeam3D::recover(const Vector& globalElementDisplacement) const {
|
||||
const Matrix transform = transformation(rotation_);
|
||||
const Vector localDisplacement = transform.multiply(globalElementDisplacement);
|
||||
const Vector localDisplacement = transform.Multiply(globalElementDisplacement);
|
||||
const auto diagonal = constitutiveDiagonal(
|
||||
youngsModulus_, shearModulus_, area_, iy_, iz_, torsionalConstant_);
|
||||
BeamRecovery recovery{};
|
||||
|
||||
// With parser/CLI distributed loading excluded, Kl*dl is the local outward end action.
|
||||
const Vector endAction = localStiffness().multiply(localDisplacement);
|
||||
const Vector endAction = localStiffness().Multiply(localDisplacement);
|
||||
for (std::size_t endpoint = 0; endpoint < 2U; ++endpoint) {
|
||||
for (std::size_t component = 0; component < 6U; ++component) {
|
||||
recovery.equilibriumEndActions[endpoint][component] =
|
||||
|
||||
@@ -126,7 +126,7 @@ std::string elementIdentity(const std::array<const Node*, kNodeCount>& nodes) {
|
||||
if (!identity.empty()) {
|
||||
identity += "-";
|
||||
}
|
||||
identity += node->sourceId.sourceLabelText;
|
||||
identity += node->sourceId.source_label_text;
|
||||
}
|
||||
return identity;
|
||||
}
|
||||
@@ -136,9 +136,9 @@ Result<Mitc4Shell> modelFailure(
|
||||
const SourceLocation& location,
|
||||
const std::string& identity,
|
||||
std::string message) {
|
||||
return Result<Mitc4Shell>::failure(Status::failure(
|
||||
FailureCategory::model,
|
||||
{{Severity::error,
|
||||
return Result<Mitc4Shell>::Failure(Status::Failure(
|
||||
FailureCategory::kModel,
|
||||
{{Severity::kError,
|
||||
std::move(code),
|
||||
location,
|
||||
"*ELEMENT",
|
||||
@@ -205,9 +205,9 @@ std::array<double, 5> localEngineeringComponents(
|
||||
}
|
||||
|
||||
Matrix scaledMatrix(const Matrix& source, double factor) {
|
||||
Matrix result{source.rows(), source.columns()};
|
||||
for (std::size_t row = 0U; row < source.rows(); ++row) {
|
||||
for (std::size_t column = 0U; column < source.columns(); ++column) {
|
||||
Matrix result{source.Rows(), source.Columns()};
|
||||
for (std::size_t row = 0U; row < source.Rows(); ++row) {
|
||||
for (std::size_t column = 0U; column < source.Columns(); ++column) {
|
||||
result(row, column) = factor * source(row, column);
|
||||
}
|
||||
}
|
||||
@@ -215,17 +215,17 @@ Matrix scaledMatrix(const Matrix& source, double factor) {
|
||||
}
|
||||
|
||||
Matrix congruence(const Matrix& local, const Matrix& transformation) {
|
||||
if (local.rows() != local.columns() ||
|
||||
local.rows() != transformation.rows()) {
|
||||
if (local.Rows() != local.Columns() ||
|
||||
local.Rows() != transformation.Rows()) {
|
||||
throw std::invalid_argument{"MITC4 congruence dimensions are incompatible."};
|
||||
}
|
||||
Matrix result{transformation.columns(), transformation.columns()};
|
||||
for (std::size_t row = 0U; row < result.rows(); ++row) {
|
||||
for (std::size_t column = row; column < result.columns(); ++column) {
|
||||
Matrix result{transformation.Columns(), transformation.Columns()};
|
||||
for (std::size_t row = 0U; row < result.Rows(); ++row) {
|
||||
for (std::size_t column = row; column < result.Columns(); ++column) {
|
||||
double value = 0.0;
|
||||
for (std::size_t localRow = 0U; localRow < local.rows(); ++localRow) {
|
||||
for (std::size_t localRow = 0U; localRow < local.Rows(); ++localRow) {
|
||||
for (std::size_t localColumn = 0U;
|
||||
localColumn < local.columns(); ++localColumn) {
|
||||
localColumn < local.Columns(); ++localColumn) {
|
||||
value += transformation(localRow, row) *
|
||||
local(localRow, localColumn) *
|
||||
transformation(localColumn, column);
|
||||
@@ -239,8 +239,8 @@ Matrix congruence(const Matrix& local, const Matrix& transformation) {
|
||||
}
|
||||
|
||||
bool isFinite(const Matrix& matrix) {
|
||||
for (std::size_t row = 0U; row < matrix.rows(); ++row) {
|
||||
for (std::size_t column = 0U; column < matrix.columns(); ++column) {
|
||||
for (std::size_t row = 0U; row < matrix.Rows(); ++row) {
|
||||
for (std::size_t column = 0U; column < matrix.Columns(); ++column) {
|
||||
if (!std::isfinite(matrix(row, column))) {
|
||||
return false;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ bool isFinite(const Matrix& matrix) {
|
||||
}
|
||||
|
||||
bool isFinite(const Vector& vector) {
|
||||
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 false;
|
||||
}
|
||||
@@ -262,9 +262,9 @@ Result<Mitc4Stiffness> stiffnessFailure(
|
||||
const SourceLocation& location,
|
||||
const std::string& identity,
|
||||
std::string message) {
|
||||
return Result<Mitc4Stiffness>::failure(Status::failure(
|
||||
FailureCategory::model,
|
||||
{{Severity::error,
|
||||
return Result<Mitc4Stiffness>::Failure(Status::Failure(
|
||||
FailureCategory::kModel,
|
||||
{{Severity::kError,
|
||||
"invalid-shell-stiffness",
|
||||
location,
|
||||
"*ELEMENT",
|
||||
@@ -276,9 +276,9 @@ Result<Mitc4PhysicalRecovery> recoveryFailure(
|
||||
const SourceLocation& location,
|
||||
const std::string& identity,
|
||||
std::string message) {
|
||||
return Result<Mitc4PhysicalRecovery>::failure(Status::failure(
|
||||
FailureCategory::model,
|
||||
{{Severity::error,
|
||||
return Result<Mitc4PhysicalRecovery>::Failure(Status::Failure(
|
||||
FailureCategory::kModel,
|
||||
{{Severity::kError,
|
||||
"invalid-shell-recovery",
|
||||
location,
|
||||
"*ELEMENT",
|
||||
@@ -430,7 +430,7 @@ Result<Mitc4Shell> Mitc4Shell::create(
|
||||
}
|
||||
}
|
||||
|
||||
return Result<Mitc4Shell>::success(std::move(shell));
|
||||
return Result<Mitc4Shell>::Success(std::move(shell));
|
||||
}
|
||||
|
||||
Mitc4ShapeFunctions Mitc4Shell::shapeFunctions(
|
||||
@@ -688,7 +688,7 @@ Result<Mitc4Stiffness> Mitc4Shell::stiffness() const {
|
||||
"MITC4 transformed stiffness must contain only finite values.");
|
||||
}
|
||||
|
||||
return Result<Mitc4Stiffness>::success(Mitc4Stiffness{
|
||||
return Result<Mitc4Stiffness>::Success(Mitc4Stiffness{
|
||||
std::move(physicalLocal),
|
||||
std::move(physicalGlobal),
|
||||
std::move(drillingGlobal),
|
||||
@@ -698,7 +698,7 @@ Result<Mitc4Stiffness> Mitc4Shell::stiffness() const {
|
||||
|
||||
Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
const Vector& globalElementDisplacement24) const {
|
||||
if (globalElementDisplacement24.size() != kGlobalDofCount) {
|
||||
if (globalElementDisplacement24.Size() != kGlobalDofCount) {
|
||||
return recoveryFailure(
|
||||
sourceLocation_, identity_,
|
||||
"MITC4 physical recovery requires exactly 24 global element DOFs.");
|
||||
@@ -710,7 +710,7 @@ Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
}
|
||||
|
||||
const Vector physicalDisplacement =
|
||||
physicalTransformation20().multiply(globalElementDisplacement24);
|
||||
physicalTransformation20().Multiply(globalElementDisplacement24);
|
||||
const Matrix tyingSamples = covariantTyingShearSamples20();
|
||||
const Matrix constitutive = materialConstitutive5();
|
||||
const Matrix planeStress = planeStressConstitutive();
|
||||
@@ -742,8 +742,8 @@ Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
const Matrix strainMatrix = strainDisplacement(
|
||||
point.naturalCoordinates[0], point.naturalCoordinates[1], zeta,
|
||||
&tyingSamples);
|
||||
const Vector strain = strainMatrix.multiply(physicalDisplacement);
|
||||
const Vector stress = constitutive.multiply(strain);
|
||||
const Vector strain = strainMatrix.Multiply(physicalDisplacement);
|
||||
const Vector stress = constitutive.Multiply(strain);
|
||||
GeometryData geometry{};
|
||||
if (!evaluateGeometry(
|
||||
point.naturalCoordinates[0], point.naturalCoordinates[1],
|
||||
@@ -769,7 +769,7 @@ Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
0.5 * thickness_ * stress[3U + component];
|
||||
}
|
||||
recovery.strainEnergy +=
|
||||
0.5 * strain.dot(stress) * geometry.jacobian;
|
||||
0.5 * strain.Dot(stress) * geometry.jacobian;
|
||||
}
|
||||
|
||||
for (std::size_t position = 0U;
|
||||
@@ -785,12 +785,12 @@ Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
const Vector strain = strainDisplacement(
|
||||
point.naturalCoordinates[0], point.naturalCoordinates[1],
|
||||
sectionPositions[position], &tyingSamples)
|
||||
.multiply(physicalDisplacement);
|
||||
.Multiply(physicalDisplacement);
|
||||
Vector inPlaneStrain{3U};
|
||||
for (std::size_t component = 0U; component < 3U; ++component) {
|
||||
inPlaneStrain[component] = strain[component];
|
||||
}
|
||||
const Vector stress = planeStress.multiply(inPlaneStrain);
|
||||
const Vector stress = planeStress.Multiply(inPlaneStrain);
|
||||
for (std::size_t component = 0U; component < 3U; ++component) {
|
||||
point.inPlaneStress[position][component] = stress[component];
|
||||
}
|
||||
@@ -819,7 +819,7 @@ Result<Mitc4PhysicalRecovery> Mitc4Shell::recoverPhysical(
|
||||
}
|
||||
}
|
||||
|
||||
return Result<Mitc4PhysicalRecovery>::success(std::move(recovery));
|
||||
return Result<Mitc4PhysicalRecovery>::Success(std::move(recovery));
|
||||
}
|
||||
|
||||
Mitc4Shell::Mitc4Shell(
|
||||
|
||||
Reference in New Issue
Block a user