badQualityToCell.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "badQualityToCell.H"
27 #include "polyMesh.H"
28 #include "motionSmoother.H"
30 #include "faceSet.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 defineTypeNameAndDebug(badQualityToCell, 0);
38 
39 addToRunTimeSelectionTable(topoSetSource, badQualityToCell, word);
40 
41 addToRunTimeSelectionTable(topoSetSource, badQualityToCell, istream);
42 
43 }
44 
45 
47 (
48  badQualityToCell::typeName,
49  "\n Usage: badQualityToCell mesh-quality-dictionary\n\n"
50  " Select all cells that do not satisfy the selection criterion\n\n"
51 );
52 
53 
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
55 
56 void Foam::badQualityToCell::combine(topoSet& set, const bool add) const
57 {
58  faceSet faces(mesh_, "meshQualityFaces", mesh_.nFaces()/100+1);
59  motionSmoother::checkMesh(false, mesh_, dict_, faces);
60  faces.sync(mesh_);
61 
62  forAllConstIter(faceSet, faces, iter)
63  {
64  label faceI = iter.key();
65  addOrDelete(set, mesh_.faceOwner()[faceI], add);
66  if (mesh_.isInternalFace(faceI))
67  {
68  addOrDelete(set, mesh_.faceNeighbour()[faceI], add);
69  }
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
75 
76 // Construct from dictionary
78 (
79  const polyMesh& mesh,
80  const dictionary& dict
81 )
82 :
84  dict_(dict)
85 {}
86 
87 
88 // Construct from Istream
90 (
91  const polyMesh& mesh,
92  Istream& is
93 )
94 :
96  dict_(is)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 (
110  const topoSetSource::setAction action,
111  topoSet& set
112 ) const
113 {
114  if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
115  {
116  Info<< " Adding bad-quality cells" << endl;
117  combine(set, true);
118  }
119  else if (action == topoSetSource::DELETE)
120  {
121  Info<< " Removing bad-quality cells" << endl;
122  combine(set, false);
123  }
124 }
125 
126 
127 // ************************************************************************* //
Foam::topoSetSource::ADD
@ ADD
Definition: topoSetSource.H:87
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::ListListOps::combine
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Foam::badQualityToCell::combine
void combine(topoSet &set, const bool add) const
Definition: badQualityToCell.C:56
Foam::topoSetSource::addToUsageTable
Class with constructor to add usage string to table.
Definition: topoSetSource.H:100
motionSmoother.H
Foam::faceSet
A list of face labels.
Definition: faceSet.H:48
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
Foam::topoSetSource::NEW
@ NEW
Definition: topoSetSource.H:85
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::faceSet::sync
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
Definition: faceSet.C:113
Foam::badQualityToCell::badQualityToCell
badQualityToCell(const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: badQualityToCell.C:78
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
badQualityToCell.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::Info
messageStream Info
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1017
faceSet.H
Foam::topoSetSource::DELETE
@ DELETE
Definition: topoSetSource.H:88
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::badQualityToCell::~badQualityToCell
virtual ~badQualityToCell()
Destructor.
Definition: badQualityToCell.C:102
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:870
Foam::badQualityToCell::dict_
const dictionary dict_
Mesh quality dictionary.
Definition: badQualityToCell.H:60
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::topoSetSource
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
Foam::badQualityToCell::usage_
static addToUsageTable usage_
Add usage string.
Definition: badQualityToCell.H:57
Foam::primitiveMesh::nFaces
label nFaces() const
Definition: primitiveMeshI.H:58
Foam::motionSmootherAlgo::checkMesh
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
Definition: motionSmootherAlgoCheck.C:415
Foam::primitiveMesh::isInternalFace
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Definition: primitiveMeshI.H:70
Foam::badQualityToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: badQualityToCell.C:109
Foam::topoSetSource::mesh_
const polyMesh & mesh_
Definition: topoSetSource.H:126
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::polyMesh::faceNeighbour
virtual const labelList & faceNeighbour() const
Return face neighbour.
Definition: polyMesh.C:1023
Foam::topoSetSource::addOrDelete
void addOrDelete(topoSet &set, const label cellI, const bool) const
Add (if bool) cellI to set or delete cellI from set.
Definition: topoSetSource.C:140