Commit 320a6429 authored by Michel Henry's avatar Michel Henry
Browse files

glyph velocity p2

parent a05cee5e
Pipeline #10136 failed with stages
in 3 minutes and 23 seconds
......@@ -374,7 +374,7 @@
initial_string="SubdivisionLevel"
command="SetParameter"
animateable="1"
default_values="4"
default_values="2"
number_of_elements="1">
<Documentation></Documentation>
</IntVectorProperty>
......@@ -397,7 +397,7 @@
name="Script"
command="SetScript"
number_of_elements="1"
default_values="import numpy as np&#xA;ipt = inputs[0].Points&#xA;nel = inputs[0].CellTypes.shape[0]&#xA;mapping = inputs[0].CellData[&quot;velocity_map&quot;]&#xA;v = inputs[0].FieldData[&quot;velocity&quot;]&#xA;f = np.array([[[0,0],[1,0],[0,1]]])&#xA;cut = np.array([&#xA; [[1,0,0],[0.5,0.5,0],[0.5,0,0.5]],&#xA; [[0,1,0],[0,0.5,0.5],[0.5,0.5,0]],&#xA; [[0,0,1],[0.5,0,0.5],[0,0.5,0.5]],&#xA; [[0.5,0.5,0],[0,0.5,0.5],[0.5,0,0.5]]])&#xA;&#xA;def split(f):&#xA; return np.einsum(&quot;cnm, emf -&gt; ecnf&quot;, cut, f).reshape(-1,f.shape[1],f.shape[2])&#xA;for i in range(SubdivisionLevel):&#xA; f = split(f)&#xA;xi = f[:,:,0]&#xA;eta = f[:,:,1]&#xA;fp1 = np.stack([1-xi-eta,xi,eta],axis=1)&#xA;fp2 = np.stack([1-3*(xi+eta)+2*(xi+eta)*(xi+eta), xi*(2*xi-1), eta*(2*eta-1), 4*xi*(1-xi-eta), 4*xi*eta, 4*eta*(1-xi-eta)]&#xA;, axis=1)&#xA;x = np.einsum(&quot;end, snm -&gt; esmd&quot;, ipt[mapping[:,:3]], fp1).reshape(-1,3,3)&#xA;v = np.einsum(&quot;end, snm -&gt; esmd&quot;, v[mapping], fp2).reshape(-1,3,2)&#xA;output.Points = x.reshape(-1,3)&#xA;ne = v.shape[0]&#xA;tri = np.zeros((ne,4))&#xA;tri[:,0] = 3&#xA;tri[:,1:] = np.arange(0,ne*3).reshape(-1,3)&#xA;loc = np.arange(0, 4*(ne+1), ne)&#xA;output.SetCells(np.full(ne,5,np.ubyte),loc,tri)&#xA;output.PointData.append(v.reshape(-1,2),&quot;velocity&quot;)&#xA;"
default_values="import numpy as np&#xA;ipt = inputs[0].Points&#xA;nel = inputs[0].CellTypes.shape[0]&#xA;mapping = inputs[0].CellData[&quot;velocity_map&quot;]&#xA;v = inputs[0].FieldData[&quot;velocity&quot;][:,:2]&#xA;f = np.array([[[0,0],[1,0],[0,1]]])&#xA;cut = np.array([&#xA; [[1,0,0],[0.5,0.5,0],[0.5,0,0.5]],&#xA; [[0,1,0],[0,0.5,0.5],[0.5,0.5,0]],&#xA; [[0,0,1],[0.5,0,0.5],[0,0.5,0.5]],&#xA; [[0.5,0.5,0],[0,0.5,0.5],[0.5,0,0.5]]])&#xA;&#xA;def split(f):&#xA; return np.einsum(&quot;cnm, emf -&gt; ecnf&quot;, cut, f).reshape(-1,f.shape[1],f.shape[2])&#xA;for i in range(SubdivisionLevel):&#xA; f = split(f)&#xA;xi = f[:,:,0]&#xA;eta = f[:,:,1]&#xA;fp1 = np.stack([1-xi-eta,xi,eta],axis=1)&#xA;fp2 = np.stack([1-3*(xi+eta)+2*(xi+eta)*(xi+eta), xi*(2*xi-1), eta*(2*eta-1), 4*xi*(1-xi-eta), 4*xi*eta, 4*eta*(1-xi-eta)]&#xA;, axis=1)&#xA;x = np.einsum(&quot;end, snm -&gt; esmd&quot;, ipt[mapping[:,:3]], fp1).reshape(-1,3,3)&#xA;v = np.einsum(&quot;end, snm -&gt; esmd&quot;, v[mapping], fp2).reshape(-1,3,2)&#xA;output.Points = x.reshape(-1,3)&#xA;ne = v.shape[0]&#xA;tri = np.zeros((ne,4))&#xA;tri[:,0] = 3&#xA;tri[:,1:] = np.arange(0,ne*3).reshape(-1,3)&#xA;loc = np.arange(0, 4*(ne+1), ne)&#xA;v = np.insert(v.reshape(-1,2), 2, 0,axis=1)&#xA;output.SetCells(np.full(ne,5,np.ubyte),loc,tri)&#xA;output.PointData.append(v,&quot;velocity&quot;)&#xA;"
panel_visibility="advanced">
<Hints>
<Widget type="multi_line"/>
......
......@@ -29,20 +29,20 @@ InputDataType = 'vtkUnstructuredGrid'
OutputDataType = 'vtkUnstructuredGrid'
ExtraXml = ''
Properties = dict(SubdivisionLevel=4)
Properties = dict(SubdivisionLevel=2)
def RequestData():
import numpy as np
ipt = inputs[0].Points
nel = inputs[0].CellTypes.shape[0]
mapping = inputs[0].CellData["velocity_map"]
v = inputs[0].FieldData["velocity"]
v = inputs[0].FieldData["velocity"][:,:2]
f = np.array([[[0,0],[1,0],[0,1]]])
cut = np.array([
[[1,0,0],[0.5,0.5,0],[0.5,0,0.5]],
[[0,1,0],[0,0.5,0.5],[0.5,0.5,0]],
[[0,0,1],[0.5,0,0.5],[0,0.5,0.5]],
[[0.5,0.5,0],[0,0.5,0.5],[0.5,0,0.5]]])
[[1,0,0],[0.5,0.5,0],[0.5,0,0.5]],
[[0,1,0],[0,0.5,0.5],[0.5,0.5,0]],
[[0,0,1],[0.5,0,0.5],[0,0.5,0.5]],
[[0.5,0.5,0],[0,0.5,0.5],[0.5,0,0.5]]])
def split(f):
return np.einsum("cnm, emf -> ecnf", cut, f).reshape(-1,f.shape[1],f.shape[2])
......@@ -61,5 +61,7 @@ def RequestData():
tri[:,0] = 3
tri[:,1:] = np.arange(0,ne*3).reshape(-1,3)
loc = np.arange(0, 4*(ne+1), ne)
v = np.insert(v.reshape(-1,2), 2, 0,axis=1)
output.SetCells(np.full(ne,5,np.ubyte),loc,tri)
output.PointData.append(v.reshape(-1,2),"velocity")
output.PointData.append(v,"velocity")
......@@ -21,17 +21,17 @@ renderView.Background = [1.0, 1.0, 1.0]
def showFluid(fluid, renderView):
Hide(fluid, renderView)
RenameSource('Fluid', fluid)
dynPressure = MigFlowdynamicpressure(Input=fluid)
RenameSource('Dynamic Pressure', dynPressure)
dynPressureDisplay = Show(dynPressure, renderView)
dynPressureDisplay.Representation = 'Surface'
ColorBy(dynPressureDisplay, ('POINTS', 'dynamic_pressure'))
# dynPressure = MigFlowdynamicpressure(Input=fluid)
# RenameSource('Dynamic Pressure', dynPressure)
# dynPressureDisplay = Show(dynPressure, renderView)
# dynPressureDisplay.Representation = 'Surface'
# ColorBy(dynPressureDisplay, ('POINTS', 'dynamic_pressure'))
# show color bar/color legend
dynPressureDisplay.SetScalarBarVisibility(renderView, True)
colorbar = GetScalarBar(GetColorTransferFunction('dynamic_pressure'), renderView)
colorbar.TitleColor = [0, 0, 0]
colorbar.LabelColor = [0, 0, 0]
# dynPressureDisplay.SetScalarBarVisibility(renderView, True)
# colorbar = GetScalarBar(GetColorTransferFunction('dynamic_pressure'), renderView)
# colorbar.TitleColor = [0, 0, 0]
# colorbar.LabelColor = [0, 0, 0]
......@@ -118,7 +118,7 @@ if isfile(particleProblemFile):
if isfile(fluidFile):
fluid = PVDReader(FileName=fluidFile)
showFluid(fluid, renderView)
showVelocity(fluid, renderView)
# showVelocity(fluid, renderView)
if isfile(particleProblemFile):
Hide(fluid, renderView)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment