Package esys :: Package escript :: Module levelset :: Class LevelSet
[hide private]
[frames] | no frames]

Class LevelSet

The level set method tracking an interface defined by the zero contour of the level set function phi.

It is assumed that phi(x)<0 defines the volume of interest.

Instance Methods [hide private]
 
__advect(self, velocity, dt)
Advects the level set function in the presence of a velocity field.
 
__init__(self, domain, phi, reinit_max=10, reinit_each=2, smooth=2.0)
Sets up the level set method.
 
__makeInterface(self, phi, smoothing_width)
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.
 
__reinitialise(self)
Reinitializes the level set.
 
getDomain(self)
Returns the domain.
 
getH(self)
Returns the mesh size.
 
getLevelSetFunction(self)
Returns the level set function.
 
getSurface(self, rel_width_factor=0.5)
Returns a mask for the phi(x)=1 region
 
getTimeStepSize(self, velocity)
Returns a new dt for a given velocity using the Courant condition.
 
getVolume(self)
Returns the volume of the phi(x)<0 region.
 
makeCharacteristicFunction(self, contour=0, phi=None, positiveSide=True, smoothing_width=None)
Makes a smooth characteristic function of the region phi(x)>contour if positiveSide and phi(x)<contour otherwise.
 
setTolerance(self, tolerance=0.001)
 
update(self, dt)
Sets a new velocity and updates the level set function.
 
update_parameter(self, param_neg=-1, param_pos=1, phi=None, smoothing_width=None)
Creates a smoothed function with param_neg where phi<0 and param_pos where phi>0 which is smoothed over a length smoothing_width across the interface.
 
update_parameter_sharp(self, param_neg=-1, param_pos=1, phi=None)
Creates a function with param_neg where phi<0 and param_pos where phi>0 (no smoothing).
 
update_phi(self, velocity, dt)
Updates phi under the presence of a velocity field.
Method Details [hide private]

__advect(self, velocity, dt)

 

Advects the level set function in the presence of a velocity field.

This implementation uses the 2-step Taylor-Galerkin method.

Parameters:
  • velocity - velocity field
  • dt - time increment
Returns:
the advected level set function

__init__(self, domain, phi, reinit_max=10, reinit_each=2, smooth=2.0)
(Constructor)

 

Sets up the level set method.

Parameters:
  • domain - the domain where the level set is used
  • phi - the initial level set function
  • reinit_max - maximum number of reinitialization steps
  • reinit_each - phi is reinitialized every reinit_each step
  • smooth - smoothing width

__reinitialise(self)

 

Reinitializes the level set.

It solves the PDE...

Returns:
reinitialized level set

getSurface(self, rel_width_factor=0.5)

 

Returns a mask for the phi(x)=1 region

Parameters:
  • rel_width_factor - relative width of region around zero contour

getTimeStepSize(self, velocity)

 

Returns a new dt for a given velocity using the Courant condition.

Parameters:
  • velocity - velocity field

makeCharacteristicFunction(self, contour=0, phi=None, positiveSide=True, smoothing_width=None)

 

Makes a smooth characteristic function of the region phi(x)>contour if positiveSide and phi(x)<contour otherwise.

Parameters:
  • phi - level set function to be used. If not present the current level set is used.
  • smoothing_width - width of the smoothing zone relative to mesh size. If not present the initial value of smooth is used.

update(self, dt)

 

Sets a new velocity and updates the level set function.

Parameters:
  • dt - time step forward

update_parameter(self, param_neg=-1, param_pos=1, phi=None, smoothing_width=None)

 

Creates a smoothed function with param_neg where phi<0 and param_pos where phi>0 which is smoothed over a length smoothing_width across the interface.

Parameters:
  • smoothing_width - width of the smoothing zone relative to mesh size. If not present the initial value of smooth is used.

update_parameter_sharp(self, param_neg=-1, param_pos=1, phi=None)

 

Creates a function with param_neg where phi<0 and param_pos where phi>0 (no smoothing).

Parameters:
  • param_neg - value of parameter on the negative side (phi<0)
  • param_pos - value of parameter on the positive side (phi>0)
  • phi - level set function to be used. If not present the current level set is used.

update_phi(self, velocity, dt)

 

Updates phi under the presence of a velocity field.

If dt is small this call is equivalent to:

   dt=LevelSet.getTimeStepSize(velocity)
   phi=LevelSet.update(dt)

otherwise substepping is used.

Parameters:
  • velocity - velocity field
  • dt - time step forward