CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   write out nusselt number (gradient of T, respectively) for timesteps (https://www.cfd-online.com/Forums/openfoam-programming-development/69832-write-out-nusselt-number-gradient-t-respectively-timesteps.html)

santos March 12, 2016 18:33

Hi Ram,

The solver was developed in 2009, back then OpenFOAM was at version 1.5 - this is why it does not compile in more recent versions.

I suggest you start from simpleFoam, and add the scalar equations in the same way you can see in simpleScalarFoam. It is not too difficult (the Programmers guide is a very good starting point to understand where and how to start).

Regards,
Jose

Scram_1 March 12, 2016 18:50

Hello Santos!
I added the temperature field to the icoFoam solver and it's working just fine. I think the problem was with my computer's anti-virus. I re-installed it and now I'm able to compile my solver without any glitches.
Thanks!!

Scram_1 March 12, 2016 19:45

Hey,
There's another roadblock that I've hit:( I've added temperature in the foamDataToFluentDict file. When I do foamDataToFuent, OpenFOAM reads the temperature field and I can see the temperature in the .dat file along with U and p. (Btw I've executed foamMeshToFluent as well) However, when I open the case file in Fluent and then the .dat file, I'm not able to see the temperature contour. I can select velocity and pressure but not the temperature. I'm stuck and don't know whether this is another bug or if I'm doing something wrong.
Thanks.

Ram

ssboss March 27, 2016 22:27

openfoam 2.2.2, not working with this
 
Hello guys

I have a modified simpleFoam solver with temperature scalar transport equation implemented. I now want to calculate the temperature gradient at wall surfaces. I followed Santos' codes in post #4 on this thread and included his codes into my solver. I am now getting a compilation error that says:

simpleEnergySourceFoamtest.C:189:17: error: no matching function for call to ‘Foam::dimensioned<Foam::Vector<double> >::dimensioned(const char [6], Foam::dimensionSet, int)’

I am not sure what 189:17 means, it seems to stay the same in the error message even after I make changes to the solver.

Can anyone please help point me to the right direction? I am using openfoam 2.2.2

Garfield March 28, 2016 15:47

Hi, Santos
Thanks for your help, and recently, I try to compile a function to calculate local Nusselt Number, in which I need to write a if statement to see whether the local surface flux = 0. As below
if (patchHeatFlux[patchi]==0)
NusseltNumber.boundaryField()[patchi] = 0;

While we I compile it, it report the error:
error: passing ‘const Foam::fvsPatchField<double>’ as ‘this’ argument of ‘void Foam::fvsPatchField<Type>::operator==(const Type&) [with Type = double]’ discards qualifiers [-fpermissive]
if (patchHeatFlux[patchi]==0)
^
NusseltCalc.C:139:39: error: could not convert ‘(&(& patchHeatFlux)->Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::GeometricBoundaryField::<anony mous>.Foam::FieldField<Foam::fvsPatchField, double>::<anonymous>.Foam::PtrList<T>::operator[]<Foam::fvsPatchField<double> >(patchi))->Foam::fvsPatchField<Type>::operator==<double>(( * &0.0))’ from ‘void’ to ‘bool’
if (patchHeatFlux[patchi]==0)
^
It seems the patchHeatFlux[patchi] is a special data type, Do you have any suggestion to make that if statement work?
Thanks a lot

vnarayana April 28, 2016 09:19

finding nusselt number
 
Dear Joes Santos,
i am using ubuntu 15.04, i want to know nusselt number at the wall and mean . i am using buoyantBoussinesqSimpleFoam. i made some changes in WallHeatFlux folder. i dont have any problem with coding.
please tell me while we are running the solver (buoyantBoussinesqSimpleFoam),
Do i change any TRANSPORT PROPERTIES / CONTROL DICT ? to get the Nusselt number ?
if so please tell me !

Thanks and Regards

Scram_1 May 7, 2016 10:48

Hey,
Has anyone written a code to calculate the Nusselt Number for laminar forced convection for an incompressible fluid?
I have modified the icoFoam solver to solve the energy equation as well. I want to calculate the Nusselt Number now. Also, to calculate the Nusselt Number, the bulk temperature of the fluid at that cross section has to be found. Can someone guide me in this regard?

Thanks!!
Ram

srv537 December 30, 2016 15:52

Quote:

Originally Posted by Scram_1 (Post 588524)
Hi Santos,
I tried compiling simpleScalarFoam but its throwing up some errors which I'm not able to correct.
This is the error I'm geting. There is no simpleScalarFoam.o file in the Make directory. I'm using OpenFOAM 2.3x on Windows (Cygwin) if that's of any help

csriram91@SRIRAM-PC /cygdrive/c/Users/csriram91/Desktop/simpleScalarFoam
$ cd /opt/OpenFOAM/OpenFOAM-2.3.x/applications/solvers/incompressible/simpleScalarFoam

csriram91@SRIRAM-PC /opt/OpenFOAM/OpenFOAM-2.3.x/applications/solvers/incompressible/simpleScalarFoam
$ wclean

csriram91@SRIRAM-PC /opt/OpenFOAM/OpenFOAM-2.3.x/applications/solvers/incompressible/simpleScalarFoam
$ wmake
Making dependency files...
In file included from /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/faceZoneMesh.H:33:0,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/polyMesh.H:56,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/fvMesh.H:50,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/fvCFD.H:7,
from simpleScalarFoam.C:33:
/opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/faceZone.H:46:32: fatal error: primitiveFacePatch.H: No such file or directory
#include "primitiveFacePatch.H"
^
compilation terminated.
SOURCE=simpleScalarFoam.C ; x86_64-w64-mingw32-g++ -m64 -Dcygwin64 -DWM_DP -DMSWIN -DLITTLE_ENDIAN -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -O3 -DNDEBUG -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/turbulenceModels/RAS -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/transportModels -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-2.3.x/src/OSspecific/MSWindows/lnInclude -c $SOURCE -o Make/cygwin64mingw-w64DPOpt/simpleScalarFoam.o
In file included from /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/faceZoneMesh.H:33:0,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/polyMesh.H:56,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/fvMesh.H:50,
from /opt/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/fvCFD.H:7,
from simpleScalarFoam.C:33:
/opt/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/faceZone.H:46:32: fatal error: primitiveFacePatch.H: No such file or directory
#include "primitiveFacePatch.H"
^
compilation terminated.
simpleScalarFoam.dep:3: recipe for target 'Make/cygwin64mingw-w64DPOpt/simpleScalarFoam.o' failed
make: *** [Make/cygwin64mingw-w64DPOpt/simpleScalarFoam.o] Error 1

csriram91@SRIRAM-PC /opt/OpenFOAM/OpenFOAM-2.3.x/applications/solvers/incompressible/simpleScalarFoam

Thanks!
Ram


Hi ram,

did you solve it?
actually i am facing the same type of problem i am using opefoam4, pls help me to solve it.

thanks

srv537 December 30, 2016 15:54

2 Attachment(s)
i tried to find gradT same as mention in this thread but i am getting error, files are attached.

srv@srv:~/OpenFOAM/srv-4.1/applications/solvers/nicoTempFoam$ wmake
Making dependency list for source file nicoTempFoam.C
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c nicoTempFoam.C -o Make/linux64GccDPInt32Opt/nicoTempFoam.o
In file included from nicoTempFoam.C:47:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:89:12: error: expected primary-expression before ‘)’ token
);
^
nicoTempFoam.C:136:31: error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument discards qualifiers [-fpermissive]
gradT.boundaryField()[patchi] = T.boundaryField()[patchi].snGrad();
^
In file included from /opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.H:592:0,
from /opt/openfoam4/src/finiteVolume/lnInclude/volFields.H:40,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:304,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolate.H:41,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvc.H:39,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:8,
from nicoTempFoam.C:33:
/opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.C:395:6: note: in call to ‘void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = double]’
void Foam::fvPatchField<Type>::operator=
^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/nicoTempFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/nicoTempFoam.o] Error 1

