Loading...
Searching...
No Matches
norm.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) 2022 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 "norm.H"
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
35namespace functionObjects
36{
39}
40}
41
42
43const Foam::Enum
44<
45 Foam::functionObjects::norm::normType
46>
47Foam::functionObjects::norm::normTypeNames
48({
49 { normType::L1 , "L1" },
50 { normType::L2 , "L2" },
51 { normType::LP , "Lp" },
52 { normType::MAX , "max" },
53 { normType::COMPOSITE , "composite" },
54 { normType::FIELD , "divisorField" }
55});
56
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59
60// Implementation
61#include "normImpl.C"
62
63
64// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
65
67{
68 return
69 (
70 calcNorm<scalar>()
71 || calcNorm<vector>()
72 || calcNorm<sphericalTensor>()
73 || calcNorm<symmTensor>()
74 || calcNorm<tensor>()
75 );
76}
77
78
79// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80
82(
83 const word& name,
84 const Time& runTime,
85 const dictionary& dict
86)
87:
89 norm_(normType::L1),
90 divisorPtr_(nullptr),
91 divisorFieldName_(),
92 p_(-1)
94 read(dict);
95}
96
97
98// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99
101{
103 {
104 return false;
105 }
106
107 norm_ = normTypeNames.get("norm", dict);
108
109 if (norm_ == normType::LP)
110 {
111 p_ = dict.getCheck<scalar>("p", scalarMinMax::ge(1));
112 }
113
114 if (norm_ == normType::COMPOSITE)
115 {
116 divisorPtr_ = Function1<scalar>::New("divisor", dict, &mesh_);
117
118 if (!divisorPtr_)
119 {
121 << "The norm 'composite' needs the input entry 'divisor'."
123 }
124 }
125
126 if (norm_ == normType::FIELD)
127 {
128 divisorFieldName_ = dict.get<word>("divisorField");
129
130 if (divisorFieldName_.empty())
131 {
133 << "The norm 'field' needs the input entry 'divisorField'."
135 }
136 }
137
138 return true;
139}
140
141
142// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
static MinMax< scalar > ge(const scalar &minVal)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Abstract base-class for Time/database function objects.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
const fvMesh & mesh_
Reference to the fvMesh.
Normalises an input field with a chosen norm, and outputs a new normalised field.
Definition norm.H:235
norm(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition norm.C:75
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition norm.C:93
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
engineTime & runTime
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
errorManip< error > abort(error &err)
Definition errorManip.H:139
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict