From 8f5a095e6b2ab05775d53e7ae14b3e4e02139dd9 Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 14 Oct 2024 11:57:09 +1100 Subject: [PATCH 01/10] MultiValues component name vtk export Implementation for parallel vtk missing --- .../SymFourthOrderTensorValueTypes.jl | 2 +- src/Visualization/Visualization.jl | 5 -- src/Visualization/Vtk.jl | 68 ++++++++++++++++++- test/VisualizationTests/VtkTests.jl | 2 + 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/src/TensorValues/SymFourthOrderTensorValueTypes.jl b/src/TensorValues/SymFourthOrderTensorValueTypes.jl index d36c2cbd7..95c7b9516 100644 --- a/src/TensorValues/SymFourthOrderTensorValueTypes.jl +++ b/src/TensorValues/SymFourthOrderTensorValueTypes.jl @@ -82,7 +82,7 @@ zero(::SymFourthOrderTensorValue{D,T,L}) where {D,T,L} = zero(SymFourthOrderTens # This is in fact the "symmetrized" 4th order identity @generated function one(::Type{<:SymFourthOrderTensorValue{D,T}}) where {D,T} S = typeof(one(T)/2) - str = join(["($i==$k && $j==$l) ? ( $i==$j ? one($S) : one(T)/2) : zero($S), " for i in 1:D for j in i:D for k in 1:D for l in k:D]) + str = join(["($i==$k && $j==$l) ? ( $i==$j ? one($S) : one($S)/2) : zero($S), " for i in 1:D for j in i:D for k in 1:D for l in k:D]) Meta.parse("SymFourthOrderTensorValue{D,$S}(($str))") end one(::SymFourthOrderTensorValue{D,T}) where {D,T} = one(SymFourthOrderTensorValue{D,T}) diff --git a/src/Visualization/Visualization.jl b/src/Visualization/Visualization.jl index 7c76fa169..c20fb41ea 100644 --- a/src/Visualization/Visualization.jl +++ b/src/Visualization/Visualization.jl @@ -45,20 +45,15 @@ import Gridap.Geometry: get_cell_type import Gridap.Geometry: get_node_coordinates import Gridap.Geometry: get_cell_node_ids -#import AbstractTrees - export writevtk export createvtk export createpvd export savepvd export write_vtk_file -#export print_op_tree export visualization_data export VisualizationData include("VisualizationData.jl") include("Vtk.jl") -#include("PrintOpTrees.jl") - end # module diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index fa9b2f9d8..f18ba8747 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -81,7 +81,7 @@ This function only creates the vtkFile, without writing to disk. The optional WriteVTK kwargs `vtk_kwargs` are passed to the `vtk_grid` constructor. """ function create_vtk_file( - trian::Grid, filebase; celldata=Dict(), nodaldata=Dict(), + trian::Grid, filebase; celldata=Dict(), nodaldata=Dict(), compress=false, append=true, ascii=false, vtkversion=:default ) @@ -94,10 +94,10 @@ function create_vtk_file( if num_cells(trian)>0 for (k,v) in celldata - vtk_cell_data(vtkfile, _prepare_data(v), k) + vtk_cell_data(vtkfile, _prepare_data(v), k; component_names=_data_component_names(v)) end for (k,v) in nodaldata - vtk_point_data(vtkfile, _prepare_data(v), k) + vtk_point_data(vtkfile, _prepare_data(v), k; component_names=_data_component_names(v)) end end @@ -181,6 +181,68 @@ function _generate_vtk_cells( end +_data_component_names(v) = nothing + +_data_component_names(v::AbstractArray{T}) where T<:MultiValue = _data_component_names(T) + +""" +Return an array containing the component labels in the order they are stored internally, consistently with _prepare_data(::Multivalue) + +For spacial dimensions d=1,2 or 3, the components are named with letters X,Y and Z similarly to the automatic naming of Paraview. Else, if d>3, they are numbered from 1 to d. +""" +_data_component_names(::Type{<:MultiValue}) = @notimplemented + +function _data_component_names(::Type{<:VectorValue{A}}) where A + [ "$i" for i in 1:A ] + if A>3 + return ["$i" for i in 1:A ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i] for i in 1:A ] + end +end + +function _data_component_names(::Type{<:TensorValue{A,B}}) where {A,B} + if A>3 || B>3 + return ["$i$j" for i in 1:A for j in 1:B ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j] for i in 1:A for j in 1:B ] + end +end + +_data_component_names(::Type{<:SymTensorValue{1}})= ["XX"] +_data_component_names(::Type{<:SymTensorValue{2}})= ["XX","XY","YY"] +_data_component_names(::Type{<:SymTensorValue{3}})= [ + "XX", "XY", "XZ", "YY", "YZ", "ZZ" +] +function _data_component_names(::Type{<:SymTensorValue{A}}) where A + if A>3 + return ["$i$j" for i in 1:A for j in i:A ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j] for i in 1:A for j in i:A ] + end +end + +function _data_component_names(::Type{<:ThirdOrderTensorValue{A,B,C}}) where {A,B,C} + if A>3 || B>3 || C>3 + return ["$i$j$k" for i in 1:A for j in 1:B for k in 1:C ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j]*c_name[k] for i in 1:A for j in 1:B for k in 1:C] + end +end + +function _data_component_names(::Type{<:SymFourthOrderTensorValue{A}}) where A + if A>3 + return ["$i$j$k$l" for i in 1:A for j in i:A for k in 1:A for l in k:A ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j]*c_name[k]*c_name[l] for i in 1:A for j in i:A for k in 1:A for l in k:A ] + end +end + _prepare_data(v) = v function _prepare_data(v::AbstractArray{<:MultiValue}) diff --git a/test/VisualizationTests/VtkTests.jl b/test/VisualizationTests/VtkTests.jl index 055da65eb..19568e05b 100644 --- a/test/VisualizationTests/VtkTests.jl +++ b/test/VisualizationTests/VtkTests.jl @@ -90,6 +90,8 @@ writevtk(trian,f,nsubcells=5,celldata=["rnd"=>rand(num_cells(trian))]) cf(x) = sin(4*x[1]*pi)*cos(5*x[2]*pi) +f = "/home/antoine/prog/Gridap/test/VisualizationTests/test_res" + writevtk(trian,f,nsubcells=10, cellfields=[ "cf"=>cf, "a"=>x->1, From 10fb6127ee6bd9277caa0571c466d4330b0ad0ca Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 14 Oct 2024 12:00:58 +1100 Subject: [PATCH 02/10] rm temp path --- test/VisualizationTests/VtkTests.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/VisualizationTests/VtkTests.jl b/test/VisualizationTests/VtkTests.jl index 19568e05b..055da65eb 100644 --- a/test/VisualizationTests/VtkTests.jl +++ b/test/VisualizationTests/VtkTests.jl @@ -90,8 +90,6 @@ writevtk(trian,f,nsubcells=5,celldata=["rnd"=>rand(num_cells(trian))]) cf(x) = sin(4*x[1]*pi)*cos(5*x[2]*pi) -f = "/home/antoine/prog/Gridap/test/VisualizationTests/test_res" - writevtk(trian,f,nsubcells=10, cellfields=[ "cf"=>cf, "a"=>x->1, From 60b9bcce3c47317c64c02e2e101734ea60c1157b Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Tue, 15 Oct 2024 12:17:11 +1100 Subject: [PATCH 03/10] update WriteVTK, finish component_names implementation --- src/Visualization/Vtk.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index f18ba8747..576ee1cac 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -94,10 +94,12 @@ function create_vtk_file( if num_cells(trian)>0 for (k,v) in celldata - vtk_cell_data(vtkfile, _prepare_data(v), k; component_names=_data_component_names(v)) + comp_names = _data_component_names(v) + vtk_cell_data(vtkfile, _prepare_data(v), k; component_names=comp_names) end for (k,v) in nodaldata - vtk_point_data(vtkfile, _prepare_data(v), k; component_names=_data_component_names(v)) + comp_names = _data_component_names(v) + vtk_point_data(vtkfile, _prepare_data(v), k; component_names=comp_names) end end @@ -118,10 +120,13 @@ function create_pvtk_file( if num_cells(trian) > 0 for (k, v) in celldata - vtkfile[k, VTKCellData()] = _prepare_data(v) + # comp_names are actually always nothing as there are no field in ptvk atm + comp_names = _data_component_names(v) + vtkfile[k, VTKCellData(), component_names=comp_names] = _prepare_data(v) end for (k, v) in nodaldata - vtkfile[k, VTKPointData()] = _prepare_data(v) + comp_names = _data_component_names(v) + vtkfile[k, VTKPointData(), component_names=comp_names] = _prepare_data(v) end end return vtkfile From 5e6d8d6dac4330380d283d7f0681e6517c910e5a Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Tue, 15 Oct 2024 15:36:49 +1100 Subject: [PATCH 04/10] add default Multivalue component_name Moved components naming into MultiValue's API and set a default --- src/TensorValues/MultiValueTypes.jl | 12 ++++ .../SymFourthOrderTensorValueTypes.jl | 13 ++++ src/TensorValues/SymTensorValueTypes.jl | 13 ++++ src/TensorValues/TensorValueTypes.jl | 14 ++++- src/TensorValues/TensorValues.jl | 1 + .../ThirdOrderTensorValueTypes.jl | 13 ++++ src/TensorValues/VectorValueTypes.jl | 14 +++++ src/Visualization/Vtk.jl | 60 +------------------ 8 files changed, 80 insertions(+), 60 deletions(-) diff --git a/src/TensorValues/MultiValueTypes.jl b/src/TensorValues/MultiValueTypes.jl index 7f7ed8e49..d756df424 100644 --- a/src/TensorValues/MultiValueTypes.jl +++ b/src/TensorValues/MultiValueTypes.jl @@ -38,3 +38,15 @@ end function data_index(::Type{<:MultiValue},i...) @abstractmethod end + +""" + indep_components_names(::MultiValue) + +Returns an array of strings containing the component labels in the order they are stored internally, consistently with _prepare_data(::Multivalue) + +If all dimensions of the tensor shape S are smaller than 3, the components should be named with letters "X","Y" and "Z" similarly to the automatic naming of Paraview. Else, if max(S)>3, they are labeled from "1" to "\$dim". +""" +function indep_components_names(::MultiValue{S,T,N,L}) where {S,T,N,L} + return ["$i" for i in 1:L] +end + diff --git a/src/TensorValues/SymFourthOrderTensorValueTypes.jl b/src/TensorValues/SymFourthOrderTensorValueTypes.jl index 95c7b9516..beb5ad34a 100644 --- a/src/TensorValues/SymFourthOrderTensorValueTypes.jl +++ b/src/TensorValues/SymFourthOrderTensorValueTypes.jl @@ -116,3 +116,16 @@ length(::SymFourthOrderTensorValue{D}) where {D} = length(SymFourthOrderTensorVa num_components(::Type{<:SymFourthOrderTensorValue{D}}) where {D} = length(SymFourthOrderTensorValue{D}) num_components(::SymFourthOrderTensorValue{D}) where {D} = num_components(SymFourthOrderTensorValue{D}) +############################################################### +# VTK export (SymFourthOrderTensorValue) +############################################################### + +function indep_components_names(::Type{<:SymFourthOrderTensorValue{A}}) where A + if A>3 + return ["$i$j$k$l" for i in 1:A for j in i:A for k in 1:A for l in k:A ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j]*c_name[k]*c_name[l] for i in 1:A for j in i:A for k in 1:A for l in k:A ] + end +end + diff --git a/src/TensorValues/SymTensorValueTypes.jl b/src/TensorValues/SymTensorValueTypes.jl index 1f9412aef..72098cc43 100644 --- a/src/TensorValues/SymTensorValueTypes.jl +++ b/src/TensorValues/SymTensorValueTypes.jl @@ -154,3 +154,16 @@ length(::SymTensorValue{D}) where {D} = length(SymTensorValue{D}) num_components(::Type{<:SymTensorValue{D}}) where {D} = length(SymTensorValue{D}) num_components(::SymTensorValue{D}) where {D} = num_components(SymTensorValue{D}) + +############################################################### +# VTK export (SymTensorValue) +############################################################### + +function indep_components_names(::Type{<:SymTensorValue{D}}) where D + if D>3 + return ["$i$j" for i in 1:D for j in i:D ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j] for i in 1:D for j in i:D ] + end +end diff --git a/src/TensorValues/TensorValueTypes.jl b/src/TensorValues/TensorValueTypes.jl index 327211c6f..2ed67c3f5 100644 --- a/src/TensorValues/TensorValueTypes.jl +++ b/src/TensorValues/TensorValueTypes.jl @@ -14,7 +14,7 @@ struct TensorValue{D1,D2,T,L} <: MultiValue{Tuple{D1,D2},T,2,L} end ############################################################### -# Constructors +# Constructors ############################################################### # Empty TensorValue constructor @@ -145,3 +145,15 @@ num_components(::Type{<:TensorValue{D}}) where {D} = length(TensorValue{D,D}) num_components(::Type{<:TensorValue{D1,D2}}) where {D1,D2} = length(TensorValue{D1,D2}) num_components(::TensorValue{D1,D2}) where {D1,D2} = num_components(TensorValue{D1,D2}) +############################################################### +# VTK export (TensorValue) +############################################################### + +function indep_components_names(::Type{<:TensorValue{D1,D2}}) where {D1,D2} + if D1>3 || D2>3 + return ["$i$j" for i in 1:D1 for j in 1:D2 ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j] for i in 1:D1 for j in 1:D2 ] + end +end diff --git a/src/TensorValues/TensorValues.jl b/src/TensorValues/TensorValues.jl index 513d046a0..6d5d4366a 100644 --- a/src/TensorValues/TensorValues.jl +++ b/src/TensorValues/TensorValues.jl @@ -59,6 +59,7 @@ export ⋅¹ export ⋅² export double_contraction export data_index +export indep_components_names import Base: show import Base: zero, one diff --git a/src/TensorValues/ThirdOrderTensorValueTypes.jl b/src/TensorValues/ThirdOrderTensorValueTypes.jl index 8b9b6b2c3..218a33950 100644 --- a/src/TensorValues/ThirdOrderTensorValueTypes.jl +++ b/src/TensorValues/ThirdOrderTensorValueTypes.jl @@ -112,3 +112,16 @@ length(::ThirdOrderTensorValue{D1,D2,D3}) where {D1,D2,D3} = length(ThirdOrderTe num_components(::Type{<:ThirdOrderTensorValue{D1,D2,D3}}) where {D1,D2,D3} = length(ThirdOrderTensorValue{D1,D2,D3}) num_components(::ThirdOrderTensorValue{D1,D2,D3}) where {D1,D2,D3} = num_components(ThirdOrderTensorValue{D1,D2,D3}) +############################################################### +# VTK export (ThirdOrderTensorValue) +############################################################### + +function indep_components_names(::Type{<:ThirdOrderTensorValue{D1,D2,D3}}) where {D1,D2,D3} + if D1>3 || D2>3 || D3>3 + return ["$i$j$k" for i in 1:D1 for j in 1:D2 for k in 1:D3 ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i]*c_name[j]*c_name[k] for i in 1:D1 for j in 1:D2 for k in 1:D3] + end +end + diff --git a/src/TensorValues/VectorValueTypes.jl b/src/TensorValues/VectorValueTypes.jl index a142afc13..6561e72b2 100644 --- a/src/TensorValues/VectorValueTypes.jl +++ b/src/TensorValues/VectorValueTypes.jl @@ -110,3 +110,17 @@ length(::VectorValue{D}) where {D} = length(VectorValue{D}) num_components(::Type{<:VectorValue{D}}) where {D} = length(VectorValue{D}) num_components(::VectorValue{D}) where {D} = num_components(VectorValue{D}) + +############################################################### +# VTK export (VectorValue) +############################################################### + +function indep_components_names(::Type{<:VectorValue{A}}) where A + [ "$i" for i in 1:A ] + if A>3 + return ["$i" for i in 1:A ] + else + c_name = ["X", "Y", "Z"] + return [c_name[i] for i in 1:A ] + end +end diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index 576ee1cac..4ad09f3ae 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -188,65 +188,7 @@ end _data_component_names(v) = nothing -_data_component_names(v::AbstractArray{T}) where T<:MultiValue = _data_component_names(T) - -""" -Return an array containing the component labels in the order they are stored internally, consistently with _prepare_data(::Multivalue) - -For spacial dimensions d=1,2 or 3, the components are named with letters X,Y and Z similarly to the automatic naming of Paraview. Else, if d>3, they are numbered from 1 to d. -""" -_data_component_names(::Type{<:MultiValue}) = @notimplemented - -function _data_component_names(::Type{<:VectorValue{A}}) where A - [ "$i" for i in 1:A ] - if A>3 - return ["$i" for i in 1:A ] - else - c_name = ["X", "Y", "Z"] - return [c_name[i] for i in 1:A ] - end -end - -function _data_component_names(::Type{<:TensorValue{A,B}}) where {A,B} - if A>3 || B>3 - return ["$i$j" for i in 1:A for j in 1:B ] - else - c_name = ["X", "Y", "Z"] - return [c_name[i]*c_name[j] for i in 1:A for j in 1:B ] - end -end - -_data_component_names(::Type{<:SymTensorValue{1}})= ["XX"] -_data_component_names(::Type{<:SymTensorValue{2}})= ["XX","XY","YY"] -_data_component_names(::Type{<:SymTensorValue{3}})= [ - "XX", "XY", "XZ", "YY", "YZ", "ZZ" -] -function _data_component_names(::Type{<:SymTensorValue{A}}) where A - if A>3 - return ["$i$j" for i in 1:A for j in i:A ] - else - c_name = ["X", "Y", "Z"] - return [c_name[i]*c_name[j] for i in 1:A for j in i:A ] - end -end - -function _data_component_names(::Type{<:ThirdOrderTensorValue{A,B,C}}) where {A,B,C} - if A>3 || B>3 || C>3 - return ["$i$j$k" for i in 1:A for j in 1:B for k in 1:C ] - else - c_name = ["X", "Y", "Z"] - return [c_name[i]*c_name[j]*c_name[k] for i in 1:A for j in 1:B for k in 1:C] - end -end - -function _data_component_names(::Type{<:SymFourthOrderTensorValue{A}}) where A - if A>3 - return ["$i$j$k$l" for i in 1:A for j in i:A for k in 1:A for l in k:A ] - else - c_name = ["X", "Y", "Z"] - return [c_name[i]*c_name[j]*c_name[k]*c_name[l] for i in 1:A for j in i:A for k in 1:A for l in k:A ] - end -end +_data_component_names(v::AbstractArray{T}) where T<:MultiValue = indep_components_names(T) _prepare_data(v) = v From 0dd67db408e91031111945b7da8876fd4196c1a8 Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Wed, 16 Oct 2024 10:49:45 +1100 Subject: [PATCH 05/10] fix indep_components_names fallback and add tests --- src/TensorValues/MultiValueTypes.jl | 2 +- test/TensorValuesTests/TypesTests.jl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/TensorValues/MultiValueTypes.jl b/src/TensorValues/MultiValueTypes.jl index d756df424..71303419e 100644 --- a/src/TensorValues/MultiValueTypes.jl +++ b/src/TensorValues/MultiValueTypes.jl @@ -46,7 +46,7 @@ Returns an array of strings containing the component labels in the order they ar If all dimensions of the tensor shape S are smaller than 3, the components should be named with letters "X","Y" and "Z" similarly to the automatic naming of Paraview. Else, if max(S)>3, they are labeled from "1" to "\$dim". """ -function indep_components_names(::MultiValue{S,T,N,L}) where {S,T,N,L} +function indep_components_names(::Type{MultiValue{S,T,N,L}) where {S,T,N,L} return ["$i" for i in 1:L] end diff --git a/test/TensorValuesTests/TypesTests.jl b/test/TensorValuesTests/TypesTests.jl index c86d8391e..2b2714f8d 100644 --- a/test/TensorValuesTests/TypesTests.jl +++ b/test/TensorValuesTests/TypesTests.jl @@ -405,6 +405,19 @@ v = VectorValue(m) @test num_components(SymTensorValue(1,2,3)) == 4 @test num_components(SymFourthOrderTensorValue(1111,1121,1122, 2111,2121,2122, 2211,2221,2222)) == 16 +@test indep_components_names(VectorValue{3}) == ["X","Y","Z"] +@test indep_components_names(VectorValue{4}) == ["1","2","3","4"] +@test indep_components_names(TensorValue{2,2}) == ["XX","XY","YX","YY"] +@test indep_components_names(TensorValue{2,4}) == ["11","12","13","14","21","22","23","24",] +@test indep_components_names(SymTensorValue{2}) == ["XX","XY","YY"] +@test indep_components_names(SymTensorValue{4}) == ["11","12","13","14","22","23","24","33","34","44"] +@test indep_components_names(ThirdOrderTensorValue{2,2,1}) == ["XXX","XYX","YXX","YYX"] +@test indep_components_names(ThirdOrderTensorValue{1,4,1}) == ["111","121","131","141"] +@test indep_components_names(SymFourthOrderTensorValue{2}) == [ + "XXXX", "XXXY", "XXYY", "XYXX", "XYXY", "XYYY", "YYXX", "YYXY", "YYYY" +] +@test indep_components_names(MultiValue{Tuple{3,4},Int,2,5}) == ["1","2","3","4","5"] + a = VectorValue(1,2,3,4) @test change_eltype(a,Float64) == VectorValue{4,Float64} From f4c7e5665e82beecc9f87af48fd6f3f6c71a9bd2 Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Wed, 16 Oct 2024 10:53:23 +1100 Subject: [PATCH 06/10] typo indep_components_names fallback --- src/TensorValues/MultiValueTypes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TensorValues/MultiValueTypes.jl b/src/TensorValues/MultiValueTypes.jl index 71303419e..8f29a4aed 100644 --- a/src/TensorValues/MultiValueTypes.jl +++ b/src/TensorValues/MultiValueTypes.jl @@ -46,7 +46,7 @@ Returns an array of strings containing the component labels in the order they ar If all dimensions of the tensor shape S are smaller than 3, the components should be named with letters "X","Y" and "Z" similarly to the automatic naming of Paraview. Else, if max(S)>3, they are labeled from "1" to "\$dim". """ -function indep_components_names(::Type{MultiValue{S,T,N,L}) where {S,T,N,L} +function indep_components_names(::Type{MultiValue{S,T,N,L}}) where {S,T,N,L} return ["$i" for i in 1:L] end From f1295fd50b1007cd4dfb621da845e70aba99e8b1 Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 21 Oct 2024 17:31:20 +1100 Subject: [PATCH 07/10] nicer kwarg name --- src/Visualization/Vtk.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index 4ad09f3ae..d3d4a7c78 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -94,12 +94,12 @@ function create_vtk_file( if num_cells(trian)>0 for (k,v) in celldata - comp_names = _data_component_names(v) - vtk_cell_data(vtkfile, _prepare_data(v), k; component_names=comp_names) + component_names = _data_component_names(v) + vtk_cell_data(vtkfile, _prepare_data(v), k; component_names) end for (k,v) in nodaldata - comp_names = _data_component_names(v) - vtk_point_data(vtkfile, _prepare_data(v), k; component_names=comp_names) + component_names = _data_component_names(v) + vtk_point_data(vtkfile, _prepare_data(v), k; component_names) end end @@ -120,13 +120,13 @@ function create_pvtk_file( if num_cells(trian) > 0 for (k, v) in celldata - # comp_names are actually always nothing as there are no field in ptvk atm - comp_names = _data_component_names(v) - vtkfile[k, VTKCellData(), component_names=comp_names] = _prepare_data(v) + # component_names are actually always nothing as there are no field in ptvk atm + component_names = _data_component_names(v) + vtkfile[k, VTKCellData(), component_names] = _prepare_data(v) end for (k, v) in nodaldata - comp_names = _data_component_names(v) - vtkfile[k, VTKPointData(), component_names=comp_names] = _prepare_data(v) + component_names = _data_component_names(v) + vtkfile[k, VTKPointData(), component_names] = _prepare_data(v) end end return vtkfile From 23a08d57c4bb6c7af3509b89389964c570320895 Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 21 Oct 2024 17:35:56 +1100 Subject: [PATCH 08/10] Updated NEWS.md --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 98d2d211f..789c85575 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added MacroFElements. These are defined as having the basis/dof-basis of a FESpace created on top of a RefinementRule. Since PR[#1024](https://github.com/gridap/Gridap.jl/pull/1024). - Added Barycentric refinement rule in 2D and 3D. Added Simplexify refinement rule. Since PR[#1024](https://github.com/gridap/Gridap.jl/pull/1024). +- Added names to vector and tensor components in VTK exports, to avoid Paraview's automatic (sometimes wrong) guesses. See `TensorValues.indep_components_names`. Since PR[#1038](https://github.com/gridap/Gridap.jl/pull/1038). ## [0.18.6] - 2024-08-29 From 336fa1798d50a73547c38279f8da205ec3c2f25e Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 21 Oct 2024 17:57:24 +1100 Subject: [PATCH 09/10] typo --- src/Visualization/Vtk.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index d3d4a7c78..c1b86c17c 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -122,11 +122,11 @@ function create_pvtk_file( for (k, v) in celldata # component_names are actually always nothing as there are no field in ptvk atm component_names = _data_component_names(v) - vtkfile[k, VTKCellData(), component_names] = _prepare_data(v) + vtkfile[k, VTKCellData(); component_names] = _prepare_data(v) end for (k, v) in nodaldata component_names = _data_component_names(v) - vtkfile[k, VTKPointData(), component_names] = _prepare_data(v) + vtkfile[k, VTKPointData(); component_names] = _prepare_data(v) end end return vtkfile From 78e7db66098eb94fac67e8689a8806365bb7abdb Mon Sep 17 00:00:00 2001 From: Antoine Marteau Date: Mon, 21 Oct 2024 18:06:36 +1100 Subject: [PATCH 10/10] typoo --- src/Visualization/Vtk.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Visualization/Vtk.jl b/src/Visualization/Vtk.jl index c1b86c17c..83c4fb6d7 100644 --- a/src/Visualization/Vtk.jl +++ b/src/Visualization/Vtk.jl @@ -122,11 +122,11 @@ function create_pvtk_file( for (k, v) in celldata # component_names are actually always nothing as there are no field in ptvk atm component_names = _data_component_names(v) - vtkfile[k, VTKCellData(); component_names] = _prepare_data(v) + vtkfile[k, VTKCellData(), component_names=component_names] = _prepare_data(v) end for (k, v) in nodaldata component_names = _data_component_names(v) - vtkfile[k, VTKPointData(); component_names] = _prepare_data(v) + vtkfile[k, VTKPointData(), component_names=component_names] = _prepare_data(v) end end return vtkfile