coordinateSystems: Initial work to simplify and rationalise

There is much more to be done, a complete rewrite of coordinateSystems would be
best.
This commit is contained in:
Henry Weller
2020-09-28 20:47:33 +01:00
parent 081f2d5726
commit e8c5163f82
32 changed files with 608 additions and 1380 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -123,10 +123,13 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData()
F_[zoneI][i].zz() = 0.5*fXYZ_.value().z(); F_[zoneI][i].zz() = 0.5*fXYZ_.value().z();
} }
const coordinateRotation& R = coordSys_.R(mesh_, cells); const coordinateRotation& R = coordSys_.R
(
UIndirectList<vector>(mesh_.C(), cells)()
);
D_[zoneI] = R.transformTensor(D_[zoneI], cells); D_[zoneI] = R.transformTensor(D_[zoneI]);
F_[zoneI] = R.transformTensor(F_[zoneI], cells); F_[zoneI] = R.transformTensor(F_[zoneI]);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -175,10 +175,13 @@ void Foam::porosityModels::fixedCoeff::calcTransformModelData()
beta_[zoneI][i].zz() = betaXYZ_.value().z(); beta_[zoneI][i].zz() = betaXYZ_.value().z();
} }
const coordinateRotation& R = coordSys_.R(mesh_, cells); const coordinateRotation& R = coordSys_.R
(
UIndirectList<vector>(mesh_.C(), cells)()
);
alpha_[zoneI] = R.transformTensor(alpha_[zoneI], cells); alpha_[zoneI] = R.transformTensor(alpha_[zoneI]);
beta_[zoneI] = R.transformTensor(beta_[zoneI], cells); beta_[zoneI] = R.transformTensor(beta_[zoneI]);
} }
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,7 +56,7 @@ fieldCoordinateSystemTransform
: :
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
fieldSet_(), fieldSet_(),
coordSys_(mesh_, dict.subDict("coordinateSystem")) coordSys_(coordinateSystem::New(mesh_, dict.subDict("coordinateSystem"))())
{ {
read(dict); read(dict);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -362,7 +362,7 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
if (dict.found("coordinateSystem")) if (dict.found("coordinateSystem"))
{ {
coordSysPtr_.reset(new coordinateSystem(obr_, dict)); coordSysPtr_ = coordinateSystem::New(obr_, dict);
Info<< "Transforming all vectorFields with coordinate system " Info<< "Transforming all vectorFields with coordinate system "
<< coordSysPtr_().name() << endl; << coordSysPtr_().name() << endl;

View File

@ -547,7 +547,7 @@ Foam::functionObjects::forces::forces
fDName_(""), fDName_(""),
rhoRef_(vGreat), rhoRef_(vGreat),
pRef_(0), pRef_(0),
coordSys_(), coordSys_("coordSys", vector::zero),
localSystem_(false), localSystem_(false),
porosity_(false), porosity_(false),
nBin_(1), nBin_(1),
@ -582,7 +582,7 @@ Foam::functionObjects::forces::forces
fDName_(""), fDName_(""),
rhoRef_(vGreat), rhoRef_(vGreat),
pRef_(0), pRef_(0),
coordSys_(), coordSys_("coordSys", vector::zero),
localSystem_(false), localSystem_(false),
porosity_(false), porosity_(false),
nBin_(1), nBin_(1),
@ -642,13 +642,16 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0); pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0);
} }
coordSys_.clear();
// Centre of rotation for moment calculations // Centre of rotation for moment calculations
// specified directly, from coordinate system, or implicitly (0 0 0) // specified directly, from coordinate system, or implicitly (0 0 0)
if (!dict.readIfPresent<point>("CofR", coordSys_.origin())) if (dict.found("CofR"))
{ {
coordSys_ = coordinateSystem(obr_, dict); coordSys_ = coordinateSystem("coordSys", vector(dict.lookup("CofR")));
localSystem_ = false;
}
else
{
coordSys_ = coordinateSystem("coordSys", dict);
localSystem_ = true; localSystem_ = true;
} }

View File

