File: mesh-getext.h

package info (click to toggle)
xmorph 1%3A20150712-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,404 kB
  • sloc: ansic: 24,887; sh: 7,755; cpp: 1,231; makefile: 524; sed: 16
file content (109 lines) | stat: -rw-r--r-- 3,146 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef _MESH_GETEXT_H__INCLUDED_
#define _MESH_GETEXT_H__INCLUDED_

#include "mesh.h"

/************ EXTRA MESH GET FUNCTIONS  **************/



/*******************
 *  if you define   MESH_GET_EXT_NOT_SAFE
 *  then meshGetExt will not be safe for any choice of
 *  xi and yi: it will be safe only in a neighbourhood of the mesh
 *
 *  but it may be faster 
 */


#ifdef MESHGETEXT_NOT_SAFE
#define MESHGETEXT__ONLY_Y__  __meshGetExt__only_y__
static inline double /* __attribute__ weak */
__meshGetExt__only_y__(MeshT *this, int xi, int yi,double *p);
#define MESHGETEXT__GETIT__  meshGet
#else
#define MESHGETEXT__ONLY_Y__  meshGetExt
#define MESHGETEXT__GETIT__  meshGetExt
#endif


static inline double /* __attribute__ weak */
meshGetExt(MeshT *this, int xi, int yi,double *p)
{
  if(xi<0 )
    return 2*MESHGETEXT__GETIT__(this,0,yi,p)
      -MESHGETEXT__ONLY_Y__(this, -xi,yi,p);
  else if (xi>=this->nx)
    return  2*MESHGETEXT__GETIT__(this,this->nx-1 ,yi,p)
      -MESHGETEXT__ONLY_Y__(this, 2*this->nx-xi-2,yi,p);
  if(yi<0 )
    return 2*MESHGETEXT__GETIT__(this,xi,0,p)
      -MESHGETEXT__GETIT__(this, xi,-yi,p);
  else if (yi>=this->ny)
    return  2*MESHGETEXT__GETIT__(this,xi,this->ny-1,p)
      -MESHGETEXT__GETIT__(this,xi, 2*this->ny-yi-2,p);
  return meshGet__no_check(this,xi,yi,p) ;
}

#ifdef MESHGETEXT_NOT_SAFE
static inline double /* __attribute__ weak */ 
__meshGetExt__only_y__(MeshT *this, int xi, int yi,double *p)
{
  if(yi<0 )
    return 2*MESHGETEXT__GETIT__(this,xi,0,p)
      -MESHGETEXT__GETIT__(this, xi,-yi,p);
  else if (yi>=this->ny)
    return  2*MESHGETEXT__GETIT__(this,xi,this->ny-1,p)
      -MESHGETEXT__GETIT__(this,xi, 2*this->ny-yi-2,p);
  return meshGet__no_check(this,xi,yi,p) ;
}
#endif


static inline double   /* __attribute__ weak */ 
meshGetxExt2(MeshT *this, int xi, int yi)
{
  return meshGetExt(this,xi,yi, this->x);
}
static inline double   /* __attribute__ weak */ 
meshGetyExt2(MeshT *this, int xi, int yi)
{
  return meshGetExt(this,xi,yi, this->y);
}


static inline double /* __attribute__ weak */ 
meshGetxExt(MeshT *this, int xi, int yi)
{
  double *p=this->x;
  if(xi<0 )
    return 2*MESHGETEXT__ONLY_Y__(this,0,yi,p)
      -MESHGETEXT__ONLY_Y__(this, -xi,yi,p);
  else if (xi>=this->nx)
    return  2*MESHGETEXT__ONLY_Y__(this,this->nx-1 ,yi,p)
      -MESHGETEXT__ONLY_Y__(this, 2*this->nx-xi-2,yi,p);
  if(yi<0 )
    return MESHGETEXT__GETIT__(this, xi,-yi,p);
  else if (yi>=this->ny)
    return MESHGETEXT__GETIT__(this,xi, 2*this->ny-yi-2,p);
  return meshGet__no_check(this,xi,yi,p) ;
}

static inline double /* __attribute__ weak */ 
meshGetyExt(MeshT *this, int xi, int yi)
{
  double *p=this->y;
  if(xi<0 )
    return MESHGETEXT__ONLY_Y__(this, -xi,yi,p);
  else if (xi>=this->nx)
    return MESHGETEXT__ONLY_Y__(this, 2*this->nx-xi-2,yi,p);
  if(yi<0 )
    return 2*MESHGETEXT__GETIT__(this,xi,0,p)
      -MESHGETEXT__GETIT__(this, xi,-yi,p);
  else if (yi>=this->ny)
    return  2*MESHGETEXT__GETIT__(this,xi,this->ny-1,p)
      -MESHGETEXT__GETIT__(this,xi, 2*this->ny-yi-2,p);
  return meshGet__no_check(this,xi,yi,p) ;
}

#endif // _MESH_GETEXT_H__INCLUDED_