When I try to export transient results from a COMSOL simulation to paraview via vtk export, I always end up with separate field names, instead of the field names in separate time steps. See images below.
Is there a method / filter to make sure that these are converted to timesteps?
Or should I use a different method to export my results?
You should change the way you are exporting your data.
If that is not possible, you can convert your data using ParaView into a temporal one but it requires manual creation of a .pvd file.
Let me know if you need help with that.
Well, I can export the separate time steps in separate vtk files (then the field names are plain u, v, w). Otherwise there is little I can change in COMSOL itself I guess (export to txt is possible).
Would that make it easier to load into paraview?
And how would I make a pvd file out of this?
THanks for your help
Would that make it easier to load into paraview?
Yes
And how would I make a pvd file out of this?
You can either create .pvd like this one: merged.pvd (3.4 KB)
Or use the time series mechanism with the naming of your files:
https://docs.paraview.org/en/latest/UsersGuide/dataIngestion.html#handling-temporal-file-series
Great!
I need a macro (âmethodâ in COMSOL) to export them as separate files, with the correct name. But then it works as your link proposed.
The time is then not fully correct, that would probably be fixed by the pvd you mention.
But for simple animation purposes, your method is perfect and will use that for now. Thanks a lot!
I have just tried this workflow (COMSOL - VTU - PVD) above, and itâs working without any issues for transient results. Thanks for the discussion.
Hi Mathieu,
I am having the same problem. There is only one way, that I know of, to export .vtu files from COMSOL and when importing to Paraview, each timestep is a fieldname basically. Can you explain more on how can I use Paraview to manually create .pvd files and how can I merge them? I am having around 70 fileldnames (such as Pressure_@t=1, Pressure@_t=2,etcâŚ).
After import the .vtu files into Paraview, I tried to save them as .pvd as you said but they dont seem to do anything.
Thanks.
Tien
Hi Tien,
Drag all vtu data in paraview pipeline browser and then file â save data â .pvd (do select write time steps option before saving from the box).
You can also do it manually just writing a PVD file with text editor such as follows:
<VTKFile type="Collection" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<Collection>
<DataSet timestep="0" part="0" file="auto/Pressure_@t=1.vtu"/>
<DataSet timestep="1" part="0" file="auto/Pressure_@t=2.vtu"/>
<DataSet timestep="2" part="0" file="auto/Pressure_@t=3.vtu"/>
</Collection>
</VTKFile>
In order to make this work, you should put all VTU data under the âauto directoryâ. âauto.pvdâ and âauto directoryâ should also be under the same directory to find VTU data. By dragging âauto.pvdâ in paraview pipeline, it should automatically read all VTU data.
Hi Serkan,
Thanks for a quick reply. I have followed the instruction and it still does not seem to work. I have got the .pvd file and also the folder and they are both in the same directory. But when I drag the .pvd file into Paraview, it still does not combine all the fieldname.
Here is the .vtu file I have exported from COMSOL (Untitled.vtu - Google Drive), I cant do an animation with this type of export.
Hi Tien, I guess that it helps to export all the timesteps as separate vtu files.
I used a method for that which looks like this:
The maxsteps is the max index of the results. For the rest make sure that the folder is correct, and that
You can also export all the steps manually, make sure that the numbering increases with every step.
int export = 1;
int max_steps = 12;
while (export < max_steps) {
with(model.result().export(âdata1â));
setIndex(âlooplevelindicesâ, export, 0);
set(âfilenameâ, âC:\vtk export\res_â+export+".vtu");
endwith();
model.result().export(âdata1â).run();
export++;
}
Hi Frank,
Thank you. I was also about to ask how you can export multiple .vtu from COMSOL? and with a large number of timesteps, I dont think exporting it manually and changing the name accordingly is a viable option.
Where do you put that piece of code in COMSOL?
You can use a âmethodâ for this (depending on the version you use).
There are several blogs and movies Build Simulation Apps from Your COMSOLÂ MultiphysicsÂŽ Model.
Sometimes it can be useful to record a method to see the code that is needed.
I use version 5.5 btw.
and then to run them:
Now I got your problem. You have a single VTU composed of multiple arrays for transient pressure data. I have currently no idea how this dataset could be broken into pieces.
Instead, what Frank proposed sounds wise. Get a âmethodâ in COMSOL to automate data extraction. You should get a VTU extract for each time step. Then the way PVD we discuss above should definitely work.
You exactly have the same data processing problem as Frank had had. You cannot create temporal data from fieldnames saved as point/cell arrays.
Thanks for the screenshot. I will try to export them this way. I am also on 5.5 as well.
Thanks Serkan, it should work if I can get COMSOL to export the files that suit Paraview.