$treeview $search $mathjax
|
Palabos
Version 1.1
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* This file is part of the Palabos library. 00002 * 00003 * Copyright (C) 2011 FlowKit Sarl 00004 * Avenue de Chailly 23 00005 * 1012 Lausanne, Switzerland 00006 * E-mail contact: contact@flowkit.com 00007 * 00008 * The most recent release of Palabos can be downloaded at 00009 * <http://www.palabos.org/> 00010 * 00011 * The library Palabos is free software: you can redistribute it and/or 00012 * modify it under the terms of the GNU Affero General Public License as 00013 * published by the Free Software Foundation, either version 3 of the 00014 * License, or (at your option) any later version. 00015 * 00016 * The library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Affero General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Affero General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef FLOW_TO_WALL_3D_HH 00026 #define FLOW_TO_WALL_3D_HH 00027 00028 #include "core/globalDefs.h" 00029 #include "offLattice/flowToWall3D.h" 00030 #include "core/util.h" 00031 #include <algorithm> 00032 00033 namespace plb { 00034 00035 template<typename T, template<typename U> class Descriptor, class ValueT> 00036 ValueT optimalInterpolate( Lattice<T,Descriptor>& lattice, T x, T y, T z, 00037 ExtrapolateValue3D<T,Descriptor,ValueT> const& extrapValue, 00038 bool& success, float& quality ) 00039 { 00040 Array<ValueT, 4> values; 00041 Array<int, 4> ok; 00042 values[0] = extrapValue(lattice, -2, x, y, z, ok[0]); 00043 values[1] = extrapValue(lattice, -1, x, y, z, ok[1]); 00044 values[2] = extrapValue(lattice, +1, x, y, z, ok[2]); 00045 values[3] = extrapValue(lattice, +2, x, y, z, ok[3]); 00046 00047 ValueT value = ValueT(); 00048 quality = 0; // By default, success failed. 00049 if (ok[1]) { // ? x ? ? 00050 if (ok[2]) { // ? x x ? 00051 if (ok[3]) { // ? x x x 00052 if (ok[0]) { // x x x x #### 00053 // O(4) interpolate: excellent quality. 00054 quality = 4; 00055 } 00056 else { // . x x x #### 00057 // O(3) interpolate: good quality. 00058 quality = 3; 00059 } 00060 } 00061 else { // ? x x . 00062 if (ok[0]) { // x x x . #### 00063 // O(3) interpolate: good quality. 00064 quality = 3; 00065 } 00066 else { // . x x . #### 00067 // O(2) interpolate: fair quality. 00068 quality = 2; 00069 } 00070 } 00071 } 00072 else { // ? x . ? 00073 if (ok[0]) { // x x . ? #### 00074 // Extrapolate: bad quality. 00075 quality = 1; 00076 } 00077 } 00078 } 00079 else { // ? . ? ? 00080 if (ok[2] && ok[3]) { // ? . x x #### 00081 // Extrapolate: bad quality. 00082 quality = 1; 00083 } 00084 } 00085 return value; 00086 } 00087 00088 template<typename T, template<typename U> class Descriptor, class ValueT> 00089 ExtrapolateValue3D<T,Descriptor,ValueT>::ExtrapolateValue3D(ComputeValue3D<T,Descriptor,ValueT>* computeValue_) 00090 : computeValue(computeValue_) 00091 { } 00092 00093 template<typename T, template<typename U> class Descriptor, class ValueT> 00094 ExtrapolateValue3D<T,Descriptor,ValueT>::ExtrapolateValue3D(ExtrapolateValue3D<T,Descriptor,ValueT> const& rhs) 00095 computeValue(rhs.computeValue->clone()) 00096 { } 00097 00098 template<typename T, template<typename U> class Descriptor, class ValueT> 00099 ExtrapolateValue3D<T,Descriptor,ValueT>& 00100 ExtrapolateValue3D<T,Descriptor,ValueT>::operator=(ExtrapolateValue3D<T,Descriptor,ValueT> const& rhs); 00101 { 00102 ExtrapolateValue3D<T,Descriptor,ValueT>(rhs).swap(*this); 00103 } 00104 00105 template<typename T, template<typename U> class Descriptor, class ValueT> 00106 void ExtrapolateValue3D<T,Descriptor,ValueT>::swap(ExtrapolateValue3D<T,Descriptor,ValueT>& rhs) { 00107 std::swap(computeValue, rhs.computeValue); 00108 } 00109 00110 template<typename T, template<typename U> class Descriptor, class ValueT> 00111 ExtrapolateValue3D<T,Descriptor,ValueT>::~ExtrapolateValue3D() { 00112 delete computeValue; 00113 } 00114 00115 00116 template<typename T, template<typename U> class Descriptor, class ValueT> 00117 TerminalExtrapolateValue3D::TerminalExtrapolateValue3D(ComputeValue3D<T,Descriptor,ValueT>* computeValue_) 00118 : ExtrapolateValue3D<T,Descriptor,ValueT>(computeValue_) 00119 { } 00120 00121 template<typename T, template<typename U> class Descriptor, class ValueT> 00122 std::vector<T> TerminalExtrapolateValue3D::operator() ( 00123 BlockLattice3D<T,Descriptor> const& lattice, plint increment, 00124 T x, T y, T z ) const 00125 { 00126 PLB_ASSERT( increment==0 ); 00127 plint iX = util::roundToInt(x); 00128 plint iY = util::roundToInt(y); 00129 plint iZ = util::roundToInt(z); 00130 this->compute(lattice, iX,iY,iZ); 00131 } 00132 00133 template<typename T, template<typename U> class Descriptor, class ValueT> 00134 TerminalExtrapolateValue3D<T,Descriptor,ValueT>* TerminalExtrapolateValue3D<T,Descriptor,ValueT>::clone() const 00135 { 00136 return new TerminalExtrapolateValue3D<T,Descriptor,ValueT>(*this); 00137 } 00138 00139 00140 template<typename T, template<typename U> class Descriptor, class ValueT> 00141 X_ExtrapolateValue3D<T,Descriptor,ValueT>::X_ExtrapolateValue3D ( 00142 ComputeValue3D<T,Descriptor,ValueT>* computeValue_, 00143 X_ExtrapolateValue3D<T,Descriptor,ValueT>* recurseValue_ ) 00144 : ExtrapolateValue3D<T,Descriptor,ValueT>(computeValue_), 00145 recurseValue(recurseValue_) 00146 { } 00147 00148 template<typename T, template<typename U> class Descriptor, class ValueT> 00149 X_ExtrapolateValue3D<T,Descriptor,ValueT>::X_ExtrapolateValue3D(X_ExtrapolateValue3D<T,Descriptor,ValueT> const& rhs) 00150 : ExtrapolateValue3D<T,Descriptor,ValueT>(rhs), 00151 recurseValue(rhs.recurseValue->clone()) 00152 { } 00153 00154 template<typename T, template<typename U> class Descriptor, class ValueT> 00155 X_ExtrapolateValue3D<T,Descriptor,ValueT>& 00156 X_ExtrapolateValue3D<T,Descriptor,ValueT>::operator=(X_ExtrapolateValue3D<T,Descriptor,ValueT> const& rhs) 00157 { 00158 X_ExtrapolateValue3D<T,Descriptor,ValueT>(rhs).swap(*this); 00159 } 00160 00161 template<typename T, template<typename U> class Descriptor, class ValueT> 00162 void X_ExtrapolateValue3D<T,Descriptor,ValueT>::swap(X_ExtrapolateValue3D<T,Descriptor,ValueT>& rhs) { 00163 ExtrapolateValue3D<T,Descriptor,ValueT>::swap(rhs); 00164 std::swap(recurseValue, rhs.recurseValue); 00165 } 00166 00167 template<typename T, template<typename U> class Descriptor, class ValueT> 00168 X_ExtrapolateValue3D<T,Descriptor,ValueT>::~X_ExtrapolateValue3D() { 00169 delete recurseValue; 00170 } 00171 00172 template<typename T, template<typename U> class Descriptor, class ValueT> 00173 std::vector<T> X_ExtrapolateValue3D<T,Descriptor,ValueT>::operator() ( 00174 BlockLattice3D<T,Descriptor> const& lattice, plint increment, 00175 T x, T y, T z ) const 00176 { 00177 plint iX = util::roundDown(x); 00178 switch(increment) { 00179 case -1: break; 00180 case -2: iX -= 1; break; 00181 case +1: iX += 1; break; 00182 case +2: iX += 2; break; 00183 defaul: PLB_ASSERT( false ); 00184 } 00185 BLA 00186 } 00187 00188 template<typename T, template<typename U> class Descriptor, class ValueT> 00189 X_ExtrapolateValue3D<T,Descriptor,ValueT>* X_ExtrapolateValue3D<T,Descriptor,ValueT>::clone() const 00190 { 00191 return new X_ExtrapolateValue3D<T,Descriptor,ValueT>(*this); 00192 } 00193 00194 } // namespace plb 00195 00196 #endif // FLOW_TO_WALL_3D_HH 00197
1.6.3
1.6.3