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

dimensionedScalar not updating, stuck on initial values

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2018, 20:50
Default dimensionedScalar not updating, stuck on initial values
  #1
Member
 
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 9
backscatter is on a distinguished road
Modifying pimpleFoam, I've created a dimensionedScalar which which computes the area weighted average over the boundary patches 'INLET' and 'OUTLET'. In createFields.H, I add the following entries to create the dimensionedScalar 'meanTOut' and 'meanTIn' (which are avg. temperatures on outlet and inlet patch respectively):


Code:
dimensionedScalar meanTOut     // used in TEqn.H
(
    "meanTOut",
    dimensionSet(0, 0, 0, 1, 0, 0 ,0),
    1 // initilization
);

dimensionedScalar meanTIn     // used in TEqn.H
(
    "meanTIn",
    dimensionSet(0, 0, 0, 1, 0, 0 ,0),
    0 // initilization
);
Then in TEqn.H, I add the following loop to compute the area weighted mean temperatures on these patches during every iteration:


Code:
// Area-weighted Temperature on OUTLET patch
    if (areaOut > 0)
    {
    dimensionedScalar meanTOut = gSum
    (
    mesh.magSf().boundaryField()[OUTLET]
    * T.boundaryField()[OUTLET]
    )/ areaOut;
    }

// Area-weighted Temperature on INLET patch
    if (areaIn > 0)
    {
    dimensionedScalar meanTIn = gSum
    (
    mesh.magSf().boundaryField()[INLET]
    * T.boundaryField()[INLET]
    )/ areaIn;
    }

     Info<< "Area weighted OUTLET patch temperature = " << meanTOut << nl << endl;
     Info<< "Area weighted INLET patch temperature = = " << meanTIn << nl << endl;
But when I run the solver on channel flow case, it doesn't update the 'meanTOut' and 'meanTIn' as per the loops given above. Instead, 'meanTOut' and 'meanTIn' are stuck at their initial values of "1" and "0" as initialized in createFields.H.


Am I missing anything basic here?

Anyhelp is appreciated.



PS: The other variables like areaIn, areaOut & patch labels like INLET and OUTLET etc. have been calculated elsewhere not shown in the code above.
backscatter is offline   Reply With Quote

Old   August 7, 2018, 08:18
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Hi,

You may need to modify the code for some reason, but if you need to find the average of a field on a patch, there is already a functionObject:

surfaceFieldValue.

Depending on the version you use it may be called differently.
Regards,
Tom
tomf is offline   Reply With Quote

Old   August 7, 2018, 20:30
Default
  #3
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
Hi,halo


Why do you define the "meanTout" twice?

If you define meanTout as dimensionedScalar in createFields.H,
there will be no need for defining it again in if{}.


Probably you are creating two different "meanTout" instances with a same name in the different scopes.
The values of meanTout inside if{} will be calculated. But, what you write out is not that one.
snak is offline   Reply With Quote

Reply


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
Segmentation fault when using reactingFOAM for Fluids Tommy Floessner OpenFOAM Running, Solving & CFD 4 April 22, 2018 12:30
HeatSource BC to the whole region in chtMultiRegionHeater xsa OpenFOAM Running, Solving & CFD 3 November 7, 2016 05:07
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 02:20
Wrong fluctuation of pressure in transient simulation caitao OpenFOAM Running, Solving & CFD 2 March 5, 2015 21:33
Compressor Simulation using rhoPimpleDyMFoam Jetfire OpenFOAM Running, Solving & CFD 107 December 9, 2014 13:38


All times are GMT -4. The time now is 15:31.