Source

PetIGA / src / petigapoint.c

Full commit
Lisandro Dalcin f3d7eb8 









Lisandro Dalcin b5d8d61 
Lisandro Dalcin f3d7eb8 













Lisandro Dalcin 0828d5d 
Lisandro Dalcin f3d7eb8 

Lisandro Dalcin 67ed8c1 





Lisandro Dalcin 6638a7d 









Lisandro Dalcin 67ed8c1 






Lisandro Dalcin 80b6e9f 










Lisandro Dalcin 67ed8c1 










Lisandro Dalcin acbe5e1 
Lisandro Dalcin 67ed8c1 
Lisandro Dalcin d67d90c 


Lisandro Dalcin f3d7eb8 




Lisandro Dalcin f0d255a 








Lisandro Dalcin f785be3 





Lisandro Dalcin d67d90c 


Lisandro Dalcin f785be3 


Lisandro Dalcin d67d90c 
Lisandro Dalcin f785be3 
Lisandro Dalcin d67d90c 
Lisandro Dalcin f785be3 
Lisandro Dalcin d67d90c 
Lisandro Dalcin f785be3 
Lisandro Dalcin f0d255a 



Lisandro Dalcin b92aa5e 










Lisandro Dalcin f3d7eb8 










Lisandro Dalcin 95c4f98 










Lisandro Dalcin 946f2e9 












Lisandro Dalcin 9116c8b 
Lisandro Dalcin f0d255a 
Lisandro Dalcin f3d7eb8 


Lisandro Dalcin f0d255a 



Lisandro Dalcin f3d7eb8 

Lisandro Dalcin f0d255a 




Lisandro Dalcin 69946e1 
Lisandro Dalcin f0d255a 




Lisandro Dalcin 69946e1 
Lisandro Dalcin f3d7eb8 
Nathan Collier a19fd73 
Lisandro Dalcin 69946e1 
Lisandro Dalcin f3d7eb8 


Lisandro Dalcin 9116c8b 

Lisandro Dalcin 8192bd7 
Nathan Collier c0fa80d 

Lisandro Dalcin 9116c8b 

Lisandro Dalcin 15c8ec5 
Lisandro Dalcin 8192bd7 

Lisandro Dalcin 23b658f 
Lisandro Dalcin 8192bd7 
Lisandro Dalcin 9116c8b 



Lisandro Dalcin 23b658f 




Lisandro Dalcin 9bb9f2d 
Lisandro Dalcin 23b658f 

Nathan Collier c0fa80d 

Lisandro Dalcin 23b658f 




Lisandro Dalcin 9116c8b 
Lisandro Dalcin 15c8ec5 
Lisandro Dalcin 9116c8b 

Lisandro Dalcin 15c8ec5 
Lisandro Dalcin 9bb9f2d 
Lisandro Dalcin dc62ba9 
Lisandro Dalcin 15c8ec5 
Nathan Collier c0fa80d 

Lisandro Dalcin 15c8ec5 




Lisandro Dalcin 4876d5d 
Nathan Collier c0fa80d 
Lisandro Dalcin 4876d5d 
Nathan Collier c0fa80d 
Lisandro Dalcin 4876d5d 
Nathan Collier c0fa80d 
Lisandro Dalcin 5e19e94 

Lisandro Dalcin ca3d144 
Lisandro Dalcin 1de3107 









Lisandro Dalcin 946f2e9 
Lisandro Dalcin 1de3107 






Lisandro Dalcin ca3d144 





Lisandro Dalcin acbe5e1 

Lisandro Dalcin ca3d144 












Lisandro Dalcin 1de3107 
Lisandro Dalcin ca3d144 


Lisandro Dalcin 1de3107 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin ca3d144 




Lisandro Dalcin acbe5e1 
Lisandro Dalcin ca3d144 



Nathan Collier c0fa80d 
Lisandro Dalcin ca3d144 











Lisandro Dalcin 1de3107 
Lisandro Dalcin ca3d144 


