mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
MRG: Integrated foundation code
This commit is contained in:
@ -79,9 +79,9 @@ ENDIF()
|
||||
TARGET_LINK_LIBRARIES(
|
||||
PVblockMeshReader_SM
|
||||
LINK_PUBLIC
|
||||
OpenFOAM
|
||||
blockMesh
|
||||
vtkPVblockMesh
|
||||
blockMesh
|
||||
OpenFOAM
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@ -30,16 +30,17 @@
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
<!-- Update GUI check box -->
|
||||
<!-- Refresh button -->
|
||||
<IntVectorProperty
|
||||
name="UpdateGUI"
|
||||
command="SetUpdateGUI"
|
||||
name="UiRefresh"
|
||||
command="SetRefresh"
|
||||
number_of_elements="1"
|
||||
is_internal="0"
|
||||
default_values="0"
|
||||
animateable="0">
|
||||
<BooleanDomain name="bool"/>
|
||||
<Documentation>
|
||||
A simple way to cause a reader GUI modification.
|
||||
Rescan for updated blockMeshDict.
|
||||
</Documentation>
|
||||
</IntVectorProperty>
|
||||
|
||||
@ -102,6 +103,7 @@
|
||||
|
||||
<Hints>
|
||||
<Property name="FileName" show="0"/>
|
||||
<Property name="UiRefresh" show="0"/>
|
||||
<Property name="UiShowPointNumbers" show="0"/>
|
||||
<ReaderFactory extensions="blockMesh"
|
||||
file_description="OpenFOAM blockMesh"/>
|
||||
|
||||
@ -58,12 +58,30 @@ pqPVblockMeshReaderPanel::pqPVblockMeshReaderPanel
|
||||
:
|
||||
pqAutoGeneratedObjectPanel(proxy, p)
|
||||
{
|
||||
// create first sublayout (at top of the panel)
|
||||
// Create first sublayout (at top of the panel)
|
||||
QGridLayout *form = new QGridLayout();
|
||||
this->PanelLayout->addLayout(form, 0, 0, 1, -1);
|
||||
|
||||
vtkSMProperty* prop = 0;
|
||||
// checkbox for showing point numbers
|
||||
|
||||
// Refresh button for updating blocks
|
||||
if ((prop = this->proxy()->GetProperty("UiRefresh")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(1);
|
||||
QPushButton* refresh = new QPushButton("Refresh");
|
||||
refresh->setToolTip("Rescan for updated blockMeshDict.");
|
||||
|
||||
form->addWidget(refresh, 0, 0, Qt::AlignLeft);
|
||||
QObject::connect
|
||||
(
|
||||
refresh,
|
||||
SIGNAL(clicked()),
|
||||
this,
|
||||
SLOT(RefreshPressed())
|
||||
);
|
||||
}
|
||||
|
||||
// Checkbox for showing point numbers
|
||||
if ((prop = this->proxy()->GetProperty("UiShowPointNumbers")) != 0)
|
||||
{
|
||||
prop->SetImmediateUpdate(true);
|
||||
@ -97,7 +115,7 @@ void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
|
||||
this->proxy()->GetProperty("UiShowPointNumbers")
|
||||
)->SetElement(0, ShowPointNumbers_->isChecked());
|
||||
|
||||
// update the active view
|
||||
// Update the active view
|
||||
if (this->view())
|
||||
{
|
||||
this->view()->render();
|
||||
@ -107,4 +125,19 @@ void pqPVblockMeshReaderPanel::ShowPointNumbersToggled()
|
||||
}
|
||||
|
||||
|
||||
void pqPVblockMeshReaderPanel::RefreshPressed()
|
||||
{
|
||||
// Update everything
|
||||
vtkSMIntVectorProperty::SafeDownCast
|
||||
(
|
||||
this->proxy()->GetProperty("UiRefresh")
|
||||
)->Modified();
|
||||
|
||||
vtkSMSourceProxy::SafeDownCast(this->proxy())->UpdatePipeline();
|
||||
|
||||
// Render all views
|
||||
pqApplicationCore::instance()->render();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -67,6 +67,7 @@ class pqPVblockMeshReaderPanel
|
||||
protected slots:
|
||||
|
||||
void ShowPointNumbersToggled();
|
||||
void RefreshPressed();
|
||||
|
||||
|
||||
public:
|
||||
@ -75,10 +76,6 @@ public:
|
||||
|
||||
//- Construct from components
|
||||
pqPVblockMeshReaderPanel(pqProxy*, QWidget*);
|
||||
|
||||
|
||||
//- Destructor
|
||||
// virtual ~pqPVblockMeshReaderPanel();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -60,7 +60,6 @@ vtkPVblockMeshReader::vtkPVblockMeshReader()
|
||||
foamData_ = nullptr;
|
||||
|
||||
ShowPointNumbers = 1;
|
||||
UpdateGUI = 0;
|
||||
|
||||
BlockSelection = vtkDataArraySelection::New();
|
||||
CurvedEdgesSelection = vtkDataArraySelection::New();
|
||||
@ -97,7 +96,7 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
|
||||
if (foamData_)
|
||||
{
|
||||
// remove point numbers
|
||||
// Remove point numbers
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
}
|
||||
@ -117,7 +116,6 @@ vtkPVblockMeshReader::~vtkPVblockMeshReader()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
// Do everything except set the output info
|
||||
int vtkPVblockMeshReader::RequestInformation
|
||||
(
|
||||
vtkInformation* vtkNotUsed(request),
|
||||
@ -158,23 +156,10 @@ int vtkPVblockMeshReader::RequestInformation
|
||||
foamData_->updateInfo();
|
||||
}
|
||||
|
||||
// might need some other type of error handling
|
||||
|
||||
// {
|
||||
// vtkErrorMacro("could not find valid OpenFOAM blockMesh");
|
||||
//
|
||||
// // delete foamData and flag it as fatal error
|
||||
// delete foamData_;
|
||||
// foamData_ = nullptr;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Set the output info
|
||||
int vtkPVblockMeshReader::RequestData
|
||||
(
|
||||
vtkInformation* vtkNotUsed(request),
|
||||
@ -190,7 +175,7 @@ int vtkPVblockMeshReader::RequestData
|
||||
return 0;
|
||||
}
|
||||
|
||||
// catch previous error
|
||||
// Catch previous error
|
||||
if (!foamData_)
|
||||
{
|
||||
vtkErrorMacro("Reader failed - perhaps no mesh?");
|
||||
@ -233,6 +218,19 @@ int vtkPVblockMeshReader::RequestData
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetRefresh(int val)
|
||||
{
|
||||
// Delete the current blockMesh to force re-read and update
|
||||
if (foamData_)
|
||||
{
|
||||
updatePointNumbersView(false);
|
||||
delete foamData_;
|
||||
foamData_ = 0;
|
||||
}
|
||||
|
||||
Modified();
|
||||
}
|
||||
|
||||
|
||||
void vtkPVblockMeshReader::SetShowPointNumbers(const int val)
|
||||
{
|
||||
@ -248,7 +246,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
{
|
||||
pqApplicationCore* appCore = pqApplicationCore::instance();
|
||||
|
||||
// need to check this, since our destructor calls this
|
||||
// Need to check this, since our destructor calls this
|
||||
if (!appCore)
|
||||
{
|
||||
return;
|
||||
@ -273,7 +271,7 @@ void vtkPVblockMeshReader::updatePointNumbersView(const bool show)
|
||||
);
|
||||
}
|
||||
|
||||
// use refresh here?
|
||||
// Use refresh here?
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -77,10 +77,8 @@ public:
|
||||
vtkGetMacro(ShowPointNumbers, int);
|
||||
|
||||
// Description:
|
||||
// GUI update control
|
||||
vtkSetMacro(UpdateGUI, int);
|
||||
vtkGetMacro(UpdateGUI, int);
|
||||
|
||||
// Refresh blockMesh from changes to blockMeshDict
|
||||
virtual void SetRefresh(int);
|
||||
|
||||
// Description:
|
||||
// Blocks selection list control
|
||||
@ -158,9 +156,6 @@ private:
|
||||
//- Show Point Numbers
|
||||
int ShowPointNumbers;
|
||||
|
||||
//- Dummy variable/switch to invoke a reader update
|
||||
int UpdateGUI;
|
||||
|
||||
vtkDataArraySelection* BlockSelection;
|
||||
|
||||
vtkDataArraySelection* CurvedEdgesSelection;
|
||||
|
||||
@ -72,12 +72,17 @@ void Foam::vtkPVblockMesh::updateInfoBlocks
|
||||
arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
|
||||
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
|
||||
const int nBlocks = blkMesh.size();
|
||||
for (int blockI = 0; blockI < nBlocks; ++blockI)
|
||||
{
|
||||
const blockDescriptor& blockDef = blkMesh[blockI];
|
||||
|
||||
word partName = Foam::name(blockI);
|
||||
// Display either blockI as a number or with its name
|
||||
// (looked up from blockMeshDict)
|
||||
OStringStream os;
|
||||
blockDescriptor::write(os, blockI, blkMesh.meshDict());
|
||||
word partName(os.str());
|
||||
|
||||
// append the (optional) zone name
|
||||
if (!blockDef.zoneName().empty())
|
||||
@ -121,9 +126,10 @@ void Foam::vtkPVblockMesh::updateInfoEdges
|
||||
forAll(edges, edgeI)
|
||||
{
|
||||
OStringStream ostr;
|
||||
|
||||
ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - "
|
||||
<< edges[edgeI].type();
|
||||
blockVertex::write(ostr, edges[edgeI].start(), blkMesh.meshDict());
|
||||
ostr<< ":";
|
||||
blockVertex::write(ostr, edges[edgeI].end(), blkMesh.meshDict());
|
||||
ostr << " - " << edges[edgeI].type();
|
||||
|
||||
// Add "beg:end - type" to GUI list
|
||||
arraySelection->AddArray(ostr.str().c_str());
|
||||
@ -352,7 +358,9 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
dictPath = dbPtr_().constant()/polyMesh::meshSubDir/dictName;
|
||||
}
|
||||
|
||||
IOdictionary meshDict
|
||||
// Store dictionary since is used as database inside blockMesh class
|
||||
// for names of vertices and blocks
|
||||
IOdictionary* meshDictPtr = new IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -360,11 +368,12 @@ void Foam::vtkPVblockMesh::updateFoamMesh()
|
||||
dbPtr_(),
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
true
|
||||
)
|
||||
);
|
||||
meshDictPtr->store();
|
||||
|
||||
meshPtr_ = new blockMesh(meshDict, meshRegion_);
|
||||
meshPtr_ = new blockMesh(*meshDictPtr, meshRegion_);
|
||||
}
|
||||
|
||||
|
||||
@ -429,15 +438,22 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
||||
|
||||
if (show && meshPtr_)
|
||||
{
|
||||
const pointField& cornerPts = meshPtr_->vertices();
|
||||
const scalar scaleFactor = meshPtr_->scaleFactor();
|
||||
const blockMesh& blkMesh = *meshPtr_;
|
||||
const pointField& cornerPts = blkMesh.vertices();
|
||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||
|
||||
pointNumberTextActorsPtrs_.setSize(cornerPts.size());
|
||||
forAll(cornerPts, pointi)
|
||||
{
|
||||
vtkTextActor* txt = vtkTextActor::New();
|
||||
|
||||
txt->SetInput(Foam::name(pointi).c_str());
|
||||
// Display either pointi as a number or with its name
|
||||
// (looked up from blockMeshDict)
|
||||
{
|
||||
OStringStream os;
|
||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||
txt->SetInput(os.str().c_str());
|
||||
}
|
||||
|
||||
// Set text properties
|
||||
vtkTextProperty* tprop = txt->GetTextProperty();
|
||||
|
||||
Reference in New Issue
Block a user