diff --git a/HySoP/hysop/operator/obstacle.py b/HySoP/hysop/operator/obstacle.py deleted file mode 100644 index 848ef3be6d243e493b74283582a83eacaadd7e59..0000000000000000000000000000000000000000 --- a/HySoP/hysop/operator/obstacle.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -Obstacles representation -""" -import numpy as np -from ..constants import * -from obstacle_d import Obstacle_d - - -class Obstacle(object): - """ - Obstacles representation. - """ - - def __init__(self, domain, name="?", zlayer, radius, center=[0.5,0.5,0.5]): - """ - Constructor. - Create an obsctacle and z-boundaries from given parameters : - - @param domain : obstacle application domain. - @param name : name of the obstacle ("sphere" or "hemisphere") - @param zlayer : width of z-boundaries layer - @param radius : radius of the obstacle - @param center : position of the obstacle center - """ - ## Application domain of the obstacle - self.domain = domain - ## Obstacle dimension. - self.dimension = self.domain.dimension - ## Discretisation of this field - self.discreteObstacle = None - # Number of different discretizations - self._obstacleId = -1 - ## List of the various discretizations of this field - self.discreteObstacle = [] - ## Name of this obstacle - self.name = name - ## Width of z-boundaries layer - self.zlayer = zlayer - ## Radius of the obstacle - self.radius = radius - ## Position of the obstacle center - self.center = np.asarray(center, dtype=PARMES_REAL) - - def discretize(self, topology=None): - """ - Obstacle discretization method. - """ - self._obstacleId += 1 - self.discreteObstacle.append(Obstacle_d(self, topology, - name=self.name + "_D_" + str(self._obstacleId), - idFromParent=self._obstacleId)) - - def __str__(self): - """ Obstacle info display """ - s = self.name + ' , ' + str(self.dimension) + 'D obstacle ' - if len(self.Obstacle_d) != 0: - s += "with the following discretizations:\n" - for i in range(len(self.Obstacle_d)): - s += self.Obstacle_d[i].__str__() - else: - s += ". Not discretised\n" - return s - -if __name__ == "__main__" : - print __doc__ - print "- Provided class : Obstacle" - print Obstacle.__doc__ diff --git a/HySoP/hysop/operator/obstacle_d.py b/HySoP/hysop/operator/obstacle_d.py deleted file mode 100644 index 7e039b87dcbe9a4573fbfff502eb8aa9429702aa..0000000000000000000000000000000000000000 --- a/HySoP/hysop/operator/obstacle_d.py +++ /dev/null @@ -1,109 +0,0 @@ -""" -Discrete obstacles description -""" -import numpy as np -from ..constants import * - - -class Obstacle_d(object): - """ - Discrete obstacles representation. - """ - - def __init__(self, parent, topology=None, name="?", idFromParent=None): - """ - Creates discrete obsctacle and z-boundaries. - - @param parent : Continuous obstacle. - @param topology : Topology informations - @param name : Obstacle name - @param idFromParent : Index in the parent's discrete obstacles - """ - - ## Topology of the obstacle - if(topology is not None): - self.topology = topology - else: - raise NotImplementedError() - ## Name of the obstacle - self.name = name - ## Obstacle dimension - self.dimension = topology.domain.dimension - ## Obstacle resolution - self.resolution = topology.mesh.resolution - ## @private Continuous obstacle - self.__parentObstacle = parent - ## @private Index in parent's discrete obstacle - self.__idFromParent = idFromParent - ## Width of z-boundaries layer - self.zlayer = self.__parentObstacle.zlayer - ## Radius of the obstacle - self.radius = self.__parentObstacle.radius - ## Position of the obstacle center - self.center = self.__parentObstacle.center - ## Number of points in the z-boundaries - self.ptsInBoundary = -1 - ## Number of points in the solid - self.ptsInSolid = -1 - ## Chi function (array) for z-boundaries - chiBoundary = [np.zeros((self.resolution), dtype=PARMES_REAL, order=ORDER) for d in xrange(self.dimension)] - ## Chi function (array) for the solid - chiSolid = [np.zeros((self.resolution), dtype=PARMES_REAL, order=ORDER) for d in xrange(self.dimension)] - - - def chiFunctions(self): - """ - Compute the chi functions associated to z-boundaries and solid - """ -# attention, il faut être sûr que coord_start est la coordonnée globale du point min du sous-domaine ou l'on se situe (idem pour max) ! - coord_start = self.topology.mesh.coord_start - coord_end = self.topology.mesh.coord_end - step = self.topology.mesh.size - prodRes = self.resolution[0] * self.resolution[1] * self.resolution[2] - layerMin = coord_start[2] + self.zlayer - layerMax = coord_end[2] - self.zlayer - - for k in xrange (self.resolution[2]): - rz = coord_start[2] + step[2] * k # attention, coord_start ok ? - for j in xrange (self.resolution[1]): - ry = coord_start[1] + step[1] * j - for i in xrange (self.resolution[0]): - rx = coord_start[0] + step[0] * i - dist = ((rx - self.center[0]) **2 + - (ry - self.center[1]) **2 + - (rz - self.center[2]) **2) - (self.radius) **2 - if (rz > layerMax or rz < layerMin): - # we are in the z-layer (North or South): - self.ptsInBoundary += 1 - self.chiBoundary[0][ptsInBoundary] = i - self.chiBoundary[1][ptsInBoundary] = j - self.chiBoundary[2][ptsInBoundary] = k - if (self.obst==0): - if (dist <= 0.0): - # we are in the sphere: - self.ptsInSolid += 1 - self.chiSolid[0][ptsInSolid] = i - self.chiSolid[1][ptsInSolid] = j - self.chiSolid[2][ptsInSolid] = k - else : - if (dist <= 0.0 and rx <= 0.0): - # we are in the hemisphere: - self.ptsInSolid += 1 - self.chiSolid[0][ptsInSolid] = i - self.chiSolid[1][ptsInSolid] = j - self.chiSolid[2][ptsInSolid] = k - - # We keep only the non-zero values in the chi arrays - self.chiBoundary=chiBoundary[0:ptsInBoundary] - self.chiSolid=chiSolid[0:ptsInSolid] - - #return self.chiBoundary ????? - #return self.chiSolid ???????? - - def __str__(self): - """ToString method""" - return "Obstacle_d (discrete obstacles)" - -if __name__ == "__main__" : - print "This module defines the following classes:" - print "Obstacle_d: ", Obstacle_d.__doc__