Skip to content
Snippets Groups Projects
Commit 10d68d25 authored by Martin Bauer's avatar Martin Bauer
Browse files

Coupling of multiple LBM steps + demo for thermal coupling

parent afd34623
No related merge requests found
...@@ -128,24 +128,23 @@ class DataHandling(ABC): ...@@ -128,24 +128,23 @@ class DataHandling(ABC):
def toCpu(self, name): def toCpu(self, name):
"""Copies GPU data of array with specified name to CPU. """Copies GPU data of array with specified name to CPU.
Works only if 'cpu=True' and 'gpu=True' has been used in 'add' method""" Works only if 'cpu=True' and 'gpu=True' has been used in 'add' method"""
pass
@abstractmethod @abstractmethod
def toGpu(self, name): def toGpu(self, name):
"""Copies GPU data of array with specified name to GPU. """Copies GPU data of array with specified name to GPU.
Works only if 'cpu=True' and 'gpu=True' has been used in 'add' method""" Works only if 'cpu=True' and 'gpu=True' has been used in 'add' method"""
pass
@abstractmethod @abstractmethod
def allToCpu(self, name): def allToCpu(self, name):
"""Copies data from GPU to CPU for all arrays that have a CPU and a GPU representation""" """Copies data from GPU to CPU for all arrays that have a CPU and a GPU representation"""
pass
@abstractmethod @abstractmethod
def allToGpu(self, name): def allToGpu(self, name):
"""Copies data from CPU to GPU for all arrays that have a CPU and a GPU representation""" """Copies data from CPU to GPU for all arrays that have a CPU and a GPU representation"""
pass
@abstractmethod
def isOnGpu(self, name):
"""Checks if this data was also allocated on the GPU - does not check if this data item is in synced"""
@abstractmethod @abstractmethod
def vtkWriter(self, fileName, dataNames, ghostLayers=False): def vtkWriter(self, fileName, dataNames, ghostLayers=False):
......
...@@ -121,6 +121,7 @@ class ParallelDataHandling(DataHandling): ...@@ -121,6 +121,7 @@ class ParallelDataHandling(DataHandling):
self._fieldNameToCpuDataName[latexName] = name self._fieldNameToCpuDataName[latexName] = name
if gpu: if gpu:
self._fieldNameToGpuDataName[latexName] = self.GPU_DATA_PREFIX + name self._fieldNameToGpuDataName[latexName] = self.GPU_DATA_PREFIX + name
return self.fields[name]
def hasData(self, name): def hasData(self, name):
return name in self._fields return name in self._fields
...@@ -213,6 +214,9 @@ class ParallelDataHandling(DataHandling): ...@@ -213,6 +214,9 @@ class ParallelDataHandling(DataHandling):
else: else:
wlb.cuda.copyFieldToGpu(self.blocks, self.GPU_DATA_PREFIX + name, name) wlb.cuda.copyFieldToGpu(self.blocks, self.GPU_DATA_PREFIX + name, name)
def isOnGpu(self, name):
return name, self.GPU_DATA_PREFIX + name in self._cpuGpuPairs
def allToCpu(self): def allToCpu(self):
for cpuName, gpuName in self._cpuGpuPairs: for cpuName, gpuName in self._cpuGpuPairs:
wlb.cuda.copyFieldToCpu(self.blocks, gpuName, cpuName) wlb.cuda.copyFieldToCpu(self.blocks, gpuName, cpuName)
......
...@@ -106,6 +106,7 @@ class SerialDataHandling(DataHandling): ...@@ -106,6 +106,7 @@ class SerialDataHandling(DataHandling):
self.fields[name] = Field.createFixedSize(latexName, shape=kwargs['shape'], indexDimensions=indexDimensions, self.fields[name] = Field.createFixedSize(latexName, shape=kwargs['shape'], indexDimensions=indexDimensions,
dtype=kwargs['dtype'], layout=layoutTuple) dtype=kwargs['dtype'], layout=layoutTuple)
self._fieldLatexNameToDataName[latexName] = name self._fieldLatexNameToDataName[latexName] = name
return self.fields[name]
def addCustomData(self, name, cpuCreationFunction, def addCustomData(self, name, cpuCreationFunction,
gpuCreationFunction=None, cpuToGpuTransferFunc=None, gpuToCpuTransferFunc=None): gpuCreationFunction=None, cpuToGpuTransferFunc=None, gpuToCpuTransferFunc=None):
...@@ -209,6 +210,9 @@ class SerialDataHandling(DataHandling): ...@@ -209,6 +210,9 @@ class SerialDataHandling(DataHandling):
else: else:
self.gpuArrays[name].set(self.cpuArrays[name]) self.gpuArrays[name].set(self.cpuArrays[name])
def isOnGpu(self, name):
return name in self.gpuArrays
def synchronizationFunctionCPU(self, names, stencilName=None, **kwargs): def synchronizationFunctionCPU(self, names, stencilName=None, **kwargs):
return self._synchronizationFunctor(names, stencilName, 'cpu') return self._synchronizationFunctor(names, stencilName, 'cpu')
......
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