Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fcc5c55
Initial commit for the inner product aux kernel .C and .h
Sep 25, 2025
5953d06
Initiall structure for the Cross Product AuxKernel s(x) * (U x V) pro…
Sep 25, 2025
9516ee2
Update framework/include/mfem/auxkernels/MFEMCrossProductAux.h
Giannis95 Oct 2, 2025
5ccf432
Add the L2 fe space with map_type = INTEGRAL. refs #31612
Oct 13, 2025
d23ae7c
Rebased and conflict resolved L2Int addition. Refs #31613
Oct 13, 2025
39387c2
Add documentation and tests for the InnerProduct. Refs #31612
Oct 13, 2025
de7338c
Add L2 option for MFEMVectorFESpaces and cross-product auxkernel test…
Oct 22, 2025
d046ff2
Fix EOF. Refs #31612
Oct 22, 2025
d27bc9c
Remove unicode characters. Refs #31612
Oct 22, 2025
b5e1d6d
change test from XMLDiff to csvdiff due to large data files, fixed cl…
Oct 22, 2025
79cb0de
Apply suggestions from code review
Giannis95 Oct 27, 2025
94d0626
Move the cross product auxkernel checks before construction, add miss…
Oct 27, 2025
9c611d5
clang-format. Refs #31612
Oct 27, 2025
d6c6f5f
Fix auxkernels test file. Refs #31612
Oct 27, 2025
ca2b748
Add a new MFEMVectorL2InnerProductIntegralPostprocessor which allow L…
Oct 30, 2025
5439ac6
Typos fix. Refs #31612
Oct 30, 2025
757e748
Clean up dot product auxkernel. Refs #31612
Oct 30, 2025
2e3fcde
delete whitespaces. Refs #31612
Oct 30, 2025
c41ff3a
deactive joule_Q_aux block. Refs #31612
Oct 30, 2025
de1f3be
Fix input file type. Refs #13612
Oct 30, 2025
fba3115
av_magnetostatic block change. Refs #31612
Oct 30, 2025
b74dd79
Update the execution orders in the cross_product examples. Refs #31612
Oct 30, 2025
1a948f2
update the inner product test. Refs #31612
Oct 30, 2025
c0eb0de
Test moving everything in the constructor for the cross-product test.…
Oct 31, 2025
2f8091d
Simplified cross product test with runtime less than a second. Refs #…
Oct 31, 2025
947c539
Whitespaces fix. Refs #31612
Oct 31, 2025
c9b17f9
Clean up av_magnetostatic. Refs #31612
Oct 31, 2025
d71b22d
Test fix. Refs #31612
Oct 31, 2025
9e55ffd
Restructure InnerProduct auxkernel. Refs #31612.
Oct 31, 2025
252de90
apply patch. Refs #31612
Oct 31, 2025
59617c1
Tighten up the solver tolerance for the inner product test. Refs #31612
Nov 3, 2025
cb8343d
Rename input vector variable names for clarity to first_source_vec an…
Nov 3, 2025
17ab87f
Add softer XLMDiff requiriments to avoid reducing the solvers toleran…
Nov 3, 2025
43e62dc
Apply suggestions from code review
Giannis95 Nov 6, 2025
c7d5559
Adding missing docstrings, delete postprocessor, fix auxkernels/test …
Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# MFEMCrossProductAux

!if! function=hasCapability('mfem')

## Summary

!syntax description /AuxKernels/MFEMCrossProductAux

## Overview

AuxKernel for calculating the cross product of two vector fields and projecting onto an L2 vector finite element space mfem auxvariable.

!equation
s(x)(u\times v), \,\,\,

where $u$ and $v$ are the two vector fields and $s(x)$ is an optional scaling.

## Example Input File Syntax

!listing mfem/auxkernels/crossproduct.i block=/AuxKernels

!syntax parameters /AuxKernels/MFEMCrossProductAux

!syntax inputs /AuxKernels/MFEMCrossProductAux

!syntax children /AuxKernels/MFEMCrossProductAux

!if-end!

!else
!include mfem/mfem_warning.md
31 changes: 31 additions & 0 deletions framework/doc/content/source/mfem/auxkernels/MFEMDotProductAux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# MFEMDotProductAux

!if! function=hasCapability('mfem')

## Summary

!syntax description /AuxKernels/MFEMDotProductAux

## Overview

AuxKernel for calculating the inner product of two vector fields and projecting onto an L2 finite element space mfem auxvariable.

!equation
s u\cdot v, \,\,\,

where $u$ and $v$ are the two fields and $s(x)$ is an optional scaling.

## Example Input File Syntax

!listing mfem/kernels/curlcurl.i block=/AuxKernels

!syntax parameters /AuxKernels/MFEMDotProductAux

!syntax inputs /AuxKernels/MFEMDotProductAux

!syntax children /AuxKernels/MFEMDotProductAux

!if-end!

