Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
The attached is a screen shot of a 3D model result. The plot option chosen is "Slice Plot" in the X-Y plane at z=0.5.



I would like to plot this same data on the slice but using iso contour lines rather than (or overplayed with) a rainbow plot.



I note that 2D iso contours are available, how about in 3D on a 2D surface (slice or planar boundary)?

Kind regards,
Randal
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Precise Simulation
Administrator
randress wrote
The attached is a screen shot of a 3D model result. The plot option chosen is "Slice Plot" in the X-Y plane at z=0.5.

I would like to plot this same data on the slice but using iso contour lines rather than (or overplayed with) a rainbow plot.

I note that 2D iso contours are available, how about in 3D on a 2D surface (slice or planar boundary)?

Kind regards,
Randal
Iso lines in 3D are not currently available with the built-in FEATool postprocessing tools. However, you should most certainly be able to do this in ParaView if you export the postprocessing data in VTK format (by selecting "Export Results..." > "ParaView VTK/VTP Format..." from the "Post" menu).
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
Iso lines in 3D are not currently available with the built-in FEATool postprocessing tools. However, you should most certainly be able to do this in ParaView if you export the postprocessing data in VTK format (by selecting "Export Results..." > "ParaView VTK/VTP Format..." from the "Post" menu).
Evidently this export capability is only available in the upgraded versions. Correct?

-Randal
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
Iso lines in 3D are not currently available with the built-in FEATool postprocessing tools. However, you should most certainly be able to do this in ParaView if you export the postprocessing data in VTK format (by selecting "Export Results..." > "ParaView VTK/VTP Format..." from the "Post" menu).
I have indeed been able to generate iso lines on a slice by exporting to ParaView for visualization.

For example, from the FEAtool problem represented by this current density plot:



using ParaView I was able to plot the voltage:



and the current density:



But I cannot seem to plot along with them, as I can with FEAtool, the geometry/wireframe of the problem. Is the geometry data placed in the exported file?

Regards,
Randal
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Precise Simulation
Administrator
randress wrote
But I cannot seem to plot along with them, as I can with FEAtool, the geometry/wireframe of the problem. Is the geometry data placed in the exported file?
No, the VTK file only includes the mesh and evaluation of postprocessing data in the vertices. However, I believe ParaView does support STL import, so you should be able to export the geometry as STL data from FEATool separately, and import it alongside your postprocessing data into ParaView.
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
No, the VTK file only includes the mesh and evaluation of postprocessing data in the vertices. However, I believe ParaView does support STL import, so you should be able to export the geometry as STL data from FEATool separately, and import it alongside your postprocessing data into ParaView.
As you say adding the STL to the same session does the trick.





Pretty powerful that ParaView!

Now I just need to get the data for those iso lines smoothed, but that is another thread ... :-)

Regards,
Randal
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
In reply to this post by Precise Simulation
Precise Simulation wrote
Iso lines in 3D are not currently available with the built-in FEATool postprocessing tools. However, you should most certainly be able to do this in ParaView if you export the postprocessing data in VTK format (by selecting "Export Results..." > "ParaView VTK/VTP Format..." from the "Post" menu).
Although I was able to export FEAtool results to ParaView and produce Iso contour plots on a planar slice/cut-plane (See results posted elsewhere in this thread.), I would still prefer to do as much processing as I can in Matlab/FEAtool. I have experimented with Matlab functions such as slice, contourslice, contour, contour3 ... These seem to offer this type of capability, but I wonder whether there is an interpolation of the fea solution data that is necessary.  So my question is, short of an FEAtool added capability, are there manual Matlab and FEAtool functions that could be used to produce and plot contour data on a slice?

Kind regards,
Randal
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Precise Simulation
Administrator
randress wrote
Although I was able to export FEAtool results to ParaView and produce Iso contour plots on a planar slice/cut-plane (See results posted elsewhere in this thread.), I would still prefer to do as much processing as I can in Matlab/FEAtool. I have experimented with Matlab functions such as slice, contourslice, contour, contour3 ... These seem to offer this type of capability, but I wonder whether there is an interpolation of the fea solution data that is necessary.  So my question is, short of an FEAtool added capability, are there manual Matlab and FEAtool functions that could be used to produce and plot contour data on a slice?
I didn't consider it before, but you can technically extract the data from a 3D slice, use it to create a 2D grid, from which a "mock" 2D fea struct can be generated, on which the usual 2D postplot functionality can be used, for example

    fea = ex_poisson6('iplot',0,'igrid',-1);

    % Plot and extract 3D slice.
    f = figure();
    h = postplot( fea, 'parent', f, 'sliceexpr', 'u', 'slicex', [], 'slicey', [], 'slicez', 0.3 );
    h = findall(h,'type','patch');   % Get Matlab graphics handle to patch/slice.

    % Create 2D grid.
    grid.p = get(h,'Vertices')';
    grid.p(3,:) = [];   % Delete z-coordinates.
    grid.c = get(h,'Faces')';
    grid.a = gridadj(grid.c,2);
    grid.b = gridbdr(grid.p,grid.c,grid.a);
    grid.s = ones(1,size(grid.c,2));

    % Create help fea2 data struct.
    fea2.sdim = {'x', 'y'};
    fea2.grid = grid;
    fea2 = addphys(fea2,@poisson);
    fea2 = parsephys(fea2);
    fea2 = parseprob(fea2);
    fea2.sol.u = get(h,'FaceVertexCData');

    f2 = figure();
    postplot( fea2, 'parent', f2, 'surfexpr', 'u', 'isoexpr', 'u' )
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
I didn't consider it before, but you can technically extract the data from a 3D slice, use it to create a 2D grid, from which a "mock" 2D fea struct can be generated, on which the usual 2D postplot functionality can be used, for example

    fea = ex_poisson6('iplot',0,'igrid',-1);

    % Plot and extract 3D slice.
    ...

    % Create 2D grid.
    ...

    % Create help fea2 data struct.
    ...
    postplot( ... )
