coordinateScaling.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-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// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29
30template<class Type>
32:
33 coordSys_(nullptr),
34 scale_(),
35 active_(false)
36{}
37
38
39template<class Type>
41(
42 const objectRegistry& obr,
43 const dictionary& dict
44)
45:
46 coordSys_
47 (
48 dict.found(coordinateSystem::typeName_())
50 : nullptr
51 ),
52 scale_(3),
53 active_(bool(coordSys_))
54{
55 for (direction dir = 0; dir < vector::nComponents; ++dir)
56 {
57 const word key("scale" + Foam::name(dir+1));
58
59 if (dict.found(key))
60 {
61 scale_.set(dir, Function1<Type>::New(key, dict));
62 active_ = true;
63 }
64 }
65}
66
67
68template<class Type>
70:
71 coordSys_(rhs.coordSys_.clone()),
72 scale_(rhs.scale_),
73 active_(rhs.active_)
74{}
75
76
77// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78
79template<class Type>
81(
83 const Field<Type>& p0
84) const
85{
86 auto tfld = tmp<Field<Type>>::New(p0);
87 auto& fld = tfld.ref();
88
89 if (coordSys_)
90 {
91 const vectorField local(coordSys_->localPosition(pos));
92 for (direction dir = 0; dir < vector::nComponents; ++dir)
93 {
94 if (scale_.set(dir))
95 {
97 (
98 fld,
99 scale_[dir].value(local.component(dir))
100 );
101 }
102 }
103
104 return coordSys_->transform(pos, fld);
105 }
106 else if (scale_.size())
107 {
108 for (direction dir = 0; dir < vector::nComponents; ++dir)
109 {
110 if (scale_.set(dir))
113 (
114 fld,
115 scale_[dir].value(pos.component(dir))
116 );
117 }
119 }
120
121 return tfld;
122}
123
124
125template<class Type>
127{
128 if (coordSys_)
129 {
130 coordSys_->writeEntry(os);
131 }
132 forAll(scale_, dir)
133 {
134 if (scale_.set(dir))
135 {
136 scale_[dir].writeData(os);
137 }
138 }
139}
140
141
142// ************************************************************************* //
bool found
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:545
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Helper class to wrap coordinate system and component-wise scaling.
coordinateScaling()
Default construct.
virtual void writeEntry(Ostream &os) const
Write dictionary entry.
Base class for coordinate system specification, the default coordinate system type is cartesian .
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
dimensioned< cmptType > component(const direction d) const
Return a component as a dimensioned<cmptType>
Default transformation behaviour.
Registry of regIOobjects.
static constexpr direction nComponents
Number of components in bool is 1.
Definition: bool.H:98
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
const volScalarField & p0
Definition: EEqn.H:36
bool
Definition: EEqn.H:20
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar pos(const dimensionedScalar &ds)
uint8_t direction
Definition: direction.H:56
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333