30 #include <vtkCellData.h> 31 #include <vtkCellType.h> 32 #include <vtkFieldData.h> 42 # include <meshOptimizer.H> 43 # include <polyMeshGenModifier.H> 65 outputStream <<
"------------- Shape Quality Statistics -------------\n\n";
66 outputStream <<
"Cell Type" << std::setw(16) <<
"Num Cells" << std::setw(16)
67 <<
"Minimum" << std::setw(16) <<
"Maximum" << std::setw(16)
68 <<
"Average" << std::setw(16) <<
"Variance" << std::endl;
70 for (
int i = 0; i < 4; ++i) {
72 outputStream <<
"Tri" << std::setw(16);
74 outputStream <<
"Quad" << std::setw(15);
76 outputStream <<
"Tet" << std::setw(16);
78 outputStream <<
"Hex" << std::setw(16);
80 vtkSmartPointer<vtkDoubleArray> qualityField =
getStats(i);
81 double *val = qualityField->GetTuple(0);
83 outputStream << std::right << val[4] << std::setw(16) << std::right
84 << val[0] << std::setw(16) << std::right << val[2]
85 << std::setw(16) << std::right << val[1] << std::setw(16)
86 << std::right << val[3] << std::endl;
89 outputStream <<
"\n------------- Detailed Statistics ------------------\n" 92 vtkSmartPointer<vtkDoubleArray> qualityArray = vtkDoubleArray::SafeDownCast(
93 qualityFilter->GetOutput()->GetCellData()->GetArray(
"Quality"));
100 outputStream <<
"Type" << std::setw(10) <<
"Quality\n" << std::endl;
103 double val = qualityArray->GetValue(i);
106 outputStream <<
"TRI\t" << std::right << setw(10) << val <<
"\n";
110 outputStream <<
"TET\t" << std::right << setw(10) << val <<
"\n";
114 outputStream <<
"QUAD\t" << std::right << setw(10) << val <<
"\n";
117 case VTK_HEXAHEDRON: {
118 outputStream <<
"HEX\t" << std::right << setw(10) << val <<
"\n";
123 <<
"Invalid cell type. Only tri, quad, tet, and hex supported." 134 std::ofstream outputStream(fname);
135 if (!outputStream.good()) {
136 std::cerr <<
"Error opening file " << fname << std::endl;
143 vtkSmartPointer<vtkDoubleArray> qualityField =
147 qualityField = vtkDoubleArray::SafeDownCast(
149 "Mesh Triangle Quality"));
153 qualityField = vtkDoubleArray::SafeDownCast(
155 "Mesh Quadrilateral Quality"));
159 qualityField = vtkDoubleArray::SafeDownCast(
161 "Mesh Tetrahedron Quality"));
165 qualityField = vtkDoubleArray::SafeDownCast(
167 "Mesh Hexahedron Quality"));
171 std::cerr <<
"Invalid cell type. Only tri, quad, tet, and hex supported." 184 char **argv =
new char *[2];
185 argv[0] =
new char[100];
186 strcpy(argv[0],
"NONE");
187 Foam::argList args(argc, argv);
189 Foam::Info <<
"Create time\n" << Foam::endl;
190 Foam::Time runTime(Foam::Time::controlDictName, args);
192 Foam::argList::noParallel();
195 Foam::Module::polyMeshGen pmg(runTime);
199 Foam::Module::meshOptimizer mOpt(pmg);
205 mOpt.lockCellsInSubset(constrainedCellSet);
208 Foam::Module::labelLongList lockedBndFaces, selectedCells;
210 const Foam::label sId = pmg.cellSubsetIndex(constrainedCellSet);
211 pmg.cellsInSubset(sId, selectedCells);
213 Foam::boolList activeCell(pmg.cells().size(),
false);
214 forAll (selectedCells, i)
215 activeCell[selectedCells[i]] =
true;
219 pmg.clearAddressingData();
231 Foam::Info <<
"Writing mesh" << Foam::endl;
235 Foam::Info <<
"Finished mesh quality enhancement task." << Foam::endl;
237 std::cerr <<
"Compile with CFMSH option enabled to use this feature." const cfmeshQualityParams * _cfmQPrms
A brief description of meshBase.
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
std::string trim_fname(const std::string &name, const std::string &ext)
vtkSmartPointer< vtkDataSet > getDataSet() const
get this meshes' dataSet
const std::string & getFileName() const
get the current file name
virtual void write() const
write the mesh to file named after the private var 'filename'.
std::shared_ptr< meshBase > mesh
jsoncons::optional< std::string > consCellSet
vtkSmartPointer< vtkDoubleArray > getStats(int n)
vtkSmartPointer< vtkMeshQuality > qualityFilter
nemId_t getNumberOfCells() const
return the number of cells