From a54927fadcdb4fd01305b1053d5f4c8c20477547 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 21 Nov 2011 12:02:12 +0000 Subject: [PATCH 01/28] ENH: Added warning if using AMI with particle tracking --- src/lagrangian/basic/Cloud/Cloud.C | 28 ++++++++++++++++++++++++++++ src/lagrangian/basic/Cloud/Cloud.H | 3 +++ src/lagrangian/basic/Cloud/CloudIO.C | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 400f8955c5..8f951b6c52 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -31,9 +31,33 @@ License #include "Time.H" #include "OFstream.H" #include "wallPolyPatch.H" +#include "cyclicAMIPolyPatch.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // +template +void Foam::Cloud::checkPatches() const +{ + const polyBoundaryMesh& pbm = polyMesh_.boundaryMesh(); + bool ok = true; + forAll(pbm, patchI) + { + if (isA(pbm[patchI])) + { + ok = false; + break; + } + } + + if (!ok) + { + WarningIn("void Foam::Cloud::initCloud(const bool)") + << "Particle tracking across AMI patches is not currently " + << "supported" << endl; + } +} + + template void Foam::Cloud::calcCellWallFaces() const { @@ -76,6 +100,8 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + checkPatches(); + // Ask for the tetBasePtIs to trigger all processors to build // them, otherwise, if some processors have no particles then // there is a comms mismatch. @@ -100,6 +126,8 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + checkPatches(); + // Ask for the tetBasePtIs to trigger all processors to build // them, otherwise, if some processors have no particles then // there is a comms mismatch. diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 69f792ad46..56b4759f1a 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -93,6 +93,9 @@ class Cloud // Private Member Functions + //- Check patches + void checkPatches() const; + //- Initialise cloud on IO constructor void initCloud(const bool checkClass); diff --git a/src/lagrangian/basic/Cloud/CloudIO.C b/src/lagrangian/basic/Cloud/CloudIO.C index a62e99808b..1845d54165 100644 --- a/src/lagrangian/basic/Cloud/CloudIO.C +++ b/src/lagrangian/basic/Cloud/CloudIO.C @@ -162,6 +162,8 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + checkPatches(); + initCloud(checkClass); } @@ -180,6 +182,8 @@ Foam::Cloud::Cloud nTrackingRescues_(), cellWallFacesPtr_() { + checkPatches(); + initCloud(checkClass); } From 9dd55c02cb32eda9840bc604217a5a145621fec8 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 21 Nov 2011 13:59:42 +0000 Subject: [PATCH 02/28] ENH: Added further ouput to volPointInterp test app --- .../Test-volPointInterpolation.C | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/applications/test/volPointInterpolation/Test-volPointInterpolation.C b/applications/test/volPointInterpolation/Test-volPointInterpolation.C index 1bbcd6da5e..96ffeeac37 100644 --- a/applications/test/volPointInterpolation/Test-volPointInterpolation.C +++ b/applications/test/volPointInterpolation/Test-volPointInterpolation.C @@ -33,11 +33,10 @@ Application int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" + #include "createTime.H" + #include "createMesh.H" Info<< "Reading field p\n" << endl; volScalarField p @@ -67,9 +66,29 @@ int main(int argc, char *argv[]) mesh ); + const pointMesh& pMesh = pointMesh::New(mesh); + const pointBoundaryMesh& pbm = pMesh.boundary(); + + Info<< "pointMesh boundary" << nl; + forAll(pbm, patchI) + { + Info<< "patch=" << pbm[patchI].name() + << ", type=" << pbm[patchI].type() + << ", coupled=" << pbm[patchI].coupled() + << endl; + } + const volPointInterpolation& pInterp = volPointInterpolation::New(mesh); + pointScalarField pp(pInterp.interpolate(p)); + Info<< pp.name() << " boundary" << endl; + forAll(pp.boundaryField(), patchI) + { + Info<< pbm[patchI].name() << " coupled=" + << pp.boundaryField()[patchI].coupled()<< endl; + } + pp.write(); pointVectorField pU(pInterp.interpolate(U)); From 49b06765737376b740903ba40fdfb6d3f56c9f48 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 21 Nov 2011 14:00:18 +0000 Subject: [PATCH 03/28] ENH: Added coefficient of variance (CoV) operation to fieldValues function objects --- .../field/fieldValues/cellSource/cellSource.C | 7 ++++--- .../field/fieldValues/cellSource/cellSource.H | 6 ++++-- .../cellSource/cellSourceTemplates.C | 17 +++++++++++++++++ .../field/fieldValues/faceSource/faceSource.C | 7 ++++--- .../field/fieldValues/faceSource/faceSource.H | 6 ++++-- .../faceSource/faceSourceTemplates.C | 19 +++++++++++++++++++ 6 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C index ebf14d47f0..3bbb078c86 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C @@ -50,7 +50,7 @@ namespace Foam const char* Foam::NamedEnum < Foam::fieldValues::cellSource::operationType, - 7 + 8 >::names[] = { "none", @@ -59,7 +59,8 @@ namespace Foam "volIntegrate", "weightedAverage", "min", - "max" + "max", + "CoV" }; } @@ -67,7 +68,7 @@ namespace Foam const Foam::NamedEnum Foam::fieldValues::cellSource::sourceTypeNames_; -const Foam::NamedEnum +const Foam::NamedEnum Foam::fieldValues::cellSource::operationTypeNames_; diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H index b3231481f6..259c2aff88 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H @@ -52,6 +52,7 @@ Description - volAverage - volIntegrate - weightedAverage + - CoV (Coefficient of variation: standard deviation/mean) SourceFiles cellSource.C @@ -106,11 +107,12 @@ public: opVolIntegrate, opWeightedAverage, opMin, - opMax + opMax, + opCoV }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: diff --git a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C index 6c3fe94438..9a3263465c 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C @@ -115,6 +115,23 @@ Type Foam::fieldValues::cellSource::processValues result = max(values); break; } + case opCoV: + { + Type meanValue = sum(values*V)/sum(V); + + const label nComp = pTraits::nComponents; + + for (direction d=0; d::names[] = { "none", @@ -62,7 +62,8 @@ namespace Foam "areaIntegrate", "weightedAverage", "min", - "max" + "max", + "CoV" }; } @@ -71,7 +72,7 @@ namespace Foam const Foam::NamedEnum Foam::fieldValues::faceSource::sourceTypeNames_; -const Foam::NamedEnum +const Foam::NamedEnum Foam::fieldValues::faceSource::operationTypeNames_; diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index 4ff40c837d..90f972c574 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -62,6 +62,7 @@ Description - weightedAverage - min - max + - CoV (Coefficient of variation: standard deviation/mean) Notes: - faces on empty patches get ignored @@ -132,11 +133,12 @@ public: opAreaIntegrate, opWeightedAverage, opMin, - opMax + opMax, + opCoV }; //- Operation type names - static const NamedEnum operationTypeNames_; + static const NamedEnum operationTypeNames_; private: diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index 47fb3a61e1..821fda5f6a 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -134,6 +134,25 @@ Type Foam::fieldValues::faceSource::processValues result = max(values); break; } + case opCoV: + { + Type meanValue = sum(values*magSf)/sum(magSf); + + const label nComp = pTraits::nComponents; + + for (direction d=0; d Date: Mon, 21 Nov 2011 15:19:41 +0000 Subject: [PATCH 04/28] ENH: Added DataEntry functionality to boundary conditions --- src/finiteVolume/Make/files | 2 - .../flowRateInletVelocityFvPatchVectorField.C | 31 ++- .../flowRateInletVelocityFvPatchVectorField.H | 19 +- ...ureInletOutletVelocityFvPatchVectorField.C | 27 +-- ...ureInletOutletVelocityFvPatchVectorField.H | 22 +-- .../rotatingTotalPressureFvPatchScalarField.C | 27 +-- .../rotatingTotalPressureFvPatchScalarField.H | 20 +- .../rotatingWallVelocityFvPatchVectorField.C | 33 ++-- .../rotatingWallVelocityFvPatchVectorField.H | 17 +- ...gFlowRateInletVelocityFvPatchVectorField.C | 132 ------------- ...gFlowRateInletVelocityFvPatchVectorField.H | 182 ----------------- ...timeVaryingUniformFixedValueFvPatchField.C | 137 ------------- ...timeVaryingUniformFixedValueFvPatchField.H | 183 ------------------ ...imeVaryingUniformFixedValueFvPatchFields.C | 43 ---- ...imeVaryingUniformFixedValueFvPatchFields.H | 49 ----- ...VaryingUniformFixedValueFvPatchFieldsFwd.H | 50 ----- .../uniformFixedValueFvPatchField.C | 28 +-- .../uniformFixedValueFvPatchField.H | 20 +- 18 files changed, 92 insertions(+), 930 deletions(-) delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.C delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.H delete mode 100644 src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFieldsFwd.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 656cc2f0ed..6a3caf2ff0 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -158,8 +158,6 @@ $(derivedFvPatchFields)/surfaceNormalFixedValue/surfaceNormalFixedValueFvPatchVe $(derivedFvPatchFields)/syringePressure/syringePressureFvPatchScalarField.C $(derivedFvPatchFields)/timeVaryingMappedFixedValue/AverageIOFields.C $(derivedFvPatchFields)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchFields.C -$(derivedFvPatchFields)/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C -$(derivedFvPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C $(derivedFvPatchFields)/totalPressure/totalPressureFvPatchScalarField.C $(derivedFvPatchFields)/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.C $(derivedFvPatchFields)/totalTemperature/totalTemperatureFvPatchScalarField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 226405b792..d4b2aa3df2 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -31,8 +31,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam:: -flowRateInletVelocityFvPatchVectorField:: +Foam::flowRateInletVelocityFvPatchVectorField:: flowRateInletVelocityFvPatchVectorField ( const fvPatch& p, @@ -40,14 +39,13 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(p, iF), - flowRate_(0), + flowRate_(), phiName_("phi"), rhoName_("rho") {} -Foam:: -flowRateInletVelocityFvPatchVectorField:: +Foam::flowRateInletVelocityFvPatchVectorField:: flowRateInletVelocityFvPatchVectorField ( const flowRateInletVelocityFvPatchVectorField& ptf, @@ -57,14 +55,13 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(ptf, p, iF, mapper), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_().clone().ptr()), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_) {} -Foam:: -flowRateInletVelocityFvPatchVectorField:: +Foam::flowRateInletVelocityFvPatchVectorField:: flowRateInletVelocityFvPatchVectorField ( const fvPatch& p, @@ -73,28 +70,26 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(p, iF, dict), - flowRate_(readScalar(dict.lookup("flowRate"))), + flowRate_(DataEntry::New("flowRate", dict)), phiName_(dict.lookupOrDefault("phi", "phi")), rhoName_(dict.lookupOrDefault("rho", "rho")) {} -Foam:: -flowRateInletVelocityFvPatchVectorField:: +Foam::flowRateInletVelocityFvPatchVectorField:: flowRateInletVelocityFvPatchVectorField ( const flowRateInletVelocityFvPatchVectorField& ptf ) : fixedValueFvPatchField(ptf), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_().clone().ptr()), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_) {} -Foam:: -flowRateInletVelocityFvPatchVectorField:: +Foam::flowRateInletVelocityFvPatchVectorField:: flowRateInletVelocityFvPatchVectorField ( const flowRateInletVelocityFvPatchVectorField& ptf, @@ -102,7 +97,7 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField(ptf, iF), - flowRate_(ptf.flowRate_), + flowRate_(ptf.flowRate_().clone().ptr()), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_) {} @@ -117,8 +112,10 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() return; } + const scalar t = db().time().value(); + // a simpler way of doing this would be nice - const scalar avgU = -flowRate_/gSum(patch().magSf()); + const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf()); tmp n = patch().nf(); @@ -157,7 +154,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl; + flowRate_->writeData(os); writeEntryIfDifferent(os, "phi", "phi", phiName_); writeEntryIfDifferent(os, "rho", "rho", rhoName_); writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index b00368a5a5..f40674ea01 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H @@ -57,6 +57,7 @@ SourceFiles #define flowRateInletVelocityFvPatchVectorField_H #include "fixedValueFvPatchFields.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -73,7 +74,7 @@ class flowRateInletVelocityFvPatchVectorField // Private data //- Inlet integral flow rate - scalar flowRate_; + autoPtr > flowRate_; //- Name of the flux transporting the field word phiName_; @@ -153,27 +154,11 @@ public: // Member functions - // Access - - //- Return the flux - scalar flowRate() const - { - return flowRate_; - } - - //- Return reference to the flux to allow adjustment - scalar& flowRate() - { - return flowRate_; - } - - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); //- Write virtual void write(Ostream&) const; - }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C index 7ccd38a18b..a382b65c8d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C @@ -33,10 +33,13 @@ License void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: calcTangentialVelocity() { - vector axisHat = omega_/mag(omega_); + const scalar t = this->db().time().value(); + vector om = omega_->value(t); + + vector axisHat = om/mag(om); const vectorField tangentialVelocity ( - (-omega_) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf())) + (-om) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf())) ); const vectorField n(patch().nf()); @@ -54,7 +57,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(p, iF), - omega_(vector::zero) + omega_() {} @@ -68,7 +71,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper), - omega_(ptf.omega_) + omega_(ptf.omega_().clone().ptr()) { calcTangentialVelocity(); } @@ -83,7 +86,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(p, iF, dict), - omega_(dict.lookup("omega")) + omega_(DataEntry::New("omega", dict)) { calcTangentialVelocity(); } @@ -92,11 +95,11 @@ rotatingPressureInletOutletVelocityFvPatchVectorField Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: rotatingPressureInletOutletVelocityFvPatchVectorField ( - const rotatingPressureInletOutletVelocityFvPatchVectorField& pivpvf + const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf ) : - pressureInletOutletVelocityFvPatchVectorField(pivpvf), - omega_(pivpvf.omega_) + pressureInletOutletVelocityFvPatchVectorField(rppvf), + omega_(rppvf.omega_().clone().ptr()) { calcTangentialVelocity(); } @@ -105,12 +108,12 @@ rotatingPressureInletOutletVelocityFvPatchVectorField Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: rotatingPressureInletOutletVelocityFvPatchVectorField ( - const rotatingPressureInletOutletVelocityFvPatchVectorField& pivpvf, + const rotatingPressureInletOutletVelocityFvPatchVectorField& rppvf, const DimensionedField& iF ) : - pressureInletOutletVelocityFvPatchVectorField(pivpvf, iF), - omega_(pivpvf.omega_) + pressureInletOutletVelocityFvPatchVectorField(rppvf, iF), + omega_(rppvf.omega_().clone().ptr()) { calcTangentialVelocity(); } @@ -125,7 +128,7 @@ void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write { fvPatchVectorField::write(os); os.writeKeyword("phi") << phiName() << token::END_STATEMENT << nl; - os.writeKeyword("omega")<< omega_ << token::END_STATEMENT << nl; + omega_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H index 3d2e3a7cc9..0635857518 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H @@ -40,6 +40,7 @@ SourceFiles #include "fvPatchFields.H" #include "pressureInletOutletVelocityFvPatchVectorField.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class rotatingPressureInletOutletVelocityFvPatch Declaration + Class rotatingPressureInletOutletVelocityFvPatch Declaration \*---------------------------------------------------------------------------*/ class rotatingPressureInletOutletVelocityFvPatchVectorField @@ -57,7 +58,7 @@ class rotatingPressureInletOutletVelocityFvPatchVectorField // Private data //- Angular velocity of the frame - vector omega_; + autoPtr > omega_; // Private Member Functions @@ -141,23 +142,6 @@ public: // Member functions - // Access - - //- Return the angular velocity of rotation - const vector& omega() const - { - return omega_; - } - - //- Reset the angular velocity of rotation - // and update the tangentialVelocity - void setOmega(const vector& omega) - { - omega_ = omega; - calcTangentialVelocity(); - } - - //- Write virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C index 249635c21b..8bd52df99e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C @@ -39,7 +39,7 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(p, iF), - omega_(vector::zero) + omega_() {} @@ -53,7 +53,7 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(ptf, p, iF, mapper), - omega_(ptf.omega_) + omega_(ptf.omega_().clone().ptr()) {} @@ -66,30 +66,30 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(p, iF, dict), - omega_(dict.lookup("omega")) + omega_(DataEntry::New("omega", dict)) {} Foam::rotatingTotalPressureFvPatchScalarField:: rotatingTotalPressureFvPatchScalarField ( - const rotatingTotalPressureFvPatchScalarField& tppsf + const rotatingTotalPressureFvPatchScalarField& rtppsf ) : - totalPressureFvPatchScalarField(tppsf), - omega_(tppsf.omega_) + totalPressureFvPatchScalarField(rtppsf), + omega_(rtppsf.omega_().clone().ptr()) {} Foam::rotatingTotalPressureFvPatchScalarField:: rotatingTotalPressureFvPatchScalarField ( - const rotatingTotalPressureFvPatchScalarField& tppsf, + const rotatingTotalPressureFvPatchScalarField& rtppsf, const DimensionedField& iF ) : - totalPressureFvPatchScalarField(tppsf, iF), - omega_(tppsf.omega_) + totalPressureFvPatchScalarField(rtppsf, iF), + omega_(rtppsf.omega_().clone().ptr()) {} @@ -102,9 +102,12 @@ void Foam::rotatingTotalPressureFvPatchScalarField::updateCoeffs() return; } - vector axisHat = omega_/mag(omega_); + const scalar t = this->db().time().value(); + const vector om = omega_->value(t); + + vector axisHat = om/mag(om); tmp rotationVelocity = - omega_ ^ (patch().Cf() - axisHat*(axisHat & patch().Cf())); + om ^ (patch().Cf() - axisHat*(axisHat & patch().Cf())); const vectorField Up ( @@ -119,7 +122,7 @@ void Foam::rotatingTotalPressureFvPatchScalarField::updateCoeffs() void Foam::rotatingTotalPressureFvPatchScalarField::write(Ostream& os) const { totalPressureFvPatchScalarField::write(os); - os.writeKeyword("omega")<< omega_ << token::END_STATEMENT << nl; + omega_->writeData(os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H index d214d56627..68e1d19c8f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H @@ -36,6 +36,7 @@ SourceFiles #define rotatingTotalPressureFvPatchScalarField_H #include "totalPressureFvPatchScalarField.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class rotatingTotalPressureFvPatch Declaration + Class rotatingTotalPressureFvPatch Declaration \*---------------------------------------------------------------------------*/ class rotatingTotalPressureFvPatchScalarField @@ -53,7 +54,7 @@ class rotatingTotalPressureFvPatchScalarField // Private data //- Angular velocity of the frame - vector omega_; + autoPtr > omega_; public: @@ -126,21 +127,6 @@ public: // Member functions - // Access - - //- Return the angular velocity of rotation - const vector& omega() const - { - return omega_; - } - - //- Return the angular velocity of rotation - vector& omega() - { - return omega_; - } - - // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C index 9ed9bb388d..b7a30a8488 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C @@ -38,7 +38,7 @@ rotatingWallVelocityFvPatchVectorField ) : fixedValueFvPatchField(p, iF), - origin_(vector::zero), + origin_(), axis_(vector::zero), omega_(0) {} @@ -56,7 +56,7 @@ rotatingWallVelocityFvPatchVectorField fixedValueFvPatchField(ptf, p, iF, mapper), origin_(ptf.origin_), axis_(ptf.axis_), - omega_(ptf.omega_) + omega_(ptf.omega_().clone().ptr()) {} @@ -71,7 +71,7 @@ rotatingWallVelocityFvPatchVectorField fixedValueFvPatchField(p, iF), origin_(dict.lookup("origin")), axis_(dict.lookup("axis")), - omega_(readScalar(dict.lookup("omega"))) + omega_(DataEntry::New("omega", dict)) { // Evaluate the wall velocity updateCoeffs(); @@ -81,27 +81,27 @@ rotatingWallVelocityFvPatchVectorField Foam::rotatingWallVelocityFvPatchVectorField:: rotatingWallVelocityFvPatchVectorField ( - const rotatingWallVelocityFvPatchVectorField& pivpvf + const rotatingWallVelocityFvPatchVectorField& rwvpvf ) : - fixedValueFvPatchField(pivpvf), - origin_(pivpvf.origin_), - axis_(pivpvf.axis_), - omega_(pivpvf.omega_) + fixedValueFvPatchField(rwvpvf), + origin_(rwvpvf.origin_), + axis_(rwvpvf.axis_), + omega_(rwvpvf.omega_().clone().ptr()) {} Foam::rotatingWallVelocityFvPatchVectorField:: rotatingWallVelocityFvPatchVectorField ( - const rotatingWallVelocityFvPatchVectorField& pivpvf, + const rotatingWallVelocityFvPatchVectorField& rwvpvf, const DimensionedField& iF ) : - fixedValueFvPatchField(pivpvf, iF), - origin_(pivpvf.origin_), - axis_(pivpvf.axis_), - omega_(pivpvf.omega_) + fixedValueFvPatchField(rwvpvf, iF), + origin_(rwvpvf.origin_), + axis_(rwvpvf.axis_), + omega_(rwvpvf.omega_().clone().ptr()) {} @@ -114,10 +114,13 @@ void Foam::rotatingWallVelocityFvPatchVectorField::updateCoeffs() return; } + const scalar t = this->db().time().value(); + scalar om = omega_->value(t); + // Calculate the rotating wall velocity from the specification of the motion const vectorField Up ( - (-omega_)*((patch().Cf() - origin_) ^ (axis_/mag(axis_))) + (-om)*((patch().Cf() - origin_) ^ (axis_/mag(axis_))) ); // Remove the component of Up normal to the wall @@ -134,7 +137,7 @@ void Foam::rotatingWallVelocityFvPatchVectorField::write(Ostream& os) const fvPatchVectorField::write(os); os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl; os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl; - os.writeKeyword("omega") << omega_ << token::END_STATEMENT << nl; + omega_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H index ac18cda23f..41f821c6d8 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H @@ -36,6 +36,7 @@ SourceFiles #define rotatingWallVelocityFvPatchVectorField_H #include "fixedValueFvPatchFields.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class rotatingWallVelocityFvPatch Declaration + Class rotatingWallVelocityFvPatch Declaration \*---------------------------------------------------------------------------*/ class rotatingWallVelocityFvPatchVectorField @@ -59,7 +60,7 @@ class rotatingWallVelocityFvPatchVectorField vector axis_; //- Rotational speed - scalar omega_; + autoPtr > omega_; public: @@ -147,12 +148,6 @@ public: return axis_; } - //- Return the rotational speed - scalar omega() const - { - return omega_; - } - //- Return non-const access to the origin of the rotation vector& origin() { @@ -165,12 +160,6 @@ public: return axis_; } - //- Return non-const access to the rotational speed - scalar& omega() - { - return omega_; - } - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C deleted file mode 100644 index 7dd71eb8b6..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C +++ /dev/null @@ -1,132 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "timeVaryingFlowRateInletVelocityFvPatchVectorField.H" -#include "volFields.H" -#include "addToRunTimeSelectionTable.H" -#include "fvPatchFieldMapper.H" -#include "surfaceFields.H" -#include "Time.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -timeVaryingFlowRateInletVelocityFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF -) -: - flowRateInletVelocityFvPatchVectorField(p, iF), - timeSeries_() -{} - - -Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -timeVaryingFlowRateInletVelocityFvPatchVectorField -( - const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - flowRateInletVelocityFvPatchVectorField(ptf, p, iF, mapper), - timeSeries_(ptf.timeSeries_) -{} - - -Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -timeVaryingFlowRateInletVelocityFvPatchVectorField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - flowRateInletVelocityFvPatchVectorField(p, iF, dict), - timeSeries_(dict) -{} - - -Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -timeVaryingFlowRateInletVelocityFvPatchVectorField -( - const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf -) -: - flowRateInletVelocityFvPatchVectorField(ptf), - timeSeries_(ptf.timeSeries_) -{} - - -Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -timeVaryingFlowRateInletVelocityFvPatchVectorField -( - const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf, - const DimensionedField& iF -) -: - flowRateInletVelocityFvPatchVectorField(ptf, iF), - timeSeries_(ptf.timeSeries_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -updateCoeffs() -{ - if (updated()) - { - return; - } - - flowRate() = timeSeries_(this->db().time().timeOutputValue()); - flowRateInletVelocityFvPatchVectorField::updateCoeffs(); -} - - -void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField:: -write(Ostream& os) const -{ - flowRateInletVelocityFvPatchVectorField::write(os); - timeSeries_.write(os); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - makePatchTypeField - ( - fvPatchVectorField, - timeVaryingFlowRateInletVelocityFvPatchVectorField - ); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H deleted file mode 100644 index 0ba11a655d..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.H +++ /dev/null @@ -1,182 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField - -Description - A time-varying form of a flow normal vector boundary condition. The - variation is specified as an interpolationTable (see - Foam::interpolationTable). - - Example of the boundary condition specification: - \verbatim - inlet - { - type timeVaryingFlowRateInletVelocity; - flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s] - value uniform (0 0 0); // placeholder - fileName "$FOAM_CASE/time-series"; - outOfBounds repeat; // (error|warn|clamp|repeat) - } - \endverbatim - -Note - - The value is positive inwards - - may not work correctly for transonic inlets! - - strange behaviour with potentialFoam since the U equation is not solved - -See Also - Foam::interpolationTable and Foam::flowRateInletVelocityFvPatchVectorField - -SourceFiles - timeVaryingFlowRateInletVelocityFvPatchVectorField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingFlowRateInletVelocityFvPatchVectorField_H -#define timeVaryingFlowRateInletVelocityFvPatchVectorField_H - -#include "flowRateInletVelocityFvPatchVectorField.H" -#include "interpolationTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -/*---------------------------------------------------------------------------*\ - Class timeVaryingFlowRateInletVelocityFvPatch Declaration -\*---------------------------------------------------------------------------*/ - -class timeVaryingFlowRateInletVelocityFvPatchVectorField -: - public flowRateInletVelocityFvPatchVectorField -{ - // Private data - - //- the time series being used, including the bounding treatment - interpolationTable timeSeries_; - - -public: - - //- Runtime type information - TypeName("timeVaryingFlowRateInletVelocity"); - - - // Constructors - - //- Construct from patch and internal field - timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given patch field onto a new patch - timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - const timeVaryingFlowRateInletVelocityFvPatchVectorField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - const timeVaryingFlowRateInletVelocityFvPatchVectorField& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new timeVaryingFlowRateInletVelocityFvPatchVectorField(*this) - ); - } - - //- Construct as copy setting internal field reference - timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - const timeVaryingFlowRateInletVelocityFvPatchVectorField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new timeVaryingFlowRateInletVelocityFvPatchVectorField - ( - *this, - iF - ) - ); - } - - - // Member functions - - // Access - - //- Return the time series used - const interpolationTable& timeSeries() const - { - return timeSeries_; - } - - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.C deleted file mode 100644 index 9ea28b4567..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.C +++ /dev/null @@ -1,137 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "timeVaryingUniformFixedValueFvPatchField.H" -#include "Time.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::timeVaryingUniformFixedValueFvPatchField:: -timeVaryingUniformFixedValueFvPatchField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchField(p, iF), - timeSeries_() -{} - - -template -Foam::timeVaryingUniformFixedValueFvPatchField:: -timeVaryingUniformFixedValueFvPatchField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchField(p, iF), - timeSeries_(dict) -{ - if (dict.found("value")) - { - fvPatchField::operator==(Field("value", dict, p.size())); - } - else - { - updateCoeffs(); - } -} - - -template -Foam::timeVaryingUniformFixedValueFvPatchField:: -timeVaryingUniformFixedValueFvPatchField -( - const timeVaryingUniformFixedValueFvPatchField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchField(ptf, p, iF, mapper), - timeSeries_(ptf.timeSeries_) -{} - - -template -Foam::timeVaryingUniformFixedValueFvPatchField:: -timeVaryingUniformFixedValueFvPatchField -( - const timeVaryingUniformFixedValueFvPatchField& ptf -) -: - fixedValueFvPatchField(ptf), - timeSeries_(ptf.timeSeries_) -{} - - -template -Foam::timeVaryingUniformFixedValueFvPatchField:: -timeVaryingUniformFixedValueFvPatchField -( - const timeVaryingUniformFixedValueFvPatchField& ptf, - const DimensionedField& iF -) -: - fixedValueFvPatchField(ptf, iF), - timeSeries_(ptf.timeSeries_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::timeVaryingUniformFixedValueFvPatchField::updateCoeffs() -{ - if (this->updated()) - { - return; - } - - fvPatchField::operator== - ( - timeSeries_(this->db().time().timeOutputValue()) - ); - fixedValueFvPatchField::updateCoeffs(); -} - - -template -void Foam::timeVaryingUniformFixedValueFvPatchField::write -( - Ostream& os -) const -{ - fvPatchField::write(os); - timeSeries_.write(os); - this->writeEntry("value", os); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H deleted file mode 100644 index 2d1f6d97ad..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchField.H +++ /dev/null @@ -1,183 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::timeVaryingUniformFixedValueFvPatchField - -Description - A time-varying form of a uniform fixed value boundary condition. The - variation is specified as an interpolationTable (see - Foam::interpolationTable for read options). - - Example of the boundary condition specification: - \verbatim - inlet - { - type timeVaryingUniformFixedValue; - fileName "$FOAM_CASE/time-series"; - outOfBounds clamp; // (error|warn|clamp|repeat) - } - \endverbatim - -Note - This class is derived directly from a fixedValue patch rather than from - a uniformFixedValue patch. - -See Also - Foam::interpolationTable and Foam::fixedValueFvPatchField - -SourceFiles - timeVaryingUniformFixedValueFvPatchField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingUniformFixedValueFvPatchField_H -#define timeVaryingUniformFixedValueFvPatchField_H - -#include "fixedValueFvPatchField.H" -#include "interpolationTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class timeVaryingUniformFixedValueFvPatch Declaration -\*---------------------------------------------------------------------------*/ - -template -class timeVaryingUniformFixedValueFvPatchField -: - public fixedValueFvPatchField -{ - // Private data - - //- The time series being used, including the bounding treatment - interpolationTable timeSeries_; - - -public: - - //- Runtime type information - TypeName("timeVaryingUniformFixedValue"); - - - // Constructors - - //- Construct from patch and internal field - timeVaryingUniformFixedValueFvPatchField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - timeVaryingUniformFixedValueFvPatchField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given patch field onto a new patch - timeVaryingUniformFixedValueFvPatchField - ( - const timeVaryingUniformFixedValueFvPatchField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - timeVaryingUniformFixedValueFvPatchField - ( - const timeVaryingUniformFixedValueFvPatchField& - ); - - //- Construct and return a clone - virtual tmp > clone() const - { - return tmp > - ( - new timeVaryingUniformFixedValueFvPatchField(*this) - ); - } - - //- Construct as copy setting internal field reference - timeVaryingUniformFixedValueFvPatchField - ( - const timeVaryingUniformFixedValueFvPatchField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp > clone - ( - const DimensionedField& iF - ) const - { - return tmp > - ( - new timeVaryingUniformFixedValueFvPatchField(*this, iF) - ); - } - - - // Member functions - - // Access - - //- Return the time series used - const interpolationTable& timeSeries() const - { - return timeSeries_; - } - - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "timeVaryingUniformFixedValueFvPatchField.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C deleted file mode 100644 index 78b31de35d..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C +++ /dev/null @@ -1,43 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "timeVaryingUniformFixedValueFvPatchFields.H" -#include "addToRunTimeSelectionTable.H" -#include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makePatchFields(timeVaryingUniformFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.H deleted file mode 100644 index ecd444cd0a..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.H +++ /dev/null @@ -1,49 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingUniformFixedValueFvPatchFields_H -#define timeVaryingUniformFixedValueFvPatchFields_H - -#include "timeVaryingUniformFixedValueFvPatchField.H" -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeFieldTypedefs(timeVaryingUniformFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFieldsFwd.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFieldsFwd.H deleted file mode 100644 index 5907a7ccf2..0000000000 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFieldsFwd.H +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingUniformFixedValueFvPatchFieldsFwd_H -#define timeVaryingUniformFixedValueFvPatchFieldsFwd_H - -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template class timeVaryingUniformFixedValueFvPatchField; - -makePatchTypeFieldTypedefs(timeVaryingUniformFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C index 622ac8959b..2770460e0d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C @@ -40,7 +40,7 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF), - uniformValue_(pTraits::zero) + uniformValue_() {} @@ -54,9 +54,10 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF), - uniformValue_(ptf.uniformValue_) + uniformValue_(ptf.uniformValue_().clone().ptr()) { - fvPatchField::operator==(uniformValue_); + const scalar t = this->db().time().value(); + fvPatchField::operator==(uniformValue_->value(t)); } @@ -69,9 +70,10 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF), - uniformValue_(pTraits(dict.lookup("uniformValue"))) + uniformValue_(DataEntry::New("uniformValue", dict)) { - fvPatchField::operator==(uniformValue_); + const scalar t = this->db().time().value(); + fvPatchField::operator==(uniformValue_->value(t)); } @@ -82,9 +84,10 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ) : fixedValueFvPatchField(ptf), - uniformValue_(ptf.uniformValue_) + uniformValue_(ptf.uniformValue_().clone().ptr()) { - fvPatchField::operator==(uniformValue_); + const scalar t = this->db().time().value(); + fvPatchField::operator==(uniformValue_->value(t)); } @@ -96,9 +99,10 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ) : fixedValueFvPatchField(ptf, iF), - uniformValue_(ptf.uniformValue_) + uniformValue_(ptf.uniformValue_().clone().ptr()) { - fvPatchField::operator==(uniformValue_); + const scalar t = this->db().time().value(); + fvPatchField::operator==(uniformValue_->value(t)); } @@ -111,7 +115,8 @@ void uniformFixedValueFvPatchField::autoMap ) { this->setSize(m.size()); - fvPatchField::operator==(uniformValue_); + const scalar t = this->db().time().value(); + fvPatchField::operator==(uniformValue_->value(t)); } @@ -119,8 +124,7 @@ template void uniformFixedValueFvPatchField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("uniformValue") - << uniformValue_ << token::END_STATEMENT << nl; + uniformValue_->writeData(os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H index 0c7b8e82e0..1b9da9ca7b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H @@ -37,6 +37,7 @@ SourceFiles #include "Random.H" #include "fixedValueFvPatchFields.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,7 +45,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class uniformFixedValueFvPatch Declaration + Class uniformFixedValueFvPatch Declaration \*---------------------------------------------------------------------------*/ template @@ -54,7 +55,7 @@ class uniformFixedValueFvPatchField { // Private data - Type uniformValue_; + autoPtr > uniformValue_; public: @@ -127,21 +128,6 @@ public: // Member functions - // Access - - //- Return the fluctuation scale - const Type& uniformValue() const - { - return uniformValue_; - } - - //- Return reference to the fluctuation scale to allow adjustment - Type& uniformValue() - { - return uniformValue_; - } - - // Mapping functions //- Map (and resize as needed) from self given a mapping object From 5763b7e4041a1f4da6e49b027e55280afce40ba1 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 21 Nov 2011 17:12:59 +0000 Subject: [PATCH 05/28] ENH: Added CSV table DataEntry --- .../primitives/functions/DataEntry/CSV/CSV.C | 285 ++++++++++++++++++ .../primitives/functions/DataEntry/CSV/CSV.H | 174 +++++++++++ .../functions/DataEntry/CSV/CSVIO.C | 85 ++++++ .../functions/DataEntry/Constant/Constant.C | 5 +- .../functions/DataEntry/Constant/Constant.H | 2 +- .../functions/DataEntry/DataEntry/DataEntry.H | 4 +- .../DataEntry/DataEntry/DataEntryNew.C | 3 +- .../functions/DataEntry/Table/Table.C | 9 +- .../functions/DataEntry/Table/Table.H | 2 +- .../functions/DataEntry/makeDataEntries.C | 24 +- .../DataEntry/polynomial/polynomial.C | 9 +- .../DataEntry/polynomial/polynomial.H | 2 +- 12 files changed, 591 insertions(+), 13 deletions(-) create mode 100644 src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C create mode 100644 src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H create mode 100644 src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C new file mode 100644 index 0000000000..438c10f60b --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C @@ -0,0 +1,285 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "CSV.H" +#include "DynamicList.H" +#include "IFstream.H" +//#include "IStringStream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +namespace Foam +{ + // doesn't recognize specialization otherwise + template<> + scalar CSV::readValue(const List& splitted) + { + if (componentColumns_[0] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[0] << " in " + << splitted << endl + << exit(FatalError); + } + + return readScalar(IStringStream(splitted[componentColumns_[0]])()); + } + + + template + Type CSV::readValue(const List& splitted) + { + Type result; + + for (label i = 0; i < pTraits::nComponents; i++) + { + if (componentColumns_[i] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[i] << " in " + << splitted << endl + << exit(FatalError); + } + + result[i] = + readScalar(IStringStream(splitted[componentColumns_[i]])()); + } + + return result; + } +} + + +template +void Foam::CSV::read() +{ + IFstream is(fName_.expand()); + + DynamicList > values; + + // skip header + if (headerLine_) + { + string line; + is.getLine(line); + } + + // read data + while (is.good()) + { + string line; + is.getLine(line); + + DynamicList splitted; + + std::size_t pos = 0; + while (pos != std::string::npos) + { + std::size_t nPos = line.find(separator_, pos); + + if (nPos == std::string::npos) + { + splitted.append(line.substr(pos)); + pos = nPos; + } + else + { + splitted.append(line.substr(pos, nPos - pos)); + pos = nPos + 1; + } + } + + if (splitted.size() <= 1) + { + break; + } + + scalar x = readScalar(IStringStream(splitted[refColumn_])()); + Type value = readValue(splitted); + + values.append(Tuple2(x, value)); + } + + table_.transfer(values); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CSV::CSV(const word& entryName, const dictionary& dict) +: + DataEntry(entryName), + headerLine_(false), + refColumn_(0), + componentColumns_(), + separator_(string(",")[0]), + fName_("none"), + table_() +{ + const dictionary coeffs(dict.subDict(type() + "Coeffs")); + coeffs.lookup("hasHeaderLine") >> headerLine_; + coeffs.lookup("refColumn") >> refColumn_; + coeffs.lookup("componentColumns") >> componentColumns_; + coeffs.readIfPresent("separator", string(separator_)[0]); + coeffs.lookup("fileName") >> fName_; + + if (componentColumns_.size() != pTraits::nComponents) + { + FatalErrorIn("Foam::CSV::CSV(const word&, Istream&)") + << componentColumns_ << " does not have the expected length " + << pTraits::nComponents << endl + << exit(FatalError); + } + + read(); + + if (!table_.size()) + { + FatalErrorIn("Foam::CSV::CSV(const Istream&)") + << "CSV for entry " << this->name_ << " is invalid (empty)" + << nl << exit(FatalError); + } +} + + +template +Foam::CSV::CSV(const CSV& tbl) +: + DataEntry(tbl), + headerLine_(tbl.headerLine_), + refColumn_(tbl.refColumn_), + componentColumns_(tbl.componentColumns_), + separator_(tbl.separator_), + fName_(tbl.fName_), + table_(tbl.table_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::CSV::~CSV() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Type Foam::CSV::value(const scalar x) const +{ + // Return zero if out of bounds + if (x < table_[0].first() || x > table_.last().first()) + { + return pTraits::zero; + } + + // Find i such that x(i) < x < x(i+1) + label i = 0; + while ((table_[i+1].first() < x) && (i+1 < table_.size())) + { + i++; + } + + // Linear interpolation to find value. Note constructor needed for + // CSV