|
[Sponsors] |
How to modify fvScheme automatically inside the code? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 27, 2011, 10:44 |
How to modify fvScheme automatically inside the code?
|
#1 |
Member
matteo lombardi
Join Date: Apr 2009
Posts: 67
Rep Power: 17 |
Hello,
I would like to be able to modify my code so that after N iterations it switches automatically from a certain fvScheme (for example a first order schemes for the div term) to another ( for example to a second order scheme). So Inside my code I would like to able to do something like this: if (runTime.time().value()> 10) { mesh.fvScheme().divSchemes_="Gauss linear" } or something similar.. (this obviously doesn't work..divSchemes_ is private and is a dictionary...) Any Idea on how to do it? Thanks, Matteo |
|
July 27, 2011, 18:56 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
Quick and dirty:
Code:
dictionary divSchemeDict; if (runTime.time().value() > 10) { divSchemeDict.set("myDivScheme", "Gauss linear"); } else { divSchemeDict.set("myDivScheme", mesh.fvScheme().divScheme("lookupName")); // lookupName is what you lookup in your fvSchemes dictionary file for the // default before runTime > 10 scheme } tmp<fv::divScheme<scalar /*or vector? */ > myDivScheme ( fv::divScheme<scalar /* or vector */ >::New ( mesh, divSchemeDict.lookup("myDivScheme") ) ); // Then in your fvScalarMatrix: fvScalarMatrix myEqn ( //all kinds of fancy equation terms, plus: + myDivScheme->fvmDiv( /*desired parameters */ ) // etc... ); |
|
July 27, 2011, 19:31 |
|
#3 |
Member
matteo lombardi
Join Date: Apr 2009
Posts: 67
Rep Power: 17 |
Hello David,
thank you very much for you answer, I see what you mean. At the moment I have actually managed to solve it with en even dirtier trick: I have written a small code that modify directly the "system/fvSchemes" file and replace the words directly there (the file system/fvSchemes is re-read a the beginning of every time step) and I call it after a certain number of time steps... Not very elegant but it works... Your way is actually much cleaner, I will give it a try tomorrow. Thanks again, ciao, Matteo |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
own Code vs. commercial code | Bernhard Mueck | Main CFD Forum | 10 | February 16, 2000 11:07 |
State of the art in CFD technology | Juan Carlos GARCIA SALAS | Main CFD Forum | 39 | November 1, 1999 15:34 |
Use of an hydrodynamic model integrated in the vertical by the PHOENICS code | Hafsia Zouhaier | Main CFD Forum | 2 | March 15, 1999 09:23 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 12:44 |
What kind of Cmmercial CFD code you feel well? | Lans | Main CFD Forum | 13 | October 27, 1998 11:20 |