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