albertaextra.hh
00001
00002
00003
00004 #ifndef DUNE_ALBERTAEXTRA_HH
00005 #define DUNE_ALBERTAEXTRA_HH
00006
00007 #include <algorithm>
00008 #include <cassert>
00009 #include <cstring>
00010
00011 #include <dune/grid/albertagrid/albertaheader.hh>
00012
00013 #if HAVE_ALBERTA
00014
00015 #ifdef __ALBERTApp__
00016 namespace Albert {
00017 #endif
00018
00019
00020
00021
00022
00023
00024 namespace AlbertHelp
00025 {
00026
00027
00028
00029
00030 template <int cdim, int vertices>
00031 struct AlbertLeafData
00032 {
00033
00034 typedef struct
00035 {
00036 double determinant;
00037 } Data;
00038
00039
00040 inline static void AlbertLeafRefine( EL *parent, EL *child[2] )
00041 {
00042 Data * ldata;
00043 int i;
00044
00045 ldata = (Data *) parent->child[1];
00046 assert(ldata != 0);
00047
00048
00049
00050 double childDet = 0.5 * ldata->determinant;
00051
00052
00053 for(i=0; i<2; i++)
00054 {
00055 Data *ldataChi = (Data *) child[i]->child[1];
00056 assert(ldataChi != 0);
00057 ldataChi->determinant = childDet;
00058 }
00059 }
00060
00061 inline static void AlbertLeafCoarsen(EL *parent, EL *child[2])
00062 {
00063 Data *ldata;
00064 int i;
00065
00066 ldata = (Data *) parent->child[1];
00067 assert(ldata != 0);
00068 double & det = ldata->determinant;
00069 det = 0.0;
00070
00071
00072
00073
00074 for(i=0; i<2; i++)
00075 {
00076 Data *ldataChi = (Data *) child[i]->child[1];
00077 assert(ldataChi != 0);
00078 det += ldataChi->determinant;
00079 }
00080 }
00081
00082 #if DUNE_ALBERTA_VERSION < 0x200
00083
00084 inline static void initLeafData(LEAF_DATA_INFO * linfo)
00085 {
00086 linfo->leaf_data_size = sizeof(Data);
00087 linfo->refine_leaf_data = &AlbertLeafRefine;
00088 linfo->coarsen_leaf_data = &AlbertLeafCoarsen;
00089 }
00090 #endif
00091
00092
00093 inline static void setLeafData(const EL_INFO * elf)
00094 {
00095 assert( elf->el->child[0] == 0 );
00096 Data *ldata = (Data *) elf->el->child[1];
00097 assert(ldata != 0);
00098
00099 ldata->determinant = ALBERTA el_det(elf);
00100 }
00101
00102
00103 inline static void initLeafDataValues( MESH * mesh, int proc )
00104 {
00105
00106 ALBERTA meshTraverse(mesh,-1, CALL_LEAF_EL|FILL_COORDS,setLeafData);
00107 }
00108
00109 };
00110
00111 }
00112
00113 #ifdef __ALBERTApp__
00114 }
00115 #endif
00116
00117 #endif // HAVE_ALBERTA
00118
00119 #endif