SpectralFunction Class Reference

#include <SpectralFunction.hpp>

Inheritance diagram for SpectralFunction:

Inheritance graph
[legend]
Collaboration diagram for SpectralFunction:

Collaboration graph
[legend]

List of all members.

Public Types

enum  Type {
  cfunction, constant, convection, dgfunction,
  femfunction, linearBasis, spectral, unaryMinus,
  modulo, sum, difference, product,
  division, power, min, max,
  gt, ge, lt, le,
  ne, eq, and_, or_,
  xor_, not_, derivate, integrate,
  normal, domainCharacteristic, meshCharacteristic, objectCharacteristic,
  composed, references, FEM0, undefined
}

Public Member Functions

const Vector< real_t > & values () const
real_t & operator[] (const size_t &i)
const real_t & operator[] (const size_t &i) const
ConstReferenceCounting
< SpectralMesh
mesh () const
bool canBeSimplified () const
const
ScalarDiscretizationTypeBase::Type
discretizationType () const
real_t operator() (const TinyVector< 3, real_t > &x) const
void operator= (const ScalarFunctionBase &f)
real_t dx (const TinyVector< 3 > &x) const
real_t dy (const TinyVector< 3 > &x) const
real_t dz (const TinyVector< 3 > &x) const
 SpectralFunction (ConstReferenceCounting< SpectralMesh > mesh)
 SpectralFunction (ConstReferenceCounting< SpectralMesh > mesh, const ScalarFunctionBase &f)
 SpectralFunction (const SpectralFunction &f)
 SpectralFunction (ConstReferenceCounting< SpectralMesh > mesh, const real_t &d)
 SpectralFunction (ConstReferenceCounting< SpectralMesh > mesh, const Vector< real_t > &values)
 ~SpectralFunction ()
void setName (const std::string &name)
const std::string & name () const
const Typetype () const
real_t operator() (const real_t &x, const real_t &y, const real_t &z) const
virtual real_t dx (const TinyVector< 3, real_t > &x) const
virtual real_t dy (const TinyVector< 3, real_t > &x) const
virtual real_t dz (const TinyVector< 3, real_t > &x) const

Protected Attributes

const Type __type
std::string __name

Private Member Functions

std::ostream & __put (std::ostream &os) const

Private Attributes

Vector< real_t > __values
ConstReferenceCounting
< SpectralMesh
__mesh
const
ScalarDiscretizationTypeBase::Type 
__discretizationType
const Interval __intervalX
const Interval __intervalY
const Interval __intervalZ
const SpectralConformTransformation __transformX
const SpectralConformTransformation __transformY
const SpectralConformTransformation __transformZ
const GaussLobatto__gaussLobattoX
const GaussLobatto__gaussLobattoY
const GaussLobatto__gaussLobattoZ
const LegendreBasis __basisX
const LegendreBasis __basisY
const LegendreBasis __basisZ
TinyVector
< 3, ConstReferenceCounting
< Interval > > 
__interval
TinyVector
< 3, ConstReferenceCounting
< SpectralConformTransformation > > 
__transform
TinyVector
< 3, ConstReferenceCounting
< GaussLobatto > > 
__gaussLobatto
TinyVector
< 3, ConstReferenceCounting
< LegendreBasis > > 
__basis

Friends

std::ostream & operator<< (std::ostream &os, const ScalarFunctionBase &scalarFunction)


Detailed Description

Definition at line 46 of file SpectralFunction.hpp.


Member Enumeration Documentation

enum ScalarFunctionBase::Type [inherited]

Enumerator:
cfunction 
constant 
convection 
dgfunction 
femfunction 
linearBasis 
spectral 
unaryMinus 
modulo 
sum 
difference 
product 
division 
power 
min 
max 
gt 
ge 
lt 
le 
ne 
eq 
and_ 
or_ 
xor_ 
not_ 
derivate 
integrate 
normal 
domainCharacteristic 
meshCharacteristic 
objectCharacteristic 
composed 
references 
FEM0 
undefined 

Definition at line 40 of file ScalarFunctionBase.hpp.

