37#include <boost/algorithm/string.hpp>
38#include <boost/algorithm/string/predicate.hpp>
39#include <boost/core/ignore_unused.hpp>
71 int shapedim =
m_fields[0]->GetShapeDimension();
124 for (
int j = 0; j < shapedim; ++j)
138 if (
m_session->DefinesSolverInfo(
"TESTMAXWELLTYPE"))
140 std::string TestMaxwellTypeStr =
141 m_session->GetSolverInfo(
"TESTMAXWELLTYPE");
159 if (
m_session->DefinesSolverInfo(
"POLTYPE"))
161 std::string PolTypeStr =
m_session->GetSolverInfo(
"POLTYPE");
177 if (
m_session->DefinesSolverInfo(
"INCTYPE"))
179 std::string IncTypeStr =
m_session->GetSolverInfo(
"INCTYPE");
195 if (
m_session->DefinesSolverInfo(
"CLOAKTYPE"))
197 std::string CloakTypeStr =
m_session->GetSolverInfo(
"CLOAKTYPE");
213 if (
m_session->DefinesSolverInfo(
"SOURCETYPE"))
215 std::string SourceTypeStr =
m_session->GetSolverInfo(
"SOURCETYPE");
258 std::cout <<
"*** rad = [ " <<
Vmath::Vmax(nq, radvec, 1) <<
" , "
259 <<
Vmath::Vmin(nq, radvec, 1) <<
" ) " << std::endl;
270 std::cout <<
"*** rad = [ " <<
Vmath::Vmax(nq, radvec, 1) <<
" , "
271 <<
Vmath::Vmin(nq, radvec, 1) <<
" ) " << std::endl;
291 NekDouble eps1min, eps1max, eps2min, eps2max, eps3min, eps3max;
292 NekDouble mu1min, mu1max, mu2min, mu2max, mu3min, mu3max;
328 std::cout <<
"*** epsvec1 = [ " << eps1min <<
" , " << eps1max
329 <<
" ], epsvec2 = [ " << eps2min <<
" , " << eps2max
330 <<
" ], epsvec3 = [ " << eps3min <<
" , " << eps3max <<
" ] "
332 std::cout <<
"*** muvec1 = [ " << mu1min <<
" , " << mu1max
333 <<
" ], muvec2 = [ " << mu2min <<
" , " << mu2max
334 <<
" ], muvec3 = [ " << mu3min <<
" , " << mu3max <<
" ] "
343 dtFactor = mu1min * eps3min;
346 dtFactor = mu2min * eps3min;
353 dtFactor = eps1min * mu3min;
354 if (eps1min > eps2min)
356 dtFactor = eps2min * mu3min;
367 std::cout <<
"*** dt factor proportional to varepsilon * mu is " << dtFactor
405 std::cout <<
"*** negepsvecminus1 = [ " << eps1min <<
" , " << eps1max
406 <<
" ], negepsvecminus1 = [ " << eps2min <<
" , " << eps2max
407 <<
" ], negepsvecminus1 = [ " << eps3min <<
" , " << eps3max
408 <<
" ] " << std::endl;
409 std::cout <<
"*** negmuvecminus1 = [ " << mu1min <<
" , " << mu1max
410 <<
" ], negmuvecminus1 = [ " << mu2min <<
" , " << mu2max
411 <<
" ], negmuvecminus1 = [ " << mu3min <<
" , " << mu3max <<
" ] "
438 ASSERTL0(
false,
"Implicit unsteady Advection not set up.");
460 for (i = 0; i < nfields; ++i)
464 nvariables = nfields;
476 for (i = 0; i < nvariables; ++i)
489 "Only one of IO_CheckTime and IO_CheckSteps "
498 bool doCheckTime =
false;
523 for (i = 0; i < nq; ++i)
528 std::cout <<
"rad" <<
rad << std::endl;
550 for (i = 0; i < nq; ++i)
559 std::cout <<
"*** Area of Planar Source = "
569 int P1indx = 0, P2indx = 0, P3indx = 0;
587 for (
int i = 0; i < nq; ++i)
589 rad =
sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i]) * (y[i]));
598 for (
int i = 0; i < nq; ++i)
601 sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i] - 1.5) * (y[i] - 1.5));
609 for (
int i = 0; i < nq; ++i)
612 sqrt((x[i] + 3.0) * (x[i] + 3.0) + (y[i] - 3.0) * (y[i] - 3.0));
638 std::cout <<
"Steps: " << std::setw(8) << std::left << step + 1
640 <<
"Time: " << std::setw(12) << std::left <<
m_time;
642 std::stringstream ss;
643 ss << cpuTime / 60.0 <<
" min.";
644 std::cout <<
" CPU Time: " << std::setw(8) << std::left << ss.str()
669 for (
int i = 0; i < 3; ++i)
685 for (i = 0; i < nvariables; ++i)
700 TimeSeries[indx] =
m_time;
717 <<
", Energy = " << Energy[indx] << std::endl;
727 m_fields[0]->GetBndCondExpansions()[0]->GetExpSize();
729 ->GetBndCondExpansions()[0]
743 m_fields[0]->ExtractTracePhys(fields[0], E1Fwd);
744 m_fields[0]->ExtractTracePhys(fields[1], E2Fwd);
745 m_fields[0]->ExtractTracePhys(fields[2], H3Fwd);
756 for (
int e = 0; e < totbdryexp; ++e)
758 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
759 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(
770 if (E1atPEC < E1atPECloc)
772 E1atPEC = E1atPECloc;
775 if (E2atPEC < E2atPECloc)
777 E2atPEC = E2atPECloc;
780 if (H3atPEC < H3atPECloc)
782 H3atPEC = H3atPECloc;
786 std::cout <<
"At PEC, Max. E1 = " << E1atPEC
787 <<
", E2 = " << E2atPEC <<
", H3 = " << H3atPEC
793 Ezantipod[cntap++] = fields[2][indxantipod];
798 P1[cntpml] = fields[2][P1indx];
799 P2[cntpml] = fields[2][P2indx];
800 P3[cntpml] = fields[2][P3indx];
813 std::cout <<
"Time-integration : " << intTime <<
"s" << std::endl;
815 std::cout <<
"TimeSeries = " << std::endl;
818 std::cout << TimeSeries[i] <<
", ";
820 std::cout << std::endl << std::endl;
822 std::cout <<
"Energy Density = " << std::endl;
825 std::cout << Energy[i] <<
", ";
827 std::cout << std::endl << std::endl;
836 std::cout <<
"Ez at antipod = " << std::endl;
839 std::cout << Ezantipod[i] <<
", ";
841 std::cout << std::endl << std::endl;
846 std::cout <<
"P1 = " << std::endl;
849 std::cout << P1[i] <<
", ";
851 std::cout << std::endl << std::endl;
853 std::cout <<
"P2 = " << std::endl;
856 std::cout << P2[i] <<
", ";
858 std::cout << std::endl << std::endl;
860 std::cout <<
"P3 = " << std::endl;
863 std::cout << P3[i] <<
", ";
865 std::cout << std::endl << std::endl;
869 for (i = 0; i < nvariables; ++i)
875 for (i = 0; i < nvariables; ++i)
894 int nvar = inarray.size();
900 for (i = 0; i < nvar; ++i)
905 Vmath::Vcopy(nq, &inarray[i][0], 1, &physarray[i][0], 1);
908 for (i = 0; i < nvar; i++)
925 for (
int i = 0; i < 3; ++i)
936 for (
int i = 0; i < 3; ++i)
939 Vmath::Vcopy(ncoeffs, &tmpout[i][0], 1, &modarray[i][0], 1);
953 for (i = 0; i < nvar; ++i)
955 m_fields[i]->MultiplyByElmtInvMass(modarray[i], modarray[i]);
956 m_fields[i]->BwdTrans(modarray[i], outarray[i]);
962 for (
int j = 0; j < 2; ++j)
965 Vmath::Vadd(nq, &F[0], 1, &outarray[j][0], 1, &outarray[j][0], 1);
972 AddPML(physarray, outarray);
1006 m_fields[0]->GetCoords(x0, x1, x2);
1009 NekDouble uxx, uxy, uyy, detu, uti, uri;
1029 for (
int i = 0; i < nq; i++)
1032 tmpIN[i] * (1.0 - 2 * x0[i] * x0[i]) + (1.0 - tmpIN[i]);
1035 for (
int i = 0; i < nq; ++i)
1037 theta = atan2((x1[i] + 2.0), (x0[i] + 2.0));
1042 uxx = uti * cos(theta) * cos(theta) +
1043 uri * sin(theta) * sin(theta);
1044 uyy = uti * sin(theta) * sin(theta) +
1045 uri * cos(theta) * cos(theta);
1046 uxy = (uti - uri) * cos(theta) * sin(theta);
1048 detu = uxx * uyy - uxy * uxy;
1050 tmpx = outarray[0][i] + (1.0 - uxx) * Hxdt[i] - uxy * Hydt[i];
1051 tmpy = outarray[1][i] - uxy * Hxdt[i] + (1.0 - uyy) * Hydt[i];
1053 outarray[0][i] = (1 / detu) * (uyy * tmpx - uxy * tmpy);
1054 outarray[1][i] = (1 / detu) * (-uxy * tmpx + uxx * tmpy);
1071 outarray[0], 1, outarray[0], 1);
1075 outarray[1], 1, outarray[1], 1);
1079 outarray[2], 1, outarray[2], 1);
1086 outarray[0], 1, outarray[0], 1);
1090 outarray[1], 1, outarray[1], 1);
1094 outarray[2], 1, outarray[2], 1);
1113 outarray[0], 1, outarray[0], 1);
1117 outarray[1], 1, outarray[1], 1);
1121 outarray[2], 1, outarray[2], 1);
1128 outarray[0], 1, outarray[0], 1);
1142 outarray[1], 1, outarray[1], 1);
1147 outarray[2], 1, outarray[2], 1);
1176 int ncoeffs = outarray[0].size();
1177 int nq = physarray[0].size();
1211 m_fields[var]->IProductWRTBase(tmp, tmpc);
1212 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1219 m_fields[var]->IProductWRTBase(tmp, tmpc);
1220 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1227 &tmp[0], 1, &tmp[0], 1);
1228 m_fields[var]->IProductWRTBase(tmp, tmpc);
1229 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1265 for (i = 0; i < nvar; ++i)
1267 physfield[i] = InField[i];
1271 for (i = 0; i < nvar; ++i)
1281 fluxvector[j], tmpc);
1282 Vmath::Vadd(ncoeffs, &tmpc[0], 1, &OutField[i][0], 1,
1283 &OutField[i][0], 1);
1293 for (i = 0; i < nvar; ++i)
1304 for (i = 0; i < nvar; ++i)
1307 m_fields[i]->AddFwdBwdTraceIntegral(numfluxFwd[i], numfluxBwd[i],
1324 boost::ignore_unused(time);
1326 int var = inarray.size();
1328 if (inarray != outarray)
1331 for (
int i = 0; i < var; ++i)
1339 bool dumpInitialConditions,
1342 boost::ignore_unused(domain);
1378 for (
int i = 0; i < nvar; i++)
1405 for (
int i = 0; i < nvar; ++i)
1412 if (dumpInitialConditions)
1418 for (
int i = 0; i < nvar; ++i)
1420 fields[i] =
m_fields[i]->GetPhys();
1431 int nq =
m_fields[0]->GetNpoints();
1472 int nq =
m_fields[0]->GetNpoints();
1478 m_fields[0]->GetCoords(x0, x1, x2);
1496 for (
int i = 0; i < 10000; ++i)
1500 (1.0 / cos(
m_n2 * omega) / cos(
m_n2 * omega) +
1501 1.0 / cos(
m_n1 * omega) / cos(
m_n1 * omega));
1503 newomega = omega - F / Fprime;
1505 if (fabs(newomega - omega) > Tol)
1518 std::complex<double> im =
sqrt(std::complex<double>(-1));
1519 std::complex<double> A1, A2, B1, B2;
1520 std::complex<double> Ak, Bk, nk;
1521 std::complex<double> Ec, Hc;
1524 A2 = exp(-1.0 * im * omega * (
m_n1 +
m_n2));
1525 B1 = A1 * exp(-2.0 * im *
m_n1 * omega);
1526 B2 = A2 * exp(2.0 * im *
m_n2 * omega);
1528 for (
int i = 0; i < nq; ++i)
1544 Ec = (Ak * exp(im * nk * omega * x0[i]) -
1545 Bk * exp(-im * nk * omega * x0[i])) *
1546 exp(im * omega * time);
1548 (Ak * exp(im * nk * omega * x0[i]) +
1549 Bk * exp(-im * nk * omega * x0[i])) *
1550 exp(im * omega * time);
1576 const NekDouble time,
unsigned int field,
1579 int nq =
m_fields[0]->GetNpoints();
1585 m_fields[0]->GetCoords(x0, x1, x2);
1600 for (
int i = 0; i < nq; ++i)
1602 switch (Polarization)
1606 Fx = -1.0 * (npi / omega) * sin(mpi * x0[i]) *
1607 cos(npi * x1[i]) * sin(omega * time);
1608 Fy = (mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1615 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1617 dFxdt = (npi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1619 dFydt = -1.0 * (mpi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1626 dFzdt[i] = omega * sin(mpi * x0[i]) * sin(npi * x1[i]) *
1633 Fx = -1.0 * (npi / omega) * cos(mpi * x0[i]) *
1634 sin(npi * x1[i]) * sin(omega * time);
1635 Fy = (mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1642 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1644 dFxdt = (npi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1646 dFydt = -1.0 * (mpi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1653 dFzdt[i] = omega * cos(mpi * x0[i]) * cos(npi * x1[i]) *
1707 const NekDouble time,
unsigned int field,
1710 int nq =
m_fields[0]->GetNpoints();
1716 m_fields[0]->GetCoords(x0, x1, x2);
1728 for (
int i = 0; i < nq; ++i)
1730 switch (Polarization)
1734 Fx = (npi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1736 Fy = -(mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1743 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1749 Fx = (npi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1751 Fy = -(mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1758 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1796 int nq =
m_fields[0]->GetTotPoints();
1821 NekDouble xj, yj, zj, sin_varphi, cos_varphi, sin_theta, cos_theta;
1823 for (
int i = 0; i < nq; i++)
1832 vth = -4.0 * sin_varphi * cos_varphi * cos_theta * cos_theta *
1833 cos_theta * sin_theta;
1835 -1.0 * sin_varphi * sin_varphi * cos_theta * cos_theta * cos_theta;
1836 velvec[0][i] = -vth * sin_theta * cos_varphi - vphi * sin_varphi;
1837 velvec[1][i] = -vth * sin_theta * sin_varphi + vphi * cos_varphi;
1838 velvec[2][i] = vth * cos_theta;
1840 E3[i] = (-4.0 * cos_theta * cos_theta * sin_theta * cos_varphi *
1842 (1.0 / omega * sin(omega * time));
1844 Fth = -omega * vth -
1845 (8.0 / omega) * cos_theta * sin_theta * cos_varphi * sin_varphi;
1846 Fphi = -omega * vphi +
1847 (4.0 / omega) * cos_varphi * cos_varphi * cos_theta *
1848 (2.0 * sin_theta * sin_theta - cos_theta * cos_theta);
1849 Fvec[0][i] = -Fth * sin_theta * cos_varphi - Fphi * sin_varphi;
1850 Fvec[1][i] = -Fth * sin_theta * sin_varphi + Fphi * cos_varphi;
1851 Fvec[2][i] = Fth * cos_theta;
1909 int nq =
m_fields[0]->GetTotPoints();
1918 int totnpts = totbdryexp * npts;
1937 m_fields[0]->ExtractTracePhys(x, xFwd);
1938 m_fields[0]->ExtractTracePhys(y, yFwd);
1940 for (
int i = 0; i < nTraceNumPoints; ++i)
1944 phiFwd[i] = atan2(yFwd[i] / radFwd[i], -1.0 * xFwd[i] / radFwd[i]);
1952 for (
int e = 0; e < totbdryexp; ++e)
1954 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1955 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
1957 Vmath::Vcopy(npts, &phiFwd[id2], 1, &Jphi[e * npts], 1);
1958 Vmath::Vcopy(npts, &radFwd[id2], 1, &Jrad[e * npts], 1);
1959 Vmath::Vcopy(npts, &ntimesHFwd[id2], 1, &Jcurrent[e * npts], 1);
1966 std::cout <<
"========================================================"
1969 std::cout <<
"phi = " << std::endl;
1970 for (
int i = 0; i < totnpts; ++i)
1972 std::cout << Jphi[i] <<
", ";
1974 std::cout << std::endl << std::endl;
1976 std::cout <<
"J = " << std::endl;
1977 for (
int i = 0; i < totnpts; ++i)
1979 std::cout << Jcurrent[i] <<
", ";
1981 std::cout << std::endl << std::endl;
1987 int nq =
m_fields[0]->GetTotPoints();
2000 for (
int i = 0; i < 2; i++)
2005 m_fields[0]->ExtractTracePhys(tmp, tmpFwd);
2007 &tmpFwd[0], 1, &outfield[0], 1, &outfield[0], 1);
2018 m_fields[0]->ExtractTracePhys(tmp, outfield);
2034 int nq =
m_fields[0]->GetNpoints();
2058 Vmath::Vsub(nq, PMLRegion, 1, RecPML, 1, CurvedPML, 1);
2066 NekDouble xRlayer, xLlayer, yRlayer, yLlayer;
2074 for (
int i = 0; i < nq; i++)
2077 if (x[i] >= xRlayer)
2079 xd = (x[i] - xRlayer) / PMLthickness;
2082 else if (x[i] <= xLlayer)
2084 xd = (xLlayer - x[i]) / PMLthickness;
2092 SigmaPML[0][i] = RecPML[i] * PMLmaxsigma * (xd * xd * xd);
2095 if (y[i] >= yRlayer)
2097 yd = (y[i] - yRlayer) / PMLthickness;
2100 else if (y[i] <= yLlayer)
2102 yd = (yLlayer - y[i]) / PMLthickness;
2110 SigmaPML[1][i] = PMLRegion[i] * PMLmaxsigma * (yd * yd * yd);
2120 for (
int i = 0; i < nq; i++)
2125 if (
rad >= PMLstart)
2127 relrad = (
rad - PMLstart) / PMLthickness;
2129 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2138 NekDouble relrad, radon, radtw, radth, radfo;
2139 for (
int i = 0; i < nq; i++)
2141 radon = -1.0 * x[i] + y[i] - 7;
2142 radtw = x[i] + y[i] - 7;
2143 radth = -x[i] - y[i] - 7;
2144 radfo = x[i] - y[i] - 7;
2148 relrad = radon / PMLthickness;
2150 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2155 relrad = radtw / PMLthickness;
2157 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2162 relrad = radth / PMLthickness;
2164 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2169 relrad = radfo / PMLthickness;
2171 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2178 std::cout <<
"*** sigma1 = [ " <<
Vmath::Vmin(nq, &SigmaPML[0][0], 1)
2180 <<
" ] , sigma2 = [ " <<
Vmath::Vmin(nq, &SigmaPML[1][0], 1)
2181 <<
" , " <<
Vmath::Vmax(nq, &SigmaPML[1][0], 1) <<
" ] "
2193 for (
int i = 0; i < 3; ++i)
2195 Vmath::Vvtvp(nq, &fields[i][0], 1, &fields[i][0], 1, &tmp[0], 1,
2199 energy = 0.5 * (
m_fields[0]->Integral(tmp));
2232 m_fields[0]->GenerateElementVector(
2259 m_fields[0]->GenerateElementVector(
2261 m_fields[0]->GenerateElementVector(
2303 boost::ignore_unused(muvec, Dispersion);
2317 NekDouble boveradel = m_b / (m_b - m_adel);
2325 if (fabs(la * lb - 1.0) < 0.00001)
2327 ExactCloakArea =
m_pi * (m_b * m_b - m_a * m_a);
2332 ExactCloakArea =
m_pi * (3.0 * lb * 3.0 * la - lb * la);
2337 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2338 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2346 for (
int i = 0; i < nq; ++i)
2348 if (Cloakregion[i] > 0)
2352 ratio = (radvec[i] - m_adel) / radvec[i];
2354 epsvec[0][i] = boveradel * boveradel;
2359 (1.0 - boveradel * boveradel * ratio * ratio) +
2365 epsvec[1][i] = boveradel * boveradel * (ratio * ratio);
2393 Vmath::Vsub(nq, Cloakregion, 1, Vacregion, 1, Cloakregion, 1);
2396 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2397 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2405 for (
int i = 0; i < nq; ++i)
2407 if (Cloakregion[i] > 0)
2413 epsvec[0][i] = radvec[i] / (radvec[i] - m_adel);
2414 epsvec[1][i] = (radvec[i] - m_adel) / radvec[i];
2415 muvec[2][i] = (m_b / (m_b - m_adel)) * (m_b / (m_b - m_adel)) *
2416 (radvec[i] - m_adel) / radvec[i];
2418 muvec[0][i] = epsvec[0][i];
2419 muvec[1][i] = epsvec[1][i];
2420 epsvec[2][i] = muvec[2][i];
2429 int nq =
m_fields[0]->GetTotPoints();
2437 &Sigma1minus0[0], 1);
2439 &Sigma0minus1[0], 1);
2441 &Sigma0plus1Neg[0], 1);
2456 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2457 &outarray[indxH0][0], 1, &outarray[indxH0][0], 1);
2458 Vmath::Vadd(nq, &physarray[indxQ0][0], 1, &outarray[indxH0][0], 1,
2459 &outarray[indxH0][0], 1);
2462 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2463 &outarray[indxH1][0], 1, &outarray[indxH1][0], 1);
2464 Vmath::Vadd(nq, &physarray[indxQ1][0], 1, &outarray[indxH1][0], 1,
2465 &outarray[indxH1][0], 1);
2468 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxE2][0], 1,
2469 &outarray[indxE2][0], 1, &outarray[indxE2][0], 1);
2470 Vmath::Vadd(nq, &physarray[indxP2][0], 1, &outarray[indxE2][0], 1,
2471 &outarray[indxE2][0], 1);
2474 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2475 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2477 &outarray[indxQ0][0], 1);
2481 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2482 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2484 &outarray[indxQ1][0], 1);
2490 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2495 &outarray[indxP2][0], 1);
2496 Vmath::Vmul(nq, &physarray[indxE2][0], 1, &outarray[indxP2][0], 1,
2497 &outarray[indxP2][0], 1);
2512 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE0][0], 1,
2513 &outarray[indxE0][0], 1, &outarray[indxE0][0], 1);
2514 Vmath::Vsub(nq, &outarray[indxE0][0], 1, &physarray[indxQ0][0], 1,
2515 &outarray[indxE0][0], 1);
2518 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE1][0], 1,
2519 &outarray[indxE1][0], 1, &outarray[indxE1][0], 1);
2520 Vmath::Vsub(nq, &outarray[indxE1][0], 1, &physarray[indxQ1][0], 1,
2521 &outarray[indxE1][0], 1);
2524 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxH2][0], 1,
2525 &outarray[indxH2][0], 1, &outarray[indxH2][0], 1);
2526 Vmath::Vsub(nq, &outarray[indxH2][0], 1, &physarray[indxP2][0], 1,
2527 &outarray[indxH2][0], 1);
2530 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE0][0], 1,
2531 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2533 &outarray[indxQ0][0], 1);
2537 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE1][0], 1,
2538 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2540 &outarray[indxQ1][0], 1);
2546 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2551 &outarray[indxP2][0], 1);
2552 Vmath::Vmul(nq, &physarray[indxH2][0], 1, &outarray[indxP2][0], 1,
2553 &outarray[indxP2][0], 1);
2567 int nq =
m_fields[0]->GetTotPoints();
2568 int ncoeffs =
m_fields[0]->GetNcoeffs();
2570 std::string outname =
2571 m_sessionName +
"Tot_" + boost::lexical_cast<std::string>(n) +
".chk";
2573 std::vector<std::string> variables(nvar);
2574 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2576 for (
int i = 0; i < nvar; ++i)
2582 for (
int i = 0; i < nvar; ++i)
2585 Vmath::Vadd(nq, fieldphys[i], 1, totfield, 1, totfield, 1);
2587 m_fields[i]->FwdTrans(totfield, fieldcoeffs[i]);
2599 int nq =
m_fields[0]->GetTotPoints();
2600 int ncoeffs =
m_fields[0]->GetNcoeffs();
2602 std::string outname =
2603 m_sessionName +
"Plot_" + boost::lexical_cast<std::string>(n) +
".chk";
2605 std::vector<std::string> variables(nvar);
2606 variables[0] =
"Fx";
2607 variables[1] =
"Fy";
2608 variables[2] =
"Fz";
2610 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2611 for (
int i = 0; i < nvar; ++i)
2622 &tmp[0], 1, &tmp[0], 1);
2624 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2635 int nq =
m_fields[0]->GetTotPoints();
2636 int ncoeffs =
m_fields[0]->GetNcoeffs();
2639 boost::lexical_cast<std::string>(n) +
".chk";
2641 std::vector<std::string> variables(nvar);
2642 variables[0] =
"Frx";
2643 variables[1] =
"Fry";
2644 variables[2] =
"Frz";
2645 for (
int i = 3; i < nvar; ++i)
2650 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2651 for (
int i = 0; i < nvar; ++i)
2661 Vmath::Vadd(nq, fieldphys[0], 1, totfield0, 1, totfield0, 1);
2664 Vmath::Vadd(nq, fieldphys[1], 1, totfield1, 1, totfield1, 1);
2671 &tmp[0], 1, &tmp[0], 1);
2673 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2676 for (
int j = 3; j < nvar; ++j)
2678 m_fields[j]->FwdTrans(fieldphys[j], fieldcoeffs[j]);
2688 boost::ignore_unused(time);
2691 int nq =
m_fields[0]->GetTotPoints();
2692 int ncoeffs =
m_fields[0]->GetNcoeffs();
2695 boost::lexical_cast<std::string>(n) +
".chk";
2697 std::vector<std::string> variables(nvar);
2698 variables[0] =
"EDFx";
2699 variables[1] =
"EDFy";
2700 variables[2] =
"EDFz";
2701 for (
int i = 3; i < nvar; ++i)
2706 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2707 for (
int i = 0; i < nvar; ++i)
2721 &tmp[0], 1, &tmp[0], 1);
2723 Vmath::Vmul(nq, &fieldphys[2][0], 1, &tmp[0], 1, &tmp[0], 1);
2730 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2740 boost::ignore_unused(time);
2743 int nq =
m_fields[0]->GetTotPoints();
2744 int ncoeffs =
m_fields[0]->GetNcoeffs();
2747 boost::lexical_cast<std::string>(n) +
".chk";
2749 std::vector<std::string> variables(nvar);
2750 variables[0] =
"Energy";
2751 variables[1] =
"EnergyFlux";
2752 variables[2] =
"Zero";
2753 for (
int i = 3; i < nvar; ++i)
2758 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2759 for (
int i = 0; i < nvar; ++i)
2773 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1, &energy[0],
2777 m_fields[0]->FwdTrans(energy, fieldcoeffs[0]);
2782 for (
int k = 0; k < 2; ++k)
2788 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1,
2789 &energyflux[0], 1, &energyflux[0], 1);
2793 Vmath::Vmul(nq, &fieldphys[2][0], 1, &energyflux[0], 1, &energyflux[0], 1);
2795 m_fields[1]->FwdTrans(energyflux, fieldcoeffs[1]);
2807 int nq =
m_fields[0]->GetTotPoints();
2808 int ncoeffs =
m_fields[0]->GetNcoeffs();
2822 1.0 / (1.0 + exp(-0.5 * (time -
m_PSduration) / SFradius));
2824 for (
int j = 0; j < nq; ++j)
2826 rad =
sqrt((x[j] - Psx) * (x[j] - Psx) + (y[j] - Psy) * (y[j] - Psy) +
2827 (
z[j] - Psz) * (
z[j] - Psz));
2828 outarray[j] = SmoothFactor * exp(-1.0 * (
rad / Gaussianradius) *
2829 (
rad / Gaussianradius));
2832 m_fields[0]->FwdTransLocalElmt(outarray, tmpc);
2833 m_fields[0]->BwdTrans(tmpc, outarray);
2845 NekDouble sin_theta, cos_theta, sin_varphi, cos_varphi;
2854 for (
int j = 0; j < nq; ++j)
2863 outarray[j] = 2.0 * m_Omega * sin_theta;
2872 int nq = physarray[0].size();
2914 Vmath::Vadd(nq, tmp, 1, outarray[j], 1, outarray[j], 1);
2929 if (CloakNlayer == 8)
2932 if (fabs(la * lb - 1.0) < 0.0001)
2958 if (CloakNlayer == 16)
2961 if (fabs(la * lb - 1.0) < 0.0001)
3007 m_fields[0]->GetCoords(x0, x1, x2);
3013 m_fields[0]->GenerateElementVector(Layer[0], 1.0, 0.0, Currenttmp);
3015 for (
int i = 1; i < CloakNlayer; ++i)
3017 m_fields[0]->GenerateElementVector(Layer[i], 1.0, 0.0, Currenttmp);
3018 m_fields[0]->GenerateElementVector(Layer[i - 1], 1.0, 0.0, Formertmp);
3020 Vmath::Vsub(nq, Currenttmp, 1, Formertmp, 1, Currenttmp, 1);
3022 Vmath::Svtvp(nq, 1.0 * (i + 1), Currenttmp, 1, Cloakregion, 1,
3028 for (
int i = 0; i < nq; ++i)
3034 if ((Cloakregion[i] > 0) && (CloakNlayer > 0))
3036 radvec[i] = 1.0 + (m_b - m_a) / CloakNlayer *
3037 (Cloakregion[i] - 0.5);
3043 sqrt(x0[i] * x0[i] / la / la + x1[i] * x1[i] / lb / lb);
3050 radvec[i] =
sqrt(2.0 * x0[i] * x0[i] +
3051 x1[i] * x1[i] * x1[i] * x1[i] + x1[i] * x1[i]);
3057 radvec[i] =
sqrt(3.0 * x0[i] * x0[i] +
3058 x1[i] * x1[i] * x1[i] * x1[i] - x1[i] * x1[i]);
3074 s,
"TestMaxwellType",
3140 int Ntot = inarray.size();
3143 for (
int i = 0; i < Ntot; ++i)
3145 std::cout <<
"[" << i <<
"] = " << inarray[2][i] << std::endl;
3148 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)
virtual ~MMFMaxwell()
Destructor.
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)
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.
virtual 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)
virtual void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time) override
virtual void v_DoSolve() override
Solves an unsteady problem.
Array< OneD, NekDouble > m_wp2
virtual 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)
virtual 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)
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Print a summary of time stepping parameters.
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
virtual 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)
The above copyright notice and this permission notice shall be included.
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 scalar 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)