perf(hex8): cache immutable paired linear Hessian

This commit is contained in:
KOKO\Mimi
2026-10-09 23:55:01 +09:00
parent 5435acdde3
commit e878379c30
6 changed files with 76 additions and 3 deletions
+11 -2
View File
@@ -151,12 +151,15 @@ Result<Hex8HighLowResponse> Hex8Element::EvaluateHighLow(
response.high.points[g] = {element_index_, static_cast<int>(g + 1U),
point.natural, point.position,
Pack(stress), Pack(strain)};
std::array<Triple, 8> fg{};
for (std::size_t a = 0; a < 8; ++a)
for (std::size_t i = 0; i < 3; ++i) {
fg[a][i] = Dot(f[i], gradients[a]);
force[3U * a + i] += Dot(p[i], gradients[a]) * HighLow{point.weight};
}
if (!nonlinear && paired_linear_tangent_ready_) continue;
std::array<Triple, 8> fg{};
for (std::size_t a = 0; a < 8; ++a)
for (std::size_t i = 0; i < 3; ++i)
fg[a][i] = Dot(f[i], gradients[a]);
for (std::size_t a = 0; a < 8; ++a)
for (std::size_t b = 0; b < 8; ++b) {
const auto dot = Dot(gradients[a], gradients[b]);
@@ -183,12 +186,18 @@ Result<Hex8HighLowResponse> Hex8Element::EvaluateHighLow(
Failure("Hex8 high+low energy is unsupported or nonfinite."));
response.high.strain_energy = energy.high;
response.strain_energy_low = energy.low;
if (!nonlinear && paired_linear_tangent_ready_) {
response.high.material_tangent = paired_linear_tangent_high_;
response.high.tangent = paired_linear_tangent_high_;
response.tangent_low = paired_linear_tangent_low_;
}
for (std::size_t i = 0; i < 24; ++i) {
if (!IsNormalized(force[i]))
return Result<Hex8HighLowResponse>::Failure(
Failure("Hex8 high+low force is unsupported or nonfinite."));
response.high.internal_force[i] = force[i].high;
response.internal_force_low[i] = force[i].low;
if (!nonlinear && paired_linear_tangent_ready_) continue;
for (std::size_t j = 0; j < 24; ++j) {
const auto tangent = material[i][j] + geometric[i][j];
if (!IsNormalized(material[i][j]) || !IsNormalized(geometric[i][j]) ||