00040             {
00041     cfunction,
00042     constant,
00043     convection,
00044     dgfunction,
00045     femfunction,
00046     linearBasis,
00047     spectral,
00048     unaryMinus,
00049 
00050     modulo,
00051     sum,
00052     difference,
00053     product,
00054     division,
00055     power,
00056 
00057     min,
00058     max,
00059 
00060     gt,
00061     ge,
00062     lt,
00063     le,
00064     ne,
00065     eq,
00066     and_,
00067     or_,
00068     xor_,
00069 
00070     not_,
00071 
00072     derivate,
00073     integrate,
00074 
00075     normal,
00076 
00077     domainCharacteristic,
00078     meshCharacteristic,
00079     objectCharacteristic,
00080 
00081     composed,
00082     references,
00083 
00084     FEM0,
00085 
00086     undefined
00087   };


Constructor & Destructor Documentation

SpectralFunction::SpectralFunction ( ConstReferenceCounting< SpectralMesh mesh  )  [inline]

Constructor

Parameters:
mesh mesh supporting the function

Definition at line 479 of file SpectralFunction.hpp.

00481     : ScalarFunctionBase(ScalarFunctionBase::spectral),
00482       __values(mesh->numberOfVertices()),
00483       __mesh(mesh),
00484       __discretizationType(ScalarDiscretizationTypeBase::spectralLegendre),
00485       __intervalX(__mesh->shape().a()[0],__mesh->shape().b()[0]),
00486       __intervalY(__mesh->shape().a()[1],__mesh->shape().b()[1]),
00487       __intervalZ(__mesh->shape().a()[2],__mesh->shape().b()[2]),
00488       __transformX(__intervalX),
00489       __transformY(__intervalY),
00490       __transformZ(__intervalZ),
00491       __gaussLobattoX(GaussLobattoManager::instance().get(__mesh->degree(0)+1)),
00492       __gaussLobattoY(GaussLobattoManager::instance().get(__mesh->degree(1)+1)),
00493       __gaussLobattoZ(GaussLobattoManager::instance().get(__mesh->degree(2)+1)),
00494       __basisX(__mesh->degree(0)),
00495       __basisY(__mesh->degree(1)),
00496       __basisZ(__mesh->degree(2))
00497   {
00498     ;
00499   }

SpectralFunction::SpectralFunction ( ConstReferenceCounting< SpectralMesh mesh,
const ScalarFunctionBase f 
) [inline]

Constructor

Parameters:
mesh mesh supporting the function
f function of initialization

Definition at line 507 of file SpectralFunction.hpp.

00509     : ScalarFunctionBase(ScalarFunctionBase::spectral),
00510       __values((mesh->degree(0)+1)*(mesh->degree(1)+1)*(mesh->degree(2)+1)),
00511       __mesh(mesh),
00512       __discretizationType(ScalarDiscretizationTypeBase::spectralLegendre),
00513       __intervalX(__mesh->shape().a()[0],__mesh->shape().b()[0]),
00514       __intervalY(__mesh->shape().a()[1],__mesh->shape().b()[1]),
00515       __intervalZ(__mesh->shape().a()[2],__mesh->shape().b()[2]),
00516       __transformX(__intervalX),
00517       __transformY(__intervalY),
00518       __transformZ(__intervalZ),
00519       __gaussLobattoX(GaussLobattoManager::instance().get(__mesh->degree(0)+1)),
00520       __gaussLobattoY(GaussLobattoManager::instance().get(__mesh->degree(1)+1)),
00521       __gaussLobattoZ(GaussLobattoManager::instance().get(__mesh->degree(2)+1)),
00522       __basisX(__mesh->degree(0)),
00523       __basisY(__mesh->degree(1)),
00524       __basisZ(__mesh->degree(2))
00525   {
00526     (*this) = f;
00527   }

SpectralFunction::SpectralFunction ( const SpectralFunction f  )  [inline, explicit]

Copy constructor

Parameters:
f given function
Note:
must be explicitly called

Definition at line 535 of file SpectralFunction.hpp.

SpectralFunction::SpectralFunction ( ConstReferenceCounting< SpectralMesh mesh,
const real_t &  d 
) [inline]

Constructor

Parameters:
mesh mesh supporting the function
d value of initialization

Definition at line 562 of file SpectralFunction.hpp.

00564     : ScalarFunctionBase(ScalarFunctionBase::spectral),
00565       __values((mesh->degree(0)+1)*(mesh->degree(1)+1)*(mesh->degree(2)+1)),
00566       __mesh(mesh),
00567       __discretizationType(ScalarDiscretizationTypeBase::spectralLegendre),
00568       __intervalX(__mesh->shape().a()[0],__mesh->shape().b()[0]),
00569       __intervalY(__mesh->shape().a()[1],__mesh->shape().b()[1]),
00570       __intervalZ(__mesh->shape().a()[2],__mesh->shape().b()[2]),
00571       __transformX(__intervalX),
00572       __transformY(__intervalY),
00573       __transformZ(__intervalZ),
00574       __gaussLobattoX(GaussLobattoManager::instance().get(__mesh->degree(0)+1)),
00575       __gaussLobattoY(GaussLobattoManager::instance().get(__mesh->degree(1)+1)),
00576       __gaussLobattoZ(GaussLobattoManager::instance().get(__mesh->degree(2)+1)),
00577       __basisX(__mesh->degree(0)),
00578       __basisY(__mesh->degree(1)),
00579       __basisZ(__mesh->degree(2))
00580   {
00581     (*this) = ScalarFunctionConstant(d);
00582   }

SpectralFunction::SpectralFunction ( ConstReferenceCounting< SpectralMesh mesh,
const Vector< real_t > &  values 
) [inline]

Constructor

Parameters:
mesh given mesh
values given values

Definition at line 590 of file SpectralFunction.hpp.

References __values, ASSERT, and Vector< T >::size().

00593     : ScalarFunctionBase(ScalarFunctionBase::spectral),
00594       __values((mesh->degree(0)+1)*(mesh->degree(1)+1)*(mesh->degree(2)+1)),
00595       __mesh(mesh),
00596       __discretizationType(ScalarDiscretizationTypeBase::spectralLegendre),
00597       __intervalX(__mesh->shape().a()[0],__mesh->shape().b()[0]),
00598       __intervalY(__mesh->shape().a()[1],__mesh->shape().b()[1]),
00599       __intervalZ(__mesh->shape().a()[2],__mesh->shape().b()[2]),
00600       __transformX(__intervalX),
00601       __transformY(__intervalY),
00602       __transformZ(__intervalZ),
00603       __gaussLobattoX(GaussLobattoManager::instance().get(__mesh->degree(0)+1)),
00604       __gaussLobattoY(GaussLobattoManager::instance().get(__mesh->degree(1)+1)),
00605       __gaussLobattoZ(GaussLobattoManager::instance().get(__mesh->degree(2)+1)),
00606       __basisX(__mesh->degree(0)),
00607       __basisY(__mesh->degree(1)),
00608       __basisZ(__mesh->degree(2))/*((__mesh->degree(2))*/
00609   {
00610     ASSERT(__values.size() == values.size());
00611     __values = values;
00612   }

Here is the call graph for this function:

SpectralFunction::~SpectralFunction (  )  [inline]

Destructor

Definition at line 618 of file SpectralFunction.hpp.

00619   {
00620     ;
00621   }


Member Function Documentation

std::ostream& SpectralFunction::__put ( std::ostream &  os  )  const [inline, private, virtual]

Overloading of the __put function

Parameters:
os given stream
Returns:
os

Implements ScalarFunctionBase.

Definition at line 96 of file SpectralFunction.hpp.

00097   {
00098     os << "{sfunction}";
00099     return os;
00100   }

const Vector<real_t>& SpectralFunction::values (  )  const [inline]

Read-only access to the set of values

Returns:
__values

Definition at line 108 of file SpectralFunction.hpp.

References __values.

Referenced by SpectralLegendreDiscretizer::assembleSecondMember().

00109   {
00110     return __values;
00111   }

real_t& SpectralFunction::operator[] ( const size_t &  i  )  [inline]

access to the value at the ith degree of freedom

Parameters:
i number of the degree of freedom
Returns:
__values[i]

Definition at line 120 of file SpectralFunction.hpp.

References __values.

00121   {
00122     return __values[i];
00123   }

const real_t& SpectralFunction::operator[] ( const size_t &  i  )  const [inline]

Read only Access to the value at the ith degree of freedom

Parameters:
i number of the degree of freedom
Returns:
__values[i]

Definition at line 132 of file SpectralFunction.hpp.

References __values.

00133   {
00134     return __values[i];
00135   }

ConstReferenceCounting<SpectralMesh> SpectralFunction::mesh (  )  const [inline]

real-only access to the spectral mesh

Returns:
__mesh

Definition at line 142 of file SpectralFunction.hpp.

References __mesh.

