Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "meshRefinement.H"
00027 #include <finiteVolume/fvMesh.H>
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036
00037 template<class T> void meshRefinement::updateList
00038 (
00039 const labelList& newToOld,
00040 const T& nullValue,
00041 List<T>& elems
00042 )
00043 {
00044 List<T> newElems(newToOld.size(), nullValue);
00045
00046 forAll(newElems, i)
00047 {
00048 label oldI = newToOld[i];
00049
00050 if (oldI >= 0)
00051 {
00052 newElems[i] = elems[oldI];
00053 }
00054 }
00055
00056 elems.transfer(newElems);
00057 }
00058
00059
00060
00061 template<class T>
00062 void meshRefinement::testSyncBoundaryFaceList
00063 (
00064 const scalar tol,
00065 const string& msg,
00066 const UList<T>& faceData,
00067 const UList<T>& syncedFaceData
00068 ) const
00069 {
00070 label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
00071
00072 if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
00073 {
00074 FatalErrorIn
00075 (
00076 "meshRefinement::testSyncBoundaryFaceList"
00077 "(const scalar, const string&, const List<T>&, const List<T>&)"
00078 ) << "Boundary faces:" << nBFaces
00079 << " faceData:" << faceData.size()
00080 << " syncedFaceData:" << syncedFaceData.size()
00081 << abort(FatalError);
00082 }
00083
00084 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
00085
00086 forAll(patches, patchI)
00087 {
00088 const polyPatch& pp = patches[patchI];
00089
00090 label bFaceI = pp.start() - mesh_.nInternalFaces();
00091
00092 forAll(pp, i)
00093 {
00094 const T& data = faceData[bFaceI];
00095 const T& syncData = syncedFaceData[bFaceI];
00096
00097 if (mag(data - syncData) > tol)
00098 {
00099 label faceI = pp.start()+i;
00100
00101 FatalErrorIn("testSyncFaces")
00102 << msg
00103 << "patchFace:" << i
00104 << " face:" << faceI
00105 << " fc:" << mesh_.faceCentres()[faceI]
00106 << " patch:" << pp.name()
00107 << " faceData:" << data
00108 << " syncedFaceData:" << syncData
00109 << " diff:" << mag(data - syncData)
00110 << abort(FatalError);
00111 }
00112
00113 bFaceI++;
00114 }
00115 }
00116 }
00117
00118
00119
00120 template<class GeoField>
00121 void meshRefinement::addPatchFields(fvMesh& mesh, const word& patchFieldType)
00122 {
00123 HashTable<const GeoField*> flds
00124 (
00125 mesh.objectRegistry::lookupClass<GeoField>()
00126 );
00127
00128 for
00129 (
00130 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
00131 iter != flds.end();
00132 ++iter
00133 )
00134 {
00135 const GeoField& fld = *iter();
00136
00137 typename GeoField::GeometricBoundaryField& bfld =
00138 const_cast<typename GeoField::GeometricBoundaryField&>
00139 (
00140 fld.boundaryField()
00141 );
00142
00143 label sz = bfld.size();
00144 bfld.setSize(sz+1);
00145 bfld.set
00146 (
00147 sz,
00148 GeoField::PatchFieldType::New
00149 (
00150 patchFieldType,
00151 mesh.boundary()[sz],
00152 fld.dimensionedInternalField()
00153 )
00154 );
00155 }
00156 }
00157
00158
00159
00160 template<class GeoField>
00161 void meshRefinement::reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
00162 {
00163 HashTable<const GeoField*> flds
00164 (
00165 mesh.objectRegistry::lookupClass<GeoField>()
00166 );
00167
00168 for
00169 (
00170 typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
00171 iter != flds.end();
00172 ++iter
00173 )
00174 {
00175 const GeoField& fld = *iter();
00176
00177 typename GeoField::GeometricBoundaryField& bfld =
00178 const_cast<typename GeoField::GeometricBoundaryField&>
00179 (
00180 fld.boundaryField()
00181 );
00182
00183 bfld.reorder(oldToNew);
00184 }
00185 }
00186
00187
00188
00189
00190
00191
00192 }
00193
00194