69 "ProcessPowerSpectrum only works for Homogeneous1D fields.");
71 if (
m_f->m_exp[0]->GetNumElmts() == 0)
76 std::set<int> variables;
77 if (
m_config[
"vars"].as<string>().compare(
"NotSet") != 0)
80 m_f->m_variables, variables);
83 "At least one variable should be selected.");
84 if (variables.empty())
88 std::vector<NekDouble> box;
89 if (
m_config[
"box"].as<string>().compare(
"NotSet") != 0)
92 "Failed to interpret box string");
95 "box string should contain at least 4 values xmin,xmax,ymin,ymax");
98 if (
m_f->m_comm->GetSpaceComm()->GetRank() == 0)
101 cout <<
"Processing frequency spectra of variables (";
102 for (
auto nsignal : variables)
104 cout <<
m_f->m_variables[nsignal] <<
", ";
106 cout <<
") in box [" << box[0] <<
", " << box[1] <<
"]X[" << box[2]
107 <<
", " << box[3] <<
"].\n";
110 for (
auto nsignal : variables)
112 m_f->m_exp[nsignal]->SetWaveSpace(
true);
113 m_f->m_exp[nsignal]->BwdTrans(
m_f->m_exp[nsignal]->GetCoeffs(),
114 m_f->m_exp[nsignal]->UpdatePhys());
117 int nplanes =
m_f->m_exp[0]->GetZIDs().size();
120 int ntot = plane0->GetNpoints();
122 for (
size_t i = 0; i < plane0->GetExpSize(); ++i)
129 for (
size_t j = 0; j < nv; ++j)
132 vertex->
GetCoords(gct[0], gct[1], gct[2]);
136 if (box[0] <= gc[0] && gc[0] <= box[1] && box[2] <= gc[1] &&
140 &masks[plane0->GetPhys_Offset(i)], 1);
143 NekDouble area =
m_f->m_exp[0]->GetPlane(0)->Integral(masks);
151 for (
size_t m = 0; m < value.size(); ++m)
153 for (
auto nsignal : variables)
157 1,
m_f->m_exp[nsignal]->GetPlane(2 * m)->GetPhys(), 1,
158 wavecoef, 1, wavecoef, 1);
160 m_f->m_exp[nsignal]->GetPlane(2 * m + 1)->GetPhys(), 1,
161 m_f->m_exp[nsignal]->GetPlane(2 * m + 1)->GetPhys(), 1,
162 wavecoef, 1, wavecoef, 1);
163 Vmath::Vmul(ntot, wavecoef, 1, masks, 1, wavecoef, 1);
168 value[m] +=
m_f->m_exp[0]->GetPlane(2 * m)->Integral(wavecoef);
172 if (
m_f->m_comm->GetSpaceComm()->GetRank() == 0)
175 ofstream powersp(
"spectra.dat");
176 powersp <<
"variables = lambda beta energy" << endl;
177 for (
size_t m = 1; m < value.size(); ++m)
179 powersp << (lz / m) <<
" " << (2. * M_PI * m / lz) <<
" "
181 energy += value[m] * value[m];
184 if (vm.count(
"error"))
186 cout <<
"L 2 error (variable E) : " << energy << endl;
190 int nfields =
m_f->m_variables.size();
191 m_f->m_exp.resize(nfields + 1);
192 m_f->m_variables.push_back(
"regions");
193 m_f->m_exp[nfields] =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
194 for (
size_t m = 0; m < nplanes; ++m)
197 m_f->m_exp[nfields]->GetPlane(m)->UpdatePhys(), 1);
199 m_f->m_exp[nfields]->FwdTrans(
m_f->m_exp[nfields]->GetPhys(),
200 m_f->m_exp[nfields]->UpdateCoeffs());
Base class for shape geometry information.
PointGeom * GetVertex(int i) const
Returns vertex i of this object.
int GetNumVerts() const
Get the number of vertices of this object.
void GetCoords(NekDouble &x, NekDouble &y, NekDouble &z)
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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.