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

CodedSource controlled by a different region

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 28, 2020, 20:53
Default CodedSource controlled by a different region
  #1
New Member
 
Alex
Join Date: May 2020
Posts: 2
Rep Power: 0
malydilnar is on a distinguished road
Hey all, ive been stuck at this problem for a while and am looking for your insight. I have a multi region conjugate heat transfer problem where I have a heater generating heat in its own region (Through scalar coded source / semi implicit source). I want to be able to turn the heater on/off based on the temperature read in a cell in a different region. (Thermostat controlling the heater)

The problem is it seems like I can only access the mesh inside the region the fvoptions file lives in for the coded source (The heater). Therefore I cant pull the temperature of a specific cell in a different region to use for my thermostat control.

This is my coded source so far, its really just copied parts from other forum users so far. The thermostat if conditions aren't there yet, because I need to figure out how to get the conditional thermostat into the coded source first.

Code:
test
{
    type          scalarCodedSource;

    active          true;

    name    sourceTime;



    scalarCodedSourceCoeffs
    {
         selectionMode   all;
         
	       fields      (h);

        codeInclude
        #{

        #};

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

        codeAddSup
        #{
	          scalar Tvol = 0;
            //const Time& time = mesh().time();
            const volScalarField& Tm = mesh_.lookupObject<volScalarField>("T"); // Look up temperature
            //Tvol = Tm.weightedAverage(mesh_.V()).value();                //averageValue of the volScalarField
            //const fvMesh& help = Tm.mesh().time();
            const vectorField& C = mesh_.C();                    //List of cellcentres
	          const scalarField& V = mesh_.V();
            //const scalarField& num = mesh_.C().size();
            scalarField& hSource = eqn.source();                //defining source
            forAll(C, i)
            {
                //hSource[i] = (Tvol - 310)*2400*V[i] ;
                hSource[i] = (Tm[2] - 310)*2400*V[i] ;
            }

            // Calling the mesh.C().size() method therefore yields the total size of the mesh.
            Pout << V << endl;
            Pout << "***codeAddSup***" << endl;
        #};

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

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

    sourceTimeCoeffs
    {
         $scalarCodedSourceCoeffs;
    }
}
As far as I can tell, mesh_.() only has access to the values of the mesh inside the region, not the combined mesh.

I have a couple of ideas on how to fix my problem, though I'm not very familiar with c++ so its difficult to really read all the source code and understand what methods I have at my disposal.
  • figure out how to extend mesh_.() to be able to pull temperature from a different region
  • it looks like coded source includes the sampling library, which should allow me to probe values, though again not sure if I can specify a different region to probe

Any input on how to solve my problem would be very appreciated, thanks.
malydilnar 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
Error when solving p_rgh bob94 OpenFOAM 0 March 17, 2020 08:12
Problem simulating the temperature rise in a composite material (chtMultiRegionFoam) Adam_K OpenFOAM Running, Solving & CFD 2 March 27, 2019 06:51
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 04:04
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 08:19


All times are GMT -4. The time now is 20:22.