mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new processorField function object - outputs field of procesor ID
This commit is contained in:
@ -18,6 +18,9 @@ fieldValues/cellSource/cellSourceFunctionObject.C
|
||||
nearWallFields/nearWallFields.C
|
||||
nearWallFields/nearWallFieldsFunctionObject.C
|
||||
|
||||
processorField/processorField.C
|
||||
processorField/processorFieldFunctionObject.C
|
||||
|
||||
readFields/readFields.C
|
||||
readFields/readFieldsFunctionObject.C
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOprocessorField
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for processorField.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOprocessorField_H
|
||||
#define IOprocessorField_H
|
||||
|
||||
#include "processorField.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<processorField> IOprocessorField;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,35 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object postProcessingDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
functions
|
||||
{
|
||||
processorField1
|
||||
{
|
||||
// Type of functionObject
|
||||
type processorField;
|
||||
|
||||
// Where to load it from (if not already in solver)
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
|
||||
// Function object enabled flag
|
||||
enabled true;
|
||||
|
||||
// When to output the average fields
|
||||
outputControl outputTime;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorField.H"
|
||||
#include "dictionary.H"
|
||||
#include "Pstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::processorField, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::processorField::processorField
|
||||
(
|
||||
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 otherise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"processorField::processorField"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::processorField::~processorField()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::processorField::read(const dictionary& dict)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::processorField::execute()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::processorField::end()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::processorField::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
volScalarField procField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"processorID",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("procI", dimless, Pstream::myProcNo())
|
||||
);
|
||||
|
||||
procField.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,146 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::processorField
|
||||
|
||||
Description
|
||||
Writes a scalar field whose value is the local processor ID. Output
|
||||
field name is processorID.
|
||||
|
||||
SourceFiles
|
||||
processorField.C
|
||||
IOprocessorField.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef processorField_H
|
||||
#define processorField_H
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "coordinateSystem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class processorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class processorField
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of nearWallFields object
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
processorField(const processorField&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const processorField&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("processorField");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
processorField
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~processorField();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the processorField object
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the input 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();
|
||||
|
||||
//- 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorFieldFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(processorFieldFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
processorFieldFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::processorFieldFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around processorField to allow
|
||||
them to be created via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
processorFieldFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef processorFieldFunctionObject_H
|
||||
#define processorFieldFunctionObject_H
|
||||
|
||||
#include "processorField.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<processorField>
|
||||
processorFieldFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorField.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
#include "transformGeometricField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::processorField::transformField
|
||||
(
|
||||
const Type& field
|
||||
) const
|
||||
{
|
||||
const word& fieldName = field.name() + "Transformed";
|
||||
|
||||
dimensionedTensor R("R", field.dimensions(), coordSys_.R());
|
||||
|
||||
if (obr_.foundObject<Type>(fieldName))
|
||||
{
|
||||
Type& transField =
|
||||
const_cast<Type&>(obr_.lookupObject<Type>(fieldName));
|
||||
|
||||
transField == field;
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
Foam::transform(transField, R, transField);
|
||||
}
|
||||
|
||||
transField.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Type& transField = obr_.store
|
||||
(
|
||||
new Type
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
field
|
||||
)
|
||||
);
|
||||
|
||||
forAll(field, i)
|
||||
{
|
||||
Foam::transform(transField, R, transField);
|
||||
}
|
||||
|
||||
transField.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::processorField::transform
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
||||
|
||||
if (obr_.foundObject<vfType>(fieldName))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
|
||||
}
|
||||
else if (obr_.foundObject<sfType>(fieldName))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< type() << ": Field " << fieldName << " already in database"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject fieldHeader
|
||||
(
|
||||
fieldName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == vfType::typeName
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<vfType>(obr_.lookupObject<vfType>(fieldName));
|
||||
}
|
||||
else if
|
||||
(
|
||||
fieldHeader.headerOk()
|
||||
&& fieldHeader.headerClassName() == sfType::typeName
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< type() << ": Field " << fieldName << " read from file"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
transformField<sfType>(obr_.lookupObject<sfType>(fieldName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user