Skip to content

Commit aea74f0

Browse files
authored
Merge pull request #31840 from freiler/p1_radiation_linearfv
P1 radiation model for the Linear FV system
2 parents c14f6e6 + 17dd5e8 commit aea74f0

15 files changed

+602
-141
lines changed

framework/include/linearfvbcs/LinearFVAdvectionDiffusionFunctorRobinBC.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
#pragma once
1111

12-
#include "LinearFVAdvectionDiffusionBC.h"
12+
#include "LinearFVAdvectionDiffusionFunctorRobinBCBase.h"
1313

1414
/**
1515
* Class implementing a Robin boundary condition for linear finite
1616
* volume variables. This is only applicable for advection-diffusion problems.
1717
* alpha, beta, gamma are provided as functors and may vary in space/time.
1818
*/
19-
class LinearFVAdvectionDiffusionFunctorRobinBC : public LinearFVAdvectionDiffusionBC
19+
class LinearFVAdvectionDiffusionFunctorRobinBC : public LinearFVAdvectionDiffusionFunctorRobinBCBase
2020
{
2121
public:
2222
/**
@@ -27,23 +27,11 @@ class LinearFVAdvectionDiffusionFunctorRobinBC : public LinearFVAdvectionDiffusi
2727

2828
static InputParameters validParams();
2929

30-
virtual Real computeBoundaryValue() const override;
31-
32-
virtual Real computeBoundaryNormalGradient() const override;
33-
34-
virtual Real computeBoundaryValueMatrixContribution() const override;
35-
36-
virtual Real computeBoundaryValueRHSContribution() const override;
37-
38-
virtual Real computeBoundaryGradientMatrixContribution() const override;
39-
40-
virtual Real computeBoundaryGradientRHSContribution() const override;
41-
4230
protected:
4331
/// Getter functions (consistent entry point for all derived classes)
44-
virtual Real getAlpha(Moose::FaceArg face, Moose::StateArg state) const;
45-
virtual Real getBeta(Moose::FaceArg face, Moose::StateArg state) const;
46-
virtual Real getGamma(Moose::FaceArg face, Moose::StateArg state) const;
32+
virtual Real getAlpha(Moose::FaceArg face, Moose::StateArg state) const override;
33+
virtual Real getBeta(Moose::FaceArg face, Moose::StateArg state) const override;
34+
virtual Real getGamma(Moose::FaceArg face, Moose::StateArg state) const override;
4735

4836
/// Functor giving the alpha coefficient (multiplying normal gradient)
4937
const Moose::Functor<Real> & _alpha;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 "LinearFVAdvectionDiffusionBC.h"
13+
14+
/**
15+
* Class implementing the base for the Robin boundary condition for linear finite
16+
* volume variables.
17+
* alpha, beta, gamma are defined as functors in derived classes.
18+
*/
19+
class LinearFVAdvectionDiffusionFunctorRobinBCBase : public LinearFVAdvectionDiffusionBC
20+
{
21+
public:
22+
/**
23+
* Class constructor.
24+
* @param parameters The InputParameters for the object
25+
*/
26+
LinearFVAdvectionDiffusionFunctorRobinBCBase(const InputParameters & parameters);
27+
28+
static InputParameters validParams();
29+
30+
virtual Real computeBoundaryValue() const override;
31+
32+
virtual Real computeBoundaryNormalGradient() const override;
33+
34+
virtual Real computeBoundaryValueMatrixContribution() const override;
35+
36+
virtual Real computeBoundaryValueRHSContribution() const override;
37+
38+
virtual Real computeBoundaryGradientMatrixContribution() const override;
39+
40+
virtual Real computeBoundaryGradientRHSContribution() const override;
41+
42+
protected:
43+
/// Getter functions (consistent entry point for all derived classes)
44+
virtual Real getAlpha(Moose::FaceArg face, Moose::StateArg state) const = 0;
45+
virtual Real getBeta(Moose::FaceArg face, Moose::StateArg state) const = 0;
46+
virtual Real getGamma(Moose::FaceArg face, Moose::StateArg state) const = 0;
47+
};

framework/src/linearfvbcs/LinearFVAdvectionDiffusionFunctorRobinBC.C

Lines changed: 2 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ registerMooseObject("MooseApp", LinearFVAdvectionDiffusionFunctorRobinBC);
1414
InputParameters
1515
LinearFVAdvectionDiffusionFunctorRobinBC::validParams()
1616
{
17-
InputParameters params = LinearFVAdvectionDiffusionBC::validParams();
17+
InputParameters params = LinearFVAdvectionDiffusionFunctorRobinBCBase::validParams();
1818
params.addClassDescription(
1919
"Adds a Robin BC of the form \\alpha * \\nabla \\phi*n + \\beta * \\phi = \\gamma, "
2020
"which can be used for the assembly of linear "
@@ -31,7 +31,7 @@ LinearFVAdvectionDiffusionFunctorRobinBC::validParams()
3131

3232
LinearFVAdvectionDiffusionFunctorRobinBC::LinearFVAdvectionDiffusionFunctorRobinBC(
3333
const InputParameters & parameters)
34-
: LinearFVAdvectionDiffusionBC(parameters),
34+
: LinearFVAdvectionDiffusionFunctorRobinBCBase(parameters),
3535
_alpha(getFunctor<Real>("alpha")),
3636
_beta(getFunctor<Real>("beta")),
3737
_gamma(getFunctor<Real>("gamma"))
@@ -67,125 +67,3 @@ LinearFVAdvectionDiffusionFunctorRobinBC::getGamma(Moose::FaceArg face, Moose::S
6767
{
6868
return _gamma(face, state);
6969
}
70-
71-
Real
72-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryValue() const
73-
{
74-
const auto face = singleSidedFaceArg(_current_face_info);
75-
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
76-
"This should not be assigned on an internal face!");
77-
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
78-
? _current_face_info->elemInfo()
79-
: _current_face_info->neighborInfo();
80-
const auto state = determineState();
81-
82-
const auto alpha = getAlpha(face, state);
83-
const auto beta = getBeta(face, state);
84-
const auto gamma = getGamma(face, state);
85-
86-
const auto phi = _var.getElemValue(*elem_info, state);
87-
const auto grad_phi = _var.gradSln(*elem_info);
88-
89-
const auto & nhat = _current_face_info->normal();
90-
91-
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
92-
const auto projection = d_cf * nhat;
93-
const auto vc = d_cf - (projection * nhat);
94-
return ((alpha * phi) + (alpha * grad_phi * vc) + (gamma * projection)) /
95-
(alpha + (beta * projection));
96-
}
97-
98-
Real
99-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryNormalGradient() const
100-
{
101-
const auto face = singleSidedFaceArg(_current_face_info);
102-
const auto state = determineState();
103-
const auto alpha = getAlpha(face, state);
104-
mooseAssert(!MooseUtils::isZero(alpha), "Alpha should not be 0!");
105-
const auto beta = _beta(face, state);
106-
const auto gamma = _gamma(face, state);
107-
return (gamma - beta * computeBoundaryValue()) / alpha;
108-
}
109-
110-
// implicit terms for advection kernel
111-
Real
112-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryValueMatrixContribution() const
113-
{
114-
const auto face = singleSidedFaceArg(_current_face_info);
115-
const auto state = determineState();
116-
const auto alpha = getAlpha(face, state);
117-
const auto beta = getBeta(face, state);
118-
const auto & nhat = _current_face_info->normal();
119-
120-
return alpha / (alpha + (beta * computeCellToFaceVector() * nhat));
121-
}
122-
123-
// explicit terms for advection kernel
124-
Real
125-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryValueRHSContribution() const
126-
{
127-
const auto face = singleSidedFaceArg(_current_face_info);
128-
const auto state = determineState();
129-
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
130-
"This should not be assigned on an internal face!");
131-
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
132-
? _current_face_info->elemInfo()
133-
: _current_face_info->neighborInfo();
134-
135-
const auto alpha = getAlpha(face, state);
136-
const auto beta = getBeta(face, state);
137-
const auto gamma = getGamma(face, state);
138-
139-
const auto & grad_phi = _var.gradSln(*elem_info);
140-
141-
const auto & nhat = _current_face_info->normal();
142-
143-
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
144-
const auto projection = d_cf * nhat;
145-
const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
146-
147-
return (gamma * projection / (alpha + (beta * projection))) +
148-
(alpha * grad_phi * vc / (alpha + (beta * projection)));
149-
}
150-
151-
// implicit terms for diffusion kernel
152-
Real
153-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryGradientMatrixContribution() const
154-
{
155-
const auto face = singleSidedFaceArg(_current_face_info);
156-
const auto state = determineState();
157-
158-
const auto alpha = getAlpha(face, state);
159-
const auto beta = getBeta(face, state);
160-
161-
const auto & nhat = _current_face_info->normal();
162-
163-
return beta / (alpha + (beta * computeCellToFaceVector() * nhat));
164-
}
165-
166-
// explicit terms for diffusion kernel
167-
Real
168-
LinearFVAdvectionDiffusionFunctorRobinBC::computeBoundaryGradientRHSContribution() const
169-
{
170-
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
171-
"This should not be assigned on an internal face!");
172-
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
173-
? _current_face_info->elemInfo()
174-
: _current_face_info->neighborInfo();
175-
const auto face = singleSidedFaceArg(_current_face_info);
176-
const auto state = determineState();
177-
const auto & grad_phi = _var.gradSln(*elem_info);
178-
179-
const auto alpha = getAlpha(face, state);
180-
const auto beta = getBeta(face, state);
181-
const auto gamma = getGamma(face, state);
182-
183-
const auto & nhat = _current_face_info->normal();
184-
185-
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
186-
const auto projection = d_cf * nhat;
187-
const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
188-
189-
return (gamma / alpha) + (-beta * gamma * projection / alpha / (alpha + (beta * projection))) +
190-
(-beta * grad_phi * vc / (alpha + (beta * projection)));
191-
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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 "LinearFVAdvectionDiffusionFunctorRobinBCBase.h"
11+
12+
InputParameters
13+
LinearFVAdvectionDiffusionFunctorRobinBCBase::validParams()
14+
{
15+
InputParameters params = LinearFVAdvectionDiffusionBC::validParams();
16+
return params;
17+
}
18+
19+
LinearFVAdvectionDiffusionFunctorRobinBCBase::LinearFVAdvectionDiffusionFunctorRobinBCBase(
20+
const InputParameters & parameters)
21+
: LinearFVAdvectionDiffusionBC(parameters)
22+
{
23+
}
24+
25+
Real
26+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValue() const
27+
{
28+
const auto face = singleSidedFaceArg(_current_face_info);
29+
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
30+
"This should not be assigned on an internal face!");
31+
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
32+
? _current_face_info->elemInfo()
33+
: _current_face_info->neighborInfo();
34+
const auto state = determineState();
35+
36+
const auto alpha = getAlpha(face, state);
37+
const auto beta = getBeta(face, state);
38+
const auto gamma = getGamma(face, state);
39+
40+
const auto phi = _var.getElemValue(*elem_info, state);
41+
const auto grad_phi = _var.gradSln(*elem_info);
42+
43+
const auto & nhat = _current_face_info->normal();
44+
45+
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
46+
const auto projection = d_cf * nhat;
47+
const auto vc = d_cf - (projection * nhat);
48+
return ((alpha * phi) + (alpha * grad_phi * vc) + (gamma * projection)) /
49+
(alpha + (beta * projection));
50+
}
51+
52+
Real
53+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryNormalGradient() const
54+
{
55+
const auto face = singleSidedFaceArg(_current_face_info);
56+
const auto state = determineState();
57+
const auto alpha = getAlpha(face, state);
58+
mooseAssert(!MooseUtils::isZero(alpha), "Alpha should not be 0!");
59+
const auto beta = getBeta(face, state);
60+
const auto gamma = getGamma(face, state);
61+
return (gamma - beta * computeBoundaryValue()) / alpha;
62+
}
63+
64+
// implicit terms for advection kernel
65+
Real
66+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueMatrixContribution() const
67+
{
68+
const auto face = singleSidedFaceArg(_current_face_info);
69+
const auto state = determineState();
70+
const auto alpha = getAlpha(face, state);
71+
const auto beta = getBeta(face, state);
72+
const auto & nhat = _current_face_info->normal();
73+
74+
return alpha / (alpha + (beta * computeCellToFaceVector() * nhat));
75+
}
76+
77+
// explicit terms for advection kernel
78+
Real
79+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryValueRHSContribution() const
80+
{
81+
const auto face = singleSidedFaceArg(_current_face_info);
82+
const auto state = determineState();
83+
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
84+
"This should not be assigned on an internal face!");
85+
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
86+
? _current_face_info->elemInfo()
87+
: _current_face_info->neighborInfo();
88+
89+
const auto alpha = getAlpha(face, state);
90+
const auto beta = getBeta(face, state);
91+
const auto gamma = getGamma(face, state);
92+
93+
const auto & grad_phi = _var.gradSln(*elem_info);
94+
95+
const auto & nhat = _current_face_info->normal();
96+
97+
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
98+
const auto projection = d_cf * nhat;
99+
const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
100+
101+
return (gamma * projection / (alpha + (beta * projection))) +
102+
(alpha * grad_phi * vc / (alpha + (beta * projection)));
103+
}
104+
105+
// implicit terms for diffusion kernel
106+
Real
107+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientMatrixContribution() const
108+
{
109+
const auto face = singleSidedFaceArg(_current_face_info);
110+
const auto state = determineState();
111+
112+
const auto alpha = getAlpha(face, state);
113+
const auto beta = getBeta(face, state);
114+
115+
const auto & nhat = _current_face_info->normal();
116+
117+
return beta / (alpha + (beta * computeCellToFaceVector() * nhat));
118+
}
119+
120+
// explicit terms for diffusion kernel
121+
Real
122+
LinearFVAdvectionDiffusionFunctorRobinBCBase::computeBoundaryGradientRHSContribution() const
123+
{
124+
mooseAssert(_current_face_type != FaceInfo::VarFaceNeighbors::BOTH,
125+
"This should not be assigned on an internal face!");
126+
const auto & elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM
127+
? _current_face_info->elemInfo()
128+
: _current_face_info->neighborInfo();
129+
const auto face = singleSidedFaceArg(_current_face_info);
130+
const auto state = determineState();
131+
const auto & grad_phi = _var.gradSln(*elem_info);
132+
133+
const auto alpha = getAlpha(face, state);
134+
const auto beta = getBeta(face, state);
135+
const auto gamma = getGamma(face, state);
136+
137+
const auto & nhat = _current_face_info->normal();
138+
139+
const auto d_cf = computeCellToFaceVector(); // vector from boundary cell centre to boundary face
140+
const auto projection = d_cf * nhat;
141+
const auto vc = d_cf - (projection * nhat); // correction vector for non-orthogonal cells
142+
143+
return (gamma / alpha) + (-beta * gamma * projection / alpha / (alpha + (beta * projection))) +
144+
(-beta * grad_phi * vc / (alpha + (beta * projection)));
145+
}

0 commit comments

Comments
 (0)