diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files
index 13a2ccf684..bc16f3a4eb 100644
--- a/src/meshTools/Make/files
+++ b/src/meshTools/Make/files
@@ -71,6 +71,7 @@ $(crot)/axisAngleRotation.C
$(crot)/coordinateRotation.C
$(crot)/cylindricalRotation.C
$(crot)/identityRotation.C
+$(crot)/specifiedRotation.C
$(crot)/EulerCoordinateRotation.C
$(crot)/STARCDCoordinateRotation.C
diff --git a/src/meshTools/coordinate/rotation/specifiedRotation.C b/src/meshTools/coordinate/rotation/specifiedRotation.C
new file mode 100644
index 0000000000..06117a99f1
--- /dev/null
+++ b/src/meshTools/coordinate/rotation/specifiedRotation.C
@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | www.openfoam.com
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ Copyright (C) 2021 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "specifiedRotation.H"
+#include "dictionary.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace coordinateRotations
+{
+
+defineTypeName(specified);
+//FUTURE addToRunTimeSelectionTable(coordinateRotation, specified, dictionary);
+
+}
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::coordinateRotations::specified::specified()
+:
+ coordinateRotation(),
+ Rmatrix_(sphericalTensor::I)
+{}
+
+
+Foam::coordinateRotations::specified::specified(const tensor& rot)
+:
+ coordinateRotation(),
+ Rmatrix_(rot)
+{}
+
+
+Foam::coordinateRotations::specified::specified(const dictionary& dict)
+:
+ specified()
+{
+ // Not yet implemented, pending definition
+}
+
+
+// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+
+void Foam::coordinateRotations::specified::clear()
+{
+ Rmatrix_ = sphericalTensor::I;
+}
+
+
+Foam::tensor Foam::coordinateRotations::specified::R() const
+{
+ return Rmatrix_;
+}
+
+
+void Foam::coordinateRotations::specified::write(Ostream& os) const
+{
+ os << "specified rotation";
+}
+
+
+void Foam::coordinateRotations::specified::writeEntry
+(
+ const word& keyword,
+ Ostream& os
+) const
+{
+ os.beginBlock(keyword);
+
+ os.writeEntry("type", type());
+
+ os.endBlock();
+}
+
+
+// ************************************************************************* //
diff --git a/src/meshTools/coordinate/rotation/specifiedRotation.H b/src/meshTools/coordinate/rotation/specifiedRotation.H
new file mode 100644
index 0000000000..8c27a65330
--- /dev/null
+++ b/src/meshTools/coordinate/rotation/specifiedRotation.H
@@ -0,0 +1,127 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | www.openfoam.com
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ Copyright (C) 2021 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Class
+ Foam::coordinateRotations::specified
+
+Description
+ An user-specified coordinateRotation, primarily to be used internally
+ within coding when the rotation matrix is already known but
+ needs to be wrapped as a coordinateRotation for use in a coordinate
+ system.
+
+Note
+ Currently no runtime selection mechanism, since specifying a
+ rotation matrix via a dictionary can be fragile due to rounding
+ factors and uncertainty if a forward or reverse rotation matrix
+ is intended.
+
+SourceFiles
+ specifiedRotation.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef coordinateRotations_specified_H
+#define coordinateRotations_specified_H
+
+#include "coordinateRotation.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace coordinateRotations
+{
+
+/*---------------------------------------------------------------------------*\
+ Class coordinateRotations::specified Declaration
+\*---------------------------------------------------------------------------*/
+
+class specified
+:
+ public coordinateRotation
+{
+ // Private Data
+
+ //- The rotation matrix
+ tensor Rmatrix_;
+
+
+public:
+
+ //- Runtime type information
+ TypeNameNoDebug("specified");
+
+
+ // Constructors
+
+ //- Default construct - an identity matrix
+ specified();
+
+ //- Construct from transformation matrix
+ explicit specified(const tensor& rot);
+
+ //- Construct from dictionary
+ explicit specified(const dictionary& unused);
+
+ //- Return clone
+ autoPtr clone() const
+ {
+ return
+ autoPtr::NewFrom
+ (*this);
+ }
+
+
+ //- Destructor
+ virtual ~specified() = default;
+
+
+ // Member Functions
+
+ //- Reset specification
+ virtual void clear();
+
+ //- Return the rotation tensor
+ virtual tensor R() const;
+
+ //- Write information
+ virtual void write(Ostream& os) const;
+
+ //- Write dictionary entry
+ virtual void writeEntry(const word& keyword, Ostream& os) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace coordinateRotations
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/meshTools/coordinate/systems/cartesianCS.C b/src/meshTools/coordinate/systems/cartesianCS.C
index 3e7a74e3cb..46574df247 100644
--- a/src/meshTools/coordinate/systems/cartesianCS.C
+++ b/src/meshTools/coordinate/systems/cartesianCS.C
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
- Copyright (C) 2018-2019 OpenCFD Ltd.
+ Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -70,6 +70,12 @@ Foam::coordSystem::cartesian::cartesian(autoPtr&& csys)
{}
+Foam::coordSystem::cartesian::cartesian(const coordinateRotation& crot)
+:
+ coordinateSystem(crot)
+{}
+
+
Foam::coordSystem::cartesian::cartesian
(
const point& origin,
diff --git a/src/meshTools/coordinate/systems/cartesianCS.H b/src/meshTools/coordinate/systems/cartesianCS.H
index 2837da76e5..2b326e5909 100644
--- a/src/meshTools/coordinate/systems/cartesianCS.H
+++ b/src/meshTools/coordinate/systems/cartesianCS.H
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
- Copyright (C) 2018-2019 OpenCFD Ltd.
+ Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -75,7 +75,7 @@ public:
// Constructors
- //- Construct null. This is an identity coordinateSystem.
+ //- Default construct. This is an identity coordinate system
cartesian();
//- Copy construct
@@ -93,6 +93,12 @@ public:
//- Move construct from autoPtr of another coordinateSystem type
explicit cartesian(autoPtr&& csys);
+ //- Copy construct from rotation with origin=0
+ explicit cartesian(const coordinateRotation& crot);
+
+ //- Move construct from rotation with origin=0
+ explicit cartesian(coordinateRotation&& crot);
+
//- Construct from origin and rotation
cartesian(const point& origin, const coordinateRotation& crot);
diff --git a/src/meshTools/coordinate/systems/coordinateSystem.H b/src/meshTools/coordinate/systems/coordinateSystem.H
index 9048c7c3c3..21083ceb8f 100644
--- a/src/meshTools/coordinate/systems/coordinateSystem.H
+++ b/src/meshTools/coordinate/systems/coordinateSystem.H
@@ -260,7 +260,7 @@ public:
// Constructors
- //- Construct null. This is an identity coordinateSystem.
+ //- Default construct. This is an identity coordinate system
coordinateSystem();
//- Copy construct from rotation with origin=0
diff --git a/src/meshTools/coordinate/systems/cylindricalCS.C b/src/meshTools/coordinate/systems/cylindricalCS.C
index 89a766bab2..a4884af3e1 100644
--- a/src/meshTools/coordinate/systems/cylindricalCS.C
+++ b/src/meshTools/coordinate/systems/cylindricalCS.C
@@ -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.
@@ -108,6 +108,12 @@ Foam::coordSystem::cylindrical::cylindrical(autoPtr&& csys)
{}
+Foam::coordSystem::cylindrical::cylindrical(const coordinateRotation& crot)
+:
+ coordinateSystem(crot)
+{}
+
+
Foam::coordSystem::cylindrical::cylindrical
(
const point& origin,
diff --git a/src/meshTools/coordinate/systems/cylindricalCS.H b/src/meshTools/coordinate/systems/cylindricalCS.H
index b05846ff1d..6441b1ccd2 100644
--- a/src/meshTools/coordinate/systems/cylindricalCS.H
+++ b/src/meshTools/coordinate/systems/cylindricalCS.H
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
- Copyright (C) 2018 OpenCFD Ltd.
+ Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -114,7 +114,7 @@ public:
// Constructors
- //- Construct null (identity coordinateSystem)
+ //- Default construct. This is an identity coordinate system
cylindrical();
//- Copy construct
@@ -132,6 +132,9 @@ public:
//- Move construct from autoPtr of another coordinateSystem type
explicit cylindrical(autoPtr&& csys);
+ //- Copy construct from rotation with origin=0
+ explicit cylindrical(const coordinateRotation& crot);
+
//- Construct from origin and rotation
cylindrical(const point& origin, const coordinateRotation& crot);
diff --git a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C
index 049fc2a494..11aacf9109 100644
--- a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C
+++ b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.C
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
- Copyright (C) 2018 OpenCFD Ltd.
+ Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -27,36 +27,103 @@ License
\*---------------------------------------------------------------------------*/
#include "geomDecomp.H"
+#include "specifiedRotation.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+void Foam::geomDecomp::setOrder()
+{
+ const word order(coeffsDict_.getOrDefault("order", ""));
+
+ if (order.empty())
+ {
+ return;
+ }
+ else if (order.size() != 3)
+ {
+ FatalIOErrorInFunction(decompDict_)
+ << "Number of characters in order (" << order << ") != 3"
+ << exit(FatalIOError);
+ }
+
+ for (int i = 0; i < 3; ++i)
+ {
+ // Change [x-z] -> [0-2]
+
+ switch (order[i])
+ {
+ case 'x': order_[i] = 0; break;
+ case 'y': order_[i] = 1; break;
+ case 'z': order_[i] = 2; break;
+
+ default:
+ FatalIOErrorInFunction(decompDict_)
+ << "Illegal decomposition order " << order << nl
+ << "It should only contain x, y or z"
+ << exit(FatalError);
+ break;
+ }
+ }
+}
+
+
void Foam::geomDecomp::readCoeffs()
{
coeffsDict_.readIfPresent("delta", delta_);
+
coeffsDict_.readEntry("n", n_);
- // Verify that the input makes sense
if (nDomains_ != n_.x()*n_.y()*n_.z())
{
+ // Verify that the input makes sense
FatalErrorInFunction
<< "Wrong number of domain divisions in geomDecomp:" << nl
<< "Number of domains : " << nDomains_ << nl
<< "Wanted decomposition : " << n_
<< exit(FatalError);
}
+ setOrder();
- const scalar d = 1 - 0.5*delta_*delta_;
- const scalar d2 = sqr(d);
+ const dictionary* transformDict =
+ coeffsDict_.findDict("transform", keyType::LITERAL);
- const scalar a = delta_;
- const scalar a2 = sqr(a);
+ if (transformDict)
+ {
+ csys_ = coordinateSystem(*transformDict);
+ }
+ else if (equal(delta_, 0))
+ {
+ csys_.clear(); // Reset to identity
+ }
+ else
+ {
+ const scalar d = 1 - 0.5*delta_*delta_;
+ const scalar d2 = sqr(d);
- rotDelta_ = tensor
- (
- d2, -a*d, a,
- a*d - a2*d, a*a2 + d2, -2*a*d,
- a*d2 + a2, a*d - a2*d, d2 - a2
- );
+ const scalar a = delta_;
+ const scalar a2 = sqr(a);
+
+ // Direction (forward/reverse) doesn't matter much
+ tensor rot
+ (
+ d2, -a*d, a,
+ a*d - a2*d, a*a2 + d2, -2*a*d,
+ a*d2 + a2, a*d - a2*d, d2 - a2
+ );
+
+ // origin=0
+ csys_ = coordinateSystem(coordinateRotations::specified(rot));
+ }
+}
+
+// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
+
+Foam::tmp Foam::geomDecomp::adjustPoints
+(
+ const pointField& points
+) const
+{
+ return csys_.localPosition(points);
}
@@ -90,10 +157,11 @@ Foam::geomDecomp::geomDecomp
)
:
decompositionMethod(decompDict),
- coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select)),
- n_(1,1,1),
delta_(0.001),
- rotDelta_(I)
+ csys_(),
+ n_(1,1,1),
+ order_(0,1,2),
+ coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select))
{
readCoeffs();
}
@@ -108,10 +176,11 @@ Foam::geomDecomp::geomDecomp
)
:
decompositionMethod(decompDict, regionName),
- coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select)),
- n_(1,1,1),
delta_(0.001),
- rotDelta_(I)
+ csys_(),
+ n_(1,1,1),
+ order_(0,1,2),
+ coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select))
{
readCoeffs();
}
diff --git a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.H b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.H
index 8233d1b883..49661c9614 100644
--- a/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.H
+++ b/src/parallel/decompose/decompositionMethods/geomDecomp/geomDecomp.H
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
- Copyright (C) 2018 OpenCFD Ltd.
+ Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -32,9 +32,11 @@ Description
Base coefficients:
\table
- Property | Description | Required | Default
- n | (nx ny nz) | yes
- delta | delta for rotation matrix | no | 0.001
+ Property | Description | Required | Default
+ n | (nx ny nz) | yes |
+ order | order of operation | no | xyz
+ delta | delta (jitter) for rotation matrix | no | 0.001
+ rotation | coordinate rotation | no |
\endtable
SourceFiles
@@ -46,7 +48,9 @@ SourceFiles
#define geomDecomp_H
#include "decompositionMethod.H"
+#include "cartesianCS.H"
#include "Vector.H"
+#include "tmp.H"
namespace Foam
{
@@ -59,29 +63,45 @@ class geomDecomp
:
public decompositionMethod
{
+ // Private Data
+
+ //- Small delta (default: 0.001) to avoid staggering when
+ //- mesh itself is aligned with x/y/z
+ scalar delta_;
+
+ //- Local coordinates, or delta rotation tensor
+ coordSystem::cartesian csys_;
+
+
// Private Member Functions
- //- Read input values and initialize the rotDelta_
+ //- Convert ordering string ("xyz") into list of components.
+ // Checks for bad entries, but no check for duplicate entries.
+ void setOrder();
+
+ //- Read input values and initialize rotation matrix
void readCoeffs();
protected:
- // Protected data
+ // Protected Data
+
+ //- The divisions
+ Vector