perf(shell): route local products through MKL and reduce Hessian storage work

This commit is contained in:
KOKO\Mimi
2026-10-14 18:07:16 +09:00
parent 8c7c41729e
commit f9e0df66dc
9 changed files with 758 additions and 179 deletions
+12 -23
View File
@@ -8,6 +8,7 @@
#include <utility>
#include "fesa/model/model_types.h"
#include "math/dense_blas_internal.h"
namespace fesa {
@@ -223,28 +224,18 @@ Matrix ScaledMatrix(const Matrix& source, double factor) {
return result;
}
/// @brief Lifts a local matrix by a deterministic serial congruence product.
/// @note The loop and accumulation order are part of reproducible stiffness.
/// @brief Lifts a local matrix through MKL and mirrors the upper triangle.
Matrix Congruence(const Matrix& local, const Matrix& transformation) {
if (local.Rows() != local.Columns() ||
local.Rows() != transformation.Rows()) {
throw std::invalid_argument{
"MITC4 congruence dimensions are incompatible."};
}
Matrix result{transformation.Columns(), transformation.Columns()};
Matrix result = dense_blas_internal::MultiplyTransposeLeft(
transformation, local.Multiply(transformation));
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 local_row = 0U; local_row < local.Rows(); ++local_row) {
for (std::size_t local_column = 0U; local_column < local.Columns();
++local_column) {
value += transformation(local_row, row) *
local(local_row, local_column) *
transformation(local_column, column);
}
}
result(row, column) = value;
result(column, row) = value;
result(column, row) = result(row, column);
}
}
return result;
@@ -611,7 +602,8 @@ Matrix Mitc4Shell::TransverseShearSectionMatrix() const {
return result;
}
Result<Mitc4Stiffness> Mitc4Shell::Stiffness() const {
Result<Mitc4Stiffness> Mitc4Shell::Stiffness() const try {
const dense_blas_internal::ScopedLocalDenseThreads local_threads{};
const Matrix constitutive = MaterialConstitutive5();
const Matrix tying_samples = CovariantTyingShearSamples20();
Matrix physical_local{kPhysicalDofCount, kPhysicalDofCount};
@@ -627,17 +619,12 @@ Result<Mitc4Stiffness> Mitc4Shell::Stiffness() const {
const Matrix strain = StrainDisplacement(
point.natural_coordinates[0], point.natural_coordinates[1],
point.natural_coordinates[2], &tying_samples);
const Matrix integrand = dense_blas_internal::MultiplyTransposeLeft(
strain, constitutive.Multiply(strain));
for (std::size_t row = 0U; row < kPhysicalDofCount; ++row) {
for (std::size_t column = row; column < kPhysicalDofCount; ++column) {
double integrand = 0.0;
for (std::size_t first = 0U; first < 5U; ++first) {
for (std::size_t second = 0U; second < 5U; ++second) {
integrand += strain(first, row) * constitutive(first, second) *
strain(second, column);
}
}
const double contribution =
integrand * geometry.jacobian * point.weight;
integrand(row, column) * geometry.jacobian * point.weight;
physical_local(row, column) += contribution;
if (row != column) {
physical_local(column, row) += contribution;
@@ -714,6 +701,8 @@ Result<Mitc4Stiffness> Mitc4Shell::Stiffness() const {
Mitc4Stiffness{std::move(physical_local), std::move(physical_global),
std::move(drilling_global), std::move(stabilized_global),
drilling_stiffness});
} catch (const std::exception& error) {
return StiffnessFailure(source_location_, identity_, error.what());
}
Result<Mitc4Mass> Mitc4Shell::Mass(const double density) const {