equationInitialResidualConditionTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "fvMesh.H"
29
30template<class Type>
33(
34 const fvMesh& mesh,
35 const dictionary& dict,
36 const word& fieldName,
37 const label componenti,
38 bool& canSet,
39 scalar& residual
40) const
41{
43
44 if (canSet && mesh.foundObject<volFieldType>(fieldName))
45 {
46 const List<SolverPerformance<Type>> sp(dict.lookup(fieldName));
47 const Type& allComponents = sp.first().initialResidual();
48
49 if (componenti != -1)
50 {
51 if (componenti > pTraits<Type>::nComponents - 1)
52 {
54 << "Requested component [" << componenti
55 << "] for field " << fieldName
56 << " is out of range 0.."
58 << exit(FatalError);
59 }
60
61 residual = component(allComponents, componenti);
62 }
63 else
64 {
65 residual = cmptMax(allComponents);
66 }
67
68 canSet = false;
69 }
70}
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
T & first()
Return the first element of the list.
Definition: UListI.H:202
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
void setResidual(const fvMesh &mesh, const dictionary &dict, const word &fieldName, const label componenti, bool &canSet, scalar &residual) const
Set the residual (scalar) value.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict