ExaFMM 1
Fast-multipole Method for exascale systems
include/serialfmm.h
Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2011 by Rio Yokota, Simon Layton, Lorena Barba
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a copy
00005 of this software and associated documentation files (the "Software"), to deal
00006 in the Software without restriction, including without limitation the rights
00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008 copies of the Software, and to permit persons to whom the Software is
00009 furnished to do so, subject to the following conditions:
00010 
00011 The above copyright notice and this permission notice shall be included in
00012 all copies or substantial portions of the Software.
00013 
00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020 THE SOFTWARE.
00021 */
00022 #ifndef serialfmm_h
00023 #define serialfmm_h
00024 #include "bottomup.h"
00025 
00026 //! Serial FMM interface
00027 template<Equation equation>
00028 class SerialFMM : public BottomUp<equation> {
00029 public:
00030   using Kernel<equation>::sortBodies;                           //!< Sort bodies according to cell index
00031   using Kernel<equation>::preCalculation;                       //!< Precalculate M2L translation matrix
00032   using Kernel<equation>::postCalculation;                      //!< Free temporary allocations
00033   using TreeStructure<equation>::buffer;                        //!< Buffer for MPI communication & sorting
00034   using TreeStructure<equation>::bodies2twigs;                  //!< Group bodies into twig cells
00035   using TreeStructure<equation>::twigs2cells;                   //!< Link twigs bottomup to create all cells in tree
00036 
00037 public:
00038 //! Constructor
00039   SerialFMM() : BottomUp<equation>() {
00040     preCalculation();
00041   }
00042 //! Destructor
00043   ~SerialFMM() {
00044     postCalculation();
00045   }
00046 
00047 //! Topdown tree constructor interface. Input: bodies, Output: cells
00048   void topdown(Bodies &bodies, Cells &cells) {
00049     TopDown<equation>::grow(bodies);                            // Grow tree structure topdown
00050 
00051     TopDown<equation>::setIndex();                              // Set index of cells
00052 
00053     buffer.resize(bodies.size());                               // Resize sort buffer
00054     sortBodies(bodies,buffer,false);                            // Sort bodies in descending order
00055 
00056     Cells twigs;                                                // Twigs are cells at the bottom of tree
00057     bodies2twigs(bodies,twigs);                                 // Turn bodies to twigs
00058 
00059     Cells sticks;                                               // Sticks are twigs from other processes that are not twigs in the current process
00060     twigs2cells(twigs,cells,sticks);                            // Turn twigs to cells
00061   }
00062 
00063 //! Bottomup tree constructor interface. Input: bodies, Output: cells
00064   void bottomup(Bodies &bodies, Cells &cells) {
00065     BottomUp<equation>::setIndex(bodies);                       // Set index of cells
00066 
00067     buffer.resize(bodies.size());                               // Resize sort buffer
00068     sortBodies(bodies,buffer,false);                            // Sort bodies in descending order
00069 
00070 /*
00071     prune(bodies);                                              // Prune tree structure bottomup
00072 
00073     BottomUp<equation>::grow(bodies);                           // Grow tree structure at bottom if necessary
00074 
00075     sortBodies(bodies,buffer,false);                            // Sort bodies in descending order
00076 */
00077 
00078     Cells twigs;                                                // Twigs are cells at the bottom of tree
00079     bodies2twigs(bodies,twigs);                                 // Turn bodies to twigs
00080 
00081     Cells sticks;                                               // Sticks are twigs from other processes not twigs here
00082     twigs2cells(twigs,cells,sticks);                            // Turn twigs to cells
00083   }
00084 };
00085 
00086 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines