CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Problem with using function object to compute Nu number in parallel.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 9, 2011, 20:17
Default Problem with using function object to compute Nu number in parallel.
  #1
Member
 
Yuri Feldman
Join Date: Mar 2011
Posts: 30
Rep Power: 15
feldy77 is on a distinguished road
Hi ,
I use a function object tool to compute Nu number directly during the the simulation (not as a postprocessing utility that works with a saved data after the simulation is done). For this purpose I use a function object tool. Attached please see three files: Nu.H, Nu.C, and controlDict:

Nu.H-----------------------------------------------------------
#ifndef Nu_H
#define Nu_H
#include "pointFieldFwd.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class Nu Declaration
\*---------------------------------------------------------------------------*/
class Nu
{
//- on/off switch
bool active_;
//- Name of this set of Nu,
// Also used as the name of the probes directory.
word name_;
const objectRegistry& obr_;
//- Maximal temperature
scalar Tmax_;
//- Minimal temperature
scalar Tmin_;
//-Nusselt number
scalar Nusselt_;
// External radius Ro
scalar Ro_;
//Inyternal radius Ri
scalar Ri_;
//Gap width
scalar L_;
//Temperature difference
scalar DT_;
//name for the temperature field
word TName_;

//- Disallow default bitwise copy construct
Nu(const Nu&);
//- Disallow default bitwise assignment
void operator=(const Nu&);

const fvMesh& mesh();
public:
//- Runtime type information
TypeName("Nu");
 
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
Nu
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
 
//- Destructor
virtual ~Nu();
 
// Member Functions
//- Return name of the set of Nu
virtual const word& name() const
{
return name_;
}
//- Read the Nu 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 the Nu
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
// ************************************************** *********************** //
Nu.C

\*---------------------------------------------------------------------------*/
#include "Nu.H"
#include "dictionary.H"
#include "Time.H"
#include "fvCFD.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(Nu, 0);
}
 
 
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Nu::Nu
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
active_(true),
name_(name),
obr_(obr)
{
// Check if the available mesh is an fvMesh otherise deactivate

if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"Foam::Nu::Nu"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating."
<< endl;
}
read(dict);
}
 
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::Nu::~Nu()
{}
 
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::Nu::read(const dictionary& dict)
{
if (active_)
{
dict.lookup("TName")>> TName_;
dict.lookup("Tmax")>>Tmax_;
dict.lookup("Tmin")>>Tmin_;
dict.lookup("Rin") >>Ri_;
dict.lookup("Rout")>>Ro_;
DT_=Tmax_-Tmin_;
L_=Ro_-Ri_;

Info<<"Tmax="<<Tmax_<<endl;
Info<<"Tmin="<<Tmin_<<endl;
Info<<"Rin=" <<Ri_ <<endl;
Info<<"Rout="<<Ro_ <<endl;
 
}
}
 
void Foam::Nu::execute()
{
// Do nothing - only valid on write
}
 
void Foam::Nu::end()
{
// Do nothing - only valid on write
}
 
void Foam::Nu::write()
{
if (active_)
{
const volScalarField& T=
obr_.lookupObject<volScalarField>(TName_);
surfaceScalarField heatFlux =
fvc::snGrad(T);
const surfaceScalarField::GeometricBoundaryField& patchHeatFlux =
heatFlux.boundaryField();
const fvMesh& mesh=refCast<const fvMesh>(obr_);
forAll(patchHeatFlux, patchi)
{
if (isA<wallFvPatch>(mesh.boundary()[patchi]))
{
if (mesh.boundary()[patchi].name()=="internal")
{
Nusselt_ = sum
(
mesh.magSf().boundaryField()[patchi]
*patchHeatFlux[patchi])
*L_/4/3.141592653589793/DT_/Ri_/Ro_;
Info<<Nusselt_;
}
}
}
}

Info<< endl;
}
 
 
// ************************************************** *********************** //
controlDict
libs ("/home/yurifeld/OpenFOAM/yurifeld-1.7.1/lib/linux64GccDPOpt/libuserFunctionObjects.so");
functions
(
Nusselt
{
type Nu;
TName T;
Tmin 293;
Tmax 333;
Rin 0.1;
Rout 0.06667;
outputControl timeStep;
outputInterval 1;
}
);
// ************************************************** *********************** //
The program works perfect when it is runnining in sequential mode, however when I try to run it in parallel it gives me the Nu number only for the zerro processor while I want to get total Nu number which should utilize the sum of all values computed on all the processors. My question is how to make it to do this. I tried to define IO scalar object so that each processor would write its Nu in for in the corresponding time step directory, however I did not suceed to define scalr IO object. If you have any idea please help me to resolve this problem.
Many thanks.
feldy77 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correction number and parallel computing psosnows OpenFOAM Bugs 5 June 17, 2013 21:56
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 14:06
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
air bubble is disappear increasing time using vof xujjun CFX 9 June 9, 2009 08:59
"The high Reynolds number flow is not difficult to compute, the problem is we simply don't know how. wowakai Main CFD Forum 1 November 11, 1998 11:24


All times are GMT -4. The time now is 22:04.