27 #include "vtkPVblockMeshReader.h" 36 #include "vtkDataArraySelection.h" 37 #include "vtkMultiBlockDataSet.h" 38 #include "vtkRenderer.h" 39 #include "vtkTextActor.h" 40 #include "vtkTextProperty.h" 52 void Foam::vtkPVblockMesh::resetCounters()
55 arrayRangeBlocks_.reset();
56 arrayRangeEdges_.reset();
57 arrayRangeCorners_.reset();
61 void Foam::vtkPVblockMesh::updateInfoBlocks
63 vtkDataArraySelection* arraySelection
68 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfoBlocks" 69 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
72 arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
74 const blockMesh& blkMesh = *meshPtr_;
76 const int nBlocks = blkMesh.size();
77 for (
int blockI = 0; blockI < nBlocks; ++blockI)
79 const blockDescriptor& blockDef = blkMesh[blockI];
85 word partName(os.str());
88 if (!blockDef.zoneName().empty())
90 partName +=
" - " + blockDef.zoneName();
94 arraySelection->AddArray(partName.c_str());
97 arrayRangeBlocks_ += nBlocks;
102 getSelectedArrayEntries(arraySelection);
104 Info<<
"<end> Foam::vtkPVblockMesh::updateInfoBlocks" <<
endl;
109 void Foam::vtkPVblockMesh::updateInfoEdges
111 vtkDataArraySelection* arraySelection
116 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfoEdges" 117 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
120 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
122 const blockMesh& blkMesh = *meshPtr_;
125 const int nEdges = edges.
size();
132 ostr <<
" - " << edges[edgeI].type();
135 arraySelection->AddArray(ostr.str().c_str());
138 arrayRangeEdges_ += nEdges;
143 getSelectedArrayEntries(arraySelection);
145 Info<<
"<end> Foam::vtkPVblockMesh::updateInfoEdges" <<
endl;
152 Foam::vtkPVblockMesh::vtkPVblockMesh
154 const char*
const FileName,
155 vtkPVblockMeshReader* reader
161 meshRegion_(polyMesh::defaultRegion),
162 meshDir_(polyMesh::meshSubDir),
163 arrayRangeBlocks_(
"block"),
164 arrayRangeEdges_(
"edges"),
165 arrayRangeCorners_(
"corners")
169 Info<<
"Foam::vtkPVblockMesh::vtkPVblockMesh - " 174 fileName fullCasePath(fileName(FileName).
path());
176 if (!
isDir(fullCasePath))
180 if (fullCasePath ==
".")
182 fullCasePath =
cwd();
186 if (fullCasePath.name().find(
"processor", 0) == 0)
188 const fileName globalCase = fullCasePath.path();
190 setEnv(
"FOAM_CASE", globalCase,
true);
191 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
195 setEnv(
"FOAM_CASE", fullCasePath,
true);
196 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
202 string caseName(fileName(FileName).lessExt());
208 beg != string::npos && caseName[beg] ==
'{' 209 && end != string::npos && end == caseName.size()-1
212 meshRegion_ = caseName.substr(beg+1, end-beg-1);
215 if (meshRegion_.empty())
217 meshRegion_ = polyMesh::defaultRegion;
220 if (meshRegion_ != polyMesh::defaultRegion)
222 meshDir_ = meshRegion_/polyMesh::meshSubDir;
228 Info<<
"fullCasePath=" << fullCasePath <<
nl 229 <<
"FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl 230 <<
"FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
238 Time::controlDictName,
239 fileName(fullCasePath.path()),
240 fileName(fullCasePath.name())
244 dbPtr_().functionObjects().off();
256 Info<<
"<end> Foam::vtkPVblockMesh::~vtkPVblockMesh" <<
endl;
261 forAll(pointNumberTextActorsPtrs_, pointi)
263 pointNumberTextActorsPtrs_[pointi]->Delete();
265 pointNumberTextActorsPtrs_.
clear();
277 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfo" 278 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"] " <<
endl;
283 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
284 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
290 bool firstTime =
false;
291 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
297 enabledParts = getSelectedArrayEntries(blockSelection);
298 enabledEdges = getSelectedArrayEntries(edgeSelection);
302 blockSelection->RemoveAllArrays();
303 edgeSelection->RemoveAllArrays();
309 updateInfoBlocks( blockSelection );
312 updateInfoEdges( edgeSelection );
317 setSelectedArrayEntries(blockSelection, enabledParts);
318 setSelectedArrayEntries(edgeSelection, enabledEdges);
323 Info<<
"<end> Foam::vtkPVblockMesh::updateInfo" <<
endl;
328 void Foam::vtkPVblockMesh::updateFoamMesh()
332 Info<<
"<beg> Foam::vtkPVblockMesh::updateFoamMesh" <<
endl;
340 Info<<
"Creating blockMesh at time=" << dbPtr_().timeName()
345 const word
dictName(
"blockMeshDict");
353 dbPtr_().
path()/dbPtr_().constant()
363 IOdictionary* meshDictPtr =
new IOdictionary
374 meshDictPtr->store();
376 meshPtr_ =
new blockMesh(*meshDictPtr, meshRegion_);
382 Info<<
"<end> Foam::vtkPVblockMesh::updateFoamMesh" <<
endl;
389 vtkMultiBlockDataSet* output
392 reader_->UpdateProgress(0.1);
395 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
398 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
400 reader_->UpdateProgress(0.2);
404 reader_->UpdateProgress(0.5);
409 convertMeshCorners(output, blockNo);
410 convertMeshBlocks(output, blockNo);
411 convertMeshEdges(output, blockNo);
413 reader_->UpdateProgress(0.8);
420 reader_->UpdateProgress(1.0);
426 vtkRenderer* renderer,
432 forAll(pointNumberTextActorsPtrs_, pointi)
434 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
435 pointNumberTextActorsPtrs_[pointi]->Delete();
437 pointNumberTextActorsPtrs_.
clear();
439 if (show && meshPtr_)
441 const blockMesh& blkMesh = *meshPtr_;
442 const pointField& cornerPts = blkMesh.vertices();
443 const scalar scaleFactor = blkMesh.scaleFactor();
445 pointNumberTextActorsPtrs_.
setSize(cornerPts.size());
455 txt->SetInput(os.str().c_str());
459 vtkTextProperty* tprop = txt->GetTextProperty();
460 tprop->SetFontFamilyToArial();
463 tprop->SetLineSpacing(1.0);
464 tprop->SetFontSize(14);
465 tprop->SetColor(1.0, 0.0, 1.0);
466 tprop->SetJustificationToCentered();
469 txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
471 txt->GetPositionCoordinate()->SetValue
473 cornerPts[pointi].
x()*scaleFactor,
474 cornerPts[pointi].
y()*scaleFactor,
475 cornerPts[pointi].z()*scaleFactor
479 renderer->AddViewProp(txt);
483 pointNumberTextActorsPtrs_[pointi] = txt;
493 os << indent <<
"Number of nodes: " 494 << (meshPtr_ ? meshPtr_->nPoints() : 0) <<
"\n";
496 os << indent <<
"Number of cells: " 497 << (meshPtr_ ? meshPtr_->nCells() : 0) <<
"\n";
499 os << indent <<
"Number of available time steps: " 500 << (dbPtr_.valid() ? dbPtr_().times().size() : 0) <<
endl;
string getEnv(const word &)
Return environment variable of given name.
#define forAll(list, i)
Loop across all elements in list.
void PrintSelf(ostream &, vtkIndent) const
Debug information.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
void renderPointNumbers(vtkRenderer *, const bool show)
Add/remove point numbers to/from the view.
vectorField pointField
pointField is a vectorField.
void clear()
Clear the list, i.e. set size to zero.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
const word dictName("particleTrackDict")
graph_traits< Graph >::vertices_size_type size_type
void Update(vtkMultiBlockDataSet *output)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
~vtkPVblockMesh()
Destructor.
label size() const
Return the number of elements in the UPtrList.
List< string > stringList
A List of strings.
void setSize(const label)
Reset size of List.
void CleanUp()
Clean any storage.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
fileName cwd()
Return current working directory path name.
static void write(Ostream &, const label, const dictionary &)
Write vertex index with optional name backsubstitution.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
int system(const std::string &command)
Execute the specified command.