/*! @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 ); }
/*! @par Revision history: - 23.01.2006, c - 02.03.2006 - 27.07.2006 */ int32 d_of_nsMinGrad( FMField *out, FMField *grad, FMField *viscosity, VolumeGeometry *vg ) { int32 ii, nQP, ret = RET_OK; float64 aux; FMField *out1 = 0, *gvel2 = 0; nQP = vg->bfGM->nLev; fmf_createAlloc( &out1, 1, 1, 1, 1 ); fmf_createAlloc( &gvel2, 1, nQP, 1, 1 ); FMF_SetFirst( out ); aux = 0.0; for (ii = 0; ii < grad->nCell; ii++) { FMF_SetCell( grad, ii ); FMF_SetCell( viscosity, ii ); FMF_SetCell( vg->det, ii ); fmf_mulATB_nn( gvel2, grad, grad ); fmf_mul( gvel2, viscosity->val ); fmf_sumLevelsMulF( out1, gvel2, vg->det->val ); aux += out1->val[0]; ERR_CheckGo( ret ); } out->val[0] = aux * 0.5; end_label: fmf_freeDestroy( &out1 ); fmf_freeDestroy( &gvel2 ); return( ret ); }
int32 d_diffusion_sa( FMField *out, FMField *grad_q, FMField *grad_p, FMField *grad_w, FMField *div_w, FMField *mtxD, Mapping *vg ) { int32 ii, dim, nQP, ret = RET_OK; FMField *aux2 = 0, *aux3 = 0, *aux4 = 0, *out0 = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; FMF_SetFirst( out ); fmf_createAlloc( &aux2, 1, nQP, dim, 1 ); fmf_createAlloc( &aux3, 1, nQP, 1, 1 ); fmf_createAlloc( &aux4, 1, nQP, dim, 1 ); fmf_createAlloc( &out0, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( grad_q, ii ); FMF_SetCell( grad_p, ii ); FMF_SetCell( grad_w, ii ); FMF_SetCell( div_w, ii ); /* div w K_ij grad_j q grad_i p */ fmf_mulAB_nn( aux2, mtxD, grad_p ); fmf_mulATB_nn( aux3, grad_q, aux2 ); fmf_mulAB_nn( out0, div_w, aux3 ); /* grad_k q K_ij grad_j w_k grad_i p */ fmf_mulATB_nn( aux4, grad_w, aux2 ); fmf_mulATB_nn( aux3, grad_q, aux4 ); fmf_subAB_nn( out0, out0, aux3 ); /* grad_k q K_ij grad_j w_k grad_i p */ fmf_mulAB_nn( aux2, grad_w, grad_p ); fmf_mulAB_nn( aux4, mtxD, aux2 ); fmf_mulATB_nn( aux3, grad_q, aux4 ); fmf_subAB_nn( out0, out0, aux3 ); fmf_sumLevelsMulF( out, out0, vg->det->val ); FMF_SetCellNext( out ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &out0 ); fmf_freeDestroy( &aux2 ); fmf_freeDestroy( &aux3 ); fmf_freeDestroy( &aux4 ); return( ret ); }