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.
This commit is contained in:
Mark Olesen
2009-01-16 22:08:24 +01:00
parent c20ab11afb
commit a83961a02a
20 changed files with 395 additions and 472 deletions

View File

@ -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());

View File

@ -107,7 +107,7 @@ class timeVaryingMappedFixedValueFvPatchField
label& lo,
label& hi
) const;
//- Read boundary points and determine interpolation weights to patch
// faceCentres
void readSamplePoints();

View File

@ -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

View File

@ -1,81 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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)
{}
// ************************************************************************* //

View File

@ -1,98 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -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 * * * * * * * * * * * * * //

View File

@ -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 * * * * * * * * * * * * * //

View File

@ -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

View File

@ -34,9 +34,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(coordinateSystem, 0);
defineRunTimeSelectionTable(coordinateSystem, origAxisDir);
defineRunTimeSelectionTable(coordinateSystem, origRotation);
defineRunTimeSelectionTable(coordinateSystem, dictionary);
defineRunTimeSelectionTable(coordinateSystem, origRotation);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -54,16 +53,14 @@ Foam::coordinateSystem::coordinateSystem()
Foam::coordinateSystem::coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
const coordinateSystem& cs
)
:
name_(name),
note_(),
origin_(origin),
R_(axis, dir),
Rtr_(R_.T())
origin_(cs.origin_),
R_(cs.R_),
Rtr_(Rtr_)
{}
@ -82,6 +79,22 @@ Foam::coordinateSystem::coordinateSystem
{}
Foam::coordinateSystem::coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn
)
:
name_(name),
note_(),
origin_(origin),
R_(axis, dirn),
Rtr_(R_.T())
{}
Foam::coordinateSystem::coordinateSystem
(
const word& name,
@ -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
{

View File

@ -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,21 +205,28 @@ public:
//- Construct null. This is equivalent to an identity coordinateSystem
coordinateSystem();
//- Construct copy with a different name
coordinateSystem
(
const word& name,
const coordinateSystem&
);
//- Construct from origin and rotation
coordinateSystem
(
const word& name,
const point& origin,
const coordinateRotation&
);
//- Construct from origin and 2 axes
coordinateSystem
(
const word& name,
const point& origin,
const vector& axis,
const vector& dir
);
//- Construct from origin and rotation angles
coordinateSystem
(
const word& name,
const point& origin,
const coordinateRotation&
const vector& dirn
);
//- Construct from dictionary with a given name
@ -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&
);

View File

@ -29,79 +29,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
const word& coordType,
const word& name,
const point& origin,
const vector& axis,
const vector& dir
)
{
if (debug)
{
Pout<< "coordinateSystem::New(const word&, const word&, "
<< "const vector&, const vector&, const vector&) : "
"constructing coordinateSystem"
<< endl;
}
origAxisDirConstructorTable::iterator cstrIter =
origAxisDirConstructorTablePtr_->find(coordType);
if (cstrIter == origAxisDirConstructorTablePtr_->end())
{
FatalErrorIn
(
"coordinateSystem::New(const word&, const word&, "
"const vector&, const vector&, const vector&) : "
"constructing coordinateSystem"
) << "Unknown coordinateSystem type " << coordType << nl << nl
<< "Valid coordinateSystem types are :" << nl
<< origAxisDirConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<coordinateSystem>(cstrIter()(name, origin, axis, dir));
}
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
const word& coordType,
const word& name,
const point& origin,
const coordinateRotation& cr
)
{
if (debug)
{
Pout<< "coordinateSystem::New(const word&, const word&, "
<< "const vector&, const coordinateRotation&) : "
"constructing coordinateSystem"
<< endl;
}
origRotationConstructorTable::iterator cstrIter =
origRotationConstructorTablePtr_->find(coordType);
if (cstrIter == origRotationConstructorTablePtr_->end())
{
FatalErrorIn
(
"coordinateSystem::New(const word&, const word&, "
"const vector&, const coordinateRotation&) : "
"constructing coordinateSystem"
) << "Unknown coordinateSystem type " << coordType << nl << nl
<< "Valid coordinateSystem types are :" << nl
<< origRotationConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
}
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
const word& name,
@ -115,12 +42,14 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
<< endl;
}
// default type is self
// construct base class directly, also allow 'cartesian' as an alias
word coordType(typeName_());
dict.readIfPresent("type", coordType);
// can (must) construct base class directly
if (coordType == typeName_())
if
(
!dict.readIfPresent("type", coordType)
|| coordType == typeName_()
|| coordType == "cartesian"
)
{
return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
}
@ -145,6 +74,42 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
}
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
const word& coordType,
const word& name,
const point& origin,
const coordinateRotation& cr
)
{
if (debug)
{
Pout<< "coordinateSystem::New(const word&, const word&, "
<< "const point&, const coordinateRotation&) : "
"constructing coordinateSystem"
<< endl;
}
origRotationConstructorTable::iterator cstrIter =
origRotationConstructorTablePtr_->find(coordType);
if (cstrIter == origRotationConstructorTablePtr_->end())
{
FatalErrorIn
(
"coordinateSystem::New(const word&, const word&, "
"const point&, const coordinateRotation&) : "
"constructing coordinateSystem"
) << "Unknown coordinateSystem type " << coordType << nl << nl
<< "Valid coordinateSystem types are :" << nl
<< origRotationConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
}
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
(
Istream& is

View File

@ -146,4 +146,5 @@ bool Foam::coordinateSystems::writeData(Ostream& os, bool subDict) const
return os.good();
}
// ************************************************************************* //

View File

@ -25,25 +25,64 @@ License
\*---------------------------------------------------------------------------*/
#include "cylindricalCS.H"
#include "addToRunTimeSelectionTable.H"
#include "one.H"
#include "Switch.H"
#include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cylindricalCS, 0);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origAxisDir);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, origRotation);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cylindricalCS::cylindricalCS()
Foam::cylindricalCS::cylindricalCS(const bool inDegrees)
:
coordinateSystem()
coordinateSystem(),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const coordinateSystem& cs,
const bool inDegrees
)
:
coordinateSystem(cs),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const coordinateSystem& cs,
const bool inDegrees
)
:
coordinateSystem(name, cs),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const point& origin,
const coordinateRotation& cr,
const bool inDegrees
)
:
coordinateSystem(name, origin, cr),
inDegrees_(inDegrees)
{}
@ -52,21 +91,12 @@ Foam::cylindricalCS::cylindricalCS
const word& name,
const point& origin,
const vector& axis,
const vector& direction
const vector& dirn,
const bool inDegrees
)
:
coordinateSystem(name, origin, axis, direction)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const point& origin,
const coordinateRotation& cr
)
:
coordinateSystem(name, origin, cr)
coordinateSystem(name, origin, axis, dirn),
inDegrees_(inDegrees)
{}
@ -76,20 +106,35 @@ Foam::cylindricalCS::cylindricalCS
const dictionary& dict
)
:
coordinateSystem(name, dict)
coordinateSystem(name, dict),
inDegrees_(dict.lookupOrDefault<Switch>("degrees", true))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::cylindricalCS::inDegrees() const
{
return inDegrees_;
}
bool& Foam::cylindricalCS::inDegrees()
{
return inDegrees_;
}
Foam::vector Foam::cylindricalCS::localToGlobal
(
const vector& local,
bool translate
) const
{
scalar theta =
local.y()*mathematicalConstant::pi/180.0;
scalar theta
(
local.y() * ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
return coordinateSystem::localToGlobal
(
@ -98,6 +143,7 @@ Foam::vector Foam::cylindricalCS::localToGlobal
);
}
Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
(
const vectorField& local,
@ -105,7 +151,11 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
) const
{
scalarField theta =
local.component(vector::Y)*mathematicalConstant::pi/180.0;
(
local.component(vector::Y)
* ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
vectorField lc(local.size());
lc.replace(vector::X, local.component(vector::X)*cos(theta));
@ -115,23 +165,28 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
return coordinateSystem::localToGlobal(lc, translate);
}
Foam::vector Foam::cylindricalCS::globalToLocal
(
const vector& global,
bool translate
) const
{
const vector lc =
coordinateSystem::globalToLocal(global, translate);
const vector lc = coordinateSystem::globalToLocal(global, translate);
return vector
(
sqrt(sqr(lc.x()) + sqr(lc.y())),
atan2(lc.y(),lc.x())*180.0/mathematicalConstant::pi,
atan2
(
lc.y(),
lc.x()
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 ),
lc.z()
);
}
Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
(
const vectorField& global,
@ -153,8 +208,11 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
result.replace
(
vector::Y,
atan2(lc.component(vector::Y), lc.component(vector::X))*
180.0/mathematicalConstant::pi
atan2
(
lc.component(vector::Y),
lc.component(vector::X)
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 )
);
result.replace(vector::Z, lc.component(vector::Z));
@ -162,4 +220,5 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
return tresult;
}
// ************************************************************************* //

View File

@ -45,13 +45,18 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cylindricalCS Declaration
Class cylindricalCS Declaration
\*---------------------------------------------------------------------------*/
class cylindricalCS
:
public coordinateSystem
{
// Private data members
//- Are angles in degrees? (default = true)
bool inDegrees_;
protected:
@ -90,28 +95,54 @@ public:
// Constructors
//- Construct null
cylindricalCS();
cylindricalCS(const bool inDegrees=true);
//- Construct from components
//- Construct copy
cylindricalCS
(
const coordinateSystem&,
const bool inDegrees=true
);
//- Construct copy with a different name
cylindricalCS
(
const word& name,
const coordinateSystem&,
const bool inDegrees=true
);
//- Construct from origin and rotation
cylindricalCS
(
const word& name,
const point& origin,
const coordinateRotation&,
const bool inDegrees=true
);
//- Construct from origin and 2 axes
cylindricalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction
);
//- Construct from origin and rotation angles
cylindricalCS
(
const word& name,
const point& origin,
const coordinateRotation&
const vector& dirn,
const bool inDegrees=true
);
//- Construct from dictionary
cylindricalCS(const word& name, const dictionary&);
// Member Functions
//- Are angles in degrees?
bool inDegrees() const;
//- Non-const access to inDegrees
bool& inDegrees();
};

View File

@ -40,6 +40,7 @@ namespace Foam
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parabolicCylindricalCS::parabolicCylindricalCS()
@ -48,18 +49,6 @@ Foam::parabolicCylindricalCS::parabolicCylindricalCS()
{}
Foam::parabolicCylindricalCS::parabolicCylindricalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction
)
:
coordinateSystem(name, origin, axis, direction)
{}
Foam::parabolicCylindricalCS::parabolicCylindricalCS
(
const word& name,

View File

@ -30,6 +30,9 @@ Description
Notation: u = a.x() v = a.y() z = a.z();
Note
The maintenance of this class may lag that of the main types.
SourceFiles
parabolicCylindricalCS.C
@ -46,7 +49,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class parabolicCylindricalCS Declaration
Class parabolicCylindricalCS Declaration
\*---------------------------------------------------------------------------*/
class parabolicCylindricalCS
@ -93,16 +96,7 @@ public:
//- Construct null
parabolicCylindricalCS();
//- Construct from components
parabolicCylindricalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction
);
//- Construct from origin and rotation angles
//- Construct from origin and rotation
parabolicCylindricalCS
(
const word& name,

View File

@ -25,24 +25,64 @@ License
\*---------------------------------------------------------------------------*/
#include "sphericalCS.H"
#include "addToRunTimeSelectionTable.H"
#include "one.H"
#include "Switch.H"
#include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(sphericalCS, 0);
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, origAxisDir);
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, origRotation);
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, dictionary);
addToRunTimeSelectionTable(coordinateSystem, sphericalCS, origRotation);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sphericalCS::sphericalCS()
Foam::sphericalCS::sphericalCS(const bool inDegrees)
:
coordinateSystem()
coordinateSystem(),
inDegrees_(inDegrees)
{}
Foam::sphericalCS::sphericalCS
(
const coordinateSystem& cs,
const bool inDegrees
)
:
coordinateSystem(cs),
inDegrees_(inDegrees)
{}
Foam::sphericalCS::sphericalCS
(
const word& name,
const coordinateSystem& cs,
const bool inDegrees
)
:
coordinateSystem(name, cs),
inDegrees_(inDegrees)
{}
Foam::sphericalCS::sphericalCS
(
const word& name,
const point& origin,
const coordinateRotation& cr,
const bool inDegrees
)
:
coordinateSystem(name, origin, cr),
inDegrees_(inDegrees)
{}
@ -51,21 +91,12 @@ Foam::sphericalCS::sphericalCS
const word& name,
const point& origin,
const vector& axis,
const vector& direction
const vector& dirn,
const bool inDegrees
)
:
coordinateSystem(name, origin, axis, direction)
{}
Foam::sphericalCS::sphericalCS
(
const word& name,
const point& origin,
const coordinateRotation& cr
)
:
coordinateSystem(name, origin, cr)
coordinateSystem(name, origin, axis, dirn),
inDegrees_(inDegrees)
{}
@ -75,11 +106,25 @@ Foam::sphericalCS::sphericalCS
const dictionary& dict
)
:
coordinateSystem(name, dict)
coordinateSystem(name, dict),
inDegrees_(dict.lookupOrDefault<Switch>("degrees", true))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sphericalCS::inDegrees() const
{
return inDegrees_;
}
bool& Foam::sphericalCS::inDegrees()
{
return inDegrees_;
}
Foam::vector Foam::sphericalCS::localToGlobal
(
const vector& local,
@ -87,8 +132,16 @@ Foam::vector Foam::sphericalCS::localToGlobal
) const
{
scalar r = local.x();
scalar theta = local.y()*mathematicalConstant::pi/180.0;
scalar phi = local.z()*mathematicalConstant::pi/180.0;
const scalar theta
(
local.y()
* ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
const scalar phi
(
local.z()
* ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
return coordinateSystem::localToGlobal
(
@ -105,12 +158,16 @@ Foam::tmp<Foam::vectorField> Foam::sphericalCS::localToGlobal
) const
{
const scalarField r = local.component(vector::X);
const scalarField theta =
local.component(vector::Y)*mathematicalConstant::pi/180.0;
const scalarField phi =
local.component(vector::Z)*mathematicalConstant::pi/180.0;
const scalarField theta
(
local.component(vector::Y)
* ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
const scalarField phi
(
local.component(vector::Z)
* ( inDegrees_ ? mathematicalConstant::pi/180.0 : 1.0 )
);
vectorField lc(local.size());
lc.replace(vector::X, r*cos(theta)*sin(phi));
@ -133,8 +190,14 @@ Foam::vector Foam::sphericalCS::globalToLocal
return vector
(
r,
atan2(lc.y(), lc.x())*180.0/mathematicalConstant::pi,
acos(lc.z()/(r + SMALL))*180.0/mathematicalConstant::pi
atan2
(
lc.y(), lc.x()
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 ),
acos
(
lc.z()/(r + SMALL)
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 )
);
}
@ -164,16 +227,20 @@ Foam::tmp<Foam::vectorField> Foam::sphericalCS::globalToLocal
(
lc.component(vector::Y),
lc.component(vector::X)
)*180.0/mathematicalConstant::pi
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 )
);
result.replace
(
vector::Z,
acos(lc.component(vector::Z)/(r + SMALL))*180.0/mathematicalConstant::pi
acos
(
lc.component(vector::Z)/(r + SMALL)
) * ( inDegrees_ ? 180.0/mathematicalConstant::pi : 1.0 )
);
return tresult;
}
// ************************************************************************* //

View File

@ -44,13 +44,18 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sphericalCS Declaration
Class sphericalCS Declaration
\*---------------------------------------------------------------------------*/
class sphericalCS
:
public coordinateSystem
{
// Private data members
//- Are angles in degrees? (default = true)
bool inDegrees_;
protected:
@ -89,30 +94,54 @@ public:
// Constructors
//- Construct null
sphericalCS();
sphericalCS(const bool inDegrees=true);
//- Construct from components
//- Construct copy
sphericalCS
(
const coordinateSystem&,
const bool inDegrees=true
);
//- Construct copy with a different name
sphericalCS
(
const word& name,
const coordinateSystem&,
const bool inDegrees=true
);
//- Construct from origin and rotation
sphericalCS
(
const word& name,
const point& origin,
const coordinateRotation&,
const bool inDegrees=true
);
//- Construct from origin and 2 axes
sphericalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction
const vector& dirn,
const bool inDegrees=true
);
//- Construct from origin and rotation angles
sphericalCS
(
const word& name,
const point& origin,
const coordinateRotation&
);
//- Construct from dictionary
sphericalCS(const word& name, const dictionary&);
// Member Functions
//- Are angles in degrees?
bool inDegrees() const;
//- Non-const access to inDegrees
bool& inDegrees();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,19 +38,6 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::toroidalCS::toroidalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction,
const scalar radius
)
:
coordinateSystem(name, origin, axis, direction),
radius_(radius)
{}
Foam::toroidalCS::toroidalCS
(

View File

@ -26,7 +26,10 @@ Class
Foam::toroidalCS
Description
Toroidal coordinate system
Toroidal coordinate system, always in degrees
Note
The maintenance of this class may lag that of the main types.
SourceFiles
toroidalCS.C
@ -91,17 +94,7 @@ public:
// Constructors
//- Construct from components
toroidalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& direction,
const scalar radius
);
//- Construct from origin and rotation angles
//- Construct from origin, rotation and radius
toroidalCS
(
const word& name,
@ -110,6 +103,7 @@ public:
const scalar radius
);
//- Construct from dictionary
toroidalCS(const word& name, const dictionary&);