Lisandro Dalcin 1de3107 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin ca3d144 




Lisandro Dalcin acbe5e1 
Lisandro Dalcin 4876d5d 
Lisandro Dalcin ca3d144 


Nathan Collier c0fa80d 
Lisandro Dalcin ca3d144 








Lisandro Dalcin 1de3107 

Lisandro Dalcin ca3d144 



Lisandro Dalcin 5e19e94 
Lisandro Dalcin 15c8ec5 
Nathan Collier c0fa80d 
Lisandro Dalcin 15c8ec5 
Nathan Collier c0fa80d 
Lisandro Dalcin 15c8ec5 
Nathan Collier c0fa80d 
Lisandro Dalcin 15c8ec5 
Nathan Collier c0fa80d 
Lisandro Dalcin 7dc7023 
Nathan Collier c0fa80d 
Lisandro Dalcin 15c8ec5 


Lisandro Dalcin 9bb9f2d 

Lisandro Dalcin ca3d144 
Lisandro Dalcin 15c8ec5 

Lisandro Dalcin 9bb9f2d 

Lisandro Dalcin 15c8ec5 









Lisandro Dalcin 9bb9f2d 

Lisandro Dalcin 15c8ec5 









Lisandro Dalcin 9bb9f2d 

Lisandro Dalcin 15c8ec5 









Lisandro Dalcin 9bb9f2d 

Lisandro Dalcin 15c8ec5 





Lisandro Dalcin 9116c8b 


Nathan Collier 2c14400 
Lisandro Dalcin 9bb9f2d 

Nathan Collier 2c14400 




Lisandro Dalcin 7dc7023 
Nathan Collier 2c14400 


Lisandro Dalcin f3d7eb8 





Lisandro Dalcin d1b0928 

Lisandro Dalcin f3d7eb8 

Lisandro Dalcin d1b0928 

Lisandro Dalcin f3d7eb8 




Lisandro Dalcin d1b0928 






Lisandro Dalcin f3d7eb8 











Lisandro Dalcin 85d0af7 

Lisandro Dalcin 80b6e9f 

Lisandro Dalcin f3d7eb8 
Lisandro Dalcin f785be3 
Lisandro Dalcin f3d7eb8 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin f3d7eb8 











Lisandro Dalcin 85d0af7 

Lisandro Dalcin 80b6e9f 

Lisandro Dalcin f3d7eb8 
Lisandro Dalcin f785be3 

Lisandro Dalcin f3d7eb8 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin f3d7eb8 




Lisandro Dalcin 85d0af7 






Lisandro Dalcin 1eef25d 

Lisandro Dalcin 85d0af7 

Lisandro Dalcin 23b658f 
Lisandro Dalcin 85d0af7 
Lisandro Dalcin d43bfa5 
Lisandro Dalcin 85d0af7 



Lisandro Dalcin f3d7eb8 


Lisandro Dalcin acbe5e1 
Lisandro Dalcin 85d0af7 
Lisandro Dalcin f3d7eb8 



Lisandro Dalcin f0d255a 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin f3d7eb8 






Lisandro Dalcin 4a4db86 
Lisandro Dalcin 85d0af7 
Lisandro Dalcin f3d7eb8 



Lisandro Dalcin f0d255a 
Lisandro Dalcin acbe5e1 
Lisandro Dalcin 4a4db86 
Lisandro Dalcin f3d7eb8 
  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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#include "petiga.h"

