Skip to content
Draft
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
70daa19
Make changes to EquationSystem and ProblemOperator to introduce non-l…
karthichockalingam Aug 13, 2025
f3e0ff3
Update jacobian in Mult
karthichockalingam Aug 20, 2025
1c7a288
Having one mult for EquationSystem and TimeDependentEquationSystem
karthichockalingam Aug 23, 2025
e8b4f7d
Use zero_vec instead of _true_rhs in problem operator
karthichockalingam Sep 14, 2025
7e9af0a
Compute residual using linearform
karthichockalingam Sep 14, 2025
e086613
Incorporate non-linear solve in EquationSystem::Mult
karthichockalingam Sep 22, 2025
60b2bc2
Example input file to test NL solve using MFEMDomainLFGradKernel
karthichockalingam Sep 22, 2025
f461ecd
Separate nonlinearactions from linearforms
karthichockalingam Sep 23, 2025
f0d91cb
Add DomainLFGradKernel
karthichockalingam Sep 11, 2025
8c10b5d
(1) Added aux vector for b contribution (2) Dropped bilinear contribu…
karthichockalingam Sep 30, 2025
5f150e9
Add MixedScalarWeakDivergenceKernel
karthichockalingam Sep 30, 2025
774d310
Add input file for non-linear problem but not working
karthichockalingam Sep 30, 2025
754732d
Fix the sign on b
karthichockalingam Oct 7, 2025
f54919a
Bug fix: Changed to use sol instead of _trueBlockSol in _jacobian->Ad…
karthichockalingam Oct 8, 2025
ca5e7ea
Dropped ApplyEssVals
karthichockalingam Oct 9, 2025
05bdb3c
Take initial condition as initial guess
karthichockalingam Oct 13, 2025
497e263
Add newton paramaters from executioner block
karthichockalingam Oct 15, 2025
b170a80
Change to the inputfile and square.e from mesh
karthichockalingam Oct 22, 2025
d13cd2e
remove nldiffusion.i
karthichockalingam Oct 22, 2025
f030cdc
Rename file from true_nldiffusion.i to nldiffusion.i
karthichockalingam Oct 22, 2025
ffe8715
change output folder name
karthichockalingam Oct 22, 2025
0dbf875
Add test for non-linear diffusion
karthichockalingam Oct 22, 2025
9b08fa1
Fixed typo in MFEMDomainLFGradKernel
karthichockalingam Oct 22, 2025
69b09be
Add documentation to kernels and functions
karthichockalingam Oct 22, 2025
12e20b3
Clang formatted #31772
karthichockalingam Oct 22, 2025
3784f26
Change default non-linear iteration to one
karthichockalingam Oct 27, 2025
1c52ce1
Fix for linear and non-linear problems #31772
karthichockalingam Oct 28, 2025
60f3881
Use local gridfunctions in UpdateEssDerivativeVals
karthichockalingam Oct 28, 2025
ea95fb0
Remove CopyVec
karthichockalingam Nov 4, 2025
e9bd16b
Accepted changes from mixed transient in TimeDependentEquationSystem:…
karthichockalingam Nov 11, 2025
02b3578
Debug prints in EquationSystem
karthichockalingam Nov 11, 2025
23aaf58
Commented call to UpdateEssDerivativeVals and debug prints in TimeDom…
karthichockalingam Nov 11, 2025
2b9f0ac
Drop changes to initial guess in ../framework/src/mfem/problem_operat…
karthichockalingam Nov 12, 2025
9ccd0f1
Changes in EquationSystem: (1) drop update to dTdt bc (2) drop debugg…
karthichockalingam Nov 12, 2025
7be1a1a
Remove MFEMProblem::setNewtonParameters
alexanderianblair Nov 12, 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,16 @@
# MFEMGradientGridFunction

!if! function=hasCapability('mfem')

## Summary

This is class which can be use as vector cofficients to MFEM problems.

## Overview

`MFEMGradientGridFunction` is intended to allow the specification of `mfem::VectorCoefficient` object to add to the MFEM problem in a manner consistent with the standard MOOSE Materials system.

!if-end!

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

!if! function=hasCapability('mfem')

!syntax description /Kernels/MFEMDomainLFGradKernel

## Overview

Adds the domain integrator for integrating the linear form

!equation
(\vec{f}, \nabla v)_\Omega \,\,\, \forall v \in V

where $v \in H^1$ is the test variable and $\vec{f}$ is a
vector forcing coefficient.

This term arises from the weak form of the forcing term

!equation
-\nabla \cdot \vec{f}

## Example Input File Syntax

!listing mfem/kernels/nldiffusion.i block=/Kernels

