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:
42
libmeanfield/interface/mapping/prepared_cache.cppm
Normal file
42
libmeanfield/interface/mapping/prepared_cache.cppm
Normal 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
|
||||
Reference in New Issue
Block a user