From f781f949c49415d3023e06ad45b0e0e76d290210 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 16 Dec 2008 19:30:02 +0000 Subject: [PATCH] better prealloc in old views to speed up plugins on windows --- Plugin/Curl.cpp | 2 +- Plugin/Divergence.cpp | 2 +- Plugin/Extract.cpp | 2 +- Plugin/Gradient.cpp | 2 +- Plugin/HarmonicToTime.cpp | 2 +- Post/PView.cpp | 4 ++-- Post/PView.h | 2 +- Post/PViewDataList.cpp | 4 ++-- Post/PViewDataList.h | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Plugin/Curl.cpp b/Plugin/Curl.cpp index 5fd5106440..98381027c4 100644 --- a/Plugin/Curl.cpp +++ b/Plugin/Curl.cpp @@ -79,7 +79,7 @@ PView *GMSH_CurlPlugin::execute(PView *v) return v; } - PView *v2 = new PView(true); + PView *v2 = new PView(true, data1->getNumElements()); PViewDataList *data2 = getDataList(v2); for(int ent = 0; ent < data1->getNumEntities(0); ent++){ diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp index 6f009a6262..4cc4f2f486 100644 --- a/Plugin/Divergence.cpp +++ b/Plugin/Divergence.cpp @@ -79,7 +79,7 @@ PView *GMSH_DivergencePlugin::execute(PView *v) return v; } - PView *v2 = new PView(true); + PView *v2 = new PView(true, data1->getNumElements()); PViewDataList *data2 = getDataList(v2); for(int ent = 0; ent < data1->getNumEntities(0); ent++){ diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp index f2b395da3e..57aa18004e 100644 --- a/Plugin/Extract.cpp +++ b/Plugin/Extract.cpp @@ -221,7 +221,7 @@ PView *GMSH_ExtractPlugin::execute(PView *v) PViewDataList *data1 = getDataList(v1); if(!data1) return v; - PView *v2 = new PView(true); + PView *v2 = new PView(true, data1->getNumElements()); PViewDataList *data2 = getDataList(v2); if(!data2) return v; diff --git a/Plugin/Gradient.cpp b/Plugin/Gradient.cpp index db9287d43f..58c1fafdcb 100644 --- a/Plugin/Gradient.cpp +++ b/Plugin/Gradient.cpp @@ -95,7 +95,7 @@ PView *GMSH_GradientPlugin::execute(PView *v) return v; } - PView *v2 = new PView(true); + PView *v2 = new PView(true, data1->getNumElements()); PViewDataList *data2 = getDataList(v2); for(int ent = 0; ent < data1->getNumEntities(0); ent++){ diff --git a/Plugin/HarmonicToTime.cpp b/Plugin/HarmonicToTime.cpp index 6e81ddb4dd..4c1f39cfb2 100644 --- a/Plugin/HarmonicToTime.cpp +++ b/Plugin/HarmonicToTime.cpp @@ -115,7 +115,7 @@ PView *GMSH_HarmonicToTimePlugin::execute(PView * v) return v1; } - PView *v2 = new PView(true); + PView *v2 = new PView(true, data1->getNumElements() * nSteps); PViewDataList *data2 = getDataList(v2); if(!data2) return v; diff --git a/Post/PView.cpp b/Post/PView.cpp index c37ba083f5..2e8e51bb6f 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -29,10 +29,10 @@ void PView::_init() for(unsigned int i = 0; i < list.size(); i++) list[i]->setIndex(i); } -PView::PView(bool allocate) +PView::PView(bool allocate, int numalloc) { _init(); - _data = new PViewDataList(allocate); + _data = new PViewDataList(allocate, numalloc); _options = new PViewOptions(PViewOptions::reference); if(_options->AdaptVisualizationGrid) _data->initAdaptiveData(_options->TimeStep, _options->MaxRecursionLevel, diff --git a/Post/PView.h b/Post/PView.h index 04f340d4eb..c8c6fed3b6 100644 --- a/Post/PView.h +++ b/Post/PView.h @@ -41,7 +41,7 @@ class PView{ public: // create a new view with list-based data, allocated or not - PView(bool allocate=true); + PView(bool allocate=true, int numalloc=1000); // construct a new view using the given data PView(PViewData *data); // construct a new view, alias of the view "ref" diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp index f30d369c2e..17dd74e0d6 100644 --- a/Post/PViewDataList.cpp +++ b/Post/PViewDataList.cpp @@ -11,7 +11,7 @@ extern Context_T CTX; -PViewDataList::PViewDataList(bool allocate) +PViewDataList::PViewDataList(bool allocate, int numalloc) : PViewData(), DataSize(sizeof(double)), NbTimeStep(0), Min(VAL_INF), Max(-VAL_INF), Time(0), NbSP(0), NbVP(0), NbTP(0), SP(0), VP(0), TP(0), @@ -37,7 +37,7 @@ PViewDataList::PViewDataList(bool allocate) for(int i = 0; i < 24; i++) _index[i] = 0; if(allocate){ -#define LCD List_Create(1, 1000, sizeof(double)) +#define LCD List_Create(1, numalloc, sizeof(double)) Time = LCD; SP = LCD; VP = LCD; TP = LCD; SL = LCD; VL = LCD; TL = LCD; SL2 = LCD; VL2 = LCD; TL2 = LCD; diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index c7daf0cc29..9f1a1cf8e7 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -56,7 +56,7 @@ class PViewDataList : public PViewData { double &x, double &y, double &z, double &style); void _splitCurvedElements(); public: - PViewDataList(bool allocate=true); + PViewDataList(bool allocate=true, int numalloc=1000); ~PViewDataList(); bool finalize(); int getNumTimeSteps(){ return NbTimeStep; } -- GitLab