Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ntree_adapt.hpp

Go to the documentation of this file.
00001 //************************************************************************************//
00002 // Module       : ntree_adapt.cpp
00003 // Date         : 9/25/03 (DLR)
00004 // Copyright    : 2003-2006 Copyright University Corporation for Atmospheric
00005 //                Research
00006 // Description  : Encapsulates the access methods and data associated with
00007 //                defining an N-tree-based adaption scheme.
00008 // Derived From : IConnAMR
00009 // Modifications:
00010 //************************************************************************************//
00011 #if !defined(NTREEADAPT_HPP)
00012 #define NTREEADAPT_HPP
00013 
00014 #include "gtypes.h"
00015 #include <iostream.h>
00016 #include <stdlib.h>
00017 #include "iconn_amr.hpp"
00018 #include "gelemlist.hpp"
00019 #include "gfieldlist.hpp"
00020 #include "gobjlist.hpp"
00021 #include "gpartmapper.hpp"
00022 #include "gpartitioner.hpp"
00023 
00024 #if !defined(MAX_NEIGHBORS)
00025 #  define MAX_NEIGHBORS (2*(GDIM-1))
00026 #endif
00027 
00028 #if !defined(REFINE_QUERY_DEF)
00029 #define REFINE_QUERY_DEF
00030 #define NRQUERYST_MEM 4
00031 struct stRefineQuery{
00032 GKEY   elem_key;
00033 GKEY   parent_key;
00034 GKEY   root_key;
00035 GINT   iflag;
00036 };
00037 #endif
00038 
00039 #define GNTREEADAPT_LEVEL(elemid,rootid_inv) ( (GINT)(1.660964047*log10(elemid*rootid_inv)+0.5) )
00040 
00041 #if 0
00042 #if !defined(COARSEN_QUERY_DEF)
00043 #define COARSEN_QUERY_DEF
00044 #define NCQUERYST_MEM 2
00045 #define MAX_NUMFACES  ((GINT )pow(2.0,GDIM))
00046 #define GMAX_NUMFACES (GDIM*GDIM)
00047 struct stCoarsenQuery{
00048 GKEY   child_key;
00049 GINT   ien[GMAX_NUMFACES];
00050 };
00051 #endif
00052 #endif
00053 
00054 
00055 class NTreeAdapt: public IConnAMR
00056 {
00057 public:
00058                            NTreeAdapt(GINT  maxlev=4);
00059                            NTreeAdapt(GElemList *gelems, GFieldList *gfields[], GINT  nfields, GINT  maxlev=4);
00060                           ~NTreeAdapt();
00061 
00062          GBOOL             Adapt(GIBuffer  &hrefine, GIBuffer  &coarsen);           // Do refinement and coarsening
00063          void              DoLoadBalance(GBOOL bal);                                // Set/Get flag for load balancing
00064          void              DoPartitioning(GBOOL doit);                              // Set/Get flag for partioning of any kind
00065          void              SetFieldGroup(GElemList *elems, GFieldList *fields[], GINT  nfields); 
00066                                                                                     // Set fields/elements
00067          void              SetRefineDir(GINT  idir);                                // Set refinement direction
00068          void              SetLevelLimit(GINT  nlevel=0);                           // Don't refine beyond specified level
00069          void              SetPartitioner(GPartitioner *part);                      // Set grid partitioner object
00070          void              SetLoadBalanceMapper(GPartMapper *pmglobal);             // Set partition mapper object for load balancing
00071 
00072 private:
00073          // Methods: 
00074          void              CheckConsistency(GIBuffer  &hrefine, GIBuffer  &coarsen);
00075          void              CheckRefinement (GIBuffer  &hrefine, GIBuffer  &coarsen);
00076          void              CheckCoarsening (GIBuffer  &hrefine, GIBuffer  &coarsen);
00077          GBOOL             AdaptAll(GIBuffer  &hrefine, GIBuffer  &coarsen); 
00078 //       GBOOL             AdaptElemental  (GIBuffer  &hrefine, GIBuffer  &coarsen);
00079          GBOOL             DoRefinement(GIBuffer &irefine);
00080          GBOOL             DoCoarsening(GIBuffer &icoarsen);
00081          GBOOL             DoPartition(GIBuffer &icoarsen, GKEYBuffer  &kcoarsen, GPartMapper *pm);
00082          GBOOL             RefineElemental(Elem2D *parent_elem, Field2D *parent_field[], GElemList *gelems, GFieldList *gfields[], GINT nfields);
00083          GBOOL             CoarsenElemental(Elem2D *esiblings[], GINT  nsiblings, Elem2D *& p_elem, GElemList *gelems, GFieldList *gfields[], GINT nfields);
00084          void              GetSiblings(Elem2D *e, Elem2D **&esiblings, GINT  &nsiblings,
00085                                        GElemList *gelems);
00086          void              EPointersToIndices(GIBuffer  &ibuff, Elem2D *pelem[], GINT  npelem);
00087          void              Restrict2OneSibMem(GIBuffer &outind, GKEYBuffer &inkeys);
00088 
00089 
00090          GKEY              ParentKey(Elem2D *elem);
00091          GKEY              ParentKey(GKEY rkey, GKEY ckey);
00092          GKEY              ChildKey (Elem2D *elem, GINT ichild);
00093          GINT              RefineLevel(Elem2D *elem);
00094          GINT              RefineLevel(GKEY rkey, GKEY ckey);
00095          void              ElemIndexToKey(GKEYBuffer &kbuff, GIBuffer &ibuff);
00096          GBOOL             SetChildVertices(Elem2D  *parent, Elem2D  *child, GINT  ichild);
00097          GBOOL             SetChildBdy     (Field2D *parent, Field2D *child, GINT  ichild);
00098          GBOOL             SetParentVertices(Elem2D  *esib[], GINT  nsib, Elem2D  *parent);
00099          GBOOL             SetParentBdy     (Field2D *fsib[], GINT  nsib, Field2D *parent);
00100          GBOOL             ReorderSiblings  (Elem2D *esiblings[], GINT  nsiblings);
00101          GBOOL             CheckPeriodic(GINT  &i, GINT  &j);
00102          GBOOL             InQueryList(stRefineQuery *lquery, GINT  nquery, GKEY key, 
00103                                        GINT  *isrch, GINT  nsrch);
00104          GINT              NumberSiblings(stRefineQuery lquery[], GINT  nquery, GKEY pkey);
00105          GINT              ElemKeyToIndex(GIBuffer &index, GKEYBuffer &key);
00106          GINT              AllSibsCoarsened(GIBuffer  &coarsebuff, GINT  *isrch, GINT  nsrch, GIBuffer  &ikeepbuff);
00107 
00108          void              OrderLevelDecreasing(GIBuffer  &buff, GINT  &nglevel);
00109          void              GetLevelRanges(GIBuffer  &ibeg, GIBuffer  &iend, GIBuffer  &buff, GINT  &nglevel);
00110          GINT              BuildGQueryList(stRefineQuery *&gquerylist, GINT  &nqlist, GIBuffer  &rclist, 
00111                                            GINT  *isrch, GINT  nsrch);
00112 
00113 
00114          // Member data
00115          GSHORT            nprocs_;            // total number of processors
00116          GSHORT            this_rank_;         // the rank of this processor
00117          GBOOL             bDoLoadBalance_;    // flag indicating that load balancing is to be done
00118          GBOOL             bPartitioning_;     // flag indicating that partitioning is to be done
00119          GBOOL             bLimitByLevel_ ;    // is there a refine. level limit?
00120          GINT              ndcomp_;            // number of sibling decompositions
00121          GINT              nlevel_limit_;      // if bLimitByLevel_=TRUE, how many refine. levels allowed?
00122          GINT              nfields_;           // number of fields on primary grid
00123          GINT              dcomp_dir_;         // refinement direction (or 0 for refinement in all)
00124          GINT              max_levels_;        // max no. of refinement levels
00125          GINT              npart_;             // max no. of partition sends for each proc
00126          GKEY              max_key_mult_;      // max change in id from root 
00127          GDOUBLE           indcomp_;           // inverse of number of sibling decompositions
00128          GC_DATATYPE       refq_type_;         // Refine query data type for communications
00129          GFieldList        **gfields_;         // Fields on primary grid
00130          GFGList           fieldgroups_;       // field group list
00131          GPartitioner      *partitioner_;      // field group list
00132          stGPartitionMap   *partmap_;          // partition map structure
00133          GPartMapper       *pmglobal_;         // partition mapper for global load balancing
00134          GPartMapper       *pmsibling_;        // partiaion mapper for sibling collection/partitioning
00135 
00136 };
00137 
00138 
00139 #endif

Generated on Wed Dec 21 16:00:48 2005 for Geophysics & Astrophysics Spectral Element Adaptive Refinement (GASpAR) 2D Code by  doxygen 1.4.4