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