ENH: support direct specification of coordinate rotation "none"

- Can specify
  ```
  transform
  {
      origin      (1 2 3);
      rotation    none;
  }
  ```
  instead of the longer form
  ```
  transform
  {
      origin      (1 2 3);
      e1          (1 0 0);
      e3          (0 0 1);
  }
  ```

COMPAT: remove old (pre-1812) Euler and STARCD keywords

- use "angles", remove old compat name "rotation"
  as clutter and possible confusion with "coordinate rotation"

STYLE: remove coordinate rotation move constructors

- an unnecessary holdover from older code.
This commit is contained in:
Mark Olesen 2021-07-16 12:09:46 +02:00
parent e2be2289a1
commit 5b09e59b3f
18 changed files with 76 additions and 96 deletions

View File

@ -35,6 +35,7 @@ Description
#include "Time.H"
#include "coordinateSystems.H"
#include "identityRotation.H"
#include "cartesianCS.H"
#include "indirectCS.H"
#include "Fstream.H"
#include "IOstreams.H"
@ -58,14 +59,15 @@ void basicTests(const coordinateSystem& cs)
{
cs.writeEntry(cs.name(), Info);
if (isA<coordSystem::indirect>(cs))
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
{
Info<< "indirect from:" << nl;
dynamicCast<const coordSystem::indirect>(cs).cs()
.writeEntry(cs.name(), Info);
if (!cartptr->active())
{
Info<< "inactive cartesian = " << (*cartptr)
<< " with: " << (*cartptr).R() << nl;
}
}
Info<< "rotation: " << cs.R() << nl;
List<point> testPoints

View File

@ -258,7 +258,7 @@ Foam::coordinateRotations::euler::euler()
Foam::coordinateRotations::euler::euler(const euler& crot)
:
coordinateRotation(crot),
coordinateRotation(),
angles_(crot.angles_),
degrees_(crot.degrees_),
order_(crot.order_)
@ -296,7 +296,7 @@ Foam::coordinateRotations::euler::euler
Foam::coordinateRotations::euler::euler(const dictionary& dict)
:
coordinateRotation(),
angles_(dict.getCompat<vector>("angles", {{"rotation", 1806}})),
angles_(dict.get<vector>("angles")),
degrees_(dict.getOrDefault("degrees", true)),
order_
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,7 +38,7 @@ Description
https://en.wikipedia.org/wiki/Euler_angles
\verbatim
coordinateRotation
rotation
{
type euler;
angles (0 0 180);
@ -109,7 +109,7 @@ public:
// Constructors
//- Construct null - an identity transform
//- Default construct - an identity transform
euler();
//- Copy construct
@ -165,7 +165,6 @@ public:
//- Write dictionary entry
virtual void writeEntry(const word& keyword, Ostream& os) const;
};
@ -173,7 +172,6 @@ public:
} // End namespace coordinateRotations
//- Compatibility typedef 1806
typedef coordinateRotations::euler EulerCoordinateRotation;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -104,7 +104,7 @@ Foam::coordinateRotations::starcd::starcd()
Foam::coordinateRotations::starcd::starcd(const starcd& crot)
:
coordinateRotation(crot),
coordinateRotation(),
angles_(crot.angles_),
degrees_(crot.degrees_)
{}
@ -139,7 +139,7 @@ Foam::coordinateRotations::starcd::starcd
Foam::coordinateRotations::starcd::starcd(const dictionary& dict)
:
coordinateRotation(),
angles_(dict.getCompat<vector>("angles", {{"rotation", 1806}})),
angles_(dict.get<vector>("angles")),
degrees_(dict.getOrDefault("degrees", true))
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +37,7 @@ Description
- the rotation angles are in degrees, unless otherwise explicitly specified:
\verbatim
coordinateRotation
rotation
{
type starcd;
angles (0 0 180);
@ -94,7 +94,7 @@ public:
// Constructors
//- Construct null - an identity transform
//- Default construct - an identity transform
starcd();
//- Copy construct
@ -150,7 +150,6 @@ public:
} // End namespace coordinateRotations
//- Compatibility typedef 1806
typedef coordinateRotations::starcd STARCDCoordinateRotation;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -211,22 +211,13 @@ Foam::coordinateRotations::axes::axes()
Foam::coordinateRotations::axes::axes(const axes& crot)
:
coordinateRotation(crot),
coordinateRotation(),
axis1_(crot.axis1_),
axis2_(crot.axis2_),
order_(crot.order_)
{}
Foam::coordinateRotations::axes::axes(axes&& crot)
:
coordinateRotation(std::move(crot)),
axis1_(std::move(crot.axis1_)),
axis2_(std::move(crot.axis2_)),
order_(crot.order_)
{}
Foam::coordinateRotations::axes::axes
(
const vector& axis1,
@ -259,8 +250,8 @@ Foam::coordinateRotations::axes::axes(const dictionary& dict)
void Foam::coordinateRotations::axes::clear()
{
axis1_ = vector(0,0,1); // e3 = global Z
axis2_ = vector(1,0,0); // e1 = global X
axis1_ = vector(0,0,1); // primary axis (e3, global Z)
axis2_ = vector(1,0,0); // secondary axis (e1, global X)
order_ = E3_E1;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,7 @@ Description
or (e3/e1). Any nonorthogonality is absorbed into the second vector.
\verbatim
coordinateRotation
rotation
{
type axes;
e1 (1 0 0);
@ -122,15 +122,12 @@ public:
// Constructors
//- Construct null - an identity transform
//- Default construct - an identity transform
axes();
//- Copy construct
axes(const axes& crot);
//- Move construct
axes(axes&& crot);
//- Construct from two axes
axes(const vector& axis1, const vector& axis2, axisOrder order=E3_E1);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,7 +90,7 @@ Foam::coordinateRotations::axisAngle::axisAngle()
Foam::coordinateRotations::axisAngle::axisAngle(const axisAngle& crot)
:
coordinateRotation(crot),
coordinateRotation(),
axis_(crot.axis_),
angle_(crot.angle_),
degrees_(crot.degrees_)
@ -99,17 +99,6 @@ Foam::coordinateRotations::axisAngle::axisAngle(const axisAngle& crot)
}
Foam::coordinateRotations::axisAngle::axisAngle(axisAngle&& crot)
:
coordinateRotation(std::move(crot)),
axis_(std::move(crot.axis_)),
angle_(std::move(crot.angle_)),
degrees_(crot.degrees_)
{
checkSpec();
}
Foam::coordinateRotations::axisAngle::axisAngle
(
const vector& axis,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ Description
about that axis.
\verbatim
coordinateRotation
rotation
{
type axisAngle;
axis (1 0 0);
@ -99,17 +99,15 @@ public:
//- Runtime type information
TypeNameNoDebug("axisAngle");
// Constructors
//- Construct null
//- Default construct. Axis = Z, angle = 0.
axisAngle();
//- Copy construct
axisAngle(const axisAngle& crot);
//- Move construct
axisAngle(axisAngle&& crot);
//- Construct from axis and angle
axisAngle(const vector& axis, scalar angle, bool degrees);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,7 +27,6 @@ License
\*---------------------------------------------------------------------------*/
#include "coordinateRotation.H"
#include "dictionary.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +37,7 @@ Description
User specification of a coordinate rotation.
\verbatim
coordinateRotation
rotation
{
type axes
e1 (1 0 0);
@ -61,8 +61,9 @@ SourceFiles
#ifndef coordinateRotation_H
#define coordinateRotation_H
#include "vectorField.H"
#include "tensorField.H"
#include "autoPtr.H"
#include "vector.H"
#include "tensor.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
@ -137,7 +138,6 @@ public:
//- Write dictionary entry
virtual void writeEntry(const word& keyword, Ostream& os) const = 0;
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,7 +81,7 @@ Foam::coordinateRotations::cylindrical::cylindrical(const dictionary& dict)
void Foam::coordinateRotations::cylindrical::write(Ostream& os) const
{
os << type() << " axis: " << axis1_;
os << type() << " axis: " << axis1_; // primary axis
}
@ -94,7 +94,7 @@ void Foam::coordinateRotations::cylindrical::writeEntry
os.beginBlock(keyword);
os.writeEntry("type", type());
os.writeEntry("axis", axis1_);
os.writeEntry("axis", axis1_); // primary axis
os.endBlock();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,6 +73,9 @@ public:
// Constructors
//- Default construct - an identity transform
cylindrical() = default;
//- Copy construct
cylindrical(const cylindrical& crot);
@ -110,9 +113,9 @@ public:
//- Write dictionary entry
virtual void writeEntry(const word& keyword, Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace coordinateRotations

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,21 +48,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coordinateRotations::identity::identity()
:
coordinateRotation()
{}
Foam::coordinateRotations::identity::identity(const identity&)
:
identity()
{}
Foam::coordinateRotations::identity::identity(const dictionary&)
:
identity()
{}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,7 +30,7 @@ Description
An identity coordinateRotation.
\verbatim
coordinateRotation
rotation
{
type none;
}
@ -73,13 +73,19 @@ public:
TypeNameNoDebug("none");
// Constructors
// Generated Methods
//- Construct null
identity();
//- Default construct
identity() = default;
//- Copy construct
identity(const identity& unused);
identity(const identity&) = default;
//- Copy assignment
identity& operator=(const identity&) = default;
// Constructors
//- Construct from dictionary
explicit identity(const dictionary& unused);
@ -110,7 +116,6 @@ public:
//- Write dictionary entry
virtual void writeEntry(const word& keyword, Ostream& os) const;
};

View File

@ -163,7 +163,6 @@ public:
//- Compatibility typedef 1806
typedef coordSystem::cartesian cartesianCS;
} // End namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -88,6 +88,10 @@ void Foam::coordinateSystem::assign(const dictionary& dict)
{
spec_ = coordinateRotation::New(finder.dict());
}
else if (finder.good() && (finder->stream().peek().isWord("none")))
{
spec_.reset(new coordinateRotations::identity());
}
else
{
// Fall through to expecting e1/e2/e3 specification in the dictionary

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,6 +67,16 @@ Description
}
\endverbatim
For an identity rotation, can use a slightly more compact format:
\verbatim
coordinateSystem
{
type cartesian;
origin (0 0 0);
rotation none;
}
\endverbatim
Types of coordinateRotation:
-# \link coordinateRotations::identity none \endlink
-# \link coordinateRotations::axes axes \endlink
@ -429,7 +439,7 @@ public:
//- Considered valid if it has a specification
virtual bool valid() const
{
return spec_;
return bool(spec_);
}
//- True if the rotation tensor is uniform for all locations
@ -495,7 +505,7 @@ public:
name_ = newName;
}
//- Provide non-constant access to the optional note
//- Edit access to optional note
virtual string& note()
{
return note_;