| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
/*! \file refine.h |
| 6 |
* \ingroup gm |
| 7 |
*/ |
| 8 |
|
| 9 |
|
| 10 |
/****************************************************************************/ |
| 11 |
/* */ |
| 12 |
/* File: refine.h */ |
| 13 |
/* */ |
| 14 |
/* Purpose: definitions for two AND three dimensional refinement */ |
| 15 |
/* */ |
| 16 |
/* Author: Peter Bastian */ |
| 17 |
/* Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */ |
| 18 |
/* Universitaet Heidelberg */ |
| 19 |
/* Im Neuenheimer Feld 368 */ |
| 20 |
/* 6900 Heidelberg */ |
| 21 |
/* internet: [email protected] */ |
| 22 |
/* */ |
| 23 |
/* History: 09.03.92 begin, ug version 2.0 */ |
| 24 |
/* */ |
| 25 |
/* Remarks: */ |
| 26 |
/* */ |
| 27 |
/****************************************************************************/ |
| 28 |
|
| 29 |
|
| 30 |
/****************************************************************************/ |
| 31 |
/* */ |
| 32 |
/* auto include mechanism and other include files */ |
| 33 |
/* */ |
| 34 |
/****************************************************************************/ |
| 35 |
|
| 36 |
#ifndef __REFINE__ |
| 37 |
#define __REFINE__ |
| 38 |
|
| 39 |
#include <dune/uggrid/low/namespace.h> |
| 40 |
#include <dune/uggrid/low/ugtypes.h> |
| 41 |
#include "gm.h" |
| 42 |
#include "algebra.h" /* just for ALGEBRA_N_CE */ |
| 43 |
|
| 44 |
START_UGDIM_NAMESPACE |
| 45 |
|
| 46 |
/****************************************************************************/ |
| 47 |
/* */ |
| 48 |
/* defines in the following order */ |
| 49 |
/* */ |
| 50 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 51 |
/* other constants */ |
| 52 |
/* macros */ |
| 53 |
/* */ |
| 54 |
/****************************************************************************/ |
| 55 |
|
| 56 |
#define NOTUSED -1 /* SHORT has to be signed! */ |
| 57 |
#define NO_CENTER_NODE NOTUSED |
| 58 |
|
| 59 |
#ifdef ModelP |
| 60 |
/* undefine if all son objects shall be identified */ |
| 61 |
#define IDENT_ONLY_NEW |
| 62 |
#endif |
| 63 |
|
| 64 |
/* define this if you want to apply anistropic rules */ |
| 65 |
/* #define __ANISOTROPIC__ */ |
| 66 |
|
| 67 |
|
| 68 |
/****************************************************************************/ |
| 69 |
/* */ |
| 70 |
/* control word definitions */ |
| 71 |
/* */ |
| 72 |
/****************************************************************************/ |
| 73 |
|
| 74 |
enum REFINE_CE { |
| 75 |
|
| 76 |
PATTERN_CE = GM_N_CE, /* continue after gm.h entries */ |
| 77 |
ADDPATTERN_CE, |
| 78 |
REFINE_CE, |
| 79 |
MARK_CE, |
| 80 |
COARSEN_CE, |
| 81 |
DECOUPLED_CE, |
| 82 |
REFINECLASS_CE, |
| 83 |
UPDATE_GREEN_CE, |
| 84 |
SIDEPATTERN_CE, |
| 85 |
MARKCLASS_CE, |
| 86 |
|
| 87 |
REFINE_N_CE |
| 88 |
}; |
| 89 |
|
| 90 |
/* edges */ |
| 91 |
#define PATTERN_SHIFT 10 |
| 92 |
#define PATTERN_LEN 1 |
| 93 |
#define PATTERN(p) CW_READ(p,PATTERN_CE) |
| 94 |
#define SETPATTERN(p,n) CW_WRITE(p,PATTERN_CE,n) |
| 95 |
|
| 96 |
#define ADDPATTERN_SHIFT 11 |
| 97 |
#define ADDPATTERN_LEN 1 |
| 98 |
#define ADDPATTERN(p) CW_READ(p,ADDPATTERN_CE) |
| 99 |
#define SETADDPATTERN(p,n) CW_WRITE(p,ADDPATTERN_CE,n) |
| 100 |
|
| 101 |
|
| 102 |
/* element */ |
| 103 |
#define REFINE_SHIFT 0 |
| 104 |
#define REFINE_LEN 8 |
| 105 |
#define REFINE(p) CW_READ(p,REFINE_CE) |
| 106 |
#define SETREFINE(p,n) CW_WRITE(p,REFINE_CE,n) |
| 107 |
|
| 108 |
#define MARK_SHIFT 0 |
| 109 |
#define MARK_LEN 8 |
| 110 |
#define MARK(p) CW_READ(p,MARK_CE) |
| 111 |
#define SETMARK(p,n) CW_WRITE(p,MARK_CE,n) |
| 112 |
|
| 113 |
#define COARSEN_SHIFT 10 |
| 114 |
#define COARSEN_LEN 1 |
| 115 |
#define COARSEN(p) CW_READ(p,COARSEN_CE) |
| 116 |
#define SETCOARSEN(p,n) CW_WRITE(p,COARSEN_CE,n) |
| 117 |
|
| 118 |
#define DECOUPLED_SHIFT 12 |
| 119 |
#define DECOUPLED_LEN 1 |
| 120 |
#define DECOUPLED(p) CW_READ(p,DECOUPLED_CE) |
| 121 |
#define SETDECOUPLED(p,n) CW_WRITE(p,DECOUPLED_SHIFT,n) |
| 122 |
|
| 123 |
#define REFINECLASS_SHIFT 15 |
| 124 |
#define REFINECLASS_LEN 2 |
| 125 |
#define REFINECLASS(p) CW_READ(p,REFINECLASS_CE) |
| 126 |
#define SETREFINECLASS(p,n) CW_WRITE(p,REFINECLASS_CE,n) |
| 127 |
|
| 128 |
#define UPDATE_GREEN_SHIFT 8 |
| 129 |
#define UPDATE_GREEN_LEN 1 |
| 130 |
#define UPDATE_GREEN(p) CW_READ(p,UPDATE_GREEN_CE) |
| 131 |
#define SETUPDATE_GREEN(p,n) CW_WRITE(p,UPDATE_GREEN_CE,n) |
| 132 |
|
| 133 |
#define SIDEPATTERN_SHIFT 0 |
| 134 |
#define SIDEPATTERN_LEN 6 |
| 135 |
#define SIDEPATTERN(p) CW_READ(p,SIDEPATTERN_CE) |
| 136 |
#define SETSIDEPATTERN(p,n) CW_WRITE(p,SIDEPATTERN_CE,n) |
| 137 |
|
| 138 |
#define MARKCLASS_SHIFT 13 |
| 139 |
#define MARKCLASS_LEN 2 |
| 140 |
#define MARKCLASS(p) CW_READ(p,MARKCLASS_CE) |
| 141 |
#define SETMARKCLASS(p,n) CW_WRITE(p,MARKCLASS_CE,n) |
| 142 |
|
| 143 |
#ifdef ModelP |
| 144 |
#define NEW_NIDENT_LEN 2 |
| 145 |
#define NEW_NIDENT(p) CW_READ(p,ce_NEW_NIDENT) |
| 146 |
#define SETNEW_NIDENT(p,n) CW_WRITE(p,ce_NEW_NIDENT,n) |
| 147 |
|
| 148 |
#define NEW_EDIDENT_LEN 2 |
| 149 |
#define NEW_EDIDENT(p) CW_READ(p,ce_NEW_EDIDENT) |
| 150 |
#define SETNEW_EDIDENT(p,n) CW_WRITE(p,ce_NEW_EDIDENT,n) |
| 151 |
#endif |
| 152 |
|
| 153 |
/* macros for refineinfo */ |
| 154 |
#define RINFO_MAX 100 |
| 155 |
#define REFINEINFO(mg) refine_info |
| 156 |
#define REFINESTEP(r) (r).step |
| 157 |
#define SETREFINESTEP(r,s) (r).step = ((s)%RINFO_MAX) |
| 158 |
#define MARKCOUNT(r) (r).markcount[(r).step] |
| 159 |
#define SETMARKCOUNT(r,n) (r).markcount[(r).step] = (n) |
| 160 |
#define PREDNEW0(r) (r).predicted_new[(r).step][0] |
| 161 |
#define SETPREDNEW0(r,n) (r).predicted_new[(r).step][0] = (n) |
| 162 |
#define PREDNEW1(r) (r).predicted_new[(r).step][1] |
| 163 |
#define SETPREDNEW1(r,n) (r).predicted_new[(r).step][1] = (n) |
| 164 |
#define PREDNEW2(r) (r).predicted_new[(r).step][2] |
| 165 |
#define SETPREDNEW2(r,n) (r).predicted_new[(r).step][2] = (n) |
| 166 |
#define REAL(r) (r).real[(r).step] |
| 167 |
#define SETREAL(r,n) (r).real[(r).step] = (n) |
| 168 |
|
| 169 |
/* macros for listing */ |
| 170 |
#define REFINE_ELEMENT_LIST(d,e,s) \ |
| 171 |
IFDEBUG(gm,d) \ |
| 172 |
if (e!=NULL) \ |
| 173 |
UserWriteF( s " ID=%d/%08x PRIO=%d TAG=%d BE=%d ECLASS=%d LEVEL=%d" \ |
| 174 |
" REFINECLASS=%d MARKCLASS=%d REFINE=%d MARK=%d COARSE=%d" \ |
| 175 |
" USED=%d NSONS=%d EFATHERID=%d SIDEPATTERN=%d\n", \ |
| 176 |
ID(e),EGID(e),EPRIO(e),TAG(e),(OBJT(e)==BEOBJ),ECLASS(e),LEVEL(e), \ |
| 177 |
REFINECLASS(e),MARKCLASS(e),REFINE(e),MARK(e),COARSEN(e), \ |
| 178 |
USED(e),NSONS(e),(EFATHER(e)!=NULL) ? ID(EFATHER(e)) : 0,SIDEPATTERN(e));\ |
| 179 |
ENDDEBUG |
| 180 |
|
| 181 |
|
| 182 |
#define REFINE_GRID_LIST(d,mg,k,s1,s2) \ |
| 183 |
IFDEBUG(gm,d) \ |
| 184 |
{ \ |
| 185 |
GRID *grid = GRID_ON_LEVEL(mg,k); \ |
| 186 |
ELEMENT *theElement; \ |
| 187 |
\ |
| 188 |
UserWriteF s1 ; \ |
| 189 |
for (theElement=PFIRSTELEMENT(grid); \ |
| 190 |
theElement!=NULL; \ |
| 191 |
theElement=SUCCE(theElement)) \ |
| 192 |
{ \ |
| 193 |
REFINE_ELEMENT_LIST(d,theElement,s2) \ |
| 194 |
} \ |
| 195 |
} \ |
| 196 |
ENDDEBUG |
| 197 |
|
| 198 |
|
| 199 |
#define REFINE_MULTIGRID_LIST(d,mg,s1,s2,s3) \ |
| 200 |
IFDEBUG(gm,d) \ |
| 201 |
{ \ |
| 202 |
INT k; \ |
| 203 |
\ |
| 204 |
UserWriteF( s1 ); \ |
| 205 |
for (k=0; k<=TOPLEVEL(mg); k++) \ |
| 206 |
{ \ |
| 207 |
GRID *grid = GRID_ON_LEVEL(mg,k); \ |
| 208 |
ELEMENT *theElement; \ |
| 209 |
\ |
| 210 |
UserWriteF( s2 ); \ |
| 211 |
for (theElement=PFIRSTELEMENT(grid); \ |
| 212 |
theElement!=NULL; \ |
| 213 |
theElement=SUCCE(theElement)) \ |
| 214 |
{ \ |
| 215 |
REFINE_ELEMENT_LIST(d,theElement,s3) \ |
| 216 |
} \ |
| 217 |
} \ |
| 218 |
} \ |
| 219 |
ENDDEBUG |
| 220 |
|
| 221 |
/****************************************************************************/ |
| 222 |
/* */ |
| 223 |
/* typedefs */ |
| 224 |
/* */ |
| 225 |
/****************************************************************************/ |
| 226 |
|
| 227 |
typedef struct refineinfo |
| 228 |
{ |
| 229 |
INT step; /* count of calls to AdaptMultiGrid */ |
| 230 |
float markcount[RINFO_MAX]; /* count of currently marked elements */ |
| 231 |
float predicted_new[RINFO_MAX][3]; |
| 232 |
/* count of elements, would be created */ |
| 233 |
float real[RINFO_MAX]; /* count of elements before refinement */ |
| 234 |
} REFINEINFO; |
| 235 |
|
| 236 |
typedef INT (*Get_Sons_of_ElementSideProcPtr)(ELEMENT *theElement, INT side, INT *Sons_of_Side,ELEMENT *SonList[MAX_SONS], INT *SonSides, INT NeedSons); |
| 237 |
|
| 238 |
/****************************************************************************/ |
| 239 |
/* */ |
| 240 |
/* definition of exported global variables */ |
| 241 |
/* */ |
| 242 |
/****************************************************************************/ |
| 243 |
|
| 244 |
extern REFINEINFO refine_info; |
| 245 |
#ifdef ModelP |
| 246 |
extern INT ce_NEW_NIDENT; |
| 247 |
extern INT ce_NEW_EDIDENT; |
| 248 |
#endif |
| 249 |
|
| 250 |
/****************************************************************************/ |
| 251 |
/* */ |
| 252 |
/* functions exported */ |
| 253 |
/* */ |
| 254 |
/****************************************************************************/ |
| 255 |
|
| 256 |
INT GetSonSideNodes (const ELEMENT *theElement, INT side, INT *nodes, NODE *SideNodes[MAX_SIDE_NODES], INT ioflag); |
| 257 |
INT Get_Sons_of_ElementSide(const ELEMENT *theElement, |
| 258 |
INT side, |
| 259 |
INT *Sons_of_Side, |
| 260 |
ELEMENT *SonList[MAX_SONS], |
| 261 |
INT *SonSides, |
| 262 |
INT NeedSons, |
| 263 |
INT ioflag, |
| 264 |
INT useRefineClass=0); |
| 265 |
INT Connect_Sons_of_ElementSide (GRID *theGrid, ELEMENT *theElement, INT side, INT Sons_of_Side, ELEMENT **Sons_of_Side_List, INT *SonSides, INT ioflag); |
| 266 |
INT Refinement_Changes (ELEMENT *theElement); |
| 267 |
|
| 268 |
END_UGDIM_NAMESPACE |
| 269 |
|
| 270 |
#endif |