OpenCMISS-Iron Internal API Documentation
analytic_analysis_routines.f90
Go to the documentation of this file.
1 
43 
46 
47  USE basis_routines
48  USE cmiss_mpi
50  USE constants
51  USE field_routines
52  USE input_output
54  USE kinds
55  USE matrix_vector
56 #ifndef NOMPIMOD
57  USE mpi
58 #endif
59  USE strings
60  USE timer
61  USE types
62 
63 #include "macros.h"
64 
65  IMPLICIT NONE
66 
67  PRIVATE
68 
69 #ifdef NOMPIMOD
70 #include "mpif.h"
71 #endif
72 
73  !Module parameters
74 
79  INTEGER(INTG), PARAMETER :: absolute_error_type=1
80  INTEGER(INTG), PARAMETER :: percentage_error_type=2
81  INTEGER(INTG), PARAMETER :: relative_error_type=3
83 
84  !Module types
85 
86  !Module variables
87 
88  !Interfaces
89 
91 
94 
97 
100 
105 
106 CONTAINS
107 
108  !
109  !================================================================================================================================
110  !
111 
113  SUBROUTINE analyticanalysis_output(FIELD,FILENAME,ERR,ERROR,*)
114 
115  !Argument variables
116  TYPE(field_type), INTENT(IN), POINTER :: FIELD
117  CHARACTER(LEN=*) :: FILENAME
118  INTEGER(INTG), INTENT(OUT) :: ERR
119  TYPE(varying_string), INTENT(OUT) :: ERROR
120  !Local Variables
121  INTEGER(INTG) :: component_idx,deriv_idx,element_idx,GHOST_NUMBER(8),local_ny,MESH_COMPONENT,MPI_IERROR,node_idx, &
122  & NUMBER(8),OUTPUT_ID,var_idx,variable_type
123  REAL(DP) :: GHOST_RMS_ERROR_PER(8),GHOST_RMS_ERROR_ABS(8),GHOST_RMS_ERROR_REL(8),RMS_ERROR_PER(8),RMS_ERROR_ABS(8), &
124  & RMS_ERROR_REL(8),VALUES(5)
125  REAL(DP), POINTER :: ANALYTIC_VALUES(:),NUMERICAL_VALUES(:)
126  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:),GHOST_INTEGRAL_ERRORS(:,:)
127  CHARACTER(LEN=40) :: FIRST_FORMAT
128  CHARACTER(LEN=MAXSTRLEN) :: FILE_NAME
129  TYPE(decomposition_type), POINTER :: DECOMPOSITION
130  TYPE(decomposition_elements_type), POINTER :: ELEMENTS_DECOMPOSITION
131  TYPE(decomposition_topology_type), POINTER :: DECOMPOSITION_TOPOLOGY
132  TYPE(domain_type), POINTER :: DOMAIN
133  TYPE(domain_elements_type), POINTER :: ELEMENTS_DOMAIN
134  TYPE(domain_nodes_type), POINTER :: NODES_DOMAIN
135  TYPE(domain_topology_type), POINTER :: DOMAIN_TOPOLOGY
136  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
137  TYPE(varying_string) :: LOCAL_ERROR,LOCAL_STRING
138 
139  NULLIFY(analytic_values)
140  NULLIFY(numerical_values)
141 
142  enters("AnalyticAnalysis_Output",err,error,*999)
143 
144  IF(ASSOCIATED(field)) THEN
145  IF(field%FIELD_FINISHED) THEN
146  IF(field%DEPENDENT_TYPE==field_dependent_type) THEN
147  IF(len_trim(filename)>=1) THEN
148 !!TODO \todo have more general ascii file mechanism
149  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
150  WRITE(file_name,'(A,".opanal.",I0)') filename(1:len_trim(filename)),computational_environment% &
151  & my_computational_node_number
152  ELSE
153  file_name=filename(1:len_trim(filename))//".opanal"
154  ENDIF
155  output_id=io1_file_unit
156  OPEN(unit=output_id,file=file_name(1:len_trim(file_name)),status="REPLACE",form="FORMATTED",iostat=err)
157  IF(err/=0) CALL flagerror("Error opening analysis output file.",err,error,*999)
158  ELSE
159  output_id=general_output_type
160  ENDIF
161  decomposition=>field%DECOMPOSITION
162  IF(ASSOCIATED(decomposition)) THEN
163  decomposition_topology=>decomposition%TOPOLOGY
164  IF(ASSOCIATED(decomposition_topology)) THEN
165  CALL write_string(output_id,"Analytic error analysis:",err,error,*999)
166  CALL write_string(output_id,"",err,error,*999)
167  local_string="Field "//trim(number_to_vstring(field%USER_NUMBER,"*",err,error))//" : "//field%LABEL
168  IF(err/=0) GOTO 999
169  CALL write_string(output_id,local_string,err,error,*999)
170  NULLIFY(numerical_values)
171  NULLIFY(analytic_values)
172  !Loop over the variables
173  DO var_idx=1,field%NUMBER_OF_VARIABLES
174  variable_type=field%VARIABLES(var_idx)%VARIABLE_TYPE
175  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
176  IF(ASSOCIATED(field_variable)) THEN
177  CALL write_string(output_id,"",err,error,*999)
178  local_string="Variable "//trim(number_to_vstring(variable_type,"*",err,error))//" : "// &
179  & field_variable%VARIABLE_LABEL
180  IF(err/=0) GOTO 999
181  CALL write_string(output_id,local_string,err,error,*999)
182  CALL write_string(output_id,"",err,error,*999)
183  !Get the dependent and analytic parameter sets
184  CALL field_parameter_set_data_get(field,variable_type,field_values_set_type,numerical_values,err,error,*999)
185  CALL field_parameter_set_data_get(field,variable_type,field_analytic_values_set_type,analytic_values, &
186  & err,error,*999)
187  !Loop over the components
188  DO component_idx=1,field%VARIABLES(var_idx)%NUMBER_OF_COMPONENTS
189  mesh_component=field_variable%COMPONENTS(component_idx)%MESH_COMPONENT_NUMBER
190  domain=>field_variable%COMPONENTS(component_idx)%DOMAIN
191  IF(ASSOCIATED(domain)) THEN
192  domain_topology=>domain%TOPOLOGY
193  IF(ASSOCIATED(domain_topology)) THEN
194  local_string="Component "//trim(number_to_vstring(component_idx,"*",err,error))//" : "// &
195  & field_variable%COMPONENTS(component_idx)%COMPONENT_LABEL
196  IF(err/=0) GOTO 999
197  CALL write_string(output_id,local_string,err,error,*999)
198  CALL write_string(output_id,"",err,error,*999)
199  SELECT CASE(field%VARIABLES(var_idx)%COMPONENTS(component_idx)%INTERPOLATION_TYPE)
200  CASE(field_constant_interpolation)
201  CALL write_string(output_id,"Constant errors:",err,error,*999)
202  local_string=" Numerical Analytic % error Absolute err Relative err"
203  CALL write_string(output_id,local_string,err,error,*999)
204  local_ny=field_variable%COMPONENTS(component_idx)%PARAM_TO_DOF_MAP%CONSTANT_PARAM2DOF_MAP
205  values(1)=numerical_values(local_ny)
206  values(2)=analytic_values(local_ny)
207  values(3)=analytic_analysis_percentage_error(values(1),values(2))
208  values(4)=analytic_analysis_absolute_error(values(1),values(2))
209  values(5)=analytic_analysis_relative_error(values(1),values(2))
210  CALL write_string_vector(output_id,1,1,5,5,5,values,"(20X,5(2X,E12.5))","(20X,5(2X,E12.5))", &
211  & err,error,*999)
212  CASE(field_element_based_interpolation)
213  elements_domain=>domain_topology%ELEMENTS
214  IF(ASSOCIATED(elements_domain)) THEN
215  decomposition=>domain%DECOMPOSITION
216  IF(ASSOCIATED(decomposition)) THEN
217  decomposition_topology=>decomposition%TOPOLOGY
218  IF(ASSOCIATED(decomposition_topology)) THEN
219  elements_decomposition=>decomposition_topology%ELEMENTS
220  IF(ASSOCIATED(elements_decomposition)) THEN
221  number=0
222  rms_error_per=0.0_dp
223  rms_error_abs=0.0_dp
224  rms_error_rel=0.0_dp
225  ghost_number=0
226  ghost_rms_error_per=0.0_dp
227  ghost_rms_error_abs=0.0_dp
228  ghost_rms_error_rel=0.0_dp
229  CALL write_string(output_id,"Element errors:",err,error,*999)
230  local_string= &
231  & " Element# Numerical Analytic % error Absolute err Relative err"
232  CALL write_string(output_id,local_string,err,error,*999)
233  DO element_idx=1,elements_domain%NUMBER_OF_ELEMENTS
234  local_ny=field_variable%COMPONENTS(component_idx)%PARAM_TO_DOF_MAP% &
235  & element_param2dof_map%ELEMENTS(element_idx)
236  values(1)=numerical_values(local_ny)
237  values(2)=analytic_values(local_ny)
238  values(3)=analytic_analysis_percentage_error(values(1),values(2))
239  values(4)=analytic_analysis_absolute_error(values(1),values(2))
240  values(5)=analytic_analysis_relative_error(values(1),values(2))
241  !Accumlate the RMS errors
242  number(1)=number(1)+1
243  rms_error_per(1)=rms_error_per(1)+values(3)*values(3)
244  rms_error_abs(1)=rms_error_abs(1)+values(4)*values(4)
245  rms_error_rel(1)=rms_error_rel(1)+values(5)*values(5)
246  WRITE(first_format,"(A,I10,A)") "('",elements_decomposition%ELEMENTS(element_idx)%USER_NUMBER, &
247  & "',20X,3(2X,E12.5))"
248  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))", &
249  & err,error,*999)
250  ENDDO !element_idx
251  DO element_idx=elements_domain%NUMBER_OF_ELEMENTS+1,elements_domain%TOTAL_NUMBER_OF_ELEMENTS
252  local_ny=field_variable%COMPONENTS(component_idx)%PARAM_TO_DOF_MAP% &
253  & element_param2dof_map%ELEMENTS(element_idx)
254  values(1)=numerical_values(local_ny)
255  values(2)=analytic_values(local_ny)
256  values(3)=analytic_analysis_percentage_error(values(1),values(2))
257  values(4)=analytic_analysis_absolute_error(values(1),values(2))
258  values(5)=analytic_analysis_relative_error(values(1),values(2))
259  !Accumlate the RMS errors
260  ghost_number(1)=ghost_number(1)+1
261  ghost_rms_error_per(1)=ghost_rms_error_per(1)+values(3)*values(3)
262  ghost_rms_error_abs(1)=ghost_rms_error_abs(1)+values(4)*values(4)
263  ghost_rms_error_rel(1)=ghost_rms_error_rel(1)+values(5)*values(5)
264  WRITE(first_format,"(A,I10,A)") "('",elements_decomposition%ELEMENTS(element_idx)%USER_NUMBER, &
265  & "',20X,3(2X,E12.5))"
266  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))", &
267  & err,error,*999)
268  ENDDO !node_idx
269  !Output RMS errors
270  CALL write_string(output_id,"",err,error,*999)
271  IF(number(1)>0) THEN
272  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
273  !Local elements only
274  CALL write_string(output_id,"Local RMS errors:",err,error,*999)
275  local_string= &
276  & " % error Absolute err Relative err"
277  CALL write_string(output_id,local_string,err,error,*999)
278  values(1)=sqrt(rms_error_per(deriv_idx)/number(deriv_idx))
279  values(2)=sqrt(rms_error_abs(deriv_idx)/number(deriv_idx))
280  values(3)=sqrt(rms_error_rel(deriv_idx)/number(deriv_idx))
281  CALL write_string_vector(output_id,1,1,3,3,3,values,"(46X,3(2X,E12.5))","(46X,3(2X,E12.5))", &
282  & err,error,*999)
283  !Local and ghost nodes
284  CALL write_string(output_id,"Local + Ghost RMS errors:",err,error,*999)
285  local_string= &
286  & " % error Absolute err Relative err"
287  CALL write_string(output_id,local_string,err,error,*999)
288  values(1)=sqrt((rms_error_per(1)+ghost_rms_error_per(1))/(number(1)+ghost_number(1)))
289  values(2)=sqrt((rms_error_abs(1)+ghost_rms_error_abs(1))/(number(1)+ghost_number(1)))
290  values(3)=sqrt((rms_error_rel(1)+ghost_rms_error_rel(1))/(number(1)+ghost_number(1)))
291  CALL write_string_vector(output_id,1,1,3,3,3,values,"(46X,3(2X,E12.5))","(46X,3(2X,E12.5))", &
292  & err,error,*999)
293  !Global RMS values
294  !Collect the values across the ranks
295  CALL mpi_allreduce(mpi_in_place,number,1,mpi_integer,mpi_sum, &
296  & computational_environment%MPI_COMM,mpi_ierror)
297  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
298  CALL mpi_allreduce(mpi_in_place,rms_error_per,1,mpi_double_precision,mpi_sum, &
299  & computational_environment%MPI_COMM,mpi_ierror)
300  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
301  CALL mpi_allreduce(mpi_in_place,rms_error_abs,1,mpi_double_precision,mpi_sum, &
302  & computational_environment%MPI_COMM,mpi_ierror)
303  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
304  CALL mpi_allreduce(mpi_in_place,rms_error_rel,1,mpi_double_precision,mpi_sum, &
305  & computational_environment%MPI_COMM,mpi_ierror)
306  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
307  CALL write_string(output_id,"Global RMS errors:",err,error,*999)
308  local_string= &
309  & " % error Absolute err Relative err"
310  CALL write_string(output_id,local_string,err,error,*999)
311  values(1)=sqrt(rms_error_per(1)/number(1))
312  values(2)=sqrt(rms_error_abs(1)/number(1))
313  values(3)=sqrt(rms_error_rel(1)/number(1))
314  CALL write_string_vector(output_id,1,1,3,3,3,values,"(46X,3(2X,E12.5))","(46X,3(2X,E12.5))", &
315  & err,error,*999)
316  ELSE
317  CALL write_string(output_id,"RMS errors:",err,error,*999)
318  local_string= &
319  & " % error Absolute err Relative err"
320  CALL write_string(output_id,local_string,err,error,*999)
321  values(1)=sqrt(rms_error_per(deriv_idx)/number(deriv_idx))
322  values(2)=sqrt(rms_error_abs(deriv_idx)/number(deriv_idx))
323  values(3)=sqrt(rms_error_rel(deriv_idx)/number(deriv_idx))
324  CALL write_string_vector(output_id,1,1,3,3,3,values,"(46X,3(2X,E12.5))","(46X,3(2X,E12.5))", &
325  & err,error,*999)
326  ENDIF
327  ENDIF
328  ELSE
329  CALL flagerror("Decomposition topology elements is not associated.",err,error,*999)
330  ENDIF
331  ELSE
332  CALL flagerror("Decomposition topology is not associated.",err,error,*999)
333  ENDIF
334  ELSE
335  CALL flagerror("Domain decomposition is not associated.",err,error,*999)
336  ENDIF
337  ELSE
338  CALL flagerror("Elements domain topology is not associated.",err,error,*999)
339  ENDIF
340  CASE(field_node_based_interpolation)
341  nodes_domain=>domain_topology%NODES
342  IF(ASSOCIATED(nodes_domain)) THEN
343  number=0
344  rms_error_per=0.0_dp
345  rms_error_abs=0.0_dp
346  rms_error_rel=0.0_dp
347  ghost_number=0
348  ghost_rms_error_per=0.0_dp
349  ghost_rms_error_abs=0.0_dp
350  ghost_rms_error_rel=0.0_dp
351  CALL write_string(output_id,"Nodal errors:",err,error,*999)
352  local_string=" Node# Deriv# Numerical Analytic % error Absolute err Relative err"
353  CALL write_string(output_id,local_string,err,error,*999)
354  DO node_idx=1,nodes_domain%NUMBER_OF_NODES
355  DO deriv_idx=1,nodes_domain%NODES(node_idx)%NUMBER_OF_DERIVATIVES
356  local_ny=field_variable%COMPONENTS(component_idx)%PARAM_TO_DOF_MAP% &
357  & node_param2dof_map%NODES(node_idx)%DERIVATIVES(deriv_idx)%VERSIONS(1)
358  values(1)=numerical_values(local_ny)
359  values(2)=analytic_values(local_ny)
360  values(3)=analytic_analysis_percentage_error(values(1),values(2))
361  values(4)=analytic_analysis_absolute_error(values(1),values(2))
362  values(5)=analytic_analysis_relative_error(values(1),values(2))
363  !Accumlate the RMS errors
364  number(deriv_idx)=number(deriv_idx)+1
365  rms_error_per(deriv_idx)=rms_error_per(deriv_idx)+values(3)*values(3)
366  rms_error_abs(deriv_idx)=rms_error_abs(deriv_idx)+values(4)*values(4)
367  rms_error_rel(deriv_idx)=rms_error_rel(deriv_idx)+values(5)*values(5)
368  IF(deriv_idx==1) THEN
369  WRITE(first_format,"(A,I10,A,I6,A)") "('",nodes_domain%NODES(node_idx)%USER_NUMBER,"',2X,'", &
370  & deriv_idx,"',5(2X,E12.5))"
371  ELSE
372  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',5(2X,E12.5))"
373  ENDIF
374  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
375  ENDDO !deriv_idx
376  ENDDO !node_idx
377  DO node_idx=nodes_domain%NUMBER_OF_NODES+1,nodes_domain%TOTAL_NUMBER_OF_NODES
378  DO deriv_idx=1,nodes_domain%NODES(node_idx)%NUMBER_OF_DERIVATIVES
379  local_ny=field_variable%COMPONENTS(component_idx)%PARAM_TO_DOF_MAP% &
380  & node_param2dof_map%NODES(node_idx)%DERIVATIVES(deriv_idx)%VERSIONS(1)
381  values(1)=numerical_values(local_ny)
382  values(2)=analytic_values(local_ny)
383  values(3)=analytic_analysis_percentage_error(values(1),values(2))
384  values(4)=analytic_analysis_absolute_error(values(1),values(2))
385  values(5)=analytic_analysis_relative_error(values(1),values(2))
386  !Accumlate the RMS errors
387  ghost_number(deriv_idx)=ghost_number(deriv_idx)+1
388  ghost_rms_error_per(deriv_idx)=ghost_rms_error_per(deriv_idx)+values(3)*values(3)
389  ghost_rms_error_abs(deriv_idx)=ghost_rms_error_abs(deriv_idx)+values(4)*values(4)
390  ghost_rms_error_rel(deriv_idx)=ghost_rms_error_rel(deriv_idx)+values(5)*values(5)
391  IF(deriv_idx==1) THEN
392  WRITE(first_format,"(A,I10,A,I6,A)") "('",nodes_domain%NODES(node_idx)%USER_NUMBER, &
393  & "',2X,'",deriv_idx,"',5(2X,E12.5))"
394  ELSE
395  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',5(2X,E12.5))"
396  ENDIF
397  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
398  ENDDO !deriv_idx
399  ENDDO !node_idx
400  !Output RMS errors
401  CALL write_string(output_id,"",err,error,*999)
402  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
403  IF(any(number>0)) THEN
404  !Local nodes only
405  CALL write_string(output_id,"Local RMS errors:",err,error,*999)
406  local_string= &
407  & " Deriv# % error Absolute err Relative err"
408  CALL write_string(output_id,local_string,err,error,*999)
409  DO deriv_idx=1,8
410  IF(number(deriv_idx)>0) THEN
411  values(1)=sqrt(rms_error_per(deriv_idx)/number(deriv_idx))
412  values(2)=sqrt(rms_error_abs(deriv_idx)/number(deriv_idx))
413  values(3)=sqrt(rms_error_rel(deriv_idx)/number(deriv_idx))
414  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',28X,3(2X,E12.5))"
415  CALL write_string_vector(output_id,1,1,3,3,3,values,first_format,"(46X,3(2X,E12.5))", &
416  & err,error,*999)
417  ENDIF
418  ENDDO !deriv_idx
419  !Local and ghost nodes
420  CALL write_string(output_id,"Local + Ghost RMS errors:",err,error,*999)
421  local_string= &
422  & " Deriv# % error Absolute err Relative err"
423  CALL write_string(output_id,local_string,err,error,*999)
424  DO deriv_idx=1,8
425  IF(number(deriv_idx)>0) THEN
426  values(1)=sqrt((rms_error_per(deriv_idx)+ghost_rms_error_per(deriv_idx))/ &
427  & (number(deriv_idx)+ghost_number(deriv_idx)))
428  values(2)=sqrt((rms_error_abs(deriv_idx)+ghost_rms_error_abs(deriv_idx))/ &
429  & (number(deriv_idx)+ghost_number(deriv_idx)))
430  values(3)=sqrt((rms_error_rel(deriv_idx)+ghost_rms_error_rel(deriv_idx))/ &
431  & (number(deriv_idx)+ghost_number(deriv_idx)))
432  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',28X,3(2X,E12.5))"
433  CALL write_string_vector(output_id,1,1,3,3,3,values,first_format,"(46X,3(2X,E12.5))", &
434  & err,error,*999)
435  ENDIF
436  ENDDO !deriv_idx
437  !Global RMS values
438  !Collect the values across the ranks
439  CALL mpi_allreduce(mpi_in_place,number,8,mpi_integer,mpi_sum,computational_environment%MPI_COMM, &
440  & mpi_ierror)
441  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
442  CALL mpi_allreduce(mpi_in_place,rms_error_per,8,mpi_double_precision,mpi_sum, &
443  & computational_environment%MPI_COMM,mpi_ierror)
444  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
445  CALL mpi_allreduce(mpi_in_place,rms_error_abs,8,mpi_double_precision,mpi_sum, &
446  & computational_environment%MPI_COMM,mpi_ierror)
447  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
448  CALL mpi_allreduce(mpi_in_place,rms_error_rel,8,mpi_double_precision,mpi_sum, &
449  & computational_environment%MPI_COMM,mpi_ierror)
450  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
451  CALL write_string(output_id,"Global RMS errors:",err,error,*999)
452  local_string= &
453  & " Deriv# % error Absolute err Relative err"
454  CALL write_string(output_id,local_string,err,error,*999)
455  DO deriv_idx=1,8
456  IF(number(deriv_idx)>0) THEN
457  values(1)=sqrt(rms_error_per(deriv_idx)/number(deriv_idx))
458  values(2)=sqrt(rms_error_abs(deriv_idx)/number(deriv_idx))
459  values(3)=sqrt(rms_error_rel(deriv_idx)/number(deriv_idx))
460  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',28X,3(2X,E12.5))"
461  CALL write_string_vector(output_id,1,1,3,3,3,values,first_format,"(46X,3(2X,E12.5))", &
462  & err,error,*999)
463  ENDIF
464  ENDDO !deriv_idx
465  ENDIF
466  ELSE
467  IF(any(number>0)) THEN
468  CALL write_string(output_id,"RMS errors:",err,error,*999)
469  local_string= &
470  & " Deriv# % error Absolute err Relative err"
471  CALL write_string(output_id,local_string,err,error,*999)
472  DO deriv_idx=1,8
473  IF(number(deriv_idx)>0) THEN
474  values(1)=sqrt(rms_error_per(deriv_idx)/number(deriv_idx))
475  values(2)=sqrt(rms_error_abs(deriv_idx)/number(deriv_idx))
476  values(3)=sqrt(rms_error_rel(deriv_idx)/number(deriv_idx))
477  WRITE(first_format,"(A,I6,A)") "(12X,'",deriv_idx,"',28X,3(2X,E12.5))"
478  CALL write_string_vector(output_id,1,1,3,3,3,values,first_format,"(46X,3(2X,E12.5))", &
479  & err,error,*999)
480  ENDIF
481  ENDDO !deriv_idx
482  ENDIF
483  ENDIF
484  ELSE
485  CALL flagerror("Nodes domain topology is not associated.",err,error,*999)
486  ENDIF
487  CASE(field_grid_point_based_interpolation)
488  CALL flagerror("Not implemented.",err,error,*999)
489  CASE(field_gauss_point_based_interpolation)
490  CALL flagerror("Not implemented.",err,error,*999)
491  CASE DEFAULT
492  local_error="The interpolation type of "// &
493  & trim(number_to_vstring(field%VARIABLES(var_idx)%COMPONENTS(component_idx)% &
494  & interpolation_type,"*",err,error))//" for component number "// &
495  & trim(number_to_vstring(component_idx,"*",err,error))//" of variable type "// &
496  & trim(number_to_vstring(variable_type,"*",err,error))//" of field number "// &
497  & trim(number_to_vstring(field%USER_NUMBER,"*",err,error))//" is invalid."
498  CALL flagerror(local_error,err,error,*999)
499  END SELECT
500  ELSE
501  CALL flagerror("Domain topology is not associated.",err,error,*999)
502  ENDIF
503  ELSE
504  CALL flagerror("Domain is not associated.",err,error,*999)
505  ENDIF
506  CALL write_string(output_id,"",err,error,*999)
507  ENDDO !component_idx
508  !Restore the dependent and analytic parameter sets
509  CALL field_parameter_set_data_restore(field,variable_type,field_values_set_type,numerical_values, &
510  & err,error,*999)
511  CALL field_parameter_set_data_restore(field,variable_type,field_analytic_values_set_type,analytic_values, &
512  & err,error,*999)
513  !Allocated the integral errors
514  ALLOCATE(integral_errors(6,field_variable%NUMBER_OF_COMPONENTS),stat=err)
515  IF(err/=0) CALL flagerror("Could not allocate integral errors.",err,error,*999)
516  ALLOCATE(ghost_integral_errors(6,field_variable%NUMBER_OF_COMPONENTS),stat=err)
517  IF(err/=0) CALL flagerror("Could not allocate ghost integral errors.",err,error,*999)
518  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
519  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
520  CALL write_string(output_id,"Local Integral errors:",err,error,*999)
521  local_string="Component# Numerical Analytic % error Absolute err Relative err"
522  CALL write_string(output_id,local_string,err,error,*999)
523  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
524  values(1)=integral_errors(1,component_idx)
525  values(2)=integral_errors(3,component_idx)
526  values(3)=analytic_analysis_percentage_error(values(1),values(2))
527  values(4)=analytic_analysis_absolute_error(values(1),values(2))
528  values(5)=analytic_analysis_relative_error(values(1),values(2))
529  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Intg ',5(2X,E12.5))"
530  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
531  values(1)=integral_errors(2,component_idx)
532  values(2)=integral_errors(4,component_idx)
533  values(3)=analytic_analysis_percentage_error(values(1),values(2))
534  values(4)=analytic_analysis_absolute_error(values(1),values(2))
535  values(5)=analytic_analysis_relative_error(values(1),values(2))
536  WRITE(first_format,"(A)") "(12X,'Intg^2',5(2X,E12.5))"
537  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
538  ENDDO !component_idx
539  local_string="Component# Numerical Analytic NID NID(%)"
540  CALL write_string(output_id,local_string,err,error,*999)
541  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
542  values(1)=integral_errors(5,component_idx)
543  values(2)=integral_errors(3,component_idx)
544  values(3)=analytic_analysis_nid_error(values(1),values(2))
545  values(4)=values(3)*100.0_dp
546  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Diff ',4(2X,E12.5))"
547  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
548  values(1)=integral_errors(6,component_idx)
549  values(2)=integral_errors(4,component_idx)
550  values(3)=analytic_analysis_nid_error(values(1),values(2))
551  values(4)=values(3)*100.0_dp
552  WRITE(first_format,"(A)") "(12X,'Diff^2',4(2X,E12.5))"
553  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
554  ENDDO !component_idx
555  CALL write_string(output_id,"Local + Ghost Integral errors:",err,error,*999)
556  local_string="Component# Numerical Analytic % error Absolute err Relative err"
557  CALL write_string(output_id,local_string,err,error,*999)
558  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
559  values(1)=integral_errors(1,component_idx)+ghost_integral_errors(1,component_idx)
560  values(2)=integral_errors(3,component_idx)+ghost_integral_errors(3,component_idx)
561  values(3)=analytic_analysis_percentage_error(values(1),values(2))
562  values(4)=analytic_analysis_absolute_error(values(1),values(2))
563  values(5)=analytic_analysis_relative_error(values(1),values(2))
564  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Intg ',5(2X,E12.5))"
565  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
566  values(1)=integral_errors(2,component_idx)
567  values(2)=integral_errors(4,component_idx)
568  values(3)=analytic_analysis_percentage_error(values(1),values(2))
569  values(4)=analytic_analysis_absolute_error(values(1),values(2))
570  values(5)=analytic_analysis_relative_error(values(1),values(2))
571  WRITE(first_format,"(A)") "(12X,'Intg^2',5(2X,E12.5))"
572  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
573  ENDDO !component_idx
574  local_string="Component# Numerical Analytic NID NID(%)"
575  CALL write_string(output_id,local_string,err,error,*999)
576  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
577  values(1)=integral_errors(5,component_idx)+ghost_integral_errors(5,component_idx)
578  values(2)=integral_errors(3,component_idx)+ghost_integral_errors(3,component_idx)
579  values(3)=analytic_analysis_nid_error(values(1),values(2))
580  values(4)=values(3)*100.0_dp
581  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Diff ',4(2X,E12.5))"
582  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
583  values(1)=integral_errors(6,component_idx)+ghost_integral_errors(6,component_idx)
584  values(2)=integral_errors(4,component_idx)+ghost_integral_errors(4,component_idx)
585  values(3)=analytic_analysis_nid_error(values(1),values(2))
586  values(4)=values(3)*100.0_dp
587  WRITE(first_format,"(A)") "(12X,'Diff^2',4(2X,E12.5))"
588  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
589  ENDDO !component_idx
590  !Collect the values across the ranks
591  CALL mpi_allreduce(mpi_in_place,integral_errors,6*field_variable%NUMBER_OF_COMPONENTS,mpi_double_precision, &
592  & mpi_sum,computational_environment%MPI_COMM,mpi_ierror)
593  CALL write_string(output_id,"Global Integral errors:",err,error,*999)
594  local_string="Component# Numerical Analytic % error Absolute err Relative err"
595  CALL write_string(output_id,local_string,err,error,*999)
596  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
597  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
598  values(1)=integral_errors(1,component_idx)
599  values(2)=integral_errors(3,component_idx)
600  values(4)=analytic_analysis_absolute_error(values(1),values(2))
601  values(5)=analytic_analysis_relative_error(values(1),values(2))
602  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Intg ',5(2X,E12.5))"
603  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
604  values(1)=integral_errors(2,component_idx)
605  values(2)=integral_errors(4,component_idx)
606  values(3)=analytic_analysis_percentage_error(values(1),values(2))
607  values(4)=analytic_analysis_absolute_error(values(1),values(2))
608  values(5)=analytic_analysis_relative_error(values(1),values(2))
609  WRITE(first_format,"(A)") "(12X,'Intg^2',5(2X,E12.5))"
610  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
611  ENDDO !component_idx
612  local_string="Component# Numerical Analytic NID NID(%)"
613  CALL write_string(output_id,local_string,err,error,*999)
614  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
615  values(1)=integral_errors(5,component_idx)
616  values(2)=integral_errors(3,component_idx)
617  values(3)=analytic_analysis_nid_error(values(1),values(2))
618  values(4)=values(3)*100.0_dp
619  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Diff ',4(2X,E12.5))"
620  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
621  values(1)=integral_errors(6,component_idx)
622  values(2)=integral_errors(4,component_idx)
623  values(3)=analytic_analysis_nid_error(values(1),values(2))
624  values(4)=values(3)*100.0_dp
625  WRITE(first_format,"(A)") "(12X,'Diff^2',4(2X,E12.5))"
626  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
627  ENDDO !component_idx
628  ELSE
629  CALL write_string(output_id,"Integral errors:",err,error,*999)
630  local_string="Component# Numerical Analytic % error Absolute err Relative err"
631  CALL write_string(output_id,local_string,err,error,*999)
632  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
633  values(1)=integral_errors(1,component_idx)
634  values(2)=integral_errors(3,component_idx)
635  values(3)=analytic_analysis_percentage_error(values(1),values(2))
636  values(4)=analytic_analysis_absolute_error(values(1),values(2))
637  values(5)=analytic_analysis_relative_error(values(1),values(2))
638  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Intg ',5(2X,E12.5))"
639  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
640  values(1)=integral_errors(2,component_idx)
641  values(2)=integral_errors(4,component_idx)
642  values(3)=analytic_analysis_percentage_error(values(1),values(2))
643  values(4)=analytic_analysis_absolute_error(values(1),values(2))
644  values(5)=analytic_analysis_relative_error(values(1),values(2))
645  WRITE(first_format,"(A)") "(12X,'Intg^2',5(2X,E12.5))"
646  CALL write_string_vector(output_id,1,1,5,5,5,values,first_format,"(20X,5(2X,E12.5))",err,error,*999)
647  ENDDO !component_idx
648  local_string="Component# Numerical Analytic NID NID(%)"
649  CALL write_string(output_id,local_string,err,error,*999)
650  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
651  values(1)=integral_errors(5,component_idx)
652  values(2)=integral_errors(3,component_idx)
653  values(3)=analytic_analysis_nid_error(values(1),values(2))
654  values(4)=values(3)*100.0_dp
655  WRITE(first_format,"(A,I10,A)") "('",component_idx,"',2X,'Diff ',4(2X,E12.5))"
656  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
657  values(1)=integral_errors(6,component_idx)
658  values(2)=integral_errors(4,component_idx)
659  values(3)=analytic_analysis_nid_error(values(1),values(2))
660  values(4)=values(3)*100.0_dp
661  WRITE(first_format,"(A)") "(12X,'Diff^2',4(2X,E12.5))"
662  CALL write_string_vector(output_id,1,1,4,4,4,values,first_format,"(20X,4(2X,E12.5))",err,error,*999)
663  ENDDO !component_idx
664  CALL write_string(output_id,"",err,error,*999)
665  ENDIF
666  IF(ALLOCATED(integral_errors)) DEALLOCATE(integral_errors)
667  IF(ALLOCATED(ghost_integral_errors)) DEALLOCATE(ghost_integral_errors)
668  ELSE
669  CALL flagerror("Field variable is not associated.",err,error,*999)
670  ENDIF
671  ENDDO !var_idx
672  ELSE
673  CALL flagerror("Decomposition topology is not associated.",err,error,*999)
674  ENDIF
675  ELSE
676  CALL flagerror("Field decomposition is not associated.",err,error,*999)
677  ENDIF
678  IF(len_trim(filename)>=1) THEN
679  CLOSE(unit=output_id,iostat=err)
680  IF(err/=0) CALL flagerror("Error closing analysis output file.",err,error,*999)
681  ENDIF
682  ELSE
683  local_error="Field number "//trim(number_to_vstring(field%USER_NUMBER,"*",err,error))// &
684  & " is not a dependent field."
685  CALL flagerror(local_error,err,error,*999)
686  ENDIF
687  ELSE
688  local_error="Field number "//trim(number_to_vstring(field%USER_NUMBER,"*",err,error))// &
689  & " has not been finished."
690  CALL flagerror(local_error,err,error,*999)
691  ENDIF
692  ELSE
693  CALL flagerror("Field is not associated.",err,error,*999)
694  ENDIF
695 
696  exits("AnalyticAnalysis_Output")
697  RETURN
698 999 IF(ALLOCATED(integral_errors)) DEALLOCATE(integral_errors)
699  IF(ALLOCATED(ghost_integral_errors)) DEALLOCATE(ghost_integral_errors)
700  errorsexits("AnalyticAnalysis_Output",err,error)
701  RETURN 1
702  END SUBROUTINE analyticanalysis_output
703 
704  !
705  !================================================================================================================================
706  !
707 
709  PURE FUNCTION analytic_analysis_absolute_error(NUMERIC_VALUE,ANALYTIC_VALUE)
711  !Argument variables
712  REAL(DP), INTENT(IN) :: NUMERIC_VALUE
713  REAL(DP), INTENT(IN) :: ANALYTIC_VALUE
714  !Function result
715  REAL(DP) :: ANALYTIC_ANALYSIS_ABSOLUTE_ERROR
716 
717  analytic_analysis_absolute_error=abs(analytic_value-numeric_value)
718 
720 
721  !
722  !================================================================================================================================
723  !
724 
726  PURE FUNCTION analytic_analysis_percentage_error(NUMERIC_VALUE,ANALYTIC_VALUE)
728  !Argument variables
729  REAL(DP), INTENT(IN) :: NUMERIC_VALUE
730  REAL(DP), INTENT(IN) :: ANALYTIC_VALUE
731  !Function result
732  REAL(DP) :: ANALYTIC_ANALYSIS_PERCENTAGE_ERROR
733 
734  IF(abs(analytic_value)>zero_tolerance) THEN
735  analytic_analysis_percentage_error=(analytic_value-numeric_value)/analytic_value*100.0_dp
736  ELSE
737  analytic_analysis_percentage_error=0.0_dp
738  ENDIF
739 
741 
742  !
743  !================================================================================================================================
744  !
745 
747  PURE FUNCTION analytic_analysis_relative_error(NUMERIC_VALUE,ANALYTIC_VALUE)
749  !Argument variables
750  REAL(DP), INTENT(IN) :: NUMERIC_VALUE
751  REAL(DP), INTENT(IN) :: ANALYTIC_VALUE
752  !Function result
753  REAL(DP) :: ANALYTIC_ANALYSIS_RELATIVE_ERROR
754 
755  IF(abs(1.0_dp+analytic_value)>zero_tolerance) THEN
756  analytic_analysis_relative_error=(analytic_value-numeric_value)/(1.0_dp+analytic_value)
757  ELSE
758  analytic_analysis_relative_error=0.0_dp
759  ENDIF
760 
762 
763  !
764  !================================================================================================================================
765  !
766 
768  PURE FUNCTION analytic_analysis_nid_error(NUMERIC_VALUE,ANALYTIC_VALUE)
770  !Argument variables
771  REAL(DP), INTENT(IN) :: NUMERIC_VALUE
772  REAL(DP), INTENT(IN) :: ANALYTIC_VALUE
773  !Function result
774  REAL(DP) :: ANALYTIC_ANALYSIS_NID_ERROR
775 
776  IF(abs(analytic_value)>zero_tolerance) THEN
777  analytic_analysis_nid_error=(analytic_value-numeric_value)/analytic_value
778  ELSE
779  analytic_analysis_nid_error=(analytic_value-numeric_value)/(1.0_dp+analytic_value)
780  ENDIF
781 
782  END FUNCTION analytic_analysis_nid_error
783 
784  !
785  !================================================================================================================================
786  !
787 
789  SUBROUTINE analytic_analysis_integral_errors(FIELD_VARIABLE,INTEGRAL_ERRORS,GHOST_INTEGRAL_ERRORS,ERR,ERROR,*)
791  !Argument variables
792  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
793  REAL(DP), INTENT(OUT) :: INTEGRAL_ERRORS(:,:)
794  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERRORS(:,:)
795  INTEGER(INTG), INTENT(OUT) :: ERR
796  TYPE(varying_string), INTENT(OUT) :: ERROR
797  !Local Variables
798  INTEGER(INTG) :: element_idx,component_idx,gauss_idx,parameter_idx,variable_type
799  REAL(DP) :: ANALYTIC_INT,NUMERICAL_INT,RWG
800  TYPE(basis_type), POINTER :: BASIS,DEPENDENT_BASIS,GEOMETRIC_BASIS
801  TYPE(decomposition_type), POINTER :: DECOMPOSITION
802  TYPE(domain_elements_type), POINTER :: DOMAIN_ELEMENTS1,DOMAIN_ELEMENTS2,DOMAIN_ELEMENTS3
803  TYPE(field_type), POINTER :: DEPENDENT_FIELD,GEOMETRIC_FIELD
804  TYPE(field_interpolated_point_ptr_type), POINTER :: GEOMETRIC_INTERP_POINT(:)
805  TYPE(field_interpolated_point_metrics_ptr_type), POINTER :: GEOMETRIC_INTERP_POINT_METRICS(:)
806  TYPE(field_interpolation_parameters_ptr_type), POINTER :: ANALYTIC_INTERP_PARAMETERS(:),GEOMETRIC_INTERP_PARAMETERS(:), &
807  & NUMERICAL_INTERP_PARAMETERS(:)
808  TYPE(field_variable_type), POINTER :: GEOMETRIC_VARIABLE
809  TYPE(quadrature_scheme_type), POINTER :: QUADRATURE_SCHEME
810  TYPE(varying_string) :: LOCAL_ERROR
811 
812  NULLIFY(geometric_interp_point)
813  NULLIFY(geometric_interp_point_metrics)
814  NULLIFY(analytic_interp_parameters)
815  NULLIFY(geometric_interp_parameters)
816  NULLIFY(numerical_interp_parameters)
817 
818  enters("ANALYTIC_ANALYSIS_INTEGRAL_ERRORS",err,error,*999)
819 
820  integral_errors=0.0_dp
821  ghost_integral_errors=0.0_dp
822  IF(ASSOCIATED(field_variable)) THEN
823  IF(SIZE(integral_errors,1)>=6.AND.SIZE(integral_errors,2)>=field_variable%NUMBER_OF_COMPONENTS) THEN
824  IF(SIZE(ghost_integral_errors,1)>=6.AND.SIZE(ghost_integral_errors,2)>=field_variable%NUMBER_OF_COMPONENTS) THEN
825  variable_type=field_variable%VARIABLE_TYPE
826  dependent_field=>field_variable%FIELD
827  IF(ASSOCIATED(dependent_field)) THEN
828  decomposition=>dependent_field%DECOMPOSITION
829  IF(ASSOCIATED(decomposition)) THEN
830  geometric_field=>dependent_field%GEOMETRIC_FIELD
831  IF(ASSOCIATED(geometric_field)) THEN
832  geometric_variable=>geometric_field%VARIABLE_TYPE_MAP(field_u_variable_type)%PTR
833  IF(ASSOCIATED(geometric_variable)) THEN
834  CALL field_interpolation_parameters_initialise(geometric_field,geometric_interp_parameters,err,error,*999)
835  CALL field_interpolation_parameters_initialise(dependent_field,numerical_interp_parameters,err,error,*999)
836  CALL field_interpolation_parameters_initialise(dependent_field,analytic_interp_parameters,err,error,*999)
837  CALL field_interpolated_points_initialise(geometric_interp_parameters,geometric_interp_point,err,error,*999)
838  CALL field_interpolatedpointsmetricsinitialise(geometric_interp_point,geometric_interp_point_metrics, &
839  & err,error,*999)
840  domain_elements1=>field_variable%COMPONENTS(decomposition%MESH_COMPONENT_NUMBER)%DOMAIN%TOPOLOGY%ELEMENTS
841  domain_elements2=>geometric_variable%COMPONENTS(decomposition%MESH_COMPONENT_NUMBER)%DOMAIN%TOPOLOGY%ELEMENTS
842  DO element_idx=1,domain_elements1%NUMBER_OF_ELEMENTS
843  dependent_basis=>domain_elements1%ELEMENTS(element_idx)%BASIS
844  geometric_basis=>domain_elements2%ELEMENTS(element_idx)%BASIS
845  quadrature_scheme=>dependent_basis%QUADRATURE%QUADRATURE_SCHEME_MAP(basis_default_quadrature_scheme)%PTR
846  CALL field_interpolation_parameters_element_get(field_values_set_type,element_idx, &
847  & geometric_interp_parameters(field_u_variable_type)%PTR,err,error,*999)
848  CALL field_interpolation_parameters_element_get(field_values_set_type,element_idx, &
849  & numerical_interp_parameters(variable_type)%PTR,err,error,*999)
850  CALL field_interpolation_parameters_element_get(field_analytic_values_set_type,element_idx, &
851  & analytic_interp_parameters(variable_type)%PTR,err,error,*999)
852  DO gauss_idx=1,quadrature_scheme%NUMBER_OF_GAUSS
853  CALL field_interpolate_gauss(first_part_deriv,basis_default_quadrature_scheme,gauss_idx, &
854  & geometric_interp_point(field_u_variable_type)%PTR,err,error,*999)
855  CALL field_interpolated_point_metrics_calculate(geometric_basis%NUMBER_OF_XI, &
856  & geometric_interp_point_metrics(field_u_variable_type)%PTR,err,error,*999)
857  rwg=geometric_interp_point_metrics(field_u_variable_type)%PTR%JACOBIAN* &
858  & quadrature_scheme%GAUSS_WEIGHTS(gauss_idx)
859  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
860  domain_elements3=>field_variable%COMPONENTS(component_idx)%DOMAIN%TOPOLOGY%ELEMENTS
861  basis=>domain_elements3%ELEMENTS(element_idx)%BASIS
862  numerical_int=0.0_dp
863  analytic_int=0.0_dp
864  SELECT CASE(dependent_field%SCALINGS%SCALING_TYPE)
865  CASE(field_no_scaling)
866  DO parameter_idx=1,basis%NUMBER_OF_ELEMENT_PARAMETERS
867  numerical_int=numerical_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
868  & numerical_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)
869  analytic_int=analytic_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
870  & analytic_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)
871  ENDDO !parameter_idx
872  CASE(field_unit_scaling,field_arc_length_scaling,field_arithmetic_mean_scaling,field_harmonic_mean_scaling)
873  DO parameter_idx=1,basis%NUMBER_OF_ELEMENT_PARAMETERS
874  numerical_int=numerical_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
875  & numerical_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)* &
876  & numerical_interp_parameters(variable_type)%PTR%SCALE_FACTORS(parameter_idx,component_idx)
877  analytic_int=analytic_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
878  & analytic_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)* &
879  & analytic_interp_parameters(variable_type)%PTR%SCALE_FACTORS(parameter_idx,component_idx)
880  ENDDO !parameter_idx
881  CASE DEFAULT
882  local_error="The dependent field scaling type of "// &
883  & trim(number_to_vstring(dependent_field%SCALINGS%SCALING_TYPE,"*",err,error))//" is invalid."
884  CALL flagerror(local_error,err,error,*999)
885  END SELECT
886  integral_errors(1,component_idx)=integral_errors(1,component_idx)+numerical_int*rwg
887  integral_errors(2,component_idx)=integral_errors(2,component_idx)+numerical_int**2*rwg
888  integral_errors(3,component_idx)=integral_errors(3,component_idx)+analytic_int*rwg
889  integral_errors(4,component_idx)=integral_errors(4,component_idx)+analytic_int**2*rwg
890  integral_errors(5,component_idx)=integral_errors(5,component_idx)+(analytic_int-numerical_int)*rwg
891  integral_errors(6,component_idx)=integral_errors(6,component_idx)+(analytic_int-numerical_int)**2*rwg
892  ENDDO !component_idx
893  ENDDO !gauss_idx
894  ENDDO !element_idx
895  DO element_idx=domain_elements1%NUMBER_OF_ELEMENTS+1,domain_elements1%TOTAL_NUMBER_OF_ELEMENTS
896  dependent_basis=>domain_elements1%ELEMENTS(element_idx)%BASIS
897  geometric_basis=>domain_elements2%ELEMENTS(element_idx)%BASIS
898  quadrature_scheme=>dependent_basis%QUADRATURE%QUADRATURE_SCHEME_MAP(basis_default_quadrature_scheme)%PTR
899  CALL field_interpolation_parameters_element_get(field_values_set_type,element_idx, &
900  & geometric_interp_parameters(field_u_variable_type)%PTR,err,error,*999)
901  CALL field_interpolation_parameters_element_get(field_values_set_type,element_idx, &
902  & numerical_interp_parameters(variable_type)%PTR,err,error,*999)
903  CALL field_interpolation_parameters_element_get(field_analytic_values_set_type,element_idx, &
904  & analytic_interp_parameters(variable_type)%PTR,err,error,*999)
905  DO gauss_idx=1,quadrature_scheme%NUMBER_OF_GAUSS
906  CALL field_interpolate_gauss(first_part_deriv,basis_default_quadrature_scheme,gauss_idx, &
907  & geometric_interp_point(field_u_variable_type)%PTR,err,error,*999)
908  CALL field_interpolated_point_metrics_calculate(geometric_basis%NUMBER_OF_XI, &
909  & geometric_interp_point_metrics(field_u_variable_type)%PTR,err,error,*999)
910  rwg=geometric_interp_point_metrics(field_u_variable_type)%PTR%JACOBIAN* &
911  & quadrature_scheme%GAUSS_WEIGHTS(gauss_idx)
912  DO component_idx=1,field_variable%NUMBER_OF_COMPONENTS
913  domain_elements3=>field_variable%COMPONENTS(component_idx)%DOMAIN%TOPOLOGY%ELEMENTS
914  basis=>domain_elements3%ELEMENTS(element_idx)%BASIS
915  numerical_int=0.0_dp
916  analytic_int=0.0_dp
917  SELECT CASE(dependent_field%SCALINGS%SCALING_TYPE)
918  CASE(field_no_scaling)
919  DO parameter_idx=1,basis%NUMBER_OF_ELEMENT_PARAMETERS
920  numerical_int=numerical_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
921  & numerical_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)
922  analytic_int=analytic_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
923  & analytic_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)
924  ENDDO !parameter_idx
925  CASE(field_unit_scaling,field_arc_length_scaling,field_arithmetic_mean_scaling,field_harmonic_mean_scaling)
926  DO parameter_idx=1,basis%NUMBER_OF_ELEMENT_PARAMETERS
927  numerical_int=numerical_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
928  & numerical_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)* &
929  & numerical_interp_parameters(variable_type)%PTR%SCALE_FACTORS(parameter_idx,component_idx)
930  analytic_int=analytic_int+quadrature_scheme%GAUSS_BASIS_FNS(parameter_idx,no_part_deriv,gauss_idx)* &
931  & analytic_interp_parameters(variable_type)%PTR%PARAMETERS(parameter_idx,component_idx)* &
932  & analytic_interp_parameters(variable_type)%PTR%SCALE_FACTORS(parameter_idx,component_idx)
933  ENDDO !parameter_idx
934  CASE DEFAULT
935  local_error="The dependent field scaling type of "// &
936  & trim(number_to_vstring(dependent_field%SCALINGS%SCALING_TYPE,"*",err,error))//" is invalid."
937  CALL flagerror(local_error,err,error,*999)
938  END SELECT
939  ghost_integral_errors(1,component_idx)=ghost_integral_errors(1,component_idx)+numerical_int*rwg
940  ghost_integral_errors(2,component_idx)=ghost_integral_errors(2,component_idx)+numerical_int**2*rwg
941  ghost_integral_errors(3,component_idx)=ghost_integral_errors(3,component_idx)+analytic_int*rwg
942  ghost_integral_errors(4,component_idx)=ghost_integral_errors(4,component_idx)+analytic_int**2*rwg
943  ghost_integral_errors(5,component_idx)=ghost_integral_errors(5,component_idx)+ &
944  & (analytic_int-numerical_int)*rwg
945  ghost_integral_errors(6,component_idx)=ghost_integral_errors(6,component_idx)+ &
946  & (analytic_int-numerical_int)**2*rwg
947  ENDDO !component_idx
948  ENDDO !gauss_idx
949  ENDDO !element_idx
950  CALL field_interpolatedpointsmetricsfinalise(geometric_interp_point_metrics,err,error,*999)
951  CALL field_interpolated_points_finalise(geometric_interp_point,err,error,*999)
952  CALL field_interpolation_parameters_finalise(analytic_interp_parameters,err,error,*999)
953  CALL field_interpolation_parameters_finalise(numerical_interp_parameters,err,error,*999)
954  CALL field_interpolation_parameters_finalise(geometric_interp_parameters,err,error,*999)
955  ELSE
956  CALL flagerror("Geometric field variable is not associated.",err,error,*999)
957  ENDIF
958  ELSE
959  CALL flagerror("Field geometric field is not associated.",err,error,*999)
960  ENDIF
961  ELSE
962  CALL flagerror("Field decomposition is not associated.",err,error,*999)
963  ENDIF
964  ELSE
965  CALL flagerror("Field variable field is not associated.",err,error,*999)
966  ENDIF
967  ELSE
968  local_error="Invalid size for GHOST_INTEGRAL_ERRORS. The size is ("// &
969  & trim(number_to_vstring(SIZE(ghost_integral_errors,1),"*",err,error))//","// &
970  & trim(number_to_vstring(SIZE(ghost_integral_errors,2),"*",err,error))//") and it needs to be at least (6,"// &
971  & trim(number_to_vstring(field_variable%NUMBER_OF_COMPONENTS,"*",err,error))//")."
972  CALL flagerror(local_error,err,error,*999)
973  ENDIF
974  ELSE
975  local_error="Invalid size for INTEGRAL_ERRORS. The size is ("// &
976  & trim(number_to_vstring(SIZE(integral_errors,1),"*",err,error))//","// &
977  & trim(number_to_vstring(SIZE(integral_errors,2),"*",err,error))//") and it needs to be at least (6,"// &
978  & trim(number_to_vstring(field_variable%NUMBER_OF_COMPONENTS,"*",err,error))//")."
979  CALL flagerror(local_error,err,error,*999)
980  ENDIF
981  ELSE
982  CALL flagerror("Field variable is not associated.",err,error,*999)
983  ENDIF
984 
985  exits("ANALYTIC_ANALYSIS_INTEGRAL_ERRORS")
986  RETURN
987 999 errorsexits("ANALYTIC_ANALYSIS_INTEGRAL_ERRORS",err,error)
988  RETURN 1
989  END SUBROUTINE analytic_analysis_integral_errors
990 
991  !
992  !================================================================================================================================
993  !
994 
996  SUBROUTINE analyticanalysis_integralabsoluteerrorget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
997  & ghost_integral_error,err,error,*)
999  !Argument variables
1000  TYPE(field_type), POINTER :: FIELD
1001  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1002  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1003  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1004  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1005  INTEGER(INTG), INTENT(OUT) :: ERR
1006  TYPE(varying_string), INTENT(OUT) :: ERROR
1007  !Local Variables
1008  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1009  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1010  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1011 
1012  enters("AnalyticAnalysis_IntegralAbsoluteErrorGet",err,error,*999)
1013 
1014  IF(ASSOCIATED(field)) THEN
1015  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1016  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1017  integral_error(1)=analytic_analysis_absolute_error(integral_errors(1,component_number),integral_errors(3,component_number))
1018  integral_error(2)=analytic_analysis_absolute_error(integral_errors(2,component_number),integral_errors(4,component_number))
1019  ghost_integral_error(1)=analytic_analysis_absolute_error(ghost_integral_errors(1,component_number), &
1020  & ghost_integral_errors(3,component_number))
1021  ghost_integral_error(2)=analytic_analysis_absolute_error(ghost_integral_errors(2,component_number), &
1022  & ghost_integral_errors(4,component_number))
1023  ELSE
1024  CALL flagerror("Field is not associated",err,error,*999)
1025  ENDIF
1026 
1027  exits("AnalyticAnalysis_IntegralAbsoluteErrorGet")
1028  RETURN
1029 999 errorsexits("AnalyticAnalysis_IntegralAbsoluteErrorGet",err,error)
1030  RETURN 1
1031 
1033 
1034  !
1035  !================================================================================================================================
1036  !
1037 
1039  SUBROUTINE analyticanalysis_integralanalyticvalueget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1040  & ghost_integral_error,err,error,*)
1042  !Argument variables
1043  TYPE(field_type), POINTER :: FIELD
1044  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1045  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1046  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1047  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1048  INTEGER(INTG), INTENT(OUT) :: ERR
1049  TYPE(varying_string), INTENT(OUT) :: ERROR
1050  !Local Variables
1051  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1052  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1053  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1054 
1055  enters("AnalyticAnalysis_IntegralAnalyticValueGet",err,error,*999)
1056 
1057  IF(ASSOCIATED(field)) THEN
1058  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1059  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1060  integral_error(1)=integral_errors(3,component_number)
1061  integral_error(2)=integral_errors(4,component_number)
1062  ghost_integral_error(1)=ghost_integral_errors(3,component_number)
1063  ghost_integral_error(2)=ghost_integral_errors(4,component_number)
1064  ELSE
1065  CALL flagerror("Field is not associated",err,error,*999)
1066  ENDIF
1067 
1068  exits("AnalyticAnalysis_IntegralAnalyticValueGet")
1069  RETURN
1070 999 errorsexits("AnalyticAnalysis_IntegralAnalyticValueGet",err,error)
1071  RETURN 1
1072 
1074 
1075  !
1076  !================================================================================================================================
1077  !
1078 
1080  SUBROUTINE analyticanalysis_integralnumericalvalueget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1081  & ghost_integral_error,err,error,*)
1083  !Argument variables
1084  TYPE(field_type), POINTER :: FIELD
1085  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1086  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1087  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1088  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1089  INTEGER(INTG), INTENT(OUT) :: ERR
1090  TYPE(varying_string), INTENT(OUT) :: ERROR
1091  !Local Variables
1092  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1093  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1094  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1095 
1096  enters("AnalyticAnalysis_IntegralNumericalValueGet",err,error,*999)
1097 
1098  IF(ASSOCIATED(field)) THEN
1099  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1100  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1101  integral_error(1)=integral_errors(1,component_number)
1102  integral_error(2)=integral_errors(2,component_number)
1103  ghost_integral_error(1)=ghost_integral_errors(1,component_number)
1104  ghost_integral_error(2)=ghost_integral_errors(2,component_number)
1105  ELSE
1106  CALL flagerror("Field is not associated",err,error,*999)
1107  ENDIF
1108 
1109  exits("AnalyticAnalysis_IntegralNumericalValueGet")
1110  RETURN
1111 999 errorsexits("AnalyticAnalysis_IntegralNumericalValueGet",err,error)
1112  RETURN 1
1113 
1115 
1116  !
1117  !================================================================================================================================
1118  !
1119 
1121  SUBROUTINE analyticanalysis_integralnidnumericalvalueget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1122  & ghost_integral_error,err,error,*)
1124  !Argument variables
1125  TYPE(field_type), POINTER :: FIELD
1126  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1127  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1128  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1129  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1130  INTEGER(INTG), INTENT(OUT) :: ERR
1131  TYPE(varying_string), INTENT(OUT) :: ERROR
1132  !Local Variables
1133  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1134  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1135  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1136 
1137  enters("AnalyticAnalysis_IntegralNIDNumericalValueGet",err,error,*999)
1138 
1139  IF(ASSOCIATED(field)) THEN
1140  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1141  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1142  integral_error(1)=integral_errors(5,component_number)
1143  integral_error(2)=integral_errors(6,component_number)
1144  ghost_integral_error(1)=ghost_integral_errors(5,component_number)
1145  ghost_integral_error(2)=ghost_integral_errors(6,component_number)
1146  ELSE
1147  CALL flagerror("Field is not associated",err,error,*999)
1148  ENDIF
1149 
1150  exits("AnalyticAnalysis_IntegralNIDNumericalValueGet")
1151  RETURN
1152 999 errors("AnalyticAnalysis_IntegralNIDNumericalValueGet",err,error)
1153  exits("AnalyticAnalysis_IntegralNIDNumericalValueGet")
1154  RETURN 1
1155 
1157 
1158  !
1159  !================================================================================================================================
1160  !
1161 
1163  SUBROUTINE analyticanalysis_integralniderrorget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1164  & ghost_integral_error,err,error,*)
1166  !Argument variables
1167  TYPE(field_type), POINTER :: FIELD
1168  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1169  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1170  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1171  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1172  INTEGER(INTG), INTENT(OUT) :: ERR
1173  TYPE(varying_string), INTENT(OUT) :: ERROR
1174  !Local Variables
1175  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1176  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1177  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1178 
1179  enters("AnalyticAnalysis_IntegralNIDErrorGet",err,error,*999)
1180 
1181  IF(ASSOCIATED(field)) THEN
1182  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1183  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1184  integral_error(1)=analytic_analysis_nid_error(integral_errors(5,component_number),integral_errors(3,component_number))
1185  integral_error(2)=analytic_analysis_nid_error(integral_errors(6,component_number),integral_errors(4,component_number))
1186  ghost_integral_error(1)=analytic_analysis_nid_error(ghost_integral_errors(5,component_number), &
1187  & ghost_integral_errors(3,component_number))
1188  ghost_integral_error(2)=analytic_analysis_nid_error(ghost_integral_errors(6,component_number), &
1189  & ghost_integral_errors(4,component_number))
1190  ELSE
1191  CALL flagerror("Field is not associated",err,error,*999)
1192  ENDIF
1193 
1194  exits("AnalyticAnalysis_IntegralNIDErrorGet")
1195  RETURN
1196 999 errorsexits("AnalyticAnalysis_IntegralNIDErrorGet",err,error)
1197  RETURN 1
1199 
1200  !
1201  !================================================================================================================================
1202  !
1203 
1205  SUBROUTINE analyticanalysis_integralpercentageerrorget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1206  & ghost_integral_error,err,error,*)
1208  !Argument variables
1209  TYPE(field_type), POINTER :: FIELD
1210  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1211  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1212  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1213  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1214  INTEGER(INTG), INTENT(OUT) :: ERR
1215  TYPE(varying_string), INTENT(OUT) :: ERROR
1216  !Local Variables
1217  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1218  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1219  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1220 
1221  enters("AnalyticAnalysis_IntegralPercentageErrorGet",err,error,*999)
1222 
1223  IF(ASSOCIATED(field)) THEN
1224  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1225  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1226  integral_error(1)=analytic_analysis_percentage_error(integral_errors(1,component_number),integral_errors(3,component_number))
1227  integral_error(2)=analytic_analysis_percentage_error(integral_errors(2,component_number),integral_errors(4,component_number))
1228  ghost_integral_error(1)=analytic_analysis_percentage_error(ghost_integral_errors(1,component_number), &
1229  & ghost_integral_errors(3,component_number))
1230  ghost_integral_error(2)=analytic_analysis_percentage_error(ghost_integral_errors(2,component_number), &
1231  & ghost_integral_errors(4,component_number))
1232  ELSE
1233  CALL flagerror("Field is not associated",err,error,*999)
1234  ENDIF
1235 
1236  exits("AnalyticAnalysis_IntegralPercentageErrorGet")
1237  RETURN
1238 999 errorsexits("AnalyticAnalysis_IntegralPercentageErrorGet",err,error)
1239  RETURN 1
1240 
1242 
1243  !
1244  !================================================================================================================================
1245  !
1246 
1248  SUBROUTINE analyticanalysis_integralrelativeerrorget(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,INTEGRAL_ERROR, &
1249  & ghost_integral_error,err,error,*)
1251  !Argument variables
1252  TYPE(field_type), POINTER :: FIELD
1253  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1254  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1255  REAL(DP), INTENT(OUT) :: INTEGRAL_ERROR(2)
1256  REAL(DP), INTENT(OUT) :: GHOST_INTEGRAL_ERROR(2)
1257  INTEGER(INTG), INTENT(OUT) :: ERR
1258  TYPE(varying_string), INTENT(OUT) :: ERROR
1259  !Local Variables
1260  TYPE(field_variable_type), POINTER :: FIELD_VARIABLE
1261  REAL(DP), ALLOCATABLE :: INTEGRAL_ERRORS(:,:)
1262  REAL(DP), ALLOCATABLE :: GHOST_INTEGRAL_ERRORS(:,:)
1263 
1264  enters("AnalyticAnalysis_IntegralRelativeErrorGet",err,error,*999)
1265 
1266  IF(ASSOCIATED(field)) THEN
1267  field_variable=>field%VARIABLE_TYPE_MAP(variable_type)%PTR
1268  CALL analytic_analysis_integral_errors(field_variable,integral_errors,ghost_integral_errors,err,error,*999)
1269  integral_error(1)=analytic_analysis_relative_error(integral_errors(1,component_number),integral_errors(3,component_number))
1270  integral_error(2)=analytic_analysis_relative_error(integral_errors(2,component_number),integral_errors(4,component_number))
1271  ghost_integral_error(1)=analytic_analysis_relative_error(ghost_integral_errors(1,component_number), &
1272  & ghost_integral_errors(3,component_number))
1273  ghost_integral_error(2)=analytic_analysis_relative_error(ghost_integral_errors(2,component_number), &
1274  & ghost_integral_errors(4,component_number))
1275  ELSE
1276  CALL flagerror("Field is not associated",err,error,*999)
1277  ENDIF
1278 
1279  exits("AnalyticAnalysis_IntegralRelativeErrorGet")
1280  RETURN
1281 999 errorsexits("AnalyticAnalysis_IntegralRelativeErrorGet",err,error)
1282  RETURN 1
1283 
1285 
1286  !
1287  !================================================================================================================================
1288  !
1289 
1291  SUBROUTINE analyticanalysis_absoluteerrorgetnode(FIELD,VARIABLE_TYPE,VERSION_NUMBER,DERIVATIVE_NUMBER,USER_NODE_NUMBER, &
1292  & component_number,VALUE,err,error,*)
1294  !Argument variables
1295  TYPE(field_type), POINTER :: FIELD
1296  INTEGER(INTG), INTENT(IN) :: VERSION_NUMBER
1297  INTEGER(INTG), INTENT(IN) :: DERIVATIVE_NUMBER
1298  INTEGER(INTG), INTENT(IN) :: USER_NODE_NUMBER
1299  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1300  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1301  REAL(DP), INTENT(OUT) :: VALUE
1302  INTEGER(INTG), INTENT(OUT) :: ERR
1303  TYPE(varying_string), INTENT(OUT) :: ERROR
1304  !Local Variables
1305  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1306 
1307  enters("AnalyticAnalysis_AbsoluteErrorGetNode",err,error,*999)
1308 
1309  IF(ASSOCIATED(field)) THEN
1310  CALL field_parameter_set_get_node(field,variable_type,field_values_set_type,version_number,derivative_number, &
1311  & user_node_number,component_number,numerical_value,err,error,*999)
1312  CALL field_parameter_set_get_node(field,variable_type,field_analytic_values_set_type,version_number,derivative_number, &
1313  & user_node_number,component_number,analytic_value,err,error,*999)
1314  VALUE=analytic_analysis_absolute_error(numerical_value,analytic_value)
1315  ELSE
1316  CALL flagerror("Field is not associated",err,error,*999)
1317  ENDIF
1318 
1319  exits("AnalyticAnalysis_AbsoluteErrorGetNode")
1320  RETURN
1321 999 errorsexits("AnalyticAnalysis_AbsoluteErrorGetNode",err,error)
1322  RETURN 1
1324 
1325  !
1326  !================================================================================================================================
1327  !
1328 
1330  SUBROUTINE analyticanalysis_percentageerrorgetnode(FIELD,VARIABLE_TYPE,VERSION_NUMBER,DERIVATIVE_NUMBER,USER_NODE_NUMBER, &
1331  & component_number,VALUE,err,error,*)
1333  !Argument variables
1334  TYPE(field_type), POINTER :: FIELD
1335  INTEGER(INTG), INTENT(IN) :: VERSION_NUMBER
1336  INTEGER(INTG), INTENT(IN) :: DERIVATIVE_NUMBER
1337  INTEGER(INTG), INTENT(IN) :: USER_NODE_NUMBER
1338  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1339  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1340  REAL(DP), INTENT(OUT) :: VALUE
1341  INTEGER(INTG), INTENT(OUT) :: ERR
1342  TYPE(varying_string), INTENT(OUT) :: ERROR
1343  !Local Variables
1344  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1345 
1346  enters("AnalyticAnalysis_PercentageErrorGetNode",err,error,*999)
1347 
1348  IF(ASSOCIATED(field)) THEN
1349  CALL field_parameter_set_get_node(field,variable_type,field_values_set_type,version_number,derivative_number, &
1350  & user_node_number,component_number,numerical_value,err,error,*999)
1351  CALL field_parameter_set_get_node(field,variable_type,field_analytic_values_set_type,version_number,derivative_number, &
1352  & user_node_number,component_number,analytic_value,err,error,*999)
1353  VALUE=analytic_analysis_percentage_error(numerical_value, analytic_value)
1354  ELSE
1355  CALL flagerror("Field is not associated",err,error,*999)
1356  ENDIF
1357 
1358  exits("AnalyticAnalysis_PercentageErrorGetNode")
1359  RETURN
1360 999 errorsexits("AnalyticAnalysis_PercentageErrorGetNode",err,error)
1361  RETURN 1
1363 
1364 
1365 
1366  !
1367  !================================================================================================================================
1368  !
1369 
1371  SUBROUTINE analyticanalysis_relativeerrorgetnode(FIELD,VARIABLE_TYPE,VERSION_NUMBER,DERIVATIVE_NUMBER,USER_NODE_NUMBER, &
1372  & component_number,VALUE,err,error,*)
1374  !Argument variables
1375  TYPE(field_type), POINTER :: FIELD
1376  INTEGER(INTG), INTENT(IN) :: VERSION_NUMBER
1377  INTEGER(INTG), INTENT(IN) :: DERIVATIVE_NUMBER
1378  INTEGER(INTG), INTENT(IN) :: USER_NODE_NUMBER
1379  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1380  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1381  REAL(DP), INTENT(OUT) :: VALUE
1382  INTEGER(INTG), INTENT(OUT) :: ERR
1383  TYPE(varying_string), INTENT(OUT) :: ERROR
1384  !Local Variables
1385  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1386 
1387  enters("AnalyticAnalysis_RelativeErrorGetNode",err,error,*999)
1388 
1389  IF(ASSOCIATED(field)) THEN
1390  CALL field_parameter_set_get_node(field,variable_type,field_values_set_type,version_number,derivative_number, &
1391  & user_node_number,component_number,numerical_value,err,error,*999)
1392  CALL field_parameter_set_get_node(field,variable_type,field_analytic_values_set_type,version_number,derivative_number, &
1393  & user_node_number,component_number,analytic_value,err,error,*999)
1394  VALUE=analytic_analysis_relative_error(numerical_value, analytic_value)
1395  ELSE
1396  CALL flagerror("Field is not associated",err,error,*999)
1397  ENDIF
1398 
1399  exits("AnalyticAnalysis_RelativeErrorGetNode")
1400  RETURN
1401 999 errorsexits("AnalyticAnalysis_RelativeErrorGetNode",err,error)
1402  RETURN 1
1404 
1405  !
1406  !================================================================================================================================
1407  !
1408 
1410  SUBROUTINE analyticanalysis_absoluteerrorgetelement(FIELD,VARIABLE_TYPE,USER_ELEMENT_NUMBER,COMPONENT_NUMBER,VALUE,ERR, &
1411  & error,*)
1413  !Argument variables
1414  TYPE(field_type), POINTER :: FIELD
1415  INTEGER(INTG), INTENT(IN) :: USER_ELEMENT_NUMBER
1416  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1417  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1418  REAL(DP), INTENT(OUT) :: VALUE
1419  INTEGER(INTG), INTENT(OUT) :: ERR
1420  TYPE(varying_string), INTENT(OUT) :: ERROR
1421  !Local Variables
1422  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1423 
1424  enters("AnalyticAnalysis_AbsoluteErrorGetElement",err,error,*999)
1425 
1426  IF(ASSOCIATED(field)) THEN
1427  CALL field_parameter_set_get_element(field,variable_type,field_values_set_type,user_element_number,component_number, &
1428  & numerical_value,err,error,*999)
1429  CALL field_parameter_set_get_element(field,variable_type,field_analytic_values_set_type,user_element_number, &
1430  & component_number,analytic_value,err,error,*999)
1431  VALUE=analytic_analysis_absolute_error(numerical_value,analytic_value)
1432  ELSE
1433  CALL flagerror("Field is not associated",err,error,*999)
1434  ENDIF
1435 
1436  exits("AnalyticAnalysis_AbsoluteErrorGetElement")
1437  RETURN
1438 999 errorsexits("AnalyticAnalysis_AbsoluteErrorGetElement",err,error)
1439  RETURN 1
1440 
1442 
1443  !
1444  !================================================================================================================================
1445  !
1446 
1448  SUBROUTINE analyticanalysis_percentageerrorgetelement(FIELD,VARIABLE_TYPE, &
1449  & user_element_number,component_number,VALUE,err,error,*)
1451  !Argument variables
1452  TYPE(field_type), POINTER :: FIELD
1453  INTEGER(INTG), INTENT(IN) :: USER_ELEMENT_NUMBER
1454  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1455  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1456  REAL(DP), INTENT(OUT) :: VALUE
1457  INTEGER(INTG), INTENT(OUT) :: ERR
1458  TYPE(varying_string), INTENT(OUT) :: ERROR
1459  !Local Variables
1460  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1461 
1462  enters("AnalyticAnalysis_PercentageErrorGetElement",err,error,*999)
1463 
1464  IF(ASSOCIATED(field)) THEN
1465  CALL field_parameter_set_get_element(field,variable_type,field_values_set_type,user_element_number,component_number, &
1466  & numerical_value,err,error,*999)
1467  CALL field_parameter_set_get_element(field,variable_type,field_analytic_values_set_type,user_element_number, &
1468  & component_number,analytic_value,err,error,*999)
1469  VALUE=analytic_analysis_percentage_error(numerical_value, analytic_value)
1470  ELSE
1471  CALL flagerror("Field is not associated",err,error,*999)
1472  ENDIF
1473 
1474  exits("AnalyticAnalysis_PercentageErrorGetElement")
1475  RETURN
1476 999 errorsexits("AnalyticAnalysis_PercentageErrorGetElement",err,error)
1477  RETURN 1
1479 
1480 
1481  !
1482  !================================================================================================================================
1483  !
1484 
1486  SUBROUTINE analyticanalysis_relativeerrorgetelement(FIELD,VARIABLE_TYPE,USER_ELEMENT_NUMBER,COMPONENT_NUMBER,VALUE,ERR, &
1487  & error,*)
1489  !Argument variables
1490  TYPE(field_type), POINTER :: FIELD
1491  INTEGER(INTG), INTENT(IN) :: USER_ELEMENT_NUMBER
1492  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1493  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1494  REAL(DP), INTENT(OUT) :: VALUE
1495  INTEGER(INTG), INTENT(OUT) :: ERR
1496  TYPE(varying_string), INTENT(OUT) :: ERROR
1497  !Local Variables
1498  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1499 
1500  enters("AnalyticAnalysis_RelativeErrorGetElement",err,error,*999)
1501 
1502  IF(ASSOCIATED(field)) THEN
1503  CALL field_parameter_set_get_element(field,variable_type,field_values_set_type,user_element_number,component_number, &
1504  & numerical_value,err,error,*999)
1505  CALL field_parameter_set_get_element(field,variable_type,field_analytic_values_set_type,user_element_number, &
1506  & component_number,analytic_value,err,error,*999)
1507  VALUE=analytic_analysis_relative_error(numerical_value, analytic_value)
1508  ELSE
1509  CALL flagerror("Field is not associated",err,error,*999)
1510  ENDIF
1511 
1512  exits("AnalyticAnalysis_RelativeErrorGetElement")
1513  RETURN
1514 999 errorsexits("AnalyticAnalysis_RelativeErrorGetElement",err,error)
1515  RETURN 1
1516 
1518 
1519  !
1520  !================================================================================================================================
1521  !
1522 
1524  SUBROUTINE analyticanalysis_absoluteerrorgetconstant(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,VALUE,ERR, &
1525  & error,*)
1527  !Argument variables
1528  TYPE(field_type), POINTER :: FIELD
1529  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1530  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1531  REAL(DP), INTENT(OUT) :: VALUE
1532  INTEGER(INTG), INTENT(OUT) :: ERR
1533  TYPE(varying_string), INTENT(OUT) :: ERROR
1534  !Local Variables
1535  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1536 
1537  enters("AnalyticAnalysis_AbsoluteErrorGetConstant",err,error,*999)
1538 
1539  IF(ASSOCIATED(field)) THEN
1540  CALL field_parameter_set_get_constant(field,variable_type,field_values_set_type,component_number,numerical_value,err,error, &
1541  & *999)
1542  CALL field_parameter_set_get_constant(field,variable_type,field_analytic_values_set_type,component_number,analytic_value, &
1543  & err,error,*999)
1544  VALUE=analytic_analysis_absolute_error(numerical_value,analytic_value)
1545  ELSE
1546  CALL flagerror("Field is not associated",err,error,*999)
1547  ENDIF
1548 
1549  exits("AnalyticAnalysis_AbsoluteErrorGetConstant")
1550  RETURN
1551 999 errorsexits("AnalyticAnalysis_AbsoluteErrorGetConstant",err,error)
1552  RETURN 1
1553 
1555 
1556  !
1557  !================================================================================================================================
1558  !
1559 
1561  SUBROUTINE analyticanalysis_percentageerrorgetconstant(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,VALUE,ERR,ERROR,*)
1563  !Argument variables
1564  TYPE(field_type), POINTER :: FIELD
1565  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1566  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1567  REAL(DP), INTENT(OUT) :: VALUE
1568  INTEGER(INTG), INTENT(OUT) :: ERR
1569  TYPE(varying_string), INTENT(OUT) :: ERROR
1570  !Local Variables
1571  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1572 
1573  enters("AnalyticAnalysis_PercentageErrorGetConstant",err,error,*999)
1574 
1575  IF(ASSOCIATED(field)) THEN
1576  CALL field_parameter_set_get_constant(field,variable_type,field_values_set_type,component_number,numerical_value,err,error, &
1577  & *999)
1578  CALL field_parameter_set_get_constant(field,variable_type,field_analytic_values_set_type,component_number,analytic_value, &
1579  & err,error,*999)
1580  VALUE=analytic_analysis_percentage_error(numerical_value, analytic_value)
1581  ELSE
1582  CALL flagerror("Field is not associated",err,error,*999)
1583  ENDIF
1584 
1585  exits("AnalyticAnalysis_PercentageErrorGetConstant")
1586  RETURN
1587 999 errorsexits("AnalyticAnalysis_PercentageErrorGetConstant",err,error)
1588  RETURN 1
1589 
1591 
1592 
1593  !
1594  !================================================================================================================================
1595  !
1596 
1598  SUBROUTINE analyticanalysis_relativeerrorgetconstant(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,VALUE,ERR, &
1599  & error,*)
1601  !Argument variables
1602  TYPE(field_type), POINTER :: FIELD
1603  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1604  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1605  REAL(DP), INTENT(OUT) :: VALUE
1606  INTEGER(INTG), INTENT(OUT) :: ERR
1607  TYPE(varying_string), INTENT(OUT) :: ERROR
1608  !Local Variables
1609  REAL(DP) :: NUMERICAL_VALUE, ANALYTIC_VALUE
1610 
1611  enters("AnalyticAnalysis_RelativeErrorGetConstant",err,error,*999)
1612 
1613  IF(ASSOCIATED(field)) THEN
1614  CALL field_parameter_set_get_constant(field,variable_type,field_values_set_type,component_number,numerical_value,err,error, &
1615  & *999)
1616  CALL field_parameter_set_get_constant(field,variable_type,field_analytic_values_set_type,component_number,analytic_value, &
1617  & err,error,*999)
1618  VALUE=analytic_analysis_relative_error(numerical_value, analytic_value)
1619  ELSE
1620  CALL flagerror("Field is not associated",err,error,*999)
1621  ENDIF
1622 
1623  exits("AnalyticAnalysis_RelativeErrorGetConstant")
1624  RETURN
1625 999 errorsexits("AnalyticAnalysis_RelativeErrorGetConstant",err,error)
1626  RETURN 1
1627 
1629 
1630  !
1631  !================================================================================================================================
1632  !
1633 
1635  SUBROUTINE analyticanalysis_rmserrorgetnode(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,ERROR_TYPE,LOCAL_RMS,LOCAL_GHOST_RMS, &
1636  & global_rms,err,error,*)
1638  !Argument variables
1639  TYPE(field_type), POINTER :: FIELD
1640  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1641  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1642  INTEGER(INTG), INTENT(IN) :: ERROR_TYPE
1643  REAL(DP), INTENT(OUT) :: LOCAL_RMS(8)
1644  REAL(DP), INTENT(OUT) :: LOCAL_GHOST_RMS(8)
1645  REAL(DP), INTENT(OUT) :: GLOBAL_RMS(8)
1646  INTEGER(INTG), INTENT(OUT) :: ERR
1647  TYPE(varying_string), INTENT(OUT) :: ERROR
1648  !Local Variables
1649  REAL(DP) :: ERROR_VALUE
1650  INTEGER(INTG) :: GHOST_NUMBER(8),NUMBER(8),MPI_IERROR
1651  REAL(DP) :: RMS_ERROR(8),GHOST_RMS_ERROR(8)
1652  TYPE(domain_nodes_type), POINTER :: NODES_DOMAIN
1653  INTEGER(INTG) :: node_idx,deriv_idx
1654 
1655  enters("ANALYTIC_ANALYSIS_RMS_PERCENTAGE_ERROR_GET_NODE",err,error,*999)
1656 
1657  IF(ASSOCIATED(field)) THEN
1658  nodes_domain=>field%VARIABLE_TYPE_MAP(variable_type)%PTR%COMPONENTS(component_number)%DOMAIN%TOPOLOGY%NODES
1659  IF(ASSOCIATED(nodes_domain)) THEN
1660  number=0
1661  rms_error=0.0_dp
1662  ghost_number=0
1663  ghost_rms_error=0.0_dp
1664  DO node_idx=1,nodes_domain%NUMBER_OF_NODES
1665  DO deriv_idx=1,nodes_domain%NODES(node_idx)%NUMBER_OF_DERIVATIVES
1666  SELECT CASE(error_type)
1667  CASE(absolute_error_type)
1668  !Default to version 1 of each node derivative
1669  CALL analyticanalysis_absoluteerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1670  & error_value,err,error,*999)
1671  CASE(percentage_error_type)
1672  !Default to version 1 of each node derivative
1673  CALL analyticanalysis_percentageerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1674  & error_value,err,error,*999)
1675  CASE(relative_error_type)
1676  !Default to version 1 of each node derivative
1677  CALL analyticanalysis_relativeerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1678  & error_value,err,error,*999)
1679  CASE DEFAULT
1680  CALL flagerror("The error type is not valid!",err,error,*999)
1681  END SELECT
1682  !Accumlate the RMS errors
1683  number(deriv_idx)=number(deriv_idx)+1
1684  rms_error(deriv_idx)=rms_error(deriv_idx)+error_value*error_value
1685  ENDDO !deriv_idx
1686  ENDDO !node_idx
1687  DO node_idx=nodes_domain%NUMBER_OF_NODES+1,nodes_domain%TOTAL_NUMBER_OF_NODES
1688  DO deriv_idx=1,nodes_domain%NODES(node_idx)%NUMBER_OF_DERIVATIVES
1689  SELECT CASE(error_type)
1690  CASE(absolute_error_type)
1691  !Default to version 1 of each node derivative
1692  CALL analyticanalysis_absoluteerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1693  & error_value,err,error,*999)
1694  CASE(percentage_error_type)
1695  !Default to version 1 of each node derivative
1696  CALL analyticanalysis_percentageerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1697  & error_value,err,error,*999)
1698  CASE(relative_error_type)
1699  !Default to version 1 of each node derivative
1700  CALL analyticanalysis_relativeerrorgetnode(field,variable_type,1,deriv_idx,node_idx,component_number, &
1701  & error_value,err,error,*999)
1702  CASE DEFAULT
1703  CALL flagerror("The error type is not valid!",err,error,*999)
1704  END SELECT
1705  !Accumlate the RMS errors
1706  ghost_number(deriv_idx)=ghost_number(deriv_idx)+1
1707  ghost_rms_error(deriv_idx)=ghost_rms_error(deriv_idx)+error_value*error_value
1708  ENDDO !deriv_idx
1709  ENDDO !node_idx
1710 
1711  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
1712  IF(any(number>0)) THEN
1713  DO deriv_idx=1,8
1714  IF(number(deriv_idx)>0) THEN
1715  local_rms(deriv_idx)=sqrt(rms_error(deriv_idx)/number(deriv_idx))
1716  ENDIF
1717  ENDDO !deriv_idx
1718  DO deriv_idx=1,8
1719  IF(number(deriv_idx)>0) THEN
1720  local_ghost_rms(deriv_idx)=sqrt((rms_error(deriv_idx)+ghost_rms_error(deriv_idx))/(number(deriv_idx) &
1721  & +ghost_number(deriv_idx)))
1722  ENDIF
1723  ENDDO !deriv_idx
1724  !Global RMS values
1725  !Collect the values across the ranks
1726  CALL mpi_allreduce(mpi_in_place,number,8,mpi_integer,mpi_sum,computational_environment%MPI_COMM,mpi_ierror)
1727  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
1728  CALL mpi_allreduce(mpi_in_place,rms_error,8,mpi_double_precision,mpi_sum,computational_environment%MPI_COMM, &
1729  & mpi_ierror)
1730  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
1731  DO deriv_idx=1,8
1732  IF(number(deriv_idx)>0) THEN
1733  global_rms(deriv_idx)=sqrt(rms_error(deriv_idx)/number(deriv_idx))
1734  ENDIF
1735  ENDDO !deriv_idx
1736  ENDIF
1737  ELSE
1738  IF(any(number>0)) THEN
1739  DO deriv_idx=1,8
1740  IF(number(deriv_idx)>0) THEN
1741  local_rms(deriv_idx)=sqrt(rms_error(deriv_idx)/number(deriv_idx))
1742  global_rms(deriv_idx)=local_rms(deriv_idx)
1743  ENDIF
1744  ENDDO !deriv_idx
1745  ENDIF
1746  ENDIF
1747  ELSE
1748  CALL flagerror("Nodes domain topology is not associated.",err,error,*999)
1749  ENDIF
1750  ELSE
1751  CALL flagerror("Field is not associated",err,error,*999)
1752  ENDIF
1753 
1754  exits("AnalyticAnalysis_RMSErrorGetNode")
1755  RETURN
1756 999 errorsexits("AnalyticAnalysis_RMSErrorGetNode",err,error)
1757  RETURN 1
1758  END SUBROUTINE analyticanalysis_rmserrorgetnode
1759 
1760  !
1761  !================================================================================================================================
1762  !
1763 
1765  SUBROUTINE analyticanalysis_rmserrorgetelement(FIELD,VARIABLE_TYPE,COMPONENT_NUMBER,ERROR_TYPE,LOCAL_RMS,LOCAL_GHOST_RMS, &
1766  & global_rms,err,error,*)
1768  !Argument variables
1769  TYPE(field_type), POINTER :: FIELD
1770  INTEGER(INTG), INTENT(IN) :: VARIABLE_TYPE
1771  INTEGER(INTG), INTENT(IN) :: COMPONENT_NUMBER
1772  INTEGER(INTG), INTENT(IN) :: ERROR_TYPE
1773  REAL(DP), INTENT(OUT) :: LOCAL_RMS
1774  REAL(DP), INTENT(OUT) :: LOCAL_GHOST_RMS
1775  REAL(DP), INTENT(OUT) :: GLOBAL_RMS
1776  INTEGER(INTG), INTENT(OUT) :: ERR
1777  TYPE(varying_string), INTENT(OUT) :: ERROR
1778  !Local Variables
1779  REAL(DP) :: ERROR_VALUE
1780  INTEGER(INTG) :: GHOST_NUMBER,NUMBER,MPI_IERROR
1781  REAL(DP) :: RMS_ERROR,GHOST_RMS_ERROR
1782  TYPE(decomposition_type), POINTER :: DECOMPOSITION
1783  TYPE(decomposition_elements_type), POINTER :: ELEMENTS_DECOMPOSITION
1784  TYPE(decomposition_topology_type), POINTER :: DECOMPOSITION_TOPOLOGY
1785  TYPE(domain_type), POINTER :: DOMAIN
1786  TYPE(domain_elements_type), POINTER :: ELEMENTS_DOMAIN
1787  INTEGER(INTG) :: element_idx
1788 
1789  enters("AnalyticAnalysis_RMSErrorGetElement",err,error,*999)
1790 
1791  IF(ASSOCIATED(field)) THEN
1792  domain=>field%VARIABLE_TYPE_MAP(variable_type)%PTR%COMPONENTS(component_number)%DOMAIN
1793  elements_domain=>domain%TOPOLOGY%ELEMENTS
1794  IF(ASSOCIATED(elements_domain)) THEN
1795  decomposition=>domain%DECOMPOSITION
1796  IF(ASSOCIATED(decomposition)) THEN
1797  decomposition_topology=>decomposition%TOPOLOGY
1798  IF(ASSOCIATED(decomposition_topology)) THEN
1799  elements_decomposition=>decomposition_topology%ELEMENTS
1800  IF(ASSOCIATED(elements_decomposition)) THEN
1801  number=0
1802  rms_error=0.0_dp
1803  ghost_number=0
1804  ghost_rms_error=0.0_dp
1805  DO element_idx=1,elements_domain%NUMBER_OF_ELEMENTS
1806  SELECT CASE(error_type)
1807  CASE(absolute_error_type)
1808  CALL analyticanalysis_absoluteerrorgetelement(field,variable_type,element_idx,component_number,error_value, &
1809  & err,error,*999)
1810  CASE(percentage_error_type)
1811  CALL analyticanalysis_percentageerrorgetelement(field,variable_type,element_idx,component_number, &
1812  & error_value,err,error,*999)
1813  CASE(relative_error_type)
1814  CALL analyticanalysis_relativeerrorgetelement(field,variable_type,element_idx,component_number,error_value, &
1815  & err,error,*999)
1816  CASE DEFAULT
1817  CALL flagerror("The error type is not valid!",err,error,*999)
1818  END SELECT
1819  number=number+1
1820  rms_error=rms_error+error_value*error_value
1821  ENDDO !element_idx
1822  DO element_idx=elements_domain%NUMBER_OF_ELEMENTS+1,elements_domain%TOTAL_NUMBER_OF_ELEMENTS
1823  SELECT CASE(error_type)
1824  CASE(absolute_error_type)
1825  CALL analyticanalysis_absoluteerrorgetelement(field,variable_type,element_idx,component_number,error_value, &
1826  & err,error,*999)
1827  CASE(percentage_error_type)
1828  CALL analyticanalysis_percentageerrorgetelement(field,variable_type,element_idx,component_number, &
1829  & error_value,err,error,*999)
1830  CASE(relative_error_type)
1831  CALL analyticanalysis_relativeerrorgetelement(field,variable_type,element_idx,component_number,error_value, &
1832  & err,error,*999)
1833  CASE DEFAULT
1834  CALL flagerror("The error type is not valid!",err,error,*999)
1835  END SELECT
1836  ghost_number=ghost_number+1
1837  ghost_rms_error=ghost_rms_error+error_value*error_value
1838  ENDDO !element_idx
1839  IF(number>0) THEN
1840  IF(computational_environment%NUMBER_COMPUTATIONAL_NODES>1) THEN
1841  !Local elements only
1842  local_rms=sqrt(rms_error/number)
1843  !Local and ghost elements
1844  local_ghost_rms=sqrt((rms_error+ghost_rms_error)/(number+ghost_number))
1845  !Global RMS values
1846  !Collect the values across the ranks
1847  CALL mpi_allreduce(mpi_in_place,number,1,mpi_integer,mpi_sum,computational_environment%MPI_COMM,mpi_ierror)
1848  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
1849  CALL mpi_allreduce(mpi_in_place,rms_error,1,mpi_double_precision,mpi_sum,computational_environment%MPI_COMM, &
1850  & mpi_ierror)
1851  CALL mpi_error_check("MPI_ALLREDUCE",mpi_ierror,err,error,*999)
1852  global_rms=sqrt(rms_error/number)
1853  ENDIF
1854  ENDIF
1855  ELSE
1856  CALL flagerror("Decomposition topology elements is not associated.",err,error,*999)
1857  ENDIF
1858  ELSE
1859  CALL flagerror("Decomposition topology is not associated.",err,error,*999)
1860  ENDIF
1861  ELSE
1862  CALL flagerror("Domain decomposition is not associated.",err,error,*999)
1863  ENDIF
1864  ELSE
1865  CALL flagerror("Elements domain topology is not associated.",err,error,*999)
1866  ENDIF
1867  ELSE
1868  CALL flagerror("Field is not associated",err,error,*999)
1869  ENDIF
1870 
1871  exits("AnalyticAnalysis_RMSErrorGetElement")
1872  RETURN
1873 999 errorsexits("AnalyticAnalysis_RMSErrorGetElement",err,error)
1874  RETURN 1
1876 
1877  !
1878  !================================================================================================================================
1879  !
1880 
1881 
1882 END MODULE analytic_analysis_routines
This module contains all basis function routines.
subroutine, public analyticanalysis_rmserrorgetelement(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, ERROR_TYPE, LOCAL_RMS, LOCAL_GHOST_RMS, GLOBAL_RMS, ERR, ERROR,)
Get rms error value for the field.
Converts a number to its equivalent varying string representation.
Definition: strings.f90:161
Contains information on the mesh decomposition.
Definition: types.f90:1063
subroutine, public analyticanalysis_relativeerrorgetconstant(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get relative error value for a constant.
integer(intg), parameter no_part_deriv
No partial derivative i.e., u.
Definition: constants.f90:177
subroutine, public analyticanalysis_absoluteerrorgetnode(FIELD, VARIABLE_TYPE, VERSION_NUMBER, DERIVATIVE_NUMBER, USER_NODE_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get absolute error value for the node.
Contains the topology information for a domain.
Definition: types.f90:724
subroutine, public analyticanalysis_absoluteerrorgetelement(FIELD, VARIABLE_TYPE, USER_ELEMENT_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get absolute error value for an element.
This module contains all string manipulation and transformation routines.
Definition: strings.f90:45
integer(intg), parameter first_part_deriv
First partial derivative i.e., du/ds.
Definition: constants.f90:178
This module contains routines for timing the program.
Definition: timer_f.f90:45
This module handles all analytic analysis routines.
integer(intg), parameter percentage_error_type
The percentage type.
Contains information for a field defined on a region.
Definition: types.f90:1346
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
integer(intg), parameter relative_error_type
The relative type.
integer(intg), parameter, public basis_default_quadrature_scheme
Identifier for the default quadrature scheme.
This module contains all program wide constants.
Definition: constants.f90:45
subroutine analytic_analysis_integral_errors(FIELD_VARIABLE, INTEGRAL_ERRORS, GHOST_INTEGRAL_ERRORS, ERR, ERROR,)
Calculates the relative error between a numeric value and an analytic value.
Contains the topology information for the elements of a domain.
Definition: types.f90:677
Contains the topology information for a decomposition.
Definition: types.f90:1054
This module contains all type definitions in order to avoid cyclic module references.
Definition: types.f90:70
Write a string to a given output stream.
subroutine, public analyticanalysis_integralpercentageerrorget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral percentage error value for the field.
subroutine, public analyticanalysis_integralnidnumericalvalueget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral nid numerical value for the field, TODO check integral calculation.
This module contains all computational environment variables.
subroutine, public analyticanalysis_relativeerrorgetnode(FIELD, VARIABLE_TYPE, VERSION_NUMBER, DERIVATIVE_NUMBER, USER_NODE_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get relative error value for the node.
This module contains CMISS MPI routines.
Definition: cmiss_mpi.f90:45
subroutine, public analyticanalysis_percentageerrorgetnode(FIELD, VARIABLE_TYPE, VERSION_NUMBER, DERIVATIVE_NUMBER, USER_NODE_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get percentage error value for the node.
subroutine, public analyticanalysis_relativeerrorgetelement(FIELD, VARIABLE_TYPE, USER_ELEMENT_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get relative error value for an element.
type(computational_environment_type), target, public computational_environment
The computational environment the program is running in.
Contains the topology information for the elements of a decomposition.
Definition: types.f90:1017
subroutine, public analyticanalysis_integralniderrorget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral nid error value for the field.
subroutine, public analyticanalysis_output(FIELD, FILENAME, ERR, ERROR,)
Output the analytic error analysis for a dependent field compared to the analytic values parameter se...
pure real(dp) function analytic_analysis_percentage_error(NUMERIC_VALUE, ANALYTIC_VALUE)
Calculates the percentage error between a numeric value and an analytic value.
Contains the topology information for the nodes of a domain.
Definition: types.f90:713
Contains information for a particular quadrature scheme.
Definition: types.f90:141
This module contains all routines dealing with (non-distributed) matrix and vectors types...
Write a string followed by a vector to a specified output stream.
subroutine, public analyticanalysis_integralanalyticvalueget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral analytic value for the field TODO should we use analytical formula to calculate the inte...
pure real(dp) function analytic_analysis_relative_error(NUMERIC_VALUE, ANALYTIC_VALUE)
Calculates the relative error between a numeric value and an analytic value.
subroutine, public analyticanalysis_percentageerrorgetelement(FIELD, VARIABLE_TYPE, USER_ELEMENT_NUMBER, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get percentage error value for the node.
Contains information for a field variable defined on a field.
Definition: types.f90:1289
pure real(dp) function analytic_analysis_nid_error(NUMERIC_VALUE, ANALYTIC_VALUE)
Calculates the Normalised Integral Difference (NID) error with a numeric value and an analytic value...
subroutine, public analyticanalysis_integralrelativeerrorget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral relative error value for the field.
A pointer to the domain decomposition for this domain.
Definition: types.f90:938
subroutine, public analyticanalysis_percentageerrorgetconstant(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get percentage error value for a constant.
subroutine, public analyticanalysis_integralnumericalvalueget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral numerical value for the field, TODO check integral calculation.
subroutine, public analyticanalysis_absoluteerrorgetconstant(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, VALUE, ERR, ERROR,)
Get absolute error value for the node.
Contains all information about a basis .
Definition: types.f90:184
integer(intg), parameter absolute_error_type
The absolute type.
subroutine, public analyticanalysis_integralabsoluteerrorget(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, INTEGRAL_ERROR, GHOST_INTEGRAL_ERROR, ERR, ERROR,)
Get integral absolute error value for the field.
pure real(dp) function analytic_analysis_absolute_error(NUMERIC_VALUE, ANALYTIC_VALUE)
Calculates the absolute error between a numeric value and an analytic value.
subroutine, public analyticanalysis_rmserrorgetnode(FIELD, VARIABLE_TYPE, COMPONENT_NUMBER, ERROR_TYPE, LOCAL_RMS, LOCAL_GHOST_RMS, GLOBAL_RMS, ERR, ERROR,)
Get rms error value for the field.
real(dp), parameter zero_tolerance
Definition: constants.f90:70
This module contains all kind definitions.
Definition: kinds.f90:45
subroutine, public mpi_error_check(ROUTINE, MPI_ERR_CODE, ERR, ERROR,)
Checks to see if an MPI error has occured during an MPI call and flags a CMISS error it if it has...
Definition: cmiss_mpi.f90:84
This module handles all formating and input and output.