-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdata_projection_routines.F90
More file actions
5693 lines (5049 loc) · 313 KB
/
data_projection_routines.F90
File metadata and controls
5693 lines (5049 loc) · 313 KB
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
!> \file
!> \author Tim Wu
!> \brief This module handles all data projection routines
!>
!> \section LICENSE
!>
!> Version: MPL 1.1/GPL 2.0/LGPL 2.1
!>
!> The contents of this file are subject to the Mozilla Public License
!> Version 1.1 (the "License"); you may not use this file except in
!> compliance with the License. You may obtain a copy of the License at
!> http://www.mozilla.org/MPL/
!>
!> Software distributed under the License is distributed on an "AS IS"
!> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
!> License for the specific language governing rights and limitations
!> under the License.
!>
!> The Original Code is OpenCMISS
!>
!> The Initial Developer of the Original Code is University of Auckland,
!> Auckland, New Zealand, the University of Oxford, Oxford, United
!> Kingdom and King's College, London, United Kingdom. Portions created
!> by the University of Auckland, the University of Oxford and King's
!> College, London are Copyright (C) 2007-2010 by the University of
!> Auckland, the University of Oxford and King's College, London.
!> All Rights Reserved.
!>
!> Contributor(s): Chris Bradley, Tim Wu, Kumar Mithraratne, Xiani (Nancy) Yan, Prasad Babarenda Gamage
!>
!> Alternatively, the contents of this file may be used under the terms of
!> either the GNU General Public License Version 2 or later (the "GPL"), or
!> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
!> in which case the provisions of the GPL or the LGPL are applicable instead
!> of those above. If you wish to allow use of your version of this file only
!> under the terms of either the GPL or the LGPL, and not to allow others to
!> use your version of this file under the terms of the MPL, indicate your
!> decision by deleting the provisions above and replace them with the notice
!> and other provisions required by the GPL or the LGPL. If you do not delete
!> the provisions above, a recipient may use your version of this file under
!> the terms of any one of the MPL, the GPL or the LGPL.
!>
!> This module handles all data projection routines.
MODULE DataProjectionRoutines
USE BaseRoutines
USE BasisRoutines
USE BasisAccessRoutines
USE CmissMPI
USE ComputationEnvironment
USE Constants
USE CoordinateSystemAccessRoutines
USE DataPointAccessRoutines
USE DataProjectionAccessRoutines
USE DOMAIN_MAPPINGS
USE FIELD_ROUTINES
USE FieldAccessRoutines
USE INPUT_OUTPUT
USE ISO_VARYING_STRING
USE Kinds
USE MESH_ROUTINES
USE MeshAccessRoutines
#ifndef NOMPIMOD
USE MPI
#endif
USE Sorting
USE Strings
USE Trees
USE Types
#include "macros.h"
IMPLICIT NONE
PRIVATE
#ifdef NOMPIMOD
#include "mpif.h"
#endif
!Module parameters
!> \addtogroup DataProjectionRoutines_DataProjectionTypes DataProjectionRoutines::DataProjectionTypes
!> \brief Datapoint projection definition type parameters
!> \see DataProjectionRoutines,OPENCMISS_DataProjectionTypes
!>@{
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_BOUNDARY_LINES_PROJECTION_TYPE=1 !<The boundary line projection type for data projection, only projects to boundary lines of the mesh. \see DataProjectionRoutines,OPENCMISS_DataProjectionTypes
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_BOUNDARY_FACES_PROJECTION_TYPE=2 !<The boundary face projection type for data projection, only projects to boundary faces of the mesh. \see DataProjectionRoutines,OPENCMISS_DataProjectionTypes
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_ALL_ELEMENTS_PROJECTION_TYPE=3 !<The element projection type for data projection, projects to all elements in mesh. \see DataProjectionRoutines,OPENCMISS_DataProjectionTypes
!>@}
!> \addtogroup DataProjectionRoutines_DataProjectionDistanceRelations DataProjectionRoutines::DataProjectionDistanceRelations
!> \brief Datapoint projection distance relations to select data points based on distance.
!> \see DataProjectionRoutines,OPENCMISS_DataProjectionExitTags
!>@{
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_DISTANCE_GREATER=1 !<Data projection distance relation is greater than \see DataProjectionRoutines,OPENCMISS_DataProjectionDistanceRelations
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_DISTANCE_GREATER_EQUAL=2 !<Data projection distance relation is greater than or equal \see DataProjectionRoutines,OPENCMISS_DataProjectionDistanceRelations
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_DISTANCE_LESS=3 !<Data projection distance relation is less than \see DataProjectionRoutines,OPENCMISS_DataProjectionDistanceRelations
INTEGER(INTG), PARAMETER :: DATA_PROJECTION_DISTANCE_LESS_EQUAL=4 !<Data projection distance relation is less than or equal \see DataProjectionRoutines,OPENCMISS_DataProjectionDistanceRelations
!>@}
!Module types
!Module variables
!Interfaces
!>Gets the label for a data projection.
INTERFACE DataProjection_LabelGet
MODULE PROCEDURE DataProjection_LabelGetC
MODULE PROCEDURE DataProjection_LabelGetVS
END INTERFACE DataProjection_LabelGet
!>Sets/changes the label for a data projection.
INTERFACE DataProjection_LabelSet
MODULE PROCEDURE DataProjection_LabelSetC
MODULE PROCEDURE DataProjection_LabelSetVS
END INTERFACE DataProjection_LabelSet
!>Cancels the data pojection for data points based on the data point user numbers
INTERFACE DataProjection_ProjectionCancelByDataPoints
MODULE PROCEDURE DataProjection_ProjectionCancelByDataPoints0
MODULE PROCEDURE DataProjection_ProjectionCancelByDataPoints1
END INTERFACE DataProjection_ProjectionCancelByDataPoints
!>Cancels the data pojection for data points based on the projection exit tag
INTERFACE DataProjection_ProjectionCancelByExitTags
MODULE PROCEDURE DataProjection_ProjectionCancelByExitTags0
MODULE PROCEDURE DataProjection_ProjectionCancelByExitTags1
END INTERFACE DataProjection_ProjectionCancelByExitTags
PUBLIC DATA_PROJECTION_BOUNDARY_LINES_PROJECTION_TYPE,DATA_PROJECTION_BOUNDARY_FACES_PROJECTION_TYPE, &
& DATA_PROJECTION_ALL_ELEMENTS_PROJECTION_TYPE
PUBLIC DATA_PROJECTION_DISTANCE_GREATER,DATA_PROJECTION_DISTANCE_GREATER_EQUAL,DATA_PROJECTION_DISTANCE_LESS, &
& DATA_PROJECTION_DISTANCE_LESS_EQUAL
PUBLIC DataProjection_AbsoluteToleranceGet,DataProjection_AbsoluteToleranceSet
PUBLIC DataProjection_CreateFinish,DataProjection_CreateStart
PUBLIC DataProjection_Destroy
PUBLIC DataProjection_DataPointFieldEvaluate
PUBLIC DataProjection_DataPointsProjectionEvaluate
PUBLIC DataProjection_DataPointsPositionEvaluate
PUBLIC DataProjection_ElementSet
PUBLIC DataProjection_LabelGet,DataProjection_LabelSet
PUBLIC DataProjection_MaximumInterationUpdateGet,DataProjection_MaximumInterationUpdateSet
PUBLIC DataProjection_MaximumNumberOfIterationsGet,DataProjection_MaximumNumberOfIterationsSet
PUBLIC DataProjection_NumberOfClosestElementsGet,DataProjection_NumberOfClosestElementsSet
PUBLIC DataProjection_ProjectionCancelByDataPoints
PUBLIC DataProjection_ProjectionCancelByDistance
PUBLIC DataProjection_ProjectionCancelByExitTags
PUBLIC DataProjection_ProjectionCandidateElementsSet
PUBLIC DataProjection_ProjectionDataCandidateElementsSet
PUBLIC DataProjection_ProjectionCandidateFacesSet
PUBLIC DataProjection_ProjectionDataCandidateFacesSet
PUBLIC DataProjection_ProjectionCandidateLinesSet
PUBLIC DataProjection_ProjectionDataCandidateLinesSet
PUBLIC DataProjection_ProjectionTypeGet,DataProjection_ProjectionTypeSet
PUBLIC DataProjection_RelativeToleranceGet,DataProjection_RelativeToleranceSet
PUBLIC DataProjection_ResultAnalysisOutput
PUBLIC DataProjection_ResultDistanceGet
PUBLIC DataProjection_ResultElementNumberGet,DataProjection_ResultElementNumberSet
PUBLIC DataProjection_ResultElementFaceNumberGet,DataProjection_ResultElementFaceNumberSet
PUBLIC DataProjection_ResultElementLineNumberGet,DataProjection_ResultElementLineNumberSet
PUBLIC DataProjection_ResultElementXiGet
PUBLIC DataProjection_ResultExitTagGet
PUBLIC DataProjection_ResultProjectionVectorGet
PUBLIC DataProjection_ResultProjectionXiGet,DataProjection_ResultProjectionXiSet
PUBLIC DataProjection_StartingXiGet,DataProjection_StartingXiSet
PUBLIC DataProjection_UserNumberFind
PUBLIC DataProjections_Initialise,DataProjections_Finalise
CONTAINS
!
!================================================================================================================================
!
!>Gets the absolute tolerance for a data projection.
SUBROUTINE DataProjection_AbsoluteToleranceGet(dataProjection,absoluteTolerance,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection to get the absolute tolerance for
REAL(DP), INTENT(OUT) :: absoluteTolerance !<On exit, the absolute tolerance of the specified data projection
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_AbsoluteToleranceGet",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(.NOT.dataProjection%dataProjectionFinished) CALL FlagError("Data projection has not been finished.",err,error,*999)
absoluteTolerance=dataProjection%absoluteTolerance
EXITS("DataProjection_AbsoluteToleranceGet")
RETURN
999 ERRORSEXITS("DataProjection_AbsoluteToleranceGet",err,error)
RETURN 1
END SUBROUTINE DataProjection_AbsoluteToleranceGet
!
!================================================================================================================================
!
!>Sets the absolute tolerance for a data projection.
SUBROUTINE DataProjection_AbsoluteToleranceSet(dataProjection,absoluteTolerance,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection to set the absolute tolerance for
REAL(DP), INTENT(IN) :: absoluteTolerance !<the absolute tolerance to set
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_AbsoluteToleranceSet",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(dataProjection%dataProjectionFinished) CALL FlagError("Data projection has been finished.",err,error,*999)
IF(absoluteTolerance<0.0_DP) &
& CALL FlagError("The specified absolute tolerance is invalid. The tolerance must be > 0.0.",err,error,*999)
dataProjection%absoluteTolerance=absoluteTolerance
EXITS("DataProjection_AbsoluteToleranceSet")
RETURN
999 ERRORSEXITS("DataProjection_AbsoluteToleranceSet",err,error)
RETURN 1
END SUBROUTINE DataProjection_AbsoluteToleranceSet
!
!================================================================================================================================
!
!>Find the closest elements to a data point based on starting xi guess.
SUBROUTINE DataProjection_ClosestElementsFind(dataProjection,interpolatedPoint,dataPointLocation,numberOfCandidates, &
& candidateElements,closestElements,closestDistances,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<Data projection problem to evaluate
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: interpolatedPoint !<The interpolated point for the data point
REAL(DP), INTENT(IN) :: dataPointLocation(:) !<dataPointLocation(componentIdx). The location of data point in the region.
INTEGER(INTG), INTENT(IN) :: numberOfCandidates !<The number of candidate elements.
INTEGER(INTG), INTENT(IN) :: candidateElements(:) !<candidateElememnts(candidateIdx). The list of candidate elements for the projection.
INTEGER(INTG), INTENT(OUT) :: closestElements(:) !<On exit, the list of element numbers with the shortest distances
REAL(DP), INTENT(OUT) :: closestDistances(:) !<On exit, the list of shortest distances (squared).
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: numberOfCoordinates !<Region coordinate dimension
INTEGER(INTG) :: numberOfClosestCandidates !<Number of closest elements to record
REAL(DP) :: distanceVector(3) !<distance vector between data point and interpolated point, maximum dimension is 3
REAL(DP) :: distance2 !<Distance squared
INTEGER(INTG) :: closestElementIdx
INTEGER(INTG) :: elementNumber,insertIdx
ENTERS("DataProjection_ClosestElementsFind",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(.NOT.dataProjection%dataProjectionFinished) CALL FlagError("Data projection has not been finished.",err,error,*999)
numberOfCoordinates=dataProjection%numberOfCoordinates
numberOfClosestCandidates=MIN(numberOfCandidates,SIZE(closestElements,1))
!loop through the first few elements
DO closestElementIdx=1,numberOfClosestCandidates
elementNumber=candidateElements(closestElementIdx)
CALL Field_InterpolationParametersElementGet(dataProjection%projectionSetType,elementNumber, &
& interpolatedPoint%INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates) = interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
DO insertIdx=closestElementIdx,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element number into the correct index
IF(insertIdx<closestElementIdx) THEN
closestDistances(insertIdx+1:closestElementIdx)=closestDistances(insertIdx:closestElementIdx-1)
closestElements(insertIdx+1:closestElementIdx)=closestElements(insertIdx:closestElementIdx-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
EXIT
ENDDO
ENDDO
!Loop through the rest of the elements
DO closestElementIdx=numberOfClosestCandidates+1,numberOfCandidates
elementNumber=candidateElements(closestElementIdx)
CALL Field_InterpolationParametersElementGet(dataProjection%projectionSetType,elementNumber, &
& interpolatedPoint%INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates)=interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
IF(distance2<closestDistances(numberOfClosestCandidates))THEN
DO insertIdx=numberOfClosestCandidates,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element into the correct index
IF(insertIdx<numberOfClosestCandidates) THEN
closestDistances(insertIdx+1:numberOfClosestCandidates)=closestDistances(insertIdx:numberOfClosestCandidates-1)
closestElements(insertIdx+1:numberOfClosestCandidates)=closestElements(insertIdx:numberOfClosestCandidates-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
EXIT
ENDDO
ENDIF
ENDDO
!closestDistances=SQRT(closestDistances) !return shortest distances
EXITS("DataProjection_ClosestElementsFind")
RETURN
999 ERRORSEXITS("DataProjection_ClosestElementsFind",err,error)
RETURN 1
END SUBROUTINE DataProjection_ClosestElementsFind
!
!================================================================================================================================
!
!>Find the closest faces to a data point base on starting xi guess.
SUBROUTINE DataProjection_ClosestFacesFind(dataProjection,interpolatedPoint,dataPointLocation,numberOfCandidates, &
& candidateElements,candidateElementFaces,closestElements,closestElementFaces,closestDistances,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<Data projection problem to evaluate
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: interpolatedPoint !<The interpolated point for the data point
REAL(DP), INTENT(IN) :: dataPointLocation(:) !<dataPointLocation(componentIdx). The location of data point in the region.
INTEGER(INTG), INTENT(IN) :: numberOfCandidates !<The number of candidate elements.
INTEGER(INTG), INTENT(IN) :: candidateElements(:) !<candidateElememnts(candidateIdx). The list of candidate elements for the projection.
INTEGER(INTG), INTENT(IN) :: candidateElementFaces(:) !<candidateElementFaces(candidateIdx). The list of candidate faces for the projection.
INTEGER(INTG), INTENT(OUT) :: closestElements(:) !<On exit, the list of element numbers with the shortest distances
INTEGER(INTG), INTENT(OUT) :: closestElementFaces(:) !<On exit, the list of face numbers with the shortest distances
REAL(DP), INTENT(OUT) :: closestDistances(:) !<On exit, the list of shortest distances (squared).
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: numberOfCoordinates !<Region coordinate dimension
INTEGER(INTG) :: numberOfClosestCandidates !<Number of closest elements to record
REAL(DP) :: distanceVector(3) !<distance vector between data point and interpolated point, maximum dimension is 3
REAL(DP) :: distance2 !<Distance squared
INTEGER(INTG) :: closestElementIdx
INTEGER(INTG) :: elementNumber,elementFaceNumber,faceNumber,insertIdx
ENTERS("DataProjection_ClosestFacesFind",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(.NOT.dataProjection%dataProjectionFinished) CALL FlagError("Data projection has not been finished.",err,error,*999)
numberOfCoordinates=dataProjection%numberOfCoordinates
numberOfClosestCandidates=MIN(numberOfCandidates,SIZE(closestElements,1))
!loop through the first few faces
DO closestElementIdx=1,numberOfClosestCandidates
elementNumber=candidateElements(closestElementIdx)
elementFaceNumber=candidateElementFaces(closestElementIdx)
faceNumber=interpolatedPoint%INTERPOLATION_PARAMETERS%field%decomposition%topology%elements%elements( &
& elementNumber)%ELEMENT_FACES(elementFaceNumber)
CALL Field_InterpolationParametersFaceGet(dataProjection%projectionSetType,faceNumber,interpolatedPoint% &
& INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates) = interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
DO insertIdx=closestElementIdx,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element number into the correct index
IF(insertIdx<closestElementIdx) THEN
closestDistances(insertIdx+1:closestElementIdx)=closestDistances(insertIdx:closestElementIdx-1)
closestElements(insertIdx+1:closestElementIdx)=closestElements(insertIdx:closestElementIdx-1)
closestElementFaces(insertIdx+1:closestElementIdx)=closestElementFaces(insertIdx:closestElementIdx-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
closestElementFaces(insertIdx)=elementFaceNumber
EXIT
ENDDO
ENDDO
!Loop through the rest of the faces
DO closestElementIdx=numberOfClosestCandidates+1,numberOfCandidates
elementNumber=candidateElements(closestElementIdx)
elementFaceNumber=candidateElementFaces(closestElementIdx)
faceNumber=interpolatedPoint%INTERPOLATION_PARAMETERS%field%decomposition%topology%elements%elements( &
& elementNumber)%ELEMENT_FACES(elementFaceNumber)
CALL Field_InterpolationParametersFaceGet(dataProjection%projectionSetType,faceNumber,interpolatedPoint% &
& INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates)=interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
IF(distance2<closestDistances(numberOfClosestCandidates))THEN
DO insertIdx=numberOfClosestCandidates,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element into the correct index
IF(insertIdx<numberOfClosestCandidates) THEN
closestDistances(insertIdx+1:numberOfClosestCandidates)=closestDistances(insertIdx:numberOfClosestCandidates-1)
closestElements(insertIdx+1:numberOfClosestCandidates)=closestElements(insertIdx:numberOfClosestCandidates-1)
closestElementFaces(insertIdx+1:numberOfClosestCandidates)=closestElementFaces(insertIdx: &
& numberOfClosestCandidates-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
closestElementFaces(insertIdx)=elementFaceNumber
EXIT
ENDDO
ENDIF
ENDDO
!closestDistances=SQRT(closestDistances) !return shortest distances
EXITS("DataProjection_ClosestFacesFind")
RETURN
999 ERRORSEXITS("DataProjection_ClosestFacesFind",err,error)
RETURN 1
END SUBROUTINE DataProjection_ClosestFacesFind
!
!================================================================================================================================
!
!>Find the closest lines to a data point base on starting xi guess.
SUBROUTINE DataProjection_ClosestLinesFind(dataProjection,interpolatedPoint,dataPointLocation,numberOfCandidates, &
& candidateElements,candidateElementLines,closestElements,closestElementLines,closestDistances,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<Data projection problem to evaluate
TYPE(FIELD_INTERPOLATED_POINT_TYPE), POINTER :: interpolatedPoint !<The interpolated point for the data point
REAL(DP), INTENT(IN) :: dataPointLocation(:) !<dataPointLocation(componentIdx). The location of data point in the region.
INTEGER(INTG), INTENT(IN) :: numberOfCandidates !<The number of candidate elements.
INTEGER(INTG), INTENT(IN) :: candidateElements(:) !<candidateElememnts(candidateIdx). The list of candidate elements for the projection.
INTEGER(INTG), INTENT(IN) :: candidateElementLines(:) !<candidateElementLines(candidateIdx). The list of candidate lines for the projection.
INTEGER(INTG), INTENT(OUT) :: closestElements(:) !<On exit, the list of element numbers with the shortest distances
INTEGER(INTG), INTENT(OUT) :: closestElementLines(:) !<On exit, the list of lines numbers with the shortest distances
REAL(DP), INTENT(OUT) :: closestDistances(:) !<On exit, the list of shortest distances (squared).
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: numberOfCoordinates !<Region coordinate dimension
INTEGER(INTG) :: numberOfClosestCandidates !<Number of closest elements to record
REAL(DP) :: distanceVector(3) !<distance vector between data point and interpolated point, maximum dimension is 3
REAL(DP) :: distance2 !<Distance squared
INTEGER(INTG) :: closestElementIdx
INTEGER(INTG) :: elementNumber,elementLineNumber,lineNumber,insertIdx
ENTERS("DataProjection_ClosestLinesFind",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(.NOT.dataProjection%dataProjectionFinished) CALL FlagError("Data projection has not been finished.",err,error,*999)
numberOfCoordinates=dataProjection%numberOfCoordinates
numberOfClosestCandidates=MIN(numberOfCandidates,SIZE(closestElements,1))
!loop through the first few lines
DO closestElementIdx=1,numberOfClosestCandidates
elementNumber=candidateElements(closestElementIdx)
elementLineNumber=candidateElementLines(closestElementIdx)
lineNumber=interpolatedPoint%INTERPOLATION_PARAMETERS%field%decomposition%topology%elements%elements( &
& elementNumber)%ELEMENT_LINES(elementLineNumber)
CALL Field_InterpolationParametersLineGet(dataProjection%projectionSetType,lineNumber,interpolatedPoint% &
& INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates) = interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
DO insertIdx=closestElementIdx,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element number into the correct index
IF(insertIdx<closestElementIdx) THEN
closestDistances(insertIdx+1:closestElementIdx)=closestDistances(insertIdx:closestElementIdx-1)
closestElements(insertIdx+1:closestElementIdx)=closestElements(insertIdx:closestElementIdx-1)
closestElementLines(insertIdx+1:closestElementIdx)=closestElementLines(insertIdx:closestElementIdx-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
closestElementLines(insertIdx)=elementLineNumber
EXIT
ENDDO
ENDDO
!Loop through the rest of the lines
DO closestElementIdx=numberOfClosestCandidates+1,numberOfCandidates
elementNumber=candidateElements(closestElementIdx)
elementLineNumber=candidateElementLines(closestElementIdx)
lineNumber=interpolatedPoint%INTERPOLATION_PARAMETERS%field%decomposition%topology%elements%elements( &
& elementNumber)%ELEMENT_LINES(elementLineNumber)
CALL Field_InterpolationParametersLineGet(dataProjection%projectionSetType,lineNumber,interpolatedPoint% &
& INTERPOLATION_PARAMETERS,err,error,*999,FIELD_GEOMETRIC_COMPONENTS_TYPE)
CALL Field_InterpolateXi(NO_PART_DERIV,dataProjection%startingXi,interpolatedPoint,err,error,*999, &
& FIELD_GEOMETRIC_COMPONENTS_TYPE)
distanceVector(1:numberOfCoordinates)=interpolatedPoint%values(:,1)-dataPointLocation
distance2 = DOT_PRODUCT(distanceVector(1:numberOfCoordinates),distanceVector(1:numberOfCoordinates))
IF(distance2<closestDistances(numberOfClosestCandidates))THEN
DO insertIdx=numberOfClosestCandidates,1,-1
IF(insertIdx>1) THEN
IF(distance2<closestDistances(insertIdx-1)) CYCLE
ENDIF
!insert the element into the correct index
IF(insertIdx<numberOfClosestCandidates) THEN
closestDistances(insertIdx+1:numberOfClosestCandidates)=closestDistances(insertIdx:numberOfClosestCandidates-1)
closestElements(insertIdx+1:numberOfClosestCandidates)=closestElements(insertIdx:numberOfClosestCandidates-1)
closestElementLines(insertIdx+1:numberOfClosestCandidates)=closestElementLines(insertIdx: &
& numberOfClosestCandidates-1)
ENDIF
closestDistances(insertIdx)=distance2
closestElements(insertIdx)=elementNumber
closestElementLines(insertIdx)=elementLineNumber
EXIT
ENDDO
ENDIF
ENDDO
!closestDistances=SQRT(closestDistances) !return shortest distances
EXITS("DataProjection_ClosestLinesFind")
RETURN
999 ERRORSEXITS("DataProjection_ClosestLinesFind",err,error)
RETURN 1
END SUBROUTINE DataProjection_ClosestLinesFind
!
!================================================================================================================================
!
!>Finishes the process of creating data projection.
SUBROUTINE DataProjection_CreateFinish(dataProjection,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<On exit, a pointer to the created data projection
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
TYPE(DataPointsType), POINTER :: dataPoints
TYPE(DECOMPOSITION_TYPE), POINTER :: decomposition
TYPE(VARYING_STRING) :: localError
ENTERS("DataProjection_CreateFinish",err,error,*999)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
IF(dataProjection%dataProjectionFinished) CALL FlagError("Data projection has already been finished.",err,error,*999)
NULLIFY(dataPoints)
CALL DataProjection_DataPointsGet(dataProjection,dataPoints,err,error,*999)
IF(.NOT.dataPoints%dataPointsFinished) &
& CALL FlagError("Data projection data points have not been finished.",err,error,*999)
NULLIFY(decomposition)
CALL DataProjection_DecompositionGet(dataProjection,decomposition,err,error,*999)
!Perform various checks
SELECT CASE(dataProjection%projectionType)
CASE(DATA_PROJECTION_BOUNDARY_LINES_PROJECTION_TYPE)
!Check we have lines calculated
IF(.NOT.decomposition%CALCULATE_LINES) &
& CALL FlagError("Need to set the decomposition calculate lines to true for a boundary lines projection type.", &
& err,error,*999)
CASE(DATA_PROJECTION_BOUNDARY_FACES_PROJECTION_TYPE)
!Check we have faces calculated
IF(.NOT.decomposition%CALCULATE_FACES) &
& CALL FlagError("Need to set the decomposition calculate faces to true for a boundary faces projection type.", &
& err,error,*999)
CASE(DATA_PROJECTION_ALL_ELEMENTS_PROJECTION_TYPE)
!Do nothing
CASE DEFAULT
localError="The data projection type of "//TRIM(NumberToVString(dataProjection%projectionType,"*",err,error))//" is invalid."
CALL FlagError(localError,err,error,*999)
END SELECT
!Finish the data projection
dataProjection%dataProjectionFinished=.TRUE.
!Initialise data projection part in data points
CALL DataProjection_DataProjectionResultsInitialise(dataProjection,err,error,*999)
EXITS("DataProjection_CreateFinish")
RETURN
999 ERRORSEXITS("DataProjection_CreateFinish",err,error)
RETURN 1
END SUBROUTINE DataProjection_CreateFinish
!
!================================================================================================================================
!
!>Starts the process of creating data projection.
SUBROUTINE DataProjection_CreateStart(dataProjectionUserNumber,dataPoints,projectionField,projectionVariableType, &
& dataProjection,err,error,*)
!Argument variables
INTEGER(INTG), INTENT(IN) :: dataProjectionUserNumber !<The user number of the data projection
TYPE(DataPointsType), POINTER :: dataPoints !<A pointer to the data points in which to create data projection
TYPE(FIELD_TYPE), POINTER :: projectionField !<A pointer to the field for the data projection
INTEGER(INTG), INTENT(IN) :: projectionVariableType !<The field variable type of the projection field for the data projection \see FIELD_ROUTINES_VariableTypes,FIELD_ROUTINES
TYPE(DataProjectionType), POINTER :: dataProjection !<On exit, a pointer to the created data projection. Must not be associated on entry.
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: dataProjectionIdx,dummyErr,insertStatus,numberOfCoordinates
TYPE(COORDINATE_SYSTEM_TYPE), POINTER :: dataPointsCoordinateSystem,fieldCoordinateSystem
TYPE(DataProjectionPtrType), ALLOCATABLE :: newDataProjections(:)
TYPE(DECOMPOSITION_TYPE), POINTER :: fieldDecomposition
TYPE(FIELD_VARIABLE_TYPE), POINTER :: projectionFieldVariable
TYPE(VARYING_STRING) :: dummyError,localError
ENTERS("DataProjection_CreateStart",err,error,*998)
IF(.NOT.ASSOCIATED(dataPoints)) CALL FlagError("Data points is not associated.",err,error,*998)
IF(.NOT.dataPoints%dataPointsFinished) CALL FlagError("Data points have not been finished.",err,error,*998)
IF(.NOT.ASSOCIATED(projectionField)) CALL FlagError("Projection field is not associated.",err,error,*998)
IF(ASSOCIATED(dataProjection)) CALL FlagError("Data projection is already associated.",err,error,*998)
NULLIFY(projectionFieldVariable)
CALL Field_VariableGet(projectionField,projectionVariableType,projectionFieldVariable,err,error,*999)
NULLIFY(dataPointsCoordinateSystem)
CALL DataPoints_CoordinateSystemGet(dataPoints,dataPointsCoordinateSystem,err,error,*999)
NULLIFY(fieldCoordinateSystem)
CALL Field_CoordinateSystemGet(projectionField,fieldCoordinateSystem,err,error,*999)
NULLIFY(fieldDecomposition)
CALL Field_DecompositionGet(projectionField,fieldDecomposition,err,error,*999)
!Check we are on the same coordinate system
IF(ASSOCIATED(dataPointsCoordinateSystem,fieldCoordinateSystem)) THEN
CALL CoordinateSystem_DimensionGet(dataPointsCoordinateSystem,numberOfCoordinates,err,error,*999)
NULLIFY(dataProjection)
CALL DataProjection_Initialise(dataProjection,err,error,*999)
dataProjection%userNumber=dataProjectionUserNumber
dataProjection%dataPoints=>dataPoints
dataProjection%projectionField=>projectionField
dataProjection%projectionVariableType=projectionVariableType
dataProjection%decomposition=>fieldDecomposition
dataProjection%numberOfCoordinates=numberOfCoordinates
dataProjection%numberOfElementXi=fieldDecomposition%numberOfDimensions
!Default always project to boundaries faces/lines when decomposition dimension is equal to region dimension.
!If decomposition dimension is less, project to all elements
IF(fieldDecomposition%numberOfDimensions<numberOfCoordinates) THEN !decomposition dimension < data dimension
dataProjection%numberOfXi=fieldDecomposition%numberOfDimensions
dataProjection%projectionType=DATA_PROJECTION_ALL_ELEMENTS_PROJECTION_TYPE
ELSE
SELECT CASE(fieldDecomposition%numberOfDimensions) !decomposition dimension = data dimension
CASE(1)
dataProjection%numberOfXi=1
dataProjection%projectionType=DATA_PROJECTION_ALL_ELEMENTS_PROJECTION_TYPE
CASE(2)
dataProjection%numberOfXi=1
dataProjection%projectionType=DATA_PROJECTION_BOUNDARY_LINES_PROJECTION_TYPE
CASE(3)
dataProjection%numberOfXi=2
dataProjection%projectionType=DATA_PROJECTION_BOUNDARY_FACES_PROJECTION_TYPE
CASE DEFAULT
localError="The decomposition dimension of "// &
& TRIM(NumberToVString(fieldDecomposition%numberOfDimensions,"*",err,error))// &
& " is invalid. The dimension should be >=1 and <= 3."
CALL FlagError(localError,err,error,*999)
END SELECT
ENDIF
SELECT CASE(dataProjection%numberOfXi) !mesh dimension = data dimension
CASE(1)
dataProjection%numberOfClosestElements=2
CASE(2)
dataProjection%numberOfClosestElements=4
CASE(3)
dataProjection%numberOfClosestElements=8
CASE DEFAULT
localError="The number of xi directions of "// &
& TRIM(NumberToVString(fieldDecomposition%numberOfDimensions,"*",err,error))// &
& " is invalid. The number of directions should be >=1 and <= 3."
CALL FlagError(localError,err,error,*999)
END SELECT
ALLOCATE(dataProjection%startingXi(dataProjection%numberOfXi),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate data points data projection starting xi.",err,error,*999)
dataProjection%startingXi=0.5_DP !<initialised to 0.5 in each xi direction
CALL DataProjection_DataProjectionCandidatesInitialise(dataProjection,err,error,*999)
ALLOCATE(newDataProjections(dataPoints%dataProjections%numberOfDataProjections+1),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate new data projections.",err,error,*999)
IF(dataPoints%dataProjections%numberOfDataProjections>0) THEN
DO dataProjectionIdx=1,dataPoints%dataProjections%numberOfDataProjections
newDataProjections(dataProjectionIdx)%ptr=>dataPoints%dataProjections%dataProjections(dataProjectionIdx)%ptr
ENDDO !xiIdx
ENDIF
!Return the pointer
newDataProjections(dataPoints%dataProjections%numberOfDataProjections+1)%ptr=>dataProjection
dataPoints%dataProjections%numberOfDataProjections=dataPoints%dataProjections%numberOfDataProjections+1
dataProjection%globalNumber=dataPoints%dataProjections%numberOfDataProjections
CALL MOVE_ALLOC(newDataProjections,dataPoints%dataProjections%dataProjections)
ELSE
CALL FlagError("The data points and projection field have different coordinate systems.",err,error,*998)
ENDIF
EXITS("DataProjection_CreateStart")
RETURN
999 CALL DataProjection_Finalise(dataProjection,dummyErr,dummyError,*998)
998 IF(ALLOCATED(newDataProjections)) DEALLOCATE(newDataProjections)
ERRORSEXITS("DataProjection_CreateStart",err,error)
RETURN 1
END SUBROUTINE DataProjection_CreateStart
!
!================================================================================================================================
!
!>Checks that a user data point number is defined for a specific data projection
SUBROUTINE DataProjection_DataPointCheckExists(dataProjection,dataPointUserNumber,dataPointExists,dataPointGlobalNumber, &
& err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection whose data points to check
INTEGER(INTG) :: dataPointUserNumber !<The user data point number to check if it exists
LOGICAL, INTENT(OUT) :: dataPointExists !<On exit, is .TRUE. if the data point user number exists in the region, .FALSE. if not
INTEGER(INTG), INTENT(OUT) :: dataPointGlobalNumber !<On exit, if the data point exists the global number corresponding to the user data point number. If the data point does not exist then global number will be 0.
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
TYPE(DataPointsType), POINTER :: dataPoints
TYPE(TREE_NODE_TYPE), POINTER :: treeNode
ENTERS("DataProjection_DataPointCheckExists",err,ERROR,*999)
dataPointExists=.FALSE.
dataPointGlobalNumber=0
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*999)
NULLIFY(dataPoints)
CALL DataProjection_DataPointsGet(dataProjection,dataPoints,err,error,*999)
NULLIFY(treeNode)
CALL Tree_Search(dataPoints%dataPointsTree,dataPointUserNumber,treeNode,err,error,*999)
IF(ASSOCIATED(treeNode)) THEN
CALL Tree_NodeValueGet(dataPoints%dataPointsTree,treeNode,dataPointGlobalNumber,err,error,*999)
dataPointExists=.TRUE.
ENDIF
EXITS("DataProjection_DataPointCheckExists")
RETURN
999 ERRORSEXITS("DataProjection_DataPointCheckExists",err,error)
RETURN 1
END SUBROUTINE DataProjection_DataPointCheckExists
!
!================================================================================================================================
!
!>Finalises the data projection candidate and deallocates all memory
SUBROUTINE DataProjection_DataProjectionCandidateFinalise(dataProjectionCandidate,err,error,*)
!Argument variables
TYPE(DataProjectionCandidateType), INTENT(INOUT) :: dataProjectionCandidate !<The data candidate result to finalise
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_DataProjectionCandidateFinalise",err,error,*999)
IF(ALLOCATED(dataProjectionCandidate%candidateElementNumbers)) DEALLOCATE(dataProjectionCandidate%candidateElementNumbers)
IF(ALLOCATED(dataProjectionCandidate%localFaceLineNumbers)) DEALLOCATE(dataProjectionCandidate%localFaceLineNumbers)
EXITS("DataProjection_DataProjectionCandidateFinalise")
RETURN
999 ERRORS("DataProjection_DataProjectionCandidateFinalise",err,error)
EXITS("DataProjection_DataProjectionCandidateFinalise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionCandidateFinalise
!
!================================================================================================================================
!
!>Initialises a data projection candidate
SUBROUTINE DataProjection_DataProjectionCandidateInitialise(dataProjectionCandidate,err,error,*)
!Argument variables
TYPE(DataProjectionCandidateType) :: dataProjectionCandidate !<The data projection candidate to initialise
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_DataProjectionCandidateInitialise",err,error,*999)
IF(ALLOCATED(dataProjectionCandidate%candidateElementNumbers)) DEALLOCATE(dataProjectionCandidate%candidateElementNumbers)
IF(ALLOCATED(dataProjectionCandidate%localFaceLineNumbers)) DEALLOCATE(dataProjectionCandidate%localFaceLineNumbers)
EXITS("DataProjection_DataProjectionCandidateInitialise")
RETURN
999 ERRORS("DataProjection_DataProjectionCandidateInitialise",err,error)
EXITS("DataProjection_DataProjectionCandidateInitialise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionCandidateInitialise
!
!================================================================================================================================
!
!>Finalise data projection candidates.
SUBROUTINE DataProjection_DataProjectionCandidatesFinalise(dataProjection,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection to finalise the data projection candidates for
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: dataPointIdx
ENTERS("DataProjection_DataProjectionCandidatesFinalise",err,error,*999)
IF(ASSOCIATED(dataProjection)) THEN
IF(ALLOCATED(dataProjection%dataProjectionCandidates)) THEN
DO dataPointIdx=0,SIZE(dataProjection%dataProjectionCandidates,1)-1
CALL DataProjection_DataProjectionCandidateFinalise(dataProjection%dataProjectionCandidates(dataPointIdx),err,error,*999)
ENDDO !dataPointIdx
DEALLOCATE(dataProjection%dataProjectionCandidates)
ENDIF
ENDIF
EXITS("DataProjection_DataProjectionCandidatesFinalise")
RETURN
999 ERRORS("DataProjection_DataProjectionCandidatesFinalise",err,error)
EXITS("DataProjection_DataProjectionCandidatesFinalise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionCandidatesFinalise
!
!================================================================================================================================
!
!>Initialises the data projection candidates.
SUBROUTINE DataProjection_DataProjectionCandidatesInitialise(dataProjection,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection to initialise the projection candidates for
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
INTEGER(INTG) :: dataPointIdx,dummyErr,numberOfDataPoints
TYPE(DataPointsType), POINTER :: dataPoints
TYPE(VARYING_STRING) :: dummyError
ENTERS("DataProjection_DataProjectionCandidatesInitialise",err,error,*998)
IF(.NOT.ASSOCIATED(dataProjection)) CALL FlagError("Data projection is not associated.",err,error,*998)
NULLIFY(dataPoints)
CALL DataProjection_DataPointsGet(dataProjection,dataPoints,err,error,*998)
numberOfDataPoints = dataPoints%numberOfDataPoints
ALLOCATE(dataProjection%dataProjectionCandidates(0:numberOfDataPoints),STAT=err)
IF(err/=0) CALL FlagError("Could not allocate data projection data projection candidates.",err,error,*999)
DO dataPointIdx=1,numberOfDataPoints
CALL DataProjection_DataProjectionCandidateInitialise(dataProjection%dataProjectionCandidates(dataPointIdx),err,error,*999)
ENDDO !dataPointIdx
EXITS("DataProjection_DataProjectionCandidatesInitialise")
RETURN
999 CALL DataProjection_DataProjectionCandidatesFinalise(dataProjection,dummyErr,dummyError,*998)
998 ERRORS("DataProjection_DataProjectionCandidatesInitialise",err,error)
EXITS("DataProjection_DataProjectionCandidatesInitialise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionCandidatesInitialise
!
!================================================================================================================================
!
!>Cancels a data projection result
SUBROUTINE DataProjection_DataProjectionResultCancel(dataProjectionResult,err,error,*)
!Argument variables
TYPE(DataProjectionResultType) :: dataProjectionResult !<The data projection result to cancel
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_DataProjectionResultCancel",err,error,*999)
CALL DataProjection_DataProjectionResultInitialise(dataProjectionResult,err,error,*999)
dataProjectionResult%exitTag=DATA_PROJECTION_CANCELLED
IF(ALLOCATED(dataProjectionResult%xi)) dataProjectionResult%xi=0.0_DP
IF(ALLOCATED(dataProjectionResult%elementXi)) dataProjectionResult%elementXi=0.0_DP
IF(ALLOCATED(dataProjectionResult%projectionVector)) dataProjectionResult%projectionVector=0.0_DP
EXITS("DataProjection_DataProjectionResultCancel")
RETURN
999 ERRORS("DataProjection_DataProjectionResultCancel",err,error)
EXITS("DataProjection_DataProjectionResultCancel")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionResultCancel
!
!================================================================================================================================
!
!>Finalises the data projection result and deallocates all memory
SUBROUTINE DataProjection_DataProjectionResultFinalise(dataProjectionResult,err,error,*)
!Argument variables
TYPE(DataProjectionResultType), INTENT(INOUT) :: dataProjectionResult !<The data projection result to finalise
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_DataProjectionResultFinalise",err,error,*999)
dataProjectionResult%userNumber=0
dataProjectionResult%distance=0.0
dataProjectionResult%elementLocalNumber=0
dataProjectionResult%elementGlobalNumber=0
dataProjectionResult%elementLineFaceNumber=0
dataProjectionResult%exitTag=0
IF(ALLOCATED(dataProjectionResult%xi)) DEALLOCATE(dataProjectionResult%xi)
IF(ALLOCATED(dataProjectionResult%elementXi)) DEALLOCATE(dataProjectionResult%elementXi)
IF(ALLOCATED(dataProjectionResult%projectionVector)) DEALLOCATE(dataProjectionResult%projectionVector)
EXITS("DataProjection_DataProjectionResultFinalise")
RETURN
999 ERRORS("DataProjection_DataProjectionResultFinalise",err,error)
EXITS("DataProjection_DataProjectionResultFinalise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionResultFinalise
!
!================================================================================================================================
!
!>Initialises a data projection result
SUBROUTINE DataProjection_DataProjectionResultInitialise(dataProjectionResult,err,error,*)
!Argument variables
TYPE(DataProjectionResultType) :: dataProjectionResult !<The data projection result to initialise
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
ENTERS("DataProjection_DataProjectionResultInitialise",err,error,*999)
dataProjectionResult%userNumber=0
dataProjectionResult%distance=0.0_DP
dataProjectionResult%elementLocalNumber=0
dataProjectionResult%elementGlobalNumber=0
dataProjectionResult%elementLineFaceNumber=0
dataProjectionResult%exitTag=DATA_PROJECTION_EXIT_TAG_NO_ELEMENT
EXITS("DataProjection_DataProjectionResultInitialise")
RETURN
999 ERRORS("DataProjection_DataProjectionResultInitialise",err,error)
EXITS("DataProjection_DataProjectionResultInitialise")
RETURN 1
END SUBROUTINE DataProjection_DataProjectionResultInitialise
!
!================================================================================================================================
!
!>Finalise a data projection.
SUBROUTINE DataProjection_DataProjectionResultsFinalise(dataProjection,err,error,*)
!Argument variables
TYPE(DataProjectionType), POINTER :: dataProjection !<A pointer to the data projection to finalise the data projection results for