[Getdp] Evaluate a scalar field at some points, print values on terminal and use them in PostOperation
michael.asam at infineon.com
michael.asam at infineon.com
Tue May 24 16:22:38 CEST 2016
Hi Gilles,
in the attachments you’ll find a simple example which I had at hand for calculating an electrostatic potential. There I implemented
the evaluation of the potential at a certain point and the evaluation of the maximum potential. The last one is just for demonstration,
because the maximum voltage is given by the Dirichlet boundary condition. The results are displayed in Gmsh’s
sidebar.
Regarding the benchmark folder: I just saw that it is obviously not in the ziped file which you can download from the homepage.
But you can find it here online: https://onelab.info/trac/getdp/browser/trunk/benchmarks There are many nice examples.
Also on the onelab homepage you can find good and well documented examples: http://onelab.info/wiki/GetDP
Have a nice day!
Michael
From: gilles quemener [mailto:quemener at lpccaen.in2p3.fr]
Sent: Tuesday, May 24, 2016 2:59 PM
To: Asam Michael (IFAG ATV BP D PD DES1)
Cc: getdp at onelab.info
Subject: Re: Evaluate a scalar field at some points, print values on terminal and use them in PostOperation
Hi Michael,
Thanks a lot for your answer, it helped me a bit but I still have some problems using registers.
In the GetDP, Gmsh and Onelab sources, I could not find any folder named "benchmarks".
However, I looked at the GetDP manual as well as at the different examples in the "models"
folder but still I could not figured out how to use registers in Print and Echo commands.
In the following code snippet you will find among other things I have tested what fails at parsing
time.
//Post Operation
//==============
PostOperation{
{Name Map_u; NameOfPostProcessing CubicCavity;
Operation{
// Stores in register #1 the scalar potential value evaluated at point {0, 0, 0.5}:
Print [ utotm, OnPoint {0, 0, 0.5}, StoreInRegister 1, Format SimpleTable, File "Result_Dummy.txt" ]; // WORKS !!!
// Stores in register #2 the minimum value of the scalar potential over region GammaInner:
Print [ utotm, OnElementsOf GammaInner, StoreMinInRegister 2, Format SimpleTable, File "Result_Dummy.txt" ]; // WORKS !!!
Echo [ Sprintf("Min = %g", #1) ]; // FAILS !!!!
// Stores in register #3 the maximum value of the scalar potential over region GammaInner:
Print [ utotm, OnElementsOf GammaInner, StoreMaxInRegister 3, Format SimpleTable, File "Result_Dummy.txt" ]; // WORKS !!!
Echo [ Sprintf("Max = %g", #2) ]; // FAILS !!!!
// Tentative to retrieve iso-contour points for the potential utotm = (utotmMin + utotmMax) / 2 :
Print [ utotm, OnElementsOf GammaInner, Iso { 0.5 * (#2 + #3) }, Sort Position, Format SimpleTable, File "out1.txt" ]; // FAILS !!!!
Print [ utotm, OnElementsOf GammaInner, Iso { Evaluate[ 0.5 * (#2 + #3)] }, Sort Position, Format SimpleTable, File "out2.txt" ]; // FAILS !!!!
}
}
}
Thanks a lot for any help,
Gilles
________________________________
De: "michael asam" <michael.asam at infineon.com<mailto:michael.asam at infineon.com>>
À: quemener at lpccaen.in2p3.fr<mailto:quemener at lpccaen.in2p3.fr>
Cc: getdp at geuz.org<mailto:getdp at geuz.org>
Envoyé: Mardi 24 Mai 2016 09:53:54
Objet: RE: Evaluate a scalar field at some points, print values on terminal and use them in PostOperation
Hi Gilles,
you can evaluate the value at a specified point in a PostOperation like this:
Print[ u, OnPoint {xp, yp, zp} , File "MyResult" , Format SimpleTable];
You can also find the min/max value and/or the corresponding coordinates and store them
in a register for later use in another PostProcessing (search in the manual for StoreMinInRegister
and StoreMinXinRegister):
Print[ u, OnElementsOf TotalDomain, StoreMaxInRegister 1, Format SimpleTable, File "Result_Dummy.txt"];
There are various examples in the folder benchmarks in the source code showing the usage
of registers and how to print number results directly in Gmsh’s sidebar.
Cheers,
Michael
From: getdp [mailto:getdp-bounces at ace20.montefiore.ulg.ac.be] On Behalf Of gilles quemener
Sent: Monday, May 23, 2016 2:30 PM
To: getdp at onelab.info<mailto:getdp at onelab.info>
Subject: [Getdp] Evaluate a scalar field at some points, print values on terminal and use them in PostOperation
Hi,
Currently I am trying to evaluate a scalar field solution at some given points
and to evaluate the min and max of this scalar field. Once this is done I would
like to print these quantities on the terminal window as well as to use them for
further PostOperation.
Assume GetDP has solved my problem and is able to compute scalar fieldsu
and utotm as described in the GetDP script below.
How can I get the following quantities at Point {xp, yp, zp}:
u1 = u(xp, yp, zp)
u2 = utotm(xp, yp, zp)
and:
umin = min(u) over a region
umax = max(u) over a region
utotmmin = min(utotm) over a region
utotmmax = max(utotm) over a region
I have tried several syntaxes for the different quantities above, but none passed the parsing phase w/o error.
Therefore if someone has clues or a solution, it would be very helpful !
//Post Processing
//===============
PostProcessing{
{Name CubicCavity; NameOfFormulation CubicCavity;
Quantity{
{Name u; Value {Local{[{u}]; In TotalDomain; Jacobian JVol;}}}
{Name utotm; Value {Local{[{u}-scalpot[]]; In TotalDomain; Jacobian JVol;}}}
}
}
}
//Post Operation
//==============
PostOperation{
{Name Map_u; NameOfPostProcessing CubicCavity;
Operation{
Print [ u, OnElementsOf GammaInner, File "uIIsur_3D.pos" ];// works !
Print [ utotm, OnElementsOf GammaInner, File "uIImuI_3D.pos" ];// works !
Print [ utotm, OnElementsOf GammaInner, Iso {0.65}, Sort Position, Format SimpleTable, File "out.txt" ];// works !
// Note: Be carefull, in order to visualize the .pos file below in Gmsh, it does not work w/ option "Iso-values"
// even if it is a single iso-contour/iso-value, I have to use option "Continuous Map" (?!?!)
Print [ utotm, OnElementsOf GammaInner, Iso {0.65}, Format Gmsh, File "toto.pos" ];// works !
// How to print the value of scalar field u or utotm at a specific point (e.g. (0,0,1.3)) on terminal ?
Printf [ "U=%g", u(0, 0, 1.3) ];
Printf [ "Utotm=%g", utotm(0, 0, 1.3) ];
// How to get min and max values on some region and use them in other PostOperation ?
umin = Min(u[]) OnElementsOf GammaInner;
umax = Max(u[]) OnElementsOf GammaInner;
N = 10;
du = (umax - umin) / N;
For i In (1, N)
uval = umin + (i - 0.5) * du;
Print[ utotm, OnElementsOf GammaInner, Iso { uval }, Sort Position, Format SimpleTable, File >> "out.txt" ];
EndFor
}
}
}
Thanks a lot for any help,
Gilles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/getdp/attachments/20160524/5f705906/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ED-Feld.zip
Type: application/x-zip-compressed
Size: 14532 bytes
Desc: ED-Feld.zip
URL: <http://onelab.info/pipermail/getdp/attachments/20160524/5f705906/attachment-0001.zip>
More information about the getdp
mailing list