Referenced by SolverExpression::execute(), and InstructionAffectation< FunctionExpression, FunctionVariable >::execute().

00143   {
00144     return __mesh;
00145   }

bool SpectralFunction::canBeSimplified (  )  const [inline, virtual]

Checks if the function can be simplified

Returns:
true

Implements ScalarFunctionBase.

Definition at line 152 of file SpectralFunction.hpp.

00153   {
00154     return false;//true;
00155   }

const ScalarDiscretizationTypeBase::Type& SpectralFunction::discretizationType (  )  const [inline]

The type of the spectral function

Returns:
__discretizationType

Definition at line 162 of file SpectralFunction.hpp.

References __discretizationType.

00163   {
00164     return __discretizationType;
00165   }

real_t SpectralFunction::operator() ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual]

Evaluates the SpectralFunction at point x.

Parameters:
x the position of evaluation
Returns:
$ f(x) $

Implements ScalarFunctionBase.

Definition at line 174 of file SpectralFunction.hpp.

References __basisX, __basisY, __basisZ, __transformX, __transformY, __transformZ, __values, LegendreBasis::dimension(), LegendreBasis::getValues(), SpectralConformTransformation::inverse(), and ScalarFunctionBase::sum.

00175   {    
00176 
00177         Vector<real_t> baseValuesX(__basisX.dimension());
00178         Vector<real_t> baseValuesY(__basisY.dimension());
00179         Vector<real_t> baseValuesZ(__basisZ.dimension());
00180     
00181         __basisX.getValues(__transformX.inverse(x[0]),baseValuesX);
00182         __basisY.getValues(__transformY.inverse(x[1]),baseValuesY);
00183         __basisZ.getValues(__transformZ.inverse(x[2]),baseValuesZ);
00184         
00185         size_t l = 0;
00186         real_t sum = 0; 
00187         for (size_t i=0; i<__basisX.dimension(); ++i) {
00188           const real_t vi = baseValuesX[i];
00189           for (size_t j=0;j<__basisY.dimension(); ++j) { 
00190             const real_t vj = baseValuesY[j];
00191             const real_t vi_vj = vi*vj;
00192             for (size_t k=0; k<__basisZ.dimension(); ++k) {
00193               const real_t vk = baseValuesZ[k];
00194               const real_t vi_vj_vk = vi_vj * vk;
00195               sum += vi_vj_vk*__values[l];
00196               l++;
00197             }
00198           }
00199         }
00200         
00201         return sum;
00202   }

Here is the call graph for this function:

void SpectralFunction::operator= ( const ScalarFunctionBase f  )  [inline]

Affects a function to a SpectralFunction

Parameters:
f original function

Construction of the nodes

calculation of the value of function f at the nodes

calculation of the value of Legendre polynomials at the nodes

calculation of the L^2-projection of the function F

Taking into account of the renormalization of the legendre polynomials

Definition at line 209 of file SpectralFunction.hpp.

References __basisX, __basisY, __basisZ, __gaussLobattoX, __gaussLobattoY, __gaussLobattoZ, __mesh, __transformX, __transformY, __transformZ, __values, LegendreBasis::dimension(), LegendreBasis::getValues(), GaussLobatto::numberOfPoints(), and GaussLobatto::weight().

