Commit b24e6ecb authored by Lukas Riedel's avatar Lukas Riedel

merging two vtkfile grids works correctly now

parent 55a1ba86
......@@ -19,7 +19,11 @@ class BaseGrid(object):
if self.dim != other.dim:
raise RuntimeError("Grid dimensions do not match!")
self._calcCellCenters()
other._calcCellCenters()
new = self._merge_derived(other)
new._calcCellCenters()
for var in self._cellVariables:
data = np.append(self.data()[var],other.data()[var],axis=0)
......@@ -157,9 +161,10 @@ class UnstructuredVTKGrid(BaseGrid):
if self.ppc != other.ppc:
raise RuntimeError("Using different numbers of points per grid cell")
points = np.append(self.points,other.points,axis=0)
connectivity = np.append(self.connectivity,other.connectivity,axis=0)
return UnstructuredVTKGrid(points,connectivity,self.ppc)
points_n = np.append(self.points,other.points,axis=0)
connectivity_n = np.append(self.connectivity,other.connectivity + len(self.points),axis=0)
return UnstructuredVTKGrid(points_n,connectivity_n,self.ppc)
def triangulation(self):
......
......@@ -78,13 +78,14 @@ class VTKFile:
for grid in root:
for layer in grid:
if layer.tag == "Piece":
filename = layer.attrib["Source"]
filename = os.path.join(os.path.split(self.path)[0],layer.attrib["Source"])
if os.path.isfile(filename):
print("adding parallel piece {} to file collection".format(filename))
piece_file = VTKFile(filename)
if out == None:
out = piece_file.read(variables)
else:
out = out.merge(piece_file.read(variables))
out = out.merge(other=piece_file.read(variables))
else:
raise RuntimeError("Problem reading {}: Piece file {} cannot be found".format(self.path,filename))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment