perf(allocations): reduced overall allocations by 95%, increaseed jacobian applicatin by 2x

This commit uses global pre allocated work space to dramatically reduce memory usage and allocation time
This commit is contained in:
2026-09-10 06:50:56 -04:00
parent b3c04d507a
commit 75cc638739
66 changed files with 207183 additions and 99552 deletions

View File

@@ -10,6 +10,7 @@ export module mean_field:operators.prepared_hdiv_mass;
export import :fem;
export import :field.mfem;
export import :mapping.domain_mapper;
import :fem.reference_tables;
export namespace mean_field::operators {
enum class HDivMassPreparationRejectionReason : std::uint8_t { invalid_mapping, non_finite_arithmetic };
@@ -58,6 +59,12 @@ export namespace mean_field::operators {
[[nodiscard]] const field::FieldDofMap &GetFluxMap() const noexcept;
[[nodiscard]] const field::FieldDofMap &GetDisplacementMap() const noexcept;
template <typename Visitor> void VisitMappedGeometryRules(Visitor &&visitor) const {
for (const ElementVariationData &data : m_variationElements) {
visitor(data.elementId, *data.integrationRule);
}
}
private:
enum class PreparationMode : std::uint8_t { primal, linearization };
@@ -71,6 +78,10 @@ export namespace mean_field::operators {
mfem::Vector baseDisplacement;
mfem::Vector compactification;
const mfem::IntegrationRule *integrationRule{nullptr};
std::shared_ptr<const fem::VectorReferenceTable> gravityReferenceTable;
// Fixed computational-mesh Piola factor, separate from J_map.
mfem::DenseMatrix meshPiolaJacobians;
mfem::Vector referenceWeights;
mfem::DenseMatrix frozenMappingData;
};
@@ -112,7 +123,10 @@ export namespace mean_field::operators {
mutable mfem::Vector m_elementDisplacementVariation;
mutable mfem::Vector m_elementVariationAction;
mutable mfem::Vector m_gravityGradientValue;
mutable mfem::Vector m_gravityReferenceCellValue;
mutable mfem::Vector m_referenceCellDual;
mutable mfem::Vector m_massTensorVariationAction;
mutable mfem::DenseMatrix m_meshPiolaJacobian;
mutable mfem::DenseMatrix m_gravityGradientShape;
mutable mfem::DenseMatrix m_massTensorVariation;
std::uint64_t m_preparation_count{0};