Output 2D file from 3D simulation

478 views
Skip to first unread message

Bing Cao

unread,
May 21, 2020, 9:56:47 AM5/21/20
to Nek5000
Dear Neker,

I am now running 3D simulations. I would like to output 2D file (say span-wise averaged velocity field). Is it possible? I tried the subroutine "output" but it comes out 3D file. Is there any other subroutine I could use?

Thanks in advance
Yours sincerely
Bing

Juan Colmenares

unread,
May 21, 2020, 12:02:52 PM5/21/20
to Nek5000
Do you mean the "outpost" subroutine? There's also the outfld2d and outfld2d_p subroutines, but it's never worked for me... you can give them a try. 

- JD

Ketan Mittal

unread,
May 21, 2020, 2:02:51 PM5/21/20
to Nek5000
Hi Bing,

The attached .usr file shows an example of how a 2D mesh can be output from a 3D mesh. Here, I assume that the 3D mesh was generated by extruding the domain in the z-direction. The size of the 2D mesh is controlled by the parameters `nxp` and `nyp` at the top of the usr file, and the routine `planar_output` interpolates data in `vx`, `vy`, `vz`, `pr`, and `t` arrays and outputs them in the 2D file using `outfld2d_xy` routine.

Let me know if you have any questions.

Ketan
example.usr

Bing Cao

unread,
May 22, 2020, 2:18:34 AM5/22/20
to Nek5000
Hi Juan,

Thanks for your hint. Please refer to Ketan's reply. It works for me at least for turbChannel case. But still thanks for your reply.

Yours sincerely
Bing

Bing Cao

unread,
May 22, 2020, 2:20:14 AM5/22/20
to Nek5000
Hi Ketan,

I have a try on turbChannel case and it works. Thanks for your help! Much appreciate!

Yours sincerely
Bing

Bing Cao

unread,
May 22, 2020, 5:04:09 AM5/22/20
to Nek5000
Hi Ketan,

When I using the code you provide, I am confused with the definition of "nxp" and "nyp". Are there any rules to define nxp and nyp? Like, "nyp" should be less equal to the number of elements on y-axis (nely in .box file). Hope I explain clear.

I find that when I define "nyp" much larger than "nely", it would cause an error message when importing to paraview.

Thanks for your time!
Yours sincerely
Bing

On Friday, May 22, 2020 at 4:02:51 AM UTC+10, Ketan Mittal wrote:

Ketan Mittal

unread,
May 22, 2020, 3:28:59 PM5/22/20
to Nek5000
Hi Bing,

There are no restrictions to nxp and nyp.

The error that you are getting is due to the format in which the header is written to the output file. The first number in the first file is supposed to have the number of elements ((nxp-1)*(nyp-1)) but due to the format of the write statement, you will probably see "****" there instead of number of elements when the count is greater than 9999. You can fix this by manually editing the first number of the output file to the actual number.

Hope this helps,
Ketan

Ketan Mittal

unread,
May 22, 2020, 3:33:09 PM5/22/20
to Nek5000
In the attached .usr file, I have fixed the issue by adding a new subroutine to the file that writes the header accurately so that you don't need to edit it manually.

Ketan
example.usr

Bing Cao

unread,
May 23, 2020, 1:59:33 AM5/23/20
to Nek5000
Hi Ketan,

It works perfect now. Thanks for your code.

Yours sincerely
Bing

Bing Cao

unread,
May 25, 2020, 5:47:46 AM5/25/20
to Nek5000
Hi Ketan,

Sorry for disturbing again. 
I notice the comment in subroutine outfld2d_xy:

c specify ifxyo and ifto to get x,y and temperature values

Could you please explain what it represents?

I would like to output the temperature field. For some case, the code seems to be fine. But for another case I run, it has bugs when outputting pressure and temperature field (if you would like to see, I will attach the snapshot). I am considering if it is relevant to the comment above. So could you please explain more? I didn't find ifxyo and ifto in subroutine and .rea file.

Thanks in advance!
Yours 
Bing

rigolli...@gmail.com

unread,
Oct 1, 2020, 10:09:44 AM10/1/20
to Nek5000
Dear all,

Due to storage issues (I have many spatial points and I also need a high temporal resolution) I would like to save instead of the usual output namefile0.f***** only a 2D slice of my 3D simulation, my setup is not too different from turb_channel but the proposed solutions is not very clear to me.

Can someone give me a hint?

Thank you so much,
best regards

Nicola

Fischer, Paul

unread,
Oct 1, 2020, 3:45:02 PM10/1/20
to rigolli...@gmail.com, Nek5000
Hi Nicola,

Ketan tried to post the below... I'm attaching it here.

hth,
Paul

Hi Nicola,

Try using the attached example.usr to output 2D slices from a 3D calculation.

In this .usr file, the output mesh size is defined at the top using `nxp` and `nyp` which define equally spaced points in the domain where the solution is interpolated. The `planar_output` routine does the following:
1. A 2D grid of nxp x nyp points is constructed and saved in `xall`, `yall` and `zall` arrays. I currently set `zall` to 0, and you can modify this based on where you want the z-slice to be at.
2. The velocities (vx, vy, and vz) and temperature (t) is interpolated using 
3. The interpolated values are stored in a 2D mesh format and output using the routine `outfld2d_xy`. 

Right now I assume that the slice is in the xy-plane. Second, the z-velocity is output in the pressure field of the 2D file.

Please let me know if you have any questions.

Ketan


From: nek...@googlegroups.com <nek...@googlegroups.com> on behalf of rigolli...@gmail.com <rigolli...@gmail.com>
Sent: Thursday, October 1, 2020 9:09 AM
To: Nek5000 <nek...@googlegroups.com>
Subject: [nek5000] Re: Output 2D file from 3D simulation
 
--
You received this message because you are subscribed to the Google Groups "Nek5000" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nek5000+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nek5000/283294d4-33ae-40de-96b4-e3ccf03ee9c1n%40googlegroups.com.
2d_out.usr

Sina Tahmooresi

unread,
Nov 25, 2024, 1:33:05 PM11/25/24
to Nek5000
Hello Ketan,

Following what you shared for extracting a 2d slice from a 3d mesh, I was wondering if one can utilize it for the perpendicular direction (x=0, for instance). I have my domain as an extrusion in z direction of  x-y plane mesh. However, my central plane is z=0 and need to visualize the data on that plane. I don't have periodic B.C.s and thus the purpose is to extract a 2D slice to monitor the flow development at an arbitrary instance. My problem is a flow out of a pipe (mapped from a pipe using neknek) into a tank.

Regards,
Sina
Reply all
Reply to author
Forward
0 new messages