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
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);
107 void Foam::vtkPVblockMesh::updateInfoEdges
109 vtkDataArraySelection* arraySelection
115 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"]" <<
endl;
118 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
120 const blockMesh& blkMesh = *meshPtr_;
123 const int nEdges = edges.
size();
130 ostr <<
" - " << edges[edgeI].type();
133 arraySelection->AddArray(ostr.str().c_str());
136 arrayRangeEdges_ += nEdges;
141 getSelectedArrayEntries(arraySelection);
150 const char*
const FileName,
151 vtkPVblockMeshReader* reader
157 meshRegion_(polyMesh::defaultRegion),
158 meshDir_(polyMesh::meshSubDir),
159 arrayRangeBlocks_(
"block"),
160 arrayRangeEdges_(
"edges"),
161 arrayRangeCorners_(
"corners")
169 fileName fullCasePath(fileName(FileName).
path());
171 if (!
isDir(fullCasePath))
175 if (fullCasePath ==
".")
177 fullCasePath =
cwd();
181 if (fullCasePath.name().find(
"processor", 0) == 0)
183 const fileName globalCase = fullCasePath.path();
185 setEnv(
"FOAM_CASE", globalCase,
true);
186 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
190 setEnv(
"FOAM_CASE", fullCasePath,
true);
191 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
197 string caseName(fileName(FileName).lessExt());
203 beg != string::npos && caseName[beg] ==
'{' 204 && end != string::npos && end == caseName.size()-1
207 meshRegion_ = caseName.substr(beg+1, end-beg-1);
210 if (meshRegion_.empty())
212 meshRegion_ = polyMesh::defaultRegion;
215 if (meshRegion_ != polyMesh::defaultRegion)
217 meshDir_ = meshRegion_/polyMesh::meshSubDir;
223 Info<<
" fullCasePath=" << fullCasePath <<
nl 224 <<
" FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl 225 <<
" FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
233 Time::controlDictName,
234 fileName(fullCasePath.path()),
235 fileName(fullCasePath.name())
239 dbPtr_().functionObjects().off();
256 forAll(pointNumberTextActorsPtrs_, pointi)
258 pointNumberTextActorsPtrs_[pointi]->Delete();
260 pointNumberTextActorsPtrs_.
clear();
273 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"nullptr") <<
"] " <<
endl;
278 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
279 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
285 bool firstTime =
false;
286 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
292 enabledParts = getSelectedArrayEntries(blockSelection);
293 enabledEdges = getSelectedArrayEntries(edgeSelection);
297 blockSelection->RemoveAllArrays();
298 edgeSelection->RemoveAllArrays();
304 updateInfoBlocks( blockSelection );
307 updateInfoEdges( edgeSelection );
312 setSelectedArrayEntries(blockSelection, enabledParts);
313 setSelectedArrayEntries(edgeSelection, enabledEdges);
318 void Foam::vtkPVblockMesh::updateFoamMesh()
331 <<
"Creating blockMesh at time=" << dbPtr_().timeName() <<
endl;
335 const word
dictName(
"blockMeshDict");
343 dbPtr_().
path()/dbPtr_().constant()
353 IOdictionary* meshDictPtr =
new IOdictionary
364 meshDictPtr->store();
366 meshPtr_ =
new blockMesh(*meshDictPtr, meshRegion_);
373 vtkMultiBlockDataSet* output
376 reader_->UpdateProgress(0.1);
379 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
382 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
384 reader_->UpdateProgress(0.2);
388 reader_->UpdateProgress(0.5);
393 convertMeshCorners(output, blockNo);
394 convertMeshBlocks(output, blockNo);
395 convertMeshEdges(output, blockNo);
397 reader_->UpdateProgress(0.8);
404 reader_->UpdateProgress(1.0);
410 vtkRenderer* renderer,
416 forAll(pointNumberTextActorsPtrs_, pointi)
418 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
419 pointNumberTextActorsPtrs_[pointi]->Delete();
421 pointNumberTextActorsPtrs_.
clear();
423 if (show && meshPtr_)
425 const blockMesh& blkMesh = *meshPtr_;
426 const pointField& cornerPts = blkMesh.vertices();
427 const scalar scaleFactor = blkMesh.scaleFactor();
429 pointNumberTextActorsPtrs_.
setSize(cornerPts.size());
439 txt->SetInput(os.str().c_str());
443 vtkTextProperty* tprop = txt->GetTextProperty();
444 tprop->SetFontFamilyToArial();
447 tprop->SetLineSpacing(1.0);
448 tprop->SetFontSize(14);
449 tprop->SetColor(1.0, 0.0, 1.0);
450 tprop->SetJustificationToCentered();
453 txt->GetPositionCoordinate()->SetCoordinateSystemToWorld();
455 txt->GetPositionCoordinate()->SetValue
457 cornerPts[pointi].
x()*scaleFactor,
458 cornerPts[pointi].
y()*scaleFactor,
459 cornerPts[pointi].z()*scaleFactor
463 renderer->AddViewProp(txt);
467 pointNumberTextActorsPtrs_[pointi] = txt;
477 os << indent <<
"Number of nodes: " 478 << (meshPtr_ ? meshPtr_->nPoints() : 0) <<
"\n";
480 os << indent <<
"Number of cells: " 481 << (meshPtr_ ? meshPtr_->nCells() : 0) <<
"\n";
483 os << indent <<
"Number of available time steps: " 484 << (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.
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.
vectorField pointField
pointField is a vectorField.
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
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)
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.
int system(const std::string &command)
Execute the specified command.
fileName path(UMean.rootPath()/UMean.caseName()/functionObjects::writeFile::outputPrefix/"graphs"/UMean.instance())
#define InfoInFunction
Report an information message using Foam::Info.