Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "InterfaceIntegralVariableValuePostprocessor.h" 11 : #include "InterfaceValueTools.h" 12 : 13 : registerMooseObject("MooseApp", InterfaceIntegralVariableValuePostprocessor); 14 : 15 : InputParameters 16 29251 : InterfaceIntegralVariableValuePostprocessor::validParams() 17 : { 18 29251 : InputParameters params = InterfaceIntegralPostprocessor::validParams(); 19 : 20 29251 : params.addRequiredCoupledVar("variable", 21 : "The name of the variable on the primary side of the interface"); 22 29251 : params.addCoupledVar( 23 : "neighbor_variable", 24 : "The name of the variable on the secondary side of the interface. By default " 25 : "the primary side variable name is used for the secondary side as well"); 26 29251 : params.addClassDescription("Add access to variables and their gradient on an interface."); 27 87753 : params.addParam<MooseEnum>("interface_value_type", 28 58502 : InterfaceValueTools::InterfaceAverageOptions(), 29 : "Type of value we want to compute"); 30 29251 : return params; 31 0 : } 32 : 33 375 : InterfaceIntegralVariableValuePostprocessor::InterfaceIntegralVariableValuePostprocessor( 34 375 : const InputParameters & parameters) 35 : : InterfaceIntegralPostprocessor(parameters), 36 : MooseVariableInterface<Real>(this, 37 : false, 38 : "variable", 39 : Moose::VarKindType::VAR_ANY, 40 : Moose::VarFieldType::VAR_FIELD_STANDARD), 41 375 : _u(coupledValue("variable")), 42 375 : _grad_u(coupledGradient("variable")), 43 750 : _u_neighbor(parameters.isParamSetByUser("neighbor_variable") 44 750 : ? coupledNeighborValue("neighbor_variable") 45 375 : : coupledNeighborValue("variable")), 46 750 : _grad_u_neighbor(parameters.isParamSetByUser("neighbor_variable") 47 750 : ? coupledNeighborGradient("neighbor_variable") 48 375 : : coupledNeighborGradient("variable")), 49 375 : _interface_value_type(parameters.get<MooseEnum>("interface_value_type")), 50 375 : _neighbor_fv_variable( 51 750 : parameters.isParamSetByUser("neighbor_variable") 52 802 : ? dynamic_cast<const MooseVariableFV<Real> *>(getFieldVar("neighbor_variable", 0)) 53 802 : : dynamic_cast<const MooseVariableFV<Real> *>(getFieldVar("variable", 0))) 54 : { 55 375 : addMooseVariableDependency(&mooseVariableField()); 56 : 57 : // Primary and secondary variable should both be of a similar variable type 58 375 : if (parameters.isParamSetByUser("neighbor_variable")) 59 969 : if ((_has_fv_vars && !getFieldVar("neighbor_variable", 0)->isFV()) || 60 646 : (!_has_fv_vars && getFieldVar("neighbor_variable", 0)->isFV())) 61 0 : mooseError("For the InterfaceIntegralVariableValuePostprocessor, variable and " 62 : "neighbor_variable should be of a similar variable type."); 63 375 : } 64 : 65 : Real 66 2436 : InterfaceIntegralVariableValuePostprocessor::computeQpIntegral() 67 : { 68 2436 : if (_has_fv_vars) 69 : { 70 : mooseAssert(_fi, "This should never be null. If it is then something went wrong in execute()"); 71 : 72 : // If both variables are different, assume this is a boundary for both variables 73 : Real u, u_neighbor; 74 0 : if (_fv_variable != _neighbor_fv_variable) 75 : { 76 0 : u = MetaPhysicL::raw_value(_fv_variable->getBoundaryFaceValue(*_fi, determineState())); 77 0 : u_neighbor = MetaPhysicL::raw_value( 78 0 : _neighbor_fv_variable->getBoundaryFaceValue(*_fi, determineState())); 79 : } 80 : // If only one variable is specified, assume this is an internal interface 81 : // FIXME Make sure getInternalFaceValue uses the right interpolation method, see #16585 82 : else 83 0 : u = u_neighbor = MetaPhysicL::raw_value((*_fv_variable)(makeCDFace(*_fi), determineState())); 84 : 85 0 : return InterfaceValueTools::getQuantity(_interface_value_type, u, u_neighbor); 86 : } 87 : else 88 2436 : return InterfaceValueTools::getQuantity(_interface_value_type, _u[_qp], _u_neighbor[_qp]); 89 : } 90 : 91 : bool 92 0 : InterfaceIntegralVariableValuePostprocessor::hasFaceSide(const FaceInfo &, bool) const 93 : { 94 : // Our default interface kernel treats elem and neighbor sides equivalently so we will assume for 95 : // now that we will happily consume functor evaluations on either side of a face and any 96 : // interpolation between said evaluations 97 0 : return true; 98 : }