/*! @par Revision history: - 22.03.2006, c */ int32 d_sd_convect( FMField *out, FMField *stateU, FMField *gradU, FMField *stateW, FMField *divMV, FMField *gradMV, VolumeGeometry *vg_u, int32 mode ) { int32 ii, dim, nQP, ret = RET_OK; FMField *aux11 = 0, *aux = 0, *fwgu = 0, *fwgugmv = 0; FMField gum[1], gmvm[1]; nQP = vg_u->bfGM->nLev; dim = vg_u->bfGM->nRow; gum->nAlloc = -1; fmf_pretend( gum, gradU->nCell, nQP, dim, dim, gradU->val0 ); fmf_createAlloc( &fwgu, 1, nQP, 1, dim ); fmf_createAlloc( &aux11, 1, nQP, 1, 1 ); if (mode == 1) { gmvm->nAlloc = -1; fmf_pretend( gmvm, gradMV->nCell, nQP, dim, dim, gradMV->val0 ); fmf_createAlloc( &fwgugmv, 1, nQP, 1, dim ); fmf_createAlloc( &aux, 1, nQP, 1, 1 ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( stateU, ii ); FMF_SetCell( stateW, ii ); FMF_SetCell( gum, ii ); FMF_SetCell( vg_u->det, ii ); fmf_mulATB_nn( fwgu, stateW, gum ); fmf_mulAB_nn( aux11, fwgu, stateU ); if (mode == 1) { FMF_SetCell( divMV, ii ); FMF_SetCell( gmvm, ii ); fmf_mul( aux11, divMV->val ); fmf_mulAB_nn( fwgugmv, fwgu, gmvm ); fmf_mulAB_nn( aux, fwgugmv, stateU ); fmf_subAB_nn( aux11, aux11, aux ); } fmf_sumLevelsMulF( out, aux11, vg_u->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &aux11 ); fmf_freeDestroy( &fwgu ); if (mode == 1) { fmf_freeDestroy( &fwgugmv ); fmf_freeDestroy( &aux ); } 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 ); }
/*! @par Revision history: - 03.08.2006, c - 01.12.2006 */ int32 dw_biot_grad( FMField *out, float64 coef, FMField *pressure_qp, FMField *mtxD, Mapping *svg, Mapping *vvg, int32 isDiff ) { int32 ii, nEPU, nEP, dim, nQP, ret = RET_OK; FMField *dfp = 0, *gtdfp = 0, *gtd = 0, *gtdf = 0; nQP = vvg->bfGM->nLev; dim = vvg->bfGM->nRow; nEPU = vvg->bfGM->nCol; nEP = svg->bf->nCol; /* fmf_print( mtxD, stdout, 0 ); */ if (isDiff == 1) { fmf_createAlloc( >d, 1, nQP, dim * nEPU, 1 ); fmf_createAlloc( >df, 1, nQP, dim * nEPU, nEP ); } else { int32 sym = (dim + 1) * dim / 2; fmf_createAlloc( &dfp, 1, nQP, sym, 1 ); fmf_createAlloc( >dfp, 1, nQP, dim * nEPU, 1 ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( vvg->bfGM, ii ); FMF_SetCell( vvg->det, ii ); if (isDiff == 1) { FMF_SetCellX1( svg->bf, ii ); form_sdcc_actOpGT_M3( gtd, vvg->bfGM, mtxD ); fmf_mulAB_nn( gtdf, gtd, svg->bf ); fmf_sumLevelsMulF( out, gtdf, vvg->det->val ); } else { FMF_SetCell( pressure_qp, ii ); fmf_mulAB_nn( dfp, mtxD, pressure_qp ); form_sdcc_actOpGT_VS3( gtdfp, vvg->bfGM, dfp ); fmf_sumLevelsMulF( out, gtdfp, vvg->det->val ); } ERR_CheckGo( ret ); } // E.g. 1/dt. fmfc_mulC( out, coef ); end_label: if (isDiff) { fmf_freeDestroy( >d ); fmf_freeDestroy( >df ); } else { fmf_freeDestroy( &dfp ); fmf_freeDestroy( >dfp ); } return( ret ); }
int32 dw_surface_flux(FMField *out, FMField *grad, FMField *mat, FMField *bf, Mapping *sg, int32 *fis, int32 nFa, int32 nFP, int32 mode) { int32 ii, ifa, dim, nQP, nEP, ret = RET_OK; FMField *ntk = 0, *ntkg = 0, *out_qp = 0; nQP = sg->normal->nLev; dim = sg->normal->nRow; nEP = sg->bfGM->nCol; fmf_createAlloc(&ntk, 1, nQP, 1, dim); if (mode) { fmf_createAlloc(&ntkg, 1, nQP, 1, nEP); fmf_createAlloc(&out_qp, 1, nQP, nEP, nEP); } else { fmf_createAlloc(&ntkg, 1, nQP, 1, 1); fmf_createAlloc(&out_qp, 1, nQP, nEP, 1); } for (ii = 0; ii < out->nCell; ii++) { ifa = fis[ii*nFP+1]; FMF_SetCell(out, ii); FMF_SetCellX1(mat, ii); FMF_SetCell(sg->det, ii); FMF_SetCell(sg->normal, ii); FMF_SetCell(bf, ifa); fmf_mulATB_nn(ntk, sg->normal, mat); if (mode) { FMF_SetCell(sg->bfGM, ii); fmf_mulAB_nn(ntkg, ntk, sg->bfGM); } else { FMF_SetCell(grad, ii); fmf_mulAB_nn(ntkg, ntk, grad); } fmf_mulATB_nn(out_qp, bf, ntkg); fmf_sumLevelsMulF(out, out_qp, sg->det->val); ERR_CheckGo(ret); } end_label: fmf_freeDestroy(&ntk); fmf_freeDestroy(&ntkg); fmf_freeDestroy(&out_qp); return(ret); }
/*! @par Revision history: - c: 03.08.2006, r: 23.01.2008 */ int32 dw_diffusion( FMField *out, FMField *grad, FMField *mtxD, Mapping *vg, int32 isDiff ) { int32 ii, dim, nQP, nEP, ret = RET_OK; FMField *gtd = 0, *gtdg = 0, *dgp = 0, *gtdgp = 0; nQP = vg->bfGM->nLev; nEP = vg->bfGM->nCol; dim = vg->bfGM->nRow; if (isDiff) { fmf_createAlloc( >d, 1, nQP, nEP, dim ); fmf_createAlloc( >dg, 1, nQP, nEP, nEP ); } else { fmf_createAlloc( &dgp, 1, nQP, dim, 1 ); fmf_createAlloc( >dgp, 1, nQP, nEP, 1 ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); if (mtxD->nCell > 1) { FMF_SetCell( mtxD, ii ); } if (isDiff) { fmf_mulATB_nn( gtd, vg->bfGM, mtxD ); fmf_mulAB_nn( gtdg, gtd, vg->bfGM ); fmf_sumLevelsMulF( out, gtdg, vg->det->val ); } else { FMF_SetCell( grad, ii ); fmf_mulAB_nn( dgp, mtxD, grad ); fmf_mulATB_nn( gtdgp, vg->bfGM, dgp ); fmf_sumLevelsMulF( out, gtdgp, vg->det->val ); } ERR_CheckGo( ret ); } end_label: if (isDiff) { fmf_freeDestroy( >d ); fmf_freeDestroy( >dg ); } else { fmf_freeDestroy( &dgp ); fmf_freeDestroy( >dgp ); } return( ret ); }
int32 dw_surface_v_dot_n_s(FMField *out, FMField *coef, FMField *val_qp, Mapping *rsg, Mapping *csg, int32 isDiff) { int32 ii, dim, nQP, nEPR, nEPC, ret = RET_OK; FMField *aux1 = 0, *aux2 = 0; nQP = rsg->normal->nLev; dim = rsg->normal->nRow; nEPR = rsg->bf->nCol; nEPC = csg->bf->nCol; fmf_createAlloc(&aux1, 1, nQP, dim * nEPR, 1); if (isDiff) { fmf_createAlloc(&aux2, 1, nQP, dim * nEPR, nEPC); } else { fmf_createAlloc(&aux2, 1, nQP, dim * nEPR, 1); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell(out, ii); FMF_SetCellX1(coef, ii); FMF_SetCell(rsg->det, ii); FMF_SetCellX1(rsg->bf, ii); FMF_SetCell(csg->normal, ii); if (isDiff) { FMF_SetCellX1(csg->bf, ii); bf_actt(aux1, rsg->bf, csg->normal); fmf_mulAB_nn(aux2, aux1, csg->bf); fmf_mul(aux2, coef->val); fmf_sumLevelsMulF(out, aux2, rsg->det->val); } else { FMF_SetCell(val_qp, ii); bf_actt(aux1, rsg->bf, csg->normal); fmf_mulAB_nn(aux2, aux1, val_qp); fmf_mul(aux2, coef->val); fmf_sumLevelsMulF(out, aux2, rsg->det->val); } ERR_CheckGo( ret ); } end_label: fmf_freeDestroy(&aux1); fmf_freeDestroy(&aux2); return( ret ); }
int32 dw_lin_strain_fib( FMField *out, FMField *mtxD, FMField *mat, Mapping *vg ) { int32 ii, dim, sym, nQP, nEP, ret = RET_OK; FMField *aux1 = 0, *aux2 = 0; nQP = vg->bfGM->nLev; nEP = vg->bfGM->nCol; dim = vg->bfGM->nRow; sym = (dim + 1) * dim / 2; fmf_createAlloc( &aux1, 1, nQP, nEP * dim, sym ); fmf_createAlloc( &aux2, 1, nQP, nEP * dim, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( mat, ii ); FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); form_sdcc_actOpGT_M3( aux1, vg->bfGM, mtxD ); fmf_mulAB_nn( aux2, aux1, mat ); fmf_sumLevelsMulF( out, aux2, vg->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &aux1 ); fmf_freeDestroy( &aux2 ); return( ret ); }
/*! @par Revision history: - c: 25.03.2008 */ int32 de_cauchy_stress( FMField *out, FMField *strain, FMField *mtxD, VolumeGeometry *vg, int32 mode ) { int32 ii, dim, sym, nQP, ret = RET_OK; FMField *stress = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; sym = (dim + 1) * dim / 2; fmf_createAlloc( &stress, 1, nQP, sym, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( strain, ii ); FMF_SetCell( vg->det, ii ); fmf_mulAB_nn( stress, mtxD, strain ); fmf_sumLevelsMulF( out, stress, vg->det->val ); if (mode == 1) { FMF_SetCell( vg->volume, ii ); fmf_mulC( out, 1.0 / vg->volume->val[0] ); } ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &stress ); return( ret ); }
int32 d_surf_lcouple( FMField *out, FMField *stateP, FMField *gradQ, FMField *coef, Mapping *sg ) { int32 ii, dim, nQP, ret = RET_OK; FMField *aux1 = 0, *aux2 = 0; nQP = stateP->nLev; dim = coef->nRow; fmf_createAlloc(&aux1, 1, nQP, dim, 1); fmf_createAlloc(&aux2, 1, nQP, 1, 1); for (ii = 0; ii < out->nCell; ii++) { if (coef->nCell > 1) FMF_SetCell( coef, ii ); FMF_SetCell( out, ii ); FMF_SetCell( sg->det, ii ); FMF_SetCell(stateP, ii); FMF_SetCell(gradQ, ii); fmf_mulAB_nn(aux1, coef, stateP); fmf_mulATB_nn(aux2, gradQ, aux1); fmf_sumLevelsMulF(out, aux2, sg->det->val); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy(&aux1); fmf_freeDestroy(&aux2); return( ret ); }
int32 d_piezo_coupling( FMField *out, FMField *strain, FMField *charge_grad, FMField *mtxG, VolumeGeometry *vg ) { int32 ii, dim, nQP, ret = RET_OK; FMField *ge = 0, *gptge = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; fmf_createAlloc( &ge, 1, nQP, dim, 1 ); fmf_createAlloc( &gptge, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxG, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCell( strain, ii ); FMF_SetCell( charge_grad, ii ); fmf_mulAB_nn( ge, mtxG, strain ); fmf_mulATB_nn( gptge, charge_grad, ge ); fmf_sumLevelsMulF( out, gptge, vg->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &ge ); fmf_freeDestroy( &gptge ); return( ret ); }
/*! @par Revision history: - c: 12.03.2007, r: 23.01.2008 */ int32 d_diffusion( FMField *out, FMField *gradP1, FMField *gradP2, FMField *mtxD, Mapping *vg ) { int32 ii, dim, nQP, ret = RET_OK; FMField *dgp2 = 0, *gp1tdgp2 = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; fmf_createAlloc( &dgp2, 1, nQP, dim, 1 ); fmf_createAlloc( &gp1tdgp2, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCell( gradP1, ii ); FMF_SetCell( gradP2, ii ); if (mtxD->nCell > 1) { FMF_SetCell( mtxD, ii ); } fmf_mulAB_nn( dgp2, mtxD, gradP2 ); fmf_mulATB_nn( gp1tdgp2, gradP1, dgp2 ); fmf_sumLevelsMulF( out, gp1tdgp2, vg->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &dgp2 ); fmf_freeDestroy( &gp1tdgp2 ); return( ret ); }
int32 dw_surf_laplace( FMField *out, FMField *grad, FMField *coef, FMField *gbf, Mapping *sg, int32 isDiff ) { int32 ii, nEP, dim, nQP, ret = RET_OK; FMField *aux1 = 0, *aux2 = 0; nQP = gbf->nLev; dim = gbf->nRow; nEP = gbf->nCol; fmf_createAlloc( &aux1, 1, nQP, nEP, dim ); if (isDiff) fmf_createAlloc( &aux2, 1, nQP, nEP, nEP ); else fmf_createAlloc( &aux2, 1, nQP, nEP, 1 ); for (ii = 0; ii < out->nCell; ii++) { if (coef->nCell > 1) FMF_SetCell( coef, ii ); FMF_SetCell( out, ii ); FMF_SetCell( sg->det, ii ); fmf_mulATB_nn(aux1, gbf, coef); if (isDiff) { fmf_mulAB_nn(aux2, aux1, gbf); } else { FMF_SetCell(grad, ii); fmf_mulAB_nn(aux2, aux1, grad); } fmf_sumLevelsMulF(out, aux2, sg->det->val); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy(&aux1); fmf_freeDestroy(&aux2); return( ret ); }
/*! @par Revision history: - 04.05.2007, c - 30.05.2007 */ int32 sg_evaluateBFBGM( SurfaceGeometry *obj, FMField *bfBGR, float64 *coorIn, int32 nNod, int32 dim, int32 *fis, int32 nFa, int32 nFP, int32 *conn, int32 nEl, int32 nEP ) { int32 ii, iel, ifa, inod, idim, pos, nQP, ret = RET_OK; FMField *volCoor0 = 0, *mtxRM = 0, *mtxRMI = 0; nQP = obj->normal->nLev; /* output( "%d %d %d %d\n", dim, nQP, nEP, nNod ); */ fmf_createAlloc( &volCoor0, 1, 1, nEP, dim ); fmf_createAlloc( &mtxRM, 1, nQP, dim, dim ); fmf_createAlloc( &mtxRMI, 1, nQP, dim, dim ); for (ii = 0; ii < nFa; ii++) { iel = fis[ii*nFP+0]; ifa = fis[ii*nFP+1]; FMF_SetCell( obj->bfBGM, ii ); FMF_SetCell( bfBGR, ifa ); for (inod = 0; inod < nEP; inod++) { pos = dim*conn[nEP*iel+inod]; for (idim = 0; idim < dim; idim++ ) { volCoor0->val[dim*inod+idim] = coorIn[idim+pos]; } } fmf_mulAB_n1( mtxRM, bfBGR, volCoor0 ); geme_invert3x3( mtxRMI, mtxRM ); fmf_mulAB_nn( obj->bfBGM, mtxRMI, bfBGR ); /* fmf_mulATBT_1n( mtxRM, volCoor0, bfBGR ); */ /* geme_invert3x3( mtxRMI, mtxRM ); */ /* fmf_mulATB_nn( obj->bfBGM, mtxRMI, bfBGR ); */ /* output( "%d %d %d\n", ii, iel, ifa); */ /* fmf_print( bfBGR, stdout, 0 ); */ /* fmf_print( volCoor0, stdout, 0 ); */ /* fmf_print( obj->bfBGM, stdout, 0 ); */ /* sys_pause(); */ ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &volCoor0 ); fmf_freeDestroy( &mtxRM ); fmf_freeDestroy( &mtxRMI ); return( RET_OK ); }
/*! @par Revision history: - 12.12.2005, c - 14.12.2005 - 22.03.2006 - 27.07.2006 */ int32 dw_adj_convect1( FMField *out, FMField *stateW, FMField *gradU, VolumeGeometry *vg, int32 isDiff ) { int32 ii, dim, nQP, nEP, ret = RET_OK; FMField *gf = 0, *ftgf = 0, *ftgfu = 0; FMField *gfu = 0; nQP = vg->bfGM->nLev; nEP = vg->bfGM->nCol; dim = vg->bfGM->nRow; if (isDiff) { fmf_createAlloc( &gf, 1, nQP, dim, dim * nEP ); fmf_createAlloc( &ftgf, 1, nQP, dim * nEP, dim * nEP ); } else { fmf_createAlloc( &gfu, 1, nQP, dim, 1 ); fmf_createAlloc( &ftgfu, 1, nQP, dim * nEP, 1 ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( gradU, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCellX1( vg->bf, ii ); if (isDiff) { bf_ract( gf, vg->bf, gradU ); bf_actt( ftgf, vg->bf, gf ); fmf_sumLevelsMulF( out, ftgf, vg->det->val ); } else { FMF_SetCell( stateW, ii ); fmf_mulAB_nn( gfu, gradU, stateW ); bf_actt( ftgfu, vg->bf, gfu ); fmf_sumLevelsMulF( out, ftgfu, vg->det->val ); } ERR_CheckGo( ret ); } end_label: if (isDiff) { fmf_freeDestroy( &gf ); fmf_freeDestroy( &ftgf ); } else { fmf_freeDestroy( &gfu ); fmf_freeDestroy( &ftgfu ); } return( ret ); }
/*! Diffusion velocity. @par Revision history: - c: 07.09.2006, r: 06.05.2008 */ int32 de_diffusion_velocity( FMField *out, FMField *state, int32 offset, FMField *mtxD, VolumeGeometry *vg, int32 *conn, int32 nEl, int32 nEP, int32 *elList, int32 elList_nRow ) { int32 ii, iel, dim, nQP, ret = RET_OK; FMField *st = 0, *gp = 0, *dgp = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; /* output( "%d %d %d %d %d %d\n", offset, nEl, nEP, nQP, dim, elList_nRow ); */ state->val = FMF_PtrFirst( state ) + offset; fmf_createAlloc( &st, 1, 1, nEP, 1 ); fmf_createAlloc( &gp, 1, nQP, dim, 1 ); fmf_createAlloc( &dgp, 1, nQP, dim, 1 ); for (ii = 0; ii < elList_nRow; ii++) { iel = elList[ii]; FMF_SetCell( out, ii ); FMF_SetCell( vg->bfGM, iel ); FMF_SetCell( vg->det, iel ); if (mtxD->nCell > 1) { FMF_SetCell( mtxD, ii ); } ele_extractNodalValuesNBN( st, state, conn + nEP * iel ); fmf_mulAB_n1( gp, vg->bfGM, st ); fmf_mulAB_nn( dgp, mtxD, gp ); fmf_sumLevelsMulF( out, dgp, vg->det->val ); ERR_CheckGo( ret ); } fmfc_mulC( out, -1.0 ); end_label: fmf_freeDestroy( &st ); fmf_freeDestroy( &gp ); fmf_freeDestroy( &dgp ); return( ret ); }
/*! @par Revision history: - 06.03.2006, c - 24.10.2007 */ int32 d_sd_div( FMField *out, FMField *divU, FMField *gradU, FMField *stateP, FMField *divMV, FMField *gradMV, VolumeGeometry *vg_u, int32 mode ) { int32 ii, nQP, ret = RET_OK; FMField *aux11 = 0; nQP = vg_u->bfGM->nLev; fmf_createAlloc( &aux11, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( stateP, ii ); FMF_SetCell( divU, ii ); FMF_SetCell( vg_u->det, ii ); fmf_mulAB_nn( aux11, stateP, divU ); if (mode == 1) { FMF_SetCell( gradU, ii ); FMF_SetCell( divMV, ii ); FMF_SetCell( gradMV, ii ); fmf_mul( aux11, divMV->val ); sub_mul_gradddgrad_scalar( aux11, gradU, gradMV, stateP ); } fmf_sumLevelsMulF( out, aux11, vg_u->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &aux11 ); return( ret ); }
/*! @par Revision history: - 02.03.2007, c */ int32 d_lin_elastic( FMField *out, float64 coef, FMField *strainV, FMField *strainU, FMField *mtxD, VolumeGeometry *vg ) { int32 ii, dim, sym, nQP, nEP, ret = RET_OK; FMField *std = 0, *stds = 0; nQP = vg->bfGM->nLev; nEP = vg->bfGM->nCol; dim = vg->bfGM->nRow; sym = (dim + 1) * dim / 2; fmf_createAlloc( &std, 1, nQP, 1, sym ); fmf_createAlloc( &stds, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCell( strainV, ii ); FMF_SetCell( strainU, ii ); fmf_mulATB_nn( std, strainV, mtxD ); fmf_mulAB_nn( stds, std, strainU ); fmf_sumLevelsMulF( out, stds, vg->det->val ); ERR_CheckGo( ret ); } // E.g. 1/dt. fmfc_mulC( out, coef ); end_label: fmf_freeDestroy( &std ); fmf_freeDestroy( &stds ); return( ret ); }
int32 d_surface_flux( FMField *out, FMField *grad, FMField *mtxD, Mapping *sg, int32 mode ) { int32 ii, dim, nQP, ret = RET_OK; FMField *dgp = 0, *ntdgp = 0; nQP = sg->normal->nLev; dim = sg->normal->nRow; fmf_createAlloc( &dgp, 1, nQP, dim, 1 ); fmf_createAlloc( &ntdgp, 1, nQP, 1, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( grad, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( sg->normal, ii ); FMF_SetCell( sg->det, ii ); fmf_mulAB_nn( dgp, mtxD, grad ); fmf_mulATB_nn( ntdgp, sg->normal, dgp ); fmf_sumLevelsMulF( out, ntdgp, sg->det->val ); if (mode == 1) { FMF_SetCell( sg->volume, ii ); fmf_mulC( out, 1.0 / sg->volume->val[0] ); } ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &dgp ); fmf_freeDestroy( &ntdgp ); return( ret ); }
int32 dw_piezo_coupling( FMField *out, FMField *strain, FMField *charge_grad, FMField *mtxG, VolumeGeometry *vg, int32 mode ) { int32 ii, nEPU, nEPP, dim, sym, nQP, ret = RET_OK; FMField *gtgp = 0, *gtgtgp = 0, *ge = 0, *gctge = 0, *gg = 0, *gctgg = 0; nQP = vg->bfGM->nLev; dim = vg->bfGM->nRow; nEPU = vg->bfGM->nCol; sym = (dim + 1) * dim / 2; if ((mode == 0) || (mode == 1)) { nEPP = out->nCol; } else { nEPP = out->nRow; } if (mode == 0) { fmf_createAlloc( >gp, 1, nQP, sym, 1 ); fmf_createAlloc( >gtgp, 1, nQP, dim * nEPU, 1 ); } else if (mode == 2) { fmf_createAlloc( &ge, 1, nQP, dim, 1 ); fmf_createAlloc( &gctge, 1, nQP, nEPP, 1 ); } else { fmf_createAlloc( &gg, 1, nQP, dim, dim * nEPU ); fmf_createAlloc( &gctgg, 1, nQP, nEPP, dim * nEPU ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxG, ii ); FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); if (mode == 0) { // vector - grad FMF_SetCell( charge_grad, ii ); fmf_mulATB_nn( gtgp, mtxG, charge_grad ); form_sdcc_actOpGT_VS3( gtgtgp, vg->bfGM, gtgp ); fmf_sumLevelsMulF( out, gtgtgp, vg->det->val ); } else if (mode == 2) { // vector - div FMF_SetCell( strain, ii ); fmf_mulAB_nn( ge, mtxG, strain ); fmf_mulATB_nn( gctge, vg->bfGM, ge ); fmf_sumLevelsMulF( out, gctge, vg->det->val ); } else { // matrix - div, grad form_sdcc_actOpG_RM3( gg, mtxG, vg->bfGM ); fmf_mulATB_nn( gctgg, vg->bfGM, gg ); if (mode == 1) { // matrix - grad fmf_sumLevelsTMulF( out, gctgg, vg->det->val ); } else { // matrix - div fmf_sumLevelsMulF( out, gctgg, vg->det->val ); } } ERR_CheckGo( ret ); } end_label: if (mode == 0) { fmf_freeDestroy( >gp ); fmf_freeDestroy( >gtgp ); } else if (mode == 2) { fmf_freeDestroy( &ge ); fmf_freeDestroy( &gctge ); } else { fmf_freeDestroy( &gg ); fmf_freeDestroy( &gctgg ); } return( ret ); }
/* dR_dx has shape (dim, n_efun), transposed w.r.t. the Python version! */ int32 eval_nurbs_basis_tp(FMField *R, FMField *dR_dx, FMField *det, FMField *dR_dxi, FMField *dx_dxi, FMField *dxi_dx, FMField *B, FMField *dB_dxi, FMField *N, FMField *dN_dxi, FMField *qp, uint32 ie, FMField *control_points, FMField *weights, int32 *degrees, int32 dim, FMField *cs, int32 *conn, int32 n_el, int32 n_ep) { int32 ret = RET_OK; uint32 ii, jj, a, i0, i1, i2; uint32 n_efuns[3]; uint32 n_efun = 1; uint32 n_els[3]; uint32 ic[3]; int32 *ec; FMField *C, *N0, *N1, *N2, *dN0_dxi, *dN1_dxi, *dN2_dxi; float64 w, W, P; float64 dw_dxi[3]; #ifdef DEBUG_FMF if (!((dim == qp->nCol) && (dim <= 3))) { errput(ErrHead "inconsistent dimension! (%d == $d <= 3)", dim, qp->nCol); ERR_CheckGo(ret); } #endif for (ii = 0; ii < dim; ii++) { n_efuns[ii] = degrees[ii] + 1; n_efun *= n_efuns[ii]; } #ifdef DEBUG_FMF if (n_efun != n_ep) { errput(ErrHead "inconsistent number of bases! (%d == $d)", n_efun, n_ep); ERR_CheckGo(ret); } #endif // Element connectivity. ec = conn + n_ep * ie; // 1D Bernstein basis B, dB/dxi. for (ii = 0; ii < dim; ii++) { eval_bernstein_basis(B + ii, dB_dxi + ii, qp->val[ii], degrees[ii]); } // 1D B-spline basis N = CB, dN/dxi = C dB/dxi. for (ii = 0; ii < dim; ii++) { n_els[ii] = (cs + ii)->nCell; } unravel_index(ic, ie, n_els, dim); for (ii = 0; ii < dim; ii++) { C = cs + ii; FMF_SetCell(C, ic[ii]); fmf_mulAB_nn(N + ii, C, B + ii); fmf_mulAB_nn(dN_dxi + ii, C, dB_dxi + ii); } ERR_CheckGo(ret); // Numerators and denominator for tensor-product NURBS basis R, dR/dxi. w = 0; // w_b for (ii = 0; ii < dim; ii++) { dw_dxi[ii] = 0.0; // dw_b/dxi } a = 0; // Basis function index. if (dim == 3) { N0 = N + 0; N1 = N + 1; N2 = N + 2; dN0_dxi = dN_dxi + 0; dN1_dxi = dN_dxi + 1; dN2_dxi = dN_dxi + 2; for (i0 = 0; i0 < n_efuns[0]; i0++) { for (i1 = 0; i1 < n_efuns[1]; i1++) { for (i2 = 0; i2 < n_efuns[2]; i2++) { W = weights->val[ec[a]]; R->val[a] = N0->val[i0] * N1->val[i1] * N2->val[i2] * W; w += R->val[a]; dR_dxi->val[a+n_ep*0] = dN0_dxi->val[i0] * N1->val[i1] * N2->val[i2] * W; dw_dxi[0] += dR_dxi->val[a+n_ep*0]; dR_dxi->val[a+n_ep*1] = N0->val[i0] * dN1_dxi->val[i1] * N2->val[i2] * W; dw_dxi[1] += dR_dxi->val[a+n_ep*1]; dR_dxi->val[a+n_ep*2] = N0->val[i0] * N1->val[i1] * dN2_dxi->val[i2] * W; dw_dxi[2] += dR_dxi->val[a+n_ep*2]; a += 1; } } } } else if (dim == 2) { N0 = N + 0; N1 = N + 1; dN0_dxi = dN_dxi + 0; dN1_dxi = dN_dxi + 1; for (i0 = 0; i0 < n_efuns[0]; i0++) { for (i1 = 0; i1 < n_efuns[1]; i1++) { W = weights->val[ec[a]]; R->val[a] = N0->val[i0] * N1->val[i1] * W; w += R->val[a]; dR_dxi->val[a+n_ep*0] = dN0_dxi->val[i0] * N1->val[i1] * W; dw_dxi[0] += dR_dxi->val[a+n_ep*0]; dR_dxi->val[a+n_ep*1] = N0->val[i0] * dN1_dxi->val[i1] * W; dw_dxi[1] += dR_dxi->val[a+n_ep*1]; a += 1; } } } else { N0 = N + 0; dN0_dxi = dN_dxi + 0; for (i0 = 0; i0 < n_efuns[0]; i0++) { W = weights->val[ec[a]]; R->val[a] = N0->val[i0] * W; w += R->val[a]; dR_dxi->val[a+n_ep*0] = dN0_dxi->val[i0] * W; dw_dxi[0] += dR_dxi->val[a+n_ep*0]; a += 1; } } // Finish R <- R / w_b. fmf_mulC(R, 1.0 / w); // Finish dR/dxi. D == W C dB/dxi, dR/dxi = (D - R dw_b/dxi) / w_b. for (a = 0; a < dR_dxi->nCol; a++) { for (ii = 0; ii < dim; ii++) { dR_dxi->val[a+n_ep*ii] = (dR_dxi->val[a+n_ep*ii] - R->val[a] * dw_dxi[ii]) / w; } } // Mapping reference -> physical domain dxi/dx. // x = sum P_a R_a, dx/dxi = sum P_a dR_a/dxi, invert. for (ii = 0; ii < dim; ii++) { for (jj = 0; jj < dim; jj++) { dx_dxi->val[dim*ii+jj] = 0.0; for (a = 0; a < dR_dxi->nCol; a++) { P = control_points->val[dim*ec[a]+ii]; dx_dxi->val[dim*ii+jj] += P * dR_dxi->val[a+n_ep*jj]; } } } geme_det3x3(det->val, dx_dxi); geme_invert3x3(dxi_dx, dx_dxi); // dR/dx. fmf_mulATB_nn(dR_dx, dxi_dx, dR_dxi); end_label: return(ret); }
int32 dw_v_dot_grad_s_vw( FMField *out, FMField *coef, FMField *grad, Mapping *vvg, Mapping *svg, int32 isDiff ) { int32 ii, nc, nEPV, nEPS, dim, nQP, ret = RET_OK; FMField *ftg = 0, *cg = 0; nQP = vvg->bfGM->nLev; dim = vvg->bfGM->nRow; nEPS = svg->bfGM->nCol; nEPV = vvg->bf->nCol; nc = coef->nCol; if (isDiff == 1) { fmf_createAlloc( &ftg, 1, nQP, dim * nEPV, nEPS ); if (nc > 1) { fmf_createAlloc( &cg, 1, nQP, dim, nEPS ); } } else { fmf_createAlloc( &ftg, 1, nQP, dim * nEPV, 1 ); if (nc > 1) { fmf_createAlloc( &cg, 1, nQP, dim, 1 ); } } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCellX1( coef, ii ); FMF_SetCell( vvg->det, ii ); FMF_SetCellX1( vvg->bf, ii ); if (isDiff == 1) { FMF_SetCell( svg->bfGM, ii ); if (nc == 1) { bf_actt( ftg, vvg->bf, svg->bfGM ); fmf_mul( ftg, coef->val ); } else { // Phi^T C Gc fmf_mulAB_nn( cg, coef, svg->bfGM ); bf_actt( ftg, vvg->bf, cg ); } } else { FMF_SetCell( grad, ii ); if (nc == 1) { bf_actt_c1( ftg, vvg->bf, grad ); fmf_mul( ftg, coef->val ); } else { // Phi^T C Gc s fmf_mulAB_nn( cg, coef, grad ); bf_actt( ftg, vvg->bf, cg ); } } fmf_sumLevelsMulF( out, ftg, vvg->det->val ); ERR_CheckGo( ret ); } end_label: fmf_freeDestroy( &ftg ); fmf_freeDestroy( &cg ); return( ret ); }
/*! @par Revision history: - 21.11.2006, c */ int32 dw_volume_dot_vector( FMField *out, FMField *coef, FMField *val_qp, Mapping *rvg, Mapping *cvg, int32 isDiff ) { int32 ii, dim, nc, nQP, nEPR, nEPC, ret = RET_OK; FMField *ftfu = 0, *ftf1 = 0, *ftf = 0,*cf = 0, *cfu = 0; nQP = rvg->nQP; dim = rvg->dim; nEPR = rvg->bf->nCol; nEPC = cvg->bf->nCol; nc = coef->nCol; if (isDiff) { fmf_createAlloc( &ftf, 1, nQP, nEPR * dim, nEPC * dim ); if (nc == 1) { fmf_createAlloc( &ftf1, 1, nQP, nEPR, nEPC ); } else { fmf_createAlloc( &cf, 1, nQP, dim, dim * nEPC ); } } else { fmf_createAlloc( &ftfu, 1, nQP, dim * nEPR, 1 ); if (nc > 1) { fmf_createAlloc( &cfu, 1, nQP, dim, 1 ); } } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCellX1( coef, ii ); FMF_SetCell( rvg->det, ii ); FMF_SetCellX1( rvg->bf, ii ); if (isDiff) { FMF_SetCellX1( cvg->bf, ii ); if (nc == 1) { fmf_mulATB_nn( ftf1, rvg->bf, cvg->bf ); bf_buildFTF( ftf, ftf1 ); fmf_mul( ftf, coef->val ); } else { bf_ract( cf, cvg->bf, coef ); bf_actt( ftf, rvg->bf, cf ); } fmf_sumLevelsMulF( out, ftf, rvg->det->val ); } else { FMF_SetCell( val_qp, ii ); if (nc == 1) { bf_actt( ftfu, rvg->bf, val_qp ); fmf_mul( ftfu, coef->val ); } else { fmf_mulAB_nn( cfu, coef, val_qp ); bf_actt( ftfu, rvg->bf, cfu ); } fmf_sumLevelsMulF( out, ftfu, rvg->det->val ); } ERR_CheckGo( ret ); } end_label: if (isDiff) { fmf_freeDestroy( &ftf ); if (nc == 1) { fmf_freeDestroy( &ftf1 ); } else { fmf_freeDestroy( &cf ); } } else { fmf_freeDestroy( &ftfu ); if (nc > 1) { fmf_freeDestroy( &cfu ); } } return( ret ); }
/*! @par Revision history: - 08.01.2006, c - 09.01.2006 - 27.02.2006 - 06.03.2006 - 07.03.2006 */ int32 d_sd_div_grad( FMField *out, FMField *gradU, FMField *gradW, FMField *divMV, FMField *gradMV, FMField *viscosity, VolumeGeometry *vg_u, int32 mode ) { int32 ii, dim, nQP, ret = RET_OK; FMField *uvel = 0, *aux = 0, *aux1 = 0, *aux2 = 0, *aux3 = 0; FMField gum[1], gwm[1], gmvm[1], aux3m[1]; nQP = vg_u->bfGM->nLev; dim = vg_u->bfGM->nRow; fmf_createAlloc( &uvel, 1, nQP, 1, 1 ); if (mode == 1) { fmf_createAlloc( &aux, 1, 1, 1, 1 ); fmf_createAlloc( &aux1, 1, nQP, 1, 1 ); fmf_createAlloc( &aux2, 1, nQP, 1, 1 ); fmf_createAlloc( &aux3, 1, nQP, dim * dim, 1 ); aux3m->nAlloc = -1; fmf_pretend( aux3m, 1, nQP, dim, dim, aux3->val ); gum->nAlloc = -1; fmf_pretend( gum, gradU->nCell, nQP, dim, dim, gradU->val0 ); gwm->nAlloc = -1; fmf_pretend( gwm, gradW->nCell, nQP, dim, dim, gradW->val0 ); gmvm->nAlloc = -1; fmf_pretend( gmvm, gradMV->nCell, nQP, dim, dim, gradMV->val0 ); } for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( gradU, ii ); FMF_SetCell( gradW, ii ); FMF_SetCell( viscosity, ii ); FMF_SetCell( vg_u->det, ii ); // (gu:gw) fmf_mulATB_nn( uvel, gradW, gradU ); if (mode == 0) { fmf_mul( uvel, viscosity->val ); fmf_sumLevelsMulF( out, uvel, vg_u->det->val ); } else if (mode == 1) { FMF_SetCell( divMV, ii ); FMF_SetCell( gum, ii ); FMF_SetCell( gwm, ii ); FMF_SetCell( gmvm, ii ); // (gu:gw) div nu fmf_mulAB_nn( aux1, uvel, divMV ); fmf_mul( aux1, viscosity->val ); fmf_sumLevelsMulF( out, aux1, vg_u->det->val ); // (gu * gnu) : gw fmf_mulAB_nn( aux3m, gum, gmvm ); fmf_mulATB_nn( aux1, aux3, gradW ); // (gw * gnu) : gu fmf_mulAB_nn( aux3m, gwm, gmvm ); fmf_mulATB_nn( aux2, aux3, gradU ); fmf_addAB_nn( aux1, aux1, aux2 ); fmf_mul( aux1, viscosity->val ); fmf_sumLevelsMulF( aux, aux1, vg_u->det->val ); fmf_subAB_nn( out, out, aux ); } ERR_CheckGo( ret ); } end_label: if (mode == 1) { fmf_freeDestroy( &aux ); fmf_freeDestroy( &aux1 ); fmf_freeDestroy( &aux2 ); fmf_freeDestroy( &aux3 ); } 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 ); }
/*! @par Revision history: - 03.08.2006, c - 29.11.2006 */ int32 dw_lin_elastic( FMField *out, float64 coef, FMField *strain, FMField *mtxD, VolumeGeometry *vg, int32 isDiff ) { int32 ii, dim, sym, nQP, nEP, ret = RET_OK; FMField *stress = 0; FMField *res = 0, *gtd = 0, *gtdg = 0; nQP = vg->bfGM->nLev; nEP = vg->bfGM->nCol; dim = vg->bfGM->nRow; sym = (dim + 1) * dim / 2; /* fmf_print( mtxD, stdout, 0 ); */ /* output( "%d %d %d %d %d %d\n", offset, nEl, nEP, nQP, dim, elList_nRow ); */ if (isDiff) { fmf_createAlloc( >d, 1, nQP, nEP * dim, sym ); fmf_createAlloc( >dg, 1, nQP, nEP * dim, nEP * dim ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); form_sdcc_actOpGT_M3( gtd, vg->bfGM, mtxD ); form_sdcc_actOpG_RM3( gtdg, gtd, vg->bfGM ); fmf_sumLevelsMulF( out, gtdg, vg->det->val ); ERR_CheckGo( ret ); } } else { fmf_createAlloc( &stress, 1, nQP, sym, 1 ); fmf_createAlloc( &res, 1, nQP, dim * nEP, 1 ); for (ii = 0; ii < out->nCell; ii++) { FMF_SetCell( out, ii ); FMF_SetCell( mtxD, ii ); FMF_SetCell( vg->bfGM, ii ); FMF_SetCell( vg->det, ii ); FMF_SetCell( strain, ii ); fmf_mulAB_nn( stress, mtxD, strain ); form_sdcc_actOpGT_VS3( res, vg->bfGM, stress ); fmf_sumLevelsMulF( out, res, vg->det->val ); ERR_CheckGo( ret ); } } // E.g. 1/dt. fmfc_mulC( out, coef ); end_label: if (isDiff) { fmf_freeDestroy( >d ); fmf_freeDestroy( >dg ); } else { fmf_freeDestroy( &res ); fmf_freeDestroy( &stress ); } return( ret ); }