linear.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "linear.H"
27 #include "one.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace blendingMethods
35 {
36  defineTypeNameAndDebug(linear, 0);
37  addToRunTimeSelectionTable(blendingMethod, linear, dictionary);
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 
45 (
46  const UPtrList<const volScalarField>& alphas,
47  const label phaseSet,
48  const label systemSet
49 ) const
50 {
51  tmp<volScalarField> x = this->x(alphas, phaseSet, systemSet);
52  tmp<volScalarField> f =
53  parameter(alphas, phaseSet, minFullyContinuousAlpha_);
54  tmp<volScalarField> p =
55  parameter(alphas, phaseSet, minPartlyContinuousAlpha_);
56  return min(max((x - p())/max(f - p(), rootVSmall), zero()), one());
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const dictionary& dict,
65  const phaseInterface& interface
66 )
67 :
68  blendingMethod(dict, interface),
69  minFullyContinuousAlpha_
70  (
71  readParameters
72  (
73  "minFullyContinuousAlpha",
74  dict,
75  interface,
76  {0, 1},
77  true
78  )
79  ),
80  minPartlyContinuousAlpha_
81  (
82  readParameters
83  (
84  "minPartlyContinuousAlpha",
85  dict,
86  interface,
87  {0, 1},
88  true
89  )
90  )
91 {
92  forAllConstIter(phaseInterface, interface, iter)
93  {
94  const label i = iter.index();
95 
96  if
97  (
98  isParameter(minFullyContinuousAlpha_[i])
99  != isParameter(minPartlyContinuousAlpha_[i])
100  )
101  {
103  << "Both minimum fully and partly continuous alpha must be "
104  << "supplied for phases that can become continuous. Only one "
105  << "is supplied for " << iter().name() << exit(FatalError);
106  }
107 
108  if
109  (
110  (
111  canBeContinuous(i)
112  && minFullyContinuousAlpha_[i] <= minPartlyContinuousAlpha_[i]
113  )
114  )
115  {
117  << "The fully continuous alpha specified for " << iter().name()
118  << " is not greater than the partly continuous alpha"
119  << exit(FatalError);
120  }
121  }
122 
123  if
124  (
125  canBeContinuous(0)
126  && canBeContinuous(1)
127  && (
128  (
129  minFullyContinuousAlpha_[0] + minPartlyContinuousAlpha_[1]
130  < 1 - rootSmall
131  )
132  || (
133  minFullyContinuousAlpha_[1] + minPartlyContinuousAlpha_[0]
134  < 1 - rootSmall
135  )
136  )
137  )
138  {
140  << typeName.capitalise() << " blending function for interface "
141  << interface.name() << " is invalid in that it creates negative "
142  << "coefficients for sub-modelled values. A valid function will "
143  << "have fully continuous alphas that are greater than one minus "
144  << "the partly continuous alphas in the opposite phase."
145  << exit(FatalError);
146  }
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
151 
153 {}
154 
155 
156 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
157 
159 {
160  return isParameter(minFullyContinuousAlpha_[index]);
161 }
162 
163 
165 {
166  return
167  canBeContinuous(0)
168  && canBeContinuous(1)
169  && (
170  minFullyContinuousAlpha_[0] + minPartlyContinuousAlpha_[1]
171  > 1 + rootSmall
172  ||
173  minFullyContinuousAlpha_[1] + minPartlyContinuousAlpha_[0]
174  > 1 + rootSmall
175  );
176 }
177 
178 
179 // ************************************************************************* //
dictionary dict
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
virtual tmp< volScalarField > fContinuous(const UPtrList< const volScalarField > &alphas, const label phaseSet, const label systemSet) const
Evaluate the blending function.
Macros for easy insertion into run-time selection tables.
virtual bool canSegregate() const
Return whether or not this interface can segregate.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual bool canBeContinuous(const label index) const
Return whether or not a phase can be considered continuous.
defineTypeNameAndDebug(combustionModel, 0)
static word typeName()
Return the instantiated type name.
Definition: linear.H:156
linear(const dictionary &dict, const phaseInterface &interface)
Construct from a dictionary and an interface.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
word capitalise() const
Return the word with the first letter capitalised.
Definition: wordI.H:131