selecting/unselecting bodies with paraview

General discussion about Elmer
raback
Site Admin
Posts: 3291
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: selecting/unselecting bodies with paraview

Post by raback » 05 Mar 2017, 00:56

Hi Wil

One can only import stuff that it supported by the format. I have not been able to figure out how names would be saved in VTU format for Paraview. Once I know the format, if such exists, it is pretty minor coding task. Any ideas?

-Peter

Wil
Posts: 62
Joined: 10 Jan 2014, 13:26
Antispam: Yes
Location: Austria

Re: selecting/unselecting bodies with paraview

Post by Wil » 05 Mar 2017, 10:31

Dear Peter,
Thx for the insight. I will try to look into it.

Do to have any suggestions regarding the posted example with storing a dummy variable for indexing the boundaries?

Thanks in advance,
Wil

Wil
Posts: 62
Joined: 10 Jan 2014, 13:26
Antispam: Yes
Location: Austria

Re: selecting/unselecting bodies with paraview

Post by Wil » 05 Mar 2017, 10:41

Hi Peter,
How about using the boundary names from .unv to automatically generate new variables with the same name and value 1. on the specific boundary while it is 0 everywhere else.
BR
Wil

annier
Posts: 1102
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: selecting/unselecting bodies with paraview

Post by annier » 05 Mar 2017, 10:58

Hi,
I opened a vtu file with libreoffice writer and found the following contents for results exported from Elmer:

Code: Select all

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="331" NumberOfCells="1616">
      <PointData>
        <DataArray type="Float64" Name="temperature" NumberOfComponents="1" format="appended" offset="0"/>
        <DataArray type="Float64" Name="temperature loads" NumberOfComponents="1" format="appended" offset="2652"/>
        <DataArray type="Float64" Name="velocity 1" NumberOfComponents="1" format="appended" offset="5304"/>
        <DataArray type="Float64" Name="pressure" NumberOfComponents="1" format="appended" offset="7956"/>
        <DataArray type="Float64" Name="flow solution loads" NumberOfComponents="3" format="appended" offset="10608"/>
      </PointData>
      <CellData>
        <DataArray type="Int32" Name="GeometryIds" format="appended" offset="18556"/>
      </CellData>
      <Points>
        <DataArray type="Float64" NumberOfComponents="3" format="appended" offset="25024"/>
      </Points>
      <Cells>
        <DataArray type="Int32" Name="connectivity" format="appended" offset="32972"/>
        <DataArray type="Int32" Name="offsets" format="appended" offset="57040"/>
        <DataArray type="Int32" Name="types" format="appended" offset="63508"/>
      </Cells>
    </Piece>
  </UnstructuredGrid>
<AppendedData encoding="raw">
_X

This is a solution for the temperature, pressure and velocity variables of coupled Heat Equation and Flow Solver. The geometry is a cube (3D). The remaining part of the vtu file cannot be read . The file is generated by Elmer . I guess additional coding needs to be done in the name "GeometryIds".

Some references:
1. http://stackoverflow.com/questions/3185 ... r-paraview
2. Software exporting the vtu file described in reference post 1.
3. http://www.vtk.org/wp-content/uploads/2 ... ormats.pdf
4. https://people.sc.fsu.edu/~jburkardt/data/vtk/vtk.html
5. https://www.file-extensions.org/vtu-file-extension
6. http://www.earthmodels.org/software/vtk ... le-formats
7.http://www.solvusoft.com/en/file-extens ... nsion-vtu/

Yours Sincerely,
Anil Kunwar

Wil
Posts: 62
Joined: 10 Jan 2014, 13:26
Antispam: Yes
Location: Austria

Re: selecting/unselecting bodies with paraview

Post by Wil » 05 Mar 2017, 23:18

Thanks Anil Kunwar but writing a vtu file myself is a little bit over the top for me.


I would be happy if I could create a dummy variable 'my_boundaries' in elmer and set these variable for specific boundaries and bodies to values I like.
It is similar to using Geometry Ids but defined by myself.

UPDATE:
I achieved the above wanted for boundaries but not simultaneously for boundaries and bodies 8-) . I introduced a variable "b" (for boundaries) in the results-output solver but was not able to create a second variable d for bodies.
The creation of several variables would also be necessary for the creation of variables for each read .unv group-name.
Here my .sif.

Code: Select all

Header
  CHECK KEYWORDS Warn
  Mesh DB "." "."
  Include Path ""
  Results Directory ""
End

Simulation
  Max Output Level = 5
  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Simulation Type = Steady state
  Steady State Max Iterations = 1
  Output Intervals = 1
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.vtu
End

Constants
  Gravity(4) = 0 -1 0 9.82
  Stefan Boltzmann = 5.67e-08
  Permittivity of Vacuum = 8.8542e-12
  Boltzmann Constant = 1.3807e-23
  Unit Charge = 1.602e-19
