functionObjects/field/fieldCoordinateSystemTransform: simplified, standardized, rationalized
This commit is contained in:
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fieldCoordinateSystemTransform.H"
|
||||
#include "dictionary.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -55,23 +54,10 @@ fieldCoordinateSystemTransform
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_(),
|
||||
coordSys_(obr_, dict)
|
||||
coordSys_(mesh_, dict)
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
Info<< type() << " " << name << ":" << nl
|
||||
@ -89,6 +75,16 @@ Foam::functionObjects::fieldCoordinateSystemTransform::
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word
|
||||
Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return fieldName + ":Transformed";
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::read
|
||||
(
|
||||
const dictionary& dict
|
||||
@ -105,11 +101,8 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
// If necessary load field
|
||||
transform<scalar>(fieldSet_[fieldi]);
|
||||
transform<vector>(fieldSet_[fieldi]);
|
||||
transform<sphericalTensor>(fieldSet_[fieldi]);
|
||||
@ -126,22 +119,11 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::write
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
{
|
||||
const word fieldName = fieldSet_[fieldi] + ":Transformed";
|
||||
|
||||
const regIOobject& field =
|
||||
obr_.lookupObject<regIOobject>(fieldName);
|
||||
|
||||
Info<< " writing field " << field.name() << nl;
|
||||
|
||||
field.write();
|
||||
fvMeshFunctionObject::write(transformFieldName(fieldSet_[fieldi]));
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ Description
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::coordinateSystem
|
||||
|
||||
SourceFiles
|
||||
@ -75,8 +75,7 @@ SourceFiles
|
||||
#ifndef functionObjects_fieldCoordinateSystemTransform_H
|
||||
#define functionObjects_fieldCoordinateSystemTransform_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "coordinateSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -96,15 +95,12 @@ namespace functionObjects
|
||||
|
||||
class fieldCoordinateSystemTransform
|
||||
:
|
||||
public functionObject
|
||||
public fvMeshFunctionObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Fields to transform
|
||||
wordList fieldSet_;
|
||||
|
||||
@ -114,22 +110,16 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return the name of the transformed field
|
||||
word transformFieldName(const word& fieldName) const;
|
||||
|
||||
//- Transform the given field
|
||||
template<class FieldType>
|
||||
void transformField(const FieldType& field);
|
||||
|
||||
//- Transform the given field if has the specified element type
|
||||
template<class Type>
|
||||
void transform(const word& fieldName) const;
|
||||
|
||||
template<class Type>
|
||||
void transformField(const Type& field) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldCoordinateSystemTransform&);
|
||||
void transform(const word& fieldName);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -26,50 +26,23 @@ License
|
||||
#include "fieldCoordinateSystemTransform.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
#include "transformGeometricField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
template<class FieldType>
|
||||
void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
|
||||
(
|
||||
const Type& field
|
||||
) const
|
||||
const FieldType& field
|
||||
)
|
||||
{
|
||||
const word& fieldName = field.name() + ":Transformed";
|
||||
word transFieldName(transformFieldName(field.name()));
|
||||
|
||||
if (!obr_.foundObject<Type>(fieldName))
|
||||
{
|
||||
obr_.store
|
||||
(
|
||||
new Type
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
field
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Type& transField =
|
||||
const_cast<Type&>(obr_.lookupObject<Type>(fieldName));
|
||||
|
||||
transField == field;
|
||||
|
||||
dimensionedTensor R("R", field.dimensions(), coordSys_.R().R());
|
||||
|
||||
Foam::transform(transField, R, transField);
|
||||
|
||||
Info<< " writing field " << transField.name() << nl << endl;
|
||||
|
||||
transField.write();
|
||||
store
|
||||
(
|
||||
transFieldName,
|
||||
Foam::transform(dimensionedTensor(coordSys_.R().R()), field)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -77,12 +50,12 @@ template<class Type>
|
||||
void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (obr_.foundObject<vfType>(fieldName))
|
||||
if (mesh_.foundObject<VolFieldType>(fieldName))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -90,9 +63,12 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
mesh_.lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else if (obr_.foundObject<sfType>(fieldName))
|
||||
else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -100,15 +76,18 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
mesh_.lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
@ -116,7 +95,7 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == vfType::typeName
|
||||
&& fieldHeader.headerClassName() == VolFieldType::typeName
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
@ -125,12 +104,15 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
|
||||
transformField<VolFieldType>
|
||||
(
|
||||
mesh_.lookupObject<VolFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == sfType::typeName
|
||||
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
@ -139,7 +121,10 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
|
||||
transformField<SurfaceFieldType>
|
||||
(
|
||||
mesh_.lookupObject<SurfaceFieldType>(fieldName)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user