CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Heat Flow across patches using chtmultiregionfoam (http://www.cfd-online.com/Forums/openfoam-post-processing/99077-heat-flow-across-patches-using-chtmultiregionfoam.html)

chaz March 25, 2012 23:43

Heat Flow across patches using chtmultiregionfoam
 
Hello,
I am having great difficulty finding out how to evaluate heat flow across patches between solid regions, and across patches that are between a solid and fluid region. This is for chtMultiRegionFoam or ..SimpleFoam.

I have installed and looked into swak4foam, but this functionality does not look to be there.

In swak4foam, I can average T across a patch between fluid and solid, but not across patches between solids.

Any guidance?
Thanks

gschaider March 26, 2012 04:17

Quote:

Originally Posted by chaz (Post 351402)
Hello,
I am having great difficulty finding out how to evaluate heat flow across patches between solid regions, and across patches that are between a solid and fluid region. This is for chtMultiRegionFoam or ..SimpleFoam.

I have installed and looked into swak4foam, but this functionality does not look to be there.

In swak4foam, I can average T across a patch between fluid and solid, but not across patches between solids.

Any guidance?
Thanks

I don't quite understand why this shouldn't work with swak4Foam. A patch is a patch. It doesn't make a difference whether it is between a solid or a fluid or two solids. The only thing that is a bit more complicated with multi-region-cases is selecting another region http://openfoamwiki.net/index.php/Co...al_expressions

chaz March 26, 2012 11:31

Hello,
Thank you for your reply and link. I am putting the function code into the controldict in order to test access to the average temperature of a patch. In my simple test model, there are three regions, with different thermal conductivities. The following code reports the correct average temperature for the external patches, but reports -1e300 for average temperature of any internal patch. The regions are met1, elem, and met2. Basically two metals on each end of a material called elem. The patches cold and hot are external, and cold_int/hot_int are internal patches between regions.

Code:

functions
(
    met1
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( cold cold_int );
        region met1;
    verbose true;
    factor 1;
    }
        elem
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( cold_int hot_int);
        region elem;
    verbose true;
    factor 1;
    }
        met2
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( hot_int hot);
        region met2;
    verbose true;
    factor 1;
    }
);

This is only to test the function to find average temperature. I still do not know how to find heat flux, which would be the area integral of -K*dT/dn, where n is the patch normal, and K is the thermal conductivity. wallHeatFlux certainly does not work, based on my tests and from looking at other postings. It appears to work on wall patches, but not patches between regions such as in chtmultiregionfoam.
Any guidance would be greatly appreciated.

gschaider March 26, 2012 16:38

Quote:

Originally Posted by chaz (Post 351550)
Hello,
Thank you for your reply and link. I am putting the function code into the controldict in order to test access to the average temperature of a patch. In my simple test model, there are three regions, with different thermal conductivities. The following code reports the correct average temperature for the external patches, but reports -1e300 for average temperature of any internal patch. The regions are met1, elem, and met2. Basically two metals on each end of a material called elem. The patches cold and hot are external, and cold_int/hot_int are internal patches between regions.

Code:

functions
(
    met1
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( cold cold_int );
        region met1;
    verbose true;
    factor 1;
    }
        elem
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( cold_int hot_int);
        region elem;
    verbose true;
    factor 1;
    }
        met2
    {
    type patchAverage;
    functionObjectLibs ("libsimpleFunctionObjects.so");
    fields ( T );
    patches ( hot_int hot);
        region met2;
    verbose true;
    factor 1;
    }
);


The -1e300 means that the patch wasn't found (you'll probably find a warning at the beginning of the log about that). The patches have to exist exactly under the specified name in the mentioned regions in order to be found (for instance the cold_int and hot_int in region elem). Please check that (in the polyMesh/boundary-files of these regions for instance)

Quote:

Originally Posted by chaz (Post 351550)
This is only to test the function to find average temperature. I still do not know how to find heat flux, which would be the area integral of -K*dT/dn, where n is the patch normal, and K is the thermal conductivity. wallHeatFlux certainly does not work, based on my tests and from looking at other postings. It appears to work on wall patches, but not patches between regions such as in chtmultiregionfoam.
Any guidance would be greatly appreciated.

The simpleFunctionObjects have "big brothers" in the simpleSwakFunctionObjects. In your case the patchExpression-functionObject with an expression like "-K*snGrad(T)" might be what you're looking for (or if you want to integrate it "-K*area()*snGrad(T)" with an accumulation "sum" I think). Have a look at the examples that come with swak, it's Wiki-page and the groovyBC-Wikipage (all functions described there work for patchExpression)

chaz March 26, 2012 16:45

Thank you, I will look into the items you pointed out.

Tuxeedo June 7, 2012 06:16

Hey Chaz,
Did you find a convinient Way to Solve your Problem?

chaz June 10, 2012 20:31

Hello,
Yes, I did make progress getting heat flow data from patches in chtmultiregionfoam.

As Bernhard suggested, swak4foam can be used to get the heat flow between two regions that are solid. I added code similar to the following to then trigger swak4foam to calculate the heat flow and to output it for every iteration into a file.

qHot
{
type swakExpression;
valueType patch;
patchName hot;
verbose true;
expression "-K*area()*snGrad(T)";
accumulations (sum);
region Solid_2;
}

I also had to load the libraries needed first in the controldict file:
libs (
"libOpenFOAM.so"
"libgroovyBC.so"
"libsimpleSwakFunctionObjects.so"
"libswakFunctionObjects.so"
"libswakTopoSources.so"
) ;
Not sure if all of these are needed, this was just copied and pasted from somewhere else.


I ran this on a simple model with two regions with different thermal conductivity and compared it to theory, and confirmed that it works.


All times are GMT -4. The time now is 01:08.