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 "FVAdvectedInterpolationMethod.h"
11 :
12 : FVAdvectedInterpolationMethod::AdvectedSystemContribution
13 8 : FVAdvectedInterpolationMethod::advectedInterpolate(const Moose::FunctorBase<Real> & functor,
14 : const FaceInfo & face,
15 : const Moose::StateArg & state,
16 : const Real mass_flux) const
17 : {
18 : mooseAssert(face.neighborPtr(),
19 : "Advected interpolation with a Moose functor requires a two-sided internal face.");
20 :
21 8 : const Moose::ElemArg elem_arg{face.elemPtr(), false};
22 8 : const Moose::ElemArg neighbor_arg{face.neighborPtr(), false};
23 8 : const Real elem_value = functor(elem_arg, state);
24 8 : const Real neighbor_value = functor(neighbor_arg, state);
25 :
26 8 : if (!needsGradients())
27 4 : return advectedInterpolate(face, elem_value, neighbor_value, nullptr, nullptr, mass_flux);
28 :
29 4 : const auto elem_grad = functor.gradient(elem_arg, state);
30 4 : const auto neighbor_grad = functor.gradient(neighbor_arg, state);
31 4 : return advectedInterpolate(
32 4 : face, elem_value, neighbor_value, &elem_grad, &neighbor_grad, mass_flux);
33 : }
34 :
35 : Real
36 12 : FVAdvectedInterpolationMethod::advectedInterpolateValue(const FaceInfo & face,
37 : Real elem_value,
38 : Real neighbor_value,
39 : const VectorValue<Real> * elem_grad,
40 : const VectorValue<Real> * neighbor_grad,
41 : Real mass_flux) const
42 : {
43 : const auto result =
44 12 : advectedInterpolate(face, elem_value, neighbor_value, elem_grad, neighbor_grad, mass_flux);
45 12 : return result.weights_matrix.first * elem_value + result.weights_matrix.second * neighbor_value -
46 12 : result.rhs_face_value;
47 : }
48 :
49 : Real
50 8 : FVAdvectedInterpolationMethod::advectedInterpolateValue(const Moose::FunctorBase<Real> & functor,
51 : const FaceInfo & face,
52 : const Moose::StateArg & state,
53 : const Real mass_flux) const
54 : {
55 : mooseAssert(face.neighborPtr(),
56 : "Advected interpolation with a Moose functor requires a two-sided internal face.");
57 :
58 8 : const Moose::ElemArg elem_arg{face.elemPtr(), false};
59 8 : const Moose::ElemArg neighbor_arg{face.neighborPtr(), false};
60 8 : const Real elem_value = functor(elem_arg, state);
61 8 : const Real neighbor_value = functor(neighbor_arg, state);
62 :
63 8 : if (!needsGradients())
64 4 : return advectedInterpolateValue(face, elem_value, neighbor_value, nullptr, nullptr, mass_flux);
65 :
66 4 : const auto elem_grad = functor.gradient(elem_arg, state);
67 4 : const auto neighbor_grad = functor.gradient(neighbor_arg, state);
68 4 : return advectedInterpolateValue(
69 4 : face, elem_value, neighbor_value, &elem_grad, &neighbor_grad, mass_flux);
70 : }
|