00210   {
00211     __values = 0;
00212     
00217     Vector<real_t> nodesX(__gaussLobattoX.numberOfPoints());
00218     for (size_t i=0; i<__gaussLobattoX.numberOfPoints(); ++i) {
00219       nodesX[i] = __transformX(__gaussLobattoX(i));
00220         }
00221     
00222     Vector<real_t> nodesY(__gaussLobattoY.numberOfPoints());
00223     for (size_t i=0; i<__gaussLobattoY.numberOfPoints(); ++i) {
00224       nodesY[i] = __transformY(__gaussLobattoY(i));
00225     }
00226     
00227     Vector<real_t> nodesZ(__gaussLobattoZ.numberOfPoints());
00228     for (size_t i=0; i<__gaussLobattoZ.numberOfPoints(); ++i) {
00229       nodesZ[i] = __transformZ(__gaussLobattoZ(i));
00230     }
00231     
00236     Vector<Vector<Vector<real_t> > > f_rst(__gaussLobattoX.numberOfPoints());
00237     for (size_t r=0; r<__gaussLobattoX.numberOfPoints(); ++r) {
00238       f_rst[r].resize(__gaussLobattoY.numberOfPoints());
00239       for (size_t s=0; s<__gaussLobattoY.numberOfPoints(); ++s) {
00240         f_rst[r][s].resize(__gaussLobattoZ.numberOfPoints());
00241         f_rst[r][s] = 0;
00242       }
00243     }
00244     
00245     for (size_t r=0; r < __gaussLobattoX.numberOfPoints(); ++r) {
00246       const real_t& x = nodesX[r];
00247       for (size_t s=0; s < __gaussLobattoY.numberOfPoints(); ++s) {
00248         const real_t& y = nodesY[s];
00249         for (size_t t=0; t < __gaussLobattoZ.numberOfPoints(); ++t) {
00250           const real_t& z = nodesZ[t];
00251           f_rst[r][s][t] = f(x,y,z);
00252         }
00253       }
00254     }
00255     
00260     Vector<Vector<real_t> > quadratureBaseValuesX(__gaussLobattoX.numberOfPoints());
00261     for (size_t i=0; i < __gaussLobattoX.numberOfPoints(); ++i) {
00262       real_t xi= __gaussLobattoX(i);
00263       quadratureBaseValuesX[i].resize(__basisX.dimension());
00264       __basisX.getValues(xi,quadratureBaseValuesX[i]);
00265     }
00266     
00267     Vector<Vector<real_t> > quadratureBaseValuesY(__gaussLobattoY.numberOfPoints());
00268     for (size_t j=0; j < __gaussLobattoY.numberOfPoints(); ++j) {
00269       real_t yj= __gaussLobattoY(j);
00270       quadratureBaseValuesY[j].resize(__basisY.dimension());
00271       __basisY.getValues(yj,quadratureBaseValuesY[j]);
00272     }
00273     
00274     Vector<Vector<real_t> > quadratureBaseValuesZ(__gaussLobattoZ.numberOfPoints());
00275     for (size_t k=0; k < __gaussLobattoZ.numberOfPoints(); ++k) {
00276       real_t zk= __gaussLobattoZ(k);
00277       quadratureBaseValuesZ[k].resize(__basisZ.dimension());
00278       __basisZ.getValues(zk,quadratureBaseValuesZ[k]);
00279     }
00280     
00285     Vector<Vector<Vector<real_t> > > values_rsk(__gaussLobattoX.numberOfPoints());
00286     for (size_t r=0; r<__gaussLobattoX.numberOfPoints(); ++r) {
00287       values_rsk[r].resize( __gaussLobattoY.numberOfPoints());
00288       for (size_t s=0; s<__gaussLobattoY.numberOfPoints(); ++s) {
00289         values_rsk[r][s].resize( __basisZ.dimension());
00290         values_rsk[r][s] = 0;
00291       }
00292     }
00293     
00294     {
00295       for (size_t r=0; r < __gaussLobattoX.numberOfPoints(); ++r) {
00296         for (size_t s=0; s < __gaussLobattoY.numberOfPoints(); ++s) {
00297           for (size_t t=0; t < __gaussLobattoZ.numberOfPoints(); ++t) {
00298             const real_t& wt = __gaussLobattoZ.weight(t);
00299             const real_t value_rst = f_rst[r][s][t]* wt;
00300             for (size_t k=0; k<__basisZ.dimension(); ++k) {
00301               values_rsk[r][s][k] += value_rst * quadratureBaseValuesZ[t][k];
00302             }
00303           }
00304         }
00305       }
00306     }
00307 
00308     Vector<Vector<Vector<real_t> > > values_rjk(__gaussLobattoX.numberOfPoints());
00309     for (size_t r=0; r<__gaussLobattoX.numberOfPoints(); ++r) {
00310       values_rjk[r].resize( __basisY.dimension());
00311       for (size_t j=0; j<__basisY.dimension(); ++j) {
00312         values_rjk[r][j].resize( __basisZ.dimension());
00313         values_rjk[r][j] = 0;
00314       }
00315     }
00316     
00317     {
00318       for (size_t r=0; r < __gaussLobattoX.numberOfPoints(); ++r) {
00319         for (size_t s=0; s < __gaussLobattoY.numberOfPoints(); ++s) {
00320           const real_t& ws = __gaussLobattoY.weight(s);
00321           for (size_t k=0; k < __basisZ.dimension(); ++k) {
00322             const real_t value_rsk = values_rsk[r][s][k]* ws;
00323             for (size_t j=0; j<__basisY.dimension(); ++j) {
00324               values_rjk[r][j][k] += value_rsk * quadratureBaseValuesY[s][j];
00325             }
00326           }
00327         }
00328       }
00329     }
00330     
00331     {
00332       
00333       for (size_t r=0; r < __gaussLobattoX.numberOfPoints(); ++r) {
00334         const real_t& wr = __gaussLobattoX.weight(r);
00335         //size_t l=0;
00336         for (size_t j=0; j < __basisY.dimension(); ++j) {
00337           for (size_t k=0; k < __basisZ.dimension(); ++k) {
00338             const real_t value_rjk = values_rjk[r][j][k]* wr;
00339             for (size_t i=0; i<__basisX.dimension(); ++i) {
00340               __values[__mesh->dofNumber(i,j,k)] +=
00341                 value_rjk * quadratureBaseValuesX[r][i];
00342               // l++;
00343             }
00344           }
00345         }
00346       }
00347     }
00348     
00352     // size_t l = 0;
00353     for (size_t i=0; i<__basisX.dimension(); ++i) {
00354       const real_t wi_8 = 1./8. * (2*i+1);
00355       for (size_t j=0;j<__basisY.dimension(); ++j) { 
00356         const real_t wi_wj_8 = wi_8 * (2*j+1);
00357         for (size_t k=0; k<__basisZ.dimension(); ++k) {
00358           const real_t wi_wj_wk_8 = wi_wj_8 * (2*k+1);
00359           __values[__mesh->dofNumber(i,j,k)] *= wi_wj_wk_8;
00360           //  l++;
00361         }
00362       }
00363     }
00364   }

