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

regexp

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 2, 2009, 03:28
Default regexp
  #1
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi,

I wonder, if anyone uses the regexp features and could show some small examples. I know this example, which is already quite complex:

http://www.cfd-online.com/Forums/ope...0787-openfoam-15-a.html



but this was still for 1.5 and 1.6.x should provide even more stuff!? In addition I wonder, if adjustments in include files for fvSchemes and fvSolution are runtime selectable as well? Right now, it seems, that they are not...

Best Regards!
Fabian
braennstroem is offline   Reply With Quote

Old   November 3, 2009, 04:42
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by braennstroem View Post
but this was still for 1.5 and 1.6.x should provide even more stuff!? In addition I wonder, if adjustments in include files for fvSchemes and fvSolution are runtime selectable as well? Right now, it seems, that they are not...
Hi Fabian,
your link seems to have been truncated. Here it is for other people:
http://www.cfd-online.com/Forums/ope...foam-15-a.html

For something simpler, how about this:
Code:
// system/fvSolution
#include        "~OpenFOAM/system/fvSolution/simple"
SIMPLE
{
    convergence     5e-4;
}
And the site-wide or user-specific file (see foamEtcFile -list)

Code:
// system/fvSolution
solvers
{
    p
    {
        solver          GAMG;
        tolerance       1e-08;
        relTol          0.05;
        smoother        GaussSeidel;
        // nPreSweeps      0;
        // nPostSweeps     2;
        // nFinestSweeps   2;
        cacheAgglomeration      false;
        nCellsInCoarsestLevel   20;
        agglomerator    faceAreaPair;
        mergeLevels     1;
    }

    "(U|h)"
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance       1e-06;
        relTol          0.1;
    }

    "(k|epsilon|omega)"
    {
        solver          smoothSolver;
        smoother        GaussSeidel;
        nSweeps         2;
        tolerance       1e-07;
        relTol          0.1;
    }
}

relaxationFactors
{
    p       0.3;
    rho     1.0;
    U       0.7;
    "(k|epsilon|omega)" 0.7;
    h       0.8;
}
Of course you are quite right that an edit to an included file won't get noticed during a simulation run. You'll have to use "touch" on the main file for the changes to be noticed.
Fortunately, since controlDict now also tracks the SHA1 of the functions entry, they will not be re-initialized by this (unless their contents have changed as well).

As you probably figured, since the solver controls are now dictionary entries, you can also use $variable interpolation to reuse values.
NB: only use the $variable to reference a plain (non-regex) entry. While referencing a regex might seem to work, just avoid it. I don't think it supposed to work like that at all.
olesen is offline   Reply With Quote

Old   November 6, 2009, 14:42
Default
  #3
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi Mark,

quite interesting... and your blog stuff as well :-)
Do you know, if it is possible to do some simple calculations like adding/dividing as well?

Thanks!
Fabian
braennstroem is offline   Reply With Quote

Old   November 6, 2009, 16:27
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by braennstroem View Post
Hi Mark,
quite interesting... and your blog stuff as well :-)
Hi Fabian,
Thanks, I'm glad that someone has looked at the blog.
I'm slowly putting together other misc. bits for it as well.

Quote:
Do you know, if it is possible to do some simple calculations like adding/dividing as well?
At the moment there isn't anything like that, but it would be a fairly convenient thing to have. Depending on what exactly you need, you could try the m4 approach as a possible workaround, provided you don't have any binary data in the file. There are some examples in the tutorials where they've used it with blockMesh.

Another workaround that would be easy enough would be to add in something like an '#system()' directive that could let you do something like this:
Code:
flowRate  #system(perl -e 'print 500/3600');   // 500 kg/h
Done properly though, I think it should support the $entry syntax and allow stuff like this:
Code:
refRho     ...;
flowRate  #calc(500 / 3600);   // 500 kg/h
volFlow    #calc( $flowRate / $rho);
This would help for anyone who has suffered with having to deal with SCFM as a mass flowrate.

However, this would mean entail a small lexer/parser and thus a bit more work. Coincidentally, I've been looking at parsers recently anyhow, but I haven't managed to form a final opinion about what is really worth trying.
If it's really pressing, I could help you with implementing the #system() workaround, but I think it's a poor stop-gap measure and I'd also feel funny about knowing that my dictionaries could contain a "reliable move, really fast" command (ie, "rm -rf").
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



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