← Back to team overview

dolfin team mailing list archive

Improve and restructure implementation of the Function class [...]

 

Commit from logg (2005-11-29 20:56 CET)
----------------

Improve and restructure implementation of the Function class

The Function class has been broken to a hierarchy of classes. The Function
class now functions as an envelope class and all functionality is implemented
in the respective letter class (sub classes of GenericFunction) for each
type of function. This should make it easier to add new functionality in the
future. The logic of the Function class is also more transparent.

All previous functionality is retained, but note the following minor
changes to the interface:

1. User-defined functions should overload

       real operator() (const Point& p, unsigned int i)

both for scalar and vector-valued functions. (Just ignore the component
index i for a scalar function.)

2. User-defined functions can now also be defined directly from a pointer
to a function of the type real(*FunctionPointer)(const Point& p, unsigned int).

3. User-defined functions can be saved to file if a mesh is attached to
the function before saving:

    u.attach(mesh);

Note that the vector dimension needs to be specified in the constructor
of a user-defined function for vector-valued functions.

4. User-defined functions no longer have access to _cell. Instead,
user-defined functions that depend on the current cell can call the function
cell(), which returns the current cell during assembly and generates an
error otherwise (when there is no current cell).

5. The problem that Andy noted earlier (non-matching elements for repeated
assembly with the same function and different elements) should now be
fixed.

Next, I plan to add support for picking sub functions of mixed functions and
components of vector-valued functions.

Please try it out and tell me if I broke anything.

  dolfin  ChangeLog                                                   1.250
  dolfin  src/demo/fem/convergence/main.cpp                           1.4
  dolfin  src/demo/nls/main.cpp                                       1.4
  dolfin  src/demo/poisson/main.cpp                                   1.9
  dolfin  src/demo/solvers/convdiff/main.cpp                          1.20
  dolfin  src/demo/solvers/elasticity/main.cpp                        1.15
  dolfin  src/demo/solvers/elasticity-updated/main.cpp                1.38
  dolfin  src/demo/solvers/heat/main.cpp                              1.9
  dolfin  src/demo/solvers/navierstokes/benchmark/main.cpp            1.26
  dolfin  src/demo/solvers/poisson/main.cpp                           1.36
  dolfin  src/demo/solvers/stokes/main.cpp                            1.4
  dolfin  src/kernel/fem/AffineMap.cpp                                1.4
  dolfin  src/kernel/fem/FEM.cpp                                      1.41
  dolfin  src/kernel/fem/dolfin/AffineMap.h                           1.4
  dolfin  src/kernel/fem/dolfin/FEM.h                                 1.22
  dolfin  src/kernel/fem/dolfin/FiniteElement.h                       1.20
  dolfin  src/kernel/form/BilinearForm.cpp                            1.10
  dolfin  src/kernel/form/Form.cpp                                    1.15
  dolfin  src/kernel/form/LinearForm.cpp                              1.10
  dolfin  src/kernel/form/dolfin/BilinearForm.h                       1.11
  dolfin  src/kernel/form/dolfin/Form.h                               1.16
  dolfin  src/kernel/form/dolfin/LinearForm.h                         1.11
+ dolfin  src/kernel/function/DiscreteFunction.cpp                    1.1
  dolfin  src/kernel/function/Function.cpp                            1.26
+ dolfin  src/kernel/function/FunctionPointerFunction.cpp             1.1
+ dolfin  src/kernel/function/GenericFunction.cpp                     1.7
+ dolfin  src/kernel/function/LocalFunctionData.cpp                   1.1
  dolfin  src/kernel/function/Makefile.am                             1.10
  dolfin  src/kernel/function/Makefile.in                             1.101
+ dolfin  src/kernel/function/UserFunction.cpp                        1.1
+ dolfin  src/kernel/function/dolfin/DiscreteFunction.h               1.1
  dolfin  src/kernel/function/dolfin/Function.h                       1.20
+ dolfin  src/kernel/function/dolfin/FunctionPointer.h                1.1
+ dolfin  src/kernel/function/dolfin/FunctionPointerFunction.h        1.1
+ dolfin  src/kernel/function/dolfin/GenericFunction.h                1.7
+ dolfin  src/kernel/function/dolfin/LocalFunctionData.h              1.1
  dolfin  src/kernel/function/dolfin/Makefile.am                      1.7
  dolfin  src/kernel/function/dolfin/Makefile.in                      1.101
+ dolfin  src/kernel/function/dolfin/UserFunction.h                   1.1
  dolfin  src/kernel/io/MFile.cpp                                     1.25
  dolfin  src/kernel/io/TecplotFile.cpp                               1.7
  dolfin  src/kernel/io/VTKFile.cpp                                   1.5
  dolfin  src/kernel/mesh/dolfin/Point.h                              1.7
  dolfin  src/modules/convdiff/ConvectionDiffusionSolver.cpp          1.17
  dolfin  src/modules/elasticity-updated/ElasticityUpdatedSolver.cpp  1.59
+ dolfin  src/test/dolfin-1.xml.gz                                    1.1
  dolfin  src/test/main.cpp                                           1.10