CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Temperature average by codedFunctionObject

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By olesen

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   March 6, 2023, 13:31
Post Temperature average by codedFunctionObject
  #1
New Member
 
george
Join Date: Feb 2021
Posts: 10
Rep Power: 5
scfd is on a distinguished road
Hi,

I'm trying to get average value of temperature with additional statements, like if the Velocity magnitude is zero take that cell to account.

I've just 2 conditions.
  1. First one is the positional, check the cell z-position if it is between P1 and P2.
  2. Second one is the velocity magnitude.
If the cell satisfies the conditions, add the temperature value of that cell by Tm. Divide Tm by counter after the for loop.
Code:
	
temperatureAverage
{
    type coded;
    libs (utilityFunctionObjects);
    writeControl writeTime;
    name temp;
	
    codeWrite
    #{
	scalar P1 = 1.0;
	scalar P2 = 2.0;
	scalar Tm = 0;
	scalar TposAve = 0;
	scalar counter = 0;
        const scalarField& zPos= mesh().C().component(2);
        const volVectorField& U = mesh().lookupObject<volVectorField>("U");
	const volScalarField& T = mesh().lookupObject<volScalarField>("T");
	forAll(zPos,i)
	{
		if (zPos[i] >= P1 && zPos[i] <= P2)
		{
			if (U[i] > 0)
			{
				Tm += T[i];
				counter += 1;
			}
		}
	}
	TposAve = Tm/counter;
#};
}
ERROR:
Code:
/aveTest/system/controlDict.functions.temperatureAverage: In member function ‘virtual bool Foam::tempFunctionObject::write()’:
/aveTest/system/controlDict.functions.temperatureAverage:96:14: error: no match for ‘operator>’ (operand types are ‘const Foam::Vector<double>’ and ‘int’)
I attached the log file for further reading.

regards,
scfd
Attached Files
File Type: txt logbuoyantPimpleFoam.txt (21.0 KB, 0 views)
scfd is offline   Reply With Quote

 

Tags
coded, coded function object, temperature average value


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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 09:21
Converging Diverging Nozzle with dbnsTurbFoam Saleh Abuhanieh OpenFOAM Running, Solving & CFD 4 December 13, 2019 10:26
Area weighted average temperature vin95 Main CFD Forum 2 August 8, 2018 01:46
How can i export the average Temperature for many time steps from Fluent? benmel2006 FLUENT 1 April 5, 2017 13:32
average interior temperature less than the operating temperature Naher FLUENT 4 March 31, 2011 23:14


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