Let
double (*function)(double x);
be a pointer to a function. Then,
Function1<double,double> F(function);
defines a function which can be used in an expression.
Example:
Variable<double,staggered,staggered,staggered> u_exact(grid);
Coordinate<WE_dir,Grid_uniform_one_d> X(grid);
Coordinate<SN_dir,Grid_uniform_one_d> Y(grid);
Function1<double,double> Cos(cos); // definition of a function
u_exact = Cos(X)*Cos(Y); // exact solution
// of an equationExample:
....
double eps(double x, double y, double z) {
if(z<0.3) return 2.0;
return 4.0
}
....
{ ...
Variable<double,staggered,staggered,staggered> epsAtCell(grid);
Coordinate<WE_dir,Grid_uniform_one_d> X(grid);
Coordinate<SN_dir,Grid_uniform_one_d> Y(grid);
Coordinate<SN_dir,Grid_uniform_one_d> Z(grid);
Function3<double,double> Eps(eps); // definition of a function
EpsAtCell = Eps(X,Y,Z);
...
}
Last modified: Tue Feb 22 11:08:52 MET 2000