diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 8506772e5ce9b6a98c63fab60ebec6f40d74e9ef..18bccb0398ca89d61eed1e7a9166ee37c47b95f8 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -16,6 +16,17 @@ </Documentation> </StringVectorProperty> + <!-- Send discrete time info to the animation panel --> + <DoubleVectorProperty + name="TimestepValues" + repeatable="1" + information_only="1"> + <TimeStepsInformationHelper/> + <Documentation> + Available timestep values. + </Documentation> + </DoubleVectorProperty> + <!-- Cache Mesh check-box --> <IntVectorProperty name="UiCacheMesh" @@ -30,20 +41,33 @@ </Documentation> </IntVectorProperty> - - <!-- Send discrete time info to the animation panel --> - <DoubleVectorProperty - name="TimestepValues" - repeatable="1" - information_only="1"> - <TimeStepsInformationHelper/> + <!-- Refresh button --> + <IntVectorProperty + name="UiRefresh" + command="SetRefresh" + number_of_elements="1" + is_internal="0" + default_values="0" + animateable="0"> + <BooleanDomain name="bool"/> <Documentation> - Available timestep values. + Rescan for updated timesteps/fields. </Documentation> - </DoubleVectorProperty> - + </IntVectorProperty> - <!-- Global settings --> + <!-- Skip Zero Time check-box --> + <IntVectorProperty + name="UiZeroTime" + command="SetSkipZeroTime" + number_of_elements="1" + is_internal="1" + default_values="0" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + Skip including the 0/ time directory + </Documentation> + </IntVectorProperty> <!-- Extrapolate Patches check-box --> <IntVectorProperty @@ -60,22 +84,24 @@ <!-- Include Sets check-box --> <IntVectorProperty - name="IncludeSets" + name="UiIncludeSets" command="SetIncludeSets" number_of_elements="1" + is_internal="1" default_values="0" animateable="0"> <Documentation> - Searches the polyMesh/sets/ directory + Search the polyMesh/sets/ directory </Documentation> <BooleanDomain name="bool"/> </IntVectorProperty> <!-- Include Zones check-box --> <IntVectorProperty - name="IncludeZones" + name="UiIncludeZones" command="SetIncludeZones" number_of_elements="1" + is_internal="1" default_values="0" animateable="0"> <Documentation> @@ -95,7 +121,7 @@ animateable="0"> <BooleanDomain name="bool"/> <Documentation> - Show patch names in render window. + Show patch names in render window </Documentation> </IntVectorProperty> @@ -112,12 +138,13 @@ </Documentation> </IntVectorProperty> - - <!-- Selections --> + <!-- + | Selections + --> <!-- Available Parts (volume, patches, lagrangian) array --> <StringVectorProperty - name="PartArrayInfo" + name="PartArrayStatus" information_only="1"> <ArraySelectionInformationHelper attribute_name="Part"/> </StringVectorProperty> @@ -129,18 +156,21 @@ repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="PartArrayInfo" + information_property="PartArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="PartArrayInfo" function="ArrayList"/> + <Property name="PartArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the mesh parts (patches, sets, zones). + </Documentation> </StringVectorProperty> <!-- Available volFields array --> <StringVectorProperty - name="VolFieldArrayInfo" + name="VolFieldArrayStatus" information_only="1"> <ArraySelectionInformationHelper attribute_name="VolField"/> </StringVectorProperty> @@ -152,18 +182,21 @@ repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="VolFieldArrayInfo" + information_property="VolFieldArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="VolFieldArrayInfo" function="ArrayList"/> + <Property name="VolFieldArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the volume fields + </Documentation> </StringVectorProperty> <!-- Available Lagrangian fields array --> <StringVectorProperty - name="LagrangianFieldArrayInfo" + name="LagrangianFieldArrayStatus" information_only="1"> <ArraySelectionInformationHelper attribute_name="LagrangianField"/> </StringVectorProperty> @@ -175,18 +208,21 @@ repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="LagrangianFieldArrayInfo" + information_property="LagrangianFieldArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="LagrangianFieldArrayInfo" function="ArrayList"/> + <Property name="LagrangianFieldArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the lagrangian fields + </Documentation> </StringVectorProperty> <!-- Available pointFields array --> <StringVectorProperty - name="PointFieldArrayInfo" + name="PointFieldArrayStatus" information_only="1"> <ArraySelectionInformationHelper attribute_name="PointField"/> </StringVectorProperty> @@ -198,19 +234,26 @@ repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="PointFieldArrayInfo" + information_property="PointFieldArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="PointFieldArrayInfo" function="ArrayList"/> + <Property name="PointFieldArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the point fields + </Documentation> </StringVectorProperty> <Hints> <Property name="FileName" show="0"/> <Property name="UiCacheMesh" show="0"/> + <Property name="UiZeroTime" show="0"/> + <Property name="UiRefresh" show="0"/> <Property name="UiShowPatchNames" show="0"/> + <Property name="UiIncludeSets" show="0"/> + <Property name="UiIncludeZones" show="0"/> </Hints> diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx index 4f12089f45d71be3aa020764467268814bac681d..7d421cbedd0dc863e371e5c81ee08376580f5d00 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx @@ -32,9 +32,10 @@ License #include <QLabel> #include <QLayout> #include <QString> +#include <QPushButton> #include <QtDebug> -// Paraview<->QT UI +// Paraview <-> QT UI #include "pqAnimationScene.h" #include "pqApplicationCore.h" #include "pqPipelineRepresentation.h" @@ -56,51 +57,169 @@ pqPV3FoamReaderPanel::pqPV3FoamReaderPanel QWidget *p ) : - pqAutoGeneratedObjectPanel(proxy, p), - sourceProxy_(vtkSMSourceProxy::SafeDownCast(this->proxy())) + pqAutoGeneratedObjectPanel(proxy, p) { // create first sublayout (at top of the panel) - QGridLayout *sect1 = new QGridLayout(); - this->PanelLayout->addLayout(sect1, 0, 0, 1, -1); + QGridLayout *form = new QGridLayout(); + this->PanelLayout->addLayout(form, 0, 0, 1, -1); + vtkSMProperty* prop = 0; + + // refresh button for updating times/fields + if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0) + { + prop->SetImmediateUpdate(1); + QPushButton *refresh = new QPushButton("Refresh Times"); + refresh->setToolTip("Rescan for updated times/fields."); + + form->addWidget(refresh, 0, 0, Qt::AlignLeft); + QObject::connect + ( + refresh, + SIGNAL(clicked()), + this, + SLOT(RefreshPressed()) + ); + } + + // checkbox for skip zeroTime + if ((prop = this->proxy()->GetProperty("UiZeroTime")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); + + ZeroTime_ = new QCheckBox("Skip Zero Time"); + ZeroTime_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + ZeroTime_->setToolTip + ( + "Skip including the 0/ time directory." + ); + + form->addWidget(ZeroTime_, 0, 1, Qt::AlignLeft); + connect + ( + ZeroTime_, + SIGNAL(stateChanged(int)), + this, + SLOT(ZeroTimeToggled()) + ); + } - // checkbox for caching mesh - CacheMesh_ = new QCheckBox("Cache Mesh"); - CacheMesh_->setChecked(true); // checkbox for caching mesh - ShowPatchNames_ = new QCheckBox("Show Patch Names"); - ShowPatchNames_->setChecked(false); + if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); - connect - ( - CacheMesh_, - SIGNAL(stateChanged(int)), - this, - SLOT(CacheMeshToggled()) - ); + CacheMesh_ = new QCheckBox("Cache Mesh"); + CacheMesh_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + CacheMesh_->setToolTip + ( + "Cache the fvMesh in memory." + ); - connect - ( - ShowPatchNames_, - SIGNAL(stateChanged(int)), - this, - SLOT(ShowPatchNamesToggled()) - ); + form->addWidget(CacheMesh_, 1, 0, Qt::AlignLeft); + connect + ( + CacheMesh_, + SIGNAL(stateChanged(int)), + this, + SLOT(CacheMeshToggled()) + ); + } - sect1->addWidget(CacheMesh_); - sect1->addWidget(ShowPatchNames_); + // checkbox for patch names + if ((prop = this->proxy()->GetProperty("UiShowPatchNames")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); + + ShowPatchNames_ = new QCheckBox("Patch Names"); + ShowPatchNames_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + ShowPatchNames_->setToolTip + ( + "Show patch names in render window." + ); + + // row/col 0,1 + form->addWidget(ShowPatchNames_, 1, 1, Qt::AlignLeft); + connect + ( + ShowPatchNames_, + SIGNAL(stateChanged(int)), + this, + SLOT(ShowPatchNamesToggled()) + ); + } + + + // checkbox for include sets + if ((prop = this->proxy()->GetProperty("UiIncludeSets")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); + + IncludeSets_ = new QCheckBox("Include Sets"); + IncludeSets_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + IncludeSets_->setToolTip + ( + "Search the polyMesh/sets/ directory." + ); + + // row/col 1,0 + form->addWidget(IncludeSets_, 2, 0, Qt::AlignLeft); + connect + ( + IncludeSets_, + SIGNAL(stateChanged(int)), + this, + SLOT(IncludeSetsToggled()) + ); + } + + + // checkbox for include zones + if ((prop = this->proxy()->GetProperty("UiIncludeZones")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); + + IncludeZones_ = new QCheckBox("Include Zones"); + IncludeZones_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + IncludeZones_->setToolTip + ( + "ZoneMesh information is used to find {cell,face,point}Zones. " + "The polyMesh/ directory is only checked on startup." + ); + + // row/col 1,1 + form->addWidget(IncludeZones_, 2, 1, Qt::AlignLeft); + connect + ( + IncludeZones_, + SIGNAL(stateChanged(int)), + this, + SLOT(IncludeZonesToggled()) + ); + } - // immediate update on the Server Manager side - vtkSMIntVectorProperty::SafeDownCast - ( - sourceProxy_->GetProperty("UiCacheMesh") - )->SetImmediateUpdate(true); - vtkSMIntVectorProperty::SafeDownCast - ( - sourceProxy_->GetProperty("UiShowPatchNames") - )->SetImmediateUpdate(true); } @@ -110,16 +229,43 @@ void pqPV3FoamReaderPanel::CacheMeshToggled() { vtkSMIntVectorProperty::SafeDownCast ( - sourceProxy_->GetProperty("UiCacheMesh") + this->proxy()->GetProperty("UiCacheMesh") )->SetElement(0, CacheMesh_->isChecked()); } +void pqPV3FoamReaderPanel::RefreshPressed() +{ + // update everything + vtkSMIntVectorProperty::SafeDownCast + ( + this->proxy()->GetProperty("UiRefresh") + )->Modified(); + + vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline(); + + // render all views + pqApplicationCore::instance()->render(); +} + + +void pqPV3FoamReaderPanel::ZeroTimeToggled() +{ + vtkSMIntVectorProperty::SafeDownCast + ( + this->proxy()->GetProperty("UiZeroTime") + )->SetElement(0, ZeroTime_->isChecked()); + + // update everything + RefreshPressed(); +} + + void pqPV3FoamReaderPanel::ShowPatchNamesToggled() { vtkSMIntVectorProperty::SafeDownCast ( - sourceProxy_->GetProperty("UiShowPatchNames") + this->proxy()->GetProperty("UiShowPatchNames") )->SetElement(0, ShowPatchNames_->isChecked()); // update the active view @@ -132,4 +278,37 @@ void pqPV3FoamReaderPanel::ShowPatchNamesToggled() } +void pqPV3FoamReaderPanel::IncludeSetsToggled() +{ + vtkSMProperty* prop; + + vtkSMIntVectorProperty::SafeDownCast + ( + this->proxy()->GetProperty("UiIncludeSets") + )->SetElement(0, IncludeSets_->isChecked()); + + if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0) + { + this->proxy()->UpdatePropertyInformation(prop); + } +} + + +void pqPV3FoamReaderPanel::IncludeZonesToggled() +{ + vtkSMProperty* prop; + + vtkSMIntVectorProperty::SafeDownCast + ( + this->proxy()->GetProperty("UiIncludeZones") + )->SetElement(0, IncludeZones_->isChecked()); + + if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0) + { + this->proxy()->UpdatePropertyInformation(prop); + } + +} + + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h index fc4f5f9adad0b89b6f395a492632d1f24de18075..49a3e11edad26ca2b82e1aea9a260c7a75df569d 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h @@ -37,6 +37,7 @@ SourceFiles #ifndef pqPV3FoamReaderPanel_h #define pqPV3FoamReaderPanel_h + #include "pqAutoGeneratedObjectPanel.h" // Forward declaration of QT classes @@ -62,8 +63,8 @@ class pqPV3FoamReaderPanel Q_OBJECT; typedef pqAutoGeneratedObjectPanel Superclass; - //- Server Manager Source Proxy - vtkSMSourceProxy* sourceProxy_; + //- ZeroTime checkbox + QCheckBox* ZeroTime_; //- CacheMesh checkbox QCheckBox* CacheMesh_; @@ -71,10 +72,20 @@ class pqPV3FoamReaderPanel //- Show Patch Names checkbox QCheckBox* ShowPatchNames_; + //- IncludeSets checkbox + QCheckBox* IncludeSets_; + + //- IncludeZones checkbox + QCheckBox* IncludeZones_; + protected slots: void CacheMeshToggled(); + void ZeroTimeToggled(); + void RefreshPressed(); void ShowPatchNamesToggled(); + void IncludeSetsToggled(); + void IncludeZonesToggled(); public: diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 32b01eb7958d8ff805c8fdeeea779d1a34b32cf1..4e5806b99c6137fe7ca2b2dbbe411a362746d47b 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -79,7 +79,9 @@ vtkPV3FoamReader::vtkPV3FoamReader() TimeStepRange[1] = 0; CacheMesh = 1; + Refresh = 0; + SkipZeroTime = 0; ExtrapolatePatches = 0; IncludeSets = 0; IncludeZones = 0; @@ -336,7 +338,6 @@ int vtkPV3FoamReader::RequestData foamData_->setTime(nRequestTime, requestTime); } - vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::SafeDownCast ( outputVector->GetInformationObject(0)->Get @@ -420,7 +421,39 @@ int vtkPV3FoamReader::RequestData } -void vtkPV3FoamReader::SetShowPatchNames(const int val) +void vtkPV3FoamReader::SetRefresh(int val) +{ + Modified(); +} + + +void vtkPV3FoamReader::SetIncludeSets(int val) +{ + if (IncludeSets != val) + { + IncludeSets = val; + if (foamData_) + { + foamData_->updateInfo(); + } + } +} + + +void vtkPV3FoamReader::SetIncludeZones(int val) +{ + if (IncludeZones != val) + { + IncludeZones = val; + if (foamData_) + { + foamData_->updateInfo(); + } + } +} + + +void vtkPV3FoamReader::SetShowPatchNames(int val) { if (ShowPatchNames != val) { @@ -430,7 +463,6 @@ void vtkPV3FoamReader::SetShowPatchNames(const int val) } - void vtkPV3FoamReader::updatePatchNamesView(const bool show) { pqApplicationCore* appCore = pqApplicationCore::instance(); @@ -452,7 +484,7 @@ void vtkPV3FoamReader::updatePatchNamesView(const bool show) // Get all the pqRenderView instances QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); - for (int viewI=0; viewI<renderViews.size(); viewI++) + for (int viewI=0; viewI < renderViews.size(); ++viewI) { foamData_->renderPatchNames ( @@ -521,7 +553,8 @@ int vtkPV3FoamReader::GetPartArrayStatus(const char* name) void vtkPV3FoamReader::SetPartArrayStatus(const char* name, int status) { - vtkDebugMacro(<<"SetPartArrayStatus"); + vtkDebugMacro("Set mesh part \"" << name << "\" status to: " << status); + if (status) { PartSelection->EnableArray(name); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index df73979205ef11886c27c7d0ced23907d9edfb9f..f3ac8a5d92958d69808af84d9435852c8e5efda9 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -83,6 +83,15 @@ public: vtkSetMacro(CacheMesh, int); vtkGetMacro(CacheMesh, int); + // Description: + // FOAM refresh times/fields + virtual void SetRefresh(int); + + // Description: + // FOAM Skip/include the 0/ time directory + vtkSetMacro(SkipZeroTime, int); + vtkGetMacro(SkipZeroTime, int); + // Description: // GUI update control vtkSetMacro(UpdateGUI, int); @@ -93,13 +102,14 @@ public: vtkSetMacro(ExtrapolatePatches, int); vtkGetMacro(ExtrapolatePatches, int); + // Description: // FOAM read sets control - vtkSetMacro(IncludeSets, int); + virtual void SetIncludeSets(int); vtkGetMacro(IncludeSets, int); // Description: // FOAM read zones control - vtkSetMacro(IncludeZones, int); + virtual void SetIncludeZones(int); vtkGetMacro(IncludeZones, int); // Description: @@ -113,7 +123,7 @@ public: // Description: // Parts selection list control - vtkDataArraySelection* GetPartSelection(); + virtual vtkDataArraySelection* GetPartSelection(); int GetNumberOfPartArrays(); int GetPartArrayStatus(const char* name); void SetPartArrayStatus(const char* name, int status); @@ -121,7 +131,7 @@ public: // Description: // volField selection list control - vtkDataArraySelection* GetVolFieldSelection(); + virtual vtkDataArraySelection* GetVolFieldSelection(); int GetNumberOfVolFieldArrays(); int GetVolFieldArrayStatus(const char* name); void SetVolFieldArrayStatus(const char* name, int status); @@ -129,7 +139,7 @@ public: // Description: // pointField selection list control - vtkDataArraySelection* GetPointFieldSelection(); + virtual vtkDataArraySelection* GetPointFieldSelection(); int GetNumberOfPointFieldArrays(); int GetPointFieldArrayStatus(const char* name); void SetPointFieldArrayStatus(const char* name, int status); @@ -137,7 +147,7 @@ public: // Description: // lagrangianField selection list control - vtkDataArraySelection* GetLagrangianFieldSelection(); + virtual vtkDataArraySelection* GetLagrangianFieldSelection(); int GetNumberOfLagrangianFieldArrays(); int GetLagrangianFieldArrayStatus(const char* name); void SetLagrangianFieldArrayStatus(const char* name, int status); @@ -156,7 +166,6 @@ public: void SelectionModified(); - protected: //- Construct null @@ -185,9 +194,10 @@ protected: //- Fill in additional port information virtual int FillOutputPortInformation(int, vtkInformation*); - // The observer to modify this object when array selections are modified + //- The observer to modify this object when array selections are modified vtkCallbackCommand* SelectionObserver; + //- The file name for this case char* FileName; private: @@ -202,14 +212,16 @@ private: void updatePatchNamesView(const bool show); int TimeStepRange[2]; + int Refresh; int CacheMesh; + int SkipZeroTime; int ExtrapolatePatches; int IncludeSets; int IncludeZones; int ShowPatchNames; - //- Dummy variable/switch for invoke a reader update + //- Dummy variable/switch to invoke a reader update int UpdateGUI; vtkDataArraySelection* PartSelection; diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C index 8989a110cb8c67a2f5571779f00d3fd9a18622c4..41933d5ebfec7834e4596c962deb875dc80d1284 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C @@ -50,16 +50,16 @@ defineTypeNameAndDebug(Foam::vtkPV3Foam, 0); void Foam::vtkPV3Foam::resetCounters() { - // Reset mesh part ids and sizes - partInfoVolume_.reset(); - partInfoPatches_.reset(); - partInfoLagrangian_.reset(); - partInfoCellZones_.reset(); - partInfoFaceZones_.reset(); - partInfoPointZones_.reset(); - partInfoCellSets_.reset(); - partInfoFaceSets_.reset(); - partInfoPointSets_.reset(); + // Reset array range information (ids and sizes) + arrayRangeVolume_.reset(); + arrayRangePatches_.reset(); + arrayRangeLagrangian_.reset(); + arrayRangeCellZones_.reset(); + arrayRangeFaceZones_.reset(); + arrayRangePointZones_.reset(); + arrayRangeCellSets_.reset(); + arrayRangeFaceSets_.reset(); + arrayRangePointSets_.reset(); } @@ -92,21 +92,6 @@ void Foam::vtkPV3Foam::reduceMemory() int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[]) { - if (debug) - { - Info<< "<beg> Foam::vtkPV3Foam::setTime("; - for (int requestI = 0; requestI < nRequest; ++requestI) - { - if (requestI) - { - Info<< ", "; - } - - Info<< requestTimes[requestI]; - } - Info<< ") - previousIndex = " << timeIndex_ << endl; - } - Time& runTime = dbPtr_(); // Get times list @@ -128,6 +113,22 @@ int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[]) nearestIndex = 0; } + if (debug) + { + Info<< "<beg> Foam::vtkPV3Foam::setTime("; + for (int requestI = 0; requestI < nRequest; ++requestI) + { + if (requestI) + { + Info<< ", "; + } + + Info<< requestTimes[requestI]; + } + Info<< ") - previousIndex = " << timeIndex_ + << ", nearestIndex = " << nearestIndex << endl; + } + // see what has changed if (timeIndex_ != nearestIndex) @@ -230,15 +231,15 @@ Foam::vtkPV3Foam::vtkPV3Foam timeIndex_(-1), meshChanged_(true), fieldsChanged_(true), - partInfoVolume_("unzoned"), - partInfoPatches_("patches"), - partInfoLagrangian_("lagrangian"), - partInfoCellZones_("cellZone"), - partInfoFaceZones_("faceZone"), - partInfoPointZones_("pointZone"), - partInfoCellSets_("cellSet"), - partInfoFaceSets_("faceSet"), - partInfoPointSets_("pointSet") + arrayRangeVolume_("unzoned"), + arrayRangePatches_("patches"), + arrayRangeLagrangian_("lagrangian"), + arrayRangeCellZones_("cellZone"), + arrayRangeFaceZones_("faceZone"), + arrayRangePointZones_("pointZone"), + arrayRangeCellSets_("cellSet"), + arrayRangeFaceSets_("faceSet"), + arrayRangePointSets_("pointSet") { if (debug) { @@ -288,7 +289,7 @@ Foam::vtkPV3Foam::vtkPV3Foam meshRegion_ = caseName.substr(beg+1, end-beg-1); // some safety - if (!meshRegion_.size()) + if (meshRegion_.empty()) { meshRegion_ = polyMesh::defaultRegion; } @@ -352,6 +353,14 @@ void Foam::vtkPV3Foam::updateInfo() vtkDataArraySelection* partSelection = reader_->GetPartSelection(); + // there are two ways to ensure we have the correct list of parts: + // 1. remove everything and then set particular entries 'on' + // 2. build a 'char **' list and call SetArraysWithDefault() + // + // Nr. 2 has the potential advantage of not touching the modification + // time of the vtkDataArraySelection, but the qt/paraview proxy + // layer doesn't care about that anyhow. + // enable 'internalMesh' on the first call // or preserve the enabled selections stringList enabledEntries; @@ -369,11 +378,11 @@ void Foam::vtkPV3Foam::updateInfo() partSelection->RemoveAllArrays(); // Update mesh parts list - add Lagrangian at the bottom - updateInfoInternalMesh(); - updateInfoPatches(); - updateInfoSets(); - updateInfoZones(); - updateInfoLagrangian(); + updateInfoInternalMesh(partSelection); + updateInfoPatches(partSelection); + updateInfoSets(partSelection); + updateInfoZones(partSelection); + updateInfoLagrangian(partSelection); // restore the enabled selections setSelectedArrayEntries(partSelection, enabledEntries); @@ -396,6 +405,8 @@ void Foam::vtkPV3Foam::updateInfo() if (debug) { + // just for debug info + getSelectedArrayEntries(partSelection); Info<< "<end> Foam::vtkPV3Foam::updateInfo" << endl; } @@ -559,11 +570,25 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps) nTimes = timeLst.size() - timeI; - // always skip "constant" time if possible + // skip "constant" time whenever possible if (timeI == 0 && nTimes > 1) { - timeI = 1; - --nTimes; + if (timeLst[timeI].name() == "constant") + { + ++timeI; + --nTimes; + } + } + + + // skip "0/" time if requested and possible + if (nTimes > 1 && reader_->GetSkipZeroTime()) + { + if (mag(timeLst[timeI].value()) < SMALL) + { + ++timeI; + --nTimes; + } } if (nTimes) @@ -607,10 +632,10 @@ void Foam::vtkPV3Foam::renderPatchNames(vtkRenderer* renderer, const bool show) wordHashSet selectedPatches = getSelected ( reader_->GetPartSelection(), - partInfoPatches_ + arrayRangePatches_ ); - if (!selectedPatches.size()) + if (selectedPatches.empty()) { return; } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 05c84744775953e3672c2805f215b7f2d7b966b3..6037e78781f193928365cfcae265603383f2d776 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -111,7 +111,7 @@ class vtkPV3Foam // Private classes //- Bookkeeping for GUI checklists and the multi-block organization - class partInfo + class arrayRange { const char *name_; int block_; @@ -120,11 +120,11 @@ class vtkPV3Foam public: - partInfo(const char *name, const int blockNo=0) + arrayRange(const char *name, const int blockNo=0) : name_(name), block_(blockNo), - start_(-1), + start_(0), size_(0) {} @@ -142,21 +142,25 @@ class vtkPV3Foam return prev; } + //- Return block name const char* name() const { return name_; } + //- Return array start index int start() const { return start_; } + //- Return array end index int end() const { return start_ + size_; } + //- Return sublist size int size() const { return size_; @@ -167,16 +171,10 @@ class vtkPV3Foam return !size_; } - void reset() + //- Reset the size to zero and optionally assign a new start + void reset(const int startAt = 0) { - start_ = -1; - size_ = 0; - } - - //- Assign new start and reset the size - void operator=(const int i) - { - start_ = i; + start_ = startAt; size_ = 0; } @@ -282,15 +280,15 @@ class vtkPV3Foam //- First instance and size of various mesh parts // used to index into partStatus_ and partDataset_ - partInfo partInfoVolume_; - partInfo partInfoPatches_; - partInfo partInfoLagrangian_; - partInfo partInfoCellZones_; - partInfo partInfoFaceZones_; - partInfo partInfoPointZones_; - partInfo partInfoCellSets_; - partInfo partInfoFaceSets_; - partInfo partInfoPointSets_; + arrayRange arrayRangeVolume_; + arrayRange arrayRangePatches_; + arrayRange arrayRangeLagrangian_; + arrayRange arrayRangeCellZones_; + arrayRange arrayRangeFaceZones_; + arrayRange arrayRangePointZones_; + arrayRange arrayRangeCellSets_; + arrayRange arrayRangeFaceSets_; + arrayRange arrayRangePointSets_; //- Decomposed cells information (mesh regions) // TODO: regions @@ -313,7 +311,7 @@ class vtkPV3Foam ( vtkMultiBlockDataSet* output, vtkDataSet* dataset, - const partInfo&, + const arrayRange&, const label datasetNo, const std::string& datasetName ); @@ -323,7 +321,7 @@ class vtkPV3Foam static vtkDataSet* GetDataSetFromBlock ( vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo ); @@ -332,7 +330,7 @@ class vtkPV3Foam static label GetNumberOfDataSets ( vtkMultiBlockDataSet* output, - const partInfo& + const arrayRange& ); //- Reset data counters @@ -344,19 +342,19 @@ class vtkPV3Foam void updateMeshPartsStatus(); //- Internal mesh info - void updateInfoInternalMesh(); + void updateInfoInternalMesh(vtkDataArraySelection*); //- Lagrangian info - void updateInfoLagrangian(); + void updateInfoLagrangian(vtkDataArraySelection*); //- Patch info - void updateInfoPatches(); + void updateInfoPatches(vtkDataArraySelection*); //- Set info - void updateInfoSets(); + void updateInfoSets(vtkDataArraySelection*); //- Zone info - void updateInfoZones(); + void updateInfoZones(vtkDataArraySelection*); //- Read zone names for zoneType from file wordList readZoneNames(const word& zoneType); @@ -511,7 +509,7 @@ class vtkPV3Foam const GeometricField<Type, fvPatchField, volMesh>&, autoPtr<GeometricField<Type, pointPatchField, pointMesh> >&, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange&, const List<polyDecomp>& decompLst ); @@ -521,7 +519,7 @@ class vtkPV3Foam ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo, const polyDecomp& ); @@ -533,7 +531,7 @@ class vtkPV3Foam const word& name, const Field<Type>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo ); @@ -543,7 +541,7 @@ class vtkPV3Foam ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo, const fvMesh&, const labelList& faceLabels @@ -555,7 +553,7 @@ class vtkPV3Foam ( const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo, const fvMesh&, const faceSet& @@ -576,7 +574,7 @@ class vtkPV3Foam ( const IOField<Type>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo ); @@ -596,7 +594,7 @@ class vtkPV3Foam ( const GeometricField<Type, pointPatchField, pointMesh>&, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange&, const List<polyDecomp>& ); @@ -607,7 +605,7 @@ class vtkPV3Foam const GeometricField<Type, pointPatchField, pointMesh>&, const GeometricField<Type, fvPatchField, volMesh>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo, const polyDecomp& ); @@ -619,7 +617,7 @@ class vtkPV3Foam const word& name, const Field<Type>&, vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo ); @@ -640,7 +638,7 @@ class vtkPV3Foam static wordHashSet getSelected ( vtkDataArraySelection*, - const partInfo& + const arrayRange& ); //- Retrieve the current selections @@ -650,7 +648,7 @@ class vtkPV3Foam static stringList getSelectedArrayEntries ( vtkDataArraySelection*, - const partInfo& + const arrayRange& ); //- Set selection(s) @@ -661,7 +659,7 @@ class vtkPV3Foam ); //- Get the first word from the mesh parts selection - word getPartName(int); + word getPartName(const int); //- Disallow default bitwise copy construct diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H index d6b1f1ed5233ed8bad59aabbcbb08232b33a684e..b945d6c6a063a476e4f346a444dfbf34b6fb6c8d 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H @@ -50,11 +50,17 @@ Foam::label Foam::vtkPV3Foam::addToSelection { if (suffix.size()) { - select->AddArray((names[nameI] + suffix).c_str()); + select->AddArray + ( + (names[nameI] + suffix).c_str() + ); } else { - select->AddArray(names[nameI].c_str()); + select->AddArray + ( + (names[nameI]).c_str() + ); } } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H index 14c0d5f9b9e82149cac48473ce6ffcfedca3fea5..68f551ae5a3979f16e7ddca13ce408a3e0950907 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H @@ -43,7 +43,7 @@ void Foam::vtkPV3Foam::convertFaceField ( const GeometricField<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const fvMesh& mesh, const labelList& faceLabels @@ -100,7 +100,7 @@ void Foam::vtkPV3Foam::convertFaceField vtkPolyData::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetCellData() ->AddArray(cellData); @@ -113,7 +113,7 @@ void Foam::vtkPV3Foam::convertFaceField ( const GeometricField<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const fvMesh& mesh, const faceSet& fSet @@ -173,7 +173,7 @@ void Foam::vtkPV3Foam::convertFaceField vtkPolyData::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetCellData() ->AddArray(cellData); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C index 38cc52f68047303136cd08d02e15c3ded723bcc7..b712fdebfe40b6dedb3006b053c1645b097d7cd7 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C @@ -51,7 +51,7 @@ void Foam::vtkPV3Foam::pruneObjectList ) { // hash all the selected field names - if (!selected.size()) + if (selected.empty()) { objects.clear(); } @@ -79,7 +79,7 @@ void Foam::vtkPV3Foam::convertVolFields reader_->GetVolFieldSelection() ); - if (!selectedFields.size()) + if (selectedFields.empty()) { return; } @@ -89,7 +89,7 @@ void Foam::vtkPV3Foam::convertVolFields IOobjectList objects(mesh, dbPtr_().timeName()); pruneObjectList(objects, selectedFields); - if (!objects.size()) + if (objects.empty()) { return; } @@ -164,7 +164,7 @@ void Foam::vtkPV3Foam::convertPointFields reader_->GetPointFieldSelection() ); - if (!selectedFields.size()) + if (selectedFields.empty()) { return; } @@ -174,7 +174,7 @@ void Foam::vtkPV3Foam::convertPointFields IOobjectList objects(mesh, dbPtr_().timeName()); pruneObjectList(objects, selectedFields); - if (!objects.size()) + if (objects.empty()) { return; } @@ -229,7 +229,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields vtkMultiBlockDataSet* output ) { - partInfo& selector = partInfoLagrangian_; + arrayRange& range = arrayRangeLagrangian_; const fvMesh& mesh = *meshPtr_; wordHashSet selectedFields = getSelected @@ -237,7 +237,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields reader_->GetLagrangianFieldSelection() ); - if (!selectedFields.size()) + if (selectedFields.empty()) { return; } @@ -248,7 +248,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word cloudName = getPartName(partId); const label datasetNo = partDataset_[partId]; @@ -270,7 +270,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields ); pruneObjectList(objects, selectedFields); - if (!objects.size()) + if (objects.empty()) { continue; } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H index 58422d69f49eb4a78b1db291d32df7a7596f6783..1b6e2a15681070cd4599aeb587f72209c46b8bfa 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H @@ -42,7 +42,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields const label datasetNo ) { - const partInfo& selector = partInfoLagrangian_; + const arrayRange& range = arrayRangeLagrangian_; forAllConstIter(IOobjectList, objects, iter) { @@ -50,7 +50,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields if (iter()->headerClassName() == IOField<Type>::typeName) { IOField<Type> tf(*iter()); - convertLagrangianField(tf, output, selector, datasetNo); + convertLagrangianField(tf, output, range, datasetNo); } } } @@ -61,7 +61,7 @@ void Foam::vtkPV3Foam::convertLagrangianField ( const IOField<Type>& tf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo ) { @@ -97,7 +97,7 @@ void Foam::vtkPV3Foam::convertLagrangianField vtkPolyData::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetPointData() ->AddArray(pointData); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C index 6550a960e14aac0b594aa80215e33f4deb536bd1..516b29d3ef4ddea2b23a473a27b7ad999442dbcb 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C @@ -49,13 +49,13 @@ void Foam::vtkPV3Foam::convertMeshVolume int& blockNo ) { - partInfo& selector = partInfoVolume_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeVolume_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; // resize for decomposed polyhedra - regionPolyDecomp_.setSize(selector.size()); + regionPolyDecomp_.setSize(range.size()); if (debug) { @@ -65,7 +65,7 @@ void Foam::vtkPV3Foam::convertMeshVolume // Convert the internalMesh // this looks like more than one part, but it isn't - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word partName = "internalMesh"; @@ -82,7 +82,7 @@ void Foam::vtkPV3Foam::convertMeshVolume if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, partName); + AddToBlock(output, vtkmesh, range, datasetNo, partName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -109,8 +109,8 @@ void Foam::vtkPV3Foam::convertMeshLagrangian int& blockNo ) { - partInfo& selector = partInfoLagrangian_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeLagrangian_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; @@ -120,7 +120,7 @@ void Foam::vtkPV3Foam::convertMeshLagrangian printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word cloudName = getPartName(partId); @@ -133,7 +133,7 @@ void Foam::vtkPV3Foam::convertMeshLagrangian if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, cloudName); + AddToBlock(output, vtkmesh, range, datasetNo, cloudName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -160,8 +160,8 @@ void Foam::vtkPV3Foam::convertMeshPatches int& blockNo ) { - partInfo& selector = partInfoPatches_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangePatches_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -172,7 +172,7 @@ void Foam::vtkPV3Foam::convertMeshPatches printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word patchName = getPartName(partId); const label patchId = patches.findPatchID(patchName); @@ -192,7 +192,7 @@ void Foam::vtkPV3Foam::convertMeshPatches if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, patchName); + AddToBlock(output, vtkmesh, range, datasetNo, patchName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -219,15 +219,15 @@ void Foam::vtkPV3Foam::convertMeshCellZones int& blockNo ) { - partInfo& selector = partInfoCellZones_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeCellZones_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; // resize for decomposed polyhedra - zonePolyDecomp_.setSize(selector.size()); + zonePolyDecomp_.setSize(range.size()); - if (!selector.size()) + if (range.empty()) { return; } @@ -239,7 +239,7 @@ void Foam::vtkPV3Foam::convertMeshCellZones } const cellZoneMesh& zMesh = mesh.cellZones(); - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word zoneName = getPartName(partId); const label zoneId = zMesh.findZoneID(zoneName); @@ -281,7 +281,7 @@ void Foam::vtkPV3Foam::convertMeshCellZones // copy pointMap as well, otherwise pointFields fail zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); - AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + AddToBlock(output, vtkmesh, range, datasetNo, zoneName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -308,13 +308,13 @@ void Foam::vtkPV3Foam::convertMeshCellSets int& blockNo ) { - partInfo& selector = partInfoCellSets_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeCellSets_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; // resize for decomposed polyhedra - csetPolyDecomp_.setSize(selector.size()); + csetPolyDecomp_.setSize(range.size()); if (debug) { @@ -322,7 +322,7 @@ void Foam::vtkPV3Foam::convertMeshCellSets printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word partName = getPartName(partId); @@ -363,7 +363,7 @@ void Foam::vtkPV3Foam::convertMeshCellSets // copy pointMap as well, otherwise pointFields fail csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap(); - AddToBlock(output, vtkmesh, selector, datasetNo, partName); + AddToBlock(output, vtkmesh, range, datasetNo, partName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -390,12 +390,12 @@ void Foam::vtkPV3Foam::convertMeshFaceZones int& blockNo ) { - partInfo& selector = partInfoFaceZones_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeFaceZones_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; - if (!selector.size()) + if (range.empty()) { return; } @@ -407,7 +407,7 @@ void Foam::vtkPV3Foam::convertMeshFaceZones } const faceZoneMesh& zMesh = mesh.faceZones(); - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word zoneName = getPartName(partId); const label zoneId = zMesh.findZoneID(zoneName); @@ -426,7 +426,7 @@ void Foam::vtkPV3Foam::convertMeshFaceZones vtkPolyData* vtkmesh = faceZoneVTKMesh(mesh, zMesh[zoneId]); if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + AddToBlock(output, vtkmesh, range, datasetNo, zoneName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -453,8 +453,8 @@ void Foam::vtkPV3Foam::convertMeshFaceSets int& blockNo ) { - partInfo& selector = partInfoFaceSets_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeFaceSets_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; @@ -464,7 +464,7 @@ void Foam::vtkPV3Foam::convertMeshFaceSets printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const word partName = getPartName(partId); @@ -483,7 +483,7 @@ void Foam::vtkPV3Foam::convertMeshFaceSets vtkPolyData* vtkmesh = faceSetVTKMesh(mesh, fSet); if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, partName); + AddToBlock(output, vtkmesh, range, datasetNo, partName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -510,8 +510,8 @@ void Foam::vtkPV3Foam::convertMeshPointZones int& blockNo ) { - partInfo& selector = partInfoPointZones_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangePointZones_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; @@ -521,10 +521,10 @@ void Foam::vtkPV3Foam::convertMeshPointZones printMemory(); } - if (selector.size()) + if (range.size()) { const pointZoneMesh& zMesh = mesh.pointZones(); - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { word zoneName = getPartName(partId); label zoneId = zMesh.findZoneID(zoneName); @@ -537,7 +537,7 @@ void Foam::vtkPV3Foam::convertMeshPointZones vtkPolyData* vtkmesh = pointZoneVTKMesh(mesh, zMesh[zoneId]); if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, zoneName); + AddToBlock(output, vtkmesh, range, datasetNo, zoneName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -566,8 +566,8 @@ void Foam::vtkPV3Foam::convertMeshPointSets int& blockNo ) { - partInfo& selector = partInfoPointSets_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangePointSets_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const fvMesh& mesh = *meshPtr_; @@ -577,7 +577,7 @@ void Foam::vtkPV3Foam::convertMeshPointSets printMemory(); } - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { word partName = getPartName(partId); @@ -596,7 +596,7 @@ void Foam::vtkPV3Foam::convertMeshPointSets vtkPolyData* vtkmesh = pointSetVTKMesh(mesh, pSet); if (vtkmesh) { - AddToBlock(output, vtkmesh, selector, datasetNo, partName); + AddToBlock(output, vtkmesh, range, datasetNo, partName); vtkmesh->Delete(); partDataset_[partId] = datasetNo++; @@ -616,4 +616,5 @@ void Foam::vtkPV3Foam::convertMeshPointSets } } + // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H index bfa2d1ac46600c4607caf4b8824d1f58eb9c7ba6..7e473a7c74950b842831cc054784262970a2390c 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H @@ -45,7 +45,7 @@ void Foam::vtkPV3Foam::convertPatchField const word& name, const Field<Type>& ptf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo ) { @@ -70,7 +70,7 @@ void Foam::vtkPV3Foam::convertPatchField vtkPolyData::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetCellData() ->AddArray(cellData); @@ -85,7 +85,7 @@ void Foam::vtkPV3Foam::convertPatchPointField const word& name, const Field<Type>& pptf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo ) { @@ -111,7 +111,7 @@ void Foam::vtkPV3Foam::convertPatchPointField vtkPolyData::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetPointData() ->AddArray(pointData); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H index 5e3ae1df423aab466fe3ff89796fcd519a3c8bd4..697044bc6b9b96f881fc610327ed0c18bee4130c 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H @@ -77,7 +77,7 @@ void Foam::vtkPV3Foam::convertPointFields ( ptf, output, - partInfoVolume_, + arrayRangeVolume_, regionPolyDecomp_ ); @@ -86,7 +86,7 @@ void Foam::vtkPV3Foam::convertPointFields ( ptf, output, - partInfoCellZones_, + arrayRangeCellZones_, zonePolyDecomp_ ); @@ -95,7 +95,7 @@ void Foam::vtkPV3Foam::convertPointFields ( ptf, output, - partInfoCellSets_, + arrayRangeCellSets_, csetPolyDecomp_ ); @@ -105,8 +105,8 @@ void Foam::vtkPV3Foam::convertPointFields // for ( - int partId = partInfoPatches_.start(); - partId < partInfoPatches_.end(); + int partId = arrayRangePatches_.start(); + partId < arrayRangePatches_.end(); ++partId ) { @@ -124,7 +124,7 @@ void Foam::vtkPV3Foam::convertPointFields fieldName, ptf.boundaryField()[patchId].patchInternalField()(), output, - partInfoPatches_, + arrayRangePatches_, datasetNo ); } @@ -137,11 +137,11 @@ void Foam::vtkPV3Foam::convertPointFieldBlock ( const GeometricField<Type, pointPatchField, pointMesh>& ptf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const List<polyDecomp>& decompLst ) { - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const label datasetNo = partDataset_[partId]; @@ -152,7 +152,7 @@ void Foam::vtkPV3Foam::convertPointFieldBlock ptf, GeometricField<Type, fvPatchField, volMesh>::null(), output, - selector, + range, datasetNo, decompLst[datasetNo] ); @@ -167,7 +167,7 @@ void Foam::vtkPV3Foam::convertPointField const GeometricField<Type, pointPatchField, pointMesh>& ptf, const GeometricField<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const polyDecomp& decomp ) @@ -260,7 +260,7 @@ void Foam::vtkPV3Foam::convertPointField vtkUnstructuredGrid::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetPointData() ->AddArray(pointData); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index 5bb2143c2a26572fac73aae5e4dbaac191f5ea40..2bed6fabd4040dea85128c9d5ab928518b483fe4 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -118,32 +118,39 @@ Foam::wordList Foam::vtkPV3Foam::readZoneNames(const word& zoneType) } -void Foam::vtkPV3Foam::updateInfoInternalMesh() +void Foam::vtkPV3Foam::updateInfoInternalMesh +( + vtkDataArraySelection* arraySelection +) { if (debug) { Info<< "<beg> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl; } - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); - // Determine mesh parts (internalMesh, patches...) //- Add internal mesh as first entry - partInfoVolume_ = partSelection->GetNumberOfArrays(); - partSelection->AddArray("internalMesh"); - partInfoVolume_ += 1; + arrayRangeVolume_.reset( arraySelection->GetNumberOfArrays() ); + arraySelection->AddArray + ( + "internalMesh" + ); + arrayRangeVolume_ += 1; if (debug) { // just for debug info - getSelectedArrayEntries(partSelection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3Foam::updateInfoInternalMesh" << endl; } } -void Foam::vtkPV3Foam::updateInfoLagrangian() +void Foam::vtkPV3Foam::updateInfoLagrangian +( + vtkDataArraySelection* arraySelection +) { if (debug) { @@ -166,34 +173,35 @@ void Foam::vtkPV3Foam::updateInfoLagrangian() readDir(dbPtr_->timePath()/lagrangianPrefix, fileName::DIRECTORY) ); - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); - partInfoLagrangian_ = partSelection->GetNumberOfArrays(); + arrayRangeLagrangian_.reset( arraySelection->GetNumberOfArrays() ); int nClouds = 0; forAll(cloudDirs, cloudI) { // Add cloud to GUI list - partSelection->AddArray + arraySelection->AddArray ( (cloudDirs[cloudI] + " - lagrangian").c_str() ); ++nClouds; } - - partInfoLagrangian_ += nClouds; + arrayRangeLagrangian_ += nClouds; if (debug) { // just for debug info - getSelectedArrayEntries(partSelection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3Foam::updateInfoLagrangian" << endl; } } -void Foam::vtkPV3Foam::updateInfoPatches() +void Foam::vtkPV3Foam::updateInfoPatches +( + vtkDataArraySelection* arraySelection +) { if (debug) { @@ -201,8 +209,7 @@ void Foam::vtkPV3Foam::updateInfoPatches() << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); - partInfoPatches_ = partSelection->GetNumberOfArrays(); + arrayRangePatches_.reset( arraySelection->GetNumberOfArrays() ); int nPatches = 0; if (meshPtr_) @@ -215,7 +222,7 @@ void Foam::vtkPV3Foam::updateInfoPatches() if (pp.size()) { // Add patch to GUI list - partSelection->AddArray + arraySelection->AddArray ( (pp.name() + " - patch").c_str() ); @@ -260,7 +267,7 @@ void Foam::vtkPV3Foam::updateInfoPatches() // Valid patch if nFace > 0 - add patch to GUI list if (nFaces) { - partSelection->AddArray + arraySelection->AddArray ( (patchEntries[entryI].keyword() + " - patch").c_str() ); @@ -270,19 +277,22 @@ void Foam::vtkPV3Foam::updateInfoPatches() } } } - partInfoPatches_ += nPatches; + arrayRangePatches_ += nPatches; if (debug) { // just for debug info - getSelectedArrayEntries(partSelection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3Foam::updateInfoPatches" << endl; } } -void Foam::vtkPV3Foam::updateInfoZones() +void Foam::vtkPV3Foam::updateInfoZones +( + vtkDataArraySelection* arraySelection +) { if (!reader_->GetIncludeZones()) { @@ -295,7 +305,6 @@ void Foam::vtkPV3Foam::updateInfoZones() << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); wordList namesLst; // @@ -310,12 +319,15 @@ void Foam::vtkPV3Foam::updateInfoZones() namesLst = readZoneNames("cellZones"); } - partInfoCellZones_ = partSelection->GetNumberOfArrays(); + arrayRangeCellZones_.reset( arraySelection->GetNumberOfArrays() ); forAll(namesLst, elemI) { - partSelection->AddArray((namesLst[elemI] + " - cellZone").c_str()); + arraySelection->AddArray + ( + (namesLst[elemI] + " - cellZone").c_str() + ); } - partInfoCellZones_ += namesLst.size(); + arrayRangeCellZones_ += namesLst.size(); // @@ -330,15 +342,15 @@ void Foam::vtkPV3Foam::updateInfoZones() namesLst = readZoneNames("faceZones"); } - partInfoFaceZones_ = partSelection->GetNumberOfArrays(); + arrayRangeFaceZones_.reset( arraySelection->GetNumberOfArrays() ); forAll(namesLst, elemI) { - partSelection->AddArray + arraySelection->AddArray ( (namesLst[elemI] + " - faceZone").c_str() ); } - partInfoFaceZones_ += namesLst.size(); + arrayRangeFaceZones_ += namesLst.size(); // @@ -353,28 +365,30 @@ void Foam::vtkPV3Foam::updateInfoZones() namesLst = readZoneNames("pointZones"); } - partInfoPointZones_ = partSelection->GetNumberOfArrays(); + arrayRangePointZones_.reset( arraySelection->GetNumberOfArrays() ); forAll(namesLst, elemI) { - partSelection->AddArray + arraySelection->AddArray ( (namesLst[elemI] + " - pointZone").c_str() ); } - partInfoPointZones_ += namesLst.size(); - + arrayRangePointZones_ += namesLst.size(); if (debug) { // just for debug info - getSelectedArrayEntries(partSelection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3Foam::updateInfoZones" << endl; } } -void Foam::vtkPV3Foam::updateInfoSets() +void Foam::vtkPV3Foam::updateInfoSets +( + vtkDataArraySelection* arraySelection +) { if (!reader_->GetIncludeSets()) { @@ -386,8 +400,6 @@ void Foam::vtkPV3Foam::updateInfoSets() Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl; } - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); - // Add names of sets IOobjectList objects ( @@ -397,26 +409,26 @@ void Foam::vtkPV3Foam::updateInfoSets() ); - partInfoCellSets_ = partSelection->GetNumberOfArrays(); - partInfoCellSets_ += addToSelection<cellSet> + arrayRangeCellSets_.reset( arraySelection->GetNumberOfArrays() ); + arrayRangeCellSets_ += addToSelection<cellSet> ( - partSelection, + arraySelection, objects, " - cellSet" ); - partInfoFaceSets_ = partSelection->GetNumberOfArrays(); - partInfoFaceSets_ += addToSelection<faceSet> + arrayRangeFaceSets_.reset( arraySelection->GetNumberOfArrays() ); + arrayRangeFaceSets_ += addToSelection<faceSet> ( - partSelection, + arraySelection, objects, " - faceSet" ); - partInfoPointSets_ = partSelection->GetNumberOfArrays(); - partInfoPointSets_ += addToSelection<pointSet> + arrayRangePointSets_.reset( arraySelection->GetNumberOfArrays() ); + arrayRangePointSets_ += addToSelection<pointSet> ( - partSelection, + arraySelection, objects, " - pointSet" ); @@ -424,7 +436,7 @@ void Foam::vtkPV3Foam::updateInfoSets() if (debug) { // just for debug info - getSelectedArrayEntries(partSelection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3Foam::updateInfoSets" << endl; } @@ -450,14 +462,13 @@ void Foam::vtkPV3Foam::updateInfoLagrangianFields() // have to decide if the second set of fields get mixed in // or dealt with separately - const partInfo& selector = partInfoLagrangian_; - int partId = selector.start(); - - if (!selector.size() || partId < 0) + const arrayRange& range = arrayRangeLagrangian_; + if (range.empty()) { return; } + int partId = range.start(); word cloudName = getPartName(partId); // use the db directly since this might be called without a mesh, diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C index f9112229445d3825e7426c265214026edfb81e1e..74a57fb5597a987c79e5323d2ed821ac291cc15d 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C @@ -76,12 +76,12 @@ void Foam::vtkPV3Foam::AddToBlock ( vtkMultiBlockDataSet* output, vtkDataSet* dataset, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const std::string& datasetName ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -117,7 +117,7 @@ void Foam::vtkPV3Foam::AddToBlock output->GetMetaData(blockNo)->Set ( vtkCompositeDataSet::NAME(), - selector.name() + range.name() ); } @@ -135,11 +135,11 @@ void Foam::vtkPV3Foam::AddToBlock vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock ( vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -157,10 +157,10 @@ vtkDataSet* Foam::vtkPV3Foam::GetDataSetFromBlock Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets ( vtkMultiBlockDataSet* output, - const partInfo& selector + const arrayRange& range ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -173,7 +173,7 @@ Foam::label Foam::vtkPV3Foam::GetNumberOfDataSets } -Foam::word Foam::vtkPV3Foam::getPartName(int partId) +Foam::word Foam::vtkPV3Foam::getPartName(const int partId) { return getFirstWord(reader_->GetPartArrayName(partId)); } @@ -202,13 +202,13 @@ Foam::wordHashSet Foam::vtkPV3Foam::getSelected Foam::wordHashSet Foam::vtkPV3Foam::getSelected ( vtkDataArraySelection* select, - const partInfo& selector + const arrayRange& range ) { int nElem = select->GetNumberOfArrays(); wordHashSet selections(2*nElem); - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { if (select->GetArraySetting(elemI)) { @@ -262,13 +262,13 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ( vtkDataArraySelection* select, - const partInfo& selector + const arrayRange& range ) { - stringList selections(selector.size()); + stringList selections(range.size()); label nElem = 0; - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { if (select->GetArraySetting(elemI)) { @@ -281,7 +281,7 @@ Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries if (debug) { Info<< "available("; - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { Info<< " \"" << select->GetArrayName(elemI) << "\""; } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H index d5387be61f3e703d191d96c8640deccb7a4131b9..e28e3940a8c08e600ba664bdfa64d99d5a0bdd76 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H @@ -81,7 +81,7 @@ void Foam::vtkPV3Foam::convertVolFields tf, ptfPtr, output, - partInfoVolume_, + arrayRangeVolume_, regionPolyDecomp_ ); @@ -91,7 +91,7 @@ void Foam::vtkPV3Foam::convertVolFields tf, ptfPtr, output, - partInfoCellZones_, + arrayRangeCellZones_, zonePolyDecomp_ ); @@ -101,7 +101,7 @@ void Foam::vtkPV3Foam::convertVolFields tf, ptfPtr, output, - partInfoCellSets_, + arrayRangeCellSets_, csetPolyDecomp_ ); @@ -117,8 +117,8 @@ void Foam::vtkPV3Foam::convertVolFields for ( - int partId = partInfoPatches_.start(); - partId < partInfoPatches_.end(); + int partId = arrayRangePatches_.start(); + partId < arrayRangePatches_.end(); ++partId ) { @@ -155,7 +155,7 @@ void Foam::vtkPV3Foam::convertVolFields tf.name(), tpptf(), output, - partInfoPatches_, + arrayRangePatches_, datasetNo ); @@ -164,7 +164,7 @@ void Foam::vtkPV3Foam::convertVolFields pointFldName, ppInterpList[patchId].faceToPointInterpolate(tpptf)(), output, - partInfoPatches_, + arrayRangePatches_, datasetNo ); } @@ -175,7 +175,7 @@ void Foam::vtkPV3Foam::convertVolFields tf.name(), ptf, output, - partInfoPatches_, + arrayRangePatches_, datasetNo ); @@ -184,7 +184,7 @@ void Foam::vtkPV3Foam::convertVolFields pointFldName, ppInterpList[patchId].faceToPointInterpolate(ptf)(), output, - partInfoPatches_, + arrayRangePatches_, datasetNo ); } @@ -195,8 +195,8 @@ void Foam::vtkPV3Foam::convertVolFields // for ( - int partId = partInfoFaceZones_.start(); - partId < partInfoFaceZones_.end(); + int partId = arrayRangeFaceZones_.start(); + partId < arrayRangeFaceZones_.end(); ++partId ) { @@ -220,7 +220,7 @@ void Foam::vtkPV3Foam::convertVolFields ( tf, output, - partInfoFaceZones_, + arrayRangeFaceZones_, datasetNo, mesh, zMesh[zoneId] @@ -234,8 +234,8 @@ void Foam::vtkPV3Foam::convertVolFields // for ( - int partId = partInfoFaceSets_.start(); - partId < partInfoFaceSets_.end(); + int partId = arrayRangeFaceSets_.start(); + partId < arrayRangeFaceSets_.end(); ++partId ) { @@ -253,7 +253,7 @@ void Foam::vtkPV3Foam::convertVolFields ( tf, output, - partInfoFaceSets_, + arrayRangeFaceSets_, datasetNo, mesh, fSet @@ -271,11 +271,11 @@ void Foam::vtkPV3Foam::convertVolFieldBlock const GeometricField<Type, fvPatchField, volMesh>& tf, autoPtr<GeometricField<Type, pointPatchField, pointMesh> >& ptfPtr, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const List<polyDecomp>& decompLst ) { - for (int partId = selector.start(); partId < selector.end(); ++partId) + for (int partId = range.start(); partId < range.end(); ++partId) { const label datasetNo = partDataset_[partId]; @@ -285,7 +285,7 @@ void Foam::vtkPV3Foam::convertVolFieldBlock ( tf, output, - selector, + range, datasetNo, decompLst[datasetNo] ); @@ -309,7 +309,7 @@ void Foam::vtkPV3Foam::convertVolFieldBlock ptfPtr(), tf, output, - selector, + range, datasetNo, decompLst[datasetNo] ); @@ -323,7 +323,7 @@ void Foam::vtkPV3Foam::convertVolField ( const GeometricField<Type, fvPatchField, volMesh>& tf, vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const polyDecomp& decompInfo ) @@ -359,7 +359,7 @@ void Foam::vtkPV3Foam::convertVolField vtkUnstructuredGrid::SafeDownCast ( - GetDataSetFromBlock(output, selector, datasetNo) + GetDataSetFromBlock(output, range, datasetNo) ) ->GetCellData() ->AddArray(celldata); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml index 2ac4774ff0de47f3e5dff9ec5a4cb01c8fb14434..b5bb304a652ff1eabd93d15c25a6e6e48ab270f1 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml @@ -43,34 +43,40 @@ </Documentation> </IntVectorProperty> - <!-- Selections --> - <!-- Available Parts (blocks) array --> + <!-- + | Selections + --> + + <!-- Available Blocks array --> <StringVectorProperty - name="PartArrayInfo" + name="BlockArrayStatus" information_only="1"> - <ArraySelectionInformationHelper attribute_name="Part"/> + <ArraySelectionInformationHelper attribute_name="Block"/> </StringVectorProperty> <StringVectorProperty - name="PartStatus" + name="BlockStatus" label="Blocks" - command="SetPartArrayStatus" + command="SetBlockArrayStatus" number_of_elements="0" repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="PartArrayInfo" + information_property="BlockArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="PartArrayInfo" function="ArrayList"/> + <Property name="BlockArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the blocks + </Documentation> </StringVectorProperty> - <!-- Available Parts (blocks) array --> + <!-- Available CurvedEdges array --> <StringVectorProperty - name="CurvedEdgesArrayInfo" + name="CurvedEdgesArrayStatus" information_only="1"> <ArraySelectionInformationHelper attribute_name="CurvedEdges"/> </StringVectorProperty> @@ -82,13 +88,16 @@ repeat_command="1" number_of_elements_per_command="2" element_types="2 0" - information_property="CurvedEdgesArrayInfo" + information_property="CurvedEdgesArrayStatus" animateable="0"> <ArraySelectionDomain name="array_list"> <RequiredProperties> - <Property name="CurvedEdgesArrayInfo" function="ArrayList"/> + <Property name="CurvedEdgesArrayStatus" function="ArrayList"/> </RequiredProperties> </ArraySelectionDomain> + <Documentation> + This property contains a list of the curved edges + </Documentation> </StringVectorProperty> <Hints> diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx index 8114a1470907a46c4976aad1812e7ccc997a4613..6a56583134674e8a02e33401494e43a0f28469b1 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx @@ -32,9 +32,10 @@ License #include <QLabel> #include <QLayout> #include <QString> +#include <QPushButton> #include <QtDebug> -// Paraview<->QT UI +// Paraview <-> QT UI #include "pqAnimationScene.h" #include "pqApplicationCore.h" #include "pqPipelineRepresentation.h" @@ -56,34 +57,35 @@ pqPV3blockMeshReaderPanel::pqPV3blockMeshReaderPanel QWidget *p ) : - pqAutoGeneratedObjectPanel(proxy, p), - sourceProxy_(vtkSMSourceProxy::SafeDownCast(this->proxy())) + pqAutoGeneratedObjectPanel(proxy, p) { // create first sublayout (at top of the panel) - QGridLayout *sect1 = new QGridLayout(); - this->PanelLayout->addLayout(sect1, 0, 0, 1, -1); - + QGridLayout *form = new QGridLayout(); + this->PanelLayout->addLayout(form, 0, 0, 1, -1); + vtkSMProperty* prop = 0; // checkbox for showing point numbers - ShowPointNumbers_ = new QCheckBox("Show Point Numbers"); - ShowPointNumbers_->setChecked(true); - - connect - ( - ShowPointNumbers_, - SIGNAL(stateChanged(int)), - this, - SLOT(ShowPointNumbersToggled()) - ); - - sect1->addWidget(ShowPointNumbers_); - - - // immediate update on the Server Manager side - vtkSMIntVectorProperty::SafeDownCast - ( - sourceProxy_->GetProperty("UiShowPointNumbers") - )->SetImmediateUpdate(true); + if ((prop = this->proxy()->GetProperty("UiShowPointNumbers")) != 0) + { + prop->SetImmediateUpdate(true); + + ShowPointNumbers_ = new QCheckBox("Show Point Numbers"); + ShowPointNumbers_->setToolTip("Show point numbers in render window."); + ShowPointNumbers_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + + form->addWidget(ShowPointNumbers_); + + connect + ( + ShowPointNumbers_, + SIGNAL(stateChanged(int)), + this, + SLOT(ShowPointNumbersToggled()) + ); + } } @@ -93,7 +95,7 @@ void pqPV3blockMeshReaderPanel::ShowPointNumbersToggled() { vtkSMIntVectorProperty::SafeDownCast ( - sourceProxy_->GetProperty("UiShowPointNumbers") + this->proxy()->GetProperty("UiShowPointNumbers") )->SetElement(0, ShowPointNumbers_->isChecked()); // update the active view diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h index 8096338315ec3532e5abc15c9b44916ae53c8998..0b1929af6d88beaae86a7d1cec93ccc6bc7e41c0 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h @@ -62,9 +62,6 @@ class pqPV3blockMeshReaderPanel Q_OBJECT; typedef pqAutoGeneratedObjectPanel Superclass; - //- Server Manager Source Proxy - vtkSMSourceProxy* sourceProxy_; - //- Show Point Numbers checkbox QCheckBox* ShowPointNumbers_; diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx index bf17a60ca314c90c312c14cd57de55ba5ff261e9..ab38d1bf4a8762d1d190065b0f1f151c869e16b4 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx @@ -64,7 +64,7 @@ vtkPV3blockMeshReader::vtkPV3blockMeshReader() ShowPointNumbers = 1; UpdateGUI = 0; - PartSelection = vtkDataArraySelection::New(); + BlockSelection = vtkDataArraySelection::New(); CurvedEdgesSelection = vtkDataArraySelection::New(); // Setup the selection callback to modify this object when an array @@ -77,7 +77,7 @@ vtkPV3blockMeshReader::vtkPV3blockMeshReader() SelectionObserver->SetClientData(this); - PartSelection->AddObserver + BlockSelection->AddObserver ( vtkCommand::ModifiedEvent, this->SelectionObserver @@ -109,11 +109,11 @@ vtkPV3blockMeshReader::~vtkPV3blockMeshReader() delete [] FileName; } - PartSelection->RemoveObserver(this->SelectionObserver); + BlockSelection->RemoveObserver(this->SelectionObserver); CurvedEdgesSelection->RemoveObserver(this->SelectionObserver); SelectionObserver->Delete(); - PartSelection->Delete(); + BlockSelection->Delete(); } @@ -292,50 +292,50 @@ void vtkPV3blockMeshReader::PrintSelf(ostream& os, vtkIndent indent) // ---------------------------------------------------------------------- -// Parts selection list control +// Block selection list control -vtkDataArraySelection* vtkPV3blockMeshReader::GetPartSelection() +vtkDataArraySelection* vtkPV3blockMeshReader::GetBlockSelection() { - vtkDebugMacro(<<"GetPartSelection"); - return PartSelection; + vtkDebugMacro(<<"GetBlockSelection"); + return BlockSelection; } -int vtkPV3blockMeshReader::GetNumberOfPartArrays() +int vtkPV3blockMeshReader::GetNumberOfBlockArrays() { - vtkDebugMacro(<<"GetNumberOfPartArrays"); - return PartSelection->GetNumberOfArrays(); + vtkDebugMacro(<<"GetNumberOfBlockArrays"); + return BlockSelection->GetNumberOfArrays(); } -const char* vtkPV3blockMeshReader::GetPartArrayName(int index) +const char* vtkPV3blockMeshReader::GetBlockArrayName(int index) { - vtkDebugMacro(<<"GetPartArrayName"); - return PartSelection->GetArrayName(index); + vtkDebugMacro(<<"GetBlockArrayName"); + return BlockSelection->GetArrayName(index); } -int vtkPV3blockMeshReader::GetPartArrayStatus(const char* name) +int vtkPV3blockMeshReader::GetBlockArrayStatus(const char* name) { - vtkDebugMacro(<<"GetPartArrayStatus"); - return PartSelection->ArrayIsEnabled(name); + vtkDebugMacro(<<"GetBlockArrayStatus"); + return BlockSelection->ArrayIsEnabled(name); } -void vtkPV3blockMeshReader::SetPartArrayStatus +void vtkPV3blockMeshReader::SetBlockArrayStatus ( const char* name, int status ) { - vtkDebugMacro(<<"SetPartArrayStatus"); + vtkDebugMacro(<<"SetBlockArrayStatus"); if (status) { - PartSelection->EnableArray(name); + BlockSelection->EnableArray(name); } else { - PartSelection->DisableArray(name); + BlockSelection->DisableArray(name); } } @@ -399,14 +399,7 @@ void vtkPV3blockMeshReader::SelectionModifiedCallback void* ) { - static_cast<vtkPV3blockMeshReader*>(clientdata)->SelectionModified(); -} - - -void vtkPV3blockMeshReader::SelectionModified() -{ - vtkDebugMacro(<<"SelectionModified"); - Modified(); + static_cast<vtkPV3blockMeshReader*>(clientdata)->Modified(); } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h index ae704d4a3be6f9a011b796c032a88837ab8295a1..ee2228f5da964722d9f09b6b26b9b6d2a8354c59 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h @@ -84,15 +84,15 @@ public: // Description: - // Parts (blocks) selection list control - vtkDataArraySelection* GetPartSelection(); - int GetNumberOfPartArrays(); - int GetPartArrayStatus(const char*); - void SetPartArrayStatus(const char*, int status); - const char* GetPartArrayName(int index); + // Blocks selection list control + vtkDataArraySelection* GetBlockSelection(); + int GetNumberOfBlockArrays(); + int GetBlockArrayStatus(const char*); + void SetBlockArrayStatus(const char*, int status); + const char* GetBlockArrayName(int index); // Description: - // Parts (blocks) selection list control + // CurvedEdges selection list control vtkDataArraySelection* GetCurvedEdgesSelection(); int GetNumberOfCurvedEdgesArrays(); int GetCurvedEdgesArrayStatus(const char*); @@ -110,8 +110,6 @@ public: void* calldata ); - void SelectionModified(); - protected: @@ -164,7 +162,7 @@ private: //- Dummy variable/switch to invoke a reader update int UpdateGUI; - vtkDataArraySelection* PartSelection; + vtkDataArraySelection* BlockSelection; vtkDataArraySelection* CurvedEdgesSelection; diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C index e9d36ec91eee61a8a67473b68656d0bd393cad32..b03908739868ff3a4f4cff58df797760a09317b7 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C @@ -49,13 +49,16 @@ defineTypeNameAndDebug(Foam::vtkPV3blockMesh, 0); void Foam::vtkPV3blockMesh::resetCounters() { // Reset mesh part ids and sizes - partInfoBlocks_.reset(); - partInfoEdges_.reset(); - partInfoCorners_.reset(); + arrayRangeBlocks_.reset(); + arrayRangeEdges_.reset(); + arrayRangeCorners_.reset(); } -void Foam::vtkPV3blockMesh::updateInfoBlocks() +void Foam::vtkPV3blockMesh::updateInfoBlocks +( + vtkDataArraySelection* arraySelection +) { if (debug) { @@ -63,8 +66,7 @@ void Foam::vtkPV3blockMesh::updateInfoBlocks() << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection* selection = reader_->GetPartSelection(); - partInfoBlocks_ = selection->GetNumberOfArrays(); + arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() ); const blockMesh& blkMesh = *meshPtr_; const int nBlocks = blkMesh.size(); @@ -81,22 +83,25 @@ void Foam::vtkPV3blockMesh::updateInfoBlocks() } // Add blockId and zoneName to GUI list - selection->AddArray(partName.c_str()); + arraySelection->AddArray(partName.c_str()); } - partInfoBlocks_ += nBlocks; + arrayRangeBlocks_ += nBlocks; if (debug) { // just for debug info - getSelectedArrayEntries(selection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3blockMesh::updateInfoBlocks" << endl; } } -void Foam::vtkPV3blockMesh::updateInfoEdges() +void Foam::vtkPV3blockMesh::updateInfoEdges +( + vtkDataArraySelection* arraySelection +) { if (debug) { @@ -104,8 +109,7 @@ void Foam::vtkPV3blockMesh::updateInfoEdges() << " [meshPtr=" << (meshPtr_ ? "set" : "NULL") << "]" << endl; } - vtkDataArraySelection* selection = reader_->GetCurvedEdgesSelection(); - partInfoEdges_ = selection->GetNumberOfArrays(); + arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() ); const blockMesh& blkMesh = *meshPtr_; const curvedEdgeList& edges = blkMesh.edges(); @@ -119,15 +123,15 @@ void Foam::vtkPV3blockMesh::updateInfoEdges() << edges[edgeI].type(); // Add "beg:end - type" to GUI list - selection->AddArray(ostr.str().c_str()); + arraySelection->AddArray(ostr.str().c_str()); } - partInfoEdges_ += nEdges; + arrayRangeEdges_ += nEdges; if (debug) { // just for debug info - getSelectedArrayEntries(selection); + getSelectedArrayEntries(arraySelection); Info<< "<end> Foam::vtkPV3blockMesh::updateInfoEdges" << endl; } @@ -145,9 +149,9 @@ Foam::vtkPV3blockMesh::vtkPV3blockMesh reader_(reader), dbPtr_(NULL), meshPtr_(NULL), - partInfoBlocks_("block"), - partInfoEdges_("edges"), - partInfoCorners_("corners") + arrayRangeBlocks_("block"), + arrayRangeEdges_("edges"), + arrayRangeCorners_("corners") { if (debug) { @@ -243,7 +247,7 @@ void Foam::vtkPV3blockMesh::updateInfo() resetCounters(); - vtkDataArraySelection* partSelection = reader_->GetPartSelection(); + vtkDataArraySelection* blockSelection = reader_->GetBlockSelection(); vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection(); // enable 'internalMesh' on the first call @@ -251,33 +255,33 @@ void Foam::vtkPV3blockMesh::updateInfo() stringList enabledParts; stringList enabledEdges; bool firstTime = false; - if (!partSelection->GetNumberOfArrays() && !meshPtr_) + if (!blockSelection->GetNumberOfArrays() && !meshPtr_) { firstTime = true; } else { - enabledParts = getSelectedArrayEntries(partSelection); + enabledParts = getSelectedArrayEntries(blockSelection); enabledEdges = getSelectedArrayEntries(edgeSelection); } // Clear current mesh parts list - partSelection->RemoveAllArrays(); + blockSelection->RemoveAllArrays(); edgeSelection->RemoveAllArrays(); // need a blockMesh updateFoamMesh(); // Update mesh parts list - updateInfoBlocks(); + updateInfoBlocks( blockSelection ); // Update curved edges list - updateInfoEdges(); + updateInfoEdges( edgeSelection ); // restore the enabled selections if (!firstTime) { - setSelectedArrayEntries(partSelection, enabledParts); + setSelectedArrayEntries(blockSelection, enabledParts); setSelectedArrayEntries(edgeSelection, enabledEdges); } @@ -337,7 +341,7 @@ void Foam::vtkPV3blockMesh::Update reader_->UpdateProgress(0.1); // Set up mesh parts selection(s) - updateBoolListStatus(partStatus_, reader_->GetPartSelection()); + updateBoolListStatus(blockStatus_, reader_->GetBlockSelection()); // Set up curved edges selection(s) updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection()); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H index a159b3cba58978185c46eebdfb8d5579996ce2df..fc612c27b8ff573890c146e3613069e259d7e525 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H @@ -88,7 +88,7 @@ class vtkPV3blockMesh // Private classes //- Bookkeeping for GUI checklists and the multi-block organization - class partInfo + class arrayRange { const char *name_; int block_; @@ -97,11 +97,11 @@ class vtkPV3blockMesh public: - partInfo(const char *name, const int blockNo=0) + arrayRange(const char *name, const int blockNo=0) : name_(name), block_(blockNo), - start_(-1), + start_(0), size_(0) {} @@ -119,21 +119,25 @@ class vtkPV3blockMesh return prev; } + //- Return block name const char* name() const { return name_; } + //- Return array start index int start() const { return start_; } + //- Return array end index int end() const { return start_ + size_; } + //- Return sublist size int size() const { return size_; @@ -144,16 +148,10 @@ class vtkPV3blockMesh return !size_; } - void reset() + //- Reset the size to zero and optionally assign a new start + void reset(const int startAt = 0) { - start_ = -1; - size_ = 0; - } - - //- Assign new start and reset the size - void operator=(const int i) - { - start_ = i; + start_ = startAt; size_ = 0; } @@ -177,22 +175,20 @@ class vtkPV3blockMesh blockMesh* meshPtr_; //- Selected geometrical parts - boolList partStatus_; + boolList blockStatus_; //- Selected curved edges boolList edgeStatus_; //- First instance and size of bleckMesh blocks - // used to index into partStatus_ - partInfo partInfoBlocks_; + // used to index into blockStatus_ + arrayRange arrayRangeBlocks_; - //- First instance and size of CurvedEdges - // only partially used - partInfo partInfoEdges_; + //- First instance and size of CurvedEdges (only partially used) + arrayRange arrayRangeEdges_; - //- First instance and size of block corners - // only partially used - partInfo partInfoCorners_; + //- First instance and size of block corners (only partially used) + arrayRange arrayRangeCorners_; //- List of point numbers for rendering to window List<vtkTextActor*> pointNumberTextActorsPtrs_; @@ -205,7 +201,7 @@ class vtkPV3blockMesh ( vtkMultiBlockDataSet* output, vtkDataSet* dataset, - const partInfo&, + const arrayRange&, const label datasetNo, const std::string& datasetName ); @@ -215,7 +211,7 @@ class vtkPV3blockMesh static vtkDataSet* GetDataSetFromBlock ( vtkMultiBlockDataSet* output, - const partInfo&, + const arrayRange&, const label datasetNo ); @@ -224,7 +220,7 @@ class vtkPV3blockMesh static label GetNumberOfDataSets ( vtkMultiBlockDataSet* output, - const partInfo& + const arrayRange& ); //- Update boolList from GUI selection @@ -240,10 +236,10 @@ class vtkPV3blockMesh // Update information helper functions //- Internal block info - void updateInfoBlocks(); + void updateInfoBlocks(vtkDataArraySelection*); //- block curved edges info - void updateInfoEdges(); + void updateInfoEdges(vtkDataArraySelection*); // Update helper functions @@ -271,7 +267,7 @@ class vtkPV3blockMesh static wordHashSet getSelected ( vtkDataArraySelection*, - const partInfo& + const arrayRange& ); //- Retrieve the current selections @@ -281,7 +277,7 @@ class vtkPV3blockMesh static stringList getSelectedArrayEntries ( vtkDataArraySelection*, - const partInfo& + const arrayRange& ); //- Set selection(s) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C index 4f76f5ebf2225f4c4915a3aa352052dc796b1d31..67a9cdbed7943cc4b1715a51aeb3366c153d9545 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C @@ -52,9 +52,9 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks int& blockNo ) { - vtkDataArraySelection* selection = reader_->GetPartSelection(); - partInfo& selector = partInfoBlocks_; - selector.block(blockNo); // set output block + vtkDataArraySelection* selection = reader_->GetBlockSelection(); + arrayRange& range = arrayRangeBlocks_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const blockMesh& blkMesh = *meshPtr_; @@ -70,25 +70,18 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks for ( - int partId = selector.start(); - partId < selector.end(); + int partId = range.start(); + partId < range.end(); ++partId, ++blockI ) { - if (!partStatus_[partId]) + if (!blockStatus_[partId]) { continue; } const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); - word partName("block"); - -// // append the (optional) zone name -// if (!blockDef.zoneName().empty()) -// { -// partName += " - " + blockDef.zoneName(); -// } -// + vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); // Convert Foam mesh vertices to VTK @@ -123,7 +116,7 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks AddToBlock ( - output, vtkmesh, selector, datasetNo, + output, vtkmesh, range, datasetNo, selection->GetArrayName(partId) ); @@ -152,9 +145,9 @@ void Foam::vtkPV3blockMesh::convertMeshEdges ) { vtkDataArraySelection* selection = reader_->GetCurvedEdgesSelection(); - partInfo& selector = partInfoEdges_; + arrayRange& range = arrayRangeEdges_; - selector.block(blockNo); // set output block + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const blockMesh& blkMesh = *meshPtr_; @@ -165,8 +158,8 @@ void Foam::vtkPV3blockMesh::convertMeshEdges for ( - int partId = selector.start(); - partId < selector.end(); + int partId = range.start(); + partId < range.end(); ++partId, ++edgeI ) { @@ -187,9 +180,7 @@ void Foam::vtkPV3blockMesh::convertMeshEdges edgeList blkEdges = blockDef.blockShape().edges(); - // find the corresponding edge within the block - label foundEdgeI = -1; forAll(blkEdges, blkEdgeI) { @@ -236,7 +227,7 @@ void Foam::vtkPV3blockMesh::convertMeshEdges AddToBlock ( - output, vtkmesh, selector, datasetNo, + output, vtkmesh, range, datasetNo, selection->GetArrayName(partId) ); @@ -269,8 +260,8 @@ void Foam::vtkPV3blockMesh::convertMeshCorners int& blockNo ) { - partInfo& selector = partInfoCorners_; - selector.block(blockNo); // set output block + arrayRange& range = arrayRangeCorners_; + range.block(blockNo); // set output block label datasetNo = 0; // restart at dataset 0 const pointField& blockPoints = meshPtr_->blockPointField(); @@ -310,7 +301,11 @@ void Foam::vtkPV3blockMesh::convertMeshCorners vtkmesh->SetVerts(vtkcells); vtkcells->Delete(); - AddToBlock(output, vtkmesh, selector, datasetNo, partInfoCorners_.name()); + AddToBlock + ( + output, vtkmesh, range, datasetNo, + arrayRangeCorners_.name() + ); vtkmesh->Delete(); datasetNo++; diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C index bde724d9a7fee2c9d90c18d6768b9b5648ec1501..5a84dd2c77e9d0452cd6514f4ad0cb421097d54c 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C @@ -71,12 +71,12 @@ void Foam::vtkPV3blockMesh::AddToBlock ( vtkMultiBlockDataSet* output, vtkDataSet* dataset, - const partInfo& selector, + const arrayRange& range, const label datasetNo, const std::string& datasetName ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -112,7 +112,7 @@ void Foam::vtkPV3blockMesh::AddToBlock output->GetMetaData(blockNo)->Set ( vtkCompositeDataSet::NAME(), - selector.name() + range.name() ); } @@ -130,11 +130,11 @@ void Foam::vtkPV3blockMesh::AddToBlock vtkDataSet* Foam::vtkPV3blockMesh::GetDataSetFromBlock ( vtkMultiBlockDataSet* output, - const partInfo& selector, + const arrayRange& range, const label datasetNo ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -152,10 +152,10 @@ vtkDataSet* Foam::vtkPV3blockMesh::GetDataSetFromBlock Foam::label Foam::vtkPV3blockMesh::GetNumberOfDataSets ( vtkMultiBlockDataSet* output, - const partInfo& selector + const arrayRange& range ) { - const int blockNo = selector.block(); + const int blockNo = range.block(); vtkDataObject* blockDO = output->GetBlock(blockNo); vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); @@ -191,13 +191,13 @@ Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected Foam::wordHashSet Foam::vtkPV3blockMesh::getSelected ( vtkDataArraySelection* select, - const partInfo& selector + const arrayRange& range ) { int nElem = select->GetNumberOfArrays(); wordHashSet selections(2*nElem); - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { if (select->GetArraySetting(elemI)) { @@ -251,13 +251,13 @@ Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries ( vtkDataArraySelection* select, - const partInfo& selector + const arrayRange& range ) { - stringList selections(selector.size()); + stringList selections(range.size()); label nElem = 0; - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { if (select->GetArraySetting(elemI)) { @@ -270,7 +270,7 @@ Foam::stringList Foam::vtkPV3blockMesh::getSelectedArrayEntries if (debug) { Info<< "available("; - for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + for (int elemI = range.start(); elemI < range.end(); ++elemI) { Info<< " \"" << select->GetArrayName(elemI) << "\""; } diff --git a/doc/Doxygen/Doxyfile b/doc/Doxygen/Doxyfile index 908fa543b949ae68c460d8d72c29cf91f7c190b2..68ff8430b205ad285cfc0e03936441425d305b3c 100644 --- a/doc/Doxygen/Doxyfile +++ b/doc/Doxygen/Doxyfile @@ -689,13 +689,13 @@ HTML_FILE_EXTENSION = .html # each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = FoamHeader.html +HTML_HEADER = $(WM_PROJECT_DIR)/doc/Doxygen/FoamHeader.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = FoamFooter.html +HTML_FOOTER = $(WM_PROJECT_DIR)/doc/Doxygen/FoamFooter.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index cc7a1c1bb5fe8b9db96e92037ca0dced0fe89b86..d68caa1c244ba6544143a427c877a1e885649894 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -1,13 +1,17 @@ +curvedEdges/CatmullRomSpline.C +curvedEdges/polyLine.C + +curvedEdges/arcEdge.C curvedEdges/curvedEdge.C curvedEdges/lineEdge.C -curvedEdges/polyLine.C curvedEdges/polyLineEdge.C -curvedEdges/arcEdge.C -curvedEdges/spline.C -curvedEdges/BSpline.C -curvedEdges/simpleSplineEdge.C -curvedEdges/polySplineEdge.C curvedEdges/lineDivide.C +curvedEdges/splineEdge.C + +curvedEdges/legacy/spline.C +curvedEdges/legacy/BSpline.C +curvedEdges/legacy/simpleSplineEdge.C +curvedEdges/legacy/polySplineEdge.C blockDescriptor/blockDescriptor.C blockDescriptor/blockDescriptorEdges.C diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index 599a108c3cbffaf4ef996f89b8afc20e8711e45f..335fc824b85200d5c89c9d153e95a08be1fa625c 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -89,7 +89,7 @@ Foam::blockDescriptor::blockDescriptor { zoneName_ = t.wordToken(); - // Get the next token + // Examine next token is >> t; } is.putBack(t); @@ -129,7 +129,12 @@ Foam::blockDescriptor::blockDescriptor scalarList expRatios(is); - if (expRatios.size() == 3) + if (expRatios.size() == 1) + { + // identical in x/y/z-directions + expand_ = expRatios[0]; + } + else if (expRatios.size() == 3) { // x-direction expand_[0] = expRatios[0]; diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C index 5fcf31f4218935aa34f52339ddc21214022f737b..afc8fcd078bc53e21897b36a25c4f56d6e6cd006 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C @@ -120,8 +120,8 @@ void Foam::blockDescriptor::setEdge // divide the line lineDivide divEdge(cedge, dim, 1.0/(gExp+SMALL)); - pointField p = divEdge.points(); - scalarList d = divEdge.lambdaDivisions(); + const pointField& p = divEdge.points(); + const scalarList& d = divEdge.lambdaDivisions(); edgePoints_[edgeI].setSize(p.size()); edgeWeights_[edgeI].setSize(d.size()); diff --git a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C new file mode 100644 index 0000000000000000000000000000000000000000..711ae8da6730ad19a6624fd771608db06680a099 --- /dev/null +++ b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.C @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "error.H" +#include "CatmullRomSpline.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::CatmullRomSpline::CatmullRomSpline +( + const pointField& Knots, + const vector&, + const vector& +) +: + polyLine(Knots) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::point Foam::CatmullRomSpline::position(const scalar mu) const +{ + // endpoints + if (mu < SMALL) + { + return points().first(); + } + else if (mu > 1 - SMALL) + { + return points().last(); + } + + scalar lambda = mu; + label segment = localParameter(lambda); + return position(segment, lambda); +} + + +Foam::point Foam::CatmullRomSpline::position +( + const label segment, + const scalar mu +) const +{ + const point& p0 = points()[segment]; + const point& p1 = points()[segment+1]; + + // special cases - no calculation needed + if (segment < 0 || mu < 0.0) + { + return p0; + } + else if (segment > nSegments() || mu >= 1.0) + { + return p1; + } + + // determine the end points + point e0; + point e1; + + if (segment == 0) + { + // end: simple reflection + e0 = 2.0 * p0 - p1; + } + else + { + e0 = points()[segment-1]; + } + + if (segment+1 == nSegments()) + { + // end: simple reflection + e1 = 2.0 * p1 - p0; + } + else + { + e1 = points()[segment+2]; + } + + + return 0.5 * + ( + ( 2 * p0 ) + + mu * + ( + ( -e0 + p1 ) + + mu * + ( + ( 2*e0 - 5*p0 + 4*p1 - e1 ) + + mu * + ( -e0 + 3*p0 - 3*p1 + e1 ) + ) + ) + ); +} + + +Foam::scalar Foam::CatmullRomSpline::length() const +{ + notImplemented("CatmullRomSpline::length() const"); + return 1.0; +} + + +// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H new file mode 100644 index 0000000000000000000000000000000000000000..6f1851a7a65821af8c7986c38c0a17d7504429e0 --- /dev/null +++ b/src/mesh/blockMesh/curvedEdges/CatmullRomSpline.H @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::CatmullRomSpline + +Description + An implementation of Catmull-Rom splines (sometime as known as + Overhauser splines). + + In this implementation, the end tangents are created + automatically by reflection. + + In matrix form, the @e local interpolation on the interval t=[0..1] is + described as follows: + @verbatim + P(t) = 0.5 * [ t^3 t^2 t 1 ] * [ -1 3 -3 1 ] * [ P-1 ] + [ 2 -5 4 -1 ] [ P0 ] + [ -1 0 1 0 ] [ P1 ] + [ 0 2 0 0 ] [ P2 ] + @endverbatim + + Where P-1 and P2 represent the neighbouring points or the + extrapolated end points. Simple reflection is used to + automatically create the end points. + + The spline is discretized based on the chord length of the + individual segments. In rare cases (sections with very high + curvatures), the resulting distribution may be sub-optimal. + +SeeAlso + http://www.algorithmist.net/catmullrom.html provides a nice + introduction + +ToDo + A future implementation could also handle closed splines - either + when the start/end points are identically or when specified. + +SourceFiles + CatmullRomSpline.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CatmullRomSpline_H +#define CatmullRomSpline_H + +#include "polyLine.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class CatmullRomSpline Declaration +\*---------------------------------------------------------------------------*/ + +class CatmullRomSpline +: + public polyLine +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + CatmullRomSpline(const CatmullRomSpline&); + + //- Disallow default bitwise assignment + void operator=(const CatmullRomSpline&); + + +public: + + // Constructors + + //- Construct from components + CatmullRomSpline + ( + const pointField& knots, + const vector& begTangentNotImplemented = vector::zero, + const vector& endTangentNotImplemented = vector::zero + ); + + + // Member Functions + + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar lambda) const; + + //- Return the point position corresponding to the local parameter + // 0 <= lambda <= 1 on the given segment + point position(const label segment, const scalar lambda) const; + + //- Return the length of the curve + scalar length() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/arcEdge.C b/src/mesh/blockMesh/curvedEdges/arcEdge.C index afb62a8f8b437daaf7ba5fa734d6b07b653ba1f2..21143ac43a5bcd6e39a4e09a79c247aff0e8e935 100644 --- a/src/mesh/blockMesh/curvedEdges/arcEdge.C +++ b/src/mesh/blockMesh/curvedEdges/arcEdge.C @@ -61,7 +61,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle() scalar fact = 0.5*(bsqr - adotb)/denom; - vector centre = 0.5*a + fact*((a ^ b) ^ a); + point centre = 0.5*a + fact*((a ^ b) ^ a); centre += p1_; @@ -71,11 +71,10 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle() vector r3(p3_ - centre); // find angles - scalar tmp = (r3&r1)/(mag(r3)*mag(r1)); - angle_ = radToDeg(acos(tmp)); + angle_ = radToDeg(acos((r3 & r1)/(mag(r3) * mag(r1)))); // check if the vectors define an exterior or an interior arcEdge - if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) + if (((r1 ^ r2) & (r1 ^ r3)) < 0.0) { angle_ = 360.0 - angle_; } @@ -99,7 +98,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle() radius_ = mag(r3); // set up and return the local coordinate system - return cylindricalCS("tmpCS", centre, tempAxis, r1); + return cylindricalCS("arcEdgeCS", centre, tempAxis, r1); } @@ -133,7 +132,7 @@ Foam::arcEdge::arcEdge(const pointField& points, Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::arcEdge::position(const scalar lambda) const +Foam::point Foam::arcEdge::position(const scalar lambda) const { if (lambda < 0 || lambda > 1) { @@ -146,7 +145,7 @@ Foam::vector Foam::arcEdge::position(const scalar lambda) const { return p1_; } - else if (lambda > 1-SMALL) + else if (lambda > 1 - SMALL) { return p3_; } diff --git a/src/mesh/blockMesh/curvedEdges/arcEdge.H b/src/mesh/blockMesh/curvedEdges/arcEdge.H index da96d150fc0803f0b6fecb6c50d31b072ff17a35..194e5c634bb39d147081af5e25624b2fe9f91de6 100644 --- a/src/mesh/blockMesh/curvedEdges/arcEdge.H +++ b/src/mesh/blockMesh/curvedEdges/arcEdge.H @@ -54,15 +54,16 @@ class arcEdge { // Private data - vector p1_, p2_, p3_; + point p1_, p2_, p3_; + cylindricalCS cs_; scalar angle_; scalar radius_; - cylindricalCS cs_; - - cylindricalCS calcAngle(); // Private Member Functions + //- Calculate the coordinate system, angle and radius + cylindricalCS calcAngle(); + //- Disallow default bitwise copy construct arcEdge(const arcEdge&); @@ -96,9 +97,9 @@ public: // Member Functions - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.C b/src/mesh/blockMesh/curvedEdges/curvedEdge.C index 4b80a221ddd16c78fead7a889344db6d4454b189..35e58b7692b96e1573f900e6554cd664d90bb799 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.C +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.C @@ -108,27 +108,27 @@ Foam::autoPtr<Foam::curvedEdge> Foam::curvedEdge::New // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::pointField Foam::curvedEdge::knotlist +Foam::pointField Foam::curvedEdge::appendEndPoints ( const pointField& points, const label start, const label end, - const pointField& otherknots + const pointField& otherKnots ) { - pointField newPoints(otherknots.size() + 2); + pointField allKnots(otherKnots.size() + 2); // start/end knots - newPoints[0] = points[start]; - newPoints[otherknots.size() + 1] = points[end]; + allKnots[0] = points[start]; + allKnots[otherKnots.size() + 1] = points[end]; // intermediate knots - forAll(otherknots, knotI) + forAll(otherKnots, knotI) { - newPoints[knotI+1] = otherknots[knotI]; + allKnots[knotI+1] = otherKnots[knotI]; } - return newPoints; + return allKnots; } diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.H b/src/mesh/blockMesh/curvedEdges/curvedEdge.H index 49ad047e45a759603d41141e38ee6b010ccf9979..bd1ad3246ada4444ef88cd3dabdfd914d695c329 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.H +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.H @@ -26,8 +26,8 @@ Class Foam::curvedEdge Description - Define a curved edge in space that is parameterised for - 0<lambda<1 from the beginning to the end point. + Define a curved edge that is parameterized for 0<lambda<1 + between the start and end point. SourceFiles curvedEdge.C @@ -62,6 +62,19 @@ protected: const label start_; const label end_; + // Protected Member Functions + + //- Return a complete point field by appending the start/end points + // to the given list + static pointField appendEndPoints + ( + const pointField&, + const label start, + const label end, + const pointField& otherKnots + ); + + public: //- Runtime type information @@ -136,23 +149,13 @@ public: // - -1: same edge, but different orientation inline int compare(const label start, const label end) const; - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - virtual vector position(const scalar) const = 0; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + virtual point position(const scalar) const = 0; //- Return the length of the curve virtual scalar length() const = 0; - //- Return a complete knotList by adding the start/end points - // to the given list - static pointField knotlist - ( - const pointField&, - const label start, - const label end, - const pointField& otherknots - ); - // Member operators diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H b/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H index 6d3de4e554009922cc29918ad31a41d5369a3e62..ade7db175bfe2e0ada926c04f0fa38b65ac25921 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H +++ b/src/mesh/blockMesh/curvedEdges/curvedEdgeI.H @@ -67,7 +67,4 @@ inline int Foam::curvedEdge::compare(const edge& e) const } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.C b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.C similarity index 96% rename from src/mesh/blockMesh/curvedEdges/BSpline.C rename to src/mesh/blockMesh/curvedEdges/legacy/BSpline.C index 3e166f25cb9650f17a5271df613e47cad7db686e..cd7ee90ca1e195e9270034943ac06a819038816d 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.C +++ b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.C @@ -115,13 +115,13 @@ Foam::BSpline::BSpline // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::BSpline::realPosition(const scalar mu) const +Foam::point Foam::BSpline::realPosition(const scalar mu) const { return spline::position(mu); } -Foam::vector Foam::BSpline::position(const scalar mu) const +Foam::point Foam::BSpline::position(const scalar mu) const { return spline::position((1.0/(nKnots() - 1))*(1.0 + mu*(nKnots() - 3))); } diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.H b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.H similarity index 89% rename from src/mesh/blockMesh/curvedEdges/BSpline.H rename to src/mesh/blockMesh/curvedEdges/legacy/BSpline.H index ace98b4e21097bd7e0f90be743683601810a9974..5ba6423ea12d4a6cdee287e9dd1803d6b13166c7 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.H +++ b/src/mesh/blockMesh/curvedEdges/legacy/BSpline.H @@ -82,13 +82,13 @@ public: // Member Functions - //- Return the real position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector realPosition(const scalar lambda) const; + //- Return the real point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point realPosition(const scalar lambda) const; - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar lambda) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar lambda) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C similarity index 92% rename from src/mesh/blockMesh/curvedEdges/polySplineEdge.C rename to src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C index 8e4f0f90b3c324888d95bb7c0de7de2f44879664..bf370cd7d3fe0fee5ebb1f554fd430a032b836a3 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.C @@ -56,7 +56,7 @@ Foam::pointField Foam::polySplineEdge::intervening { BSpline spl ( - knotlist(points_, start_, end_, otherknots), + appendEndPoints(curvedEdge::points_, start_, end_, otherknots), fstend, sndend ); @@ -73,7 +73,7 @@ Foam::pointField Foam::polySplineEdge::intervening interval /= nBetweenKnots + 1; pointField ans(nSize); - ans[0] = points_[start_]; + ans[0] = curvedEdge::points_[start_]; register scalar index(init); for (register label i=1; i<nSize-1; i++) @@ -82,7 +82,7 @@ Foam::pointField Foam::polySplineEdge::intervening ans[i] = spl.realPosition(index); } - ans[nSize-1] = points_[end_]; + ans[nSize-1] = curvedEdge::points_[end_]; return ans; } @@ -128,14 +128,14 @@ Foam::polySplineEdge::polySplineEdge vector fstend(is); vector sndend(is); - controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend); - calcDistances(); + polyLine::points_ = intervening(otherKnots_, nInterKnots, fstend, sndend); + calcParam(); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::polySplineEdge::position(const scalar mu) const +Foam::point Foam::polySplineEdge::position(const scalar mu) const { return polyLine::position(mu); } diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H similarity index 91% rename from src/mesh/blockMesh/curvedEdges/polySplineEdge.H rename to src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H index b133b9e45dd15de1f261e118593993bb8b2ca02c..dcb5fc2dfe97da62bbbf423196dc84a7839b86cb 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/legacy/polySplineEdge.H @@ -26,7 +26,7 @@ Class Foam::polySplineEdge Description - A spline representation via a polyLine + A curvedEdge interface for B-splines. SourceFiles polySplineEdge.C @@ -90,16 +90,16 @@ public: polySplineEdge(const pointField&, Istream&); - // Destructor - - virtual ~polySplineEdge(){} + //- Destructor + virtual ~polySplineEdge() + {} // Member Functions - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar mu) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar mu) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C similarity index 90% rename from src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C rename to src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C index 3132a1f7eaff97f24178dc84aef9d1f774ab12e9..c5dc9e6d9c866015c02c0914640413a5b72f3bc0 100644 --- a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.C @@ -48,7 +48,7 @@ Foam::simpleSplineEdge::simpleSplineEdge ) : curvedEdge(points, start, end), - BSpline(knotlist(points, start, end, otherknots)) + BSpline(appendEndPoints(points, start, end, otherknots)) {} @@ -63,20 +63,20 @@ Foam::simpleSplineEdge::simpleSplineEdge ) : curvedEdge(points, start, end), - BSpline(knotlist(points, start, end, otherknots), fstend, sndend) + BSpline(appendEndPoints(points, start, end, otherknots), fstend, sndend) {} Foam::simpleSplineEdge::simpleSplineEdge(const pointField& points, Istream& is) : curvedEdge(points, is), - BSpline(knotlist(points, start_, end_, pointField(is))) + BSpline(appendEndPoints(points, start_, end_, pointField(is))) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::simpleSplineEdge::position(const scalar mu) const +Foam::point Foam::simpleSplineEdge::position(const scalar mu) const { return BSpline::position(mu); } diff --git a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H similarity index 93% rename from src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H rename to src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H index 4c6df2a5095a3893f0a609cb8f4c4134b204b4b8..91acf6fdee535928dd7589b8c50b3bcc017bba73 100644 --- a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/legacy/simpleSplineEdge.H @@ -26,7 +26,7 @@ Class Foam::simpleSplineEdge Description - The actual access class for Bspline + A curvedEdge interface for B-splines. SourceFiles simpleSplineEdge.C @@ -102,9 +102,9 @@ public: // Member Functions - //- Return the position of a point on the simple spline curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar mu) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar) const; //- Return the length of the simple spline curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/spline.C b/src/mesh/blockMesh/curvedEdges/legacy/spline.C similarity index 96% rename from src/mesh/blockMesh/curvedEdges/spline.C rename to src/mesh/blockMesh/curvedEdges/legacy/spline.C index cddf6fa8edaad6653612d396760d69ad009820d5..4f7ab8e195e33f12144a2ba90bc264fb5e13bb67 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.C +++ b/src/mesh/blockMesh/curvedEdges/legacy/spline.C @@ -72,9 +72,9 @@ Foam::spline::spline(const pointField& knotPoints) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::spline::position(const scalar mu) const +Foam::point Foam::spline::position(const scalar mu) const { - vector loc(vector::zero); + point loc(point::zero); for (register label i=0; i < knots_.size(); i++) { diff --git a/src/mesh/blockMesh/curvedEdges/spline.H b/src/mesh/blockMesh/curvedEdges/legacy/spline.H similarity index 90% rename from src/mesh/blockMesh/curvedEdges/spline.H rename to src/mesh/blockMesh/curvedEdges/legacy/spline.H index 74e73afdc652c00efe762d0d72b75cbb23ca7800..1055690933919980b3b5fa9e1959210dba04d165 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.H +++ b/src/mesh/blockMesh/curvedEdges/legacy/spline.H @@ -81,6 +81,13 @@ public: // Access + //- Return the knot points in the spline + const pointField& knotPoints() const + { + return knots_; + } + + //- Return the number of knots in the spline label nKnots() const { @@ -88,9 +95,9 @@ public: } - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar) const; //- Return the length of the spline curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/lineDivide.H b/src/mesh/blockMesh/curvedEdges/lineDivide.H index 37f1d9ba5c3670ea55ecb7295bf11acc8db9f129..1b3f33e69da6184b76f2b8adb699d360a749184f 100644 --- a/src/mesh/blockMesh/curvedEdges/lineDivide.H +++ b/src/mesh/blockMesh/curvedEdges/lineDivide.H @@ -55,14 +55,14 @@ class lineDivide // Private data pointField points_; + scalarList divisions_; public: // Constructors - //- Construct from components - // discretization and expansion ration + //- Construct from components with discretization and expansion ratio lineDivide ( const curvedEdge&, diff --git a/src/mesh/blockMesh/curvedEdges/lineEdge.C b/src/mesh/blockMesh/curvedEdges/lineEdge.C index 72e173ea2ce3e6b88d953b1006de372cc78a9b80..586d495d491d8e0a556a0d96f81e630fe308a35b 100644 --- a/src/mesh/blockMesh/curvedEdges/lineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/lineEdge.C @@ -46,23 +46,23 @@ Foam::lineEdge::lineEdge const label end ) : - curvedEdge(points, start, end), - startPoint_(points_[start_]), - direction_(points_[end_] - points_[start_]) + curvedEdge(points, start, end) {} Foam::lineEdge::lineEdge(const pointField& points, Istream& is) : - curvedEdge(points, is), - startPoint_(points_[start_]), - direction_(points_[end_] - points_[start_]) + curvedEdge(points, is) {} +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // + +Foam::lineEdge::~lineEdge() +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::lineEdge::position(const scalar lambda) const +Foam::point Foam::lineEdge::position(const scalar lambda) const { if (lambda < 0 || lambda > 1) { @@ -71,13 +71,13 @@ Foam::vector Foam::lineEdge::position(const scalar lambda) const << abort(FatalError); } - return startPoint_ + lambda*direction_; + return points_[start_] + lambda * (points_[end_] - points_[start_]); } Foam::scalar Foam::lineEdge::length() const { - return mag(direction_); + return mag(points_[end_] - points_[start_]); } diff --git a/src/mesh/blockMesh/curvedEdges/lineEdge.H b/src/mesh/blockMesh/curvedEdges/lineEdge.H index a601830f7f70e6449110a5949ef44cf41a734855..3d295912325ae204df275b720707defdb416a62a 100644 --- a/src/mesh/blockMesh/curvedEdges/lineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/lineEdge.H @@ -26,7 +26,7 @@ Class Foam::lineEdge Description - Defines a straight line between the start point and the end point. + A straight edge between the start point and the end point. SourceFiles lineEdge.C @@ -52,14 +52,6 @@ class lineEdge : public curvedEdge { - // Private data - - //- Avoid repetitive calculation of the start point - const vector startPoint_; - - //- Avoid repetitive calculation of the direction (end - start) - const vector direction_; - // Private Member Functions //- Disallow default bitwise copy construct @@ -68,7 +60,6 @@ class lineEdge //- Disallow default bitwise assignment void operator=(const lineEdge&); - public: //- Runtime type information @@ -79,20 +70,19 @@ public: //- Construct from components lineEdge(const pointField&, const label start, const label end); - //- Construct from Istream setting pointsList + //- Construct from Istream with a pointField lineEdge(const pointField&, Istream&); - // Destructor - - virtual ~lineEdge(){} + //- Destructor + virtual ~lineEdge(); // Member Functions - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.C b/src/mesh/blockMesh/curvedEdges/polyLine.C index a08ab8fc4033a632d5e9a2fc1295f759b07c2905..08083041f2d5c7c82bb8b0fb86af14f3120d1468 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.C +++ b/src/mesh/blockMesh/curvedEdges/polyLine.C @@ -29,29 +29,26 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// calcDistances generates the distances_ lookup table (cumulative -// distance along the line) from the individual vectors to the points - -void Foam::polyLine::calcDistances() +void Foam::polyLine::calcParam() { - distances_.setSize(controlPoints_.size()); + param_.setSize(points_.size()); - if (distances_.size()) + if (param_.size()) { - distances_[0] = 0.0; + param_[0] = 0.0; - for (label i=1; i<distances_.size(); i++) + for (label i=1; i < param_.size(); i++) { - distances_[i] = distances_[i-1] + - mag(controlPoints_[i] - controlPoints_[i-1]); + param_[i] = param_[i-1] + mag(points_[i] - points_[i-1]); } - // normalize - lineLength_ = distances_.last(); - for (label i=1; i<distances_.size(); i++) + // normalize on the interval 0-1 + lineLength_ = param_.last(); + for (label i=1; i < param_.size() - 1; i++) { - distances_[i] /= lineLength_; + param_[i] /= lineLength_; } + param_.last() = 1.0; } else { @@ -65,20 +62,75 @@ void Foam::polyLine::calcDistances() Foam::polyLine::polyLine(const pointField& ps) : - controlPoints_(ps), - distances_(0), - lineLength_(0.0) + points_(ps), + lineLength_(0.0), + param_(0) { - calcDistances(); + calcParam(); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::polyLine::position(const scalar lambda) const +const Foam::pointField& Foam::polyLine::points() const +{ + return points_; +} + + +Foam::label Foam::polyLine::nSegments() const +{ + return points_.size()-1; +} + + +Foam::label Foam::polyLine::localParameter(scalar& lambda) const { // check range of lambda + if (lambda < 0 || lambda > 1) + { + FatalErrorIn("polyLine::localParameter(scalar&)") + << "Parameter out-of-range, " + << "lambda = " << lambda + << abort(FatalError); + } + // check endpoints + if (lambda < SMALL) + { + lambda = 0; + return 0; + } + else if (lambda > 1 - SMALL) + { + lambda = 1; + return nSegments(); + } + + // search table of cumulative distances to find which line-segment + // we are on. Check the upper bound. + + label segmentI = 1; + while (param_[segmentI] < lambda) + { + segmentI++; + } + segmentI--; // we want the corresponding lower bound + + // the local parameter [0-1] on this line segment + lambda = + ( + ( lambda - param_[segmentI] ) + / ( param_[segmentI+1] - param_[segmentI] ) + ); + + return segmentI; +} + + +Foam::point Foam::polyLine::position(const scalar lambda) const +{ + // check range of lambda if (lambda < 0 || lambda > 1) { FatalErrorIn("polyLine::position(const scalar)") @@ -87,37 +139,36 @@ Foam::vector Foam::polyLine::position(const scalar lambda) const << abort(FatalError); } - // Quick calc of endpoints - + // check endpoints if (lambda < SMALL) { - return controlPoints_[0]; + return points_[0]; } else if (lambda > 1 - SMALL) { - return controlPoints_.last(); + return points_.last(); } - // search table of cumulative distance to find which linesegment we - // are on + // search table of cumulative distances to find which line-segment + // we are on. Check the upper bound. - label i(0); - do + label segmentI = 1; + while (param_[segmentI] < lambda) { - i++; - } while (distances_[i] < lambda); - - i--; // we overshot! - - // construct position vector - scalar offsetDist = - (lambda - distances_[i]) - /(distances_[i+1] - distances_[i]); + ++segmentI; + } + --segmentI; // we now want the lower bound - vector offsetV = controlPoints_[i+1] - controlPoints_[i]; - return controlPoints_[i] + offsetDist*offsetV; + // linear interpolation + return + ( + points_[segmentI] + + ( points_[segmentI+1] - points_[segmentI] ) + * ( lambda - param_[segmentI] ) + / ( param_[segmentI+1] - param_[segmentI] ) + ); } diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.H b/src/mesh/blockMesh/curvedEdges/polyLine.H index 4ef97f30525b6368e3f9a0f7ddb6a4ef5107bd5b..ea8c59e389bf08cfa5a6d28c1cd5d1503342e107 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.H +++ b/src/mesh/blockMesh/curvedEdges/polyLine.H @@ -26,10 +26,8 @@ Class Foam::polyLine Description - Defines a curvedEdge in terms of a series of straight line segments. - - This is the basic polyLine class which implements just the line - (no topology - it is not derived from curvedEdge) + A series of straight line segments, which can also be interpreted as + a series of control points for splines, etc. SourceFiles polyLine.C @@ -66,15 +64,26 @@ protected: // Protected data - pointField controlPoints_; - scalarList distances_; + //- The control points or ends of each segments + pointField points_; + + //- The real line length scalar lineLength_; + //- The rational (0-1) cumulative parameter value for each point + scalarList param_; + // Protected member functions - void calcDistances(); + //- Precalculate the rational cumulative parameter value + // and the line-length + void calcParam(); + //- Return the line segment and the local parameter [0..1] + // corresponding to the global lambda [0..1] + label localParameter(scalar& lambda) const; + public: // Constructors @@ -85,9 +94,15 @@ public: // Member Functions - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar) const; + //- Return const-access to the control-points + const pointField& points() const; + + //- Return the number of line segments + label nSegments() const; + + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C index 89029d1af97726cf6895650b32e8baaa8e1bf971..1f038a78a85af3e3812bb3b0b0bf93eaa2e5c7cc 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C @@ -44,24 +44,30 @@ Foam::polyLineEdge::polyLineEdge const pointField& ps, const label start, const label end, - const pointField& otherpoints + const pointField& otherPoints ) : curvedEdge(ps, start, end), - polyLine(knotlist(ps, start, end, otherpoints)) + polyLine(appendEndPoints(ps, start_, end_, otherPoints)) {} Foam::polyLineEdge::polyLineEdge(const pointField& ps, Istream& is) : curvedEdge(ps, is), - polyLine(knotlist(ps, start_, end_, pointField(is))) + polyLine(appendEndPoints(ps, start_, end_, pointField(is))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::polyLineEdge::~polyLineEdge() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::vector Foam::polyLineEdge::position(const scalar lambda) const +Foam::point Foam::polyLineEdge::position(const scalar lambda) const { return polyLine::position(lambda); } diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H index 532a91ad5d50c265ca3b42c76033a0d04fc4725c..e941bba716183daf3c111ae92bcb1925a781c2bf 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H @@ -26,8 +26,7 @@ Class Foam::polyLineEdge Description - Defines a curvedEdge in terms of a series of straight line segments. - This is the public face of polyLine + A curvedEdge defined in terms of a series of straight line segments. SourceFiles polyLineEdge.C @@ -84,16 +83,15 @@ public: polyLineEdge(const pointField&, Istream&); - // Destructor - - virtual ~polyLineEdge(){} + //- Destructor + virtual ~polyLineEdge(); // Member Functions - //- Return the position of a point on the curve given by - // the parameter 0 <= lambda <= 1 - vector position(const scalar lambda) const; + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + point position(const scalar lambda) const; //- Return the length of the curve scalar length() const; diff --git a/src/mesh/blockMesh/curvedEdges/splineEdge.C b/src/mesh/blockMesh/curvedEdges/splineEdge.C new file mode 100644 index 0000000000000000000000000000000000000000..6c5df771a9cc19865a7b9559f571c105a547f396 --- /dev/null +++ b/src/mesh/blockMesh/curvedEdges/splineEdge.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "splineEdge.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(splineEdge, 0); + addToRunTimeSelectionTable(curvedEdge, splineEdge, Istream); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::splineEdge::splineEdge +( + const pointField& points, + const label start, + const label end, + const pointField& otherknots +) +: + curvedEdge(points, start, end), + CatmullRomSpline(appendEndPoints(points, start, end, otherknots)) +{} + + +Foam::splineEdge::splineEdge(const pointField& points, Istream& is) +: + curvedEdge(points, is), + CatmullRomSpline(appendEndPoints(points, start_, end_, pointField(is))) +{ + token t(is); + is.putBack(t); + + // might have start/end tangents that we currently ignore + if (t == token::BEGIN_LIST) + { + vector fstend(is); + vector sndend(is); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::point Foam::splineEdge::position(const scalar mu) const +{ + return CatmullRomSpline::position(mu); +} + + +Foam::scalar Foam::splineEdge::length() const +{ + return CatmullRomSpline::length(); +} + + +// ************************************************************************* // diff --git a/src/mesh/blockMesh/curvedEdges/splineEdge.H b/src/mesh/blockMesh/curvedEdges/splineEdge.H new file mode 100644 index 0000000000000000000000000000000000000000..c1ad9f5f76868be578c04c374cec87854c45b86b --- /dev/null +++ b/src/mesh/blockMesh/curvedEdges/splineEdge.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::splineEdge + +Description + A curvedEdge interface for Catmull-Rom splines. + +SourceFiles + splineEdge.C + +\*---------------------------------------------------------------------------*/ + +#ifndef splineEdge_H +#define splineEdge_H + +#include "curvedEdge.H" +#include "CatmullRomSpline.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class splineEdge Declaration +\*---------------------------------------------------------------------------*/ + +class splineEdge +: + public curvedEdge, + public CatmullRomSpline +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + splineEdge(const splineEdge&); + + //- Disallow default bitwise assignment + void operator=(const splineEdge&); + + +public: + + //- Runtime type information + TypeName("spline"); + + + // Constructors + + //- Construct from components + splineEdge + ( + const pointField&, + const label start, + const label end, + const pointField& otherKnots + ); + + //- Construct from Istream setting pointsList + splineEdge(const pointField&, Istream&); + + + // Destructor + + virtual ~splineEdge() + {} + + + // Member Functions + + //- Return the point position corresponding to the curve parameter + // 0 <= lambda <= 1 + virtual point position(const scalar) const; + + //- Return the length of the simple spline curve + virtual scalar length() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //