This commit uses global pre allocated work space to dramatically reduce memory usage and allocation time
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
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
|