-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add divergence and gradient auxkernels
- Loading branch information
1 parent
2732f7b
commit c0ccb4f
Showing
6 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "../common/pfem_extras.hpp" | ||
#include "MFEMAuxKernel.h" | ||
|
||
/* | ||
Class to set an L2 auxvariable to be the divergence of a H(div) vector variable. | ||
*/ | ||
class MFEMDivAux : public MFEMAuxKernel | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMDivAux(const InputParameters & parameters); | ||
|
||
virtual ~MFEMDivAux() = default; | ||
|
||
// Computes the auxvariable. | ||
virtual void execute() override; | ||
|
||
protected: | ||
// Name of source MFEMVariable to take the divergence of. | ||
VariableName _source_var_name; | ||
// Pointer to source gridfunction. | ||
mfem::ParGridFunction & _source_var; | ||
// FESpaces | ||
mfem::ParFiniteElementSpace & _hdiv_fespace; | ||
mfem::ParFiniteElementSpace & _l2_fespace; | ||
// Divergence operator | ||
mfem::common::ParDiscreteCurlOperator _div; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
#include "../common/pfem_extras.hpp" | ||
#include "MFEMAuxKernel.h" | ||
|
||
/* | ||
Class to set an H(curl) auxvariable to be the gradient of a H1 scalar variable. | ||
*/ | ||
class MFEMGradAux : public MFEMAuxKernel | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMGradAux(const InputParameters & parameters); | ||
|
||
virtual ~MFEMGradAux() = default; | ||
|
||
// Computes the auxvariable. | ||
virtual void execute() override; | ||
|
||
protected: | ||
// Name of source MFEMVariable to take the gradient of. | ||
VariableName _source_var_name; | ||
// Pointer to source gridfunction. | ||
mfem::ParGridFunction & _source_var; | ||
// FESpaces | ||
mfem::ParFiniteElementSpace & _h1_fespace; | ||
mfem::ParFiniteElementSpace & _hcurl_fespace; | ||
// Grad operator | ||
mfem::common::ParDiscreteGradOperator _grad; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include "MFEMDivAux.h" | ||
|
||
registerMooseObject("PlatypusApp", MFEMDivAux); | ||
|
||
/* | ||
Class to set an L2 auxvariable to be the divergence of a H(div) vector variable. | ||
*/ | ||
InputParameters | ||
MFEMDivAux::validParams() | ||
{ | ||
InputParameters params = MFEMAuxKernel::validParams(); | ||
params.addRequiredParam<VariableName>("source", | ||
"Vector H(div) MFEMVariable to take the divergence of."); | ||
return params; | ||
} | ||
|
||
MFEMDivAux::MFEMDivAux(const InputParameters & parameters) | ||
: MFEMAuxKernel(parameters), | ||
_source_var_name(getParam<VariableName>("source")), | ||
_source_var(*getMFEMProblem().getProblemData()._gridfunctions.Get(_source_var_name)), | ||
_hdiv_fespace(*_source_var.ParFESpace()), | ||
_l2_fespace(*_result_var.ParFESpace()), | ||
_div(&_hdiv_fespace, &_l2_fespace) | ||
{ | ||
_div.Assemble(); | ||
_div.Finalize(); | ||
} | ||
|
||
// Computes the auxvariable. | ||
void | ||
MFEMDivAux::execute() | ||
{ | ||
_div.Mult(_source_var, _result_var); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include "MFEMGradAux.h" | ||
|
||
registerMooseObject("PlatypusApp", MFEMGradAux); | ||
|
||
/* | ||
Class to set an H(curl) auxvariable to be the gradient of a H1 scalar variable. | ||
*/ | ||
InputParameters | ||
MFEMGradAux::validParams() | ||
{ | ||
InputParameters params = MFEMAuxKernel::validParams(); | ||
params.addRequiredParam<VariableName>("source", | ||
"Scalar H1 MFEMVariable to take the gradient of."); | ||
return params; | ||
} | ||
|
||
MFEMGradAux::MFEMGradAux(const InputParameters & parameters) | ||
: MFEMAuxKernel(parameters), | ||
_source_var_name(getParam<VariableName>("source")), | ||
_source_var(*getMFEMProblem().getProblemData()._gridfunctions.Get(_source_var_name)), | ||
_h1_fespace(*_source_var.ParFESpace()), | ||
_hcurl_fespace(*_result_var.ParFESpace()), | ||
_grad(&_h1_fespace, &_hcurl_fespace) | ||
{ | ||
_grad.Assemble(); | ||
_grad.Finalize(); | ||
} | ||
|
||
// Computes the auxvariable. | ||
void | ||
MFEMGradAux::execute() | ||
{ | ||
_grad.Mult(_source_var, _result_var); | ||
} |