Here is the call graph for this function:

real_t SpectralFunction::dx ( const TinyVector< 3 > &  x  )  const [inline]

Evaluates first derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_x f at position x $

Definition at line 373 of file SpectralFunction.hpp.

References __basisX, __basisY, __basisZ, __transformX, __transformY, __transformZ, __values, LegendreBasis::dimension(), LegendreBasis::getDerivativeValues(), LegendreBasis::getValues(), SpectralConformTransformation::inverse(), SpectralConformTransformation::inverseDeterminant(), and ScalarFunctionBase::sum.

00374   {
00375     Vector<real_t> baseDerivativeValuesX(__basisX.dimension());
00376     Vector<real_t> baseValuesY(__basisY.dimension());
00377     Vector<real_t> baseValuesZ(__basisZ.dimension());
00378 
00379     __basisX.getDerivativeValues(__transformX.inverse(x[0]),baseDerivativeValuesX);
00380     __basisY.getValues(__transformY.inverse(x[1]),baseValuesY);
00381     __basisZ.getValues(__transformZ.inverse(x[2]),baseValuesZ);
00382 
00383     size_t l = 0;
00384     real_t sum = 0;
00385     for (size_t i=0; i<__basisX.dimension(); ++i) {
00386       const real_t vi = baseDerivativeValuesX[i];
00387       for (size_t j=0;j<__basisY.dimension(); ++j) { 
00388         const real_t vj = baseValuesY[j];
00389         const real_t vi_vj = vi*vj;
00390         for (size_t k=0; k<__basisZ.dimension(); ++k) {
00391           const real_t vk = baseValuesZ[k];
00392           const real_t vi_vj_vk = vi_vj * vk;
00393           sum += vi_vj_vk*__values[l];
00394           l++;
00395         }
00396       }
00397     }
00398     
00399     return sum * __transformX.inverseDeterminant();
00400   }

Here is the call graph for this function:

real_t SpectralFunction::dy ( const TinyVector< 3 > &  x  )  const [inline]

Evaluates second derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_y f at position x $

Definition at line 409 of file SpectralFunction.hpp.

References __basisX, __basisY, __basisZ, __transformX, __transformY, __transformZ, __values, LegendreBasis::dimension(), LegendreBasis::getDerivativeValues(), LegendreBasis::getValues(), SpectralConformTransformation::inverse(), SpectralConformTransformation::inverseDeterminant(), and ScalarFunctionBase::sum.

