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