mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
re-structuring
This commit is contained in:
@ -117,45 +117,6 @@ void Foam::fieldValues::cellSource::initialise()
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::cellSource::makeFile()
|
||||
{
|
||||
// Create the forces file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/obr_.time().timeName();
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/obr_.time().timeName();
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::cellSource::writeFileHeader()
|
||||
{
|
||||
if (outputFilePtr_.valid())
|
||||
@ -190,16 +151,9 @@ Foam::fieldValues::cellSource::cellSource
|
||||
fieldValue(name, obr, dict, loadFromFiles),
|
||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
cellId_(),
|
||||
outputFilePtr_(NULL)
|
||||
cellId_()
|
||||
{
|
||||
initialise();
|
||||
|
||||
if (active_)
|
||||
{
|
||||
// Create the output file if not already created
|
||||
makeFile();
|
||||
}
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -213,9 +167,11 @@ Foam::fieldValues::cellSource::~cellSource()
|
||||
|
||||
void Foam::fieldValues::cellSource::read(const dictionary& dict)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
// no additional info to read
|
||||
initialise();
|
||||
}
|
||||
}
|
||||
@ -223,13 +179,10 @@ void Foam::fieldValues::cellSource::read(const dictionary& dict)
|
||||
|
||||
void Foam::fieldValues::cellSource::write()
|
||||
{
|
||||
fieldValue::write();
|
||||
|
||||
if (active_)
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
}
|
||||
|
||||
outputFilePtr_()
|
||||
<< obr_.time().value() << tab
|
||||
<< sum(filterField(mesh().V()));
|
||||
|
||||
@ -58,7 +58,6 @@ SourceFiles
|
||||
#include "NamedEnum.H"
|
||||
#include "fieldValue.H"
|
||||
#include "labelList.H"
|
||||
#include "OFstream.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -114,9 +113,6 @@ private:
|
||||
//- Set cells to evaluate based on a patch
|
||||
void setPatchCells();
|
||||
|
||||
//- Create the output file if not already created
|
||||
void makeFile();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -131,9 +127,6 @@ protected:
|
||||
//- Local list of cell IDs
|
||||
labelList cellId_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
|
||||
@ -258,45 +258,6 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::makeFile()
|
||||
{
|
||||
// Create the forces file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/obr_.time().timeName();
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/obr_.time().timeName();
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::writeFileHeader()
|
||||
{
|
||||
if (outputFilePtr_.valid())
|
||||
@ -334,16 +295,9 @@ Foam::fieldValues::faceSource::faceSource
|
||||
faceId_(),
|
||||
facePatchId_(),
|
||||
flipMap_(),
|
||||
outputFilePtr_(NULL),
|
||||
weightFieldName_("undefinedWeightedFieldName")
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
initialise(dict);
|
||||
|
||||
// Create the output file if not already created
|
||||
makeFile();
|
||||
}
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -357,9 +311,10 @@ Foam::fieldValues::faceSource::~faceSource()
|
||||
|
||||
void Foam::fieldValues::faceSource::read(const dictionary& dict)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
initialise(dict);
|
||||
}
|
||||
}
|
||||
@ -367,13 +322,10 @@ void Foam::fieldValues::faceSource::read(const dictionary& dict)
|
||||
|
||||
void Foam::fieldValues::faceSource::write()
|
||||
{
|
||||
fieldValue::write();
|
||||
|
||||
if (active_)
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
}
|
||||
|
||||
outputFilePtr_()
|
||||
<< obr_.time().value() << tab
|
||||
<< sum(filterField(mesh().magSf()));
|
||||
|
||||
@ -66,7 +66,6 @@ SourceFiles
|
||||
#include "NamedEnum.H"
|
||||
#include "fieldValue.H"
|
||||
#include "labelList.H"
|
||||
#include "OFstream.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
@ -125,9 +124,6 @@ private:
|
||||
//- Set faces to evaluate based on a patch
|
||||
void setPatchFaces();
|
||||
|
||||
//- Create the output file if not already created
|
||||
void makeFile();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -148,9 +144,6 @@ protected:
|
||||
//- List of +1/-1 representing face flip map
|
||||
labelList flipMap_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
//- Weight field name - only used for opWeightedAverage mode
|
||||
word weightFieldName_;
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "fieldValue.H"
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,6 +55,73 @@ void Foam::fieldValue::movePoints(const Field<point>&)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::makeFile()
|
||||
{
|
||||
// Create the forces file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
writeFileHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("valueOutput") >> valueOutput_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValue::fieldValue
|
||||
@ -70,7 +138,8 @@ Foam::fieldValue::fieldValue
|
||||
log_(false),
|
||||
sourceName_(dict.lookup("sourceName")),
|
||||
fields_(dict.lookup("fields")),
|
||||
valueOutput_(dict.lookup("valueOutput"))
|
||||
valueOutput_(dict.lookup("valueOutput")),
|
||||
outputFilePtr_(NULL)
|
||||
{
|
||||
// Only active if obr is an fvMesh
|
||||
if (isA<fvMesh>(obr_))
|
||||
@ -103,65 +172,6 @@ Foam::fieldValue::~fieldValue()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::fieldValue::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::objectRegistry& Foam::fieldValue::obr() const
|
||||
{
|
||||
return obr_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fieldValue::active() const
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::Switch& Foam::fieldValue::log() const
|
||||
{
|
||||
return log_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::word& Foam::fieldValue::sourceName() const
|
||||
{
|
||||
return sourceName_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::wordList& Foam::fieldValue::fields() const
|
||||
{
|
||||
return fields_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::Switch& Foam::fieldValue::valueOutput() const
|
||||
{
|
||||
return valueOutput_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::fvMesh& Foam::fieldValue::mesh() const
|
||||
{
|
||||
return refCast<const fvMesh>(obr_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("valueOutput") >> valueOutput_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValue::execute()
|
||||
{
|
||||
// Do nothing
|
||||
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
|
||||
#include "Switch.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -82,9 +83,18 @@ protected:
|
||||
//- Output field values flag
|
||||
Switch valueOutput_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Functions to be over-ridden from IOoutputFilter class
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
|
||||
//- Write the output file header
|
||||
virtual void writeFileHeader() = 0;
|
||||
|
||||
//- Update mesh
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
@ -117,28 +127,28 @@ public:
|
||||
// Access
|
||||
|
||||
//- Return the name of the geometric source
|
||||
const word& name() const;
|
||||
inline const word& name() const;
|
||||
|
||||
//- Return the reference to the object registry
|
||||
const objectRegistry& obr() const;
|
||||
inline const objectRegistry& obr() const;
|
||||
|
||||
//- Return the active flag
|
||||
bool active() const;
|
||||
inline bool active() const;
|
||||
|
||||
//- Return the switch to send output to Info as well as to file
|
||||
const Switch& log() const;
|
||||
inline const Switch& log() const;
|
||||
|
||||
//- Return the source name
|
||||
const word& sourceName() const;
|
||||
inline const word& sourceName() const;
|
||||
|
||||
//- Return the list of field names
|
||||
const wordList& fields() const;
|
||||
inline const wordList& fields() const;
|
||||
|
||||
//- Return the output field values flag
|
||||
const Switch& valueOutput() const;
|
||||
inline const Switch& valueOutput() const;
|
||||
|
||||
//- Helper function to return the reference to the mesh
|
||||
const fvMesh& mesh() const;
|
||||
inline const fvMesh& mesh() const;
|
||||
|
||||
|
||||
// Function object functions
|
||||
@ -146,6 +156,9 @@ public:
|
||||
//- Read from dictionary
|
||||
virtual void read(const dictionary& dict);
|
||||
|
||||
//- Write to screen/file
|
||||
virtual void write();
|
||||
|
||||
//- Execute
|
||||
virtual void execute();
|
||||
|
||||
@ -160,6 +173,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "fieldValueI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-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 "fieldValue.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::word& Foam::fieldValue::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::objectRegistry& Foam::fieldValue::obr() const
|
||||
{
|
||||
return obr_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::fieldValue::active() const
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::Switch& Foam::fieldValue::log() const
|
||||
{
|
||||
return log_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::word& Foam::fieldValue::sourceName() const
|
||||
{
|
||||
return sourceName_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::wordList& Foam::fieldValue::fields() const
|
||||
{
|
||||
return fields_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::Switch& Foam::fieldValue::valueOutput() const
|
||||
{
|
||||
return valueOutput_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::fvMesh& Foam::fieldValue::mesh() const
|
||||
{
|
||||
return refCast<const fvMesh>(obr_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user