Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2009-03-13 16:43:36 +00:00
123 changed files with 7843 additions and 290 deletions

View File

@ -308,6 +308,7 @@ Foam::fieldAverage::fieldAverage
active_(true),
prevTimeIndex_(-1),
cleanRestart_(false),
resetOnOutput_(false),
faItems_(),
meanScalarFields_(),
meanVectorFields_(),
@ -355,6 +356,7 @@ void Foam::fieldAverage::read(const dictionary& dict)
if (active_)
{
dict.readIfPresent("cleanRestart", cleanRestart_);
dict.readIfPresent("resetOnOutput", resetOnOutput_);
dict.lookup("fields") >> faItems_;
initialize();
@ -387,6 +389,17 @@ void Foam::fieldAverage::write()
calcAverages();
writeAverages();
writeAveragingProperties();
if (resetOnOutput_)
{
Info<< "fieldAverage: restarting averaging at time "
<< obr_.time().timeName() << nl << endl;
initialize();
// ensure first averaging works unconditionally
prevTimeIndex_ = -1;
}
}
}

View File

@ -41,6 +41,11 @@ Description
// averaging info if available
cleanRestart true;
// Whether to reset the averaged fields after they have been written.
// Used to average over only the preceding write interval for transient
// cases.
resetOnOutput true;
// Fields to be averaged. runTime modifiable!
fields
(
@ -132,6 +137,9 @@ protected:
//- Clean restart flag
Switch cleanRestart_;
//- resetOnOutput flag
Switch resetOnOutput_;
//- List of field average items, describing what averages to be
// calculated and output
List<fieldAverageItem> faItems_;

View File

@ -151,6 +151,8 @@ Foam::forces::forces
patchSet_(),
pName_(""),
UName_(""),
directForceDensity_(false),
fDName_(""),
rhoRef_(0),
CofR_(vector::zero),
forcesFilePtr_(NULL)
@ -161,7 +163,13 @@ Foam::forces::forces
active_ = false;
WarningIn
(
"forces::forces(const objectRegistry& obr, const dictionary& dict)"
"Foam::forces::forces"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating."
<< endl;
}
@ -189,27 +197,50 @@ void Foam::forces::read(const dictionary& dict)
patchSet_ =
mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
// Optional entries U and p
pName_ = dict.lookupOrDefault<word>("pName", "p");
UName_ = dict.lookupOrDefault<word>("UName", "U");
dict.readIfPresent("directForceDensity", directForceDensity_);
// Check whether UName and pName exists, if not deactivate forces
if
(
!obr_.foundObject<volVectorField>(UName_)
|| !obr_.foundObject<volScalarField>(pName_)
)
if (directForceDensity_)
{
active_ = false;
WarningIn("void forces::read(const dictionary& dict)")
<< "Could not find " << UName_ << " or "
<< pName_ << " in database." << nl
<< " De-activating forces."
<< endl;
}
// Optional entry for fDName
fDName_ = dict.lookupOrDefault<word>("fDName", "fD");
// Reference density needed for incompressible calculations
rhoRef_ = readScalar(dict.lookup("rhoInf"));
// Check whether fDName exists, if not deactivate forces
if
(
!obr_.foundObject<volVectorField>(fDName_)
)
{
active_ = false;
WarningIn("void forces::read(const dictionary& dict)")
<< "Could not find " << fDName_ << " in database." << nl
<< " De-activating forces."
<< endl;
}
}
else
{
// Optional entries U and p
pName_ = dict.lookupOrDefault<word>("pName", "p");
UName_ = dict.lookupOrDefault<word>("UName", "U");
// Check whether UName and pName exists, if not deactivate forces
if
(
!obr_.foundObject<volVectorField>(UName_)
|| !obr_.foundObject<volScalarField>(pName_)
)
{
active_ = false;
WarningIn("void forces::read(const dictionary& dict)")
<< "Could not find " << UName_ << " or "
<< pName_ << " in database." << nl
<< " De-activating forces."
<< endl;
}
// Reference density needed for incompressible calculations
rhoRef_ = readScalar(dict.lookup("rhoInf"));
}
// Centre of rotation for moment calculations
CofR_ = dict.lookup("CofR");
@ -307,40 +338,76 @@ void Foam::forces::write()
Foam::forces::forcesMoments Foam::forces::calcForcesMoment() const
{
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
const fvMesh& mesh = U.mesh();
forcesMoments fm
(
pressureViscous(vector::zero, vector::zero),
pressureViscous(vector::zero, vector::zero)
);
const surfaceVectorField::GeometricBoundaryField& Sfb =
mesh.Sf().boundaryField();
tmp<volSymmTensorField> tdevRhoReff = devRhoReff();
const volSymmTensorField::GeometricBoundaryField& devRhoReffb
= tdevRhoReff().boundaryField();
forAllConstIter(labelHashSet, patchSet_, iter)
if (directForceDensity_)
{
label patchi = iter.key();
const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_);
vectorField Md = mesh.C().boundaryField()[patchi] - CofR_;
const fvMesh& mesh = fD.mesh();
vectorField pf =
mesh.Sf().boundaryField()[patchi]*p.boundaryField()[patchi];
const surfaceVectorField::GeometricBoundaryField& Sfb =
mesh.Sf().boundaryField();
fm.first().first() += rho(p)*sum(pf);
fm.second().first() += rho(p)*sum(Md ^ pf);
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
vectorField vf = Sfb[patchi] & devRhoReffb[patchi];
vectorField Md = mesh.C().boundaryField()[patchi] - CofR_;
fm.first().second() += sum(vf);
fm.second().second() += sum(Md ^ vf);
scalarField sA = mag(Sfb[patchi]);
// Normal force = surfaceUnitNormal * (surfaceNormal & forceDensity)
vectorField fN =
Sfb[patchi]/sA
*(
Sfb[patchi] & fD.boundaryField()[patchi]
);
fm.first().first() += sum(fN);
fm.second().first() += sum(Md ^ fN);
// Tangential force (total force minus normal fN)
vectorField fT = sA*fD.boundaryField()[patchi] - fN;
fm.first().second() += sum(fT);
fm.second().second() += sum(Md ^ fT);
}
}
else
{
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
const fvMesh& mesh = U.mesh();
const surfaceVectorField::GeometricBoundaryField& Sfb =
mesh.Sf().boundaryField();
tmp<volSymmTensorField> tdevRhoReff = devRhoReff();
const volSymmTensorField::GeometricBoundaryField& devRhoReffb
= tdevRhoReff().boundaryField();
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
vectorField Md = mesh.C().boundaryField()[patchi] - CofR_;
vectorField pf = Sfb[patchi]*p.boundaryField()[patchi];
fm.first().first() += rho(p)*sum(pf);
fm.second().first() += rho(p)*sum(Md ^ pf);
vectorField vf = Sfb[patchi] & devRhoReffb[patchi];
fm.first().second() += sum(vf);
fm.second().second() += sum(Md ^ vf);
}
}
reduce(fm, sumOp());

