Exemple #1
0
/*!
  @par Revision history:
  - 04.09.2007, c
*/
int32 dw_mass_scalar( FMField *out, FMField *state, int32 offset,
		      FMField *bf, VolumeGeometry *vg,
		      int32 *conn, int32 nEl, int32 nEP,
		      int32 *elList, int32 elList_nRow,
		      int32 isDiff )
{
  int32 ii, iel, dim, nQP, ret = RET_OK;
  FMField *st = 0, *fp = 0, *ftfp = 0, *ftf = 0;

  nQP = vg->bfGM->nLev;
  dim = vg->bfGM->nRow;

/*   output( "%d %d %d %d %d %d\n", offset, nEl, nEP, nQP, dim, elList_nRow ); */
  if (isDiff) {
    fmf_createAlloc( &ftf, 1, nQP, nEP, nEP );

    fmf_mulATB_nn( ftf, bf, bf );

    for (ii = 0; ii < elList_nRow; ii++) {
      iel = elList[ii];

      FMF_SetCell( out, ii );
      FMF_SetCell( vg->det, iel );

      fmf_sumLevelsMulF( out, ftf, vg->det->val );

      ERR_CheckGo( ret );
    }
  } else {
    state->val = FMF_PtrFirst( state ) + offset;

    fmf_createAlloc( &st, 1, 1, 1, nEP );
    fmf_createAlloc( &fp, 1, nQP, 1, 1 );
    fmf_createAlloc( &ftfp, 1, nQP, nEP, 1 );

    for (ii = 0; ii < elList_nRow; ii++) {
      iel = elList[ii];

      FMF_SetCell( out, ii );
      FMF_SetCell( vg->det, iel );

      ele_extractNodalValuesDBD( st, state, conn + nEP * iel );

      bf_act( fp, bf, st );
      bf_actt( ftfp, bf, fp );
      fmf_sumLevelsMulF( out, ftfp, vg->det->val );

      ERR_CheckGo( ret );
    }
  }

 end_label:
  if (isDiff) {
    fmf_freeDestroy( &ftf );
  } else {
    fmf_freeDestroy( &st ); 
    fmf_freeDestroy( &fp ); 
    fmf_freeDestroy( &ftfp ); 
  }

  return( ret );
}
Exemple #2
0
/*!
  @par Revision history:
  - 21.11.2006, c
*/
int32 dw_mass( FMField *out, float64 coef, FMField *state, int32 offset,
	       FMField *bf, VolumeGeometry *vg,
	       int32 *conn, int32 nEl, int32 nEP,
	       int32 *elList, int32 elList_nRow,
	       int32 isDiff )
{
  int32 ii, iel, dim, nQP, ret = RET_OK;
  FMField *st = 0, *fu = 0, *ftfu = 0, *ftf1 = 0, *ftf = 0;

  nQP = vg->bfGM->nLev;
  dim = vg->bfGM->nRow;

/*   output( "%d %d %d %d %d %d\n", offset, nEl, nEP, nQP, dim, elList_nRow ); */
  if (isDiff) {
    fmf_createAlloc( &ftf, 1, nQP, nEP * dim, nEP * dim );
    fmf_createAlloc( &ftf1, 1, nQP, nEP, nEP );

    fmf_mulATB_nn( ftf1, bf, bf );
    bf_buildFTF( ftf, ftf1 );

/*     fmf_print( bf, stdout, 0 ); */
/*     fmf_print( ftf1, stdout, 0 ); */
/*     fmf_print( ftf, stdout, 0 ); */
/*     sys_pause(); */

    for (ii = 0; ii < elList_nRow; ii++) {
      iel = elList[ii];

      FMF_SetCell( out, ii );
      FMF_SetCell( vg->det, iel );

      fmf_sumLevelsMulF( out, ftf, vg->det->val );
/*       fmf_print( out, stdout, 0 ); */
/*       sys_pause(); */

      ERR_CheckGo( ret );
    }
  } else {
    state->val = FMF_PtrFirst( state ) + offset;

    fmf_createAlloc( &st, 1, 1, dim, nEP );
    fmf_createAlloc( &fu, 1, nQP, dim, 1 );
    fmf_createAlloc( &ftfu, 1, nQP, dim * nEP, 1 );

    for (ii = 0; ii < elList_nRow; ii++) {
      iel = elList[ii];

      FMF_SetCell( out, ii );
      FMF_SetCell( vg->det, iel );

      ele_extractNodalValuesDBD( st, state, conn + nEP * iel );

      bf_act( fu, bf, st );
      bf_actt( ftfu, bf, fu );
      fmf_sumLevelsMulF( out, ftfu, vg->det->val );

      ERR_CheckGo( ret );
    }
  }

  // E.g. 1/dt.
  fmfc_mulC( out, coef );

 end_label:
  if (isDiff) {
    fmf_freeDestroy( &ftf1 );
    fmf_freeDestroy( &ftf );
  } else {
    fmf_freeDestroy( &st ); 
    fmf_freeDestroy( &fu ); 
    fmf_freeDestroy( &ftfu ); 
  }

  return( ret );
}
/*!
  @par Revision history:
  - 30.10.2007, c
*/
int32 dw_st_adj1_supg_p( FMField *out, FMField *stateW, FMField *gradP,
			 FMField *coef, VolumeGeometry *vg_w,
			 int32 *conn_w, int32 nEl_w, int32 nEP_w,
			 int32 isDiff )
{
  int32 ii, dim, nQP, ret = RET_OK;
  FMField *stW = 0, *gPTgT = 0, *fTgPTgT = 0;
  FMField *outqp = 0;
  FMField stWv[1];

  nQP = vg_w->bfGM->nLev;
  dim = vg_w->bfGM->nRow;

  stateW->val = FMF_PtrFirst( stateW );

  fmf_createAlloc( &gPTgT, 1, nQP, dim, nEP_w * dim );
  fmf_createAlloc( &fTgPTgT, 1, nQP, nEP_w * dim, nEP_w * dim );

  if (isDiff == 0) {
    fmf_createAlloc( &outqp, 1, nQP, nEP_w * dim, 1 );

    fmf_createAlloc( &stW, 1, 1, dim, nEP_w );
    stWv->nAlloc = -1;
    fmf_pretend( stWv, 1, 1, nEP_w * dim, 1, stW->val );
  }

  for (ii = 0; ii < out->nCell; ii++) {
    FMF_SetCell( out, ii );
    FMF_SetCell( gradP, ii );
    FMF_SetCell( vg_w->bfGM, ii );
    FMF_SetCell( vg_w->det, ii );
    FMF_SetCell( coef, ii );
    FMF_SetCellX1( vg_w->bf, ii );

    // (grad p, grad).
    convect_build_vtbg( gPTgT, vg_w->bfGM, gradP );
    // (grad p, v grad).
    bf_actt( fTgPTgT, vg_w->bf, gPTgT );

    if (isDiff == 1) {
      fmf_sumLevelsMulF( out, fTgPTgT, vg_w->det->val );
    } else {
      ele_extractNodalValuesDBD( stW, stateW, conn_w + nEP_w * ii );

      // (grad p, v grad w).
      fmf_mulAB_n1( outqp, fTgPTgT, stWv );
      fmf_sumLevelsMulF( out, outqp, vg_w->det->val );
    }
    fmf_mulC( out, coef->val[0] );

    ERR_CheckGo( ret );
  }

 end_label:
  fmf_freeDestroy( &gPTgT );
  fmf_freeDestroy( &fTgPTgT );
  if (isDiff == 0) {
    fmf_freeDestroy( &stW );
    fmf_freeDestroy( &outqp );
  }

  return( ret );
}
/*!
  @par Revision history:
  - 30.10.2007, c
*/
int32 dw_st_adj2_supg_p( FMField *out, FMField *gradU, FMField *stateR,
			 FMField *coef,
			 VolumeGeometry *vg_u, VolumeGeometry *vg_r,
			 int32 *conn_r, int32 nEl_r, int32 nEP_r,
			 int32 isDiff )
{
  int32 ii, dim, nQP, nEP_u, ret = RET_OK;
  FMField *stR = 0, *gUTg = 0, *fTgUTg = 0;
  FMField *outqp = 0;
  FMField stRv[1];

  nQP = vg_u->bfGM->nLev;
  nEP_u = vg_u->bfGM->nCol;
  dim = vg_u->bfGM->nRow;

  stateR->val = FMF_PtrFirst( stateR );

  fmf_createAlloc( &gUTg, 1, nQP, dim, nEP_r );
  fmf_createAlloc( &fTgUTg, 1, nQP, nEP_u * dim, nEP_r );

  if (isDiff == 0) {
    fmf_createAlloc( &outqp, 1, nQP, nEP_u * dim, 1 );

    fmf_createAlloc( &stR, 1, 1, 1, nEP_r );
    stRv->nAlloc = -1;
    fmf_pretend( stRv, 1, 1, nEP_r, 1, stR->val );
  }

  for (ii = 0; ii < out->nCell; ii++) {
    FMF_SetCell( out, ii );
    FMF_SetCell( gradU, ii );
    FMF_SetCell( vg_r->bfGM, ii );
    FMF_SetCell( vg_u->det, ii );
    FMF_SetCell( coef, ii );
    FMF_SetCellX1( vg_u->bf, ii );

    // (grad u, grad).
    fmf_mulATB_nn( gUTg, gradU, vg_r->bfGM );

    // (v grad u, grad).
    bf_actt( fTgUTg, vg_u->bf, gUTg );

    if (isDiff == 1) {
      fmf_sumLevelsMulF( out, fTgUTg, vg_u->det->val );
    } else {
      ele_extractNodalValuesDBD( stR, stateR, conn_r + nEP_r * ii );

      // (v grad u, grad r).
      fmf_mulAB_n1( outqp, fTgUTg, stRv );
      fmf_sumLevelsMulF( out, outqp, vg_u->det->val );
    }
    fmf_mulC( out, coef->val[0] );

    ERR_CheckGo( ret );
  }

 end_label:
  fmf_freeDestroy( &gUTg );
  fmf_freeDestroy( &fTgUTg );
  if (isDiff == 0) {
    fmf_freeDestroy( &stR );
    fmf_freeDestroy( &outqp );
  }

  return( ret );
}
/*!
  @par Revision history:
  - 30.10.2007, c
*/
int32 dw_st_adj_supg_c( FMField *out, FMField *stateW,
			FMField *stateU, FMField *gradU,
			FMField *coef, VolumeGeometry *vg,
			int32 *conn, int32 nEl, int32 nEP,
			int32 isDiff )
{
  int32 ii, dim, nQP, ret = RET_OK;
  FMField *stW = 0, *gUfU = 0, *fUTg = 0;
  FMField *gUfUTg = 0, *fTgUfUTg = 0;
  FMField *gUfUTgT = 0, *fTgUfUTgT = 0;
  FMField *outdqp = 0, *outqp = 0, *out1qp = 0, *out2qp = 0;
  FMField stWv[1];

  nQP = vg->bfGM->nLev;
  dim = vg->bfGM->nRow;

  stateW->val = FMF_PtrFirst( stateW );

  fmf_createAlloc( &gUfU, 1, nQP, dim, 1 );
  fmf_createAlloc( &gUfUTgT, 1, nQP, dim, nEP * dim );
  fmf_createAlloc( &fTgUfUTgT, 1, nQP, nEP * dim, nEP * dim );

  fmf_createAlloc( &fUTg, 1, nQP, dim, nEP * dim );
  fmf_createAlloc( &gUfUTg, 1, nQP, dim, nEP * dim );
  fmf_createAlloc( &fTgUfUTg, 1, nQP, nEP * dim, nEP * dim );

  if (isDiff == 1) {
    fmf_createAlloc( &outdqp, 1, nQP, dim * nEP, dim * nEP );
  } else {
    fmf_createAlloc( &stW, 1, 1, dim, nEP );
    stWv->nAlloc = -1;
    fmf_pretend( stWv, 1, 1, nEP * dim, 1, stW->val );

    fmf_createAlloc( &out1qp, 1, nQP, dim * nEP, 1 );
    fmf_createAlloc( &out2qp, 1, nQP, dim * nEP, 1 );
    fmf_createAlloc( &outqp, 1, nQP, dim * nEP, 1 );
  }

  for (ii = 0; ii < out->nCell; ii++) {
    FMF_SetCell( out, ii );
    FMF_SetCell( stateU, ii );
    FMF_SetCell( gradU, ii );
    FMF_SetCell( vg->bfGM, ii );
    FMF_SetCell( vg->det, ii );
    FMF_SetCell( coef, ii );
    FMF_SetCellX1( vg->bf, ii );

    // u grad u.
    fmf_mulAB_nn( gUfU, gradU, stateU );
    // (u grad u, grad).
    convect_build_vtbg( gUfUTgT, vg->bfGM, gUfU );
    // (u grad u, v grad).
    bf_actt( fTgUfUTgT, vg->bf, gUfUTgT );

    // u grad.
    convect_build_vtg( fUTg, vg->bfGM, stateU );
    // (grad u, u^T grad).
    fmf_mulAB_nn( gUfUTg, gradU, fUTg );
    // (v grad u, u grad).
    bf_actt( fTgUfUTg, vg->bf, gUfUTg );

    if (isDiff == 1) {
      fmf_addAB_nn( outdqp, fTgUfUTgT, fTgUfUTg );
      fmf_sumLevelsMulF( out, outdqp, vg->det->val );
    } else {
      ele_extractNodalValuesDBD( stW, stateW, conn + nEP * ii );

      // (u grad u, v grad w).
      fmf_mulAB_n1( out1qp, fTgUfUTgT, stWv );

      // (v grad u, u grad w).
      fmf_mulAB_n1( out2qp, fTgUfUTg, stWv );

      fmf_addAB_nn( outqp, out1qp, out2qp );
      fmf_sumLevelsMulF( out, outqp, vg->det->val );

    }
    fmf_mulC( out, coef->val[0] );

    ERR_CheckGo( ret );
  }

 end_label:
  fmf_freeDestroy( &gUfU );
  fmf_freeDestroy( &gUfUTgT );
  fmf_freeDestroy( &fTgUfUTgT );
  fmf_freeDestroy( &fUTg );
  fmf_freeDestroy( &gUfUTg );
  fmf_freeDestroy( &fTgUfUTg );
  if (isDiff) {
    fmf_freeDestroy( &outdqp );
  } else {
    fmf_freeDestroy( &stW );
    fmf_freeDestroy( &out1qp );
    fmf_freeDestroy( &out2qp );
    fmf_freeDestroy( &outqp );
  }

  return( ret );
}