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-2023 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 {
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);
53  parameter(alphas, phaseSet, minFullyContinuousAlpha_);
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  minFullyContinuousAlpha_[i].valid
99  != minPartlyContinuousAlpha_[i].valid
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].value
113  <= minPartlyContinuousAlpha_[i].value
114  )
115  )
116  {
118  << "The fully continuous alpha specified for " << iter().name()
119  << " is not greater than the partly continuous alpha"
120  << exit(FatalError);
121  }
122  }
123 
124  if
125  (
126  canBeContinuous(0)
127  && canBeContinuous(1)
128  && (
129  (
130  minFullyContinuousAlpha_[0].value
131  + minPartlyContinuousAlpha_[1].value
132  < 1 - rootSmall
133  )
134  || (
135  minFullyContinuousAlpha_[1].value
136  + minPartlyContinuousAlpha_[0].value
137  < 1 - rootSmall
138  )
139  )
140  )
141  {
143  << typeName.capitalise() << " blending function for interface "
144  << interface.name() << " is invalid in that it creates negative "
145  << "coefficients for sub-modelled values. A valid function will "
146  << "have fully continuous alphas that are greater than one minus "
147  << "the partly continuous alphas in the opposite phase."
148  << exit(FatalError);
149  }
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 
156 {}
157 
158 
159 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
160 
162 {
163  return minFullyContinuousAlpha_[index].valid;
164 }
165 
166 
168 {
169  return
170  canBeContinuous(0)
171  && canBeContinuous(1)
172  && (
173  (
174  minFullyContinuousAlpha_[0].value
175  + minPartlyContinuousAlpha_[1].value
176  > 1 + rootSmall
177  )
178  || (
179  minFullyContinuousAlpha_[1].value
180  + minPartlyContinuousAlpha_[0].value
181  > 1 + rootSmall
182  )
183  );
184 }
185 
186 
187 // ************************************************************************* //
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Macros for easy insertion into run-time selection tables.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
Abstract base class for functions that are used to combine interfacial sub-models according to the vo...
tmp< volScalarField > x(const UPtrList< const volScalarField > &alphas, const label phaseSet, const label systemSet) const
Return the coordinate of the blending function.
tmp< volScalarField > parameter(const UPtrList< const volScalarField > &alphas, const label set, const Pair< blendingParameter > &parameters) const
Get a blending parameter averaged for the given set.
virtual tmp< volScalarField > f(const UPtrList< const volScalarField > &alphas, const label phaseSet, const label systemSet) const
Evaluate the blending function. Filters out phases that cannot.
Blending method based on piecewise linear functions. Supports the full range of phase fraction space....
Definition: linear.H:62
virtual tmp< volScalarField > fContinuous(const UPtrList< const volScalarField > &alphas, const label phaseSet, const label systemSet) const
Evaluate the blending function.
Definition: linear.C:45
virtual bool canSegregate() const
Return whether or not this interface can segregate.
Definition: linear.C:167
linear(const dictionary &dict, const phaseInterface &interface)
Construct from a dictionary and an interface.
Definition: linear.C:63
virtual bool canBeContinuous(const label index) const
Return whether or not a phase can be considered continuous.
Definition: linear.C:161
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class representing the concept of 1 (scalar(1)) used to avoid unnecessary manipulations for objects...
Definition: one.H:51
Class to represent an interface between phases. Derivations can further specify the configuration of ...
A class for managing temporary objects.
Definition: tmp.H:55
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
bool valid(const PtrList< ModelType > &l)
defineTypeNameAndDebug(continuous, 0)
addToRunTimeSelectionTable(blendingMethod, continuous, dictionary)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
error FatalError
dictionary dict
volScalarField & p