27 #include "vtkPV3blockMeshReader.h" 36 #include "vtkDataArraySelection.h" 37 #include "vtkMultiBlockDataSet.h" 38 #include "vtkRenderer.h" 39 #include "vtkTextActor.h" 40 #include "vtkTextProperty.h" 52 void Foam::vtkPV3blockMesh::resetCounters()
55 arrayRangeBlocks_.reset();
56 arrayRangeEdges_.reset();
57 arrayRangeCorners_.reset();
61 void Foam::vtkPV3blockMesh::updateInfoBlocks
63 vtkDataArraySelection* arraySelection
68 Info<<
"<beg> Foam::vtkPV3blockMesh::updateInfoBlocks" 69 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"]" <<
endl;
72 arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() );
74 const blockMesh& blkMesh = *meshPtr_;
75 const int nBlocks = blkMesh.size();
76 for (
int blockI = 0; blockI < nBlocks; ++blockI)
78 const blockDescriptor& blockDef = blkMesh[blockI].blockDef();
83 if (!blockDef.zoneName().empty())
85 partName +=
" - " + blockDef.zoneName();
89 arraySelection->AddArray(partName.c_str());
92 arrayRangeBlocks_ += nBlocks;
99 Info<<
"<end> Foam::vtkPV3blockMesh::updateInfoBlocks" <<
endl;
104 void Foam::vtkPV3blockMesh::updateInfoEdges
106 vtkDataArraySelection* arraySelection
111 Info<<
"<beg> Foam::vtkPV3blockMesh::updateInfoEdges" 112 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"]" <<
endl;
115 arrayRangeEdges_.reset( arraySelection->GetNumberOfArrays() );
117 const blockMesh& blkMesh = *meshPtr_;
120 const int nEdges = edges.
size();
125 ostr<< edges[edgeI].start() <<
":" << edges[edgeI].end() <<
" - " 126 << edges[edgeI].type();
129 arraySelection->AddArray(ostr.str().c_str());
132 arrayRangeEdges_ += nEdges;
139 Info<<
"<end> Foam::vtkPV3blockMesh::updateInfoEdges" <<
endl;
146 Foam::vtkPV3blockMesh::vtkPV3blockMesh
148 const char*
const FileName,
149 vtkPV3blockMeshReader* reader
155 meshRegion_(polyMesh::defaultRegion),
156 meshDir_(polyMesh::meshSubDir),
157 arrayRangeBlocks_(
"block"),
158 arrayRangeEdges_(
"edges"),
159 arrayRangeCorners_(
"corners")
163 Info<<
"Foam::vtkPV3blockMesh::vtkPV3blockMesh - " 168 fileName fullCasePath(fileName(FileName).
path());
170 if (!
isDir(fullCasePath))
174 if (fullCasePath ==
".")
176 fullCasePath =
cwd();
180 if (fullCasePath.name().find(
"processor", 0) == 0)
182 const fileName globalCase = fullCasePath.path();
184 setEnv(
"FOAM_CASE", globalCase,
true);
185 setEnv(
"FOAM_CASENAME", globalCase.name(),
true);
189 setEnv(
"FOAM_CASE", fullCasePath,
true);
190 setEnv(
"FOAM_CASENAME", fullCasePath.name(),
true);
196 string caseName(fileName(FileName).lessExt());
202 beg != string::npos && caseName[beg] ==
'{' 203 && end != string::npos && end == caseName.size()-1
206 meshRegion_ = caseName.substr(beg+1, end-beg-1);
209 if (meshRegion_.empty())
211 meshRegion_ = polyMesh::defaultRegion;
214 if (meshRegion_ != polyMesh::defaultRegion)
216 meshDir_ = meshRegion_/polyMesh::meshSubDir;
222 Info<<
"fullCasePath=" << fullCasePath <<
nl 223 <<
"FOAM_CASE=" <<
getEnv(
"FOAM_CASE") <<
nl 224 <<
"FOAM_CASENAME=" <<
getEnv(
"FOAM_CASENAME") <<
endl;
232 Time::controlDictName,
233 fileName(fullCasePath.path()),
234 fileName(fullCasePath.name())
238 dbPtr_().functionObjects().off();
250 Info<<
"<end> Foam::vtkPV3blockMesh::~vtkPV3blockMesh" <<
endl;
255 forAll(pointNumberTextActorsPtrs_, pointi)
257 pointNumberTextActorsPtrs_[pointi]->Delete();
259 pointNumberTextActorsPtrs_.
clear();
271 Info<<
"<beg> Foam::vtkPV3blockMesh::updateInfo" 272 <<
" [meshPtr=" << (meshPtr_ ?
"set" :
"NULL") <<
"] " <<
endl;
277 vtkDataArraySelection* blockSelection = reader_->GetBlockSelection();
278 vtkDataArraySelection* edgeSelection = reader_->GetCurvedEdgesSelection();
284 bool firstTime =
false;
285 if (!blockSelection->GetNumberOfArrays() && !meshPtr_)
291 enabledParts = getSelectedArrayEntries(blockSelection);
292 enabledEdges = getSelectedArrayEntries(edgeSelection);
296 blockSelection->RemoveAllArrays();
297 edgeSelection->RemoveAllArrays();
303 updateInfoBlocks( blockSelection );
306 updateInfoEdges( edgeSelection );
311 setSelectedArrayEntries(blockSelection, enabledParts);
312 setSelectedArrayEntries(edgeSelection, enabledEdges);
317 Info<<
"<end> Foam::vtkPV3blockMesh::updateInfo" <<
endl;
322 void Foam::vtkPV3blockMesh::updateFoamMesh()
326 Info<<
"<beg> Foam::vtkPV3blockMesh::updateFoamMesh" <<
endl;
334 Info<<
"Creating blockMesh at time=" << dbPtr_().timeName()
339 const word
dictName(
"blockMeshDict");
347 dbPtr_().
path()/dbPtr_().constant()
355 IOdictionary meshDict
367 meshPtr_ =
new blockMesh(meshDict, meshRegion_);
373 Info<<
"<end> Foam::vtkPV3blockMesh::updateFoamMesh" <<
endl;
380 vtkMultiBlockDataSet* output
383 reader_->UpdateProgress(0.1);
386 updateBoolListStatus(blockStatus_, reader_->GetBlockSelection());
389 updateBoolListStatus(edgeStatus_, reader_->GetCurvedEdgesSelection());
391 reader_->UpdateProgress(0.2);
395 reader_->UpdateProgress(0.5);
400 convertMeshCorners(output, blockNo);
401 convertMeshBlocks(output, blockNo);
402 convertMeshEdges(output, blockNo);
404 reader_->UpdateProgress(0.8);
411 reader_->UpdateProgress(1.0);
417 vtkRenderer* renderer,
423 forAll(pointNumberTextActorsPtrs_, pointi)
425 renderer->RemoveViewProp(pointNumberTextActorsPtrs_[pointi]);
426 pointNumberTextActorsPtrs_[pointi]->Delete();
428 pointNumberTextActorsPtrs_.
clear();
430 if (show && meshPtr_)
433 const scalar scaleFactor = meshPtr_->
scaleFactor();
435 pointNumberTextActorsPtrs_.
setSize(cornerPts.size());
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.
scalar scaleFactor() const
The scaling factor used to convert to metres.
#define forAll(list, i)
Loop across all elements in list.
PtrList< curvedEdge > curvedEdgeList
A PtrList of curvedEdges.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
~vtkPV3blockMesh()
Destructor.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
vectorField pointField
pointField is a vectorField.
stringList getSelectedArrayEntries(vtkDataArraySelection *)
Retrieve the current selections.
void clear()
Clear the list, i.e. set size to zero.
void PrintSelf(ostream &, vtkIndent) const
Debug information.
const pointField & blockPointField() const
Reference to point field defining the block mesh.
graph_traits< Graph >::vertices_size_type size_type
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
void Update(vtkMultiBlockDataSet *output)
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
List< string > stringList
A List of strings.
void setSize(const label)
Reset size of List.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
word dictName("noiseDict")
fileName cwd()
Return current working directory path name.
void renderPointNumbers(vtkRenderer *, const bool show)
Add/remove point numbers to/from the view.
bool setEnv(const word &name, const std::string &value, const bool overwrite)
Set an environment variable.
void CleanUp()
Clean any storage.
int system(const std::string &command)
Execute the specified command.
label size() const
Return the number of elements in the UPtrList.