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();
1331 for (
int i = 0; i < var; ++i)
1338 bool dumpInitialConditions,
1341 boost::ignore_unused(domain);
1377 for (
int i = 0; i < nvar; i++)
1404 for (
int i = 0; i < nvar; ++i)
1411 if (dumpInitialConditions)
1417 for (
int i = 0; i < nvar; ++i)
1419 fields[i] =
m_fields[i]->GetPhys();
1430 int nq =
m_fields[0]->GetNpoints();
1471 int nq =
m_fields[0]->GetNpoints();
1477 m_fields[0]->GetCoords(x0, x1, x2);
1495 for (
int i = 0; i < 10000; ++i)
1499 (1.0 / cos(
m_n2 * omega) / cos(
m_n2 * omega) +
1500 1.0 / cos(
m_n1 * omega) / cos(
m_n1 * omega));
1502 newomega = omega - F / Fprime;
1504 if (fabs(newomega - omega) > Tol)
1517 std::complex<double> im =
sqrt(std::complex<double>(-1));
1518 std::complex<double> A1, A2, B1, B2;
1519 std::complex<double> Ak, Bk, nk;
1520 std::complex<double> Ec, Hc;
1523 A2 = exp(-1.0 * im * omega * (
m_n1 +
m_n2));
1524 B1 = A1 * exp(-2.0 * im *
m_n1 * omega);
1525 B2 = A2 * exp(2.0 * im *
m_n2 * omega);
1527 for (
int i = 0; i < nq; ++i)
1543 Ec = (Ak * exp(im * nk * omega * x0[i]) -
1544 Bk * exp(-im * nk * omega * x0[i])) *
1545 exp(im * omega * time);
1547 (Ak * exp(im * nk * omega * x0[i]) +
1548 Bk * exp(-im * nk * omega * x0[i])) *
1549 exp(im * omega * time);
1575 const NekDouble time,
unsigned int field,
1578 int nq =
m_fields[0]->GetNpoints();
1584 m_fields[0]->GetCoords(x0, x1, x2);
1599 for (
int i = 0; i < nq; ++i)
1601 switch (Polarization)
1605 Fx = -1.0 * (npi / omega) * sin(mpi * x0[i]) *
1606 cos(npi * x1[i]) * sin(omega * time);
1607 Fy = (mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1614 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1616 dFxdt = (npi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1618 dFydt = -1.0 * (mpi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1625 dFzdt[i] = omega * sin(mpi * x0[i]) * sin(npi * x1[i]) *
1632 Fx = -1.0 * (npi / omega) * cos(mpi * x0[i]) *
1633 sin(npi * x1[i]) * sin(omega * time);
1634 Fy = (mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1641 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1643 dFxdt = (npi)*cos(mpi * x0[i]) * sin(npi * x1[i]) *
1645 dFydt = -1.0 * (mpi)*sin(mpi * x0[i]) * cos(npi * x1[i]) *
1652 dFzdt[i] = omega * cos(mpi * x0[i]) * cos(npi * x1[i]) *
1706 const NekDouble time,
unsigned int field,
1709 int nq =
m_fields[0]->GetNpoints();
1715 m_fields[0]->GetCoords(x0, x1, x2);
1727 for (
int i = 0; i < nq; ++i)
1729 switch (Polarization)
1733 Fx = (npi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1735 Fy = -(mpi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1742 Fz[i] = cos(mpi * x0[i]) * cos(npi * x1[i]) * cos(omega * time);
1748 Fx = (npi / omega) * sin(mpi * x0[i]) * cos(npi * x1[i]) *
1750 Fy = -(mpi / omega) * cos(mpi * x0[i]) * sin(npi * x1[i]) *
1757 Fz[i] = sin(mpi * x0[i]) * sin(npi * x1[i]) * cos(omega * time);
1795 int nq =
m_fields[0]->GetTotPoints();
1820 NekDouble xj, yj, zj, sin_varphi, cos_varphi, sin_theta, cos_theta;
1822 for (
int i = 0; i < nq; i++)
1831 vth = -4.0 * sin_varphi * cos_varphi * cos_theta * cos_theta *
1832 cos_theta * sin_theta;
1834 -1.0 * sin_varphi * sin_varphi * cos_theta * cos_theta * cos_theta;
1835 velvec[0][i] = -vth * sin_theta * cos_varphi - vphi * sin_varphi;
1836 velvec[1][i] = -vth * sin_theta * sin_varphi + vphi * cos_varphi;
1837 velvec[2][i] = vth * cos_theta;
1839 E3[i] = (-4.0 * cos_theta * cos_theta * sin_theta * cos_varphi *
1841 (1.0 / omega * sin(omega * time));
1843 Fth = -omega * vth -
1844 (8.0 / omega) * cos_theta * sin_theta * cos_varphi * sin_varphi;
1845 Fphi = -omega * vphi +
1846 (4.0 / omega) * cos_varphi * cos_varphi * cos_theta *
1847 (2.0 * sin_theta * sin_theta - cos_theta * cos_theta);
1848 Fvec[0][i] = -Fth * sin_theta * cos_varphi - Fphi * sin_varphi;
1849 Fvec[1][i] = -Fth * sin_theta * sin_varphi + Fphi * cos_varphi;
1850 Fvec[2][i] = Fth * cos_theta;
1908 int nq =
m_fields[0]->GetTotPoints();
1917 int totnpts = totbdryexp * npts;
1936 m_fields[0]->ExtractTracePhys(x, xFwd);
1937 m_fields[0]->ExtractTracePhys(y, yFwd);
1939 for (
int i = 0; i < nTraceNumPoints; ++i)
1943 phiFwd[i] = atan2(yFwd[i] / radFwd[i], -1.0 * xFwd[i] / radFwd[i]);
1951 for (
int e = 0; e < totbdryexp; ++e)
1953 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1954 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
1956 Vmath::Vcopy(npts, &phiFwd[id2], 1, &Jphi[e * npts], 1);
1957 Vmath::Vcopy(npts, &radFwd[id2], 1, &Jrad[e * npts], 1);
1958 Vmath::Vcopy(npts, &ntimesHFwd[id2], 1, &Jcurrent[e * npts], 1);
1965 std::cout <<
"========================================================"
1968 std::cout <<
"phi = " << std::endl;
1969 for (
int i = 0; i < totnpts; ++i)
1971 std::cout << Jphi[i] <<
", ";
1973 std::cout << std::endl << std::endl;
1975 std::cout <<
"J = " << std::endl;
1976 for (
int i = 0; i < totnpts; ++i)
1978 std::cout << Jcurrent[i] <<
", ";
1980 std::cout << std::endl << std::endl;
1986 int nq =
m_fields[0]->GetTotPoints();
1999 for (
int i = 0; i < 2; i++)
2004 m_fields[0]->ExtractTracePhys(tmp, tmpFwd);
2006 &tmpFwd[0], 1, &outfield[0], 1, &outfield[0], 1);
2017 m_fields[0]->ExtractTracePhys(tmp, outfield);
2033 int nq =
m_fields[0]->GetNpoints();
2057 Vmath::Vsub(nq, PMLRegion, 1, RecPML, 1, CurvedPML, 1);
2065 NekDouble xRlayer, xLlayer, yRlayer, yLlayer;
2073 for (
int i = 0; i < nq; i++)
2076 if (x[i] >= xRlayer)
2078 xd = (x[i] - xRlayer) / PMLthickness;
2081 else if (x[i] <= xLlayer)
2083 xd = (xLlayer - x[i]) / PMLthickness;
2091 SigmaPML[0][i] = RecPML[i] * PMLmaxsigma * (xd * xd * xd);
2094 if (y[i] >= yRlayer)
2096 yd = (y[i] - yRlayer) / PMLthickness;
2099 else if (y[i] <= yLlayer)
2101 yd = (yLlayer - y[i]) / PMLthickness;
2109 SigmaPML[1][i] = PMLRegion[i] * PMLmaxsigma * (yd * yd * yd);
2119 for (
int i = 0; i < nq; i++)
2124 if (
rad >= PMLstart)
2126 relrad = (
rad - PMLstart) / PMLthickness;
2128 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2137 NekDouble relrad, radon, radtw, radth, radfo;
2138 for (
int i = 0; i < nq; i++)
2140 radon = -1.0 * x[i] + y[i] - 7;
2141 radtw = x[i] + y[i] - 7;
2142 radth = -x[i] - y[i] - 7;
2143 radfo = x[i] - y[i] - 7;
2147 relrad = radon / PMLthickness;
2149 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2154 relrad = radtw / PMLthickness;
2156 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2161 relrad = radth / PMLthickness;
2163 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2168 relrad = radfo / PMLthickness;
2170 PMLRegion[i] * PMLmaxsigma * pow(relrad,
m_PMLorder);
2177 std::cout <<
"*** sigma1 = [ " <<
Vmath::Vmin(nq, &SigmaPML[0][0], 1)
2179 <<
" ] , sigma2 = [ " <<
Vmath::Vmin(nq, &SigmaPML[1][0], 1)
2180 <<
" , " <<
Vmath::Vmax(nq, &SigmaPML[1][0], 1) <<
" ] "
2192 for (
int i = 0; i < 3; ++i)
2194 Vmath::Vvtvp(nq, &fields[i][0], 1, &fields[i][0], 1, &tmp[0], 1,
2198 energy = 0.5 * (
m_fields[0]->Integral(tmp));
2231 m_fields[0]->GenerateElementVector(
2258 m_fields[0]->GenerateElementVector(
2260 m_fields[0]->GenerateElementVector(
2302 boost::ignore_unused(muvec, Dispersion);
2316 NekDouble boveradel = m_b / (m_b - m_adel);
2324 if (fabs(la * lb - 1.0) < 0.00001)
2326 ExactCloakArea =
m_pi * (m_b * m_b - m_a * m_a);
2331 ExactCloakArea =
m_pi * (3.0 * lb * 3.0 * la - lb * la);
2336 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2337 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2345 for (
int i = 0; i < nq; ++i)
2347 if (Cloakregion[i] > 0)
2351 ratio = (radvec[i] - m_adel) / radvec[i];
2353 epsvec[0][i] = boveradel * boveradel;
2358 (1.0 - boveradel * boveradel * ratio * ratio) +
2364 epsvec[1][i] = boveradel * boveradel * (ratio * ratio);
2392 Vmath::Vsub(nq, Cloakregion, 1, Vacregion, 1, Cloakregion, 1);
2395 ExactCloakArea = ExactCloakArea - (
m_fields[0]->Integral(Cloakregion));
2396 std::cout <<
"*** Error of Cloakregion area = " << ExactCloakArea
2404 for (
int i = 0; i < nq; ++i)
2406 if (Cloakregion[i] > 0)
2412 epsvec[0][i] = radvec[i] / (radvec[i] - m_adel);
2413 epsvec[1][i] = (radvec[i] - m_adel) / radvec[i];
2414 muvec[2][i] = (m_b / (m_b - m_adel)) * (m_b / (m_b - m_adel)) *
2415 (radvec[i] - m_adel) / radvec[i];
2417 muvec[0][i] = epsvec[0][i];
2418 muvec[1][i] = epsvec[1][i];
2419 epsvec[2][i] = muvec[2][i];
2428 int nq =
m_fields[0]->GetTotPoints();
2436 &Sigma1minus0[0], 1);
2438 &Sigma0minus1[0], 1);
2440 &Sigma0plus1Neg[0], 1);
2455 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2456 &outarray[indxH0][0], 1, &outarray[indxH0][0], 1);
2457 Vmath::Vadd(nq, &physarray[indxQ0][0], 1, &outarray[indxH0][0], 1,
2458 &outarray[indxH0][0], 1);
2461 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2462 &outarray[indxH1][0], 1, &outarray[indxH1][0], 1);
2463 Vmath::Vadd(nq, &physarray[indxQ1][0], 1, &outarray[indxH1][0], 1,
2464 &outarray[indxH1][0], 1);
2467 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxE2][0], 1,
2468 &outarray[indxE2][0], 1, &outarray[indxE2][0], 1);
2469 Vmath::Vadd(nq, &physarray[indxP2][0], 1, &outarray[indxE2][0], 1,
2470 &outarray[indxE2][0], 1);
2473 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxH0][0], 1,
2474 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2476 &outarray[indxQ0][0], 1);
2480 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxH1][0], 1,
2481 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2483 &outarray[indxQ1][0], 1);
2489 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2494 &outarray[indxP2][0], 1);
2495 Vmath::Vmul(nq, &physarray[indxE2][0], 1, &outarray[indxP2][0], 1,
2496 &outarray[indxP2][0], 1);
2511 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE0][0], 1,
2512 &outarray[indxE0][0], 1, &outarray[indxE0][0], 1);
2513 Vmath::Vsub(nq, &outarray[indxE0][0], 1, &physarray[indxQ0][0], 1,
2514 &outarray[indxE0][0], 1);
2517 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE1][0], 1,
2518 &outarray[indxE1][0], 1, &outarray[indxE1][0], 1);
2519 Vmath::Vsub(nq, &outarray[indxE1][0], 1, &physarray[indxQ1][0], 1,
2520 &outarray[indxE1][0], 1);
2523 Vmath::Vvtvp(nq, &Sigma0plus1Neg[0], 1, &physarray[indxH2][0], 1,
2524 &outarray[indxH2][0], 1, &outarray[indxH2][0], 1);
2525 Vmath::Vsub(nq, &outarray[indxH2][0], 1, &physarray[indxP2][0], 1,
2526 &outarray[indxH2][0], 1);
2529 Vmath::Vvtvp(nq, &Sigma1minus0[0], 1, &physarray[indxE0][0], 1,
2530 &physarray[indxQ0][0], 1, &outarray[indxQ0][0], 1);
2532 &outarray[indxQ0][0], 1);
2536 Vmath::Vvtvp(nq, &Sigma0minus1[0], 1, &physarray[indxE1][0], 1,
2537 &physarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2539 &outarray[indxQ1][0], 1);
2545 &outarray[indxQ1][0], 1, &outarray[indxQ1][0], 1);
2550 &outarray[indxP2][0], 1);
2551 Vmath::Vmul(nq, &physarray[indxH2][0], 1, &outarray[indxP2][0], 1,
2552 &outarray[indxP2][0], 1);
2566 int nq =
m_fields[0]->GetTotPoints();
2567 int ncoeffs =
m_fields[0]->GetNcoeffs();
2569 std::string outname =
2570 m_sessionName +
"Tot_" + boost::lexical_cast<std::string>(n) +
".chk";
2572 std::vector<std::string> variables(nvar);
2573 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2575 for (
int i = 0; i < nvar; ++i)
2581 for (
int i = 0; i < nvar; ++i)
2584 Vmath::Vadd(nq, fieldphys[i], 1, totfield, 1, totfield, 1);
2586 m_fields[i]->FwdTrans(totfield, fieldcoeffs[i]);
2598 int nq =
m_fields[0]->GetTotPoints();
2599 int ncoeffs =
m_fields[0]->GetNcoeffs();
2601 std::string outname =
2602 m_sessionName +
"Plot_" + boost::lexical_cast<std::string>(n) +
".chk";
2604 std::vector<std::string> variables(nvar);
2605 variables[0] =
"Fx";
2606 variables[1] =
"Fy";
2607 variables[2] =
"Fz";
2609 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2610 for (
int i = 0; i < nvar; ++i)
2621 &tmp[0], 1, &tmp[0], 1);
2623 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2634 int nq =
m_fields[0]->GetTotPoints();
2635 int ncoeffs =
m_fields[0]->GetNcoeffs();
2638 boost::lexical_cast<std::string>(n) +
".chk";
2640 std::vector<std::string> variables(nvar);
2641 variables[0] =
"Frx";
2642 variables[1] =
"Fry";
2643 variables[2] =
"Frz";
2644 for (
int i = 3; i < nvar; ++i)
2649 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2650 for (
int i = 0; i < nvar; ++i)
2660 Vmath::Vadd(nq, fieldphys[0], 1, totfield0, 1, totfield0, 1);
2663 Vmath::Vadd(nq, fieldphys[1], 1, totfield1, 1, totfield1, 1);
2670 &tmp[0], 1, &tmp[0], 1);
2672 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2675 for (
int j = 3; j < nvar; ++j)
2677 m_fields[j]->FwdTrans(fieldphys[j], fieldcoeffs[j]);
2687 boost::ignore_unused(time);
2690 int nq =
m_fields[0]->GetTotPoints();
2691 int ncoeffs =
m_fields[0]->GetNcoeffs();
2694 boost::lexical_cast<std::string>(n) +
".chk";
2696 std::vector<std::string> variables(nvar);
2697 variables[0] =
"EDFx";
2698 variables[1] =
"EDFy";
2699 variables[2] =
"EDFz";
2700 for (
int i = 3; i < nvar; ++i)
2705 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2706 for (
int i = 0; i < nvar; ++i)
2720 &tmp[0], 1, &tmp[0], 1);
2722 Vmath::Vmul(nq, &fieldphys[2][0], 1, &tmp[0], 1, &tmp[0], 1);
2729 m_fields[k]->FwdTrans(tmp, fieldcoeffs[k]);
2739 boost::ignore_unused(time);
2742 int nq =
m_fields[0]->GetTotPoints();
2743 int ncoeffs =
m_fields[0]->GetNcoeffs();
2746 boost::lexical_cast<std::string>(n) +
".chk";
2748 std::vector<std::string> variables(nvar);
2749 variables[0] =
"Energy";
2750 variables[1] =
"EnergyFlux";
2751 variables[2] =
"Zero";
2752 for (
int i = 3; i < nvar; ++i)
2757 std::vector<Array<OneD, NekDouble>> fieldcoeffs(nvar);
2758 for (
int i = 0; i < nvar; ++i)
2772 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1, &energy[0],
2776 m_fields[0]->FwdTrans(energy, fieldcoeffs[0]);
2781 for (
int k = 0; k < 2; ++k)
2787 Vmath::Vvtvp(nq, &fieldphys[k][0], 1, &fieldphys[k][0], 1,
2788 &energyflux[0], 1, &energyflux[0], 1);
2792 Vmath::Vmul(nq, &fieldphys[2][0], 1, &energyflux[0], 1, &energyflux[0], 1);
2794 m_fields[1]->FwdTrans(energyflux, fieldcoeffs[1]);
2806 int nq =
m_fields[0]->GetTotPoints();
2807 int ncoeffs =
m_fields[0]->GetNcoeffs();
2821 1.0 / (1.0 + exp(-0.5 * (time -
m_PSduration) / SFradius));
2823 for (
int j = 0; j < nq; ++j)
2825 rad =
sqrt((x[j] - Psx) * (x[j] - Psx) + (y[j] - Psy) * (y[j] - Psy) +
2826 (z[j] - Psz) * (z[j] - Psz));
2827 outarray[j] = SmoothFactor * exp(-1.0 * (
rad / Gaussianradius) *
2828 (
rad / Gaussianradius));
2831 m_fields[0]->FwdTransLocalElmt(outarray, tmpc);
2832 m_fields[0]->BwdTrans(tmpc, outarray);
2844 NekDouble sin_theta, cos_theta, sin_varphi, cos_varphi;
2853 for (
int j = 0; j < nq; ++j)
2862 outarray[j] = 2.0 * m_Omega * sin_theta;
2871 int nq = physarray[0].size();
2913 Vmath::Vadd(nq, tmp, 1, outarray[j], 1, outarray[j], 1);
2928 if (CloakNlayer == 8)
2931 if (fabs(la * lb - 1.0) < 0.0001)
2957 if (CloakNlayer == 16)
2960 if (fabs(la * lb - 1.0) < 0.0001)
3006 m_fields[0]->GetCoords(x0, x1, x2);
3012 m_fields[0]->GenerateElementVector(Layer[0], 1.0, 0.0, Currenttmp);
3014 for (
int i = 1; i < CloakNlayer; ++i)
3016 m_fields[0]->GenerateElementVector(Layer[i], 1.0, 0.0, Currenttmp);
3017 m_fields[0]->GenerateElementVector(Layer[i - 1], 1.0, 0.0, Formertmp);
3019 Vmath::Vsub(nq, Currenttmp, 1, Formertmp, 1, Currenttmp, 1);
3021 Vmath::Svtvp(nq, 1.0 * (i + 1), Currenttmp, 1, Cloakregion, 1,
3027 for (
int i = 0; i < nq; ++i)
3033 if ((Cloakregion[i] > 0) && (CloakNlayer > 0))
3035 radvec[i] = 1.0 + (m_b - m_a) / CloakNlayer *
3036 (Cloakregion[i] - 0.5);
3042 sqrt(x0[i] * x0[i] / la / la + x1[i] * x1[i] / lb / lb);
3049 radvec[i] =
sqrt(2.0 * x0[i] * x0[i] +
3050 x1[i] * x1[i] * x1[i] * x1[i] + x1[i] * x1[i]);
3056 radvec[i] =
sqrt(3.0 * x0[i] * x0[i] +
3057 x1[i] * x1[i] * x1[i] * x1[i] - x1[i] * x1[i]);
3073 s,
"TestMaxwellType",
3139 int Ntot = inarray.size();
3142 for (
int i = 0; i < Ntot; ++i)
3144 std::cout <<
"[" << i <<
"] = " << inarray[2][i] << std::endl;
3147 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.
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)
MMFMaxwell(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
void Printout_SurfaceCurrent(Array< OneD, Array< OneD, NekDouble >> &fields, const int time)
virtual void v_InitObject(bool DeclareFields=true) override
Initialise the object.
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)
virtual void v_EvaluateExactSolution(unsigned int field, Array< OneD, NekDouble > &outfield, const NekDouble time) override
virtual void v_DoSolve() override
Solves an unsteady problem.
void AddCoriolis(Array< OneD, Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
void print_MMF(Array< OneD, Array< OneD, NekDouble >> &inarray)
Array< OneD, NekDouble > m_wp2
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print Summary.
void Checkpoint_EDFluxOutput(const int n, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &fieldphys)
virtual void v_SetInitialConditions(const NekDouble initialtime, bool dumpInitialConditions, const int domain) override
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.
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 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)
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)
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()
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
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)