Convection< Structured3DMesh > Class Template Reference

#include <Convection.hpp>

Inheritance diagram for Convection< Structured3DMesh >:

Inheritance graph
[legend]
Collaboration diagram for Convection< Structured3DMesh >:

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

real_t operator() (const TinyVector< 3 > &X) const
 Ealuates the convected function at position X.
bool canBeSimplified () const
 Convection (const ScalarFunctionBase &phi, const FieldOfScalarFunction &u, const real_t &dt, const Structured3DMesh &M)
 ~Convection ()
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 operator() (const TinyVector< 3, real_t > &X) const =0
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
 Convection (const Convection< Structured3DMesh > &C)

Private Attributes

const real_t __deltaT
 The time interval for the equation integration.
const Structured3DMesh__mesh
 __mesh where to convect v.
const FieldOfScalarFunction__u
 The $ u$ function.
const ScalarFunctionBase__phi
 __phi The scalar function that is to convect.

Friends

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


Detailed Description

template<>
class Convection< Structured3DMesh >

Definition at line 61 of file Convection.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

Convection< Structured3DMesh >::Convection ( const Convection< Structured3DMesh > &  C  )  [private]

Forbidden copy constructor

Parameters:
C given convection function

Convection< Structured3DMesh >::Convection ( const ScalarFunctionBase phi,
const FieldOfScalarFunction u,
const real_t &  dt,
const Structured3DMesh M 
) [inline]

Constructor

Parameters:
phi the function to convect
u the velocity field
dt the time step
M the mesh

Definition at line 215 of file Convection.hpp.

References ErrorHandler::normal, and stringify().

00219     : ScalarFunctionBase(ScalarFunctionBase::convection),
00220       __deltaT(dt),
00221       __mesh(M),
00222       __u(u),
00223       __phi(phi)
00224   {
00225     if (__u.numberOfComponents() != 3) {
00226       throw ErrorHandler(__FILE__,__LINE__,
00227                          "Convection needs a 3 component field, you provided "+stringify(__u),
00228                          ErrorHandler::normal);
00229     }
00230   }

Here is the call graph for this function:

Convection< Structured3DMesh >::~Convection (  )  [inline]

Destructor

Definition at line 236 of file Convection.hpp.

00237   {
00238     ;
00239   }


Member Function Documentation

std::ostream& Convection< Structured3DMesh >::__put ( std::ostream &  os  )  const [inline, private, virtual]

writes the function to an ostream

Parameters:
os the given ostream
Returns:
os

Implements ScalarFunctionBase.

Definition at line 72 of file Convection.hpp.

00073   {
00074     os << "convect(" << __u << ","
00075        << __deltaT << ',' << __phi << ')';
00076     return os;
00077   }

real_t Convection< Structured3DMesh >::operator() ( const TinyVector< 3 > &  X  )  const [inline]

Ealuates the convected function at position X.

Definition at line 100 of file Convection.hpp.

References Connectivity< MeshType >::cells(), Mesh::T_iterator< MeshType, CellType >::end(), ConnectivityBuilder< MeshType >::generates(), Connectivity< MeshType >::hasCellToCells(), ConformTransformationQ1CartesianHexahedron::invertT(), and ConformTransformationQ1CartesianHexahedron::value().