Zeppo December 31, 2016 04:42

Quote:

Originally Posted by srv537 (Post 631624)
In file included from nicoTempFoam.C:47:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:89:12: error: expected primary-expression before ‘)’ token
);
^

Redundant comma.
Code:

        volScalarField gradT
          (
                IOobject
                (
                    "gradT",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                mesh,
          );

==>
Code:

        volScalarField gradT
          (
                IOobject
                (
                    "gradT",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                mesh
          );


srv537 December 31, 2016 07:59

2 Attachment(s)
Hello Zeppo

i deleted that comma and tried to wmake but still i am getting error

/OpenFOAM/srv-4.1/applications/solvers/nicoTempFoam$ wmake
Making dependency list for source file nicoTempFoam.C
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c nicoTempFoam.C -o Make/linux64GccDPInt32Opt/nicoTempFoam.o
nicoTempFoam.C: In function ‘int main(int, char**)’:
nicoTempFoam.C:136:31: error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument discards qualifiers [-fpermissive]
gradT.boundaryField()[patchi] = T.boundaryField()[patchi].snGrad();
^
In file included from /opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.H:592:0,
from /opt/openfoam4/src/finiteVolume/lnInclude/volFields.H:40,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:304,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolate.H:41,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvc.H:39,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:8,
from nicoTempFoam.C:33:
/opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.C:395:6: note: in call to ‘void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = double]’
void Foam::fvPatchField<Type>::operator=
^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/nicoTempFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/nicoTempFoam.o] Error 1

srv537 December 31, 2016 08:08

I am using openfoam4, in my code if i delete

gradT.boundaryField()[patchi]=T.boundaryField()[patchi].snGrad();

then wmake works perfectly, so the problem is only in this line execution to calculating gradT.

and if i use to define dimension of gradT

Info<< "Reading field gradT\n" << endl;
volScalarField gradT
(
IOobject
(
"gradT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
dimensionedScalar
(
"gradT",
DT.dimensions()/dimLength,
0
)

);

then the Error is

srv@srv:~/OpenFOAM/srv-4.1/applications/solvers/nicoTempFoam$ wmake
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c nicoTempFoam.C -o Make/linux64GccDPInt32Opt/nicoTempFoam.o
In file included from nicoTempFoam.C:47:0:
createFields.H: In function ‘int main(int, char**)’:
createFields.H:91:5: error: expected ‘)’ before ‘dimensionedScalar’
dimensionedScalar
^
nicoTempFoam.C:136:30: error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument discards qualifiers [-fpermissive]
gradT.boundaryField()[patchi]=T.boundaryField()[patchi].snGrad();
^
In file included from /opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.H:592:0,
from /opt/openfoam4/src/finiteVolume/lnInclude/volFields.H:40,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:304,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolate.H:41,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvc.H:39,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:8,
from nicoTempFoam.C:33:
/opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.C:395:6: note: in call to ‘void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = double]’
void Foam::fvPatchField<Type>::operator=
^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/nicoTempFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/nicoTempFoam.o] Error 1

Zeppo December 31, 2016 09:30

Code:

