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 : #pragma once 11 : 12 : #include "MooseVariableBase.h" 13 : #include "Coupleable.h" 14 : 15 : #define usingNeighborCoupleableMembers usingCoupleableMembers 16 : 17 : /** 18 : * Enhances Coupleable interface to also couple the values from neighbor elements 19 : * 20 : */ 21 : class NeighborCoupleable : public Coupleable 22 : { 23 : public: 24 : /** 25 : * Constructing the object 26 : * @param parameters Parameters that come from constructing the object 27 : * @param nodal true if we need to couple with nodal values, otherwise false 28 : * @param is_fv Whether the \p MooseObject is a finite volume object 29 : */ 30 : NeighborCoupleable(const MooseObject * moose_object, 31 : bool nodal, 32 : bool neighbor_nodal, 33 : bool is_fv = false); 34 : 35 : // neighbor 36 : virtual const VariableValue & coupledNeighborValue(const std::string & var_name, 37 : unsigned int comp = 0) const; 38 : 39 : std::vector<const VariableValue *> coupledNeighborValues(const std::string & var_name) const; 40 : std::vector<const VariableValue *> coupledNeighborValuesOld(const std::string & var_name) const; 41 : std::vector<const VariableValue *> coupledNeighborValuesOlder(const std::string & var_name) const; 42 : 43 : /** 44 : * Get the coupled neighbor variable value for \p var_name with derivative information for 45 : * automatic differentiation objects 46 : */ 47 : virtual const ADVariableValue & adCoupledNeighborValue(const std::string & var_name, 48 : unsigned int comp = 0) const; 49 : 50 : /** 51 : * Retrieve the coupled neighbor variable value whether AD or not 52 : */ 53 : template <bool is_ad> 54 : const auto & coupledGenericNeighborValue(const std::string & var_name, 55 : unsigned int comp = 0) const; 56 : 57 : /** 58 : * Retrieve the coupled neighbor variable gradient whether AD or not 59 : */ 60 : template <bool is_ad> 61 : const auto & coupledGenericNeighborGradient(const std::string & var_name, 62 : unsigned int comp = 0) const; 63 : 64 : /** 65 : * Get the time derivative of the coupled neighbor variable value for \p var_name with derivative 66 : * information for automatic differentiation objects 67 : */ 68 : virtual const ADVariableValue & adCoupledNeighborValueDot(const std::string & var_name, 69 : unsigned int comp = 0) const; 70 : 71 : std::vector<const ADVariableValue *> adCoupledNeighborValues(const std::string & var_name) const; 72 : 73 : /** 74 : * Get the coupled neighbor vector variable value for \p var_name with derivative information for 75 : * automatic differentiation objects 76 : */ 77 : virtual const ADVectorVariableValue & adCoupledVectorNeighborValue(const std::string & var_name, 78 : unsigned int comp = 0) const; 79 : virtual const VariableValue & coupledNeighborValueDot(const std::string & var_name, 80 : unsigned int comp = 0) const; 81 : virtual const VariableValue & coupledNeighborValueDotDu(const std::string & var_name, 82 : unsigned int comp = 0) const; 83 : virtual const VariableValue & coupledNeighborValueOld(const std::string & var_name, 84 : unsigned int comp = 0) const; 85 : virtual const VariableValue & coupledNeighborValueOlder(const std::string & var_name, 86 : unsigned int comp = 0) const; 87 : 88 : virtual const VariableGradient & coupledNeighborGradient(const std::string & var_name, 89 : unsigned int comp = 0) const; 90 : virtual std::vector<const VariableGradient *> 91 : coupledNeighborGradients(const std::string & var_name) const; 92 : virtual const VariableGradient & coupledNeighborGradientOld(const std::string & var_name, 93 : unsigned int comp = 0) const; 94 : virtual const VariableGradient & coupledNeighborGradientOlder(const std::string & var_name, 95 : unsigned int comp = 0) const; 96 : 97 : /** 98 : * Get the coupled neighbor variable gradient for \p var_name with derivative information for 99 : * automatic differentiation objects 100 : */ 101 : virtual const ADVariableGradient & adCoupledNeighborGradient(const std::string & var_name, 102 : unsigned int comp = 0) const; 103 : 104 : virtual const VectorVariableGradient & coupledVectorNeighborGradient(const std::string & var_name, 105 : unsigned int comp = 0) const; 106 : virtual const VectorVariableGradient & 107 : coupledVectorNeighborGradientOld(const std::string & var_name, unsigned int comp = 0) const; 108 : virtual const VectorVariableGradient & 109 : coupledVectorNeighborGradientOlder(const std::string & var_name, unsigned int comp = 0) const; 110 : 111 : virtual const ArrayVariableValue & coupledArrayNeighborValue(const std::string & var_name, 112 : unsigned int comp = 0) const; 113 : virtual const ArrayVariableGradient & coupledArrayNeighborGradient(const std::string & var_name, 114 : unsigned int comp = 0) const; 115 : virtual const ArrayVariableGradient & 116 : coupledArrayNeighborGradientOld(const std::string & var_name, unsigned int comp = 0) const; 117 : virtual const ArrayVariableGradient & 118 : coupledArrayNeighborGradientOlder(const std::string & var_name, unsigned int comp = 0) const; 119 : 120 : virtual const VariableSecond & coupledNeighborSecond(const std::string & var_name, 121 : unsigned int i = 0) const; 122 : 123 : virtual const VariableValue & coupledNeighborDofValues(const std::string & var_name, 124 : unsigned int comp = 0) const; 125 : virtual const VariableValue & coupledNeighborDofValuesOld(const std::string & var_name, 126 : unsigned int comp = 0) const; 127 : virtual const VariableValue & coupledNeighborDofValuesOlder(const std::string & var_name, 128 : unsigned int comp = 0) const; 129 : 130 : protected: 131 : bool _neighbor_nodal; 132 : }; 133 : 134 : template <bool is_ad> 135 : const auto & 136 264 : NeighborCoupleable::coupledGenericNeighborValue(const std::string & var_name, 137 : const unsigned int comp) const 138 : { 139 : if constexpr (is_ad) 140 13 : return adCoupledNeighborValue(var_name, comp); 141 : else 142 251 : return coupledNeighborValue(var_name, comp); 143 : } 144 : 145 : template <bool is_ad> 146 : const auto & 147 : NeighborCoupleable::coupledGenericNeighborGradient(const std::string & var_name, 148 : const unsigned int comp) const 149 : { 150 : if constexpr (is_ad) 151 : return adCoupledNeighborGradient(var_name, comp); 152 : else 153 : return coupledNeighborGradient(var_name, comp); 154 : }