|
[Sponsors] |
May 20, 2020, 07:27 |
porting solver from v5 to v7
|
#1 |
New Member
Dries van Oosten
Join Date: Nov 2017
Posts: 6
Rep Power: 9 |
Hi everyone,
some time ago, I wrote a solver for OpenFOAM 5, which I now need to port to version 7. My problem is that the mesh.solver() method no longer exists version 7. I am thus stuck with this bit of code: Code:
// corrector for Yi solve ( fvm::ddt(rho,Yi) - fvc::ddt(rho,Yi) + fvm::div(phi,Yi) - fvc::div(phi,Yi), mesh.solver("Yi") ); Code:
// corrector for Yi fvScalarMatrix YiEqn ( fvm::ddt(rho,Yi) - fvc::ddt(rho,Yi) + fvm::div(phi,Yi) - fvc::div(phi,Yi) ); YiEqn.solve(); best, Dries |
|
May 20, 2020, 07:37 |
|
#2 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Dear Dries,
both codes are equal. The part mesh.solver("Yi"), just told FOAM which linear solver to use, here, the "Yi" dictionary is searched in the fvSolutions and these settings are applied. Both codes of you are identical in terms of equations. The difference is:
However, I don´t get the idea of the equation? Implicit part - explicit part? Is this a numerical trick? Both are equal.
__________________
Keep foaming, Tobias Holzmann |
|
May 20, 2020, 07:42 |
|
#3 |
New Member
Dries van Oosten
Join Date: Nov 2017
Posts: 6
Rep Power: 9 |
Dear Tobias,
thanks for your quick explanation. In that case, I will have to dig deeper to find out why the simulation is failing. best, Dries |
|
May 20, 2020, 09:30 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi, I updated my previous message to improve quality and my english. Just one more comment.
You should be able to use your previous code still (https://cpp.openfoam.org/v6/namespac...0126875aa319): Code:
const dictionary yourDict = ...; // Access to your dictionary --> mesh.solver("Yi") // corrector for Yi solve ( fvm::ddt(rho,Yi) - fvc::ddt(rho,Yi) + fvm::div(phi,Yi) - fvc::div(phi,Yi), yourDict ); Code:
solve ( fvm::ddt(rho,Yi) - fvc::ddt(rho,Yi) + fvm::div(phi,Yi) - fvc::div(phi,Yi), mesh.solver("Yi") ); Additionally, it would be good to know your compilation error. Nevertheless, both calculations are equal.
__________________
Keep foaming, Tobias Holzmann |
|
May 20, 2020, 10:44 |
|
#5 |
New Member
Dries van Oosten
Join Date: Nov 2017
Posts: 6
Rep Power: 9 |
If I understand your last suggestion correctly, this means that the mesh.solver() method if just the code that reads the dictionary in fvSolutions to find out what type of solver the user has specified.
|
|
May 20, 2020, 11:06 |
|
#6 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Correct, if I got you right. The method solver() is a function that you apply onto the object named 'mesh'. This object is of type 'fvMesh' which includes the public derivative to the 'solutions' class in which the function solver() is defined.
This function returns a dictionary. The dictionary which is returned is based on the argument you provide. To be more precisely, the function is actually defined as 'solver(const word)'. What it does is to return the dictionary you set in the fvSolutions related to the word you set. E.g., mesh.solver("h") will return the linear solver settings specified within the dictionary 'h' in the fvSolutions file. If there is no dict specified, you get an error. .
__________________
Keep foaming, Tobias Holzmann |
|
May 20, 2020, 11:18 |
|
#7 |
New Member
Dries van Oosten
Join Date: Nov 2017
Posts: 6
Rep Power: 9 |
Ok. Thank you very much for the explanation!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Duplicate library entries when running a solver with custom library | francescomarra | OpenFOAM Programming & Development | 3 | May 17, 2022 09:37 |
thobois class engineTopoChangerMesh error | Peter_600 | OpenFOAM | 4 | August 2, 2014 10:52 |
Divergence problem | Smaras | FLUENT | 13 | February 21, 2013 06:03 |
3d vof | Smaras | FLUENT | 2 | February 19, 2013 07:58 |
why the solver reject it? Anyone with experience? | bearcat | CFX | 6 | April 28, 2008 15:08 |