MCPcopy Create free account
hub / github.com/KratosMultiphysics/Kratos / Interpolate

Function Interpolate

kratos/python_scripts/point_output_process.py:231–251  ·  view source on GitHub ↗
(variable, entity, sf_values, historical_value)

Source from the content-addressed store, hash-verified

229 return header
230
231def Interpolate(variable, entity, sf_values, historical_value):
232 if type(entity) == KratosMultiphysics.Node:
233 if historical_value:
234 return entity.GetSolutionStepValue(variable)
235 else:
236 return entity.GetValue(variable)
237 else: # entity is element or condition
238 nodes = entity.GetNodes()
239 # Initializing 'value' like this, i don't need to know its type
240 # => this way it works both for scalar and array3 variables
241 if historical_value:
242 value = nodes[0].GetSolutionStepValue(variable) * sf_values[0]
243 for n,c in zip(nodes[1:], sf_values[1:]):
244 value = value + c * n.GetSolutionStepValue(variable)
245 else:
246 value = nodes[0].GetValue(variable) * sf_values[0]
247 for n,c in zip(nodes[1:], sf_values[1:]):
248 value = value + c * n.GetValue(variable)
249
250
251 return value
252
253def IsArrayVariable(var):
254 return type(var) == KratosMultiphysics.Array1DVariable3

Calls 4

GetNodesMethod · 0.80
typeFunction · 0.50
GetSolutionStepValueMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected