Skip to content

Commit

Permalink
Add a vector material property extractor to auxvariables, refs idahol…
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Nov 15, 2021
1 parent 9373e58 commit 342a9f4
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
37 changes: 37 additions & 0 deletions framework/include/auxkernels/FunctorVectorMatPropElementalAux.h
@@ -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 framework/src/auxkernels/FunctorVectorMatPropElementalAux.C
@@ -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));
}

0 comments on commit 342a9f4

Please sign in to comment.