41 #include <boost/math/special_functions/gamma.hpp>
85 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
93 int nConvectiveFields = pFields.num_elements();
94 int nDim = pFields[0]->GetCoordim(0);
95 int nSolutionPts = pFields[0]->GetTotPoints();
96 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
98 m_IF1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
100 m_DU1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
102 m_DFC1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
104 m_BD1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
106 m_D1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
108 m_DD1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
110 m_IF2 = Array<OneD, Array<OneD, NekDouble> > (nConvectiveFields);
111 m_DFC2 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
113 m_divFD = Array<OneD, Array<OneD, NekDouble> > (nConvectiveFields);
114 m_divFC = Array<OneD, Array<OneD, NekDouble> > (nConvectiveFields);
116 m_tmp1 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
118 m_tmp2 = Array<OneD, Array<OneD, Array<OneD, NekDouble> > > (
123 for (i = 0; i < nConvectiveFields; ++i)
125 m_IF1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
126 m_DU1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
127 m_DFC1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
128 m_BD1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
129 m_D1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
130 m_DD1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
131 m_IF2[i] = Array<OneD, NekDouble>(nTracePts, 0.0);
132 m_DFC2[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
133 m_divFD[i] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
134 m_divFC[i] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
136 m_tmp1[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
137 m_tmp2[i] = Array<OneD, Array<OneD, NekDouble> >(nDim);
139 for (j = 0; j < nDim; ++j)
141 m_IF1[i][j] = Array<OneD, NekDouble>(nTracePts, 0.0);
142 m_DU1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
143 m_DFC1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
144 m_BD1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
145 m_D1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
146 m_DD1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
147 m_DFC2[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
149 m_tmp1[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
150 m_tmp2[i][j] = Array<OneD, NekDouble>(nSolutionPts, 0.0);
174 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
179 int nLocalSolutionPts;
180 int nElements = pFields[0]->GetExpSize();
181 int nDimensions = pFields[0]->GetCoordim(0);
182 int nSolutionPts = pFields[0]->GetTotPoints();
183 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
185 m_traceNormals = Array<OneD, Array<OneD, NekDouble> >(nDimensions);
186 for (i = 0; i < nDimensions; ++i)
192 Array<TwoD, const NekDouble> gmat;
193 Array<OneD, const NekDouble> jac;
195 m_jac = Array<OneD, NekDouble>(nSolutionPts);
197 Array<OneD, NekDouble> auxArray1;
198 Array<OneD, LibUtilities::BasisSharedPtr> base;
205 for (n = 0; n < nElements; ++n)
207 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
208 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
209 phys_offset = pFields[0]->GetPhys_Offset(n);
210 jac = pFields[0]->GetExp(n)
213 for (i = 0; i < nLocalSolutionPts; ++i)
215 m_jac[i+phys_offset] = jac[0];
222 m_gmat = Array<OneD, Array<OneD, NekDouble> >(4);
223 m_gmat[0] = Array<OneD, NekDouble>(nSolutionPts);
224 m_gmat[1] = Array<OneD, NekDouble>(nSolutionPts);
225 m_gmat[2] = Array<OneD, NekDouble>(nSolutionPts);
226 m_gmat[3] = Array<OneD, NekDouble>(nSolutionPts);
228 m_Q2D_e0 = Array<OneD, Array<OneD, NekDouble> >(nElements);
229 m_Q2D_e1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
230 m_Q2D_e2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
231 m_Q2D_e3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
233 for (n = 0; n < nElements; ++n)
235 base = pFields[0]->GetExp(n)->GetBase();
236 nquad0 = base[0]->GetNumPoints();
237 nquad1 = base[1]->GetNumPoints();
239 m_Q2D_e0[n] = Array<OneD, NekDouble>(nquad0);
240 m_Q2D_e1[n] = Array<OneD, NekDouble>(nquad1);
241 m_Q2D_e2[n] = Array<OneD, NekDouble>(nquad0);
242 m_Q2D_e3[n] = Array<OneD, NekDouble>(nquad1);
245 pFields[0]->GetExp(n)->GetEdgeQFactors(
246 0, auxArray1 = m_Q2D_e0[n]);
247 pFields[0]->GetExp(n)->GetEdgeQFactors(
248 1, auxArray1 = m_Q2D_e1[n]);
249 pFields[0]->GetExp(n)->GetEdgeQFactors(
250 2, auxArray1 = m_Q2D_e2[n]);
251 pFields[0]->GetExp(n)->GetEdgeQFactors(
252 3, auxArray1 = m_Q2D_e3[n]);
254 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
255 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
256 phys_offset = pFields[0]->GetPhys_Offset(n);
258 jac = pFields[0]->GetExp(n)
261 gmat = pFields[0]->GetExp(n)
265 if (pFields[0]->GetExp(n)
266 ->as<LocalRegions::Expansion2D>()->GetGeom2D()
267 ->GetMetricInfo()->GetGtype()
270 for (i = 0; i < nLocalSolutionPts; ++i)
272 m_jac[i+phys_offset] = jac[i];
273 m_gmat[0][i+phys_offset] = gmat[0][i];
274 m_gmat[1][i+phys_offset] = gmat[1][i];
275 m_gmat[2][i+phys_offset] = gmat[2][i];
276 m_gmat[3][i+phys_offset] = gmat[3][i];
281 for (i = 0; i < nLocalSolutionPts; ++i)
283 m_jac[i+phys_offset] = jac[0];
284 m_gmat[0][i+phys_offset] = gmat[0][0];
285 m_gmat[1][i+phys_offset] = gmat[1][0];
286 m_gmat[2][i+phys_offset] = gmat[2][0];
287 m_gmat[3][i+phys_offset] = gmat[3][0];
295 ASSERTL0(
false,
"3DFR Metric terms not implemented yet");
300 ASSERTL0(
false,
"Expansion dimension not recognised");
324 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
328 int nquad0, nquad1, nquad2;
329 int nmodes0, nmodes1, nmodes2;
330 Array<OneD, LibUtilities::BasisSharedPtr> base;
332 int nElements = pFields[0]->GetExpSize();
333 int nDim = pFields[0]->GetCoordim(0);
339 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
340 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
342 for (n = 0; n < nElements; ++n)
344 base = pFields[0]->GetExp(n)->GetBase();
345 nquad0 = base[0]->GetNumPoints();
346 nmodes0 = base[0]->GetNumModes();
347 Array<OneD, const NekDouble> z0;
348 Array<OneD, const NekDouble> w0;
350 base[0]->GetZW(z0, w0);
352 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
353 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
357 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
358 Array<OneD,NekDouble> dLpp0 (nquad0, 0.0);
359 Array<OneD,NekDouble> dLpm0 (nquad0, 0.0);
362 int p0 = nmodes0 - 1;
368 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
370 * boost::math::tgamma(p0 + 1)
371 * boost::math::tgamma(p0 + 1));
380 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
381 * (ap0 * boost::math::tgamma(p0 + 1))
382 * (ap0 * boost::math::tgamma(p0 + 1)));
386 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
387 * (ap0 * boost::math::tgamma(p0 + 1))
388 * (ap0 * boost::math::tgamma(p0 + 1)));
392 c0 = -2.0 / ((2.0 * p0 + 1.0)
393 * (ap0 * boost::math::tgamma(p0 + 1))
394 * (ap0 * boost::math::tgamma(p0 + 1)));
398 c0 = 10000000000000000.0;
401 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
402 * (ap0 * boost::math::tgamma(p0 + 1))
403 * (ap0 * boost::math::tgamma(p0 + 1));
405 NekDouble overeta0 = 1.0 / (1.0 + etap0);
416 for(i = 0; i < nquad0; ++i)
422 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
426 for(i = 0; i < nquad0; ++i)
428 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
429 m_dGR_xi1[n][i] += dLpp0[i];
430 m_dGR_xi1[n][i] *= overeta0;
431 m_dGR_xi1[n][i] += dLp0[i];
432 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
444 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
445 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
446 m_dGL_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
447 m_dGR_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
449 for (n = 0; n < nElements; ++n)
451 base = pFields[0]->GetExp(n)->GetBase();
452 nquad0 = base[0]->GetNumPoints();
453 nquad1 = base[1]->GetNumPoints();
454 nmodes0 = base[0]->GetNumModes();
455 nmodes1 = base[1]->GetNumModes();
457 Array<OneD, const NekDouble> z0;
458 Array<OneD, const NekDouble> w0;
459 Array<OneD, const NekDouble> z1;
460 Array<OneD, const NekDouble> w1;
462 base[0]->GetZW(z0, w0);
463 base[1]->GetZW(z1, w1);
465 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
466 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
467 m_dGL_xi2[n] = Array<OneD, NekDouble>(nquad1);
468 m_dGR_xi2[n] = Array<OneD, NekDouble>(nquad1);
472 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
473 Array<OneD,NekDouble> dLpp0 (nquad0, 0.0);
474 Array<OneD,NekDouble> dLpm0 (nquad0, 0.0);
475 Array<OneD,NekDouble> dLp1 (nquad1, 0.0);
476 Array<OneD,NekDouble> dLpp1 (nquad1, 0.0);
477 Array<OneD,NekDouble> dLpm1 (nquad1, 0.0);
480 int p0 = nmodes0 - 1;
481 int p1 = nmodes1 - 1;
488 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
490 * boost::math::tgamma(p0 + 1)
491 * boost::math::tgamma(p0 + 1));
493 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
495 * boost::math::tgamma(p1 + 1)
496 * boost::math::tgamma(p1 + 1));
506 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
507 * (ap0 * boost::math::tgamma(p0 + 1))
508 * (ap0 * boost::math::tgamma(p0 + 1)));
510 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
511 * (ap1 * boost::math::tgamma(p1 + 1))
512 * (ap1 * boost::math::tgamma(p1 + 1)));
516 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
517 * (ap0 * boost::math::tgamma(p0 + 1))
518 * (ap0 * boost::math::tgamma(p0 + 1)));
520 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
521 * (ap1 * boost::math::tgamma(p1 + 1))
522 * (ap1 * boost::math::tgamma(p1 + 1)));
526 c0 = -2.0 / ((2.0 * p0 + 1.0)
527 * (ap0 * boost::math::tgamma(p0 + 1))
528 * (ap0 * boost::math::tgamma(p0 + 1)));
530 c1 = -2.0 / ((2.0 * p1 + 1.0)
531 * (ap1 * boost::math::tgamma(p1 + 1))
532 * (ap1 * boost::math::tgamma(p1 + 1)));
536 c0 = 10000000000000000.0;
537 c1 = 10000000000000000.0;
540 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
541 * (ap0 * boost::math::tgamma(p0 + 1))
542 * (ap0 * boost::math::tgamma(p0 + 1));
544 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
545 * (ap1 * boost::math::tgamma(p1 + 1))
546 * (ap1 * boost::math::tgamma(p1 + 1));
548 NekDouble overeta0 = 1.0 / (1.0 + etap0);
549 NekDouble overeta1 = 1.0 / (1.0 + etap1);
564 for(i = 0; i < nquad0; ++i)
570 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
574 for(i = 0; i < nquad1; ++i)
576 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
577 m_dGL_xi2[n][i] += dLpp1[i];
578 m_dGL_xi2[n][i] *= overeta1;
579 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
580 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
584 for(i = 0; i < nquad0; ++i)
586 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
587 m_dGR_xi1[n][i] += dLpp0[i];
588 m_dGR_xi1[n][i] *= overeta0;
589 m_dGR_xi1[n][i] += dLp0[i];
590 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
594 for(i = 0; i < nquad1; ++i)
596 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
597 m_dGR_xi2[n][i] += dLpp1[i];
598 m_dGR_xi2[n][i] *= overeta1;
599 m_dGR_xi2[n][i] += dLp1[i];
600 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
607 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
608 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
609 m_dGL_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
610 m_dGR_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
611 m_dGL_xi3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
612 m_dGR_xi3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
614 for (n = 0; n < nElements; ++n)
616 base = pFields[0]->GetExp(n)->GetBase();
617 nquad0 = base[0]->GetNumPoints();
618 nquad1 = base[1]->GetNumPoints();
619 nquad2 = base[2]->GetNumPoints();
620 nmodes0 = base[0]->GetNumModes();
621 nmodes1 = base[1]->GetNumModes();
622 nmodes2 = base[2]->GetNumModes();
624 Array<OneD, const NekDouble> z0;
625 Array<OneD, const NekDouble> w0;
626 Array<OneD, const NekDouble> z1;
627 Array<OneD, const NekDouble> w1;
628 Array<OneD, const NekDouble> z2;
629 Array<OneD, const NekDouble> w2;
631 base[0]->GetZW(z0, w0);
632 base[1]->GetZW(z1, w1);
633 base[1]->GetZW(z2, w2);
635 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
636 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
637 m_dGL_xi2[n] = Array<OneD, NekDouble>(nquad1);
638 m_dGR_xi2[n] = Array<OneD, NekDouble>(nquad1);
639 m_dGL_xi3[n] = Array<OneD, NekDouble>(nquad2);
640 m_dGR_xi3[n] = Array<OneD, NekDouble>(nquad2);
644 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
645 Array<OneD,NekDouble> dLpp0 (nquad0, 0.0);
646 Array<OneD,NekDouble> dLpm0 (nquad0, 0.0);
647 Array<OneD,NekDouble> dLp1 (nquad1, 0.0);
648 Array<OneD,NekDouble> dLpp1 (nquad1, 0.0);
649 Array<OneD,NekDouble> dLpm1 (nquad1, 0.0);
650 Array<OneD,NekDouble> dLp2 (nquad2, 0.0);
651 Array<OneD,NekDouble> dLpp2 (nquad2, 0.0);
652 Array<OneD,NekDouble> dLpm2 (nquad2, 0.0);
655 int p0 = nmodes0 - 1;
656 int p1 = nmodes1 - 1;
657 int p2 = nmodes2 - 1;
665 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
667 * boost::math::tgamma(p0 + 1)
668 * boost::math::tgamma(p0 + 1));
671 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
673 * boost::math::tgamma(p1 + 1)
674 * boost::math::tgamma(p1 + 1));
677 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1)
679 * boost::math::tgamma(p2 + 1)
680 * boost::math::tgamma(p2 + 1));
691 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
692 * (ap0 * boost::math::tgamma(p0 + 1))
693 * (ap0 * boost::math::tgamma(p0 + 1)));
695 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
696 * (ap1 * boost::math::tgamma(p1 + 1))
697 * (ap1 * boost::math::tgamma(p1 + 1)));
699 c2 = 2.0 * p2 / ((2.0 * p2 + 1.0) * (p2 + 1.0)
700 * (ap2 * boost::math::tgamma(p2 + 1))
701 * (ap2 * boost::math::tgamma(p2 + 1)));
705 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
706 * (ap0 * boost::math::tgamma(p0 + 1))
707 * (ap0 * boost::math::tgamma(p0 + 1)));
709 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
710 * (ap1 * boost::math::tgamma(p1 + 1))
711 * (ap1 * boost::math::tgamma(p1 + 1)));
713 c2 = 2.0 * (p2 + 1.0) / ((2.0 * p2 + 1.0) * p2
714 * (ap2 * boost::math::tgamma(p2 + 1))
715 * (ap2 * boost::math::tgamma(p2 + 1)));
719 c0 = -2.0 / ((2.0 * p0 + 1.0)
720 * (ap0 * boost::math::tgamma(p0 + 1))
721 * (ap0 * boost::math::tgamma(p0 + 1)));
723 c1 = -2.0 / ((2.0 * p1 + 1.0)
724 * (ap1 * boost::math::tgamma(p1 + 1))
725 * (ap1 * boost::math::tgamma(p1 + 1)));
727 c2 = -2.0 / ((2.0 * p2 + 1.0)
728 * (ap2 * boost::math::tgamma(p2 + 1))
729 * (ap2 * boost::math::tgamma(p2 + 1)));
733 c0 = 10000000000000000.0;
734 c1 = 10000000000000000.0;
735 c2 = 10000000000000000.0;
738 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
739 * (ap0 * boost::math::tgamma(p0 + 1))
740 * (ap0 * boost::math::tgamma(p0 + 1));
742 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
743 * (ap1 * boost::math::tgamma(p1 + 1))
744 * (ap1 * boost::math::tgamma(p1 + 1));
746 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0)
747 * (ap2 * boost::math::tgamma(p2 + 1))
748 * (ap2 * boost::math::tgamma(p2 + 1));
750 NekDouble overeta0 = 1.0 / (1.0 + etap0);
751 NekDouble overeta1 = 1.0 / (1.0 + etap1);
752 NekDouble overeta2 = 1.0 / (1.0 + etap2);
771 for(i = 0; i < nquad0; ++i)
777 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
781 for(i = 0; i < nquad1; ++i)
783 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
784 m_dGL_xi2[n][i] += dLpp1[i];
785 m_dGL_xi2[n][i] *= overeta1;
786 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
787 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
791 for(i = 0; i < nquad2; ++i)
793 m_dGL_xi3[n][i] = etap2 * dLpm2[i];
794 m_dGL_xi3[n][i] += dLpp2[i];
795 m_dGL_xi3[n][i] *= overeta2;
796 m_dGL_xi3[n][i] = dLp2[i] - m_dGL_xi3[n][i];
797 m_dGL_xi3[n][i] = 0.5 * sign2 * m_dGL_xi3[n][i];
801 for(i = 0; i < nquad0; ++i)
803 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
804 m_dGR_xi1[n][i] += dLpp0[i];
805 m_dGR_xi1[n][i] *= overeta0;
806 m_dGR_xi1[n][i] += dLp0[i];
807 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
811 for(i = 0; i < nquad1; ++i)
813 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
814 m_dGR_xi2[n][i] += dLpp1[i];
815 m_dGR_xi2[n][i] *= overeta1;
816 m_dGR_xi2[n][i] += dLp1[i];
817 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
821 for(i = 0; i < nquad2; ++i)
823 m_dGR_xi3[n][i] = etap2 * dLpm2[i];
824 m_dGR_xi3[n][i] += dLpp2[i];
825 m_dGR_xi3[n][i] *= overeta2;
826 m_dGR_xi3[n][i] += dLp2[i];
827 m_dGR_xi3[n][i] = 0.5 * m_dGR_xi3[n][i];
834 ASSERTL0(
false,
"Expansion dimension not recognised");
846 const int nConvectiveFields,
847 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
848 const Array<
OneD, Array<OneD, NekDouble> > &inarray,
849 Array<
OneD, Array<OneD, NekDouble> > &outarray)
855 Array<OneD, NekDouble> auxArray1, auxArray2;
857 Array<OneD, LibUtilities::BasisSharedPtr> Basis;
858 Basis = fields[0]->GetExp(0)->GetBase();
860 int nElements = fields[0]->GetExpSize();
861 int nDim = fields[0]->GetCoordim(0);
862 int nSolutionPts = fields[0]->GetTotPoints();
863 int nCoeffs = fields[0]->GetNcoeffs();
865 Array<OneD, Array<OneD, NekDouble> > outarrayCoeff(nConvectiveFields);
866 for (i = 0; i < nConvectiveFields; ++i)
868 outarrayCoeff[i] = Array<OneD, NekDouble>(nCoeffs);
879 for (i = 0; i < nConvectiveFields; ++i)
883 for (n = 0; n < nElements; n++)
885 phys_offset = fields[0]->GetPhys_Offset(n);
887 fields[i]->GetExp(n)->PhysDeriv(0,
888 auxArray1 = inarray[i] + phys_offset,
889 auxArray2 =
m_DU1[i][0] + phys_offset);
915 for (i = 0; i < nConvectiveFields; ++i)
919 for (n = 0; n < nElements; n++)
921 phys_offset = fields[0]->GetPhys_Offset(n);
923 fields[i]->GetExp(n)->PhysDeriv(0,
924 auxArray1 =
m_D1[i][0] + phys_offset,
925 auxArray2 =
m_DD1[i][0] + phys_offset);
941 &
m_DD1[i][0][0], 1, &outarray[i][0], 1);
944 if (!(Basis[0]->Collocation()))
946 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
947 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
955 for(i = 0; i < nConvectiveFields; ++i)
957 for (j = 0; j < nDim; ++j)
960 Array<OneD, NekDouble> u1_hat(nSolutionPts, 0.0);
961 Array<OneD, NekDouble> u2_hat(nSolutionPts, 0.0);
966 &
m_gmat[0][0], 1, &u1_hat[0], 1);
969 &
m_jac[0], 1, &u1_hat[0], 1);
972 &
m_gmat[1][0], 1, &u2_hat[0], 1);
975 &
m_jac[0], 1, &u2_hat[0], 1);
980 &
m_gmat[2][0], 1, &u1_hat[0], 1);
983 &
m_jac[0], 1, &u1_hat[0], 1);
986 &
m_gmat[3][0], 1, &u2_hat[0], 1);
989 &
m_jac[0], 1, &u2_hat[0], 1);
992 for (n = 0; n < nElements; n++)
994 phys_offset = fields[0]->GetPhys_Offset(n);
996 fields[i]->GetExp(n)->StdPhysDeriv(0,
997 auxArray1 = u1_hat + phys_offset,
998 auxArray2 =
m_tmp1[i][j] + phys_offset);
1000 fields[i]->GetExp(n)->StdPhysDeriv(1,
1001 auxArray1 = u2_hat + phys_offset,
1002 auxArray2 =
m_tmp2[i][j] + phys_offset);
1007 &
m_DU1[i][j][0], 1);
1016 inarray[i],
m_IF1[i][j],
1022 for (j = 0; j < nSolutionPts; ++j)
1045 for (j = 0; j < nSolutionPts; j++)
1054 m_gmat[0][j] * m_BD1[i][1][j] -
1055 m_gmat[1][j] * m_BD1[i][0][j];
1059 for (j = 0; j < nDim; ++j)
1073 for (i = 0; i < nConvectiveFields; ++i)
1075 Array<OneD, NekDouble> f_hat(nSolutionPts, 0.0);
1076 Array<OneD, NekDouble> g_hat(nSolutionPts, 0.0);
1078 for (j = 0; j < nSolutionPts; j++)
1087 for (n = 0; n < nElements; n++)
1089 phys_offset = fields[0]->GetPhys_Offset(n);
1091 fields[0]->GetExp(n)->StdPhysDeriv(0,
1092 auxArray1 = f_hat + phys_offset,
1093 auxArray2 =
m_DD1[i][0] + phys_offset);
1095 fields[0]->GetExp(n)->StdPhysDeriv(1,
1096 auxArray1 = g_hat + phys_offset,
1097 auxArray2 =
m_DD1[i][1] + phys_offset);
1107 if (Basis[0]->GetPointsType() ==
1109 Basis[1]->GetPointsType() ==
1125 &
m_divFC[i][0], 1, &outarray[i][0], 1);
1130 &
m_jac[0], 1, &outarray[i][0], 1);
1133 if (!(Basis[0]->Collocation()))
1135 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
1136 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
1144 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1155 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1156 const Array<
OneD, Array<OneD, NekDouble> > &ufield,
1157 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &uflux)
1160 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1161 int nvariables = fields.num_elements();
1162 int nDim = fields[0]->GetCoordim(0);
1164 Array<OneD, NekDouble > Fwd (nTracePts);
1165 Array<OneD, NekDouble > Bwd (nTracePts);
1166 Array<OneD, NekDouble > Vn (nTracePts, 0.0);
1167 Array<OneD, NekDouble > fluxtemp(nTracePts, 0.0);
1170 for (i = 0; i < nDim; ++i)
1179 for (j = 0; j < nDim; ++j)
1181 for (i = 0; i < nvariables ; ++i)
1184 fields[i]->GetFwdBwdTracePhys(ufield[i], Fwd, Bwd);
1194 fields[i]->GetTrace()->Upwind(Vn, Fwd, Bwd, fluxtemp);
1205 if(fields[0]->GetBndCondExpansions().num_elements())
1230 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1232 const Array<OneD, const NekDouble> &ufield,
1233 Array<OneD, NekDouble> &penaltyflux)
1237 int nBndEdgePts, nBndEdges;
1239 int nBndRegions = fields[var]->GetBndCondExpansions().num_elements();
1240 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1243 Array<OneD, NekDouble > uplus(nTracePts);
1244 fields[var]->ExtractTracePhys(ufield, uplus);
1247 for (i = 0; i < nBndRegions; ++i)
1250 nBndEdges = fields[var]->
1251 GetBndCondExpansions()[i]->GetExpSize();
1254 for (e = 0; e < nBndEdges ; ++e)
1257 nBndEdgePts = fields[var]->
1258 GetBndCondExpansions()[i]->GetExp(e)->GetTotPoints();
1262 GetBndCondExpansions()[i]->GetPhys_Offset(e);
1265 id2 = fields[0]->GetTrace()->
1266 GetPhys_Offset(fields[0]->GetTraceMap()->
1267 GetBndCondTraceToGlobalTraceMap(cnt++));
1270 if (fields[var]->GetBndConditions()[i]->
1275 GetBndCondExpansions()[i]->
1277 &penaltyflux[id2], 1);
1280 else if ((fields[var]->GetBndConditions()[i])->
1285 &penaltyflux[id2], 1);
1296 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1297 const Array<
OneD, Array<OneD, NekDouble> > &ufield,
1298 Array<
OneD, Array<
OneD, Array<OneD, NekDouble> > > &qfield,
1299 Array<
OneD, Array<OneD, NekDouble> > &qflux)
1302 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1303 int nvariables = fields.num_elements();
1304 int nDim = fields[0]->GetCoordim(0);
1307 Array<OneD, NekDouble > Fwd(nTracePts);
1308 Array<OneD, NekDouble > Bwd(nTracePts);
1309 Array<OneD, NekDouble > Vn (nTracePts, 0.0);
1311 Array<OneD, NekDouble > qFwd (nTracePts);
1312 Array<OneD, NekDouble > qBwd (nTracePts);
1313 Array<OneD, NekDouble > qfluxtemp(nTracePts, 0.0);
1314 Array<OneD, NekDouble > uterm(nTracePts);
1317 for(i = 0; i < nDim; ++i)
1325 for (i = 0; i < nvariables; ++i)
1327 qflux[i] = Array<OneD, NekDouble> (nTracePts, 0.0);
1328 for (j = 0; j < nDim; ++j)
1331 fields[i]->GetFwdBwdTracePhys(qfield[i][j], qFwd, qBwd);
1345 fields[i]->GetTrace()->Upwind(Vn, qBwd, qFwd, qfluxtemp);
1370 if (fields[0]->GetBndCondExpansions().num_elements())
1392 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1395 const Array<OneD, const NekDouble> &qfield,
1396 Array<OneD, NekDouble> &penaltyflux,
1400 int nBndEdges, nBndEdgePts;
1401 int nBndRegions = fields[var]->GetBndCondExpansions().num_elements();
1402 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
1404 Array<OneD, NekDouble > uterm(nTracePts);
1405 Array<OneD, NekDouble > qtemp(nTracePts);
1408 fields[var]->ExtractTracePhys(qfield, qtemp);
1410 for (i = 0; i < nBndRegions; ++i)
1412 nBndEdges = fields[var]->
1413 GetBndCondExpansions()[i]->GetExpSize();
1416 for (e = 0; e < nBndEdges ; ++e)
1418 nBndEdgePts = fields[var]->
1419 GetBndCondExpansions()[i]->GetExp(e)->GetTotPoints();
1422 GetBndCondExpansions()[i]->GetPhys_Offset(e);
1424 id2 = fields[0]->GetTrace()->
1425 GetPhys_Offset(fields[0]->GetTraceMap()->
1426 GetBndCondTraceToGlobalTraceMap(cnt++));
1430 if (fields[var]->GetBndConditions()[i]->
1434 &qtemp[id2], 1, &penaltyflux[id2], 1);
1437 else if ((fields[var]->GetBndConditions()[i])->
1441 &(fields[var]->GetBndCondExpansions()[i]->
1442 GetPhys())[id1], 1, &penaltyflux[id2], 1);
1459 const int nConvectiveFields,
1460 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1461 const Array<OneD, const NekDouble> &flux,
1462 const Array<OneD, const NekDouble> &iFlux,
1463 Array<OneD, NekDouble> &derCFlux)
1466 int nLocalSolutionPts, phys_offset, t_offset;
1468 Array<OneD, NekDouble> auxArray1, auxArray2;
1469 Array<TwoD, const NekDouble> gmat;
1470 Array<OneD, const NekDouble> jac;
1474 Basis = fields[0]->GetExp(0)->GetBasis(0);
1476 int nElements = fields[0]->GetExpSize();
1477 int nSolutionPts = fields[0]->GetTotPoints();
1482 Array<OneD, NekDouble> DCL(nSolutionPts/nElements, 0.0);
1483 Array<OneD, NekDouble> DCR(nSolutionPts/nElements, 0.0);
1486 Array<OneD, NekDouble> JumpL(nElements);
1487 Array<OneD, NekDouble> JumpR(nElements);
1489 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1490 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1492 for (n = 0; n < nElements; ++n)
1494 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1495 phys_offset = fields[0]->GetPhys_Offset(n);
1497 Array<OneD, NekDouble> tmparrayX1(nLocalSolutionPts, 0.0);
1500 &flux[phys_offset], 1,
1503 fields[0]->GetExp(n)->GetVertexPhysVals(0, tmparrayX1,
1506 t_offset = fields[0]->GetTrace()
1507 ->GetPhys_Offset(elmtToTrace[n][0]->GetElmtId());
1509 if(negatedFluxNormal[2*n])
1511 JumpL[n] = iFlux[t_offset] - tmpFluxVertex;
1515 JumpL[n] = -iFlux[t_offset] - tmpFluxVertex;
1518 t_offset = fields[0]->GetTrace()
1519 ->GetPhys_Offset(elmtToTrace[n][1]->GetElmtId());
1521 fields[0]->GetExp(n)->GetVertexPhysVals(1, tmparrayX1,
1523 if(negatedFluxNormal[2*n+1])
1525 JumpR[n] = -iFlux[t_offset] - tmpFluxVertex;
1529 JumpR[n] = iFlux[t_offset] - tmpFluxVertex;
1533 for (n = 0; n < nElements; ++n)
1535 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1536 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1537 phys_offset = fields[0]->GetPhys_Offset(n);
1538 jac = fields[0]->GetExp(n)
1542 JumpL[n] = JumpL[n] * jac[0];
1543 JumpR[n] = JumpR[n] * jac[0];
1554 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1555 &derCFlux[phys_offset], 1);
1575 const int nConvectiveFields,
1576 const int direction,
1577 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1578 const Array<OneD, const NekDouble> &flux,
1579 const Array<OneD, NekDouble> &iFlux,
1580 Array<OneD, NekDouble> &derCFlux)
1582 int n, e, i, j, cnt;
1584 Array<TwoD, const NekDouble> gmat;
1585 Array<OneD, const NekDouble> jac;
1587 int nElements = fields[0]->GetExpSize();
1589 int trace_offset, phys_offset;
1590 int nLocalSolutionPts;
1595 Array<OneD, NekDouble> auxArray1, auxArray2;
1596 Array<OneD, LibUtilities::BasisSharedPtr> base;
1597 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1598 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1601 for (n = 0; n < nElements; ++n)
1604 phys_offset = fields[0]->GetPhys_Offset(n);
1605 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1606 ptsKeys = fields[0]->GetExp(n)->GetPointsKeys();
1611 base = fields[0]->GetExp(n)->GetBase();
1612 nquad0 = base[0]->GetNumPoints();
1613 nquad1 = base[1]->GetNumPoints();
1615 Array<OneD, NekDouble> divCFluxE0(nLocalSolutionPts, 0.0);
1616 Array<OneD, NekDouble> divCFluxE1(nLocalSolutionPts, 0.0);
1617 Array<OneD, NekDouble> divCFluxE2(nLocalSolutionPts, 0.0);
1618 Array<OneD, NekDouble> divCFluxE3(nLocalSolutionPts, 0.0);
1621 for (e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1624 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1627 Array<OneD, NekDouble> tmparray(nEdgePts, 0.0);
1630 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1631 elmtToTrace[n][e]->GetElmtId());
1640 fields[0]->GetExp(n)->GetEdgePhysVals(e, elmtToTrace[n][e],
1642 auxArray1 = tmparray);
1646 Array<OneD, NekDouble> fluxJumps(nEdgePts, 0.0);
1648 &tmparray[0], 1, &fluxJumps[0], 1);
1652 if (fields[0]->GetExp(n)->GetEorient(e) ==
1661 if (fields[0]->GetExp(n)->as<LocalRegions::Expansion2D>()
1662 ->GetGeom2D()->GetMetricInfo()->GetGtype()
1666 Array<OneD, NekDouble> jacEdge(nEdgePts, 0.0);
1668 fields[0]->GetExp(n)->GetEdgePhysVals(
1669 e, elmtToTrace[n][e],
1670 jac, auxArray1 = jacEdge);
1674 if (fields[0]->GetExp(n)->GetEorient(e) ==
1684 for (j = 0; j < nEdgePts; j++)
1686 fluxJumps[j] = fluxJumps[j] * jacEdge[j];
1704 for (i = 0; i < nquad0; ++i)
1709 for (j = 0; j < nquad1; ++j)
1712 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1717 for (i = 0; i < nquad1; ++i)
1722 for (j = 0; j < nquad0; ++j)
1724 cnt = (nquad0)*i + j;
1725 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1730 for (i = 0; i < nquad0; ++i)
1735 for (j = 0; j < nquad1; ++j)
1737 cnt = (nquad0 - 1) + j*nquad0 - i;
1738 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1743 for (i = 0; i < nquad1; ++i)
1747 for (j = 0; j < nquad0; ++j)
1749 cnt = (nquad0*nquad1 - nquad0) + j - i*nquad0;
1750 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1756 ASSERTL0(
false,
"edge value (< 3) is out of range");
1766 &divCFluxE3[0], 1, &derCFlux[phys_offset], 1);
1768 else if (direction == 1)
1771 &divCFluxE2[0], 1, &derCFlux[phys_offset], 1);
1790 const int nConvectiveFields,
1791 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1792 const Array<OneD, const NekDouble> &fluxX1,
1793 const Array<OneD, const NekDouble> &fluxX2,
1794 const Array<OneD, const NekDouble> &numericalFlux,
1795 Array<OneD, NekDouble> &divCFlux)
1797 int n, e, i, j, cnt;
1799 int nElements = fields[0]->GetExpSize();
1801 int nLocalSolutionPts;
1808 Array<OneD, NekDouble> auxArray1, auxArray2;
1809 Array<OneD, LibUtilities::BasisSharedPtr> base;
1811 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1812 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1815 for(n = 0; n < nElements; ++n)
1818 phys_offset = fields[0]->GetPhys_Offset(n);
1819 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1821 base = fields[0]->GetExp(n)->GetBase();
1822 nquad0 = base[0]->GetNumPoints();
1823 nquad1 = base[1]->GetNumPoints();
1825 Array<OneD, NekDouble> divCFluxE0(nLocalSolutionPts, 0.0);
1826 Array<OneD, NekDouble> divCFluxE1(nLocalSolutionPts, 0.0);
1827 Array<OneD, NekDouble> divCFluxE2(nLocalSolutionPts, 0.0);
1828 Array<OneD, NekDouble> divCFluxE3(nLocalSolutionPts, 0.0);
1831 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1834 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1836 Array<OneD, NekDouble> tmparrayX1(nEdgePts, 0.0);
1837 Array<OneD, NekDouble> tmparrayX2(nEdgePts, 0.0);
1838 Array<OneD, NekDouble> fluxN (nEdgePts, 0.0);
1839 Array<OneD, NekDouble> fluxT (nEdgePts, 0.0);
1840 Array<OneD, NekDouble> fluxJumps(nEdgePts, 0.0);
1843 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1844 elmtToTrace[n][e]->GetElmtId());
1847 const Array<OneD, const Array<OneD, NekDouble> > &normals =
1848 fields[0]->GetExp(n)->GetEdgeNormal(e);
1852 fields[0]->GetExp(n)->GetEdgePhysVals(
1853 e, elmtToTrace[n][e],
1854 fluxX1 + phys_offset,
1855 auxArray1 = tmparrayX1);
1859 fields[0]->GetExp(n)->GetEdgePhysVals(
1860 e, elmtToTrace[n][e],
1861 fluxX2 + phys_offset,
1862 auxArray1 = tmparrayX2);
1865 for (i = 0; i < nEdgePts; ++i)
1874 &numericalFlux[trace_offset], 1,
1875 &fluxN[0], 1, &fluxJumps[0], 1);
1878 if (fields[0]->GetExp(n)->GetEorient(e) ==
1882 auxArray1 = fluxJumps, 1,
1883 auxArray2 = fluxJumps, 1);
1886 NekDouble fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1889 for (i = 0; i < nEdgePts; ++i)
1894 fluxJumps[i] = -fluxJumps[i];
1902 for (i = 0; i < nquad0; ++i)
1905 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
1907 for (j = 0; j < nquad1; ++j)
1910 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1915 for (i = 0; i < nquad1; ++i)
1918 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
1920 for (j = 0; j < nquad0; ++j)
1922 cnt = (nquad0)*i + j;
1923 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1928 for (i = 0; i < nquad0; ++i)
1931 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
1933 for (j = 0; j < nquad1; ++j)
1935 cnt = (nquad0 - 1) + j*nquad0 - i;
1936 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1941 for (i = 0; i < nquad1; ++i)
1944 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
1945 for (j = 0; j < nquad0; ++j)
1947 cnt = (nquad0*nquad1 - nquad0) + j - i*nquad0;
1948 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1954 ASSERTL0(
false,
"edge value (< 3) is out of range");
1961 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
1963 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1964 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1966 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1967 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
1986 const int nConvectiveFields,
1987 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1988 const Array<OneD, const NekDouble> &fluxX1,
1989 const Array<OneD, const NekDouble> &fluxX2,
1990 const Array<OneD, const NekDouble> &numericalFlux,
1991 Array<OneD, NekDouble> &divCFlux)
1993 int n, e, i, j, cnt;
1995 int nElements = fields[0]->GetExpSize();
1996 int nLocalSolutionPts;
2003 Array<OneD, NekDouble> auxArray1, auxArray2;
2004 Array<OneD, LibUtilities::BasisSharedPtr> base;
2006 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
2007 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
2010 for(n = 0; n < nElements; ++n)
2013 phys_offset = fields[0]->GetPhys_Offset(n);
2014 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
2016 base = fields[0]->GetExp(n)->GetBase();
2017 nquad0 = base[0]->GetNumPoints();
2018 nquad1 = base[1]->GetNumPoints();
2020 Array<OneD, NekDouble> divCFluxE0(nLocalSolutionPts, 0.0);
2021 Array<OneD, NekDouble> divCFluxE1(nLocalSolutionPts, 0.0);
2022 Array<OneD, NekDouble> divCFluxE2(nLocalSolutionPts, 0.0);
2023 Array<OneD, NekDouble> divCFluxE3(nLocalSolutionPts, 0.0);
2026 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
2029 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
2031 Array<OneD, NekDouble> fluxN (nEdgePts, 0.0);
2032 Array<OneD, NekDouble> fluxT (nEdgePts, 0.0);
2033 Array<OneD, NekDouble> fluxN_R (nEdgePts, 0.0);
2034 Array<OneD, NekDouble> fluxN_D (nEdgePts, 0.0);
2035 Array<OneD, NekDouble> fluxJumps (nEdgePts, 0.0);
2038 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
2039 elmtToTrace[n][e]->GetElmtId());
2042 const Array<OneD, const Array<OneD, NekDouble> > &normals =
2043 fields[0]->GetExp(n)->GetEdgeNormal(e);
2052 fields[0]->GetExp(n)->GetEdgePhysVals(
2053 e, elmtToTrace[n][e],
2054 fluxX2 + phys_offset,
2055 auxArray1 = fluxN_D);
2061 &numericalFlux[trace_offset], 1,
2065 if (fields[0]->GetExp(n)->GetEorient(e) ==
2069 auxArray1 = fluxN, 1,
2070 auxArray2 = fluxN, 1);
2073 auxArray1 = fluxN_D, 1,
2074 auxArray2 = fluxN_D, 1);
2078 for (i = 0; i < nquad0; ++i)
2081 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
2084 for (i = 0; i < nEdgePts; ++i)
2091 fluxN_R[i] = -fluxN_R[i];
2099 &fluxN_D[0], 1, &fluxJumps[0], 1);
2103 for (i = 0; i < nquad0; ++i)
2105 for (j = 0; j < nquad1; ++j)
2117 fields[0]->GetExp(n)->GetEdgePhysVals(
2118 e, elmtToTrace[n][e],
2119 fluxX1 + phys_offset,
2120 auxArray1 = fluxN_D);
2124 &numericalFlux[trace_offset], 1,
2128 if (fields[0]->GetExp(n)->GetEorient(e) ==
2132 auxArray1 = fluxN, 1,
2133 auxArray2 = fluxN, 1);
2136 auxArray1 = fluxN_D, 1,
2137 auxArray2 = fluxN_D, 1);
2141 for (i = 0; i < nquad1; ++i)
2144 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
2147 for (i = 0; i < nEdgePts; ++i)
2154 fluxN_R[i] = -fluxN_R[i];
2162 &fluxN_D[0], 1, &fluxJumps[0], 1);
2166 for (i = 0; i < nquad1; ++i)
2168 for (j = 0; j < nquad0; ++j)
2170 cnt = (nquad0)*i + j;
2182 fields[0]->GetExp(n)->GetEdgePhysVals(
2183 e, elmtToTrace[n][e],
2184 fluxX2 + phys_offset,
2185 auxArray1 = fluxN_D);
2189 &numericalFlux[trace_offset], 1,
2193 if (fields[0]->GetExp(n)->GetEorient(e) ==
2197 auxArray1 = fluxN, 1,
2198 auxArray2 = fluxN, 1);
2201 auxArray1 = fluxN_D, 1,
2202 auxArray2 = fluxN_D, 1);
2206 for (i = 0; i < nquad0; ++i)
2209 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
2212 for (i = 0; i < nEdgePts; ++i)
2219 fluxN_R[i] = -fluxN_R[i];
2228 &fluxN_D[0], 1, &fluxJumps[0], 1);
2232 for (i = 0; i < nquad0; ++i)
2234 for (j = 0; j < nquad1; ++j)
2236 cnt = (nquad0 - 1) + j*nquad0 - i;
2247 fields[0]->GetExp(n)->GetEdgePhysVals(
2248 e, elmtToTrace[n][e],
2249 fluxX1 + phys_offset,
2250 auxArray1 = fluxN_D);
2255 &numericalFlux[trace_offset], 1,
2259 if (fields[0]->GetExp(n)->GetEorient(e) ==
2263 auxArray1 = fluxN, 1,
2264 auxArray2 = fluxN, 1);
2267 auxArray1 = fluxN_D, 1,
2268 auxArray2 = fluxN_D, 1);
2272 for (i = 0; i < nquad1; ++i)
2275 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
2278 for (i = 0; i < nEdgePts; ++i)
2285 fluxN_R[i] = -fluxN_R[i];
2294 &fluxN_D[0], 1, &fluxJumps[0], 1);
2298 for (i = 0; i < nquad1; ++i)
2300 for (j = 0; j < nquad0; ++j)
2302 cnt = (nquad0*nquad1 - nquad0) + j
2310 ASSERTL0(
false,
"edge value (< 3) is out of range");
2318 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
2320 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2321 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
2323 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
2324 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);