OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

USERD_get_part_element_ids_by_type.H

Go to the documentation of this file.
00001 int USERD_get_part_element_ids_by_type
00002 (
00003     int part_number,
00004     int element_type,
00005     int *elemid_array
00006 )
00007 {
00008 
00009 #ifdef ENSIGHTDEBUG
00010     Info << "Entering: USERD_get_part_element_ids_by_type" << endl 
00011         << "part_number = " << part_number << endl 
00012         << "element_type = " << element_type << endl << flush;
00013 #endif
00014 
00015     if (part_number == 1)
00016     {
00017         const cellShapeList& cellShapes = meshPtr->cellShapes();
00018         const cellList& cells = meshPtr->cells();
00019 
00020         label nCells = cells.size();
00021 
00022         label nPen06 = 0;
00023         label nHex08 = 0;
00024         label nPyr05 = 0;
00025         label nTet04 = 0;
00026         label nFaced = 0;
00027 
00028         if (element_type == Z_HEX08)
00029         {
00030             for (label n=0; n<nCells; n++)
00031             {
00032                 label nFaces = cells[n].size();
00033                 labelList points = cellShapes[n];
00034                 
00035                 if ((nFaces == 6) && (points.size() == 8))
00036                 {
00037                     elemid_array[nHex08++] = n + 1;
00038                 }
00039             }
00040         }
00041         else if (element_type == Z_PEN06)
00042         {
00043             for (label n=0; n<nCells; n++)
00044             {
00045                 label nFaces = cells[n].size();
00046                 labelList points = cellShapes[n];
00047                 
00048                 if ((nFaces == 5) && (points.size() == 6))
00049                 {
00050                     elemid_array[nPen06++] = n + 1;
00051                 }
00052             }
00053         }
00054         else if (element_type == Z_PYR05)
00055         {
00056             for (label n=0; n<nCells; n++)
00057             {
00058                 label nFaces = cells[n].size();
00059                 labelList points = cellShapes[n];
00060                 
00061                 if ((nFaces == 5) && (points.size() == 5))
00062                 {
00063                     elemid_array[nPyr05++] = n + 1;
00064                 }
00065             }
00066         }
00067         else if (element_type == Z_TET04)
00068         {
00069             for (label n=0; n<nCells; n++)
00070             {
00071                 label nFaces = cells[n].size();
00072                 labelList points = cellShapes[n];
00073                 
00074                 if ((nFaces == 4) && (points.size() == 4))
00075                 {
00076                     elemid_array[nTet04++] = n + 1;
00077                 }
00078             }
00079         }
00080         else if (element_type == Z_NFACED)
00081         {
00082             for (label n=0; n<nCells; n++)
00083             {
00084                 label nFaces = cells[n].size();
00085                 labelList points = cellShapes[n];
00086                 if ((nFaces == 6) && (points.size() == 8))
00087                 {}
00088                 else if ((nFaces == 5) && (points.size() == 6))
00089                 {}
00090                 else if ((nFaces == 5) && (points.size() == 5))
00091                 {}
00092                 else if ((nFaces == 4) && (points.size() == 4))
00093                 {}
00094                 else
00095                 {
00096                     elemid_array[nFaced++] = n + 1;
00097                 }
00098 
00099             }
00100         }
00101     }
00102     else if (part_number < nPatches+2)
00103     {
00104      
00105         const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
00106         label patchi = part_number - 2;
00107 
00108         label nTri03 = 0;
00109         label nQuad04 = 0;
00110         label nPoly = 0;
00111 
00112         if (element_type == Z_TRI03)
00113         {
00114             forAll(bMesh[patchi], facei)
00115             {
00116                 if (bMesh[patchi][facei].size() == 3)
00117                 {
00118                     elemid_array[nTri03++] = facei + 1;
00119                 }
00120             }
00121         }
00122         else if (element_type == Z_QUA04)
00123         {
00124             forAll(bMesh[patchi], facei)
00125             {
00126                 if (bMesh[patchi][facei].size() == 4)
00127                 {
00128                     elemid_array[nQuad04++] = facei + 1;
00129                 }
00130             }            
00131         }
00132         else if (element_type == Z_NSIDED)
00133         {
00134             forAll(bMesh[patchi], facei)
00135             {
00136                 label nPoints = bMesh[patchi][facei].size();
00137                 if ((nPoints != 3) && (nPoints != 4))
00138                 {
00139                     elemid_array[nPoly++] = facei + 1;
00140                 }
00141             }
00142         }
00143 
00144     }
00145     else if (part_number == nPatches+2)
00146     {
00147         for (label n=0; n<sprayPtr->size(); n++)
00148         {
00149             elemid_array[n] = n + 1;
00150         }
00151     }
00152     else
00153     {
00154         return Z_ERR;
00155     }
00156 
00157 #ifdef ENSIGHTDEBUG
00158     Info << "Leaving: USERD_get_part_element_ids_by_type" << endl << flush;
00159 #endif
00160 
00161     return Z_OK;
00162 }
Copyright © 2000-2009 OpenCFD Ltd