00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 \*---------------------------------------------------------------------------*/ 00025 00026 #include "cyclicFvPatch.H" 00027 #include <OpenFOAM/addToRunTimeSelectionTable.H> 00028 #include <finiteVolume/fvMesh.H> 00029 00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00031 00032 namespace Foam 00033 { 00034 00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00036 00037 defineTypeNameAndDebug(cyclicFvPatch, 0); 00038 addToRunTimeSelectionTable(fvPatch, cyclicFvPatch, polyPatch); 00039 00040 00041 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00042 00043 // Make patch weighting factors 00044 void cyclicFvPatch::makeWeights(scalarField& w) const 00045 { 00046 const scalarField& magFa = magSf(); 00047 00048 scalarField deltas = nf() & fvPatch::delta(); 00049 label sizeby2 = deltas.size()/2; 00050 00051 for (label facei = 0; facei < sizeby2; facei++) 00052 { 00053 scalar avFa = (magFa[facei] + magFa[facei + sizeby2])/2.0; 00054 00055 if (mag(magFa[facei] - magFa[facei + sizeby2])/avFa > 1e-4) 00056 { 00057 FatalErrorIn("cyclicFvPatch::makeWeights(scalarField& w) const") 00058 << "face " << facei << " and " << facei + sizeby2 00059 << " areas do not match by " 00060 << 100*mag(magFa[facei] - magFa[facei + sizeby2])/avFa 00061 << "% -- possible face ordering problem" 00062 << abort(FatalError); 00063 } 00064 00065 scalar di = deltas[facei]; 00066 scalar dni = deltas[facei + sizeby2]; 00067 00068 w[facei] = dni/(di + dni); 00069 w[facei + sizeby2] = 1 - w[facei]; 00070 } 00071 } 00072 00073 00074 // Make patch face - neighbour cell distances 00075 void cyclicFvPatch::makeDeltaCoeffs(scalarField& dc) const 00076 { 00077 scalarField deltas = nf() & fvPatch::delta(); 00078 label sizeby2 = deltas.size()/2; 00079 00080 for (label facei = 0; facei < sizeby2; facei++) 00081 { 00082 scalar di = deltas[facei]; 00083 scalar dni = deltas[facei + sizeby2]; 00084 00085 dc[facei] = 1.0/(di + dni); 00086 dc[facei + sizeby2] = dc[facei]; 00087 } 00088 } 00089 00090 00091 // Return delta (P to N) vectors across coupled patch 00092 tmp<vectorField> cyclicFvPatch::delta() const 00093 { 00094 vectorField patchD = fvPatch::delta(); 00095 label sizeby2 = patchD.size()/2; 00096 00097 tmp<vectorField> tpdv(new vectorField(patchD.size())); 00098 vectorField& pdv = tpdv(); 00099 00100 // To the transformation if necessary 00101 if (parallel()) 00102 { 00103 for (label facei = 0; facei < sizeby2; facei++) 00104 { 00105 vector ddi = patchD[facei]; 00106 vector dni = patchD[facei + sizeby2]; 00107 00108 pdv[facei] = ddi - dni; 00109 pdv[facei + sizeby2] = -pdv[facei]; 00110 } 00111 } 00112 else 00113 { 00114 for (label facei = 0; facei < sizeby2; facei++) 00115 { 00116 vector ddi = patchD[facei]; 00117 vector dni = patchD[facei + sizeby2]; 00118 00119 pdv[facei] = ddi - transform(forwardT()[0], dni); 00120 pdv[facei + sizeby2] = -transform(reverseT()[0], pdv[facei]); 00121 } 00122 } 00123 00124 return tpdv; 00125 } 00126 00127 00128 tmp<labelField> cyclicFvPatch::interfaceInternalField 00129 ( 00130 const unallocLabelList& internalData 00131 ) const 00132 { 00133 return patchInternalField(internalData); 00134 } 00135 00136 00137 tmp<labelField> cyclicFvPatch::transfer 00138 ( 00139 const Pstream::commsTypes, 00140 const unallocLabelList& interfaceData 00141 ) const 00142 { 00143 tmp<labelField> tpnf(new labelField(this->size())); 00144 labelField& pnf = tpnf(); 00145 00146 label sizeby2 = this->size()/2; 00147 00148 for (label facei=0; facei<sizeby2; facei++) 00149 { 00150 pnf[facei] = interfaceData[facei + sizeby2]; 00151 pnf[facei + sizeby2] = interfaceData[facei]; 00152 } 00153 00154 return tpnf; 00155 } 00156 00157 00158 tmp<labelField> cyclicFvPatch::internalFieldTransfer 00159 ( 00160 const Pstream::commsTypes commsType, 00161 const unallocLabelList& iF 00162 ) const 00163 { 00164 const unallocLabelList& faceCells = this->patch().faceCells(); 00165 00166 tmp<labelField> tpnf(new labelField(this->size())); 00167 labelField& pnf = tpnf(); 00168 00169 label sizeby2 = this->size()/2; 00170 00171 for (label facei=0; facei<sizeby2; facei++) 00172 { 00173 pnf[facei] = iF[faceCells[facei + sizeby2]]; 00174 pnf[facei + sizeby2] = iF[faceCells[facei]]; 00175 } 00176 00177 return tpnf; 00178 } 00179 00180 00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00182 00183 } // End namespace Foam 00184 00185 // ************************ vim: set sw=4 sts=4 et: ************************ //