T H I S works G R E A T!

I have created a function isolineslice() (attached).  It only requires the export of the fea struct after being solved.

isolineslice.m

A call looks like this:
isolineslice (fea, 'XY', 0.5, 20);
with these results:

and



I would like to eliminate the orthoplane and val arguments by just copying them from fea:
    xslice = PROB.gui.post.slicex;
    yslice = PROB.gui.post.slicey;
    zslice = PROB.gui.post.slicez;
after plotting the slice with FEAtool. However, it seems that some of these post fields get re-populated by a default(?) after plotting the specified slice.  This looks like an unintended feature that could perhaps be corrected. Corrrect?

I would also like to add more control of the iso lines and the legend such as the plotted range (begin and end values) and how to scale the legend to fit on the page. Any help would be greatly appreciated.

Thanks for digging into this for me!
-Randal




Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Precise Simulation
Administrator
randress wrote
I have created a function isolineslice() (attached).  It only requires the export of the fea struct after being solved.

isolineslice.m

A call looks like this:
    isolineslice (fea, 'XY', 0.5, 20);
This is very nice, thank you for sharing your function and results.

randress wrote
I would like to eliminate the orthoplane and val arguments by just copying them from fea:
    xslice = PROB.gui.post.slicex;
    yslice = PROB.gui.post.slicey;
    zslice = PROB.gui.post.slicez;
after plotting the slice with FEAtool. However, it seems that some of these post fields get re-populated by a default(?) after plotting the specified slice.  This looks like an unintended feature that could perhaps be corrected. Correct?
Hmm, actually the whole "gui" field should probably not be present during fea struct export, so I would not recommend using any information from there. I think you can reconstruct the slice input from the actual slice coordinates, something like:


   h = findall(0,'tag','fea_slice');   % Get patch directly from FEATool GUI.

   if( isempty(h) )   % Plot slice manually if not available.
     h = postplot( PROB, 'sliceexpr' ... 
   end

   ...

   TOL = sqrt(eps);
   for i=1:3
     if( all( abs(p(i,:) - p(i,1)) < TOL ) )
       slice_pos_xyz{i} = mean(p(i,:));
     else
       slice_pos_xyz{i} = [];
     end	 
   end

randress wrote
I would also like to add more control of the iso lines and the legend such as the plotted range (begin and end values) and how to scale the legend to fit on the page.
If the "isoval" input is an integer scalar then the contour lines are computed as "linspace(min_val, max_val, isoval)", alternatively you can input a vector of specific value yourself, for example "isoval := [0.1, 0.2, 0.5]" or "isoval := linspace(0.1,0.5,10)".
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
Hmm, actually the whole "gui" field should probably not be present during fea struct export, so I would not recommend using any information from there. I think you can reconstruct the slice input from the actual slice coordinates, something like:
HA!! I just upgraded to 1.12.2 ... you warned me :-)  Just as I had figured out how to assure the side effect that I wanted...

Anyway I decided to require the input of that info anyway. I can imagine wanting to execute it repeatedly using different parameters and without having to go back to FEATool to do the postprocessing plot.  Here is what the definition and call looks like now:
 
%   function isolineslice (PROB, evalexpr, orthoplane, val, lvls, cmap)
>> isolineslice(fea,  "V", "XY", 0.5, 10, "autumn")
And here is the updated file: isolineslice.m

But there seems to be something wrong ...

When I execute this:
>> isolineslice(fea,  "s_dc*sqrt(Vx^2+Vy^2+Vz^2)", "XY", 0.5, 40, "jet")

I get ...

3D plot:



2D plot:


and when I execute this:
>> isolineslice(fea,  "s_dc*sqrt(Vx^2+Vy^2+Vz^2)", "YZ", 0.5, 40, "jet")

I get...

3D plot:


2D plot:


Two things seem to be wrong.

1. Only one of the small connecting cylinders is plotted in each case.

2. A different one is plotted in each case.

Can you see what is amiss?

I am also attaching the model file:cylinders_between_cylinders_in_boxv1.fea

Kind regards,
Randal


Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

Precise Simulation
Administrator
This was a technical bug, please re-install/update to 1.12.2 Build 20.04.120:

https://github.com/precise-simulation/featool-multiphysics/raw/master/FEATool%20Multiphysics.mlappinstall
Reply | Threaded
Open this post in threaded view
|

Re: Slice Plot of 3D Result Showing Iso Contour Lines on a Slice

randress
Precise Simulation wrote
This was a technical bug, please re-install/update to 1.12.2 Build 20.04.120:

https://github.com/precise-simulation/featool-multiphysics/raw/master/FEATool%20Multiphysics.mlappinstall
Looks good now. Thanks for the fix!
Kind regards,
Randal