Permalink
Browse files

ENH: MRFZone converted to DataEntry Type and updating tutorials

  • Loading branch information...
1 parent 4e8644c commit 9306436ae6451b60ce252261d94d58d3e0fd6045 sergio committed Nov 14, 2012
@@ -32,6 +32,7 @@ License
#include "faceSet.H"
#include "geometricOneField.H"
+
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::MRFZone, 0);
@@ -239,8 +240,7 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
),
origin_(dict_.lookup("origin")),
axis_(dict_.lookup("axis")),
- omega_(dict_.lookup("omega")),
- Omega_("Omega", omega_*axis_)
+ omega_(DataEntry<scalar>::New("omega", dict_))
{
if (dict_.found("patches"))
{
@@ -255,7 +255,6 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
axis_ = axis_/mag(axis_);
- Omega_ = omega_*axis_;
excludedPatchLabels_.setSize(excludedPatchNames_.size());
@@ -273,8 +272,8 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
}
}
-
bool cellZoneFound = (cellZoneID_ != -1);
+
reduce(cellZoneFound, orOp<bool>());
if (!cellZoneFound)
@@ -307,7 +306,8 @@ void Foam::MRFZone::addCoriolis
const scalarField& V = mesh_.V();
vectorField& ddtUc = ddtU.internalField();
const vectorField& Uc = U.internalField();
- const vector& Omega = Omega_.value();
+
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
forAll(cells, i)
{
@@ -328,7 +328,8 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const
const scalarField& V = mesh_.V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
- const vector& Omega = Omega_.value();
+
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
forAll(cells, i)
{
@@ -353,7 +354,8 @@ void Foam::MRFZone::addCoriolis
const scalarField& V = mesh_.V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
- const vector& Omega = Omega_.value();
+
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
forAll(cells, i)
{
@@ -367,15 +369,14 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const
{
const volVectorField& C = mesh_.C();
- const vector& origin = origin_.value();
- const vector& Omega = Omega_.value();
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
const labelList& cells = mesh_.cellZones()[cellZoneID_];
forAll(cells, i)
{
label celli = cells[i];
- U[celli] -= (Omega ^ (C[celli] - origin));
+ U[celli] -= (Omega ^ (C[celli] - origin_));
}
// Included patches
@@ -395,7 +396,8 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const
{
label patchFacei = excludedFaces_[patchi][i];
U.boundaryField()[patchi][patchFacei] -=
- (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin));
+ (Omega
+ ^ (C.boundaryField()[patchi][patchFacei] - origin_));
}
}
}
@@ -405,15 +407,14 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const
{
const volVectorField& C = mesh_.C();
- const vector& origin = origin_.value();
- const vector& Omega = Omega_.value();
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
const labelList& cells = mesh_.cellZones()[cellZoneID_];
forAll(cells, i)
{
label celli = cells[i];
- U[celli] += (Omega ^ (C[celli] - origin));
+ U[celli] += (Omega ^ (C[celli] - origin_));
}
// Included patches
@@ -423,7 +424,7 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const
{
label patchFacei = includedFaces_[patchi][i];
U.boundaryField()[patchi][patchFacei] =
- (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin));
+ (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin_));
}
}
@@ -434,7 +435,7 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const
{
label patchFacei = excludedFaces_[patchi][i];
U.boundaryField()[patchi][patchFacei] +=
- (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin));
+ (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin_));
}
}
}
@@ -474,8 +475,8 @@ void Foam::MRFZone::absoluteFlux
void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const
{
- const vector& origin = origin_.value();
- const vector& Omega = Omega_.value();
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
+
// Included patches
forAll(includedFaces_, patchi)
@@ -488,7 +489,7 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const
{
label patchFacei = includedFaces_[patchi][i];
- pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin));
+ pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
}
U.boundaryField()[patchi] == pfld;
@@ -503,7 +504,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const MRFZone& MRF)
os << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl;
os.writeKeyword("axis") << MRF.axis_ << token::END_STATEMENT << nl;
- os.writeKeyword("omega") << MRF.omega_ << token::END_STATEMENT << nl;
+ MRF.omega_->writeData(os);
if (MRF.excludedPatchNames_.size())
{
@@ -48,6 +48,8 @@ SourceFiles
#include "surfaceFieldsFwd.H"
#include "fvMatricesFwd.H"
#include "fvMatrices.H"
+#include "DataEntry.H"
+#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -85,10 +87,14 @@ class MRFZone
//- Excluded faces (per patch) that do not move with the MRF
labelListList excludedFaces_;
- const dimensionedVector origin_;
- dimensionedVector axis_;
- const dimensionedScalar omega_;
- dimensionedVector Omega_;
+ //- Origin of the axis
+ const vector origin_;
+
+ //- Axis vector
+ vector axis_;
+
+ //- Angular velocty (rad/sec)
+ autoPtr<DataEntry<scalar> > omega_;
// Private Member Functions
@@ -157,6 +163,11 @@ public:
};
+ //- Destructor
+ virtual ~MRFZone()
+ {}
+
+
// Member Functions
//- Update the mesh corresponding to given map
@@ -205,9 +216,11 @@ public:
void correctBoundaryVelocity(volVectorField& U) const;
- // Ostream Operator
+ // IOstream operator
friend Ostream& operator<<(Ostream& os, const MRFZone& MRF);
+
+
};
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
+ \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -41,8 +41,7 @@ void Foam::MRFZone::relativeRhoFlux
const surfaceVectorField& Cf = mesh_.Cf();
const surfaceVectorField& Sf = mesh_.Sf();
- const vector& origin = origin_.value();
- const vector& Omega = Omega_.value();
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
const vectorField& Cfi = Cf.internalField();
const vectorField& Sfi = Sf.internalField();
@@ -52,7 +51,7 @@ void Foam::MRFZone::relativeRhoFlux
forAll(internalFaces_, i)
{
label facei = internalFaces_[i];
- phii[facei] -= rho[facei]*(Omega ^ (Cfi[facei] - origin)) & Sfi[facei];
+ phii[facei] -= rho[facei]*(Omega ^ (Cfi[facei] - origin_)) & Sfi[facei];
}
// Included patches
@@ -75,7 +74,7 @@ void Foam::MRFZone::relativeRhoFlux
phi.boundaryField()[patchi][patchFacei] -=
rho.boundaryField()[patchi][patchFacei]
- * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin))
+ * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin_))
& Sf.boundaryField()[patchi][patchFacei];
}
}
@@ -92,8 +91,7 @@ void Foam::MRFZone::absoluteRhoFlux
const surfaceVectorField& Cf = mesh_.Cf();
const surfaceVectorField& Sf = mesh_.Sf();
- const vector& origin = origin_.value();
- const vector& Omega = Omega_.value();
+ const vector Omega = omega_->value(mesh_.time().timeOutputValue())*axis_;
const vectorField& Cfi = Cf.internalField();
const vectorField& Sfi = Sf.internalField();
@@ -103,7 +101,7 @@ void Foam::MRFZone::absoluteRhoFlux
forAll(internalFaces_, i)
{
label facei = internalFaces_[i];
- phii[facei] += rho[facei]*(Omega ^ (Cfi[facei] - origin)) & Sfi[facei];
+ phii[facei] += rho[facei]*(Omega ^ (Cfi[facei] - origin_)) & Sfi[facei];
}
// Included patches
@@ -115,7 +113,7 @@ void Foam::MRFZone::absoluteRhoFlux
phi.boundaryField()[patchi][patchFacei] +=
rho.boundaryField()[patchi][patchFacei]
- * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin))
+ * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin_))
& Sf.boundaryField()[patchi][patchFacei];
}
}
@@ -129,7 +127,7 @@ void Foam::MRFZone::absoluteRhoFlux
phi.boundaryField()[patchi][patchFacei] +=
rho.boundaryField()[patchi][patchFacei]
- * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin))
+ * (Omega ^ (Cf.boundaryField()[patchi][patchFacei] - origin_))
& Sf.boundaryField()[patchi][patchFacei];
}
}
@@ -187,4 +187,5 @@ bool Foam::MRFZones::readData(Istream& is)
return is.good();
}
+
// ************************************************************************* //
@@ -115,10 +115,12 @@ public:
//- Correct the boundary velocity for the roation of the MRF region
void correctBoundaryVelocity(volVectorField& U) const;
+
// I-O
//- Read from Istream
virtual bool readData(Istream&);
+
};
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 1047.2;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 1047.2;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 104.72;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 104.72;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 104.72;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 104.72;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 6.2831853;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 6.2831853;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 6.2831853;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 6.2831853;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 6.2831853;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 6.2831853;
}
)
@@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ();
- origin origin [0 1 0 0 0 0 0] (0 0 0);
- axis axis [0 0 0 0 0 0 0] (0 0 1);
- omega omega [0 0 -1 0 0 0 0] 10.472;
+ origin (0 0 0);
+ axis (0 0 1);
+ omega constant 10.472;
}
)
Oops, something went wrong.

0 comments on commit 9306436

Please sign in to comment.