44 #include <boost/math/special_functions/gamma.hpp>
91 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
116 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
121 int nLocalSolutionPts;
122 int nElements = pFields[0]->GetExpSize();
123 int nDimensions = pFields[0]->GetCoordim(0);
124 int nSolutionPts = pFields[0]->GetTotPoints();
125 int nTracePts = pFields[0]->GetTrace()->GetTotPoints();
127 Array<TwoD, const NekDouble> gmat;
128 Array<OneD, const NekDouble> jac;
130 m_jac = Array<OneD, NekDouble>(nSolutionPts);
132 Array<OneD, NekDouble> auxArray1;
133 Array<OneD, LibUtilities::BasisSharedPtr> base;
140 for (n = 0; n < nElements; ++n)
142 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
143 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
144 phys_offset = pFields[0]->GetPhys_Offset(n);
145 jac = pFields[0]->GetExp(n)
148 for (i = 0; i < nLocalSolutionPts; ++i)
150 m_jac[i+phys_offset] = jac[0];
157 m_gmat = Array<OneD, Array<OneD, NekDouble> >(4);
158 m_gmat[0] = Array<OneD, NekDouble>(nSolutionPts);
159 m_gmat[1] = Array<OneD, NekDouble>(nSolutionPts);
160 m_gmat[2] = Array<OneD, NekDouble>(nSolutionPts);
161 m_gmat[3] = Array<OneD, NekDouble>(nSolutionPts);
163 m_Q2D_e0 = Array<OneD, Array<OneD, NekDouble> >(nElements);
164 m_Q2D_e1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
165 m_Q2D_e2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
166 m_Q2D_e3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
170 for (n = 0; n < nElements; ++n)
172 base = pFields[0]->GetExp(n)->GetBase();
173 nquad0 = base[0]->GetNumPoints();
174 nquad1 = base[1]->GetNumPoints();
176 m_Q2D_e0[n] = Array<OneD, NekDouble>(nquad0);
177 m_Q2D_e1[n] = Array<OneD, NekDouble>(nquad1);
178 m_Q2D_e2[n] = Array<OneD, NekDouble>(nquad0);
179 m_Q2D_e3[n] = Array<OneD, NekDouble>(nquad1);
182 pFields[0]->GetExp(n)->GetEdgeQFactors(
183 0, auxArray1 = m_Q2D_e0[n]);
184 pFields[0]->GetExp(n)->GetEdgeQFactors(
185 1, auxArray1 = m_Q2D_e1[n]);
186 pFields[0]->GetExp(n)->GetEdgeQFactors(
187 2, auxArray1 = m_Q2D_e2[n]);
188 pFields[0]->GetExp(n)->GetEdgeQFactors(
189 3, auxArray1 = m_Q2D_e3[n]);
191 ptsKeys = pFields[0]->GetExp(n)->GetPointsKeys();
192 nLocalSolutionPts = pFields[0]->GetExp(n)->GetTotPoints();
193 phys_offset = pFields[0]->GetPhys_Offset(n);
195 jac = pFields[0]->GetExp(n)
198 gmat = pFields[0]->GetExp(n)
202 if (pFields[0]->GetExp(n)
203 ->as<LocalRegions::Expansion2D>()->GetGeom2D()
204 ->GetMetricInfo()->GetGtype()
207 for (i = 0; i < nLocalSolutionPts; ++i)
209 m_jac[i+phys_offset] = jac[i];
210 m_gmat[0][i+phys_offset] = gmat[0][i];
211 m_gmat[1][i+phys_offset] = gmat[1][i];
212 m_gmat[2][i+phys_offset] = gmat[2][i];
213 m_gmat[3][i+phys_offset] = gmat[3][i];
218 for (i = 0; i < nLocalSolutionPts; ++i)
220 m_jac[i+phys_offset] = jac[0];
221 m_gmat[0][i+phys_offset] = gmat[0][0];
222 m_gmat[1][i+phys_offset] = gmat[1][0];
223 m_gmat[2][i+phys_offset] = gmat[2][0];
224 m_gmat[3][i+phys_offset] = gmat[3][0];
231 for(i = 0; i < nDimensions; ++i)
241 ASSERTL0(
false,
"3DFR Metric terms not implemented yet");
246 ASSERTL0(
false,
"Expansion dimension not recognised");
270 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
274 int nquad0, nquad1, nquad2;
275 int nmodes0, nmodes1, nmodes2;
276 Array<OneD, LibUtilities::BasisSharedPtr> base;
278 int nElements = pFields[0]->GetExpSize();
279 int nDimensions = pFields[0]->GetCoordim(0);
285 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
286 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
288 for (n = 0; n < nElements; ++n)
290 base = pFields[0]->GetExp(n)->GetBase();
291 nquad0 = base[0]->GetNumPoints();
292 nmodes0 = base[0]->GetNumModes();
293 Array<OneD, const NekDouble> z0;
294 Array<OneD, const NekDouble> w0;
296 base[0]->GetZW(z0, w0);
298 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
299 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
303 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
304 Array<OneD,NekDouble> dLpp0(nquad0, 0.0);
305 Array<OneD,NekDouble> dLpm0(nquad0, 0.0);
308 int p0 = nmodes0 - 1;
314 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
316 * boost::math::tgamma(p0 + 1)
317 * boost::math::tgamma(p0 + 1));
326 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
327 * (ap0 * boost::math::tgamma(p0 + 1))
328 * (ap0 * boost::math::tgamma(p0 + 1)));
332 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
333 * (ap0 * boost::math::tgamma(p0 + 1))
334 * (ap0 * boost::math::tgamma(p0 + 1)));
338 c0 = -2.0 / ((2.0 * p0 + 1.0)
339 * (ap0 * boost::math::tgamma(p0 + 1))
340 * (ap0 * boost::math::tgamma(p0 + 1)));
344 c0 = 10000000000000000.0;
347 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
348 * (ap0 * boost::math::tgamma(p0 + 1))
349 * (ap0 * boost::math::tgamma(p0 + 1));
351 NekDouble overeta0 = 1.0 / (1.0 + etap0);
362 for(i = 0; i < nquad0; ++i)
368 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
372 for(i = 0; i < nquad0; ++i)
374 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
375 m_dGR_xi1[n][i] += dLpp0[i];
376 m_dGR_xi1[n][i] *= overeta0;
377 m_dGR_xi1[n][i] += dLp0[i];
378 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
390 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
391 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
392 m_dGL_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
393 m_dGR_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
395 for (n = 0; n < nElements; ++n)
397 base = pFields[0]->GetExp(n)->GetBase();
398 nquad0 = base[0]->GetNumPoints();
399 nquad1 = base[1]->GetNumPoints();
400 nmodes0 = base[0]->GetNumModes();
401 nmodes1 = base[1]->GetNumModes();
403 Array<OneD, const NekDouble> z0;
404 Array<OneD, const NekDouble> w0;
405 Array<OneD, const NekDouble> z1;
406 Array<OneD, const NekDouble> w1;
408 base[0]->GetZW(z0, w0);
409 base[1]->GetZW(z1, w1);
411 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
412 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
413 m_dGL_xi2[n] = Array<OneD, NekDouble>(nquad1);
414 m_dGR_xi2[n] = Array<OneD, NekDouble>(nquad1);
418 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
419 Array<OneD,NekDouble> dLpp0 (nquad0, 0.0);
420 Array<OneD,NekDouble> dLpm0 (nquad0, 0.0);
421 Array<OneD,NekDouble> dLp1 (nquad1, 0.0);
422 Array<OneD,NekDouble> dLpp1 (nquad1, 0.0);
423 Array<OneD,NekDouble> dLpm1 (nquad1, 0.0);
426 int p0 = nmodes0 - 1;
427 int p1 = nmodes1 - 1;
434 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
436 * boost::math::tgamma(p0 + 1)
437 * boost::math::tgamma(p0 + 1));
439 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
441 * boost::math::tgamma(p1 + 1)
442 * boost::math::tgamma(p1 + 1));
452 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
453 * (ap0 * boost::math::tgamma(p0 + 1))
454 * (ap0 * boost::math::tgamma(p0 + 1)));
456 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
457 * (ap1 * boost::math::tgamma(p1 + 1))
458 * (ap1 * boost::math::tgamma(p1 + 1)));
462 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
463 * (ap0 * boost::math::tgamma(p0 + 1))
464 * (ap0 * boost::math::tgamma(p0 + 1)));
466 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
467 * (ap1 * boost::math::tgamma(p1 + 1))
468 * (ap1 * boost::math::tgamma(p1 + 1)));
472 c0 = -2.0 / ((2.0 * p0 + 1.0)
473 * (ap0 * boost::math::tgamma(p0 + 1))
474 * (ap0 * boost::math::tgamma(p0 + 1)));
476 c1 = -2.0 / ((2.0 * p1 + 1.0)
477 * (ap1 * boost::math::tgamma(p1 + 1))
478 * (ap1 * boost::math::tgamma(p1 + 1)));
482 c0 = 10000000000000000.0;
483 c1 = 10000000000000000.0;
486 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
487 * (ap0 * boost::math::tgamma(p0 + 1))
488 * (ap0 * boost::math::tgamma(p0 + 1));
490 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
491 * (ap1 * boost::math::tgamma(p1 + 1))
492 * (ap1 * boost::math::tgamma(p1 + 1));
494 NekDouble overeta0 = 1.0 / (1.0 + etap0);
495 NekDouble overeta1 = 1.0 / (1.0 + etap1);
510 for(i = 0; i < nquad0; ++i)
516 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
520 for(i = 0; i < nquad1; ++i)
522 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
523 m_dGL_xi2[n][i] += dLpp1[i];
524 m_dGL_xi2[n][i] *= overeta1;
525 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
526 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
530 for(i = 0; i < nquad0; ++i)
532 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
533 m_dGR_xi1[n][i] += dLpp0[i];
534 m_dGR_xi1[n][i] *= overeta0;
535 m_dGR_xi1[n][i] += dLp0[i];
536 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
540 for(i = 0; i < nquad1; ++i)
542 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
543 m_dGR_xi2[n][i] += dLpp1[i];
544 m_dGR_xi2[n][i] *= overeta1;
545 m_dGR_xi2[n][i] += dLp1[i];
546 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
553 m_dGL_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
554 m_dGR_xi1 = Array<OneD, Array<OneD, NekDouble> >(nElements);
555 m_dGL_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
556 m_dGR_xi2 = Array<OneD, Array<OneD, NekDouble> >(nElements);
557 m_dGL_xi3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
558 m_dGR_xi3 = Array<OneD, Array<OneD, NekDouble> >(nElements);
560 for (n = 0; n < nElements; ++n)
562 base = pFields[0]->GetExp(n)->GetBase();
563 nquad0 = base[0]->GetNumPoints();
564 nquad1 = base[1]->GetNumPoints();
565 nquad2 = base[2]->GetNumPoints();
566 nmodes0 = base[0]->GetNumModes();
567 nmodes1 = base[1]->GetNumModes();
568 nmodes2 = base[2]->GetNumModes();
570 Array<OneD, const NekDouble> z0;
571 Array<OneD, const NekDouble> w0;
572 Array<OneD, const NekDouble> z1;
573 Array<OneD, const NekDouble> w1;
574 Array<OneD, const NekDouble> z2;
575 Array<OneD, const NekDouble> w2;
577 base[0]->GetZW(z0, w0);
578 base[1]->GetZW(z1, w1);
579 base[1]->GetZW(z2, w2);
581 m_dGL_xi1[n] = Array<OneD, NekDouble>(nquad0);
582 m_dGR_xi1[n] = Array<OneD, NekDouble>(nquad0);
583 m_dGL_xi2[n] = Array<OneD, NekDouble>(nquad1);
584 m_dGR_xi2[n] = Array<OneD, NekDouble>(nquad1);
585 m_dGL_xi3[n] = Array<OneD, NekDouble>(nquad2);
586 m_dGR_xi3[n] = Array<OneD, NekDouble>(nquad2);
590 Array<OneD,NekDouble> dLp0 (nquad0, 0.0);
591 Array<OneD,NekDouble> dLpp0 (nquad0, 0.0);
592 Array<OneD,NekDouble> dLpm0 (nquad0, 0.0);
593 Array<OneD,NekDouble> dLp1 (nquad1, 0.0);
594 Array<OneD,NekDouble> dLpp1 (nquad1, 0.0);
595 Array<OneD,NekDouble> dLpm1 (nquad1, 0.0);
596 Array<OneD,NekDouble> dLp2 (nquad2, 0.0);
597 Array<OneD,NekDouble> dLpp2 (nquad2, 0.0);
598 Array<OneD,NekDouble> dLpm2 (nquad2, 0.0);
601 int p0 = nmodes0 - 1;
602 int p1 = nmodes1 - 1;
603 int p2 = nmodes2 - 1;
610 NekDouble ap0 = boost::math::tgamma(2 * p0 + 1)
612 * boost::math::tgamma(p0 + 1)
613 * boost::math::tgamma(p0 + 1));
616 NekDouble ap1 = boost::math::tgamma(2 * p1 + 1)
618 * boost::math::tgamma(p1 + 1)
619 * boost::math::tgamma(p1 + 1));
622 NekDouble ap2 = boost::math::tgamma(2 * p2 + 1)
624 * boost::math::tgamma(p2 + 1)
625 * boost::math::tgamma(p2 + 1));
636 c0 = 2.0 * p0 / ((2.0 * p0 + 1.0) * (p0 + 1.0)
637 * (ap0 * boost::math::tgamma(p0 + 1))
638 * (ap0 * boost::math::tgamma(p0 + 1)));
640 c1 = 2.0 * p1 / ((2.0 * p1 + 1.0) * (p1 + 1.0)
641 * (ap1 * boost::math::tgamma(p1 + 1))
642 * (ap1 * boost::math::tgamma(p1 + 1)));
644 c2 = 2.0 * p2 / ((2.0 * p2 + 1.0) * (p2 + 1.0)
645 * (ap2 * boost::math::tgamma(p2 + 1))
646 * (ap2 * boost::math::tgamma(p2 + 1)));
650 c0 = 2.0 * (p0 + 1.0) / ((2.0 * p0 + 1.0) * p0
651 * (ap0 * boost::math::tgamma(p0 + 1))
652 * (ap0 * boost::math::tgamma(p0 + 1)));
654 c1 = 2.0 * (p1 + 1.0) / ((2.0 * p1 + 1.0) * p1
655 * (ap1 * boost::math::tgamma(p1 + 1))
656 * (ap1 * boost::math::tgamma(p1 + 1)));
658 c2 = 2.0 * (p2 + 1.0) / ((2.0 * p2 + 1.0) * p2
659 * (ap2 * boost::math::tgamma(p2 + 1))
660 * (ap2 * boost::math::tgamma(p2 + 1)));
664 c0 = -2.0 / ((2.0 * p0 + 1.0)
665 * (ap0 * boost::math::tgamma(p0 + 1))
666 * (ap0 * boost::math::tgamma(p0 + 1)));
668 c1 = -2.0 / ((2.0 * p1 + 1.0)
669 * (ap1 * boost::math::tgamma(p1 + 1))
670 * (ap1 * boost::math::tgamma(p1 + 1)));
672 c2 = -2.0 / ((2.0 * p2 + 1.0)
673 * (ap2 * boost::math::tgamma(p2 + 1))
674 * (ap2 * boost::math::tgamma(p2 + 1)));
678 c0 = 10000000000000000.0;
679 c1 = 10000000000000000.0;
680 c2 = 10000000000000000.0;
683 NekDouble etap0 = 0.5 * c0 * (2.0 * p0 + 1.0)
684 * (ap0 * boost::math::tgamma(p0 + 1))
685 * (ap0 * boost::math::tgamma(p0 + 1));
687 NekDouble etap1 = 0.5 * c1 * (2.0 * p1 + 1.0)
688 * (ap1 * boost::math::tgamma(p1 + 1))
689 * (ap1 * boost::math::tgamma(p1 + 1));
691 NekDouble etap2 = 0.5 * c2 * (2.0 * p2 + 1.0)
692 * (ap2 * boost::math::tgamma(p2 + 1))
693 * (ap2 * boost::math::tgamma(p2 + 1));
695 NekDouble overeta0 = 1.0 / (1.0 + etap0);
696 NekDouble overeta1 = 1.0 / (1.0 + etap1);
697 NekDouble overeta2 = 1.0 / (1.0 + etap2);
716 for(i = 0; i < nquad0; ++i)
722 m_dGL_xi1[n][i] = 0.5 * sign0 * m_dGL_xi1[n][i];
726 for(i = 0; i < nquad1; ++i)
728 m_dGL_xi2[n][i] = etap1 * dLpm1[i];
729 m_dGL_xi2[n][i] += dLpp1[i];
730 m_dGL_xi2[n][i] *= overeta1;
731 m_dGL_xi2[n][i] = dLp1[i] - m_dGL_xi2[n][i];
732 m_dGL_xi2[n][i] = 0.5 * sign1 * m_dGL_xi2[n][i];
736 for(i = 0; i < nquad2; ++i)
738 m_dGL_xi3[n][i] = etap2 * dLpm2[i];
739 m_dGL_xi3[n][i] += dLpp2[i];
740 m_dGL_xi3[n][i] *= overeta2;
741 m_dGL_xi3[n][i] = dLp2[i] - m_dGL_xi3[n][i];
742 m_dGL_xi3[n][i] = 0.5 * sign1 * m_dGL_xi3[n][i];
746 for(i = 0; i < nquad0; ++i)
748 m_dGR_xi1[n][i] = etap0 * dLpm0[i];
749 m_dGR_xi1[n][i] += dLpp0[i];
750 m_dGR_xi1[n][i] *= overeta0;
751 m_dGR_xi1[n][i] += dLp0[i];
752 m_dGR_xi1[n][i] = 0.5 * m_dGR_xi1[n][i];
756 for(i = 0; i < nquad1; ++i)
758 m_dGR_xi2[n][i] = etap1 * dLpm1[i];
759 m_dGR_xi2[n][i] += dLpp1[i];
760 m_dGR_xi2[n][i] *= overeta1;
761 m_dGR_xi2[n][i] += dLp1[i];
762 m_dGR_xi2[n][i] = 0.5 * m_dGR_xi2[n][i];
766 for(i = 0; i < nquad2; ++i)
768 m_dGR_xi3[n][i] = etap2 * dLpm2[i];
769 m_dGR_xi3[n][i] += dLpp2[i];
770 m_dGR_xi3[n][i] *= overeta2;
771 m_dGR_xi3[n][i] += dLp2[i];
772 m_dGR_xi3[n][i] = 0.5 * m_dGR_xi3[n][i];
779 ASSERTL0(
false,
"Expansion dimension not recognised");
798 const int nConvectiveFields,
799 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
800 const Array<
OneD, Array<OneD, NekDouble> > &advVel,
801 const Array<
OneD, Array<OneD, NekDouble> > &inarray,
802 Array<
OneD, Array<OneD, NekDouble> > &outarray)
807 Array<OneD, NekDouble> auxArray1, auxArray2;
809 Array<OneD, LibUtilities::BasisSharedPtr> Basis;
810 Basis = fields[0]->GetExp(0)->GetBase();
812 int nElements = fields[0]->GetExpSize();
813 int nDimensions = fields[0]->GetCoordim(0);
814 int nSolutionPts = fields[0]->GetTotPoints();
815 int nTracePts = fields[0]->GetTrace()->GetTotPoints();
816 int nCoeffs = fields[0]->GetNcoeffs();
819 Array<OneD, Array<OneD, Array<OneD, NekDouble> > > fluxvector
822 Array<OneD, Array<OneD, NekDouble> > outarrayCoeff
825 Array<OneD, Array<OneD, NekDouble> > Fwd (nConvectiveFields);
826 Array<OneD, Array<OneD, NekDouble> > Bwd (nConvectiveFields);
827 Array<OneD, Array<OneD, NekDouble> > numflux(nConvectiveFields);
830 for (i = 0; i < nConvectiveFields; ++i)
833 Array<OneD, Array<OneD, NekDouble> >(
m_spaceDim);
837 fluxvector[i][j] = Array<OneD, NekDouble>(nSolutionPts);
841 for (i = 0; i < nConvectiveFields; ++i)
843 outarrayCoeff[i] = Array<OneD, NekDouble>(nCoeffs);
844 Fwd[i] = Array<OneD, NekDouble>(nTracePts);
845 Bwd[i] = Array<OneD, NekDouble>(nTracePts);
846 numflux[i] = Array<OneD, NekDouble>(nTracePts);
847 fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
859 Array<OneD, NekDouble> DfluxvectorX1(nSolutionPts);
860 Array<OneD, NekDouble> divFC (nSolutionPts);
866 for(i = 0; i < nConvectiveFields; ++i)
868 for (n = 0; n < nElements; n++)
870 phys_offset = fields[0]->GetPhys_Offset(n);
872 fields[i]->GetExp(n)->PhysDeriv(
873 0, fluxvector[i][0] + phys_offset,
874 auxArray2 = DfluxvectorX1 + phys_offset);
879 fluxvector[i][0], numflux[i], divFC);
887 &DfluxvectorX1[0], 1, &outarray[i][0], 1);
890 if (!(Basis[0]->Collocation()))
892 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
893 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
901 Array<OneD, NekDouble> DfluxvectorX1(nSolutionPts);
902 Array<OneD, NekDouble> DfluxvectorX2(nSolutionPts);
903 Array<OneD, NekDouble> divFD(nSolutionPts);
904 Array<OneD, NekDouble> divFC(nSolutionPts);
909 for (i = 0; i < nConvectiveFields; ++i)
912 Array<OneD, NekDouble> f_hat(nSolutionPts);
913 Array<OneD, NekDouble> g_hat(nSolutionPts);
917 &fluxvector[i][0][0], 1,
919 &fluxvector[i][1][0], 1,
927 &fluxvector[i][0][0], 1,
929 &fluxvector[i][1][0], 1,
936 for (n = 0; n < nElements; n++)
938 phys_offset = fields[0]->GetPhys_Offset(n);
939 fields[0]->GetExp(n)->StdPhysDeriv(0,
940 auxArray1 = f_hat + phys_offset,
941 auxArray2 = DfluxvectorX1 + phys_offset);
942 fields[0]->GetExp(n)->StdPhysDeriv(1,
943 auxArray1 = g_hat + phys_offset,
944 auxArray2 = DfluxvectorX2 + phys_offset);
949 DfluxvectorX2, 1, divFD, 1);
952 if (Basis[0]->GetPointsType() ==
954 Basis[1]->GetPointsType() ==
958 nConvectiveFields, fields, f_hat, g_hat,
964 nConvectiveFields, fields,
965 fluxvector[i][0], fluxvector[i][1],
976 &
m_jac[0], 1, &outarray[i][0], 1);
979 if (!(Basis[0]->Collocation()))
981 fields[i]->FwdTrans(outarray[i], outarrayCoeff[i]);
982 fields[i]->BwdTrans(outarrayCoeff[i], outarray[i]);
990 ASSERTL0(
false,
"3D FRDG case not implemented yet");
1007 const int nConvectiveFields,
1008 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1009 const Array<OneD, const NekDouble> &fluxX1,
1010 const Array<OneD, const NekDouble> &numericalFlux,
1011 Array<OneD, NekDouble> &divCFlux)
1014 int nLocalSolutionPts, phys_offset, t_offset;
1017 Basis = fields[0]->GetExp(0)->GetBasis(0);
1019 int nElements = fields[0]->GetExpSize();
1020 int nSolutionPts = fields[0]->GetTotPoints();
1026 Array<OneD, NekDouble> DCL(nSolutionPts/nElements, 0.0);
1027 Array<OneD, NekDouble> DCR(nSolutionPts/nElements, 0.0);
1030 Array<OneD, NekDouble> JumpL(nElements);
1031 Array<OneD, NekDouble> JumpR(nElements);
1033 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1034 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1036 for (n = 0; n < nElements; ++n)
1038 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1039 phys_offset = fields[0]->GetPhys_Offset(n);
1041 Array<OneD, NekDouble> tmparrayX1(nLocalSolutionPts, 0.0);
1044 &fluxX1[phys_offset], 1,
1047 fields[0]->GetExp(n)->GetVertexPhysVals(0, tmparrayX1,
1050 t_offset = fields[0]->GetTrace()
1051 ->GetPhys_Offset(elmtToTrace[n][0]->GetElmtId());
1053 if(negatedFluxNormal[2*n])
1055 JumpL[n] = numericalFlux[t_offset] - tmpFluxVertex;
1059 JumpL[n] = -numericalFlux[t_offset] - tmpFluxVertex;
1062 fields[0]->GetExp(n)->GetVertexPhysVals(1, tmparrayX1,
1065 t_offset = fields[0]->GetTrace()
1066 ->GetPhys_Offset(elmtToTrace[n][1]->GetElmtId());
1068 if(negatedFluxNormal[2*n+1])
1070 JumpR[n] = -numericalFlux[t_offset] - tmpFluxVertex;
1074 JumpR[n] = numericalFlux[t_offset] - tmpFluxVertex;
1078 for (n = 0; n < nElements; ++n)
1080 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1081 phys_offset = fields[0]->GetPhys_Offset(n);
1092 Vmath::Vadd(nLocalSolutionPts, &DCL[0], 1, &DCR[0], 1,
1093 &divCFlux[phys_offset], 1);
1110 const int nConvectiveFields,
1111 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1112 const Array<OneD, const NekDouble> &fluxX1,
1113 const Array<OneD, const NekDouble> &fluxX2,
1114 const Array<OneD, const NekDouble> &numericalFlux,
1115 Array<OneD, NekDouble> &divCFlux)
1117 int n, e, i, j, cnt;
1119 int nElements = fields[0]->GetExpSize();
1121 int nLocalSolutionPts, nEdgePts;
1122 int trace_offset, phys_offset;
1125 Array<OneD, NekDouble> auxArray1;
1126 Array<OneD, LibUtilities::BasisSharedPtr> base;
1128 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1129 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1132 for(n = 0; n < nElements; ++n)
1135 phys_offset = fields[0]->GetPhys_Offset(n);
1136 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1138 base = fields[0]->GetExp(n)->GetBase();
1139 nquad0 = base[0]->GetNumPoints();
1140 nquad1 = base[1]->GetNumPoints();
1142 Array<OneD, NekDouble> divCFluxE0(nLocalSolutionPts, 0.0);
1143 Array<OneD, NekDouble> divCFluxE1(nLocalSolutionPts, 0.0);
1144 Array<OneD, NekDouble> divCFluxE2(nLocalSolutionPts, 0.0);
1145 Array<OneD, NekDouble> divCFluxE3(nLocalSolutionPts, 0.0);
1148 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1151 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1153 Array<OneD, NekDouble> tmparrayX1(nEdgePts, 0.0);
1154 Array<OneD, NekDouble> tmparrayX2(nEdgePts, 0.0);
1155 Array<OneD, NekDouble> fluxN (nEdgePts, 0.0);
1156 Array<OneD, NekDouble> fluxT (nEdgePts, 0.0);
1157 Array<OneD, NekDouble> fluxJumps (nEdgePts, 0.0);
1160 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1161 elmtToTrace[n][e]->GetElmtId());
1164 const Array<OneD, const Array<OneD, NekDouble> > &normals =
1165 fields[0]->GetExp(n)->GetEdgeNormal(e);
1169 fields[0]->GetExp(n)->GetEdgePhysVals(
1170 e, elmtToTrace[n][e],
1171 fluxX1 + phys_offset,
1172 auxArray1 = tmparrayX1);
1176 fields[0]->GetExp(n)->GetEdgePhysVals(
1177 e, elmtToTrace[n][e],
1178 fluxX2 + phys_offset,
1179 auxArray1 = tmparrayX2);
1189 Vmath::Vsub(nEdgePts, &numericalFlux[trace_offset], 1,
1190 &fluxN[0], 1, &fluxJumps[0], 1);
1193 if (fields[0]->GetExp(n)->GetEorient(e) ==
1200 NekDouble fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1203 for (i = 0; i < nEdgePts; ++i)
1208 fluxJumps[i] = -fluxJumps[i];
1216 for (i = 0; i < nquad0; ++i)
1219 fluxJumps[i] = -(
m_Q2D_e0[n][i]) * fluxJumps[i];
1221 for (j = 0; j < nquad1; ++j)
1224 divCFluxE0[cnt] = fluxJumps[i] *
m_dGL_xi2[n][j];
1229 for (i = 0; i < nquad1; ++i)
1232 fluxJumps[i] = (
m_Q2D_e1[n][i]) * fluxJumps[i];
1234 for (j = 0; j < nquad0; ++j)
1236 cnt = (nquad0)*i + j;
1237 divCFluxE1[cnt] = fluxJumps[i] *
m_dGR_xi1[n][j];
1242 for (i = 0; i < nquad0; ++i)
1245 fluxJumps[i] = (
m_Q2D_e2[n][i]) * fluxJumps[i];
1247 for (j = 0; j < nquad1; ++j)
1249 cnt = (nquad0 - 1) + j*nquad0 - i;
1250 divCFluxE2[cnt] = fluxJumps[i] *
m_dGR_xi2[n][j];
1255 for (i = 0; i < nquad1; ++i)
1258 fluxJumps[i] = -(
m_Q2D_e3[n][i]) * fluxJumps[i];
1259 for (j = 0; j < nquad0; ++j)
1261 cnt = (nquad0*nquad1 - nquad0) + j - i*nquad0;
1262 divCFluxE3[cnt] = fluxJumps[i] *
m_dGL_xi1[n][j];
1267 ASSERTL0(
false,
"edge value (< 3) is out of range");
1274 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
1276 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1277 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1279 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1280 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
1299 const int nConvectiveFields,
1300 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1301 const Array<OneD, const NekDouble> &fluxX1,
1302 const Array<OneD, const NekDouble> &fluxX2,
1303 const Array<OneD, const NekDouble> &numericalFlux,
1304 Array<OneD, NekDouble> &divCFlux)
1306 int n, e, i, j, cnt;
1308 int nElements = fields[0]->GetExpSize();
1309 int nLocalSolutionPts;
1318 Array<OneD, NekDouble> auxArray1, auxArray2;
1319 Array<OneD, LibUtilities::BasisSharedPtr> base;
1321 Array<OneD, Array<OneD, StdRegions::StdExpansionSharedPtr> >
1322 &elmtToTrace = fields[0]->GetTraceMap()->GetElmtToTrace();
1325 for(n = 0; n < nElements; ++n)
1328 phys_offset = fields[0]->GetPhys_Offset(n);
1329 nLocalSolutionPts = fields[0]->GetExp(n)->GetTotPoints();
1331 base = fields[0]->GetExp(n)->GetBase();
1332 nquad0 = base[0]->GetNumPoints();
1333 nquad1 = base[1]->GetNumPoints();
1335 Array<OneD, NekDouble> divCFluxE0(nLocalSolutionPts, 0.0);
1336 Array<OneD, NekDouble> divCFluxE1(nLocalSolutionPts, 0.0);
1337 Array<OneD, NekDouble> divCFluxE2(nLocalSolutionPts, 0.0);
1338 Array<OneD, NekDouble> divCFluxE3(nLocalSolutionPts, 0.0);
1341 for(e = 0; e < fields[0]->GetExp(n)->GetNedges(); ++e)
1344 nEdgePts = fields[0]->GetExp(n)->GetEdgeNumPoints(e);
1346 Array<OneD, NekDouble> fluxN (nEdgePts, 0.0);
1347 Array<OneD, NekDouble> fluxT (nEdgePts, 0.0);
1348 Array<OneD, NekDouble> fluxN_R (nEdgePts, 0.0);
1349 Array<OneD, NekDouble> fluxN_D (nEdgePts, 0.0);
1350 Array<OneD, NekDouble> fluxJumps (nEdgePts, 0.0);
1353 trace_offset = fields[0]->GetTrace()->GetPhys_Offset(
1354 elmtToTrace[n][e]->GetElmtId());
1357 const Array<OneD, const Array<OneD, NekDouble> > &normals =
1358 fields[0]->GetExp(n)->GetEdgeNormal(e);
1367 fields[0]->GetExp(n)->GetEdgePhysVals(
1368 e, elmtToTrace[n][e],
1369 fluxX2 + phys_offset,
1370 auxArray1 = fluxN_D);
1376 &numericalFlux[trace_offset], 1,
1380 if (fields[0]->GetExp(n)->GetEorient(e) ==
1384 auxArray1 = fluxN, 1,
1385 auxArray2 = fluxN, 1);
1388 auxArray1 = fluxN_D, 1,
1389 auxArray2 = fluxN_D, 1);
1393 for (i = 0; i < nquad0; ++i)
1396 fluxN_R[i] = (
m_Q2D_e0[n][i]) * fluxN[i];
1399 fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1402 for (i = 0; i < nEdgePts; ++i)
1405 != fac*normals[0][i] ||
1407 != fac*normals[1][i])
1409 fluxN_R[i] = -fluxN_R[i];
1417 &fluxN_D[0], 1, &fluxJumps[0], 1);
1421 for (i = 0; i < nquad0; ++i)
1423 for (j = 0; j < nquad1; ++j)
1435 fields[0]->GetExp(n)->GetEdgePhysVals(
1436 e, elmtToTrace[n][e],
1437 fluxX1 + phys_offset,
1438 auxArray1 = fluxN_D);
1442 &numericalFlux[trace_offset], 1,
1446 if (fields[0]->GetExp(n)->GetEorient(e) ==
1450 auxArray1 = fluxN, 1,
1451 auxArray2 = fluxN, 1);
1454 auxArray1 = fluxN_D, 1,
1455 auxArray2 = fluxN_D, 1);
1459 for (i = 0; i < nquad1; ++i)
1462 fluxN_R[i] = (
m_Q2D_e1[n][i]) * fluxN[i];
1465 fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1468 for (i = 0; i < nEdgePts; ++i)
1471 != fac*normals[0][i] ||
1473 != fac*normals[1][i])
1475 fluxN_R[i] = -fluxN_R[i];
1483 &fluxN_D[0], 1, &fluxJumps[0], 1);
1487 for (i = 0; i < nquad1; ++i)
1489 for (j = 0; j < nquad0; ++j)
1491 cnt = (nquad0)*i + j;
1503 fields[0]->GetExp(n)->GetEdgePhysVals(
1504 e, elmtToTrace[n][e],
1505 fluxX2 + phys_offset,
1506 auxArray1 = fluxN_D);
1510 &numericalFlux[trace_offset], 1,
1514 if (fields[0]->GetExp(n)->GetEorient(e) ==
1518 auxArray1 = fluxN, 1,
1519 auxArray2 = fluxN, 1);
1522 auxArray1 = fluxN_D, 1,
1523 auxArray2 = fluxN_D, 1);
1527 for (i = 0; i < nquad0; ++i)
1530 fluxN_R[i] = (
m_Q2D_e2[n][i]) * fluxN[i];
1533 fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1536 for (i = 0; i < nEdgePts; ++i)
1539 != fac*normals[0][i] ||
1541 != fac*normals[1][i])
1543 fluxN_R[i] = -fluxN_R[i];
1552 &fluxN_D[0], 1, &fluxJumps[0], 1);
1556 for (i = 0; i < nquad0; ++i)
1558 for (j = 0; j < nquad1; ++j)
1560 cnt = (nquad0 - 1) + j*nquad0 - i;
1571 fields[0]->GetExp(n)->GetEdgePhysVals(
1572 e, elmtToTrace[n][e],
1573 fluxX1 + phys_offset,
1574 auxArray1 = fluxN_D);
1579 &numericalFlux[trace_offset], 1,
1583 if (fields[0]->GetExp(n)->GetEorient(e) ==
1587 auxArray1 = fluxN, 1,
1588 auxArray2 = fluxN, 1);
1591 auxArray1 = fluxN_D, 1,
1592 auxArray2 = fluxN_D, 1);
1596 for (i = 0; i < nquad1; ++i)
1599 fluxN_R[i] = (
m_Q2D_e3[n][i]) * fluxN[i];
1602 fac = fields[0]->GetExp(n)->EdgeNormalNegated(e) ?
1605 for (i = 0; i < nEdgePts; ++i)
1608 != fac*normals[0][i] ||
1610 != fac*normals[1][i])
1612 fluxN_R[i] = -fluxN_R[i];
1621 &fluxN_D[0], 1, &fluxJumps[0], 1);
1625 for (i = 0; i < nquad1; ++i)
1627 for (j = 0; j < nquad0; ++j)
1629 cnt = (nquad0*nquad1 - nquad0) + j
1637 ASSERTL0(
false,
"edge value (< 3) is out of range");
1645 &divCFluxE1[0], 1, &divCFlux[phys_offset], 1);
1647 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1648 &divCFluxE2[0], 1, &divCFlux[phys_offset], 1);
1650 Vmath::Vadd(nLocalSolutionPts, &divCFlux[phys_offset], 1,
1651 &divCFluxE3[0], 1, &divCFlux[phys_offset], 1);
1670 const int nConvectiveFields,
1671 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
1672 const Array<OneD, const NekDouble> &fluxX1,
1673 const Array<OneD, const NekDouble> &fluxX2,
1674 const Array<OneD, const NekDouble> &fluxX3,
1675 const Array<OneD, const NekDouble> &numericalFlux,
1676 Array<OneD, NekDouble> &divCFlux)