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

OpenFOAM v2306 Using expressions or Function1 within controlDict file?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 5, 2023, 12:29
Default OpenFOAM v2306 Using expressions or Function1 within controlDict file?
  #1
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
Hello,

I am using OpenFOAM v2306. I wonder if it is possible to use expressions or Function1 to set the values in controlDict, here is what I mean:

Code:
adjustTimeModifiable  true;
maxCo       foo; <<< I want to adjust this using a table of values or using expression
I want to use a value for foo that depends on the simulation time, t, for example:
  • foo = 0.5 for t < 0.7 .
  • foo = 1.5 for 0.7 < t < 1.3
  • foo = 2.0 for t > 1.3


Please note that I am aware of the timeActivatedFileUpdate function object (which is in my exprience becomes quickly confusing, and it is error prone) or using the coded function object to adjust some parameters by using C++ code.

The reasons why I don't like using coded Function object:
  • It is not clean, and the file becomes quickly hard to read, and requires the user to write C++ code which is in most cases tricky to get right.
  • Sometimes I have very good reasons to use OpenFOAM on Windows with the native mingw installation which does not support compiling code. Also I don't have WSL2 installed for good reasons too.

So my questions are:
  • Is it possible to use Function1 table in controlDict to adjust values?
  • Is it possible to use expressions(see link below) ?

any help is appreciated


Link to expressions: https://www.openfoam.com/documentati...on-syntax.html
NotOverUnderated is offline   Reply With Quote

Old   December 8, 2023, 03:48
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
There obviously isn't a trivial way for that at the moment. In general, it should be somewhat doable since controlDict is used almost exclusively by Time, which means it would be possible to have access to a registry and define a Function1 (constant, table, expression, whatever).
It is probably worth taking a look at solution.H, solution.C in OpenFOAM-v2112 or later (commit 53e8f2a807b). There is support for regular Function1 handling for relaxation, which is a similar idea to what you are asking, but it also has a slightly clever approach of caching various Function1 items so that they are only created on-demand once (per field).
NotOverUnderated likes this.
olesen 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
Custom Thermophysical Properties wsmith02 OpenFOAM 4 June 1, 2023 14:30
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 17:18
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 12:41
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


All times are GMT -4. The time now is 21:36.