forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a vector material property extractor to auxvariables, refs idahol…
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
framework/include/auxkernels/FunctorVectorMatPropElementalAux.h
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,37 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* 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 | ||
|
||
#pragma once | ||
|
||
#include "AuxKernel.h" | ||
|
||
/** | ||
* Evaluate a functor vector material property with the element as the functor argument | ||
* and save one component to an auxiliary variable | ||
*/ | ||
template <bool is_ad> | ||
class FunctorVectorMatPropElementalAuxTempl : public AuxKernel | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
FunctorVectorMatPropElementalAuxTempl(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeValue() override; | ||
|
||
/// Reference to the material property | ||
const Moose::Functor<GenericRealVectorValue<is_ad>> & _mat_prop; | ||
|
||
/// The component to retrieve | ||
const unsigned int _component; | ||
}; | ||
|
||
typedef FunctorVectorMatPropElementalAuxTempl<false> FunctorVectorMatPropElementalAux; | ||
typedef FunctorVectorMatPropElementalAuxTempl<true> FunctorADVectorMatPropElementalAux; |
43 changes: 43 additions & 0 deletions
43
framework/src/auxkernels/FunctorVectorMatPropElementalAux.C
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,43 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* 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 | ||
|
||
#include "FunctorVectorMatPropElementalAux.h" | ||
#include "metaphysicl/raw_type.h" | ||
|
||
registerMooseObject("MooseApp", FunctorVectorMatPropElementalAux); | ||
registerMooseObject("MooseApp", FunctorADVectorMatPropElementalAux); | ||
|
||
template <bool is_ad> | ||
InputParameters | ||
FunctorVectorMatPropElementalAuxTempl<is_ad>::validParams() | ||
{ | ||
InputParameters params = AuxKernel::validParams(); | ||
params.addClassDescription( | ||
"Evaluates a functor vector material property on the current element." | ||
"For finite volume, this evaluates the material property at the centroid."); | ||
params.addRequiredParam<MaterialPropertyName>("mat_prop", "The functor material property"); | ||
params.addRequiredParam<unsigned int>("component", "Component of the vector material property"); | ||
return params; | ||
} | ||
|
||
template <bool is_ad> | ||
FunctorVectorMatPropElementalAuxTempl<is_ad>::FunctorVectorMatPropElementalAuxTempl( | ||
const InputParameters & parameters) | ||
: AuxKernel(parameters), | ||
_mat_prop(getFunctor<GenericRealVectorValue<is_ad>>("mat_prop")), | ||
_component(getParam<unsigned int>("component")) | ||
{ | ||
} | ||
|
||
template <bool is_ad> | ||
Real | ||
FunctorVectorMatPropElementalAuxTempl<is_ad>::computeValue() | ||
{ | ||
return MetaPhysicL::raw_value(_mat_prop(_current_elem)(_component)); | ||
} |