vectorTensorTransform.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2025 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 \*---------------------------------------------------------------------------*/
28 
29 #include "vectorTensorTransform.H"
30 #include "IOstreams.H"
31 #include "StringStream.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 const char* const Foam::vectorTensorTransform::typeName =
36  "vectorTensorTransform";
37 
39 (
40  Zero,
41  Zero,
42  false
43 );
44 
45 
47 (
48  Zero,
50  false
51 );
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
57 {
58  is >> *this;
59 }
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
65 {
66  // Detect identity and zero rotations
67  hasR_ = !(R_.is_identity(tol) || Foam::mag(R_) < tol);
68 }
69 
70 
71 Foam::word Foam::name(const vectorTensorTransform& s)
72 {
73  OStringStream buf;
74 
75  buf << '(' << s.t() << ',' << s.R() << ')';
76 
77  return buf.str();
78 }
79 
80 
81 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
82 
83 Foam::Istream& Foam::operator>>(Istream& is, vectorTensorTransform& tr)
84 {
85  is.readBegin("vectorTensorTransform");
86 
87  is >> tr.t_ >> tr.R_ >> tr.hasR_;
88 
89  is.readEnd("vectorTensorTransform");
90 
91  is.check(FUNCTION_NAME);
92 
93  return is;
94 }
95 
96 
97 Foam::Ostream& Foam::operator<<(Ostream& os, const vectorTensorTransform& tr)
98 {
100  << tr.t() << token::SPACE << tr.R() << token::SPACE << tr.hasR()
101  << token::END_LIST;
102 
103  return os;
104 }
105 
106 
107 // ************************************************************************* //
static const char *const typeName
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool readBegin(const char *funcName)
Begin read of data chunk, starts with &#39;(&#39;.
Definition: Istream.C:134
Input/output from string buffers.
Vector-tensor class used to perform translations and rotations in 3D space.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Begin list [isseparator].
Definition: token.H:161
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
static const Identity< scalar > I
Definition: Identity.H:100
A class for handling words, derived from Foam::string.
Definition: word.H:63
Istream & operator>>(Istream &, directionInfo &)
Space [isspace].
Definition: token.H:131
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
End list [isseparator].
Definition: token.H:162
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
static const vectorTensorTransform I
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
void checkRotation(const scalar tol=ROOTVSMALL)
Test for identity rotation and set hasR accordingly.
static const vectorTensorTransform zero
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))
vectorTensorTransform()
Default construct - no translation, identity rotation.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127