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

Heat source by cell chtMultiRegionSimpleFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree15Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 29, 2019, 09:27
Default
  #21
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
Thank you so much for your reply.


I am not using blockMeshDict to generate mesh, instead I am using Salome for that. then how can I define a face now?


Thank you

Last edited by priyankap; April 29, 2019 at 10:38.
priyankap is offline   Reply With Quote

Old   April 29, 2019, 10:37
Default
  #22
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
Hi,


How can define my cellSet if I am using ideasUnvToFoam utility to import my mesh from salome to openfoam? because in this case, I can't use topoSetDict to define my regions. Instead, I am using following command for this:


Code:
splitMeshRegions -cellZones -overwrite | tee log.splitMeshRegions
priyankap is offline   Reply With Quote

Old   April 29, 2019, 11:12
Default Internal Energy
  #23
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hi,

'h' here is the internal energy/enthalpy [J/Kg] of the system.

To get a better understanding of 'h' and other constants used in the fvOptions framework, I would suggest going through this thread:

Help with the units of enthalpy (h) in chtMultiRegionFoam

In that thread, it is confirmed that the 'h' given in fvOptions does represent power (Watts), so your understanding of putting the power value there is correct. But, there is one more important option to consider, i.e.:

What is the volume mode of your heat source? Here as you can see there are two options:
i) Absolute: It assigns a single emission rate to the whole source, no matter if the source consists of 2 cells or 100 cells. So here the value is given directly as quantity [W].
ii) Specific: Here the value is given as <quantity>/m^3 [W/m^3]

Note: If it is 1000W directly then it is an absolute source.

This and the definitions for every field entry in fvOptions is defined in this blog,

https://caefn.com/openfoam/page/3


Now, for the relationship between enthalpy and the temperature difference, basically

(H2 -H1) = rho*Cp* (T2 -T1) .................................................. ............(i)

where: rho is density
Cp is specific heat at constant pressure

The way it is implemented in the solver is by using thermal diffusivity coefficient;

alpha = kappa/(rho*Cp)


When equation (i) is applied to the case of a simple slab it reduces to the equation which you have given.

So to understand how the temperature is calculated, I would suggest first finding out the value of alpha for your system and then substituting the respective values into equation (i).

To get a perfect understanding of how energy balance and resulting temperature distribution is calculated for each cell, go through your solver's source code, it does take time but it is worth it (and most of the terms are explained in that thread.)


I do not know Salome, so sorry I won't be able to help you with that.
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   April 29, 2019, 16:57
Default
  #24
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
thank you so much for your help. It was really useful.
priyankap is offline   Reply With Quote

Old   May 2, 2019, 11:17
Default
  #25
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
Quote:
Originally Posted by shaileshbg View Post
Hi,

You can use the selectionMode option to specify the source region.

Code:
selectionMode   cellSet; // all, cellSet, cellZone, points
But there is no option to set faces or boundary patches. To overcome this, we can use topoSet to select all the faces in the patch (front face) to form a faceSet and then use that faceSet to form a cellSet.

First, define your patch ("front", in this case), easiest is to set it in blockMeshDict.

Then in your topoSetDict, use that patch info to form your faceSet.

Code:
{
        name    frontFaces;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name "front";
        }
    }
And then use this faceSet to define your cellSet

Code:
// Select based on faceSet

    name    frontFaceCellSet;
    type      cellSet;
    action    new;
    source   faceToCell;
    sourceInfo
   {
       set frontFaces;             // Name of faceSet

       //option neighbour; // cell with neighbour in faceSet
        //option owner;     //  ,,       owner
        option any;         // cell with any face in faceSet
       //option all;       // cell with all faces in faceSet
    }
Use this cellSet in the selectionMode while defining the source.
Code:
selectionMode   cellSet; // all, cellSet, cellZone, points
         cellSet        frontFaceCellSet;
Hope this helps.

Hi Shailesh,

I am using ideasUnvToFoam utility instead of blockMeshDict because I made my geometry in Salome. So I created the patch also in Salome.





After that, I tried using topoSet as per your suggestion. My toposetDict is given below:


Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      topoSetDict;
}

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

actions
(
    // wall
    {
        name    hot;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name "hotFace";
        }
    }
// Select based on faceSet
    {
        name    hotFaceCellSet;
        type      cellSet;
        action    new;
        source   faceToCell;
        sourceInfo
        {
            set hot;             // Name of faceSet

       //option neighbour; // cell with neighbour in faceSet
            //option owner;     //  ,,       owner
            option any;         // cell with any face in faceSet
            //option all;       // cell with all faces in faceSet
        }
    }
)
Now it is creating the faceSet and cellSet properly. The log file is given below:


