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 "angularOscillatingVelocityPointPatchVectorField.H"
00028 #include "pointPatchFields.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 #include "Time.H"
00031 #include "polyMesh.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 angularOscillatingVelocityPointPatchVectorField::
00041 angularOscillatingVelocityPointPatchVectorField
00042 (
00043 const pointPatch& p,
00044 const DimensionedField<vector, pointMesh>& iF
00045 )
00046 :
00047 fixedValuePointPatchField<vector>(p, iF),
00048 axis_(vector::zero),
00049 origin_(vector::zero),
00050 angle0_(0.0),
00051 amplitude_(0.0),
00052 omega_(0.0),
00053 p0_(p.localPoints())
00054 {}
00055
00056
00057 angularOscillatingVelocityPointPatchVectorField::
00058 angularOscillatingVelocityPointPatchVectorField
00059 (
00060 const pointPatch& p,
00061 const DimensionedField<vector, pointMesh>& iF,
00062 const dictionary& dict
00063 )
00064 :
00065 fixedValuePointPatchField<vector>(p, iF, dict),
00066 axis_(dict.lookup("axis")),
00067 origin_(dict.lookup("origin")),
00068 angle0_(readScalar(dict.lookup("angle0"))),
00069 amplitude_(readScalar(dict.lookup("amplitude"))),
00070 omega_(readScalar(dict.lookup("omega")))
00071 {
00072 if (!dict.found("value"))
00073 {
00074 updateCoeffs();
00075 }
00076
00077 if (dict.found("p0"))
00078 {
00079 p0_ = vectorField("p0", dict , p.size());
00080 }
00081 else
00082 {
00083 p0_ = p.localPoints();
00084 }
00085 }
00086
00087
00088 angularOscillatingVelocityPointPatchVectorField::
00089 angularOscillatingVelocityPointPatchVectorField
00090 (
00091 const angularOscillatingVelocityPointPatchVectorField& ptf,
00092 const pointPatch& p,
00093 const DimensionedField<vector, pointMesh>& iF,
00094 const pointPatchFieldMapper& mapper
00095 )
00096 :
00097 fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
00098 axis_(ptf.axis_),
00099 origin_(ptf.origin_),
00100 angle0_(ptf.angle0_),
00101 amplitude_(ptf.amplitude_),
00102 omega_(ptf.omega_),
00103 p0_(ptf.p0_)
00104 {}
00105
00106
00107 angularOscillatingVelocityPointPatchVectorField::
00108 angularOscillatingVelocityPointPatchVectorField
00109 (
00110 const angularOscillatingVelocityPointPatchVectorField& ptf,
00111 const DimensionedField<vector, pointMesh>& iF
00112 )
00113 :
00114 fixedValuePointPatchField<vector>(ptf, iF),
00115 axis_(ptf.axis_),
00116 origin_(ptf.origin_),
00117 angle0_(ptf.angle0_),
00118 amplitude_(ptf.amplitude_),
00119 omega_(ptf.omega_),
00120 p0_(ptf.p0_)
00121 {}
00122
00123
00124
00125
00126 void angularOscillatingVelocityPointPatchVectorField::updateCoeffs()
00127 {
00128 if (this->updated())
00129 {
00130 return;
00131 }
00132
00133 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
00134 const Time& t = mesh.time();
00135 const pointPatch& p = this->patch();
00136
00137 scalar angle = angle0_ + amplitude_*sin(omega_*t.value());
00138 vector axisHat = axis_/mag(axis_);
00139 vectorField p0Rel = p0_ - origin_;
00140
00141 vectorField::operator=
00142 (
00143 (
00144 p0_
00145 + p0Rel*(cos(angle) - 1)
00146 + (axisHat ^ p0Rel*sin(angle))
00147 + (axisHat & p0Rel)*(1 - cos(angle))*axisHat
00148 - p.localPoints()
00149 )/t.deltaT().value()
00150 );
00151
00152 fixedValuePointPatchField<vector>::updateCoeffs();
00153 }
00154
00155
00156 void angularOscillatingVelocityPointPatchVectorField::write
00157 (
00158 Ostream& os
00159 ) const
00160 {
00161 pointPatchField<vector>::write(os);
00162 os.writeKeyword("axis")
00163 << axis_ << token::END_STATEMENT << nl;
00164 os.writeKeyword("origin")
00165 << origin_ << token::END_STATEMENT << nl;
00166 os.writeKeyword("angle0")
00167 << angle0_ << token::END_STATEMENT << nl;
00168 os.writeKeyword("amplitude")
00169 << amplitude_ << token::END_STATEMENT << nl;
00170 os.writeKeyword("omega")
00171 << omega_ << token::END_STATEMENT << nl;
00172 p0_.writeEntry("p0", os);
00173 writeEntry("value", os);
00174 }
00175
00176
00177
00178
00179 makePointPatchTypeField
00180 (
00181 pointPatchVectorField,
00182 angularOscillatingVelocityPointPatchVectorField
00183 );
00184
00185
00186
00187 }
00188
00189