Commit a83961a0 authored by Mark Olesen's avatar Mark Olesen
Browse files

coordinate system cleanup

- coordinateSystem, cylindricalCS, sphericalCS:
  get copy with name constructor

- cylindricalCS, sphericalCS:
  can switch off default degrees

- dropped cartesianCS class (already covered by coordinateSystem) and just
  always use coordinateSystem directly.
  The dictionary runtime selection still accepts type "cartesian" as an alias,
  to provide the least surprises.

- dropped runtime selection based on origin/axis/direction (not used), but
  left runtime selection based on origin/coordinateRotation as still being
  potentially useful.
parent c20ab11a
......@@ -28,7 +28,6 @@ License
#include "Time.H"
#include "triSurfaceTools.H"
#include "triSurface.H"
#include "cartesianCS.H"
#include "vector2D.H"
#include "OFstream.H"
#include "long.H"
......@@ -348,12 +347,12 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
referenceCS_.reset
(
new cartesianCS
new coordinateSystem
(
"reference",
p0, // origin
n, // normal
e1 // 0-axis
p0, // origin
n, // normal
e1 // 0-axis
)
);
......@@ -397,7 +396,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()
str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
}
// Determine interpolation onto face centres.
triSurfaceTools::calcInterpolationWeights
(
......@@ -721,7 +720,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
{
const Field<Type>& fld = *this;
Type averagePsi =
Type averagePsi =
gSum(this->patch().magSf()*fld)
/gSum(this->patch().magSf());
......
......@@ -107,7 +107,7 @@ class timeVaryingMappedFixedValueFvPatchField
label& lo,
label& hi
) const;
//- Read boundary points and determine interpolation weights to patch
// faceCentres
void readSamplePoints();
......
......@@ -10,13 +10,12 @@ cellDist/wallPoint/wallPoint.C
cellFeatures/cellFeatures.C
coordinateSystems/coordinateSystem.C
coordinateSystems/coordinateSystemNew.C
coordinateSystems/coordinateSystems.C
coordinateSystems/parabolicCylindricalCS.C
coordinateSystems/toroidalCS.C
coordinateSystems/cartesianCS.C
coordinateSystems/newCoordinateSystem.C
coordinateSystems/cylindricalCS.C
coordinateSystems/sphericalCS.C
coordinateSystems/parabolicCylindricalCS.C
coordinateSystems/toroidalCS.C
coordinateSystems/coordinateRotation/coordinateRotation.C
coordinateSystems/coordinateRotation/EulerCoordinateRotation.C
coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cartesianCS.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cartesianCS, 0);
addToRunTimeSelectionTable(coordinateSystem, cartesianCS, origAxisDir);
addToRunTimeSelectionTable(coordinateSystem, cartesianCS, origRotation);
addToRunTimeSelectionTable(coordinateSystem, cartesianCS, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cartesianCS::cartesianCS()
:
coordinateSystem()
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
)
:
coordinateSystem(name, origin, axis, dir)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const coordinateRotation& cr
)
:
coordinateSystem(name, origin, cr)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const dictionary& dict
)
:
coordinateSystem(name, dict)
{}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::cartesianCS
Description
General coordinate transformations from arbitrary coordinate systems
to the global Cartesian system
SourceFiles
cartesianCS.C
\*---------------------------------------------------------------------------*/
#ifndef cartesianCS_H
#define cartesianCS_H
#include "coordinateSystem.H"
#include "typeInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cartesianCS Declaration
\*---------------------------------------------------------------------------*/
class cartesianCS
:
public coordinateSystem
{
public:
//- Runtime type information
TypeName("cartesian");
// Constructors
//- Construct null
cartesianCS();
//- Construct from origin and 2 axes
cartesianCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
);
//- Construct from origin and rotation
cartesianCS
(
const word& name,
const point& origin,
const coordinateRotation&
);
//- Construct from dictionary
cartesianCS(const word& name, const dictionary&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -25,10 +25,10 @@ License
\*---------------------------------------------------------------------------*/
#include "EulerCoordinateRotation.H"
#include "dictionary.H"
#include "addToRunTimeSelectionTable.H"
#include "Switch.H"
#include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -25,10 +25,10 @@ License
\*---------------------------------------------------------------------------*/
#include "STARCDCoordinateRotation.H"
#include "dictionary.H"
#include "addToRunTimeSelectionTable.H"
#include "Switch.H"
#include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -73,6 +73,7 @@ Deprecated
#include "vector.H"
#include "tensor.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -80,8 +81,6 @@ Deprecated
namespace Foam
{
class dictionary;
/*---------------------------------------------------------------------------*\
Class coordinateRotation Declaration
\*---------------------------------------------------------------------------*/
......@@ -93,7 +92,8 @@ class coordinateRotation
// Private data
//- the combination of local axes to be used
enum axisOrder {
enum axisOrder
{
e1e2,
e2e3,
e3e1
......@@ -129,6 +129,11 @@ public:
//- Construct from dictionary
coordinateRotation(const dictionary&);
//- Return clone
autoPtr<coordinateRotation> clone() const
{
return autoPtr<coordinateRotation>(new coordinateRotation(*this));
}
// Declare run-time constructor selection table
......
......@@ -34,9 +34,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(coordinateSystem, 0);
defineRunTimeSelectionTable(coordinateSystem, origAxisDir);
defineRunTimeSelectionTable(coordinateSystem, origRotation);
defineRunTimeSelectionTable(coordinateSystem, dictionary);
defineRunTimeSelectionTable(coordinateSystem, origRotation);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -51,18 +50,31 @@ Foam::coordinateSystem::coordinateSystem()
{}
Foam::coordinateSystem::coordinateSystem
(
const word& name,
const coordinateSystem& cs
)
:
name_(name),
note_(),
origin_(cs.origin_),
R_(cs.R_),
Rtr_(Rtr_)
{}
Foam::coordinateSystem::coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const coordinateRotation& cr
)
:
name_(name),
note_(),
origin_(origin),
R_(axis, dir),
R_(cr),
Rtr_(R_.T())
{}
......@@ -71,13 +83,14 @@ Foam::coordinateSystem::coordinateSystem
(
const word& name,
const point& origin,
const coordinateRotation& cr
const vector& axis,
const vector& dirn
)
:
name_(name),
note_(),
origin_(origin),
R_(cr),
R_(axis, dirn),
Rtr_(R_.T())
{}
......@@ -348,10 +361,7 @@ void Foam::coordinateSystem::operator=(const dictionary& rhs)
// specify via coordinateRotation sub-dictionary
if (dict.found("coordinateRotation"))
{
autoPtr<coordinateRotation> cr =
coordinateRotation::New(dict.subDict("coordinateRotation"));
R_ = cr();
R_ = coordinateRotation::New(dict.subDict("coordinateRotation"))();
}
else
{
......
......@@ -27,7 +27,7 @@ Class
Description
A cartesian coordinate system and the base class for other coordinate
system specifications
system specifications.
All systems are defined by an origin point and a coordinateRotation.
For convenience, the dictionary constructor forms allow a few shortcuts:
......@@ -38,7 +38,6 @@ Description
@verbatim
flipped
{
type cartesian;
origin (0 0 0);
coordinateRotation
{
......@@ -54,7 +53,6 @@ Description
@verbatim
flipped // the same, specified as axes
{
type cartesian;
origin (0 0 0);
coordinateRotation
{
......@@ -71,7 +69,7 @@ Description
@endverbatim
- if a sub-dictionary coordinateSystem is found within the dictionary, it
will be used. This provides a convenient means of embedding the
will be used. This provides a convenient means of embedding
coordinateSystem information in another dictionary.
This is used, for example, in the porousZones:
......@@ -101,6 +99,7 @@ Description
- additionally, if the coordinateSystem points to a plain entry,
it can be used to reference one of the global coordinateSystems
@verbatim
1
(
......@@ -206,16 +205,14 @@ public:
//- Construct null. This is equivalent to an identity coordinateSystem
coordinateSystem();
//- Construct from origin and 2 axes
//- Construct copy with a different name
coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const coordinateSystem&
);
//- Construct from origin and rotation angles
//- Construct from origin and rotation
coordinateSystem
(
const word& name,
......@@ -223,6 +220,15 @@ public:
const coordinateRotation&
);
//- Construct from origin and 2 axes
coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn
);
//- Construct from dictionary with a given name
coordinateSystem(const word& name, const dictionary&);
......@@ -240,15 +246,7 @@ public:
//- Return clone
autoPtr<coordinateSystem> clone() const
{
return autoPtr<coordinateSystem>
(
new coordinateSystem
(
name(),
origin(),
rotation()
)
);
return autoPtr<coordinateSystem>(new coordinateSystem(*this));
}
// Declare run-time constructor selection table
......@@ -257,14 +255,12 @@ public:
(
autoPtr,
coordinateSystem,
origAxisDir,
dictionary,
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const dictionary& dict
),
(name, origin, axis, dir)
(name, dict)
);
declareRunTimeSelectionTable
......@@ -280,29 +276,13 @@ public:
(name, origin, cr)
);
declareRunTimeSelectionTable
(
autoPtr,
coordinateSystem,
dictionary,
(
const word& name,
const dictionary& dict
),
(name, dict)
);
// Selectors
//- Select constructed from origin and 2 axes
//- Select constructed from dictionary
static autoPtr<coordinateSystem> New
(
const word& coordType,
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const dictionary&
);
//- Select constructed from origin and rotation
......@@ -314,13 +294,6 @@ public:
const coordinateRotation&
);
//- Select constructed from dictionary
static autoPtr<coordinateSystem> New
(
const word& name,
const dictionary&
);
//- Select constructed from Istream
static autoPtr<coordinateSystem> New(Istream& is);
......@@ -490,7 +463,7 @@ public:
friend bool operator!=
(
const coordinateSystem&,
const coordinateSystem&,
const coordinateSystem&
);
......
......@@ -31,38 +31,46 @@ License
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
const word& coordType,
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const dictionary& dict
)
{
if (debug)
{
Pout<< "coordinateSystem::New(const word&, const word&, "
<< "const vector&, const vector&, const vector&) : "
"constructing coordinateSystem"
Pout<< "coordinateSystem::New(const word&, const dictionary&) : "
<< "constructing coordinateSystem"
<< endl;
}
origAxisDirConstructorTable::iterator cstrIter =
origAxisDirConstructorTablePtr_->find(coordType);
// construct base class directly, also allow 'cartesian' as an alias
word coordType(typeName_());
if
(
!dict.readIfPresent("type", coordType)
|| coordType == typeName_()
|| coordType == "cartesian"
)
{
return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
}
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(coordType);
if (cstrIter == origAxisDirConstructorTablePtr_->end())
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
FatalIOErrorIn
(
"coordinateSystem::New(const word&, const word&, "
"const vector&, const vector&, const vector&) : "
"constructing coordinateSystem"
"coordinateSystem::New(const word&, const dictionary&)",
dict
) << "Unknown coordinateSystem type " << coordType << nl << nl
<< "Valid coordinateSystem types are :" << nl
<< origAxisDirConstructorTablePtr_->toc()
<< exit(FatalError);
<< "[default: " << typeName_() << "]"
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalIOError);
}
return autoPtr<coordinateSystem>(cstrIter()(name, origin, axis, dir));
return autoPtr<coordinateSystem>(cstrIter()(name, dict));
}