|
[Sponsors] |
Quick How-To: Sample like in sampleDict during runtime |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 22, 2016, 04:29 |
Quick How-To: Sample like in sampleDict during runtime
|
#1 |
Member
Join Date: Feb 2015
Posts: 39
Rep Power: 11 |
Hi everyone,
I recently tried to sample various data during runtime. Since I never found a satisfying example on how to do it, here is my (commented) source code that I added at the end of my control dict. The example shows a surface and a line, but can be changed to almost anything that you can use in sampleDict as well. Code:
libs ( "libOpenFOAM.so" ); functions { // ----------------- Samples a line with equidistant points ------------------ pos_1250_300_test1 /* Any name you want - will be a subfolder in "postProcessing" */ { functionObjectLibs ("libsampling.so"); /* Below this same structure as in sampleDict until the closing "}" - you have to define each sample for itself, if something differs (e.g. interpolation, otherwise you can use different values in sets*/ type sets; outputControl timeStep; outputInterval 1; setFormat raw; interpolationScheme cellPoint; fields ( p U k omega ); sets ( line_plot_1250_300 /* Name of the first line */ { type uniform; axis xyz; start ( 1.25 0.3 -1.2); end ( 1.25 0.3 1.2); nPoints 240; } line_plot_1250_200 /* Name of the second line */ { type uniform; axis xyz; start ( 1.25 0.2 -1.2); end ( 1.25 0.2 1.2); nPoints 240; } ) }; // ----------------- Sample for single point ------------------ pos_1000_300_0 /* Example for a single point - hence in a new block you can change your properties */ { type probes; functionObjectLibs ("libsampling.so"); probeLocations ( (1 0.3 0) ); fields ( p U ); outputControl timeStep; outputInterval 100; } // ----------------- Sample for a plane ------------------ cuttingPlane { type surfaces; functionObjectLibs ( "libsampling.so" ); outputControl timeStep; outputInterval 4; surfaceFormat foamFile; fields ( U ); interpolationScheme cellPoint; surfaces ( yNormal_OF /* First surface's name */ { type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (0.5 0 0); normalVector (1 0 0); } interpolate true; } someOtherSurface /* Second surface's name */ { type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (0.5 0 0); normalVector (1 0 0); } interpolate true; } ); } } I hope I was able to help you with this short code. Let me know if I messed something up, forgot something or if there is a better tutorial (case) somewhere out there =) Henning |
|
February 7, 2017, 04:29 |
|
#2 |
Member
Oleg Sutyrin
Join Date: Feb 2016
Location: Russia
Posts: 41
Rep Power: 10 |
Exactly what I need, thanks!
I've used only line sampling in OF4.0 so far. Small error in the code: there should be semicolon after "sets(...)" inside "pos_1250_300_test1" function. |
|
June 26, 2017, 19:12 |
|
#3 |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
does it run in parallel?
|
|
July 10, 2017, 08:04 |
|
#4 |
Member
Join Date: Feb 2015
Posts: 39
Rep Power: 11 |
Yes, it should run in parallel as well
|
|
May 28, 2018, 07:55 |
Point cloud
|
#5 |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Here is one more sampling function. It provides a point cloud where the points are arranged along Cartesian axes. The fields can be interpolated on these points. I found this function somewhere on OpenFOAMWiki.
I used it to generate data files which I can use in order average the flow-fields along a particular coordinate axes. //-----3D array of points along Cartesian axes---------------------- my_point_cloud { functionObjectLibs ("libsampling.so"); type sets; outputControl timeStep; outputInterval 1; setFormat raw; interpolationScheme cellPoint; fields ( U D ); sets ( arrayA1 { type array; axis xyz; coordinateSystem { e1 (1 0 0); e2 (0 1 0); origin (0 0 0); } pointsDensity (2500 200 100); spanBox (3.5 0.1 0.25); } ); } |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sample utility bug? For many cloud points in the sampleDict, some are neglected! | brandius | OpenFOAM Post-Processing | 10 | August 22, 2022 09:56 |
sample on a plane during the runtime | openfoammaofnepo | OpenFOAM Post-Processing | 2 | April 4, 2015 00:27 |
runtime sample plan: how to get gradP | Sylv | OpenFOAM Programming & Development | 5 | September 17, 2013 03:35 |
sample error depending on the name of sampleDict element | HakikiCanakkaleli | OpenFOAM Post-Processing | 0 | March 24, 2013 06:45 |
How to sample (with interpolation) at runtime | ole | OpenFOAM Programming & Development | 4 | December 14, 2010 12:57 |