Loading...
Searching...
No Matches
FieldBase.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) 2018-2025 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 "Field.H"
29#include "debug.H"
30#include "dictionary.H"
31#include "error.H"
32#include "registerSwitch.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36const char* const Foam::FieldBase::typeName("Field");
39
41(
42 Foam::debug::optimisationSwitch("unifiedGeometricField", 0)
43);
45(
46 "unifiedGeometricField",
47 bool,
49);
50
51
53(
54 Foam::debug::optimisationSwitch("localBoundaryConsistency", 1)
55);
57(
58 "localConsistency",
59 int,
61);
62
63
65(
67 (
68 "localBoundaryConsistency::tolerance", 0
69 )
70);
72(
73 "localBoundaryConsistency::tolerance",
74 Foam::scalar,
76);
77
78
79// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
80
81// This is a really ugly solution, but no obvious simpler method
82
84(
85 const dictionary& dict
86)
87{
88 // New: localBoundaryConsistency
89 // Old:
90 // - localConsistency
91 // - point(Vector)Field::Boundary::localConsistency
92 // - point(Spherical|Symm)?TensorField::Boundary::localConsistency
93 // - (surface|vol)(Scalar|Vector)Field::Boundary::localConsistency
94 // - (surface|vol)(Spherical|Symm)?TensorField::Boundary::localConsistency
95
96 // New: localBoundaryConsistency::tolerance
97 // Old:
98 // - (vol|surface)(Scalar|Vector)Field::Boundary::tolerance
99 // - (vol|surface)(Spherical|Symm)?TensorField::Boundary::tolerance
100
101 {
102 constexpr int version(2412);
103
104 const word flagName("localBoundaryConsistency");
105 const word tolName("localBoundaryConsistency::tolerance");
106
107 // Warn: "using " kw -> flagName;
108 const auto emitWarning =
109 [=](const std::string& oldName, const std::string& newName)
110 {
111 if (error::master())
112 {
113 std::cerr
114 << "--> FOAM IOWarning :" << nl
115 << " Found [v" << version << "] '"
116 << oldName.c_str() << "' entry instead of '"
117 << newName.c_str() << "'" << nl
118 << std::endl;
119 error::warnAboutAge("keyword", version);
120 }
121 };
122
123 for (const entry& e : dict)
124 {
125 const auto& kw = e.keyword();
126
127 if (kw.contains("Field::Boundary::"))
128 {
129 if (kw.ends_with("Field::Boundary::localConsistency"))
130 {
131 emitWarning(kw, flagName);
132 }
133 else if (kw.ends_with("Field::Boundary::tolerance"))
134 {
135 emitWarning(kw, tolName);
136 }
137 }
138 else if (kw == "localConsistency")
139 {
140 emitWarning(kw, flagName);
141 }
142 }
143 }
144}
145
146
147// ************************************************************************* //
static bool unifiedGeometricField
GeometricField with extra capacity for flattened boundary fields. Uses opt-switch "unifiedGeometricFi...
Definition Field.H:106
static bool allowConstructFromLargerSize
Permit read construct from a larger size.
Definition Field.H:100
static void warnLocalBoundaryConsistencyCompat(const dictionary &)
Warn about keyword changes for local boundary consistency checks.
Definition FieldBase.C:77
static scalar localBoundaryTolerance_
Tolerance for local boundary field consistency checks. Uses opt-switch "localBoundaryConsistency::tol...
Definition Field.H:118
static int localBoundaryConsistency_
Local boundary field consistency checks. Uses opt-switch "localBoundaryConsistency".
Definition Field.H:112
static const char *const typeName
Typename for Field.
Definition Field.H:93
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
static bool master(const int communicator=-1)
Like Pstream::master but with a Pstream::parRun guard in case Pstream has not yet been initialised.
Definition error.C:53
static bool warnAboutAge(const int version) noexcept
Test if an age warning should be emitted.
Definition error.C:67
A class for handling words, derived from Foam::string.
Definition word.H:66
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
Definition debug.C:240
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
Definition debug.C:234
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define registerOptSwitch(Name, Type, SwitchVar)
dictionary dict
volScalarField & e