Code:
Create time

Create polyMesh for time = 0

Reading topoSetDict

Time = 0
    mesh not changed.
Created faceSet hot
    Applying source patchToFace
    Adding all faces of patch hotFace ...
    Found matching patch hotFace with 1092 faces.
    faceSet hot now size 1092
Created cellSet hotFaceCellSet
    Applying source faceToCell
    Adding cells according to faceSet hot ...
    cellSet hotFaceCellSet now size 1092
End
But I am getting an error. My error is given below:

Code:
Creating finite volume options from "constant/fvOptions"

Selecting finite volume options model type scalarSemiImplicitSource
    Source: heatSource
    - selecting cells using cellSet hotFaceCellSet


--> FOAM FATAL ERROR: 
Illegal content 4105 of set:hotFaceCellSet of type cellSet
Value should be between 0 and 3956

    From function void Foam::topoSet::check(Foam::label)
    in file sets/topoSets/topoSet.C at line 189.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::abort() at ??:?
#2  Foam::topoSet::check(int) at ??:?
#3  Foam::cellSet::cellSet(Foam::polyMesh const&, Foam::word  const&, Foam::IOobject::readOption, Foam::IOobject::writeOption) at  ??:?
#4  Foam::fv::cellSetOption::setCellSet() at ??:?
#5  Foam::fv::cellSetOption::cellSetOption(Foam::word const&,  Foam::word const&, Foam::dictionary const&, Foam::fvMesh  const&) at ??:?
#6   Foam::fv::option::adddictionaryConstructorToTable<Foam::fv::SemiImplicitSource<double>  >::New(Foam::word const&, Foam::word const&,  Foam::dictionary const&, Foam::fvMesh const&) at ??:?
#7  Foam::fv::option::New(Foam::word const&, Foam::dictionary const&, Foam::fvMesh const&) at ??:?
#8  Foam::fv::optionList::reset(Foam::dictionary const&) at ??:?
#9  Foam::fv::optionList::optionList(Foam::fvMesh const&, Foam::dictionary const&) at ??:?
#10  Foam::fv::options::options(Foam::fvMesh const&) at ??:?
#11  ? at ??:?
#12  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#13  ? at ??:?
Aborted (core dumped)
Now, I can see that my faceSet and cellSet is created and fvOption is also reading it, But there is some problem with my faceSet (highlighted above).


I don't understand what I did wrong. Can you please guide me if possible?


Thank you
priyankap is offline   Reply With Quote

Old   May 3, 2019, 05:51
Default
  #26
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
Hi Shailesh,


I tried making cellSet as you suggested, bu it is giving me errors, and when I tried to view it in paraFoam. It shows the following:


When I create faceSet, it seems to be working, as you can see in the figure below that the red area is the faceSet.


But when I try to make cellSet on the same faceSet, it comes our like some rough shapes on the faceSet.


My topoSetDict file is given below for your reference.



Code:
actions
(
    {
        name    hot1;
        type    faceSet;
        action  new;
        source  patchToFace;
        sourceInfo
        {
            name "hotFace";
        }
    }



//cellSet

    {

        name    hotcell;
        type    cellSet;
        action  new;
        source  faceToCell;
        sourceInfo
        {
            set hot1;      // Name of faceZone, regular expressions allowed
            option  any;      // master/slave
        }
    }

My requirement is to make a cellSet exactly same as faceSet, which means just one suface/face of the box, as you can see in the figure of faceSet below.


I shall be highly thankful if you can help me out in this.
Attached Images
File Type: jpg faceSet.jpg (85.1 KB, 12 views)
File Type: jpg cellSet.jpg (79.5 KB, 10 views)
priyankap is offline   Reply With Quote

Old   May 3, 2019, 09:35
Default Change source info option
  #27
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hi,

This is my guess. It may be because the option 'any' is selected in the source info while defining the cellSet.
Code:
option any;         // cell with any face in faceSet
As it says, all cells with any of its face in the faceSet are selected and assigned to the cellSet. This might include faces that are not on the boundary patch, thus explaining the cellSet distribution in your image. This selection might give us some irregular cells selected, thus in fvOptions (where you are telling it to add heat sources to irregular cells), is throwing you an error.

Could you try changing this option to i) owner and ii) all (this might be more accurate as it asks to select only those cells which have all its faces in the faceSet), and see if it correctly selects the cellSet. If paraFoam shows the correct cell distribution then you can add heat sources to it.
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   May 3, 2019, 11:24
Default
  #28
Member
 
