From 14a392fe0a209a189cae04c149d91fea6365a1ec Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 19 Sep 2008 11:13:44 +0200 Subject: [PATCH 001/113] derived bcs: consistent treatment of "phi" and "rho" lookups, etc --- .../derived/advective/advectiveFvPatchField.C | 37 +++++----- ...MappedVelocityFluxFixedValueFvPatchField.C | 10 +-- .../derived/fan/fanFvPatchFields.C | 8 +-- .../fixedFluxPressureFvPatchScalarField.C | 62 +++++++++------- .../flowRateInletVelocityFvPatchVectorField.C | 29 ++------ .../fluxCorrectedVelocityFvPatchVectorField.C | 51 +++++++------ .../inletOutlet/inletOutletFvPatchField.C | 10 +-- ...OutletTotalTemperatureFvPatchScalarField.C | 67 +++++++++-------- ...sFlowRateInletVelocityFvPatchVectorField.C | 6 +- .../movingWallVelocityFvPatchVectorField.C | 2 +- ...tedInletOutletVelocityFvPatchVectorField.C | 10 ++- ...eDirectedInletVelocityFvPatchVectorField.C | 10 ++- ...ureInletOutletVelocityFvPatchVectorField.C | 12 ++-- .../pressureInletVelocityFvPatchVectorField.C | 16 +++-- ...malInletOutletVelocityFvPatchVectorField.C | 2 +- .../syringePressureFvPatchScalarField.C | 6 +- .../timeVaryingMappedFixedValueFvPatchField.C | 2 +- ...ngUniformTotalPressureFvPatchScalarField.C | 50 +++++++------ ...ngUniformTotalPressureFvPatchScalarField.H | 4 +- .../totalPressureFvPatchScalarField.C | 72 ++++++++++--------- .../totalTemperatureFvPatchScalarField.C | 63 +++++++++------- ...sityKineticEnergyInletFvPatchScalarField.C | 39 +++++----- .../waveTransmissiveFvPatchField.C | 27 ++++--- 23 files changed, 308 insertions(+), 287 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C index 84d78fcd83..c661cca69a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/advective/advectiveFvPatchField.C @@ -47,8 +47,8 @@ advectiveFvPatchField::advectiveFvPatchField ) : mixedFvPatchField(p, iF), - phiName_("Undefined"), - rhoName_("Undefined"), + phiName_("phi"), + rhoName_("rho"), fieldInf_(pTraits::zero), lInf_(0.0) { @@ -84,8 +84,8 @@ advectiveFvPatchField::advectiveFvPatchField ) : mixedFvPatchField(p, iF), - phiName_(dict.lookup("phi")), - rhoName_("Undefined"), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), fieldInf_(pTraits::zero), lInf_(0.0) { @@ -105,15 +105,9 @@ advectiveFvPatchField::advectiveFvPatchField this->refGrad() = pTraits::zero; this->valueFraction() = 0.0; - if (dict.found("rho")) - { - dict.lookup("rho") >> rhoName_; - } - - if (dict.found("lInf")) + if (dict.readIfPresent("lInf", lInf_)) { dict.lookup("fieldInf") >> fieldInf_; - dict.lookup("lInf") >> lInf_; if (lInf_ < 0.0) { @@ -123,8 +117,8 @@ advectiveFvPatchField::advectiveFvPatchField "advectiveFvPatchField" "(const fvPatch&, const Field&, const dictionary&)", dict - ) << "unphysical lInf_ specified (lInf_ < 0)" - << "\n on patch " << this->patch().name() + ) << "unphysical lInf specified (lInf < 0)\n" + << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalIOError); @@ -167,7 +161,7 @@ advectiveFvPatchField::advectiveFvPatchField template tmp advectiveFvPatchField::advectionSpeed() const { - const surfaceScalarField& phi = + const surfaceScalarField& phi = this->db().objectRegistry::lookupObject(phiName_); fvsPatchField phip = this->patch().lookupPatchField @@ -210,7 +204,7 @@ void advectiveFvPatchField::updateCoeffs() ); scalar deltaT = this->db().time().deltaT().value(); - const GeometricField& field = + const GeometricField& field = this->db().objectRegistry:: lookupObject > ( @@ -239,7 +233,7 @@ void advectiveFvPatchField::updateCoeffs() || ddtScheme == fv::CrankNicholsonDdtScheme::typeName ) { - this->refValue() = + this->refValue() = ( field.oldTime().boundaryField()[patchi] + k*fieldInf_ )/(1.0 + k); @@ -314,9 +308,12 @@ template void advectiveFvPatchField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - if (rhoName_ != "Undefined") + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (rhoName_ != "rho") { os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; } @@ -324,9 +321,9 @@ void advectiveFvPatchField::write(Ostream& os) const if (lInf_ > SMALL) { os.writeKeyword("fieldInf") << fieldInf_ - << token::END_STATEMENT << endl; + << token::END_STATEMENT << nl; os.writeKeyword("lInf") << lInf_ - << token::END_STATEMENT << endl; + << token::END_STATEMENT << nl; } this->writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C index e77e698533..8e7a8b92fa 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C @@ -238,11 +238,11 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs() const word& fieldName = dimensionedInternalField().name(); const volVectorField& UField = db().lookupObject(fieldName); - surfaceScalarField& phiField = - const_cast - ( - db().lookupObject(phiName_) - ); + + surfaceScalarField& phiField = const_cast + ( + db().lookupObject(phiName_) + ); switch (mpp.mode()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index b02db5c7dd..33eec56864 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -52,11 +52,9 @@ void fanFvPatchField::updateCoeffs() if (f_.size() > 1) { - const surfaceScalarField& phi = db().lookupObject - ( - "phi" - ); - + const surfaceScalarField& phi = + db().lookupObject("phi"); + const fvsPatchField& phip = patch().patchField(phi); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 7f24742db0..33c6e2d98a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -30,28 +30,23 @@ License #include "surfaceFields.H" #include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField +Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : fixedGradientFvPatchScalarField(p, iF), - UName_("Undefined"), - phiName_("Undefined"), - rhoName_("Undefined"), + UName_("U"), + phiName_("phi"), + rhoName_("rho"), adjoint_(false) {} -fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField +Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( const fixedFluxPressureFvPatchScalarField& ptf, const fvPatch& p, @@ -67,7 +62,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField {} -fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField +Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -75,9 +70,9 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - UName_(dict.lookup("U")), - phiName_(dict.lookup("phi")), - rhoName_(dict.lookup("rho")), + UName_(dict.lookupOrDefault("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) adjoint_(dict.lookup("adjoint")) { if (dict.found("gradient")) @@ -94,7 +89,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField } -fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField +Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( const fixedFluxPressureFvPatchScalarField& wbppsf ) @@ -107,7 +102,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField {} -fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField +Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( const fixedFluxPressureFvPatchScalarField& wbppsf, const DimensionedField& iF @@ -123,7 +118,7 @@ fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void fixedFluxPressureFvPatchScalarField::updateCoeffs() +void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -133,8 +128,9 @@ void fixedFluxPressureFvPatchScalarField::updateCoeffs() const fvPatchField& Up = patch().lookupPatchField(UName_); - const surfaceScalarField& phi = + const surfaceScalarField& phi = db().lookupObject(phiName_); + fvsPatchField phip = patch().patchField(phi); @@ -162,12 +158,21 @@ void fixedFluxPressureFvPatchScalarField::updateCoeffs() } -void fixedFluxPressureFvPatchScalarField::write(Ostream& os) const +void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + if (UName_ != "U") + { + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (rhoName_ != "rho") + { + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + } os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl; gradient().writeEntry("gradient", os); } @@ -175,10 +180,13 @@ void fixedFluxPressureFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, fixedFluxPressureFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + fixedFluxPressureFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 2d2f6f204c..1df1c91969 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -75,19 +75,9 @@ flowRateInletVelocityFvPatchVectorField : fixedValueFvPatchField(p, iF, dict), flowRate_(readScalar(dict.lookup("flowRate"))), - phiName_("phi"), - rhoName_("rho") -{ - if (dict.found("phi")) - { - dict.lookup("phi") >> phiName_; - } - - if (dict.found("rho")) - { - dict.lookup("rho") >> rhoName_; - } -} + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) +{} Foam:: @@ -133,10 +123,8 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() vectorField n = patch().nf(); - const surfaceScalarField& phi = db().lookupObject - ( - phiName_ - ); + const surfaceScalarField& phi = + db().lookupObject(phiName_); if (phi.dimensions() == dimVelocity*dimArea) { @@ -170,20 +158,15 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField::write(os); - - os.writeKeyword("flowRate") << flowRate_ - << token::END_STATEMENT << nl; - + os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl; if (phiName_ != "phi") { os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; } - if (rhoName_ != "rho") { os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; } - writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C index 7082962d9f..2a858f4fa1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C @@ -32,12 +32,9 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -fluxCorrectedVelocityFvPatchVectorField:: +Foam::fluxCorrectedVelocityFvPatchVectorField:: fluxCorrectedVelocityFvPatchVectorField ( const fvPatch& p, @@ -50,7 +47,7 @@ fluxCorrectedVelocityFvPatchVectorField {} -fluxCorrectedVelocityFvPatchVectorField:: +Foam::fluxCorrectedVelocityFvPatchVectorField:: fluxCorrectedVelocityFvPatchVectorField ( const fluxCorrectedVelocityFvPatchVectorField& ptf, @@ -65,7 +62,7 @@ fluxCorrectedVelocityFvPatchVectorField {} -fluxCorrectedVelocityFvPatchVectorField:: +Foam::fluxCorrectedVelocityFvPatchVectorField:: fluxCorrectedVelocityFvPatchVectorField ( const fvPatch& p, @@ -81,7 +78,7 @@ fluxCorrectedVelocityFvPatchVectorField } -fluxCorrectedVelocityFvPatchVectorField:: +Foam::fluxCorrectedVelocityFvPatchVectorField:: fluxCorrectedVelocityFvPatchVectorField ( const fluxCorrectedVelocityFvPatchVectorField& fcvpvf, @@ -96,7 +93,7 @@ fluxCorrectedVelocityFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void fluxCorrectedVelocityFvPatchVectorField::evaluate +void Foam::fluxCorrectedVelocityFvPatchVectorField::evaluate ( const Pstream::commsTypes ) @@ -130,9 +127,12 @@ void fluxCorrectedVelocityFvPatchVectorField::evaluate } else { - FatalErrorIn("fluxCorrectedVelocityFvPatchVectorField::evaluate()") - << "dimensions of phi are not correct" - << "\n on patch " << this->patch().name() + FatalErrorIn + ( + "fluxCorrectedVelocityFvPatchVectorField::evaluate()" + ) + << "dimensions of phi are incorrect\n" + << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); @@ -140,25 +140,30 @@ void fluxCorrectedVelocityFvPatchVectorField::evaluate } -void fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const +void Foam::fluxCorrectedVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (rhoName_ != "rho") + { + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + } writeEntry("value", os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchVectorField, - fluxCorrectedVelocityFvPatchVectorField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + fluxCorrectedVelocityFvPatchVectorField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C index c41d207724..8031001a57 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutlet/inletOutletFvPatchField.C @@ -72,7 +72,7 @@ inletOutletFvPatchField::inletOutletFvPatchField ) : mixedFvPatchField(p, iF), - phiName_("phi") + phiName_(dict.lookupOrDefault("phi", "phi")) { this->refValue() = Field("inletValue", dict, p.size()); @@ -90,11 +90,6 @@ inletOutletFvPatchField::inletOutletFvPatchField this->refGrad() = pTraits::zero; this->valueFraction() = 0.0; - - if (dict.found("phi")) - { - dict.lookup("phi") >> phiName_; - } } @@ -150,8 +145,7 @@ void inletOutletFvPatchField::write(Ostream& os) const fvPatchField::write(os); if (phiName_ != "phi") { - os.writeKeyword("phi") - << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; } this->refValue().writeEntry("inletValue", os); this->writeEntry("value", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C index 0a2dff4a4c..255f3b4117 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C @@ -32,12 +32,9 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inletOutletTotalTemperatureFvPatchScalarField:: +Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const fvPatch& p, @@ -45,9 +42,9 @@ inletOutletTotalTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - UName_(), - phiName_(), - psiName_(), + UName_("U"), + phiName_("phi"), + psiName_("psi"), gamma_(0.0), T0_(p.size(), 0.0) { @@ -57,7 +54,7 @@ inletOutletTotalTemperatureFvPatchScalarField } -inletOutletTotalTemperatureFvPatchScalarField:: +Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& ptf, @@ -75,7 +72,7 @@ inletOutletTotalTemperatureFvPatchScalarField {} -inletOutletTotalTemperatureFvPatchScalarField:: +Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const fvPatch& p, @@ -84,9 +81,9 @@ inletOutletTotalTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - UName_(dict.lookup("U")), - phiName_(dict.lookup("phi")), - psiName_(dict.lookup("psi")), + UName_(dict.lookupOrDefault("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + psiName_(dict.lookupOrDefault("psi", "psi")), gamma_(readScalar(dict.lookup("gamma"))), T0_("T0", dict, p.size()) { @@ -108,7 +105,7 @@ inletOutletTotalTemperatureFvPatchScalarField } -inletOutletTotalTemperatureFvPatchScalarField:: +Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& tppsf @@ -123,7 +120,7 @@ inletOutletTotalTemperatureFvPatchScalarField {} -inletOutletTotalTemperatureFvPatchScalarField:: +Foam::inletOutletTotalTemperatureFvPatchScalarField:: inletOutletTotalTemperatureFvPatchScalarField ( const inletOutletTotalTemperatureFvPatchScalarField& tppsf, @@ -141,7 +138,7 @@ inletOutletTotalTemperatureFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void inletOutletTotalTemperatureFvPatchScalarField::autoMap +void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) @@ -151,7 +148,7 @@ void inletOutletTotalTemperatureFvPatchScalarField::autoMap } -void inletOutletTotalTemperatureFvPatchScalarField::rmap +void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr @@ -166,7 +163,7 @@ void inletOutletTotalTemperatureFvPatchScalarField::rmap } -void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs() +void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -192,13 +189,22 @@ void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs() } -void inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const +void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl; + if (UName_ != "U") + { + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "psi") + { + os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; + } + os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; T0_.writeEntry("T0", os); writeEntry("value", os); } @@ -206,14 +212,13 @@ void inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - inletOutletTotalTemperatureFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + inletOutletTotalTemperatureFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C index 99e07855ae..e950d87663 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C @@ -128,10 +128,8 @@ void Foam::massFlowRateInletVelocityFvPatchVectorField::updateCoeffs() vectorField n = patch().nf(); - const surfaceScalarField& phi = db().lookupObject - ( - phiName_ - ); + const surfaceScalarField& phi = + db().lookupObject(phiName_); if (phi.dimensions() == dimVelocity*dimArea) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C index 08c795f90b..1284b361aa 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C @@ -115,7 +115,7 @@ void movingWallVelocityFvPatchVectorField::updateCoeffs() vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaT().value(); const volVectorField& U = db().lookupObject("U"); - scalarField phip = + scalarField phip = p.patchField(fvc::meshPhi(U)); vectorField n = p.nf(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C index afbccbd03a..6784821e78 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletOutletVelocity/pressureDirectedInletOutletVelocityFvPatchVectorField.C @@ -196,8 +196,14 @@ void pressureDirectedInletOutletVelocityFvPatchVectorField:: write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (rhoName_ != "rho") + { + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + } inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C index fa9b68f545..4a0930f65d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureDirectedInletVelocity/pressureDirectedInletVelocityFvPatchVectorField.C @@ -184,8 +184,14 @@ void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs() void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (rhoName_ != "rho") + { + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + } inletDir_.writeEntry("inletDirection", os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C index fb80ec7db4..529ed22363 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletOutletVelocity/pressureInletOutletVelocityFvPatchVectorField.C @@ -80,15 +80,10 @@ pressureInletOutletVelocityFvPatchVectorField ) : directionMixedFvPatchVectorField(p, iF), - phiName_("phi") + phiName_(dict.lookupOrDefault("phi", "phi")) { fvPatchVectorField::operator=(vectorField("value", dict, p.size())); - if (dict.found("phi")) - { - dict.lookup("phi") >> phiName_; - } - if (dict.found("tangentialVelocity")) { setTangentialVelocity @@ -193,7 +188,10 @@ void pressureInletOutletVelocityFvPatchVectorField::updateCoeffs() void pressureInletOutletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } if (tangentialVelocity_.size()) { tangentialVelocity_.writeEntry("tangentialVelocity", os); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C index 75242aabb5..f4636e68a4 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureInletVelocity/pressureInletVelocityFvPatchVectorField.C @@ -109,10 +109,8 @@ void pressureInletVelocityFvPatchVectorField::updateCoeffs() return; } - const surfaceScalarField& phi = db().lookupObject - ( - phiName_ - ); + const surfaceScalarField& phi = + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); @@ -148,8 +146,14 @@ void pressureInletVelocityFvPatchVectorField::updateCoeffs() void pressureInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (tangentialVelocity_.size()) + { + tangentialVelocity_.writeEntry("tangentialVelocity", os); + } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C index 30b7b12ff7..9704a65ca9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressureNormalInletOutletVelocity/pressureNormalInletOutletVelocityFvPatchVectorField.C @@ -123,7 +123,7 @@ void pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs() } const surfaceScalarField& phi = - db().lookupObject(phiName_); + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C index fee0fa2bf2..51f5c01834 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/syringePressure/syringePressureFvPatchScalarField.C @@ -198,10 +198,8 @@ void syringePressureFvPatchScalarField::updateCoeffs() scalar t = db().time().value(); scalar deltaT = db().time().deltaT().value(); - const surfaceScalarField& phi = db().lookupObject - ( - "phi" - ); + const surfaceScalarField& phi = + db().lookupObject("phi"); const fvsPatchField& phip = patch().patchField(phi); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index d78f497e84..91473124c0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -95,7 +95,7 @@ timeVaryingMappedFixedValueFvPatchField { if (debug) { - Pout<< "timeVarying("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")), + psiName_(dict.lookupOrDefault("psi", "none")), gamma_(readScalar(dict.lookup("gamma"))), p0_(readScalar(dict.lookup("p0"))), - totalPressureTimeSeries_(dict) + timeSeries_(dict) { if (dict.found("value")) { @@ -97,7 +97,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField psiName_(ptf.psiName_), gamma_(ptf.gamma_), p0_(ptf.p0_), - totalPressureTimeSeries_(ptf.totalPressureTimeSeries_) + timeSeries_(ptf.timeSeries_) {} @@ -114,7 +114,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), p0_(tppsf.p0_), - totalPressureTimeSeries_(tppsf.totalPressureTimeSeries_) + timeSeries_(tppsf.timeSeries_) {} @@ -132,7 +132,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), p0_(tppsf.p0_), - totalPressureTimeSeries_(tppsf.totalPressureTimeSeries_) + timeSeries_(tppsf.timeSeries_) {} @@ -148,7 +148,7 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs return; } - p0_ = totalPressureTimeSeries_(this->db().time().timeOutputValue()); + p0_ = timeSeries_(this->db().time().timeOutputValue()); const fvsPatchField& phip = patch().lookupPatchField(phiName_); @@ -194,11 +194,11 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs ( "timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs()" ) << " rho or psi set inconsitently, rho = " << rhoName_ - << ", psi = " << psiName_ << '.' << nl + << ", psi = " << psiName_ << ".\n" << " Set either rho or psi or neither depending on the " - "definition of total pressure." << nl - << " Set the unused variables to 'none'." - << "\n on patch " << this->patch().name() + "definition of total pressure.\n" + << " Set the unused variables to 'none'.\n" + << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); @@ -218,13 +218,19 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField:: write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + if (UName_ != "U") + { + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; - os.writeKeyword("p0") << p0_ << token::END_STATEMENT << endl; - totalPressureTimeSeries_.write(os); + os.writeKeyword("p0") << p0_ << token::END_STATEMENT << nl; + timeSeries_.write(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H index 8d02bcefeb..53775789b0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.H @@ -77,8 +77,8 @@ class timeVaryingUniformTotalPressureFvPatchScalarField //- Total pressure scalar p0_; - //- Table of time vs total pressure - interpolationTable totalPressureTimeSeries_; + //- Table of time vs total pressure, including the bounding treatment + interpolationTable timeSeries_; public: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C index 881ebdad50..be3f8125b5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/totalPressure/totalPressureFvPatchScalarField.C @@ -32,28 +32,25 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -totalPressureFvPatchScalarField::totalPressureFvPatchScalarField +Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : fixedValueFvPatchScalarField(p, iF), - UName_("undefined"), - phiName_("undefined"), - rhoName_("undefined"), - psiName_("undefined"), + UName_("U"), + phiName_("phi"), + rhoName_("none"), + psiName_("none"), gamma_(0.0), p0_(p.size(), 0.0) {} -totalPressureFvPatchScalarField::totalPressureFvPatchScalarField +Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -61,10 +58,10 @@ totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - UName_(dict.lookup("U")), - phiName_(dict.lookup("phi")), - rhoName_(dict.lookup("rho")), - psiName_(dict.lookup("psi")), + UName_(dict.lookupOrDefault("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")), + psiName_(dict.lookupOrDefault("psi", "none")), gamma_(readScalar(dict.lookup("gamma"))), p0_("p0", dict, p.size()) { @@ -82,7 +79,7 @@ totalPressureFvPatchScalarField::totalPressureFvPatchScalarField } -totalPressureFvPatchScalarField::totalPressureFvPatchScalarField +Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ( const totalPressureFvPatchScalarField& ptf, const fvPatch& p, @@ -100,7 +97,7 @@ totalPressureFvPatchScalarField::totalPressureFvPatchScalarField {} -totalPressureFvPatchScalarField::totalPressureFvPatchScalarField +Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ( const totalPressureFvPatchScalarField& tppsf ) @@ -115,7 +112,7 @@ totalPressureFvPatchScalarField::totalPressureFvPatchScalarField {} -totalPressureFvPatchScalarField::totalPressureFvPatchScalarField +Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField ( const totalPressureFvPatchScalarField& tppsf, const DimensionedField& iF @@ -133,7 +130,7 @@ totalPressureFvPatchScalarField::totalPressureFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void totalPressureFvPatchScalarField::autoMap +void Foam::totalPressureFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) @@ -143,7 +140,7 @@ void totalPressureFvPatchScalarField::autoMap } -void totalPressureFvPatchScalarField::rmap +void Foam::totalPressureFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr @@ -158,7 +155,7 @@ void totalPressureFvPatchScalarField::rmap } -void totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up) +void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up) { if (updated()) { @@ -208,12 +205,12 @@ void totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up) FatalErrorIn ( "totalPressureFvPatchScalarField::updateCoeffs()" - ) << " rho or psi set inconsitently, rho = " << rhoName_ - << ", psi = " << psiName_ << '.' << nl + ) << " rho or psi set inconsistently, rho = " << rhoName_ + << ", psi = " << psiName_ << ".\n" << " Set either rho or psi or neither depending on the " "definition of total pressure." << nl - << " Set the unused variables to 'none'." - << "\n on patch " << this->patch().name() + << " Set the unused variable(s) to 'none'.\n" + << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); @@ -223,20 +220,26 @@ void totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up) } -void totalPressureFvPatchScalarField::updateCoeffs() +void Foam::totalPressureFvPatchScalarField::updateCoeffs() { updateCoeffs(patch().lookupPatchField(UName_)); } -void totalPressureFvPatchScalarField::write(Ostream& os) const +void Foam::totalPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + if (UName_ != "U") + { + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl; + os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; p0_.writeEntry("p0", os); writeEntry("value", os); } @@ -244,10 +247,13 @@ void totalPressureFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, totalPressureFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + totalPressureFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C index afa6a9dc49..d0b4137644 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/totalTemperature/totalTemperatureFvPatchScalarField.C @@ -32,27 +32,24 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField +Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF ) : fixedValueFvPatchScalarField(p, iF), - UName_("Undefined"), - phiName_("Undefined"), - psiName_("Undefined"), + UName_("U"), + phiName_("phi"), + psiName_("psi"), gamma_(0.0), T0_(p.size(), 0.0) {} -totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField +Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ( const totalTemperatureFvPatchScalarField& ptf, const fvPatch& p, @@ -69,7 +66,7 @@ totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField {} -totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField +Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -77,9 +74,9 @@ totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - UName_(dict.lookup("U")), - phiName_(dict.lookup("phi")), - psiName_(dict.lookup("psi")), + UName_(dict.lookupOrDefault("U", "U")), + phiName_(dict.lookupOrDefault("phi", "phi")), + psiName_(dict.lookupOrDefault("psi", "psi")), gamma_(readScalar(dict.lookup("gamma"))), T0_("T0", dict, p.size()) { @@ -97,7 +94,7 @@ totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField } -totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField +Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ( const totalTemperatureFvPatchScalarField& tppsf ) @@ -111,7 +108,7 @@ totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField {} -totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField +Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField ( const totalTemperatureFvPatchScalarField& tppsf, const DimensionedField& iF @@ -128,7 +125,7 @@ totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void totalTemperatureFvPatchScalarField::autoMap +void Foam::totalTemperatureFvPatchScalarField::autoMap ( const fvPatchFieldMapper& m ) @@ -138,7 +135,7 @@ void totalTemperatureFvPatchScalarField::autoMap } -void totalTemperatureFvPatchScalarField::rmap +void Foam::totalTemperatureFvPatchScalarField::rmap ( const fvPatchScalarField& ptf, const labelList& addr @@ -153,7 +150,7 @@ void totalTemperatureFvPatchScalarField::rmap } -void totalTemperatureFvPatchScalarField::updateCoeffs() +void Foam::totalTemperatureFvPatchScalarField::updateCoeffs() { if (updated()) { @@ -180,13 +177,22 @@ void totalTemperatureFvPatchScalarField::updateCoeffs() } -void totalTemperatureFvPatchScalarField::write(Ostream& os) const +void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; - os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl; + if (UName_ != "U") + { + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "phi") + { + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + } + if (phiName_ != "psi") + { + os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; + } + os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; T0_.writeEntry("T0", os); writeEntry("value", os); } @@ -194,10 +200,13 @@ void totalTemperatureFvPatchScalarField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, totalTemperatureFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + totalTemperatureFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C index 540a938f7d..b08c9a23f8 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C @@ -30,14 +30,9 @@ License #include "surfaceFields.H" #include "volFields.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -turbulentIntensityKineticEnergyInletFvPatchScalarField:: +Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField ( const fvPatch& p, @@ -48,7 +43,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField intensity_(0.05) {} -turbulentIntensityKineticEnergyInletFvPatchScalarField:: +Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField ( const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf, @@ -61,7 +56,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField intensity_(ptf.intensity_) {} -turbulentIntensityKineticEnergyInletFvPatchScalarField:: +Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField ( const fvPatch& p, @@ -90,7 +85,7 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField } } -turbulentIntensityKineticEnergyInletFvPatchScalarField:: +Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField ( const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf @@ -100,7 +95,8 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField intensity_(ptf.intensity_) {} -turbulentIntensityKineticEnergyInletFvPatchScalarField:: + +Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField ( const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf, @@ -114,7 +110,8 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void turbulentIntensityKineticEnergyInletFvPatchScalarField::updateCoeffs() +void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: +updateCoeffs() { if (updated()) { @@ -130,7 +127,7 @@ void turbulentIntensityKineticEnergyInletFvPatchScalarField::updateCoeffs() } -void turbulentIntensityKineticEnergyInletFvPatchScalarField::write +void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write ( Ostream& os ) const @@ -143,15 +140,13 @@ void turbulentIntensityKineticEnergyInletFvPatchScalarField::write // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchScalarField, - turbulentIntensityKineticEnergyInletFvPatchScalarField -); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + turbulentIntensityKineticEnergyInletFvPatchScalarField + ); +} // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C index eb255068b1..acff82ef2f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/waveTransmissive/waveTransmissiveFvPatchField.C @@ -47,7 +47,7 @@ waveTransmissiveFvPatchField::waveTransmissiveFvPatchField ) : advectiveFvPatchField(p, iF), - psiName_("Undefined"), + psiName_("psi"), gamma_(0.0) {} @@ -76,7 +76,7 @@ waveTransmissiveFvPatchField::waveTransmissiveFvPatchField ) : advectiveFvPatchField(p, iF, dict), - psiName_(dict.lookup("psi")), + psiName_(dict.lookupOrDefault("psi", "psi")), gamma_(readScalar(dict.lookup("gamma"))) {} @@ -119,7 +119,7 @@ tmp waveTransmissiveFvPatchField::advectionSpeed() const reinterpret_cast(NULL) ); - const surfaceScalarField& phi = + const surfaceScalarField& phi = this->db().objectRegistry::lookupObject (this->phiName_); @@ -153,22 +153,27 @@ template void waveTransmissiveFvPatchField::write(Ostream& os) const { fvPatchField::write(os); - os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl; - if (this->rhoName_ != "Undefined") + if (this->phiName_ != "phi") + { + os.writeKeyword("phi") << this->phiName_ << token::END_STATEMENT << nl; + } + if (this->rhoName_ != "rho") { os.writeKeyword("rho") << this->rhoName_ << token::END_STATEMENT << nl; } - - os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; - os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl; + if (psiName_ != "psi") + { + os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; + } + os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; if (this->lInf_ > SMALL) { os.writeKeyword("fieldInf") << this->fieldInf_ - << token::END_STATEMENT << endl; - os.writeKeyword("lInf") << this->lInf_ - << token::END_STATEMENT << endl; + << token::END_STATEMENT << nl; + os.writeKeyword("lInf") << this->lInf_ + << token::END_STATEMENT << nl; } this->writeEntry("value", os); From 99628401f4b5b2820fce0976c1a68f01ce2920a9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 19 Sep 2008 13:12:32 +0200 Subject: [PATCH 002/113] use dictionary::lookupOrDefault to simplify some code --- .../T/smoluchowskiJumpTFvPatchScalarField.C | 19 +++------- .../general/include/readPIMPLEControls.H | 21 ++++------- .../general/include/readPISOControls.H | 36 ++++++------------- .../general/include/readSIMPLEControls.H | 29 +++++---------- .../general/include/readTimeControls.H | 8 ++--- .../EulerCoordinateRotation.C | 8 +---- .../STARCDCoordinateRotation.C | 8 +---- 7 files changed, 35 insertions(+), 94 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index a1347365f5..101c41a353 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -77,13 +77,13 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField : mixedFvPatchScalarField(p, iF), accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))), - Twall_("Twall", dict, p.size()) + Twall_("Twall", dict, p.size()), + gamma_(dict.lookupOrDefault("gamma", 1.4)) { if ( mag(accommodationCoeff_) < SMALL - || - mag(accommodationCoeff_) > 2.0 + || mag(accommodationCoeff_) > 2.0 ) { FatalIOErrorIn @@ -96,8 +96,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField " const dictionary&" ")", dict - ) << "unphysical accommodationCoeff_ specified" - << "(0 < accommodationCoeff_ <= 1)" << endl + ) << "unphysical accommodationCoeff specified" + << "(0 < accommodationCoeff <= 1)" << endl << exit(FatalError); } @@ -113,15 +113,6 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField fvPatchField::operator=(patchInternalField()); } - if (dict.found("gamma")) - { - gamma_ = readScalar(dict.lookup("gamma")); - } - else - { - gamma_ = 1.4; - } - refValue() = *this; refGrad() = 0.0; valueFraction() = 0.0; diff --git a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H index fe3ccd324b..9de98ee20b 100644 --- a/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPIMPLEControls.H @@ -3,20 +3,11 @@ int nOuterCorr(readInt(pimple.lookup("nOuterCorrectors"))); int nCorr(readInt(pimple.lookup("nCorrectors"))); - int nNonOrthCorr = 0; - if (pimple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(pimple.lookup("nNonOrthogonalCorrectors")); - } + int nNonOrthCorr = + pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = true; - if (pimple.found("momentumPredictor")) - { - momentumPredictor = Switch(pimple.lookup("momentumPredictor")); - } + bool momentumPredictor = + pimple.lookupOrDefault("momentumPredictor", true); - bool transonic = false; - if (pimple.found("transonic")) - { - transonic = Switch(pimple.lookup("transonic")); - } + bool transonic = + pimple.lookupOrDefault("transonic", false); diff --git a/src/finiteVolume/cfdTools/general/include/readPISOControls.H b/src/finiteVolume/cfdTools/general/include/readPISOControls.H index e51ecdbb8b..5f14c2bcae 100644 --- a/src/finiteVolume/cfdTools/general/include/readPISOControls.H +++ b/src/finiteVolume/cfdTools/general/include/readPISOControls.H @@ -2,32 +2,18 @@ int nCorr(readInt(piso.lookup("nCorrectors"))); - int nNonOrthCorr = 0; - if (piso.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors")); - } + int nNonOrthCorr = + piso.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = true; - if (piso.found("momentumPredictor")) - { - momentumPredictor = Switch(piso.lookup("momentumPredictor")); - } + bool momentumPredictor = + piso.lookupOrDefault("momentumPredictor", true); - bool transonic = false; - if (piso.found("transonic")) - { - transonic = Switch(piso.lookup("transonic")); - } + bool transonic = + piso.lookupOrDefault("transonic", false); - int nOuterCorr = 1; - if (piso.found("nOuterCorrectors")) - { - nOuterCorr = readInt(piso.lookup("nOuterCorrectors")); - } + int nOuterCorr = + piso.lookupOrDefault("nOuterCorrectors", 1); + + bool ddtPhiCorr = + piso.lookupOrDefault("ddtPhiCorr", false); - bool ddtPhiCorr = false; - if (piso.found("ddtPhiCorr")) - { - ddtPhiCorr = Switch(piso.lookup("ddtPhiCorr")); - } diff --git a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H index 44c1eef780..b3ea4bf674 100644 --- a/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H +++ b/src/finiteVolume/cfdTools/general/include/readSIMPLEControls.H @@ -1,25 +1,14 @@ dictionary simple = mesh.solutionDict().subDict("SIMPLE"); - int nNonOrthCorr = 0; - if (simple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); - } + int nNonOrthCorr = + simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - bool momentumPredictor = true; - if (simple.found("momentumPredictor")) - { - momentumPredictor = Switch(simple.lookup("momentumPredictor")); - } + bool momentumPredictor = + simple.lookupOrDefault("momentumPredictor", true); - bool fluxGradp = false; - if (simple.found("fluxGradp")) - { - fluxGradp = Switch(simple.lookup("fluxGradp")); - } + bool fluxGradp = + simple.lookupOrDefault("fluxGradp", false); + + bool transonic = + simple.lookupOrDefault("transonic", false); - bool transonic = false; - if (simple.found("transonic")) - { - transonic = Switch(simple.lookup("transonic")); - } diff --git a/src/finiteVolume/cfdTools/general/include/readTimeControls.H b/src/finiteVolume/cfdTools/general/include/readTimeControls.H index 0f92947b62..34e805aadc 100644 --- a/src/finiteVolume/cfdTools/general/include/readTimeControls.H +++ b/src/finiteVolume/cfdTools/general/include/readTimeControls.H @@ -40,11 +40,7 @@ scalar maxCo readScalar(runTime.controlDict().lookup("maxCo")) ); -scalar maxDeltaT = GREAT; - -if (runTime.controlDict().found("maxDeltaT")) -( - maxDeltaT = readScalar(runTime.controlDict().lookup("maxDeltaT")) -); +scalar maxDeltaT = + runTime.controlDict().lookupOrDefault("maxDeltaT", GREAT); // ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C index d3afa3021f..00828a0db8 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C @@ -133,18 +133,12 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation { vector rotation(dict.lookup("rotation")); - bool inDegrees = true; - if (dict.found("degrees")) - { - inDegrees = Switch(dict.lookup("degrees")); - } - calcTransform ( rotation.component(vector::X), rotation.component(vector::Y), rotation.component(vector::Z), - inDegrees + dict.lookupOrDefault("degrees", true) ); } diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C index 8ea78b3827..a8f03d5f89 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C @@ -134,18 +134,12 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation { vector rotation(dict.lookup("rotation")); - bool inDegrees = true; - if (dict.found("degrees")) - { - inDegrees = Switch(dict.lookup("degrees")); - } - calcTransform ( rotation.component(vector::X), rotation.component(vector::Y), rotation.component(vector::Z), - inDegrees + dict.lookupOrDefault("degrees", true) ); } From d5d80f0181f7b9ba8420eb00fcd15e463037709c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 19 Sep 2008 14:47:06 +0200 Subject: [PATCH 003/113] modified remaining Allwmake scripts to run from anywhere --- applications/solvers/compressible/rhoCentralFoam/Allwmake | 3 +++ applications/solvers/compressible/rhopSonicFoam/Allwmake | 3 +++ applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake | 3 +++ applications/utilities/mesh/conversion/Optional/Allwmake | 3 +-- applications/utilities/mesh/generation/extrudeMesh/Allwmake | 2 ++ applications/utilities/mesh/manipulation/setSet/Allwmake | 3 +++ .../utilities/postProcessing/graphics/PV3FoamReader/Allwmake | 2 ++ .../utilities/postProcessing/graphics/PVFoamReader/Allwmake | 3 +++ .../postProcessing/graphics/ensightFoamReader/Allwmake | 4 ++++ doc/Doxygen/Allwmake | 1 + src/Pstream/Allwmake | 2 ++ src/conversion/Allwmake | 3 +++ src/decompositionAgglomeration/Allwmake | 1 + src/lagrangian/Allwmake | 2 ++ src/postProcessing/Allwmake | 3 ++- src/thermophysicalModels/Allwmake | 2 ++ src/transportModels/Allwmake | 5 ++++- src/turbulenceModels/Allwmake | 3 +++ src/turbulenceModels/LES/Allwmake | 3 +++ src/turbulenceModels/RAS/Allwmake | 3 +++ 20 files changed, 50 insertions(+), 4 deletions(-) diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwmake b/applications/solvers/compressible/rhoCentralFoam/Allwmake index 69a108d537..698558da0b 100755 --- a/applications/solvers/compressible/rhoCentralFoam/Allwmake +++ b/applications/solvers/compressible/rhoCentralFoam/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x wmake libso BCs wmake +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/compressible/rhopSonicFoam/Allwmake b/applications/solvers/compressible/rhopSonicFoam/Allwmake index cccfd63757..698558da0b 100755 --- a/applications/solvers/compressible/rhopSonicFoam/Allwmake +++ b/applications/solvers/compressible/rhopSonicFoam/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso BCs wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake b/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake index 8314bfa069..29294d166a 100755 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake @@ -1,7 +1,10 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso phaseModel wmake libso interfacialModels wmake libso kineticTheoryModels wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake index 2db40f48ad..2734e41562 100755 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ b/applications/utilities/mesh/conversion/Optional/Allwmake @@ -2,7 +2,6 @@ # # Build optional components (eg, may depend on third-party libraries) # ----------------------------------------------------------------------------- - cd ${0%/*} || exit 1 # run from this directory set -x @@ -18,4 +17,4 @@ then wmake ccm26ToFoam fi -# end +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/extrudeMesh/Allwmake b/applications/utilities/mesh/generation/extrudeMesh/Allwmake index 876125ce82..871cad2b68 100755 --- a/applications/utilities/mesh/generation/extrudeMesh/Allwmake +++ b/applications/utilities/mesh/generation/extrudeMesh/Allwmake @@ -1,6 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso extrudeModel wmake +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/manipulation/setSet/Allwmake b/applications/utilities/mesh/manipulation/setSet/Allwmake index 35e3af7c1b..e10d037cbc 100755 --- a/applications/utilities/mesh/manipulation/setSet/Allwmake +++ b/applications/utilities/mesh/manipulation/setSet/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory READLINE=0 if [ -f /usr/include/readline/readline.h ]; then @@ -9,3 +10,5 @@ if [ -f /usr/include/readline/readline.h ]; then fi export READLINE wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake index a7e703b8c0..c7a80fc7fb 100755 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake @@ -17,3 +17,5 @@ then ;; esac fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake index ea67e28d5b..b1106aa608 100755 --- a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] @@ -16,3 +17,5 @@ then ;; esac fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake index aca3e014c9..f29cdda208 100755 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake @@ -1,2 +1,6 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + wmake libso + +# ----------------------------------------------------------------- end-of-file diff --git a/doc/Doxygen/Allwmake b/doc/Doxygen/Allwmake index 7f9ccb0522..dab44579b8 100755 --- a/doc/Doxygen/Allwmake +++ b/doc/Doxygen/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x umask 22 diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index eb51ef379e..4398b810f9 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso dummy @@ -18,3 +19,4 @@ GAMMA) ;; esac +# ----------------------------------------------------------------- end-of-file diff --git a/src/conversion/Allwmake b/src/conversion/Allwmake index 72e9c2b141..a7168eeab1 100755 --- a/src/conversion/Allwmake +++ b/src/conversion/Allwmake @@ -1,4 +1,7 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso + +# ----------------------------------------------------------------- end-of-file diff --git a/src/decompositionAgglomeration/Allwmake b/src/decompositionAgglomeration/Allwmake index 62018ac3fc..144244776f 100755 --- a/src/decompositionAgglomeration/Allwmake +++ b/src/decompositionAgglomeration/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso decompositionMethods diff --git a/src/lagrangian/Allwmake b/src/lagrangian/Allwmake index 0a5e86bdef..a3aa179490 100755 --- a/src/lagrangian/Allwmake +++ b/src/lagrangian/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso basic @@ -8,3 +9,4 @@ wmake libso dieselSpray (cd molecularDynamics && wmake libso potential) (cd molecularDynamics && wmake libso molecule) +# ----------------------------------------------------------------- end-of-file diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake index a7b00e35a3..f67ba57aa1 100755 --- a/src/postProcessing/Allwmake +++ b/src/postProcessing/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libo postCalc @@ -6,4 +7,4 @@ wmake libso forces wmake libso fieldAverage wmake libso foamCalcFunctions - +# ----------------------------------------------------------------- end-of-file diff --git a/src/thermophysicalModels/Allwmake b/src/thermophysicalModels/Allwmake index 69a99a09ad..62175e440f 100755 --- a/src/thermophysicalModels/Allwmake +++ b/src/thermophysicalModels/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso specie @@ -16,3 +17,4 @@ wmake libso pdfs wmake libso radiation wmake libso barotropicCompressibilityModel +# ----------------------------------------------------------------- end-of-file diff --git a/src/transportModels/Allwmake b/src/transportModels/Allwmake index fed5ed5fc1..7272653e0d 100755 --- a/src/transportModels/Allwmake +++ b/src/transportModels/Allwmake @@ -1,6 +1,9 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso incompressible wmake libso interfaceProperties -#wmake libso compressible +# wmake libso compressible + +# ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/Allwmake b/src/turbulenceModels/Allwmake index a05e81fc00..b4633551ac 100755 --- a/src/turbulenceModels/Allwmake +++ b/src/turbulenceModels/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x ( cd RAS && ./Allwmake ) ( cd LES && ./Allwmake ) + +# ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/LES/Allwmake b/src/turbulenceModels/LES/Allwmake index a8a3a782d0..bd99dd1f4e 100755 --- a/src/turbulenceModels/LES/Allwmake +++ b/src/turbulenceModels/LES/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso LESfilters @@ -6,3 +7,5 @@ wmakeLnInclude incompressible wmake libso LESdeltas wmake libso incompressible wmake libso compressible + +# ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/RAS/Allwmake b/src/turbulenceModels/RAS/Allwmake index 5ccba2b371..5761ba6ffd 100755 --- a/src/turbulenceModels/RAS/Allwmake +++ b/src/turbulenceModels/RAS/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso incompressible wmake libso compressible + +# ----------------------------------------------------------------- end-of-file From 905b6ebfb2deb869a2ae7e924a8104e5c3321176 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 2 Oct 2008 12:20:08 +0200 Subject: [PATCH 004/113] wmakeScheduler: prefix non-coloured output with hostname; cosmetic changes --- wmake/wmakeScheduler | 181 +++++++++++++++++++++++++------------------ 1 file changed, 104 insertions(+), 77 deletions(-) diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler index 2a2ed0fd76..a4c88624ab 100755 --- a/wmake/wmakeScheduler +++ b/wmake/wmakeScheduler @@ -57,14 +57,15 @@ lockDir=$HOME/.wmakeScheduler # count the total number of slots available and exit if [ "$1" = "-count" ] then - expr $( - for slotGroup in $WM_HOSTS - do - n=${slotGroup##*:} - if [ "$n" = "${slotGroup%%:*}" ]; then n=1; fi # missing ':' - echo "+ ${n:-1}" - done) - exit 0 + expr $( + for slotGroup in $WM_HOSTS + do + n=${slotGroup##*:} + [ "$n" = "${slotGroup%%:*}" ] && n=1 # missing ':' + echo "+ ${n:-1}" + done + ) + exit 0 fi # where to source WM_PROJECT settings in a remote shell @@ -75,25 +76,26 @@ fi sourceFoam=false # fallback command case $SHELL in */csh | */tcsh ) # [t]csh vs bash|ksh|sh - shellRc=cshrc - ;; + shellRc=cshrc + ;; *) - shellRc=bashrc - ;; + shellRc=bashrc + ;; esac # check ~/.$WM_PROJECT/$WM_PROJECT_VERSION/ # check ~/.$WM_PROJECT/ # check /etc/ -if [ "$WM_PROJECT" ]; then - +if [ "$WM_PROJECT" ] +then for i in \ $HOME/.$WM_PROJECT/$WM_PROJECT_VERSION \ $HOME/.$WM_PROJECT \ $WM_PROJECT_DIR/etc \ ; do - if [ -f "$i/$shellRc" ]; then + if [ -f "$i/$shellRc" ] + then sourceFoam="$i/$shellRc" break fi @@ -105,7 +107,8 @@ fi # attempt to preserve the installation directory 'FOAM_INST_DIR' case $sourceFoam in */bashrc) - if [ "$FOAM_INST_DIR" ]; then + if [ "$FOAM_INST_DIR" ] + then sourceFoam='[ "$WM_PROJECT" ] || '"FOAM_INST_DIR=$FOAM_INST_DIR . $sourceFoam" else sourceFoam='[ "$WM_PROJECT" ] || '". $sourceFoam" @@ -125,25 +128,50 @@ rcmd=$(echo $* | sed -e s/\"/\'\"\'/g) # Convert WM_COLOURS into an array -declare colours +declare colourList nColours=0 for col in $WM_COLOURS do - colours[$nColours]=$col - ((nColours = $nColours + 1)) + colourList[$nColours]=$col + ((nColours = $nColours + 1)) done -# Bashism: make pipe fail early. This make sure return value of compilation -# is returned and not of colouring pipe. +# Bashism: make pipe fail early. +# This ensures the return value of the command is returned and not of the +# colouring pipe etc. set -o pipefail -# Define function to colour output by argument 1 -colourPipe(){ - if [ "$1" ]; then - (while read line; do setterm -foreground $1; echo "$line" ; done; setterm -foreground default) - else - cat - fi + +# +# colour output by argument 1 +# +colourPipe() +{ + if [ "$1" ] + then + ( + while read line + do + setterm -foreground $1 + echo "$line" + done + setterm -foreground default + ) + else + cat + fi +} + + +# +# prefix message with [HOSTNAME] +# +prefixPipe() +{ + while read line + do + echo "[$@] $line" + done } @@ -151,61 +179,60 @@ colourIndex=0 while : do - for slotGroup in $WM_HOSTS - do - # split 'host:N', but catch 'host:' and 'host' too - host=${slotGroup%%:*} - n=${slotGroup##*:} - if [ "$n" = "$host" ]; then n=1; fi # missing ':' - : ${n:=1} + for slotGroup in $WM_HOSTS + do + # split 'host:N', but catch 'host:' and 'host' too + host=${slotGroup%%:*} + n=${slotGroup##*:} + [ "$n" = "$host" ] && n=1 # missing ':' + : ${n:=1} - i=0 - while [ "$i" -lt "$n" ] - do - lockFile="$lockDir/$host:$i" - if lockfile -r0 "$lockFile" 2>/dev/null; then - if [ "$WM_COLOURS" ]; then - # Set colour - colour="${colours[$colourIndex]}" + i=0 + while [ "$i" -lt "$n" ] + do + lockFile="$lockDir/$host:$i" + if lockfile -r0 "$lockFile" 2>/dev/null + then + if [ "$nColours" -gt 0 ] + then + # Set colour and index to next colour + colour="${colourList[$colourIndex]}" + colourIndex=$(expr $colourIndex + 1) + [ "$colourIndex" -lt "$nColours" ] || colourIndex=0 - if [ "$host" = "$HOST" ]; then - eval $* 2>&1 | colourPipe "$colour" - elif [ -n "$JOB_ID" ]; then - qrsh -inherit -v PWD $host "$rcmd" - else - ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour" - fi - retval=$? - else - if [ "$host" = "$HOST" ]; then - eval $* - elif [ -n "$JOB_ID" ]; then - qrsh -inherit -v PWD $host "$rcmd" - else - ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" - fi - retval=$? - fi - - # Release lock - rm -f "$lockFile" 2>/dev/null - exit $retval + if [ "$host" = "$HOST" ]; then + eval $* 2>&1 | colourPipe "$colour" + elif [ -n "$JOB_ID" ]; then + qrsh -inherit -v PWD $host "$rcmd" + else + ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour" + fi + retval=$? + else + if [ "$host" = "$HOST" ]; then + eval $* 2>&1 | prefixPipe "$host" + elif [ -n "$JOB_ID" ]; then + qrsh -inherit -v PWD $host "$rcmd" | prefixPipe "$host" + else + ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | prefixPipe "$host" + fi + retval=$? fi - i=$(expr $i + 1) - # Cycle through colours - colourIndex=$(expr $colourIndex + 1) - if (( $colourIndex >= $nColours )); then - colourIndex=0 - fi - done - done - # Did not find any free slots. Rest a bit. - sleep 1 + # Release lock + rm -f "$lockFile" 2>/dev/null + exit $retval + fi + i=$(expr $i + 1) + done + done + # Did not find any free slots. Rest a bit. + sleep 1 done -if [ "$WM_COLOURS" ]; then - setterm -foreground default +if [ "$nColours" -gt 0 ] +then + setterm -foreground default fi #------------------------------------------------------------------------------ From 6437f3dbada3fe5fc3937774b92468253bc081dc Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Oct 2008 09:09:30 +0200 Subject: [PATCH 005/113] UList cosmetic change --- src/OpenFOAM/containers/Lists/UList/UListIO.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index 24f824cd79..2981634163 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -60,7 +60,7 @@ void Foam::UList::writeEntry(const word& keyword, Ostream& os) const template -Foam::Ostream& Foam:: operator<<(Foam::Ostream& os, const Foam::UList& L) +Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList& L) { // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous()) From 9f107b6a01e6ee49841e5527b68f58750c4c920e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Oct 2008 10:05:02 +0200 Subject: [PATCH 006/113] settings.sh - bugfix - let _foamAddPath and _foamAddLib handle ':'-separated variables This unfortunately gets the order backwards, but at least doesn't try making really stupid directory names TODO: - settings.csh still has the same bug - perhaps _foamAddExistingLib function (or with a switch) to avoid the mkdir --- etc/settings.sh | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/etc/settings.sh b/etc/settings.sh index 743d8e1fc0..6c05f9f44e 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -33,22 +33,40 @@ _foamAddPath() { - while [ $# -ge 1 ] - do - [ -d $1 ] || mkdir -p $1 - export PATH=$1:$PATH - shift - done + if [ $# -eq 1 ] + then + oldIFS="$IFS" + IFS=':' # split on ':' + set -- $1 + IFS="$oldIFS" + unset oldIFS + fi + + while [ $# -ge 1 ] + do + [ -d $1 ] || mkdir -p $1 + export PATH=$1:$PATH + shift + done } _foamAddLib() { - while [ $# -ge 1 ] - do - [ -d $1 ] || mkdir -p $1 - export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH - shift - done + if [ $# -eq 1 ] + then + oldIFS="$IFS" + IFS=':' # split on ':' + set -- $1 + IFS="$oldIFS" + unset oldIFS + fi + + while [ $# -ge 1 ] + do + [ -d $1 ] || mkdir -p $1 + export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH + shift + done } @@ -99,7 +117,6 @@ case "$WM_COMPILER_INST" in OpenFOAM) case "$WM_COMPILER" in Gcc) - #export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib @@ -127,7 +144,7 @@ esac if [ -d "$WM_COMPILER_BIN" ]; then _foamAddPath $WM_COMPILER_BIN - _foamAddLib $WM_COMPILER_LIB + _foamAddLib $WM_COMPILER_LIB fi unset WM_COMPILER_BIN WM_COMPILER_LIB From 1da63f2237dd89b5ca17a60734ed21a3509e4621 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Oct 2008 10:33:33 +0200 Subject: [PATCH 007/113] update to gmp-4.2.4 --- etc/settings.csh | 3 +-- etc/settings.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/etc/settings.csh b/etc/settings.csh index cfa1927ef2..905163f496 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -82,10 +82,9 @@ switch ("$WM_COMPILER_INST") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: - #setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib - _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib breaksw case Gcc42: setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH diff --git a/etc/settings.sh b/etc/settings.sh index 6c05f9f44e..51b540dc84 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -119,7 +119,7 @@ OpenFOAM) Gcc) export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib - _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib ;; Gcc42) export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH From 27fce4fa4e451214a638aa38a048e542458a978f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Oct 2008 11:06:44 +0200 Subject: [PATCH 008/113] added draft of xfer class - A simple container for objects of type \ that can be used for transferring the contents rather than copying them. - The wrapped object of type \ must implement a transfer() method. --- src/OpenFOAM/containers/misc/xfer.H | 157 +++++++++++++++++++++++++++ src/OpenFOAM/containers/misc/xferI.H | 151 ++++++++++++++++++++++++++ 2 files changed, 308 insertions(+) create mode 100644 src/OpenFOAM/containers/misc/xfer.H create mode 100644 src/OpenFOAM/containers/misc/xferI.H diff --git a/src/OpenFOAM/containers/misc/xfer.H b/src/OpenFOAM/containers/misc/xfer.H new file mode 100644 index 0000000000..41de52a43d --- /dev/null +++ b/src/OpenFOAM/containers/misc/xfer.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::xfer + +Description + A simple container for objects of type \ that can be used for + transferring the contents rather than copying them. + + The wrapped object of type \ must implement a transfer() method. + +SourceFiles + xferI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef xfer_H +#define xfer_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class Istream; +class Ostream; + +// Forward declaration of friend functions and operators +template class xfer; + +template Istream& operator>>(Istream&, xfer&); +template Ostream& operator<<(Ostream&, const xfer&); + + +/*---------------------------------------------------------------------------*\ + Class xfer Declaration +\*---------------------------------------------------------------------------*/ + +template +class xfer +{ + // Private data + + //- Reference to the underlying datatype + T& ref_; + + // Private Member Functions + + //- Disallow default bitwise copy construct + xfer(const xfer&); + + //- Disallow default bitwise assignment + void operator=(const xfer&); + +public: + + // Constructors + + //- Construct null, delaying the transfer to later + inline xfer(); + + //- Construct by transferring the parameter into this object + inline xfer(T&); + + //- Construct by transferring the parameter into this object + inline xfer(xfer&); + + // Destructor + + inline ~xfer(); + + // Member Functions + + //- Access to the underlying datatype + inline T& ref(); + + //- Transfer the contents of the parameter into this object + inline void transfer(T&); + + //- Transfer the contents of the parameter into this object + inline void transfer(xfer&); + + //- Transfer the contents from this object to the parameter + inline void yield(T&); + + //- Transfer the contents from this object to the parameter + inline void yield(xfer&); + + // Member Operators + + //- Transfer the contents into this object + inline void operator=(T&); + + //- Transfer the contents into this object + inline void operator=(xfer&); + + //- Return a non-const reference to const object + // Useful for read-constructors where the argument is temporary + inline xfer& operator()() const; + + + // Istream operator + + //- Read from Istream, discarding current contents + friend Istream& operator>> + #ifndef __CINT__ + + #endif + (Istream&, xfer&); + + // Ostream operator + + //- Write to Ostream + friend Ostream& operator<< + #ifndef __CINT__ + + #endif + (Ostream&, const xfer&); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "xferI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/misc/xferI.H b/src/OpenFOAM/containers/misc/xferI.H new file mode 100644 index 0000000000..a1bd4cd7f3 --- /dev/null +++ b/src/OpenFOAM/containers/misc/xferI.H @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::xfer::xfer() +: + ref_() +{} + + +template +Foam::xfer::xfer(T& t) +: + ref_() +{ + transfer(t); +} + + +template +Foam::xfer::xfer(xfer& t) +: + ref_() +{ + transfer(t); +} + + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::xfer::~xfer() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +T& Foam::xfer::ref() +{ + return ref_; +} + + +template +void Foam::xfer::transfer(T& t) +{ + ref_.transfer(t); +} + + +template +void Foam::xfer::transfer(xfer& t) +{ + ref_.transfer(t.ref_); +} + + +template +void Foam::xfer::yield(T& t) +{ + t.transfer(ref_); +} + + +template +void Foam::xfer::yield(xfer& t) +{ + t.ref_.transfer(ref_); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + + +template +void Foam::xfer::operator=(T& t) +{ + transfer(t); +} + + +template +void Foam::xfer::operator=(xfer& t) +{ + if (this == &t) + { + FatalErrorIn + ( + "Foam::xfer::operator=" + "(const Foam::xfer&)" + ) << "Attempted assignment to self" + << abort(FatalError); + } + + transfer(t); +} + + +template +Foam::xfer& Foam::xfer::operator()() const +{ + return const_cast&>(*this); +} + + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +Foam::Istream& Foam::operator>>(Istream& is, xfer& t) +{ + is >> t.ref_; + return is; +} + + +template +Foam::Ostream& Foam::operator<<(Ostream& os, const xfer& t) +{ + os << t.ref_; + return os; +} + +// ************************************************************************* // From eb73c6925b201c7066caa7fe6c2a2edbc2e540ae Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Oct 2008 11:08:53 +0200 Subject: [PATCH 009/113] Added xfer constructors for the various list-types --- .../containers/Lists/CompactListList/CompactListList.C | 6 ++++++ .../containers/Lists/CompactListList/CompactListList.H | 3 +++ src/OpenFOAM/containers/Lists/List/List.C | 8 ++++++++ src/OpenFOAM/containers/Lists/List/List.H | 4 ++++ src/OpenFOAM/containers/Lists/PackedList/PackedList.C | 8 ++++++++ src/OpenFOAM/containers/Lists/PackedList/PackedList.H | 3 +++ src/OpenFOAM/containers/Lists/PtrList/PtrList.C | 7 +++++++ src/OpenFOAM/containers/Lists/PtrList/PtrList.H | 3 +++ src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C | 7 +++++++ src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H | 3 +++ 10 files changed, 52 insertions(+) diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C index 9be79966c6..f6d8cb6218 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C @@ -92,6 +92,12 @@ CompactListList::CompactListList(const UList