End

Body 1
  Target Bodies(1) = 1
  Name = "Body 1"
  Equation = 1
  Material = 1
End

Solver 2
  Equation = Electrostatics
  Variable = Potential
  Procedure = "StatElecSolve" "StatElecSolver"
  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-5
  Nonlinear System Convergence Tolerance = 1.0e-7
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1
  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStab
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 2
  Linear System Preconditioning = Diagonal
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 1
  Linear System Precondition Recompute = 1
End

Solver 1
  Equation = Result Output
  Output Format = Vtu
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
Variable = b
!Variable2 = d
  Output File Name = case
  Scalar Field 3 = d
  Scalar Field 2 = b
  Scalar Field 1 = Potential
  Exec Solver = Always
End

Equation 1
  Name = "Equation 1"
d = Real 1.
  Active Solvers(2) = 2 1
End

Material 1
  Name = "Air (room temperature)"
  Viscosity = 1.983e-5
  Heat expansion Coefficient = 3.43e-3
  Heat Conductivity = 0.0257
  Relative Permittivity = 1.00059
  Sound speed = 343.0
  Heat Capacity = 1005.0
  Density = 1.205
End

Boundary Condition 1
  Target Boundaries(1) = 1 
  Name = "BoundaryCondition 1"
  Potential = 1
b=Real 1.
End

Boundary Condition 2
  Target Boundaries(1) = 2 
  Name = "BoundaryCondition 2"
  Potential = 2
b = Real 2.
End

Boundary Condition 3
  Target Boundaries(1) = 3 
  Name = "BoundaryCondition 3"
b = Real 3.
End
Any suggestions?

BR,
Wil
Attachments
export.zip
project for selecting my own set boundary ids in paraview using thresholds.
(138.08 KiB) Downloaded 72 times

raback
Site Admin
Posts: 3291
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: selecting/unselecting bodies with paraview

Post by raback » 06 Mar 2017, 11:49

Hi

Ok, I don't think there is an easy way to directly use the names in Paraview. Having a field that is 1 only for a name and 0 for others would be a solution but a quite excessive one.

Now I just implemented a remapping of Geometry Ids when saving VTU format. By default the Geometry id is "body id" for bodies and "bc id + offset" for BCs. Now the user may override this by keyword

Code: Select all

Geometry Id = Integer
Available for both body and bc. The default is still as before. However, if one wants to toggle with that there are the following keywords that ResultOutputSolver can take:

Code: Select all

Default Body Id = Integer
Default BC id = Integer 
BC id offset = Integer 
These keywords should allow easy selection of entities.

For example:
* set default body is to 0 and default bc id to 1 => One can easily toggle between body and boundary visualization with the treshhold filter.
* set all rotor bodies to 1, or stator bodies to 2, and air between to 0 => one can easily choose either stator or rotor for visualization.

This is now in devel.

Have fun!

-Peter

Wil
Posts: 62
Joined: 10 Jan 2014, 13:26
Antispam: Yes
Location: Austria

Re: selecting/unselecting bodies with paraview

Post by Wil » 07 Mar 2017, 10:22

raback wrote:Ok, I don't think there is an easy way to directly use the names in Paraview. Having a field that is 1 only for a name and 0 for others would be a solution but a quite excessive one.
Do you really think so? We are talking usually of less than ten group names (<3) and as long a as binary 0/1 information is needed the needed memory should be limited.
The main benefit would be to use the same names as during geometry /mesh creation. Otherwise I always have to have a lookup-table which group is which number. Since you a already use these names inside elmer it should be easy to export it (with a switch).

Thanks for your info I will test it within the next days.

Will

raback
Site Admin
Posts: 3291
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: selecting/unselecting bodies with paraview

Post by raback » 07 Mar 2017, 11:26

Hi,

You may be right. It would be more costly to have them as reals but having them as single precision integers, or even logical would be more efficient. I can study that time permitting.

-Peter

Wil
Posts: 62
Joined: 10 Jan 2014, 13:26
Antispam: Yes
Location: Austria

Re: selecting/unselecting bodies with paraview

Post by Wil » 30 Aug 2017, 20:50

Hy Peter,
Any changes on this topic?
BR,
HoWil

raback
Site Admin
Posts: 3291
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: selecting/unselecting bodies with paraview

Post by raback » 01 Sep 2017, 10:39

Hi

I just committed a tentative feature that writes each body and boundary to a different vtu file, and generates a Paraview collection file (.pvd) that enables to open them at once. This allows the use of filter "ExtractBlock" in Paraview, but of course one can also open the files related to given body / boundary. They are named by the "Name" so one should use unique names for entities.

To activate this say for ResultOutputSolver:

Code: Select all

  vtu group collection = logical true
This is still only in branch "VtuBlocks" in GitHub but I might migrate it to devel if it works ok.

-Peter

Post Reply