Priyanka P
Join Date: Apr 2019
Location: Germany
Posts: 40
Rep Power: 7
priyankap is on a distinguished road
Hi,


Thank you for your reply. I already tried these options and even then it is not selecting just the faceSet. When I use i) owner, it remains same as "any" and when I use ii) All, it selects nothing.


I am attaching the dropbox link to my case, I would be grateful if you can please have a look on it.


https://www.dropbox.com/sh/3fy3k575f...MLiNQ-WOa?dl=0


Thank you.
priyankap is offline   Reply With Quote

Old   May 7, 2019, 08:56
Default Working with Structured Mesh
  #29
Member
 
Shailesh BG
Join Date: Aug 2017
Location: Bangalore
Posts: 39
Rep Power: 8
shaileshbg is on a distinguished road
Hi,

Very sorry for such a late reply, I was not in town. Apart from the mesh creation in Salome, the topoSet creation of cellSet and fvOptions definition of the source to that cellSet should be the same.

I do not know Salome, so just to check if the process works I created a simple cube mesh using blockMesh and used the same topoSet to define the cellSet and gave that cellSet scalarSemiImplicitSource. And it works, the option I used in topoSet selection was "any".

I have attached the paraFoam screenshot showing the cube with the lower face acting as the heat source, on the RHS of the screenshot I have shown just the cellSet.

The only difference might be that Salome has created an unstructured mesh, so when you use the option "any", it is selecting interior cells also. You can visualize the cellSet generated in paraFoam, on the left-hand side properties column select the option "Include Sets" under Selection. This should give you the 'cellSet' and the 'faceSet' option under Mesh Parts.

See if the cellSets are selected properly. If the cellSets selected are unruly because of the unstructured mesh, then creating a structured mesh just around your heat source face in Salome would solve your problem.
Attached Images
File Type: png faceSource.png (44.5 KB, 16 views)
__________________
Regards,
Shailesh
shaileshbg is offline   Reply With Quote

Old   February 17, 2022, 02:03
Arrow
  #30
New Member
 
ZhuangLi
Join Date: Jan 2022
Posts: 13
Rep Power: 4
zhuangli is on a distinguished road
Quote:
Originally Posted by Swagga5aur View Post
I took the liberty to try and implement what it seems you want, into a new chtMultiRegionSimpleFoam solver.
I have attached the code and an example of how to setup the case.
I don't have the time to thoroughly test it, but it should be a decent starting point to your solution.
https://www.dropbox.com/s/g8fz1xmxtf...ission.gz?dl=0

Best regards Lasse.

Hi Lasse,
I am also working on adding heat source to every cell in chtMultiRegionSimpleFoam, could you please share the dropbox link again, it doesn't work now.

It would be very helpful to me.


__________
Best regards,
zhuangli
zhuangli is offline   Reply With Quote

Old   February 17, 2022, 02:11
Thumbs up
  #31
New Member
 
ZhuangLi
Join Date: Jan 2022
Posts: 13
Rep Power: 4
zhuangli is on a distinguished road
Quote:
Originally Posted by shaileshbg View Post
Hi Lasse,

I am also working on adding heat source to every cell in chtMultiRegionSimpleFoam, could you please share the dropbox link again, it doesn't work now. That would be very helpful to me.

Hi Shailesh,
I am also working on adding heat source to every cell in chtMultiRegionSimpleFoam, could you please share the dropbox link from Lasse, it does not work now.


__________
Best regards,
zhuangli
zhuangli is offline   Reply With Quote

Old   February 17, 2022, 02:52
Default
  #32
Senior Member
 
Lasse Brams Vinther
Join Date: Oct 2015
Posts: 112
Rep Power: 10
Swagga5aur is on a distinguished road
Hello Zhuangli,

That link no longer works, however, there is a new link 3 posts below the original which works.

It's here as well: https://www.dropbox.com/s/4dxbyvk5a2...on.tar.gz?dl=0

Let me know if there are any questions in this regard.
Swagga5aur is offline   Reply With Quote

Old   February 17, 2022, 03:10
Thumbs up
  #33
New Member
 
ZhuangLi
Join Date: Jan 2022
Posts: 13
Rep Power: 4
zhuangli is on a distinguished road
Quote:
Originally Posted by Swagga5aur View Post
Hello Zhuangli,

That link no longer works, however, there is a new link 3 posts below the original which works.

It's here as well: https://www.dropbox.com/s/4dxbyvk5a2...on.tar.gz?dl=0

Let me know if there are any questions in this regard.

Oh Lasse, thank you so much. I can receive your reply so soon. you save me online!


Zhuangli
zhuangli is offline   Reply With Quote

Old   February 17, 2022, 04:11
Default
  #34
