feat(surface): major work on implementing surface constraints in a presciption agnostic manner
This commit is contained in:
@@ -21,6 +21,12 @@ namespace {
|
||||
);
|
||||
}
|
||||
|
||||
[[nodiscard]] mfem::Vector make_computational_origin(const mfem::ParMesh &mesh) {
|
||||
mfem::Vector origin(mesh.SpaceDimension());
|
||||
origin = 0.0;
|
||||
return origin;
|
||||
}
|
||||
|
||||
[[nodiscard]] mean_field::operators::StellarEquilibriumLayout make_layout(
|
||||
const mean_field::field::FieldDofMap &densityMap,
|
||||
const mean_field::field::FieldDofMap &displacementMap,
|
||||
@@ -253,6 +259,8 @@ namespace mean_field::operators {
|
||||
field::FieldDofMap gravityFluxMap;
|
||||
field::FieldDofMap gravityPotentialMap;
|
||||
field::FieldDofMap enthalpyMap;
|
||||
field::FieldBoundaryDofMap pressureSurfaceRows;
|
||||
field::FieldPointDofMap centerDisplacementRows;
|
||||
|
||||
StellarEquilibriumLayout layout;
|
||||
mfem::Array<int> gravityStateOffsets;
|
||||
@@ -284,6 +292,23 @@ namespace mean_field::operators {
|
||||
field::Enthalpy,
|
||||
DomainSchema>(*f.enthalpyFes)
|
||||
),
|
||||
pressureSurfaceRows(
|
||||
field::make_field_boundary_dof_map<
|
||||
field::Enthalpy,
|
||||
utils::domain::StellarSurface,
|
||||
DomainSchema>(
|
||||
*f.enthalpyFes,
|
||||
enthalpyMap
|
||||
)
|
||||
),
|
||||
centerDisplacementRows(
|
||||
field::make_field_point_dof_map<field::Displacement>(
|
||||
*f.displacementFes,
|
||||
displacementMap,
|
||||
make_computational_origin(*f.mesh),
|
||||
1.0e-12
|
||||
)
|
||||
),
|
||||
layout(make_layout(
|
||||
densityMap,
|
||||
displacementMap,
|
||||
@@ -314,27 +339,15 @@ namespace mean_field::operators {
|
||||
fem::FEM &f,
|
||||
const mapping::DomainMapper &domainMapper,
|
||||
const eos::Polytrope &equationOfState,
|
||||
const models::StellarModel &stellarModel
|
||||
)
|
||||
: PreparedStellarEquilibriumOperator(
|
||||
f,
|
||||
domainMapper,
|
||||
equationOfState,
|
||||
stellarModel.targetMass()
|
||||
) {
|
||||
}
|
||||
|
||||
PreparedStellarEquilibriumOperator::PreparedStellarEquilibriumOperator(
|
||||
fem::FEM &f,
|
||||
const mapping::DomainMapper &domainMapper,
|
||||
const eos::Polytrope &equationOfState,
|
||||
const double targetMass
|
||||
const double targetMass,
|
||||
const PressureSurfaceConstraintView surfaceConstraint
|
||||
)
|
||||
: PreparedStellarEquilibriumOperator(
|
||||
f,
|
||||
domainMapper,
|
||||
equationOfState,
|
||||
targetMass,
|
||||
surfaceConstraint,
|
||||
MakeConstructionData(f)
|
||||
) {
|
||||
}
|
||||
@@ -344,6 +357,7 @@ namespace mean_field::operators {
|
||||
const mapping::DomainMapper &domainMapper,
|
||||
const eos::Polytrope &equationOfState,
|
||||
const double targetMass,
|
||||
const PressureSurfaceConstraintView surfaceConstraint,
|
||||
ConstructionData constructionData
|
||||
)
|
||||
: mfem::Operator(
|
||||
@@ -390,6 +404,11 @@ namespace mean_field::operators {
|
||||
domainMapper,
|
||||
m_gravityContext
|
||||
),
|
||||
m_surfaceConstraintOperator(
|
||||
constructionData.pressureSurfaceRows,
|
||||
surfaceConstraint
|
||||
),
|
||||
m_centeringConstraintOperator(constructionData.centerDisplacementRows),
|
||||
m_targetMass(targetMass) {
|
||||
MFEM_VERIFY(
|
||||
std::isfinite(m_targetMass) && m_targetMass > 0.0,
|
||||
@@ -506,6 +525,14 @@ namespace mean_field::operators {
|
||||
report.massNormalization =
|
||||
m_massNormalizationOperator.Prepare({.targetMass = m_targetMass}, make_mass_dependencies(dependencies));
|
||||
|
||||
report.surfaceConstraint = m_surfaceConstraintOperator.Prepare(
|
||||
reducedEnthalpy, !wasPrepared || dependencies.enthalpy != m_preparedDependencies.enthalpy
|
||||
);
|
||||
|
||||
report.centeringConstraint = m_centeringConstraintOperator.Prepare(
|
||||
displacement, !wasPrepared || dependencies.displacement != m_preparedDependencies.displacement
|
||||
);
|
||||
|
||||
const bool dependenciesChanged = !wasPrepared || dependencies != m_preparedDependencies;
|
||||
if (dependenciesChanged || report.DidAnyChildWork()) {
|
||||
AssembleResidual();
|
||||
@@ -542,7 +569,9 @@ namespace mean_field::operators {
|
||||
m_gravityOperator.Mult(m_gravityState, gravity);
|
||||
m_barotropicClosureOperator.BuildResidual(closure);
|
||||
m_displacementOperator.BuildResidual(displacement);
|
||||
m_centeringConstraintOperator.ApplyResidualRows(displacement);
|
||||
m_hydrostaticOperator.BuildResidual(hydrostatic);
|
||||
m_surfaceConstraintOperator.ApplyResidualRows(hydrostatic);
|
||||
m_massNormalizationOperator.BuildResidual(mass);
|
||||
|
||||
m_cachedResidual.SetSize(Height());
|
||||
@@ -659,11 +688,13 @@ namespace mean_field::operators {
|
||||
reducedDensityDirection, displacementDirection, gravityGradientDirection, reducedEnthalpyDirection,
|
||||
displacementAction
|
||||
);
|
||||
m_centeringConstraintOperator.ApplyJacobianRows(displacementDirection, displacementAction);
|
||||
|
||||
m_hydrostaticOperator.ApplyCompleteJacobianAction(
|
||||
reducedEnthalpyDirection, gravityPotentialDirection, bernoulliDirection(0), displacementDirection,
|
||||
hydrostaticAction
|
||||
);
|
||||
m_surfaceConstraintOperator.ApplyJacobianRows(reducedEnthalpyDirection, hydrostaticAction);
|
||||
|
||||
m_massNormalizationOperator.ApplyCompleteJacobianAction(
|
||||
reducedDensityDirection, displacementDirection, massAction
|
||||
@@ -712,7 +743,8 @@ namespace mean_field::operators {
|
||||
bool PreparedStellarEquilibriumOperator::IsPrepared() const noexcept {
|
||||
return m_isPrepared && m_gravityContext.IsPrepared() && m_barotropicClosureOperator.IsPrepared() &&
|
||||
m_hydrostaticOperator.IsPrepared() && m_displacementOperator.IsPrepared() &&
|
||||
m_massNormalizationOperator.IsPrepared();
|
||||
m_massNormalizationOperator.IsPrepared() && m_surfaceConstraintOperator.IsPrepared() &&
|
||||
m_centeringConstraintOperator.IsPrepared();
|
||||
}
|
||||
|
||||
double PreparedStellarEquilibriumOperator::GetTargetMass() const noexcept {
|
||||
@@ -771,6 +803,16 @@ namespace mean_field::operators {
|
||||
return m_massNormalizationOperator;
|
||||
}
|
||||
|
||||
const PreparedPressureSurfaceConstraint &
|
||||
PreparedStellarEquilibriumOperator::GetSurfaceConstraintOperator() const noexcept {
|
||||
return m_surfaceConstraintOperator;
|
||||
}
|
||||
|
||||
const PreparedCenteringConstraint &
|
||||
PreparedStellarEquilibriumOperator::GetCenteringConstraintOperator() const noexcept {
|
||||
return m_centeringConstraintOperator;
|
||||
}
|
||||
|
||||
void PreparedStellarEquilibriumOperator::VerifyPrepared() const {
|
||||
MFEM_VERIFY(
|
||||
IsPrepared(), "PreparedStellarEquilibriumOperator must be prepared before residual or Jacobian application."
|
||||
|
||||
Reference in New Issue
Block a user