diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H index f6371c47cb..82ac8a2fd2 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/readPIMPLEControls.H @@ -1,9 +1,9 @@ // We do not have a top-level mesh. Construct the fvSolution for // the runTime instead. + runTime.readOpt() = IOobject::MUST_READ_IF_MODIFIED; fvSolution solutionDict(runTime); const dictionary& pimple = solutionDict.subDict("PIMPLE"); const int nOuterCorr = pimple.lookupOrDefault("nOuterCorrectors", 1); - diff --git a/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/porousSimpleFoam.C b/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/porousSimpleFoam.C index 6140eb1718..3507fded85 100644 --- a/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/porousSimpleFoam.C +++ b/applications/solvers/incompressible/simpleFoam/porousSimpleFoam/porousSimpleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/multiphase/bubbleFoam/UEqns.H b/applications/solvers/multiphase/bubbleFoam/UEqns.H index 82d53d84b0..3239df21cb 100644 --- a/applications/solvers/multiphase/bubbleFoam/UEqns.H +++ b/applications/solvers/multiphase/bubbleFoam/UEqns.H @@ -2,7 +2,7 @@ fvVectorMatrix UaEqn(Ua, Ua.dimensions()*dimVol/dimTime); fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); { - volTensorField Rca(-nuEffa*(fvc::grad(Ua)().T())); + volTensorField Rca(-nuEffa*(T(fvc::grad(Ua)))); Rca = Rca + (2.0/3.0)*sqr(Ct)*I*k - (2.0/3.0)*I*tr(Rca); surfaceScalarField phiRa @@ -36,7 +36,7 @@ fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); UaEqn.relax(); - volTensorField Rcb(-nuEffb*fvc::grad(Ub)().T()); + volTensorField Rcb(-nuEffb*T(fvc::grad(Ub))); Rcb = Rcb + (2.0/3.0)*I*k - (2.0/3.0)*I*tr(Rcb); surfaceScalarField phiRb diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H index b07f3e70dd..0a590e6bf9 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/UEqns.H @@ -3,7 +3,7 @@ fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); { { - volTensorField gradUaT(fvc::grad(Ua)().T()); + volTensorField gradUaT(T(fvc::grad(Ua))); if (kineticTheory.on()) { @@ -58,7 +58,7 @@ fvVectorMatrix UbEqn(Ub, Ub.dimensions()*dimVol/dimTime); } { - volTensorField gradUbT(fvc::grad(Ub)().T()); + volTensorField gradUbT(T(fvc::grad(Ub))); volTensorField Rcb ( "Rcb", diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index 6d9bfd7bab..a53045225a 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -43,6 +43,8 @@ int main(int argc, char *argv[]) " $HOME kjhkjhkjh \" \\$HOME/tyetyery $; ${FOAM_RUN} \n $; hkjh;" " $(DONOTSUBST) some other <${USER}> with '${__UNKNOWN:-some default}'" " value " + " or with '${HOME:+Home was set}' via :+ alternative" + " or with '${__UNKNOWN:+unknown}' empty" ); dictionary dict; diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index 2fbadd3a6a..ebbc47ca3b 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -31,6 +31,45 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +//! \cond fileScope +// Find the type/position of the ":-" or ":+" alternative values +// +static inline int findParameterAlternative +( + const std::string& s, + std::string::size_type& pos, + std::string::size_type endPos +) +{ + while (pos != std::string::npos) + { + pos = s.find(':', pos); + if (pos != std::string::npos) + { + if (pos < endPos) + { + // in-range: check for '+' or '-' following the ':' + const int altType = s[pos+1]; + if (altType == '+' || altType == '-') + { + return altType; + } + + ++pos; // unknown/unsupported - continue at next position + } + else + { + // out-of-range: abort + pos = std::string::npos; + } + } + } + + return 0; +} +//! \endcond + + Foam::string Foam::stringOps::expand ( const string& original, @@ -66,7 +105,8 @@ Foam::string& Foam::stringOps::inplaceExpand string::size_type endVar = begVar; string::size_type delim = 0; - // The position of the ":-" default value + // The type/position of the ":-" or ":+" alternative values + int altType = 0; string::size_type altPos = string::npos; if (s[begVar+1] == '{') @@ -74,14 +114,11 @@ Foam::string& Foam::stringOps::inplaceExpand endVar = s.find('}', begVar); delim = 1; - // looks like ${parameter:-word} + // check for ${parameter:-word} or ${parameter:+word} if (endVar != string::npos) { - altPos = s.find(":-", begVar); - if (altPos != string::npos && altPos > endVar) - { - altPos = string::npos; - } + altPos = begVar; + altType = findParameterAlternative(s, altPos, endVar); } } else @@ -134,7 +171,7 @@ Foam::string& Foam::stringOps::inplaceExpand std::string altValue; if (altPos != string::npos) { - // had ":-" default value + // had ":-" or ":+" alternative value altValue = s.substr ( altPos + 2, @@ -148,17 +185,32 @@ Foam::string& Foam::stringOps::inplaceExpand if (fnd != HashTable::end()) { - s.std::string::replace - ( - begVar, - endVar - begVar + 1, - *fnd - ); - begVar += (*fnd).size(); + if (altPos != string::npos && altType == '+') + { + // was found, use ":+" alternative + s.std::string::replace + ( + begVar, + endVar - begVar + 1, + altValue + ); + begVar += altValue.size(); + } + else + { + // was found, use value + s.std::string::replace + ( + begVar, + endVar - begVar + 1, + *fnd + ); + begVar += (*fnd).size(); + } } - else if (altPos != string::npos) + else if (altPos != string::npos && altType == '-') { - // use alternative provided + // was not found, use ":-" alternative s.std::string::replace ( begVar, @@ -169,12 +221,8 @@ Foam::string& Foam::stringOps::inplaceExpand } else { - s.std::string::replace - ( - begVar, - endVar - begVar + 1, - "" - ); + // substitute with nothing, also for ":+" alternative + s.std::string::erase(begVar, endVar - begVar + 1); } } } @@ -351,7 +399,8 @@ Foam::string& Foam::stringOps::inplaceExpand string::size_type endVar = begVar; string::size_type delim = 0; - // The position of the ":-" default value + // The type/position of the ":-" or ":+" alternative values + int altType = 0; string::size_type altPos = string::npos; if (s[begVar+1] == '{') @@ -359,14 +408,11 @@ Foam::string& Foam::stringOps::inplaceExpand endVar = s.find('}', begVar); delim = 1; - // looks like ${parameter:-word} + // check for ${parameter:-word} or ${parameter:+word} if (endVar != string::npos) { - altPos = s.find(":-", begVar); - if (altPos != string::npos && altPos > endVar) - { - altPos = string::npos; - } + altPos = begVar; + altType = findParameterAlternative(s, altPos, endVar); } } else @@ -413,7 +459,7 @@ Foam::string& Foam::stringOps::inplaceExpand std::string altValue; if (altPos != string::npos) { - // had ":-" default value + // had ":-" or ":+" alternative value altValue = s.substr ( altPos + 2, @@ -424,34 +470,53 @@ Foam::string& Foam::stringOps::inplaceExpand const string varValue = getEnv(varName); if (varValue.size()) { - // direct replacement - s.std::string::replace - ( - begVar, - endVar - begVar + 1, - varValue - ); - begVar += varValue.size(); + if (altPos != string::npos && altType == '+') + { + // was found, use ":+" alternative + s.std::string::replace + ( + begVar, + endVar - begVar + 1, + altValue + ); + begVar += altValue.size(); + } + else + { + // was found, use value + s.std::string::replace + ( + begVar, + endVar - begVar + 1, + varValue + ); + begVar += varValue.size(); + } } else if (altPos != string::npos) { - // use alternative provided - s.std::string::replace - ( - begVar, - endVar - begVar + 1, - altValue - ); - begVar += altValue.size(); + // use ":-" or ":+" alternative values + if (altType == '-') + { + // was not found, use ":-" alternative + s.std::string::replace + ( + begVar, + endVar - begVar + 1, + altValue + ); + begVar += altValue.size(); + } + else + { + // was not found, ":+" alternative implies + // substitute with nothing + s.std::string::erase(begVar, endVar - begVar + 1); + } } else if (allowEmpty) { - s.std::string::replace - ( - begVar, - endVar - begVar + 1, - "" - ); + s.std::string::erase(begVar, endVar - begVar + 1); } else { @@ -459,7 +524,7 @@ Foam::string& Foam::stringOps::inplaceExpand ( "stringOps::inplaceExpand(string&, const bool)" ) - << "Unknown variable name " << varName << '.' + << "Unknown variable name '" << varName << "'" << exit(FatalError); } } diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H index 63a4679c9b..68ce3ac719 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H @@ -62,6 +62,13 @@ namespace stringOps // If parameter is unset or null, the \c defValue is substituted. // Otherwise, the value of parameter is substituted. // + // Supports alternative values as per the Bourne/Korn shell. + // \code + // "${parameter:+altValue}" + // \endcode + // If parameter is unset or null, nothing is substituted. + // Otherwise the \c altValue is substituted. + // // Any unknown entries are removed silently. // // Malformed entries (eg, brace mismatch, sigil followed by bad character) @@ -89,6 +96,13 @@ namespace stringOps // If parameter is unset or null, the \c defValue is substituted. // Otherwise, the value of parameter is substituted. // + // Supports alternative values as per the Bourne/Korn shell. + // \code + // "${parameter:+altValue}" + // \endcode + // If parameter is unset or null, nothing is substituted. + // Otherwise the \c altValue is substituted. + // // Any unknown entries are removed silently. // // Malformed entries (eg, brace mismatch, sigil followed by bad character) @@ -155,6 +169,13 @@ namespace stringOps // If parameter is unset or null, the \c defValue is substituted. // Otherwise, the value of parameter is substituted. // + // Supports alternative values as per the Bourne/Korn shell. + // \code + // "${parameter:+altValue}" + // \endcode + // If parameter is unset or null, nothing is substituted. + // Otherwise the \c altValue is substituted. + // // Any unknown entries are removed silently, if allowEmpty is true. // // Malformed entries (eg, brace mismatch, sigil followed by bad character) @@ -187,6 +208,13 @@ namespace stringOps // If parameter is unset or null, the \c defValue is substituted. // Otherwise, the value of parameter is substituted. // + // Supports alternative values as per the Bourne/Korn shell. + // \code + // "${parameter:+altValue}" + // \endcode + // If parameter is unset or null, nothing is substituted. + // Otherwise the \c altValue is substituted. + // // Any unknown entries are removed silently, if allowEmpty is true. // // Malformed entries (eg, brace mismatch, sigil followed by bad character) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 618959fb79..d5086f5951 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1180,6 +1180,43 @@ void Foam::fvMatrix::operator*= } +template +void Foam::fvMatrix::operator*= +( + const volScalarField& vsf +) +{ + dimensions_ *= vsf.dimensions(); + lduMatrix::operator*=(vsf.field()); + source_ *= vsf.field(); + + forAll(vsf.boundaryField(), patchI) + { + const fvPatchScalarField& psf = vsf.boundaryField()[patchI]; + + if (psf.coupled()) + { + internalCoeffs_[patchI] *= psf.patchInternalField(); + boundaryCoeffs_[patchI] *= psf.patchNeighbourField(); + } + else + { + internalCoeffs_[patchI] *= psf.patchInternalField(); + boundaryCoeffs_[patchI] *= psf; + } + } + + if (faceFluxCorrectionPtr_) + { + FatalErrorIn + ( + "fvMatrix::operator*=" + "(const DimensionedField&)" + ) << "cannot scale a matrix containing a faceFluxCorrection" + << abort(FatalError); + } +} + template void Foam::fvMatrix::operator*= ( diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 8e53051af6..773db6dad9 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -460,6 +460,7 @@ public: void operator*=(const DimensionedField&); void operator*=(const tmp >&); + void operator*=(const volScalarField&); void operator*=(const tmp&); void operator*=(const dimensioned&); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 457517b0cd..77fcefb2d9 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -27,24 +27,6 @@ License // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -template -Foam::label Foam::LocalInteraction::applyToPatch -( - const label globalPatchI -) const -{ - forAll(patchIDs_, patchI) - { - if (patchIDs_[patchI] == globalPatchI) - { - return patchI; - } - } - - return -1; -} - - template void Foam::LocalInteraction::readProps() { @@ -131,7 +113,6 @@ Foam::LocalInteraction::LocalInteraction : PatchInteractionModel(dict, cloud, typeName), patchData_(cloud.mesh(), this->coeffDict()), - patchIDs_(patchData_.size()), nEscape0_(patchData_.size(), 0), massEscape0_(patchData_.size(), 0.0), nStick0_(patchData_.size(), 0), @@ -173,7 +154,6 @@ Foam::LocalInteraction::LocalInteraction : PatchInteractionModel(pim), patchData_(pim.patchData_), - patchIDs_(pim.patchIDs_), nEscape0_(pim.nEscape0_), massEscape0_(pim.massEscape0_), nStick0_(pim.nStick0_), @@ -208,7 +188,7 @@ bool Foam::LocalInteraction::correct bool& active = p.active(); - label patchI = applyToPatch(pp.index()); + label patchI = patchData_.applyToPatch(pp.index()); if (patchI >= 0) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H index 5d6962b595..624dd73d25 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H @@ -53,9 +53,6 @@ class LocalInteraction //- List of participating patches const patchInteractionDataList patchData_; - //- List of participating patch ids - List