!syntax parameters /Kernels/MFEMDomainLFGradKernel

!syntax inputs /Kernels/MFEMDomainLFGradKernel

!syntax children /Kernels/MFEMDomainLFGradKernel

!if-end!

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

!if! function=hasCapability('mfem')

!syntax description /Kernels/MFEMMixedScalarWeakDivergenceKernel

## Overview

Adds the domain integrator for integrating the bilinear form

!equation
(-\vec{\lambda} u, \nabla v)_\Omega \,\,\, \forall v \in V

where $v \in H^1$ is the test variable and $\vec{\lambda}$ is a
vector forcing coefficient.

This term arises from the weak form of the forcing term

!equation
\nabla \cdot(\vec{\lambda} u)

## Example Input File Syntax

!listing mfem/kernels/nldiffusion.i block=/Kernels

!syntax parameters /Kernels/MFEMMixedScalarWeakDivergenceKernel

!syntax inputs /Kernels/MFEMMixedScalarWeakDivergenceKernel

!syntax children /Kernels/MFEMMixedScalarWeakDivergenceKernel

!if-end!

!else
!include mfem/mfem_warning.md
52 changes: 48 additions & 4 deletions framework/include/mfem/equation_systems/EquationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class EquationSystem : public mfem::Operator

public:
friend class EquationSystemProblemOperator;
friend class TimeDomainEquationSystemProblemOperator;

EquationSystem() = default;
~EquationSystem() override;
Expand Down Expand Up @@ -63,6 +62,8 @@ class EquationSystem : public mfem::Operator
/// Update all essentially constrained true DoF markers and values on boundaries
virtual void ApplyEssentialBCs();

virtual void BuildNonLinearActions();

/// Perform trivial eliminations of coupled variables lacking corresponding test variables
virtual void EliminateCoupledVariables();

Expand All @@ -71,7 +72,8 @@ class EquationSystem : public mfem::Operator
/// Build mixed bilinear forms (off-diagonal Jacobian contributions)
virtual void BuildMixedBilinearForms();
/// Build all forms comprising this EquationSystem
virtual void BuildEquationSystem();
virtual void BuildEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
mfem::Array<int> & btoffsets);

/// Form Jacobian operator based on on- and off-diagonal bilinear form contributions, populate
/// solution and RHS vectors of true DoFs, and apply constraints
Expand All @@ -97,6 +99,8 @@ class EquationSystem : public mfem::Operator
mfem::BlockVector & trueX,
mfem::BlockVector & trueRHS);

void UpdateJacobian() const;

/// Build linear system, with essential boundary conditions accounted for
virtual void BuildJacobian(mfem::BlockVector & trueX, mfem::BlockVector & trueRHS);

Expand Down Expand Up @@ -155,7 +159,7 @@ class EquationSystem : public mfem::Operator
// Components of weak form. // Named according to test variable
Moose::MFEM::NamedFieldsMap<mfem::ParBilinearForm> _blfs;
Moose::MFEM::NamedFieldsMap<mfem::ParLinearForm> _lfs;
Moose::MFEM::NamedFieldsMap<mfem::ParNonlinearForm> _nlfs;
Moose::MFEM::NamedFieldsMap<mfem::ParLinearForm> _nlfs;
Moose::MFEM::NamedFieldsMap<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm>>
_mblfs; // named according to trial variable

Expand All @@ -177,6 +181,12 @@ class EquationSystem : public mfem::Operator
Moose::MFEM::NamedFieldsMap<
Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>> & kernels_map);

void ApplyDomainNLActionIntegrators(
const std::string & test_var_name,
std::shared_ptr<mfem::ParLinearForm> form,
Moose::MFEM::NamedFieldsMap<
Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>> & kernels_map);

template <class FormType>
void ApplyBoundaryBLFIntegrators(
const std::string & trial_var_name,
Expand Down Expand Up @@ -212,8 +222,16 @@ class EquationSystem : public mfem::Operator
Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMEssentialBC>>> _essential_bc_map;

mutable mfem::OperatorHandle _jacobian;
mutable mfem::Vector _trueRHS;
mutable mfem::BlockVector _trueBlockRHS, _trueBlockSol, _BlockResidual;

Moose::MFEM::GridFunctions * _gfuncs;
mfem::Array<int> * _block_true_offsets;
mfem::Array<int> empty_tdof;

mfem::AssemblyLevel _assembly_level;

bool _non_linear = false;
};

template <class FormType>
Expand Down Expand Up @@ -264,6 +282,30 @@ EquationSystem::ApplyDomainLFIntegrators(
}
}

