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

@@ -4,6 +4,7 @@ module;
#include <cstddef>
#include <cstdint>
#include <expected>
#include <memory>
#include <optional>
#include <vector>
@@ -13,8 +14,10 @@ export module mean_field:operators.prepared_pressure_force;
export import :eos.polytrope;
export import :fem;
export import :fem.reference_tables;
export import :field.mfem;
export import :mapping.domain_mapper;
export import :mapping.prepared_cache;
export import :operators.context.pressure_force;
export import :utils.blocks;
@@ -168,6 +171,12 @@ export namespace mean_field::operators {
[[nodiscard]]
const fem::FEM &GetFEM() const noexcept;
template <typename Visitor> void VisitMappedGeometryRules(Visitor &&visitor) const {
for (const ElementPAData &data : m_elements) {
visitor(data.elementId, *data.integrationRule);
}
}
private:
struct ConstructionData;
@@ -196,10 +205,13 @@ export namespace mean_field::operators {
const mfem::IntegrationRule *integrationRule{nullptr};
/*
* Rows are quadrature points and columns are enthalpy DOFs.
*/
mfem::DenseMatrix enthalpyBasis;
// Immutable reference values and gradients are shared by FE/rule.
std::shared_ptr<const fem::ScalarReferenceTable> enthalpyReferenceTable;
std::shared_ptr<const fem::ScalarReferenceTable> displacementReferenceTable;
[[nodiscard]] const mfem::DenseMatrix &GetEnthalpyBasis() const {
return enthalpyReferenceTable->GetValues();
}
/*
* Each entry is:
@@ -208,11 +220,9 @@ export namespace mean_field::operators {
* x
* physical dimension.
*/
std::vector<mfem::DenseMatrix> referenceTestGradients;
std::vector<mfem::DenseMatrix> physicalTestGradients;
std::vector<mapping::VolumeMappingContext> baseMappingContexts;
mapping::VolumeMappingCache baseMappingContexts;
std::optional<mapping::ElementDisplacementData> baseDisplacementData;