globalPointPatchField.C
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
00027 #include "globalPointPatchField.H"
00028 #include "PstreamCombineReduceOps.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034
00035
00036
00037 template<class Type>
00038 globalPointPatchField<Type>::globalPointPatchField
00039 (
00040 const pointPatch& p,
00041 const DimensionedField<Type, pointMesh>& iF
00042 )
00043 :
00044 coupledPointPatchField<Type>(p, iF),
00045 globalPointPatch_(refCast<const globalPointPatch>(p))
00046 {}
00047
00048
00049 template<class Type>
00050 globalPointPatchField<Type>::globalPointPatchField
00051 (
00052 const pointPatch& p,
00053 const DimensionedField<Type, pointMesh>& iF,
00054 const dictionary& dict
00055 )
00056 :
00057 coupledPointPatchField<Type>(p, iF, dict),
00058 globalPointPatch_(refCast<const globalPointPatch>(p))
00059 {
00060 if (!isType<globalPointPatch>(p))
00061 {
00062 FatalIOErrorIn
00063 (
00064 "globalPointPatchField<Type>::globalPointPatchField\n"
00065 "(\n"
00066 " const pointPatch& p,\n"
00067 " const Field<Type>& field,\n"
00068 " const dictionary& dict\n"
00069 ")\n",
00070 dict
00071 ) << "patch " << this->patch().index()
00072 << " not processorPoint type. "
00073 << "Patch type = " << p.type()
00074 << exit(FatalIOError);
00075 }
00076 }
00077
00078
00079 template<class Type>
00080 globalPointPatchField<Type>::globalPointPatchField
00081 (
00082 const globalPointPatchField<Type>& ptf,
00083 const pointPatch& p,
00084 const DimensionedField<Type, pointMesh>& iF,
00085 const pointPatchFieldMapper& mapper
00086 )
00087 :
00088 coupledPointPatchField<Type>(ptf, p, iF, mapper),
00089 globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
00090 {
00091 if (!isType<globalPointPatch>(this->patch()))
00092 {
00093 FatalErrorIn
00094 (
00095 "globalPointPatchField<Type>::globalPointPatchField\n"
00096 "(\n"
00097 " const globalPointPatchField<Type>& ptf,\n"
00098 " const pointPatch& p,\n"
00099 " const DimensionedField<Type, pointMesh>& iF,\n"
00100 " const pointPatchFieldMapper& mapper\n"
00101 ")\n"
00102 ) << "Field type does not correspond to patch type for patch "
00103 << this->patch().index() << "." << endl
00104 << "Field type: " << typeName << endl
00105 << "Patch type: " << this->patch().type()
00106 << exit(FatalError);
00107 }
00108 }
00109
00110
00111 template<class Type>
00112 globalPointPatchField<Type>::globalPointPatchField
00113 (
00114 const globalPointPatchField<Type>& ptf,
00115 const DimensionedField<Type, pointMesh>& iF
00116 )
00117 :
00118 coupledPointPatchField<Type>(ptf, iF),
00119 globalPointPatch_(refCast<const globalPointPatch>(ptf.patch()))
00120 {}
00121
00122
00123
00124
00125 template<class Type>
00126 globalPointPatchField<Type>::~globalPointPatchField()
00127 {}
00128
00129
00130
00131
00132 template<class Type>
00133 void globalPointPatchField<Type>::swapAdd(Field<Type>& pField) const
00134 {
00135
00136 if (globalPointPatch_.globalPointSize() > 0)
00137 {
00138 Field<Type> lpf = patchInternalField(pField);
00139 const labelList& addr = globalPointPatch_.sharedPointAddr();
00140
00141 Field<Type> gpf
00142 (
00143 globalPointPatch_.globalPointSize(),
00144 pTraits<Type>::zero
00145 );
00146
00147 forAll(addr, i)
00148 {
00149 gpf[addr[i]] += lpf[i];
00150 }
00151
00152 combineReduce(gpf, plusEqOp<Field<Type> >());
00153
00154
00155 forAll (addr, i)
00156 {
00157 lpf[i] = gpf[addr[i]];
00158 }
00159
00160 setInInternalField(pField, lpf);
00161 }
00162 }
00163
00164
00165
00166
00167 }
00168
00169
Copyright © 2000-2009 OpenCFD Ltd