FEM: Extraction code CodeQL updated and typo fix

This commit is contained in:
Stefan Tröger
2025-06-15 13:03:26 +02:00
parent bd64303686
commit 0e7f7e7813
14 changed files with 19 additions and 70 deletions

View File

@@ -123,7 +123,7 @@ class Extractor(base_fempythonobject.BaseFemPythonObject):
case _:
return ["Not a vector"]
def get_representive_fieldname(self):
def get_representive_fieldname(self, obj):
# should return the representive field name, e.g. Position (X)
return ""

View File

@@ -160,8 +160,8 @@ class PostVisualization(base_fempythonobject.BaseFemPythonObject):
array.SetNumberOfComponents(c_array.GetNumberOfComponents())
array.SetNumberOfTuples(rows)
array.Fill(0) # so that all non-used entries are set to 0
for i in range(c_array.GetNumberOfTuples()):
array.SetTuple(i, c_array.GetTuple(i))
for j in range(c_array.GetNumberOfTuples()):
array.SetTuple(j, c_array.GetTuple(j))
array.SetName(f"{child.Source.Name}: {c_array.GetName()}")
table.AddColumn(array)

View File

@@ -77,17 +77,16 @@ class PostFieldData1D(base_fempostextractors.Extractor1D):
obj.Table = table
return
frames = False
timesteps=[]
if obj.ExtractFrames:
# check if we have timesteps
info = obj.Source.getOutputAlgorithm().GetOutputInformation(0)
if info.Has(vtkStreamingDemandDrivenPipeline.TIME_STEPS()):
timesteps = info.Get(vtkStreamingDemandDrivenPipeline.TIME_STEPS())
frames = True
else:
FreeCAD.Console.PrintWarning("No frames available in data, ignoring \"ExtractFrames\" property")
if not frames:
if not timesteps:
# get the dataset and extract the correct array
array = self._x_array_from_dataset(obj, dataset)
if array.GetNumberOfComponents() > 1:

View File

@@ -78,17 +78,16 @@ class PostFieldData2D(base_fempostextractors.Extractor2D):
obj.Table = table
return
frames = False
timesteps = []
if obj.ExtractFrames:
# check if we have timesteps
info = obj.Source.getOutputAlgorithm().GetOutputInformation(0)
if info.Has(vtkStreamingDemandDrivenPipeline.TIME_STEPS()):
timesteps = info.Get(vtkStreamingDemandDrivenPipeline.TIME_STEPS())
frames = True
else:
FreeCAD.Console.PrintWarning("No frames available in data, ignoring \"ExtractFrames\" property")
if not frames:
if not timesteps:
# get the dataset and extract the correct array
xarray = self._x_array_from_dataset(obj, dataset)
if xarray.GetNumberOfComponents() > 1:

View File

@@ -1,4 +1,4 @@
2# ***************************************************************************
# ***************************************************************************
# * Copyright (c) 2025 Stefan Tröger <stefantroeger@gmx.net> *
# * *
# * This file is part of the FreeCAD CAx development system. *