feat(libmeanfield): centrifugal + pressure

This commit is contained in:
2026-08-04 14:24:55 -04:00
parent 9bc4f2758a
commit dc912fd15e
115 changed files with 260058 additions and 163261 deletions

View File

@@ -4,7 +4,9 @@ module;
module mean_field;
namespace mean_field::integrators {
AdvectionIntegrator::AdvectionIntegrator(const mapping::DomainMapper &map) : m_map(map) {}
AdvectionIntegrator::AdvectionIntegrator(const mapping::DomainMapper &map)
: m_map(map) {
}
void AdvectionIntegrator::AssembleElementVector(
const mfem::Array<const mfem::FiniteElement *> &el,
@@ -16,17 +18,17 @@ namespace mean_field::integrators {
return;
}
const mfem::FiniteElement *fe_v = el[0];
const mfem::FiniteElement *fe_v = el[0];
const mfem::FiniteElement *fe_rho = el[1];
const int dof_v = fe_v->GetDof();
const int dof_rho = fe_rho->GetDof();
const int dim = Tr.GetSpaceDim();
const int dof_v = fe_v->GetDof();
const int dof_rho = fe_rho->GetDof();
const int dim = Tr.GetSpaceDim();
const mfem::Vector &v_dofs = *elfun[0];
const mfem::Vector &rho_dofs = *elfun[1];
const mfem::Vector &v_dofs = *elfun[0];
const mfem::Vector &rho_dofs = *elfun[1];
mfem::Vector &r_v = *elvec[0];
mfem::Vector &r_v = *elvec[0];
r_v.SetSize(dof_v * dim);
r_v = 0.0;
if (elvec[1]) {
@@ -37,7 +39,8 @@ namespace mean_field::integrators {
mfem::Vector shape_v(dof_v), shape_rho(dof_rho);
mfem::DenseMatrix dshape_v_ref(dof_v, dim), dshape_v_phys(dof_v, dim);
const mfem::IntegrationRule *ir = &mfem::IntRules.Get(fe_v->GetGeomType(), 2 * fe_v->GetOrder() + 1);
const mfem::IntegrationRule *ir =
&mfem::IntRules.Get(fe_v->GetGeomType(), 2 * fe_v->GetOrder() + 1);
for (int q = 0; q < ir->GetNPoints(); q++) {
const mfem::IntegrationPoint &ip = ir->IntPoint(q);
@@ -80,7 +83,8 @@ namespace mean_field::integrators {
for (int i = 0; i < dof_v; ++i) {
for (int c = 0; c < dim; ++c) {
r_v(i + c * dof_v) += shape_v(i) * rho_val * adv_val(c) * weight;
r_v(i + c * dof_v) +=
shape_v(i) * rho_val * adv_val(c) * weight;
}
}
}
@@ -91,27 +95,30 @@ namespace mean_field::integrators {
mfem::ElementTransformation &Tr,
const mfem::Array<const mfem::Vector *> &elfun,
const mfem::Array2D<mfem::DenseMatrix *> &elmats
) {
const mfem::FiniteElement *fe_v = el[0];
) {
const mfem::FiniteElement *fe_v = el[0];
const mfem::FiniteElement *fe_rho = el[1];
const int dof_v = fe_v->GetDof();
const int dof_rho = fe_rho->GetDof();
const int dim = Tr.GetSpaceDim();
const int dof_v = fe_v->GetDof();
const int dof_rho = fe_rho->GetDof();
const int dim = Tr.GetSpaceDim();
const mfem::Vector &v_dofs = *elfun[0];
const mfem::Vector &rho_dofs = *elfun[1];
const mfem::Vector &v_dofs = *elfun[0];
const mfem::Vector &rho_dofs = *elfun[1];
mfem::DenseMatrix *dv_dv = elmats(0, 0);
mfem::DenseMatrix *dv_drho = elmats(0, 1);
mfem::DenseMatrix *dv_dv = elmats(0, 0);
mfem::DenseMatrix *dv_drho = elmats(0, 1);
if (dv_dv) *dv_dv = 0.0;
if (dv_drho) *dv_drho = 0.0;
if (dv_dv)
*dv_dv = 0.0;
if (dv_drho)
*dv_drho = 0.0;
mfem::Vector shape_v(dof_v), shape_rho(dof_rho);
mfem::DenseMatrix dshape_v_ref(dof_v, dim), dshape_v_phys(dof_v, dim);
const mfem::IntegrationRule *ir = &mfem::IntRules.Get(fe_v->GetGeomType(), 2 * fe_v->GetOrder() + 1);
const mfem::IntegrationRule *ir =
&mfem::IntRules.Get(fe_v->GetGeomType(), 2 * fe_v->GetOrder() + 1);
for (int q = 0; q < ir->GetNPoints(); q++) {
const mfem::IntegrationPoint &ip = ir->IntPoint(q);
@@ -164,22 +171,27 @@ namespace mean_field::integrators {
double v_dot_grad_phi_j = 0.0;
for (int k = 0; k < dim; ++k) {
v_dot_grad_phi_j += v_val(k) * dshape_v_phys(j, k);
v_dot_grad_phi_j +=
v_val(k) * dshape_v_phys(j, k);
}
for (int d = 0; d < dim; ++d) {
// Trial function component
int col = j + d * dof_v;
int col = j + d * dof_v;
// \rho (\delta \vec{v} \cdot \nabla \vec{v})
// \delta v is along direction 'd' for the cth component of advection
// \delta v is along direction 'd' for the cth
// component of advection
double termA = shape_v(j) * grad_v(c, d);
// \rho(\vec{v} \cdot \nabla \delta \vec{v})
// Only non-zero when the advected component matches the test component
double termB = (c == d) ? v_dot_grad_phi_j : 0.0;
// Only non-zero when the advected component
// matches the test component
double termB =
(c == d) ? v_dot_grad_phi_j : 0.0;
(*dv_dv)(row, col) += shape_v(i) * rho_val * (termA + termB) * weight;
(*dv_dv)(row, col) += shape_v(i) * rho_val *
(termA + termB) * weight;
}
}
}
@@ -192,7 +204,7 @@ namespace mean_field::integrators {
for (int c = 0; c < dim; ++c) {
int row = i + c * dof_v;
for (int j = 0; j < dof_rho; ++j) {
int col = j;
int col = j;
// \delta \rho * (\vec{v} \cdot \nabla \vec{v})
double term = shape_rho(j) * adv_val(c);
@@ -203,4 +215,4 @@ namespace mean_field::integrators {
}
}
}
}
} // namespace mean_field::integrators