View File

@ -121,7 +121,7 @@ protected:
//- Switch to send output to Info as well as to file
Switch log_;
// Read from dictonary
// Read from dictionary
//- Patches to integrate forces over
labelHashSet patchSet_;
@ -132,6 +132,12 @@ protected:
//- Name of velocity field
word UName_;
//- Is the force density being supplied directly?
Switch directForceDensity_;
//- The name of the force density (fD) field
word fDName_;
//- Reference density needed for incompressible calculations
scalar rhoRef_;

View File

@ -1,4 +1,7 @@
staticPressure/staticPressure.C
staticPressure/staticPressureFunctionObject.C
dsmcFields/dsmcFields.C
dsmcFields/dsmcFieldsFunctionObject.C
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects

View File

@ -1,9 +1,13 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/dsmc/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lsampling
-lsampling \
-llagrangian \
-ldsmc

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Typedef
Foam::IOdsmcFields
Description
Instance of the generic IOOutputFilter for dsmcFields.
\*---------------------------------------------------------------------------*/
#ifndef IOdsmcFields_H
#define IOdsmcFields_H
#include "dsmcFields.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<dsmcFields> IOdsmcFields;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,236 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "dsmcFields.H"
#include "volFields.H"
#include "dictionary.H"
#include "dsmcCloud.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(dsmcFields, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dsmcFields::dsmcFields
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true)
{
// Check if the available mesh is an fvMesh, otherwise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"dsmcFields::dsmcFields"
"(const objectRegistry&, const dictionary&)"
) << "No fvMesh available, deactivating." << nl
<< endl;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::dsmcFields::~dsmcFields()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::dsmcFields::read(const dictionary& dict)
{
if (active_)
{
}
}
void Foam::dsmcFields::execute()
{
// Do nothing - only valid on write
}
void Foam::dsmcFields::end()
{
// Do nothing - only valid on write
}
void Foam::dsmcFields::write()
{
if (active_)
{
word rhoNMeanName = "rhoNMean";
word rhoMMeanName = "rhoMMean";
word momentumMeanName = "momentumMean";
word linearKEMeanName = "linearKEMean";
word internalEMeanName = "internalEMean";
word iDofMeanName = "iDofMean";
const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
(
rhoNMeanName
);
const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
(
rhoMMeanName
);
const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
(
momentumMeanName
);
const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
(
linearKEMeanName
);
const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
(
internalEMeanName
);
const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
(
iDofMeanName
);
if (min(rhoNMean).value() > VSMALL)
{
Info<< "Calculating dsmcFields." << endl;
Info<< " Calculating UMean field." << endl;
volVectorField UMean
(
IOobject
(
"UMean",
obr_.time().timeName(),
obr_,
IOobject::NO_READ
),
momentumMean/rhoMMean
);
Info<< " Calculating translationalT field." << endl;
volScalarField translationalT
(
IOobject
(
"translationalT",
obr_.time().timeName(),
obr_,
IOobject::NO_READ
),
2.0/(3.0*dsmcCloud::kb*rhoNMean)
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
);
Info<< " Calculating internalT field." << endl;
volScalarField internalT
(
IOobject
(
"internalT",
obr_.time().timeName(),
obr_,
IOobject::NO_READ
),
2.0/(dsmcCloud::kb*iDofMean)*internalEMean
);
Info<< " Calculating overallT field." << endl;
volScalarField overallT
(
IOobject
(
"overallT",
obr_.time().timeName(),
obr_,
IOobject::NO_READ
),
2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
);
Info<< " mag(UMean) max/min : "
<< max(mag(UMean)).value() << " "
<< min(mag(UMean)).value() << endl;
Info<< " translationalT max/min : "
<< max(translationalT).value() << " "
<< min(translationalT).value() << endl;
Info<< " internalT max/min : "
<< max(internalT).value() << " "
<< min(internalT).value() << endl;
Info<< " overallT max/min : "
<< max(overallT).value() << " "
<< min(overallT).value() << endl;
UMean.write();
translationalT.write();
internalT.write();
overallT.write();
Info<< "dsmcFields written." << nl << endl;
}
else
{
Info<< "Small or negative value (" << min(rhoNMean)
<< ") found in rhoNMean field. "
<< "Not calculating dsmcFields to avoid division by zero "
<< "or invalid results."
<< endl;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::dsmcFields
Description
Calculate intensive fields:
- UMean
- translationalT
- internalT
- overallT
from averaged extensive fields from a DSMC calculation.
SourceFiles
dsmcFields.C
IOdsmcFields.H
\*---------------------------------------------------------------------------*/
#ifndef dsmcFields_H
#define dsmcFields_H
#include "pointFieldFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class dsmcFields Declaration
\*---------------------------------------------------------------------------*/
class dsmcFields
{
// Private data
//- Name of this set of dsmcFields objects
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
// Private Member Functions
//- Disallow default bitwise copy construct
dsmcFields(const dsmcFields&);
//- Disallow default bitwise assignment
void operator=(const dsmcFields&);
public:
//- Runtime type information
TypeName("dsmcFields");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
dsmcFields
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor
virtual ~dsmcFields();
// Member Functions
//- Return name of the set of dsmcFields
virtual const word& name() const
{
return name_;
}
//- Read the dsmcFields data
virtual void read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Calculate the dsmcFields and write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const pointField&)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "dsmcFieldsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(dsmcFieldsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
dsmcFieldsFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Typedef
Foam::dsmcFieldsFunctionObject
Description
FunctionObject wrapper around dsmcFields to allow it to be created via
the functions list within controlDict.
SourceFiles
dsmcFieldsFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef dsmcFieldsFunctionObject_H
#define dsmcFieldsFunctionObject_H
#include "dsmcFields.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<dsmcFields>
dsmcFieldsFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //