(variable, entity, sf_values, historical_value)
| 229 | return header |
| 230 | |
| 231 | def 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 | |
| 253 | def IsArrayVariable(var): |
| 254 | return type(var) == KratosMultiphysics.Array1DVariable3 |
no test coverage detected