Snapshot optimized solver and audit diagnostics before numerical experiments
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
module;
|
||||
|
||||
#include "mean_field.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
export module mean_field:mapping.domain_mapper;
|
||||
export import :mapping.types;
|
||||
@@ -108,8 +110,35 @@ export namespace mean_field::mapping {
|
||||
|
||||
DomainMapper(const DomainMapper &) = delete;
|
||||
DomainMapper &operator=(const DomainMapper &) = delete;
|
||||
DomainMapper(DomainMapper &&) = default;
|
||||
DomainMapper &operator=(DomainMapper &&) = default;
|
||||
~DomainMapper();
|
||||
DomainMapper(DomainMapper &&) noexcept;
|
||||
DomainMapper &operator=(DomainMapper &&) noexcept;
|
||||
|
||||
struct FixedMeshGeometry {
|
||||
mfem::Vector position;
|
||||
mfem::DenseMatrix jacobian, inverseJacobian;
|
||||
double weight{0.0};
|
||||
};
|
||||
struct GeometryCacheStatistics {
|
||||
std::uint64_t hits{0}, misses{0};
|
||||
std::size_t points{0};
|
||||
};
|
||||
// Only computational-mesh geometry is cached, never displacement or
|
||||
// compactification state. MFEM mesh/node sequence changes invalidate it.
|
||||
// After raw coordinate edits call Mesh::NodesUpdated(), as required by
|
||||
// MFEM's own geometric-factor cache, or ClearGeometryCache(). A mesh
|
||||
// must outlive its cached entries; clear before destroying/replacing it.
|
||||
// Like MFEM element transformations, this cache is not thread-safe.
|
||||
void SetGeometryCacheEnabled(bool enabled) const;
|
||||
[[nodiscard]] bool IsGeometryCacheEnabled() const noexcept;
|
||||
void ClearGeometryCache() const;
|
||||
[[nodiscard]] GeometryCacheStatistics GetGeometryCacheStatistics() const;
|
||||
// Sets the transformation's integration point. nullptr means use MFEM
|
||||
// directly (disabled cache, non-mesh transformation, or unsupported data).
|
||||
// Returned data remains valid until cache invalidation or mapper destruction.
|
||||
[[nodiscard]] const FixedMeshGeometry *GetFixedMeshGeometry(
|
||||
mfem::ElementTransformation &transformation, const mfem::IntegrationPoint &point
|
||||
) const;
|
||||
|
||||
[[nodiscard]] MappingStatus EvaluatePoint(
|
||||
const ElementMappingData &element_data,
|
||||
@@ -119,12 +148,19 @@ export namespace mean_field::mapping {
|
||||
MappingPointContext &context
|
||||
) const;
|
||||
|
||||
// A sample from the same element DOFs and integration point. Its
|
||||
// gradient is with respect to finite-element coordinates, not the mesh.
|
||||
struct ReferenceDisplacementSample {
|
||||
const mfem::Vector &value;
|
||||
const mfem::DenseMatrix &gradient;
|
||||
};
|
||||
[[nodiscard]] MappingStatus EvaluateVolume(
|
||||
const ElementMappingData &element_data,
|
||||
mfem::ElementTransformation &transformation,
|
||||
const mfem::IntegrationPoint &integration_point,
|
||||
Workspace &workspace,
|
||||
VolumeMappingContext &context
|
||||
VolumeMappingContext &context,
|
||||
const ReferenceDisplacementSample *displacementSample = nullptr
|
||||
) const;
|
||||
|
||||
[[nodiscard]] MappingStatus EvaluateFace(
|
||||
@@ -172,6 +208,12 @@ export namespace mean_field::mapping {
|
||||
[[nodiscard]] const compactification::ExteriorDomainMap &GetExteriorMap() const noexcept;
|
||||
|
||||
private:
|
||||
[[nodiscard]] MappingStatus EvaluatePointImpl(
|
||||
const ElementMappingData &element_data, mfem::ElementTransformation &transformation,
|
||||
const mfem::IntegrationPoint &integration_point, Workspace &workspace,
|
||||
MappingPointContext &context, const FixedMeshGeometry *meshGeometry,
|
||||
const ReferenceDisplacementSample *displacementSample = nullptr
|
||||
) const;
|
||||
void ValidateElementData(const ElementMappingData &element_data) const;
|
||||
|
||||
void EvaluateField(
|
||||
@@ -214,6 +256,8 @@ export namespace mean_field::mapping {
|
||||
FaceElementSide side
|
||||
);
|
||||
|
||||
struct GeometryCache;
|
||||
mutable std::unique_ptr<GeometryCache> m_geometryCache;
|
||||
utils::DomainMapperOptions m_options;
|
||||
std::unique_ptr<const compactification::ExteriorDomainMap> m_exterior_map;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user