$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

multiGridDataField3D.hh

Go to the documentation of this file.
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 /* Main author: Daniel Lagrava
00026  **/
00027 
00028 #ifndef MULTI_GRID_DATA_FIELD_3D_HH
00029 #define MULTI_GRID_DATA_FIELD_3D_HH
00030 
00031 #include "core/globalDefs.h"
00032 #include "multiGrid/multiGridDataField3D.h"
00033 #include "multiGrid/multiGridGenerator3D.h"
00034 
00035 
00036 namespace plb {
00037 
00038 template<typename T>
00039 MultiGridScalarField3D<T>::MultiGridScalarField3D (
00040                         MultiGridManagement3D management_,
00041                         std::vector<BlockCommunicator3D* > communicators_,
00042                         std::vector<CombinedStatistics*> combinedStatistics_, 
00043                         plint behaviorLevel_ )
00044             : MultiGrid3D(management_, behaviorLevel_)
00045 {
00046     allocateFields(communicators_,combinedStatistics_);
00047 }
00048 
00049 template<typename T>
00050 MultiGridScalarField3D<T>::MultiGridScalarField3D (
00051                         MultiGridManagement3D management_,
00052                         plint behaviorLevel_ )
00053     : MultiGrid3D(management_, behaviorLevel_)
00054 {
00055     allocateFields();
00056 }
00057 
00058 template<typename T>
00059 MultiGridScalarField3D<T>::MultiGridScalarField3D(MultiGridScalarField3D<T> const& rhs)
00060     : MultiGrid3D(rhs)
00061 {
00062     allocateFields();
00063 }
00064 
00065 template<typename T>
00066 MultiGridScalarField3D<T>::MultiGridScalarField3D(MultiGrid3D const& rhs, Box3D subDomain, bool crop)
00067     : MultiGrid3D(extractManagement(rhs.getMultiGridManagement(),subDomain,crop),rhs.getBehaviorLevel())
00068 {
00069     allocateFields();
00070 }
00071 
00072 
00073 template<typename T>
00074 MultiGridScalarField3D<T>::~MultiGridScalarField3D(){
00075     for (plint iLevel=0; iLevel<(plint)fields.size(); ++iLevel){
00076         delete fields[iLevel];
00077     }
00078 }
00079 
00080 template<typename T>
00081 void MultiGridScalarField3D<T>::reset(){
00082     for (plint iLevel=0; iLevel<(plint)fields.size(); ++iLevel){
00083         fields[iLevel]->reset();
00084     }
00085 }
00086 
00087 template<typename T>
00088 T& MultiGridScalarField3D<T>::get(plint iX, plint iY, plint iZ){
00089     return fields[this->getBehaviorLevel()]->get(iX,iY,iZ);
00090 }
00091 
00092 template<typename T>
00093 T const& MultiGridScalarField3D<T>::get(plint iX, plint iY, plint iZ) const {
00094     return fields[this->getBehaviorLevel()]->get(iX,iY,iZ);
00095 }
00096 
00097 template<typename T>
00098 MultiScalarField3D<T>& MultiGridScalarField3D<T>::getComponent(plint level){
00099     PLB_PRECONDITION(level<(plint)fields.size());
00100     return *fields[level];
00101 }
00102 
00103 template<typename T>
00104 MultiScalarField3D<T> const& MultiGridScalarField3D<T>::getComponent(plint level) const{
00105     PLB_PRECONDITION(level<(plint)fields.size());
00106     return *fields[level];
00107 }
00108 
00109 template<typename T>
00110 std::auto_ptr<MultiScalarField3D<T> > MultiGridScalarField3D<T>::convertToCoarsest(plint dimDx, plint dimDt){
00111 
00112 //TODO modify this to use the methods implemented by Jonas   
00113 //     plint levels = this->getNumLevels();
00114 //     
00115 //     MultiScalarField3D<T> *copy, *tmp;
00116 //     copy = joinMultiScalarInCoarsest(
00117 //         *fields[levels-2],*fields[levels-1], dimDx, dimDt);
00118 //     
00119 //     tmp=copy;
00120 //     
00121 //     for (plint iLevel=levels-2; iLevel>0; --iLevel){
00122 //         copy = joinMultiScalarInCoarsest(
00123 //             *fields[iLevel-1],*copy, dimDx, dimDt );
00124 //         delete tmp; // erase the old value of copy
00125 //         tmp = copy; // keep always a pointer over copy
00126 //     }
00127 //     
00128 //     return std::auto_ptr<MultiScalarField3D<T> >(copy);
00129 }
00130 
00131 template<typename T>
00132 std::auto_ptr<MultiScalarField3D<T> > MultiGridScalarField3D<T>::convertToFinest(plint dimDx, plint dimDt){
00133     
00134 //TODO modify this to use the methods implemented by Jonas   
00135 //     MultiScalarField3D<T> *copy, *tmp;
00136 //     copy = joinMultiScalarInFinest(
00137 //         *fields[0],*fields[1], dimDx, dimDt );
00138 //         
00139 //     tmp=copy;
00140 //                     
00141 //     for (plint iLevel=2; iLevel<(plint)fields.size(); ++iLevel){
00142 //         copy = joinMultiScalarInFinest(
00143 //                     *tmp,*fields[iLevel], dimDx, dimDt );
00144 //         delete tmp; // erase the old value of copy
00145 //         tmp = copy; // keep always a pointer over copy
00146 //     }
00147 //         
00148 //     return std::auto_ptr<MultiScalarField3D<T> >(copy);
00149 }
00150 
00151 
00153 template<typename T>
00154 void MultiGridScalarField3D<T>::allocateFields(){
00155     fields = generateScalarFields<T>( this->getMultiGridManagement(),
00156                                       defaultMultiGridPolicy3D().getBlockCommunicator(this->getNumLevels()),
00157                                       defaultMultiGridPolicy3D().getCombinedStatistics(this->getNumLevels()) );
00158 }
00159 
00160 template<typename T>
00161 void MultiGridScalarField3D<T>::allocateFields( std::vector<BlockCommunicator3D* > communicators,
00162                                                 std::vector<CombinedStatistics*> combinedStatistics ){
00163     fields = generateScalarFields<T>( this->getMultiGridManagement(),
00164                                       communicators, combinedStatistics );
00165 }
00166 
00167 
00168 
00169 template<typename T>
00170 int MultiGridScalarField3D<T>::getBlockId() const {
00171     return fields[0]->getStaticId();
00172 }
00173 
00174 
00175 /* ************** MultiGridTensorField3D ******************* */
00176 
00177 template<typename T, int nDim>
00178 MultiGridTensorField3D<T,nDim>::MultiGridTensorField3D ( MultiGridManagement3D management_,
00179                                                     std::vector<BlockCommunicator3D* > communicators_,
00180                                                     std::vector<CombinedStatistics*> combinedStatistics_, 
00181                                                     plint behaviorLevel_ )
00182 {
00183     allocateFields(communicators_,combinedStatistics_);
00184 }
00185 
00186 template<typename T, int nDim>
00187 MultiGridTensorField3D<T,nDim>::MultiGridTensorField3D (
00188                 MultiGridManagement3D management_,
00189                 plint behaviorLevel_ )
00190 {
00191     allocateFields( defaultMultiGridPolicy3D().getBlockCommunicator(this->getNumLevels()),
00192                     defaultMultiGridPolicy3D().getCombinedStatistics(this->getNumLevels()) );
00193 }
00194                 
00195 template<typename T, int nDim>
00196 MultiGridTensorField3D<T,nDim>::MultiGridTensorField3D(MultiGridTensorField3D<T,nDim> const& rhs)
00197 {
00198     allocateFields();
00199 }
00200 
00201 template<typename T, int nDim>
00202 MultiGridTensorField3D<T,nDim>::MultiGridTensorField3D(MultiGrid3D const& rhs)
00203         : MultiGrid3D(rhs.getMultiGridManagement(),rhs.getBehaviorLevel())
00204 {
00205     allocateFields();
00206 }
00207 
00208 template<typename T, int nDim>
00209 MultiGridTensorField3D<T,nDim>::MultiGridTensorField3D(
00210                         MultiGrid3D const& rhs, 
00211                         Box3D subDomain, bool crop)
00212         : MultiGrid3D(extractManagement(rhs.getMultiGridManagement(),subDomain,crop),rhs.getBehaviorLevel())
00213 {
00214     allocateFields();
00215 }
00216 
00217 
00218 template<typename T, int nDim>
00219 MultiGridTensorField3D<T,nDim>::~MultiGridTensorField3D(){
00220     for (pluint iLevel=0; iLevel<fields.size(); ++iLevel){
00221         delete fields[iLevel];
00222     }
00223 }
00224 
00225 
00226 template<typename T, int nDim>
00227 void MultiGridTensorField3D<T,nDim>::reset(){
00228     for (pluint iLevel=0; iLevel<fields.size(); ++iLevel){
00229         fields[iLevel]->reset();
00230     }
00231 }
00232 
00233 template<typename T, int nDim>
00234 Array<T,nDim>& MultiGridTensorField3D<T,nDim>::get(plint iX, plint iY, plint iZ){
00235     return fields[this->getBehaviorLevel()]->get(iX,iY,iZ);
00236 }
00237 
00238 template<typename T, int nDim>
00239 Array<T,nDim> const& MultiGridTensorField3D<T,nDim>::get(plint iX, plint iY, plint iZ) const{
00240     return fields[this->getBehaviorLevel()]->get(iX,iY,iZ);
00241 }
00242 
00243 template<typename T, int nDim>
00244 MultiTensorField3D<T,nDim>& MultiGridTensorField3D<T,nDim>::getComponent(plint level){
00245     PLB_PRECONDITION(level<(plint)fields.size());
00246     return *fields[level];
00247 }
00248 
00249 template<typename T, int nDim>
00250 MultiTensorField3D<T,nDim> const& MultiGridTensorField3D<T,nDim>::getComponent(plint level) const{
00251     PLB_PRECONDITION(level<(plint)fields.size());
00252     return *fields[level];
00253 }
00254 
00255 template<typename T, int nDim>
00256 int MultiGridTensorField3D<T,nDim>::getBlockId() const{
00257     return fields[this->getBehaviorLevel()]->getStaticId();
00258 }
00259 
00260 
00261 template<typename T, int nDim>
00262 std::auto_ptr<MultiTensorField3D<T,nDim> > MultiGridTensorField3D<T,nDim>::convertToCoarsest(plint dimDx, plint dimDt){
00263 
00264 //TODO Complete with the functions that Jonas implemented
00265 //     plint levels = this->getNumLevels();
00266 //     
00267 //     MultiTensorField3D<T,nDim> *copy, *tmp;
00268 //     copy = joinMultiTensorInCoarsest(
00269 //             *fields[levels-2],*fields[levels-1], dimDx, dimDt);
00270 //     
00271 //     tmp=copy;
00272 //     
00273 //     for (plint iLevel=levels-2; iLevel>0; --iLevel){
00274 //         copy = joinMultiTensorInCoarsest(
00275 //             *fields[iLevel-1],*copy, dimDx, dimDt );
00276 //         delete tmp; // erase the old value of copy
00277 //         tmp = copy; // keep always a pointer over copy
00278 //     }
00279 //     
00280 //     return std::auto_ptr<MultiTensorField3D<T,nDim> >(copy);
00281 }
00282 
00283 template<typename T, int nDim>
00284 std::auto_ptr<MultiTensorField3D<T,nDim> > MultiGridTensorField3D<T,nDim>::convertToFinest(plint dimDx, plint dimDt){
00285     
00286 //TODO Complete with the functions that Jonas implemented
00287 //     MultiTensorField3D<T,nDim> *copy, *tmp;
00288 //     copy = joinMultiTensorInFinest(
00289 //         *fields[0],*fields[1], dimDx, dimDt );
00290 //         
00291 //     tmp=copy;
00292 //                     
00293 //     for (plint iLevel=2; iLevel<(plint)fields.size(); ++iLevel){
00294 //         copy = joinMultiTensorInFinest(
00295 //                     *tmp,*fields[iLevel], dimDx, dimDt );
00296 //         delete tmp; // erase the old value of copy
00297 //         tmp = copy; // keep always a pointer over copy
00298 //     }
00299 //         
00300 //     return std::auto_ptr<MultiTensorField3D<T,nDim> >(copy);
00301 }
00302 
00303 
00304 
00306 template<typename T, int nDim>
00307 void MultiGridTensorField3D<T,nDim>::allocateFields(){
00308     fields = generateTensorFields<T,nDim>( this->getMultiGridManagement(),
00309                                       defaultMultiGridPolicy3D().getBlockCommunicator(this->getNumLevels()),
00310                                       defaultMultiGridPolicy3D().getCombinedStatistics(this->getNumLevels()) );
00311 }
00312 
00313 template<typename T, int nDim>
00314 void MultiGridTensorField3D<T,nDim>::allocateFields( std::vector<BlockCommunicator3D* > communicators,
00315                                                 std::vector<CombinedStatistics*> combinedStatistics ){
00316     fields = generateTensorFields<T,nDim>(  this->getMultiGridManagement(),
00317                                             communicators, combinedStatistics );
00318 }
00319 
00320 
00321 
00322 
00323 } // namespace plb
00324 
00325 #endif  // MULTI_GRID_DATA_FIELD_3D_HH
00326