@ -24,11 +24,12 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "rotorDiskSource.H" #include "rotorDiskSource.H"
#include "addToRunTimeSelectionTable.H"
#include "trimModel.H" #include "trimModel.H"
#include "fvMatrices.H" #include "fvMatrices.H"
#include "geometricOneField.H" #include "geometricOneField.H"
#include "syncTools.H" #include "syncTools.H"
#include "axesRotation.H"
#include "addToRunTimeSelectionTable.H"
using namespace Foam::constant; using namespace Foam::constant;
@ -42,8 +43,8 @@ namespace Foam
addToRunTimeSelectionTable(option, rotorDiskSource, dictionary); addToRunTimeSelectionTable(option, rotorDiskSource, dictionary);
} }
template<> const char* NamedEnum<fv::rotorDiskSource::geometryModeType, 2>:: template<> const char*
names[] = NamedEnum<fv::rotorDiskSource::geometryModeType, 2>::names[] =
{ {
"auto", "auto",
"specified" "specified"
@ -52,8 +53,8 @@ namespace Foam
const NamedEnum<fv::rotorDiskSource::geometryModeType, 2> const NamedEnum<fv::rotorDiskSource::geometryModeType, 2>
fv::rotorDiskSource::geometryModeTypeNames_; fv::rotorDiskSource::geometryModeTypeNames_;
template<> const char* NamedEnum<fv::rotorDiskSource::inletFlowType, 3>:: template<> const char*
names[] = NamedEnum<fv::rotorDiskSource::inletFlowType, 3>::names[] =
{ {
"fixed", "fixed",
"surfaceNormal", "surfaceNormal",
@ -338,13 +339,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
cylindrical_.reset cylindrical_.reset
( (
new cylindrical new cylindrical(axis, origin, UIndirectList<vector>(C, cells)())
(
mesh_,
axis,
origin,
cells
)
); );
// Set the face areas and apply correction to calculated axis // Set the face areas and apply correction to calculated axis
@ -363,10 +358,9 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
( (
new cylindrical new cylindrical
( (
mesh_,
axis, axis,
origin, origin,
cells() UIndirectList<vector>(mesh_.C(), this->cells())()
) )
); );
@ -475,7 +469,6 @@ Foam::fv::rotorDiskSource::rotorDiskSource
const word& modelType, const word& modelType,
const dictionary& dict, const dictionary& dict,
const fvMesh& mesh const fvMesh& mesh
) )
: :
cellSetOption(name, modelType, dict, mesh), cellSetOption(name, modelType, dict, mesh),
@ -490,7 +483,7 @@ Foam::fv::rotorDiskSource::rotorDiskSource
R_(cells().size(), I), R_(cells().size(), I),
invR_(cells().size(), I), invR_(cells().size(), I),
area_(cells().size(), 0.0), area_(cells().size(), 0.0),
coordSys_(false), coordSys_("rotorCoordSys", vector::zero, axesRotation(sphericalTensor::I)),
cylindrical_(), cylindrical_(),
rMax_(0.0), rMax_(0.0),
trim_(trimModel::New(*this, coeffs_)), trim_(trimModel::New(*this, coeffs_)),

View File

@ -30,6 +30,7 @@ License
#include "Random.H" #include "Random.H"
#include "triangle.H" #include "triangle.H"
#include "cloud.H" #include "cloud.H"
#include "axesRotation.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -522,7 +523,7 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
faceTris_(), faceTris_(),
nSector_(0), nSector_(0),
radius_(), radius_(),
coordSys_(false), coordSys_("coordSys", vector::zero, axesRotation(sphericalTensor::I)),
normal_(), normal_(),
negateParcelsOppositeNormal_ negateParcelsOppositeNormal_
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,84 +38,7 @@ namespace Foam
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::cartesianCS::cartesianCS()
:
coordinateSystem()
{}
Foam::cartesianCS::cartesianCS
(
const coordinateSystem& cs
)
:
coordinateSystem(cs)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const coordinateSystem& cs
)
:
coordinateSystem(name, cs)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const coordinateRotation& cr
)
:
coordinateSystem(name, origin, cr)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn
)
:
coordinateSystem(name, origin, axis, dirn)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const dictionary& dict
)
:
coordinateSystem(name, dict)
{}
Foam::cartesianCS::cartesianCS
(
const objectRegistry& obr,
const dictionary& dict
)
:
coordinateSystem(obr, dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cartesianCS::~cartesianCS()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::cartesianCS::localToGlobal Foam::vector Foam::cartesianCS::localToGlobal
( (
@ -157,4 +80,45 @@ Foam::tmp<Foam::vectorField> Foam::cartesianCS::globalToLocal
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const coordinateRotation& cr
)
:
coordinateSystem(name, origin, cr)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn
)
:
coordinateSystem(name, origin, axis, dirn)
{}
Foam::cartesianCS::cartesianCS
(
const word& name,
const dictionary& dict
)
:
coordinateSystem(name, dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cartesianCS::~cartesianCS()
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -51,10 +51,7 @@ class cartesianCS
: :
public coordinateSystem public coordinateSystem
{ {
protected: // Private Member Functions
// Protected Member Functions
//- Convert from local coordinate system to the global Cartesian system //- Convert from local coordinate system to the global Cartesian system
// with optional translation for the origin // with optional translation for the origin
@ -89,22 +86,6 @@ public:
// Constructors // Constructors
//- Construct null
cartesianCS();
//- Construct copy
cartesianCS
(
const coordinateSystem&
);
//- Construct copy with a different name
cartesianCS
(
const word& name,
const coordinateSystem&
);
//- Construct from origin and rotation //- Construct from origin and rotation
cartesianCS cartesianCS
( (
@ -126,13 +107,8 @@ public:
cartesianCS(const word&, const dictionary&); cartesianCS(const word&, const dictionary&);
//- Construct from dictionary and objectRegistry
cartesianCS(const objectRegistry&, const dictionary&);
//- Destructor //- Destructor
virtual ~cartesianCS(); virtual ~cartesianCS();
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,109 +43,10 @@ namespace Foam
( (
coordinateRotation, coordinateRotation,
EulerCoordinateRotation, EulerCoordinateRotation,
objectRegistry points
); );
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::vector Foam::EulerCoordinateRotation::transform(const vector& st) const
{
return (R_ & st);
}
Foam::vector Foam::EulerCoordinateRotation::invTransform
(
const vector& st
) const
{
return (Rtr_ & st);
}
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::transform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::invTransform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
const Foam::tensorField& Foam::EulerCoordinateRotation::Tr() const
{
NotImplemented;
return NullObjectRef<tensorField>();
}
Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
(
const tensorField& st
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tensor Foam::EulerCoordinateRotation::transformTensor
(
const tensor& st
) const
{
return (R_ & st & Rtr_);
}
Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
(
const tensorField& st,
const labelList& cellMap
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tmp<Foam::symmTensorField> Foam::EulerCoordinateRotation::
transformVector
(
const vectorField& st
) const
{
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
symmTensorField& fld = tfld.ref();
forAll(fld, i)
{
fld[i] = transformPrincipal(R_, st[i]);
}
return tfld;
}
Foam::symmTensor Foam::EulerCoordinateRotation::transformVector
(
const vector& st
) const
{
return transformPrincipal(R_, st);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -192,47 +93,6 @@ void Foam::EulerCoordinateRotation::calcTransform
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::EulerCoordinateRotation::EulerCoordinateRotation()
:
R_(sphericalTensor::I),
Rtr_(R_)
{}
Foam::EulerCoordinateRotation::EulerCoordinateRotation
(
const vector& phiThetaPsi,
const bool inDegrees
)
:
R_(sphericalTensor::I),
Rtr_(R_)
{
calcTransform
(
phiThetaPsi.component(vector::X),
phiThetaPsi.component(vector::Y),
phiThetaPsi.component(vector::Z),
inDegrees
);
}
Foam::EulerCoordinateRotation::EulerCoordinateRotation
(
const scalar phiAngle,
const scalar thetaAngle,
const scalar psiAngle,
const bool inDegrees
)
:
R_(sphericalTensor::I),
Rtr_(R_)
{
calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees);
}
Foam::EulerCoordinateRotation::EulerCoordinateRotation Foam::EulerCoordinateRotation::EulerCoordinateRotation
( (
const dictionary& dict const dictionary& dict
@ -256,21 +116,92 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation
Foam::EulerCoordinateRotation::EulerCoordinateRotation Foam::EulerCoordinateRotation::EulerCoordinateRotation
( (
const dictionary& dict, const dictionary& dict,
const objectRegistry& const UList<vector>& points
) )
: :
R_(sphericalTensor::I), EulerCoordinateRotation(dict)
Rtr_(R_) {}
{
vector rotation(dict.lookup("rotation"));
calcTransform
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::vector Foam::EulerCoordinateRotation::transform(const vector& st) const
{
return (R_ & st);
}
Foam::vector Foam::EulerCoordinateRotation::invTransform
( (
rotation.component(vector::X), const vector& st
rotation.component(vector::Y), ) const
rotation.component(vector::Z), {
dict.lookupOrDefault("degrees", true) return (Rtr_ & st);
); }
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::transform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::vectorField> Foam::EulerCoordinateRotation::invTransform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::tensorField> Foam::EulerCoordinateRotation::transformTensor
(
const tensorField& st
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tensor Foam::EulerCoordinateRotation::transformTensor
(
const tensor& st
) const
{
return (R_ & st & Rtr_);
}
Foam::tmp<Foam::symmTensorField> Foam::EulerCoordinateRotation::
transformVector
(
const vectorField& st
) const
{
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
symmTensorField& fld = tfld.ref();
forAll(fld, i)
{
fld[i] = transformPrincipal(R_, st[i]);
}
return tfld;
}
Foam::symmTensor Foam::EulerCoordinateRotation::transformVector
(
const vector& st
) const
{
return transformPrincipal(R_, st);
} }
@ -281,4 +212,5 @@ void Foam::EulerCoordinateRotation::write(Ostream& os) const
writeEntry(os, "e3", e3()); writeEntry(os, "e3", e3());
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -98,43 +98,26 @@ public:
// Constructors // Constructors
//- Construct null
EulerCoordinateRotation();
//- Construct from rotation vector
EulerCoordinateRotation
(
const vector& phiThetaPsi,
const bool inDegrees=true
);
//- Construct from components of rotation vector
EulerCoordinateRotation
(
const scalar phiAngle,
const scalar thetaAngle,
const scalar psiAngle,
const bool inDegrees=true
);
//- Construct from dictionary //- Construct from dictionary
EulerCoordinateRotation(const dictionary&); EulerCoordinateRotation(const dictionary&);
//- Construct from dictionary and mesh //- Construct from dictionary and list of points
EulerCoordinateRotation(const dictionary&, const objectRegistry&); EulerCoordinateRotation(const dictionary&, const UList<vector>& points);
//- Construct and return a clone
virtual autoPtr<coordinateRotation> clone() const
{
return autoPtr<coordinateRotation>
(
new EulerCoordinateRotation(*this)
);
}
// Member Functions // Member Functions
//- Reset rotation to an identity rotation //- Update the rotation for a list of points
virtual void clear() virtual void updatePoints(const UList<vector>& points)
{
R_ = sphericalTensor::I;
Rtr_ = sphericalTensor::I;
}
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{} {}
//- Return local-to-global transformation tensor //- Return local-to-global transformation tensor
@ -143,12 +126,6 @@ public:
return R_; return R_;
} }
//- Return global-to-local transformation tensor
virtual const tensor& Rtr() const
{
return Rtr_;
};
//- Return local Cartesian x-axis in global coordinates //- Return local Cartesian x-axis in global coordinates
virtual const vector e1() const virtual const vector e1() const
{ {
@ -167,9 +144,6 @@ public:
return Rtr_.z(); return Rtr_.z();
} }
//- Return transformation tensor field
virtual const tensorField& Tr() const;
//- Transform vectorField using transformation tensor field //- Transform vectorField using transformation tensor field
virtual tmp<vectorField> transform(const vectorField& st) const; virtual tmp<vectorField> transform(const vectorField& st) const;
@ -188,13 +162,6 @@ public:
//- Transform tensor using transformation tensorField //- Transform tensor using transformation tensorField
virtual tensor transformTensor(const tensor& st) const; virtual tensor transformTensor(const tensor& st) const;
//- Transform tensor sub-field using transformation tensorField
virtual tmp<tensorField> transformTensor
(
const tensorField& st,
const labelList& cellMap
) const;
//- Transform vectorField using transformation tensorField and return //- Transform vectorField using transformation tensorField and return
// symmetrical tensorField // symmetrical tensorField
virtual tmp<symmTensorField> transformVector virtual tmp<symmTensorField> transformVector

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,110 +43,11 @@ namespace Foam
( (
coordinateRotation, coordinateRotation,
STARCDCoordinateRotation, STARCDCoordinateRotation,
objectRegistry points
); );
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::vector Foam::STARCDCoordinateRotation::transform(const vector& st) const
{
return (R_ & st);
}
Foam::vector Foam::STARCDCoordinateRotation::invTransform
(
const vector& st
) const
{
return (Rtr_ & st);
}
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::transform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::invTransform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
const Foam::tensorField& Foam::STARCDCoordinateRotation::Tr() const
{
NotImplemented;
return NullObjectRef<tensorField>();
}
Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
(
const tensorField& st
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tensor Foam::STARCDCoordinateRotation::transformTensor
(
const tensor& st
) const
{
return (R_ & st & Rtr_);
}
Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
(
const tensorField& st,
const labelList& cellMap
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tmp<Foam::symmTensorField> Foam::STARCDCoordinateRotation::
transformVector
(
const vectorField& st
) const
{
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
symmTensorField& fld = tfld.ref();
forAll(fld, i)
{
fld[i] = transformPrincipal(R_, st[i]);
}
return tfld;
}
Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector
(
const vector& st
) const
{
return transformPrincipal(R_, st);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::STARCDCoordinateRotation::calcTransform void Foam::STARCDCoordinateRotation::calcTransform
@ -192,47 +93,6 @@ void Foam::STARCDCoordinateRotation::calcTransform
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation()
:
R_(sphericalTensor::I),
Rtr_(R_)
{}
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
(
const vector& rotZrotXrotY,
const bool inDegrees
)
:
R_(sphericalTensor::I),
Rtr_(R_)
{
calcTransform
(
rotZrotXrotY.component(vector::X),
rotZrotXrotY.component(vector::Y),
rotZrotXrotY.component(vector::Z),
inDegrees
);
}
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
(
const scalar rotZ,
const scalar rotX,
const scalar rotY,
const bool inDegrees
)
:
R_(sphericalTensor::I),
Rtr_(R_)
{
calcTransform(rotZ, rotX, rotY, inDegrees);
}
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
( (
const dictionary& dict const dictionary& dict
@ -256,18 +116,92 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
Foam::STARCDCoordinateRotation::STARCDCoordinateRotation Foam::STARCDCoordinateRotation::STARCDCoordinateRotation
( (
const dictionary& dict, const dictionary& dict,
const objectRegistry& const UList<vector>& points
) )
{ :
vector rotation(dict.lookup("rotation")); STARCDCoordinateRotation(dict)
{}
calcTransform
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::vector Foam::STARCDCoordinateRotation::transform(const vector& st) const
{
return (R_ & st);
}
Foam::vector Foam::STARCDCoordinateRotation::invTransform
( (
rotation.component(vector::X), const vector& st
rotation.component(vector::Y), ) const
rotation.component(vector::Z), {
dict.lookupOrDefault("degrees", true) return (Rtr_ & st);
); }
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::transform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::vectorField> Foam::STARCDCoordinateRotation::invTransform
(
const vectorField& st
) const
{
NotImplemented;
return tmp<vectorField>(nullptr);
}
Foam::tmp<Foam::tensorField> Foam::STARCDCoordinateRotation::transformTensor
(
const tensorField& st
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tensor Foam::STARCDCoordinateRotation::transformTensor
(
const tensor& st
) const
{
return (R_ & st & Rtr_);
}
Foam::tmp<Foam::symmTensorField> Foam::STARCDCoordinateRotation::
transformVector
(
const vectorField& st
) const
{
tmp<symmTensorField> tfld(new symmTensorField(st.size()));
symmTensorField& fld = tfld.ref();
forAll(fld, i)
{
fld[i] = transformPrincipal(R_, st[i]);
}
return tfld;
}
Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector
(
const vector& st
) const
{
return transformPrincipal(R_, st);
} }
@ -278,4 +212,5 @@ void Foam::STARCDCoordinateRotation::write(Ostream& os) const
writeEntry(os, "e3", e3()); writeEntry(os, "e3", e3());
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -95,42 +95,30 @@ public:
// Constructors // Constructors
//- Construct null
STARCDCoordinateRotation();
//- Construct from rotation vector
STARCDCoordinateRotation
(
const vector& rotZrotXrotY,
const bool inDegrees=true
);
//- Construct from components of rotation vector
STARCDCoordinateRotation
(
const scalar rotZ,
const scalar rotX,
const scalar rotY,
const bool inDegrees=true
);
//- Construct from dictionary //- Construct from dictionary
STARCDCoordinateRotation(const dictionary&); STARCDCoordinateRotation(const dictionary&);
//- Construct from dictionary and mesh //- Construct from dictionary and list of points
STARCDCoordinateRotation(const dictionary&, const objectRegistry&); STARCDCoordinateRotation
(
const dictionary&,
const UList<vector>& points
);
//- Construct and return a clone
virtual autoPtr<coordinateRotation> clone() const
{
return autoPtr<coordinateRotation>
(
new STARCDCoordinateRotation(*this)
);
}
// Member Functions // Member Functions
//- Reset rotation to an identity rotation //- Update the rotation for a list of points
virtual void clear() virtual void updatePoints(const UList<vector>& points)
{
R_ = sphericalTensor::I;
Rtr_ = sphericalTensor::I;
}
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{} {}
//- Return local-to-global transformation tensor //- Return local-to-global transformation tensor
@ -139,12 +127,6 @@ public:
return R_; return R_;
} }
//- Return global-to-local transformation tensor
virtual const tensor& Rtr() const
{
return Rtr_;
};
//- Return local Cartesian x-axis in global coordinates //- Return local Cartesian x-axis in global coordinates
virtual const vector e1() const virtual const vector e1() const
{ {
@ -163,9 +145,6 @@ public:
return Rtr_.z(); return Rtr_.z();
} }
//- Return transformation tensor field
virtual const tensorField& Tr() const;
//- Transform vectorField using transformation tensor field //- Transform vectorField using transformation tensor field
virtual tmp<vectorField> transform(const vectorField& st) const; virtual tmp<vectorField> transform(const vectorField& st) const;
@ -184,13 +163,6 @@ public:
//- Transform tensor using transformation tensorField //- Transform tensor using transformation tensorField
virtual tensor transformTensor(const tensor& st) const; virtual tensor transformTensor(const tensor& st) const;
//- Transform tensor sub-field using transformation tensorField
virtual tmp<tensorField> transformTensor
(
const tensorField& st,
const labelList& cellMap
) const;
//- Transform vectorField using transformation tensorField and return //- Transform vectorField using transformation tensorField and return
// symmetrical tensorField // symmetrical tensorField
virtual tmp<symmTensorField> transformVector virtual tmp<symmTensorField> transformVector

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,12 +33,7 @@ namespace Foam
{ {
defineTypeNameAndDebug(axesRotation, 0); defineTypeNameAndDebug(axesRotation, 0);
addToRunTimeSelectionTable(coordinateRotation, axesRotation, dictionary); addToRunTimeSelectionTable(coordinateRotation, axesRotation, dictionary);
addToRunTimeSelectionTable addToRunTimeSelectionTable(coordinateRotation, axesRotation, points);
(
coordinateRotation,
axesRotation,
objectRegistry
);
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -105,13 +100,6 @@ void Foam::axesRotation::calcTransform
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::axesRotation::axesRotation()
:
R_(sphericalTensor::I),
Rtr_(R_)
{}
Foam::axesRotation::axesRotation Foam::axesRotation::axesRotation
( (
const vector& axis, const vector& axis,
@ -125,6 +113,13 @@ Foam::axesRotation::axesRotation
} }
Foam::axesRotation::axesRotation(const tensor& R)
:
R_(R),
Rtr_(R_.T())
{}
Foam::axesRotation::axesRotation Foam::axesRotation::axesRotation
( (
const dictionary& dict const dictionary& dict
@ -140,32 +135,15 @@ Foam::axesRotation::axesRotation
Foam::axesRotation::axesRotation Foam::axesRotation::axesRotation
( (
const dictionary& dict, const dictionary& dict,
const objectRegistry& obr const UList<vector>& points
) )
: :
R_(sphericalTensor::I), axesRotation(dict)
Rtr_(R_)
{
operator=(dict);
}
Foam::axesRotation::axesRotation(const tensor& R)
:
R_(R),
Rtr_(R_.T())
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::tensorField& Foam::axesRotation::Tr() const
{
NotImplemented;
return NullObjectRef<tensorField>();
}
Foam::tmp<Foam::vectorField> Foam::axesRotation::transform Foam::tmp<Foam::vectorField> Foam::axesRotation::transform
( (
const vectorField& st const vectorField& st
@ -215,17 +193,6 @@ Foam::tensor Foam::axesRotation::transformTensor
} }
Foam::tmp<Foam::tensorField> Foam::axesRotation::transformTensor
(
const tensorField& st,
const labelList& cellMap
) const
{
NotImplemented;
return tmp<tensorField>(nullptr);
}
Foam::tmp<Foam::symmTensorField> Foam::axesRotation::transformVector Foam::tmp<Foam::symmTensorField> Foam::axesRotation::transformVector
( (
const vectorField& st const vectorField& st
@ -251,6 +218,14 @@ Foam::symmTensor Foam::axesRotation::transformVector
} }
void Foam::axesRotation::write(Ostream& os) const
{
writeEntry(os, "e1", e1());
writeEntry(os, "e2", e2());
writeEntry(os, "e3", e3());
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::axesRotation::operator=(const dictionary& dict) void Foam::axesRotation::operator=(const dictionary& dict)
@ -296,12 +271,4 @@ void Foam::axesRotation::operator=(const dictionary& dict)
} }
void Foam::axesRotation::write(Ostream& os) const
{
writeEntry(os, "e1", e1());
writeEntry(os, "e2", e2());
writeEntry(os, "e3", e3());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -100,25 +100,22 @@ public:
// Constructors // Constructors
//- Construct null
axesRotation();
//- Construct from 2 axes //- Construct from 2 axes
axesRotation(const vector& axis, const vector& dir); axesRotation(const vector& axis, const vector& dir);
//- Construct from dictionary
axesRotation(const dictionary&);
//- Construct from components //- Construct from components
axesRotation(const tensor& R); axesRotation(const tensor& R);
//- Construct from dictionary and mesh //- Construct from dictionary
axesRotation(const dictionary&, const objectRegistry&); axesRotation(const dictionary&);
//- Return clone //- Construct from dictionary and list of points
autoPtr<axesRotation> clone() const axesRotation(const dictionary&, const UList<vector>& points);
//- Construct and return a clone
virtual autoPtr<coordinateRotation> clone() const
{ {
return autoPtr<axesRotation>(new axesRotation(*this)); return autoPtr<coordinateRotation>(new axesRotation(*this));
} }
@ -129,15 +126,8 @@ public:
// Member Functions // Member Functions
//- Reset rotation to an identity rotation //- Update the rotation for a list of points
virtual void clear() virtual void updatePoints(const UList<vector>& points)
{
R_ = sphericalTensor::I;
Rtr_ = sphericalTensor::I;
}
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{} {}
//- Return local-to-global transformation tensor //- Return local-to-global transformation tensor
@ -146,12 +136,6 @@ public:
return R_; return R_;
} }
//- Return global-to-local transformation tensor
virtual const tensor& Rtr() const
{
return Rtr_;
}
//- Return local Cartesian x-axis in global coordinates //- Return local Cartesian x-axis in global coordinates
virtual const vector e1() const virtual const vector e1() const
{ {
@ -170,9 +154,6 @@ public:
return Rtr_.z(); return Rtr_.z();
} }
//- Return transformation tensor field
virtual const tensorField& Tr() const;
//- Transform vectorField using transformation tensor field //- Transform vectorField using transformation tensor field
virtual tmp<vectorField> transform(const vectorField& st) const; virtual tmp<vectorField> transform(const vectorField& st) const;
@ -191,13 +172,6 @@ public:
//- Transform tensor using transformation tensorField //- Transform tensor using transformation tensorField
virtual tensor transformTensor(const tensor& st) const; virtual tensor transformTensor(const tensor& st) const;
//- Transform tensor sub-field using transformation tensorField
virtual tmp<tensorField> transformTensor
(
const tensorField& st,
const labelList& cellMap
) const;
//- Transform vectorField using transformation tensorField and return //- Transform vectorField using transformation tensorField and return
// symmetric tensorField // symmetric tensorField
virtual tmp<symmTensorField> transformVector virtual tmp<symmTensorField> transformVector

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,7 +33,7 @@ namespace Foam
{ {
defineTypeNameAndDebug(coordinateRotation, 0); defineTypeNameAndDebug(coordinateRotation, 0);
defineRunTimeSelectionTable(coordinateRotation, dictionary); defineRunTimeSelectionTable(coordinateRotation, dictionary);
defineRunTimeSelectionTable(coordinateRotation, objectRegistry); defineRunTimeSelectionTable(coordinateRotation, points);
} }

View File

@ -85,20 +85,6 @@ public:
TypeName("coordinateRotation"); TypeName("coordinateRotation");
// Declare run-time constructor selection table
// for constructors with dictionary and objectRegistry
declareRunTimeSelectionTable
(
autoPtr,
coordinateRotation,
objectRegistry,
(
const dictionary& dict, const objectRegistry& obr
),
(dict, obr)
);
// Declare run-time constructor selection table // Declare run-time constructor selection table
// for constructors with dictionary // for constructors with dictionary
declareRunTimeSelectionTable declareRunTimeSelectionTable
@ -112,13 +98,32 @@ public:
(dict) (dict)
); );
// Declare run-time constructor selection table
// for constructors with dictionary and list of points
declareRunTimeSelectionTable
(
autoPtr,
coordinateRotation,
points,
(
const dictionary& dict, const UList<vector>& points
),
(dict, points)
);
// Constructors
//- Construct and return a clone
virtual autoPtr<coordinateRotation> clone() const = 0;
// Selectors // Selectors
//- Select constructed from dictionary and objectRegistry //- Select constructed from dictionary and list of points
static autoPtr<coordinateRotation> New static autoPtr<coordinateRotation> New
( (
const dictionary& dict, const objectRegistry& obr const dictionary& dict, const UList<vector>& points
); );
//- Select constructed from dictionary //- Select constructed from dictionary
@ -135,22 +140,12 @@ public:
// Member Functions // Member Functions
//- Reset rotation to an identity rotation //- Update the rotation for a list of points
virtual void clear() = 0; virtual void updatePoints(const UList<vector>& points) = 0;
//- Update the rotation for a list of cells
virtual void updateCells
(
const polyMesh& mesh,
const labelList& cells
) = 0;
//- Return local-to-global transformation tensor //- Return local-to-global transformation tensor
virtual const tensor& R() const = 0; virtual const tensor& R() const = 0;
//- Return global-to-local transformation tensor
virtual const tensor& Rtr() const = 0;
//- Return local Cartesian x-axis //- Return local Cartesian x-axis
virtual const vector e1() const = 0; virtual const vector e1() const = 0;
@ -160,9 +155,6 @@ public:
//- Return local Cartesian z-axis //- Return local Cartesian z-axis
virtual const vector e3() const = 0; virtual const vector e3() const = 0;
//- Return local-to-global transformation tensor
virtual const tensorField& Tr() const = 0;
//- Return true if the rotation tensor is uniform //- Return true if the rotation tensor is uniform
virtual bool uniform() const virtual bool uniform() const
{ {
@ -187,13 +179,6 @@ public:
const tensorField& st const tensorField& st
) const = 0; ) const = 0;
//- Transform tensor sub-field using transformation tensorField
virtual tmp<tensorField> transformTensor
(
const tensorField& st,
const labelList& cellMap
) const = 0;
//- Transform tensor using transformation tensorField //- Transform tensor using transformation tensorField
virtual tensor transformTensor(const tensor& st) const = 0; virtual tensor transformTensor(const tensor& st) const = 0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,39 +28,6 @@ License
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
(
const dictionary& dict, const objectRegistry& obr
)
{
if (debug)
{
Pout<< "coordinateRotation::New(const dictionary&) : "
<< "constructing coordinateRotation"
<< endl;
}
word rotType = dict.lookup("type");
objectRegistryConstructorTable::iterator cstrIter =
objectRegistryConstructorTablePtr_->find(rotType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorInFunction
(
dict
) << "Unknown coordinateRotation type "
<< rotType << nl << nl
<< "Valid coordinateRotation types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<coordinateRotation>(cstrIter()(dict, obr));
}
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
( (
const dictionary& dict const dictionary& dict
@ -93,4 +60,40 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
return autoPtr<coordinateRotation>(cstrIter()(dict)); return autoPtr<coordinateRotation>(cstrIter()(dict));
} }
Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
(
const dictionary& dict,
const UList<vector>& points
)
{
if (debug)
{
Pout<< "coordinateRotation::New"
"(const dictionary&,const UList<vector>&) : "
<< "constructing coordinateRotation"
<< endl;
}
word rotType = dict.lookup("type");
pointsConstructorTable::iterator cstrIter =
pointsConstructorTablePtr_->find(rotType);
if (cstrIter == pointsConstructorTablePtr_->end())
{
FatalIOErrorInFunction
(
dict
) << "Unknown coordinateRotation type "
<< rotType << nl << nl
<< "Valid coordinateRotation types are :" << nl
<< pointsConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<coordinateRotation>(cstrIter()(dict, points));
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,27 +25,16 @@ License
#include "cylindrical.H" #include "cylindrical.H"
#include "axesRotation.H" #include "axesRotation.H"
#include "addToRunTimeSelectionTable.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "tensorIOField.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(cylindrical, 0); defineTypeNameAndDebug(cylindrical, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable(coordinateRotation, cylindrical, dictionary);
( addToRunTimeSelectionTable(coordinateRotation, cylindrical, points);
coordinateRotation,
cylindrical,
dictionary
);
addToRunTimeSelectionTable
(
coordinateRotation,
cylindrical,
objectRegistry
);
} }
@ -58,7 +47,7 @@ Foam::tensor Foam::cylindrical::R(const vector& dir) const
if (mag(r) < small) if (mag(r) < small)
{ {
// If the cell centre is on the axis choose any radial direction // If the point is on the axis choose any radial direction
return axesRotation(e3, perpendicular(e3)).R(); return axesRotation(e3, perpendicular(e3)).R();
} }
else else
@ -68,35 +57,17 @@ Foam::tensor Foam::cylindrical::R(const vector& dir) const
} }
void Foam::cylindrical::init void Foam::cylindrical::init(const UList<vector>& points)
(
const objectRegistry& obr,
const List<label>& cells
)
{ {
const polyMesh& mesh = refCast<const polyMesh>(obr); Rptr_.reset(new tensorField(points.size()));
Rptr_.reset(new tensorField(cells.size()));
updateCells(mesh, cells);
}
void Foam::cylindrical::init(const objectRegistry& obr)
{
const polyMesh& mesh = refCast<const polyMesh>(obr);
Rptr_.reset(new tensorField(mesh.nCells()));
const vectorField& cc = mesh.cellCentres();
tensorField& R = Rptr_(); tensorField& R = Rptr_();
forAll(cc, celli)
forAll(points, i)
{ {
vector dir = cc[celli] - origin_; vector dir = points[i] - origin_;
dir /= mag(dir) + vSmall; dir /= mag(dir) + vSmall;
R[celli] = this->R(dir); R[i] = this->R(dir);
} }
} }
@ -105,55 +76,16 @@ void Foam::cylindrical::init(const objectRegistry& obr)
Foam::cylindrical::cylindrical Foam::cylindrical::cylindrical
( (
const dictionary& dict,
const objectRegistry& obr
)
:
Rptr_(),
origin_(point::zero),
e3_(Zero)
{
// If origin is specified in the coordinateSystem
if (dict.parent().found("origin"))
{
dict.parent().lookup("origin") >> origin_;
}
// rotation axis
dict.lookup("e3") >> e3_;
init(obr);
}
Foam::cylindrical::cylindrical
(
const objectRegistry& obr,
const vector& axis,
const point& origin
)
:
Rptr_(),
origin_(origin),
e3_(axis)
{
init(obr);
}
Foam::cylindrical::cylindrical
(
const objectRegistry& obr,
const vector& axis, const vector& axis,
const point& origin, const point& origin,
const List<label>& cells const UList<vector>& points
) )
: :
Rptr_(), Rptr_(),
origin_(origin), origin_(origin),
e3_(axis) e3_(axis)
{ {
init(obr, cells); init(points);
} }
@ -163,50 +95,47 @@ Foam::cylindrical::cylindrical(const dictionary& dict)
origin_(), origin_(),
e3_() e3_()
{ {
FatalErrorInFunction // If origin is specified in the coordinateSystem
<< " cylindrical can not be constructed from dictionary " if (dict.parent().found("origin"))
<< " use the constructor : " {
"(" dict.parent().lookup("origin") >> origin_;
" const dictionary&, const objectRegistry&" }
")"
<< exit(FatalIOError); // Rotation axis
dict.lookup("e3") >> e3_;
} }
Foam::cylindrical::cylindrical(const tensorField& R) Foam::cylindrical::cylindrical
(
const dictionary& dict,
const UList<vector>& points
)
: :
Rptr_(), cylindrical(dict)
origin_(Zero),
e3_(Zero)
{ {
Rptr_() = R; init(points);
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::cylindrical::clear() void Foam::cylindrical::updatePoints(const UList<vector>& points)
{ {
if (!Rptr_.empty()) if (Rptr_.valid())
{ {
Rptr_.clear(); Rptr_().setSize(points.size());
} }
else
{
Rptr_.reset(new tensorField(points.size()));
} }
void Foam::cylindrical::updateCells
(
const polyMesh& mesh,
const labelList& cells
)
{
const vectorField& cc = mesh.cellCentres();
tensorField& R = Rptr_(); tensorField& R = Rptr_();
forAll(cells, i) forAll(points, i)
{ {
label celli = cells[i]; vector dir = points[i] - origin_;
vector dir = cc[celli] - origin_;
dir /= mag(dir) + vSmall; dir /= mag(dir) + vSmall;
R[i] = this->R(dir); R[i] = this->R(dir);
@ -252,6 +181,13 @@ Foam::tmp<Foam::vectorField> Foam::cylindrical::invTransform
const vectorField& vf const vectorField& vf
) const ) const
{ {
if (Rptr_->size() != vf.size())
{
FatalErrorInFunction
<< "vectorField st has different size to tensorField "
<< abort(FatalError);
}
return (Rptr_().T() & vf); return (Rptr_().T() & vf);
} }
@ -294,37 +230,10 @@ Foam::tensor Foam::cylindrical::transformTensor
) const ) const
{ {
NotImplemented; NotImplemented;
return Zero; return Zero;
} }
Foam::tmp<Foam::tensorField> Foam::cylindrical::transformTensor
(
const tensorField& tf,
const labelList& cellMap
) const
{
if (cellMap.size() != tf.size())
{
FatalErrorInFunction
<< "tensorField tf has different size to tensorField Tr"
<< abort(FatalError);
}
const tensorField& R = Rptr_();
const tensorField Rtr(R.T());
tmp<tensorField> tt(new tensorField(cellMap.size()));
tensorField& t = tt.ref();
forAll(cellMap, i)
{
t[i] = R[i] & tf[i] & Rtr[i];
}
return tt;
}
Foam::tmp<Foam::symmTensorField> Foam::cylindrical::transformVector Foam::tmp<Foam::symmTensorField> Foam::cylindrical::transformVector
( (
const vectorField& vf const vectorField& vf

View File

@ -27,10 +27,10 @@ Class
Description Description
A local coordinate rotation. A local coordinate rotation.
The cell based rotational field can be created in two ways: The rotational field can be created in two ways:
-# Each rotational tensor is defined with two vectors (\c dir and \c e3) -# Each rotational tensor is defined with two vectors (\c dir and \c e3)
where <tt>dir = cellC - origin</tt> and \c e3 is the rotation axis. where <tt>dir = point - origin</tt> and \c e3 is the rotation axis.
Per each cell an axesRotation type of rotation is created Per each point an axesRotation type of rotation is created
(cylindrical coordinates). For example: (cylindrical coordinates). For example:
\verbatim \verbatim
cylindrical cylindrical
@ -85,15 +85,8 @@ class cylindrical
// corresponding to the given vector // corresponding to the given vector
tensor R(const vector& dir) const; tensor R(const vector& dir) const;
//- Initialise transformation tensor field for cell set //- Initialise transformation tensor field for given points
void init void init(const UList<vector>& points);
(
const objectRegistry& obr,
const List<label>& cells
);
//- Initialise transformation tensor field for all cells
void init(const objectRegistry& obr);
public: public:
@ -103,36 +96,24 @@ public:
// Constructors // Constructors
//- Construct from dictionary and objectRegistry //- Construct from components for list of points
cylindrical(const dictionary&, const objectRegistry&);
//- Construct from components for all cells
cylindrical cylindrical
( (
const objectRegistry&,
const vector& axis,
const point& origin
);
//- Construct from components for list of cells
cylindrical
(
const objectRegistry&,
const vector& axis, const vector& axis,
const point& origin, const point& origin,
const List<label>& cells const UList<vector>& points
); );
//- Construct from dictionary //- Construct from dictionary
cylindrical(const dictionary&); cylindrical(const dictionary&);
//- Construct from tensor Field //- Construct from dictionary
cylindrical(const tensorField&); cylindrical(const dictionary&, const UList<vector>& points);
//- Return clone //- Return clone
autoPtr<cylindrical> clone() const virtual autoPtr<coordinateRotation> clone() const
{ {
return autoPtr<cylindrical>(new cylindrical(*this)); return autoPtr<coordinateRotation>(new cylindrical(*this));
} }
@ -143,11 +124,8 @@ public:
// Member Functions // Member Functions
//- Reset rotation to an identity rotation //- Update the rotation for a list of points
virtual void clear(); virtual void updatePoints(const UList<vector>& points);
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh& mesh, const labelList& cells);
//- Return local-to-global transformation tensor //- Return local-to-global transformation tensor
virtual const tensor& R() const virtual const tensor& R() const
@ -156,13 +134,6 @@ public:
return tensor::zero; return tensor::zero;
} }
//- Return global-to-local transformation tensor
virtual const tensor& Rtr() const
{
NotImplemented;
return tensor::zero;
}
//- Return local Cartesian x-axis in global coordinates //- Return local Cartesian x-axis in global coordinates
virtual const vector e1() const virtual const vector e1() const
{ {
@ -183,11 +154,6 @@ public:
return e3_; return e3_;
} }
virtual const tensorField& Tr() const
{
return Rptr_();
}
//- Transform vectorField using transformation tensor field //- Transform vectorField using transformation tensor field
virtual tmp<vectorField> transform(const vectorField& tf) const; virtual tmp<vectorField> transform(const vectorField& tf) const;
@ -218,13 +184,6 @@ public:
//- Transform tensor using transformation tensorField //- Transform tensor using transformation tensorField
virtual tensor transformTensor(const tensor& t) const; virtual tensor transformTensor(const tensor& t) const;
//- Transform tensor sub-field using transformation tensorField
virtual tmp<tensorField> transformTensor
(
const tensorField& tf,
const labelList& cellMap
) const;
//- Transform vectorField using transformation tensorField and return //- Transform vectorField using transformation tensorField and return
// symmetrical tensorField // symmetrical tensorField
virtual tmp<symmTensorField> transformVector virtual tmp<symmTensorField> transformVector

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,10 +23,9 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IOstream.H"
#include "axesRotation.H"
#include "coordinateSystem.H" #include "coordinateSystem.H"
#include "coordinateSystems.H" #include "coordinateSystems.H"
#include "axesRotation.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -39,25 +38,15 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coordinateSystem::coordinateSystem()
:
name_(),
note_(),
origin_(point::zero),
R_(new axesRotation(sphericalTensor::I))
{}
Foam::coordinateSystem::coordinateSystem Foam::coordinateSystem::coordinateSystem
( (
const word& name, const word& name,
const coordinateSystem& cs const point& origin
) )
: :
name_(name), name_(name),
note_(), origin_(origin),
origin_(cs.origin_), R_(new axesRotation(sphericalTensor::I))
R_(const_cast<coordinateRotation*>(&cs.R()))
{} {}
@ -69,9 +58,8 @@ Foam::coordinateSystem::coordinateSystem
) )
: :
name_(name), name_(name),
note_(),
origin_(origin), origin_(origin),
R_(const_cast<coordinateRotation*>(&cr)) R_(cr.clone())
{} {}
@ -84,7 +72,6 @@ Foam::coordinateSystem::coordinateSystem
) )
: :
name_(name), name_(name),
note_(),
origin_(origin), origin_(origin),
R_(new axesRotation(axis, dirn)) R_(new axesRotation(axis, dirn))
{} {}
@ -97,83 +84,9 @@ Foam::coordinateSystem::coordinateSystem
) )
: :
name_(name), name_(name),
note_(), origin_(dict.lookup("origin")),
origin_(point::zero), R_(coordinateRotation::New(dict.subDict("coordinateRotation")).ptr())
R_() {}
{
init(dict);
}
Foam::coordinateSystem::coordinateSystem(const dictionary& dict)
:
name_(),
note_(),
origin_(point::zero),
R_()
{
init(dict);
}
Foam::coordinateSystem::coordinateSystem
(
const objectRegistry& obr,
const dictionary& dict
)
:
name_(),
note_(),
origin_(point::zero),
R_()
{
const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false);
// non-dictionary entry is a lookup into global coordinateSystems
if (entryPtr && !entryPtr->isDict())
{
keyType key(entryPtr->stream());
const coordinateSystems& lst = coordinateSystems::New(obr);
const label index = lst.findIndex(key);
if (debug)
{
InfoInFunction
<< "Using global coordinate system: "
<< key << "=" << index << endl;
}
if (index < 0)
{
FatalErrorInFunction
<< "could not find coordinate system: " << key << nl
<< "available coordinate systems: " << lst.toc() << nl << nl
<< exit(FatalError);
}
// copy coordinateSystem, but assign the name as the typeName
// to avoid strange things in writeDict()
operator=(lst[index]);
name_ = typeName_();
}
else
{
init(dict, obr);
}
}
Foam::coordinateSystem::coordinateSystem(Istream& is)
:
name_(is),
note_(),
origin_(point::zero),
R_()
{
dictionary dict(is);
init(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -184,32 +97,6 @@ Foam::coordinateSystem::~coordinateSystem()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::dictionary Foam::coordinateSystem::dict(bool ignoreType) const
{
dictionary dict;
dict.add("name", name_);
// only write type for derived types
if (!ignoreType && type() != typeName_())
{
dict.add("type", type());
}
// The note entry is optional
if (note_.size())
{
dict.add("note", note_);
}
dict.add("origin", origin_);
dict.add("e1", R_->e1());
dict.add("e3", R_->e3());
return dict;
}
Foam::vector Foam::coordinateSystem::localToGlobal Foam::vector Foam::coordinateSystem::localToGlobal
( (
const vector& local, const vector& local,
@ -278,14 +165,6 @@ Foam::tmp<Foam::vectorField> Foam::coordinateSystem::globalToLocal
} }
void Foam::coordinateSystem::clear()
{
note_.clear();
origin_ = Zero;
R_->clear();
}
void Foam::coordinateSystem::write(Ostream& os) const void Foam::coordinateSystem::write(Ostream& os) const
{ {
os << type() << " origin: " << origin() << nl; os << type() << " origin: " << origin() << nl;
@ -304,12 +183,6 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
writeEntry(os, "type", type()); writeEntry(os, "type", type());
// The note entry is optional
if (note_.size())
{
writeEntry(os, "note", note_);
}
writeEntry(os, "origin", origin_); writeEntry(os, "origin", origin_);
R_->write(os); R_->write(os);
@ -320,59 +193,6 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::coordinateSystem::init(const dictionary& rhs)
{
rhs.lookup("origin") >> origin_;
note_.clear();
rhs.readIfPresent("note", note_);
R_.reset(coordinateRotation::New(rhs.subDict("coordinateRotation")).ptr());
}
void Foam::coordinateSystem::init
(
const dictionary& rhs,
const objectRegistry& obr
)
{
if (debug)
{
Pout<< "coordinateSystem::operator="
"("
"const dictionary&, "
"const objectRegistry&"
") : "
<< "assign from " << rhs << endl;
}
rhs.lookup("origin") >> origin_;
// The note entry is optional
note_.clear();
rhs.readIfPresent("note", note_);
R_.reset
(
coordinateRotation::New(rhs.subDict("coordinateRotation"), obr).ptr()
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
bool Foam::operator!=(const coordinateSystem& a, const coordinateSystem& b)
{
return
(
a.origin() != b.origin()
|| a.R().R() != b.R().R()
|| a.type() != b.type()
);
}
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const coordinateSystem& cs) Foam::Ostream& Foam::operator<<(Ostream& os, const coordinateSystem& cs)

View File

@ -61,15 +61,9 @@ SourceFiles
#ifndef coordinateSystem_H #ifndef coordinateSystem_H
#define coordinateSystem_H #define coordinateSystem_H
#include "vector.H"
#include "point.H"
#include "tensor.H"
#include "vectorField.H"
#include "pointField.H"
#include "tmp.H"
#include "coordinateRotation.H" #include "coordinateRotation.H"
#include "objectRegistry.H" #include "objectRegistry.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,14 +89,11 @@ class coordinateSystem
//- Name of coordinate system //- Name of coordinate system
word name_; word name_;
//- Optional note
string note_;
//- Origin //- Origin
point origin_; point origin_;
//- Local-to-Global transformation tensor //- Local-to-Global transformation tensor
autoPtr<coordinateRotation> R_; mutable autoPtr<coordinateRotation> R_;
protected: protected:
@ -133,12 +124,6 @@ protected:
bool translate bool translate
) const; ) const;
//- Init from dict and obr
void init(const dictionary&);
//- Init from dictionary
void init(const dictionary&, const objectRegistry&);
public: public:
@ -148,14 +133,11 @@ public:
// Constructors // Constructors
//- Construct null. This is equivalent to an identity coordinateSystem //- Construct from origin
coordinateSystem();
//- Construct copy with a different name
coordinateSystem coordinateSystem
( (
const word& name, const word& name,
const coordinateSystem& const point& origin
); );
//- Construct from origin and rotation //- Construct from origin and rotation
@ -178,17 +160,6 @@ public:
//- Construct from dictionary with a given name //- Construct from dictionary with a given name
coordinateSystem(const word& name, const dictionary&); coordinateSystem(const word& name, const dictionary&);
//- Construct from dictionary with default name
coordinateSystem(const dictionary&);
//- Construct from dictionary (default name)
// With the ability to reference global coordinateSystems
coordinateSystem(const objectRegistry&, const dictionary&);
//- Construct from Istream
// The Istream contains a word followed by a dictionary
coordinateSystem(Istream&);
//- Return clone //- Return clone
autoPtr<coordinateSystem> clone() const autoPtr<coordinateSystem> clone() const
@ -204,10 +175,10 @@ public:
coordinateSystem, coordinateSystem,
dictionary, dictionary,
( (
const objectRegistry& obr, const word& name,
const dictionary& dict const dictionary& dict
), ),
(obr, dict) (name, dict)
); );
@ -220,9 +191,10 @@ public:
const dictionary& dict const dictionary& dict
); );
//- Select constructed from dictionary //- Select constructed from name and dictionary
static autoPtr<coordinateSystem> New static autoPtr<coordinateSystem> New
( (
const word& name,
const dictionary& dict const dictionary& dict
); );
@ -244,18 +216,6 @@ public:
return name_; return name_;
} }
//- Return non-constant access to the optional note
string& note()
{
return note_;
}
//- Return the optional note
const string& note() const
{
return note_;
}
//- Return origin //- Return origin
const point& origin() const const point& origin() const
{ {
@ -268,47 +228,13 @@ public:
return R_(); return R_();
} }
//- Return non const reference to co-ordinate rotation //- Update and return the co-ordinate rotation for a list of points
coordinateRotation& R() const coordinateRotation& R(const UList<vector>& points) const
{ {
R_->updatePoints(points);
return R_(); return R_();
} }
//- Update and return the co-ordinate rotation for a list of cells
const coordinateRotation& R
(
const polyMesh& mesh,
const labelList& cells
)
{
R_->updateCells(mesh, cells);
return R_();
}
//- Return as dictionary of entries
// \param[in] ignoreType drop type (cartesian, cylindrical, etc)
// when generating the dictionary
virtual dictionary dict(bool ignoreType=false) const;
// Edit
//- Rename
void rename(const word& newName)
{
name_ = newName;
}
//- Edit access to origin
point& origin()
{
return origin_;
}
//- Reset origin and rotation to an identity coordinateSystem
// Also resets the note
virtual void clear();
// Write // Write
@ -378,17 +304,6 @@ public:
} }
// Member Operators
// friend Operators
friend bool operator!=
(
const coordinateSystem&,
const coordinateSystem&
);
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const coordinateSystem&); friend Ostream& operator<<(Ostream&, const coordinateSystem&);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,8 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "coordinateSystem.H" #include "coordinateSystems.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -35,7 +34,37 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
) )
{ {
const dictionary& coordDict = dict.subDict(typeName_()); const dictionary& coordDict = dict.subDict(typeName_());
word coordType = coordDict.lookup("type");
const entry* entryPtr = coordDict.lookupEntryPtr(typeName_(), false, false);
// non-dictionary entry is a lookup into global coordinateSystems
if (entryPtr && !entryPtr->isDict())
{
keyType key(entryPtr->stream());
const coordinateSystems& lst = coordinateSystems::New(obr);
const label index = lst.findIndex(key);
if (debug)
{
InfoInFunction
<< "Using global coordinate system: "
<< key << "=" << index << endl;
}
if (index < 0)
{
FatalErrorInFunction
<< "could not find coordinate system: " << key << nl
<< "available coordinate systems: " << lst.toc() << nl << nl
<< exit(FatalError);
}
return lst[index].clone();
}
else
{
const word coordType = coordDict.lookup("type");
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(coordType); dictionaryConstructorTablePtr_->find(coordType);
@ -52,18 +81,35 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
<< exit(FatalIOError); << exit(FatalIOError);
} }
return autoPtr<coordinateSystem>(cstrIter()(obr, coordDict)); return autoPtr<coordinateSystem>(cstrIter()(coordType, coordDict));
}
} }
Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
( (
const word& name,
const dictionary& dict const dictionary& dict
) )
{ {
const dictionary& coordDict = dict.subDict(typeName_()); const word coordType = dict.lookup("type");
return autoPtr<coordinateSystem>(new coordinateSystem(coordDict)); dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(coordType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalIOErrorInFunction
(
dict
) << "Unknown coordinateSystem type "
<< coordType << nl << nl
<< "Valid coordinateSystem types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
return autoPtr<coordinateSystem>(cstrIter()(name, dict));
} }
@ -75,7 +121,7 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
const word name(is); const word name(is);
const dictionary dict(is); const dictionary dict(is);
return autoPtr<coordinateSystem>(new coordinateSystem(name, dict)); return autoPtr<coordinateSystem>(coordinateSystem::New(name, dict));
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,9 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "coordinateSystems.H" #include "coordinateSystems.H"
#include "IOPtrList.H"
#include "Time.H" #include "Time.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -44,29 +43,8 @@ Foam::coordinateSystems::coordinateSystems(const IOobject& io)
{} {}
Foam::coordinateSystems::coordinateSystems
(
const IOobject& io,
const PtrList<coordinateSystem>& lst
)
:
IOPtrList<coordinateSystem>(io, lst)
{}
Foam::coordinateSystems::coordinateSystems
(
const IOobject& io,
PtrList<coordinateSystem>&& lst
)
:
IOPtrList<coordinateSystem>(io, move(lst))
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
// Read construct from registry, or return previously registered
const Foam::coordinateSystems& Foam::coordinateSystems::New const Foam::coordinateSystems& Foam::coordinateSystems::New
( (
const objectRegistry& obr const objectRegistry& obr
@ -127,8 +105,9 @@ Foam::label Foam::coordinateSystems::findIndex(const keyType& key) const
{ {
if (key.isPattern()) if (key.isPattern())
{ {
labelList indices = findIndices(key); const labelList indices = findIndices(key);
// return first element
// Return first element
if (!indices.empty()) if (!indices.empty())
{ {
return indices[0]; return indices[0];

View File

@ -73,6 +73,12 @@ class coordinateSystems
: :
public IOPtrList<coordinateSystem> public IOPtrList<coordinateSystem>
{ {
// Private member functions
//- Find and return indices for all matches
labelList findIndices(const keyType& key) const;
public: public:
//- Runtime type information //- Runtime type information
@ -83,20 +89,6 @@ public:
//- Read construct from IOobject //- Read construct from IOobject
explicit coordinateSystems(const IOobject&); explicit coordinateSystems(const IOobject&);
//- Construct from IOobject and a PtrList
coordinateSystems
(
const IOobject&,
const PtrList<coordinateSystem>&
);
//- Construct from IOobject and transferring the PtrList contents
coordinateSystems
(
const IOobject&,
PtrList<coordinateSystem>&&
);
//- Disallow default bitwise copy construction //- Disallow default bitwise copy construction
coordinateSystems(const coordinateSystems&) = delete; coordinateSystems(const coordinateSystems&) = delete;
@ -109,9 +101,6 @@ public:
// Member Functions // Member Functions
//- Find and return indices for all matches
labelList findIndices(const keyType& key) const;
//- Find and return index for the first match, return -1 if not found //- Find and return index for the first match, return -1 if not found
label findIndex(const keyType& key) const; label findIndex(const keyType& key) const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,107 +29,16 @@ License
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // namespace Foam
Foam::cylindricalCS::cylindricalCS(const bool inDegrees)
:
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)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn,
const bool inDegrees
)
:
coordinateSystem(name, origin, axis, dirn),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const dictionary& dict
)
:
coordinateSystem(name, dict),
inDegrees_(dict.lookupOrDefault("degrees", true))
{}
Foam::cylindricalCS::cylindricalCS
(
const objectRegistry& obr,
const dictionary& dict
)
:
coordinateSystem(obr, dict),
inDegrees_(dict.lookupOrDefault("degrees", true))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cylindricalCS::~cylindricalCS()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::cylindricalCS::inDegrees() const
{ {
return inDegrees_; defineTypeNameAndDebug(cylindricalCS, 0);
addToRunTimeSelectionTable(coordinateSystem, cylindricalCS, dictionary);
} }
bool& Foam::cylindricalCS::inDegrees() // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
{
return inDegrees_;
}
Foam::vector Foam::cylindricalCS::localToGlobal Foam::vector Foam::cylindricalCS::localToGlobal
( (
@ -162,7 +71,6 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::localToGlobal
*(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0) *(inDegrees_ ? constant::mathematical::pi/180.0 : 1.0)
); );
vectorField lc(local.size()); vectorField lc(local.size());
lc.replace(vector::X, local.component(vector::X)*cos(theta)); lc.replace(vector::X, local.component(vector::X)*cos(theta));
lc.replace(vector::Y, local.component(vector::X)*sin(theta)); lc.replace(vector::Y, local.component(vector::X)*sin(theta));
@ -232,4 +140,50 @@ Foam::tmp<Foam::vectorField> Foam::cylindricalCS::globalToLocal
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const point& origin,
const coordinateRotation& cr,
const bool inDegrees
)
:
coordinateSystem(name, origin, cr),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const point& origin,
const vector& axis,
const vector& dirn,
const bool inDegrees
)
:
coordinateSystem(name, origin, axis, dirn),
inDegrees_(inDegrees)
{}
Foam::cylindricalCS::cylindricalCS
(
const word& name,
const dictionary& dict
)
:
coordinateSystem(name, dict),
inDegrees_(dict.lookupOrDefault("degrees", true))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cylindricalCS::~cylindricalCS()
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,9 +56,7 @@ class cylindricalCS
bool inDegrees_; bool inDegrees_;
protected: // Private Member Functions
// Protected Member Functions
//- Convert from local coordinate system to the global Cartesian system //- Convert from local coordinate system to the global Cartesian system
@ -88,27 +86,12 @@ protected:
public: public:
//- Runtime type information
TypeName("cylindrical");
// Constructors // Constructors
//- Construct null
cylindricalCS(const bool inDegrees=true);
//- 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 //- Construct from origin and rotation
cylindricalCS cylindricalCS
( (
@ -131,21 +114,9 @@ public:
//- Construct from dictionary and name //- Construct from dictionary and name
cylindricalCS(const word&, const dictionary&); cylindricalCS(const word&, const dictionary&);
//- Construct from dictionary and objectRegistry
cylindricalCS(const objectRegistry&, const dictionary&);
//- Destructor //- Destructor
virtual ~cylindricalCS(); virtual ~cylindricalCS();
// Member Functions
//- Are angles in degrees?
bool inDegrees() const;
//- Non-const access to inDegrees
bool& inDegrees();
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -203,6 +203,7 @@ Foam::searchableSurfaceCollection::searchableSurfaceCollection
surfI, surfI,
coordinateSystem::New coordinateSystem::New
( (
io.db(),
subDict.subDict("transform") subDict.subDict("transform")
) )
); );

View File

@ -57,10 +57,13 @@ Foam::sampledSurfaces::plane::plane
// allow lookup from global coordinate systems // allow lookup from global coordinate systems
if (dict.found("coordinateSystem")) if (dict.found("coordinateSystem"))
{ {
coordinateSystem cs(mesh, dict.subDict("coordinateSystem")); autoPtr<coordinateSystem> cs
(
coordinateSystem::New(mesh, dict.subDict("coordinateSystem"))
);
point base = cs.globalPosition(planeDesc().refPoint()); point base = cs->globalPosition(planeDesc().refPoint());
vector norm = cs.globalVector(planeDesc().normal()); vector norm = cs->globalVector(planeDesc().normal());
// Assign the plane description // Assign the plane description
static_cast<Foam::plane&>(*this) = Foam::plane(base, norm); static_cast<Foam::plane&>(*this) = Foam::plane(base, norm);

View File

@ -294,12 +294,14 @@ Foam::heSolidThermo<BasicSolidThermo, MixtureType>::KappaLocal() const
); );
volSymmTensorField& KappaLocal = tKappaLocal.ref(); volSymmTensorField& KappaLocal = tKappaLocal.ref();
KappaLocal.primitiveFieldRef() = coordinates.R().transformVector(Kappa); KappaLocal.primitiveFieldRef() =
coordinates.R(mesh.C()).transformVector(Kappa);
forAll(KappaLocal.boundaryField(), patchi) forAll(KappaLocal.boundaryField(), patchi)
{ {
KappaLocal.boundaryFieldRef()[patchi] = KappaLocal.boundaryFieldRef()[patchi] =
coordinates.R().transformVector(Kappa.boundaryField()[patchi]); coordinates.R(mesh.boundary()[patchi].Cf())
.transformVector(Kappa.boundaryField()[patchi]);
} }
return tKappaLocal; return tKappaLocal;
@ -320,7 +322,9 @@ Foam::heSolidThermo<BasicSolidThermo, MixtureType>::KappaLocal
coordinateSystem::New(mesh, this->properties()) coordinateSystem::New(mesh, this->properties())
); );
return coordinates.R().transformVector(Kappa(patchi)); return
coordinates.R(mesh.boundary()[patchi].Cf())
.transformVector(Kappa(patchi));
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -285,7 +285,7 @@ Foam::mixerFvMesh::mixerFvMesh
( (
coordinateSystem::New coordinateSystem::New
( (
"coordinateSystem", io.db(),
motionDict_.subDict("coordinateSystem") motionDict_.subDict("coordinateSystem")
) )
), ),

View File

@ -36,7 +36,7 @@ SourceFiles
#define mixerFvMesh_H #define mixerFvMesh_H
#include "topoChangerFvMesh.H" #include "topoChangerFvMesh.H"
#include "cylindricalCS.H" #include "coordinateSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //