CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Code To Compute Nusselt # on wall (https://www.cfd-online.com/Forums/openfoam/78854-code-compute-nusselt-wall.html)

deji August 4, 2010 02:33

Code To Compute Nusselt # on wall
 
Hey there Foamers. I am writing a post-processor to compute the mean Nusselt number on a wall in a turbulent flow (LES). I am getting the following error:

wallHeatRates.C: In function ‘int main(int, char**)’:
wallHeatRates.C:99: error: ‘obr_’ was not declared in this scope
wallHeatRates.C:99: error: expected primary-expression before ‘>’ token
make: *** [Make/linuxGccDPOpt/wallHeatRates.o] Error 1

Here is my code wallHeatRates.C

Code:

#include "fvCFD.H" //adds file prior to compiling source
#include "makeGraph.H"
#include <cmath>
#include "LESModel.H"
#include "wallHeatRates.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
  defineTypeNameAndDebug(wallHeatRates,0);
// addNamedToRunTimeSelectionTable(wallHeatRates);
}

//**************Constructor definition*********//

Foam::wallHeatRates::wallHeatRates
(
    const objectRegistry& obr
)
: obr_(obr)
{
}

Foam::wallHeatRates::~wallHeatRates()  //Destructor
{
}
// int main(int argc, char *argv[])

 int main(int argc, char **argv)
{
    timeSelector::addOptions();
#  include "setRootCase.H"  //checks if run is scalar or parallel to distribute arguments accordingly
#  include "createTime.H"    //cpu,clock time stuff,access to constant dir.
    instantList timeDirs = timeSelector::select0(runTime, args);
#  include "createMesh.H" //required for mesh info.,interpolation,mesh stuff....

//    const word& gFormat = runTime.graphFormat();

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);
 
        Info<< "Time = " << runTime.timeName() << endl;

        IOobject TMeanheader
        (
            "TMean",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        // Check T exists
        if (TMeanheader.headerOk())
        {
            mesh.readUpdate();

            Info<< " Reading TMean Field" << endl;

            volScalarField TMean(TMeanheader, mesh);

            Info<< " Calculating wallGradTMean" << endl;

            Info << "Reading LES Properties" << endl;
   
            const Foam::compressible::LESModel & sgs = obr_.lookupObject<compressible::LESModel>("LESProperties");//<---
             
            label patchK = mesh.boundaryMesh().findPatchID("wallHot"); //specifies the patch to compute dT/dn
         
            const scalarField alphaEffw = sgs.alphaEff()().boundaryField()[patchK];
           
        const scalarField alphaw = sgs.alpha().boundaryField()[patchK];
               
            scalarField GradTw = TMean.boundaryField()[patchK].snGrad();

            direction d_;  //axis direction,

            d_= Foam::point::Z;

            const scalarField Xv = mesh.boundaryMesh()[patchK].faceCentres().component(d_);

            label length = Xv.size();
           
            for (label i=0;i<length;i++)         
            {
              //  makeGraph( Xv[i], magGradT[i],"dTdn",runTime.path(), gFormat );
              //  Info << "Height" << tab << Xv[i] << tab << "dTdn" << tab << GradTw[i] <<endl;
            }             
         
            Info << "Spatially Average in Spanwise Direction" << endl;

            scalarField Xv_tmp(Xv);
           
            Foam::sort(Xv_tmp);

            label nbVerticalPoint = 1;
       
            scalarField Xv_mean(length);
 
            Xv_mean[0] = Xv_tmp[0];
           
            for(label i=1; i<length; i++)
            {
                if((Xv_tmp[i] - Xv_mean[nbVerticalPoint-1]) > 1e-6)
                  {
                    Xv_mean[nbVerticalPoint++] = Xv_tmp[i];
                  }
            }

            scalarField GradTwMean(nbVerticalPoint);
           
            for(label j=0; j<nbVerticalPoint; j++)
            {
                  GradTwMean[j] = 0.0;
            }
 
            for(label i=0; i<length; i++)
            {
                label index = -1;
                for(label j = 0; j< nbVerticalPoint; j++)
                {
                 
                    //if(((Xv_tmp[i] - Xv_mean[j]) < 1e-6) || ((Xv_tmp[i] - Xv_mean[j]) > 1e-6))
                    if( mag(Xv_tmp[i] - Xv_mean[j]) < 1e-6 )
                    {
                          index= j ;
                          break;
                    }
                }
                GradTwMean[index] += GradTw[i];
            }
 
            for (label j= 0; j< nbVerticalPoint; j++)
            {     
                GradTwMean[j] /= ceil(length/nbVerticalPoint);
                // Info<<Xv_mean[j]<<tab<<GradTwMean[j]<<endl;
            }
                 
        }

        else

        {
            Info<< "No TMean" << endl;
        }
    }
 
    Info<< "End" << endl;

    return 0;
}

I do have a header file as well called wallHeatRates.H where I defined the wallHeatRates constructor. The error is pointing to this line that has
const Foam::compressible::LESModel & sgs = obr_.lookupObject<compressible::LESModel>("LESProp erties");

Can someone help me out here as I am just working my way up in OpenFOAM programming.

deji August 4, 2010 02:34

Here is the header file wallHeatRates.C
Code:

#ifndef wallHeatRates_H
#define wallHeatRates_H
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "pointFieldFwd.H"
//**************************************************//

namespace Foam
{

class objectRegistry; //Forward declaration

class wallHeatRates  //Declare wallHeatRates class
{
protected:

    const objectRegistry& obr_; //obr_ defined only within class wallHeatRates 

    //- Disallow default bitwise copy construct
    wallHeatRates(const wallHeatRates&);

    //- Disallow default bitwise assignment
    void operator=(const wallHeatRates&);
 
public:
    //Runtime type information
    TypeName ("wallHeatRates");

      //Constructor declaration
      wallHeatRates
      (
        const objectRegistry&
      );

      //Destructor
    virtual ~wallHeatRates();


};

}; //end namespace Foam

#endif
//**************************************************************************//



All times are GMT -4. The time now is 16:29.