Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2011-03-22 22:17:36 +00:00
60 changed files with 149037 additions and 336 deletions

View File

@ -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<string, word, string::hash>::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);
}
}

View File

@ -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)

View File

@ -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<Type>::operator*=
}
template<class Type>
void Foam::fvMatrix<Type>::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<Type>::operator*="
"(const DimensionedField<scalar, volMesh>&)"
) << "cannot scale a matrix containing a faceFluxCorrection"
<< abort(FatalError);
}
}
template<class Type>
void Foam::fvMatrix<Type>::operator*=
(

View File

@ -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<scalar, volMesh>&);
void operator*=(const tmp<DimensionedField<scalar, volMesh> >&);
void operator*=(const volScalarField&);
void operator*=(const tmp<volScalarField>&);
void operator*=(const dimensioned<scalar>&);

View File

@ -27,24 +27,6 @@ License
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class CloudType>
Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
(
const label globalPatchI
) const
{
forAll(patchIDs_, patchI)
{
if (patchIDs_[patchI] == globalPatchI)
{
return patchI;
}
}
return -1;
}
template<class CloudType>
void Foam::LocalInteraction<CloudType>::readProps()
{
@ -131,7 +113,6 @@ Foam::LocalInteraction<CloudType>::LocalInteraction
:
PatchInteractionModel<CloudType>(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<CloudType>::LocalInteraction
:
PatchInteractionModel<CloudType>(pim),
patchData_(pim.patchData_),
patchIDs_(pim.patchIDs_),
nEscape0_(pim.nEscape0_),
massEscape0_(pim.massEscape0_),
nStick0_(pim.nStick0_),
@ -208,7 +188,7 @@ bool Foam::LocalInteraction<CloudType>::correct
bool& active = p.active();
label patchI = applyToPatch(pp.index());
label patchI = patchData_.applyToPatch(pp.index());
if (patchI >= 0)
{

View File

@ -53,9 +53,6 @@ class LocalInteraction
//- List of participating patches
const patchInteractionDataList patchData_;
//- List of participating patch ids
List<label> patchIDs_;
// Counters for initial particle fates
@ -89,9 +86,6 @@ class LocalInteraction
// Private Member Functions
//- Returns local patchI if patch is in patchIds_ list
label applyToPatch(const label globalPatchI) const;
//- Read interaction properties from file
void readProps();

View File

@ -36,15 +36,12 @@ Foam::label Foam::PatchPostProcessing<CloudType>::applyToPatch
const label globalPatchI
) const
{
label patchI = 0;
forAllConstIter(labelHashSet, patchIDs_, iter)
forAll(patchIDs_, i)
{
if (iter.key() == globalPatchI)
if (patchIDs_[i] == globalPatchI)
{
return patchI;
return i;
}
patchI++;
}
return -1;
@ -105,7 +102,7 @@ void Foam::PatchPostProcessing<CloudType>::write()
);
sort(globalData);
patchOutFile<< "# Time " + parcelType::propHeader << nl;
patchOutFile<< "# Time currentProc " + parcelType::propHeader << nl;
forAll(globalData, dataI)
{
@ -135,6 +132,7 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
const wordList allPatchNames = owner.mesh().boundaryMesh().names();
wordList patchName(this->coeffDict().lookup("patches"));
labelHashSet uniquePatchIDs;
forAllReverse(patchName, i)
{
labelList patchIDs = findStrings(patchName[i], allPatchNames);
@ -152,9 +150,18 @@ Foam::PatchPostProcessing<CloudType>::PatchPostProcessing
<< endl;
}
forAll(patchIDs, j)
uniquePatchIDs.insert(patchIDs);
}
patchIDs_ = uniquePatchIDs.toc();
if (debug)
{
forAll(patchIDs_, i)
{
patchIDs_.insert(patchIDs[j]);
const label patchI = patchIDs_[i];
const word& patchName = owner.mesh().boundaryMesh()[patchI].name();
Info<< "Post-process patch " << patchName << endl;
}
}
@ -195,7 +202,8 @@ void Foam::PatchPostProcessing<CloudType>::postPatch
if (localPatchI != -1 && patchData_[localPatchI].size() < maxStoredParcels_)
{
OStringStream data;
data<< this->owner().time().timeName() << ' ' << p;
data<< this->owner().time().timeName() << ' ' << Pstream::myProcNo()
<< ' ' << p;
patchData_[localPatchI].append(data.str());
}
}

View File

@ -59,7 +59,7 @@ class PatchPostProcessing
label maxStoredParcels_;
//- List of patch indices to post-process
labelHashSet patchIDs_;
labelList patchIDs_;
//- List of output data per patch
List<DynamicList<string> > patchData_;

View File

@ -90,7 +90,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)