FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

printMeshStats.C

Go to the documentation of this file.
00001 #include "printMeshStats.H"
00002 #include <OpenFOAM/polyMesh.H>
00003 #include <OpenFOAM/globalMeshData.H>
00004 
00005 #include <OpenFOAM/hexMatcher.H>
00006 #include <OpenFOAM/wedgeMatcher.H>
00007 #include <OpenFOAM/prismMatcher.H>
00008 #include <OpenFOAM/pyrMatcher.H>
00009 #include <OpenFOAM/tetWedgeMatcher.H>
00010 #include <OpenFOAM/tetMatcher.H>
00011 
00012 
00013 void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
00014 {
00015     Info<< "Mesh stats" << nl
00016         << "    points:           "
00017         << returnReduce(mesh.points().size(), sumOp<label>()) << nl;
00018 
00019     label nInternalPoints = returnReduce
00020     (
00021         mesh.nInternalPoints(),
00022         sumOp<label>()
00023     );
00024 
00025     if (nInternalPoints != -Pstream::nProcs())
00026     {
00027         Info<< "    internal points:  " << nInternalPoints << nl;
00028 
00029         if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1)
00030         {
00031             WarningIn("Foam::printMeshStats(const polyMesh&, const bool)")
00032                 << "Some processors have their points sorted into internal"
00033                 << " and external and some do not." << endl
00034                 << "This can cause problems later on." << endl;
00035         }
00036     }
00037 
00038     if (allTopology && nInternalPoints != -Pstream::nProcs())
00039     {
00040         label nEdges = returnReduce(mesh.nEdges(), sumOp<label>());
00041         label nInternalEdges = returnReduce
00042         (
00043             mesh.nInternalEdges(),
00044             sumOp<label>()
00045         );
00046         label nInternal1Edges = returnReduce
00047         (
00048             mesh.nInternal1Edges(),
00049             sumOp<label>()
00050         );
00051         label nInternal0Edges = returnReduce
00052         (
00053             mesh.nInternal0Edges(),
00054             sumOp<label>()
00055         );
00056 
00057         Info<< "    edges:            " << nEdges << nl
00058             << "    internal edges:   " << nInternalEdges << nl
00059             << "    internal edges using one boundary point:   "
00060             << nInternal1Edges-nInternal0Edges << nl
00061             << "    internal edges using two boundary points:  "
00062             << nInternalEdges-nInternal1Edges << nl;
00063     }
00064 
00065     Info<< "    faces:            "
00066         << returnReduce(mesh.faces().size(), sumOp<label>()) << nl
00067         << "    internal faces:   "
00068         << returnReduce(mesh.faceNeighbour().size(), sumOp<label>()) << nl
00069         << "    cells:            "
00070         << returnReduce(mesh.cells().size(), sumOp<label>()) << nl
00071         << "    boundary patches: "
00072         << mesh.boundaryMesh().size() << nl
00073         << "    point zones:      "
00074         << mesh.pointZones().size() << nl
00075         << "    face zones:       "
00076         << mesh.faceZones().size() << nl
00077         << "    cell zones:       "
00078         << mesh.cellZones().size() << nl
00079         << endl;
00080 
00081 
00082     // Construct shape recognizers
00083     hexMatcher hex;
00084     prismMatcher prism;
00085     wedgeMatcher wedge;
00086     pyrMatcher pyr;
00087     tetWedgeMatcher tetWedge;
00088     tetMatcher tet;
00089 
00090     // Counters for different cell types
00091     label nHex = 0;
00092     label nWedge = 0;
00093     label nPrism = 0;
00094     label nPyr = 0;
00095     label nTet = 0;
00096     label nTetWedge = 0;
00097     label nUnknown = 0;
00098 
00099     for(label cellI = 0; cellI < mesh.nCells(); cellI++)
00100     {
00101         if (hex.isA(mesh, cellI))
00102         {
00103             nHex++;
00104         }
00105         else if (tet.isA(mesh, cellI))
00106         {
00107             nTet++;
00108         }
00109         else if (pyr.isA(mesh, cellI))
00110         {
00111             nPyr++;
00112         }
00113         else if (prism.isA(mesh, cellI))
00114         {
00115             nPrism++;
00116         }
00117         else if (wedge.isA(mesh, cellI))
00118         {
00119             nWedge++;
00120         }
00121         else if (tetWedge.isA(mesh, cellI))
00122         {
00123             nTetWedge++;
00124         }
00125         else
00126         {
00127             nUnknown++;
00128         }
00129     }
00130 
00131     reduce(nHex,sumOp<label>());
00132     reduce(nPrism,sumOp<label>()); 
00133     reduce(nWedge,sumOp<label>());
00134     reduce(nPyr,sumOp<label>());
00135     reduce(nTetWedge,sumOp<label>());
00136     reduce(nTet,sumOp<label>());
00137     reduce(nUnknown,sumOp<label>());
00138 
00139     Info<< "Overall number of cells of each type:" << nl
00140         << "    hexahedra:     " << nHex << nl
00141         << "    prisms:        " << nPrism << nl
00142         << "    wedges:        " << nWedge << nl
00143         << "    pyramids:      " << nPyr << nl
00144         << "    tet wedges:    " << nTetWedge << nl
00145         << "    tetrahedra:    " << nTet << nl
00146         << "    polyhedra:     " << nUnknown
00147         << nl << endl;
00148 }
00149 
00150 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines