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

@@ -0,0 +1,42 @@
module;
#include <mfem.hpp>
#include <vector>
export module mean_field:mapping.prepared_cache;
import :mapping.types;
export namespace mean_field::mapping {
// Flat, owning storage for prepared volume contexts. Load into reusable
// workspaces: no MFEM buffers or pointer aliases are owned per quadrature
// point. The layout retains every public context field without recomputing
// inverses or changing the mapper's numerical contract.
class VolumeMappingCache {
public:
void SetSize(
int point_count,
int dimension
);
void Store(
int point,
const VolumeMappingContext &context
);
void Load(
int point,
VolumeMappingContext &context
) const;
void LoadInverseJacobian(
int point,
mfem::DenseMatrix &inverse
) const;
[[nodiscard]] int GetPointCount() const;
[[nodiscard]] int GetDimension() const;
private:
[[nodiscard]] const double *GetPointData(int point) const;
std::vector<double> m_data;
int m_point_count{0};
int m_dimension{0};
int m_point_stride{0};
};
} // namespace mean_field::mapping