00410   {
00411     Vector<real_t> baseValuesX(__basisX.dimension());
00412     Vector<real_t> baseDerivativeValuesY(__basisY.dimension());
00413     Vector<real_t> baseValuesZ(__basisZ.dimension());
00414 
00415     __basisX.getValues(__transformX.inverse(x[0]),baseValuesX);
00416     __basisY.getDerivativeValues(__transformY.inverse(x[1]),baseDerivativeValuesY);
00417     __basisZ.getValues(__transformZ.inverse(x[2]),baseValuesZ);
00418 
00419     size_t l = 0;
00420     real_t sum = 0;
00421     for (size_t i=0; i<__basisX.dimension(); ++i) {
00422       const real_t vi = baseValuesX[i];
00423       for (size_t j=0;j<__basisY.dimension(); ++j) { 
00424         const real_t vj = baseDerivativeValuesY[j];
00425         const real_t vi_vj = vi*vj;
00426         for (size_t k=0; k<__basisZ.dimension(); ++k) {
00427           const real_t vk = baseValuesZ[k];
00428           const real_t vi_vj_vk = vi_vj * vk;
00429           sum += vi_vj_vk*__values[l];
00430           l++;
00431         }
00432       }
00433     }
00434     
00435     return sum * __transformY.inverseDeterminant();
00436   }

Here is the call graph for this function:

real_t SpectralFunction::dz ( const TinyVector< 3 > &  x  )  const [inline]

Evaluates third derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_z f at position x $

Definition at line 445 of file SpectralFunction.hpp.

References __basisX, __basisY, __basisZ, __transformX, __transformY, __transformZ, __values, LegendreBasis::dimension(), LegendreBasis::getDerivativeValues(), LegendreBasis::getValues(), SpectralConformTransformation::inverse(), SpectralConformTransformation::inverseDeterminant(), and ScalarFunctionBase::sum.

00446   {
00447     Vector<real_t> baseValuesX(__basisX.dimension());
00448     Vector<real_t> baseValuesY(__basisY.dimension());
00449     Vector<real_t> baseDerivativeValuesZ(__basisZ.dimension());
00450    
00451     __basisX.getValues(__transformX.inverse(x[0]),baseValuesX);
00452     __basisY.getValues(__transformY.inverse(x[1]),baseValuesY);
00453     __basisZ.getDerivativeValues(__transformZ.inverse(x[2]),baseDerivativeValuesZ);
00454   
00455     size_t l = 0;
00456     real_t sum = 0;
00457     for (size_t i=0; i<__basisX.dimension(); ++i) {
00458       const real_t vi = baseValuesX[i];
00459       for (size_t j=0;j<__basisY.dimension(); ++j) { 
00460         const real_t vj = baseValuesY[j];
00461         const real_t vi_vj = vi*vj;
00462         for (size_t k=0; k<__basisZ.dimension(); ++k) {
00463           const real_t vk = baseDerivativeValuesZ[k];
00464           const real_t vi_vj_vk = vi_vj * vk;
00465           sum += vi_vj_vk*__values[l];
00466           l++;
00467         }
00468       }
00469     }
00470     
00471     return sum * __transformZ.inverseDeterminant();
00472   }

Here is the call graph for this function:

void ScalarFunctionBase::setName ( const std::string &  name  )  [inline, inherited]

Sets the name of the function

Parameters:
name name to give to this function

Definition at line 109 of file ScalarFunctionBase.hpp.

References ScalarFunctionBase::__name.

Referenced by FunctionExpressionVariable::execute().

00110   {
00111     __name = name;
00112   }

const std::string& ScalarFunctionBase::name (  )  const [inline, inherited]

Gets the name of the function

Returns:
__name

Definition at line 119 of file ScalarFunctionBase.hpp.

References ScalarFunctionBase::__name.

00120   {
00121     return __name;
00122   }

const Type& ScalarFunctionBase::type (  )  const [inline, inherited]

real_t ScalarFunctionBase::operator() ( const real_t &  x,
const real_t &  y,
const real_t &  z 
) const [inline, inherited]

Evaluates the function at point $ (x,y,z) $

Parameters:
x $ x $
y $ y $
z $ z $
Returns:
$ f(x,y,z) $

Definition at line 162 of file ScalarFunctionBase.hpp.

00165   {
00166     return this->operator()(TinyVector<3, real_t>(x,y,z));    
00167   }

virtual real_t ScalarFunctionBase::dx ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates first derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_x f $ at position $ x $

