Commit 4af88a0e authored by François Henrotte's avatar François Henrotte

add freqency and numperiod parameters

parent da7a206e
......@@ -11,6 +11,8 @@ StringXNumber HarmonicToTimeOptions_Number[] = {
{GMSH_FULLRC, "ImaginaryPart", NULL, 1.},
{GMSH_FULLRC, "NumSteps", NULL, 20.},
{GMSH_FULLRC, "TimeSign", NULL, -1.},
{GMSH_FULLRC, "Frequency", NULL, 1},
{GMSH_FULLRC, "NumPeriods", NULL, 1},
{GMSH_FULLRC, "View", NULL, -1.}
};
......@@ -51,7 +53,9 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView * v)
int iIndex = (int)HarmonicToTimeOptions_Number[1].def;
int nSteps = (int)HarmonicToTimeOptions_Number[2].def;
double tsign = HarmonicToTimeOptions_Number[3].def > 0 ? 1. : -1.;
int iView = (int)HarmonicToTimeOptions_Number[4].def;
double frequency = HarmonicToTimeOptions_Number[4].def;
int nPeriods = (int)HarmonicToTimeOptions_Number[5].def;
int iView = (int)HarmonicToTimeOptions_Number[6].def;
PView *v1 = getView(iView, v);
if(!v1) return v;
......@@ -61,6 +65,10 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView * v)
Msg::Error("HarmonicToTime plugin cannot be applied to multi-mesh views");
return v1;
}
if(frequency==0){
Msg::Error("HarmonicToTime plugin: null frequency is forbidden");
return v1;
}
if(rIndex < 0 || rIndex >= data1->getNumTimeSteps() ||
iIndex < 0 || iIndex >= data1->getNumTimeSteps()){
......@@ -95,8 +103,8 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView * v)
for(int nod = 0; nod < numNodes; nod++) out->push_back(x[nod]);
for(int nod = 0; nod < numNodes; nod++) out->push_back(y[nod]);
for(int nod = 0; nod < numNodes; nod++) out->push_back(z[nod]);
for(int t = 0; t < nSteps; t++) {
double p = 2. * M_PI * t / nSteps;
for(int k = 0; k < nSteps; k++) {
double p = 2. * M_PI * nPeriods * k / nSteps;
for(int nod = 0; nod < numNodes; nod++) {
for(int comp = 0; comp < numComp; comp++) {
double val =
......@@ -109,9 +117,9 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView * v)
}
}
for(int i = 0; i < nSteps; i++){
double p = 2. * M_PI * i / (double)nSteps;
data2->Time.push_back(p);
for(int k = 0; k < nSteps; k++){
double t = 2. * M_PI * nPeriods * k / frequency / (double)nSteps;
data2->Time.push_back(t);
}
data2->setName(data1->getName() + "_HarmonicToTime");
data2->setFileName(data1->getName() + "_HarmonicToTime.pos");
......
......@@ -20,7 +20,7 @@ class GMSH_HarmonicToTimePlugin : public GMSH_PostPlugin
std::string getName() const { return "HarmonicToTime"; }
std::string getShortHelp() const
{
return "Transform harmonic data into time domain";
return "Transform harmonic data into time domain data";
}
std::string getHelp() const;
int getNbOptions() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment