-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add an MFEM Postprocessor to calculate the flux of an MFEM Vector variable through a boundary #32852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Add an MFEM Postprocessor to calculate the flux of an MFEM Vector variable through a boundary #32852
Changes from 4 commits
09e668b
bc39156
2904129
d7c9cf7
d6b17ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # MFEMVectorBoundaryFluxIntegralPostprocessor | ||
|
|
||
| !if! function=hasCapability('mfem') | ||
|
|
||
| ## Overview | ||
|
|
||
| Postprocessor for calculating the integral of the flux of a vector $H^{1,d}$, | ||
| $L^{2,d}$, $H(\mathrm{curl})$, or $H(\mathrm{div})$ conforming source variable through a given boundary surface. | ||
|
|
||
| !equation | ||
| (k \vec v \cdot \hat n)_{\partial\Omega} | ||
|
|
||
| where $\vec v \in H^{1,d}$, $L^{2,d}$, $H(\mathrm{curl})$, or $H(\mathrm{div})$, | ||
| $k$ is an optional scalar coefficient, $\partial\Omega$ is the user-specified mesh boundary, | ||
| and $\hat n$ is the outward facing unit normal vector on the boundary. | ||
| If $k$ is provided as a material coefficient, it must be defined on the boundary itself, rather than on a submesh adjacent to the boundary. | ||
|
|
||
| ## Example Input File Syntax | ||
|
|
||
| !listing mfem/submeshes/av_magnetostatic.i block=Postprocessors/CoilCurrent | ||
|
|
||
|
|
||
| !syntax parameters /Postprocessors/MFEMVectorBoundaryFluxIntegralPostprocessor | ||
|
|
||
| !syntax inputs /Postprocessors/MFEMVectorBoundaryFluxIntegralPostprocessor | ||
|
|
||
| !syntax children /Postprocessors/MFEMVectorBoundaryFluxIntegralPostprocessor | ||
|
|
||
| !if-end! | ||
|
|
||
| !else | ||
| !include mfem/mfem_warning.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| //* 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 "MFEMBoundaryRestrictable.h" | ||
|
|
||
| /** | ||
| * Compute the integral of the flux of an MFEM vector variable across a boundary, | ||
| * scaled by an optional scalar coefficient. | ||
| */ | ||
| class MFEMVectorBoundaryFluxIntegralPostprocessor : public MFEMPostprocessor, | ||
| public MFEMBoundaryRestrictable | ||
| { | ||
| public: | ||
| static InputParameters validParams(); | ||
|
|
||
| MFEMVectorBoundaryFluxIntegralPostprocessor(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 & _var; | ||
| mfem::Coefficient & _scalar_coef; | ||
| mfem::RT_FECollection _rt_fec; | ||
| mfem::ParFiniteElementSpace _rt_vector_fespace; | ||
| mfem::ParGridFunction _rt_var; | ||
| mfem::VectorGridFunctionCoefficient _var_coef; | ||
| mfem::ParLinearForm _boundary_integrator; | ||
| }; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||
| //* 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 "MFEMVectorBoundaryFluxIntegralPostprocessor.h" | ||||||
| #include "MFEMProblem.h" | ||||||
|
|
||||||
| registerMooseObject("MooseApp", MFEMVectorBoundaryFluxIntegralPostprocessor); | ||||||
|
|
||||||
| InputParameters | ||||||
| MFEMVectorBoundaryFluxIntegralPostprocessor::validParams() | ||||||
| { | ||||||
| InputParameters params = MFEMPostprocessor::validParams(); | ||||||
| params += MFEMBoundaryRestrictable::validParams(); | ||||||
| params.addClassDescription( | ||||||
| "Calculates the integral of the flux of a vector variable across a boundary."); | ||||||
| params.addParam<MFEMScalarCoefficientName>( | ||||||
| "coefficient", "1.", "Name of optional scalar coefficient to scale integrand by."); | ||||||
| params.addRequiredParam<VariableName>("variable", "Name of the vector variable."); | ||||||
| return params; | ||||||
| } | ||||||
|
|
||||||
| MFEMVectorBoundaryFluxIntegralPostprocessor::MFEMVectorBoundaryFluxIntegralPostprocessor( | ||||||
| const InputParameters & parameters) | ||||||
| : MFEMPostprocessor(parameters), | ||||||
| MFEMBoundaryRestrictable(parameters, | ||||||
| *getMFEMProblem() | ||||||
| .getProblemData() | ||||||
| .gridfunctions.Get(getParam<VariableName>("variable")) | ||||||
| ->ParFESpace() | ||||||
| ->GetParMesh()), | ||||||
|
amg56 marked this conversation as resolved.
Outdated
|
||||||
| _var( | ||||||
| getMFEMProblem().getProblemData().gridfunctions.GetRef(getParam<VariableName>("variable"))), | ||||||
| _scalar_coef(getScalarCoefficient("coefficient")), | ||||||
| _rt_fec(_var.ParFESpace()->GetMaxElementOrder(), getMesh().Dimension()), | ||||||
| _rt_vector_fespace(const_cast<mfem::ParMesh *>(&getMesh()), &_rt_fec), | ||||||
| _rt_var(&_rt_vector_fespace), | ||||||
| _var_coef(&_var), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| _boundary_integrator(&_rt_vector_fespace) | ||||||
| { | ||||||
| _boundary_integrator.AddBoundaryIntegrator( | ||||||
| new mfem::VectorFEBoundaryFluxLFIntegrator(_scalar_coef), getBoundaryMarkers()); | ||||||
| } | ||||||
|
|
||||||
| void | ||||||
| MFEMVectorBoundaryFluxIntegralPostprocessor::execute() | ||||||
| { | ||||||
| _rt_var.ProjectBdrCoefficientNormal(_var_coef, getBoundaryMarkers()); | ||||||
| _boundary_integrator.Assemble(); | ||||||
| _integral = _boundary_integrator(_rt_var); | ||||||
| } | ||||||
|
|
||||||
| PostprocessorValue | ||||||
| MFEMVectorBoundaryFluxIntegralPostprocessor::getValue() const | ||||||
| { | ||||||
| return _integral; | ||||||
| } | ||||||
|
|
||||||
| #endif | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| time,CoilCurrent | ||
| 0,0 | ||
| 1,-0.099634666692599 |
Uh oh!
There was an error while loading. Please reload this page.