Info<< "Reading field gradT\n" << endl;
volScalarField gradT
(
IOobject
(
"gradT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
dimensionedScalar
(
"gradT",
DT.dimensions()/dimLength,
0
)

);

==>
Code:

Info<< "Reading field gradT\n" << endl;
volScalarField gradT
(
IOobject
(
"gradT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"gradT",
DT.dimensions()/dimLength,
0
)

);


srv537 December 31, 2016 09:50

Sir here DT is thermal diffusivity or deltaT?

code

Info<< "Reading field gradT\n" << endl;
volScalarField gradT
(
IOobject
(
"gradT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"gradT",
DT.dimensions()/dimLength,
0
)

);


i tried as you suggested but still i am getting error

~/OpenFOAM/srv-4.1/applications/solvers/nicoTempFoam$ wmake
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam4/src/finiteVolume/lnInclude -I/opt/openfoam4/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam4/src/OpenFOAM/lnInclude -I/opt/openfoam4/src/OSspecific/POSIX/lnInclude -fPIC -c nicoTempFoam.C -o Make/linux64GccDPInt32Opt/nicoTempFoam.o
nicoTempFoam.C: In function ‘int main(int, char**)’:
nicoTempFoam.C:136:30: error: passing ‘const Foam::fvPatchField<double>’ as ‘this’ argument discards qualifiers [-fpermissive]
gradT.boundaryField()[patchi]=T.boundaryField()[patchi].snGrad();
^
In file included from /opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.H:592:0,
from /opt/openfoam4/src/finiteVolume/lnInclude/volFields.H:40,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.C:27,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolationScheme.H:304,
from /opt/openfoam4/src/finiteVolume/lnInclude/surfaceInterpolate.H:41,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvc.H:39,
from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:8,
from nicoTempFoam.C:33:
/opt/openfoam4/src/finiteVolume/lnInclude/fvPatchField.C:395:6: note: in call to ‘void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = double]’
void Foam::fvPatchField<Type>::operator=
^
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/nicoTempFoam.o' failed
make: *** [Make/linux64GccDPInt32Opt/nicoTempFoam.o] Error 1
srv@srv:~/OpenFOAM/srv-4.1/applications/solvers/nicoTempFoam$

Zeppo December 31, 2016 10:44

Code:

gradT.boundaryField()[patchi]=T.boundaryField()[patchi].snGrad();
==>
Code:

gradT.boundaryFieldRef()[patchi]=T.boundaryFieldRef()[patchi].snGrad();

srv537 December 31, 2016 12:34

Quote:

Originally Posted by Zeppo (Post 631668)
Code:

gradT.boundaryField()[patchi]=T.boundaryField()[patchi].snGrad();
==>
Code:

gradT.boundaryFieldRef()[patchi]=T.boundaryFieldRef()[patchi].snGrad();


Thank you so much sir
it is working perfectly :) :D.

Sir last question,

label patchi = mesh.boundaryMesh().findPatchID("HEATEDWALL");

if i change the geometry and name of patchi (surface) then i have to go to solver and modify its patchi name and then use wmake everytime.
is there any solution for this so i dont need to change solver everytime.

thanks again sir

Zeppo December 31, 2016 14:10

Quote:

Originally Posted by srv537 (Post 631675)
label patchi = mesh.boundaryMesh().findPatchID("HEATEDWALL");

if i change the geometry and name of patchi (surface) then i have to go to solver and modify its patchi name and then use wmake everytime.
is there any solution for this so i dont need to change solver everytime.

Yes, you can do it in the FOAM-way: create a dictionary-file somewhere in your case directory with
Code:

patchName yourPatchName;
In your code write:
Code:

const dictionary dic ("ralative/path/to/the/file/with/your/patchName");
if(dic.found("patchName")
{
    const word patchName = dic.lookup("patchName");
    const label patchi = mesh.boundaryMesh().findPatchID(patchName);
}


srv537 January 2, 2017 04:02

i have added in my solver

//specify patch name

const dictionary dic ("/home/saurav/OpenFOAM/srv-4.1/run/icoTempFoam/constant/patchName");
if(dic.found("patchName"))
{
const word patchName = dic.lookup("patchName");
const label patchi = mesh.boundaryMesh().findPatchID(patchName);
}


i have created a file in constant/patchName

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object patchName;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

patchName heatedWall;


// ************************************************** *********************** //



but i am getting error


Calculating gradT
#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigSegv::sigHandler(int) at ??:?
#2 ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3 ? at ??:?
#4 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#5 ? at ??:?
Segmentation fault (core dumped)

Zeppo January 2, 2017 04:59

Now you have to locate yourself the specific line in the code which causes the error.


All times are GMT -4. The time now is 02:32.