exprDriverOps.H
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
26Namespace
27 Foam::expressions::exprDriverOps
28
29Description
30 Miscellaneous operations used in combination with the
31 expressions::exprDriver
32
33SourceFiles
34 exprDriverOps.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef expressions_exprDriverOps_H
39#define expressions_exprDriverOps_H
40
41#include "scalarOps.H"
42#include "FieldOps.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48namespace expressions
49{
50namespace exprDriverOps
51{
52
53/*---------------------------------------------------------------------------*\
54 Namespace exprDriverOps Declarations
55\*---------------------------------------------------------------------------*/
56
57//- A modulo operation similar to that used in swak4foam
58// This operation produces values in the -1/2 to +1/2 range.
60{
61 scalar operator()(const scalar& a, const scalar& b) const
62 {
63 if (Foam::mag(b) < ROOTVSMALL)
64 {
65 return 0;
66 }
67
68 const scalar val = std::fmod(a, b);
69
70 if (Foam::mag(val) > (0.5*b))
71 {
72 if (val > 0)
73 {
74 return (val - b);
75 }
76 else
77 {
78 return (val + b);
79 }
80 }
81
82 return val;
83 }
84};
85
86
87// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88
89} // End namespace exprDriverOps
90} // End namespace expressions
91} // End namespace Foam
92
93// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94
95#endif
96
97// ************************************************************************* //
Namespace for OpenFOAM.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Functors that are scalar-specific.
volScalarField & b
Definition: createFields.H:27
A modulo operation similar to that used in swak4foam.
Definition: exprDriverOps.H:60
scalar operator()(const scalar &a, const scalar &b) const
Definition: exprDriverOps.H:61