1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "meshRefinement.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 template<class T> void meshRefinement::updateList
40 const labelList& newToOld,
45 List<T> newElems(newToOld.size(), nullValue);
49 label oldI = newToOld[i];
53 newElems[i] = elems[oldI];
57 elems.transfer(newElems);
61 // Compare two lists over all boundary faces
63 void meshRefinement::testSyncBoundaryFaceList
67 const UList<T>& faceData,
68 const UList<T>& syncedFaceData
71 label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
73 if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
77 "meshRefinement::testSyncBoundaryFaceList"
78 "(const scalar, const string&, const List<T>&, const List<T>&)"
79 ) << "Boundary faces:" << nBFaces
80 << " faceData:" << faceData.size()
81 << " syncedFaceData:" << syncedFaceData.size()
85 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
87 forAll(patches, patchI)
89 const polyPatch& pp = patches[patchI];
91 label bFaceI = pp.start() - mesh_.nInternalFaces();
95 const T& data = faceData[bFaceI];
96 const T& syncData = syncedFaceData[bFaceI];
98 if (mag(data - syncData) > tol)
100 label faceI = pp.start()+i;
102 FatalErrorIn("testSyncFaces")
106 << " fc:" << mesh_.faceCentres()[faceI]
107 << " patch:" << pp.name()
108 << " faceData:" << data
109 << " syncedFaceData:" << syncData
110 << " diff:" << mag(data - syncData)
111 << abort(FatalError);
120 //template <class T, class Mesh>
121 template<class GeoField>
122 void meshRefinement::addPatchFields(fvMesh& mesh, const word& patchFieldType)
124 HashTable<const GeoField*> flds
126 mesh.objectRegistry::lookupClass<GeoField>()
131 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
136 const GeoField& fld = *iter();
138 typename GeoField::GeometricBoundaryField& bfld =
139 const_cast<typename GeoField::GeometricBoundaryField&>
144 label sz = bfld.size();
149 GeoField::PatchFieldType::New
153 fld.dimensionedInternalField()
160 // Reorder patch field
161 template<class GeoField>
162 void meshRefinement::reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
164 HashTable<const GeoField*> flds
166 mesh.objectRegistry::lookupClass<GeoField>()
171 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
176 const GeoField& fld = *iter();
178 typename GeoField::GeometricBoundaryField& bfld =
179 const_cast<typename GeoField::GeometricBoundaryField&>
184 bfld.reorder(oldToNew);
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 } // End namespace Foam
195 // ************************************************************************* //