labelSpecific.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) 2014-2017 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Typedef
28  Foam::label
29 
30 Description
31  label specific functions for which there is no uLabel equivalent
32 
33 \*---------------------------------------------------------------------------*/
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 //- Return 1 if s is greater_equal zero, or otherwise -1
43 inline label sign(const label s) noexcept
44 {
45  return (s >= 0)? 1: -1;
46 }
47 
48 
49 //- Return 1 if s is greater_equal zero, or otherwise 0
50 inline label pos0(const label s) noexcept
51 {
52  return (s >= 0)? 1: 0;
53 }
54 
55 
56 //- Return 1 if s is less than zero, or otherwise 0
57 inline label neg(const label s) noexcept
58 {
59  return (s < 0)? 1: 0;
60 }
61 
62 
63 //- Return 1 if s is less_equal zero, or otherwise 0
64 inline label neg0(const label s) noexcept
65 {
66  return (s <= 0)? 1: 0;
67 }
68 
69 
70 //- Return the positive part of s, otherwise zero. Same as max(0, s).
71 inline label posPart(const label s) noexcept
72 {
73  return (s > 0)? s: 0;
74 }
75 
76 
77 //- Return the negative part of s, otherwise zero. Same as min(0, s).
78 // Does not change the sign
79 inline label negPart(const label s) noexcept
80 {
81  return (s < 0)? s: 0;
82 }
83 
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 } // End namespace Foam
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar posPart(const dimensionedScalar &ds)
dimensionedScalar neg(const dimensionedScalar &ds)
dimensionedScalar neg0(const dimensionedScalar &ds)
const direction noexcept
Definition: Scalar.H:258
dimensionedScalar pos0(const dimensionedScalar &ds)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
dimensionedScalar negPart(const dimensionedScalar &ds)