1 #include <lifev/navier_stokes_blocks/solver/FastAssemblerNS.hpp> 7 using namespace std::chrono;
11 using namespace LifeV;
15 FastAssemblerNS::FastAssemblerNS(
const meshPtr_Type& mesh,
const commPtr_Type& comm,
17 const fespacePtr_Type& fespace_velocity,
const fespacePtr_Type& fespace_pressure,
21 M_referenceFE_velocity ( refFE_velocity ),
22 M_referenceFE_pressure ( refFE_pressure ),
23 M_fespace_velocity ( fespace_velocity ),
24 M_fespace_pressure ( fespace_pressure ),
31 FastAssemblerNS::~FastAssemblerNS()
35 delete[] M_detJacobian;
39 for(
int i = 0 ; i < M_numElements ; i++ )
41 for (
int j = 0; j < 3; j++ )
43 delete [] M_invJacobian[i][j];
45 delete [] M_invJacobian[i];
47 delete [] M_invJacobian;
51 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
53 delete [] M_phi_velocity[i];
56 delete [] M_phi_velocity;
60 for(
int i = 0 ; i < M_referenceFE_velocity->nbDof() ; i++ )
62 for (
int j = 0; j < M_qr->nbQuadPt(); j++ )
64 delete [] M_dphi_velocity[i][j];
66 delete [] M_dphi_velocity[i];
68 delete [] M_dphi_velocity;
72 for(
int i = 0 ; i < M_referenceFE_velocity->nbDof() ; i++ )
74 for (
int j = 0; j < M_qr->nbQuadPt(); j++ )
76 for (
int k = 0; k < 3; k++ )
78 delete [] M_d2phi_velocity[i][j][k];
80 delete [] M_d2phi_velocity[i][j];
82 delete [] M_d2phi_velocity[i];
84 delete [] M_d2phi_velocity;
88 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
90 delete [] M_phi_pressure[i];
93 delete [] M_phi_pressure;
97 for(
int i = 0 ; i < M_referenceFE_pressure->nbDof() ; i++ )
99 for (
int j = 0; j < M_qr->nbQuadPt(); j++ )
101 delete [] M_dphi_pressure[i][j];
103 delete [] M_dphi_pressure[i];
105 delete [] M_dphi_pressure;
109 for(
int i = 0 ; i < M_numElements ; i++ )
111 delete [] M_elements_velocity[i];
113 delete [] M_elements_velocity;
117 for(
int i = 0 ; i < M_numElements ; i++ )
119 delete [] M_elements_pressure[i];
121 delete [] M_elements_pressure;
125 for(
int i = 0 ; i < M_numElements ; i++ )
127 delete [] M_rows_velocity[i];
128 delete [] M_cols_velocity[i];
129 delete [] M_rows_pressure[i];
130 delete [] M_cols_pressure[i];
132 delete [] M_rows_velocity;
133 delete [] M_cols_velocity;
134 delete [] M_rows_pressure;
135 delete [] M_cols_pressure;
139 for(
int i = 0 ; i < M_numElements ; i++ )
141 for (
int j = 0; j < M_referenceFE_velocity->nbDof(); j++ )
143 delete [] M_vals_00[i][j];
145 delete [] M_vals_00[i];
151 for(
int i = 0 ; i < M_numElements ; i++ )
153 for (
int j = 0; j < M_referenceFE_velocity->nbDof(); j++ )
155 delete [] M_vals_01[i][j];
157 delete [] M_vals_01[i];
163 for(
int i = 0 ; i < M_numElements ; i++ )
165 for (
int j = 0; j < M_referenceFE_pressure->nbDof(); j++ )
167 delete [] M_vals_10[i][j];
169 delete [] M_vals_10[i];
175 for(
int i = 0 ; i < M_numElements ; i++ )
177 for (
int j = 0; j < M_referenceFE_pressure->nbDof(); j++ )
179 delete [] M_vals_11[i][j];
181 delete [] M_vals_11[i];
187 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
189 for (
int k = 0; k < 3; k++ )
191 for (
int z = 0; z < 3; z++ )
193 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
195 delete [] M_vals_supg[i_elem][k][z][i];
197 delete [] M_vals_supg[i_elem][k][z];
199 delete [] M_vals_supg[i_elem][k];
201 delete [] M_vals_supg[i_elem];
203 delete [] M_vals_supg;
205 for(
int i = 0 ; i < M_numElements ; i++ )
207 for (
int k = 0; k < 3; k++ )
209 for (
int j = 0; j < M_referenceFE_velocity->nbDof(); j++ )
211 delete [] M_vals_supg_01[i][k][j];
213 delete [] M_vals_supg_01[i][k];
215 delete [] M_vals_supg_01[i];
217 delete [] M_vals_supg_01;
219 for(
int i = 0 ; i < M_numElements ; i++ )
221 for (
int k = 0; k < 3; k++ )
223 for (
int j = 0; j < M_referenceFE_pressure->nbDof(); j++ )
225 delete [] M_vals_supg_10[i][k][j];
227 delete [] M_vals_supg_10[i][k];
229 delete [] M_vals_supg_10[i];
231 delete [] M_vals_supg_10;
233 for(
int i = 0 ; i < M_numElements ; i++ )
235 delete [] M_rows_tmp[i];
236 delete [] M_cols_tmp[i];
238 delete [] M_rows_tmp;
239 delete [] M_cols_tmp;
242 for(
int i = 0 ; i < M_numElements ; i++ )
244 for (
int j = 0; j < 3; j++ )
250 delete [] M_Tau_M[i];
251 delete [] M_Tau_C[i];
252 delete [] M_Tau_M_hat[i];
258 delete [] M_Tau_M_hat;
264 FastAssemblerNS::setConstants_NavierStokes(
const Real& density,
const Real& viscosity,
const Real& timestep,
const Real& orderBDF,
const Real& C_I )
267 M_viscosity = viscosity;
268 M_timestep = timestep;
269 M_orderBDF = orderBDF;
274 FastAssemblerNS::setConstants_NavierStokes(
const Real& density,
const Real& viscosity,
const Real& timestep,
const Real& orderBDF,
const Real& C_I,
const Real& alpha )
277 M_viscosity = viscosity;
278 M_timestep = timestep;
279 M_orderBDF = orderBDF;
285 FastAssemblerNS::updateGeoQuantities (
CurrentFE* current_fe )
287 for (
int i = 0; i < M_numElements; i++ )
289 current_fe->update( M_mesh->element (i), UPDATE_D2PHI );
291 for (
int j = 0; j < 3; j++ )
293 for (
int k = 0; k < 3; k++ )
302 for (
int i = 0; i < M_numElements; i++ )
304 M_G[i][0][0] = M_invJacobian[i][0][0]*M_invJacobian[i][0][0] + M_invJacobian[i][0][1]*M_invJacobian[i][0][1] + M_invJacobian[i][0][2]*M_invJacobian[i][0][2];
305 M_G[i][0][1] = M_invJacobian[i][0][0]*M_invJacobian[i][1][0] + M_invJacobian[i][0][1]*M_invJacobian[i][1][1] + M_invJacobian[i][0][2]*M_invJacobian[i][1][2];
306 M_G[i][0][2] = M_invJacobian[i][0][0]*M_invJacobian[i][2][0] + M_invJacobian[i][0][1]*M_invJacobian[i][2][1] + M_invJacobian[i][0][2]*M_invJacobian[i][2][2];
308 M_G[i][1][0] = M_invJacobian[i][1][0]*M_invJacobian[i][0][0] + M_invJacobian[i][1][1]*M_invJacobian[i][0][1] + M_invJacobian[i][1][2]*M_invJacobian[i][0][2];
309 M_G[i][1][1] = M_invJacobian[i][1][0]*M_invJacobian[i][1][0] + M_invJacobian[i][1][1]*M_invJacobian[i][1][1] + M_invJacobian[i][1][2]*M_invJacobian[i][1][2];
310 M_G[i][1][2] = M_invJacobian[i][1][0]*M_invJacobian[i][2][0] + M_invJacobian[i][1][1]*M_invJacobian[i][2][1] + M_invJacobian[i][1][2]*M_invJacobian[i][2][2];
312 M_G[i][2][0] = M_invJacobian[i][2][0]*M_invJacobian[i][0][0] + M_invJacobian[i][2][1]*M_invJacobian[i][0][1] + M_invJacobian[i][2][2]*M_invJacobian[i][0][2];
313 M_G[i][2][1] = M_invJacobian[i][2][0]*M_invJacobian[i][1][0] + M_invJacobian[i][2][1]*M_invJacobian[i][1][1] + M_invJacobian[i][2][2]*M_invJacobian[i][1][2];
314 M_G[i][2][2] = M_invJacobian[i][2][0]*M_invJacobian[i][2][0] + M_invJacobian[i][2][1]*M_invJacobian[i][2][1] + M_invJacobian[i][2][2]*M_invJacobian[i][2][2];
315 M_g[i][0] = M_invJacobian[i][0][0] + M_invJacobian[i][0][1] + M_invJacobian[i][0][2];
316 M_g[i][1] = M_invJacobian[i][1][0] + M_invJacobian[i][1][1] + M_invJacobian[i][1][2];
317 M_g[i][2] = M_invJacobian[i][2][0] + M_invJacobian[i][2][1] + M_invJacobian[i][2][2];
323 FastAssemblerNS::allocateSpace (
CurrentFE* current_fe_velocity,
const bool& use_supg )
325 M_useSUPG = use_supg;
327 M_numElements = M_mesh->numVolumes();
329 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
331 M_detJacobian =
new double[ M_numElements ];
333 M_invJacobian =
new double** [ M_numElements ];
337 M_invJacobian =
new double** [ M_numElements];
339 for (
int i = 0; i < M_numElements; i++ )
341 M_invJacobian[i] =
new double* [ 3 ];
342 for (
int j = 0; j < 3 ; j++ )
344 M_invJacobian[i][j] =
new double [ 3 ];
348 for (
int i = 0; i < M_numElements; i++ )
350 current_fe_velocity->update( M_mesh->element (i), UPDATE_D2PHI );
352 for (
int j = 0; j < 3; j++ )
354 for (
int k = 0; k < 3; k++ )
365 M_phi_velocity =
new double* [ M_referenceFE_velocity->nbDof() ];
366 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
368 M_phi_velocity[i] =
new double [ M_qr->nbQuadPt() ];
374 for (UInt j (0); j < M_referenceFE_velocity->nbDof(); ++j)
376 M_phi_velocity[j][q] = M_referenceFE_velocity->phi (j, M_qr->quadPointCoor (q) );
384 M_dphi_velocity =
new double** [ M_referenceFE_velocity->nbDof() ];
386 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
388 M_dphi_velocity[i] =
new double* [ M_qr->nbQuadPt() ];
389 for (
int j = 0; j < M_qr->nbQuadPt() ; j++ )
391 M_dphi_velocity[i][j] =
new double [ 3 ];
398 for (UInt i (0); i < M_referenceFE_velocity->nbDof(); ++i)
400 for (UInt j (0); j < 3; ++j)
402 M_dphi_velocity[i][q][j] = M_referenceFE_velocity->dPhi (i, j, M_qr->quadPointCoor (q) );
411 M_d2phi_velocity =
new double*** [ M_referenceFE_velocity->nbDof() ];
413 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
415 M_d2phi_velocity[i] =
new double** [ M_qr->nbQuadPt() ];
416 for (
int j = 0; j < M_qr->nbQuadPt() ; j++ )
418 M_d2phi_velocity[i][j] =
new double* [ 3 ];
419 for (
int k = 0; k < 3 ; k++ )
421 M_d2phi_velocity[i][j][k] =
new double [ 3 ];
429 for (UInt i (0); i < M_referenceFE_velocity->nbDof(); ++i)
431 for (UInt j (0); j < 3; ++j)
433 for (UInt k (0); k < 3; ++k)
435 M_d2phi_velocity[i][q][j][k] = M_referenceFE_velocity->d2Phi (i, j, k, M_qr->quadPointCoor (q) );
445 M_phi_pressure =
new double* [ M_referenceFE_pressure->nbDof() ];
446 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
448 M_phi_pressure[i] =
new double [ M_qr->nbQuadPt() ];
454 for (UInt j (0); j < M_referenceFE_pressure->nbDof(); ++j)
456 M_phi_pressure[j][q] = M_referenceFE_pressure->phi (j, M_qr->quadPointCoor (q) );
464 M_dphi_pressure =
new double** [ M_referenceFE_pressure->nbDof() ];
466 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
468 M_dphi_pressure[i] =
new double* [ M_qr->nbQuadPt() ];
469 for (
int j = 0; j < M_qr->nbQuadPt() ; j++ )
471 M_dphi_pressure[i][j] =
new double [ 3 ];
478 for (UInt i (0); i < M_referenceFE_pressure->nbDof(); ++i)
480 for (UInt j (0); j < 3; ++j)
482 M_dphi_pressure[i][q][j] = M_referenceFE_pressure->dPhi (i, j, M_qr->quadPointCoor (q) );
491 M_elements_velocity =
new double* [ M_numElements ];
493 for (
int i = 0; i < M_numElements; i++ )
495 M_elements_velocity[i] =
new double [ M_referenceFE_velocity->nbDof() ];
498 for (
int i = 0; i < M_numElements; i++ )
500 for (
int j = 0; j < M_referenceFE_velocity->nbDof(); j++ )
502 M_elements_velocity[i][j] = M_fespace_velocity->dof().localToGlobalMap (i, j);
510 M_elements_pressure =
new double* [ M_numElements ];
512 for (
int i = 0; i < M_numElements; i++ )
514 M_elements_pressure[i] =
new double [ M_referenceFE_pressure->nbDof() ];
517 for (
int i = 0; i < M_numElements; i++ )
519 for (
int j = 0; j < M_referenceFE_pressure->nbDof(); j++ )
521 M_elements_pressure[i][j] = M_fespace_pressure->dof().localToGlobalMap (i, j);
529 M_rows_velocity =
new int* [M_numElements];
531 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
533 M_rows_velocity[i_elem] =
new int [ M_referenceFE_velocity->nbDof() ];
540 M_rows_pressure =
new int* [M_numElements];
542 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
544 M_rows_pressure[i_elem] =
new int [ M_referenceFE_pressure->nbDof() ];
551 M_cols_velocity =
new int* [M_numElements];
553 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
555 M_cols_velocity[i_elem] =
new int [ M_referenceFE_velocity->nbDof() ];
562 M_cols_pressure =
new int* [M_numElements];
564 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
566 M_cols_pressure[i_elem] =
new int [ M_referenceFE_pressure->nbDof() ];
573 M_vals_00 =
new double** [M_numElements];
575 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
577 M_vals_00[i_elem] =
new double* [ M_referenceFE_velocity->nbDof() ];
578 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
580 M_vals_00[i_elem][i] =
new double [ M_referenceFE_velocity->nbDof() ];
588 M_vals_01 =
new double** [M_numElements];
590 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
592 M_vals_01[i_elem] =
new double* [ M_referenceFE_velocity->nbDof() ];
593 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
595 M_vals_01[i_elem][i] =
new double [ M_referenceFE_pressure->nbDof() ];
603 M_vals_10 =
new double** [M_numElements];
605 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
607 M_vals_10[i_elem] =
new double* [ M_referenceFE_pressure->nbDof() ];
608 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
610 M_vals_10[i_elem][i] =
new double [ M_referenceFE_velocity->nbDof() ];
618 M_vals_11 =
new double** [M_numElements];
620 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
622 M_vals_11[i_elem] =
new double* [ M_referenceFE_pressure->nbDof() ];
623 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
625 M_vals_11[i_elem][i] =
new double [ M_referenceFE_pressure->nbDof() ];
635 M_vals_supg =
new double**** [M_numElements];
637 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
639 M_vals_supg[i_elem] =
new double*** [ 3 ];
640 for (
int k = 0; k < 3; k++ )
642 M_vals_supg[i_elem][k] =
new double** [ 3 ];
643 for (
int z = 0; z < 3; z++ )
645 M_vals_supg[i_elem][k][z] =
new double* [ M_referenceFE_velocity->nbDof() ];
646 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
648 M_vals_supg[i_elem][k][z][i] =
new double [ M_referenceFE_velocity->nbDof() ];
649 for (
int j = 0; j < M_referenceFE_velocity->nbDof(); j++ )
651 M_vals_supg[i_elem][k][z][i][j] = 0.0;
658 M_vals_supg_01 =
new double*** [M_numElements];
659 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
661 M_vals_supg_01[i_elem] =
new double** [ 3 ];
662 for (
int k = 0; k < 3; k++ )
664 M_vals_supg_01[i_elem][k] =
new double* [ M_referenceFE_velocity->nbDof() ];
665 for (
int i = 0; i < M_referenceFE_velocity->nbDof(); i++ )
667 M_vals_supg_01[i_elem][k][i] =
new double [ M_referenceFE_pressure->nbDof() ];
672 M_vals_supg_10 =
new double*** [M_numElements];
673 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
675 M_vals_supg_10[i_elem] =
new double** [ 3 ];
676 for (
int k = 0; k < 3; k++ )
678 M_vals_supg_10[i_elem][k] =
new double* [ M_referenceFE_pressure->nbDof() ];
679 for (
int i = 0; i < M_referenceFE_pressure->nbDof(); i++ )
681 M_vals_supg_10[i_elem][k][i] =
new double [ M_referenceFE_velocity->nbDof() ];
686 M_rows_tmp =
new int* [M_numElements];
688 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
690 M_rows_tmp[i_elem] =
new int [ M_referenceFE_velocity->nbDof() ];
693 M_cols_tmp =
new int* [M_numElements];
695 for (
int i_elem = 0; i_elem < M_numElements; i_elem++ )
697 M_cols_tmp[i_elem] =
new int [ M_referenceFE_velocity->nbDof() ];
704 M_G =
new double** [ M_numElements];
705 M_g =
new double* [ M_numElements];
707 for (
int i = 0; i < M_numElements; i++ )
709 M_G[i] =
new double* [ 3 ];
710 M_g[i] =
new double [ 3 ];
711 for (
int j = 0; j < 3 ; j++ )
713 M_G[i][j] =
new double [ 3 ];
721 M_Tau_M =
new double* [ M_numElements];
722 M_Tau_C =
new double* [ M_numElements];
723 M_Tau_M_hat =
new double* [ M_numElements];
724 for (
int i = 0; i < M_numElements; i++ )
733 for (
int i = 0; i < M_numElements; i++ )
735 M_G[i][0][0] = M_invJacobian[i][0][0]*M_invJacobian[i][0][0] + M_invJacobian[i][0][1]*M_invJacobian[i][0][1] + M_invJacobian[i][0][2]*M_invJacobian[i][0][2];
736 M_G[i][0][1] = M_invJacobian[i][0][0]*M_invJacobian[i][1][0] + M_invJacobian[i][0][1]*M_invJacobian[i][1][1] + M_invJacobian[i][0][2]*M_invJacobian[i][1][2];
737 M_G[i][0][2] = M_invJacobian[i][0][0]*M_invJacobian[i][2][0] + M_invJacobian[i][0][1]*M_invJacobian[i][2][1] + M_invJacobian[i][0][2]*M_invJacobian[i][2][2];
739 M_G[i][1][0] = M_invJacobian[i][1][0]*M_invJacobian[i][0][0] + M_invJacobian[i][1][1]*M_invJacobian[i][0][1] + M_invJacobian[i][1][2]*M_invJacobian[i][0][2];
740 M_G[i][1][1] = M_invJacobian[i][1][0]*M_invJacobian[i][1][0] + M_invJacobian[i][1][1]*M_invJacobian[i][1][1] + M_invJacobian[i][1][2]*M_invJacobian[i][1][2];
741 M_G[i][1][2] = M_invJacobian[i][1][0]*M_invJacobian[i][2][0] + M_invJacobian[i][1][1]*M_invJacobian[i][2][1] + M_invJacobian[i][1][2]*M_invJacobian[i][2][2];
743 M_G[i][2][0] = M_invJacobian[i][2][0]*M_invJacobian[i][0][0] + M_invJacobian[i][2][1]*M_invJacobian[i][0][1] + M_invJacobian[i][2][2]*M_invJacobian[i][0][2];
744 M_G[i][2][1] = M_invJacobian[i][2][0]*M_invJacobian[i][1][0] + M_invJacobian[i][2][1]*M_invJacobian[i][1][1] + M_invJacobian[i][2][2]*M_invJacobian[i][1][2];
745 M_G[i][2][2] = M_invJacobian[i][2][0]*M_invJacobian[i][2][0] + M_invJacobian[i][2][1]*M_invJacobian[i][2][1] + M_invJacobian[i][2][2]*M_invJacobian[i][2][2];
746 M_g[i][0] = M_invJacobian[i][0][0] + M_invJacobian[i][0][1] + M_invJacobian[i][0][2];
747 M_g[i][1] = M_invJacobian[i][1][0] + M_invJacobian[i][1][1] + M_invJacobian[i][1][2];
748 M_g[i][2] = M_invJacobian[i][2][0] + M_invJacobian[i][2][1] + M_invJacobian[i][2][2];
754 FastAssemblerNS::assemble_supg_terms( matrixPtr_Type& block00, matrixPtr_Type& block01, matrixPtr_Type& block10, matrixPtr_Type& block11,
const vector_Type& u_h )
756 int ndof_velocity = M_referenceFE_velocity->nbDof();
757 int ndof_pressure = M_referenceFE_pressure->nbDof();
759 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
760 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
762 double w_quad[NumQuadPoints];
763 for (
int q = 0; q < NumQuadPoints ; q++ )
768 #pragma omp parallel firstprivate( w_quad, ndof_velocity, ndof_pressure, NumQuadPoints) 770 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof, dim_mat, iCoor, jCoor, k1, k2;
771 double integral, integral_test, integral_trial, integral_partial, integral_lapl, partialSum;
773 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
774 double dphi_phys_pressure[ndof_pressure][NumQuadPoints][3];
775 double d2phi_phys_velocity[ndof_velocity][NumQuadPoints][3][3];
776 double uhq[3][NumQuadPoints];
780 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
783 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
786 for ( q = 0; q < NumQuadPoints ; q++ )
789 for ( d1 = 0; d1 < 3 ; d1++ )
791 dphi_phys_velocity[i_dof][q][d1] = 0.0;
794 for ( d2 = 0; d2 < 3 ; d2++ )
796 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
803 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
806 for ( q = 0; q < NumQuadPoints ; q++ )
809 for ( d1 = 0; d1 < 3 ; d1++ )
811 dphi_phys_pressure[i_dof][q][d1] = 0.0;
814 for ( d2 = 0; d2 < 3 ; d2++ )
816 dphi_phys_pressure[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_pressure[i_dof][q][d2];
823 for ( q = 0; q < NumQuadPoints ; q++ )
826 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
829 for ( iCoor = 0; iCoor < 3 ; iCoor++ )
832 for ( jCoor = 0; jCoor < 3 ; jCoor++ )
836 for ( k1 = 0; k1 < 3 ; k1++ )
839 for ( k2 = 0; k2 < 3 ; k2++ )
841 partialSum += M_invJacobian[i_elem][iCoor][k1]
842 * M_d2phi_velocity[i_dof][q][k1][k2]
843 * M_invJacobian[i_elem][jCoor][k2];
846 d2phi_phys_velocity[i_dof][q][iCoor][jCoor] = partialSum;
853 for ( q = 0; q < NumQuadPoints ; q++ )
855 for ( d1 = 0; d1 < 3 ; d1++ )
858 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
860 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
861 uhq[d1][q] += u_h
[e_idof] * M_phi_velocity[i_dof][q];
867 for ( q = 0; q < NumQuadPoints ; q++ )
869 M_Tau_M[i_elem][q] = 1.0/std::sqrt(
870 M_density*M_density*M_orderBDF*M_orderBDF/(M_timestep*M_timestep)
871 +M_density*M_density*( uhq[0][q]*( M_G[i_elem][0][0]* uhq[0][q] + M_G[i_elem][0][1] * uhq[1][q] + M_G[i_elem][0][2] * uhq[2][q] ) +
872 uhq[1][q]*( M_G[i_elem][1][0]* uhq[0][q] + M_G[i_elem][1][1] * uhq[1][q] + M_G[i_elem][1][2] * uhq[2][q] ) +
873 uhq[2][q]*( M_G[i_elem][2][0]* uhq[0][q] + M_G[i_elem][2][1] * uhq[1][q] + M_G[i_elem][2][2] * uhq[2][q] )
875 +M_C_I*M_viscosity*M_viscosity*(
876 M_G[i_elem][0][0]*M_G[i_elem][0][0] + M_G[i_elem][0][1]*M_G[i_elem][0][1] + M_G[i_elem][0][2]*M_G[i_elem][0][2] +
877 M_G[i_elem][1][0]*M_G[i_elem][1][0] + M_G[i_elem][1][1]*M_G[i_elem][1][1] + M_G[i_elem][1][2]*M_G[i_elem][1][2] +
878 M_G[i_elem][2][0]*M_G[i_elem][2][0] + M_G[i_elem][2][1]*M_G[i_elem][2][1] + M_G[i_elem][2][2]*M_G[i_elem][2][2]
882 M_Tau_C[i_elem][q] = 1.0/( M_g[i_elem][0]*M_Tau_M[i_elem][q]*M_g[i_elem][0] +
883 M_g[i_elem][1]*M_Tau_M[i_elem][q]*M_g[i_elem][1] +
884 M_g[i_elem][2]*M_Tau_M[i_elem][q]*M_g[i_elem][2]
890 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
892 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
895 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
897 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
901 for ( q = 0; q < NumQuadPoints ; q++ )
904 integral_trial = 0.0;
908 for ( d1 = 0; d1 < 3 ; d1++ )
910 integral_lapl += d2phi_phys_velocity[i_trial][q][d1][d1];
911 integral_test += uhq[d1][q] * dphi_phys_velocity[i_test][q][d1];
912 integral_trial += uhq[d1][q] * dphi_phys_velocity[i_trial][q][d1];
914 integral += M_Tau_M[i_elem][q] * (integral_test * integral_trial + integral_test * M_phi_velocity[i_trial][q]
915 - integral_test * integral_lapl ) * w_quad[q];
918 M_vals_supg[i_elem][0][0][i_test][i_trial] = integral * M_detJacobian[i_elem];
919 M_vals_supg[i_elem][1][1][i_test][i_trial] = integral * M_detJacobian[i_elem];
920 M_vals_supg[i_elem][2][2][i_test][i_trial] = integral * M_detJacobian[i_elem];
922 for ( d1 = 0; d1 < 3; d1++ )
924 for ( d2 = 0; d2 < 3; d2++ )
928 for ( q = 0; q < NumQuadPoints ; q++ )
930 integral += M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][d1] * dphi_phys_velocity[i_trial][q][d2] * w_quad[q];
932 M_vals_supg[i_elem][d1][d2][i_test][i_trial] += integral * M_detJacobian[i_elem];
938 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
940 for ( dim_mat = 0; dim_mat < 3 ; dim_mat++ )
942 M_cols_pressure[i_elem][i_trial] = M_elements_pressure[i_elem][i_trial];
947 for ( q = 0; q < NumQuadPoints ; q++ )
949 integral_partial = 0.0;
950 for ( d1 = 0; d1 < 3 ; d1++ )
952 integral_partial += ( dphi_phys_velocity[i_test][q][d1] * uhq[d1][q] );
954 integral += M_Tau_M[i_elem][q] * dphi_phys_pressure[i_trial][q][dim_mat] * integral_partial * w_quad[q];
956 M_vals_supg_01[i_elem][dim_mat][i_test][i_trial] = integral * M_detJacobian[i_elem];
963 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
965 M_rows_pressure[i_elem][i_test] = M_elements_pressure[i_elem][i_test];
968 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
972 for ( q = 0; q < NumQuadPoints ; q++ )
975 for ( d1 = 0; d1 < 3 ; d1++ )
977 integral += M_Tau_M[i_elem][q] * dphi_phys_pressure[i_test][q][d1] * dphi_phys_pressure[i_trial][q][d1]*w_quad[q];
980 M_vals_11[i_elem][i_test][i_trial] = 0.0;
981 M_vals_11[i_elem][i_test][i_trial] = integral * M_detJacobian[i_elem];
985 for ( dim_mat = 0; dim_mat < 3 ; dim_mat++ )
988 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
991 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
996 for ( q = 0; q < NumQuadPoints ; q++ )
998 integral_partial = 0.0;
999 for ( d1 = 0; d1 < 3 ; d1++ )
1001 integral_partial += ( dphi_phys_velocity[i_trial][q][d1] * uhq[d1][q] - d2phi_phys_velocity[i_trial][q][d1][d1] );
1003 integral += M_Tau_M[i_elem][q] * ( dphi_phys_pressure[i_test][q][dim_mat] * M_phi_velocity[i_trial][q] +
1004 dphi_phys_pressure[i_test][q][dim_mat] * integral_partial ) * w_quad[q];
1007 M_vals_supg_10[i_elem][dim_mat][i_test][i_trial] = integral * M_detJacobian[i_elem];
1014 for (
UInt d1 = 0; d1 < 3 ; d1++ )
1016 for (
int k = 0; k < M_numElements; ++k )
1018 for (
UInt i = 0; i < ndof_velocity; i++ )
1020 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
1022 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k], ndof_velocity, M_cols_velocity[k], M_vals_supg[k][d1][0], Epetra_FECrsMatrix::ROW_MAJOR);
1023 block01->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k], ndof_pressure, M_cols_pressure[k], M_vals_supg_01[k][d1], Epetra_FECrsMatrix::ROW_MAJOR);
1026 for (
int k = 0; k < M_numElements; ++k )
1028 for (
UInt i = 0; i < ndof_velocity; i++ )
1030 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
1032 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k], ndof_velocity, M_cols_tmp[k], M_vals_supg[k][d1][1], Epetra_FECrsMatrix::ROW_MAJOR);
1035 for (
int k = 0; k < M_numElements; ++k )
1037 for (
UInt i = 0; i < ndof_velocity; i++ )
1039 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
1041 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k], ndof_velocity, M_cols_tmp[k], M_vals_supg[k][d1][2], Epetra_FECrsMatrix::ROW_MAJOR);
1045 for (
int k = 0; k < M_numElements; ++k )
1047 block11->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_pressure, M_cols_pressure[k], M_vals_11[k], Epetra_FECrsMatrix::ROW_MAJOR);
1050 for (
UInt d1 = 0; d1 < 3 ; d1++ )
1052 for (
int k = 0; k < M_numElements; ++k )
1054 for (
UInt i = 0; i < ndof_velocity; i++ )
1056 M_cols_tmp[k][i] = M_cols_velocity[k][i] + d1 * M_numScalarDofs;
1058 block10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_velocity, M_cols_tmp[k], M_vals_supg_10[k][d1], Epetra_FECrsMatrix::ROW_MAJOR);
1064 FastAssemblerNS::assemble_constant_terms( matrixPtr_Type& mass, matrixPtr_Type& stiffness, matrixPtr_Type& b01, matrixPtr_Type& b10 )
1066 int ndof_velocity = M_referenceFE_velocity->nbDof();
1067 int ndof_pressure = M_referenceFE_pressure->nbDof();
1069 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
1070 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
1072 double w_quad[NumQuadPoints];
1073 for (
int q = 0; q < NumQuadPoints ; q++ )
1078 #pragma omp parallel firstprivate( w_quad, ndof_velocity, ndof_pressure, NumQuadPoints) 1080 int i_elem, i_dof, q, d1, d2, i_test, i_trial, dim_mat, dim_mat1, dim_mat2;
1081 double integral, integral_00, integral_01, integral_02, integral_10, integral_11, integral_12;
1082 double integral_20, integral_21, integral_22;
1084 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
1088 for ( i_elem = 0; i_elem < M_numElements ; i_elem++ )
1091 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1094 for ( q = 0; q < NumQuadPoints ; q++ )
1097 for ( d1 = 0; d1 < 3 ; d1++ )
1099 dphi_phys_velocity[i_dof][q][d1] = 0.0;
1102 for ( d2 = 0; d2 < 3 ; d2++ )
1104 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
1111 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1113 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
1116 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1118 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
1119 M_vals_00[i_elem][i_test][i_trial] = 0.0;
1122 for ( q = 0; q < NumQuadPoints ; q++ )
1124 integral += M_phi_velocity[i_test][q] * M_phi_velocity[i_trial][q]*w_quad[q];
1126 M_vals_00[i_elem][i_test][i_trial] = M_density * integral * M_detJacobian[i_elem];
1131 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1134 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1136 M_vals_supg[i_elem][0][0][i_test][i_trial] = 0.0;
1137 M_vals_supg[i_elem][0][1][i_test][i_trial] = 0.0;
1138 M_vals_supg[i_elem][0][2][i_test][i_trial] = 0.0;
1139 M_vals_supg[i_elem][1][0][i_test][i_trial] = 0.0;
1140 M_vals_supg[i_elem][1][1][i_test][i_trial] = 0.0;
1141 M_vals_supg[i_elem][1][2][i_test][i_trial] = 0.0;
1142 M_vals_supg[i_elem][2][0][i_test][i_trial] = 0.0;
1143 M_vals_supg[i_elem][2][1][i_test][i_trial] = 0.0;
1144 M_vals_supg[i_elem][2][2][i_test][i_trial] = 0.0;
1155 for ( q = 0; q < NumQuadPoints ; q++ )
1157 integral_00 += ( 2*dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0] +
1158 dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1] +
1159 dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2] ) * w_quad[q];
1161 integral_01 += dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][0] * w_quad[q];
1163 integral_02 += dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][0] * w_quad[q];
1165 integral_10 += dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][1] * w_quad[q];
1167 integral_11 += ( 2*dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1] +
1168 dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0] +
1169 dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2] ) * w_quad[q];
1171 integral_12 += dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][1] * w_quad[q];
1173 integral_20 += dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][2] * w_quad[q];
1175 integral_21 += dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][2] * w_quad[q];
1177 integral_22 += ( 2*dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2] +
1178 dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0] +
1179 dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1] ) * w_quad[q];
1182 M_vals_supg[i_elem][0][0][i_test][i_trial] = M_viscosity * integral_00 * M_detJacobian[i_elem];
1183 M_vals_supg[i_elem][0][1][i_test][i_trial] = M_viscosity * integral_01 * M_detJacobian[i_elem];
1184 M_vals_supg[i_elem][0][2][i_test][i_trial] = M_viscosity * integral_02 * M_detJacobian[i_elem];
1185 M_vals_supg[i_elem][1][0][i_test][i_trial] = M_viscosity * integral_10 * M_detJacobian[i_elem];
1186 M_vals_supg[i_elem][1][1][i_test][i_trial] = M_viscosity * integral_11 * M_detJacobian[i_elem];
1187 M_vals_supg[i_elem][1][2][i_test][i_trial] = M_viscosity * integral_12 * M_detJacobian[i_elem];
1188 M_vals_supg[i_elem][2][0][i_test][i_trial] = M_viscosity * integral_20 * M_detJacobian[i_elem];
1189 M_vals_supg[i_elem][2][1][i_test][i_trial] = M_viscosity * integral_21 * M_detJacobian[i_elem];
1190 M_vals_supg[i_elem][2][2][i_test][i_trial] = M_viscosity * integral_22 * M_detJacobian[i_elem];
1194 for ( dim_mat = 0; dim_mat < 3 ; dim_mat++ )
1197 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1200 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
1202 M_vals_supg_01[i_elem][dim_mat][i_test][i_trial] = 0.0;
1203 M_cols_pressure[i_elem][i_trial] = M_elements_pressure[i_elem][i_trial];
1206 for ( q = 0; q < NumQuadPoints ; q++ )
1208 integral += dphi_phys_velocity[i_test][q][dim_mat]*M_phi_pressure[i_trial][q]*w_quad[q];
1210 M_vals_supg_01[i_elem][dim_mat][i_test][i_trial] = -1.0 * integral * M_detJacobian[i_elem];
1215 for ( dim_mat = 0; dim_mat < 3 ; dim_mat++ )
1218 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
1220 M_rows_pressure[i_elem][i_test] = M_elements_pressure[i_elem][i_test];
1223 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1225 M_vals_supg_10[i_elem][dim_mat][i_test][i_trial] = 0.0;
1228 for ( q = 0; q < NumQuadPoints ; q++ )
1230 integral += dphi_phys_velocity[i_trial][q][dim_mat]*M_phi_pressure[i_test][q]*w_quad[q];
1233 M_vals_supg_10[i_elem][dim_mat][i_test][i_trial] = integral * M_detJacobian[i_elem];
1240 for (
int k = 0; k < M_numElements; ++k )
1242 mass->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_velocity[k],
1243 ndof_velocity, M_cols_velocity[k],
1245 Epetra_FECrsMatrix::ROW_MAJOR);
1247 b01->matrixPtr()->InsertGlobalValues ( ndof_velocity,
1251 M_vals_supg_01[k][0],
1252 Epetra_FECrsMatrix::ROW_MAJOR);
1254 b10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k],
1255 ndof_velocity, M_cols_velocity[k],
1256 M_vals_supg_10[k][0],
1257 Epetra_FECrsMatrix::ROW_MAJOR);
1261 for (
UInt d1 = 0; d1 < 3 ; d1++ )
1263 for (
int k = 0; k < M_numElements; ++k )
1265 for (
UInt i = 0; i < ndof_velocity; i++ )
1267 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
1269 stiffness->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1270 ndof_velocity, M_cols_velocity[k],
1271 M_vals_supg[k][d1][0],
1272 Epetra_FECrsMatrix::ROW_MAJOR);
1276 for (
int k = 0; k < M_numElements; ++k )
1278 for (
UInt i = 0; i < ndof_velocity; i++ )
1280 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
1282 stiffness->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1283 ndof_velocity, M_cols_tmp[k],
1284 M_vals_supg[k][d1][1],
1285 Epetra_FECrsMatrix::ROW_MAJOR);
1288 for (
int k = 0; k < M_numElements; ++k )
1290 for (
UInt i = 0; i < ndof_velocity; i++ )
1292 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
1294 stiffness->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1295 ndof_velocity, M_cols_tmp[k],
1296 M_vals_supg[k][d1][2],
1297 Epetra_FECrsMatrix::ROW_MAJOR);
1301 for (
UInt d1 = 1; d1 < 3 ; d1++ )
1303 for (
int k = 0; k < M_numElements; ++k )
1305 for (
UInt i = 0; i < ndof_velocity; i++ )
1307 M_rows_velocity[k][i] += M_numScalarDofs;
1308 M_cols_velocity[k][i] += M_numScalarDofs;
1310 mass->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_velocity[k],
1311 ndof_velocity, M_cols_velocity[k],
1313 Epetra_FECrsMatrix::ROW_MAJOR);
1315 b01->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_velocity[k],
1316 ndof_pressure, M_cols_pressure[k],
1317 M_vals_supg_01[k][d1],
1318 Epetra_FECrsMatrix::ROW_MAJOR);
1320 b10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k],
1321 ndof_velocity, M_cols_velocity[k],
1322 M_vals_supg_10[k][d1],
1323 Epetra_FECrsMatrix::ROW_MAJOR);
1330 FastAssemblerNS::assembleConvective( matrixPtr_Type& matrix,
const vector_Type& u_h )
1332 int ndof_velocity = M_referenceFE_velocity->nbDof();
1334 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
1335 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
1337 double w_quad[NumQuadPoints];
1338 for (
int q = 0; q < NumQuadPoints ; q++ )
1343 #pragma omp parallel firstprivate( w_quad, ndof_velocity, NumQuadPoints) 1345 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof;
1348 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
1350 double uhq[3][NumQuadPoints];
1354 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
1357 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1360 for ( q = 0; q < NumQuadPoints ; q++ )
1363 for ( d1 = 0; d1 < 3 ; d1++ )
1365 dphi_phys_velocity[i_dof][q][d1] = 0.0;
1368 for ( d2 = 0; d2 < 3 ; d2++ )
1370 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
1377 for ( q = 0; q < NumQuadPoints ; q++ )
1379 for ( d1 = 0; d1 < 3 ; d1++ )
1382 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1384 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
1385 uhq[d1][q] += u_h
[e_idof] * M_phi_velocity[i_dof][q];
1391 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1393 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
1396 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1398 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
1400 M_vals_00[i_elem][i_test][i_trial] = 0.0;
1404 for ( q = 0; q < NumQuadPoints ; q++ )
1407 for ( d1 = 0; d1 < 3 ; d1++ )
1409 integral += uhq[d1][q] * dphi_phys_velocity[i_trial][q][d1] * M_phi_velocity[i_test][q] * w_quad[q];
1412 M_vals_00[i_elem][i_test][i_trial] = M_density * integral * M_detJacobian[i_elem];
1418 for (
int k = 0; k < M_numElements; ++k )
1420 matrix->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_velocity[k],
1421 ndof_velocity, M_cols_velocity[k],
1423 Epetra_FECrsMatrix::ROW_MAJOR);
1426 for (
UInt d1 = 1; d1 < 3 ; d1++ )
1428 for (
int k = 0; k < M_numElements; ++k )
1430 for (
UInt i = 0; i < ndof_velocity; i++ )
1432 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
1433 M_cols_tmp[k][i] = M_cols_velocity[k][i] + d1 * M_numScalarDofs;
1435 matrix->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1436 ndof_velocity, M_cols_tmp[k],
1438 Epetra_FECrsMatrix::ROW_MAJOR);
1444 FastAssemblerNS::jacobianNS( matrixPtr_Type& matrix,
const vector_Type& u_h )
1446 int ndof_velocity = M_referenceFE_velocity->nbDof();
1448 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
1449 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
1451 double w_quad[NumQuadPoints];
1452 for (
int q = 0; q < NumQuadPoints ; q++ )
1457 #pragma omp parallel firstprivate( w_quad, ndof_velocity, NumQuadPoints) 1459 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof;
1460 double integral, integral_00, integral_01, integral_02, integral_10, integral_11, integral_12;
1461 double integral_20, integral_21, integral_22;
1463 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
1465 double duhq[3][3][NumQuadPoints];
1469 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
1473 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1476 for ( q = 0; q < NumQuadPoints ; q++ )
1479 for ( d1 = 0; d1 < 3 ; d1++ )
1481 dphi_phys_velocity[i_dof][q][d1] = 0.0;
1484 for ( d2 = 0; d2 < 3 ; d2++ )
1486 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
1493 for ( q = 0; q < NumQuadPoints ; q++ )
1495 for ( d1 = 0; d1 < 3 ; d1++ )
1497 for ( d2 = 0; d2 < 3 ; d2++ )
1499 duhq[d1][d2][q] = 0.0;
1500 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1502 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
1503 duhq[d1][d2][q] += u_h
[e_idof] * dphi_phys_velocity[i_dof][q][d2];
1510 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1512 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
1514 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1516 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
1518 M_vals_supg[i_elem][0][0][i_test][i_trial] = 0.0;
1519 M_vals_supg[i_elem][0][1][i_test][i_trial] = 0.0;
1520 M_vals_supg[i_elem][0][2][i_test][i_trial] = 0.0;
1521 M_vals_supg[i_elem][1][0][i_test][i_trial] = 0.0;
1522 M_vals_supg[i_elem][1][1][i_test][i_trial] = 0.0;
1523 M_vals_supg[i_elem][1][2][i_test][i_trial] = 0.0;
1524 M_vals_supg[i_elem][2][0][i_test][i_trial] = 0.0;
1525 M_vals_supg[i_elem][2][1][i_test][i_trial] = 0.0;
1526 M_vals_supg[i_elem][2][2][i_test][i_trial] = 0.0;
1537 for ( q = 0; q < NumQuadPoints ; q++ )
1539 integral_00 += M_phi_velocity[i_test][q] * duhq[0][0][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1541 integral_01 += M_phi_velocity[i_test][q] * duhq[0][1][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1543 integral_02 += M_phi_velocity[i_test][q] * duhq[0][2][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1545 integral_10 += M_phi_velocity[i_test][q] * duhq[1][0][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1547 integral_11 += M_phi_velocity[i_test][q] * duhq[1][1][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1549 integral_12 += M_phi_velocity[i_test][q] * duhq[1][2][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1551 integral_20 += M_phi_velocity[i_test][q] * duhq[2][0][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1553 integral_21 += M_phi_velocity[i_test][q] * duhq[2][1][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1555 integral_22 += M_phi_velocity[i_test][q] * duhq[2][2][q] * M_phi_velocity[i_trial][q] * w_quad[q];
1558 M_vals_supg[i_elem][0][0][i_test][i_trial] = M_density * integral_00 * M_detJacobian[i_elem];
1559 M_vals_supg[i_elem][0][1][i_test][i_trial] = M_density * integral_01 * M_detJacobian[i_elem];
1560 M_vals_supg[i_elem][0][2][i_test][i_trial] = M_density * integral_02 * M_detJacobian[i_elem];
1561 M_vals_supg[i_elem][1][0][i_test][i_trial] = M_density * integral_10 * M_detJacobian[i_elem];
1562 M_vals_supg[i_elem][1][1][i_test][i_trial] = M_density * integral_11 * M_detJacobian[i_elem];
1563 M_vals_supg[i_elem][1][2][i_test][i_trial] = M_density * integral_12 * M_detJacobian[i_elem];
1564 M_vals_supg[i_elem][2][0][i_test][i_trial] = M_density * integral_20 * M_detJacobian[i_elem];
1565 M_vals_supg[i_elem][2][1][i_test][i_trial] = M_density * integral_21 * M_detJacobian[i_elem];
1566 M_vals_supg[i_elem][2][2][i_test][i_trial] = M_density * integral_22 * M_detJacobian[i_elem];
1572 for (
UInt d1 = 0; d1 < 3 ; d1++ )
1574 for (
int k = 0; k < M_numElements; ++k )
1576 for (
UInt i = 0; i < ndof_velocity; i++ )
1578 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
1580 matrix->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1581 ndof_velocity, M_cols_velocity[k],
1582 M_vals_supg[k][d1][0],
1583 Epetra_FECrsMatrix::ROW_MAJOR);
1587 for (
int k = 0; k < M_numElements; ++k )
1589 for (
UInt i = 0; i < ndof_velocity; i++ )
1591 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
1593 matrix->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1594 ndof_velocity, M_cols_tmp[k],
1595 M_vals_supg[k][d1][1],
1596 Epetra_FECrsMatrix::ROW_MAJOR);
1599 for (
int k = 0; k < M_numElements; ++k )
1601 for (
UInt i = 0; i < ndof_velocity; i++ )
1603 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
1605 matrix->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
1606 ndof_velocity, M_cols_tmp[k],
1607 M_vals_supg[k][d1][2],
1608 Epetra_FECrsMatrix::ROW_MAJOR);
1614 FastAssemblerNS::supg_FI_FSI_terms ( matrixPtr_Type& block00,
1615 matrixPtr_Type& block01,
1616 matrixPtr_Type& block10,
1617 matrixPtr_Type& block11,
1618 const vector_Type& beta_km1,
1619 const vector_Type& u_km1,
1620 const vector_Type& p_km1,
1621 const vector_Type& u_bdf)
1623 int ndof_velocity = M_referenceFE_velocity->nbDof();
1624 int ndof_pressure = M_referenceFE_pressure->nbDof();
1626 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
1627 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
1629 double w_quad[NumQuadPoints];
1630 for (
int q = 0; q < NumQuadPoints ; q++ )
1635 #pragma omp parallel firstprivate( w_quad, ndof_velocity, ndof_pressure, NumQuadPoints) 1637 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof, dim_mat, iCoor, jCoor, k1, k2;
1638 double integral, integral_test, integral_trial, integral_partial, integral_lapl, partialSum;
1640 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
1641 double dphi_phys_pressure[ndof_pressure][NumQuadPoints][3];
1642 double d2phi_phys_velocity[ndof_velocity][NumQuadPoints][3][3];
1643 double u_km1_q[3][NumQuadPoints];
1644 double beta_km1_q[3][NumQuadPoints];
1645 double u_bdf_q[3][NumQuadPoints];
1646 double p_km1_q[NumQuadPoints];
1647 double i_00, i_01, i_02, i_10, i_11, i_12, i_20, i_21, i_22;
1648 double d_ukm1_q[3][3][NumQuadPoints];
1649 double d_pkm1_q[3][NumQuadPoints];
1653 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
1656 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1659 for ( q = 0; q < NumQuadPoints ; q++ )
1662 for ( d1 = 0; d1 < 3 ; d1++ )
1664 dphi_phys_velocity[i_dof][q][d1] = 0.0;
1667 for ( d2 = 0; d2 < 3 ; d2++ )
1669 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
1676 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
1679 for ( q = 0; q < NumQuadPoints ; q++ )
1682 for ( d1 = 0; d1 < 3 ; d1++ )
1684 dphi_phys_pressure[i_dof][q][d1] = 0.0;
1687 for ( d2 = 0; d2 < 3 ; d2++ )
1689 dphi_phys_pressure[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_pressure[i_dof][q][d2];
1696 for ( q = 0; q < NumQuadPoints ; q++ )
1698 for ( d1 = 0; d1 < 3 ; d1++ )
1700 beta_km1_q[d1][q] = 0.0;
1701 u_km1_q[d1][q] = 0.0;
1702 u_bdf_q[d1][q] = 0.0;
1703 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1705 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs;
1706 beta_km1_q[d1][q] += beta_km1
[e_idof] * M_phi_velocity[i_dof][q];
1707 u_km1_q[d1][q] += u_km1
[e_idof] * M_phi_velocity[i_dof][q];
1708 u_bdf_q[d1][q] += u_bdf
[e_idof] * M_phi_velocity[i_dof][q];
1713 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
1715 e_idof = M_elements_pressure[i_elem][i_dof];
1716 p_km1_q[q] += p_km1
[e_idof] * M_phi_pressure[i_dof][q];
1722 for ( q = 0; q < NumQuadPoints ; q++ )
1724 for ( d1 = 0; d1 < 3 ; d1++ )
1726 for ( d2 = 0; d2 < 3 ; d2++ )
1728 d_ukm1_q[d1][d2][q] = 0.0;
1729 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
1731 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
1732 d_ukm1_q[d1][d2][q] += u_km1
[e_idof] * dphi_phys_velocity[i_dof][q][d2];
1739 for ( q = 0; q < NumQuadPoints ; q++ )
1741 for ( d1 = 0; d1 < 3 ; d1++ )
1743 d_pkm1_q[d1][q] = 0.0;
1744 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
1746 e_idof = M_elements_pressure[i_elem][i_dof];
1747 d_pkm1_q[d1][q] += p_km1
[e_idof] * dphi_phys_pressure[i_dof][q][d1];
1753 for ( q = 0; q < NumQuadPoints ; q++ )
1755 M_Tau_M[i_elem][q] = 1.0/std::sqrt(
1756 M_density*M_density*M_orderBDF*M_orderBDF/(M_timestep*M_timestep)
1757 +M_density*M_density*( beta_km1_q[0][q]*( M_G[i_elem][0][0]* beta_km1_q[0][q] + M_G[i_elem][0][1] * beta_km1_q[1][q] + M_G[i_elem][0][2] * beta_km1_q[2][q] ) +
1758 beta_km1_q[1][q]*( M_G[i_elem][1][0]* beta_km1_q[0][q] + M_G[i_elem][1][1] * beta_km1_q[1][q] + M_G[i_elem][1][2] * beta_km1_q[2][q] ) +
1759 beta_km1_q[2][q]*( M_G[i_elem][2][0]* beta_km1_q[0][q] + M_G[i_elem][2][1] * beta_km1_q[1][q] + M_G[i_elem][2][2] * beta_km1_q[2][q] )
1761 +M_C_I*M_viscosity*M_viscosity*(
1762 M_G[i_elem][0][0]*M_G[i_elem][0][0] + M_G[i_elem][0][1]*M_G[i_elem][0][1] + M_G[i_elem][0][2]*M_G[i_elem][0][2] +
1763 M_G[i_elem][1][0]*M_G[i_elem][1][0] + M_G[i_elem][1][1]*M_G[i_elem][1][1] + M_G[i_elem][1][2]*M_G[i_elem][1][2] +
1764 M_G[i_elem][2][0]*M_G[i_elem][2][0] + M_G[i_elem][2][1]*M_G[i_elem][2][1] + M_G[i_elem][2][2]*M_G[i_elem][2][2]
1768 M_Tau_C[i_elem][q] = 1.0/( M_g[i_elem][0]*M_Tau_M[i_elem][q]*M_g[i_elem][0] +
1769 M_g[i_elem][1]*M_Tau_M[i_elem][q]*M_g[i_elem][1] +
1770 M_g[i_elem][2]*M_Tau_M[i_elem][q]*M_g[i_elem][2]
1776 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
1778 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
1781 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
1783 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
1786 i_00 = 0.0; i_01 = 0.0; i_02 = 0.0; i_10 = 0.0; i_11 = 0.0; i_12 = 0.0; i_20 = 0.0; i_21 = 0.0; i_22 = 0.0;
1788 M_vals_supg[i_elem][0][0][i_test][i_trial] = 0.0;
1789 M_vals_supg[i_elem][0][1][i_test][i_trial] = 0.0;
1790 M_vals_supg[i_elem][0][2][i_test][i_trial] = 0.0;
1791 M_vals_supg[i_elem][1][0][i_test][i_trial] = 0.0;
1792 M_vals_supg[i_elem][1][1][i_test][i_trial] = 0.0;
1793 M_vals_supg[i_elem][1][2][i_test][i_trial] = 0.0;
1794 M_vals_supg[i_elem][2][0][i_test][i_trial] = 0.0;
1795 M_vals_supg[i_elem][2][1][i_test][i_trial] = 0.0;
1796 M_vals_supg[i_elem][2][2][i_test][i_trial] = 0.0;
1799 for ( q = 0; q < NumQuadPoints ; q++ )
1801 integral_test = 0.0;
1802 integral_trial = 0.0;
1803 integral_partial = 0.0;
1806 for ( d1 = 0; d1 < 3 ; d1++ )
1808 integral_test += beta_km1_q[d1][q] * dphi_phys_velocity[i_test][q][d1];
1811 integral_partial = ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] +
1812 dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] +
1813 dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q]
1815 ( dphi_phys_velocity[i_trial][q][0] * beta_km1_q[0][q] +
1816 dphi_phys_velocity[i_trial][q][1] * beta_km1_q[1][q] +
1817 dphi_phys_velocity[i_trial][q][2] * beta_km1_q[2][q]
1820 i_00 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1821 ( M_density * M_alpha / M_timestep * u_km1_q[0][q] +
1824 -dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] * u_bdf_q[0][q]
1825 +M_density * M_density *
1826 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[0][0][q] * M_phi_velocity[i_trial][q]
1827 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[0][0][q] * M_phi_velocity[i_trial][q]
1828 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[0][0][q] * M_phi_velocity[i_trial][q]
1830 + M_density * M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1831 ( d_ukm1_q[0][0][q] * beta_km1_q[0][q] + d_ukm1_q[0][1][q] * beta_km1_q[1][q] + d_ukm1_q[0][2][q] * beta_km1_q[2][q] )
1833 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0] )
1836 i_01 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1837 ( M_density * M_alpha / M_timestep * u_km1_q[0][q] +
1840 -dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] * u_bdf_q[0][q]
1841 +M_density * M_density *
1842 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[0][1][q] * M_phi_velocity[i_trial][q]
1843 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[0][1][q] * M_phi_velocity[i_trial][q]
1844 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[0][1][q] * M_phi_velocity[i_trial][q]
1846 + M_density * M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1847 ( d_ukm1_q[0][0][q] * beta_km1_q[0][q] + d_ukm1_q[0][1][q] * beta_km1_q[1][q] + d_ukm1_q[0][2][q] * beta_km1_q[2][q] )
1849 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][1] )
1852 i_02 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1853 ( M_density * M_alpha / M_timestep * u_km1_q[0][q] +
1856 -dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] * u_bdf_q[0][q]
1857 +M_density * M_density *
1858 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[0][2][q] * M_phi_velocity[i_trial][q]
1859 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[0][2][q] * M_phi_velocity[i_trial][q]
1860 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[0][2][q] * M_phi_velocity[i_trial][q]
1862 + M_density * M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1863 ( d_ukm1_q[0][0][q] * beta_km1_q[0][q] + d_ukm1_q[0][1][q] * beta_km1_q[1][q] + d_ukm1_q[0][2][q] * beta_km1_q[2][q] )
1865 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][2] )
1868 i_10 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1869 ( M_density * M_alpha / M_timestep * u_km1_q[1][q] +
1872 -dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] * u_bdf_q[1][q]
1873 +M_density * M_density *
1874 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[1][0][q] * M_phi_velocity[i_trial][q]
1875 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[1][0][q] * M_phi_velocity[i_trial][q]
1876 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[1][0][q] * M_phi_velocity[i_trial][q]
1878 + M_density * M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1879 ( d_ukm1_q[1][0][q] * beta_km1_q[0][q] + d_ukm1_q[1][1][q] * beta_km1_q[1][q] + d_ukm1_q[1][2][q] * beta_km1_q[2][q] )
1881 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][0] )
1884 i_11 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1885 ( M_density * M_alpha / M_timestep * u_km1_q[1][q] +
1888 -dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] * u_bdf_q[1][q]
1889 +M_density * M_density *
1890 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[1][1][q] * M_phi_velocity[i_trial][q]
1891 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[1][1][q] * M_phi_velocity[i_trial][q]
1892 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[1][1][q] * M_phi_velocity[i_trial][q]
1894 + M_density * M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1895 ( d_ukm1_q[1][0][q] * beta_km1_q[0][q] + d_ukm1_q[1][1][q] * beta_km1_q[1][q] + d_ukm1_q[1][2][q] * beta_km1_q[2][q] )
1897 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1] )
1900 i_12 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1901 ( M_density * M_alpha / M_timestep * u_km1_q[1][q] +
1904 -dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] * u_bdf_q[1][q]
1905 +M_density * M_density *
1906 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[1][2][q] * M_phi_velocity[i_trial][q]
1907 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[1][2][q] * M_phi_velocity[i_trial][q]
1908 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[1][2][q] * M_phi_velocity[i_trial][q]
1910 + M_density * M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1911 ( d_ukm1_q[1][0][q] * beta_km1_q[0][q] + d_ukm1_q[1][1][q] * beta_km1_q[1][q] + d_ukm1_q[1][2][q] * beta_km1_q[2][q] )
1913 + M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][2] )
1916 i_20 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1917 ( M_density * M_alpha / M_timestep * u_km1_q[2][q] +
1920 -dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] * u_bdf_q[2][q]
1921 +M_density * M_density *
1922 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[2][0][q] * M_phi_velocity[i_trial][q]
1923 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[2][0][q] * M_phi_velocity[i_trial][q]
1924 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[2][0][q] * M_phi_velocity[i_trial][q]
1926 + M_density * M_density * dphi_phys_velocity[i_test][q][0] * M_phi_velocity[i_trial][q] *
1927 ( d_ukm1_q[2][0][q] * beta_km1_q[0][q] + d_ukm1_q[2][1][q] * beta_km1_q[1][q] + d_ukm1_q[2][2][q] * beta_km1_q[2][q] )
1929 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][0] )
1932 i_21 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1933 ( M_density * M_alpha / M_timestep * u_km1_q[2][q] +
1936 -dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] * u_bdf_q[2][q]
1937 +M_density * M_density *
1938 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[2][1][q] * M_phi_velocity[i_trial][q]
1939 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[2][1][q] * M_phi_velocity[i_trial][q]
1940 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[2][1][q] * M_phi_velocity[i_trial][q]
1942 + M_density * M_density * dphi_phys_velocity[i_test][q][1] * M_phi_velocity[i_trial][q] *
1943 ( d_ukm1_q[2][0][q] * beta_km1_q[0][q] + d_ukm1_q[2][1][q] * beta_km1_q[1][q] + d_ukm1_q[2][2][q] * beta_km1_q[2][q] )
1945 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][1] )
1948 i_22 += ( M_Tau_M[i_elem][q] * ( M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1949 ( M_density * M_alpha / M_timestep * u_km1_q[2][q] +
1952 -dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] * u_bdf_q[2][q]
1953 +M_density * M_density *
1954 ( dphi_phys_velocity[i_test][q][0] * beta_km1_q[0][q] * d_ukm1_q[2][2][q] * M_phi_velocity[i_trial][q]
1955 +dphi_phys_velocity[i_test][q][1] * beta_km1_q[1][q] * d_ukm1_q[2][2][q] * M_phi_velocity[i_trial][q]
1956 +dphi_phys_velocity[i_test][q][2] * beta_km1_q[2][q] * d_ukm1_q[2][2][q] * M_phi_velocity[i_trial][q]
1958 + M_density * M_density * dphi_phys_velocity[i_test][q][2] * M_phi_velocity[i_trial][q] *
1959 ( d_ukm1_q[2][0][q] * beta_km1_q[0][q] + d_ukm1_q[2][1][q] * beta_km1_q[1][q] + d_ukm1_q[2][2][q] * beta_km1_q[2][q] )
1961 +M_Tau_C[i_elem][q] * ( dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2] )
1964 integral += M_Tau_M[i_elem][q] * ( M_density * M_density * M_alpha / M_timestep * integral_test * M_phi_velocity[i_trial][q]
1965 + M_density * M_density * integral_partial
1970 M_vals_supg[i_elem][0][0][i_test][i_trial] = (i_00 + integral) * M_detJacobian[i_elem];
1971 M_vals_supg[i_elem][0][1][i_test][i_trial] = (i_01 ) * M_detJacobian[i_elem];
1972 M_vals_supg[i_elem][0][2][i_test][i_trial] = (i_02 ) * M_detJacobian[i_elem];
1973 M_vals_supg[i_elem][1][0][i_test][i_trial] = (i_10 ) * M_detJacobian[i_elem];
1974 M_vals_supg[i_elem][1][1][i_test][i_trial] = (i_11 + integral) * M_detJacobian[i_elem];
1975 M_vals_supg[i_elem][1][2][i_test][i_trial] = (i_12 ) * M_detJacobian[i_elem];
1976 M_vals_supg[i_elem][2][0][i_test][i_trial] = (i_20 ) * M_detJacobian[i_elem];
1977 M_vals_supg[i_elem][2][1][i_test][i_trial] = (i_21 ) * M_detJacobian[i_elem];
1978 M_vals_supg[i_elem][2][2][i_test][i_trial] = (i_22 + integral) * M_detJacobian[i_elem];
1982 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
1984 for ( dim_mat = 0; dim_mat < 3 ; dim_mat++ )
1986 M_cols_pressure[i_elem][i_trial] = M_elements_pressure[i_elem][i_trial];
1987 M_vals_supg_01[i_elem][dim_mat][i_test][i_trial] = 0.0;
1992 for ( q = 0; q < NumQuadPoints ; q++ )
1994 integral_partial = 0.0;
1995 for ( d1 = 0; d1 < 3 ; d1++ )
1997 integral_partial += ( dphi_phys_velocity[i_test][q][d1] * beta_km1_q[d1][q] );
1999 integral += M_Tau_M[i_elem][q] * dphi_phys_pressure[i_trial][q][dim_mat] * integral_partial * w_quad[q];
2001 M_vals_supg_01[i_elem][dim_mat][i_test][i_trial] = integral * M_detJacobian[i_elem];
2007 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
2009 M_rows_pressure[i_elem][i_test] = M_elements_pressure[i_elem][i_test];
2012 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
2014 M_vals_11[i_elem][i_test][i_trial] = 0.0;
2017 for ( q = 0; q < NumQuadPoints ; q++ )
2020 for ( d1 = 0; d1 < 3 ; d1++ )
2022 integral += M_Tau_M[i_elem][q] * dphi_phys_pressure[i_test][q][d1] * dphi_phys_pressure[i_trial][q][d1]*w_quad[q];
2025 M_vals_11[i_elem][i_test][i_trial] = integral * M_detJacobian[i_elem];
2030 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
2033 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
2039 M_vals_supg_10[i_elem][0][i_test][i_trial] = 0.0;
2040 M_vals_supg_10[i_elem][1][i_test][i_trial] = 0.0;
2041 M_vals_supg_10[i_elem][2][i_test][i_trial] = 0.0;
2044 for ( q = 0; q < NumQuadPoints ; q++ )
2046 i_00 += M_Tau_M[i_elem][q] * (
2047 M_alpha * M_density / M_timestep * dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q]
2049 +M_density * ( dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q] * d_ukm1_q[0][0][q]
2050 +dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q] * d_ukm1_q[1][0][q]
2051 +dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q] * d_ukm1_q[2][0][q]
2053 +M_density * dphi_phys_pressure[i_test][q][0] * (
2054 dphi_phys_velocity[i_trial][q][0]*beta_km1_q[0][q]
2055 +dphi_phys_velocity[i_trial][q][1]*beta_km1_q[1][q]
2056 +dphi_phys_velocity[i_trial][q][2]*beta_km1_q[2][q]
2060 i_10 += M_Tau_M[i_elem][q] * (
2061 M_alpha * M_density / M_timestep * dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q]
2062 +M_density * ( dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q] * d_ukm1_q[0][1][q]
2063 +dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q] * d_ukm1_q[1][1][q]
2064 +dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q] * d_ukm1_q[2][1][q]
2066 +M_density * dphi_phys_pressure[i_test][q][1] * (
2067 dphi_phys_velocity[i_trial][q][0]*beta_km1_q[0][q]
2068 +dphi_phys_velocity[i_trial][q][1]*beta_km1_q[1][q]
2069 +dphi_phys_velocity[i_trial][q][2]*beta_km1_q[2][q]
2074 i_20 += M_Tau_M[i_elem][q] * (
2075 M_alpha * M_density / M_timestep * dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q]
2076 +M_density * ( dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q] * d_ukm1_q[0][2][q]
2077 +dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q] * d_ukm1_q[1][2][q]
2078 +dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q] * d_ukm1_q[2][2][q]
2080 +M_density * dphi_phys_pressure[i_test][q][2] * (
2081 dphi_phys_velocity[i_trial][q][0]*beta_km1_q[0][q]
2082 +dphi_phys_velocity[i_trial][q][1]*beta_km1_q[1][q]
2083 +dphi_phys_velocity[i_trial][q][2]*beta_km1_q[2][q]
2089 M_vals_supg_10[i_elem][0][i_test][i_trial] = i_00 * M_detJacobian[i_elem];
2090 M_vals_supg_10[i_elem][1][i_test][i_trial] = i_10 * M_detJacobian[i_elem];
2091 M_vals_supg_10[i_elem][2][i_test][i_trial] = i_20 * M_detJacobian[i_elem];
2098 for (
UInt d1 = 0; d1 < 3 ; d1++ )
2100 for (
int k = 0; k < M_numElements; ++k )
2102 for (
UInt i = 0; i < ndof_velocity; i++ )
2104 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
2106 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2107 ndof_velocity, M_cols_velocity[k],
2108 M_vals_supg[k][d1][0],
2109 Epetra_FECrsMatrix::ROW_MAJOR);
2110 block01->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2111 ndof_pressure, M_cols_pressure[k],
2112 M_vals_supg_01[k][d1],
2113 Epetra_FECrsMatrix::ROW_MAJOR);
2116 for (
int k = 0; k < M_numElements; ++k )
2118 for (
UInt i = 0; i < ndof_velocity; i++ )
2120 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
2122 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2123 ndof_velocity, M_cols_tmp[k],
2124 M_vals_supg[k][d1][1],
2125 Epetra_FECrsMatrix::ROW_MAJOR);
2128 for (
int k = 0; k < M_numElements; ++k )
2130 for (
UInt i = 0; i < ndof_velocity; i++ )
2132 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
2134 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2135 ndof_velocity, M_cols_tmp[k],
2136 M_vals_supg[k][d1][2],
2137 Epetra_FECrsMatrix::ROW_MAJOR);
2141 for (
int k = 0; k < M_numElements; ++k )
2143 block11->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k],
2144 ndof_pressure, M_cols_pressure[k],
2146 Epetra_FECrsMatrix::ROW_MAJOR);
2149 for (
UInt d1 = 0; d1 < 3 ; d1++ )
2151 for (
int k = 0; k < M_numElements; ++k )
2153 for (
UInt i = 0; i < ndof_velocity; i++ )
2155 M_cols_tmp[k][i] = M_cols_velocity[k][i] + d1 * M_numScalarDofs;
2157 block10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k],
2158 ndof_velocity, M_cols_tmp[k],
2159 M_vals_supg_10[k][d1],
2160 Epetra_FECrsMatrix::ROW_MAJOR);
2166 FastAssemblerNS::vmsles_semi_implicit_terms ( matrixPtr_Type& block00,
2167 matrixPtr_Type& block01,
2168 matrixPtr_Type& block10,
2169 matrixPtr_Type& block11,
2170 const std::vector<std::vector<VectorSmall<3>>>& fine_scale,
2171 const vector_Type& u_extr )
2173 int ndof_velocity = M_referenceFE_velocity->nbDof();
2174 int ndof_pressure = M_referenceFE_pressure->nbDof();
2175 int NumQuadPoints = M_qr->nbQuadPt();
2176 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
2177 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
2179 double w_quad[NumQuadPoints];
2180 for (
int q = 0; q < NumQuadPoints ; q++ )
2182 w_quad[q] = M_qr->weight(q);
2185 #pragma omp parallel firstprivate( w_quad, ndof_velocity, ndof_pressure, NumQuadPoints) 2187 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof, dim_mat, iCoor, jCoor, k1, k2;
2188 double integral, integral_test, integral_trial, integral_partial, integral_lapl, partialSum;
2190 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
2191 double dphi_phys_pressure[ndof_pressure][NumQuadPoints][3];
2192 double d2phi_phys_velocity[ndof_velocity][NumQuadPoints][3][3];
2193 double uhq[3][NumQuadPoints];
2194 double i_00, i_01, i_02, i_10, i_11, i_12, i_20, i_21, i_22;
2199 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
2202 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
2205 for ( q = 0; q < NumQuadPoints ; q++ )
2208 for ( d1 = 0; d1 < 3 ; d1++ )
2210 dphi_phys_velocity[i_dof][q][d1] = 0.0;
2213 for ( d2 = 0; d2 < 3 ; d2++ )
2215 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
2221 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
2224 for ( q = 0; q < NumQuadPoints ; q++ )
2227 for ( d1 = 0; d1 < 3 ; d1++ )
2229 dphi_phys_pressure[i_dof][q][d1] = 0.0;
2232 for ( d2 = 0; d2 < 3 ; d2++ )
2234 dphi_phys_pressure[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_pressure[i_dof][q][d2];
2241 for ( q = 0; q < NumQuadPoints ; q++ )
2244 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
2247 for ( iCoor = 0; iCoor < 3 ; iCoor++ )
2250 for ( jCoor = 0; jCoor < 3 ; jCoor++ )
2254 for ( k1 = 0; k1 < 3 ; k1++ )
2257 for ( k2 = 0; k2 < 3 ; k2++ )
2259 partialSum += M_invJacobian[i_elem][iCoor][k1]
2260 * M_d2phi_velocity[i_dof][q][k1][k2]
2261 * M_invJacobian[i_elem][jCoor][k2];
2264 d2phi_phys_velocity[i_dof][q][iCoor][jCoor] = partialSum;
2271 for ( q = 0; q < NumQuadPoints ; q++ )
2273 for ( d1 = 0; d1 < 3 ; d1++ )
2276 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
2278 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
2279 uhq[d1][q] += u_extr[e_idof] * M_phi_velocity[i_dof][q];
2285 for ( q = 0; q < NumQuadPoints ; q++ )
2287 M_Tau_M[i_elem][q] = 1.0/std::sqrt(
2288 M_density*M_density*( uhq[0][q]*( M_G[i_elem][0][0]* uhq[0][q] + M_G[i_elem][0][1] * uhq[1][q] + M_G[i_elem][0][2] * uhq[2][q] ) +
2289 uhq[1][q]*( M_G[i_elem][1][0]* uhq[0][q] + M_G[i_elem][1][1] * uhq[1][q] + M_G[i_elem][1][2] * uhq[2][q] ) +
2290 uhq[2][q]*( M_G[i_elem][2][0]* uhq[0][q] + M_G[i_elem][2][1] * uhq[1][q] + M_G[i_elem][2][2] * uhq[2][q] )
2292 +M_C_I*M_viscosity*M_viscosity*(
2293 M_G[i_elem][0][0]*M_G[i_elem][0][0] + M_G[i_elem][0][1]*M_G[i_elem][0][1] + M_G[i_elem][0][2]*M_G[i_elem][0][2] +
2294 M_G[i_elem][1][0]*M_G[i_elem][1][0] + M_G[i_elem][1][1]*M_G[i_elem][1][1] + M_G[i_elem][1][2]*M_G[i_elem][1][2] +
2295 M_G[i_elem][2][0]*M_G[i_elem][2][0] + M_G[i_elem][2][1]*M_G[i_elem][2][1] + M_G[i_elem][2][2]*M_G[i_elem][2][2]
2299 M_Tau_C[i_elem][q] = 1.0/( M_g[i_elem][0]*M_Tau_M[i_elem][q]*M_g[i_elem][0] +
2300 M_g[i_elem][1]*M_Tau_M[i_elem][q]*M_g[i_elem][1] +
2301 M_g[i_elem][2]*M_Tau_M[i_elem][q]*M_g[i_elem][2]
2304 M_Tau_M_hat[i_elem][q] = 1.0/( M_alpha * M_density / M_timestep + 1.0/M_Tau_M[i_elem][q]);
2308 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
2310 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
2313 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
2315 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
2317 i_00 = 0.0; i_01 = 0.0; i_02 = 0.0; i_10 = 0.0; i_11 = 0.0; i_12 = 0.0; i_20 = 0.0; i_21 = 0.0; i_22 = 0.0;
2319 M_vals_supg[i_elem][0][0][i_test][i_trial] = 0.0;
2320 M_vals_supg[i_elem][0][1][i_test][i_trial] = 0.0;
2321 M_vals_supg[i_elem][0][2][i_test][i_trial] = 0.0;
2322 M_vals_supg[i_elem][1][0][i_test][i_trial] = 0.0;
2323 M_vals_supg[i_elem][1][1][i_test][i_trial] = 0.0;
2324 M_vals_supg[i_elem][1][2][i_test][i_trial] = 0.0;
2325 M_vals_supg[i_elem][2][0][i_test][i_trial] = 0.0;
2326 M_vals_supg[i_elem][2][1][i_test][i_trial] = 0.0;
2327 M_vals_supg[i_elem][2][2][i_test][i_trial] = 0.0;
2329 double tmp_supg = 0.0;
2330 double tmp_supg_test = 0.0;
2331 double tmp_supg_trial = 0.0;
2334 for ( q = 0; q < NumQuadPoints ; q++ )
2336 tmp_supg = M_alpha * M_density * M_density / M_timestep * (
2337 dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q]
2338 ) * M_phi_velocity[i_trial][q];
2341 dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q];
2344 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q];
2346 i_00 += ( M_Tau_M_hat[i_elem][q] * (
2347 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2348 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * (
2349 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2351 -M_viscosity * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] *
2352 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2354 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2355 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[0][q] * (
2356 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2358 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][0] * uhq[0][q] * (
2359 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2363 +M_density * M_density * tmp_supg_test*tmp_supg_trial
2364 -M_density * M_viscosity * tmp_supg_test * (
2365 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2368 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0]
2372 i_01 += ( M_Tau_M_hat[i_elem][q] * (
2373 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2374 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * (
2375 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2377 -M_viscosity * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] *
2378 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2380 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2381 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[0][q] * (
2382 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2384 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][1] * uhq[0][q] * (
2385 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2388 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][1]
2391 i_02 += ( M_Tau_M_hat[i_elem][q] * (
2392 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2393 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * (
2394 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2396 -M_viscosity * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] *
2397 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2399 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2400 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[0][q] * (
2401 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2403 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][2] * uhq[0][q] * (
2404 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2407 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][2]
2410 i_10 += ( M_Tau_M_hat[i_elem][q] * (
2411 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2412 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * (
2413 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2415 -M_viscosity * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] *
2416 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2418 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2419 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[1][q] * (
2420 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2422 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][0] * uhq[1][q] * (
2423 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2426 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][0]
2429 i_11 += ( M_Tau_M_hat[i_elem][q] * (
2430 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2431 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * (
2432 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2434 -M_viscosity * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] *
2435 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2437 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2438 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[1][q] * (
2439 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2441 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][1] * uhq[1][q] * (
2442 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2446 +M_density * M_density * tmp_supg_test*tmp_supg_trial
2447 -M_density * M_viscosity * tmp_supg_test * (
2448 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2451 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1]
2454 i_12 += ( M_Tau_M_hat[i_elem][q] * (
2455 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2456 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * (
2457 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2459 -M_viscosity * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] *
2460 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2462 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2463 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[1][q] * (
2464 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2466 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][2] * uhq[1][q] * (
2467 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2470 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][2]
2473 i_20 += ( M_Tau_M_hat[i_elem][q] * (
2474 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
2475 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * (
2476 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2478 -M_viscosity * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] *
2479 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2481 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[2][q] * M_phi_velocity[i_trial][q] )
2482 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[2][q] * (
2483 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2485 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][0] * uhq[2][q] * (
2486 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2489 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][0]
2492 i_21 += ( M_Tau_M_hat[i_elem][q] * (
2493 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
2494 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * (
2495 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2497 -M_viscosity * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] *
2498 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2500 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[2][q] * M_phi_velocity[i_trial][q] )
2501 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[2][q] * (
2502 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2504 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][1] * uhq[2][q] * (
2505 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2508 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][1]
2511 i_22 += ( M_Tau_M_hat[i_elem][q] * (
2512 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
2513 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * (
2514 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2516 -M_viscosity * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] *
2517 ( d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2] )
2519 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[2][q] * M_phi_velocity[i_trial][q] )
2520 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[2][q] * (
2521 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2523 -M_density * M_viscosity * dphi_phys_velocity[i_test][q][2] * uhq[2][q] * (
2524 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2528 +M_density * M_density * tmp_supg_test*tmp_supg_trial
2529 -M_density * M_viscosity * tmp_supg_test * (
2530 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2533 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2]
2539 M_vals_supg[i_elem][0][0][i_test][i_trial] = (i_00 ) * M_detJacobian[i_elem];
2540 M_vals_supg[i_elem][0][1][i_test][i_trial] = (i_01 ) * M_detJacobian[i_elem];
2541 M_vals_supg[i_elem][0][2][i_test][i_trial] = (i_02 ) * M_detJacobian[i_elem];
2542 M_vals_supg[i_elem][1][0][i_test][i_trial] = (i_10 ) * M_detJacobian[i_elem];
2543 M_vals_supg[i_elem][1][1][i_test][i_trial] = (i_11 ) * M_detJacobian[i_elem];
2544 M_vals_supg[i_elem][1][2][i_test][i_trial] = (i_12 ) * M_detJacobian[i_elem];
2545 M_vals_supg[i_elem][2][0][i_test][i_trial] = (i_20 ) * M_detJacobian[i_elem];
2546 M_vals_supg[i_elem][2][1][i_test][i_trial] = (i_21 ) * M_detJacobian[i_elem];
2547 M_vals_supg[i_elem][2][2][i_test][i_trial] = (i_22 ) * M_detJacobian[i_elem];
2551 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
2553 M_cols_pressure[i_elem][i_trial] = M_elements_pressure[i_elem][i_trial];
2554 M_vals_supg_01[i_elem][0][i_test][i_trial] = 0.0;
2555 M_vals_supg_01[i_elem][1][i_test][i_trial] = 0.0;
2556 M_vals_supg_01[i_elem][2][i_test][i_trial] = 0.0;
2563 for ( q = 0; q < NumQuadPoints ; q++ )
2565 i_00 += M_Tau_M_hat[i_elem][q] * (
2566 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][0]
2567 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][1]
2568 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][2]
2570 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
2571 * dphi_phys_pressure[i_trial][q][0]
2572 + dphi_phys_velocity[i_test][q][0] * uhq[0][q] * dphi_phys_pressure[i_trial][q][0]
2573 + dphi_phys_velocity[i_test][q][1] * uhq[0][q] * dphi_phys_pressure[i_trial][q][1]
2574 + dphi_phys_velocity[i_test][q][2] * uhq[0][q] * dphi_phys_pressure[i_trial][q][2]
2578 i_10 += M_Tau_M_hat[i_elem][q] * (
2579 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][0]
2580 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][1]
2581 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][2]
2583 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
2584 * dphi_phys_pressure[i_trial][q][1]
2585 + dphi_phys_velocity[i_test][q][0] * uhq[1][q] * dphi_phys_pressure[i_trial][q][0]
2586 + dphi_phys_velocity[i_test][q][1] * uhq[1][q] * dphi_phys_pressure[i_trial][q][1]
2587 + dphi_phys_velocity[i_test][q][2] * uhq[1][q] * dphi_phys_pressure[i_trial][q][2]
2591 i_20 += M_Tau_M_hat[i_elem][q] * (
2592 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][0]
2593 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][1]
2594 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][2]
2596 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
2597 * dphi_phys_pressure[i_trial][q][2]
2598 + dphi_phys_velocity[i_test][q][0] * uhq[2][q] * dphi_phys_pressure[i_trial][q][0]
2599 + dphi_phys_velocity[i_test][q][1] * uhq[2][q] * dphi_phys_pressure[i_trial][q][1]
2600 + dphi_phys_velocity[i_test][q][2] * uhq[2][q] * dphi_phys_pressure[i_trial][q][2]
2605 M_vals_supg_01[i_elem][0][i_test][i_trial] = i_00 * M_detJacobian[i_elem];
2606 M_vals_supg_01[i_elem][1][i_test][i_trial] = i_10 * M_detJacobian[i_elem];
2607 M_vals_supg_01[i_elem][2][i_test][i_trial] = i_20 * M_detJacobian[i_elem];
2614 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
2616 M_rows_pressure[i_elem][i_test] = M_elements_pressure[i_elem][i_test];
2619 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
2621 M_vals_11[i_elem][i_test][i_trial] = 0.0;
2625 for ( q = 0; q < NumQuadPoints ; q++ )
2628 for ( d1 = 0; d1 < 3 ; d1++ )
2630 integral += M_Tau_M_hat[i_elem][q] * dphi_phys_pressure[i_test][q][d1] * dphi_phys_pressure[i_trial][q][d1]*w_quad[q];
2633 M_vals_11[i_elem][i_test][i_trial] = integral * M_detJacobian[i_elem];
2638 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
2641 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
2648 for ( q = 0; q < NumQuadPoints ; q++ )
2650 i_00 += M_Tau_M_hat[i_elem][q] * (
2651 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q]
2652 +M_density * dphi_phys_pressure[i_test][q][0] * (
2653 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2655 -M_viscosity * dphi_phys_pressure[i_test][q][0] * (
2656 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2660 i_01 += M_Tau_M_hat[i_elem][q] * (
2661 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q]
2662 +M_density * dphi_phys_pressure[i_test][q][1] * (
2663 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2665 -M_viscosity * dphi_phys_pressure[i_test][q][1] * (
2666 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2670 i_02 += M_Tau_M_hat[i_elem][q] * (
2671 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q]
2672 +M_density * dphi_phys_pressure[i_test][q][2] * (
2673 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2675 -M_viscosity * dphi_phys_pressure[i_test][q][2] * (
2676 d2phi_phys_velocity[i_trial][q][0][0] + d2phi_phys_velocity[i_trial][q][1][1] + d2phi_phys_velocity[i_trial][q][2][2]
2681 M_vals_supg_10[i_elem][0][i_test][i_trial] = i_00 * M_detJacobian[i_elem];
2682 M_vals_supg_10[i_elem][1][i_test][i_trial] = i_01 * M_detJacobian[i_elem];
2683 M_vals_supg_10[i_elem][2][i_test][i_trial] = i_02 * M_detJacobian[i_elem];
2690 for ( UInt d1 = 0; d1 < 3 ; d1++ )
2692 for (
int k = 0; k < M_numElements; ++k )
2694 for ( UInt i = 0; i < ndof_velocity; i++ )
2696 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
2698 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2699 ndof_velocity, M_cols_velocity[k],
2700 M_vals_supg[k][d1][0],
2701 Epetra_FECrsMatrix::ROW_MAJOR);
2703 block01->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2704 ndof_pressure, M_cols_pressure[k],
2705 M_vals_supg_01[k][d1],
2706 Epetra_FECrsMatrix::ROW_MAJOR);
2709 for (
int k = 0; k < M_numElements; ++k )
2711 for ( UInt i = 0; i < ndof_velocity; i++ )
2713 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
2715 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2716 ndof_velocity, M_cols_tmp[k],
2717 M_vals_supg[k][d1][1],
2718 Epetra_FECrsMatrix::ROW_MAJOR);
2721 for (
int k = 0; k < M_numElements; ++k )
2723 for ( UInt i = 0; i < ndof_velocity; i++ )
2725 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
2727 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
2728 ndof_velocity, M_cols_tmp[k],
2729 M_vals_supg[k][d1][2],
2730 Epetra_FECrsMatrix::ROW_MAJOR);
2734 for (
int k = 0; k < M_numElements; ++k )
2736 block11->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_pressure, M_cols_pressure[k], M_vals_11[k], Epetra_FECrsMatrix::ROW_MAJOR);
2739 for ( UInt d1 = 0; d1 < 3 ; d1++ )
2741 for (
int k = 0; k < M_numElements; ++k )
2743 for ( UInt i = 0; i < ndof_velocity; i++ )
2745 M_cols_tmp[k][i] = M_cols_velocity[k][i] + d1 * M_numScalarDofs;
2747 block10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_velocity, M_cols_tmp[k], M_vals_supg_10[k][d1], Epetra_FECrsMatrix::ROW_MAJOR);
2753 FastAssemblerNS::vmsles_semi_implicit_termsP1P1 ( matrixPtr_Type& block00,
2754 matrixPtr_Type& block01,
2755 matrixPtr_Type& block10,
2756 matrixPtr_Type& block11,
2757 const std::vector<std::vector<VectorSmall<3>>>& fine_scale,
2758 const vector_Type& u_extr )
2760 int ndof_velocity = M_referenceFE_velocity->nbDof();
2761 int ndof_pressure = M_referenceFE_pressure->nbDof();
2762 int NumQuadPoints = M_qr->nbQuadPt();
2763 int ndof_vec = M_referenceFE_velocity->nbDof()*3;
2764 M_numScalarDofs = M_fespace_velocity->dof().numTotalDof();
2766 double w_quad[NumQuadPoints];
2767 for (
int q = 0; q < NumQuadPoints ; q++ )
2769 w_quad[q] = M_qr->weight(q);
2772 #pragma omp parallel firstprivate( w_quad, ndof_velocity, ndof_pressure, NumQuadPoints) 2774 int i_elem, i_dof, q, d1, d2, i_test, i_trial, e_idof, dim_mat, iCoor, jCoor, k1, k2;
2775 double integral, integral_test, integral_trial, integral_partial, integral_lapl, partialSum;
2777 double dphi_phys_velocity[ndof_velocity][NumQuadPoints][3];
2778 double dphi_phys_pressure[ndof_pressure][NumQuadPoints][3];
2779 double uhq[3][NumQuadPoints];
2780 double i_00, i_01, i_02, i_10, i_11, i_12, i_20, i_21, i_22;
2785 for ( i_elem = 0; i_elem < M_numElements; i_elem++ )
2788 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
2791 for ( q = 0; q < NumQuadPoints ; q++ )
2794 for ( d1 = 0; d1 < 3 ; d1++ )
2796 dphi_phys_velocity[i_dof][q][d1] = 0.0;
2799 for ( d2 = 0; d2 < 3 ; d2++ )
2801 dphi_phys_velocity[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_velocity[i_dof][q][d2];
2807 for ( i_dof = 0; i_dof < ndof_pressure; i_dof++ )
2810 for ( q = 0; q < NumQuadPoints ; q++ )
2813 for ( d1 = 0; d1 < 3 ; d1++ )
2815 dphi_phys_pressure[i_dof][q][d1] = 0.0;
2818 for ( d2 = 0; d2 < 3 ; d2++ )
2820 dphi_phys_pressure[i_dof][q][d1] += M_invJacobian[i_elem][d1][d2] * M_dphi_pressure[i_dof][q][d2];
2827 for ( q = 0; q < NumQuadPoints ; q++ )
2829 for ( d1 = 0; d1 < 3 ; d1++ )
2832 for ( i_dof = 0; i_dof < ndof_velocity; i_dof++ )
2834 e_idof = M_elements_velocity[i_elem][i_dof] + d1*M_numScalarDofs ;
2835 uhq[d1][q] += u_extr[e_idof] * M_phi_velocity[i_dof][q];
2841 for ( q = 0; q < NumQuadPoints ; q++ )
2843 M_Tau_M[i_elem][q] = 1.0/std::sqrt(
2844 M_density*M_density*( uhq[0][q]*( M_G[i_elem][0][0]* uhq[0][q] + M_G[i_elem][0][1] * uhq[1][q] + M_G[i_elem][0][2] * uhq[2][q] ) +
2845 uhq[1][q]*( M_G[i_elem][1][0]* uhq[0][q] + M_G[i_elem][1][1] * uhq[1][q] + M_G[i_elem][1][2] * uhq[2][q] ) +
2846 uhq[2][q]*( M_G[i_elem][2][0]* uhq[0][q] + M_G[i_elem][2][1] * uhq[1][q] + M_G[i_elem][2][2] * uhq[2][q] )
2848 +M_C_I*M_viscosity*M_viscosity*(
2849 M_G[i_elem][0][0]*M_G[i_elem][0][0] + M_G[i_elem][0][1]*M_G[i_elem][0][1] + M_G[i_elem][0][2]*M_G[i_elem][0][2] +
2850 M_G[i_elem][1][0]*M_G[i_elem][1][0] + M_G[i_elem][1][1]*M_G[i_elem][1][1] + M_G[i_elem][1][2]*M_G[i_elem][1][2] +
2851 M_G[i_elem][2][0]*M_G[i_elem][2][0] + M_G[i_elem][2][1]*M_G[i_elem][2][1] + M_G[i_elem][2][2]*M_G[i_elem][2][2]
2855 M_Tau_C[i_elem][q] = 1.0/( M_g[i_elem][0]*M_Tau_M[i_elem][q]*M_g[i_elem][0] +
2856 M_g[i_elem][1]*M_Tau_M[i_elem][q]*M_g[i_elem][1] +
2857 M_g[i_elem][2]*M_Tau_M[i_elem][q]*M_g[i_elem][2]
2860 M_Tau_M_hat[i_elem][q] = 1.0/( M_alpha * M_density / M_timestep + 1.0/M_Tau_M[i_elem][q]);
2864 for ( i_test = 0; i_test < ndof_velocity; i_test++ )
2866 M_rows_velocity[i_elem][i_test] = M_elements_velocity[i_elem][i_test];
2869 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
2871 M_cols_velocity[i_elem][i_trial] = M_elements_velocity[i_elem][i_trial];
2873 i_00 = 0.0; i_01 = 0.0; i_02 = 0.0; i_10 = 0.0; i_11 = 0.0; i_12 = 0.0; i_20 = 0.0; i_21 = 0.0; i_22 = 0.0;
2875 M_vals_supg[i_elem][0][0][i_test][i_trial] = 0.0;
2876 M_vals_supg[i_elem][0][1][i_test][i_trial] = 0.0;
2877 M_vals_supg[i_elem][0][2][i_test][i_trial] = 0.0;
2878 M_vals_supg[i_elem][1][0][i_test][i_trial] = 0.0;
2879 M_vals_supg[i_elem][1][1][i_test][i_trial] = 0.0;
2880 M_vals_supg[i_elem][1][2][i_test][i_trial] = 0.0;
2881 M_vals_supg[i_elem][2][0][i_test][i_trial] = 0.0;
2882 M_vals_supg[i_elem][2][1][i_test][i_trial] = 0.0;
2883 M_vals_supg[i_elem][2][2][i_test][i_trial] = 0.0;
2885 double tmp_supg = 0.0;
2886 double tmp_supg_test = 0.0;
2887 double tmp_supg_trial = 0.0;
2890 for ( q = 0; q < NumQuadPoints ; q++ )
2892 tmp_supg = M_alpha * M_density * M_density / M_timestep * (
2893 dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q]
2894 ) * M_phi_velocity[i_trial][q];
2897 dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q];
2900 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q];
2902 i_00 += ( M_Tau_M_hat[i_elem][q] * (
2903 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2904 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * (
2905 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2908 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2909 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[0][q] * (
2910 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2914 +M_density * M_density * tmp_supg_test*tmp_supg_trial
2916 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][0]
2920 i_01 += ( M_Tau_M_hat[i_elem][q] * (
2921 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2922 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * (
2923 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2926 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2927 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[0][q] * (
2928 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2932 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][1]
2935 i_02 += ( M_Tau_M_hat[i_elem][q] * (
2936 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * M_phi_velocity[i_trial][q] +
2937 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * (
2938 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2942 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[0][q] * M_phi_velocity[i_trial][q] )
2943 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[0][q] * (
2944 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2947 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][0] * dphi_phys_velocity[i_trial][q][2]
2950 i_10 += ( M_Tau_M_hat[i_elem][q] * (
2951 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2952 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * (
2953 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2957 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2958 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[1][q] * (
2959 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2962 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][0]
2965 i_11 += ( M_Tau_M_hat[i_elem][q] * (
2966 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2967 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * (
2968 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2972 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2973 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[1][q] * (
2974 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2978 +M_density * M_density * tmp_supg_test*tmp_supg_trial
2980 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][1]
2983 i_12 += ( M_Tau_M_hat[i_elem][q] * (
2984 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * M_phi_velocity[i_trial][q] +
2985 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * (
2986 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2989 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[1][q] * M_phi_velocity[i_trial][q] )
2990 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[1][q] * (
2991 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
2994 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][1] * dphi_phys_velocity[i_trial][q][2]
2997 i_20 += ( M_Tau_M_hat[i_elem][q] * (
2998 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
2999 M_density * dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * (
3000 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3003 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][0] * uhq[2][q] * M_phi_velocity[i_trial][q] )
3004 +M_density * M_density * dphi_phys_velocity[i_test][q][0] * uhq[2][q] * (
3005 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3008 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][0]
3011 i_21 += ( M_Tau_M_hat[i_elem][q] * (
3012 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
3013 M_density * dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * (
3014 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3017 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][1] * uhq[2][q] * M_phi_velocity[i_trial][q] )
3018 +M_density * M_density * dphi_phys_velocity[i_test][q][1] * uhq[2][q] * (
3019 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3022 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][1]
3025 i_22 += ( M_Tau_M_hat[i_elem][q] * (
3026 M_alpha * M_density * M_density / M_timestep * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * M_phi_velocity[i_trial][q] +
3027 M_density * dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * (
3028 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3031 +M_alpha * M_density * M_density / M_timestep * ( dphi_phys_velocity[i_test][q][2] * uhq[2][q] * M_phi_velocity[i_trial][q] )
3032 +M_density * M_density * dphi_phys_velocity[i_test][q][2] * uhq[2][q] * (
3033 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3037 +M_density * M_density * tmp_supg_test*tmp_supg_trial
3039 + M_Tau_C[i_elem][q] * dphi_phys_velocity[i_test][q][2] * dphi_phys_velocity[i_trial][q][2]
3045 M_vals_supg[i_elem][0][0][i_test][i_trial] = (i_00 ) * M_detJacobian[i_elem];
3046 M_vals_supg[i_elem][0][1][i_test][i_trial] = (i_01 ) * M_detJacobian[i_elem];
3047 M_vals_supg[i_elem][0][2][i_test][i_trial] = (i_02 ) * M_detJacobian[i_elem];
3048 M_vals_supg[i_elem][1][0][i_test][i_trial] = (i_10 ) * M_detJacobian[i_elem];
3049 M_vals_supg[i_elem][1][1][i_test][i_trial] = (i_11 ) * M_detJacobian[i_elem];
3050 M_vals_supg[i_elem][1][2][i_test][i_trial] = (i_12 ) * M_detJacobian[i_elem];
3051 M_vals_supg[i_elem][2][0][i_test][i_trial] = (i_20 ) * M_detJacobian[i_elem];
3052 M_vals_supg[i_elem][2][1][i_test][i_trial] = (i_21 ) * M_detJacobian[i_elem];
3053 M_vals_supg[i_elem][2][2][i_test][i_trial] = (i_22 ) * M_detJacobian[i_elem];
3057 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
3059 M_cols_pressure[i_elem][i_trial] = M_elements_pressure[i_elem][i_trial];
3060 M_vals_supg_01[i_elem][0][i_test][i_trial] = 0.0;
3061 M_vals_supg_01[i_elem][1][i_test][i_trial] = 0.0;
3062 M_vals_supg_01[i_elem][2][i_test][i_trial] = 0.0;
3069 for ( q = 0; q < NumQuadPoints ; q++ )
3071 i_00 += M_Tau_M_hat[i_elem][q] * (
3072 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][0]
3073 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][1]
3074 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][0] * dphi_phys_pressure[i_trial][q][2]
3076 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
3077 * dphi_phys_pressure[i_trial][q][0]
3078 + dphi_phys_velocity[i_test][q][0] * uhq[0][q] * dphi_phys_pressure[i_trial][q][0]
3079 + dphi_phys_velocity[i_test][q][1] * uhq[0][q] * dphi_phys_pressure[i_trial][q][1]
3080 + dphi_phys_velocity[i_test][q][2] * uhq[0][q] * dphi_phys_pressure[i_trial][q][2]
3084 i_10 += M_Tau_M_hat[i_elem][q] * (
3085 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][0]
3086 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][1]
3087 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][1] * dphi_phys_pressure[i_trial][q][2]
3089 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
3090 * dphi_phys_pressure[i_trial][q][1]
3091 + dphi_phys_velocity[i_test][q][0] * uhq[1][q] * dphi_phys_pressure[i_trial][q][0]
3092 + dphi_phys_velocity[i_test][q][1] * uhq[1][q] * dphi_phys_pressure[i_trial][q][1]
3093 + dphi_phys_velocity[i_test][q][2] * uhq[1][q] * dphi_phys_pressure[i_trial][q][2]
3097 i_20 += M_Tau_M_hat[i_elem][q] * (
3098 dphi_phys_velocity[i_test][q][0] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][0]
3099 +dphi_phys_velocity[i_test][q][1] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][1]
3100 +dphi_phys_velocity[i_test][q][2] * fine_scale[i_elem][q][2] * dphi_phys_pressure[i_trial][q][2]
3102 (dphi_phys_velocity[i_test][q][0] * uhq[0][q] + dphi_phys_velocity[i_test][q][1] * uhq[1][q] + dphi_phys_velocity[i_test][q][2] * uhq[2][q])
3103 * dphi_phys_pressure[i_trial][q][2]
3104 + dphi_phys_velocity[i_test][q][0] * uhq[2][q] * dphi_phys_pressure[i_trial][q][0]
3105 + dphi_phys_velocity[i_test][q][1] * uhq[2][q] * dphi_phys_pressure[i_trial][q][1]
3106 + dphi_phys_velocity[i_test][q][2] * uhq[2][q] * dphi_phys_pressure[i_trial][q][2]
3111 M_vals_supg_01[i_elem][0][i_test][i_trial] = i_00 * M_detJacobian[i_elem];
3112 M_vals_supg_01[i_elem][1][i_test][i_trial] = i_10 * M_detJacobian[i_elem];
3113 M_vals_supg_01[i_elem][2][i_test][i_trial] = i_20 * M_detJacobian[i_elem];
3120 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
3122 M_rows_pressure[i_elem][i_test] = M_elements_pressure[i_elem][i_test];
3125 for ( i_trial = 0; i_trial < ndof_pressure; i_trial++ )
3127 M_vals_11[i_elem][i_test][i_trial] = 0.0;
3131 for ( q = 0; q < NumQuadPoints ; q++ )
3134 for ( d1 = 0; d1 < 3 ; d1++ )
3136 integral += M_Tau_M_hat[i_elem][q] * dphi_phys_pressure[i_test][q][d1] * dphi_phys_pressure[i_trial][q][d1]*w_quad[q];
3139 M_vals_11[i_elem][i_test][i_trial] = integral * M_detJacobian[i_elem];
3144 for ( i_test = 0; i_test < ndof_pressure; i_test++ )
3147 for ( i_trial = 0; i_trial < ndof_velocity; i_trial++ )
3154 for ( q = 0; q < NumQuadPoints ; q++ )
3156 i_00 += M_Tau_M_hat[i_elem][q] * (
3157 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][0] * M_phi_velocity[i_trial][q]
3158 +M_density * dphi_phys_pressure[i_test][q][0] * (
3159 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3164 i_01 += M_Tau_M_hat[i_elem][q] * (
3165 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][1] * M_phi_velocity[i_trial][q]
3166 +M_density * dphi_phys_pressure[i_test][q][1] * (
3167 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3172 i_02 += M_Tau_M_hat[i_elem][q] * (
3173 M_density * M_alpha / M_timestep * dphi_phys_pressure[i_test][q][2] * M_phi_velocity[i_trial][q]
3174 +M_density * dphi_phys_pressure[i_test][q][2] * (
3175 dphi_phys_velocity[i_trial][q][0] * uhq[0][q] + dphi_phys_velocity[i_trial][q][1] * uhq[1][q] + dphi_phys_velocity[i_trial][q][2] * uhq[2][q]
3180 M_vals_supg_10[i_elem][0][i_test][i_trial] = i_00 * M_detJacobian[i_elem];
3181 M_vals_supg_10[i_elem][1][i_test][i_trial] = i_01 * M_detJacobian[i_elem];
3182 M_vals_supg_10[i_elem][2][i_test][i_trial] = i_02 * M_detJacobian[i_elem];
3189 for ( UInt d1 = 0; d1 < 3 ; d1++ )
3191 for (
int k = 0; k < M_numElements; ++k )
3193 for ( UInt i = 0; i < ndof_velocity; i++ )
3195 M_rows_tmp[k][i] = M_rows_velocity[k][i] + d1 * M_numScalarDofs;
3197 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
3198 ndof_velocity, M_cols_velocity[k],
3199 M_vals_supg[k][d1][0],
3200 Epetra_FECrsMatrix::ROW_MAJOR);
3202 block01->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
3203 ndof_pressure, M_cols_pressure[k],
3204 M_vals_supg_01[k][d1],
3205 Epetra_FECrsMatrix::ROW_MAJOR);
3208 for (
int k = 0; k < M_numElements; ++k )
3210 for ( UInt i = 0; i < ndof_velocity; i++ )
3212 M_cols_tmp[k][i] = M_cols_velocity[k][i] + M_numScalarDofs;
3214 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
3215 ndof_velocity, M_cols_tmp[k],
3216 M_vals_supg[k][d1][1],
3217 Epetra_FECrsMatrix::ROW_MAJOR);
3220 for (
int k = 0; k < M_numElements; ++k )
3222 for ( UInt i = 0; i < ndof_velocity; i++ )
3224 M_cols_tmp[k][i] = M_cols_velocity[k][i] + 2 * M_numScalarDofs;
3226 block00->matrixPtr()->InsertGlobalValues ( ndof_velocity, M_rows_tmp[k],
3227 ndof_velocity, M_cols_tmp[k],
3228 M_vals_supg[k][d1][2],
3229 Epetra_FECrsMatrix::ROW_MAJOR);
3233 for (
int k = 0; k < M_numElements; ++k )
3235 block11->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_pressure, M_cols_pressure[k], M_vals_11[k], Epetra_FECrsMatrix::ROW_MAJOR);
3238 for ( UInt d1 = 0; d1 < 3 ; d1++ )
3240 for (
int k = 0; k < M_numElements; ++k )
3242 for ( UInt i = 0; i < ndof_velocity; i++ )
3244 M_cols_tmp[k][i] = M_cols_velocity[k][i] + d1 * M_numScalarDofs;
3246 block10->matrixPtr()->InsertGlobalValues ( ndof_pressure, M_rows_pressure[k], ndof_velocity, M_cols_tmp[k], M_vals_supg_10[k][d1], Epetra_FECrsMatrix::ROW_MAJOR);
const Real & weight(const UInt &ig) const
weight(ig) is the ig-th quadrature weight
const data_type & operator[](const UInt row) const
Access operators.
void updateInverseJacobian(const UInt &iQuadPt)
Real tInverseJacobian(UInt element1, UInt element2, UInt quadNode) const
Getter for the inverse of the jacobian.
double Real
Generic real data.
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
The class for a reference Lagrangian finite element.
Real detJacobian(UInt quadNode) const
Getter for the determinant of the jacobian in a given quadrature node.
const UInt & nbQuadPt() const
Getter for the number of quadrature points.
uint32_type UInt
generic unsigned integer (used mainly for addressing)