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

Using arithmetic operators in dictionaries

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 27, 2024, 19:10
Exclamation Using arithmetic operators in dictionaries
  #1
New Member
 
Abdullah Saifee
Join Date: Feb 2021
Posts: 13
Rep Power: 5
saifee is on a distinguished road
I'm using OpenFOAM 10. Following is a portion of a p boundary condition for a particular patch in the domain. I'm trying to achieve a sinusoidal pressure evolution, meaning the flow will be changing direction over the period. Is the following correct for a 3 second period? The reason I'm asking is because in the results, if I look at some p file, the frequency shows to be 2.

Code:
    {
	type		uniformTotalPressure;
	p0
	{
		type		sine;
		frequency	2.0*pi/3.0;
		amplitude	-50.0;
		//scale		-1;
		level		0;
	}


    }
Whereas in some p file from the results, it shows

Code:
    {
        type            uniformTotalPressure;
        rho             rho;
        psi             none;
        gamma           1;
        p0              
        {
            type            sine;
            amplitude       
            {
                type            constant;
                value           -50;
            }
            frequency       2;
            start           0;
            level           
            {
                type            constant;
                value           0;
            }
        }
        value           uniform -12.4322;
    }
saifee is offline   Reply With Quote

Old   May 28, 2024, 04:33
Default
  #2
Senior Member
 
Join Date: Dec 2021
Posts: 251
Rep Power: 5
Alczem is on a distinguished road
Hey!


Not sure about formulas directly written in place of a number, although you could use eval to compute your frequency or any variable beforehand. So for instance, you would write before the boundary subdictionary:


Code:
freq     #eval {2*pi/3};




{
    type        uniformTotalPressure;
    p0
    {
        type        sine;
        frequency    $freq;
        amplitude    -50.0;
        //scale        -1;
        level        0;
    }
}

And of course, you can use variables inside variables (dont forget the $ sign when calling other variables). Hope it helps! There is probably a way to do this inside the boundary condition but I am not sure how (maybe codedStream?).
Alczem is online now   Reply With Quote

Old   May 28, 2024, 06:04
Default
  #3
New Member
 
Abdullah Saifee
Join Date: Feb 2021
Posts: 13
Rep Power: 5
saifee is on a distinguished road
Thanks for the response.

Where should I put this eval function? Not in the p file?
saifee is offline   Reply With Quote

Old   May 28, 2024, 06:17
Default
  #4
New Member
 
Abdullah Saifee
Join Date: Feb 2021
Posts: 13
Rep Power: 5
saifee is on a distinguished road
Quote:
Originally Posted by Alczem View Post
Hey!


Not sure about formulas directly written in place of a number, although you could use eval to compute your frequency or any variable beforehand. So for instance, you would write before the boundary subdictionary:


Code:
freq     #eval {2*pi/3};




{
    type        uniformTotalPressure;
    p0
    {
        type        sine;
        frequency    $freq;
        amplitude    -50.0;
        //scale        -1;
        level        0;
    }
}

And of course, you can use variables inside variables (dont forget the $ sign when calling other variables). Hope it helps! There is probably a way to do this inside the boundary condition but I am not sure how (maybe codedStream?).
I put the freq #eval {2*pi/3}; in the p file before the boundaryField subdictionary. I received the error:
Quote:
--> FOAM FATAL ERROR:
Unknown functionEntry 'eval' in ".../0/p" near line 21

Valid functionEntries are :

6
(
codeStream
include
neg
calc
includeIfPresent
includeEtc
)
Then I used calc from the list, which then gave me this error:

Quote:
--> FOAM FATAL IO ERROR:
Failed wmake "dynamicCode/_6d73af34a7a2711a081b60b9b371eecacacd3dbd/platforms/linux64GccDPInt32-spack/lib/libcodeStream_6d73af34a7a2711a081b60b9b371eecacacd 3dbd.so"
Now I am running the simulation on a mainframe, so I don't have the write access to certain directories, just mine.

So is there a way to use some different approach?
saifee is offline   Reply With Quote

Old   May 28, 2024, 06:24
Default
  #5
Senior Member
 
Join Date: Dec 2021
Posts: 251
Rep Power: 5
Alczem is on a distinguished road
Hey!


Okay that's weird. I noticed that you use OpenFOAM 10 while I use OpenFOAM v2312, maybe the eval feature is not available for the Foundation version.


The calc function seems to need to compile stuff, since there is a dynamicCode folder and a wmake command sent. To make sure the error is not related to access privileges, you could try to run a test case locally on your computer if you can.
Alczem is online now   Reply With Quote

Reply

Tags
boundary condition, openfoam 10, pressure b.c, sine


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
Arithmetic Average of Monitor Point as Workbench Output Parameter jaxk CFX 4 September 25, 2023 09:18
Accessing dictionaries from constant folder in multi region solver F42 OpenFOAM Programming & Development 5 January 19, 2022 06:56
What are dictionaries in Openfoam ? granzer OpenFOAM 3 November 25, 2020 01:47
What are the units used in the thermophysicalProperties and fvOptions dictionaries? ophr OpenFOAM Pre-Processing 2 June 16, 2019 02:29
How to decide which dictionaries need to be created? darthcoder OpenFOAM Running, Solving & CFD 2 April 4, 2015 11:27


All times are GMT -4. The time now is 09:43.