feat(libmeanfield): centrifugal + pressure
This commit is contained in:
@@ -1,95 +1,183 @@
|
||||
module;
|
||||
|
||||
#include <stroid/stroid.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <mfem.hpp>
|
||||
#include <stroid/stroid.h>
|
||||
|
||||
export module mean_field:fem;
|
||||
|
||||
export import :physics.contexts;
|
||||
export import :boundary.contexts;
|
||||
export import :mapping.domain_mapper;
|
||||
export import :utils.misc;
|
||||
export import :utils.user;
|
||||
export import :quadrature.mfem;
|
||||
export import :field.mfem;
|
||||
|
||||
export namespace mean_field::fem {
|
||||
using GravityField = field::Field<field::Gravity>;
|
||||
using DisplacementField = field::Field<field::Displacement>;
|
||||
using DensityField = field::Field<field::Density>;
|
||||
using EnthalpyField = field::Field<field::Enthalpy>;
|
||||
|
||||
struct FEM {
|
||||
// =====================================================================
|
||||
// Mesh
|
||||
// =====================================================================
|
||||
|
||||
stroid::StroidMesh smesh;
|
||||
std::unique_ptr<mfem::ParMesh> mesh;
|
||||
|
||||
// =====================================
|
||||
// 2. Finite Element Collections
|
||||
// =====================================
|
||||
// H1 (Continuous): For Gravitational Potential (Phi) and Velocity (v)
|
||||
std::unique_ptr<mfem::FiniteElementCollection> H1_fec;
|
||||
// =====================================================================
|
||||
// Compile-time field descriptors
|
||||
// =====================================================================
|
||||
|
||||
// L2 (Discontinuous): For Density (rho) to fix O-grid boundary scalloping
|
||||
std::unique_ptr<mfem::FiniteElementCollection> L2_fec;
|
||||
GravityField gravityField;
|
||||
DisplacementField displacementField;
|
||||
DensityField densityField;
|
||||
EnthalpyField enthalpyField;
|
||||
|
||||
// H(div)/RT space for gravitational field
|
||||
std::unique_ptr<mfem::RT_FECollection> RT_fec;
|
||||
// =====================================================================
|
||||
// Gravity field
|
||||
//
|
||||
// Collection members are declared before their corresponding spaces so
|
||||
// that the spaces are destroyed first.
|
||||
// =====================================================================
|
||||
|
||||
std::unique_ptr<mfem::FiniteElementCollection> gravityPotentialFec;
|
||||
|
||||
// =====================================
|
||||
// 3. Finite Element Spaces
|
||||
// =====================================
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> H1_fes; // Scalar continuous (Gravity)
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> Vec_H1_fes; // Vector continuous (Velocity field)
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> L2_fes; // Scalar discontinuous (Density)
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> RT_fes; // H(div)/RT space for gravitational field
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> gravityPotentialFes;
|
||||
|
||||
// Preconditioning for Gravity
|
||||
std::unique_ptr<mfem::ParLORDiscretization> H1_lor_disc;
|
||||
const mfem::ParFiniteElementSpace *H1_lor_fes{nullptr};
|
||||
std::unique_ptr<mfem::FiniteElementCollection> gravityFluxFec;
|
||||
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> gravityFluxFes;
|
||||
|
||||
// =====================================================================
|
||||
// Displacement field
|
||||
// =====================================================================
|
||||
|
||||
std::unique_ptr<mfem::FiniteElementCollection> displacementFec;
|
||||
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> displacementFes;
|
||||
|
||||
std::unique_ptr<mfem::ParGridFunction> displacement;
|
||||
|
||||
// =====================================================================
|
||||
// Density field
|
||||
// =====================================================================
|
||||
|
||||
std::unique_ptr<mfem::FiniteElementCollection> densityFec;
|
||||
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> densityFes;
|
||||
|
||||
// =====================================================================
|
||||
// Specific-enthalpy field
|
||||
// =====================================================================
|
||||
|
||||
std::unique_ptr<mfem::FiniteElementCollection> enthalpyFec;
|
||||
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> enthalpyFes;
|
||||
|
||||
// =====================================================================
|
||||
// Compactification coordinate
|
||||
// =====================================================================
|
||||
|
||||
std::unique_ptr<mfem::H1_FECollection> compactificationFec;
|
||||
|
||||
std::unique_ptr<mfem::ParFiniteElementSpace> compactificationFes;
|
||||
|
||||
std::unique_ptr<mfem::ParGridFunction> compactificationCoordinate;
|
||||
|
||||
// =====================================================================
|
||||
// Domain mapping
|
||||
//
|
||||
// These are declared after displacement so that they are destroyed
|
||||
// before the displacement grid function to which mapping may refer.
|
||||
// DomainMapper is retained only for legacy integrators. New operators
|
||||
// use DomainMapperStateless exclusively.
|
||||
// =====================================================================
|
||||
|
||||
// =====================================
|
||||
// 4. Domain Mapping
|
||||
// =====================================
|
||||
std::unique_ptr<mapping::DomainMapper> mapping;
|
||||
|
||||
// =====================================
|
||||
// 5. Global System Tracking
|
||||
// =====================================
|
||||
// [ Velocity | Density | Mapping Parameters (Surface) ]
|
||||
mfem::Array<int> block_true_offsets;
|
||||
std::unique_ptr<mapping::DomainMapperStateless> domainMapperStateless;
|
||||
|
||||
mfem::Array<int> gravity_block_true_offsets;
|
||||
// =====================================================================
|
||||
// Block layouts
|
||||
//
|
||||
// These arrays are retained only for legacy code. Canonical operator
|
||||
// layouts are defined by the compile-time forms in :utils.blocks.
|
||||
//
|
||||
// Main system: [Displacement | Density]
|
||||
// Gravity system: [Flux | Potential]
|
||||
// =====================================================================
|
||||
|
||||
// Essential Boundary Conditions for the fluid (e.g., surface stress-free)
|
||||
mfem::Array<int> ess_v_tdofs;
|
||||
mfem::Array<int> blockTrueOffsets;
|
||||
mfem::Array<int> gravityBlockTrueOffsets;
|
||||
|
||||
// Elements entirely in the vacuum domain where fluid equations are not solved
|
||||
mfem::Array<int> vacuum_tdof_rho;
|
||||
mfem::Array<int> vacuum_tdof_v;
|
||||
// =====================================================================
|
||||
// Boundary conditions and domain masks
|
||||
// =====================================================================
|
||||
|
||||
mfem::Array<int> essentialDisplacementTdofs;
|
||||
mfem::Array<int> vacuumDensityTdofs;
|
||||
mfem::Array<int> vacuumEnthalpyTdofs;
|
||||
mfem::Array<int> vacuumDisplacementTdofs;
|
||||
|
||||
// =====================================================================
|
||||
// Global diagnostics
|
||||
// =====================================================================
|
||||
|
||||
// =====================================
|
||||
// 6. Multiphysics State & Integration
|
||||
// =====================================
|
||||
mfem::Vector com;
|
||||
mfem::DenseMatrix Q;
|
||||
|
||||
int int_order{3};
|
||||
std::unique_ptr<mfem::IntegrationRule> int_rule;
|
||||
// =====================================================================
|
||||
// Physics and boundary contexts
|
||||
// =====================================================================
|
||||
|
||||
physics::GravityContext gravity_context;
|
||||
boundary::BoundaryContext boundary_context;
|
||||
physics::GravityContext gravityContext;
|
||||
boundary::BoundaryContext boundaryContext;
|
||||
|
||||
std::unique_ptr<quadrature::RuleFactory> quadrature_factory;
|
||||
std::unique_ptr<quadrature::RuleFactory> quadratureFactory;
|
||||
|
||||
// =====================================================================
|
||||
// Validation
|
||||
// =====================================================================
|
||||
|
||||
// =====================================
|
||||
// 7. Utilities
|
||||
// =====================================
|
||||
[[nodiscard]] bool okay() const {
|
||||
return (mesh != nullptr) &&
|
||||
(H1_fec != nullptr) && (L2_fec != nullptr) && (RT_fec != nullptr) &&
|
||||
(H1_fes != nullptr) && (Vec_H1_fes != nullptr) && (L2_fes != nullptr) && (RT_fes != nullptr);
|
||||
return mesh != nullptr &&
|
||||
|
||||
gravityPotentialFec != nullptr &&
|
||||
gravityPotentialFes != nullptr &&
|
||||
gravityFluxFec != nullptr && gravityFluxFes != nullptr &&
|
||||
|
||||
displacementFec != nullptr && displacementFes != nullptr &&
|
||||
displacement != nullptr &&
|
||||
|
||||
densityFec != nullptr && densityFes != nullptr &&
|
||||
|
||||
enthalpyFec != nullptr && enthalpyFes != nullptr &&
|
||||
|
||||
compactificationFec != nullptr &&
|
||||
compactificationFes != nullptr &&
|
||||
compactificationCoordinate != nullptr &&
|
||||
|
||||
mapping != nullptr && domainMapperStateless != nullptr &&
|
||||
quadratureFactory != nullptr &&
|
||||
|
||||
blockTrueOffsets.Size() == 3 &&
|
||||
gravityBlockTrueOffsets.Size() == 3;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool has_mapping() const { return mapping != nullptr; }
|
||||
[[nodiscard]] bool has_mapping() const {
|
||||
return mapping != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
FEM setup_fem(const std::string &filename, const utils::Args &args, int extra_refine = 0);
|
||||
}
|
||||
|
||||
FEM setup_fem(
|
||||
const std::string &filename,
|
||||
const utils::Args &args,
|
||||
int extraRefine = 0
|
||||
);
|
||||
} // namespace mean_field::fem
|
||||
|
||||
Reference in New Issue
Block a user