#undef  __FUNCT__
#define __FUNCT__ "IGAPointCreate"
PetscErrorCode IGAPointCreate(IGAPoint *_point)
{
  IGAPoint       point;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(_point,3);
  ierr = PetscCalloc1(1,_point);CHKERRQ(ierr);
  point = *_point;
  point->refct =  1;
  point->index = -1;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointDestroy"
PetscErrorCode IGAPointDestroy(IGAPoint *_point)
{
  IGAPoint       point;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(_point,1);
  point = *_point; *_point = NULL;
  if (!point) PetscFunctionReturn(0);
  if (--point->refct > 0) PetscFunctionReturn(0);
  ierr = IGAPointReset(point);CHKERRQ(ierr);
  ierr = PetscFree(point);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointReference"
PetscErrorCode IGAPointReference(IGAPoint point)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  point->refct++;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFreeWork"
static
PetscErrorCode IGAPointFreeWork(IGAPoint point)
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  {
    size_t MAX_WORK_VEC = sizeof(point->wvec)/sizeof(PetscScalar*);
    size_t MAX_WORK_MAT = sizeof(point->wmat)/sizeof(PetscScalar*);
    size_t i;
    for (i=0; i<MAX_WORK_VEC; i++)
      {ierr = PetscFree(point->wvec[i]);CHKERRQ(ierr);}
    point->nvec = 0;
    for (i=0; i<MAX_WORK_MAT; i++)
      {ierr = PetscFree(point->wmat[i]);CHKERRQ(ierr);}
    point->nmat = 0;
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointReset"
PetscErrorCode IGAPointReset(IGAPoint point)
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  if (!point) PetscFunctionReturn(0);
  PetscValidPointer(point,1);
  point->count =  0;
  point->index = -1;
  point->rational = NULL;
  point->geometry = NULL;
  point->property = NULL;
  ierr = IGAPointFreeWork(point);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointInit"
PetscErrorCode IGAPointInit(IGAPoint point,IGAElement element)
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(element,2);
  ierr = IGAPointReset(point);CHKERRQ(ierr);
  point->parent = element;
  point->neq = element->neq;
  point->nen = element->nen;
  point->dof = element->dof;
  point->dim = element->dim;
  point->nsd = element->nsd;
  point->npd = element->npd;
  point->rational = element->rational ? element->rationalW : NULL;
  point->geometry = element->geometry ? element->geometryX : NULL;
  point->property = element->property ? element->propertyA : NULL;
  { /* */
    size_t MAX_WORK_VEC = sizeof(point->wvec)/sizeof(PetscScalar*);
    size_t MAX_WORK_MAT = sizeof(point->wmat)/sizeof(PetscScalar*);
    size_t i, nv = element->nen * element->dof, nm = nv*nv;
    for (i=0; i<MAX_WORK_VEC; i++)
      {ierr = PetscMalloc1(nv,&point->wvec[i]);CHKERRQ(ierr);}
    for (i=0; i<MAX_WORK_MAT; i++)
      {ierr = PetscMalloc1(nm,&point->wmat[i]);CHKERRQ(ierr);}
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetParent"
PetscErrorCode IGAPointGetParent(IGAPoint point,IGAElement *element)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(element,2);
  *element = point->parent;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetIndex"
PetscErrorCode IGAPointGetIndex(IGAPoint point,PetscInt *index)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidIntPointer(index,2);
  *index = point->index;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetCount"
PetscErrorCode IGAPointGetCount(IGAPoint point,PetscInt *count)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidIntPointer(count,2);
  *count = point->count;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointAtBoundary"
PetscErrorCode IGAPointAtBoundary(IGAPoint point,PetscInt *axis,PetscInt *side)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  if (axis) PetscValidIntPointer(axis,2);
  if (side) PetscValidIntPointer(side,3);
  if (axis) *axis = point->atboundary ? point->boundary_id / 2 : -1;
  if (side) *side = point->atboundary ? point->boundary_id % 2 : -1;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetSizes"
PetscErrorCode IGAPointGetSizes(IGAPoint point,PetscInt *neq,PetscInt *nen,PetscInt *dof)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  if (neq) PetscValidIntPointer(neq,2);
  if (nen) PetscValidIntPointer(nen,3);
  if (dof) PetscValidIntPointer(dof,4);
  if (neq) *neq = point->neq;
  if (nen) *nen = point->nen;
  if (dof) *dof = point->dof;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetDims"
PetscErrorCode IGAPointGetDims(IGAPoint point,PetscInt *dim,PetscInt *nsd,PetscInt *npd)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  if (dim) PetscValidIntPointer(dim,2);
  if (nsd) PetscValidIntPointer(nsd,3);
  if (npd) PetscValidIntPointer(npd,4);
  if (dim) *dim = point->dim;
  if (nsd) *nsd = point->nsd;
  if (npd) *nsd = point->npd;
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetQuadrature"
PetscErrorCode IGAPointGetQuadrature(IGAPoint point,
				     PetscReal *weight,
				     PetscReal *detJac)
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  if (weight) PetscValidRealPointer(weight,3);
  if (detJac) PetscValidRealPointer(detJac,4);
  if (weight) *weight = point->weight[0];
  if (detJac) *detJac = point->detJac[0];
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetBasisFuns"
PetscErrorCode IGAPointGetBasisFuns(IGAPoint point,PetscInt der,const PetscReal *basisfuns[])
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(basisfuns,3);
  if (PetscUnlikely(der < 0 || der >= (PetscInt)(sizeof(point->basis)/sizeof(PetscReal*))))
    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,
	    "Requested derivative must be in range [0,%d], got %D",
	    (int)(sizeof(point->basis)/sizeof(PetscReal*)-1),der);
  *basisfuns = point->basis[der];
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetShapeFuns"
PetscErrorCode IGAPointGetShapeFuns(IGAPoint point,PetscInt der,const PetscReal *shapefuns[])
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(shapefuns,3);
  if (PetscUnlikely(der < 0 || der >= (PetscInt)(sizeof(point->shape)/sizeof(PetscReal*))))
    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,
	    "Requested derivative must be in range [0,%d], got %D",
	    (int)(sizeof(point->shape)/sizeof(PetscReal*)-1),der);
  *shapefuns = point->shape[der];
  PetscFunctionReturn(0);
}

EXTERN_C_BEGIN
extern void IGA_GetGeomMap        (PetscInt nen,PetscInt nsd,
				   const PetscReal N[],const PetscReal C[],PetscReal X[]);
extern void IGA_GetGradGeomMap    (PetscInt nen,PetscInt nsd,PetscInt dim,
				   const PetscReal N[],const PetscReal C[],PetscReal F[]);
extern void IGA_GetInvGradGeomMap (PetscInt nen,PetscInt nsd,PetscInt dim,
				   const PetscReal N[],const PetscReal C[],PetscReal G[]);
EXTERN_C_END

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormScale"
static PetscErrorCode IGAPointFormScale(IGAPoint p,PetscReal L[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidRealPointer(L,2);
  {
    PetscInt i;
    PetscInt dim = p->dim;
    PetscInt *ID = p->parent->ID;
    IGABasis *BD = p->parent->parent->basis;
    for (i=0; i<dim; i++)
      L[i] = BD[i]->detJ[ID[i]];
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormGeomMap"
PetscErrorCode IGAPointFormGeomMap(IGAPoint p,PetscReal x[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidRealPointer(x,2);
  if (p->geometry) {
    const PetscReal *X = p->geometry;
    IGA_GetGeomMap(p->nen,p->nsd,p->shape[0],X,x);
  } else {
    PetscInt i,dim = p->dim;
    const PetscReal *X = p->point;
    for (i=0; i<dim; i++) x[i] = X[i];
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormGradGeomMap"
PetscErrorCode IGAPointFormGradGeomMap(IGAPoint p,PetscReal F[])
{
  PetscReal L[3] = {1,1,1};
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidRealPointer(F,2);
  (void)IGAPointFormScale(p,L);
  if (p->geometry) {
    PetscInt a,dim = p->dim;
    PetscInt i,nsd = p->nsd;
    if (dim == nsd) {
      (void)PetscMemcpy(F,p->gradX[0],nsd*dim*sizeof(PetscReal));
    } else {
      const PetscReal *X = p->geometry;
      IGA_GetGradGeomMap(p->nen,nsd,dim,p->basis[1],X,F);
    }
    for (i=0; i<nsd; i++)
      for (a=0; a<dim; a++)
	F[i*dim+a] *= L[a];
  } else {
    PetscInt i,dim = p->dim;
    (void)PetscMemzero(F,dim*dim*sizeof(PetscReal));
    for (i=0; i<dim; i++) F[i*(dim+1)] = L[i];
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormInvGradGeomMap"
PetscErrorCode IGAPointFormInvGradGeomMap(IGAPoint p,PetscReal G[])
{
  PetscReal L[3] = {1,1,1};
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidRealPointer(G,2);
  (void)IGAPointFormScale(p,L);
  if (p->geometry) {
    PetscInt a,dim = p->dim;
    PetscInt i,nsd = p->nsd;
    if (dim == nsd) {
      (void)PetscMemcpy(G,p->gradX[1],dim*nsd*sizeof(PetscReal));
    } else {
      const PetscReal *X = p->geometry;
      IGA_GetInvGradGeomMap(p->nen,nsd,dim,p->basis[1],X,G);
    }
    for (a=0; a<dim; a++)
      for (i=0; i<nsd; i++)
	G[a*nsd+i] /= L[a];
  } else {
    PetscInt i,dim = p->dim;
    (void)PetscMemzero(G,dim*dim*sizeof(PetscReal));
    for (i=0; i<dim; i++) G[i*(dim+1)] = 1/L[i];
  }
  PetscFunctionReturn(0);
}

EXTERN_C_BEGIN
void igapoint_geommap       (IGAPoint p,PetscReal x[]) {(void)IGAPointFormGeomMap(p,x);}
void igapoint_gradgeommap   (IGAPoint p,PetscReal f[]) {(void)IGAPointFormGradGeomMap(p,f);}
void igapoint_invgradgeommap(IGAPoint p,PetscReal g[]) {(void)IGAPointFormInvGradGeomMap(p,g);}
EXTERN_C_END


EXTERN_C_BEGIN
extern void IGA_GetValue(PetscInt nen,PetscInt dof,const PetscReal N[],
			 const PetscScalar U[],PetscScalar u[]);
extern void IGA_GetGrad (PetscInt nen,PetscInt dof,PetscInt dim,const PetscReal N[],
			 const PetscScalar U[],PetscScalar u[]);
extern void IGA_GetHess (PetscInt nen,PetscInt dof,PetscInt dim,const PetscReal N[],
			 const PetscScalar U[],PetscScalar u[]);
extern void IGA_GetDel2 (PetscInt nen,PetscInt dof,PetscInt dim,const PetscReal N[],
			 const PetscScalar U[],PetscScalar u[]);
extern void IGA_GetDer3 (PetscInt nen,PetscInt dof,PetscInt dim,const PetscReal N[],
			 const PetscScalar U[],PetscScalar u[]);
EXTERN_C_END

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormPoint"
PetscErrorCode IGAPointFormPoint(IGAPoint p,PetscReal x[])
{ return IGAPointFormGeomMap(p,x); }

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormValue"
PetscErrorCode IGAPointFormValue(IGAPoint p,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidScalarPointer(U,2);
  PetscValidScalarPointer(u,3);
  IGA_GetValue(p->nen,p->dof,p->shape[0],U,u);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormGrad"
PetscErrorCode IGAPointFormGrad(IGAPoint p,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidScalarPointer(U,2);
  PetscValidScalarPointer(u,3);
  IGA_GetGrad(p->nen,p->dof,p->dim,p->shape[1],U,u);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormHess"
PetscErrorCode IGAPointFormHess(IGAPoint p,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidScalarPointer(U,2);
  PetscValidScalarPointer(u,3);
  IGA_GetHess(p->nen,p->dof,p->dim,p->shape[2],U,u);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormDel2"
PetscErrorCode IGAPointFormDel2(IGAPoint p,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidScalarPointer(U,2);
  PetscValidScalarPointer(u,3);
  IGA_GetDel2(p->nen,p->dof,p->dim,p->shape[2],U,u);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointFormDer3"
PetscErrorCode IGAPointFormDer3(IGAPoint p,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(p,1);
  PetscValidScalarPointer(U,2);
  PetscValidScalarPointer(u,3);
  IGA_GetDer3(p->nen,p->dof,p->dim,p->shape[3],U,u);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointInterpolate"
PetscErrorCode IGAPointInterpolate(IGAPoint point,PetscInt ider,const PetscScalar U[],PetscScalar u[])
{
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(U,4);
  PetscValidPointer(u,4);
  if (PetscUnlikely(point->index < 0))
    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Must call during point loop");
  if (PetscUnlikely(ider < 0 || ider > 3))
    SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Expecting 0<=ider<=3, got der=%D",ider);
  {
    PetscInt nen = point->nen;
    PetscInt dof = point->dof;
    PetscInt dim = point->dim;
    PetscReal *N = point->shape[ider];
    switch (ider) {
    case 0: IGA_GetValue(nen,dof,/**/N,U,u); break;
    case 1: IGA_GetGrad (nen,dof,dim,N,U,u); break;
    case 2: IGA_GetHess (nen,dof,dim,N,U,u); break;
    case 3: IGA_GetDer3 (nen,dof,dim,N,U,u); break;
    default: PetscFunctionReturn(PETSC_ERR_ARG_OUTOFRANGE);
    }
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetWorkVec"
PetscErrorCode IGAPointGetWorkVec(IGAPoint point,PetscScalar *V[])
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(V,2);
  if (PetscUnlikely(point->index < 0))
    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Must call during point loop");
  if (PetscUnlikely(point->nvec >= sizeof(point->wvec)/sizeof(PetscScalar*)))
      SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many work vectors requested");
  {
    size_t m = (size_t)(point->neq * point->dof);
    *V = point->wvec[point->nvec++];
    ierr = PetscMemzero(*V,m*sizeof(PetscScalar));CHKERRQ(ierr);
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointGetWorkMat"
PetscErrorCode IGAPointGetWorkMat(IGAPoint point,PetscScalar *M[])
{
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidPointer(M,2);
  if (PetscUnlikely(point->index < 0))
    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Must call during point loop");
  if (PetscUnlikely(point->nmat >= sizeof(point->wmat)/sizeof(PetscScalar*)))
    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Too many work matrices requested");
  {
    size_t m = (size_t)(point->neq * point->dof);
    size_t n = (size_t)(point->nen * point->dof);
    *M = point->wmat[point->nmat++];
    ierr = PetscMemzero(*M,m*n*sizeof(PetscScalar));CHKERRQ(ierr);
  }
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointAddArray"
PetscErrorCode IGAPointAddArray(IGAPoint point,PetscInt n,const PetscScalar a[],PetscScalar A[])
{
  PetscInt  i;
  PetscReal JW;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidScalarPointer(a,3);
  PetscValidScalarPointer(A,4);
  if (PetscUnlikely(point->index < 0))
    SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Must call during point loop");
  JW = point->detJac[0] * point->weight[0];
  for (i=0; i<n; i++) A[i] += a[i] * JW;
  (void)PetscLogFlops(2*n);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointAddVec"
PetscErrorCode IGAPointAddVec(IGAPoint point,const PetscScalar f[],PetscScalar F[])
{
  PetscInt       m;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidScalarPointer(f,2);
  PetscValidScalarPointer(F,3);
  m = point->neq * point->dof;
  ierr = IGAPointAddArray(point,m,f,F);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

#undef  __FUNCT__
#define __FUNCT__ "IGAPointAddMat"
PetscErrorCode IGAPointAddMat(IGAPoint point,const PetscScalar k[],PetscScalar K[])
{
  PetscInt       m,n;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscValidPointer(point,1);
  PetscValidScalarPointer(k,2);
  PetscValidScalarPointer(K,3);
  m = point->neq * point->dof;
  n = point->nen * point->dof;
  ierr = IGAPointAddArray(point,m*n,k,K);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}