Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
54 changes: 54 additions & 0 deletions framework/include/mfem/auxkernels/MFEMCrossProductAux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//* 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.
*
* Notes:
* - 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;
/// Scaling factor applied on the resulting field
const mfem::real_t _scale_factor;

/// Coefficient wrappers
mfem::VectorGridFunctionCoefficient _u_coef;
mfem::VectorGridFunctionCoefficient _v_coef;
mfem::VectorCrossProductCoefficient _cross_uv;
mfem::ConstantCoefficient _scale_c;

///Final coefficient that applies the scale factor to the crossproduct
mfem::ScalarVectorProductCoefficient _final_coef;
};

#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.
*
* Notes:
* - Currently supports only interior DOFs (no shared/constrained DOFs).
* - The target variable's FE Space must be L2.
*/
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;

/// Coefficient wrappers
mfem::VectorGridFunctionCoefficient _u_coef;
mfem::VectorGridFunctionCoefficient _v_coef;
mfem::InnerProductCoefficient _dot_uv;
mfem::ConstantCoefficient _scale_c;

///Final coefficient that applies the scale factor to the inner product
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
73 changes: 73 additions & 0 deletions framework/src/mfem/auxkernels/MFEMCrossProductAux.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//* 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)
{
// Check the target variable type and dimensions
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()
{

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

#endif // MOOSE_MFEM_ENABLED
61 changes: 61 additions & 0 deletions framework/src/mfem/auxkernels/MFEMDotProductAux.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//* 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 "MFEMDotProductAux.h"
#include "MFEMProblem.h"

registerMooseObject("MooseApp", MFEMDotProductAux);

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

MFEMDotProductAux::MFEMDotProductAux(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),
_dot_uv(_u_coef, _v_coef),
_scale_c(_scale_factor),
_final_coef(_scale_c, _dot_uv)
{
// Must be L2
mfem::ParFiniteElementSpace * fes = _result_var.ParFESpace();
if (!dynamic_cast<const mfem::L2_FECollection *>(fes->FEColl()))
paramError("variable", "The target variable must use L2_FECollection.");

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

void
MFEMDotProductAux::execute()
{
// Project into the scalar aux result variable per element projection for L2
_result_var = 0.0;
_result_var.ProjectCoefficient(_final_coef);
}

#endif // MOOSE_MFEM_ENABLED
13 changes: 12 additions & 1 deletion framework/src/mfem/fespaces/MFEMScalarFESpace.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ MFEMScalarFESpace::validParams()
basis_types,
"Specifies the basis used for scalar elements. H1 spaces require a closed basis "
"(GaussLobatto Positive ClosedUniform Serendipity ClosedGL)");
MooseEnum fec_maps("VALUE INTEGRAL", "VALUE", true);
params.addParam<MooseEnum>(
"fec_map",
fec_maps,
"Specify the FE map type used VALUE or INTEGRAL (meaningful for L2 only)");

return params;
}

MFEMScalarFESpace::MFEMScalarFESpace(const InputParameters & parameters)
: MFEMSimplifiedFESpace(parameters), _fec_type(getParam<MooseEnum>("fec_type"))
: MFEMSimplifiedFESpace(parameters),
_fec_type(getParam<MooseEnum>("fec_type")),
_fec_map(getParam<MooseEnum>("fec_map"))
{
}

Expand All @@ -48,6 +55,10 @@ MFEMScalarFESpace::getFECName() const
// This is to get around an MFEM bug (to be removed in #31525)
basis = (basis == "@G" || basis == "_T0") ? "" : basis;

if (_fec_map == "INTEGRAL")
return "L2Int" + basis + "_" + std::to_string(getProblemDim()) + "D_P" +
std::to_string(_fec_order);

return _fec_type + basis + "_" + std::to_string(getProblemDim()) + "D_P" +
std::to_string(_fec_order);
}
Expand Down
11 changes: 11 additions & 0 deletions framework/src/mfem/fespaces/MFEMVectorFESpace.C
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ MFEMVectorFESpace::validParams()
"(the default) means it will be the same as the problem dimension. "
"Note that MFEM does not currently support 2D vectors in 1D space "
"for ND and RT elements.");
MooseEnum fec_maps("VALUE INTEGRAL", "VALUE", true);
params.addParam<MooseEnum>(
"fec_map",
fec_maps,
"Specify the FE map type used VALUE or INTEGRAL (meaningful for L2 only)");

return params;
}

Expand Down Expand Up @@ -88,6 +94,11 @@ MFEMVectorFESpace::getFECName() const
// This is to get around an MFEM bug (to be removed in #31525)
basis = (basis == "@Gg" || basis == "@G" || basis == "_T0") ? "" : basis;

if (_fec_map == "INTEGRAL" && _fec_type == "L2")
{
return "L2Int" + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
}

return actual_type + basis + "_" + std::to_string(pdim) + "D_P" + std::to_string(_fec_order);
}

Expand Down
Loading