00101   {
00102     Structured3DMesh::const_iterator h = __mesh.find(X[0], X[1], X[2]);
00103     if (h.end()) {
00104       return 0; // we are outside the mesh
00105     }
00106 
00107     const ScalarFunctionBase& u0 = *__u.function(0);
00108     const ScalarFunctionBase& u1 = *__u.function(1);
00109     const ScalarFunctionBase& u2 = *__u.function(2);
00110 
00111     const Connectivity<Structured3DMesh>& connectivity = __mesh.connectivity();
00112     if (not(connectivity.hasCellToCells())) {
00113       ConnectivityBuilder<Structured3DMesh> c(__mesh);
00114       c.generates(Connectivity<Structured3DMesh>::CellToCells);
00115     }
00116 
00117     TinyVector<3, real_t> X0 = X;
00118 
00119     TinyVector<3, real_t> Xhat0;
00120     {
00121       ConformTransformationQ1CartesianHexahedron T0(*h);
00122       T0.invertT(X0, Xhat0);
00123     }
00124 
00125     real_t dt0 = __deltaT;
00126 
00127     const size_t faceNumberConverter[6] = {4,2,1,3,0,5};
00128 
00129     do {
00130       const CartesianHexahedron& H = (*h);
00131       ConformTransformationQ1CartesianHexahedron T(H);
00132 
00133       T.value(Xhat0,X0);
00134 
00135       TinyVector<3, real_t> X1;
00136       X1[0] = X0[0]-u0(X0)*dt0;
00137       X1[1] = X0[1]-u1(X0)*dt0;
00138       X1[2] = X0[2]-u2(X0)*dt0;
00139 
00140       TinyVector<3, real_t> Xhat1;
00141       T.invertT(X1, Xhat1);
00142 
00143       if((   Xhat1[0] >= 0)
00144          and(Xhat1[1] >= 0)
00145          and(Xhat1[2] >= 0)
00146          and(Xhat1[0] <= 1)
00147          and(Xhat1[1] <= 1)
00148          and(Xhat1[2] <= 1)) {
00149         dt0 = 0;
00150         X0 = X1;
00151       } else {
00152 
00153         const TinyVector<3, real_t> deltaX = Xhat1-Xhat0;
00154         
00155         // Get the planes which are required to compute intersection
00156         TinyVector<3, real_t> x0 = 0;
00157         for (size_t i=0; i<3; ++i) {
00158           if (deltaX[i]>0) x0[i] = 1;
00159         }
00160 
00161         // Computes the linear abcisse required to reach faces
00162         TinyVector<3, real_t> coef = std::numeric_limits<real_t>::max();
00163         for (size_t i=0; i<3; ++i) {
00164           if (std::abs(deltaX[i])>0) {
00165             coef[i] = std::abs((x0[i]-Xhat0[i])/deltaX[i]);
00166           }
00167         }
00168 
00169         size_t minimumCoefficentNumber = 0;
00170         for (size_t i=1; i<3; ++i) {
00171           minimumCoefficentNumber
00172             = (coef[minimumCoefficentNumber]<coef[i])?minimumCoefficentNumber:i;
00173         }
00174 
00175         const size_t outGoingFace
00176           = faceNumberConverter[2*minimumCoefficentNumber + ((deltaX[minimumCoefficentNumber]>0)?1:0)];
00177 
00178         const real_t dt = dt0*coef[minimumCoefficentNumber];
00179 
00180         Xhat0 += coef[minimumCoefficentNumber] * deltaX;
00181         dt0-=dt;
00182 
00183         h = connectivity.cells(*h)[outGoingFace];
00184         if (h.end()) {
00185           T.value(Xhat0,X0);
00186           dt0=0;
00187         } // takes the value on the border when going outside
00188 
00189         // X0 is not updated. We compute the value of Xhat0 in the next cell
00190         // This make the periodic boundary conditions valid
00191         Xhat0[minimumCoefficentNumber] = 1-x0[minimumCoefficentNumber];
00192       }
00193     } while (dt0>0);
00194     return __phi(X0);
00195   }

Here is the call graph for this function:

bool Convection< Structured3DMesh >::canBeSimplified (  )  const [inline, virtual]

Checks if the function can be simplified

Returns:
false

Implements ScalarFunctionBase.

Definition at line 202 of file Convection.hpp.

00203   {
00204     return false;
00205   }

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::operator() ( const TinyVector< 3, real_t > &  X  )  const [pure virtual, inherited]

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

const real_t Convection< Structured3DMesh >::__deltaT [private]

The time interval for the equation integration.

Definition at line 80 of file Convection.hpp.

__mesh where to convect v.

Definition at line 83 of file Convection.hpp.

The $ u$ function.

Definition at line 86 of file Convection.hpp.

__phi The scalar function that is to convect.

Definition at line 89 of file Convection.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:05:28 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6