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 "fvFieldDecomposer.H"
00027 #include <finiteVolume/processorFvPatchField.H>
00028 #include <finiteVolume/processorFvsPatchField.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 template<class Type>
00038 tmp<GeometricField<Type, fvPatchField, volMesh> >
00039 fvFieldDecomposer::decomposeField
00040 (
00041 const GeometricField<Type, fvPatchField, volMesh>& field
00042 ) const
00043 {
00044
00045 Field<Type> internalField(field.internalField(), cellAddressing_);
00046
00047
00048 PtrList<fvPatchField<Type> > patchFields(boundaryAddressing_.size());
00049
00050 forAll (boundaryAddressing_, patchi)
00051 {
00052 if (boundaryAddressing_[patchi] >= 0)
00053 {
00054 patchFields.set
00055 (
00056 patchi,
00057 fvPatchField<Type>::New
00058 (
00059 field.boundaryField()[boundaryAddressing_[patchi]],
00060 procMesh_.boundary()[patchi],
00061 DimensionedField<Type, volMesh>::null(),
00062 *patchFieldDecomposerPtrs_[patchi]
00063 )
00064 );
00065 }
00066 else
00067 {
00068 patchFields.set
00069 (
00070 patchi,
00071 new processorFvPatchField<Type>
00072 (
00073 procMesh_.boundary()[patchi],
00074 DimensionedField<Type, volMesh>::null(),
00075 Field<Type>
00076 (
00077 field.internalField(),
00078 *processorVolPatchFieldDecomposerPtrs_[patchi]
00079 )
00080 )
00081 );
00082 }
00083 }
00084
00085
00086 return tmp<GeometricField<Type, fvPatchField, volMesh> >
00087 (
00088 new GeometricField<Type, fvPatchField, volMesh>
00089 (
00090 IOobject
00091 (
00092 field.name(),
00093 procMesh_.time().timeName(),
00094 procMesh_,
00095 IOobject::NO_READ,
00096 IOobject::NO_WRITE
00097 ),
00098 procMesh_,
00099 field.dimensions(),
00100 internalField,
00101 patchFields
00102 )
00103 );
00104 }
00105
00106
00107 template<class Type>
00108 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00109 fvFieldDecomposer::decomposeField
00110 (
00111 const GeometricField<Type, fvsPatchField, surfaceMesh>& field
00112 ) const
00113 {
00114 labelList mapAddr
00115 (
00116 labelList::subList
00117 (
00118 faceAddressing_,
00119 procMesh_.nInternalFaces()
00120 )
00121 );
00122 forAll (mapAddr, i)
00123 {
00124 mapAddr[i] -= 1;
00125 }
00126
00127
00128 Field<Type> internalField
00129 (
00130 field.internalField(),
00131 mapAddr
00132 );
00133
00134
00135
00136
00137
00138
00139 Field<Type> allFaceField(field.mesh().nFaces());
00140
00141 forAll (field.internalField(), i)
00142 {
00143 allFaceField[i] = field.internalField()[i];
00144 }
00145
00146 forAll (field.boundaryField(), patchi)
00147 {
00148 const Field<Type> & p = field.boundaryField()[patchi];
00149
00150 const label patchStart = field.mesh().boundaryMesh()[patchi].start();
00151
00152 forAll (p, i)
00153 {
00154 allFaceField[patchStart + i] = p[i];
00155 }
00156 }
00157
00158
00159 PtrList<fvsPatchField<Type> > patchFields(boundaryAddressing_.size());
00160
00161 forAll (boundaryAddressing_, patchi)
00162 {
00163 if (boundaryAddressing_[patchi] >= 0)
00164 {
00165 patchFields.set
00166 (
00167 patchi,
00168 fvsPatchField<Type>::New
00169 (
00170 field.boundaryField()[boundaryAddressing_[patchi]],
00171 procMesh_.boundary()[patchi],
00172 DimensionedField<Type, surfaceMesh>::null(),
00173 *patchFieldDecomposerPtrs_[patchi]
00174 )
00175 );
00176 }
00177 else
00178 {
00179 patchFields.set
00180 (
00181 patchi,
00182 new processorFvsPatchField<Type>
00183 (
00184 procMesh_.boundary()[patchi],
00185 DimensionedField<Type, surfaceMesh>::null(),
00186 Field<Type>
00187 (
00188 allFaceField,
00189 *processorSurfacePatchFieldDecomposerPtrs_[patchi]
00190 )
00191 )
00192 );
00193 }
00194 }
00195
00196
00197 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00198 (
00199 new GeometricField<Type, fvsPatchField, surfaceMesh>
00200 (
00201 IOobject
00202 (
00203 field.name(),
00204 procMesh_.time().timeName(),
00205 procMesh_,
00206 IOobject::NO_READ,
00207 IOobject::NO_WRITE
00208 ),
00209 procMesh_,
00210 field.dimensions(),
00211 internalField,
00212 patchFields
00213 )
00214 );
00215 }
00216
00217
00218 template<class GeoField>
00219 void fvFieldDecomposer::decomposeFields
00220 (
00221 const PtrList<GeoField>& fields
00222 ) const
00223 {
00224 forAll (fields, fieldI)
00225 {
00226 decomposeField(fields[fieldI])().write();
00227 }
00228 }
00229
00230
00231
00232
00233 }
00234
00235