!else
!include mfem/mfem_warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# MFEMVectorL2InnerProductIntegralPostprocessor

!if! function=hasCapability('mfem')

## Summary

!syntax description /Postprocessors/MFEMVectorL2InnerProductIntegralPostprocessor

## Overview

Postprocessor for calculating the integral of the dot product between two L2 vector variables over a
user-specified subdomain of the mesh:

!equation
(k \vec u, \vec v)_\Omega

where $\vec u$, $\vec v \in \mathrm{L2}$, $k$ is an optional scalar coefficient,
and $\Omega$ is the user-specified mesh subdomain.

## Example Input File Syntax

!listing mfem/submeshes/av_magnetostatic.i block=Postprocessors

!syntax parameters /Postprocessors/MFEMVectorL2InnerProductIntegralPostprocessor

!syntax inputs /Postprocessors/MFEMVectorL2InnerProductIntegralPostprocessor

!syntax children /Postprocessors/MFEMVectorL2InnerProductIntegralPostprocessor

!if-end!

!else
!include mfem/mfem_warning.md
60 changes: 60 additions & 0 deletions framework/include/mfem/auxkernels/MFEMCrossProductAux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//* This file is part of the MOOSE framework
//* https://mooseframework.inl.gov
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifdef MOOSE_MFEM_ENABLED
#pragma once

#include "MFEMAuxKernel.h"
#include "mfem.hpp"

/**
* Project s(x) * (U x V) onto a vector MFEM auxvariable.
*
* Parameters:
* - variable (AuxVariableName, required): AuxVariable name (inherited)
* - first_source_vec (VariableName, required): vector MFEM variable U (vdim = 3)
* - second_source_vec (VariableName, required): vector MFEM variable V (vdim = 3)
* - scale_factor (mfem::real_t, default=1.0): constant multiplier s(x)=scale_factor
*
* Notes:
* - Default L2_FECollection with map_type = VALUE and optional map_type = INTEGRAL .
* - Currently supports only interior DOFs (no shared/constrained DOFs).
* - Enforces 3D: mesh dimension and all involved vdim must be 3.
*/
class MFEMCrossProductAux : public MFEMAuxKernel
{
public:
static InputParameters validParams();

MFEMCrossProductAux(const InputParameters & parameters);
~MFEMCrossProductAux() override = default;

void execute() override;

protected:
// Names of vector sources
const VariableName _u_var_name;
const VariableName _v_var_name;

// References to the vector ParGridFunctions
const mfem::ParGridFunction & _u_var;
const mfem::ParGridFunction & _v_var;
const mfem::real_t _scale_factor;

mfem::VectorGridFunctionCoefficient _u_coef;
mfem::VectorGridFunctionCoefficient _v_coef;
mfem::VectorCrossProductCoefficient _cross_uv;
mfem::ConstantCoefficient _scale_c;
mfem::ScalarVectorProductCoefficient _final_coef; // coef suffix !!

// Constant multiplier
// const mfem::real_t _scale_factor;
};

#endif // MOOSE_MFEM_ENABLED
53 changes: 53 additions & 0 deletions framework/include/mfem/auxkernels/MFEMDotProductAux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//* This file is part of the MOOSE framework
//* https://mooseframework.inl.gov
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifdef MOOSE_MFEM_ENABLED
#pragma once

#include "MFEMAuxKernel.h"
#include "mfem.hpp"

/**
* Project s(x) * (U . V) onto a scalar MFEM auxvariable.
*
* Parameters:
* - first_source_vec (VariableName): vector MFEM variable U
* - second_source_vec (VariableName): vector MFEM variable V
* - scale_factor (mfem::real_t, default=1.0): constant multiplier
* - scale_variable (VariableName, optional): scalar MFEM variable s(x)
*/
class MFEMDotProductAux : public MFEMAuxKernel
{
public:
static InputParameters validParams();

MFEMDotProductAux(const InputParameters & parameters);
~MFEMDotProductAux() override = default;

void execute() override;

protected:
// Names of vector sources
const VariableName _u_var_name;
const VariableName _v_var_name;

// References to the vector ParGridFunctions
const mfem::ParGridFunction & _u_var;
const mfem::ParGridFunction & _v_var;
const mfem::real_t _scale_factor;

mfem::VectorGridFunctionCoefficient _u_coef;
mfem::VectorGridFunctionCoefficient _v_coef;
mfem::InnerProductCoefficient _dot_uv;
mfem::ConstantCoefficient _scale_c;

mfem::ProductCoefficient _final_coef;
};

#endif // MOOSE_MFEM_ENABLED
2 changes: 2 additions & 0 deletions framework/include/mfem/fespaces/MFEMScalarFESpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class MFEMScalarFESpace : public MFEMSimplifiedFESpace
private:
/// Name of the family of finite element collections to use
const std::string _fec_type;
/// Name of the map types VALUE OR INTEGRAL to use (meaningful only for L2)
const std::string _fec_map;
};

#endif
3 changes: 3 additions & 0 deletions framework/include/mfem/fespaces/MFEMVectorFESpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class MFEMVectorFESpace : public MFEMSimplifiedFESpace

/// The number of vector components in the reference space.
const int _range_dim;

/// Name of the map types VALUE or INTEGRAL to use (meaningful only for L2)
const std::string _fec_map;
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//* This file is part of the MOOSE framework
//* https://mooseframework.inl.gov
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifdef MOOSE_MFEM_ENABLED

#pragma once
#include "MFEMPostprocessor.h"
#include "MFEMBlockRestrictable.h"

/**
* Compute the integral of the innter product between two MFEM vector FE variables, scaled by an
* optional scalar coefficient.
*/
class MFEMVectorL2InnerProductIntegralPostprocessor : public MFEMPostprocessor,
public MFEMBlockRestrictable
{
public:
static InputParameters validParams();

MFEMVectorL2InnerProductIntegralPostprocessor(const InputParameters & parameters);

/**
* Evaluate integral.
*/
virtual void execute() override;

/**
* Return the last evaluated integral value.
*/
virtual PostprocessorValue getValue() const override final;

private:
mfem::real_t _integral;
mfem::ParGridFunction & _primal_var;
mfem::ParGridFunction & _dual_var;
mfem::Coefficient & _scalar_coef;
mfem::VectorGridFunctionCoefficient _dual_var_coef;
mfem::ScalarVectorProductCoefficient _scaled_dual_var_coef;
mfem::ParLinearForm _subdomain_integrator;
};

#endif
81 changes: 81 additions & 0 deletions framework/src/mfem/auxkernels/MFEMCrossProductAux.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//* This file is part of the MOOSE framework
//* https://mooseframework.inl.gov
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#ifdef MOOSE_MFEM_ENABLED

#include "MFEMCrossProductAux.h"
#include "MFEMProblem.h"
#include "mfem.hpp"

registerMooseObject("MooseApp", MFEMCrossProductAux);

InputParameters
MFEMCrossProductAux::validParams()
{
InputParameters params = MFEMAuxKernel::validParams();
params.addClassDescription("Projects s(x) * (U x V) onto a vector MFEM auxvariable");
params.addRequiredParam<VariableName>("first_source_vec", "Vector MFEMVariable U (vdim=3)");
params.addRequiredParam<VariableName>("second_source_vec", "Vector MFEMVariable V (vdim=3)");
params.addParam<mfem::real_t>(
"scale_factor", 1.0, "Constant multiplier applied to the cross product");
return params;
}

MFEMCrossProductAux::MFEMCrossProductAux(const InputParameters & parameters)
: MFEMAuxKernel(parameters),
_u_var_name(getParam<VariableName>("first_source_vec")),
_v_var_name(getParam<VariableName>("second_source_vec")),
_u_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_u_var_name)),
_v_var(*getMFEMProblem().getProblemData().gridfunctions.Get(_v_var_name)),
_scale_factor(getParam<mfem::real_t>("scale_factor")),
_u_coef(&_u_var),
_v_coef(&_v_var),
_cross_uv(_u_coef, _v_coef),
_scale_c(_scale_factor),
_final_coef(_scale_c, _cross_uv)
{
// // Must be vector L2 with interior DOFs
mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
const int mesh_dim = fes->GetMesh()->Dimension();

// Enforce 3D cross product
if (mesh_dim != 3)
mooseError("MFEMCrossProductAux requires a 3D mesh (Dimension == 3).");

if (fes->GetVDim() != 3)
mooseError("MFEMCrossProductAux requires AuxVariable to have vdim == 3.");

// // Must be L2
if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()))
mooseError("MFEMCrossProductAux requires the target variable to use L2_FECollection.");

// // Must have no shared/constrained DOFs (pure interior DOFs)
if (fes->GetTrueVSize() != fes->GetVSize())
mooseError("MFEMCrossProductAux currently supports only L2 spaces with interior DOFs "
"(no shared/constrained DOFs).");
}

void
MFEMCrossProductAux::execute()
{
// // Build vector coefficient: s(x) * (U x V)
// mfem::VectorGridFunctionCoefficient Ucoef(&_u_var);
// mfem::VectorGridFunctionCoefficient Vcoef(&_v_var);
// mfem::VectorCrossProductCoefficient cross_uv(Ucoef, Vcoef); // vector-valued

// // s(x) = constant scale factor for now
// mfem::ConstantCoefficient scoef(_scale_factor);
// mfem::ScalarVectorProductCoefficient final_vec(scoef, cross_uv); // vector-valued

// MFEM element projection for L2
_result_var = 0.0;
_result_var.ProjectCoefficient(_final_coef);
}

#endif // MOOSE_MFEM_ENABLED
Loading