New Member
 
ZhuangLi
Join Date: Jan 2022
Posts: 13
Rep Power: 4
zhuangli is on a distinguished road
Quote:
Originally Posted by Swagga5aur View Post
Hello Zhuangli,

That link no longer works, however, there is a new link 3 posts below the original which works.

It's here as well: https://www.dropbox.com/s/4dxbyvk5a2...on.tar.gz?dl=0

Let me know if there are any questions in this regard.
Hi Lasse,
The version of OpenFOAM I use is v2012. I am a new Foamer, and what modifications you have done with chtMultiRegionSimpleFoam and make it to meet adding heat source by cells?


______
Regard!
Zhuangli
zhuangli is offline   Reply With Quote

Old   February 17, 2022, 04:29
Default
  #35
Senior Member
 
Lasse Brams Vinther
Join Date: Oct 2015
Posts: 112
Rep Power: 10
Swagga5aur is on a distinguished road
The code is for OpenFOAM V4.0 I believe and it's quite some time ago since I made it, however, just looked briefly at it and the main changes are the following:

Add volPowerField to createFluidFields
Code:
    PtrList<volScalarField> volPowerFluid(fluidRegions.size());
Info<< "    Adding to volPowerFluid\n" << endl;
    volPowerFluid.set
    (
        i,
        new volScalarField
        (
            IOobject
            (
                "volPower",
                runTime.constant(),
                fluidRegions[i],
                IOobject::MUST_READ,
                IOobject::AUTO_WRITE
            ),
            fluidRegions[i]
        )
    );
Added the following setRegionFluidFields.H

Code:
    volScalarField& volPower = volPowerFluid[i];
Added the following to fvOptions in the case.
Code:
energySource
{
    type            scalarCodedSource;	//scalarSemiImplicitSource
    active          true;
    name	    sourceTime;

    scalarCodedSourceCoeffs	//scalarSemiImplicitSourceCoeffs    S(x) = Su + Sp*x  //   q in [W]; or in [W/m³] if you use specific mode
    {
        selectionMode   all;
	fields 		(h);

	fieldNames	(h);
	name		sourceTime;

        codeInclude
        #{

        #};

        codeCorrect
        #{
//            Pout<< "**codeCorrect**" << endl;
        #};

	codeAddSup
        #{

            const scalarField& V = mesh_.V();
            const vectorField& C = mesh_.C();
	    
            const volScalarField volPower = mesh().lookupObject<volScalarField>("volPower");


            scalarField& hSource = eqn.source();
            forAll(C, i)
            {
            	hSource[i] -= volPower[i]*V[i];
            }
            //Pout << "***codeAddSup***" << endl;
        #};

        codeSetValue
        #{
//            Pout<< "**codeSetValue**" << endl;
        #};

        // Dummy entry. Make dependent on above to trigger recompilation
        code
        #{
            $codeInclude
            $codeCorrect
            $codeAddSup
            $codeSetValue
        #};
    }

    sourceTimeCoeffs
    {
        // Dummy entry
    }
}
I believe that was all.
Swagga5aur is offline   Reply With Quote

Old   February 18, 2022, 08:55
Default
  #36
New Member
 
ZhuangLi
Join Date: Jan 2022
Posts: 13
Rep Power: 4
zhuangli is on a distinguished road
Hi Lassse,
I have learnt the sharing for sometime. But, I did not understand why it could be “hSource[i] -= volPower[i]*V[i]; ”, As the equation shows, the dimension of hSource is watt , not (w/m3) . The heat source’s distribution is generated from solid region in my case, which is different between iterations. At the same time, I noticed the hEqn in solveSolid.H file(show below), and the dimension of h is (w/m3). I got comfused with the dismatch dimension. Am I right?
p { margin-bottom: 0.1in; line-height: 115%; background: transparent }


for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth)
{
fvScalarMatrix hEqn
(
(
thermo.isotropic()
? -fvm::laplacian(betav*thermo.alpha(), h, "laplacian(alpha,h)")
: -fvm::laplacian(betav*taniAlpha(), h, "laplacian(alpha,h)")
)
==
fvOptions(rho, h)
);


hEqn.relax();


fvOptions.constrain(hEqn);


hEqn.solve();


fvOptions.correct(h);
}


___________
Regard!
Zhuangli

p { margin-bottom: 0.1in; line-height: 115%; background: transparent }
zhuangli is offline   Reply With Quote

Reply

Tags
cell, chtmultiregionsimplefoam, heatsource


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
heat source in one cell only! David UTFSM MEC Fluent UDF and Scheme Programming 1 October 15, 2013 17:14
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


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