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

implement heat flux

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2011, 17:19
Unhappy implement heat flux
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
hey together,

i am using OF 1.7.x and working with OF for a half year now.
Using the chtMultiRegionSimpleFoam to solve the heat transfer from fluid to solid and
solid to solid.

The solutions are very good and now i want to implement the heat flux in the cht..Foam so that i can visual it like U / rho / etc in paraview.

First of all i want to implement the heat flux in my solid regions.
Code:
Q = lambda / delta * A * dT  =  K * A * dT

and q = Q/A   

q = K * dT     (is this correct?) 

 q = - K * grad(T)
I changed this files in the ~/applications/solver/heatTransfer/chtMultiRegionSimpleFoam/solid/:

createSolidFields.H
Code:
        Info<< " Adding to fluxs\n" << endl;
        fluxs.set
        (
            i,
            new volScalarField
            (
                IOobject
                (
                    "flux",
                    runTime.timeName(),
                    solidRegions[i],
                    IOobject::MUST_READ,
                    IOobject::AUTO_WRITE
                ),
                solidRegions[i]
            )
        );


setRegionSolidFields.H
Code:
volScalarField& flux = fluxs[i];

solveSolid.H
Code:
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix tEqn ( -fvm::laplacian(K, T) ); tEqn.relax(); eqnResidual = tEqn.solve().initialResidual(); maxResidual = max(eqnResidual, maxResidual); // solving heatflux fvScalarMatrix fluxEqn ( -K*fvc::grad(T) ); fluxEqn.relax(); eqnResidual = fluxEqn.solve().initialResidual(); maxResidual = max(eqnResidual, maxResidual); }
if i add "-K*fvc::grad(T) i got a error while compiling.

Don 't know how to implement q = K * grad(T)
and if this code is correct ... ??? tried some other codes but always got an error...
Code:
    fvScalarMatrix fluxEqn
        (
          
           -K*fvc::grad(T)
        );
        fluxEqn.relax();
        eqnResidual =          fluxEqn.solve().initialResidual();
        maxResidual = max(eqnResidual, maxResidual);


Its the first time i want to add a equation and i am not sure how i have to implement this? I think i got all wrong or?

Can someone help me - thanks ?

Tobi
Tobi is offline   Reply With Quote

Old   January 19, 2011, 07:19
Default use groovyBC for setting wall heat fluxes
  #2
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
Hi Tobi

I can not immediately see what goes wrong in your code, but I would use groovyBC for setting heat fluxes. No need to rewrite you code, and it is very flexible (parallel run no problem, non-uniform and time dependent heat fluxes possible, only editing in bounary conditions of variables required, etc.). Have a look at my post

http://www.cfd-online.com/Forums/ope...r-restart.html

Regards

Eelco
eelcovv is offline   Reply With Quote

Old   January 19, 2011, 07:31
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Eelco,

thanks for you answer. I ll have a look at your post.

But you said that this is a BC. ? ?
I don 't want to start with a heatflux BC.

Simple expamle. I have two walls parallel and know the temperature t_hot and t_cold. Further i know K and A and now i want to calculate the heat flux in both walls. Is this possible with groovyBC ?

And i know that the compilations error occurs with the following line:


-K*fvc::grad(T)

Hmmm...
But i will have a look at groovyBC.
Thx.

Tobi
Tobi is offline   Reply With Quote

Old   January 19, 2011, 07:46
Default
  #4
Member
 
Fábio César Canesin
Join Date: Mar 2010
Location: Florianópolis
Posts: 67
Rep Power: 16
Canesin is on a distinguished road
You have to change the dictionary setting...

"MUST_READ" .. you SHOULDN'T read the that dict.. you need only to write in it.


Them, in the equation what you really have is: -K*grad(T) = 0 ... what you want is: flux = -K*grat(T).

That should do.
Canesin is offline   Reply With Quote

Old   January 19, 2011, 08:24
Default surfaceScalarField
  #5
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
Hi Toby

Sorry, I assumed you want to impose a heat flux at a wall. No, I don't think you can use groovyBC for internal faces.

Perhaps something is going wrong because you are mixing up a surfaceScalarField (i.e. scalar values defined at the cell faces) and volumeScalarField (i.e. scalar values defined at the cell centres).

Have a look at the wallHeatFlux utility for instance. Here you can see the difference between the both. More details can be found in the programmers Guide.

Good luck!

Regards,
Eelco
eelcovv is offline   Reply With Quote

Old   January 19, 2011, 08:54
Default
  #6
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

@eelcovv don 't matter but i 'll have a look at your advice.

@Canesin:

thats true - i just have to write in it so i changed the syntax to: NO_READ
I suppose that the flux - file is added automatically.
Further i changed the solveSolid.H:

Code:
    for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
    {
        fvScalarMatrix tEqn
        (
            -fvm::laplacian(K, T)
        );
        tEqn.relax();
        eqnResidual = tEqn.solve().initialResidual();
        maxResidual = max(eqnResidual, maxResidual);
    
        fvScalarMatrix fluxEqn
        (
           flux = -K*fvc::grad(T)
        );
        fluxEqn.relax();
        eqnResidual = fluxEqn.solve().initialResidual();
        maxResidual = max(eqnResidual, maxResidual);
    }
or is this the correct form:

Code:
    for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
    {
        fvScalarMatrix tEqn
        (
            -fvm::laplacian(K, T)
        );
        tEqn.relax();
        eqnResidual = tEqn.solve().initialResidual();
        maxResidual = max(eqnResidual, maxResidual);
    }

    flux = -K*fvc::grad(T)
I tried to compile both code's and got this error-message for the first code:

Code:
tobi@shorty:~/OpenFOAM/OpenFOAM-1.7.x/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam$ wmake
Making dependency list for source file chtMultiRegionSimpleFoam.C
SOURCE=chtMultiRegionSimpleFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-40 -Ifluid     -Isolid     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/meshTools/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/thermophysicalModels/basic/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels/compressible/turbulenceModel/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels/compressible/RAS/lnInclude -IlnInclude -I. -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/chtMultiRegionSimpleFoam.o
In file included from chtMultiRegionSimpleFoam.C:79:
solid/solveSolid.H: In function ‘int main(int, char**)’:
solid/solveSolid.H:15: error: no match for ‘operator=’ in ‘fluxEqn = Foam::operator*(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::fvc::grad(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = double]()))))’
/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude/fvMatrix.C:867: note: candidates are: void Foam::fvMatrix<Type>::operator=(const Foam::fvMatrix<Type>&) [with Type = double]
/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude/fvMatrix.C:902: note:                 void Foam::fvMatrix<Type>::operator=(const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = double]
solid/setRegionSolidFields.H:1: warning: unused variable ‘mesh’
solid/setRegionSolidFields.H:3: warning: unused variable ‘flux’
solid/setRegionSolidFields.H:4: warning: unused variable ‘rho’
solid/setRegionSolidFields.H:5: warning: unused variable ‘cp’
make: *** [Make/linux64GccDPOpt/chtMultiRegionSimpleFoam.o] Fehler 1
and for the second time that one:

Code:
aking dependency list for source file chtMultiRegionSimpleFoam.C
SOURCE=chtMultiRegionSimpleFoam.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-40 -Ifluid     -Isolid     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/meshTools/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/thermophysicalModels/basic/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels/compressible/turbulenceModel/lnInclude     -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/turbulenceModels/compressible/RAS/lnInclude -IlnInclude -I. -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/chtMultiRegionSimpleFoam.o
In file included from chtMultiRegionSimpleFoam.C:79:
solid/solveSolid.H: In function ‘int main(int, char**)’:
solid/solveSolid.H:14: error: no match for ‘operator=’ in ‘flux = Foam::operator*(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >*)(& Foam::fvc::grad(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = double]()))))’
/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude/GeometricField.C:1086: note: candidates are: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude/GeometricField.C:1111: note:                 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/tobi/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude/GeometricField.C:1147: note:                 void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=(const Foam::dimensioned<Type>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
solid/setRegionSolidFields.H:1: warning: unused variable ‘mesh’
solid/setRegionSolidFields.H:4: warning: unused variable ‘rho’
solid/setRegionSolidFields.H:5: warning: unused variable ‘cp’
make: *** [Make/linux64GccDPOpt/chtMultiRegionSimpleFoam.o] Fehler 1
The error is in line 15: flux = -K*grad(T)
Something i did wrong. Can not interpret that error message completly

Tobi
Tobi is offline   Reply With Quote

Old   January 19, 2011, 09:55
Default
  #7
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
it´s just
flux=fvc:-K*grad(T);
flux.write;

no solve, no residual. did you forgot about some ";"?
Is it possible to make flux a volScalarField and then do smth. ON a patch; sounds mored like surfaceScalarField??!!
mvoss is offline   Reply With Quote

Old   January 19, 2011, 10:54
Default
  #8
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

okay first of all i could compile my code but why can i compile that one:

Code:
 -K*fvc::snGrad(T) = flux;
and here i got a error:

Code:
 flux = -K*fvc::snGrad(T);
and whats the difference of "grad(T)" and "snGrad(T)" ?

But i can 't use my solver anymore if i compile it with the code first...
sorry but i am not an expert of OpenFoam
Tobi is offline   Reply With Quote

Old   January 21, 2011, 20:11
Default
  #9
Senior Member
 
aerothermal's Avatar
 
Guilherme da Silva
Join Date: Aug 2010
Location: Sao Paulo - Brazil
Posts: 118
Rep Power: 15
aerothermal is on a distinguished road
Send a message via Skype™ to aerothermal
snGrad(T) is the grad(T) projected into surface normal
aerothermal is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Sign of Heat Flux at wall Kyung FLUENT 2 February 26, 2016 16:25
Variable name for heat flux peterle CFX 4 February 13, 2014 02:21
Heat Flux Wall Boundary Confusion. Joee FLUENT 1 August 21, 2010 12:20
Heat flux in ansys cfx juliom OpenFOAM Running, Solving & CFD 2 April 14, 2009 14:30
Heat Transfer Coeff. at Heat Flux Boundary Rushyen CFX 6 January 18, 2001 05:09


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