Merge commit 'OpenCFD/master' into olesenm

Conflicts:

	src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C
	src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C
This commit is contained in:
Mark Olesen
2009-01-07 09:39:17 +01:00
171 changed files with 2187 additions and 1309 deletions

View File

@ -0,0 +1,7 @@
forces/forces.C
forces/forcesFunctionObject.C
forceCoeffs/forceCoeffs.C
forceCoeffs/forceCoeffsFunctionObject.C
LIB = $(FOAM_LIBBIN)/libforces

View File

@ -0,0 +1,20 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
LIB_LIBS = \
-lincompressibleTransportModels \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lbasicThermophysicalModels \
-lspecie \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lfiniteVolume \
-lmeshTools \
-lsampling

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::IOforces
Description
Instance of the generic IOOutputFilter for forceCoeffs.
\*---------------------------------------------------------------------------*/
#ifndef IOforceCoeffs_H
#define IOforceCoeffs_H
#include "forceCoeffs.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<forceCoeffs> IOforceCoeffs;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "forceCoeffs.H"
#include "dictionary.H"
#include "Time.H"
#include "Pstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(forceCoeffs, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::forceCoeffs::forceCoeffs
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
forces(name, obr, dict, loadFromFiles),
liftDir_(vector::zero),
dragDir_(vector::zero),
pitchAxis_(vector::zero),
magUInf_(0.0),
lRef_(0.0),
Aref_(0.0)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::forceCoeffs::~forceCoeffs()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::forceCoeffs::read(const dictionary& dict)
{
if (active_)
{
forces::read(dict);
// Directions for lift and drag forces, and pitch moment
dict.lookup("liftDir") >> liftDir_;
dict.lookup("dragDir") >> dragDir_;
dict.lookup("pitchAxis") >> pitchAxis_;
// Free stream velocity magnitude
dict.lookup("magUInf") >> magUInf_;
// Reference length and area scales
dict.lookup("lRef") >> lRef_;
dict.lookup("Aref") >> Aref_;
}
}
void Foam::forceCoeffs::writeFileHeader()
{
if (forcesFilePtr_.valid())
{
forcesFilePtr_()
<< "# Time" << tab << "Cd" << tab << "Cl" << tab << "Cm" << endl;
}
}
void Foam::forceCoeffs::execute()
{
// Do nothing - only valid on write
}
void Foam::forceCoeffs::write()
{
if (active_)
{
// Create the forces file if not already created
makeFile();
forcesMoments fm = forces::calcForcesMoment();
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
vector totForce = fm.first().first() + fm.first().second();
vector totMoment = fm.second().first() + fm.second().second();
scalar liftForce = totForce & liftDir_;
scalar dragForce = totForce & dragDir_;
scalar pitchMoment = totMoment & pitchAxis_;
scalar Cl = liftForce/(Aref_*pDyn);
scalar Cd = dragForce/(Aref_*pDyn);
scalar Cm = pitchMoment/(Aref_*lRef_*pDyn);
if (Pstream::master())
{
forcesFilePtr_()
<< obr_.time().value() << tab
<< Cd << tab << Cl << tab << Cm << endl;
if (log_)
{
Info<< "forceCoeffs output:" << nl
<< " Cd = " << Cd << nl
<< " Cl = " << Cl << nl
<< " Cm = " << Cm << nl
<< endl;
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::forceCoeffs
Description
Derived from the forces function object, creates a specialisation to
calculate lift and drag forces.
SourceFiles
forceCoeffs.C
IOforceCoeffs.H
\*---------------------------------------------------------------------------*/
#ifndef forceCoeffs_H
#define forceCoeffs_H
#include "forces.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class forceCoeffs Declaration
\*---------------------------------------------------------------------------*/
class forceCoeffs
:
public forces
{
// Private data
// Force coefficient geometry
//- Lift
vector liftDir_;
//- Drag
vector dragDir_;
//- Pitch
vector pitchAxis_;
// Free-stream conditions
//- Velocity magnitude
scalar magUInf_;
// Reference scales
//- Length
scalar lRef_;
//- Area
scalar Aref_;
// Private member functions
//- Disallow default bitwise copy construct
forceCoeffs(const forceCoeffs&);
//- Disallow default bitwise assignment
void operator=(const forceCoeffs&);
protected:
//- Output file header information
virtual void writeFileHeader();
public:
//- Runtime type information
TypeName("forceCoeffs");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
forceCoeffs
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor
virtual ~forceCoeffs();
// Member Functions
//- Read the forces data
virtual void read(const dictionary&);
//- Execute
virtual void execute();
//- Write the forces
virtual void write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // 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 "forceCoeffsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(forceCoeffsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
forceCoeffsFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::forceCoeffsFunctionObject
Description
FunctionObject wrapper around forceCoeffs to allow them to be created via
the functions list within controlDict.
SourceFiles
forceCoeffsFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef forceCoeffsFunctionObject_H
#define forceCoeffsFunctionObject_H
#include "forceCoeffs.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<forceCoeffs> forceCoeffsFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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::IOforces
Description
Instance of the generic IOOutputFilter for forces.
\*---------------------------------------------------------------------------*/
#ifndef IOforces_H
#define IOforces_H
#include "forces.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<forces> IOforces;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,345 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "forces.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
#include "incompressible/RAS/RASModel/RASModel.H"
#include "incompressible/LES/LESModel/LESModel.H"
#include "basicThermo.H"
#include "compressible/RAS/RASModel/RASModel.H"
#include "compressible/LES/LESModel/LESModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(forces, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volSymmTensorField> Foam::forces::devRhoReff() const
{
if (obr_.foundObject<compressible::RASModel>("RASProperties"))
{
const compressible::RASModel& ras
= obr_.lookupObject<compressible::RASModel>("RASProperties");
return ras.devRhoReff();
}
else if (obr_.foundObject<incompressible::RASModel>("RASProperties"))
{
const incompressible::RASModel& ras
= obr_.lookupObject<incompressible::RASModel>("RASProperties");
return rhoRef_*ras.devReff();
}
else if (obr_.foundObject<compressible::LESModel>("LESProperties"))
{
const compressible::LESModel& les =
obr_.lookupObject<compressible::LESModel>("LESProperties");
return les.devRhoBeff();
}
else if (obr_.foundObject<incompressible::LESModel>("LESProperties"))
{
const incompressible::LESModel& les
= obr_.lookupObject<incompressible::LESModel>("LESProperties");
return rhoRef_*les.devBeff();
}
else if (obr_.foundObject<basicThermo>("thermophysicalProperties"))
{
const basicThermo& thermo =
obr_.lookupObject<basicThermo>("thermophysicalProperties");
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
return -thermo.mu()*dev(twoSymm(fvc::grad(U)));
}
else if
(
obr_.foundObject<singlePhaseTransportModel>("transportProperties")
)
{
const singlePhaseTransportModel& laminarT =
obr_.lookupObject<singlePhaseTransportModel>
("transportProperties");
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
return -rhoRef_*laminarT.nu()*dev(twoSymm(fvc::grad(U)));
}
else if (obr_.foundObject<dictionary>("transportProperties"))
{
const dictionary& transportProperties =
obr_.lookupObject<dictionary>("transportProperties");
dimensionedScalar nu(transportProperties.lookup("nu"));
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
return -rhoRef_*nu*dev(twoSymm(fvc::grad(U)));
}
else
{
FatalErrorIn("forces::devRhoReff()")
<< "No valid model for viscous stress calculation."
<< exit(FatalError);
return volSymmTensorField::null();
}
}
Foam::scalar Foam::forces::rho(const volScalarField& p) const
{
if (p.dimensions() == dimPressure)
{
return 1.0;
}
else
{
return rhoRef_;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::forces::forces
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true),
log_(false),
patchSet_(),
pName_(""),
UName_(""),
rhoRef_(0),
CofR_(vector::zero),
forcesFilePtr_(NULL)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"forces::forces(const objectRegistry& obr, const dictionary& dict)"
) << "No fvMesh available, deactivating."
<< endl;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::forces::~forces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::forces::read(const dictionary& dict)
{
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
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");
// 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");
}
}
void Foam::forces::makeFile()
{
// Create the forces file if not already created
if (!forcesFilePtr_.valid())
{
if (debug)
{
Info<< "Creating forces file." << endl;
}
// File update
if (Pstream::master())
{
fileName forcesDir;
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
forcesDir =
obr_.time().path()/".."/name_/obr_.time().timeName();
}
else
{
forcesDir = obr_.time().path()/name_/obr_.time().timeName();
}
// Create directory if does not exist.
mkDir(forcesDir);
// Open new file at start up
forcesFilePtr_.reset(new OFstream(forcesDir/(type() + ".dat")));
// Add headers to output data
writeFileHeader();
}
}
}
void Foam::forces::writeFileHeader()
{
if (forcesFilePtr_.valid())
{
forcesFilePtr_()
<< "# Time" << tab
<< "forces(pressure, viscous) moment(pressure, viscous)"
<< endl;
}
}
void Foam::forces::execute()
{
// Do nothing - only valid on write
}
void Foam::forces::write()
{
if (active_)
{
// Create the forces file if not already created
makeFile();
forcesMoments fm = calcForcesMoment();
if (Pstream::master())
{
forcesFilePtr_() << obr_.time().value() << tab << fm << endl;
if (log_)
{
Info<< "forces output:" << nl
<< " forces(pressure, viscous)" << fm.first() << nl
<< " moment(pressure, viscous)" << fm.second() << nl
<< endl;
}
}
}
}
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)
{
label patchi = iter.key();
vectorField Md = mesh.C().boundaryField()[patchi] - CofR_;
vectorField pf =
mesh.Sf().boundaryField()[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());
return fm;
}
// ************************************************************************* //

View File

@ -0,0 +1,230 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::forces
Description
Calculates the forces and moments by integrating the pressure and
skin-friction forces over a given list of patches.
Member function calcForcesMoment()calculates and returns the forces and
moments.
Member function forces::write() calls calcForcesMoment() and writes the
forces and moments into the file \<timeDir\>/forces.dat
SourceFiles
forces.C
IOforces.H
\*---------------------------------------------------------------------------*/
#ifndef forces_H
#define forces_H
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "HashSet.H"
#include "Tuple2.H"
#include "OFstream.H"
#include "Switch.H"
#include "pointFieldFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class forces Declaration
\*---------------------------------------------------------------------------*/
class forces
{
public:
// Tuple which holds the pressure (.first()) and viscous (.second) forces
typedef Tuple2<vector, vector> pressureViscous;
// Tuple which holds the forces (.first()) and moment (.second)
// pressure/viscous forces Tuples.
typedef Tuple2<pressureViscous, pressureViscous> forcesMoments;
//- Sum operation class to accumulate the pressure, viscous forces and moments
class sumOp
{
public:
forcesMoments operator()
(
const forcesMoments& fm1,
const forcesMoments& fm2
) const
{
return forcesMoments
(
pressureViscous
(
fm1.first().first() + fm2.first().first(),
fm1.first().second() + fm2.first().second()
),
pressureViscous
(
fm1.second().first() + fm2.second().first(),
fm1.second().second() + fm2.second().second()
)
);
}
};
protected:
// Private data
//- Name of this set of forces,
// Also used as the name of the probes directory.
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Switch to send output to Info as well as to file
Switch log_;
// Read from dictonary
//- Patches to integrate forces over
labelHashSet patchSet_;
//- Name of pressure field
word pName_;
//- Name of velocity field
word UName_;
//- Reference density needed for incompressible calculations
scalar rhoRef_;
//- Centre of rotation
vector CofR_;
//- Forces/moment file ptr
autoPtr<OFstream> forcesFilePtr_;
// Private Member Functions
//- If the forces file has not been created create it
void makeFile();
//- Return the effective viscous stress (laminar + turbulent).
tmp<volSymmTensorField> devRhoReff() const;
//- Return rhoRef if the pressure field is dynamic, i.e. p/rho
// otherwise return 1
scalar rho(const volScalarField& p) const;
//- Disallow default bitwise copy construct
forces(const forces&);
//- Disallow default bitwise assignment
void operator=(const forces&);
//- Output file header information
virtual void writeFileHeader();
public:
//- Runtime type information
TypeName("forces");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
forces
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor
virtual ~forces();
// Member Functions
//- Return name of the set of forces
virtual const word& name() const
{
return name_;
}
//- Read the forces data
virtual void read(const dictionary&);
//- Execute
virtual void execute();
//- Write the forces
virtual void write();
//- Calculate and return forces and moment
virtual forcesMoments calcForcesMoment() const;
//- 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 "forcesFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(forcesFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
forcesFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::forcesFunctionObject
Description
FunctionObject wrapper around forces to allow them to be created via the
functions list within controlDict.
SourceFiles
forcesFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef forcesFunctionObject_H
#define forcesFunctionObject_H
#include "forces.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<forces> forcesFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //