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

This commit is contained in:
andy
2011-07-01 15:22:41 +01:00
19 changed files with 1046 additions and 71 deletions

View File

@ -0,0 +1,3 @@
temporalInterpolate.C
EXE = $(FOAM_APPBIN)/temporalInterpolate

View File

@ -0,0 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume

View File

@ -0,0 +1,253 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Interpolate fields between time-steps e.g. for animation.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "Time.H"
#include "volMesh.H"
#include "surfaceMesh.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "pointFields.H"
#include "ReadFields.H"
using namespace Foam;
class fieldInterpolator
{
Time& runTime_;
const fvMesh& mesh_;
const IOobjectList& objects_;
const HashSet<word>& selectedFields_;
instant ti_;
instant ti1_;
int divisions_;
public:
fieldInterpolator
(
Time& runTime,
const fvMesh& mesh,
const IOobjectList& objects,
const HashSet<word>& selectedFields,
const instant& ti,
const instant& ti1,
int divisions
)
:
runTime_(runTime),
mesh_(mesh),
objects_(objects),
selectedFields_(selectedFields),
ti_(ti),
ti1_(ti1),
divisions_(divisions)
{}
template<class GeoFieldType>
void interpolate();
};
template<class GeoFieldType>
void fieldInterpolator::interpolate()
{
const word& fieldClassName = GeoFieldType::typeName;
IOobjectList fields = objects_.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " " << fieldClassName << "s:";
forAllConstIter(IOobjectList, fields, fieldIter)
{
if
(
selectedFields_.empty()
|| selectedFields_.found(fieldIter()->name())
)
{
Info<< " " << fieldIter()->name() << '(';
GeoFieldType fieldi
(
IOobject
(
fieldIter()->name(),
ti_.name(),
fieldIter()->db(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
mesh_
);
GeoFieldType fieldi1
(
IOobject
(
fieldIter()->name(),
ti1_.name(),
fieldIter()->db(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
),
mesh_
);
scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1);
for (int j=0; j<divisions_; j++)
{
instant timej = instant(ti_.value() + (j + 1)*deltaT);
runTime_.setTime(timej.name(), 0);
Info<< timej.name();
if (j < divisions_-1)
{
Info<< " ";
}
scalar lambda = scalar(j + 1)/scalar(divisions_ + 1);
GeoFieldType fieldj
(
IOobject
(
fieldIter()->name(),
timej.name(),
fieldIter()->db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
(1.0 - lambda)*fieldi + lambda*fieldi1
);
fieldj.write();
}
Info<< ')';
}
}
Info<< endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::addOption
(
"fields",
"list",
"specify a list of fields to be interpolated. Eg, '(U T p)' - "
"regular expressions not currently supported"
);
argList::addOption
(
"divisions",
"integer",
"specify number of temporal sub-divisions to create (default = 1)."
);
#include "setRootCase.H"
#include "createTime.H"
runTime.functionObjects().off();
HashSet<word> selectedFields;
if (args.optionFound("fields"))
{
args.optionLookup("fields")() >> selectedFields;
}
int divisions = 1;
if (args.optionFound("divisions"))
{
args.optionLookup("divisions")() >> divisions;
}
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createMesh.H"
Info<< "Interpolating fields for times:" << endl;
for (label timei = 0; timei < timeDirs.size() - 1; timei++)
{
runTime.setTime(timeDirs[timei], timei);
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
fieldInterpolator interpolator
(
runTime,
mesh,
objects,
selectedFields,
timeDirs[timei],
timeDirs[timei+1],
divisions
);
// Interpolate vol fields
interpolator.interpolate<volScalarField>();
interpolator.interpolate<volVectorField>();
interpolator.interpolate<volSphericalTensorField>();
interpolator.interpolate<volSymmTensorField>();
interpolator.interpolate<volTensorField>();
// Interpolate surface fields
interpolator.interpolate<surfaceScalarField>();
interpolator.interpolate<surfaceVectorField>();
interpolator.interpolate<surfaceSphericalTensorField>();
interpolator.interpolate<surfaceSymmTensorField>();
interpolator.interpolate<surfaceTensorField>();
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -160,6 +160,7 @@ $(dictionaryEntry)/dictionaryEntry.C
$(dictionaryEntry)/dictionaryEntryIO.C
functionEntries = $(dictionary)/functionEntries
$(functionEntries)/calcEntry/calcEntry.C
$(functionEntries)/codeStream/codeStream.C
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/includeEntry/includeEntry.C

View File

@ -2520,7 +2520,7 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
{
scalar nearestDistSqr = startDistSqr;
label nearestShapeI = -1;
point nearestPoint;
point nearestPoint = vector::zero;
if (nodes_.size())
{
@ -2534,10 +2534,6 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findNearest
nearestPoint
);
}
else
{
nearestPoint = vector::zero;
}
return pointIndexHit(nearestShapeI != -1, nearestPoint, nearestShapeI);
}

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "calcEntry.H"
#include "addToMemberFunctionSelectionTable.H"
#include "dictionary.H"
#include "dynamicCode.H"
#include "codeStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
defineTypeNameAndDebug(calcEntry, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
calcEntry,
execute,
primitiveEntryIstream
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::calcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& thisEntry,
Istream& is
)
{
Info<< "Using #calcEntry at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::calcEntry::execute(..)",
parentDict
);
// Read string
string s(is);
// Make sure we stop this entry
//is.putBack(token(token::END_STATEMENT, is.lineNumber()));
// Construct codeDict for codeStream
// must reference parent for stringOps::expand to work nicely.
dictionary codeSubDict;
codeSubDict.add("code", "os << (" + s + ");");
dictionary codeDict(parentDict, codeSubDict);
codeStream::streamingFunctionType function = codeStream::getFunction
(
parentDict,
codeDict
);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
thisEntry.read(parentDict, resultStream);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionEntries::calcEntry
Description
Uses dynamic compilation to provide calculating functionality
for entering dictionary entries.
E.g.
\verbatim
a 1.0;
b 3;
c #calc "$a/$b";
\endverbatim
Note the explicit trailing 0 ('1.0') to force a to be read (and written)
as a floating point number.
Note
Internally this is just a wrapper around codeStream functionality - the
#calc string gets used to construct a dictionary for codeStream.
SourceFiles
calcEntry.C
\*---------------------------------------------------------------------------*/
#ifndef calcEntry_H
#define calcEntry_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class dlLibraryTable;
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class calcEntry Declaration
\*---------------------------------------------------------------------------*/
class calcEntry
:
public functionEntry
{
// Private Member Functions
//- Disallow default bitwise copy construct
calcEntry(const calcEntry&);
//- Disallow default bitwise assignment
void operator=(const calcEntry&);
public:
//- Runtime type information
ClassName("calc");
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute
(
const dictionary& parentDict,
primitiveEntry&,
Istream&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -92,28 +92,13 @@ Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
Foam::functionEntries::codeStream::streamingFunctionType
Foam::functionEntries::codeStream::getFunction
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
const dictionary& codeDict
)
{
Info<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
// get code, codeInclude, codeOptions
dynamicCodeContext context(codeDict);
@ -260,6 +245,34 @@ bool Foam::functionEntries::codeStream::execute
<< " in library " << lib << exit(FatalIOError);
}
return function;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
Info<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
@ -268,6 +281,7 @@ bool Foam::functionEntries::codeStream::execute
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
return true;
}

View File

@ -103,6 +103,9 @@ class dlLibraryTable;
namespace functionEntries
{
// Forward declaration of friend classes
class calcEntry;
/*---------------------------------------------------------------------------*\
Class codeStream Declaration
\*---------------------------------------------------------------------------*/
@ -123,6 +126,14 @@ class codeStream
//- Helper function: access to dlLibraryTable of Time
static dlLibraryTable& libs(const dictionary& dict);
//- Construct, compile, load and return streaming function
static streamingFunctionType getFunction
(
const dictionary& parentDict,
const dictionary& codeDict
);
//- Disallow default bitwise copy construct
codeStream(const codeStream&);
@ -137,6 +148,11 @@ public:
//- Name of the C code template to be used
static const word codeTemplateC;
// Related types
//- Declare friendship with the calcEntry class
friend class calcEntry;
//- Runtime type information
ClassName("codeStream");

View File

@ -328,6 +328,10 @@ Foam::string& Foam::stringOps::inplaceExpand
if (ePtr)
{
OStringStream buf;
// Force floating point numbers to be printed with at least
// some decimal digits.
buf << fixed;
buf.precision(IOstream::defaultPrecision());
if (ePtr->isDict())
{
ePtr->dict().write(buf, false);

View File

@ -122,6 +122,7 @@ $(derivedFvPatchFields)/directMappedFixedValue/directMappedFixedValueFvPatchFiel
$(derivedFvPatchFields)/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C
$(derivedFvPatchFields)/directMappedFlowRate/directMappedFlowRateFvPatchVectorField.C
$(derivedFvPatchFields)/fan/fanFvPatchFields.C
$(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C
$(derivedFvPatchFields)/buoyantPressure/buoyantPressureFvPatchScalarField.C
$(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
$(derivedFvPatchFields)/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C

View File

@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fanPressureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::fanPressureFvPatchScalarField::fanFlowDirection,
2
>::names[] =
{
"in",
"out"
};
}
const Foam::NamedEnum
<
Foam::fanPressureFvPatchScalarField::fanFlowDirection,
2
> Foam::fanPressureFvPatchScalarField::fanFlowDirectionNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
phiName_("phi"),
rhoName_("rho"),
p0_(p.size(), 0.0),
fanCurve_(),
direction_(ffdOut)
{}
Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
p0_(ptf.p0_, mapper),
fanCurve_(ptf.fanCurve_),
direction_(ptf.direction_)
{}
Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
p0_("p0", dict, p.size()),
fanCurve_(dict),
direction_(fanFlowDirectionNames_.read(dict.lookup("direction")))
{
// Assign initial pressure by "value"
fvPatchField<scalar>::operator==(scalarField("value", dict, p.size()));
}
Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField& pfopsf
)
:
fixedValueFvPatchScalarField(pfopsf),
phiName_(pfopsf.phiName_),
rhoName_(pfopsf.rhoName_),
p0_(pfopsf.p0_),
fanCurve_(pfopsf.fanCurve_),
direction_(pfopsf.direction_)
{}
Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField& pfopsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(pfopsf, iF),
phiName_(pfopsf.phiName_),
rhoName_(pfopsf.rhoName_),
p0_(pfopsf.p0_),
fanCurve_(pfopsf.fanCurve_),
direction_(pfopsf.direction_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fanPressureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// Retrieve flux field
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi);
int dir = 2*direction_ - 1;
// Average volumetric flow rate
scalar aveFlowRate = 0;
if (phi.dimensions() == dimVelocity*dimArea)
{
aveFlowRate = dir*gSum(phip)/gSum(patch().magSf());
}
else if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
{
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
aveFlowRate = dir*gSum(phip/rhop)/gSum(patch().magSf());
}
else
{
FatalErrorIn("fanPressureFvPatchScalarField::updateCoeffs()")
<< "dimensions of phi are not correct"
<< "\n on patch " << patch().name()
<< " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath() << nl
<< exit(FatalError);
}
// Normal flow through fan
if (aveFlowRate >= 0.0)
{
// Pressure drop for this flow rate
const scalar pdFan = fanCurve_(aveFlowRate);
operator==(p0_ - dir*pdFan);
}
// Reverse flow
else
{
// Assume that fan has stalled if flow reversed
// i.e. apply dp for zero flow rate
const scalar pdFan = fanCurve_(0);
// Flow speed across patch
scalarField Up = phip/(patch().magSf());
// Pressure drop associated withback flow = dynamic pressure
scalarField pdBackFlow = 0.5*magSqr(Up);
if (phi.dimensions() == dimVelocity*dimArea*dimDensity)
{
const scalarField& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
pdBackFlow /= rhop;
}
operator==(p0_ - dir*(pdBackFlow + pdFan));
}
fixedValueFvPatchScalarField::updateCoeffs();
}
void Foam::fanPressureFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
fanCurve_.write(os);
os.writeKeyword("direction")
<< fanFlowDirectionNames_[direction_] << token::END_STATEMENT << nl;
p0_.writeEntry("p0", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
fanPressureFvPatchScalarField
);
};
// ************************************************************************* //

View File

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fanPressureFvPatchScalarField
Description
Assigns pressure inlet or outlet condition for a fan.
User specifies:
- pressure drop vs volumetric flow rate table (fan curve) file name;
- direction of normal flow through the fan, in or out;
- total pressure of the environment.
Example of the boundary condition specification:
\verbatim
inlet
{
type fanPressure;
fileName "fanCurve"; // Fan curve file name
outOfBounds clamp; // (error|warn|clamp|repeat)
direction in; // Direction of flow through fan
p0 uniform 0; // Environmental total pressure
value uniform 0; // Initial pressure
}
outlet
{
type fanPressure;
fileName "fanCurve"; // Fan curve file name
outOfBounds clamp; // (error|warn|clamp|repeat)
direction out; // Direction of flow through fan
p0 uniform 0; // Environmental total pressure
value uniform 0; // Initial pressure
}
\endverbatim
See Also
Foam::interpolationTable and
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField
SourceFiles
fanPressureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef fanPressureFvPatchScalarField_H
#define fanPressureFvPatchScalarField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
#include "interpolationTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fanPressureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class fanPressureFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Name of the flux transporting the field
word phiName_;
//- Name of the density field
word rhoName_;
//- Total pressure
scalarField p0_;
//- Tabulated fan curve
interpolationTable<scalar> fanCurve_;
//- Fan flow direction
enum fanFlowDirection
{
ffdIn,
ffdOut
};
static const NamedEnum<fanFlowDirection, 2> fanFlowDirectionNames_;
//- Direction of flow through the fan relative to patch
fanFlowDirection direction_;
public:
//- Runtime type information
TypeName("fanPressure");
// Constructors
//- Construct from patch and internal field
fanPressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
fanPressureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// fanPressureFvPatchScalarField
// onto a new patch
fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new fanPressureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
fanPressureFvPatchScalarField
(
const fanPressureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new fanPressureFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,9 @@ Description
limitedSurfaceInterpolationScheme.
The limited scheme is specified first followed by the scheme to be scaled
by the limiter and then the scheme scaled by 1 - limiter.
by the limiter and then the scheme scaled by 1 - limiter e.g.
div(phi,U) Gauss limiterBlended vanLeer linear linearUpwind grad(U);
SourceFiles
limiterBlended.C

View File

@ -738,7 +738,6 @@ void Foam::triSurfaceMesh::findLineAll
// we need something bigger since we're doing calculations)
// - if the start-end vector is zero we still progress
const vectorField dirVec(end-start);
const scalarField magSqrDirVec(magSqr(dirVec));
const vectorField smallVec
(
indexedOctree<treeDataTriSurface>::perturbTol()*dirVec

View File

@ -255,7 +255,6 @@ void Foam::orientedSurface::findZoneSide
zoneFaceI = -1;
isOutside = false;
List<pointIndexHit> hits;
forAll(faceZone, faceI)
@ -305,7 +304,6 @@ void Foam::orientedSurface::findZoneSide
{
isOutside = ((n & d) > 0);
}
break;
}
}
@ -354,6 +352,50 @@ bool Foam::orientedSurface::flipSurface
}
bool Foam::orientedSurface::orientConsistent(triSurface& s)
{
bool anyFlipped = false;
// Do initial flipping to make triangles consistent. Otherwise if the
// nearest is e.g. on an edge inbetween inconsistent triangles it might
// make the wrong decision.
if (s.size() > 0)
{
// Whether face has to be flipped.
// UNVISITED: unvisited
// NOFLIP: no need to flip
// FLIP: need to flip
labelList flipState(s.size(), UNVISITED);
label faceI = 0;
while (true)
{
label startFaceI = -1;
while (faceI < s.size())
{
if (flipState[faceI] == UNVISITED)
{
startFaceI = faceI;
break;
}
faceI++;
}
if (startFaceI == -1)
{
break;
}
flipState[startFaceI] = NOFLIP;
walkSurface(s, startFaceI, flipState);
}
anyFlipped = flipSurface(s, flipState);
}
return anyFlipped;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
@ -404,44 +446,10 @@ bool Foam::orientedSurface::orient
const bool orientOutside
)
{
bool anyFlipped = false;
// Do initial flipping to make triangles consistent. Otherwise if the
// nearest is e.g. on an edge inbetween inconsistent triangles it might
// make the wrong decision.
if (s.size() > 0)
{
// Whether face has to be flipped.
// UNVISITED: unvisited
// NOFLIP: no need to flip
// FLIP: need to flip
labelList flipState(s.size(), UNVISITED);
label faceI = 0;
while (true)
{
label startFaceI = -1;
while (faceI < s.size())
{
if (flipState[faceI] == UNVISITED)
{
startFaceI = faceI;
break;
}
faceI++;
}
if (startFaceI == -1)
{
break;
}
flipState[startFaceI] = NOFLIP;
walkSurface(s, startFaceI, flipState);
}
anyFlipped = flipSurface(s, flipState);
}
bool topoFlipped = orientConsistent(s);
// Whether face has to be flipped.
@ -497,7 +505,7 @@ bool Foam::orientedSurface::orient
// Now finally flip triangles according to flipState.
bool geomFlipped = flipSurface(s, flipState);
return anyFlipped || geomFlipped;
return topoFlipped || geomFlipped;
}
@ -509,6 +517,11 @@ bool Foam::orientedSurface::orient
const bool orientOutside
)
{
// Do initial flipping to make triangles consistent. Otherwise if the
// nearest is e.g. on an edge inbetween inconsistent triangles it might
// make the wrong decision.
bool topoFlipped = orientConsistent(s);
// Determine disconnected parts of surface
boolList borderEdge(s.nEdges(), false);
forAll(s.edgeFaces(), edgeI)
@ -549,7 +562,11 @@ bool Foam::orientedSurface::orient
}
walkSurface(s, zoneFaceI, flipState);
}
return flipSurface(s, flipState);
// Now finally flip triangles according to flipState.
bool geomFlipped = flipSurface(s, flipState);
return topoFlipped || geomFlipped;
}

View File

@ -128,6 +128,9 @@ class orientedSurface
// anything flipped.
static bool flipSurface(triSurface& s, const labelList& flipState);
//- Make surface surface has consistent orientation across connected
// triangles.
static bool orientConsistent(triSurface& s);
public:
ClassName("orientedSurface");

View File

@ -201,9 +201,8 @@ const
if (inter.hit())
{
label sz = hits.size();
hits.setSize(sz+1);
hits[sz] = inter;
hits.setSize(1);
hits[0] = inter;
const vector dirVec(end-start);
const scalar magSqrDirVec(magSqr(dirVec));

View File

@ -25,14 +25,23 @@ Class
Foam::incompressible::LESModels::kOmegaSSTSAS
Description
kOmegaSSTSAS LES turbulence model for incompressible flows
kOmegaSSTSAS LES turbulence model for incompressible flows
based on:
"Evaluation of the SST-SAS model: channel flow, asymmetric diffuser
and axi-symmetric hill".
European Conference on Computational Fluid Dynamics ECCOMAS CFD 2006.
Lars Davidson
The first term of the Qsas expression is corrected following:
DESider A European Effort on Hybrid RANS-LES Modelling:
Results of the European-Union Funded Project, 2004 - 2007
(Notes on Numerical Fluid Mechanics and Multidisciplinary Design).
Chapter 8 Formulation of the Scale-Adaptive Simulation (SAS) Model during
the DESIDER Project. Published in Springer-Verlag Berlin Heidelberg 2009.
Chapter 2, section 8 Formulation of the Scale-Adaptive Simulation (SAS)
Model during the DESIDER Project. Published in Springer-Verlag Berlin
Heidelberg 2009.
F. R. Menter and Y. Egorov.
SourceFiles