mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: streamLine/wallBoundedStreamLine - minor refactoring to enable new derived functionality
This commit is contained in:
@ -141,11 +141,11 @@ void Foam::functionObjects::streamLineBase::initInterpolations
|
|||||||
{
|
{
|
||||||
if (foundObject<volScalarField>(fieldName))
|
if (foundObject<volScalarField>(fieldName))
|
||||||
{
|
{
|
||||||
nScalar++;
|
++nScalar;
|
||||||
}
|
}
|
||||||
else if (foundObject<volVectorField>(fieldName))
|
else if (foundObject<volVectorField>(fieldName))
|
||||||
{
|
{
|
||||||
nVector++;
|
++nVector;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -509,114 +509,8 @@ void Foam::functionObjects::streamLineBase::trimToBox(const treeBoundBox& bb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||||
|
|
||||||
Foam::functionObjects::streamLineBase::streamLineBase
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const Time& runTime,
|
|
||||||
const dictionary& dict
|
|
||||||
)
|
|
||||||
:
|
|
||||||
fvMeshFunctionObject(name, runTime, dict),
|
|
||||||
dict_(dict)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::functionObjects::streamLineBase::~streamLineBase()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
|
|
||||||
{
|
{
|
||||||
if (&dict_ != &dict)
|
|
||||||
{
|
|
||||||
// Update local copy of dictionary:
|
|
||||||
dict_ = dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
fvMeshFunctionObject::read(dict);
|
|
||||||
|
|
||||||
Info<< type() << " " << name() << ":" << nl;
|
|
||||||
|
|
||||||
dict.lookup("fields") >> fields_;
|
|
||||||
UName_ = dict.lookupOrDefault<word>("U", "U");
|
|
||||||
|
|
||||||
Info<< " Employing velocity field " << UName_ << endl;
|
|
||||||
|
|
||||||
if (!fields_.found(UName_))
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "Velocity field for tracking " << UName_
|
|
||||||
<< " should be present in the list of fields " << fields_
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dict.lookup("trackForward") >> trackForward_;
|
|
||||||
dict.lookup("lifeTime") >> lifeTime_;
|
|
||||||
if (lifeTime_ < 1)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Illegal value " << lifeTime_ << " for lifeTime"
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
trackLength_ = VGREAT;
|
|
||||||
if (dict.readIfPresent("trackLength", trackLength_))
|
|
||||||
{
|
|
||||||
Info<< type() << " : fixed track length specified : "
|
|
||||||
<< trackLength_ << nl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bounds_ = boundBox::invertedBox;
|
|
||||||
if (dict.readIfPresent("bounds", bounds_) && !bounds_.empty())
|
|
||||||
{
|
|
||||||
Info<< " clipping all segments to " << bounds_ << nl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
interpolationScheme_ = dict.lookupOrDefault
|
|
||||||
(
|
|
||||||
"interpolationScheme",
|
|
||||||
interpolationCellPoint<scalar>::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
//Info<< " using interpolation " << interpolationScheme_ << endl;
|
|
||||||
|
|
||||||
cloudName_ = dict.lookupOrDefault<word>("cloud", type());
|
|
||||||
|
|
||||||
sampledSetPtr_.clear();
|
|
||||||
sampledSetAxis_.clear();
|
|
||||||
|
|
||||||
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
|
|
||||||
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::streamLineBase::execute()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::streamLineBase::write()
|
|
||||||
{
|
|
||||||
Log << type() << " " << name() << " write:" << nl;
|
|
||||||
|
|
||||||
|
|
||||||
// Do all injection and tracking
|
|
||||||
track();
|
|
||||||
|
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Append slave tracks to master ones
|
// Append slave tracks to master ones
|
||||||
@ -897,6 +791,147 @@ bool Foam::functionObjects::streamLineBase::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::functionObjects::streamLineBase::resetFieldNames
|
||||||
|
(
|
||||||
|
const word& newUName,
|
||||||
|
const wordList& newFieldNames
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UName_ = newUName;
|
||||||
|
fields_ = newFieldNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::streamLineBase::streamLineBase
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
dict_(dict),
|
||||||
|
fields_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::functionObjects::streamLineBase::streamLineBase
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
dict_(dict),
|
||||||
|
fields_(fieldNames)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::streamLineBase::~streamLineBase()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (&dict_ != &dict)
|
||||||
|
{
|
||||||
|
// Update local copy of dictionary:
|
||||||
|
dict_ = dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
fvMeshFunctionObject::read(dict);
|
||||||
|
|
||||||
|
Info<< type() << " " << name() << ":" << nl;
|
||||||
|
|
||||||
|
UName_ = dict.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
if (fields_.empty())
|
||||||
|
{
|
||||||
|
dict.lookup("fields") >> fields_;
|
||||||
|
|
||||||
|
if (!fields_.found(UName_))
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "Velocity field for tracking " << UName_
|
||||||
|
<< " should be present in the list of fields " << fields_
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " Employing velocity field " << UName_ << endl;
|
||||||
|
|
||||||
|
dict.lookup("trackForward") >> trackForward_;
|
||||||
|
dict.lookup("lifeTime") >> lifeTime_;
|
||||||
|
if (lifeTime_ < 1)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Illegal value " << lifeTime_ << " for lifeTime"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
trackLength_ = VGREAT;
|
||||||
|
if (dict.readIfPresent("trackLength", trackLength_))
|
||||||
|
{
|
||||||
|
Info<< type() << " : fixed track length specified : "
|
||||||
|
<< trackLength_ << nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bounds_ = boundBox::invertedBox;
|
||||||
|
if (dict.readIfPresent("bounds", bounds_) && !bounds_.empty())
|
||||||
|
{
|
||||||
|
Info<< " clipping all segments to " << bounds_ << nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interpolationScheme_ = dict.lookupOrDefault
|
||||||
|
(
|
||||||
|
"interpolationScheme",
|
||||||
|
interpolationCellPoint<scalar>::typeName
|
||||||
|
);
|
||||||
|
|
||||||
|
//Info<< " using interpolation " << interpolationScheme_ << endl;
|
||||||
|
|
||||||
|
cloudName_ = dict.lookupOrDefault<word>("cloud", type());
|
||||||
|
|
||||||
|
sampledSetPtr_.clear();
|
||||||
|
sampledSetAxis_.clear();
|
||||||
|
|
||||||
|
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
|
||||||
|
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::streamLineBase::execute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::streamLineBase::write()
|
||||||
|
{
|
||||||
|
Log << type() << " " << name() << " write:" << nl;
|
||||||
|
|
||||||
|
// Do all injection and tracking
|
||||||
|
track();
|
||||||
|
|
||||||
|
writeToFile();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjects::streamLineBase::updateMesh(const mapPolyMesh& mpm)
|
void Foam::functionObjects::streamLineBase::updateMesh(const mapPolyMesh& mpm)
|
||||||
{
|
{
|
||||||
if (&mpm.mesh() == &mesh_)
|
if (&mpm.mesh() == &mesh_)
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class streamLineBase
|
|||||||
:
|
:
|
||||||
public fvMeshFunctionObject
|
public fvMeshFunctionObject
|
||||||
{
|
{
|
||||||
// Private data
|
protected:
|
||||||
|
|
||||||
//- Seed set engine
|
//- Seed set engine
|
||||||
mutable autoPtr<sampledSet> sampledSetPtr_;
|
mutable autoPtr<sampledSet> sampledSetPtr_;
|
||||||
@ -71,8 +71,6 @@ class streamLineBase
|
|||||||
//- Axis of the sampled points to output
|
//- Axis of the sampled points to output
|
||||||
mutable word sampledSetAxis_;
|
mutable word sampledSetAxis_;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//- Input dictionary
|
//- Input dictionary
|
||||||
dictionary dict_;
|
dictionary dict_;
|
||||||
|
|
||||||
@ -184,6 +182,16 @@ protected:
|
|||||||
//- Do the actual tracking to fill the track data
|
//- Do the actual tracking to fill the track data
|
||||||
virtual void track() = 0;
|
virtual void track() = 0;
|
||||||
|
|
||||||
|
//- Write tracks to file
|
||||||
|
virtual bool writeToFile();
|
||||||
|
|
||||||
|
//- Reset the field names
|
||||||
|
virtual void resetFieldNames
|
||||||
|
(
|
||||||
|
const word& newUName,
|
||||||
|
const wordList& newFieldNames
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -202,6 +210,15 @@ public:
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary and list of fields to sample
|
||||||
|
streamLineBase
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~streamLineBase();
|
virtual ~streamLineBase();
|
||||||
|
|||||||
@ -236,6 +236,20 @@ Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames
|
||||||
|
)
|
||||||
|
:
|
||||||
|
streamLineBase(name, runTime, dict, fieldNames)
|
||||||
|
{
|
||||||
|
read(dict_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine()
|
Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine()
|
||||||
|
|||||||
@ -125,6 +125,17 @@ class wallBoundedStreamLine
|
|||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
wallBoundedStreamLine(const wallBoundedStreamLine&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const wallBoundedStreamLine&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Find wall tet on cell
|
//- Find wall tet on cell
|
||||||
tetIndices findNearestTet
|
tetIndices findNearestTet
|
||||||
(
|
(
|
||||||
@ -133,12 +144,6 @@ class wallBoundedStreamLine
|
|||||||
const label celli
|
const label celli
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
wallBoundedStreamLine(const wallBoundedStreamLine&) = delete;
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const wallBoundedStreamLine&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -156,6 +161,15 @@ public:
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary and list of fields to sample
|
||||||
|
wallBoundedStreamLine
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict,
|
||||||
|
const wordList& fieldNames
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~wallBoundedStreamLine();
|
virtual ~wallBoundedStreamLine();
|
||||||
|
|||||||
@ -121,12 +121,15 @@ public:
|
|||||||
allScalars_(allScalars),
|
allScalars_(allScalars),
|
||||||
allVectors_(allVectors)
|
allVectors_(allVectors)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual ~trackingData()
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
// Private data
|
// Protected data
|
||||||
|
|
||||||
//- Lifetime of particle. Particle dies when reaches 0.
|
//- Lifetime of particle. Particle dies when reaches 0.
|
||||||
label lifeTime_;
|
label lifeTime_;
|
||||||
@ -141,7 +144,7 @@ private:
|
|||||||
List<DynamicList<vector>> sampledVectors_;
|
List<DynamicList<vector>> sampledVectors_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
vector interpolateFields
|
vector interpolateFields
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user