コード例 #1
0
ファイル: Lagrange2D.cpp プロジェクト: bbanerjee/ParSim
// get shape functions and optionally derivatives wrt x and y, but derivatives only work
// if it is a regular array. Shape functions are general
void Lagrange2D::ShapeFunction(Vector *xi,int getDeriv,double *sfxn,
									 double *xDeriv,double *yDeriv,double *zDeriv) const
{
	sfxn[0]=0.25 * (xi->x-1.)*xi->x * (xi->y-1.)*xi->y;		// (-1,-1)
	sfxn[1]=0.25 * (xi->x+1.)*xi->x * (xi->y-1.)*xi->y;		// (1,-1)
	sfxn[2]=0.25 * (xi->x+1.)*xi->x * (xi->y+1.)*xi->y;		// (1,1)
	sfxn[3]=0.25 * (xi->x-1.)*xi->x * (xi->y+1.)*xi->y;		// (-1,1)
	sfxn[4]=0.5 * (1.-xi->x*xi->x) * (xi->y-1.)*xi->y;		// (0,-1)
	sfxn[5]=0.5 * (xi->x+1.)*xi->x * (1.-xi->y*xi->y);		// (1,0)
	sfxn[6]=0.5 * (1.-xi->x*xi->x) * (xi->y+1.)*xi->y;		// (0,1)
	sfxn[7]=0.5 * (xi->x-1.)*xi->x * (1.-xi->y*xi->y);		// (-1,0)
	sfxn[8]=(1.-xi->x*xi->x) * (1.-xi->y*xi->y);			// (0,0)
	
	if(getDeriv)
	{	xDeriv[0]=0.5 * (2.*xi->x-1.) * (xi->y-1.)*xi->y/GetDeltaX();		// (-1,-1)
		xDeriv[1]=0.5 * (2.*xi->x+1.) * (xi->y-1.)*xi->y/GetDeltaX();		// (1,-1)
		xDeriv[2]=0.5 * (2.*xi->x+1.) * (xi->y+1.)*xi->y/GetDeltaX();		// (1,1)
		xDeriv[3]=0.5 * (2.*xi->x-1.) * (xi->y+1.)*xi->y/GetDeltaX();		// (-1,1)
		xDeriv[4]=(-2.*xi->x) * (xi->y-1.)*xi->y/GetDeltaX();				// (0,-1)
		xDeriv[5]=(2.*xi->x+1.) * (1.-xi->y*xi->y)/GetDeltaX();			// (1,0)
		xDeriv[6]=(-2.*xi->x) * (xi->y+1.)*xi->y/GetDeltaX();				// (0,1)
		xDeriv[7]=(2.*xi->x-1.) * (1.-xi->y*xi->y)/GetDeltaX();			// (-1,0)
		xDeriv[8]=2.0 * (-2.*xi->x) * (1.-xi->y*xi->y)/GetDeltaX();		// (0,0)
		
		yDeriv[0]=0.5 * (xi->x-1.)*xi->x * (2.*xi->y-1.)/GetDeltaY();		// (-1,-1)
		yDeriv[1]=0.5 * (xi->x+1.)*xi->x * (2.*xi->y-1.)/GetDeltaY();		// (1,-1)
		yDeriv[2]=0.5 * (xi->x+1.)*xi->x * (2.*xi->y+1.)/GetDeltaY();		// (1,1)
		yDeriv[3]=0.5 * (xi->x-1.)*xi->x * (2.*xi->y+1.)/GetDeltaY();		// (-1,1)
		yDeriv[4]=(1.-xi->x*xi->x) * (2.*xi->y-1.)/GetDeltaY();			// (0,-1)
		yDeriv[5]=(xi->x+1.)*xi->x * (-2.*xi->y)/GetDeltaY();				// (1,0)
		yDeriv[6]=(1.-xi->x*xi->x) * (2.*xi->y+1.)/GetDeltaY();			// (0,1)
		yDeriv[7]=(xi->x-1.)*xi->x * (-2.*xi->y)/GetDeltaY();				// (-1,0)
		yDeriv[8]=2.0 * (1.-xi->x*xi->x) * (-2.*xi->y)/GetDeltaY();		// (0,0)
	}
}
コード例 #2
0
 /**
  * Calculate the average dy/dx over the whole window.  This may only
  * be called after HasEnoughData() has returned true.
  */
 gcc_pure
 double DeriveAverage() const {
   auto delta_x = GetDeltaX();
   auto delta_y = GetDeltaY();
   return delta_y / delta_x;
 }
コード例 #3
0
 /**
  * Calculate the average dy/dx over the whole window.  This may only
  * be called after HasEnoughData() has returned true.
  */
 gcc_pure
 fixed DeriveAverage() const {
   const fixed delta_x = GetDeltaX();
   const fixed delta_y = GetDeltaY();
   return delta_y / delta_x;
 }