示例#1
0
/*!
  @par Revision history:
  - c: 21.12.2005, r: 18.01.2008
*/
int32 sg_print( SurfaceGeometry *obj, FILE *file, int32 mode )
{
  int32 ii;

  fprintf( file, "SurfaceGeometry: mode %d, nFa %d, nQP %d, dim: %d, nFP: %d\n",
	   obj->mode, obj->nFa, obj->nQP, obj->dim, obj->nFP );
  fprintf( file, "totalArea: %.5f\n", obj->totalArea );

  for (ii = 0; ii < obj->det->nCell; ii++) {
    FMF_SetCell( obj->normal, ii );
    FMF_SetCell( obj->det, ii );
    FMF_SetCell( obj->area, ii );
    
    fprintf( file, "%d normal:\n", ii );
    fmf_print( obj->normal, file, mode );
    
    fprintf( file, "%d det:\n", ii );
    fmf_print( obj->det, file, mode );
    
    fprintf( file, "%d area:\n", ii );
    fmf_print( obj->area, file, mode );

    if (obj->bfBGM) {
      FMF_SetCell( obj->bfBGM, ii );
      fprintf( file, "%d bfBGM:\n", ii );
      fmf_print( obj->bfBGM, file, mode );
    }

  }

  return( RET_OK );
}
示例#2
0
/*!
  @par Revision history:
  - 11.10.2005, c
  - 12.10.2005
  - 12.10.2006
*/
int32 vg_print( VolumeGeometry *obj, FILE *file, int32 mode )
{
  int32 ii;

  fprintf( file, "VolumeGeometry: mode %d, nEl %d, nQP %d, dim: %d, nEP: %d\n",
	   obj->mode, obj->nEl, obj->nQP, obj->dim, obj->nEP );
  fprintf( file, "totalVolume: %.5f\n", obj->totalVolume );

  for (ii = 0; ii < obj->det->nCell; ii++) {
    FMF_SetCell( obj->bfGM, ii );
    FMF_SetCell( obj->det, ii );
    FMF_SetCell( obj->volume, ii );
    
    fprintf( file, "%d bfGM:\n", ii );
    fmf_print( obj->bfGM, file, mode );
    
    fprintf( file, "%d det:\n", ii );
    fmf_print( obj->det, file, mode );
    
    fprintf( file, "%d volume:\n", ii );
    fmf_print( obj->volume, file, mode );
  }


  return( RET_OK );
}
示例#3
0
文件: fmfield.c 项目: certik/sfepy
/*!
  @par Revision history:
  - 15.07.2002, c
  - 26.07.2002
  - 05.03.2003, adopted from rcfem2
  - 18.03.2003
*/
int32 fmfc_save( FMField *obj, const char *fileName, int32 mode )
{
  int32 ii;
  FILE *file;

  if ((file = fopen( fileName, "w" )) == 0) {
    errput( ErrHead "ERR_FileOpen\n" );
  }

  if (mode == 0) {
    FMF_SetFirst( obj );
    for (ii = 0; ii < obj->nCell; ii++) {
      fmf_print( obj, file, 0 );
      FMF_SetCellNext( obj );
    }
  } else if (mode == 1) {
    fprintf( file, "%d\n", obj->nAlloc );
    for (ii = 0; ii < obj->nAlloc; ii++) {
      fprintf( file, "%d %.12e\n", ii, obj->val0[ii] );
    }
  }

  fclose( file );

  return( RET_OK );
}
示例#4
0
文件: fmfield.c 项目: certik/sfepy
/*!
  @par Revision history:
  - 04.12.2003, c
*/
int32 fmfr_print( FMField *obj, FILE *file, int32 mode )
{
  int32 i, j, il;

  if (mode == 0) {
    fprintf( file, "%d %d %d %d %d\n", obj->nLev, obj->nRow, obj->nCol,
	     obj->offset, obj->nColFull );
    for (il = 0; il < obj->nLev; il++) {
      fprintf( file, "%d\n", il );
      for (i = 0; i < obj->nRow; i++) {
	for (j = 0; j < obj->nCol; j++) {
	  fprintf( file, " %.12e",
		   obj->val[obj->offset+obj->nColFull*(obj->nRow*il+i)+j] );
	}
	fprintf( file, "\n" );
      }
    }
  } else if (mode == 1) {
    fmf_print( obj, file, mode );
  } else {
    errput( ErrHead "ERR_Switch!\n" );
  }

  return( RET_OK );
}
示例#5
0
文件: fmfield.c 项目: certik/sfepy
/*!
  @par Revision history:
  - 06.02.2001, c
  - 05.03.2003, adopted from rcfem2
  - 18.03.2003
*/
int32 fmf_save( FMField *obj, const char *fileName, int32 mode )
{
  FILE *file;

  if ((file = fopen( fileName, "w" )) == 0) {
    errput( ErrHead "ERR_FileOpen\n" );
  }

  fmf_print( obj, file, mode );

  fclose( file );

  return( RET_OK );
}
示例#6
0
/*!
  @par Revision history:
  - 21.12.2005, c
  - 05.09.2006
*/
int32 sg_describe( SurfaceGeometry *obj,
		   float64 *coorIn, int32 nNod, int32 dim,
		   int32 *fconn, int32 nFa, int32 nFP,
		   FMField *bfGR, FMField *weight )
{
  int32 ii, pos, inod, idim, iqp, nQP, ret = RET_OK;
  float64 c1, c2, c3, det;
  float64 *jmat;
  FMField *faceCoor = 0, *mtxRMS = 0;
  
  nQP = bfGR->nLev;
  if (!((nFa == obj->nFa) &&
	(dim == obj->dim) &&
	(nQP == obj->nQP) &&
	(nFP == obj->nFP))) {
    output( "nNod: %d, dim: %d, nFa: %d, nFP: %d\n",  nNod, dim, nFa, nFP );
    fmf_print( obj->normal, stdout, 1 );
    fmf_print( bfGR, stdout, 1 );
    fmf_print( weight, stdout, 1 );
    errput( "size mismatch!\n" );
    return( RET_Fail );
  }

/*    output( "%d %d %d %d\n", dim, nQP, nFP, nNod ); */
  fmf_createAlloc( &faceCoor, 1, 1, nFP, dim );
  fmf_createAlloc( &mtxRMS, 1, nQP, dim - 1, dim );

  for (ii = 0; ii < nFa; ii++) {
    FMF_SetCell( obj->normal, ii );
    FMF_SetCell( obj->det, ii );
    FMF_SetCell( obj->area, ii );

    for (inod = 0; inod < nFP; inod++) {
      pos = dim*fconn[inod];
      for (idim = 0; idim < dim; idim++ ) {
	faceCoor->val[dim*inod+idim] = coorIn[idim+pos];
      }
    }

/*      fmf_print( faceCoor, stdout, 0 ); */
    fmf_mulAB_n1( mtxRMS, bfGR, faceCoor );
    /* Surface jacobian and normal. */
    switch (dim) {
    case 2:
      /* dl = \norma{dx} = sqrt( dx^2 + dy^2 ) */
      for (iqp = 0; iqp < nQP; iqp++) {
	jmat = FMF_PtrLevel( mtxRMS, iqp );
	c1 = jmat[0];
	c2 = jmat[1];
	det = sqrt( c1*c1 + c2*c2 );
	obj->det->val[iqp] = det * weight->val[iqp];
	/* Unit outward normal. */
	obj->normal->val[2*(iqp)+0] = c2 / det;
	obj->normal->val[2*(iqp)+1] = -c1 / det;
      }
      break;
    case 3:
      /* dS = \norma{dx x dy} */
      for (iqp = 0; iqp < nQP; iqp++) {
	jmat = FMF_PtrLevel( mtxRMS, iqp );
	c1 = jmat[1] * jmat[5] - jmat[4] * jmat[2];
	c2 = jmat[0] * jmat[5] - jmat[3] * jmat[2];
	c3 = jmat[0] * jmat[4] - jmat[1] * jmat[3];
	det = sqrt( c1*c1 + c2*c2 + c3*c3 );
	/*  	  printf( "s: %f %f %f %f\n", c1, -c2, c3, det ); */
	obj->det->val[iqp] = det * weight->val[iqp];
	/* Unit outward normal. */
	obj->normal->val[3*(iqp)+0] = c1 / det;
	obj->normal->val[3*(iqp)+1] = -c2 / det;
	obj->normal->val[3*(iqp)+2] = c3 / det;
      }
      break;
    default:
      errput( ErrHead "ERR_Switch\n" );
    }

    // Element area.
    geme_elementVolume( obj->area->val, obj->det->val, nQP );
    obj->totalArea += obj->area->val[0];

  
    fconn += nFP;
    ERR_CheckGo( ret );
  }

 end_label:
  fmf_freeDestroy( &faceCoor );
  fmf_freeDestroy( &mtxRMS );

  return( ret );
}
示例#7
0
/*!
  @par Revision history:
  - 11.10.2005, c
  - 12.10.2005
  - 05.06.2006
  - 06.06.2006
*/
int32 vg_describe( VolumeGeometry *obj,
		   float64 *coorIn, int32 nNod, int32 dim,
		   int32 *conn, int32 nEl, int32 nEP,
		   FMField *bfGR, FMField *weight )
{
  int32 iel, inod, idim, pos, iqp, nQP, ret = RET_OK;
  FMField *mtxMR = 0, *mtxMRI = 0, *coor = 0;
  
  nQP = bfGR->nLev;
  if (!((nEl == obj->nEl) &&
	(dim == obj->dim) &&
	(nQP == obj->nQP) &&
	(nEP == obj->nEP))) {
    output( "nNod: %d, dim: %d, nEl: %d, nEP: %d\n",  nNod, dim, nEl, nEP );
    fmf_print( obj->bfGM, stdout, 1 );
    fmf_print( bfGR, stdout, 1 );
    fmf_print( weight, stdout, 1 );
    errput( "size mismatch!\n" );
    return( RET_Fail );
  }

  fmf_createAlloc( &mtxMR, 1, nQP, dim, dim );
  fmf_createAlloc( &mtxMRI, 1, nQP, dim, dim );
  fmf_createAlloc( &coor, 1, 1, nEP, dim );

  obj->totalVolume = 0.0;
/*   output( "nCell %d\n",  obj->bfGM->nCell ); */
  for (iel = 0; iel < obj->bfGM->nCell; iel++) {
    FMF_SetCell( obj->bfGM, iel );
    FMF_SetCell( obj->det, iel );
    FMF_SetCell( obj->volume, iel );

    for (inod = 0; inod < nEP; inod++) {
      pos = dim*conn[inod];
      for (idim = 0; idim < dim; idim++ ) {
	coor->val[dim*inod+idim] = coorIn[idim+pos];
      }
    }

    // Jacobi matrix from reference to material system.
    fmf_mulATBT_1n( mtxMR, coor, bfGR );
    // Its determinant, preweighted.
    geme_det3x3( obj->det->val, mtxMR );
    for (iqp = 0; iqp < nQP; iqp++) {
      if (obj->det->val[iqp] <= MachEps) {
	errput( "warp violation %e at (iel: %d, iqp: %d)!\n",
		obj->det->val[iqp], iel, iqp );
      }
    }
    fmf_mul( obj->det, weight->val );

    // Element volume.
    geme_elementVolume( obj->volume->val, obj->det->val, nQP );
    obj->totalVolume += obj->volume->val[0];

    // Inverse of Jacobi matrix reference to material system.
    geme_invert3x3( mtxMRI, mtxMR );
    // Base function gradient w.r.t. material system.
    fmf_mulATB_nn( obj->bfGM, mtxMRI, bfGR );

    conn += nEP;
    
/*     output( "cell %d\n", iel ); */
/*     fmf_print( coor, stdout, 0 ); */
/*     fmf_print( obj->det, stdout, 0 ); */

    ERR_CheckGo( ret );
  }
 end_label:
  fmf_freeDestroy( &mtxMR ); 
  fmf_freeDestroy( &mtxMRI ); 
  fmf_freeDestroy( &coor ); 

  return( ret );
}