/
FEM.jl
2671 lines (2568 loc) · 151 KB
/
FEM.jl
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
#local coordinate transformation type
struct CooTrafo
trafo
inv
det
orig
end
#constructor
function CooTrafo(X)
dim=size(X)
J=Array{Float64}(undef,dim[1],dim[1])
orig=X[:,end]
J[:,1:dim[2]-1]=X[:,1:end-1].-X[:,end]
if dim[2]==3 #surface triangle #TODO:implement lines and all dimensions
n=LinearAlgebra.cross(J[:,1],J[:,2])
J[:,end]=n./LinearAlgebra.norm(n)
end
Jinv=LinearAlgebra.inv(J)
det=LinearAlgebra.det(J)
CooTrafo(J,Jinv,det,orig)
end
function create_indices(smplx)
ii=Array{Int64}(undef,length(smplx),length(smplx))
for i=1:length(smplx)
for j=1:length(smplx)
ii[i,j]=smplx[i]
end
end
jj=ii'
return ii, jj
end
function create_indices(elmnt1,elmnt2)
ii=Array{Int64}(undef,length(elmnt1),length(elmnt2))
jj=Array{Int64}(undef,length(elmnt1),length(elmnt2))
for i=1:length(elmnt1)
for j=1:length(elmnt2)
ii[i,j]=elmnt1[i]
jj[i,j]=elmnt2[j]
end
end
return ii, jj
end
## the following two functions should be eventually moved to meshutils once the revision of FEM is done.
import ..Meshutils: get_line_idx, find_smplx, insert_smplx!
function collect_triangles(mesh::Mesh)
inner_triangles=[]
for tet in mesh.tetrahedra
for tri in [tet[[1,2,3]],tet[[1,2,4]],tet[[1,3,4]],tet[[2,3,4]] ]
idx=find_smplx(mesh.triangles,tri) #returns 0 if triangle is not in mesh.triangles
#this mmay be misleading. Better strategy is to count the occurence of all triangles
# if they occure once its an inner, if they occure twice its outer.
#This can be done quite easily. By populating a list of innertriangles and moving
# an inner triangle to a list of outer triangles when its detected to be already in the list
#of inner triangles. Avoiding three (or higher multiples) of occurence
# in a sanity check can be done by first checking the list on inner triangles
# for no occurence.
# Best moment to do this is after reading the raw lists from file.
if idx==0
insert_smplx!(inner_triangles,tri)
end
end
end
return inner_triangles
end
##
#TODO: write function aggregate_elements(mesh, idx el_type=:lin) for a single element
# and integrate this as method to the Mesh type
##
"""
triangles, tetrahedra, dim = aggregate_elements(mesh,el_type)
Agregate lists (`triangles` and `tetrahedra`) of lists of indexed degrees of freedom
for unstructured tetrahedral meshes. `dim` is the total number of DoF in the
mesh featured by the requested element-type (`el_type`). Available element types
are `:lin` for first order elements (the default), `:quad` for second order elements,
and `:herm` for Hermitian elements.
"""
function aggregate_elements(mesh::Mesh, el_type=:lin)
N_points=size(mesh.points)[2]
if (el_type in (:quad,:herm) ) && length(mesh.lines)==0
collect_lines!(mesh)
end
if el_type==:lin
tetrahedra=mesh.tetrahedra
triangles=mesh.triangles
dim=N_points
elseif el_type==:quad
triangles=Array{Array{UInt32,1}}(undef,length(mesh.triangles))
tetrahedra=Array{Array{UInt32,1}}(undef,length(mesh.tetrahedra))
tet=Array{UInt32}(undef,10)
tri=Array{UInt32}(undef,6)
for (idx,smplx) in enumerate(mesh.tetrahedra)
tet[1:4]=smplx[:]
tet[5]=get_line_idx(mesh,smplx[[1,2]])+N_points#find_smplx(mesh.lines,smplx[[1,2]])+N_points #TODO: type stability
tet[6]=get_line_idx(mesh,smplx[[1,3]])+N_points
tet[7]=get_line_idx(mesh,smplx[[1,4]])+N_points
tet[8]=get_line_idx(mesh,smplx[[2,3]])+N_points
tet[9]=get_line_idx(mesh,smplx[[2,4]])+N_points
tet[10]=get_line_idx(mesh,smplx[[3,4]])+N_points
tetrahedra[idx]=copy(tet)
end
for (idx,smplx) in enumerate(mesh.triangles)
tri[1:3]=smplx[:]
tri[4]=get_line_idx(mesh,smplx[[1,2]])+N_points
tri[5]=get_line_idx(mesh,smplx[[1,3]])+N_points
tri[6]=get_line_idx(mesh,smplx[[2,3]])+N_points
triangles[idx]=copy(tri)
end
dim=N_points+length(mesh.lines)
elseif el_type==:herm
#if mesh.tri2tet[1]==0xffffffff
# link_triangles_to_tetrahedra!(mesh)
#end
inner_triangles=collect_triangles(mesh) #TODO integrate into mesh structure
triangles=Array{Array{UInt32,1}}(undef,length(mesh.triangles))
tetrahedra=Array{Array{UInt32,1}}(undef,length(mesh.tetrahedra))
tet=Array{UInt32}(undef,20)
tri=Array{UInt32}(undef,13)
for (idx,smplx) in enumerate(mesh.triangles)
tri[1:3] = smplx[:]
tri[4:6] = smplx[:].+N_points
tri[7:9] = smplx[:].+2*N_points
tri[10:12] = smplx[:].+3*N_points
fcidx = find_smplx(mesh.triangles,smplx)
if fcidx !=0
tri[13] = fcidx+4*N_points
else
tri[13] = find_smplx(inner_triangles,smplx)+4*N_points+length(mesh.triangles)
end
triangles[idx]=copy(tri)
end
for (idx, smplx) in enumerate(mesh.tetrahedra)
tet[1:4] = smplx[:]
tet[5:8] = smplx[:].+N_points
tet[9:12] = smplx[:].+2*N_points
tet[13:16]= smplx[:].+3*N_points
for (jdx,tria) in enumerate([smplx[[2,3,4]],smplx[[1,3,4]],smplx[[1,2,4]],smplx[[1,2,3]]])
fcidx = find_smplx(mesh.triangles,tria)
if fcidx !=0
tet[16+jdx] = fcidx+4*N_points
else
fcidx=find_smplx(inner_triangles,tria) #TODO: Use the new int_triangles field in mesh
if fcidx==0
println("Error, face not found!!!")
return nothing
end
tet[16+jdx] = fcidx+4*N_points+length(mesh.triangles)
end
end
tetrahedra[idx]=copy(tet)
end
dim=4*N_points+length(mesh.triangles)+length(inner_triangles)
else
println("Error: element order $(:el_type) not defined!")
return nothing
end
return triangles, tetrahedra, dim
end
##
function recombine_hermite(J::CooTrafo,M)
A=zeros(ComplexF64,size(M))
J=J.trafo
if size(M)==(20,20)
valpoints=[1,2,3,4,17,18,19,20] #point indices where value is 1 NOT the derivative!
# entires that are based on these points only need no recombination
for i =valpoints
for j=valpoints
A[i,j]=copy(M[i,j]) #TODO: Chek whetehr copy is needed or even deepcopy
end
end
#now recombine entries that are based on derivativ points with value points
for k=0:3
A[5+k,valpoints]+=M[5+k,valpoints].*J[1,1]+M[9+k,valpoints].*J[1,2]+M[13+k,valpoints].*J[1,3]
A[9+k,valpoints]+=M[5+k,valpoints].*J[2,1]+M[9+k,valpoints].*J[2,2]+M[13+k,valpoints].*J[2,3]
A[13+k,valpoints]+=M[5+k,valpoints].*J[3,1]+M[9+k,valpoints].*J[3,2]+M[13+k,valpoints].*J[3,3]
A[valpoints,5+k]+=M[valpoints,5+k].*J[1,1]+M[valpoints,9+k].*J[1,2]+M[valpoints,13+k].*J[1,3]
A[valpoints,9+k]+=M[valpoints,5+k].*J[2,1]+M[valpoints,9+k].*J[2,2]+M[valpoints,13+k].*J[2,3]
A[valpoints,13+k]+=M[valpoints,5+k].*J[3,1]+M[valpoints,9+k].*J[3,2]+M[valpoints,13+k].*J[3,3]
end
#finally recombine entries based on derivative points with derivative points
for i = 5:16
if i in (5,6,7,8) #dx
Ji=J[1,:]
elseif i in (9,10,11,12) #dy
Ji=J[2,:]
elseif i in (13,14,15,16) #dz
Ji=J[3,:]
end
if i in (5,9,13)
idcs=[5,9,13]
elseif i in (6,10,14)
idcs=[6,10,14]
elseif i in (7,11,15)
idcs=[7,11,15]
elseif i in (8,12,16)
idcs=[8,12,16]
end
for j = 5:16
if j in (5,6,7,8) #dx
Jj=J[1,:]
elseif j in (9,10,11,12) #dy
Jj=J[2,:]
elseif j in (13,14,15,16) #dz
Jj=J[3,:]
end
if j in (5,9,13)
jdcs=[5,9,13]
elseif j in (6,10,14)
jdcs=[6,10,14]
elseif j in (7,11,15)
jdcs=[7,11,15]
elseif j in (8,12,16)
jdcs=[8,12,16]
end
#actual recombination
for (idk,k) in enumerate(idcs)
for (idl,l) in enumerate(jdcs)
A[i,j]+=Ji[idk]*Jj[idl]*M[k,l]
end
end
end
end
return A
elseif length(M)==20
valpoints=[1,2,3,4,17,18,19,20] #point indices where value is 1 NOT the derivative!
# entires that are based on these points only need no recombination
for i =valpoints
A[i]=copy(M[i]) #TODO: Chek whether copy is needed or even deepcopy
end
#now recombine entries that are based on derivativ points with value points
for k=0:3
A[5+k]+=M[5+k].*J[1,1]+M[9+k].*J[1,2]+M[13+k].*J[1,3]
A[9+k]+=M[5+k].*J[2,1]+M[9+k].*J[2,2]+M[13+k].*J[2,3]
A[13+k]+=M[5+k].*J[3,1]+M[9+k].*J[3,2]+M[13+k].*J[3,3]
end
return A
elseif size(M)==(13,13)
valpoints=[1,2,3,13]#point indices where value is 1 NOT the derivative!
# entires that are based on these points only need no recombination
for i =valpoints
for j=valpoints
A[i,j]=copy(M[i,j]) #TODO: Chek whetehr copy is needed or even deepcopy
end
end
#now recombine entries that are based on derivative points with value points
for k=0:2
A[4+k,valpoints]+=M[4+k,valpoints].*J[1,1]+M[7+k,valpoints].*J[1,2]
A[7+k,valpoints]+=M[4+k,valpoints].*J[2,1]+M[7+k,valpoints].*J[2,2]
A[10+k,valpoints]+=M[4+k,valpoints].*J[3,1]+M[7+k,valpoints].*J[3,2]
A[valpoints,4+k]+=M[valpoints,4+k].*J[1,1]+M[valpoints,7+k].*J[1,2]
A[valpoints,7+k]+=M[valpoints,4+k].*J[2,1]+M[valpoints,7+k].*J[2,2]
A[valpoints,10+k]+=M[valpoints,4+k].*J[3,1]+M[valpoints,7+k].*J[3,2]
end
#finally recombine entries based on derivative points with derivative points
for i = 4:12
if i in (4,5,6) #dx
Ji=J[1,:]
elseif i in (7,8,9) #dy
Ji=J[2,:]
elseif i in (10,11,12) #dz
Ji=J[3,:]
end
if i in (4,7,10)
idcs=[4,7]
elseif i in (5,8,11)
idcs=[5,8]
elseif i in (6,9,12)
idcs=[6,9]
#elseif i in (8,12,16)
# idcs=[8,12,16]
end
for j = 4:12
if j in (4,5,6) #dx
Jj=J[1,:]
elseif j in (7,8,9) #dy
Jj=J[2,:]
elseif j in (10,11,12) #dz
Jj=J[3,:]
end
if j in (4,7,10)
jdcs=[4,7]
elseif j in (5,8,11)
jdcs=[5,8]
elseif j in (6,9,12)
jdcs=[6,9]
#elseif j in (8,12,16)
# jdcs=[8,12,16]
end
#actual recombination
for (idk,k) in enumerate(idcs)
for (idl,l) in enumerate(jdcs)
A[i,j]+=Ji[idk]*Jj[idl]*M[k,l]
end
end
end
end
return A
elseif length(M)==13
valpoints=(1,2,3,13)
for i in valpoints
A[i]=copy(M[i])
end
#diffpoints=(4,5,6,7,8,9)
for k in 0:2
A[4+k]=J[1,1]*M[4+k]+J[1,2]*M[7+k]
A[7+k]=J[2,1]*M[4+k]+J[2,2]*M[7+k]
A[10+k]=J[3,1]*M[4+k]+J[3,2]*M[7+k]
end
return A
end
return nothing #force crash if input format is not supported
end
function s43diffc1(J::CooTrafo,c,d)
c1,c2,c3,c4=c
return (c1-c4)*J.inv[d,1]+(c2-c4)*J.inv[d,2]+(c3-c4)*J.inv[d,3]
end
function s43diffc2(J::CooTrafo,c,d)
dx = [3.0 0.0 0.0 1.0 0.0 0.0 -4.0 0.0 0.0 0.0 ;
-1.0 0.0 0.0 1.0 4.0 0.0 0.0 0.0 -4.0 0.0 ;
-1.0 0.0 0.0 1.0 0.0 4.0 0.0 0.0 0.0 -4.0 ;
-1.0 0.0 0.0 -3.0 0.0 0.0 4.0 0.0 0.0 0.0 ;
]
dy = [0.0 -1.0 0.0 1.0 4.0 0.0 -4.0 0.0 0.0 0.0 ;
0.0 3.0 0.0 1.0 0.0 0.0 0.0 0.0 -4.0 0.0 ;
0.0 -1.0 0.0 1.0 0.0 0.0 0.0 4.0 0.0 -4.0 ;
0.0 -1.0 0.0 -3.0 0.0 0.0 0.0 0.0 4.0 0.0 ;
]
dz = [0.0 0.0 -1.0 1.0 0.0 4.0 -4.0 0.0 0.0 0.0 ;
0.0 0.0 -1.0 1.0 0.0 0.0 0.0 4.0 -4.0 0.0 ;
0.0 0.0 3.0 1.0 0.0 0.0 0.0 0.0 0.0 -4.0 ;
0.0 0.0 -1.0 -3.0 0.0 0.0 0.0 0.0 0.0 4.0 ;
]
return dx*c*J.inv[d,1]+dy*c*J.inv[d,2]+dz*c*J.inv[d,3]
end
function s43diffch(J::CooTrafo,c,d)
dx= [0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
3.25 1.75 0.0 1.75 -0.75 0.5 0.0 0.25 0.75 -0.5 0.0 0.25 0.0 0.0 0.0 0.0 0.0 0.0 -6.75 0.0 ;
3.25 0.0 1.75 1.75 -0.75 0.0 0.5 0.25 0.0 0.0 0.0 0.0 0.75 0.0 -0.5 0.25 0.0 -6.75 0.0 0.0 ;
1.5 0.0 0.0 -1.5 -0.25 0.0 0.0 -0.25 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
-1.75 0.0 0.0 1.75 0.5 0.0 0.0 0.0 -0.25 0.0 0.0 0.25 -0.25 0.0 0.0 0.25 -6.75 0.0 0.0 6.75 ;
-1.75 -1.75 0.0 -3.25 0.5 0.0 0.0 0.0 -0.25 0.5 0.0 -0.75 0.0 0.0 0.0 0.0 0.0 0.0 6.75 0.0 ;
-1.75 0.0 -1.75 -3.25 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.25 0.0 0.5 -0.75 0.0 6.75 0.0 0.0 ;
]
dy=[0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
1.75 3.25 0.0 1.75 -0.5 0.75 0.0 0.25 0.5 -0.75 0.0 0.25 0.0 0.0 0.0 0.0 0.0 0.0 -6.75 0.0 ;
0.0 -1.75 0.0 1.75 0.0 -0.25 0.0 0.25 0.0 0.5 0.0 0.0 0.0 -0.25 0.0 0.25 0.0 -6.75 0.0 6.75 ;
-1.75 -1.75 0.0 -3.25 0.5 -0.25 0.0 -0.75 0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 6.75 0.0 ;
0.0 3.25 1.75 1.75 0.0 0.0 0.0 0.0 0.0 -0.75 0.5 0.25 0.0 0.75 -0.5 0.25 -6.75 0.0 0.0 0.0 ;
0.0 1.5 0.0 -1.5 0.0 0.0 0.0 0.0 0.0 -0.25 0.0 -0.25 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 -1.75 -1.75 -3.25 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 -0.25 0.5 -0.75 6.75 0.0 0.0 0.0 ;
]
dz=[0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 ;
0.0 0.0 -1.75 1.75 0.0 0.0 -0.25 0.25 0.0 0.0 -0.25 0.25 0.0 0.0 0.5 0.0 0.0 0.0 -6.75 6.75 ;
1.75 0.0 3.25 1.75 -0.5 0.0 0.75 0.25 0.0 0.0 0.0 0.0 0.5 0.0 -0.75 0.25 0.0 -6.75 0.0 0.0 ;
-1.75 0.0 -1.75 -3.25 0.5 0.0 -0.25 -0.75 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 6.75 0.0 0.0 ;
0.0 1.75 3.25 1.75 0.0 0.0 0.0 0.0 0.0 -0.5 0.75 0.25 0.0 0.5 -0.75 0.25 -6.75 0.0 0.0 0.0 ;
0.0 -1.75 -1.75 -3.25 0.0 0.0 0.0 0.0 0.0 0.5 -0.25 -0.75 0.0 0.0 0.5 0.0 6.75 0.0 0.0 0.0 ;
0.0 0.0 1.5 -1.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -0.25 -0.25 0.0 0.0 0.0 0.0 ;
]
for i=1:10
dx[i,:]=recombine_hermite(J,dx)
dy[i,:]=recombine_hermite(J,dy)
dz[i,:]=recombine_hermite(J,dz)
end
return dx*c*J.inv[d,1]+dy*c*J.inv[d,2]+dz*c*J.inv[d,3]
end
# Functions to compute local finite element matrices on simplices. The function
# names follow the pattern `sAB[D]vC[D]uC[[D]cE]`. Where
# - `A`: is the number of vertices of the simplex, e.g. 4 for a tetrahedron
# - `B`: is the number of space dimension
# - `C`: the order of the ansatz functions
# - `D`: optional classificator its `d` for a partial derivative
# (coordinate is specified in the function call), `n` for a nabla operator,
# `x` for a dirac-delta at some point x to get the function value there, and
# `r` for scalar multiplication with a direction vector.
# - `E`: the interpolation order of the (optional) coefficient function
#
# optional `d` indicate a partial derivative.
#
# Example: Lets assume you want to discretize the term ∂u(x,y,z)/∂x*c(x,y,z)
# Then the local weak form gives rise to the integral
# ∫∫∫_(Tet) v*∂u(x,y,z)/∂x*c(x,y,z) dxdydz where `Tet` is the tetrahedron.
# Furthermore, trial and test functions u and v should be of second order
# while the coefficient function should be interpolated linearly.
# Then, the function that returns the local discretization matrix of this weak
# form is s43v2du2c1. (The direction of the partial derivative is specified in
# the function call.)
#TODO: multiple dispatch instead of/additionally to function names
## mass matrices
#triangles
function s33v1u1(J::CooTrafo)
M=[1/12 1/24 1/24;
1/24 1/12 1/24;
1/24 1/24 1/12]
return M*abs(J.det)
end
function s33v2u2(J::CooTrafo)
M=[1/60 -1/360 -1/360 0 0 -1/90;
-1/360 1/60 -1/360 0 -1/90 0;
-1/360 -1/360 1/60 -1/90 0 0;
0 0 -1/90 4/45 2/45 2/45;
0 -1/90 0 2/45 4/45 2/45;
-1/90 0 0 2/45 2/45 4/45]
return M*abs(J.det)
end
function s33vhuh(J::CooTrafo)
M=[313/5040 1/720 1/720 -53/5040 17/10080 17/10080 53/10080 -1/2520 -13/10080 0 0 0 3/112;
1/720 313/5040 1/720 -1/2520 53/10080 -13/10080 17/10080 -53/5040 17/10080 0 0 0 3/112;
1/720 1/720 313/5040 -1/2520 -13/10080 53/10080 -13/10080 -1/2520 53/10080 0 0 0 3/112;
-53/5040 -1/2520 -1/2520 1/504 -1/2520 -1/2520 -1/1008 1/10080 1/3360 0 0 0 -3/560;
17/10080 53/10080 -13/10080 -1/2520 1/1260 -1/5040 1/2016 -1/1008 -1/10080 0 0 0 3/1120;
17/10080 -13/10080 53/10080 -1/2520 -1/5040 1/1260 -1/10080 1/3360 1/5040 0 0 0 3/1120;
53/10080 17/10080 -13/10080 -1/1008 1/2016 -1/10080 1/1260 -1/2520 -1/5040 0 0 0 3/1120;
-1/2520 -53/5040 -1/2520 1/10080 -1/1008 1/3360 -1/2520 1/504 -1/2520 0 0 0 -3/560;
-13/10080 17/10080 53/10080 1/3360 -1/10080 1/5040 -1/5040 -1/2520 1/1260 0 0 0 3/1120;
0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0;
3/112 3/112 3/112 -3/560 3/1120 3/1120 3/1120 -3/560 3/1120 0 0 0 81/560]
return recombine_hermite(J,M)*abs(J.det)
end
function s33v1u1c1(J::CooTrafo,c)
c1,c2,c4=c
M=Array{ComplexF64}(undef,3,3)
M[1,1]=c1/20 + c2/60 + c4/60
M[1,2]=c1/60 + c2/60 + c4/120
M[1,3]=c1/60 + c2/120 + c4/60
M[2,2]=c1/60 + c2/20 + c4/60
M[2,3]=c1/120 + c2/60 + c4/60
M[3,3]=c1/60 + c2/60 + c4/20
M[2,1]=M[1,2]
M[3,1]=M[1,3]
M[3,2]=M[2,3]
return M*abs(J.det)
end
function s33v2u2c1(J::CooTrafo,c)
c1,c2,c4=c
M=Array{ComplexF64}(undef,6,6)
M[1,1]=c1/84 + c2/420 + c4/420
M[1,2]=-c1/630 - c2/630 + c4/2520
M[1,3]=-c1/630 + c2/2520 - c4/630
M[1,4]=c1/210 - c2/315 - c4/630
M[1,5]=c1/210 - c2/630 - c4/315
M[1,6]=-c1/630 - c2/210 - c4/210
M[2,2]=c1/420 + c2/84 + c4/420
M[2,3]=c1/2520 - c2/630 - c4/630
M[2,4]=-c1/315 + c2/210 - c4/630
M[2,5]=-c1/210 - c2/630 - c4/210
M[2,6]=-c1/630 + c2/210 - c4/315
M[3,3]=c1/420 + c2/420 + c4/84
M[3,4]=-c1/210 - c2/210 - c4/630
M[3,5]=-c1/315 - c2/630 + c4/210
M[3,6]=-c1/630 - c2/315 + c4/210
M[4,4]=4*c1/105 + 4*c2/105 + 4*c4/315
M[4,5]=2*c1/105 + 4*c2/315 + 4*c4/315
M[4,6]=4*c1/315 + 2*c2/105 + 4*c4/315
M[5,5]=4*c1/105 + 4*c2/315 + 4*c4/105
M[5,6]=4*c1/315 + 4*c2/315 + 2*c4/105
M[6,6]=4*c1/315 + 4*c2/105 + 4*c4/105
M[2,1]=M[1,2]
M[3,1]=M[1,3]
M[4,1]=M[1,4]
M[5,1]=M[1,5]
M[6,1]=M[1,6]
M[3,2]=M[2,3]
M[4,2]=M[2,4]
M[5,2]=M[2,5]
M[6,2]=M[2,6]
M[4,3]=M[3,4]
M[5,3]=M[3,5]
M[6,3]=M[3,6]
M[5,4]=M[4,5]
M[6,4]=M[4,6]
M[6,5]=M[5,6]
return M*abs(J.det)
end
function s33vhuhc1(J::CooTrafo,c)
c1,c2,c4=c
M=Array{ComplexF64}(undef,13,13)
M[1,1]=31*c1/720 + c2/105 + c4/105
M[1,2]=c1/672 + c2/672 - c4/630
M[1,3]=c1/672 - c2/630 + c4/672
M[1,4]=-17*c1/2520 - 19*c2/10080 - 19*c4/10080
M[1,5]=c1/1120 + c2/1260
M[1,6]=c1/1120 + c4/1260
M[1,7]=17*c1/5040 + c2/720 + c4/2016
M[1,8]=-c1/2520 - c2/2520 + c4/2520
M[1,9]=-c1/2016 - c2/2520 - c4/2520
M[1,10]=0
M[1,11]=0
M[1,12]=0
M[1,13]=c1/56 + c2/224 + c4/224
M[2,2]=c1/105 + 31*c2/720 + c4/105
M[2,3]=-c1/630 + c2/672 + c4/672
M[2,4]=-c1/2520 - c2/2520 + c4/2520
M[2,5]=c1/720 + 17*c2/5040 + c4/2016
M[2,6]=-c1/2520 - c2/2016 - c4/2520
M[2,7]=c1/1260 + c2/1120
M[2,8]=-19*c1/10080 - 17*c2/2520 - 19*c4/10080
M[2,9]=c2/1120 + c4/1260
M[2,10]=0
M[2,11]=0
M[2,12]=0
M[2,13]=c1/224 + c2/56 + c4/224
M[3,3]=c1/105 + c2/105 + 31*c4/720
M[3,4]=-c1/2520 + c2/2520 - c4/2520
M[3,5]=-c1/2520 - c2/2520 - c4/2016
M[3,6]=c1/720 + c2/2016 + 17*c4/5040
M[3,7]=-c1/2520 - c2/2520 - c4/2016
M[3,8]=c1/2520 - c2/2520 - c4/2520
M[3,9]=c1/2016 + c2/720 + 17*c4/5040
M[3,10]=0
M[3,11]=0
M[3,12]=0
M[3,13]=c1/224 + c2/224 + c4/56
M[4,4]=c1/840 + c2/2520 + c4/2520
M[4,5]=-c1/5040 - c2/5040
M[4,6]=-c1/5040 - c4/5040
M[4,7]=-c1/1680 - c2/3360 - c4/10080
M[4,8]=c1/10080 + c2/10080 - c4/10080
M[4,9]=c1/10080 + c2/10080 + c4/10080
M[4,10]=0
M[4,11]=0
M[4,12]=0
M[4,13]=-c1/280 - c2/1120 - c4/1120
M[5,5]=c1/3780 + c2/2160 + c4/15120
M[5,6]=-c1/15120 - c2/15120 - c4/15120
M[5,7]=c1/4320 + c2/4320 + c4/30240
M[5,8]=-c1/3360 - c2/1680 - c4/10080
M[5,9]=-c1/30240 - c2/30240 - c4/30240
M[5,10]=0
M[5,11]=0
M[5,12]=0
M[5,13]=c1/1120 + c2/560
M[6,6]=c1/3780 + c2/15120 + c4/2160
M[6,7]=-c1/30240 - c2/30240 - c4/30240
M[6,8]=c1/10080 + c2/10080 + c4/10080
M[6,9]=c1/30240 + c2/30240 + c4/7560
M[6,10]=0
M[6,11]=0
M[6,12]=0
M[6,13]=c1/1120 + c4/560
M[7,7]=c1/2160 + c2/3780 + c4/15120
M[7,8]=-c1/5040 - c2/5040
M[7,9]=-c1/15120 - c2/15120 - c4/15120
M[7,10]=0
M[7,11]=0
M[7,12]=0
M[7,13]=c1/560 + c2/1120
M[8,8]=c1/2520 + c2/840 + c4/2520
M[8,9]=-c2/5040 - c4/5040
M[8,10]=0
M[8,11]=0
M[8,12]=0
M[8,13]=-c1/1120 - c2/280 - c4/1120
M[9,9]=c1/15120 + c2/3780 + c4/2160
M[9,10]=0
M[9,11]=0
M[9,12]=0
M[9,13]=c2/1120 + c4/560
M[10,10]=0
M[10,11]=0
M[10,12]=0
M[10,13]=0
M[11,11]=0
M[11,12]=0
M[11,13]=0
M[12,12]=0
M[12,13]=0
M[13,13]=27*c1/560 + 27*c2/560 + 27*c4/560
M[2,1]=M[1,2]
M[3,1]=M[1,3]
M[4,1]=M[1,4]
M[5,1]=M[1,5]
M[6,1]=M[1,6]
M[7,1]=M[1,7]
M[8,1]=M[1,8]
M[9,1]=M[1,9]
M[10,1]=M[1,10]
M[11,1]=M[1,11]
M[12,1]=M[1,12]
M[13,1]=M[1,13]
M[3,2]=M[2,3]
M[4,2]=M[2,4]
M[5,2]=M[2,5]
M[6,2]=M[2,6]
M[7,2]=M[2,7]
M[8,2]=M[2,8]
M[9,2]=M[2,9]
M[10,2]=M[2,10]
M[11,2]=M[2,11]
M[12,2]=M[2,12]
M[13,2]=M[2,13]
M[4,3]=M[3,4]
M[5,3]=M[3,5]
M[6,3]=M[3,6]
M[7,3]=M[3,7]
M[8,3]=M[3,8]
M[9,3]=M[3,9]
M[10,3]=M[3,10]
M[11,3]=M[3,11]
M[12,3]=M[3,12]
M[13,3]=M[3,13]
M[5,4]=M[4,5]
M[6,4]=M[4,6]
M[7,4]=M[4,7]
M[8,4]=M[4,8]
M[9,4]=M[4,9]
M[10,4]=M[4,10]
M[11,4]=M[4,11]
M[12,4]=M[4,12]
M[13,4]=M[4,13]
M[6,5]=M[5,6]
M[7,5]=M[5,7]
M[8,5]=M[5,8]
M[9,5]=M[5,9]
M[10,5]=M[5,10]
M[11,5]=M[5,11]
M[12,5]=M[5,12]
M[13,5]=M[5,13]
M[7,6]=M[6,7]
M[8,6]=M[6,8]
M[9,6]=M[6,9]
M[10,6]=M[6,10]
M[11,6]=M[6,11]
M[12,6]=M[6,12]
M[13,6]=M[6,13]
M[8,7]=M[7,8]
M[9,7]=M[7,9]
M[10,7]=M[7,10]
M[11,7]=M[7,11]
M[12,7]=M[7,12]
M[13,7]=M[7,13]
M[9,8]=M[8,9]
M[10,8]=M[8,10]
M[11,8]=M[8,11]
M[12,8]=M[8,12]
M[13,8]=M[8,13]
M[10,9]=M[9,10]
M[11,9]=M[9,11]
M[12,9]=M[9,12]
M[13,9]=M[9,13]
M[11,10]=M[10,11]
M[12,10]=M[10,12]
M[13,10]=M[10,13]
M[12,11]=M[11,12]
M[13,11]=M[11,13]
M[13,12]=M[12,13]
return recombine_hermite(J,M)*abs(J.det)
end
#tetrahedra
function s43v1u1(J::CooTrafo)
M = [1/60 1/120 1/120 1/120;
1/120 1/60 1/120 1/120;
1/120 1/120 1/60 1/120;
1/120 1/120 1/120 1/60]
return M*abs(J.det)
end
function s43v2u1(J::CooTrafo)
M = [0 -1/360 -1/360 -1/360;
-1/360 0 -1/360 -1/360;
-1/360 -1/360 0 -1/360;
-1/360 -1/360 -1/360 0;
1/90 1/90 1/180 1/180;
1/90 1/180 1/90 1/180;
1/90 1/180 1/180 1/90;
1/180 1/90 1/90 1/180;
1/180 1/90 1/180 1/90;
1/180 1/180 1/90 1/90]
return M*abs(J.det)
end
function s43v2u2(J::CooTrafo)
M = [1/420 1/2520 1/2520 1/2520 -1/630 -1/630 -1/630 -1/420 -1/420 -1/420;
1/2520 1/420 1/2520 1/2520 -1/630 -1/420 -1/420 -1/630 -1/630 -1/420;
1/2520 1/2520 1/420 1/2520 -1/420 -1/630 -1/420 -1/630 -1/420 -1/630;
1/2520 1/2520 1/2520 1/420 -1/420 -1/420 -1/630 -1/420 -1/630 -1/630;
-1/630 -1/630 -1/420 -1/420 4/315 2/315 2/315 2/315 2/315 1/315;
-1/630 -1/420 -1/630 -1/420 2/315 4/315 2/315 2/315 1/315 2/315;
-1/630 -1/420 -1/420 -1/630 2/315 2/315 4/315 1/315 2/315 2/315;
-1/420 -1/630 -1/630 -1/420 2/315 2/315 1/315 4/315 2/315 2/315;
-1/420 -1/630 -1/420 -1/630 2/315 1/315 2/315 2/315 4/315 2/315;
-1/420 -1/420 -1/630 -1/630 1/315 2/315 2/315 2/315 2/315 4/315]
return M*abs(J.det)
end
function s43vhuh(J::CooTrafo)
M=[253/30240 -23/45360 -23/45360 -23/45360 -97/60480 1/12960 1/12960 1/12960 97/181440 1/11340 -1/12096 -1/12096 97/181440 -1/12096 1/11340 -1/12096 -1/320 1/6720 1/6720 1/6720;
-23/45360 253/30240 -23/45360 -23/45360 1/11340 97/181440 -1/12096 -1/12096 1/12960 -97/60480 1/12960 1/12960 -1/12096 97/181440 1/11340 -1/12096 1/6720 -1/320 1/6720 1/6720;
-23/45360 -23/45360 253/30240 -23/45360 1/11340 -1/12096 97/181440 -1/12096 -1/12096 1/11340 97/181440 -1/12096 1/12960 1/12960 -97/60480 1/12960 1/6720 1/6720 -1/320 1/6720;
-23/45360 -23/45360 -23/45360 253/30240 1/11340 -1/12096 -1/12096 97/181440 -1/12096 1/11340 -1/12096 97/181440 -1/12096 -1/12096 1/11340 97/181440 1/6720 1/6720 1/6720 -1/320;
-97/60480 1/11340 1/11340 1/11340 1/3024 -1/45360 -1/45360 -1/45360 -1/9072 -1/90720 1/60480 1/60480 -1/9072 1/60480 -1/90720 1/60480 1/1120 1/6720 1/6720 1/6720;
1/12960 97/181440 -1/12096 -1/12096 -1/45360 1/15120 -1/90720 -1/90720 1/30240 -1/9072 -1/181440 -1/181440 -1/181440 1/45360 1/60480 0 -1/6720 -1/3360 0 0;
1/12960 -1/12096 97/181440 -1/12096 -1/45360 -1/90720 1/15120 -1/90720 -1/181440 1/60480 1/45360 0 1/30240 -1/181440 -1/9072 -1/181440 -1/6720 0 -1/3360 0;
1/12960 -1/12096 -1/12096 97/181440 -1/45360 -1/90720 -1/90720 1/15120 -1/181440 1/60480 0 1/45360 -1/181440 0 1/60480 1/45360 -1/6720 0 0 -1/3360;
97/181440 1/12960 -1/12096 -1/12096 -1/9072 1/30240 -1/181440 -1/181440 1/15120 -1/45360 -1/90720 -1/90720 1/45360 -1/181440 1/60480 0 -1/3360 -1/6720 0 0;
1/11340 -97/60480 1/11340 1/11340 -1/90720 -1/9072 1/60480 1/60480 -1/45360 1/3024 -1/45360 -1/45360 1/60480 -1/9072 -1/90720 1/60480 1/6720 1/1120 1/6720 1/6720;
-1/12096 1/12960 97/181440 -1/12096 1/60480 -1/181440 1/45360 0 -1/90720 -1/45360 1/15120 -1/90720 -1/181440 1/30240 -1/9072 -1/181440 0 -1/6720 -1/3360 0;
-1/12096 1/12960 -1/12096 97/181440 1/60480 -1/181440 0 1/45360 -1/90720 -1/45360 -1/90720 1/15120 0 -1/181440 1/60480 1/45360 0 -1/6720 0 -1/3360;
97/181440 -1/12096 1/12960 -1/12096 -1/9072 -1/181440 1/30240 -1/181440 1/45360 1/60480 -1/181440 0 1/15120 -1/90720 -1/45360 -1/90720 -1/3360 0 -1/6720 0;
-1/12096 97/181440 1/12960 -1/12096 1/60480 1/45360 -1/181440 0 -1/181440 -1/9072 1/30240 -1/181440 -1/90720 1/15120 -1/45360 -1/90720 0 -1/3360 -1/6720 0;
1/11340 1/11340 -97/60480 1/11340 -1/90720 1/60480 -1/9072 1/60480 1/60480 -1/90720 -1/9072 1/60480 -1/45360 -1/45360 1/3024 -1/45360 1/6720 1/6720 1/1120 1/6720;
-1/12096 -1/12096 1/12960 97/181440 1/60480 0 -1/181440 1/45360 0 1/60480 -1/181440 1/45360 -1/90720 -1/90720 -1/45360 1/15120 0 0 -1/6720 -1/3360;
-1/320 1/6720 1/6720 1/6720 1/1120 -1/6720 -1/6720 -1/6720 -1/3360 1/6720 0 0 -1/3360 0 1/6720 0 9/560 9/1120 9/1120 9/1120;
1/6720 -1/320 1/6720 1/6720 1/6720 -1/3360 0 0 -1/6720 1/1120 -1/6720 -1/6720 0 -1/3360 1/6720 0 9/1120 9/560 9/1120 9/1120;
1/6720 1/6720 -1/320 1/6720 1/6720 0 -1/3360 0 0 1/6720 -1/3360 0 -1/6720 -1/6720 1/1120 -1/6720 9/1120 9/1120 9/560 9/1120;
1/6720 1/6720 1/6720 -1/320 1/6720 0 0 -1/3360 0 1/6720 0 -1/3360 0 0 1/6720 -1/3360 9/1120 9/1120 9/1120 9/560]
return recombine_hermite(J,M)*abs(J.det)
end
function s43v1u1c1(J::CooTrafo,c)
c1,c2,c3,c4=c
M=Array{ComplexF64}(undef,4,4)
M[1,1]=c1/120 + c2/360 + c3/360 + c4/360
M[1,2]=c1/360 + c2/360 + c3/720 + c4/720
M[1,3]=c1/360 + c2/720 + c3/360 + c4/720
M[1,4]=c1/360 + c2/720 + c3/720 + c4/360
M[2,2]=c1/360 + c2/120 + c3/360 + c4/360
M[2,3]=c1/720 + c2/360 + c3/360 + c4/720
M[2,4]=c1/720 + c2/360 + c3/720 + c4/360
M[3,3]=c1/360 + c2/360 + c3/120 + c4/360
M[3,4]=c1/720 + c2/720 + c3/360 + c4/360
M[4,4]=c1/360 + c2/360 + c3/360 + c4/120
M[2,1]=M[1,2]
M[3,1]=M[1,3]
M[4,1]=M[1,4]
M[3,2]=M[2,3]
M[4,2]=M[2,4]
M[4,3]=M[3,4]
return M*abs(J.det)
end
function s43v2u2c1(J::CooTrafo,c)
c1,c2,c3,c4=c
M=Array{ComplexF64}(undef,10,10)
M[1,1]=c1/840 + c2/2520 + c3/2520 + c4/2520
M[1,2]=c3/5040 + c4/5040
M[1,3]=c2/5040 + c4/5040
M[1,4]=c2/5040 + c3/5040
M[1,5]=-c2/1260 - c3/2520 - c4/2520
M[1,6]=-c2/2520 - c3/1260 - c4/2520
M[1,7]=-c2/2520 - c3/2520 - c4/1260
M[1,8]=-c1/2520 - c2/1260 - c3/1260 - c4/2520
M[1,9]=-c1/2520 - c2/1260 - c3/2520 - c4/1260
M[1,10]=-c1/2520 - c2/2520 - c3/1260 - c4/1260
M[2,2]=c1/2520 + c2/840 + c3/2520 + c4/2520
M[2,3]=c1/5040 + c4/5040
M[2,4]=c1/5040 + c3/5040
M[2,5]=-c1/1260 - c3/2520 - c4/2520
M[2,6]=-c1/1260 - c2/2520 - c3/1260 - c4/2520
M[2,7]=-c1/1260 - c2/2520 - c3/2520 - c4/1260
M[2,8]=-c1/2520 - c3/1260 - c4/2520
M[2,9]=-c1/2520 - c3/2520 - c4/1260
M[2,10]=-c1/2520 - c2/2520 - c3/1260 - c4/1260
M[3,3]=c1/2520 + c2/2520 + c3/840 + c4/2520
M[3,4]=c1/5040 + c2/5040
M[3,5]=-c1/1260 - c2/1260 - c3/2520 - c4/2520
M[3,6]=-c1/1260 - c2/2520 - c4/2520
M[3,7]=-c1/1260 - c2/2520 - c3/2520 - c4/1260
M[3,8]=-c1/2520 - c2/1260 - c4/2520
M[3,9]=-c1/2520 - c2/1260 - c3/2520 - c4/1260
M[3,10]=-c1/2520 - c2/2520 - c4/1260
M[4,4]=c1/2520 + c2/2520 + c3/2520 + c4/840
M[4,5]=-c1/1260 - c2/1260 - c3/2520 - c4/2520
M[4,6]=-c1/1260 - c2/2520 - c3/1260 - c4/2520
M[4,7]=-c1/1260 - c2/2520 - c3/2520
M[4,8]=-c1/2520 - c2/1260 - c3/1260 - c4/2520
M[4,9]=-c1/2520 - c2/1260 - c3/2520
M[4,10]=-c1/2520 - c2/2520 - c3/1260
M[5,5]=c1/210 + c2/210 + c3/630 + c4/630
M[5,6]=c1/420 + c2/630 + c3/630 + c4/1260
M[5,7]=c1/420 + c2/630 + c3/1260 + c4/630
M[5,8]=c1/630 + c2/420 + c3/630 + c4/1260
M[5,9]=c1/630 + c2/420 + c3/1260 + c4/630
M[5,10]=c1/1260 + c2/1260 + c3/1260 + c4/1260
M[6,6]=c1/210 + c2/630 + c3/210 + c4/630
M[6,7]=c1/420 + c2/1260 + c3/630 + c4/630
M[6,8]=c1/630 + c2/630 + c3/420 + c4/1260
M[6,9]=c1/1260 + c2/1260 + c3/1260 + c4/1260
M[6,10]=c1/630 + c2/1260 + c3/420 + c4/630
M[7,7]=c1/210 + c2/630 + c3/630 + c4/210
M[7,8]=c1/1260 + c2/1260 + c3/1260 + c4/1260
M[7,9]=c1/630 + c2/630 + c3/1260 + c4/420
M[7,10]=c1/630 + c2/1260 + c3/630 + c4/420
M[8,8]=c1/630 + c2/210 + c3/210 + c4/630
M[8,9]=c1/1260 + c2/420 + c3/630 + c4/630
M[8,10]=c1/1260 + c2/630 + c3/420 + c4/630
M[9,9]=c1/630 + c2/210 + c3/630 + c4/210
M[9,10]=c1/1260 + c2/630 + c3/630 + c4/420
M[10,10]=c1/630 + c2/630 + c3/210 + c4/210
M[2,1]=M[1,2]
M[3,1]=M[1,3]
M[4,1]=M[1,4]
M[5,1]=M[1,5]
M[6,1]=M[1,6]
M[7,1]=M[1,7]
M[8,1]=M[1,8]
M[9,1]=M[1,9]
M[10,1]=M[1,10]
M[3,2]=M[2,3]
M[4,2]=M[2,4]
M[5,2]=M[2,5]
M[6,2]=M[2,6]
M[7,2]=M[2,7]
M[8,2]=M[2,8]
M[9,2]=M[2,9]
M[10,2]=M[2,10]
M[4,3]=M[3,4]
M[5,3]=M[3,5]
M[6,3]=M[3,6]
M[7,3]=M[3,7]
M[8,3]=M[3,8]
M[9,3]=M[3,9]
M[10,3]=M[3,10]
M[5,4]=M[4,5]
M[6,4]=M[4,6]
M[7,4]=M[4,7]
M[8,4]=M[4,8]
M[9,4]=M[4,9]
M[10,4]=M[4,10]
M[6,5]=M[5,6]
M[7,5]=M[5,7]
M[8,5]=M[5,8]
M[9,5]=M[5,9]
M[10,5]=M[5,10]
M[7,6]=M[6,7]
M[8,6]=M[6,8]
M[9,6]=M[6,9]
M[10,6]=M[6,10]
M[8,7]=M[7,8]
M[9,7]=M[7,9]
M[10,7]=M[7,10]
M[9,8]=M[8,9]
M[10,8]=M[8,10]
M[10,9]=M[9,10]
return M*abs(J.det)
end
function s43vhuhc1(J::CooTrafo,c)
c1,c2,c3,c4=c
M=Array{ComplexF64}(undef,20,20)
M[1,1]=31*c1/6300 + 521*c2/453600 + 521*c3/453600 + 521*c4/453600
M[1,2]=-73*c1/302400 - 73*c2/302400 - 11*c3/907200 - 11*c4/907200
M[1,3]=-73*c1/302400 - 11*c2/907200 - 73*c3/302400 - 11*c4/907200
M[1,4]=-73*c1/302400 - 11*c2/907200 - 11*c3/907200 - 73*c4/302400
M[1,5]=-43*c1/50400 - 227*c2/907200 - 227*c3/907200 - 227*c4/907200
M[1,6]=c1/43200 + 31*c2/907200 + c3/100800 + c4/100800
M[1,7]=c1/43200 + c2/100800 + 31*c3/907200 + c4/100800
M[1,8]=c1/43200 + c2/100800 + c3/100800 + 31*c4/907200
M[1,9]=43*c1/151200 + 23*c2/181440 + c3/16200 + c4/16200
M[1,10]=11*c1/181440 + 11*c2/302400 - c3/226800 - c4/226800
M[1,11]=-19*c1/453600 - c2/64800 - c3/28350 + c4/100800
M[1,12]=-19*c1/453600 - c2/64800 + c3/100800 - c4/28350
M[1,13]=43*c1/151200 + c2/16200 + 23*c3/181440 + c4/16200
M[1,14]=-19*c1/453600 - c2/28350 - c3/64800 + c4/100800
M[1,15]=11*c1/181440 - c2/226800 + 11*c3/302400 - c4/226800
M[1,16]=-19*c1/453600 + c2/100800 - c3/64800 - c4/28350
M[1,17]=-3*c1/11200 - c2/1050 - c3/1050 - c4/1050
M[1,18]=3*c1/2800 - 3*c2/11200 - 11*c3/33600 - 11*c4/33600
M[1,19]=3*c1/2800 - 11*c2/33600 - 3*c3/11200 - 11*c4/33600
M[1,20]=3*c1/2800 - 11*c2/33600 - 11*c3/33600 - 3*c4/11200
M[2,2]=521*c1/453600 + 31*c2/6300 + 521*c3/453600 + 521*c4/453600
M[2,3]=-11*c1/907200 - 73*c2/302400 - 73*c3/302400 - 11*c4/907200
M[2,4]=-11*c1/907200 - 73*c2/302400 - 11*c3/907200 - 73*c4/302400
M[2,5]=11*c1/302400 + 11*c2/181440 - c3/226800 - c4/226800
M[2,6]=23*c1/181440 + 43*c2/151200 + c3/16200 + c4/16200
M[2,7]=-c1/64800 - 19*c2/453600 - c3/28350 + c4/100800
M[2,8]=-c1/64800 - 19*c2/453600 + c3/100800 - c4/28350
M[2,9]=31*c1/907200 + c2/43200 + c3/100800 + c4/100800
M[2,10]=-227*c1/907200 - 43*c2/50400 - 227*c3/907200 - 227*c4/907200
M[2,11]=c1/100800 + c2/43200 + 31*c3/907200 + c4/100800
M[2,12]=c1/100800 + c2/43200 + c3/100800 + 31*c4/907200
M[2,13]=-c1/28350 - 19*c2/453600 - c3/64800 + c4/100800
M[2,14]=c1/16200 + 43*c2/151200 + 23*c3/181440 + c4/16200
M[2,15]=-c1/226800 + 11*c2/181440 + 11*c3/302400 - c4/226800
M[2,16]=c1/100800 - 19*c2/453600 - c3/64800 - c4/28350
M[2,17]=-3*c1/11200 + 3*c2/2800 - 11*c3/33600 - 11*c4/33600
M[2,18]=-c1/1050 - 3*c2/11200 - c3/1050 - c4/1050
M[2,19]=-11*c1/33600 + 3*c2/2800 - 3*c3/11200 - 11*c4/33600
M[2,20]=-11*c1/33600 + 3*c2/2800 - 11*c3/33600 - 3*c4/11200
M[3,3]=521*c1/453600 + 521*c2/453600 + 31*c3/6300 + 521*c4/453600
M[3,4]=-11*c1/907200 - 11*c2/907200 - 73*c3/302400 - 73*c4/302400
M[3,5]=11*c1/302400 - c2/226800 + 11*c3/181440 - c4/226800
M[3,6]=-c1/64800 - c2/28350 - 19*c3/453600 + c4/100800
M[3,7]=23*c1/181440 + c2/16200 + 43*c3/151200 + c4/16200
M[3,8]=-c1/64800 + c2/100800 - 19*c3/453600 - c4/28350
M[3,9]=-c1/28350 - c2/64800 - 19*c3/453600 + c4/100800
M[3,10]=-c1/226800 + 11*c2/302400 + 11*c3/181440 - c4/226800
M[3,11]=c1/16200 + 23*c2/181440 + 43*c3/151200 + c4/16200
M[3,12]=c1/100800 - c2/64800 - 19*c3/453600 - c4/28350
M[3,13]=31*c1/907200 + c2/100800 + c3/43200 + c4/100800
M[3,14]=c1/100800 + 31*c2/907200 + c3/43200 + c4/100800
M[3,15]=-227*c1/907200 - 227*c2/907200 - 43*c3/50400 - 227*c4/907200
M[3,16]=c1/100800 + c2/100800 + c3/43200 + 31*c4/907200
M[3,17]=-3*c1/11200 - 11*c2/33600 + 3*c3/2800 - 11*c4/33600
M[3,18]=-11*c1/33600 - 3*c2/11200 + 3*c3/2800 - 11*c4/33600
M[3,19]=-c1/1050 - c2/1050 - 3*c3/11200 - c4/1050
M[3,20]=-11*c1/33600 - 11*c2/33600 + 3*c3/2800 - 3*c4/11200
M[4,4]=521*c1/453600 + 521*c2/453600 + 521*c3/453600 + 31*c4/6300
M[4,5]=11*c1/302400 - c2/226800 - c3/226800 + 11*c4/181440
M[4,6]=-c1/64800 - c2/28350 + c3/100800 - 19*c4/453600
M[4,7]=-c1/64800 + c2/100800 - c3/28350 - 19*c4/453600
M[4,8]=23*c1/181440 + c2/16200 + c3/16200 + 43*c4/151200
M[4,9]=-c1/28350 - c2/64800 + c3/100800 - 19*c4/453600
M[4,10]=-c1/226800 + 11*c2/302400 - c3/226800 + 11*c4/181440
M[4,11]=c1/100800 - c2/64800 - c3/28350 - 19*c4/453600
M[4,12]=c1/16200 + 23*c2/181440 + c3/16200 + 43*c4/151200
M[4,13]=-c1/28350 + c2/100800 - c3/64800 - 19*c4/453600
M[4,14]=c1/100800 - c2/28350 - c3/64800 - 19*c4/453600
M[4,15]=-c1/226800 - c2/226800 + 11*c3/302400 + 11*c4/181440
M[4,16]=c1/16200 + c2/16200 + 23*c3/181440 + 43*c4/151200
M[4,17]=-3*c1/11200 - 11*c2/33600 - 11*c3/33600 + 3*c4/2800
M[4,18]=-11*c1/33600 - 3*c2/11200 - 11*c3/33600 + 3*c4/2800
M[4,19]=-11*c1/33600 - 11*c2/33600 - 3*c3/11200 + 3*c4/2800
M[4,20]=-c1/1050 - c2/1050 - c3/1050 - 3*c4/11200
M[5,5]=c1/6300 + 13*c2/226800 + 13*c3/226800 + 13*c4/226800
M[5,6]=-c1/151200 - c2/113400 - c3/302400 - c4/302400
M[5,7]=-c1/151200 - c2/302400 - c3/113400 - c4/302400
M[5,8]=-c1/151200 - c2/302400 - c3/302400 - c4/113400
M[5,9]=-c1/18900 - 13*c2/453600 - 13*c3/907200 - 13*c4/907200
M[5,10]=-c1/113400 - c2/113400 + c3/302400 + c4/302400
M[5,11]=c1/129600 + c2/302400 + c3/113400 - c4/302400
M[5,12]=c1/129600 + c2/302400 - c3/302400 + c4/113400
M[5,13]=-c1/18900 - 13*c2/907200 - 13*c3/453600 - 13*c4/907200
M[5,14]=c1/129600 + c2/113400 + c3/302400 - c4/302400
M[5,15]=-c1/113400 + c2/302400 - c3/113400 + c4/302400
M[5,16]=c1/129600 - c2/302400 + c3/302400 + c4/113400
M[5,17]=c1/11200 + 3*c2/11200 + 3*c3/11200 + 3*c4/11200
M[5,18]=-c1/5600 + c2/11200 + c3/8400 + c4/8400
M[5,19]=-c1/5600 + c2/8400 + c3/11200 + c4/8400
M[5,20]=-c1/5600 + c2/8400 + c3/8400 + c4/11200
M[6,6]=c1/50400 + c2/30240 + c3/151200 + c4/151200
M[6,7]=-c1/302400 - c2/226800 - c3/226800 + c4/907200
M[6,8]=-c1/302400 - c2/226800 + c3/907200 - c4/226800
M[6,9]=c1/75600 + c2/75600 + c3/302400 + c4/302400
M[6,10]=-13*c1/453600 - c2/18900 - 13*c3/907200 - 13*c4/907200
M[6,11]=-c1/907200 - c2/302400 - c3/453600 + c4/907200
M[6,12]=-c1/907200 - c2/302400 + c3/907200 - c4/453600
M[6,13]=-c1/302400 - c2/453600 - c3/907200 + c4/907200
M[6,14]=c1/226800 + c2/100800 + c3/226800 + c4/302400
M[6,15]=c1/302400 + c2/113400 + c3/129600 - c4/302400
M[6,16]=c1/907200 - c2/907200 + c3/907200 - c4/907200
M[6,17]=-c1/33600 - c3/16800 - c4/16800
M[6,18]=-c1/11200 - c2/33600 - c3/11200 - c4/11200
M[6,19]=c2/11200 - c3/33600 - c4/16800
M[6,20]=c2/11200 - c3/16800 - c4/33600
M[7,7]=c1/50400 + c2/151200 + c3/30240 + c4/151200