inline void
EquationSystem::ApplyDomainNLActionIntegrators(
const std::string & test_var_name,
std::shared_ptr<mfem::ParLinearForm> form,
Moose::MFEM::NamedFieldsMap<
Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>> & kernels_map)
{
if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
{
auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
for (auto & kernel : kernels)
{
mfem::LinearFormIntegrator * integ = kernel->createNLActionIntegrator();
if (integ != nullptr)
{
_non_linear = true;
kernel->isSubdomainRestricted()
? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
: form->AddDomainIntegrator(std::move(integ));
}
}
}
}

template <class FormType>
void
EquationSystem::ApplyBoundaryBLFIntegrators(
Expand Down Expand Up @@ -322,14 +364,16 @@ EquationSystem::ApplyBoundaryLFIntegrators(
class TimeDependentEquationSystem : public EquationSystem
{
public:
friend class TimeDomainEquationSystemProblemOperator;
TimeDependentEquationSystem(const Moose::MFEM::TimeDerivativeMap & time_derivative_map);

/// Initialise
virtual void Init(Moose::MFEM::GridFunctions & gridfunctions,
mfem::AssemblyLevel assembly_level) override;

virtual void SetTimeStep(mfem::real_t dt);
virtual void UpdateEquationSystem();
virtual void UpdateEquationSystem(Moose::MFEM::GridFunctions & gridfunctions,
mfem::Array<int> & btoffsets);

virtual void AddKernel(std::shared_ptr<MFEMKernel> kernel) override;
virtual void BuildBilinearForms() override;
Expand Down
4 changes: 4 additions & 0 deletions framework/include/mfem/executioners/MFEMProblemSolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class MFEMProblemSolve : public SolveObject
protected:
MFEMProblem & _mfem_problem;
std::vector<std::shared_ptr<Moose::MFEM::ProblemOperatorBase>> & _problem_operators;
unsigned int _nl_max_its;
mfem::real_t _nl_abs_tol;
mfem::real_t _nl_rel_tol;
unsigned int _print_level;
};

#endif
34 changes: 34 additions & 0 deletions framework/include/mfem/kernels/MFEMDomainLFGradKernel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//* 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 "MFEMKernel.h"

/**
* \f[
* (f, v)
* \f]
*/
class MFEMDomainLFGradKernel : public MFEMKernel
{
public:
static InputParameters validParams();

MFEMDomainLFGradKernel(const InputParameters & parameters);

virtual mfem::LinearFormIntegrator * createNLActionIntegrator() override;

protected:
mfem::Coefficient & _coef;
mfem::ScalarVectorProductCoefficient * _product_coeff;
};

#endif
1 change: 1 addition & 0 deletions framework/include/mfem/kernels/MFEMKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MFEMKernel : public MFEMGeneralUserObject, public MFEMBlockRestrictable

/// Create a new MFEM integrator to apply to the weak form. Ownership managed by the caller.
virtual mfem::LinearFormIntegrator * createLFIntegrator() { return nullptr; }
virtual mfem::LinearFormIntegrator * createNLActionIntegrator() { return nullptr; }
virtual mfem::BilinearFormIntegrator * createBFIntegrator() { return nullptr; }

/// Get name of the test variable labelling the weak form this kernel is added to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//* 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 "MFEMKernel.h"

/**
* \f[
* (k \vec \nabla u, \vec \nabla v)
* \f]
*/
class MFEMMixedScalarWeakDivergenceKernel : public MFEMKernel
{
public:
static InputParameters validParams();

MFEMMixedScalarWeakDivergenceKernel(const InputParameters & parameters);

virtual mfem::BilinearFormIntegrator * createBFIntegrator() override;

protected:
mfem::Coefficient & _coef;
mfem::ScalarVectorProductCoefficient * _product_coef;
};

#endif
9 changes: 5 additions & 4 deletions framework/include/mfem/problem/MFEMProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class MFEMProblem : public ExternalProblem
MFEMProblem(const InputParameters & params);
virtual ~MFEMProblem() {}

virtual void initialSetup() override;
virtual void externalSolve() override {}
virtual void syncSolutions(Direction) override {}

Expand Down Expand Up @@ -160,10 +159,12 @@ class MFEMProblem : public ExternalProblem
InputParameters & parameters);

/**
* Add the nonlinear solver to the system. TODO: allow user to specify solver options,
* similar to the linear solvers.
* Add the nonlinear solver to the system.
*/
void addMFEMNonlinearSolver();
void addMFEMNonlinearSolver(unsigned int nl_max_its,
mfem::real_t nl_abs_tol,
mfem::real_t nl_rel_tol,
unsigned int print_level);

/**
* Method used to get an mfem FEC depending on the variable family specified in the input file.
Expand Down
Loading