27 #include "vtkPVblockMeshReader.h" 37 #include "vtkDataArraySelection.h" 38 #include "vtkMultiBlockDataSet.h" 39 #include "vtkRenderer.h" 40 #include "vtkTextActor.h" 41 #include "vtkTextProperty.h" 53 void Foam::vtkPVblockMesh::resetCounters()
56 arrayRangeBlocks_.reset();
57 arrayRangeEdges_.reset();
58 arrayRangeCorners_.reset();
62 void Foam::vtkPVblockMesh::updateInfoBlocks
64 vtkDataArraySelection* arraySelection
69 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfoBlocks" 70 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
73 arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
75 const blockMesh& blkMesh = *meshPtr_;
77 const int nBlocks = blkMesh.size();
78 for (
int blockI = 0; blockI < nBlocks; ++blockI)
80 const blockDescriptor& blockDef = blkMesh[blockI];
86 word partName(os.str());
89 if (!blockDef.zoneName().empty())
91 partName +=
" - " + blockDef.zoneName();
95 arraySelection->AddArray(partName.c_str());
98 arrayRangeBlocks_ += nBlocks;
103 getSelectedArrayEntries(arraySelection);
105 Info<<
"<end> Foam::vtkPVblockMesh::updateInfoBlocks" <<
endl;
110 void Foam::vtkPVblockMesh::updateInfoEdges
112 vtkDataArraySelection* arraySelection
117 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfoEdges" 118 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
121 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
123 const blockMesh& blkMesh = *meshPtr_;
126 const int nEdges = edges.
size();
133 ostr <<
" - " << edges[edgeI].type();
136 arraySelection->AddArray(ostr.str().c_str());
139 arrayRangeEdges_ += nEdges;
144 getSelectedArrayEntries(arraySelection);
146 Info<<
"<end> Foam::vtkPVblockMesh::updateInfoEdges" <<
endl;
153 Foam::vtkPVblockMesh::vtkPVblockMesh
155 const char*
const FileName,
156 vtkPVblockMeshReader* reader
162 meshRegion_(polyMesh::defaultRegion),
163 meshDir_(polyMesh::meshSubDir),
164 arrayRangeBlocks_(
"block"),
165 arrayRangeEdges_(
"edges"),
166 arrayRangeCorners_(
"corners")
170 Info<<
"Foam::vtkPVblockMesh::vtkPVblockMesh - " 177 fileOperations::collatedFileOperation::maxThreadFileBufferSize = 0;
181 fileName fullCasePath(fileName(FileName).
path());
183 if (!
isDir(fullCasePath))
187 if (fullCasePath ==
".")
189 fullCasePath =
cwd();
193 if (fullCasePath.name().find(
"processor", 0) == 0)
195 const fileName globalCase = fullCasePath.path();
197 setEnv(
"FOAM_CASE", globalCase,
true);
198 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
202 setEnv(
"FOAM_CASE", fullCasePath,
true);
203 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
209 string caseName(fileName(FileName).lessExt());
215 beg != string::npos && caseName[beg] ==
'{' 216 && end != string::npos && end == caseName.size()-1
219 meshRegion_ = caseName.substr(beg+1, end-beg-1);
222 if (meshRegion_.empty())
224 meshRegion_ = polyMesh::defaultRegion;
227 if (meshRegion_ != polyMesh::defaultRegion)
229 meshDir_ = meshRegion_/polyMesh::meshSubDir;
235 Info<<
"fullCasePath=" << fullCasePath <<
nl 236 <<
"FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl 237 <<
"FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
245 Time::controlDictName,
246 fileName(fullCasePath.path()),
247 fileName(fullCasePath.name())
251 dbPtr_().functionObjects().off();
263 Info<<
"<end> Foam::vtkPVblockMesh::~vtkPVblockMesh" <<
endl;
268 forAll(pointNumberTextActorsPtrs_, pointi)
270 pointNumberTextActorsPtrs_[pointi]->Delete();
272 pointNumberTextActorsPtrs_.
clear();
284 Info<<
"<beg> Foam::vtkPVblockMesh::updateInfo" 285 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"] " <<
endl;
290 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
291 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
297 bool firstTime =
false;
298 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
304 enabledParts = getSelectedArrayEntries(blockSelection);
305 enabledEdges = getSelectedArrayEntries(edgeSelection);
309 blockSelection->RemoveAllArrays();
310 edgeSelection->RemoveAllArrays();
316 updateInfoBlocks( blockSelection );
319 updateInfoEdges( edgeSelection );
324 setSelectedArrayEntries(blockSelection, enabledParts);
325 setSelectedArrayEntries(edgeSelection, enabledEdges);
330 Info<<
"<end> Foam::vtkPVblockMesh::updateInfo" <<
endl;
335 void Foam::vtkPVblockMesh::updateFoamMesh()
339 Info<<
"<beg> Foam::vtkPVblockMesh::updateFoamMesh" <<
endl;
347 Info<<
"Creating blockMesh at time=" << dbPtr_().timeName()
352 const word
dictName(
"blockMeshDict");
360 dbPtr_().
path()/dbPtr_().constant()
370 IOdictionary* meshDictPtr =
new IOdictionary
381 meshDictPtr->store();
383 meshPtr_ =
new blockMesh(*meshDictPtr, meshRegion_);
389 Info<<
"<end> Foam::vtkPVblockMesh::updateFoamMesh" <<
endl;
396 vtkMultiBlockDataSet* output
399 reader_->UpdateProgress(0.1);
402 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
405 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
407 reader_->UpdateProgress(0.2);
411 reader_->UpdateProgress(0.5);
416 convertMeshCorners(output, blockNo);
417 convertMeshBlocks(output, blockNo);
418 convertMeshEdges(output, blockNo);
420 reader_->UpdateProgress(0.8);
427 reader_->UpdateProgress(1.0);
433 vtkRenderer* renderer,
439 forAll(pointNumberTextActorsPtrs_, pointi)
441 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
442 pointNumberTextActorsPtrs_[pointi]->Delete();
444 pointNumberTextActorsPtrs_.
clear();
446 if (show && meshPtr_)
448 const blockMesh& blkMesh = *meshPtr_;
449 const pointField& cornerPts = blkMesh.vertices();
450 const scalar scaleFactor = blkMesh.scaleFactor();
452 pointNumberTextActorsPtrs_.
setSize(cornerPts.size());
462 txt->SetInput(os.str().c_str());
466 vtkTextProperty* tprop = txt->GetTextProperty();
467 tprop->SetFontFamilyToArial();
470 tprop->SetLineSpacing(1.0);
471 tprop->SetFontSize(14);
472 tprop->SetColor(1.0, 0.0, 1.0);
473 tprop->SetJustificationToCentered();
476 txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
478 txt->GetPositionCoordinate()->SetValue
480 cornerPts[pointi].
x()*scaleFactor,
481 cornerPts[pointi].
y()*scaleFactor,
482 cornerPts[pointi].z()*scaleFactor
486 renderer->AddViewProp(txt);
490 pointNumberTextActorsPtrs_[pointi] = txt;
500 os << indent <<
"Number of nodes: " 501 << (meshPtr_ ? meshPtr_->nPoints() : 0) <<
"\n";
503 os << indent <<
"Number of cells: " 504 << (meshPtr_ ? meshPtr_->nCells() : 0) <<
"\n";
506 os << indent <<
"Number of available time steps: " 507 << (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.