37 #include <boost/core/ignore_unused.hpp>
38 #include <boost/algorithm/string/predicate.hpp>
39 #include <boost/algorithm/string.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;
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));
636 std::cout <<
"Steps: " << std::setw(8) << std::left << step + 1 <<
" "
637 <<
"Time: " << std::setw(12) << std::left <<
m_time;
639 std::stringstream ss;
640 ss << cpuTime / 60.0 <<
" min.";
641 std::cout <<
" CPU Time: " << std::setw(8) << std::left << ss.str()
666 for (
int i = 0; i < 3; ++i)
682 for (i = 0; i < nvariables; ++i)
697 TimeSeries[indx] =
m_time;
714 <<
", Energy = " << Energy[indx] << std::endl;
723 m_fields[0]->GetBndCondExpansions()[0]->GetExpSize();
725 ->GetBndCondExpansions()[0]
739 m_fields[0]->ExtractTracePhys(fields[0], E1Fwd);
740 m_fields[0]->ExtractTracePhys(fields[1], E2Fwd);
741 m_fields[0]->ExtractTracePhys(fields[2], H3Fwd);
752 for (
int e = 0; e < totbdryexp; ++e)
754 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
757 ->GetBndCondIDToGlobalTraceID(cnt + e));
767 if (E1atPEC < E1atPECloc)
769 E1atPEC = E1atPECloc;
772 if (E2atPEC < E2atPECloc)
774 E2atPEC = E2atPECloc;
777 if (H3atPEC < H3atPECloc)
779 H3atPEC = H3atPECloc;
783 std::cout <<
"At PEC, Max. E1 = " << E1atPEC
784 <<
", E2 = " << E2atPEC <<
", H3 = " << H3atPEC
790 Ezantipod[cntap++] = fields[2][indxantipod];
795 P1[cntpml] = fields[2][P1indx];
796 P2[cntpml] = fields[2][P2indx];
797 P3[cntpml] = fields[2][P3indx];
808 if (
m_session->GetComm()->GetRank() == 0)
810 std::cout <<
"Time-integration : " << intTime <<
"s" << std::endl;
812 std::cout <<
"TimeSeries = " << std::endl;
815 std::cout << TimeSeries[i] <<
", ";
817 std::cout << std::endl << std::endl;
819 std::cout <<
"Energy Density = " << std::endl;
822 std::cout << Energy[i] <<
", ";
824 std::cout << std::endl << std::endl;
833 std::cout <<
"Ez at antipod = " << std::endl;
836 std::cout << Ezantipod[i] <<
", ";
838 std::cout << std::endl << std::endl;
843 std::cout <<
"P1 = " << std::endl;
846 std::cout << P1[i] <<
", ";
848 std::cout << std::endl << std::endl;
850 std::cout <<
"P2 = " << std::endl;
853 std::cout << P2[i] <<
", ";
855 std::cout << std::endl << std::endl;
857 std::cout <<
"P3 = " << std::endl;
860 std::cout << P3[i] <<
", ";
862 std::cout << std::endl << std::endl;
866 for (i = 0; i < nvariables; ++i)
872 for (i = 0; i < nvariables; ++i)
891 int nvar = inarray.size();
897 for (i = 0; i < nvar; ++i)
902 Vmath::Vcopy(nq, &inarray[i][0], 1, &physarray[i][0], 1);
905 for (i = 0; i < nvar; i++)
922 for (
int i = 0; i < 3; ++i)
933 for (
int i = 0; i < 3; ++i)
936 Vmath::Vcopy(ncoeffs, &tmpout[i][0], 1, &modarray[i][0], 1);
950 for (i = 0; i < nvar; ++i)
952 m_fields[i]->MultiplyByElmtInvMass(modarray[i], modarray[i]);
953 m_fields[i]->BwdTrans(modarray[i], outarray[i]);
959 for (
int j = 0; j < 2; ++j)
962 Vmath::Vadd(nq, &F[0], 1, &outarray[j][0], 1, &outarray[j][0], 1);
969 AddPML(physarray, outarray);
1003 m_fields[0]->GetCoords(x0, x1, x2);
1006 NekDouble uxx, uxy, uyy, detu, uti, uri;
1026 for (
int i = 0; i < nq; i++)
1029 tmpIN[i] * (1.0 - 2 * x0[i] * x0[i]) + (1.0 - tmpIN[i]);
1032 for (
int i = 0; i < nq; ++i)
1034 theta = atan2((x1[i] + 2.0), (x0[i] + 2.0));
1039 uxx = uti * cos(theta) * cos(theta) +
1040 uri * sin(theta) * sin(theta);
1041 uyy = uti * sin(theta) * sin(theta) +
1042 uri * cos(theta) * cos(theta);
1043 uxy = (uti - uri) * cos(theta) * sin(theta);
1045 detu = uxx * uyy - uxy * uxy;
1047 tmpx = outarray[0][i] + (1.0 - uxx) * Hxdt[i] - uxy * Hydt[i];
1048 tmpy = outarray[1][i] - uxy * Hxdt[i] + (1.0 - uyy) * Hydt[i];
1050 outarray[0][i] = (1 / detu) * (uyy * tmpx - uxy * tmpy);
1051 outarray[1][i] = (1 / detu) * (-uxy * tmpx + uxx * tmpy);
1068 outarray[0], 1, outarray[0], 1);
1072 outarray[1], 1, outarray[1], 1);
1076 outarray[2], 1, outarray[2], 1);
1083 outarray[0], 1, outarray[0], 1);
1087 outarray[1], 1, outarray[1], 1);
1091 outarray[2], 1, outarray[2], 1);
1110 outarray[0], 1, outarray[0], 1);
1114 outarray[1], 1, outarray[1], 1);
1118 outarray[2], 1, outarray[2], 1);
1125 outarray[0], 1, outarray[0], 1);
1139 outarray[1], 1, outarray[1], 1);
1144 outarray[2], 1, outarray[2], 1);
1173 int ncoeffs = outarray[0].size();
1174 int nq = physarray[0].size();
1208 m_fields[var]->IProductWRTBase(tmp, tmpc);
1209 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1216 m_fields[var]->IProductWRTBase(tmp, tmpc);
1217 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1224 &tmp[0], 1, &tmp[0], 1);
1225 m_fields[var]->IProductWRTBase(tmp, tmpc);
1226 Vmath::Vadd(ncoeffs, tmpc, 1, outarray[var], 1, outarray[var], 1);
1262 for (i = 0; i < nvar; ++i)
1264 physfield[i] = InField[i];
1268 for (i = 0; i < nvar; ++i)
1278 fluxvector[j], tmpc);
1279 Vmath::Vadd(ncoeffs, &tmpc[0], 1, &OutField[i][0], 1,
1280 &OutField[i][0], 1);
1290 for (i = 0; i < nvar; ++i)
1301 for (i = 0; i < nvar; ++i)
1304 m_fields[i]->AddFwdBwdTraceIntegral(numfluxFwd[i], numfluxBwd[i],
1321 boost::ignore_unused(time);
1323 int var = inarray.size();
1328 for (
int i = 0; i < var; ++i)
1335 bool dumpInitialConditions,
1338 boost::ignore_unused(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)
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);
1543 Hc = nk * (Ak * exp(im * nk * omega * x0[i]) +
1544 Bk * exp(-im * nk * omega * x0[i])) *
1545 exp(im * omega * time);
1571 const NekDouble time,
unsigned int field,
1574 int nq =
m_fields[0]->GetNpoints();
1580 m_fields[0]->GetCoords(x0, x1, x2);
1595 for (
int i = 0; i < nq; ++i)
1597 switch (Polarization)
1601 Fx = -1.0 * (npi / omega) * sin(mpi * x0[i]) *
1602 cos(npi * x1[i]) * sin(omega * time);
1603 Fy = (mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1610 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1612 dFxdt = (npi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1614 dFydt = -1.0 * (mpi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1621 dFzdt[i] = omega * sin(mpi * x0[i]) * sin(npi * x1[i]) *
1628 Fx = -1.0 * (npi / omega) * cos(mpi * x0[i]) *
1629 sin(npi * x1[i]) * sin(omega * time);
1630 Fy = (mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1637 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1639 dFxdt = (npi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1641 dFydt = -1.0 * (mpi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1648 dFzdt[i] = omega * cos(mpi * x0[i]) * cos(npi * x1[i]) *
1702 const NekDouble time,
unsigned int field,
1705 int nq =
m_fields[0]->GetNpoints();
1711 m_fields[0]->GetCoords(x0, x1, x2);
1723 for (
int i = 0; i < nq; ++i)
1725 switch (Polarization)
1729 Fx = (npi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1731 Fy = -(mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1738 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1744 Fx = (npi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1746 Fy = -(mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1753 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1791 int nq =
m_fields[0]->GetTotPoints();
1816 NekDouble xj, yj, zj, sin_varphi, cos_varphi, sin_theta, cos_theta;
1818 for (
int i = 0; i < nq; i++)
1827 vth = -4.0 * sin_varphi * cos_varphi * cos_theta * cos_theta *
1828 cos_theta * sin_theta;
1830 -1.0 * sin_varphi * sin_varphi * cos_theta * cos_theta * cos_theta;
1831 velvec[0][i] = -vth * sin_theta * cos_varphi - vphi * sin_varphi;
1832 velvec[1][i] = -vth * sin_theta * sin_varphi + vphi * cos_varphi;
1833 velvec[2][i] = vth * cos_theta;
1835 E3[i] = (-4.0 * cos_theta * cos_theta * sin_theta * cos_varphi *
1837 (1.0 / omega * sin(omega * time));
1839 Fth = -omega * vth -
1840 (8.0 / omega) * cos_theta * sin_theta * cos_varphi * sin_varphi;
1841 Fphi = -omega * vphi +
1842 (4.0 / omega) * cos_varphi * cos_varphi * cos_theta *
1843 (2.0 * sin_theta * sin_theta - cos_theta * cos_theta);
1844 Fvec[0][i] = -Fth * sin_theta * cos_varphi - Fphi * sin_varphi;
1845 Fvec[1][i] = -Fth * sin_theta * sin_varphi + Fphi * cos_varphi;
1846 Fvec[2][i] = Fth * cos_theta;
1904 int nq =
m_fields[0]->GetTotPoints();
1913 int totnpts = totbdryexp * npts;
1932 m_fields[0]->ExtractTracePhys(x, xFwd);
1933 m_fields[0]->ExtractTracePhys(y, yFwd);
1935 for (
int i = 0; i < nTraceNumPoints; ++i)
1939 phiFwd[i] = atan2(yFwd[i] / radFwd[i], -1.0 * xFwd[i] / radFwd[i]);
1947 for (
int e = 0; e < totbdryexp; ++e)
1949 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1950 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
1952 Vmath::Vcopy(npts, &phiFwd[id2], 1, &Jphi[e * npts], 1);
1953 Vmath::Vcopy(npts, &radFwd[id2], 1, &Jrad[e * npts], 1);
1954 Vmath::Vcopy(npts, &ntimesHFwd[id2], 1, &Jcurrent[e * npts], 1);
1961 std::cout <<
"========================================================"
1964 std::cout <<
"phi = " << std::endl;
1965 for (
int i = 0; i < totnpts; ++i)
1967 std::cout << Jphi[i] <<
", ";
1969 std::cout << std::endl << std::endl;
1971 std::cout <<
"J = " << std::endl;
1972 for (
int i = 0; i < totnpts; ++i)
1974 std::cout << Jcurrent[i] <<
", ";
1976 std::cout << std::endl << std::endl;
1982 int nq =
m_fields[0]->GetTotPoints();
1995 for (
int i = 0; i < 2; i++)
2000 m_fields[0]->ExtractTracePhys(tmp, tmpFwd);
2002 &tmpFwd[0], 1, &outfield[0], 1, &outfield[0], 1);
2013 m_fields[0]->ExtractTracePhys(tmp, outfield);
2029 int nq =
m_fields[0]->GetNpoints();
2053 Vmath::Vsub(nq, PMLRegion, 1, RecPML, 1, CurvedPML, 1);
2061 NekDouble xRlayer, xLlayer, yRlayer, yLlayer;
2069 for (
int i = 0; i < nq; i++)
2072 if (x[i] >= xRlayer)
2074 xd = (x[i] - xRlayer) / PMLthickness;
2077 else if (x[i] <= xLlayer)
2079 xd = (xLlayer - x[i]) / PMLthickness;
2087 SigmaPML[0][i] = RecPML[i] * PMLmaxsigma * (xd * xd * xd);
2090 if (y[i] >= yRlayer)
2092 yd = (y[i] - yRlayer) / PMLthickness;
2095 else if (y[i] <= yLlayer)
2097 yd = (yLlayer - y[i]) / PMLthickness;
2105 SigmaPML[1][i] = PMLRegion[i] * PMLmaxsigma * (yd * yd * yd);
2115 for (
int i = 0; i < nq; i++)
2120 if (
rad >= PMLstart)
2122 relrad = (
rad - PMLstart) / PMLthickness;
2124 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2133 NekDouble relrad, radon, radtw, radth, radfo;
2134 for (
int i = 0; i < nq; i++)
2136 radon = -1.0 * x[i] + y[i] - 7;
2137 radtw = x[i] + y[i] - 7;
2138 radth = -x[i] - y[i] - 7;
2139 radfo = x[i] - y[i] - 7;
2143 relrad = radon / PMLthickness;
2145 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2150 relrad = radtw / PMLthickness;
2152 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2157 relrad = radth / PMLthickness;
2159 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2164 relrad = radfo / PMLthickness;
2166 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2173 std::cout <<
"*** sigma1 = [ " <<
Vmath::Vmin(nq, &SigmaPML[0][0], 1)
2175 <<
" ] , sigma2 = [ " <<
Vmath::Vmin(nq, &SigmaPML[1][0], 1)
2176 <<
" , " <<
Vmath::Vmax(nq, &SigmaPML[1][0], 1) <<
" ] "
2188 for (
int i = 0; i < 3; ++i)
2190 Vmath::Vvtvp(nq, &fields[i][0], 1, &fields[i][0], 1, &tmp[0], 1,
2194 energy = 0.5 * (
m_fields[0]->Integral(tmp));
2227 m_fields[0]->GenerateElementVector(
2254 m_fields[0]->GenerateElementVector(
2256 m_fields[0]->GenerateElementVector(
2298 boost::ignore_unused(muvec, 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 =
2566 m_sessionName +
"Tot_" + boost::lexical_cast<std::string>(n) +
".chk";
2568 std::vector<std::string> variables(nvar);
2569 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2571 for (
int i = 0; i < nvar; ++i)
2577 for (
int i = 0; i < nvar; ++i)
2580 Vmath::Vadd(nq, fieldphys[i], 1, totfield, 1, totfield, 1);
2582 m_fields[i]->FwdTrans(totfield, fieldcoeffs[i]);
2594 int nq =
m_fields[0]->GetTotPoints();
2595 int ncoeffs =
m_fields[0]->GetNcoeffs();
2597 std::string outname =
2598 m_sessionName +
"Plot_" + boost::lexical_cast<std::string>(n) +
".chk";
2600 std::vector<std::string> variables(nvar);
2601 variables[0] =
"Fx";
2602 variables[1] =
"Fy";
2603 variables[2] =
"Fz";
2605 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2606 for (
int i = 0; i < nvar; ++i)
2617 &tmp[0], 1, &tmp[0], 1);
2619 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2630 int nq =
m_fields[0]->GetTotPoints();
2631 int ncoeffs =
m_fields[0]->GetNcoeffs();
2634 boost::lexical_cast<std::string>(n) +
".chk";
2636 std::vector<std::string> variables(nvar);
2637 variables[0] =
"Frx";
2638 variables[1] =
"Fry";
2639 variables[2] =
"Frz";
2640 for (
int i = 3; i < nvar; ++i)
2645 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2646 for (
int i = 0; i < nvar; ++i)
2656 Vmath::Vadd(nq, fieldphys[0], 1, totfield0, 1, totfield0, 1);
2659 Vmath::Vadd(nq, fieldphys[1], 1, totfield1, 1, totfield1, 1);
2666 &tmp[0], 1, &tmp[0], 1);
2668 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2671 for (
int j = 3; j < nvar; ++j)
2673 m_fields[j]->FwdTrans(fieldphys[j], fieldcoeffs[j]);
2683 boost::ignore_unused(time);
2686 int nq =
m_fields[0]->GetTotPoints();
2687 int ncoeffs =
m_fields[0]->GetNcoeffs();
2690 boost::lexical_cast<std::string>(n) +
".chk";
2692 std::vector<std::string> variables(nvar);
2693 variables[0] =
"EDFx";
2694 variables[1] =
"EDFy";
2695 variables[2] =
"EDFz";
2696 for (
int i = 3; i < nvar; ++i)
2701 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2702 for (
int i = 0; i < nvar; ++i)
2716 &tmp[0], 1, &tmp[0], 1);
2718 Vmath::Vmul(nq, &fieldphys[2][0], 1, &tmp[0], 1, &tmp[0], 1);
2725 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2735 boost::ignore_unused(time);
2738 int nq =
m_fields[0]->GetTotPoints();
2739 int ncoeffs =
m_fields[0]->GetNcoeffs();
2742 boost::lexical_cast<std::string>(n) +
".chk";
2744 std::vector<std::string> variables(nvar);
2745 variables[0] =
"Energy";
2746 variables[1] =
"EnergyFlux";
2747 variables[2] =
"Zero";
2748 for (
int i = 3; i < nvar; ++i)
2753 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2754 for (
int i = 0; i < nvar; ++i)
2768 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1, &energy[0],
2772 m_fields[0]->FwdTrans(energy, fieldcoeffs[0]);
2777 for (
int k = 0; k < 2; ++k)
2783 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1,
2784 &energyflux[0], 1, &energyflux[0], 1);
2788 Vmath::Vmul(nq, &fieldphys[2][0], 1, &energyflux[0], 1, &energyflux[0], 1);
2790 m_fields[1]->FwdTrans(energyflux, fieldcoeffs[1]);
2802 int nq =
m_fields[0]->GetTotPoints();
2803 int ncoeffs =
m_fields[0]->GetNcoeffs();
2817 1.0 / (1.0 + exp(-0.5 * (time -
m_PSduration) / SFradius));
2819 for (
int j = 0; j < nq; ++j)
2821 rad =
sqrt((x[j] - Psx) * (x[j] - Psx) + (y[j] - Psy) * (y[j] - Psy) +
2822 (z[j] - Psz) * (z[j] - Psz));
2823 outarray[j] = SmoothFactor * exp(-1.0 * (
rad / Gaussianradius) *
2824 (
rad / Gaussianradius));
2827 m_fields[0]->FwdTrans_IterPerExp(outarray, tmpc);
2828 m_fields[0]->BwdTrans(tmpc, outarray);
2840 NekDouble sin_theta, cos_theta, sin_varphi, cos_varphi;
2849 for (
int j = 0; j < nq; ++j)
2858 outarray[j] = 2.0 * m_Omega * sin_theta;
2867 int nq = physarray[0].size();
2909 Vmath::Vadd(nq, tmp, 1, outarray[j], 1, outarray[j], 1);
2924 if (CloakNlayer == 8)
2927 if (fabs(la * lb - 1.0) < 0.0001)
2953 if (CloakNlayer == 16)
2956 if (fabs(la * lb - 1.0) < 0.0001)
3002 m_fields[0]->GetCoords(x0, x1, x2);
3008 m_fields[0]->GenerateElementVector(Layer[0], 1.0, 0.0, Currenttmp);
3010 for (
int i = 1; i < CloakNlayer; ++i)
3012 m_fields[0]->GenerateElementVector(Layer[i], 1.0, 0.0, Currenttmp);
3013 m_fields[0]->GenerateElementVector(Layer[i - 1], 1.0, 0.0, Formertmp);
3015 Vmath::Vsub(nq, Currenttmp, 1, Formertmp, 1, Currenttmp, 1);
3017 Vmath::Svtvp(nq, 1.0 * (i + 1), Currenttmp, 1, Cloakregion, 1,
3023 for (
int i = 0; i < nq; ++i)
3029 if ((Cloakregion[i] > 0) && (CloakNlayer > 0))
3033 (m_b - m_a) / CloakNlayer * (Cloakregion[i] - 0.5);
3039 sqrt(x0[i] * x0[i] / la / la + x1[i] * x1[i] / lb / lb);
3046 radvec[i] =
sqrt(2.0 * x0[i] * x0[i] +
3047 x1[i] * x1[i] * x1[i] * x1[i] + x1[i] * x1[i]);
3053 radvec[i] =
sqrt(3.0 * x0[i] * x0[i] +
3054 x1[i] * x1[i] * x1[i] * x1[i] - x1[i] * x1[i]);
3070 s,
"TestMaxwellType",
3136 int Ntot = inarray.size();
3139 for (
int i = 0; i < Ntot; ++i)
3141 std::cout <<
"[" << i <<
"] = " << inarray[2][i] << std::endl;
3144 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.
Array< OneD, NekDouble > m_mu
void ComputeMaterialVector(Array< OneD, Array< OneD, NekDouble >> &epsvec, Array< OneD, Array< OneD, NekDouble >> &muvec)
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 Checkpoint_TotalFieldOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
void Checkpoint_EnergyOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
void Checkpoint_TotPlotOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
void GenerateSigmaPML(const NekDouble PMLthickness, const NekDouble PMLstart, const NekDouble PMLmaxsigma, Array< OneD, Array< OneD, NekDouble >> &SigmaPML)
void Checkpoint_PlotOutput(const int n, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
Array< OneD, NekDouble > ComputeRadCloak(const int Nlayer=5)
Array< OneD, NekDouble > TestMaxwell2DPEC(const NekDouble time, unsigned int field, const SolverUtils::PolType Polarization)
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the projection.
Array< OneD, NekDouble > m_SourceVector
virtual ~MMFMaxwell()
Destructor.
void AddPML(const Array< OneD, const Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
NekDouble m_Cloakraddelta
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the RHS.
static std::string className
Name of class.
virtual void v_SetInitialConditions(const NekDouble initialtime, bool dumpInitialConditions, const int domain)
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 .
void ComputeMaterialMicroWaveCloak(const Array< OneD, const NekDouble > &radvec, Array< OneD, Array< OneD, NekDouble >> &epsvec, Array< OneD, Array< OneD, NekDouble >> &muvec)
Array< OneD, Array< OneD, NekDouble > > m_SigmaPML
Array< OneD, NekDouble > m_varepsilon
void AddGreenDerivCompensate(const Array< OneD, const Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
virtual void v_InitObject()
Initialise the object.
MMFMaxwell(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
void Printout_SurfaceCurrent(Array< OneD, Array< OneD, NekDouble >> &fields, const int time)
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
int m_PrintoutSurfaceCurrent
Array< OneD, NekDouble > GaussianPulse(const NekDouble time, const NekDouble Psx, const NekDouble Psy, const NekDouble Psz, const NekDouble Gaussianradius)
void AddCoriolis(Array< OneD, Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
virtual void v_DoSolve()
Solves an unsteady problem.
void print_MMF(Array< OneD, Array< OneD, NekDouble >> &inarray)
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print Summary.
Array< OneD, NekDouble > m_wp2
void Checkpoint_EDFluxOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
virtual void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time)
void ComputeMaterialOpticalCloak(const Array< OneD, const NekDouble > &radvec, Array< OneD, Array< OneD, NekDouble >> &epsvec, Array< OneD, Array< OneD, NekDouble >> &muvec, const bool Dispersion=false)
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)
NekDouble ComputeEnergyDensity(Array< OneD, Array< OneD, NekDouble >> &fields)
Array< OneD, NekDouble > ComputeSurfaceCurrent(const int time, const Array< OneD, const Array< OneD, NekDouble >> &fields)
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT int GetTraceNpoints()
NekDouble m_timestep
Time step size.
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 Array< OneD, NekDouble > CartesianToMovingframes(const Array< OneD, const Array< OneD, NekDouble >> &uvec, unsigned int field)
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 ComputeZimYim(Array< OneD, Array< OneD, NekDouble >> &epsvec, Array< OneD, Array< OneD, NekDouble >> &muvec)
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 DeriveCrossProductMF(Array< OneD, Array< OneD, NekDouble >> &CrossProductMF)
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
SOLVER_UTILS_EXPORT void MMFInitObject(const Array< OneD, const Array< OneD, NekDouble >> &Anisotropy, const int TangentXelem=-1)
Array< OneD, Array< OneD, NekDouble > > m_negepsvecminus1
SOLVER_UTILS_EXPORT void AdddedtMaxwell(const Array< OneD, const Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
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)
TestMaxwellType m_TestMaxwellType
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_CurlMF
SOLVER_UTILS_EXPORT void Computedemdxicdote()
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
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.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
std::vector< int > m_intVariables
int m_infosteps
Number of time steps between outputting status information.
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
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 plus 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)