Welcome to mirror list, hosted at ThFree Co, Russian Federation.

loop_tools.h « intern « elbeem « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f06fa7c28610cf222208a76d89ee794e5c4b867d (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/** \file elbeem/intern/loop_tools.h
 *  \ingroup elbeem
 */

// advance pointer in main loop
#define ADVANCE_POINTERS(p)	\
	ccel += (QCELLSTEP*(p));	\
	tcel += (QCELLSTEP*(p));	\
	pFlagSrc+= (p); \
	pFlagDst+= (p); \
	i+= (p);

#define MAX_CALC_ARR 4

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// init region vars
#define  GRID_REGION_INIT()   \
	const int istart = -1+gridLoopBound; \
	const int iend   = mLevel[mMaxRefine].lSizex-1-gridLoopBound; \
	LbmFloat calcCurrentMass=0; \
	LbmFloat calcCurrentVolume=0; \
	int      calcCellsFilled=0; \
	int      calcCellsEmptied=0; \
	int      calcNumUsedCells=0; \




//  -----------------------------------------------------------------------------------
// serial stuff
#if PARALLEL!=1

#define PERFORM_USQRMAXCHECK USQRMAXCHECK(usqr,ux,uy,uz, mMaxVlen, mMxvx,mMxvy,mMxvz);
#define LIST_EMPTY(x) mListEmpty.push_back( x );
#define LIST_FULL(x)  mListFull.push_back( x );
#define FSGR_ADDPART(x)  mpParticles->addFullParticle( x );

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define  GRID_REGION_START()  \
	{ /* main_region */ \
	int kstart=getForZMinBnd(), kend=getForZMaxBnd(mMaxRefine); \
	if(gridLoopBound>0){ kstart=getForZMin1(), kend=getForZMax1(mMaxRefine); } \
	int kdir = 1; \
	int jstart = gridLoopBound; \
	int jend   = mLevel[mMaxRefine].lSizey-gridLoopBound; \
	const int id=0; \
	LbmFloat *ccel = NULL, *tcel = NULL; \
	CellFlagType *pFlagSrc=NULL, *pFlagDst=NULL; \
	if(mLevel[mMaxRefine].setCurr==1) { \
	kdir = -1; \
	int temp = kend; \
	kend = kstart-1; \
	kstart = temp-1; \
	temp = id; /* dummy remove warning */ \
	} \



	

//  -----------------------------------------------------------------------------------
#else // PARALLEL==1

//#include "paraloop.h"
#define PERFORM_USQRMAXCHECK USQRMAXCHECK(usqr,ux,uy,uz, calcMaxVlen, calcMxvx,calcMxvy,calcMxvz);
#define LIST_EMPTY(x)    calcListEmpty.push_back( x );
#define LIST_FULL(x)     calcListFull.push_back( x );
#define FSGR_ADDPART(x)  calcListParts.push_back( x );


// parallel region
//was: # pragma omp parallel default(shared) 
#if COMPRESSGRIDS!=1
	// requires compressed grids...!
	ERROR!
#endif

// loop start
#define  GRID_REGION_START()  \
	{ \
	 \
	 \
	if(mSizez<2) { \
	mPanic = 1; \
	errFatal("ParaLoop::2D","Not valid...!", SIMWORLD_GENERICERROR); \
	} \
	 \
	 \
	vector<LbmPoint> calcListFull; \
	vector<LbmPoint> calcListEmpty; \
	vector<ParticleObject> calcListParts; \
	LbmFloat calcMxvx, calcMxvy, calcMxvz, calcMaxVlen; \
	calcMxvx = calcMxvy = calcMxvz = calcMaxVlen = 0.0; \
	calcListEmpty.reserve(mListEmpty.capacity() / omp_get_num_threads() ); \
	calcListFull.reserve( mListFull.capacity()  / omp_get_num_threads() ); \
	calcListParts.reserve(mSizex); \
	 \
	 \
	const int id = omp_get_thread_num(); \
	const int Nthrds = omp_get_num_threads(); \
	 \
	 \
	 \
	 \
	 \
	int kdir = 1; \
	 \
	int kstart=getForZMinBnd(), kend=getForZMaxBnd(mMaxRefine); \
	if(gridLoopBound>0){ kstart=getForZMin1(); kend=getForZMax1(mMaxRefine); } \
	LbmFloat *ccel = NULL, *tcel = NULL; \
	CellFlagType *pFlagSrc=NULL, *pFlagDst=NULL; \
	 \
	 \
	if(mLevel[mMaxRefine].setCurr==1) { \
	kdir = -1; \
	int temp = kend; \
	kend = kstart-1; \
	kstart = temp-1; \
	} \
	 \
	const int Nj = mLevel[mMaxRefine].lSizey; \
	int jstart = 0+( (id * Nj ) / Nthrds ); \
	int jend   = 0+(((id+1) * Nj ) / Nthrds ); \
	if( ((Nj/Nthrds) *Nthrds) != Nj) { \
	errMsg("LbmFsgrSolver","Invalid domain size Nj="<<Nj<<" Nthrds="<<Nthrds); \
	} \
	 \
	if(jstart<gridLoopBound) jstart = gridLoopBound; \
	if(jend>mLevel[mMaxRefine].lSizey-gridLoopBound) jend = mLevel[mMaxRefine].lSizey-gridLoopBound; \
	 \
	debMsgStd("ParaLoop::OMP",DM_MSG,"Thread:"<<id<<" i:"<<istart<<"-"<<iend<<" j:"<<jstart<<"-"<<jend<<", k:"<<kstart<<"-"<<kend<<"  ", 1); \
	 \




// para GRID LOOP END is parainc3 

#endif // PARALLEL==1


//  -----------------------------------------------------------------------------------

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define  GRID_LOOP_START()   \
	for(int k=kstart;k!=kend;k+=kdir) { \
	pFlagSrc = &RFLAG(lev, istart, jstart, k, SRCS(lev)); \
	pFlagDst = &RFLAG(lev, istart, jstart, k, TSET(lev)); \
	ccel = RACPNT(lev,     istart, jstart, k, SRCS(lev)); \
	tcel = RACPNT(lev,     istart, jstart, k, TSET(lev)); \
	for(int j=jstart;j!=jend;++j) { \
	/* for(int i=0;i<mLevel[lev].lSizex-2;   ) { */ \
	for(int i=istart;i!=iend;   ) { \
	ADVANCE_POINTERS(1); \




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define  GRID_LOOPREG_END()  \
	 \
	} /* i */ \
	int i=0; \
	ADVANCE_POINTERS(2*gridLoopBound); \
	} /* j */ \
	/* COMPRESSGRIDS!=1 */ \
	/* int i=0;  */ \
	/* ADVANCE_POINTERS(mLevel[lev].lSizex*2);  */ \
	} /* all cell loop k,j,i */ \
	if(doReduce) { } /* dummy remove warning */ \
	} /* main_region */ \
	 \




// old loop for COMPRESSGRIDS==0
#define old__GRID_LOOP_START() \
  for(int k=kstart;k<kend;++k) { \
	  for(int j=1;j<mLevel[lev].lSizey-1;++j) { \
  		for(int i=0;i<mLevel[lev].lSizex-2;   ) {