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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -90,7 +90,7 @@ Foam::coordinateRotations::axisAngle::axisAngle()
Foam::coordinateRotations::axisAngle::axisAngle(const axisAngle& crot) Foam::coordinateRotations::axisAngle::axisAngle(const axisAngle& crot)
: :
coordinateRotation(crot), coordinateRotation(),
axis_(crot.axis_), axis_(crot.axis_),
angle_(crot.angle_), angle_(crot.angle_),
degrees_(crot.degrees_) 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 Foam::coordinateRotations::axisAngle::axisAngle
( (
const vector& axis, const vector& axis,

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. 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 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.beginBlock(keyword);
os.writeEntry("type", type()); os.writeEntry("type", type());
os.writeEntry("axis", axis1_); os.writeEntry("axis", axis1_); // primary axis
os.endBlock(); os.endBlock();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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