triSurfFacets.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "triSurfFacets.H"
29 #include "pointIOField.H"
30 #include "IOobjectList.H"
31 #include "pointSet.H"
32 #include "stringListOps.H"
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
40 :
41  triangles_(),
42  patches_(),
43  facetSubsets_()
44 {}
45 
47 :
48  triangles_(triangles),
49  patches_(1),
50  facetSubsets_()
51 {
52  forAll(triangles_, triI)
53  triangles_[triI].region() = 0;
54 
55  patches_[0].name() = "patch";
56 }
57 
59 (
60  const LongList<labelledTri>& triangles,
62 )
63 :
64  triangles_(triangles),
65  patches_(patches),
66  facetSubsets_()
67 {}
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 // Destructor
72 {}
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
77 {
78  wordList t(patches_.size());
79 
80  forAll(patches_, patchI)
81  {
82  t[patchI] = patches_[patchI].name();
83  }
84 
85  return t;
86 }
87 
88 labelList triSurfFacets::findPatches(const word& patchName) const
89 {
90  const wordList allPatches = patchNames();
91 
92  const labelList patchIDs = findStrings(patchName, allPatches);
93 
94  # ifdef DEBUGtriSurf
95  if(patchIDs.empty())
96  {
97  WarningIn("triSurfFacets::findPatches(const word&)")
98  << "Cannot find any patch names matching " << patchName << endl;
99  }
100  # endif
101 
102  return patchIDs;
103 }
104 
106 {
107  label id = facetSubsetIndex(subsetName);
108  if( id >= 0 )
109  {
110  Warning << "Point subset " << subsetName << " already exists!" << endl;
111  return id;
112  }
113 
114  id = 0;
116  id = Foam::max(id, it.key()+1);
117 
118  facetSubsets_.insert
119  (
120  id,
122  );
123 
124  return id;
125 }
126 
128 {
129  if( facetSubsets_.find(subsetID) == facetSubsets_.end() )
130  return;
131 
132  facetSubsets_.erase(subsetID);
133 }
134 
136 {
138  if( it == facetSubsets_.end() )
139  {
140  Warning << "Subset " << subsetID << " is not a facet subset" << endl;
141  return word();
142  }
143 
144  return it().name();
145 }
146 
148 {
150  {
151  if( it().name() == subsetName )
152  return it.key();
153  }
154 
155  return -1;
156 }
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace Foam
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::triSurfFacets::triangles_
LongList< labelledTri > triangles_
list of triangles
Definition: triSurfFacets.H:58
Foam::triSurfFacets::patches_
geometricSurfacePatchList patches_
list of boundary patches and their properties
Definition: triSurfFacets.H:61
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::triSurfFacets::patchNames
wordList patchNames() const
return list of patches in the boundary
Definition: triSurfFacets.C:76
Foam::Warning
messageStream Warning
Foam::meshSubset::FACESUBSET
@ FACESUBSET
Definition: meshSubset.H:76
Foam::HashTable::const_iterator
An STL-conforming const_iterator.
Definition: HashTable.H:470
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: PrimitivePatchTemplate.H:68
pointIOField.H
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::triSurfFacets::triSurfFacets
triSurfFacets()
Null constructor.
Definition: triSurfFacets.C:39
Foam::LongList
Definition: LongList.H:55
Foam::triSurfFacets::removeFacetSubset
void removeFacetSubset(const label)
Definition: triSurfFacets.C:127
Foam::meshSubset
Definition: meshSubset.H:55
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
Foam::triSurfFacets::findPatches
labelList findPatches(const word &patchName) const
return a list of patch indices corresponding to the given
Definition: triSurfFacets.C:88
Foam::triSurfFacets::addFacetSubset
label addFacetSubset(const word &)
point subsets
Definition: triSurfFacets.C:105
Foam::triSurfFacets::~triSurfFacets
~triSurfFacets()
Definition: triSurfFacets.C:71
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::findStrings
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::triSurfFacets::facetSubsets_
Map< meshSubset > facetSubsets_
map of point subsets
Definition: triSurfFacets.H:64
triSurfFacets.H
Foam::triSurfFacets::facetSubsetName
word facetSubsetName(const label) const
Definition: triSurfFacets.C:135
stringListOps.H
Operations on lists of strings.
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::triSurfFacets::facetSubsetIndex
label facetSubsetIndex(const word &) const
Definition: triSurfFacets.C:147
WarningIn
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Definition: messageStream.H:254
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
pointSet.H