Skip to content
Snippets Groups Projects
Commit 93d53a7f authored by Emilie Marchandise's avatar Emilie Marchandise
Browse files

modified plugin to keep time step and to be able to integrate over time...

modified plugin to keep time step and to be able to integrate over time (needed for onelab laser project)
parent 31288144
Branches
Tags
No related merge requests found
...@@ -1215,7 +1215,7 @@ void Centerline::operator() (double x, double y, double z, SMetric3 &metr, GEnt ...@@ -1215,7 +1215,7 @@ void Centerline::operator() (double x, double y, double z, SMetric3 &metr, GEnt
double rho = radMax; double rho = radMax;
double hwall_n = thickness/20.; double hwall_n = thickness/20.;
double hwall_t = 2*M_PI*rho/nbPoints; double hwall_t = 2*M_PI*rho/nbPoints;
double hfar = radMax/5.; double hfar = radMax/8.;
double lc_a = 3.*hwall_t; double lc_a = 3.*hwall_t;
//dir_a = direction along the centerline //dir_a = direction along the centerline
...@@ -1246,12 +1246,15 @@ void Centerline::operator() (double x, double y, double z, SMetric3 &metr, GEnt ...@@ -1246,12 +1246,15 @@ void Centerline::operator() (double x, double y, double z, SMetric3 &metr, GEnt
beta, lc_n, lc_t, hwall_t); beta, lc_n, lc_t, hwall_t);
} }
else if (ds > thickness && onInOutlets){ else if (ds > thickness && onInOutlets){
curvMetric = buildMetricTangentToCurve(dir_n,lc_n,lc_t); metr = buildMetricTangentToCurve(dir_n,lc_n,lc_t);
} }
else if (ds > thickness && !onInOutlets){ else if (ds > thickness && onInOutlets){
curvMetric = buildMetricTangentToCurve(dir_n,lc_n,lc_a); //curvMetric = metricBasedOnSurfaceCurvature(dMin, dMax, cMin, cMax, radMax, beta, lc_n, lc_t, hwall_t);
metr = SMetric3(1./(lc_a*lc_a), 1./(lc_n*lc_n), 1./(lc_t*lc_t), dir_a, dir_n, dir_cross); curvMetric = buildMetricTangentToCurve(dir_n,lc_n,lc_n); //lc_t
//metr = SMetric3(1./(lc_a*lc_a), 1./(lc_n*lc_n),1./(lc_n*lc_n), dir_a, dir_a1, dir_a2);
metr = SMetric3(1./(lc_a*lc_a), 1./(lc_n*lc_n), 1./(lc_n*lc_n), dir_a, dir_n, dir_cross);
metr = intersection_conserveM1(metr,curvMetric); metr = intersection_conserveM1(metr,curvMetric);
//metr = intersection(metr,curvMetric);
} }
return; return;
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "PViewOptions.h" #include "PViewOptions.h"
StringXNumber IntegrateOptions_Number[] = { StringXNumber IntegrateOptions_Number[] = {
{GMSH_FULLRC, "View", NULL, -1.} {GMSH_FULLRC, "View", NULL, -1.},
{GMSH_FULLRC, "OverTime", NULL, -1.}
}; };
extern "C" extern "C"
...@@ -27,6 +28,8 @@ std::string GMSH_IntegratePlugin::getHelp() const ...@@ -27,6 +28,8 @@ std::string GMSH_IntegratePlugin::getHelp() const
"line/surface elements.\n\n" "line/surface elements.\n\n"
"If `View' < 0, the plugin is run on the current view.\n\n" "If `View' < 0, the plugin is run on the current view.\n\n"
"Plugin(Integrate) creates one new view."; "Plugin(Integrate) creates one new view.";
"If `OverTime' = 1 , the plugin integrates the scalar view over time instead of over space.\n\n"
"Plugin(Integrate) creates one new view.";
} }
int GMSH_IntegratePlugin::getNbOptions() const int GMSH_IntegratePlugin::getNbOptions() const
...@@ -42,6 +45,7 @@ StringXNumber *GMSH_IntegratePlugin::getOption(int iopt) ...@@ -42,6 +45,7 @@ StringXNumber *GMSH_IntegratePlugin::getOption(int iopt)
PView *GMSH_IntegratePlugin::execute(PView * v) PView *GMSH_IntegratePlugin::execute(PView * v)
{ {
int iView = (int)IntegrateOptions_Number[0].def; int iView = (int)IntegrateOptions_Number[0].def;
int overTime = (int)IntegrateOptions_Number[1].def;
PView *v1 = getView(iView, v); PView *v1 = getView(iView, v);
if(!v1) return v; if(!v1) return v;
...@@ -50,6 +54,7 @@ PView *GMSH_IntegratePlugin::execute(PView * v) ...@@ -50,6 +54,7 @@ PView *GMSH_IntegratePlugin::execute(PView * v)
PView *v2 = new PView(); PView *v2 = new PView();
PViewDataList *data2 = getDataList(v2); PViewDataList *data2 = getDataList(v2);
if (overTime == -1) {
double x = data1->getBoundingBox().center().x(); double x = data1->getBoundingBox().center().x();
double y = data1->getBoundingBox().center().y(); double y = data1->getBoundingBox().center().y();
double z = data1->getBoundingBox().center().z(); double z = data1->getBoundingBox().center().z();
...@@ -110,6 +115,48 @@ PView *GMSH_IntegratePlugin::execute(PView * v) ...@@ -110,6 +115,48 @@ PView *GMSH_IntegratePlugin::execute(PView * v)
double time = data1->getTime(i); double time = data1->getTime(i);
data2->Time.push_back(time); data2->Time.push_back(time);
} }
}
else{
printf("EMI INTEGRATE OVER TIME \n");
int timeBeg = data1->getFirstNonEmptyTimeStep();
int timeEnd = data1->getNumTimeSteps();
for(int ent = 0; ent < data1->getNumEntities(timeBeg); ent++){
for(int ele = 0; ele < data1->getNumElements(timeBeg, ent); ele++){
if(data1->skipElement(timeBeg, ent, ele)) continue;
int numNodes = data1->getNumNodes(timeBeg, ent, ele);
int type = data1->getType(timeBeg, ent, ele);
int numComp = data1->getNumComponents(timeBeg, ent, ele);
if (numComp != 1) Msg::Error("Can only integrate in time scalar views");
std::vector<double> *out = data2->incrementList(numComp, type, numNodes);
std::vector<double> x(numNodes), y(numNodes), z(numNodes);
for(int nod = 0; nod < numNodes; nod++)
data1->getNode(timeBeg, ent, ele, nod, x[nod], y[nod], z[nod]);
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]);
double time = 0.0;
std::vector<double> timeIntegral(numNodes, 0.);
for(int step = timeBeg; step < timeEnd; step++){
if(!data1->hasTimeStep(step)) continue;
double val;
double newTime = data1->getTime(step);
double dt = newTime - time;
time = newTime;
for(int nod = 0; nod < numNodes; nod++){
double val;
data1->getValue(step, ent, ele, nod, 0, val);
timeIntegral[nod] += val*dt;
}
}
for(int nod = 0; nod < numNodes; nod++)
out->push_back(timeIntegral[nod]);
}
}
}
data2->setName(data1->getName() + "_Integrate"); data2->setName(data1->getName() + "_Integrate");
data2->setFileName(data1->getName() + "_Integrate.pos"); data2->setFileName(data1->getName() + "_Integrate.pos");
data2->finalize(); data2->finalize();
......
...@@ -412,6 +412,13 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata, ...@@ -412,6 +412,13 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata,
_addElement(np, numEdges, numComp, xp, yp, zp, valp, out, step == stepmin); _addElement(np, numEdges, numComp, xp, yp, zp, valp, out, step == stepmin);
} }
if(vstep < 0){
for(int i = stepmin; i < stepmax; i++) {
out->Time.push_back(vdata->getTime(i));
}
}
} }
} }
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment