Snapshot optimized solver and audit diagnostics before numerical experiments
This commit is contained in:
@@ -23,6 +23,7 @@ export import :deformation.radial_extensions;
|
||||
export import :deformation.surface_prescription;
|
||||
export import :deformation.vacuum_extension;
|
||||
export import :fem;
|
||||
import :fem.reference_tables;
|
||||
export import :field.mfem;
|
||||
export import :utils.domain;
|
||||
|
||||
@@ -141,8 +142,7 @@ export namespace mean_field::deformation {
|
||||
m_interiorSurfacePullbackWorkspace(surfaceDisplacementSize()),
|
||||
m_vacuumSurfacePullbackWorkspace(surfaceDisplacementSize()),
|
||||
m_surfacePullbackWorkspace(surfaceDisplacementSize()),
|
||||
m_parameterPullbackWorkspace(parameterCount()),
|
||||
m_volumeGridFunctionWorkspace(std::make_unique<mfem::ParGridFunction>(&volumeDisplacementSpace)) {
|
||||
m_parameterPullbackWorkspace(parameterCount()) {
|
||||
validateCompatibility(surfaceScalarSpace, volumeDisplacementSpace, logicalReferenceMesh);
|
||||
compileOwnership();
|
||||
|
||||
@@ -322,55 +322,8 @@ export namespace mean_field::deformation {
|
||||
requireCurrentDiscretization();
|
||||
requireVolumeSize(volumeDisplacement);
|
||||
|
||||
m_volumeGridFunctionWorkspace->SetFromTrueDofs(volumeDisplacement);
|
||||
mfem::Mesh *mesh = m_volumeDisplacementSpace->GetMesh();
|
||||
double localMinimumDeterminant = std::numeric_limits<double>::infinity();
|
||||
int localGeometryIsFinite = 1;
|
||||
|
||||
for (int element = 0; element < mesh->GetNE(); ++element) {
|
||||
mfem::ElementTransformation *transformation = mesh->GetElementTransformation(element);
|
||||
const mfem::FiniteElement *finiteElement = m_volumeDisplacementSpace->GetFE(element);
|
||||
// Positivity is a pointwise geometry requirement, not an
|
||||
// integration-accuracy requirement. A rule only slightly
|
||||
// above the displacement order can miss a narrow negative
|
||||
// region of the determinant even when a downstream physics
|
||||
// rule samples it. The determinant of a d-dimensional
|
||||
// degree-p deformation gradient can vary at substantially
|
||||
// higher order, so inspect at a conservative d*p scale.
|
||||
const int geometryInspectionOrder =
|
||||
std::max(finiteElement->GetOrder() + 2, 2 * spatialDimension() * finiteElement->GetOrder());
|
||||
const mfem::IntegrationRule &rule =
|
||||
mfem::IntRules.Get(transformation->GetGeometryType(), geometryInspectionOrder);
|
||||
|
||||
for (int point = 0; point < rule.GetNPoints(); ++point) {
|
||||
transformation->SetIntPoint(&rule.IntPoint(point));
|
||||
mfem::DenseMatrix deformationGradient;
|
||||
m_volumeGridFunctionWorkspace->GetVectorGradient(*transformation, deformationGradient);
|
||||
for (int component = 0; component < spatialDimension(); ++component) {
|
||||
deformationGradient(component, component) += 1.0;
|
||||
}
|
||||
const double determinant = deformationGradient.Det();
|
||||
if (!std::isfinite(determinant)) {
|
||||
localGeometryIsFinite = 0;
|
||||
} else {
|
||||
localMinimumDeterminant = std::min(localMinimumDeterminant, determinant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double globalMinimumDeterminant = 0.0;
|
||||
int globalGeometryIsFinite = 0;
|
||||
MPI_Allreduce(
|
||||
&localMinimumDeterminant, &globalMinimumDeterminant, 1, MPI_DOUBLE, MPI_MIN,
|
||||
m_volumeDisplacementSpace->GetComm()
|
||||
);
|
||||
MPI_Allreduce(
|
||||
&localGeometryIsFinite, &globalGeometryIsFinite, 1, MPI_INT, MPI_MIN,
|
||||
m_volumeDisplacementSpace->GetComm()
|
||||
);
|
||||
if (globalGeometryIsFinite == 0) {
|
||||
globalMinimumDeterminant = std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
const double globalMinimumDeterminant =
|
||||
m_geometryInspector.Inspect(*m_volumeDisplacementSpace, volumeDisplacement);
|
||||
++m_actionStatistics.geometryInspections;
|
||||
return {.minimumJacobianDeterminant = globalMinimumDeterminant};
|
||||
}
|
||||
@@ -579,7 +532,7 @@ export namespace mean_field::deformation {
|
||||
mutable mfem::Vector m_vacuumSurfacePullbackWorkspace;
|
||||
mutable mfem::Vector m_surfacePullbackWorkspace;
|
||||
mutable mfem::Vector m_parameterPullbackWorkspace;
|
||||
mutable std::unique_ptr<mfem::ParGridFunction> m_volumeGridFunctionWorkspace;
|
||||
mutable fem::PreparedGeometryInspector m_geometryInspector;
|
||||
};
|
||||
|
||||
template <
|
||||
|
||||
Reference in New Issue
Block a user