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

MULTIZONE using NEMO as solver

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 7, 2024, 11:22
Unhappy MULTIZONE using NEMO as solver
  #1
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Hello everyone,

Over the past months I've been trying to simulate a pulsed detonation engine. I wanted to use NEMO_NAVIER_STOKES as my solver and mutation++ for the gas model. In order to initialize the detonation I had to split my domain in two section, a small section patched with high Pressure and Temperature, and the other at ambient conditions. To do so I used MULTIZONE. I gradually build up my cfg file and tested with different solver (e.g. EULER) before moving towards the NEMO solver. Everything worked fine up until I switched my solver to NEMO. In SU2 website it is not specified if multizone works with nemo. However the version of su2 stated there is the previous one.

Has anyone tried to couple NEMO with multizone? Is this even possible?

I noticed that when I define MARKER_ZONE_INTERFACE as well as MARKER_FLUID _INTERFACE, it crashes just before it begins to solve. Also gives a segmentation error that was identified by another member. When I comment out MARKER_ZONE_INTERFACE, simulation starts but I am not sure the results follow what is written in the cfg file (initial conditions and values are different).

Any help would be greatly appreciated. I can explain in more detail as soon as someone lets me know that it is indeed possible to use NEMO and MULTIZONE.
Thanks in advance,
Athos
Athos_e is offline   Reply With Quote

Old   February 7, 2024, 12:30
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
I am not sure if NEMO works with multizone, but I do not think that you should create initial conditions in this manner. That is because multizone computations are not very efficient and with these computations you want to be as efficient as possible.
It is better to just create an initial solution with a python script.
bigfootedrockmidget is offline   Reply With Quote

Old   February 7, 2024, 13:22
Default
  #3
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Thanks from the quick reply and the tips.
So you mean I should initialize and patch that area using an external script in python and don't use multizone?
Are you able to provide more details on how this should be done? Or a tutorial or something that can help me out as I am not familiar with this approach.
Thanks again
Athos_e is offline   Reply With Quote

Old   February 7, 2024, 13:36
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
Hi,
Just save an ASCII solution file after one iteration with NEMO. Use

OUTPUT_FILES= RESTART_ASCII
Then inspect the restart.csv file, you will see that it looks like this:
Quote:
"PointID","x","y","Pressure","Velocity_x","Velocit y_y","Pressure_Coefficient","Density","Laminar_Vis cosity"
0, 0.000000000000000e+00, -0.000000000000000e+00, 1.845439581469250e-01, 9.999989861901982e-01, -5.674622749955219e-07, 3.065514254932308e-01, 1.204000000000000e+00, 1.806000000000000e-05, 1.004703000000000e+03, 2.520130025000000e
-02, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, -4.163336342344337e-17, -1.328693289499538e-16, -5.187040137829907e-18, 1.263005603512085e-01, 1.000000000000000e+02



It is basically the solution at every point in the mesh, so it is easy to create it. You can ignore everything that is not a flow or species variable. The point coordinates are in the su2 file, it looks like this:
Quote:
NPOIN= 375
0 -0 0
0.5 -0 1
0.5 0.5 2



Read the SU2 mesh in python (or another language) and store all the points in an array, and then loop over the points. Based on the value of the coordinates, you then write a line in the restart file.
bigfootedrockmidget is offline   Reply With Quote

Old   February 8, 2024, 05:54
Default
  #5
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Hello,

Thank you very much for this. I will try it asap and come back to update the thread.

Thanks again,
Athos
Athos_e is offline   Reply With Quote

Old   February 9, 2024, 12:53
Default
  #6
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Hi again,

