Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "toroidalCS.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/mathematicalConstants.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034 defineTypeNameAndDebug(toroidalCS, 0);
00035 addToRunTimeSelectionTable(coordinateSystem, toroidalCS, dictionary);
00036 }
00037
00038
00039
00040
00041 Foam::toroidalCS::toroidalCS
00042 (
00043 const word& name,
00044 const point& origin,
00045 const coordinateRotation& cr,
00046 const scalar radius
00047 )
00048 :
00049 coordinateSystem(name, origin, cr),
00050 radius_(radius)
00051 {}
00052
00053
00054 Foam::toroidalCS::toroidalCS
00055 (
00056 const word& name,
00057 const dictionary& dict
00058 )
00059 :
00060 coordinateSystem(name, dict),
00061 radius_(readScalar(dict.lookup("radius")))
00062 {}
00063
00064
00065
00066
00067 Foam::vector Foam::toroidalCS::localToGlobal
00068 (
00069 const vector& local,
00070 bool translate
00071 ) const
00072 {
00073
00074 scalar theta = local.y()*mathematicalConstant::pi/180.0;
00075 scalar phi = local.z()*mathematicalConstant::pi/180.0;
00076
00077 scalar rprime = radius_ + local.x()*sin(phi);
00078
00079 if ((local.x()*sin(phi)) > (radius_))
00080 {
00081 FatalErrorIn("toroidalCS::toGlobal(vector) const")
00082 << "Badly defined toroidal coordinates"
00083 << abort(FatalError);
00084 }
00085
00086 return coordinateSystem::localToGlobal
00087 (
00088 vector(rprime*cos(theta), rprime*sin(theta), local.x()*cos(phi)),
00089 translate
00090 );
00091 }
00092
00093
00094 Foam::tmp<Foam::vectorField> Foam::toroidalCS::localToGlobal
00095 (
00096 const vectorField& local,
00097 bool translate
00098 ) const
00099 {
00100 const scalarField r = local.component(vector::X);
00101
00102 const scalarField theta =
00103 local.component(vector::Y)*mathematicalConstant::pi/180.0;
00104
00105 const scalarField phi =
00106 local.component(vector::Z)*mathematicalConstant::pi/180.0;
00107
00108 const scalarField rprime = radius_ + r*sin(phi);
00109
00110 vectorField lc(local.size());
00111 lc.replace(vector::X, rprime*cos(theta));
00112 lc.replace(vector::Y, rprime*sin(theta));
00113 lc.replace(vector::Z, r*cos(phi));
00114
00115 return coordinateSystem::localToGlobal(lc, translate);
00116 }
00117
00118
00119 Foam::vector Foam::toroidalCS::globalToLocal
00120 (
00121 const vector& global,
00122 bool translate
00123 ) const
00124 {
00125 notImplemented
00126 (
00127 "toroidalCS::globalToLocal(const vector&, bool) const"
00128 );
00129
00130 return vector::zero;
00131 }
00132
00133
00134 Foam::tmp<Foam::vectorField> Foam::toroidalCS::globalToLocal
00135 (
00136 const vectorField& global,
00137 bool translate
00138 ) const
00139 {
00140 notImplemented
00141 (
00142 "toroidalCS::globalToLocal(const vectorField&, bool) const"
00143 );
00144
00145 return tmp<vectorField>(vectorField::null());
00146 }
00147
00148
00149 void Foam::toroidalCS::write(Ostream& os) const
00150 {
00151 coordinateSystem::write(os);
00152 os << "radius: " << radius() << endl;
00153 }
00154
00155
00156 void Foam::toroidalCS::writeDict(Ostream& os, bool subDict) const
00157 {
00158 if (subDict)
00159 {
00160 os << indent << name() << nl
00161 << indent << token::BEGIN_BLOCK << incrIndent << nl;
00162 }
00163
00164 coordinateSystem::writeDict(os, false);
00165 os.writeKeyword("radius") << radius() << token::END_STATEMENT << nl;
00166
00167 if (subDict)
00168 {
00169 os << decrIndent << indent << token::END_BLOCK << endl;
00170 }
00171 }
00172
00173