forked from pcoulier/hbemfun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bemmat_mex.cpp
3212 lines (2618 loc) · 125 KB
/
bemmat_mex.cpp
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
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*BEMMAT Boundary element system matrices.
*
* [U,T] = BEMMAT(nod,elt,typ,green,...) computes the boundary element
* system matrices. The Green's functions, specified as a full space
* solution (green='fs***') or a user specified solution (green='user'), are
* integrated over the boundary element mesh defined by its nodes, elements
* and element types.
*
* Depending on the Green's function, the following syntax is used:
*
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen2d_inplane0',E,nu)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen2d_outofplane0',mu)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen3d0',E,nu)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen2d_outofplane',Cs,Ds,rho,omega)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen2d_inplane',Cs,Cp,Ds,Dp,rho,omega)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen3d',Cs,Cp,Ds,Dp,rho,omega)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen3d',Cs,Cp,Ds,Dp,rho,omega)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreen3dt',Cs,Cp,rho,delt,t)
* [U,T] = BEMMAT(nod,elt,typ,'fsgreenf',Cs,Cp,Ds,Dp,rho,py,omega)
* [U,T] = BEMMAT(nod,elt,typ,'user',zs,r,z,ug,sg,sg0)
*
* [Ue,Te] = BEMMAT(nod,elt,typ,s,green,...)
*
*
*
* nod Nodes (nNod * 4). Each row has the layout [nodID x y z] where
* nodID is the node number and x, y, and z are the nodal
* coordinates.
* elt Elements (nElt * nColumn). Each row has the layout
* [eltID typID n1 n2 n3 ... ] where eltID is the element number,
* typID is the element type number and n1, n2, n3, ... are the node
* numbers representing the nodal connectivity of the element.
* typ Element type definitions. Cell array with the layout
* {{typID type keyOpts} ... } where typID is the element type number,
* type is the element type (string) and keyOpts is a cell array of
* strings with key options.
* green Green's function (string). 'fs***' for a full-space solution or
* 'user' for a user specified Green's function.
* mu Shear modulus (1 * 1).
* E Young's modulus (1 * 1).
* nu Poisson coefficient (1 * 1).
* Cs Shear wave velocity (1 * 1).
* Cp Dilatational wave velocity (1 * 1).
* Ds Shear damping ratio (1 * 1).
* Dp Dilatational damping ratio (1 * 1).
* rho Density (1 * 1).
* delt Time step (1 * 1) in time domain BE analysis.
* t Time (1*nTime).
* omega Circular frequency (nFreq * 1).
* py Slowness in y-direction, logarithmically sampled (nyWave * 1).
* If omega ~= 0, the wavenumber sampling is given by ky = omega * py.
* If omega == 0, the wavenumber sampling is given by ky = py.
* zs Source locations (vertical coordinate) (nzSrc * 1).
* r Receiver locations (x-coordinate) (nxRec * 1).
* z Receiver locations (z-coordinate) (nzRec * 1).
* ug Green's displacements.
* sg Green's stresses.
* sg0 Static Green's stresses, used for the regularisation of the boundary
* integral equation.
* U Boundary element displacement system matrix (nDof * nDof * ...).
* T Boundary element traction system matrix (nDof * nDof * ...).
*/
/* $Make: mex -O -output bemmat bemmat_mex.cpp bemmat.cpp eltdef.cpp
bemcollpoints.cpp shapefun.cpp bemintreg3d.cpp
bemintreg3dperiodic.cpp bemintreg2d.cpp bemintregaxi.cpp
bemintsing3d.cpp bemintsing3dperiodic.cpp bemintsing2d.cpp bemintsingaxi.cpp gausspw.cpp search1.cpp bemnormal.cpp bemdimension.cpp bemisaxisym.cpp bemisperiodic.cpp greeneval2d.cpp greeneval3d.cpp greenrotate2d.cpp greenrotate3d.cpp fsgreenf.cpp fsgreen2d_inplane.cpp fsgreen2d_outofplane.cpp besselh.cpp fsgreen3d.cpp fsgreen3dt.cpp$*/
/*
mexFunction-|
|
|--> IntegrateGreenUser ---> bemIntegrate
|
|--> IntegrateFsGreenf ---> bemIntegrate
|
|--> IntegrateFsGreen3d ---> bemIntegrate
|
|--> IntegrateFsGreen2d_inplane ---> bemIntegrate
|
|--> IntegrateFsGreenf2d_outofplane ---> bemIntegrate
|
|--> ...
*/
#include "mex.h"
#include <string.h>
#include "eltdef.h"
#include "gausspw.h"
#include "shapefun.h"
#include "bemcollpoints.h"
#include "bemmat.h"
#include "bemdimension.h"
#include "bemisaxisym.h"
#include "bemisperiodic.h"
//#include "checklicense.h"
#include <math.h>
#include <new>
// #include "mex.h"
#include <time.h>
#include <assert.h>
#ifndef __GNUC__
#define strcasecmp _strcmpi
#endif
#ifndef _int64_
typedef long long int int64;
typedef unsigned long long int uint64;
#endif
using namespace std;
//==============================================================================
static bool CacheValid=false;
static unsigned int nNod;
static double* Nod;
// static double* Nodtest;
static double* Elt;
static unsigned int nElt;
static unsigned int maxEltColumn;
static bool keyOpts=true;
static unsigned int nEltType;
static unsigned int maxKeyOpts = 50; // Maximum number of keyoptions per element type
static unsigned int* TypeID;
static unsigned int* nKeyOpt;
static char** TypeName;
static char** TypeKeyOpts;
static unsigned int probDim;
static bool probAxi;
static bool probPeriodic;
// COLLOCATION POINTS: NODAL OR CENTROID
// static int* NodalColl=0;
// static int* NodalColl=NULL;
static unsigned int* NodalColl;
// static int* CentroidColl=0;
// static int* CentroidColl=NULL;
static unsigned int* CentroidColl;
static unsigned int nCentroidColl;
static unsigned int nNodalColl;
// COLLOCATION POINT COORDINATES
static unsigned int nTotalColl;
// static double* CollPoints=0;
// static double* CollPoints=NULL;
static double* CollPoints;
// CHECK FOR COINCIDENT NODES
// static double* CoincNodes=0;
// static double* CoincNodes=NULL;
static double* CoincNodes;
static bool SlavesExist;
static unsigned int* EltParent;
static unsigned int* nEltNod;
static unsigned int* nEltColl;
static unsigned int* EltShapeN;
static unsigned int* EltShapeM;
static unsigned int* EltDim;
static unsigned int* AxiSym;
static unsigned int* Periodic;
static unsigned int* nGauss;
static unsigned int* nEltDiv;
static unsigned int* nGaussSing;
static unsigned int* nEltDivSing;
static unsigned int* ncumulEltCollIndex;
static unsigned int NEltCollIndex;
static unsigned int* eltCollIndex;
static unsigned int* RegularColl;
static unsigned int* ncumulSingularColl;
static unsigned int NSingularColl;
static unsigned int* nRegularColl;
static unsigned int* nSingularColl;
static unsigned int* ncumulEltNod;
static unsigned int NEltNod;
static double* EltNod;
static unsigned int* RefEltType;
static unsigned int* ncumulnXi;
static unsigned int NnXi;
static unsigned int* nXi;
static double* xi;
static double* H;
static unsigned int* ncumulNshape;
static unsigned int NNshape;
static double* Nshape;
static double* Mshape;
static double* dNshape;
//==============================================================================
void IntegrateGreenUser(mxArray* plhs[], int nrhs,
const mxArray* prhs[], const bool probAxi, const bool probPeriodic,
const unsigned int& probDim, const double* const Nod,
const unsigned int& nNod, const double* const Elt,
const unsigned int& nElt, const unsigned int* const TypeID,
const char* const TypeName[], const char* const TypeKeyOpts[],
const unsigned int* const nKeyOpt, const unsigned int& nEltType,
const double* const CollPoints, const unsigned int& nTotalColl,
// const int& nCentroidColl,
// const double* const CoincNodes, const bool& SlavesExist,
const bool& UmatOut,
const bool& TmatOut,
const unsigned int& greenPos,
const double* const s, const unsigned int& ms, const unsigned int& ns,
const unsigned int* const EltParent, const unsigned int* const nEltNod, const unsigned int* const nEltColl,
const unsigned int* const EltShapeN, const unsigned int* const EltShapeM, const unsigned int* const EltDim,
const unsigned int* const AxiSym, const unsigned int* const Periodic, const unsigned int* const nGauss,
const unsigned int* const nEltDiv, const unsigned int* const nGaussSing, const unsigned int* const nEltDivSing,
const unsigned int* const ncumulEltCollIndex,
// const int& NEltCollIndex,
const unsigned int* const eltCollIndex,
const unsigned int* const ncumulSingularColl, const unsigned int* const nSingularColl, const int& NSingularColl,
const unsigned int* const RegularColl,
// const int* const nRegularColl, const int* const nSingularColl,
const unsigned int* const ncumulEltNod, const double* const EltNod,
const unsigned int* const RefEltType, const unsigned int* const ncumulnXi, const unsigned int* const nXi, const double* const xi, const double* const H,
const unsigned int* const ncumulNshape, const double* const Nshape, const double* const Mshape, const double* const dNshape)
/* Initialize Green's function for user defined Green's function ('USER')
*
* greenPtr[0]=&GreenFunType; Green's function type identifier
* greenPtr[1]=&nGrSet; Number of function sets (nFreq,nTime,nCase)
* greenPtr[...] different definition for different
* Green's function types
*
*/
//==============================================================================
{
// mexPrintf("greenPos %d \n",greenPos);
// mexPrintf("greenPos %d \n",greenPos+5);
// mexPrintf("greenPos %d \n",greenPos+7);
// mexPrintf("nrhs %d \n",nrhs);
// INPUT ARGUMENT PROCESSING
if (probPeriodic)
{
if (!(nrhs==13)) throw("Wrong number of input arguments.");
}
else
{
// if ((unsigned)nrhs>greenPos+7) throw("Too many input arguments.");
// if ((unsigned)nrhs<greenPos+5) throw("Not enough input arguments."); //opnieuw!!
if (nrhs>(greenPos+7)) throw("Too many input arguments.");
if (nrhs<(greenPos+5)) throw("Not enough input arguments."); //opnieuw!!
}
// mexPrintf("nrhs<(greenPos+5): %s \n", (nrhs<(greenPos+5)) ? "true": "false");
if (!mxIsNumeric(prhs[greenPos+1])) throw("Input argument 'zs' must be numeric.");
if (mxIsSparse(prhs[greenPos+1])) throw("Input argument 'zs' must not be sparse.");
if (mxIsEmpty(prhs[greenPos+1])) throw("Input argument 'zs' must not be empty.");
const unsigned int nzs=mxGetNumberOfElements(prhs[greenPos+1]);
const double* const zs=mxGetPr(prhs[greenPos+1]);
for (unsigned int izs=1; izs<nzs; izs++) if (!(zs[izs-1]<zs[izs])) throw("Input argument 'zs' must be monotonically increasing.");
// mexPrintf("nzs: %d \n",nzs);
// for (int i=0; i<nzs ; i++)
// {
// mexPrintf("zs [%i]: %e \n",i,zs[i]);
// }
if (!mxIsNumeric(prhs[greenPos+2])) throw("Input argument 'r' must be numeric.");
if (mxIsSparse(prhs[greenPos+2])) throw("Input argument 'r' must not be sparse.");
if (mxIsEmpty(prhs[greenPos+2])) throw("Input argument 'r' must not be empty.");
const unsigned int nr=mxGetNumberOfElements(prhs[greenPos+2]);
const double* const r=mxGetPr(prhs[greenPos+2]);
for (unsigned int ir=1; ir<nr; ir++) if (!(r[ir-1]<r[ir])) throw("Input argument 'r' must be monotonically increasing.");
if (!mxIsNumeric(prhs[greenPos+3])) throw("Input argument 'z' must be numeric.");
if (mxIsSparse(prhs[greenPos+3])) throw("Input argument 'z' must not be sparse.");
if (mxIsEmpty(prhs[greenPos+3])) throw("Input argument 'z' must not be empty.");
const unsigned int nz=mxGetNumberOfElements(prhs[greenPos+3]);
const double* const z=mxGetPr(prhs[greenPos+3]);
for (unsigned int iz=1; iz<nz; iz++) if (!(z[iz-1]<z[iz])) throw("Input argument 'z' must be monotonically increasing.");
// mexPrintf("nz: %d \n",nz);
// for (int i=0; i<nz ; i++)
// {
// mexPrintf("z [%i]: %e \n",i,z[i]);
// }
if (!mxIsNumeric(prhs[greenPos+4])) throw("Input argument 'ug' must be numeric.");
if (mxIsSparse(prhs[greenPos+4])) throw("Input argument 'ug' must not be sparse.");
if (mxIsEmpty(prhs[greenPos+4])) throw("Input argument 'ug' must not be empty.");
const unsigned int nugdim=mxGetNumberOfDimensions(prhs[greenPos+4]);
const size_t* const ugdim=mxGetDimensions(prhs[greenPos+4]);
const unsigned int nugComp=ugdim[0];
const unsigned int nGreenDim=((nugdim>4)?(nugdim-4):1);
unsigned int* const greenDim=new(nothrow) unsigned int[nGreenDim];
unsigned int nGrSet=1;
greenDim[0]=1;
if (nugdim>4)
{
for (unsigned int iDim=4; iDim<nugdim; iDim++)
{
greenDim[iDim-4]=ugdim[iDim];
nGrSet=nGrSet*ugdim[iDim];
}
}
if (probDim==2)
{
if (!(probAxi) && (!((nugComp==1)|(nugComp==4)|(nugComp==9)))) throw("The first dimension of input argument 'ug' for a 2D problem must be 1 (out-of-plane), 4 (in-plane) or 9 for a 2.5D problem.");
if (probAxi && (!(nugComp==5))) throw("The first dimension of input argument 'ug' must be 4 for an axisymmetric problem .");
}
else if (probDim==3) if (!(nugComp==5)) throw("The first dimension of input argument 'ug' must be 5 for a 3D problem.");
if (!((unsigned)nzs == ((nugdim>1)? ugdim[1]:1))) throw("Input arguments 'ug' and 'zs' are incompatible");
if (!((unsigned)nr == ((nugdim>2)? ugdim[2]:1))) throw("Input arguments 'ug' and 'r' are incompatible");
if (!((unsigned)nz == ((nugdim>3)? ugdim[3]:1))) throw("Input arguments 'ug' and 'z' are incompatible");
const double* const ugRe=mxGetPr(prhs[greenPos+4]);
const double* const ugIm=mxGetPi(prhs[greenPos+4]);
const bool ugCmplx=mxIsComplex(prhs[greenPos+4]);
unsigned int ntgComp;
if (nugComp==1) ntgComp=2; // 2D, out-of-plane
if (nugComp==4) ntgComp=6; // 2D, in-plane
if (nugComp==5) ntgComp=10; // 3D / axisymmetric
if (nugComp==9) ntgComp=18; // 2.5D
if (TmatOut)
{
if (nrhs<(greenPos+7)) throw("Not enough input arguments.");
if (!mxIsNumeric(prhs[greenPos+5])) throw("Input argument 'sg' must be numeric.");
if (mxIsSparse(prhs[greenPos+5])) throw("Input argument 'sg' must not be sparse.");
const unsigned int ntgdim=mxGetNumberOfDimensions(prhs[greenPos+5]);
const size_t* const tgdim=mxGetDimensions(prhs[greenPos+5]);
if (!(tgdim[0]==(unsigned)ntgComp)) throw("The first dimension of input argument 'sg' has incorrect size.");
if (!(nugdim==ntgdim)) throw("Matrix dimensions of input arguments 'ug' and 'sg' must agree.");
for (unsigned int iDim=1; iDim<nugdim; iDim++)
{
if (!(ugdim[iDim]==tgdim[iDim])) throw("Matrix dimensions of input arguments 'ug' and 'sg' are incompatible.");
}
if (!mxIsNumeric(prhs[greenPos+6])) throw("Input argument 'sg0' must be numeric.");
if (mxIsSparse(prhs[greenPos+6])) throw("Input argument 'sg0' must not be sparse.");
const unsigned int ntg0dim=mxGetNumberOfDimensions(prhs[greenPos+6]);
const size_t* const tg0dim=mxGetDimensions(prhs[greenPos+6]);
if (!(tg0dim[0]==(unsigned)ntgComp)) throw("The first dimension of input argument 'sg0' has incorrect size.");
if (!(nugdim==ntg0dim)) throw("Matrix dimensions of input arguments 'ug' and 'sg0' must agree.");
for (unsigned int iDim=1; iDim<nugdim; iDim++)
{
if (!(ugdim[iDim]==tg0dim[iDim])) throw("Matrix dimensions of input arguments 'ug' and 'sg0' are incompatible.");
}
}
const double* const tgRe= (TmatOut? mxGetPr(prhs[greenPos+5]):0);
const double* const tgIm= (TmatOut? mxGetPi(prhs[greenPos+5]):0);
const bool tgCmplx=(TmatOut? mxIsComplex(prhs[greenPos+5]):false);
const double* const tg0Re= (TmatOut? mxGetPr(prhs[greenPos+6]):0);
const double* const tg0Im= (TmatOut? mxGetPi(prhs[greenPos+6]):0);
const bool tg0Cmplx=(TmatOut? mxIsComplex(prhs[greenPos+6]):false);
// Number of degrees of freedom points per collocation point.
unsigned int nColDof;
if (nugComp==1) nColDof=1; // 2D, out-of-plane
if (nugComp==4) nColDof=2; // 2D, in-plane
if ((nugComp==5) && !(probAxi)) nColDof=3; // 3D
if ((nugComp==5) && probAxi ) nColDof=2; // Axisymmetric
if (nugComp==9) nColDof=3; // 2.5D
// Vertical receiver coordinate is passed relative
const bool zRel=false; // ! No longer relative receiver grid ...
// Copy variables to generic array of pointers greenPtr
const unsigned int nGreenPtr=14;
const unsigned int GreenFunType=1;
const void** const greenPtr=new(nothrow) const void*[nGreenPtr];
if (greenPtr==0) throw("Out of memory.");
greenPtr[0]=&GreenFunType;
greenPtr[1]=&nzs;
greenPtr[2]=zs;
greenPtr[3]=&nr;
greenPtr[4]=r;
greenPtr[5]=&nz;
greenPtr[6]=z;
greenPtr[7]=ugRe;
greenPtr[8]=ugIm;
greenPtr[9]=tgRe;
greenPtr[10]=tgIm;
greenPtr[11]=tg0Re;
greenPtr[12]=tg0Im;
greenPtr[13]=&zRel;
// mexPrintf("nzs: %d \n",nzs);
// for (int i=0; i<nzs ; i++)
// {
// mexPrintf("zs [%i]: %d \n",i,zs[i]);
// }
// mexPrintf("nz: %d \n",nz);
// for (int i=0; i<nz ; i++)
// {
// mexPrintf("z [%i]: %d \n",i,z[i]);
// }
// Periodic problems
if (probPeriodic){
if (!mxIsNumeric(prhs[greenPos+7])) throw("Input argument 'L' must be numeric.");
if (mxIsSparse(prhs[greenPos+7])) throw("Input argument 'L' must not be sparse.");
if (mxIsComplex(prhs[greenPos+7])) throw("Input argument 'L' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+7])==1)) throw("Input argument 'L' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+8])) throw("Input argument 'ky' must be numeric.");
if (mxIsSparse(prhs[greenPos+8])) throw("Input argument 'ky' must not be sparse.");
if (mxIsComplex(prhs[greenPos+8])) throw("Input argument 'ky' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+8])>2) ||
((mxGetM(prhs[greenPos+8])>1) && (mxGetN(prhs[greenPos+8])>1)))
throw("Input argument 'ky' must be a scalar or a vector.");
if (!mxIsNumeric(prhs[greenPos+9])) throw("Input argument 'nmax' must be numeric.");
if (mxIsSparse(prhs[greenPos+9])) throw("Input argument 'nmax' must not be sparse.");
if (mxIsComplex(prhs[greenPos+9])) throw("Input argument 'nmax' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+9])==1)) throw("Input argument 'nmax' must be a scalar.");
}
const double L=(probPeriodic ? mxGetScalar(prhs[greenPos+7]) : -1.0);
const double* const ky=(probPeriodic ? mxGetPr(prhs[greenPos+8]) : 0);
const unsigned int nWave=(probPeriodic ? mxGetNumberOfElements(prhs[greenPos+8]) : 0);
const unsigned int nmax=(probPeriodic ? (unsigned int)mxGetScalar(prhs[greenPos+9]) : 0);
// OUTPUT ARGUMENT POINTERS
// unsigned int nDof=nColDof*nTotalColl;
uint64 nDof=nColDof*nTotalColl;
const unsigned int nMatDim=(probPeriodic ? 3+nGreenDim : 2+nGreenDim);
// size_t* const MatDim = new(nothrow) size_t[nMatDim];
// if (MatDim==0) throw("Out of memory.");
size_t* const MatDimU = new(nothrow) size_t[nMatDim];
if (MatDimU==0) throw("Out of memory.");
MatDimU[0]=(s==0 ? nDof : ms);
MatDimU[1]=(s==0 ? nDof : ns);
if (UmatOut==false){MatDimU[0]=0; MatDimU[1]=0;}
for (unsigned int iDim=0; iDim<nGreenDim; iDim++) MatDimU[2+iDim]=greenDim[iDim];
if (probPeriodic) MatDimU[nMatDim-1]=nWave;
bool uCmplx=false;
if (ugCmplx || probPeriodic){uCmplx=true;}
// plhs[0]=mxCreateNumericArray(nMatDim,MatDim,mxDOUBLE_CLASS,mxCOMPLEX);
plhs[0]=mxCreateNumericArray(nMatDim,MatDimU,mxDOUBLE_CLASS,(uCmplx ? mxCOMPLEX : mxREAL));
double* const URe=mxGetPr(plhs[0]);
double* const UIm=mxGetPi(plhs[0]);
// mexPrintf("MatDimU[0]: %d\n",MatDimU[0]);
// mexPrintf("MatDimU[1]: %d\n",MatDimU[1]);
bool tCmplx=false;
if (tgCmplx || probPeriodic){tCmplx=true;}
double* TRe=0;
double* TIm=0;
if (TmatOut)
{
size_t* const MatDimT = new(nothrow) size_t[nMatDim];
if (MatDimT==0) throw("Out of memory.");
MatDimT[0]=(s==0 ? nDof : ms);
MatDimT[1]=(s==0 ? nDof : ns);
for (unsigned int iDim=0; iDim<nGreenDim; iDim++) MatDimT[2+iDim]=greenDim[iDim];
if (probPeriodic) MatDimT[nMatDim-1]=nWave;
plhs[1]=mxCreateNumericArray(nMatDim,MatDimT,mxDOUBLE_CLASS,(tCmplx ? mxCOMPLEX : mxREAL));
TRe=mxGetPr(plhs[1]);
TIm=mxGetPi(plhs[1]);
delete [] MatDimT;
}
delete [] MatDimU;
// BEMMAT
bemmat(probAxi,probPeriodic,probDim,nColDof,UmatOut,TmatOut,Nod,nNod,Elt,nElt,TypeID,
TypeName,TypeKeyOpts,nKeyOpt,nEltType,CollPoints,nTotalColl,
greenPtr,nGrSet,nugComp,
ugCmplx,tgCmplx,tg0Cmplx,URe,UIm,TRe,TIm,s,ms,ns,L,ky,nWave,nmax,
EltParent,nEltNod,nEltColl,EltShapeN,EltShapeM,EltDim,AxiSym,Periodic,nGauss,nEltDiv,nGaussSing,nEltDivSing,
ncumulEltCollIndex,eltCollIndex,
ncumulSingularColl,nSingularColl,NSingularColl,
RegularColl,
ncumulEltNod,EltNod,
RefEltType,ncumulnXi,nXi,xi,H,ncumulNshape,Nshape,Mshape,dNshape);
delete [] greenPtr;
delete [] greenDim;
}
//==============================================================================
void IntegrateFsGreenf(mxArray* plhs[], int nrhs, const mxArray* prhs[],
const bool probAxi, const bool probPeriodic, const unsigned int& probDim,
const double* const Nod,const unsigned int& nNod,
const double* const Elt,const unsigned int& nElt,
const unsigned int* const TypeID, char** const TypeName,
char** const TypeKeyOpts, const unsigned int* const nKeyOpt,
const unsigned int& nEltType, const double* const CollPoints,
const unsigned int& nTotalColl,
// const int& nCentroidColl,
// const double* const CoincNodes, const bool& SlavesExist,
const bool& UmatOut,
const bool& TmatOut,
const unsigned int& greenPos,
const double* const s, const unsigned int& ms, const unsigned int& ns,
const unsigned int* const EltParent, const unsigned int* const nEltNod, const unsigned int* const nEltColl,
const unsigned int* const EltShapeN, const unsigned int* const EltShapeM, const unsigned int* const EltDim,
const unsigned int* const AxiSym, const unsigned int* const Periodic, const unsigned int* const nGauss,
const unsigned int* const nEltDiv, const unsigned int* const nGaussSing, const unsigned int* const nEltDivSing,
const unsigned int* const ncumulEltCollIndex,
// const int& NEltCollIndex,
const unsigned int* const eltCollIndex,
const unsigned int* const ncumulSingularColl, const unsigned int* const nSingularColl, const int& NSingularColl,
const unsigned int* const RegularColl,
// const int* const nRegularColl, const int* const nSingularColl,
const unsigned int* const ncumulEltNod, const double* const EltNod,
const unsigned int* const RefEltType, const unsigned int* const ncumulnXi, const unsigned int* const nXi, const double* const xi, const double* const H,
const unsigned int* const ncumulNshape, const double* const Nshape, const double* const Mshape, const double* const dNshape)
/* Initialize 2.5D Green's function (fsgreenf)
*
*/
//==============================================================================
{
// INPUT ARGUMENT PROCESSING
if (!(nrhs==11)) throw("Wrong number of input arguments.");
if (!mxIsNumeric(prhs[greenPos+1])) throw("Input argument 'Cs' must be numeric.");
if (mxIsSparse(prhs[greenPos+1])) throw("Input argument 'Cs' must not be sparse.");
if (mxIsComplex(prhs[greenPos+1])) throw("Input argument 'Cs' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+1])==1)) throw("Input argument 'Cs' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+2])) throw("Input argument 'Cp' must be numeric.");
if (mxIsSparse(prhs[greenPos+2])) throw("Input argument 'Cp' must not be sparse.");
if (mxIsComplex(prhs[greenPos+2])) throw("Input argument 'Cp' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+2])==1)) throw("Input argument 'Cp' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+3])) throw("Input argument 'Ds' must be numeric.");
if (mxIsSparse(prhs[greenPos+3])) throw("Input argument 'Ds' must not be sparse.");
if (mxIsComplex(prhs[greenPos+3])) throw("Input argument 'Ds' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+3])==1)) throw("Input argument 'Ds' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+4])) throw("Input argument 'Dp' must be numeric.");
if (mxIsSparse(prhs[greenPos+4])) throw("Input argument 'Dp' must not be sparse.");
if (mxIsComplex(prhs[greenPos+4])) throw("Input argument 'Dp' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+4])==1)) throw("Input argument 'Dp' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+5])) throw("Input argument 'rho' must be numeric.");
if (mxIsSparse(prhs[greenPos+5])) throw("Input argument 'rho' must not be sparse.");
if (mxIsComplex(prhs[greenPos+5])) throw("Input argument 'rho' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+5])==1)) throw("Input argument 'rho' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+6])) throw("Input argument 'py' must be numeric.");
if (mxIsSparse(prhs[greenPos+6])) throw("Input argument 'py' must not be sparse.");
if (mxIsComplex(prhs[greenPos+6])) throw("Input argument 'py' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+6])>2) ||
((mxGetM(prhs[greenPos+6])>1) && (mxGetN(prhs[greenPos+6])>1)))
throw("Input argument 'py' must be a scalar or a vector.");
if (!mxIsNumeric(prhs[greenPos+7])) throw("Input argument 'omega' must be numeric.");
if (mxIsSparse(prhs[greenPos+7])) throw("Input argument 'omega' must not be sparse.");
if (mxIsComplex(prhs[greenPos+7])) throw("Input argument 'omega' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+7])>2) ||
((mxGetM(prhs[greenPos+7])>1) && (mxGetN(prhs[greenPos+7])>1)))
throw("Input argument 'omega' must be a scalar or a vector.");
const unsigned int nugComp=9;
const unsigned int nColDof=3;
const double Cs = mxGetScalar(prhs[greenPos+1]);
const double Cp = mxGetScalar(prhs[greenPos+2]);
const double Ds = mxGetScalar(prhs[greenPos+3]);
const double Dp = mxGetScalar(prhs[greenPos+4]);
const double rho = mxGetScalar(prhs[greenPos+5]);
const double* const py = mxGetPr(prhs[greenPos+6]);
const unsigned int nWave = mxGetNumberOfElements(prhs[greenPos+6]);
const double* const omega = mxGetPr(prhs[greenPos+7]);
const unsigned int nFreq = mxGetNumberOfElements(prhs[greenPos+7]);
const unsigned int nGrSet=nFreq*nWave;
const bool ugCmplx=true;
const bool tgCmplx=true;
const bool tg0Cmplx=true;
// OUTPUT ARGUMENT LAST DIMENSIONS
const unsigned int nGreenDim=2;
unsigned int* const greenDim=new(nothrow) unsigned int[nGreenDim];
greenDim[0]=nWave;
greenDim[1]=nFreq;
// COPY VARIABLES TO GENERIC ARRAY OF POINTERS GREENPTR
const unsigned int nGreenPtr=10;
const unsigned int GreenFunType=2;
const void** const greenPtr=new(nothrow) const void*[nGreenPtr];
if (greenPtr==0) throw("Out of memory.");
greenPtr[0]=&GreenFunType;
greenPtr[1]=&Cs;
greenPtr[2]=&Cp;
greenPtr[3]=&Ds;
greenPtr[4]=&Dp;
greenPtr[5]=ρ
greenPtr[6]=&nWave;
greenPtr[7]=&nFreq;
greenPtr[8]=py;
greenPtr[9]=omega;
// OUTPUT ARGUMENT POINTERS
//unsigned int nDof=nColDof*nTotalColl;
uint64 nDof=nColDof*nTotalColl;
const unsigned int nMatDim=2+nGreenDim;
size_t* const MatDim = new(nothrow) size_t[nMatDim];
if (MatDim==0) throw("Out of memory.");
MatDim[0]=(s==0 ? nDof : ms);
MatDim[1]=(s==0 ? nDof : ns);
for (unsigned int iDim=2; iDim<nMatDim; iDim++) MatDim[iDim]=greenDim[iDim-2];
plhs[0]=mxCreateNumericArray(2+nGreenDim,MatDim,mxDOUBLE_CLASS,(ugCmplx ? mxCOMPLEX : mxREAL));
double* const URe=mxGetPr(plhs[0]);
double* const UIm=mxGetPi(plhs[0]);
double* TRe=0;
double* TIm=0;
if (TmatOut)
{
plhs[1]=mxCreateNumericArray(2+nGreenDim,MatDim,mxDOUBLE_CLASS,(tgCmplx ? mxCOMPLEX : mxREAL));
TRe=mxGetPr(plhs[1]);
TIm=mxGetPi(plhs[1]);
}
delete [] MatDim;
// BEMMAT
const double L=-1.0;
const double* const ky=0;
const unsigned int nky=0;
const unsigned int nmax=0;
bemmat(probAxi,probPeriodic,probDim,nColDof,UmatOut,TmatOut,Nod,nNod,Elt,nElt,TypeID,
TypeName,TypeKeyOpts,nKeyOpt,nEltType,CollPoints,nTotalColl,
greenPtr,nGrSet,nugComp,
ugCmplx,tgCmplx,tg0Cmplx,URe,UIm,TRe,TIm,s,ms,ns,L,ky,nky,nmax,
EltParent,nEltNod,nEltColl,EltShapeN,EltShapeM,EltDim,AxiSym,Periodic,nGauss,nEltDiv,nGaussSing,nEltDivSing,
ncumulEltCollIndex,eltCollIndex,
ncumulSingularColl,nSingularColl,NSingularColl,
RegularColl,
ncumulEltNod,EltNod,
RefEltType,ncumulnXi,nXi,xi,H,ncumulNshape,Nshape,Mshape,dNshape);
delete [] greenPtr;
delete [] greenDim;
}
//==============================================================================
void IntegrateFsGreen3d(mxArray* plhs[], int nrhs, const mxArray* prhs[],
const bool probAxi, const bool probPeriodic, const unsigned int& probDim,
const double* const Nod,const unsigned int& nNod,
const double* const Elt,const unsigned int& nElt,
const unsigned int* const TypeID, char** const TypeName,
char** const TypeKeyOpts, const unsigned int* const nKeyOpt,
const unsigned int& nEltType, const double* const CollPoints,
const unsigned int& nTotalColl,
// const int& nCentroidColl,
// const double* const CoincNodes, const bool& SlavesExist,
const bool& UmatOut,
const bool& TmatOut,
const unsigned int& greenPos,
const double* const s, const unsigned int& ms, const unsigned int& ns,
const unsigned int* const EltParent, const unsigned int* const nEltNod, const unsigned int* const nEltColl,
const unsigned int* const EltShapeN, const unsigned int* const EltShapeM, const unsigned int* const EltDim,
const unsigned int* const AxiSym, const unsigned int* const Periodic, const unsigned int* const nGauss,
const unsigned int* const nEltDiv, const unsigned int* const nGaussSing, const unsigned int* const nEltDivSing,
const unsigned int* const ncumulEltCollIndex,
// const int& NEltCollIndex,
const unsigned int* const eltCollIndex,
const unsigned int* const ncumulSingularColl, const unsigned int* const nSingularColl, const int& NSingularColl,
const unsigned int* const RegularColl,
// const int* const nRegularColl, const int* const nSingularColl,
const unsigned int* const ncumulEltNod, const double* const EltNod,
const unsigned int* const RefEltType, const unsigned int* const ncumulnXi, const unsigned int* const nXi, const double* const xi, const double* const H,
const unsigned int* const ncumulNshape, const double* const Nshape, const double* const Mshape, const double* const dNshape)
/* Initialize Green's function for 3D Full space solution (fsgreen3d)
*
*/
//==============================================================================
{
// INPUT ARGUMENT PROCESSING
// if ((probPeriodic&&(!(nrhs==13))) | (!(probPeriodic)&&(!(nrhs==10)))) throw("Wrong number of input arguments.");
if (probPeriodic)
{
if (!(nrhs==13)) throw("Wrong number of input arguments.");
}
else
{
if (nrhs>(greenPos+7)) throw("Too many input arguments.");
if (nrhs<(greenPos+5)) throw("Not enough input arguments."); //opnieuw!!
}
if (!mxIsNumeric(prhs[greenPos+1])) throw("Input argument 'Cs' must be numeric.");
if (mxIsSparse(prhs[greenPos+1])) throw("Input argument 'Cs' must not be sparse.");
if (mxIsComplex(prhs[greenPos+1])) throw("Input argument 'Cs' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+1])==1)) throw("Input argument 'Cs' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+2])) throw("Input argument 'Cp' must be numeric.");
if (mxIsSparse(prhs[greenPos+2])) throw("Input argument 'Cp' must not be sparse.");
if (mxIsComplex(prhs[greenPos+2])) throw("Input argument 'Cp' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+2])==1)) throw("Input argument 'Cp' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+3])) throw("Input argument 'Ds' must be numeric.");
if (mxIsSparse(prhs[greenPos+3])) throw("Input argument 'Ds' must not be sparse.");
if (mxIsComplex(prhs[greenPos+3])) throw("Input argument 'Ds' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+3])==1)) throw("Input argument 'Ds' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+4])) throw("Input argument 'Dp' must be numeric.");
if (mxIsSparse(prhs[greenPos+4])) throw("Input argument 'Dp' must not be sparse.");
if (mxIsComplex(prhs[greenPos+4])) throw("Input argument 'Dp' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+4])==1)) throw("Input argument 'Dp' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+5])) throw("Input argument 'rho' must be numeric.");
if (mxIsSparse(prhs[greenPos+5])) throw("Input argument 'rho' must not be sparse.");
if (mxIsComplex(prhs[greenPos+5])) throw("Input argument 'rho' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+5])==1)) throw("Input argument 'rho' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+6])) throw("Input argument 'omega' must be numeric.");
if (mxIsSparse(prhs[greenPos+6])) throw("Input argument 'omega' must not be sparse.");
if (mxIsComplex(prhs[greenPos+6])) throw("Input argument 'omega' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+6])>2) ||
((mxGetM(prhs[greenPos+6])>1) && (mxGetN(prhs[greenPos+6])>1)))
throw("Input argument 'omega' must be a scalar or a vector.");
if (probPeriodic){
if (!mxIsNumeric(prhs[greenPos+7])) throw("Input argument 'L' must be numeric.");
if (mxIsSparse(prhs[greenPos+7])) throw("Input argument 'L' must not be sparse.");
if (mxIsComplex(prhs[greenPos+7])) throw("Input argument 'L' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+7])==1)) throw("Input argument 'L' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+8])) throw("Input argument 'ky' must be numeric.");
if (mxIsSparse(prhs[greenPos+8])) throw("Input argument 'ky' must not be sparse.");
if (mxIsComplex(prhs[greenPos+8])) throw("Input argument 'ky' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+8])>2) ||
((mxGetM(prhs[greenPos+8])>1) && (mxGetN(prhs[greenPos+8])>1)))
throw("Input argument 'ky' must be a scalar or a vector.");
if (!mxIsNumeric(prhs[greenPos+9])) throw("Input argument 'nmax' must be numeric.");
if (mxIsSparse(prhs[greenPos+9])) throw("Input argument 'nmax' must not be sparse.");
if (mxIsComplex(prhs[greenPos+9])) throw("Input argument 'nmax' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+9])==1)) throw("Input argument 'nmax' must be a scalar.");
}
const unsigned int nugComp=5;
const unsigned int nColDof=(probAxi ? 2 : 3);
const double Cs=mxGetScalar(prhs[greenPos+1]);
const double Cp=mxGetScalar(prhs[greenPos+2]);
const double Ds=mxGetScalar(prhs[greenPos+3]);
const double Dp=mxGetScalar(prhs[greenPos+4]);
const double rho=mxGetScalar(prhs[greenPos+5]);
const unsigned int nFreq=mxGetNumberOfElements(prhs[greenPos+6]);
const double* const omega=mxGetPr(prhs[greenPos+6]);
const double L=(probPeriodic ? mxGetScalar(prhs[greenPos+7]) : -1.0);
const double* const ky=(probPeriodic ? mxGetPr(prhs[greenPos+8]) : 0);
const unsigned int nWave=(probPeriodic ? mxGetNumberOfElements(prhs[greenPos+8]) : 0);
const unsigned int nmax=(probPeriodic ? (unsigned int)mxGetScalar(prhs[greenPos+9]) : 0);
const unsigned int nGrSet=nFreq;
const bool ugCmplx=true;
const bool tgCmplx=true;
const bool tg0Cmplx=false;
// OUTPUT ARGUMENT LAST DIMENSIONS
const unsigned int nGreenDim=1;
unsigned int* const greenDim=new(nothrow) unsigned int[nGreenDim];
greenDim[0]=nFreq;
// COPY VARIABLES TO GENERIC ARRAY OF POINTERS GREENPTR
const unsigned int nGreenPtr=8;
const unsigned int GreenFunType=3;
const void** const greenPtr=new(nothrow) const void*[nGreenPtr];
if (greenPtr==0) throw("Out of memory.");
greenPtr[0]=&GreenFunType;
greenPtr[1]=&Cs;
greenPtr[2]=&Cp;
greenPtr[3]=&Ds;
greenPtr[4]=&Dp;
greenPtr[5]=ρ
greenPtr[6]=&nFreq;
greenPtr[7]=omega;
// OUTPUT ARGUMENT POINTERS
// unsigned int nDof=nColDof*nTotalColl;
uint64 nDof=nColDof*nTotalColl;
const unsigned int nMatDim=(probPeriodic ? 3+nGreenDim : 2+nGreenDim);
size_t* const MatDim = new(nothrow) size_t[nMatDim];
if (MatDim==0) throw("Out of memory.");
MatDim[0]=(s==0 ? nDof : ms);
MatDim[1]=(s==0 ? nDof : ns);
for (unsigned int iDim=0; iDim<nGreenDim; iDim++) MatDim[2+iDim]=greenDim[iDim];
if (probPeriodic) MatDim[nMatDim-1]=nWave;
bool uCmplx=false;
if (ugCmplx || probPeriodic){uCmplx=true;}
plhs[0]=mxCreateNumericArray(nMatDim,MatDim,mxDOUBLE_CLASS,(uCmplx ? mxCOMPLEX : mxREAL));
double* const URe=mxGetPr(plhs[0]);
double* const UIm=mxGetPi(plhs[0]);
bool tCmplx=false;
if (tgCmplx || probPeriodic){tCmplx=true;}
double* TRe=0;
double* TIm=0;
if (TmatOut)
{
plhs[1]=mxCreateNumericArray(nMatDim,MatDim,mxDOUBLE_CLASS,(tCmplx ? mxCOMPLEX : mxREAL));
TRe=mxGetPr(plhs[1]);
TIm=mxGetPi(plhs[1]);
}
delete [] MatDim;
// BEMMAT
bemmat(probAxi,probPeriodic,probDim,nColDof,UmatOut,TmatOut,Nod,nNod,Elt,nElt,TypeID,
TypeName,TypeKeyOpts,nKeyOpt,nEltType,CollPoints,nTotalColl,
greenPtr,nGrSet,nugComp,
ugCmplx,tgCmplx,tg0Cmplx,URe,UIm,TRe,TIm,s,ms,ns,L,ky,nWave,nmax,
EltParent,nEltNod,nEltColl,EltShapeN,EltShapeM,EltDim,AxiSym,Periodic,nGauss,nEltDiv,nGaussSing,nEltDivSing,
ncumulEltCollIndex,eltCollIndex,
ncumulSingularColl,nSingularColl,NSingularColl,
RegularColl,
ncumulEltNod,EltNod,
RefEltType,ncumulnXi,nXi,xi,H,ncumulNshape,Nshape,Mshape,dNshape);
delete [] greenPtr;
delete [] greenDim;
}
//==============================================================================
void IntegrateFsGreen3d0(mxArray* plhs[], int nrhs, const mxArray* prhs[],
const bool probAxi, const bool probPeriodic, const unsigned int& probDim,
const double* const Nod,const unsigned int& nNod,
const double* const Elt,const unsigned int& nElt,
const unsigned int* const TypeID, char** const TypeName,
char** const TypeKeyOpts, const unsigned int* const nKeyOpt,
const unsigned int& nEltType, const double* const CollPoints,
const unsigned int& nTotalColl,
// const int& nCentroidColl,
// const double* const CoincNodes, const bool& SlavesExist,
const bool& UmatOut,
const bool& TmatOut,
const unsigned int& greenPos,
const double* const s, const unsigned int& ms, const unsigned int& ns,
const unsigned int* const EltParent, const unsigned int* const nEltNod, const unsigned int* const nEltColl,
const unsigned int* const EltShapeN, const unsigned int* const EltShapeM, const unsigned int* const EltDim,
const unsigned int* const AxiSym, const unsigned int* const Periodic, const unsigned int* const nGauss,
const unsigned int* const nEltDiv, const unsigned int* const nGaussSing, const unsigned int* const nEltDivSing,
const unsigned int* const ncumulEltCollIndex,
// const int& NEltCollIndex,
const unsigned int* const eltCollIndex,
const unsigned int* const ncumulSingularColl, const unsigned int* const nSingularColl, const int& NSingularColl,
const unsigned int* const RegularColl,
// const int* const nRegularColl, const int* const nSingularColl,
const unsigned int* const ncumulEltNod, const double* const EltNod,
const unsigned int* const RefEltType, const unsigned int* const ncumulnXi, const unsigned int* const nXi, const double* const xi, const double* const H,
const unsigned int* const ncumulNshape, const double* const Nshape, const double* const Mshape, const double* const dNshape)
/* Initialize Green's function for static 3D Full space solution (FsGreen3d0)
*
*
*/
//==============================================================================
{
// mexPrintf("TestIntegrate 3d0 \n");
// mexPrintf("UmatOut: %s \n", UmatOut ? "true": "false");
// INPUT ARGUMENT PROCESSING
if ((probPeriodic&&(!(nrhs==10))) | (!(probPeriodic)&&(!((unsigned)nrhs==greenPos+3)))) throw("Wrong number of input arguments.");
if (!mxIsNumeric(prhs[greenPos+1])) throw("Input argument 'E' must be numeric.");
if (mxIsSparse(prhs[greenPos+1])) throw("Input argument 'E' must not be sparse.");
if (mxIsComplex(prhs[greenPos+1])) throw("Input argument 'E' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+1])==1)) throw("Input argument 'E' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+2])) throw("Input argument 'nu' must be numeric.");
if (mxIsSparse(prhs[greenPos+2])) throw("Input argument 'nu' must not be sparse.");
if (mxIsComplex(prhs[greenPos+2])) throw("Input argument 'nu' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+2])==1)) throw("Input argument 'nu' must be a scalar.");
if (probPeriodic){
if (!mxIsNumeric(prhs[greenPos+3])) throw("Input argument 'L' must be numeric.");
if (mxIsSparse(prhs[greenPos+3])) throw("Input argument 'L' must not be sparse.");
if (mxIsComplex(prhs[greenPos+3])) throw("Input argument 'L' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+3])==1)) throw("Input argument 'L' must be a scalar.");
if (!mxIsNumeric(prhs[greenPos+4])) throw("Input argument 'ky' must be numeric.");
if (mxIsSparse(prhs[greenPos+4])) throw("Input argument 'ky' must not be sparse.");
if (mxIsComplex(prhs[greenPos+4])) throw("Input argument 'ky' must be real.");
if ((mxGetNumberOfDimensions(prhs[greenPos+4])>2) ||
((mxGetM(prhs[greenPos+4])>1) && (mxGetN(prhs[greenPos+4])>1)))
throw("Input argument 'ky' must be a scalar or a vector.");
if (!mxIsNumeric(prhs[greenPos+5])) throw("Input argument 'nmax' must be numeric.");
if (mxIsSparse(prhs[greenPos+5])) throw("Input argument 'nmax' must not be sparse.");
if (mxIsComplex(prhs[greenPos+5])) throw("Input argument 'nmax' must be real.");
if (!(mxGetNumberOfElements(prhs[greenPos+5])==1)) throw("Input argument 'nmax' must be a scalar.");
}
const unsigned int nugComp=5;
const unsigned int nColDof=(probAxi ? 2 : 3);
const double E=mxGetScalar(prhs[greenPos+1]);
const double nu=mxGetScalar(prhs[greenPos+2]);
const double L=(probPeriodic ? mxGetScalar(prhs[greenPos+3]) : -1.0);
const double* const ky=(probPeriodic ? mxGetPr(prhs[greenPos+4]) : 0);
const unsigned int nWave=(probPeriodic ? mxGetNumberOfElements(prhs[greenPos+4]) : 0);
const unsigned int nmax=(probPeriodic ? (unsigned int)mxGetScalar(prhs[greenPos+5]) : 0);
const double mu=0.5*E/(1.0+nu);
const double M=E*(1.0-nu)/(1.0+nu)/(1.0-2.0*nu);
const double rho=1.0;
const double Cs=sqrt(mu/rho);
const double Cp=sqrt(M/rho);
const double Ds=0.0;
const double Dp=0.0;
const unsigned int nFreq=1;
double* const omega = new(nothrow) double[nFreq];
omega[0]=0.0;
const unsigned int nGrSet=nFreq;
const bool ugCmplx=false;
const bool tgCmplx=false;
const bool tg0Cmplx=false;
// OUTPUT ARGUMENT LAST DIMENSIONS
const unsigned int nGreenDim=1;
unsigned int* const greenDim=new(nothrow) unsigned int[nGreenDim];
greenDim[0]=nFreq;
// COPY VARIABLES TO GENERIC ARRAY OF POINTERS GREENPTR
const unsigned int nGreenPtr=8;
const unsigned int GreenFunType=3;
const void** const greenPtr=new(nothrow) const void*[nGreenPtr];
if (greenPtr==0) throw("Out of memory.");
greenPtr[0]=&GreenFunType;
greenPtr[1]=&Cs;
greenPtr[2]=&Cp;
greenPtr[3]=&Ds;
greenPtr[4]=&Dp;
greenPtr[5]=ρ
greenPtr[6]=&nFreq;
greenPtr[7]=omega;
// OUTPUT ARGUMENT POINTERS
// unsigned int nDof=nColDof*nTotalColl;
uint64 nDof=nColDof*nTotalColl;
const unsigned int nMatDim=(probPeriodic ? 3+nGreenDim : 2+nGreenDim);
// size_t* const MatDim = new(nothrow) size_t[nMatDim];
// if (MatDim==0) throw("Out of memory.");
// MatDim[0]=(s==0 ? nDof : ms);
// MatDim[1]=(s==0 ? nDof : ns);
size_t* const MatDimU = new(nothrow) size_t[nMatDim];
if (MatDimU==0) throw("Out of memory.");
MatDimU[0]=(s==0 ? nDof : ms);
MatDimU[1]=(s==0 ? nDof : ns);
if (UmatOut==false){MatDimU[0]=0; MatDimU[1]=0;}
for (unsigned int iDim=0; iDim<nGreenDim; iDim++) MatDimU[2+iDim]=greenDim[iDim];
if (probPeriodic) MatDimU[nMatDim-1]=nWave;
bool uCmplx=false;
if (ugCmplx || probPeriodic){uCmplx=true;}
plhs[0]=mxCreateNumericArray(nMatDim,MatDimU,mxDOUBLE_CLASS,(uCmplx ? mxCOMPLEX : mxREAL));
double* const URe=mxGetPr(plhs[0]);