I spend some time understanding how the restart files work but I have a doubt.
I initially run the multizone mesh which gives me the initial conditions (since it's only one iteration) for every point along the mesh. This comes out as the restart file. Since I am using multizone i get two restart files, one for each zone. The idea is the to use these initial conditions and remove the multizone mesh and just use a mesh identical to the multizone but without any common interfaces correct?

When doing so it came to me that the two restart files will have some points that are exactly the same as this would correspond to the nodes along the interface. The problem is that I am not sure how to identify these points and then remove them from the restart file (otherwise the single zone mesh would have different point from the restart files.). Once this is done I just use the restart function and basically start my simulation with those values at every point.
As a procedure it totally makes sense, however I am not quite sure on how to identify which are the common points that I need to remove before creating a single restart file. Is there an easy way on this?

Thanks again for the help.
Best regards,
Athos.
Athos_e is offline   Reply With Quote

Old   February 9, 2024, 14:41
Default
  #7
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
Where does the mesh come from? Can't you merge the zones in the software that you used to create the geometry or the mesh?
bigfootedrockmidget is offline   Reply With Quote

Old   February 9, 2024, 15:56
Default
  #8
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
I am using GMSH to create my mesh. I created two different geo files and then obtained 2 different su2 files (one for each zone). After that I manually created the multizone mesh using the IZONE etc. as explained in su2 website. Finally in the cfg file I specified the interface.

There might be an option to merge the two meshes in gmsh, however will this solve the problem? Doesn't megring the mesh create only one set of points for the interface?
In the 2 restart files, each file contains the common interface point values. So I am not sure if this will help. However, I'll look into it
Thanks again.
Athos_e is offline   Reply With Quote

Old   February 9, 2024, 18:13
Default
  #9
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
When you have the geo files, merge the information in these files. Just create one geo file that creates the entire geometry and one single mesh.
bigfootedrockmidget is offline   Reply With Quote

Old   February 10, 2024, 05:52
Default
  #10
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
I was able to do so, basically rebuilding the mesh as one single mesh. However when i ran the simulation I noticed that even the first iteration that was supposed to be the initial conditions read by the restart file are wrong.
After I inspected both the su2 that i exported from the geo and the restart file I noticed that the correspondence of the points between the two is no longer there. In simple terms point 1 for example in the restart file does not match with the coordinates of point 1 in the su2 file. Therefore the value associated to point 1 from the restart file is given to another node in the simulation.

(Just to be clear not all nodes are wrong. The starting points up to the point where the interface was initially seem to be ok.)
So the problem is if there is a way to ensure that the two files (the two restart files and the new su2 fie containing the whole geometry) do not lose that correspondence.

Also note that in order for this to work I had to manually go into the second restart file and remove the values for the nodes on the interface. If I hadn't done this, then the number of points in the restart file would be more than the su2 file as the restart file would include the nodes of the interface twice.
It looks like this approach will work but I am not sure how to not lose this correspondece of the nodes. And doing it manually seems like a lot of work...

Appreciate you help!!
Athos_e is offline   Reply With Quote

Old   February 10, 2024, 06:30
Default
  #11
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
You need to create a restart file with your new single zone mesh.
Then, you read the restart file in for instance a python script (the easiest I think) and make a new restart file the way you want it. You do not even need the mesh file because the coordinates are in the restart file.

Here is some quick (pseudo) python code that is more or less what you should do

Code:
 with open('newrestart.csv', 'a') as my_file:   
  with open('restart.csv') as f:
   # first line are the names of the columns 
  line = f.readline()
  my_file.write(line + '\n')
  # all other line contain the coordinates on location 1,2,3 (location 0 is the index)
  line = f.readline()
  # split the lines at location of the comma
  line=line.split(',')
  coordx=float(line[1])
  coordy=float(line[2])
  coordz=float(line[3])
  # if the coordinates have a certain value, then use a specific pressure, temperature, etc.
  if (coordx< 0.12345):
    Pressure = 1.234
    # the line is split, so you can replace the STRING at the location of the pressure, for instance when it is in column 5, you do
    line[4] = str(Pressure)
    # now merge everything into a single string again and write to file

    line = ','.join(line)
bigfootedrockmidget is offline   Reply With Quote

Old   March 2, 2024, 06:44
Default
  #12
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Hey again and sorry for the late response.
Thanks for all the help, this works fine! I am encountering some issues with the NaN values but that is something I can fix i believe.
I have some other issues arising from using mutationpp but I will create a new thread about it as it is a different topic.
Again many thanks and best regards,
Athos
Athos_e is offline   Reply With Quote

Old   March 2, 2024, 13:17
Default
  #13
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 504
Rep Power: 17
bigfootedrockmidget is on a distinguished road
That's great to hear! Maybe you can write a small tutorial for the website explaining how you did this.
bigfootedrockmidget is offline   Reply With Quote

Old   March 3, 2024, 03:10
Default
  #14
New Member
 
Join Date: Aug 2023
Posts: 13
Rep Power: 2
Athos_e is on a distinguished road
Of course. So the procedure is as follows:

I divided my domain in 2 different zones. The left one being with high pressure and temperature (to initiate expansion), and the right one being with ambient conditions. So now I have two cfg files and two su2/mesh files (one for each domain, so 2 different simulations basically). I then ran the simulation for time_iter= 2 for each domain. This is because I was using second order dual time stepping method as time marching. When this is done we have 4 restart files, 2 for iter_1 (1 for the left and one for the right domain) and 2 for iter_2 (restart_flow_00000, restart_flow_00001). Using these we then want to create a solution file for the case where we combine the two domains into a single mesh (cfg and su2 file for the complete domain).

I wrote a script in matlab (but can be done in python as well). The idea of the script is to first read the restart file and then create a new restart file that contains all the points of the whole domain so as to be used as a restart solution on the final combined domain. To do this I created a general csv file that only has the first row, and first 3 columns and contains all the points of the combined mesh. To build this you can just run the combined simulation without restart solution just to get the csv file, then just delete all entries apart from 1st row and first 3 columns (first row is the variables' name and first three columns should be the Point ID, x and y coordinates).

The script basically then reads the 1st iter restart flow of the left and right domain, and combines the two in a single csv file. It also ignores double entries that will arise at the point of intersection, where the left and right domain meet. Then you have a restart solution that has all the points of the combined mesh but not in order as the su2 file of the combined mesh. I noticed that the solution csv file and su2 file should have the same order of pointID.

Therefore a second function reads the generated restart solution of the first iter and also reads the general.csv file. It goes through the coordinates of x and y of the general.csv and copies the corresponding values from the generated restart flow. Now we are left with a solution_00000.csv file that is technically the file that containes the values of all the points for the combined mesh. Some NaN values may arise so you can either write a script to remove them. I believe this is due to how matlab handles some variables, python may be better suited for this job.

Then you just repeat the above process but for the 2nd iter of restart flows of left and right domain. This will give you the second solution_00001.csv file needed to run the simulation on the whole domain without the need of multizone functions.

It might be a bit confusing but i will also include some pictures and csv files to get the idea.

In simpler terms: we have 2 domains (left and right). We run for 2 time iters each giving us in total 4 restart_flow.csv files (2 for 1st iter for left and right and 2 for 2nd iter). We prepare a general.csv file that contains the pointID,x,y coordinates as the su2 file of the whole combined domain. We input in the script 1st iter of left and right domain that creates the 1st iter restart file for the combined domain. Then we use the general adn generated restart file to rearrange the points in csv and match the order in the su2 file. Then need to remove any NaN values and we get the solution file that will be used for the 1st iter of the combined mesh. Repeat for the 2nd iter.

Please reply to this post if something is unclear and you need more guidance. Also any feedback is greatly appreciated!
Attached Images
File Type: jpg Domains.jpg (23.6 KB, 3 views)
Attached Files
File Type: txt Matlab script.txt (2.6 KB, 1 views)
Athos_e is offline   Reply With Quote

Reply

Tags
multizone meshing, nemo, su2 8.0.0


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 do I connect a geometry to my solver devansh.purohit Main CFD Forum 4 November 16, 2021 08:51
thobois class engineTopoChangerMesh error Peter_600 OpenFOAM 4 August 2, 2014 09:52
Divergence problem Smaras FLUENT 13 February 21, 2013 05:03
3d vof Smaras FLUENT 2 February 19, 2013 06:58
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 14:08


All times are GMT -4. The time now is 07:09.