diff --git a/plot2d.py b/plot2d.py index bd1fe0570a730ce0ed34491134c568c06985bd72..0e90de4aaf076d8ef496fca498534a7d8996c699 100644 --- a/plot2d.py +++ b/plot2d.py @@ -53,49 +53,6 @@ def multipleScalarFields(field, **kwargs): colorbar() -def plotBoundaryHandling(boundaryHandling, boundaryNameToColor=None): - """ - Shows boundary cells - - :param boundaryHandling: instance of :class:`lbmpy.boundaries.BoundaryHandling` - :param boundaryNameToColor: optional dictionary mapping boundary names to colors - """ - import matplotlib - import matplotlib.pyplot as plt - - if len(boundaryHandling.flagField.shape) != 2: - raise NotImplementedError("Only implemented for 2D boundary handlings") - - if boundaryNameToColor: - fixedColors = boundaryNameToColor - else: - fixedColors = { - 'fluid': '#1f77ff11', - 'noSlip': '#000000' - } - - boundaryNames = [] - flagValues = [] - for name, flag in sorted(boundaryHandling.getBoundaryNameToFlagDict().items(), key=lambda l: l[1]): - boundaryNames.append(name) - flagValues.append(flag) - defaultCycler = matplotlib.rcParams['axes.prop_cycle'] - colorValues = [fixedColors[name] if name in fixedColors else cycle['color'] - for cycle, name in zip(defaultCycler, boundaryNames)] - - cmap = matplotlib.colors.ListedColormap(colorValues) - bounds = np.array(flagValues, dtype=float) - 0.5 - bounds = list(bounds) + [bounds[-1] + 1] - norm = matplotlib.colors.BoundaryNorm(bounds, cmap.N) - - flagField = boundaryHandling.flagField.swapaxes(0, 1) - plt.imshow(flagField, interpolation='none', origin='lower', - cmap=cmap, norm=norm) - - patches = [matplotlib.patches.Patch(color=color, label=name) for color, name in zip(colorValues, boundaryNames)] - plt.axis('equal') - plt.legend(handles=patches, bbox_to_anchor=(1.02, 0.5), loc=2, borderaxespad=0.) - # ------------------------------------------- Animations ---------------------------------------------------------------