|
[Sponsors] |
January 12, 2011, 07:56 |
Implementation of runTime-updated scalar
|
#1 |
Member
Sebastian Lang
Join Date: Aug 2009
Posts: 47
Rep Power: 17 |
Hi there!
I am writing a modified solver and had to add a new entry "steadyIterationSteps" to my controlDict. This constant should be updated every time step for my transient solver. The aim is, that the constant can be modified during runtime, like for example the value of "stopAt" in the controlDict. I read the constant every time step (=> The "read"-command is located inside the "while (runTime.run())"-loop), but the value with which the solver works isn't updated! If I change the value before starting the solver, then it reads the value as I want it to, but a modification during runtime still is not possible! So my problem is, that the controlDict is read for the first time step, but not for the following time steps! Maybe the operation of reading is not the problem, but at least the variable "iterationSteps" in my solver does not receive the new value properly! I tried both of the following commands to read in the value: Code:
scalar iterationSteps = runTime.controlDict().lookupOrDefault<scalar>("steadyIterationSteps", 500); Code:
scalar iterationSteps(readScalar(runTime.controlDict().lookup("steadyIterationSteps"))); Could you give me a hint what is missing in my code or what I do wrong? I also tried to find out how the other entries in the controlDict are read in, but I didn't understand the codes and classes as they seem to be extremely nested at this point! Thanks for every reply! Greetings Sebastian |
|
January 12, 2011, 09:49 |
Problem solved!!!
|
#3 |
Member
Sebastian Lang
Join Date: Aug 2009
Posts: 47
Rep Power: 17 |
Thanks Laurence!
Your idea solved the problem! I did not know, that the whole controlDict is saved inside this "runTime"-variable. I thought the "runTime.controlDict()" just directs the commands I showed in my first post to find the controlDict inside the system-directory. Well, this "runTime.read()" command was in fact missing in the solver I based my modified solver on, too! I am trying to modify the chtMultiRegionFoam-solver and copied my style to read in "iterationSteps"-variable from the original way to read in the maximum allowed diffusion number in chtMultiRegionFoam. After a test, I realized that a runtime-modification of that value is not possible in the original chtMultiRegionFoam, either. But: maybe this has a physical reason which I don't know, so I don't want to blame the author of the original chtMultiregionFoam-solver. Well, thanks to Lawrence again! Greetings Sebastian |
|
January 12, 2011, 10:13 |
|
#4 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
runTime.readModifiedObjects() might be better.
Have a look at Foam::Time in doxygen: http://foam.sourceforge.net/docs/cpp...am_1_1Time.php If you think there's a bug then post it on the openfoam site.
__________________
Laurence R. McGlashan :: Website |
|
January 12, 2011, 17:29 |
|
#5 |
Member
Sebastian Lang
Join Date: Aug 2009
Posts: 47
Rep Power: 17 |
Hi Lawrence,
thanks again for the post! At the moment I don't know if the "runTime.readModifiedObjects()" is better, because I can't really see from doxygen what it does. But "runTime.read()" works fine for me, thank you! Can you really get information about what you need from doxygen? The only thing I can use it for is to look up unknown functions and hope that the description-text is detailed enough for me to understand! If there is no description text the only possibility that's left to me is to guess what the function does from it's input and output arguments. I never got any information from looking at the method-definitions in the source code, because OpenFoam (and maybe other object-oriented programs, too) is coded in such a nested way that it is really hard to understand! How do you search functions you need or look up what a function does, Lawrence? Thanks in advance! Greetings Sebastian |
|
January 13, 2011, 06:02 |
|
#6 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
I empathise with you a little. . The Class references are very useful though! I found this on the OFwiki: How to use Doxygen with OF. A few points of mine would be:
Have a look at Foam::Time, which is the type of runTime. The inheritance diagram shows us that Time inherits (publically) from various other classes, objectRegistry being one. If you want to see what readModifiedObjects() does, click on the function name and it takes you down to the description. It tells you that it's been reimplemented from objectRegistry. You can click on line 192 and it takes you to the part of the source code that contains the implementation of readModifiedObjects(). Ignore the parallel bit for now and compare it to read(). You'll see that it calls objectRegistry::readModifiedObjects(). List of all members is also a useful link if you want to quickly see what ALL the functions that are available to the class are.
__________________
Laurence R. McGlashan :: Website |
|
January 13, 2011, 06:47 |
|
#7 |
Member
Sebastian Lang
Join Date: Aug 2009
Posts: 47
Rep Power: 17 |
Hi Lawrence!
Thanks again for your explanations! The WIKI-page really describes the basics, this is very good for all beginners out there! What helped me is especially your hint to the "List of all members"! I did not see that link all the time, because I was working in Doxygen when entered from www.openfoam.com and that page is not really nice to view as the typical openfoam.com header always limits your view. I think I can use doxygen better from now on. Thanks a lot Lawrence! If you've still got other tips for ambitious OpenFOAM programmers ;-) then I would appreciate if you share them with me (our us ;-) ) Thanks a lot! Greetings Sebastian |
|
Tags |
controldict, read from file, runtime, update |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Solving for an additional species CO in coalChemistryFoam | N. A. | OpenFOAM Programming & Development | 3 | February 18, 2019 06:58 |
dieselFoam problem!! trying to introduce a new heat transfer model | vivek070176 | OpenFOAM Programming & Development | 10 | December 24, 2014 00:48 |
Specifying nonuniform boundary condition | maka | OpenFOAM Running, Solving & CFD | 59 | October 22, 2014 15:52 |
CFX12 rif errors | romance | CFX | 4 | October 26, 2009 14:41 |
solving passive scalar by user function in AVLFIRE | huyp | Main CFD Forum | 0 | September 4, 2008 11:21 |