diff --git a/flow-over-heated-plate/metadata.yaml b/flow-over-heated-plate/metadata.yaml index 0fea0d842..ebabec822 100644 --- a/flow-over-heated-plate/metadata.yaml +++ b/flow-over-heated-plate/metadata.yaml @@ -13,6 +13,12 @@ cases: run: ./run.sh component: openfoam-adapter + fluid-su2: + participant: Fluid + directory: ./fluid-su2 + run: ./run.sh + component: su2-adapter + solid-fenics: participant: Solid directory: ./solid-fenics diff --git a/flow-over-heated-plate/plot-final-interface-temperature-requirements.txt b/flow-over-heated-plate/plot-final-interface-temperature-requirements.txt index 47cfc5967..b25baafe7 100644 --- a/flow-over-heated-plate/plot-final-interface-temperature-requirements.txt +++ b/flow-over-heated-plate/plot-final-interface-temperature-requirements.txt @@ -1,3 +1,4 @@ vtk numpy matplotlib +os \ No newline at end of file diff --git a/flow-over-heated-plate/plot-final-interface-temperature.py b/flow-over-heated-plate/plot-final-interface-temperature.py index 9a767b020..b4f84409a 100644 --- a/flow-over-heated-plate/plot-final-interface-temperature.py +++ b/flow-over-heated-plate/plot-final-interface-temperature.py @@ -1,10 +1,15 @@ +#!/usr/bin/env python3 import vtk from matplotlib import pyplot as plt import numpy as np - +import os def vtk_to_dict(case): vtkFileName = "solid-{}/precice-exports/Fluid-Mesh-Solid.dt100.vtk".format(case) + if not os.path.exists(vtkFileName): + print("No file found for " + vtkFileName) + return {} # return empty dict if file not found + # read the vtk file as an unstructured grid reader = vtk.vtkUnstructuredGridReader() reader.SetFileName(vtkFileName) @@ -16,53 +21,43 @@ def vtk_to_dict(case): data = reader.GetOutput() n_data = data.GetPointData().GetNumberOfTuples() - name = "Temperature" - data_names = [] - i = 0 - max_i = data.GetPointData().GetNumberOfArrays() - while i < max_i: - this_data_name = data.GetPointData().GetArray(i).GetName() - data_names.append(this_data_name) - if (this_data_name == name): - data_id = i - break - i += 1 - data_dict = {} - if not data_id: - raise Exception( - "For file {} name {} not found. Only the following names are available: {}. " - "Aborting!".format(vtkFileName, name, data_names)) for i in range(n_data): - data_dict[data.GetPoint(i)] = data.GetPointData().GetArray(data_id).GetValue(i) - + data_dict[data.GetPoint(i)] = data.GetPointData().GetArray("Temperature").GetValue(i) return data_dict -cases = [] -cases.append('fenics') -cases.append('openfoam') -cases.append('nutils') -cases.append('dunefem') -case_labels = { - 'fenics': 'OpenFOAM-FEniCS', - 'openfoam': 'OpenFOAM-OpenFOAM', - 'nutils': 'OpenFOAM-Nutils', - 'dunefem': 'OpenFOAM-DuneFem'} -styles = [':', '-', '--'] -colors = ['r', 'b', 'g', 'k'] -i = 0 +def main(): + case_labels = { + 'fenics': 'Fluid-FEniCS', + 'openfoam': 'Fluid-OpenFOAM', + 'nutils': 'Fluid-Nutils', + 'dunefem': 'Fluid-DuneFem'} + styles = [':', '-', '--'] + colors = ['r', 'b', 'g', 'k'] + + for i, case in enumerate(case_labels.keys()): + case_data = vtk_to_dict(case) + if not case_data: + continue + x, t = [p[0] for p in case_data.keys()], np.array(list(case_data.values())) + + # sort by x + combined = list(zip(x,t)) + combined.sort() + x, t = zip(*combined) + x = np.array(x) + t = np.array(t) + + theta = (t - 300) / (310 - 300) + plt.plot(x, theta, colors[i % 4] + styles[i % 3], label=case_labels[case]) -for case in cases: - case_data = vtk_to_dict(case) - x, t = [p[0] for p in case_data.keys()], np.array(list(case_data.values())) - theta = (t - 300) / (310 - 300) - plt.plot(x, theta, colors[i % 4] + styles[i % 3], label=case_labels[case]) - i += 1 + plt.ylabel("Theta") + plt.xlabel("x-coordinate along coupling interface") + plt.legend() + plt.show() -plt.ylabel("Theta") -plt.xlabel("x-coordinate along coupling interface") -plt.legend() -plt.show() +if __name__ == '__main__': + main() \ No newline at end of file