Index

NAME

FDM - base class and methods for finite difference programming


INCLUDE

include "FDM.h"

SYNTAX

 class FDM : public SimCase
 {

 protected:

   CPUclock        cpu;
   double          cpu_time_makeSystem;
   void cputime();                           // gets cpu time and writes report

   MatVecContribFD contrib;

   virtual void calcMatVecContrib
     (
      int              node_no,
      MatVecContribFD& contrib,
      Stencil&         stencil,
      DegFreeFD&       dof
     );

   void fillAndAssembleContrib
     (
      int              node_no,
      MatVecContribFD& contrib,
      Stencil&         stencil,
      DegFreeFD&       dof,
      LinEqAdmFD&      lineq,
      int              curr_dof
     );

   void fillAndAssembleContrib
     (
      MatVecContribFD& contrib,
      DegFreeFD&       dof,
      LinEqAdmFD&      lineq
     );

   void fillRightHandSide
     (
      StencilCollection& stencils,
      DegFreeFD&         dof,
      LinEqAdmFD&        lineq
     );

   virtual void findContribOverIndexSet
     (
      IndexSet&          indexset,
      StencilCollection& stencils,
      DegFreeFD&         dof,
      MatVecContribFD&   contrib,
      LinEqAdmFD&        lineq,
      int                indexset_no
     ) =0;

   virtual void findContribOverGrid
     (
      DegFreeFD&         dof,
      StencilCollection& stencils,
      MatVecContribFD&   contrib,
      LinEqAdmFD&        lineq
     ) =0;

   virtual void fillRHSOverIndexSet
     (
      IndexSet&          idxset,
      int                indexset_no,
      StencilCollection& stencils,
      DegFreeFD&         dof,
      Vec(NUMT)&         rhs
     ) =0;

   virtual void fillRHSOverGrid
     (
      StencilCollection& stencils,
      DegFreeFD&         dof,
      Vec(NUMT)&         rhs
     ) =0;


 public:

   FDM ();
   virtual ~FDM ();

   virtual void makeSystem
     (
      DegFreeFD&          dof,
      StencilCollection&  ptopcoll,
      StencilCollection&  rhs_stencil,
      LinEqAdmFD&         lineq,
      bool                compute_A      = true,
      bool                compute_RHS    = true
     );

   virtual void makeSystem
     (
      DegFreeFD&          dof,
      StencilCollection&  ptopcoll,
      FieldWithPtValues&  rhs_stencil,
      LinEqAdmFD&         lineq,
      bool                compute_A      = true,
      bool                compute_RHS    = true
     );

   virtual void makeSystem
     (
      DegFreeFD&          dof,
      StencilCollection&  ptopcoll,
      FieldsWithPtValues& rhs_fields,
      LinEqAdmFD&         lineq,
      bool                compute_A      = true,
      bool                compute_RHS    = true
     );

   // --------------------------------------------------------------------------

   double getCPUtime4makeSystem () const { return cpu_time_makeSystem; }

   COPY_CONSTRUCTOR(FDM);
   ASSIGNMENT_OPERATOR(FDM);

   CLASS_INFO
   // virtual cast functions, one for each subclass:
   DEF_VIRTUAL_CAST(FDMLattice)
   DEF_VIRTUAL_CAST(FDMUnstruct)
 };



KEYWORDS

finite difference method, base class, problem dependent data



DESCRIPTION

Class FDM offers tools for setting up a linear system based on an
object of type DegFreeFD and a set of stencils  representing  the
left and right hand side of the system.


CONSTRUCTORS AND INITIALIZATION

There  is  only one constructor, a constructor without arguments.
Further initialization is unnecessary.


MEMBER FUNCTIONS

makeSystem - computes the linear system  arising  from  a  finite
difference  method.  Based  on the information from the DegFreeFD
object, and the stencil collection for both the  left  and  right
hand  side (or in some cases a FieldWithPtValues or FieldsWithPt­
Values objects for the right hand side). It is necessary that the
supplied stencil collections match the grid and indexset informa­
tion in the DegFreeFD object. That is, if an indexsetunion is set
in  the DegFreeFD, the stencil collection must have the same num­
ber of stencils per degree of freedom as the number  of  sets  in
the indexset union, the stencils must also be organized such that
they occur in the same order as  the  indexsets  they  should  be
applied  with.  If  there  is  only  one indexset specified or no
indexset at all, the stencil collection must have one stencil per
degree  of  freedom.  Note  that if the single specified indexset
does not cover the entire grid, the linear system will be  incom­
plete  and  must be finished by the user. It is currently left up
to the user to ensure that the supplied stencil is  valid  inside
the  corresponding  indexset.  In  the  case  that no indexset or
indexset union has been specified, the stencil will be applied on
every  node  in  the grid, and if parts of the stencil is outside
the grid, these entries will be ignored. This may  lead  to  some
incorrect matrix entries in rows corresponding to the edge of the
grid, and it is left up to the user to edit these values.

It is recommended to use a complete  indexset  collection  and  a
corresponding  stencil  collection such that the linear system is
automatically correctly set.

The makeSystem functions measures the CPU time spent in the func­
tion.  This  CPU  time is written to the logfile (casename.dp) if
more than half a second is  spent  in  the  makeSystem  function.
Similar  CPU time information is provided by LinEqAdm:: solve and
written on the same line in the logfile. The CPU time  is  avail­
able  in an internal (protected) variable that the programmer can
use in a derived simulation class if desired.




DEVELOPED BY

Numerical Objects AS, Oslo, Norway


AUTHOR

Elizabeth Acklam, NO