|
|
|
cyclicFvPatch.CGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 \*---------------------------------------------------------------------------*/ 00026 00027 #include "cyclicFvPatch.H" 00028 #include "addToRunTimeSelectionTable.H" 00029 #include "fvMesh.H" 00030 00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00032 00033 namespace Foam 00034 { 00035 00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00037 00038 defineTypeNameAndDebug(cyclicFvPatch, 0); 00039 addToRunTimeSelectionTable(fvPatch, cyclicFvPatch, polyPatch); 00040 00041 00042 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00043 00044 // Make patch weighting factors 00045 void cyclicFvPatch::makeWeights(scalarField& w) const 00046 { 00047 const scalarField& magFa = magSf(); 00048 00049 scalarField deltas = nf() & fvPatch::delta(); 00050 label sizeby2 = deltas.size()/2; 00051 00052 for (label facei = 0; facei < sizeby2; facei++) 00053 { 00054 scalar avFa = (magFa[facei] + magFa[facei + sizeby2])/2.0; 00055 00056 if (mag(magFa[facei] - magFa[facei + sizeby2])/avFa > 1e-4) 00057 { 00058 FatalErrorIn("cyclicFvPatch::makeWeights(scalarField& w) const") 00059 << "face " << facei << " and " << facei + sizeby2 00060 << " areas do not match by " 00061 << 100*mag(magFa[facei] - magFa[facei + sizeby2])/avFa 00062 << "% -- possible face ordering problem" 00063 << abort(FatalError); 00064 } 00065 00066 scalar di = deltas[facei]; 00067 scalar dni = deltas[facei + sizeby2]; 00068 00069 w[facei] = dni/(di + dni); 00070 w[facei + sizeby2] = 1 - w[facei]; 00071 } 00072 } 00073 00074 00075 // Make patch face - neighbour cell distances 00076 void cyclicFvPatch::makeDeltaCoeffs(scalarField& dc) const 00077 { 00078 scalarField deltas = nf() & fvPatch::delta(); 00079 label sizeby2 = deltas.size()/2; 00080 00081 for (label facei = 0; facei < sizeby2; facei++) 00082 { 00083 scalar di = deltas[facei]; 00084 scalar dni = deltas[facei + sizeby2]; 00085 00086 dc[facei] = 1.0/(di + dni); 00087 dc[facei + sizeby2] = dc[facei]; 00088 } 00089 } 00090 00091 00092 // Return delta (P to N) vectors across coupled patch 00093 tmp<vectorField> cyclicFvPatch::delta() const 00094 { 00095 vectorField patchD = fvPatch::delta(); 00096 label sizeby2 = patchD.size()/2; 00097 00098 tmp<vectorField> tpdv(new vectorField(patchD.size())); 00099 vectorField& pdv = tpdv(); 00100 00101 // To the transformation if necessary 00102 if (parallel()) 00103 { 00104 for (label facei = 0; facei < sizeby2; facei++) 00105 { 00106 vector ddi = patchD[facei]; 00107 vector dni = patchD[facei + sizeby2]; 00108 00109 pdv[facei] = ddi - dni; 00110 pdv[facei + sizeby2] = -pdv[facei]; 00111 } 00112 } 00113 else 00114 { 00115 for (label facei = 0; facei < sizeby2; facei++) 00116 { 00117 vector ddi = patchD[facei]; 00118 vector dni = patchD[facei + sizeby2]; 00119 00120 pdv[facei] = ddi - transform(forwardT()[0], dni); 00121 pdv[facei + sizeby2] = -transform(reverseT()[0], pdv[facei]); 00122 } 00123 } 00124 00125 return tpdv; 00126 } 00127 00128 00129 tmp<labelField> cyclicFvPatch::interfaceInternalField 00130 ( 00131 const unallocLabelList& internalData 00132 ) const 00133 { 00134 return patchInternalField(internalData); 00135 } 00136 00137 00138 tmp<labelField> cyclicFvPatch::transfer 00139 ( 00140 const Pstream::commsTypes, 00141 const unallocLabelList& interfaceData 00142 ) const 00143 { 00144 tmp<labelField> tpnf(new labelField(this->size())); 00145 labelField& pnf = tpnf(); 00146 00147 label sizeby2 = this->size()/2; 00148 00149 for (label facei=0; facei<sizeby2; facei++) 00150 { 00151 pnf[facei] = interfaceData[facei + sizeby2]; 00152 pnf[facei + sizeby2] = interfaceData[facei]; 00153 } 00154 00155 return tpnf; 00156 } 00157 00158 00159 tmp<labelField> cyclicFvPatch::internalFieldTransfer 00160 ( 00161 const Pstream::commsTypes commsType, 00162 const unallocLabelList& iF 00163 ) const 00164 { 00165 const unallocLabelList& faceCells = this->patch().faceCells(); 00166 00167 tmp<labelField> tpnf(new labelField(this->size())); 00168 labelField& pnf = tpnf(); 00169 00170 label sizeby2 = this->size()/2; 00171 00172 for (label facei=0; facei<sizeby2; facei++) 00173 { 00174 pnf[facei] = iF[faceCells[facei + sizeby2]]; 00175 pnf[facei + sizeby2] = iF[faceCells[facei]]; 00176 } 00177 00178 return tpnf; 00179 } 00180 00181 00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00183 00184 } // End namespace Foam 00185 00186 // ************************************************************************* // |