jvx.numeric

## Class PnEnergyMinimizer

- java.lang.Object
- - jv.object.PsObject
  - - jvx.numeric.PnEnergyMinimizer

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Runnable, PsUpdateIf

      public class PnEnergyMinimizer
      extends PsObject
      implements java.lang.Runnable

  Main class to vary a surface to minimize a given energy functional. Minimization runs in a separate thread. For Dirichlet and Area minimization support for hessian and eigenvalues included.
  See Also:
    Serialized Form
  Author:
    Konrad Polthier
  Version:
    06.02.04, 1.80 revised (kp) Fixing of marked vertices corrected since checkbox showed no effect.
    19.12.01, 1.70 revised (ep) Internationalization.
    17.01.01, 1.60 revised (ep) Thread handling slightly corrected. More coming later.
    04.01.01, 1.50 revised (kp) Domain geometry may be missing.
    08.11.00, 2.10 revised (kp) Replace formatting with PuString rather than Fmt.
    21.07.99, 2.00 revised (kp)
    00.00.98, 1.00 created (kp)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ALIGNMENT`
    `static int` | `AREA`
    `static int` | `CONFORMAL`
    `static int` | `DIRICHLET`
    `static int` | `GAUSS`
    `static int` | `SPRING`
    `static int` | `VOLUME`

    - ### Fields inherited from class jv.object.PsObject

      `HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PnEnergyMinimizer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `computeEigenvectors()` Compute eigenvectors either of Hessian or of an L2-corrected Hessian.
    `void` | `enableUpdateDomain(boolean flag)` Flag whether domain is updated after each CG-minimization loop.
    `PgElementSet` | `getDomain()` Get currently registered domain geometry.
    `java.lang.String[]` | `getEigenSolver()`
    `PsPanel` | `getEigenSolverPanel(int id)`
    `PnEnergy` | `getEnergy()` Get current energy.
    `double` | `getInitialStepsize()` Get stepsize used in cg iteration.
    `PgElementSet` | `getSurface()` Get currently registered surface.
    `void` | `init()` If instance has missing name then assign default name 'Object_NUMBER' where number is the total number of already created instances.
    `boolean` | `isEnabledConstrainMatrix()` Determine if usage of a constrain matrix is enabled.
    `boolean` | `isEnabledFixVertices()` Determine if marked vertices remain fixed during minimization.
    `boolean` | `isRunning()` Check whether energy minimizer will be stopped.
    `boolean` | `isStopped()` Check whether energy minimizer is currently NOT running a minimizing thread.
    `double` | `minimize()` Minimize energy by invoking conjugate gradient method in a loop.
    `void` | `printEigenvalues()` Print eigenvalues of hessian to JavaView console.
    `void` | `printEigenvectors()` Print eigenvectors of hessian to JavaView console.
    `void` | `printGradient()` Evaluate and print the energy gradient to the JavaView console.
    `void` | `printHessian()` Evaluate the Hessian matrix of the energy and print its content to the JavaView console.
    `void` | `run()` Do energy minimization until `m_numLoops` are done or until a call of stop().
    `void` | `saveEigenvectors()` Save eigenvectors of hessian as vector fields of the surface.
    `void` | `setEigenSolver(int id)`
    `void` | `setEnabledConstrainMatrix(boolean flag)` Enable usage of a constrain matrix for index computation of Neumann boundary geometries.
    `void` | `setEnabledFixVertices(boolean flag)` Enable if marked vertices remain fixed during minimization.
    `void` | `setEnergy(PnEnergy energy)` Set new energy and clear all vector fields.
    `void` | `setInitialStepsize(double h)` Set stepsize used in cg iteration.
    `void` | `setNumLoops(int numLoops)` Set number of calls of conjugate gradient method to be performed during each call to PnEnergyMinimizer#minimize().
    `boolean` | `setSurface(PgElementSet domain, PgElementSet surface)` Set references to domain and image surface.
    `void` | `setUpdateDomain(boolean flag)` Set flag which enables the updating of the domain with the current surface after every minimization step.
    `void` | `showEigenvector(int ind)` Show eigenvectors of hessian as vector field on the surface.
    `void` | `showGradient()` Evaluate and show the gradient as vectors at each vertex.
    `void` | `showNone()` Clear all internal vector fields of this class and of the registered surface.
    `void` | `start()` Start energy minimization in separate thread.
    `void` | `step()` Move vertices in negative gradient direction a certain amount.
    `void` | `step(int numSteps)` Move vertices in negative gradient direction a certain amount.
    `void` | `stop()` Stop energy minimization in separate thread.
    `boolean` | `update(java.lang.Object event)` Update the class whenever a child has changed.

    - ### Methods inherited from class jv.object.PsObject

      `addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, updatePanels`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DIRICHLET

          public static final int DIRICHLET

      See Also:
        Constant Field Values

    - #### AREA

          public static final int AREA

      See Also:
        Constant Field Values

    - #### CONFORMAL

          public static final int CONFORMAL

      See Also:
        Constant Field Values

    - #### SPRING

          public static final int SPRING

      See Also:
        Constant Field Values

    - #### ALIGNMENT

          public static final int ALIGNMENT

      See Also:
        Constant Field Values

    - #### VOLUME

          public static final int VOLUME

      See Also:
        Constant Field Values

    - #### GAUSS

          public static final int GAUSS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PnEnergyMinimizer

          public PnEnergyMinimizer()

  - ### Method Detail

    - #### init

          public void init()

      Description copied from class: `PsObject`
      If instance has missing name then assign default name 'Object_NUMBER' where number is the total number of already created instances.
      Overrides:
        `init` in class `PsObject`

    - #### update

          public boolean update(java.lang.Object event)

      Update the class whenever a child has changed. Method is usually invoked from the children.
      Specified by:
        `update` in interface `PsUpdateIf`
      Overrides:
        `update` in class `PsObject`
      Parameters:
        `event` - carries a lot of information
      Returns:
        true if event has been handled, otherwise false
      See Also:
        `PsObject.setParent(PsUpdateIf)`, `PsObject.getFather()`, `PsObject.addUpdateListener(PsUpdateIf)`

    - #### getEnergy

          public PnEnergy getEnergy()

      Get current energy.

    - #### setEnergy

          public void setEnergy(PnEnergy energy)

      Set new energy and clear all vector fields. Domain argument maybe null.
      Version:
        04.01.01, 1.10 revised (kp) Domain geometry may be missing.

    - #### isEnabledFixVertices

          public boolean isEnabledFixVertices()

      Determine if marked vertices remain fixed during minimization.

    - #### setEnabledFixVertices

          public void setEnabledFixVertices(boolean flag)

      Enable if marked vertices remain fixed during minimization.

    - #### isEnabledConstrainMatrix

          public boolean isEnabledConstrainMatrix()

      Determine if usage of a constrain matrix is enabled.

    - #### setEnabledConstrainMatrix

          public void setEnabledConstrainMatrix(boolean flag)

      Enable usage of a constrain matrix for index computation of Neumann boundary geometries.

    - #### enableUpdateDomain

          public void enableUpdateDomain(boolean flag)

      Flag whether domain is updated after each CG-minimization loop. When iteratively computing harmonic maps copy image surface into domain after minimization to update domain metric. Main use is inside Pinkall/Polthier algorithm on computing minimal surfaces by iterating harmonic maps.

    - #### getDomain

          public PgElementSet getDomain()

      Get currently registered domain geometry.

    - #### getSurface

          public PgElementSet getSurface()

      Get currently registered surface.

    - #### setSurface

          public boolean setSurface(PgElementSet domain,
                                    PgElementSet surface)

      Set references to domain and image surface. Image surface is usually being minimized while domain surface is often used when minimizing energy of maps between surfaces. Dimension of vertices of domain and surface may be different, e.g., domain may have 2-dimensional and surface may have 1-dimensional vertices.

      Remark: If the geometries are changed outside this energy minimizer, the user must call setSurface() again to update the energy minimizer. Otherwise, further minimization calls will use the old geometry information.

    - #### setNumLoops

          public void setNumLoops(int numLoops)

      Set number of calls of conjugate gradient method to be performed during each call to PnEnergyMinimizer#minimize().

      This number of loops is independent of the number of iterations used in each single invocation of the CG-method, which depends on the requested accuracy PnEnergyMinimizer#m_cgEps.

      See Also:
        `minimize()`

    - #### minimize

          public double minimize()

      Minimize energy by invoking conjugate gradient method in a loop. A separate thread is started which calls in each step a conjugate gradient method. The number of loops may be set using #setNumLoops(int).
      See Also:
        `setNumLoops(int)`

    - #### setUpdateDomain

          public void setUpdateDomain(boolean flag)

      Set flag which enables the updating of the domain with the current surface after every minimization step. This is an essential part of the computation of minimal surface through an iteration of minimizing the Dirichlet energy, but in some other cases the domain is preferably not updated.

    - #### getInitialStepsize

          public double getInitialStepsize()

      Get stepsize used in cg iteration.

    - #### setInitialStepsize

          public void setInitialStepsize(double h)

      Set stepsize used in cg iteration.

    - #### step

          public void step()

      Move vertices in negative gradient direction a certain amount. Amount is gradient*h with user defined stepsize. This method is applied numLoops times.
      See Also:
        `step(int)`
      Version:
        26.06.01, 1.60 revised (kp) Allow a small tolerance when searching for step size.
        14.03.01, 1.50 revised (kp) No longer multiply h with numLoops.

    - #### step

          public void step(int numSteps)

      Move vertices in negative gradient direction a certain amount. Amount is gradient*h with `h=0.01`. This method is applied numSteps times.

      Method starts a new thread if `numSteps>1` which calls `step()`.

      See Also:
        `step()`
      Version:
        14.03.01, 1.00 created (kp)

    - #### printGradient

          public void printGradient()

      Evaluate and print the energy gradient to the JavaView console.

    - #### showNone

          public void showNone()

      Clear all internal vector fields of this class and of the registered surface.

    - #### showGradient

          public void showGradient()

      Evaluate and show the gradient as vectors at each vertex. This method assigns a new vector field to the surface, or reuses a vector field with name "Vector Field".

    - #### printHessian

          public void printHessian()

      Evaluate the Hessian matrix of the energy and print its content to the JavaView console. This method should only be applied to surfaces with few coordinates.

    - #### computeEigenvectors

          public int computeEigenvectors()

      Compute eigenvectors either of Hessian or of an L2-corrected Hessian.
      Version:
        12.02.03, 1.10 revised (kp) Implement Neumann conditions for pure Hessian.

    - #### printEigenvalues

          public void printEigenvalues()

      Print eigenvalues of hessian to JavaView console. If the eigenvectors are null, then compute eigenvectors.

    - #### printEigenvectors

          public void printEigenvectors()

      Print eigenvectors of hessian to JavaView console. If the eigenvectors are null, then compute eigenvectors.

    - #### saveEigenvectors

          public void saveEigenvectors()

      Save eigenvectors of hessian as vector fields of the surface. If the eigenvectors are null, then compute eigenvectors.

    - #### showEigenvector

          public void showEigenvector(int ind)

      Show eigenvectors of hessian as vector field on the surface. If the eigenvectors are null, then compute eigenvectors.

    - #### getEigenSolver

          public java.lang.String[] getEigenSolver()

      Returns:
        Names of available eigensolver.

    - #### getEigenSolverPanel

          public PsPanel getEigenSolverPanel(int id)

      Parameters:
        `id` - of eigensolver corresponding to order in of Names in Array returned by getEigenSolver().
      Returns:
        InfoPanel of eigensolver.

    - #### setEigenSolver

          public void setEigenSolver(int id)

      Parameters:
        `id` - of eigensolver corresponding to order in of Names in Array returned by getEigenSolver().

    - #### isRunning

          public boolean isRunning()

      Check whether energy minimizer will be stopped.
      Returns:
        false, if the energy minimizer will stop (just shutting down regularly).

    - #### isStopped

          public boolean isStopped()

      Check whether energy minimizer is currently NOT running a minimizing thread.

    - #### start

          public void start()

      Start energy minimization in separate thread.

    - #### stop

          public void stop()

      Stop energy minimization in separate thread.
      Version:
        02.08.00, 1.10 revised (kp) Disabled setting of m_energy.enableEvaluation(false).

    - #### run

          public void run()

      Do energy minimization until `m_numLoops` are done or until a call of stop().
      Specified by:
        `run` in interface `java.lang.Runnable`

"

The software JavaView? is copyright protected. All Rights Reserved.
"