37#include <boost/algorithm/string.hpp>
38#include <boost/algorithm/string/predicate.hpp>
70 int shapedim =
m_fields[0]->GetShapeDimension();
123 for (
int j = 0; j < shapedim; ++j)
137 if (
m_session->DefinesSolverInfo(
"TESTMAXWELLTYPE"))
139 std::string TestMaxwellTypeStr =
140 m_session->GetSolverInfo(
"TESTMAXWELLTYPE");
158 if (
m_session->DefinesSolverInfo(
"POLTYPE"))
160 std::string PolTypeStr =
m_session->GetSolverInfo(
"POLTYPE");
176 if (
m_session->DefinesSolverInfo(
"INCTYPE"))
178 std::string IncTypeStr =
m_session->GetSolverInfo(
"INCTYPE");
194 if (
m_session->DefinesSolverInfo(
"CLOAKTYPE"))
196 std::string CloakTypeStr =
m_session->GetSolverInfo(
"CLOAKTYPE");
212 if (
m_session->DefinesSolverInfo(
"SOURCETYPE"))
214 std::string SourceTypeStr =
m_session->GetSolverInfo(
"SOURCETYPE");
257 std::cout <<
"*** rad = [ " <<
Vmath::Vmax(nq, radvec, 1) <<
" , "
258 <<
Vmath::Vmin(nq, radvec, 1) <<
" ) " << std::endl;
269 std::cout <<
"*** rad = [ " <<
Vmath::Vmax(nq, radvec, 1) <<
" , "
270 <<
Vmath::Vmin(nq, radvec, 1) <<
" ) " << std::endl;
290 NekDouble eps1min, eps1max, eps2min, eps2max, eps3min, eps3max;
291 NekDouble mu1min, mu1max, mu2min, mu2max, mu3min, mu3max;
327 std::cout <<
"*** epsvec1 = [ " << eps1min <<
" , " << eps1max
328 <<
" ], epsvec2 = [ " << eps2min <<
" , " << eps2max
329 <<
" ], epsvec3 = [ " << eps3min <<
" , " << eps3max <<
" ] "
331 std::cout <<
"*** muvec1 = [ " << mu1min <<
" , " << mu1max
332 <<
" ], muvec2 = [ " << mu2min <<
" , " << mu2max
333 <<
" ], muvec3 = [ " << mu3min <<
" , " << mu3max <<
" ] "
342 dtFactor = mu1min * eps3min;
345 dtFactor = mu2min * eps3min;
352 dtFactor = eps1min * mu3min;
353 if (eps1min > eps2min)
355 dtFactor = eps2min * mu3min;
366 std::cout <<
"*** dt factor proportional to varepsilon * mu is " << dtFactor
404 std::cout <<
"*** negepsvecminus1 = [ " << eps1min <<
" , " << eps1max
405 <<
" ], negepsvecminus1 = [ " << eps2min <<
" , " << eps2max
406 <<
" ], negepsvecminus1 = [ " << eps3min <<
" , " << eps3max
407 <<
" ] " << std::endl;
408 std::cout <<
"*** negmuvecminus1 = [ " << mu1min <<
" , " << mu1max
409 <<
" ], negmuvecminus1 = [ " << mu2min <<
" , " << mu2max
410 <<
" ], negmuvecminus1 = [ " << mu3min <<
" , " << mu3max <<
" ] "
437 ASSERTL0(
false,
"Implicit unsteady Advection not set up.");
459 for (i = 0; i < nfields; ++i)
463 nvariables = nfields;
475 for (i = 0; i < nvariables; ++i)
488 "Only one of IO_CheckTime and IO_CheckSteps "
497 bool doCheckTime =
false;
522 for (i = 0; i < nq; ++i)
527 std::cout <<
"rad" <<
rad << std::endl;
549 for (i = 0; i < nq; ++i)
558 std::cout <<
"*** Area of Planar Source = "
568 int P1indx = 0, P2indx = 0, P3indx = 0;
586 for (
int i = 0; i < nq; ++i)
588 rad =
sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i]) * (y[i]));
597 for (
int i = 0; i < nq; ++i)
600 sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i] - 1.5) * (y[i] - 1.5));
608 for (
int i = 0; i < nq; ++i)
611 sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i] - 3.0) * (y[i] - 3.0));
637 std::cout <<
"Steps: " << std::setw(8) << std::left << step + 1
639 <<
"Time: " << std::setw(12) << std::left <<
m_time;
641 std::stringstream ss;
642 ss << cpuTime / 60.0 <<
" min.";
643 std::cout <<
" CPU Time: " << std::setw(8) << std::left << ss.str()
668 for (
int i = 0; i < 3; ++i)
684 for (i = 0; i < nvariables; ++i)
699 TimeSeries[indx] =
m_time;
716 <<
", Energy = " << Energy[indx] << std::endl;
726 m_fields[0]->GetBndCondExpansions()[0]->GetExpSize();
728 ->GetBndCondExpansions()[0]
742 m_fields[0]->ExtractTracePhys(fields[0], E1Fwd);
743 m_fields[0]->ExtractTracePhys(fields[1], E2Fwd);
744 m_fields[0]->ExtractTracePhys(fields[2], H3Fwd);
755 for (
int e = 0; e < totbdryexp; ++e)
757 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
758 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(
769 if (E1atPEC < E1atPECloc)
771 E1atPEC = E1atPECloc;
774 if (E2atPEC < E2atPECloc)
776 E2atPEC = E2atPECloc;
779 if (H3atPEC < H3atPECloc)
781 H3atPEC = H3atPECloc;
785 std::cout <<
"At PEC, Max. E1 = " << E1atPEC
786 <<
", E2 = " << E2atPEC <<
", H3 = " << H3atPEC
792 Ezantipod[cntap++] = fields[2][indxantipod];
797 P1[cntpml] = fields[2][P1indx];
798 P2[cntpml] = fields[2][P2indx];
799 P3[cntpml] = fields[2][P3indx];
812 std::cout <<
"Time-integration : " << intTime <<
"s" << std::endl;
814 std::cout <<
"TimeSeries = " << std::endl;
817 std::cout << TimeSeries[i] <<
", ";
819 std::cout << std::endl << std::endl;
821 std::cout <<
"Energy Density = " << std::endl;
824 std::cout << Energy[i] <<
", ";
826 std::cout << std::endl << std::endl;
835 std::cout <<
"Ez at antipod = " << std::endl;
838 std::cout << Ezantipod[i] <<
", ";
840 std::cout << std::endl << std::endl;
845 std::cout <<
"P1 = " << std::endl;
848 std::cout << P1[i] <<
", ";
850 std::cout << std::endl << std::endl;
852 std::cout <<
"P2 = " << std::endl;
855 std::cout << P2[i] <<
", ";
857 std::cout << std::endl << std::endl;
859 std::cout <<
"P3 = " << std::endl;
862 std::cout << P3[i] <<
", ";
864 std::cout << std::endl << std::endl;
868 for (i = 0; i < nvariables; ++i)
874 for (i = 0; i < nvariables; ++i)
893 int nvar = inarray.size();
899 for (i = 0; i < nvar; ++i)
904 Vmath::Vcopy(nq, &inarray[i][0], 1, &physarray[i][0], 1);
907 for (i = 0; i < nvar; i++)
924 for (
int i = 0; i < 3; ++i)
935 for (
int i = 0; i < 3; ++i)
938 Vmath::Vcopy(ncoeffs, &tmpout[i][0], 1, &modarray[i][0], 1);
952 for (i = 0; i < nvar; ++i)
954 m_fields[i]->MultiplyByElmtInvMass(modarray[i], modarray[i]);
955 m_fields[i]->BwdTrans(modarray[i], outarray[i]);
961 for (
int j = 0; j < 2; ++j)
964 Vmath::Vadd(nq, &F[0], 1, &outarray[j][0], 1, &outarray[j][0], 1);
971 AddPML(physarray, outarray);
1005 m_fields[0]->GetCoords(x0, x1, x2);
1008 NekDouble uxx, uxy, uyy, detu, uti, uri;
1028 for (
int i = 0; i < nq; i++)
1031 tmpIN[i] * (1.0 - 2 * x0[i] * x0[i]) + (1.0 - tmpIN[i]);
1034 for (
int i = 0; i < nq; ++i)
1036 theta = atan2((x1[i] + 2.0), (x0[i] + 2.0));
1041 uxx = uti * cos(theta) * cos(theta) +
1042 uri * sin(theta) * sin(theta);
1043 uyy = uti * sin(theta) * sin(theta) +
1044 uri * cos(theta) * cos(theta);
1045 uxy = (uti - uri) * cos(theta) * sin(theta);
1047 detu = uxx * uyy - uxy * uxy;
1049 tmpx = outarray[0][i] + (1.0 - uxx) * Hxdt[i] - uxy * Hydt[i];
1050 tmpy = outarray[1][i] - uxy * Hxdt[i] + (1.0 - uyy) * Hydt[i];
1052 outarray[0][i] = (1 / detu) * (uyy * tmpx - uxy * tmpy);
1053 outarray[1][i] = (1 / detu) * (-uxy * tmpx + uxx * tmpy);
1070 outarray[0], 1, outarray[0], 1);
1074 outarray[1], 1, outarray[1], 1);
1078 outarray[2], 1, outarray[2], 1);
1085 outarray[0], 1, outarray[0], 1);
1089 outarray[1], 1, outarray[1], 1);
1093 outarray[2], 1, outarray[2], 1);
1112 outarray[0], 1, outarray[0], 1);
1116 outarray[1], 1, outarray[1], 1);
1120 outarray[2], 1, outarray[2], 1);
1127 outarray[0], 1, outarray[0], 1);
1141 outarray[1], 1, outarray[1], 1);
1146 outarray[2], 1, outarray[2], 1);
1175 int ncoeffs = outarray[0].size();
1176 int nq = physarray[0].size();
1210 m_fields[var]->IProductWRTBase(tmp, tmpc);
1211 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1218 m_fields[var]->IProductWRTBase(tmp, tmpc);
1219 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1226 &tmp[0], 1, &tmp[0], 1);
1227 m_fields[var]->IProductWRTBase(tmp, tmpc);
1228 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1264 for (i = 0; i < nvar; ++i)
1266 physfield[i] = InField[i];
1270 for (i = 0; i < nvar; ++i)
1280 fluxvector[j], tmpc);
1281 Vmath::Vadd(ncoeffs, &tmpc[0], 1, &OutField[i][0], 1,
1282 &OutField[i][0], 1);
1292 for (i = 0; i < nvar; ++i)
1303 for (i = 0; i < nvar; ++i)
1306 m_fields[i]->AddFwdBwdTraceIntegral(numfluxFwd[i], numfluxBwd[i],
1324 int var = inarray.size();
1326 if (inarray != outarray)
1329 for (
int i = 0; i < var; ++i)
1337 bool dumpInitialConditions,
1338 [[maybe_unused]]
const int domain)
1374 for (
int i = 0; i < nvar; i++)
1401 for (
int i = 0; i < nvar; ++i)
1408 if (dumpInitialConditions)
1414 for (
int i = 0; i < nvar; ++i)
1416 fields[i] =
m_fields[i]->GetPhys();
1427 int nq =
m_fields[0]->GetNpoints();
1468 int nq =
m_fields[0]->GetNpoints();
1474 m_fields[0]->GetCoords(x0, x1, x2);
1492 for (
int i = 0; i < 10000; ++i)
1496 (1.0 / cos(
m_n2 * omega) / cos(
m_n2 * omega) +
1497 1.0 / cos(
m_n1 * omega) / cos(
m_n1 * omega));
1499 newomega = omega - F / Fprime;
1501 if (fabs(newomega - omega) > Tol)
1514 std::complex<double> im =
sqrt(std::complex<double>(-1));
1515 std::complex<double> A1, A2, B1, B2;
1516 std::complex<double> Ak, Bk, nk;
1517 std::complex<double> Ec, Hc;
1520 A2 = exp(-1.0 * im * omega * (
m_n1 +
m_n2));
1521 B1 = A1 * exp(-2.0 * im *
m_n1 * omega);
1522 B2 = A2 * exp(2.0 * im *
m_n2 * omega);
1524 for (
int i = 0; i < nq; ++i)
1540 Ec = (Ak * exp(im * nk * omega * x0[i]) -
1541 Bk * exp(-im * nk * omega * x0[i])) *
1542 exp(im * omega * time);
1544 (Ak * exp(im * nk * omega * x0[i]) +
1545 Bk * exp(-im * nk * omega * x0[i])) *
1546 exp(im * omega * time);
1575 int nq =
m_fields[0]->GetNpoints();
1581 m_fields[0]->GetCoords(x0, x1, x2);
1596 for (
int i = 0; i < nq; ++i)
1598 switch (Polarization)
1602 Fx = -1.0 * (npi / omega) * sin(mpi * x0[i]) *
1603 cos(npi * x1[i]) * sin(omega * time);
1604 Fy = (mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1611 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1613 dFxdt = (npi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1615 dFydt = -1.0 * (mpi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1622 dFzdt[i] = omega * sin(mpi * x0[i]) * sin(npi * x1[i]) *
1629 Fx = -1.0 * (npi / omega) * cos(mpi * x0[i]) *
1630 sin(npi * x1[i]) * sin(omega * time);
1631 Fy = (mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1638 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1640 dFxdt = (npi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1642 dFydt = -1.0 * (mpi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1649 dFzdt[i] = omega * cos(mpi * x0[i]) * cos(npi * x1[i]) *
1706 int nq =
m_fields[0]->GetNpoints();
1712 m_fields[0]->GetCoords(x0, x1, x2);
1724 for (
int i = 0; i < nq; ++i)
1726 switch (Polarization)
1730 Fx = (npi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1732 Fy = -(mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1739 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1745 Fx = (npi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1747 Fy = -(mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1754 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1792 int nq =
m_fields[0]->GetTotPoints();
1817 NekDouble xj, yj, zj, sin_varphi, cos_varphi, sin_theta, cos_theta;
1819 for (
int i = 0; i < nq; i++)
1828 vth = -4.0 * sin_varphi * cos_varphi * cos_theta * cos_theta *
1829 cos_theta * sin_theta;
1831 -1.0 * sin_varphi * sin_varphi * cos_theta * cos_theta * cos_theta;
1832 velvec[0][i] = -vth * sin_theta * cos_varphi - vphi * sin_varphi;
1833 velvec[1][i] = -vth * sin_theta * sin_varphi + vphi * cos_varphi;
1834 velvec[2][i] = vth * cos_theta;
1836 E3[i] = (-4.0 * cos_theta * cos_theta * sin_theta * cos_varphi *
1838 (1.0 / omega * sin(omega * time));
1840 Fth = -omega * vth -
1841 (8.0 / omega) * cos_theta * sin_theta * cos_varphi * sin_varphi;
1842 Fphi = -omega * vphi +
1843 (4.0 / omega) * cos_varphi * cos_varphi * cos_theta *
1844 (2.0 * sin_theta * sin_theta - cos_theta * cos_theta);
1845 Fvec[0][i] = -Fth * sin_theta * cos_varphi - Fphi * sin_varphi;
1846 Fvec[1][i] = -Fth * sin_theta * sin_varphi + Fphi * cos_varphi;
1847 Fvec[2][i] = Fth * cos_theta;
1905 int nq =
m_fields[0]->GetTotPoints();
1914 int totnpts = totbdryexp * npts;
1933 m_fields[0]->ExtractTracePhys(x, xFwd);
1934 m_fields[0]->ExtractTracePhys(y, yFwd);
1936 for (
int i = 0; i < nTraceNumPoints; ++i)
1940 phiFwd[i] = atan2(yFwd[i] / radFwd[i], -1.0 * xFwd[i] / radFwd[i]);
1948 for (
int e = 0; e < totbdryexp; ++e)
1950 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1951 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
1953 Vmath::Vcopy(npts, &phiFwd[id2], 1, &Jphi[e * npts], 1);
1954 Vmath::Vcopy(npts, &radFwd[id2], 1, &Jrad[e * npts], 1);
1955 Vmath::Vcopy(npts, &ntimesHFwd[id2], 1, &Jcurrent[e * npts], 1);
1962 std::cout <<
"========================================================"
1965 std::cout <<
"phi = " << std::endl;
1966 for (
int i = 0; i < totnpts; ++i)
1968 std::cout << Jphi[i] <<
", ";
1970 std::cout << std::endl << std::endl;
1972 std::cout <<
"J = " << std::endl;
1973 for (
int i = 0; i < totnpts; ++i)
1975 std::cout << Jcurrent[i] <<
", ";
1977 std::cout << std::endl << std::endl;
1983 int nq =
m_fields[0]->GetTotPoints();
1996 for (
int i = 0; i < 2; i++)
2001 m_fields[0]->ExtractTracePhys(tmp, tmpFwd);
2003 &tmpFwd[0], 1, &outfield[0], 1, &outfield[0], 1);
2014 m_fields[0]->ExtractTracePhys(tmp, outfield);
2030 int nq =
m_fields[0]->GetNpoints();
2054 Vmath::Vsub(nq, PMLRegion, 1, RecPML, 1, CurvedPML, 1);
2062 NekDouble xRlayer, xLlayer, yRlayer, yLlayer;
2070 for (
int i = 0; i < nq; i++)
2073 if (x[i] >= xRlayer)
2075 xd = (x[i] - xRlayer) / PMLthickness;
2078 else if (x[i] <= xLlayer)
2080 xd = (xLlayer - x[i]) / PMLthickness;
2088 SigmaPML[0][i] = RecPML[i] * PMLmaxsigma * (xd * xd * xd);
2091 if (y[i] >= yRlayer)
2093 yd = (y[i] - yRlayer) / PMLthickness;
2096 else if (y[i] <= yLlayer)
2098 yd = (yLlayer - y[i]) / PMLthickness;
2106 SigmaPML[1][i] = PMLRegion[i] * PMLmaxsigma * (yd * yd * yd);
2116 for (
int i = 0; i < nq; i++)
2121 if (
rad >= PMLstart)
2123 relrad = (
rad - PMLstart) / PMLthickness;
2125 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2134 NekDouble relrad, radon, radtw, radth, radfo;
2135 for (
int i = 0; i < nq; i++)
2137 radon = -1.0 * x[i] + y[i] - 7;
2138 radtw = x[i] + y[i] - 7;
2139 radth = -x[i] - y[i] - 7;
2140 radfo = x[i] - y[i] - 7;
2144 relrad = radon / PMLthickness;
2146 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2151 relrad = radtw / PMLthickness;
2153 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2158 relrad = radth / PMLthickness;
2160 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2165 relrad = radfo / PMLthickness;
2167 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2174 std::cout <<
"*** sigma1 = [ " <<
Vmath::Vmin(nq, &SigmaPML[0][0], 1)
2176 <<
" ] , sigma2 = [ " <<
Vmath::Vmin(nq, &SigmaPML[1][0], 1)
2177 <<
" , " <<
Vmath::Vmax(nq, &SigmaPML[1][0], 1) <<
" ] "
2189 for (
int i = 0; i < 3; ++i)
2191 Vmath::Vvtvp(nq, &fields[i][0], 1, &fields[i][0], 1, &tmp[0], 1,
2195 energy = 0.5 * (
m_fields[0]->Integral(tmp));
2228 m_fields[0]->GenerateElementVector(
2255 m_fields[0]->GenerateElementVector(
2257 m_fields[0]->GenerateElementVector(
2298 [[maybe_unused]]
const bool Dispersion)
2312 NekDouble boveradel = m_b / (m_b - m_adel);
2320 if (fabs(la * lb - 1.0) < 0.00001)
2322 ExactCloakArea =
m_pi * (m_b * m_b - m_a * m_a);
2327 ExactCloakArea =
m_pi * (3.0 * lb * 3.0 * la - lb * la);
2332 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2333 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2341 for (
int i = 0; i < nq; ++i)
2343 if (Cloakregion[i] > 0)
2347 ratio = (radvec[i] - m_adel) / radvec[i];
2349 epsvec[0][i] = boveradel * boveradel;
2354 (1.0 - boveradel * boveradel * ratio * ratio) +
2360 epsvec[1][i] = boveradel * boveradel * (ratio * ratio);
2388 Vmath::Vsub(nq, Cloakregion, 1, Vacregion, 1, Cloakregion, 1);
2391 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2392 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2400 for (
int i = 0; i < nq; ++i)
2402 if (Cloakregion[i] > 0)
2408 epsvec[0][i] = radvec[i] / (radvec[i] - m_adel);
2409 epsvec[1][i] = (radvec[i] - m_adel) / radvec[i];
2410 muvec[2][i] = (m_b / (m_b - m_adel)) * (m_b / (m_b - m_adel)) *
2411 (radvec[i] - m_adel) / radvec[i];
2413 muvec[0][i] = epsvec[0][i];
2414 muvec[1][i] = epsvec[1][i];
2415 epsvec[2][i] = muvec[2][i];
2424 int nq =
m_fields[0]->GetTotPoints();
2432 &Sigma1minus0[0], 1);
2434 &Sigma0minus1[0], 1);
2436 &Sigma0plus1Neg[0], 1);
2451 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2452 &outarray[indxH0][0], 1, &outarray[indxH0][0], 1);
2453 Vmath::Vadd(nq, &physarray[indxQ0][0], 1, &outarray[indxH0][0], 1,
2454 &outarray[indxH0][0], 1);
2457 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2458 &outarray[indxH1][0], 1, &outarray[indxH1][0], 1);
2459 Vmath::Vadd(nq, &physarray[indxQ1][0], 1, &outarray[indxH1][0], 1,
2460 &outarray[indxH1][0], 1);
2463 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxE2][0], 1,
2464 &outarray[indxE2][0], 1, &outarray[indxE2][0], 1);
2465 Vmath::Vadd(nq, &physarray[indxP2][0], 1, &outarray[indxE2][0], 1,
2466 &outarray[indxE2][0], 1);
2469 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2470 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2472 &outarray[indxQ0][0], 1);
2476 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2477 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2479 &outarray[indxQ1][0], 1);
2485 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2490 &outarray[indxP2][0], 1);
2491 Vmath::Vmul(nq, &physarray[indxE2][0], 1, &outarray[indxP2][0], 1,
2492 &outarray[indxP2][0], 1);
2507 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE0][0], 1,
2508 &outarray[indxE0][0], 1, &outarray[indxE0][0], 1);
2509 Vmath::Vsub(nq, &outarray[indxE0][0], 1, &physarray[indxQ0][0], 1,
2510 &outarray[indxE0][0], 1);
2513 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE1][0], 1,
2514 &outarray[indxE1][0], 1, &outarray[indxE1][0], 1);
2515 Vmath::Vsub(nq, &outarray[indxE1][0], 1, &physarray[indxQ1][0], 1,
2516 &outarray[indxE1][0], 1);
2519 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxH2][0], 1,
2520 &outarray[indxH2][0], 1, &outarray[indxH2][0], 1);
2521 Vmath::Vsub(nq, &outarray[indxH2][0], 1, &physarray[indxP2][0], 1,
2522 &outarray[indxH2][0], 1);
2525 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE0][0], 1,
2526 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2528 &outarray[indxQ0][0], 1);
2532 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE1][0], 1,
2533 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2535 &outarray[indxQ1][0], 1);
2541 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2546 &outarray[indxP2][0], 1);
2547 Vmath::Vmul(nq, &physarray[indxH2][0], 1, &outarray[indxP2][0], 1,
2548 &outarray[indxP2][0], 1);
2562 int nq =
m_fields[0]->GetTotPoints();
2563 int ncoeffs =
m_fields[0]->GetNcoeffs();
2565 std::string outname =
m_sessionName +
"Tot_" + std::to_string(n) +
".chk";
2567 std::vector<std::string> variables(nvar);
2568 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2570 for (
int i = 0; i < nvar; ++i)
2576 for (
int i = 0; i < nvar; ++i)
2579 Vmath::Vadd(nq, fieldphys[i], 1, totfield, 1, totfield, 1);
2581 m_fields[i]->FwdTrans(totfield, fieldcoeffs[i]);
2593 int nq =
m_fields[0]->GetTotPoints();
2594 int ncoeffs =
m_fields[0]->GetNcoeffs();
2596 std::string outname =
m_sessionName +
"Plot_" + std::to_string(n) +
".chk";
2598 std::vector<std::string> variables(nvar);
2599 variables[0] =
"Fx";
2600 variables[1] =
"Fy";
2601 variables[2] =
"Fz";
2603 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2604 for (
int i = 0; i < nvar; ++i)
2615 &tmp[0], 1, &tmp[0], 1);
2617 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2628 int nq =
m_fields[0]->GetTotPoints();
2629 int ncoeffs =
m_fields[0]->GetNcoeffs();
2631 std::string outname =
2634 std::vector<std::string> variables(nvar);
2635 variables[0] =
"Frx";
2636 variables[1] =
"Fry";
2637 variables[2] =
"Frz";
2638 for (
int i = 3; i < nvar; ++i)
2643 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2644 for (
int i = 0; i < nvar; ++i)
2654 Vmath::Vadd(nq, fieldphys[0], 1, totfield0, 1, totfield0, 1);
2657 Vmath::Vadd(nq, fieldphys[1], 1, totfield1, 1, totfield1, 1);
2664 &tmp[0], 1, &tmp[0], 1);
2666 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2669 for (
int j = 3; j < nvar; ++j)
2671 m_fields[j]->FwdTrans(fieldphys[j], fieldcoeffs[j]);
2678 const int n, [[maybe_unused]]
const NekDouble time,
2682 int nq =
m_fields[0]->GetTotPoints();
2683 int ncoeffs =
m_fields[0]->GetNcoeffs();
2685 std::string outname =
2688 std::vector<std::string> variables(nvar);
2689 variables[0] =
"EDFx";
2690 variables[1] =
"EDFy";
2691 variables[2] =
"EDFz";
2692 for (
int i = 3; i < nvar; ++i)
2697 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2698 for (
int i = 0; i < nvar; ++i)
2712 &tmp[0], 1, &tmp[0], 1);
2714 Vmath::Vmul(nq, &fieldphys[2][0], 1, &tmp[0], 1, &tmp[0], 1);
2721 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2728 const int n, [[maybe_unused]]
const NekDouble time,
2732 int nq =
m_fields[0]->GetTotPoints();
2733 int ncoeffs =
m_fields[0]->GetNcoeffs();
2735 std::string outname =
2738 std::vector<std::string> variables(nvar);
2739 variables[0] =
"Energy";
2740 variables[1] =
"EnergyFlux";
2741 variables[2] =
"Zero";
2742 for (
int i = 3; i < nvar; ++i)
2747 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2748 for (
int i = 0; i < nvar; ++i)
2762 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1, &energy[0],
2766 m_fields[0]->FwdTrans(energy, fieldcoeffs[0]);
2771 for (
int k = 0; k < 2; ++k)
2777 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1,
2778 &energyflux[0], 1, &energyflux[0], 1);
2782 Vmath::Vmul(nq, &fieldphys[2][0], 1, &energyflux[0], 1, &energyflux[0], 1);
2784 m_fields[1]->FwdTrans(energyflux, fieldcoeffs[1]);
2796 int nq =
m_fields[0]->GetTotPoints();
2797 int ncoeffs =
m_fields[0]->GetNcoeffs();
2811 1.0 / (1.0 + exp(-0.5 * (time -
m_PSduration) / SFradius));
2813 for (
int j = 0; j < nq; ++j)
2815 rad =
sqrt((x[j] - Psx) * (x[j] - Psx) + (y[j] - Psy) * (y[j] - Psy) +
2816 (
z[j] - Psz) * (
z[j] - Psz));
2817 outarray[j] = SmoothFactor * exp(-1.0 * (
rad / Gaussianradius) *
2818 (
rad / Gaussianradius));
2821 m_fields[0]->FwdTransLocalElmt(outarray, tmpc);
2822 m_fields[0]->BwdTrans(tmpc, outarray);
2834 NekDouble sin_theta, cos_theta, sin_varphi, cos_varphi;
2843 for (
int j = 0; j < nq; ++j)
2852 outarray[j] = 2.0 * m_Omega * sin_theta;
2861 int nq = physarray[0].size();
2903 Vmath::Vadd(nq, tmp, 1, outarray[j], 1, outarray[j], 1);
2918 if (CloakNlayer == 8)
2921 if (fabs(la * lb - 1.0) < 0.0001)
2947 if (CloakNlayer == 16)
2950 if (fabs(la * lb - 1.0) < 0.0001)
2996 m_fields[0]->GetCoords(x0, x1, x2);
3002 m_fields[0]->GenerateElementVector(Layer[0], 1.0, 0.0, Currenttmp);
3004 for (
int i = 1; i < CloakNlayer; ++i)
3006 m_fields[0]->GenerateElementVector(Layer[i], 1.0, 0.0, Currenttmp);
3007 m_fields[0]->GenerateElementVector(Layer[i - 1], 1.0, 0.0, Formertmp);
3009 Vmath::Vsub(nq, Currenttmp, 1, Formertmp, 1, Currenttmp, 1);
3011 Vmath::Svtvp(nq, 1.0 * (i + 1), Currenttmp, 1, Cloakregion, 1,
3017 for (
int i = 0; i < nq; ++i)
3023 if ((Cloakregion[i] > 0) && (CloakNlayer > 0))
3025 radvec[i] = 1.0 + (m_b - m_a) / CloakNlayer *
3026 (Cloakregion[i] - 0.5);
3032 sqrt(x0[i] * x0[i] / la / la + x1[i] * x1[i] / lb / lb);
3039 radvec[i] =
sqrt(2.0 * x0[i] * x0[i] +
3040 x1[i] * x1[i] * x1[i] * x1[i] + x1[i] * x1[i]);
3046 radvec[i] =
sqrt(3.0 * x0[i] * x0[i] +
3047 x1[i] * x1[i] * x1[i] * x1[i] - x1[i] * x1[i]);
3063 s,
"TestMaxwellType",
3129 int Ntot = inarray.size();
3132 for (
int i = 0; i < Ntot; ++i)
3134 std::cout <<
"[" << i <<
"] = " << inarray[2][i] << std::endl;
3137 reval =
sqrt(reval / Ntot);
#define ASSERTL0(condition, msg)
const char *const CloakTypeMap[]
const char *const SourceTypeMap[]
@ eOpticalDispersiveCloak
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
void Checkpoint_EDFluxOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &fieldphys)
Array< OneD, NekDouble > m_mu
void AddCoriolis(Array< OneD, Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the RHS.
Array< OneD, NekDouble > TestMaxwellSphere(const NekDouble time, const NekDouble omega, unsigned int field)
Array< OneD, NekDouble > m_coriolis
Array< OneD, Array< OneD, NekDouble > > m_CrossProductMF
NekDouble m_Gaussianradius
void WeakDGMaxwellDirDeriv(const Array< OneD, const Array< OneD, NekDouble > > &InField, Array< OneD, Array< OneD, NekDouble > > &OutField, const NekDouble time=0.0)
Calculate weak DG advection in the form .
Array< OneD, NekDouble > ComputeRadCloak(const int Nlayer=5)
void print_MMF(Array< OneD, Array< OneD, NekDouble > > &inarray)
Array< OneD, NekDouble > TestMaxwell2DPEC(const NekDouble time, unsigned int field, const SolverUtils::PolType Polarization)
Array< OneD, NekDouble > m_SourceVector
NekDouble ComputeEnergyDensity(Array< OneD, Array< OneD, NekDouble > > &fields)
NekDouble m_Cloakraddelta
static std::string className
Name of class.
void Checkpoint_EnergyOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &fieldphys)
~MMFMaxwell() override
Destructor.
void Checkpoint_TotalFieldOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &fieldphys)
void ComputeMaterialMicroWaveCloak(const Array< OneD, const NekDouble > &radvec, Array< OneD, Array< OneD, NekDouble > > &epsvec, Array< OneD, Array< OneD, NekDouble > > &muvec)
Array< OneD, NekDouble > ComputeSurfaceCurrent(const int time, const Array< OneD, const Array< OneD, NekDouble > > &fields)
Array< OneD, Array< OneD, NekDouble > > m_SigmaPML
void Checkpoint_TotPlotOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &fieldphys)
Array< OneD, NekDouble > m_varepsilon
MMFMaxwell(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the projection.
void v_InitObject(bool DeclareFields=true) override
Initialise the object.
void ComputeMaterialOpticalCloak(const Array< OneD, const NekDouble > &radvec, Array< OneD, Array< OneD, NekDouble > > &epsvec, Array< OneD, Array< OneD, NekDouble > > &muvec, const bool Dispersion=false)
void AddGreenDerivCompensate(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void ComputeMaterialVector(Array< OneD, Array< OneD, NekDouble > > &epsvec, Array< OneD, Array< OneD, NekDouble > > &muvec)
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
int m_PrintoutSurfaceCurrent
void GenerateSigmaPML(const NekDouble PMLthickness, const NekDouble PMLstart, const NekDouble PMLmaxsigma, Array< OneD, Array< OneD, NekDouble > > &SigmaPML)
Array< OneD, NekDouble > GaussianPulse(const NekDouble time, const NekDouble Psx, const NekDouble Psy, const NekDouble Psz, const NekDouble Gaussianradius)
void Printout_SurfaceCurrent(Array< OneD, Array< OneD, NekDouble > > &fields, const int time)
void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time) override
void v_DoSolve() override
Solves an unsteady problem.
Array< OneD, NekDouble > m_wp2
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print Summary.
void AddPML(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void v_SetInitialConditions(const NekDouble initialtime, bool dumpInitialConditions, const int domain) override
Array< OneD, NekDouble > TestMaxwell2DPMC(const NekDouble time, unsigned int field, const SolverUtils::PolType Polarization)
Array< OneD, NekDouble > EvaluateCoriolis()
Array< OneD, NekDouble > TestMaxwell1D(const NekDouble time, unsigned int field)
void Checkpoint_PlotOutput(const int n, const Array< OneD, const Array< OneD, NekDouble > > &fieldphys)
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT int GetTraceNpoints()
NekDouble m_timestep
Time step size.
int m_infosteps
Number of time steps between outputting status information.
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
NekDouble m_fintime
Finish time of the simulation.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
NekDouble m_checktime
Time between checkpoints.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
std::string m_sessionName
Name of the session.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
int m_steps
Number of steps to take.
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetTotPoints()
A base class for PDEs which include an advection component.
SOLVER_UTILS_EXPORT void GetMaxwellFluxVector(const int var, const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &flux)
SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Virtual function for generating summary information.
SOLVER_UTILS_EXPORT void DeriveCrossProductMF(Array< OneD, Array< OneD, NekDouble > > &CrossProductMF)
SOLVER_UTILS_EXPORT void NumericalMaxwellFlux(Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &numfluxFwd, Array< OneD, Array< OneD, NekDouble > > &numfluxBwd, const NekDouble time=0.0)
SOLVER_UTILS_EXPORT void AdddedtMaxwell(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
SOLVER_UTILS_EXPORT void ComputeZimYim(Array< OneD, Array< OneD, NekDouble > > &epsvec, Array< OneD, Array< OneD, NekDouble > > &muvec)
Array< OneD, Array< OneD, NekDouble > > m_muvec
SpatialDomains::GeomMMF m_MMFdir
Array< OneD, Array< OneD, NekDouble > > m_movingframes
Array< OneD, NekDouble > m_MMFfactors
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > GetIncidentField(const int var, const NekDouble time)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_ntimesMFFwd
Array< OneD, Array< OneD, NekDouble > > m_negepsvecminus1
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > CartesianToMovingframes(const Array< OneD, const Array< OneD, NekDouble > > &uvec, unsigned int field)
Array< OneD, Array< OneD, NekDouble > > m_epsvec
SOLVER_UTILS_EXPORT void CartesianToSpherical(const NekDouble x0j, const NekDouble x1j, const NekDouble x2j, NekDouble &sin_varphi, NekDouble &cos_varphi, NekDouble &sin_theta, NekDouble &cos_theta)
Array< OneD, Array< OneD, NekDouble > > m_negmuvecminus1
SOLVER_UTILS_EXPORT void ComputeNtimesMF()
SOLVER_UTILS_EXPORT NekDouble RootMeanSquare(const Array< OneD, const NekDouble > &inarray)
SOLVER_UTILS_EXPORT void MMFInitObject(const Array< OneD, const Array< OneD, NekDouble > > &Anisotropy, const int TangentXelem=-1)
TestMaxwellType m_TestMaxwellType
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_CurlMF
SOLVER_UTILS_EXPORT void Computedemdxicdote()
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
std::vector< int > m_intVariables
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
static NekDouble rad(NekDouble x, NekDouble y)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static const NekDouble kNekZeroTol
const char *const IncTypeMap[]
std::vector< std::pair< std::string, std::string > > SummaryList
@ SIZE_TestMaxwellType
Length of enum list.
@ eTestMaxwell2DPECAVGFLUX
EquationSystemFactory & GetEquationSystemFactory()
const char *const TestMaxwellTypeMap[]
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
const char *const PolTypeMap[]
@ eTangentIrregular
Circular around the centre of domain.
@ eTangentCircular
Circular around the centre of domain.
@ eTangentNonconvex
Circular around the centre of domain.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::vector< double > z(NPUPPER)
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*x + y.
void Neg(int n, T *x, const int incx)
Negate x = -x.
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector minus vector): z = w*x - y
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
void Zero(int n, T *x, const int incx)
Zero vector.
T Vamax(int n, const T *x, const int incx)
Return the maximum absolute element in x called vamax to avoid conflict with max.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
scalarT< T > sqrt(scalarT< T > in)