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

Trying to Generalize fvSolutions file

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 24, 2020, 04:38
Default Trying to Generalize fvSolutions file
  #1
New Member
 
Farhan Ahmed
Join Date: Feb 2020
Posts: 6
Rep Power: 6
Focus00000 is on a distinguished road
Hi Everyone!
We are trying to develop a GUI OF OPENFOAM FOR OUR INSTITUTE. To do so initially we are Generalizing the fvSchemes controldict and other OPENFOAM files by listing every option available in them.
The problem is with fvSolutions file every solver has a different fvSolutions file ....is it possible to make a single generalized fvSolutions file which will work with any solver ???
Focus00000 is offline   Reply With Quote

Old   February 25, 2020, 06:52
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


If not for all, but for the most you can do it. Supply the PIMPLE and SIMPLE dictionary, all fields which can be in the solver. You can also use regex so for example ".*"{solverOptions} will be used for every field, etc...
You can add everything in the fvSolution, the solver will only read what is needed.


A bruteforce method can be if you just use the same fvSolution for different solvers. If the solver will miss something, just add it. Then go to the next solver with the same fvSolution...


Another possibility if you create more fvSolutions, like fvSolution.simpleFoam, fvSolution.icoFoam, etc. For all the solvers you need. And then just copy-paste the needed file into your case.
simrego is offline   Reply With Quote

Old   February 25, 2020, 10:07
Default
  #3
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
Hey,

If you know the general structure of a solver and each of your group follows strict naming conventions, you could try to find out which fields are being solved by pattern matching the solver files. For instance, running:
Code:
grep -Erh "[a-zA-Z]*\.solve\(" | cut -f 1 -d '.'| tr -d ' '| sed "s/Eqn//"
in a solver directory should give you a list of field names. Again, here, I assume some OF conventions, for intance that the name of the matrix object to solve field 'X' is called 'XEqn' and that the field 'X' is also registered with name 'X' at runtime. It's just an idea. Maybe this helps. Also, I'm not the best at bash scripting. They are probably cleaner approaches than the one I suggest. Good luck!
raumpolizei is offline   Reply With Quote

Old   February 26, 2020, 23:31
Default
  #4
New Member
 
Farhan Ahmed
Join Date: Feb 2020
Posts: 6
Rep Power: 6
Focus00000 is on a distinguished road
Thank you So Much ...your suggestions were great help
Focus00000 is offline   Reply With Quote

Old   February 27, 2020, 00:44
Default
  #5
New Member
 
Farhan Ahmed
Join Date: Feb 2020
Posts: 6
Rep Power: 6
Focus00000 is on a distinguished road
I'm not familiar with regex .* concept.
can u help me understand it ?
I have noticed in fvSolutions with some solver options it uses .*
e.g in some files it uses "k.*" ....in others just simply k without .*?
if we use .* for every solver option or dont use .* at all ..what difference will it make?
I'm new to openfoam or ubuntu scriting ...So i hope you don't mind answering my questions ?..Thanks
Focus00000 is offline   Reply With Quote

Old   February 27, 2020, 02:42
Default
  #6
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


You can search for "POSIX regex" and probably you will find how to use it.
The most common ones I know are:


".*" -> everything matches
"U.*" -> Everything starts with U
"(U|k|h)" -> match for U, k, and h so you don't need 3 dictionary if they are the same.
"(U|k|h)Final" -> This will match for UFinal, kFinal, hFinal


You can do fancy stuff with POSIX regex, but sadly these are ones I know
Also in the tutorials you can find some usage.

I hope it helps.
raumpolizei and MCrossover97 like this.
simrego is offline   Reply With Quote

Old   February 27, 2020, 02:44
Default
  #7
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Sorry I missed it and can't edit my post:

" are needed around the variables!!!
simrego is offline   Reply With Quote

Old   February 27, 2020, 08:11
Default
  #8
Member
 
Join Date: Dec 2018
Location: Darmstadt, Germany
Posts: 87
Rep Power: 7
raumpolizei is on a distinguished road
Quote:
Originally Posted by Focus00000 View Post
I'm not familiar with regex .* concept.
can u help me understand it ?
I have noticed in fvSolutions with some solver options it uses .*
e.g in some files it uses "k.*" ....in others just simply k without .*?
if we use .* for every solver option or dont use .* at all ..what difference will it make?
I'm new to openfoam or ubuntu scriting ...So i hope you don't mind answering my questions ?..Thanks
As you correctly figured out, the grep command means with the -E option enables regex pattern. The first part "[a-zA-Z]*" matches 0 or more of the characters in the brackets, so here any letter. Actually, it would be better to use "[a-zA-Z]+" which would mean at least one or more of the characters in the brackets. For instance, this would match "UEqn" or "pEqn" or "rhoEqn", the second part "\.solve\(" matches the part following the first part and simply translates to ".solve(". In such a manner you are able to match "UEqn.solve(".

In the fvSolution files the expression "rho.*" is also a regex expression matching. The dot "." matches any character. The "*", as previously explained, matches zero or more of the previous character. This means that the expression "rho.*" matches not only "rho" but also "rhoFinal" or "rhoAwesomeVariable234askj2" and will use the same solution settings for all these fields. Hope it's understandable.
raumpolizei is offline   Reply With Quote

Old   March 2, 2020, 03:44
Smile
  #9
New Member
 
Farhan Ahmed
Join Date: Feb 2020
Posts: 6
Rep Power: 6
Focus00000 is on a distinguished road
Quote:
Originally Posted by raumpolizei View Post
As you correctly figured out, the grep command means with the -E option enables regex pattern. The first part "[a-zA-Z]*" matches 0 or more of the characters in the brackets, so here any letter. Actually, it would be better to use "[a-zA-Z]+" which would mean at least one or more of the characters in the brackets. For instance, this would match "UEqn" or "pEqn" or "rhoEqn", the second part "\.solve\(" matches the part following the first part and simply translates to ".solve(". In such a manner you are able to match "UEqn.solve(".

In the fvSolution files the expression "rho.*" is also a regex expression matching. The dot "." matches any character. The "*", as previously explained, matches zero or more of the previous character. This means that the expression "rho.*" matches not only "rho" but also "rhoFinal" or "rhoAwesomeVariable234askj2" and will use the same solution settings for all these fields. Hope it's understandable.
yeah got it....you quite clearly explained it to me ....Appreciated
Focus00000 is offline   Reply With Quote

Old   March 2, 2020, 04:17
Default
  #10
New Member
 
Farhan Ahmed
Join Date: Feb 2020
Posts: 6
Rep Power: 6
Focus00000 is on a distinguished road
raumpolizei....Thanks Man

yeah it was quite clear to understand ..i got it Thanks
Focus00000 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
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 08:46
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 21:03
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46


All times are GMT -4. The time now is 03:05.