The SWAGE Function

<< Click to Display Table of Contents >>

Navigation:  Problem Descriptor Reference > The Elements of a Descriptor > Built-in Functions >

The SWAGE Function

Previous pageReturn to chapter overviewNext page

The SWAGE function has been introduced to provide an alternative to discontinuous functions like USTEP and the discontinuous IF..THEN construct.  Discontinuous switching can cause serious difficulties, especially in time dependent problems, and is strongly discouraged.


FlexPDE is an adaptive system.  Its procedures are based on the assumption that by making timesteps and/or cell sizes smaller, a scale can be found at which the behavior of the solution is representable by polynomials.  Discontinuities do not satisfy this assumption.  A discontinuity is a discontinuity, no matter how close you look.  Instantaneous turn-on or turn-off introduces high frequency spatial or temporal components into the solution, including those which are far beyond the physical limits of real systems to respond.  This makes the computation slow and possibly physically meaningless.


The SWAGE function generates a smooth transition from one value to another. The slope at the center of the transition is the same as a RAMP of the given width, but the curve extends to five times the given width on each side, reaching the end values exactly.  It also has smooth derivatives, except for a one percent jump at the cutoff points.  It can be thought of as a "fuzzy IF", and has a usage very similar to an IF.. THEN, but without the harsh switching characteristics.


The form is:


value = SWAGE(expression, left_value, right_value, width )


This expression is logically equivalent to


value = IF expression < 0 THEN left_value ELSE right_value


except that the transition will be smeared over width.


See the RAMP function for a similar function which is smooth in value, but not in derivative.



see "Samples | Usage | Swage_test.pde" for a picture of the SWAGE and RAMP transitions and their derivatives.


swage 1.(noun) A tool, variously shaped or grooved on the end or face, used by blacksmiths and other workers in metals, for shaping their work. 2.(verb)To bend or shape using a swage.