blendingFactorTemplates.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) 2013-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 "gaussConvectionScheme.H"
27 #include "blendedSchemeBase.H"
28 #include "fvcCellReduce.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 template<class Type>
33 bool Foam::functionObjects::blendingFactor::calcBF()
34 {
35  if (!foundObject<VolField<Type>>(fieldName_))
36  {
37  return false;
38  }
39 
40  const VolField<Type>& field = lookupObject<VolField<Type>>(fieldName_);
41 
42  const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')');
43  ITstream& its = mesh_.schemes().div(divScheme);
44 
45  const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
46 
47  tmp<fv::convectionScheme<Type>> cs =
49 
50  const fv::gaussConvectionScheme<Type>& gcs =
51  refCast<const fv::gaussConvectionScheme<Type>>(cs());
52 
53  const surfaceInterpolationScheme<Type>& interpScheme =
54  gcs.interpScheme();
55 
56  if (!isA<blendedSchemeBase<Type>>(interpScheme))
57  {
59  << interpScheme.typeName << " is not a blended scheme"
60  << exit(FatalError);
61  }
62 
63  // Retrieve the face-based blending factor
64  const blendedSchemeBase<Type>& blendedScheme =
65  refCast<const blendedSchemeBase<Type>>(interpScheme);
66  tmp<surfaceScalarField> factorf(blendedScheme.blendingFactor(field));
67 
68  // Convert into vol field whose values represent the local face maxima
69  return store
70  (
72  fvc::cellReduce(factorf, maxEqOp<scalar>())
73  );
74 }
75 
76 
77 // ************************************************************************* //
word resultName_
Name of result field.
const word fieldName_
Name of field to process.
const fvMesh & mesh_
Reference to the fvMesh.
bool foundObject(const word &fieldName) const
Find field in the objectRegistry.
bool store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1748
ITstream & div(const word &name) const
Definition: fvSchemes.C:479
static tmp< convectionScheme< Type > > New(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &schemeData)
Return a pointer to a new convectionScheme created on freestore.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Construct a volume field from a surface field using a combine operator.
tmp< VolField< Type > > cellReduce(const SurfaceField< Type > &, const CombineOp &cop, const Type &nullValue=pTraits< Type >::zero)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
SurfaceField< scalar > surfaceScalarField
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:139
error FatalError