50 "Output power spectrum at given regions from a 3DH1D expansion.");
56 "Specify a rectangular box by box=xmin,xmax,ymin,ymax");
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)
126 int nv = geom->GetNumVerts();
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());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
~ProcessPowerSpectrum() override
void v_Process(po::variables_map &vm) override
Write mesh to output file.
ProcessPowerSpectrum(FieldSharedPtr f)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static bool GenerateVariableSet(const std::string &str, const std::vector< std::string > &variables, std::set< int > &out)
Generate a set of variable locations.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekZeroTol
std::shared_ptr< PointGeom > PointGeomSharedPtr
std::shared_ptr< Geometry > GeometrySharedPtr
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 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.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Represents a command-line configuration option.