Ejemplo n.º 1
0
 def getInterface(self,phi=None,smoothing_width=None):
     """
     creates a characteristic function which is 1 over the over the length
     *2*h*smoothing_width*  around the interface and zero elsewhere
     """
     if smoothing_width is None: smoothing_width = self.__smooth
     if phi is None: phi = self.__phi
     s=smoothing_width*self.__h 
     phi_on_h=es.interpolate(phi,esc.Function(self.__domain))
     return es.whereNegative(abs(phi_on_h)-s)
Ejemplo n.º 2
0
 def getSmoothedJump(self,phi=None,smoothing_width=None):
     """
     Creates a smooth interface from -1 to 1 over the length
     *2*h*smoothing_width* where -1 is used where the level set is negative
     and 1 where the level set is 1.
     """
     if smoothing_width is None: smoothing_width = self.__smooth
     if phi is None: phi = self.__phi
     s=smoothing_width*self.__h
     phi_on_h=es.interpolate(phi,esc.Function(self.__domain))
     mask_neg = es.whereNonNegative(-s-phi_on_h)
     mask_pos = es.whereNonNegative(phi_on_h-s)
     mask_interface = 1.-mask_neg-mask_pos
     interface=phi_on_h/s
     return - mask_neg + mask_pos + mask_interface * interface