perf(hex8): defer optional paired tangent until a valid linear trial

This commit is contained in:
KOKO\Mimi
2026-10-14 17:38:27 +09:00
parent 774bfbcbdd
commit 6a6c8c33c8
5 changed files with 167 additions and 22 deletions
+9 -6
View File
@@ -2,6 +2,7 @@
#define FESA_ELEMENTS_HEX8_ELEMENT_H_
#include <array>
#include <memory>
#include <optional>
#include "fesa/elements/element.h"
@@ -9,6 +10,9 @@
#include "fesa/results/solid_result_records.h"
namespace fesa {
namespace hex8_internal {
struct LinearTangentCache;
}
/// @brief Owns all local quantities from one validated linear or TL trial.
struct Hex8Response {
@@ -90,7 +94,8 @@ class Hex8Element final : public Element {
bool nonlinear) const;
/// @brief Uses one paired gradient for energy, force and analytic Hessian.
Result<Hex8HighLowResponse> EvaluateHighLow(
const Vector& high, const Vector& low, bool nonlinear) const;
const Vector& high, const Vector& low, bool nonlinear,
bool prepare_linear_cache = true) const;
/// @brief Attaches stable source context to a model failure.
Status Failure(const char* message) const;
@@ -103,11 +108,9 @@ class Hex8Element final : public Element {
SourceLocation location_;
std::array<ReferencePoint, 8> points_{};
Matrix stiffness_{24U, 24U};
// Optional immutable Hessian from the same paired quadrature graph. Failure
// to build it does not reject models supported by the original F64 paths.
bool paired_linear_tangent_ready_{false};
Matrix paired_linear_tangent_high_{24U, 24U};
Matrix paired_linear_tangent_low_{24U, 24U};
// Optional immutable paired Hessian, prepared once on the first valid paired
// linear trial. Copies share only their identical owned reference definition.
std::shared_ptr<hex8_internal::LinearTangentCache> paired_linear_tangent_;
};
} // namespace fesa