Definition at line 185 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00186   {
00187     std::stringstream errorMsg;
00188 
00189     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00190     errorMsg << "the function " << (*this) << " is not of that kind"
00191              << std::ends;
00192 
00193     throw ErrorHandler(__FILE__,__LINE__,
00194                        errorMsg.str(),
00195                        ErrorHandler::normal);
00196     return 0;
00197   }

virtual real_t ScalarFunctionBase::dy ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates second derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_y f $ at position $ x $

Definition at line 206 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00207   {
00208     std::stringstream errorMsg;
00209 
00210     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00211     errorMsg << "the function " << (*this) << " is not of that kind"
00212              << std::ends;
00213 
00214     throw ErrorHandler(__FILE__,__LINE__,
00215                        errorMsg.str(),
00216                        ErrorHandler::normal);
00217     return 0;
00218   }

virtual real_t ScalarFunctionBase::dz ( const TinyVector< 3, real_t > &  x  )  const [inline, virtual, inherited]

Evaluates third derivative of the function

Parameters:
x position of evaluation
Returns:
$ \partial_z f $ at position $ x $

Definition at line 227 of file ScalarFunctionBase.hpp.

References ErrorHandler::normal.

00228   {
00229     std::stringstream errorMsg;
00230 
00231     errorMsg << "cannot compute derivative of non discrete functions :-(\n";
00232     errorMsg << "the function " << (*this) << " is not of that kind"
00233              << std::ends;
00234 
00235     throw ErrorHandler(__FILE__,__LINE__,
00236                        errorMsg.str(),
00237                        ErrorHandler::normal);
00238     return 0;
00239   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ScalarFunctionBase scalarFunction 
) [friend, inherited]

Writes the function scalarFunction to the stream os

Parameters:
os the output stream
scalarFunction the function to write
Returns:
os

Definition at line 142 of file ScalarFunctionBase.hpp.

00144   {
00145     if (scalarFunction.__name.size()>0) {
00146       os << scalarFunction.__name;
00147       return os;
00148     } else {
00149       return scalarFunction.__put(os);
00150     }
00151   }


Member Data Documentation

coefficients in the spectral basis

Definition at line 50 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), operator=(), operator[](), SpectralFunction(), and values().

the mesh where the function leaves

Definition at line 54 of file SpectralFunction.hpp.

Referenced by mesh(), and operator=().

type of discretization

Definition at line 58 of file SpectralFunction.hpp.

Referenced by discretizationType().

interval in the $ x $ direction

Definition at line 60 of file SpectralFunction.hpp.

interval in the $ y $ direction

Definition at line 61 of file SpectralFunction.hpp.

interval in the $ z $ direction

Definition at line 62 of file SpectralFunction.hpp.

geometric transformation of $ (-1,1) $ to $ (a_x,b_x) $

Definition at line 65 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

geometric transformation of $ (-1,1) $ to $ (a_y,b_y) $

Definition at line 68 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

geometric transformation of $ (-1,1) $ to $ (a_z,b_z) $

Definition at line 71 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

Quadrature points for $ (a_x,b_x) $

Definition at line 74 of file SpectralFunction.hpp.

Referenced by operator=().

Quadrature points for $ (a_y,b_y) $

Definition at line 76 of file SpectralFunction.hpp.

Referenced by operator=().

Quadrature points for $ (a_z,b_z) $

Definition at line 78 of file SpectralFunction.hpp.

Referenced by operator=().

Basis in the $ x $ direction

Definition at line 80 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

Basis in the $ y $ direction

Definition at line 81 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

Basis in the $ z $ direction

Definition at line 82 of file SpectralFunction.hpp.

Referenced by dx(), dy(), dz(), operator()(), and operator=().

Definition at line 84 of file SpectralFunction.hpp.

Definition at line 85 of file SpectralFunction.hpp.

Definition at line 86 of file SpectralFunction.hpp.

Definition at line 87 of file SpectralFunction.hpp.

const Type ScalarFunctionBase::__type [protected, inherited]

type of the function

Definition at line 90 of file ScalarFunctionBase.hpp.

Referenced by ScalarFunctionBase::type().

std::string ScalarFunctionBase::__name [protected, inherited]

name of the function

Definition at line 92 of file ScalarFunctionBase.hpp.

Referenced by ScalarFunctionBase::name(), and ScalarFunctionBase::setName().


The documentation for this class was generated from the following file:

Generated on Wed Nov 19 00:14:38 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6