1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "meshRefinement.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 template<class T> void meshRefinement::updateList
39 const labelList& newToOld,
44 List<T> newElems(newToOld.size(), nullValue);
48 label oldI = newToOld[i];
52 newElems[i] = elems[oldI];
56 elems.transfer(newElems);
60 // Compare two lists over all boundary faces
62 void meshRefinement::testSyncBoundaryFaceList
66 const UList<T>& faceData,
67 const UList<T>& syncedFaceData
70 label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
72 if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
76 "meshRefinement::testSyncBoundaryFaceList"
77 "(const scalar, const string&, const List<T>&, const List<T>&)"
78 ) << "Boundary faces:" << nBFaces
79 << " faceData:" << faceData.size()
80 << " syncedFaceData:" << syncedFaceData.size()
84 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
86 forAll(patches, patchI)
88 const polyPatch& pp = patches[patchI];
90 label bFaceI = pp.start() - mesh_.nInternalFaces();
94 const T& data = faceData[bFaceI];
95 const T& syncData = syncedFaceData[bFaceI];
97 if (mag(data - syncData) > tol)
99 label faceI = pp.start()+i;
101 FatalErrorIn("testSyncFaces")
105 << " fc:" << mesh_.faceCentres()[faceI]
106 << " patch:" << pp.name()
107 << " faceData:" << data
108 << " syncedFaceData:" << syncData
109 << " diff:" << mag(data - syncData)
110 << abort(FatalError);
119 //template <class T, class Mesh>
120 template<class GeoField>
121 void meshRefinement::addPatchFields(fvMesh& mesh, const word& patchFieldType)
123 HashTable<const GeoField*> flds
125 mesh.objectRegistry::lookupClass<GeoField>()
128 forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
130 const GeoField& fld = *iter();
132 typename GeoField::GeometricBoundaryField& bfld =
133 const_cast<typename GeoField::GeometricBoundaryField&>
138 label sz = bfld.size();
143 GeoField::PatchFieldType::New
147 fld.dimensionedInternalField()
154 // Reorder patch field
155 template<class GeoField>
156 void meshRefinement::reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
158 HashTable<const GeoField*> flds
160 mesh.objectRegistry::lookupClass<GeoField>()
163 forAllConstIter(typename HashTable<const GeoField*>, flds, iter)
165 const GeoField& fld = *iter();
167 typename GeoField::GeometricBoundaryField& bfld =
168 const_cast<typename GeoField::GeometricBoundaryField&>
173 bfld.reorder(oldToNew);
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 } // End namespace Foam
184 // ************************************************************************* //