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

lbmpy: fixes in boundaries that take field values

previously the value was taken from the cell next to the boundary cell (i.e. the inner cell)
parent 5934016f
Branches
Tags
No related merge requests found
...@@ -2,6 +2,7 @@ import sympy as sp ...@@ -2,6 +2,7 @@ import sympy as sp
from lbmpy.simplificationfactory import createSimplificationStrategy from lbmpy.simplificationfactory import createSimplificationStrategy
from pystencils.sympyextensions import getSymmetricPart from pystencils.sympyextensions import getSymmetricPart
from pystencils import Field
from lbmpy.boundaries.boundaryhandling import offsetFromDir, weightOfDirection, invDir from lbmpy.boundaries.boundaryhandling import offsetFromDir, weightOfDirection, invDir
...@@ -20,6 +21,8 @@ def ubb(pdfField, direction, lbMethod, velocity, adaptVelocityToForce=False): ...@@ -20,6 +21,8 @@ def ubb(pdfField, direction, lbMethod, velocity, adaptVelocityToForce=False):
neighbor = offsetFromDir(direction, lbMethod.dim) neighbor = offsetFromDir(direction, lbMethod.dim)
inverseDir = invDir(direction) inverseDir = invDir(direction)
velocity = tuple(v_i.getShifted(*neighbor) if isinstance(v_i, Field.Access) else v_i for v_i in velocity)
if adaptVelocityToForce: if adaptVelocityToForce:
cqc = lbMethod.conservedQuantityComputation cqc = lbMethod.conservedQuantityComputation
shiftedVelEqs = cqc.equilibriumInputEquationsFromInitValues(velocity=velocity) shiftedVelEqs = cqc.equilibriumInputEquationsFromInitValues(velocity=velocity)
......
...@@ -13,11 +13,12 @@ WEIGHTS_SYMBOL = TypedSymbol("weights", "double") ...@@ -13,11 +13,12 @@ WEIGHTS_SYMBOL = TypedSymbol("weights", "double")
class BoundaryHandling(object): class BoundaryHandling(object):
class BoundaryInfo(object): class BoundaryInfo(object):
def __init__(self, name, flag, function, kernel): def __init__(self, name, flag, function, kernel, ast):
self.name = name self.name = name
self.flag = flag self.flag = flag
self.function = function self.function = function
self.kernel = kernel self.kernel = kernel
self.ast = ast
def __init__(self, pdfField, domainShape, lbMethod, ghostLayers=1, target='cpu'): def __init__(self, pdfField, domainShape, lbMethod, ghostLayers=1, target='cpu'):
""" """
...@@ -135,7 +136,7 @@ class BoundaryHandling(object): ...@@ -135,7 +136,7 @@ class BoundaryHandling(object):
return self._boundaryInfos[name].flag return self._boundaryInfos[name].flag
newIdx = len(self._boundaryInfos) + 1 # +1 because 2**0 is reserved for fluid flag newIdx = len(self._boundaryInfos) + 1 # +1 because 2**0 is reserved for fluid flag
boundaryInfo = self.BoundaryInfo(name, 2 ** newIdx, boundaryFunction, None) boundaryInfo = self.BoundaryInfo(name, 2 ** newIdx, boundaryFunction, None, None)
self._boundaryInfos.append(boundaryInfo) self._boundaryInfos.append(boundaryInfo)
self._nameToBoundary[name] = boundaryInfo self._nameToBoundary[name] = boundaryInfo
self._dirty = True self._dirty = True
...@@ -173,7 +174,7 @@ class BoundaryHandling(object): ...@@ -173,7 +174,7 @@ class BoundaryHandling(object):
boundary.flag, self._fluidFlag, self._ghostLayers) boundary.flag, self._fluidFlag, self._ghostLayers)
ast = generateBoundaryHandling(self._symbolicPdfField, idxField, self._lbMethod, boundary.function, ast = generateBoundaryHandling(self._symbolicPdfField, idxField, self._lbMethod, boundary.function,
target=self._target) target=self._target)
boundary.ast = ast
if self._target == 'cpu': if self._target == 'cpu':
from pystencils.cpu import makePythonFunction as makePythonCpuFunction from pystencils.cpu import makePythonFunction as makePythonCpuFunction
boundary.kernel = makePythonCpuFunction(ast, {'indexField': idxField}) boundary.kernel = makePythonCpuFunction(ast, {'indexField': idxField})
......
...@@ -428,6 +428,7 @@ def compareMomentBasedLbMethods(reference, other, showDeviationsOnly=False): ...@@ -428,6 +428,7 @@ def compareMomentBasedLbMethods(reference, other, showDeviationsOnly=False):
def compressibleToIncompressibleMomentValue(term, rho, u): def compressibleToIncompressibleMomentValue(term, rho, u):
term = sp.sympify(term)
term = term.expand() term = term.expand()
if term.func != sp.Add: if term.func != sp.Add:
args = [term, ] args = [term, ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment