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
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);
108 void Foam::vtkPVblockMesh::updateInfoEdges
110 vtkDataArraySelection* arraySelection
116 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
119 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
121 const blockMesh& blkMesh = *meshPtr_;
124 const int nEdges = edges.
size();
131 ostr <<
" - " << edges[edgeI].type();
134 arraySelection->AddArray(ostr.str().c_str());
137 arrayRangeEdges_ += nEdges;
142 getSelectedArrayEntries(arraySelection);
151 const char*
const FileName,
152 vtkPVblockMeshReader* reader
158 meshRegion_(polyMesh::defaultRegion),
159 meshDir_(polyMesh::meshSubDir),
160 arrayRangeBlocks_(
"block"),
161 arrayRangeEdges_(
"edges"),
162 arrayRangeCorners_(
"corners")
170 fileName fullCasePath(fileName(FileName).path());
172 if (!
isDir(fullCasePath))
176 if (fullCasePath ==
".")
178 fullCasePath =
cwd();
182 if (fullCasePath.name().find(
"processor", 0) == 0)
184 const fileName globalCase = fullCasePath.path();
186 setEnv(
"FOAM_CASE", globalCase,
true);
187 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
191 setEnv(
"FOAM_CASE", fullCasePath,
true);
192 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
198 string caseName(fileName(FileName).lessExt());
204 beg != string::npos && caseName[beg] ==
'{' 205 && end != string::npos && end == caseName.size()-1
208 meshRegion_ = caseName.substr(beg+1, end-beg-1);
211 if (meshRegion_.empty())
213 meshRegion_ = polyMesh::defaultRegion;
216 if (meshRegion_ != polyMesh::defaultRegion)
218 meshDir_ = meshRegion_/polyMesh::meshSubDir;
224 Info<<
" fullCasePath=" << fullCasePath <<
nl 225 <<
" FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl 226 <<
" FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
234 Time::controlDictName,
235 fileName(fullCasePath.path()),
236 fileName(fullCasePath.name())
240 dbPtr_().functionObjects().off();
257 forAll(pointNumberTextActorsPtrs_, pointi)
259 pointNumberTextActorsPtrs_[pointi]->Delete();
261 pointNumberTextActorsPtrs_.
clear();
274 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"] " <<
endl;
279 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
280 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
286 bool firstTime =
false;
287 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
293 enabledParts = getSelectedArrayEntries(blockSelection);
294 enabledEdges = getSelectedArrayEntries(edgeSelection);
298 blockSelection->RemoveAllArrays();
299 edgeSelection->RemoveAllArrays();
305 updateInfoBlocks( blockSelection );
308 updateInfoEdges( edgeSelection );
313 setSelectedArrayEntries(blockSelection, enabledParts);
314 setSelectedArrayEntries(edgeSelection, enabledEdges);
319 void Foam::vtkPVblockMesh::updateFoamMesh()
332 <<
"Creating blockMesh at time=" << dbPtr_().timeName() <<
endl;
336 const word
dictName(
"blockMeshDict");
344 dbPtr_().path()/dbPtr_().constant()
354 IOdictionary* meshDictPtr =
new IOdictionary
365 meshDictPtr->store();
367 meshPtr_ =
new blockMesh(*meshDictPtr, meshRegion_);
374 vtkMultiBlockDataSet* output
377 reader_->UpdateProgress(0.1);
380 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
383 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
385 reader_->UpdateProgress(0.2);
389 reader_->UpdateProgress(0.5);
394 convertMeshCorners(output, blockNo);
395 convertMeshBlocks(output, blockNo);
396 convertMeshEdges(output, blockNo);
398 reader_->UpdateProgress(0.8);
405 reader_->UpdateProgress(1.0);
411 vtkRenderer* renderer,
417 forAll(pointNumberTextActorsPtrs_, pointi)
419 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
420 pointNumberTextActorsPtrs_[pointi]->Delete();
422 pointNumberTextActorsPtrs_.
clear();
424 if (show && meshPtr_)
426 const blockMesh& blkMesh = *meshPtr_;
427 const pointField& cornerPts = blkMesh.vertices();
428 const scalar scaleFactor = blkMesh.scaleFactor();
430 pointNumberTextActorsPtrs_.
setSize(cornerPts.size());
440 txt->SetInput(os.str().c_str());
444 vtkTextProperty* tprop = txt->GetTextProperty();
445 tprop->SetFontFamilyToArial();
448 tprop->SetLineSpacing(1.0);
449 tprop->SetFontSize(14);
450 tprop->SetColor(1.0, 0.0, 1.0);
451 tprop->SetJustificationToCentered();
454 txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
456 txt->GetPositionCoordinate()->SetValue
458 cornerPts[pointi].
x()*scaleFactor,
459 cornerPts[pointi].
y()*scaleFactor,
460 cornerPts[pointi].z()*scaleFactor
464 renderer->AddViewProp(txt);
468 pointNumberTextActorsPtrs_[pointi] = txt;
478 os << indent <<
"Number of nodes: " 479 << (meshPtr_ ? meshPtr_->nPoints() : 0) <<
"\n";
481 os << indent <<
"Number of cells: " 482 << (meshPtr_ ? meshPtr_->nCells() : 0) <<
"\n";
484 os << indent <<
"Number of available time steps: " 485 << (dbPtr_.valid() ? dbPtr_().times().size() : 0) <<
endl;
string getEnv(const word &)
Return environment variable of given name.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
#define forAll(list, i)
Loop across all elements in list.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
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.
void renderPointNumbers(vtkRenderer *, const bool show)
Add/remove point numbers to/from the view.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
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?
graph_traits< Graph >::vertices_size_type size_type
void Update(vtkMultiBlockDataSet *output)
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.
vtkPVblockMesh(const char *const FileName, vtkPVblockMeshReader *reader)
Construct from components.
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.
const word dictName("noiseDict")
int system(const std::string &command)
Execute the specified command.
#define InfoInFunction
Report an information message using Foam::Info.