82 INTEGER(INTG),
PARAMETER :: decomposition_all_type=1
83 INTEGER(INTG),
PARAMETER :: decomposition_calculated_type=2
84 INTEGER(INTG),
PARAMETER :: decomposition_user_defined_type=3
94 INTERFACE mesh_create_start
95 MODULE PROCEDURE mesh_create_start_interface
96 MODULE PROCEDURE mesh_create_start_region
100 INTERFACE meshes_initialise
101 MODULE PROCEDURE meshes_initialise_interface
102 MODULE PROCEDURE meshes_initialise_region
105 INTERFACE mesh_user_number_find
106 MODULE PROCEDURE mesh_user_number_find_interface
107 MODULE PROCEDURE mesh_user_number_find_region
110 INTERFACE meshtopologynodecheckexists
111 MODULE PROCEDURE meshtopologynodecheckexistsmesh
112 MODULE PROCEDURE meshtopologynodecheckexistsmeshnodes
113 END INTERFACE meshtopologynodecheckexists
115 INTERFACE meshtopologyelementcheckexists
116 MODULE PROCEDURE meshtopologyelementcheckexistsmesh
117 MODULE PROCEDURE meshtopologyelementcheckexistsmeshelements
118 END INTERFACE meshtopologyelementcheckexists
120 PUBLIC decomposition_all_type,decomposition_calculated_type,decomposition_user_defined_type
122 PUBLIC decompositions_initialise,decompositions_finalise
124 PUBLIC decomposition_create_start,decomposition_create_finish
126 PUBLIC decomposition_destroy
128 PUBLIC decomposition_element_domain_calculate
130 PUBLIC decomposition_element_domain_get,decomposition_element_domain_set
132 PUBLIC decomposition_mesh_component_number_get,decomposition_mesh_component_number_set
134 PUBLIC decomposition_number_of_domains_get,decomposition_number_of_domains_set
136 PUBLIC decomposition_topology_element_check_exists,decompositiontopology_datapointcheckexists
138 PUBLIC decompositiontopology_dataprojectioncalculate
140 PUBLIC decompositiontopology_elementdatapointlocalnumberget
142 PUBLIC decompositiontopology_elementdatapointusernumberget
144 PUBLIC decompositiontopology_numberofelementdatapointsget
146 PUBLIC decomposition_type_get,decomposition_type_set
148 PUBLIC decomposition_user_number_find, decomposition_user_number_to_decomposition
150 PUBLIC decomposition_node_domain_get
152 PUBLIC decomposition_calculate_lines_set,decomposition_calculate_faces_set
154 PUBLIC domain_topology_node_check_exists
156 PUBLIC domaintopology_elementbasisget
158 PUBLIC meshtopologyelementcheckexists,meshtopologynodecheckexists
160 PUBLIC mesh_create_start,mesh_create_finish
164 PUBLIC mesh_number_of_components_get,mesh_number_of_components_set
166 PUBLIC mesh_number_of_elements_get,mesh_number_of_elements_set
168 PUBLIC mesh_topology_elements_create_start,mesh_topology_elements_create_finish
170 PUBLIC mesh_topology_elements_destroy
172 PUBLIC mesh_topology_elements_element_basis_get,mesh_topology_elements_element_basis_set
174 PUBLIC mesh_topology_elements_adjacent_element_get
176 PUBLIC mesh_topology_elements_element_nodes_get
178 PUBLIC mesh_topology_elements_element_nodes_set,meshelements_elementnodeversionset
180 PUBLIC mesh_topology_elements_get
182 PUBLIC meshelements_elementusernumberget,meshelements_elementusernumberset
184 PUBLIC meshtopologyelementsusernumbersallset
186 PUBLIC meshtopologydatapointscalculateprojection
188 PUBLIC meshtopologynodederivativesget
190 PUBLIC meshtopologynodenumberofderivativesget
192 PUBLIC meshtopologynodenumberofversionsget
194 PUBLIC meshtopologynodesnumberofnodesget
196 PUBLIC meshtopologynodesdestroy
198 PUBLIC meshtopologynodesget
200 PUBLIC mesh_user_number_find, mesh_user_number_to_mesh
202 PUBLIC mesh_surrounding_elements_calculate_set
204 PUBLIC mesh_embedding_create,mesh_embedding_set_child_node_position
206 PUBLIC mesh_embedding_set_gauss_point_data
208 PUBLIC meshes_initialise,meshes_finalise
217 SUBROUTINE decomposition_adjacent_element_finalise(DECOMPOSITION_ADJACENT_ELEMENT,ERR,ERROR,*)
221 INTEGER(INTG),
INTENT(OUT) :: err
225 enters(
"DECOMPOSITION_ADJACENT_ELEMENT_FINALISE",err,error,*999)
227 decomposition_adjacent_element%NUMBER_OF_ADJACENT_ELEMENTS=0
228 IF(
ALLOCATED(decomposition_adjacent_element%ADJACENT_ELEMENTS))
DEALLOCATE(decomposition_adjacent_element%ADJACENT_ELEMENTS)
230 exits(
"DECOMPOSITION_ADJACENT_ELEMENT_FINALISE")
232 999 errorsexits(
"DECOMPOSITION_ADJACENT_ELEMENT_FINALISE",err,error)
235 END SUBROUTINE decomposition_adjacent_element_finalise
241 SUBROUTINE decomposition_adjacent_element_initialise(DECOMPOSITION_ADJACENT_ELEMENT,ERR,ERROR,*)
245 INTEGER(INTG),
INTENT(OUT) :: err
249 enters(
"DECOMPOSITION_ADJACENT_ELEMENT_INITIALISE",err,error,*999)
251 decomposition_adjacent_element%NUMBER_OF_ADJACENT_ELEMENTS=0
253 exits(
"DECOMPOSITION_ADJACENT_ELEMENT_INITIALISE")
255 999 errorsexits(
"DECOMPOSITION_ADJACENT_ELEMENT_INITIALISE",err,error)
258 END SUBROUTINE decomposition_adjacent_element_initialise
265 SUBROUTINE decomposition_create_finish(DECOMPOSITION,ERR,ERROR,*)
269 INTEGER(INTG),
INTENT(OUT) :: err
272 INTEGER(INTG) :: decomposition_no
275 enters(
"DECOMPOSITION_CREATE_FINISH",err,error,*999)
277 IF(
ASSOCIATED(decomposition))
THEN 279 CALL decomposition_element_domain_calculate(decomposition,err,error,*999)
281 CALL decomposition_topology_initialise(decomposition,err,error,*999)
283 CALL domain_initialise(decomposition,err,error,*999)
285 CALL decomposition_topology_calculate(decomposition,err,error,*999)
286 decomposition%DECOMPOSITION_FINISHED=.true.
289 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
293 mesh=>decomposition%MESH
294 IF(
ASSOCIATED(mesh))
THEN 297 & mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS,err,error,*999)
298 DO decomposition_no=1,mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS
301 & mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_no)%PTR%GLOBAL_NUMBER,err,error,*999)
303 & mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_no)%PTR%USER_NUMBER,err,error,*999)
306 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
310 exits(
"DECOMPOSITION_CREATE_FINISH")
312 999 errorsexits(
"DECOMPOSITION_CREATE_FINISH",err,error)
314 END SUBROUTINE decomposition_create_finish
321 SUBROUTINE decomposition_create_start(USER_NUMBER,MESH,DECOMPOSITION,ERR,ERROR,*)
324 INTEGER(INTG),
INTENT(IN) :: user_number
327 INTEGER(INTG),
INTENT(OUT) :: err
330 INTEGER(INTG) :: decomposition_no
335 NULLIFY(new_decomposition)
336 NULLIFY(new_decompositions)
338 enters(
"DECOMPOSITION_CREATE_START",err,error,*999)
340 NULLIFY(decomposition)
342 IF(
ASSOCIATED(mesh))
THEN 343 IF(mesh%MESH_FINISHED)
THEN 344 IF(
ASSOCIATED(mesh%TOPOLOGY))
THEN 345 IF(
ASSOCIATED(mesh%DECOMPOSITIONS))
THEN 346 CALL decomposition_user_number_find(user_number,mesh,decomposition,err,error,*999)
347 IF(
ASSOCIATED(decomposition))
THEN 349 &
" has already been created on mesh number "//
trim(
number_to_vstring(mesh%USER_NUMBER,
"*",err,error))//
"." 350 CALL flagerror(local_error,err,error,*999)
353 ALLOCATE(new_decomposition,stat=err)
354 IF(err/=0)
CALL flagerror(
"Could not allocate new decomposition.",err,error,*999)
356 new_decomposition%GLOBAL_NUMBER=mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS+1
357 new_decomposition%USER_NUMBER=user_number
358 new_decomposition%DECOMPOSITION_FINISHED=.false.
359 new_decomposition%CALCULATE_LINES=.true.
360 new_decomposition%CALCULATE_FACES=.false.
361 new_decomposition%DECOMPOSITIONS=>mesh%DECOMPOSITIONS
362 new_decomposition%MESH=>mesh
364 new_decomposition%MESH_COMPONENT_NUMBER=1
366 new_decomposition%DECOMPOSITION_TYPE=decomposition_all_type
367 new_decomposition%NUMBER_OF_DOMAINS=1
368 ALLOCATE(new_decomposition%ELEMENT_DOMAIN(mesh%NUMBER_OF_ELEMENTS),stat=err)
369 IF(err/=0)
CALL flagerror(
"Could not allocate new decomposition element domain.",err,error,*999)
370 new_decomposition%ELEMENT_DOMAIN=0
372 NULLIFY(new_decomposition%DOMAIN)
374 NULLIFY(new_decomposition%TOPOLOGY)
377 ALLOCATE(new_decompositions(mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS+1),stat=err)
378 IF(err/=0)
CALL flagerror(
"Could not allocate new decompositions.",err,error,*999)
379 DO decomposition_no=1,mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS
380 new_decompositions(decomposition_no)%PTR=>mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_no)%PTR
382 new_decompositions(mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS+1)%PTR=>new_decomposition
383 IF(
ASSOCIATED(mesh%DECOMPOSITIONS%DECOMPOSITIONS))
DEALLOCATE(mesh%DECOMPOSITIONS%DECOMPOSITIONS)
384 mesh%DECOMPOSITIONS%DECOMPOSITIONS=>new_decompositions
385 mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS=mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS+1
386 decomposition=>new_decomposition
389 local_error=
"The decompositions on mesh number "//
trim(
number_to_vstring(mesh%USER_NUMBER,
"*",err,error))// &
390 &
" are not associated." 391 CALL flagerror(local_error,err,error,*999)
394 CALL flagerror(
"Mesh topology is not associated",err,error,*999)
397 CALL flagerror(
"Mesh has not been finished.",err,error,*999)
400 CALL flagerror(
"Mesh is not associated",err,error,*999)
403 exits(
"DECOMPOSITION_CREATE_START")
405 999
IF(
ASSOCIATED(new_decomposition))
THEN 406 IF(
ALLOCATED(new_decomposition%ELEMENT_DOMAIN))
DEALLOCATE(new_decomposition%ELEMENT_DOMAIN)
407 DEALLOCATE(new_decomposition)
409 IF(
ASSOCIATED(new_decompositions))
DEALLOCATE(new_decompositions)
410 NULLIFY(decomposition)
411 errorsexits(
"DECOMPOSITION_CREATE_START",err,error)
413 END SUBROUTINE decomposition_create_start
420 SUBROUTINE decomposition_destroy_number(USER_NUMBER,MESH,ERR,ERROR,*)
423 INTEGER(INTG),
INTENT(IN) :: user_number
425 INTEGER(INTG),
INTENT(OUT) :: err
428 INTEGER(INTG) :: decomposition_idx,decomposition_position
434 NULLIFY(new_decompositions)
436 enters(
"DECOMPOSITION_DESTROY_NUMBER",err,error,*999)
438 IF(
ASSOCIATED(mesh))
THEN 439 IF(
ASSOCIATED(mesh%DECOMPOSITIONS))
THEN 443 decomposition_position=0
444 DO WHILE(decomposition_position<mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS.AND..NOT.found)
445 decomposition_position=decomposition_position+1
446 IF(mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_position)%PTR%USER_NUMBER==user_number) found=.true.
451 decomposition=>mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_position)%PTR
454 IF(
ALLOCATED(decomposition%ELEMENT_DOMAIN))
DEALLOCATE(decomposition%ELEMENT_DOMAIN)
455 CALL decomposition_topology_finalise(decomposition,err,error,*999)
456 CALL domain_finalise(decomposition,err,error,*999)
458 DEALLOCATE(decomposition)
461 IF(mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS>1)
THEN 462 ALLOCATE(new_decompositions(mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS-1),stat=err)
463 IF(err/=0)
CALL flagerror(
"Could not allocate new decompositions.",err,error,*999)
464 DO decomposition_idx=1,mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS
465 IF(decomposition_idx<decomposition_position)
THEN 466 new_decompositions(decomposition_idx)%PTR=>mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR
467 ELSE IF(decomposition_idx>decomposition_position)
THEN 468 mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR%GLOBAL_NUMBER= &
469 & mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR%GLOBAL_NUMBER-1
470 new_decompositions(decomposition_idx-1)%PTR=>mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR
473 DEALLOCATE(mesh%DECOMPOSITIONS%DECOMPOSITIONS)
474 mesh%DECOMPOSITIONS%DECOMPOSITIONS=>new_decompositions
475 mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS=mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS-1
477 DEALLOCATE(mesh%DECOMPOSITIONS%DECOMPOSITIONS)
478 mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS=0
483 &
" has not been created on mesh number "//
trim(
number_to_vstring(mesh%USER_NUMBER,
"*",err,error))//
"." 484 CALL flagerror(local_error,err,error,*999)
487 local_error=
"The decompositions on mesh number "//
trim(
number_to_vstring(mesh%USER_NUMBER,
"*",err,error))// &
488 &
" are not associated." 489 CALL flagerror(local_error,err,error,*999)
492 CALL flagerror(
"Mesh is not associated.",err,error,*999)
495 exits(
"DECOMPOSITION_DESTROY_NUMBER")
497 999
IF(
ASSOCIATED(new_decompositions))
DEALLOCATE(new_decompositions)
498 errorsexits(
"DECOMPOSITION_DESTROY_NUMBER",err,error)
500 END SUBROUTINE decomposition_destroy_number
507 SUBROUTINE decomposition_destroy(DECOMPOSITION,ERR,ERROR,*)
511 INTEGER(INTG),
INTENT(OUT) :: err
514 INTEGER(INTG) :: decomposition_idx,decomposition_position
518 NULLIFY(new_decompositions)
520 enters(
"DECOMPOSITION_DESTROY",err,error,*999)
522 IF(
ASSOCIATED(decomposition))
THEN 523 decompositions=>decomposition%DECOMPOSITIONS
524 IF(
ASSOCIATED(decompositions))
THEN 525 decomposition_position=decomposition%GLOBAL_NUMBER
528 IF(
ALLOCATED(decomposition%ELEMENT_DOMAIN))
DEALLOCATE(decomposition%ELEMENT_DOMAIN)
529 CALL decomposition_topology_finalise(decomposition,err,error,*999)
530 CALL domain_finalise(decomposition,err,error,*999)
532 DEALLOCATE(decomposition)
535 IF(decompositions%NUMBER_OF_DECOMPOSITIONS>1)
THEN 536 ALLOCATE(new_decompositions(decompositions%NUMBER_OF_DECOMPOSITIONS-1),stat=err)
537 IF(err/=0)
CALL flagerror(
"Could not allocate new decompositions.",err,error,*999)
538 DO decomposition_idx=1,decompositions%NUMBER_OF_DECOMPOSITIONS
539 IF(decomposition_idx<decomposition_position)
THEN 540 new_decompositions(decomposition_idx)%PTR=>decompositions%DECOMPOSITIONS(decomposition_idx)%PTR
541 ELSE IF(decomposition_idx>decomposition_position)
THEN 542 decompositions%DECOMPOSITIONS(decomposition_idx)%PTR%GLOBAL_NUMBER= &
543 & decompositions%DECOMPOSITIONS(decomposition_idx)%PTR%GLOBAL_NUMBER-1
544 new_decompositions(decomposition_idx-1)%PTR=>decompositions%DECOMPOSITIONS(decomposition_idx)%PTR
547 DEALLOCATE(decompositions%DECOMPOSITIONS)
548 decompositions%DECOMPOSITIONS=>new_decompositions
549 decompositions%NUMBER_OF_DECOMPOSITIONS=decompositions%NUMBER_OF_DECOMPOSITIONS-1
551 DEALLOCATE(decompositions%DECOMPOSITIONS)
552 decompositions%NUMBER_OF_DECOMPOSITIONS=0
555 CALL flagerror(
"Decomposition decompositions is not associated.",err,error,*999)
558 CALL flagerror(
"Decompositions is not associated.",err,error,*999)
561 exits(
"DECOMPOSITION_DESTROY")
563 999
IF(
ASSOCIATED(new_decompositions))
DEALLOCATE(new_decompositions)
564 errorsexits(
"DECOMPOSITION_DESTROY",err,error)
566 END SUBROUTINE decomposition_destroy
573 SUBROUTINE decomposition_element_domain_calculate(DECOMPOSITION,ERR,ERROR,*)
577 INTEGER(INTG),
INTENT(OUT) :: err
581 & no_computational_node,ELEMENT_START,ELEMENT_STOP,MY_ELEMENT_START,MY_ELEMENT_STOP,NUMBER_OF_ELEMENTS, &
582 & MY_NUMBER_OF_ELEMENTS,MPI_IERROR,MAX_NUMBER_ELEMENTS_PER_NODE,component_idx,minNumberXi
583 INTEGER(INTG),
ALLOCATABLE :: element_count(:),element_ptr(:),element_indicies(:),element_distance(:),displacements(:), &
585 INTEGER(INTG) :: element_weight(1),weight_flag,number_flag,number_of_constraints, &
586 & NUMBER_OF_COMMON_NODES,PARMETIS_OPTIONS(0:2)
591 REAL(DP),
ALLOCATABLE :: tpwgts(:)
592 REAL(DP) :: number_elements_per_node
597 enters(
"DECOMPOSITION_ELEMENT_DOMAIN_CALCULATE",err,error,*999)
599 IF(
ASSOCIATED(decomposition))
THEN 600 IF(
ASSOCIATED(decomposition%MESH))
THEN 601 mesh=>decomposition%MESH
602 IF(
ASSOCIATED(mesh%TOPOLOGY))
THEN 604 component_idx=decomposition%MESH_COMPONENT_NUMBER
611 SELECT CASE(decomposition%DECOMPOSITION_TYPE)
612 CASE(decomposition_all_type)
614 CASE(decomposition_calculated_type)
617 IF(decomposition%NUMBER_OF_DOMAINS==1)
THEN 618 decomposition%ELEMENT_DOMAIN=0
623 number_elements_per_node=
REAL(mesh%number_of_elements,
dp)/
REAL(number_computational_nodes,
dp)
626 max_number_elements_per_node=-1
627 ALLOCATE(receive_counts(0:number_computational_nodes-1),stat=err)
628 IF(err/=0)
CALL flagerror(
"Could not allocate recieve counts.",err,error,*999)
629 ALLOCATE(displacements(0:number_computational_nodes-1),stat=err)
630 IF(err/=0)
CALL flagerror(
"Could not allocate displacements.",err,error,*999)
631 ALLOCATE(element_distance(0:number_computational_nodes),stat=err)
632 IF(err/=0)
CALL flagerror(
"Could not allocate element distance.",err,error,*999)
633 element_distance(0)=0
634 DO no_computational_node=0,number_computational_nodes-1
635 element_start=element_stop+1
636 IF(no_computational_node==number_computational_nodes-1)
THEN 637 element_stop=mesh%NUMBER_OF_ELEMENTS
639 element_stop=element_start+nint(number_elements_per_node,
intg)-1
641 IF((number_computational_nodes-1-no_computational_node)>(mesh%NUMBER_OF_ELEMENTS-element_stop)) &
642 & element_stop=mesh%NUMBER_OF_ELEMENTS-(number_computational_nodes-1-no_computational_node)
643 IF(element_start>mesh%NUMBER_OF_ELEMENTS) element_start=mesh%NUMBER_OF_ELEMENTS
644 IF(element_stop>mesh%NUMBER_OF_ELEMENTS) element_stop=mesh%NUMBER_OF_ELEMENTS
645 displacements(no_computational_node)=element_start-1
646 element_distance(no_computational_node+1)=element_stop
647 number_of_elements=element_stop-element_start+1
648 receive_counts(no_computational_node)=number_of_elements
649 IF(number_of_elements>max_number_elements_per_node) max_number_elements_per_node=number_of_elements
651 my_element_start=element_start
652 my_element_stop=element_stop
653 my_number_of_elements=element_stop-element_start+1
654 number_elem_indicies=0
655 DO ne=my_element_start,my_element_stop
656 basis=>mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS(ne)%BASIS
657 number_elem_indicies=number_elem_indicies+basis%NUMBER_OF_NODES
662 ALLOCATE(element_ptr(0:my_number_of_elements),stat=err)
663 IF(err/=0)
CALL flagerror(
"Could not allocate element pointer list.",err,error,*999)
664 ALLOCATE(element_indicies(0:number_elem_indicies-1),stat=err)
665 IF(err/=0)
CALL flagerror(
"Could not allocate element indicies list.",err,error,*999)
666 ALLOCATE(tpwgts(1:decomposition%NUMBER_OF_DOMAINS),stat=err)
667 IF(err/=0)
CALL flagerror(
"Could not allocate tpwgts.",err,error,*999)
672 DO ne=my_element_start,my_element_stop
673 elem_count=elem_count+1
674 basis=>mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS(ne)%BASIS
675 IF(basis%NUMBER_OF_XI<minnumberxi) minnumberxi=basis%NUMBER_OF_XI
676 DO nn=1,basis%NUMBER_OF_NODES
677 element_indicies(elem_index)=mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS(ne)% &
678 & mesh_element_nodes(nn)-1
679 elem_index=elem_index+1
681 element_ptr(elem_count)=elem_index
688 number_of_constraints=1
689 IF(minnumberxi==1)
THEN 690 number_of_common_nodes=1
692 number_of_common_nodes=2
697 tpwgts=1.0_dp/
REAL(decomposition%number_of_domains,
dp)
699 parmetis_options(0)=1
700 parmetis_options(1)=7
704 CALL parmetis_partmeshkway(element_distance,element_ptr,element_indicies,element_weight,weight_flag,number_flag, &
705 & number_of_constraints,number_of_common_nodes,decomposition%NUMBER_OF_DOMAINS,tpwgts,ubvec,parmetis_options, &
710 IF(number_computational_nodes>1)
THEN 712 CALL mpi_allgatherv(mpi_in_place,max_number_elements_per_node,mpi_integer,decomposition%ELEMENT_DOMAIN, &
717 DEALLOCATE(displacements)
718 DEALLOCATE(receive_counts)
719 DEALLOCATE(element_distance)
720 DEALLOCATE(element_ptr)
721 DEALLOCATE(element_indicies)
726 CASE(decomposition_user_defined_type)
729 CALL flagerror(
"Invalid domain decomposition type.",err,error,*999)
733 ALLOCATE(element_count(0:number_computational_nodes-1),stat=err)
734 IF(err/=0)
CALL flagerror(
"Could not allocate element count.",err,error,*999)
736 DO elem_index=1,mesh%NUMBER_OF_ELEMENTS
737 no_computational_node=decomposition%ELEMENT_DOMAIN(elem_index)
738 IF(no_computational_node>=0.AND.no_computational_node<number_computational_nodes)
THEN 739 element_count(no_computational_node)=element_count(no_computational_node)+1
741 local_error=
"The computational node number of "//
trim(
number_to_vstring(no_computational_node,
"*",err,error))// &
743 &
" is invalid. The computational node number must be between 0 and "// &
745 CALL flagerror(local_error,err,error,*999)
748 DO no_computational_node=0,number_computational_nodes-1
749 IF(element_count(no_computational_node)==0)
THEN 750 local_error=
"Invalid decomposition. There are no elements in computational node "// &
752 CALL flagerror(local_error,err,error,*999)
755 DEALLOCATE(element_count)
758 CALL flagerror(
"Decomposition mesh topology is not associated.",err,error,*999)
761 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
764 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
775 IF(decomposition%DECOMPOSITION_TYPE==decomposition_calculated_type)
THEN 781 DO ne=1,decomposition%MESH%NUMBER_OF_ELEMENTS
788 exits(
"DECOMPOSITION_ELEMENT_DOMAIN_CALCULATE")
790 999
IF(
ALLOCATED(receive_counts))
DEALLOCATE(receive_counts)
791 IF(
ALLOCATED(displacements))
DEALLOCATE(displacements)
792 IF(
ALLOCATED(element_distance))
DEALLOCATE(element_distance)
793 IF(
ALLOCATED(element_ptr))
DEALLOCATE(element_ptr)
794 IF(
ALLOCATED(element_indicies))
DEALLOCATE(element_indicies)
795 IF(
ALLOCATED(tpwgts))
DEALLOCATE(tpwgts)
796 errorsexits(
"DECOMPOSITION_ELEMENT_DOMAIN_CALCULATE",err,error)
798 END SUBROUTINE decomposition_element_domain_calculate
805 SUBROUTINE decomposition_element_domain_get(DECOMPOSITION,USER_ELEMENT_NUMBER,DOMAIN_NUMBER,ERR,ERROR,*)
809 INTEGER(INTG),
INTENT(IN) :: user_element_number
810 INTEGER(INTG),
INTENT(OUT) :: domain_number
811 INTEGER(INTG),
INTENT(OUT) :: err
817 INTEGER(INTG) :: global_element_number
822 enters(
"DECOMPOSITION_ELEMENT_DOMAIN_GET",err,error,*999)
824 global_element_number=0
825 IF(
ASSOCIATED(decomposition))
THEN 826 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 827 mesh=>decomposition%MESH
828 IF(
ASSOCIATED(mesh))
THEN 829 mesh_topology=>mesh%TOPOLOGY(decomposition%MESH_COMPONENT_NUMBER)%PTR
830 IF(
ASSOCIATED(mesh_topology))
THEN 831 mesh_elements=>mesh_topology%ELEMENTS
832 IF(
ASSOCIATED(mesh_elements))
THEN 834 CALL tree_search(mesh_elements%ELEMENTS_TREE,user_element_number,tree_node,err,error,*999)
835 IF(
ASSOCIATED(tree_node))
THEN 836 CALL tree_node_value_get(mesh_elements%ELEMENTS_TREE,tree_node,global_element_number,err,error,*999)
837 IF(global_element_number>0.AND.global_element_number<=mesh_topology%ELEMENTS%NUMBER_OF_ELEMENTS)
THEN 838 domain_number=decomposition%ELEMENT_DOMAIN(global_element_number)
840 local_error=
"Global element number found "//
trim(
number_to_vstring(global_element_number,
"*",err,error))// &
841 &
" is invalid. The limits are 1 to "// &
843 CALL flagerror(local_error,err,error,*999)
846 CALL flagerror(
"Decomposition mesh element corresponding to user number not found.",err,error,*999)
849 CALL flagerror(
"Decomposition mesh elements are not associated.",err,error,*999)
852 CALL flagerror(
"Decomposition mesh topology is not associated.",err,error,*999)
855 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
858 CALL flagerror(
"Decomposition has not been finished.",err,error,*999)
861 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
864 exits(
"DECOMPOSITION_ELEMENT_DOMAIN_GET")
866 999 errorsexits(
"DECOMPOSITION_ELEMENT_DOMAIN_GET",err,error)
868 END SUBROUTINE decomposition_element_domain_get
875 SUBROUTINE decomposition_element_domain_set(DECOMPOSITION,GLOBAL_ELEMENT_NUMBER,DOMAIN_NUMBER,ERR,ERROR,*)
879 INTEGER(INTG),
INTENT(IN) :: global_element_number
880 INTEGER(INTG),
INTENT(IN) :: domain_number
881 INTEGER(INTG),
INTENT(OUT) :: err
884 INTEGER(INTG) :: number_computational_nodes
889 enters(
"DECOMPOSITION_ELEMENT_DOMAIN_SET",err,error,*999)
893 IF(
ASSOCIATED(decomposition))
THEN 894 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 895 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
897 mesh=>decomposition%MESH
898 IF(
ASSOCIATED(mesh))
THEN 899 mesh_topology=>mesh%TOPOLOGY(decomposition%MESH_COMPONENT_NUMBER)%PTR
900 IF(
ASSOCIATED(mesh_topology))
THEN 901 IF(global_element_number>0.AND.global_element_number<=mesh_topology%ELEMENTS%NUMBER_OF_ELEMENTS)
THEN 904 IF(domain_number>=0.AND.domain_number<number_computational_nodes)
THEN 905 decomposition%ELEMENT_DOMAIN(global_element_number)=domain_number
908 &
" is invalid. The limits are 0 to "//
trim(
number_to_vstring(number_computational_nodes,
"*",err,error))//
"." 909 CALL flagerror(local_error,err,error,*999)
912 local_error=
"Global element number "//
trim(
number_to_vstring(global_element_number,
"*",err,error))// &
913 &
" is invalid. The limits are 1 to "// &
915 CALL flagerror(local_error,err,error,*999)
918 CALL flagerror(
"Decomposition mesh topology is not associated.",err,error,*999)
921 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
925 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
928 exits(
"DECOMPOSITION_ELEMENT_DOMAIN_SET")
930 999 errorsexits(
"DECOMPOSITION_ELEMENT_DOMAIN_SET",err,error)
932 END SUBROUTINE decomposition_element_domain_set
941 SUBROUTINE decomposition_mesh_component_number_get(DECOMPOSITION,MESH_COMPONENT_NUMBER,ERR,ERROR,*)
945 INTEGER(INTG),
INTENT(OUT) :: mesh_component_number
946 INTEGER(INTG),
INTENT(OUT) :: err
950 enters(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_GET",err,error,*999)
952 IF(
ASSOCIATED(decomposition))
THEN 953 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 954 IF(
ASSOCIATED(decomposition%MESH))
THEN 955 mesh_component_number=decomposition%MESH_COMPONENT_NUMBER
957 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
960 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
963 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
966 exits(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_GET")
968 999 errorsexits(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_GET",err,error)
970 END SUBROUTINE decomposition_mesh_component_number_get
978 SUBROUTINE decomposition_mesh_component_number_set(DECOMPOSITION,MESH_COMPONENT_NUMBER,ERR,ERROR,*)
982 INTEGER(INTG),
INTENT(IN) :: mesh_component_number
983 INTEGER(INTG),
INTENT(OUT) :: err
988 enters(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_SET",err,error,*999)
990 IF(
ASSOCIATED(decomposition))
THEN 991 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 992 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
994 IF(
ASSOCIATED(decomposition%MESH))
THEN 995 IF(mesh_component_number>0.AND.mesh_component_number<=decomposition%MESH%NUMBER_OF_COMPONENTS)
THEN 996 decomposition%MESH_COMPONENT_NUMBER=mesh_component_number
998 local_error=
"The specified mesh component number of "//
trim(
number_to_vstring(mesh_component_number,
"*",err,error))// &
999 &
"is invalid. The component number must be between 1 and "// &
1001 CALL flagerror(local_error,err,error,*999)
1004 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
1008 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
1011 exits(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_SET")
1013 999 errorsexits(
"DECOMPOSITION_MESH_COMPONENT_NUMBER_SET",err,error)
1015 END SUBROUTINE decomposition_mesh_component_number_set
1024 SUBROUTINE decomposition_number_of_domains_get(DECOMPOSITION,NUMBER_OF_DOMAINS,ERR,ERROR,*)
1028 INTEGER(INTG),
INTENT(OUT) :: number_of_domains
1029 INTEGER(INTG),
INTENT(OUT) :: err
1033 enters(
"DECOMPOSITION_NUMBER_OF_DOMAINS_GET",err,error,*999)
1035 IF(
ASSOCIATED(decomposition))
THEN 1036 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 1037 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
1039 number_of_domains=decomposition%NUMBER_OF_DOMAINS
1042 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
1045 exits(
"DECOMPOSITION_NUMBER_OF_DOMAINS_GET")
1047 999 errorsexits(
"DECOMPOSITION_NUMBER_OF_DOMAINS_GET",err,error)
1049 END SUBROUTINE decomposition_number_of_domains_get
1057 SUBROUTINE decomposition_number_of_domains_set(DECOMPOSITION,NUMBER_OF_DOMAINS,ERR,ERROR,*)
1061 INTEGER(INTG),
INTENT(IN) :: number_of_domains
1062 INTEGER(INTG),
INTENT(OUT) :: err
1065 INTEGER(INTG) :: number_computational_nodes
1068 enters(
"DECOMPOSITION_NUMBER_OF_DOMAINS_SET",err,error,*999)
1070 IF(
ASSOCIATED(decomposition))
THEN 1071 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 1072 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
1074 SELECT CASE(decomposition%DECOMPOSITION_TYPE)
1075 CASE(decomposition_all_type)
1076 IF(number_of_domains==1)
THEN 1077 decomposition%NUMBER_OF_DOMAINS=1
1079 CALL flagerror(
"Can only have one domain for all decomposition type.",err,error,*999)
1081 CASE(decomposition_calculated_type,decomposition_user_defined_type)
1082 IF(number_of_domains>=1)
THEN 1084 IF(number_of_domains<=decomposition%MESH%NUMBER_OF_ELEMENTS)
THEN 1090 decomposition%NUMBER_OF_DOMAINS=number_of_domains
1099 &
") must be <= the number of global elements ("// &
1101 CALL flagerror(local_error,err,error,*999)
1104 CALL flagerror(
"Number of domains must be >= 1.",err,error,*999)
1107 local_error=
"Decomposition type "//
trim(
number_to_vstring(decomposition%DECOMPOSITION_TYPE,
"*",err,error))// &
1109 CALL flagerror(local_error,err,error,*999)
1113 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
1116 exits(
"DECOMPOSITION_NUMBER_OF_DOMAINS_SET")
1118 999 errorsexits(
"DECOMPOSITION_NUMBER_OF_DOMAINS_SET",err,error)
1120 END SUBROUTINE decomposition_number_of_domains_set
1127 SUBROUTINE decomposition_topology_calculate(DECOMPOSITION,ERR,ERROR,*)
1131 INTEGER(INTG),
INTENT(OUT) :: err
1134 INTEGER(INTG) :: meshcomponentnumber
1136 enters(
"DECOMPOSITION_TOPOLOGY_CALCULATE",err,error,*999)
1138 IF(
ASSOCIATED(decomposition%TOPOLOGY))
THEN 1140 CALL decomposition_topology_elements_calculate(decomposition%TOPOLOGY,err,error,*999)
1142 IF(decomposition%CALCULATE_LINES)
THEN 1143 CALL decomposition_topology_lines_calculate(decomposition%TOPOLOGY,err,error,*999)
1146 IF(decomposition%CALCULATE_FACES)
THEN 1147 CALL decomposition_topology_faces_calculate(decomposition%TOPOLOGY,err,error,*999)
1149 meshcomponentnumber=decomposition%MESH_COMPONENT_NUMBER
1150 IF(
ALLOCATED(decomposition%MESH%TOPOLOGY(meshcomponentnumber)%PTR%dataPoints%dataPoints))
THEN 1151 CALL decompositiontopology_datapointscalculate(decomposition%TOPOLOGY,err,error,*999)
1154 CALL flagerror(
"Topology is not associated.",err,error,*999)
1157 exits(
"DECOMPOSITION_TOPOLOGY_CALCULATE")
1159 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_CALCULATE",err,error)
1161 END SUBROUTINE decomposition_topology_calculate
1168 SUBROUTINE decompositiontopology_datapointscalculate(TOPOLOGY,ERR,ERROR,*)
1172 INTEGER(INTG),
INTENT(OUT) :: err
1175 INTEGER(INTG) :: localelement,globalelement,datapointidx,localdata,meshcomponentnumber
1177 & NUMBER_OF_LOCAL_DATA
1184 enters(
"DecompositionTopology_DataPointsCalculate",err,error,*999)
1186 IF(
ASSOCIATED(topology))
THEN 1187 decompositiondata=>topology%dataPoints
1188 IF(
ASSOCIATED(decompositiondata))
THEN 1189 decomposition=>decompositiondata%DECOMPOSITION
1190 IF(
ASSOCIATED(decomposition))
THEN 1191 decompositionelements=>topology%ELEMENTS
1192 IF(
ASSOCIATED(decompositionelements))
THEN 1193 elementsmapping=>decomposition%DOMAIN(decomposition%MESH_COMPONENT_NUMBER)%PTR%MAPPINGS%ELEMENTS
1194 IF(
ASSOCIATED(elementsmapping))
THEN 1195 meshcomponentnumber=decomposition%MESH_COMPONENT_NUMBER
1196 meshdata=>decomposition%MESH%TOPOLOGY(meshcomponentnumber)%PTR%dataPoints
1197 IF(
ASSOCIATED(meshdata))
THEN 1204 ALLOCATE(decompositiondata%numberOfElementDataPoints(decompositionelements%NUMBER_OF_GLOBAL_ELEMENTS),stat=err)
1205 ALLOCATE(decompositiondata%elementDataPoint(decompositionelements%TOTAL_NUMBER_OF_ELEMENTS),stat=err)
1206 IF(err/=0)
CALL flagerror(
"Could not allocate decomposition element data points.",err,error,*999)
1210 decompositiondata%numberOfGlobalDataPoints=meshdata%totalNumberOfProjectedData
1211 DO globalelement=1,decompositionelements%NUMBER_OF_GLOBAL_ELEMENTS
1212 decompositiondata%numberOfElementDataPoints(globalelement)= &
1213 & meshdata%elementDataPoint(globalelement)%numberOfProjectedData
1216 DO localelement=1,decompositionelements%TOTAL_NUMBER_OF_ELEMENTS
1217 globalelement=decompositionelements%ELEMENTS(localelement)%GLOBAL_NUMBER
1218 decompositiondata%elementDataPoint(localelement)%numberOfProjectedData= &
1219 & meshdata%elementDataPoint(globalelement)%numberOfProjectedData
1220 decompositiondata%elementDataPoint(localelement)%globalElementNumber=globalelement
1221 IF(localelement<elementsmapping%GHOST_START)
THEN 1222 decompositiondata%numberOfDataPoints=decompositiondata%numberOfDataPoints+ &
1223 & decompositiondata%elementDataPoint(localelement)%numberOfProjectedData
1225 decompositiondata%totalNumberOfDataPoints=decompositiondata%totalNumberOfDataPoints+ &
1226 & decompositiondata%elementDataPoint(localelement)%numberOfProjectedData
1227 ALLOCATE(decompositiondata%elementDataPoint(localelement)%dataIndices(decompositiondata% &
1228 & elementdatapoint(localelement)%numberOfProjectedData),stat=err)
1229 DO datapointidx=1,decompositiondata%elementDataPoint(localelement)%numberOfProjectedData
1230 decompositiondata%elementDataPoint(localelement)%dataIndices(datapointidx)%userNumber= &
1231 & meshdata%elementDataPoint(globalelement)%dataIndices(datapointidx)%userNumber
1232 decompositiondata%elementDataPoint(localelement)%dataIndices(datapointidx)%globalNumber= &
1233 & meshdata%elementDataPoint(globalelement)%dataIndices(datapointidx)%globalNumber
1234 localdata=localdata+1
1235 decompositiondata%elementDataPoint(localelement)%dataIndices(datapointidx)%localNumber=localdata
1236 CALL tree_item_insert(decompositiondata%dataPointsTree,decompositiondata% &
1237 & elementdatapoint(localelement)%dataIndices(datapointidx)%userNumber,localdata, &
1238 & insert_status,err,error,*999)
1242 number_of_local_data=decompositiondata%numberOfDataPoints
1243 number_of_ghost_data=decompositiondata%totalNumberOfDataPoints-decompositiondata%numberOfDataPoints
1245 CALL mpi_allgather(number_of_local_data,1,mpi_integer,decompositiondata% &
1249 CALL mpi_allgather(number_of_ghost_data,1,mpi_integer,decompositiondata% &
1253 CALL flagerror(
"Mesh data points topology is not associated.",err,error,*999)
1256 CALL flagerror(
"Element mapping is not associated.",err,error,*999)
1259 CALL flagerror(
"Decomposition elements topology is not associated.",err,error,*999)
1262 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
1265 CALL flagerror(
"Decomposition data points topology is not associated.",err,error,*999)
1268 CALL flagerror(
"Topology is not associated.",err,error,*999)
1271 exits(
"DecompositionTopology_DataPointsCalculate")
1273 999 errorsexits(
"DecompositionTopology_DataPointsCalculate",err,error)
1275 END SUBROUTINE decompositiontopology_datapointscalculate
1282 SUBROUTINE decompositiontopology_dataprojectioncalculate(decompositionTopology,err,error,*)
1286 INTEGER(INTG),
INTENT(OUT) :: err
1289 enters(
"DecompositionTopology_DataProjectionCalculate",err,error,*999)
1291 IF(
ASSOCIATED(decompositiontopology))
THEN 1292 CALL decompositiontopology_datapointsinitialise(decompositiontopology,err,error,*999)
1293 CALL decompositiontopology_datapointscalculate(decompositiontopology,err,error,*999)
1295 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1298 exits(
"DecompositionTopology_DataProjectionCalculate")
1300 999
errors(
"DecompositionTopology_DataProjectionCalculate",err,error)
1301 exits(
"DecompositionTopology_DataProjectionCalculate")
1303 END SUBROUTINE decompositiontopology_dataprojectioncalculate
1310 SUBROUTINE decompositiontopology_elementdatapointlocalnumberget(decompositionTopology,elementNumber,dataPointIndex, &
1311 & datapointlocalnumber,err,error,*)
1315 INTEGER(INTG),
INTENT(IN) :: elementnumber
1316 INTEGER(INTG),
INTENT(IN) :: datapointindex
1317 INTEGER(INTG),
INTENT(OUT) :: datapointlocalnumber
1318 INTEGER(INTG),
INTENT(OUT) :: err
1322 INTEGER(INTG) :: numberofdatapoints
1325 enters(
"DecompositionTopology_ElementDataPointLocalNumberGet",err,error,*999)
1327 IF(
ASSOCIATED(decompositiontopology))
THEN 1328 decompositiondata=>decompositiontopology%dataPoints
1329 IF(
ASSOCIATED(decompositiondata))
THEN 1330 numberofdatapoints = decompositiondata%elementDataPoint(elementnumber)%numberOfProjectedData
1331 IF(datapointindex > 0 .AND. datapointindex <= numberofdatapoints)
THEN 1332 datapointlocalnumber = decompositiondata%elementDataPoint(elementnumber)%dataIndices(datapointindex)%localNumber
1336 CALL flagerror(localerror,err,error,*999)
1339 CALL flagerror(
"Decomposition topology data points are not associated.",err,error,*999)
1342 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1345 exits(
"DecompositionTopology_ElementDataPointLocalNumberGet")
1347 999
errors(
"DecompositionTopology_ElementDataPointLocalNumberGet",err,error)
1348 exits(
"DecompositionTopology_ElementDataPointLocalNumberGet")
1350 END SUBROUTINE decompositiontopology_elementdatapointlocalnumberget
1357 SUBROUTINE decompositiontopology_elementdatapointusernumberget(decompositionTopology,userElementNumber,dataPointIndex, &
1358 & datapointusernumber,err,error,*)
1362 INTEGER(INTG),
INTENT(IN) :: userelementnumber
1363 INTEGER(INTG),
INTENT(IN) :: datapointindex
1364 INTEGER(INTG),
INTENT(OUT) :: datapointusernumber
1365 INTEGER(INTG),
INTENT(OUT) :: err
1369 INTEGER(INTG) :: numberofdatapoints,decompositionlocalelementnumber
1370 LOGICAL :: ghostelement,userelementexists
1373 enters(
"DecompositionTopology_ElementDataPointUserNumberGet",err,error,*999)
1375 IF(
ASSOCIATED(decompositiontopology))
THEN 1376 decompositiondata=>decompositiontopology%dataPoints
1377 IF(
ASSOCIATED(decompositiondata))
THEN 1378 CALL decomposition_topology_element_check_exists(decompositiontopology,userelementnumber, &
1379 & userelementexists,decompositionlocalelementnumber,ghostelement,err,error,*999)
1380 IF(userelementexists)
THEN 1381 IF(ghostelement)
THEN 1382 localerror=
"Cannot update by data point for user element "// &
1384 CALL flagerror(localerror,err,error,*999)
1386 numberofdatapoints = decompositiondata%elementDataPoint(decompositionlocalelementnumber)%numberOfProjectedData
1387 IF(datapointindex > 0 .AND. datapointindex <= numberofdatapoints)
THEN 1388 datapointusernumber = decompositiondata%elementDataPoint(decompositionlocalelementnumber)% &
1389 & dataindices(datapointindex)%userNumber
1393 CALL flagerror(localerror,err,error,*999)
1397 localerror=
"The specified user element number of "// &
1399 &
" does not exist." 1400 CALL flagerror(localerror,err,error,*999)
1403 CALL flagerror(
"Decomposition topology data points are not associated.",err,error,*999)
1406 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1409 exits(
"DecompositionTopology_ElementDataPointUserNumberGet")
1411 999
errors(
"DecompositionTopology_ElementDataPointUserNumberGet",err,error)
1412 exits(
"DecompositionTopology_ElementDataPointUserNumberGet")
1415 END SUBROUTINE decompositiontopology_elementdatapointusernumberget
1422 SUBROUTINE decompositiontopology_numberofelementdatapointsget(decompositionTopology,userElementNumber, &
1423 & numberofdatapoints,err,error,*)
1427 INTEGER(INTG),
INTENT(IN) :: userelementnumber
1428 INTEGER(INTG),
INTENT(OUT) :: numberofdatapoints
1429 INTEGER(INTG),
INTENT(OUT) :: err
1433 INTEGER(INTG) :: decompositionlocalelementnumber
1434 LOGICAL :: ghostelement,userelementexists
1437 enters(
"DecompositionTopology_NumberOfElementDataPointsGet",err,error,*999)
1439 IF(
ASSOCIATED(decompositiontopology))
THEN 1440 decompositiondata=>decompositiontopology%dataPoints
1441 IF(
ASSOCIATED(decompositiondata))
THEN 1442 CALL decomposition_topology_element_check_exists(decompositiontopology,userelementnumber, &
1443 & userelementexists,decompositionlocalelementnumber,ghostelement,err,error,*999)
1444 IF(userelementexists)
THEN 1445 IF(ghostelement)
THEN 1446 localerror=
"Cannot update by data point for user element "// &
1448 CALL flagerror(localerror,err,error,*999)
1450 numberofdatapoints = decompositiondata%elementDataPoint(decompositionlocalelementnumber)%numberOfProjectedData
1453 localerror=
"The specified user element number of "// &
1455 &
" does not exist." 1456 CALL flagerror(localerror,err,error,*999)
1459 CALL flagerror(
"Decomposition topology data points are not associated.",err,error,*999)
1462 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1465 exits(
"DecompositionTopology_NumberOfElementDataPointsGet")
1467 999
errors(
"DecompositionTopology_NumberOfElementDataPointsGet",err,error)
1468 exits(
"DecompositionTopology_NumberOfElementDataPointsGet")
1470 END SUBROUTINE decompositiontopology_numberofelementdatapointsget
1477 SUBROUTINE decompositiontopology_datapointcheckexists(decompositionTopology,userDataPointNumber,userDataPointExists, &
1478 & decompositionlocaldatapointnumber,ghostdatapoint,err,error,*)
1482 INTEGER(INTG),
INTENT(IN) :: userdatapointnumber
1483 LOGICAL,
INTENT(OUT) :: userdatapointexists
1484 INTEGER(INTG),
INTENT(OUT) :: decompositionlocaldatapointnumber
1485 LOGICAL,
INTENT(OUT) :: ghostdatapoint
1486 INTEGER(INTG),
INTENT(OUT) :: err
1492 enters(
"DecompositionTopology_DataPointCheckExists",err,error,*999)
1494 userdatapointexists=.false.
1495 decompositionlocaldatapointnumber=0
1496 ghostdatapoint=.false.
1497 IF(
ASSOCIATED(decompositiontopology))
THEN 1498 decompositiondata=>decompositiontopology%dataPoints
1499 IF(
ASSOCIATED(decompositiondata))
THEN 1501 CALL tree_search(decompositiondata%dataPointsTree,userdatapointnumber,treenode,err,error,*999)
1502 IF(
ASSOCIATED(treenode))
THEN 1503 CALL tree_node_value_get(decompositiondata%dataPointsTree,treenode,decompositionlocaldatapointnumber,err,error,*999)
1504 userdatapointexists=.true.
1505 ghostdatapoint=decompositionlocaldatapointnumber>decompositiondata%numberOfDataPoints
1508 CALL flagerror(
"Decomposition data point topology is not associated.",err,error,*999)
1511 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1514 exits(
"DecompositionTopology_DataPointCheckExists")
1516 999
errors(
"DecompositionTopology_DataPointCheckExists",err,error)
1517 exits(
"DecompositionTopology_DataPointCheckExists")
1520 END SUBROUTINE decompositiontopology_datapointcheckexists
1527 SUBROUTINE decomposition_topology_element_check_exists(DECOMPOSITION_TOPOLOGY,USER_ELEMENT_NUMBER,ELEMENT_EXISTS, &
1528 & decomposition_local_element_number,ghost_element,err,error,*)
1532 INTEGER(INTG),
INTENT(IN) :: user_element_number
1533 LOGICAL,
INTENT(OUT) :: element_exists
1534 INTEGER(INTG),
INTENT(OUT) :: decomposition_local_element_number
1535 LOGICAL,
INTENT(OUT) :: ghost_element
1536 INTEGER(INTG),
INTENT(OUT) :: err
1542 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENT_CHECK_EXISTS",err,error,*999)
1544 element_exists=.false.
1545 decomposition_local_element_number=0
1546 ghost_element=.false.
1547 IF(
ASSOCIATED(decomposition_topology))
THEN 1548 decomposition_elements=>decomposition_topology%ELEMENTS
1549 IF(
ASSOCIATED(decomposition_elements))
THEN 1551 CALL tree_search(decomposition_elements%ELEMENTS_TREE,user_element_number,tree_node,err,error,*999)
1552 IF(
ASSOCIATED(tree_node))
THEN 1553 CALL tree_node_value_get(decomposition_elements%ELEMENTS_TREE,tree_node,decomposition_local_element_number,err,error,*999)
1554 element_exists=.true.
1555 ghost_element=decomposition_local_element_number>decomposition_elements%NUMBER_OF_ELEMENTS
1558 CALL flagerror(
"Decomposition topology elements is not associated.",err,error,*999)
1561 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1564 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_CHECK_EXISTS")
1566 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_CHECK_EXISTS",err,error)
1569 END SUBROUTINE decomposition_topology_element_check_exists
1576 SUBROUTINE domaintopology_elementbasisget(domainTopology,userElementNumber, &
1577 & basis,err,error,*)
1581 INTEGER(INTG),
INTENT(IN) :: userelementnumber
1582 TYPE(
basis_type),
POINTER,
INTENT(OUT) :: basis
1583 INTEGER(INTG),
INTENT(OUT) :: err
1588 LOGICAL :: userelementexists,ghostelement
1589 INTEGER(INTG) :: localelementnumber
1591 enters(
"DomainTopology_ElementBasisGet",err,error,*999)
1595 IF(
ASSOCIATED(domaintopology))
THEN 1596 domainelements=>domaintopology%elements
1597 IF(
ASSOCIATED(domainelements))
THEN 1598 decompositiontopology=>domaintopology%domain%decomposition%topology
1599 IF(
ASSOCIATED(decompositiontopology))
THEN 1600 CALL decomposition_topology_element_check_exists(decompositiontopology,userelementnumber, &
1601 & userelementexists,localelementnumber,ghostelement,err,error,*999)
1602 IF(.NOT.userelementexists)
THEN 1603 CALL flagerror(
"The specified user element number of "// &
1605 &
" does not exist in the domain decomposition.",err,error,*999)
1607 basis=>domainelements%elements(localelementnumber)%basis
1609 CALL flagerror(
"Decomposition topology is not associated.",err,error,*999)
1612 CALL flagerror(
"Domain topology elements is not associated.",err,error,*999)
1615 CALL flagerror(
"Domain topology is not associated.",err,error,*999)
1618 exits(
"DomainTopology_ElementBasisGet")
1620 999 errorsexits(
"DomainTopology_ElementBasisGet",err,error)
1623 END SUBROUTINE domaintopology_elementbasisget
1630 SUBROUTINE decomposition_topology_element_finalise(ELEMENT,ERR,ERROR,*)
1634 INTEGER(INTG),
INTENT(OUT) :: err
1637 INTEGER(INTG) :: nic
1639 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENT_FINALISE",err,error,*999)
1641 IF(
ALLOCATED(element%ADJACENT_ELEMENTS))
THEN 1642 DO nic=lbound(element%ADJACENT_ELEMENTS,1),ubound(element%ADJACENT_ELEMENTS,1)
1643 CALL decomposition_adjacent_element_finalise(element%ADJACENT_ELEMENTS(nic),err,error,*999)
1645 DEALLOCATE(element%ADJACENT_ELEMENTS)
1647 IF(
ALLOCATED(element%ELEMENT_LINES))
DEALLOCATE(element%ELEMENT_LINES)
1648 IF(
ALLOCATED(element%ELEMENT_FACES))
DEALLOCATE(element%ELEMENT_FACES)
1650 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_FINALISE")
1652 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_FINALISE",err,error)
1654 END SUBROUTINE decomposition_topology_element_finalise
1661 SUBROUTINE decomposition_topology_element_initialise(ELEMENT,ERR,ERROR,*)
1665 INTEGER(INTG),
INTENT(OUT) :: err
1669 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENT_INITIALISE",err,error,*999)
1671 element%USER_NUMBER=0
1672 element%LOCAL_NUMBER=0
1673 element%GLOBAL_NUMBER=0
1674 element%BOUNDARY_ELEMENT=.false.
1676 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_INITALISE")
1678 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENT_INITALISE",err,error)
1680 END SUBROUTINE decomposition_topology_element_initialise
1687 SUBROUTINE decompositiontopology_elementadjacentelementcalculate(TOPOLOGY,ERR,ERROR,*)
1691 INTEGER(INTG),
INTENT(OUT) :: err
1694 INTEGER(INTG) :: j,ne,ne1,nep1,ni,nic,nn,nn1,nn2,nn3,np,np1,dummy_err,face_xi(2),face_xic(3),node_position_index(4)
1695 INTEGER(INTG) :: xi_direction,direction_index,xi_dir_check,xi_dir_search,number_node_matches
1696 INTEGER(INTG) :: candidate_idx,face_node_idx,node_idx,surrounding_el_idx,candidate_el,
idx 1697 INTEGER(INTG) :: number_surrounding,number_of_nodes_xic(4),numbersurroundingelements
1698 INTEGER(INTG),
ALLOCATABLE :: node_matches(:),adjacent_elements(:), surroundingelements(:)
1699 LOGICAL :: xi_collapsed,face_collapsed(-3:3),subset
1700 TYPE(
list_type),
POINTER :: node_match_list, surroundingelementslist
1711 NULLIFY(node_match_list)
1713 NULLIFY(adjacent_elements_list(nic)%PTR)
1716 enters(
"DecompositionTopology_ElementAdjacentElementCalculate",err,error,*999)
1718 IF(
ASSOCIATED(topology))
THEN 1719 decomposition=>topology%DECOMPOSITION
1720 IF(
ASSOCIATED(decomposition))
THEN 1721 decomposition_elements=>topology%ELEMENTS
1722 IF(
ASSOCIATED(decomposition_elements))
THEN 1723 domain=>decomposition%DOMAIN(decomposition%MESH_COMPONENT_NUMBER)%PTR
1724 IF(
ASSOCIATED(domain))
THEN 1725 domain_topology=>domain%TOPOLOGY
1726 IF(
ASSOCIATED(domain_topology))
THEN 1727 domain_nodes=>domain_topology%NODES
1728 IF(
ASSOCIATED(domain_nodes))
THEN 1729 domain_elements=>domain_topology%ELEMENTS
1730 IF(
ASSOCIATED(domain_elements))
THEN 1732 DO ne=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
1733 basis=>domain_elements%ELEMENTS(ne)%BASIS
1735 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
1736 NULLIFY(adjacent_elements_list(nic)%PTR)
1742 number_of_nodes_xic=1
1743 number_of_nodes_xic(1:basis%NUMBER_OF_XI_COORDINATES)= &
1744 & basis%NUMBER_OF_NODES_XIC(1:basis%NUMBER_OF_XI_COORDINATES)
1746 CALL list_item_add(adjacent_elements_list(0)%PTR,decomposition_elements%ELEMENTS(ne)%LOCAL_NUMBER, &
1748 SELECT CASE(basis%TYPE)
1752 node_position_index=1
1754 DO ni=1,basis%NUMBER_OF_XI
1759 node_position_index(ni)=1
1761 DO direction_index=-1,1,2
1762 xi_direction=direction_index*ni
1763 face_collapsed(xi_direction)=.false.
1765 xi_dir_check=face_xi(j)
1766 IF(xi_dir_check<=basis%NUMBER_OF_XI)
THEN 1767 xi_dir_search=face_xi(3-j)
1768 node_position_index(xi_dir_search)=1
1770 DO WHILE(node_position_index(xi_dir_search)<=number_of_nodes_xic(xi_dir_search).AND.xi_collapsed)
1772 node_position_index(xi_dir_check)=1
1773 nn1=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2), &
1774 & node_position_index(3),1)
1776 node_position_index(xi_dir_check)=2
1777 nn2=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2), &
1778 & node_position_index(3),1)
1779 IF(nn1/=0.AND.nn2/=0)
THEN 1780 IF(domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn1)/= &
1781 & domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn2)) xi_collapsed=.false.
1783 node_position_index(xi_dir_search)=node_position_index(xi_dir_search)+1
1785 IF(xi_collapsed) face_collapsed(xi_direction)=.true.
1788 node_position_index(ni)=number_of_nodes_xic(ni)
1792 DO ni=1,basis%NUMBER_OF_XI
1797 DO direction_index=-1,1,2
1798 xi_direction=direction_index*ni
1800 NULLIFY(node_match_list)
1805 IF(direction_index==-1)
THEN 1806 node_position_index(ni)=1
1808 node_position_index(ni)=number_of_nodes_xic(ni)
1813 IF(face_collapsed(xi_direction).AND..NOT.face_collapsed(-xi_direction))
THEN 1817 SELECT CASE(basis%NUMBER_OF_XI)
1819 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),1,1,1)
1821 np=domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn)
1825 DO nn1=1,number_of_nodes_xic(face_xi(1)),number_of_nodes_xic(face_xi(1))-1
1826 node_position_index(face_xi(1))=nn1
1827 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2),1,1)
1829 np=domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn)
1834 DO nn1=1,number_of_nodes_xic(face_xi(1)),number_of_nodes_xic(face_xi(1))-1
1835 node_position_index(face_xi(1))=nn1
1836 DO nn2=1,number_of_nodes_xic(face_xi(2)),number_of_nodes_xic(face_xi(2))-1
1837 node_position_index(face_xi(2))=nn2
1838 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2), &
1839 & node_position_index(3),1)
1841 np=domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn)
1847 local_error=
"The number of xi directions in the basis of "// &
1849 CALL flagerror(local_error,err,error,*999)
1854 number_surrounding=0
1855 IF(number_node_matches>0)
THEN 1860 NULLIFY(surroundingelementslist)
1865 DO face_node_idx=1,number_node_matches
1867 node_idx=node_matches(face_node_idx)
1868 DO surrounding_el_idx=1,domain_nodes%NODES(node_idx)%NUMBER_OF_SURROUNDING_ELEMENTS
1869 candidate_el=domain_nodes%NODES(node_idx)%SURROUNDING_ELEMENTS(surrounding_el_idx)
1870 IF(candidate_el/=ne)
THEN 1871 candidate_idx=candidate_idx+1
1872 CALL list_item_add(surroundingelementslist,candidate_el,err,error,*999)
1878 DO idx=1,candidate_idx
1879 ne1=surroundingelements(
idx)
1880 IF(count(surroundingelements(1:numbersurroundingelements)==ne1)>=basis%NUMBER_OF_XI)
THEN 1882 CALL list_item_add(adjacent_elements_list(xi_direction)%PTR,ne1,err,error,*999)
1883 number_surrounding=number_surrounding+1
1888 IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
1889 IF(
ALLOCATED(surroundingelements))
DEALLOCATE(surroundingelements)
1894 DO nic=1,basis%NUMBER_OF_XI_COORDINATES
1900 NULLIFY(node_match_list)
1905 node_position_index(nic)=1
1907 DO nn1=1,number_of_nodes_xic(face_xic(1))
1908 node_position_index(face_xic(1))=nn1
1909 DO nn2=1,number_of_nodes_xic(face_xic(2))
1910 node_position_index(face_xic(2))=nn2
1911 DO nn3=1,number_of_nodes_xic(face_xic(3))
1912 node_position_index(face_xic(3))=nn3
1913 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2), &
1914 & node_position_index(3),node_position_index(4))
1916 np=domain_elements%ELEMENTS(ne)%ELEMENT_NODES(nn)
1924 IF(number_node_matches>0)
THEN 1926 DO node_idx=1,number_node_matches
1927 np1=node_matches(node_idx)
1928 DO nep1=1,domain_nodes%NODES(np1)%NUMBER_OF_SURROUNDING_ELEMENTS
1929 ne1=domain_nodes%NODES(np1)%SURROUNDING_ELEMENTS(nep1)
1935 CALL list_subset_of(node_matches(1:number_node_matches),domain_elements%ELEMENTS(ne1)% &
1936 & element_nodes,subset,err,error,*999)
1938 CALL list_item_add(adjacent_elements_list(nic)%PTR,ne1,err,error,*999)
1944 IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
1947 CALL flagerror(
"Not implemented.",err,error,*999)
1949 CALL flagerror(
"Not implemented.",err,error,*999)
1951 CALL flagerror(
"Not implemented.",err,error,*999)
1953 CALL flagerror(
"Not implemented.",err,error,*999)
1955 CALL flagerror(
"Not implemented.",err,error,*999)
1959 CALL flagerror(local_error,err,error,*999)
1962 ALLOCATE(decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(-basis%NUMBER_OF_XI_COORDINATES: &
1963 basis%NUMBER_OF_XI_COORDINATES),stat=err)
1964 IF(err/=0)
CALL flagerror(
"Could not allocate adjacent elements.",err,error,*999)
1965 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
1966 CALL decomposition_adjacent_element_initialise(decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic), &
1969 & adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS,adjacent_elements,err,error,*999)
1970 ALLOCATE(decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%ADJACENT_ELEMENTS( &
1971 decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS),stat=err)
1972 IF(err/=0)
CALL flagerror(
"Could not allocate element adjacent elements.",err,error,*999)
1973 decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%ADJACENT_ELEMENTS(1: &
1974 & decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS)= &
1975 adjacent_elements(1:decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS)
1976 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
1980 CALL flagerror(
"Domain topology elements is not associated.",err,error,*999)
1983 CALL flagerror(
"Domain topology nodes is not associated.",err,error,*999)
1986 CALL flagerror(
"Topology decomposition domain topology is not associated.",err,error,*999)
1989 CALL flagerror(
"Topology decomposition domain is not associated.",err,error,*999)
1992 CALL flagerror(
"Topology elements is not associated.",err,error,*999)
1995 CALL flagerror(
"Topology decomposition is not associated.",err,error,*999)
1998 CALL flagerror(
"Topology is not allocated.",err,error,*999)
2003 & total_number_of_elements,err,error,*999)
2004 DO ne=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
2005 basis=>domain_elements%ELEMENTS(ne)%BASIS
2009 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
2012 & decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS,err,error,*999)
2013 IF(decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS>0)
THEN 2015 & adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS,8,8,decomposition_elements%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)% &
2016 & adjacent_elements,
'(" Adjacent elements :",8(X,I6))',
'(30x,8(X,I6))',err,error,*999)
2022 exits(
"DecompositionTopology_ElementAdjacentElementCalculate")
2024 999
IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
2025 IF(
ALLOCATED(surroundingelements))
DEALLOCATE(surroundingelements)
2026 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
2027 IF(
ASSOCIATED(node_match_list))
CALL list_destroy(node_match_list,dummy_err,dummy_error,*998)
2028 998
IF(
ASSOCIATED(surroundingelementslist))
CALL list_destroy(surroundingelementslist,dummy_err,dummy_error,*997)
2030 IF(
ASSOCIATED(adjacent_elements_list(nic)%PTR))
CALL list_destroy(adjacent_elements_list(nic)%PTR,dummy_err,dummy_error,*996)
2032 996
errors(
"DecompositionTopology_ElementAdjacentElementCalculate",err,error)
2033 exits(
"DecompositionTopology_ElementAdjacentElementCalculate")
2036 END SUBROUTINE decompositiontopology_elementadjacentelementcalculate
2043 SUBROUTINE decomposition_topology_elements_calculate(TOPOLOGY,ERR,ERROR,*)
2047 INTEGER(INTG),
INTENT(OUT) :: err
2050 INTEGER(INTG) :: global_element,insert_status,local_element
2062 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_CALCULATE",err,error,*999)
2064 IF(
ASSOCIATED(topology))
THEN 2065 decomposition_elements=>topology%ELEMENTS
2066 IF(
ASSOCIATED(decomposition_elements))
THEN 2067 decomposition=>topology%DECOMPOSITION
2068 IF(
ASSOCIATED(decomposition))
THEN 2069 domain=>decomposition%DOMAIN(decomposition%MESH_COMPONENT_NUMBER)%PTR
2070 IF(
ASSOCIATED(domain))
THEN 2071 domain_topology=>domain%TOPOLOGY
2072 IF(
ASSOCIATED(domain_topology))
THEN 2073 domain_elements=>domain_topology%ELEMENTS
2074 IF(
ASSOCIATED(domain_elements))
THEN 2078 IF(
ASSOCIATED(domain_elements_mapping))
THEN 2079 mesh=>decomposition%MESH
2080 IF(
ASSOCIATED(mesh))
THEN 2081 mesh_topology=>mesh%TOPOLOGY(decomposition%MESH_COMPONENT_NUMBER)%PTR
2082 IF(
ASSOCIATED(mesh_topology))
THEN 2083 mesh_elements=>mesh_topology%ELEMENTS
2084 IF(
ASSOCIATED(mesh_elements))
THEN 2086 ALLOCATE(decomposition_elements%ELEMENTS(domain_elements%TOTAL_NUMBER_OF_ELEMENTS),stat=err)
2087 IF(err/=0)
CALL flagerror(
"Could not allocate decomposition elements elements.",err,error,*999)
2088 decomposition_elements%NUMBER_OF_ELEMENTS=domain_elements%NUMBER_OF_ELEMENTS
2089 decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS=domain_elements%TOTAL_NUMBER_OF_ELEMENTS
2090 decomposition_elements%NUMBER_OF_GLOBAL_ELEMENTS=domain_elements%NUMBER_OF_GLOBAL_ELEMENTS
2094 DO local_element=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
2095 CALL decomposition_topology_element_initialise(decomposition_elements%ELEMENTS(local_element), &
2097 global_element=domain_elements_mapping%LOCAL_TO_GLOBAL_MAP(local_element)
2098 decomposition_elements%ELEMENTS(local_element)%USER_NUMBER=mesh_elements%ELEMENTS(global_element)% &
2100 decomposition_elements%ELEMENTS(local_element)%LOCAL_NUMBER=local_element
2101 CALL tree_item_insert(decomposition_elements%ELEMENTS_TREE,decomposition_elements% &
2102 & elements(local_element)%USER_NUMBER,local_element,insert_status,err,error,*999)
2103 decomposition_elements%ELEMENTS(local_element)%GLOBAL_NUMBER=global_element
2104 decomposition_elements%ELEMENTS(local_element)%BOUNDARY_ELEMENT=mesh_elements% &
2105 & elements(global_element)%BOUNDARY_ELEMENT
2108 CALL decompositiontopology_elementadjacentelementcalculate(topology,err,error,*999)
2110 CALL flagerror(
"Mesh elements is not associated.",err,error,*999)
2113 CALL flagerror(
"Mesh topology is not associated.",err,error,*999)
2116 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
2119 CALL flagerror(
"Domain mappings elements is not associated.",err,error,*999)
2122 CALL flagerror(
"Domain mappings is not associated.",err,error,*999)
2125 CALL flagerror(
"Domain topology elements is not associated.",err,error,*999)
2128 CALL flagerror(
"Topology decomposition domain topology is not associated.",err,error,*999)
2131 CALL flagerror(
"Topology decomposition domain is not associated.",err,error,*999)
2134 CALL flagerror(
"Topology decomposition is not associated.",err,error,*999)
2137 CALL flagerror(
"Topology elements is not associated.",err,error,*999)
2140 CALL flagerror(
"Topology is not associated.",err,error,*999)
2143 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_CALCULATE")
2145 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_CALCULATE",err,error)
2147 END SUBROUTINE decomposition_topology_elements_calculate
2154 SUBROUTINE decomposition_topology_elements_finalise(TOPOLOGY,ERR,ERROR,*)
2158 INTEGER(INTG),
INTENT(OUT) :: err
2163 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_FINALISE",err,error,*999)
2165 IF(
ASSOCIATED(topology))
THEN 2166 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 2167 DO ne=1,topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS
2168 CALL decomposition_topology_element_finalise(topology%ELEMENTS%ELEMENTS(ne),err,error,*999)
2170 IF(
ASSOCIATED(topology%ELEMENTS%ELEMENTS))
DEALLOCATE(topology%ELEMENTS%ELEMENTS)
2171 IF(
ASSOCIATED(topology%ELEMENTS%ELEMENTS_TREE))
CALL tree_destroy(topology%ELEMENTS%ELEMENTS_TREE,err,error,*999)
2172 DEALLOCATE(topology%ELEMENTS)
2175 CALL flagerror(
"Topology is not associated.",err,error,*999)
2178 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_FINALISE")
2180 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_FINALISE",err,error)
2182 END SUBROUTINE decomposition_topology_elements_finalise
2189 SUBROUTINE decomposition_topology_elements_initialise(TOPOLOGY,ERR,ERROR,*)
2193 INTEGER(INTG),
INTENT(OUT) :: err
2197 enters(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_INITIALISE",err,error,*999)
2199 IF(
ASSOCIATED(topology))
THEN 2200 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 2201 CALL flagerror(
"Decomposition already has topology elements associated.",err,error,*999)
2203 ALLOCATE(topology%ELEMENTS,stat=err)
2204 IF(err/=0)
CALL flagerror(
"Could not allocate topology elements.",err,error,*999)
2205 topology%ELEMENTS%NUMBER_OF_ELEMENTS=0
2206 topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS=0
2207 topology%ELEMENTS%NUMBER_OF_GLOBAL_ELEMENTS=0
2208 topology%ELEMENTS%DECOMPOSITION=>topology%DECOMPOSITION
2209 NULLIFY(topology%ELEMENTS%ELEMENTS)
2210 NULLIFY(topology%ELEMENTS%ELEMENTS_TREE)
2213 CALL flagerror(
"Topology is not associated.",err,error,*999)
2216 exits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_INITIALISE")
2218 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_ELEMENTS_INITIALISE",err,error)
2220 END SUBROUTINE decomposition_topology_elements_initialise
2227 SUBROUTINE decomposition_topology_finalise(DECOMPOSITION,ERR,ERROR,*)
2231 INTEGER(INTG),
INTENT(OUT) :: err
2235 enters(
"DECOMPOSITION_TOPOLOGY_FINALISE",err,error,*999)
2237 IF(
ASSOCIATED(decomposition))
THEN 2238 CALL decomposition_topology_elements_finalise(decomposition%TOPOLOGY,err,error,*999)
2239 IF(decomposition%CALCULATE_LINES)
THEN 2240 CALL decomposition_topology_lines_finalise(decomposition%TOPOLOGY,err,error,*999)
2242 IF(decomposition%CALCULATE_FACES)
THEN 2243 CALL decomposition_topology_faces_finalise(decomposition%TOPOLOGY,err,error,*999)
2245 DEALLOCATE(decomposition%TOPOLOGY)
2247 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
2250 exits(
"DECOMPOSITION_TOPOLOGY_FINALISE")
2252 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_FINALISE",err,error)
2255 END SUBROUTINE decomposition_topology_finalise
2262 SUBROUTINE decomposition_topology_initialise(DECOMPOSITION,ERR,ERROR,*)
2266 INTEGER(INTG),
INTENT(OUT) :: err
2269 INTEGER(INTG) :: meshcomponentnumber
2271 enters(
"DECOMPOSITION_TOPOLOGY_INITIALISE",err,error,*999)
2273 IF(
ASSOCIATED(decomposition))
THEN 2274 IF(
ASSOCIATED(decomposition%TOPOLOGY))
THEN 2275 CALL flagerror(
"Decomposition already has topology associated.",err,error,*999)
2278 ALLOCATE(decomposition%TOPOLOGY,stat=err)
2279 IF(err/=0)
CALL flagerror(
"Decomposition topology could not be allocated.",err,error,*999)
2280 decomposition%TOPOLOGY%DECOMPOSITION=>decomposition
2281 NULLIFY(decomposition%TOPOLOGY%ELEMENTS)
2282 NULLIFY(decomposition%TOPOLOGY%LINES)
2283 NULLIFY(decomposition%TOPOLOGY%FACES)
2284 NULLIFY(decomposition%TOPOLOGY%dataPoints)
2286 CALL decomposition_topology_elements_initialise(decomposition%TOPOLOGY,err,error,*999)
2287 IF(decomposition%CALCULATE_LINES)
THEN 2288 CALL decomposition_topology_lines_initialise(decomposition%TOPOLOGY,err,error,*999)
2290 IF(decomposition%CALCULATE_FACES)
THEN 2291 CALL decomposition_topology_faces_initialise(decomposition%TOPOLOGY,err,error,*999)
2293 meshcomponentnumber=decomposition%MESH_COMPONENT_NUMBER
2294 IF(
ALLOCATED(decomposition%MESH%TOPOLOGY(meshcomponentnumber)%PTR%dataPoints%dataPoints))
THEN 2295 CALL decompositiontopology_datapointsinitialise(decomposition%TOPOLOGY,err,error,*999)
2299 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
2302 exits(
"DECOMPOSITION_TOPOLOGY_INITIALISE")
2304 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_INITIALISE",err,error)
2306 END SUBROUTINE decomposition_topology_initialise
2313 SUBROUTINE decomposition_topology_line_finalise(LINE,ERR,ERROR,*)
2317 INTEGER(INTG),
INTENT(OUT) :: err
2321 enters(
"DECOMPOSITION_TOPOLOGY_LINE_FINALISE",err,error,*999)
2325 line%NUMBER_OF_SURROUNDING_ELEMENTS=0
2326 IF(
ALLOCATED(line%SURROUNDING_ELEMENTS))
DEALLOCATE(line%SURROUNDING_ELEMENTS)
2327 IF(
ALLOCATED(line%ELEMENT_LINES))
DEALLOCATE(line%ELEMENT_LINES)
2328 line%ADJACENT_LINES=0
2330 exits(
"DECOMPOSITION_TOPOLOGY_LINE_FINALISE")
2332 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_LINE_FINALISE",err,error)
2334 END SUBROUTINE decomposition_topology_line_finalise
2341 SUBROUTINE decomposition_topology_line_initialise(LINE,ERR,ERROR,*)
2345 INTEGER(INTG),
INTENT(OUT) :: err
2349 enters(
"DECOMPOSITION_TOPOLOGY_LINE_INITIALISE",err,error,*999)
2353 line%NUMBER_OF_SURROUNDING_ELEMENTS=0
2354 line%ADJACENT_LINES=0
2355 line%BOUNDARY_LINE=.false.
2357 exits(
"DECOMPOSITION_TOPOLOGY_LINE_INITIALISE")
2359 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_LINE_INITIALISE",err,error)
2361 END SUBROUTINE decomposition_topology_line_initialise
2368 SUBROUTINE decomposition_topology_lines_calculate(TOPOLOGY,ERR,ERROR,*)
2372 INTEGER(INTG),
INTENT(OUT) :: err
2375 INTEGER(INTG) :: component_idx,element_idx,surrounding_element_idx,basis_local_line_idx, &
2376 & surrounding_element_basis_local_line_idx,element_local_node_idx,basis_local_line_node_idx,derivative_idx,version_idx, &
2377 & local_line_idx,surrounding_element_local_line_idx,node_idx,local_node_idx,elem_idx,line_end_node_idx,basis_node_idx, &
2378 & NODES_IN_LINE(4),NUMBER_OF_LINES,MAX_NUMBER_OF_LINES,NEW_MAX_NUMBER_OF_LINES,LINE_NUMBER,COUNT
2379 INTEGER(INTG),
ALLOCATABLE :: nodes_number_of_lines(:)
2380 INTEGER(INTG),
POINTER :: temp_lines(:,:),new_temp_lines(:,:)
2381 REAL(DP) :: approx_dimension
2400 NULLIFY(new_temp_lines)
2402 enters(
"DECOMPOSITION_TOPOLOGY_LINES_CALCULATE",err,error,*999)
2404 IF(
ASSOCIATED(topology))
THEN 2405 decomposition_lines=>topology%LINES
2406 IF(
ASSOCIATED(decomposition_lines))
THEN 2407 decomposition_elements=>topology%ELEMENTS
2408 IF(
ASSOCIATED(decomposition_elements))
THEN 2409 decomposition=>topology%DECOMPOSITION
2410 IF(
ASSOCIATED(decomposition))
THEN 2413 domain=>decomposition%DOMAIN(decomposition%MESH_COMPONENT_NUMBER)%PTR
2414 IF(
ASSOCIATED(domain))
THEN 2415 domain_topology=>domain%TOPOLOGY
2416 IF(
ASSOCIATED(domain_topology))
THEN 2417 domain_nodes=>domain_topology%NODES
2418 IF(
ASSOCIATED(domain_nodes))
THEN 2419 domain_elements=>domain_topology%ELEMENTS
2420 IF(
ASSOCIATED(domain_elements))
THEN 2422 SELECT CASE(domain%NUMBER_OF_DIMENSIONS)
2424 max_number_of_lines=domain_elements%TOTAL_NUMBER_OF_ELEMENTS
2426 approx_dimension=sqrt(
REAL(domain_elements%total_number_of_elements,
dp))
2428 max_number_of_lines=nint(3.0_dp*approx_dimension*(approx_dimension+1),
intg)
2431 approx_dimension=
REAL(domain_elements%total_number_of_elements,
dp)**(1.0_dp/3.0_dp)
2432 max_number_of_lines=nint(11.0_dp*approx_dimension*approx_dimension*(approx_dimension+1),
intg)
2434 CALL flagerror(
"Invalid number of dimensions for a topology domain.",err,error,*999)
2436 domain_lines=>domain_topology%LINES
2437 IF(
ASSOCIATED(domain_lines))
THEN 2438 ALLOCATE(temp_lines(4,max_number_of_lines),stat=err)
2439 IF(err/=0)
CALL flagerror(
"Could not allocate temporary lines array.",err,error,*999)
2440 ALLOCATE(nodes_number_of_lines(domain_nodes%TOTAL_NUMBER_OF_NODES),stat=err)
2441 IF(err/=0)
CALL flagerror(
"Could not allocate nodes number of lines array.",err,error,*999)
2442 nodes_number_of_lines=0
2446 DO element_idx=1,domain_elements%TOTAL_NUMBER_OF_ELEMENTS
2447 domain_element=>domain_elements%ELEMENTS(element_idx)
2448 decomposition_element=>decomposition_elements%ELEMENTS(element_idx)
2449 basis=>domain_element%BASIS
2450 ALLOCATE(decomposition_element%ELEMENT_LINES(basis%NUMBER_OF_LOCAL_LINES),stat=err)
2451 IF(err/=0)
CALL flagerror(
"Could not allocate element element lines.",err,error,*999)
2453 DO basis_local_line_idx=1,basis%NUMBER_OF_LOCAL_LINES
2456 DO basis_local_line_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)
2457 nodes_in_line(basis_local_line_node_idx)=domain_element%ELEMENT_NODES( &
2458 & basis%NODE_NUMBERS_IN_LOCAL_LINE(basis_local_line_node_idx,basis_local_line_idx))
2462 node_idx=nodes_in_line(1)
2463 DO elem_idx=1,domain_nodes%NODES(node_idx)%NUMBER_OF_SURROUNDING_ELEMENTS
2464 surrounding_element_idx=domain_nodes%NODES(node_idx)%SURROUNDING_ELEMENTS(elem_idx)
2465 IF(surrounding_element_idx/=element_idx)
THEN 2466 IF(
ALLOCATED(decomposition_elements%ELEMENTS(surrounding_element_idx)%ELEMENT_LINES))
THEN 2467 basis2=>domain_elements%ELEMENTS(surrounding_element_idx)%BASIS
2468 DO surrounding_element_basis_local_line_idx=1,basis2%NUMBER_OF_LOCAL_LINES
2469 local_line_idx=decomposition_elements%ELEMENTS(surrounding_element_idx)% &
2470 & element_lines(surrounding_element_basis_local_line_idx)
2471 IF(all(nodes_in_line(1:basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx))== &
2472 & temp_lines(1:basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx),local_line_idx)))
THEN 2483 decomposition_element%ELEMENT_LINES(basis_local_line_idx)=local_line_idx
2486 IF(number_of_lines==max_number_of_lines)
THEN 2488 new_max_number_of_lines=nint(1.20_dp*
REAL(MAX_NUMBER_OF_LINES,DP),
intg)
2489 ALLOCATE(new_temp_lines(4,new_max_number_of_lines),stat=err)
2490 IF(err/=0)
CALL flagerror(
"Could not allocate new number of lines.",err,error,*999)
2491 new_temp_lines(:,1:number_of_lines)=temp_lines(:,1:number_of_lines)
2492 new_temp_lines(:,number_of_lines+1:new_max_number_of_lines)=0
2493 DEALLOCATE(temp_lines)
2494 temp_lines=>new_temp_lines
2495 NULLIFY(new_temp_lines)
2496 max_number_of_lines=new_max_number_of_lines
2498 number_of_lines=number_of_lines+1
2499 temp_lines(:,number_of_lines)=nodes_in_line
2500 decomposition_element%ELEMENT_LINES(basis_local_line_idx)=number_of_lines
2501 DO basis_local_line_node_idx=1,
SIZE(nodes_in_line,1)
2502 IF(nodes_in_line(basis_local_line_node_idx)/=0) &
2503 & nodes_number_of_lines(nodes_in_line(basis_local_line_node_idx))= &
2504 & nodes_number_of_lines(nodes_in_line(basis_local_line_node_idx))+1
2510 DO node_idx=1,domain_nodes%TOTAL_NUMBER_OF_NODES
2511 ALLOCATE(domain_nodes%NODES(node_idx)%NODE_LINES(nodes_number_of_lines(node_idx)),stat=err)
2512 IF(err/=0)
CALL flagerror(
"Could not allocate node lines array.",err,error,*999)
2513 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_LINES=0
2515 DEALLOCATE(nodes_number_of_lines)
2516 ALLOCATE(decomposition_lines%LINES(number_of_lines),stat=err)
2517 IF(err/=0)
CALL flagerror(
"Could not allocate decomposition topology lines.",err,error,*999)
2518 decomposition_lines%NUMBER_OF_LINES=number_of_lines
2519 ALLOCATE(domain_lines%LINES(number_of_lines),stat=err)
2520 IF(err/=0)
CALL flagerror(
"Could not allocate domain topology lines.",err,error,*999)
2521 domain_lines%NUMBER_OF_LINES=number_of_lines
2522 DO local_line_idx=1,domain_lines%NUMBER_OF_LINES
2523 CALL decomposition_topology_line_initialise(decomposition_lines%LINES(local_line_idx),err,error,*999)
2524 CALL domain_topology_line_initialise(domain_lines%LINES(local_line_idx),err,error,*999)
2525 DO basis_local_line_node_idx=1,
SIZE(temp_lines,1)
2526 IF(temp_lines(basis_local_line_node_idx,local_line_idx)/=0)
THEN 2527 node_idx=temp_lines(basis_local_line_node_idx,local_line_idx)
2528 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_LINES=domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_LINES+1
2529 domain_nodes%NODES(node_idx)%NODE_LINES(domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_LINES)= &
2534 DO element_idx=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
2535 decomposition_element=>decomposition_elements%ELEMENTS(element_idx)
2536 domain_element=>domain_elements%ELEMENTS(element_idx)
2537 basis=>domain_element%BASIS
2538 DO basis_local_line_idx=1,basis%NUMBER_OF_LOCAL_LINES
2539 line_number=decomposition_element%ELEMENT_LINES(basis_local_line_idx)
2540 decomposition_line=>decomposition_lines%LINES(line_number)
2541 domain_line=>domain_lines%LINES(line_number)
2542 decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS=decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS+1
2543 IF(.NOT.
ASSOCIATED(domain_line%BASIS))
THEN 2544 decomposition_line%NUMBER=line_number
2545 domain_line%NUMBER=line_number
2546 domain_line%ELEMENT_NUMBER=element_idx
2547 decomposition_line%XI_DIRECTION=basis%LOCAL_LINE_XI_DIRECTION(basis_local_line_idx)
2548 domain_line%BASIS=>basis%LINE_BASES(decomposition_line%XI_DIRECTION)%PTR
2549 ALLOCATE(domain_line%NODES_IN_LINE(basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)),stat=err)
2550 IF(err/=0)
CALL flagerror(
"Could not allocate line nodes in line.",err,error,*999)
2551 ALLOCATE(domain_line%DERIVATIVES_IN_LINE(2,domain_line%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES, &
2552 & basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)),stat=err)
2553 IF(err/=0)
CALL flagerror(
"Could not allocate line derivatives in line.",err,error,*999)
2554 domain_line%NODES_IN_LINE(1:basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx))= &
2555 & temp_lines(1:basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx),line_number)
2556 DO basis_local_line_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)
2558 domain_line%DERIVATIVES_IN_LINE(1,1,basis_local_line_node_idx)=
no_global_deriv 2560 version_idx=domain_element%elementVersions(1,basis%NODE_NUMBERS_IN_LOCAL_LINE( &
2561 & basis_local_line_node_idx,basis_local_line_idx))
2562 domain_line%DERIVATIVES_IN_LINE(2,1,basis_local_line_node_idx)=version_idx
2563 IF(domain_line%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES>1)
THEN 2564 derivative_idx=domain_element%ELEMENT_DERIVATIVES( &
2565 & basis%DERIVATIVE_NUMBERS_IN_LOCAL_LINE(basis_local_line_node_idx,basis_local_line_idx), &
2566 & basis%NODE_NUMBERS_IN_LOCAL_LINE(basis_local_line_node_idx,basis_local_line_idx))
2567 domain_line%DERIVATIVES_IN_LINE(1,2,basis_local_line_node_idx)=derivative_idx
2568 version_idx=domain_element%elementVersions(basis%DERIVATIVE_NUMBERS_IN_LOCAL_LINE( &
2569 & basis_local_line_node_idx,basis_local_line_idx),basis%NODE_NUMBERS_IN_LOCAL_LINE( &
2570 & basis_local_line_node_idx,basis_local_line_idx))
2571 domain_line%DERIVATIVES_IN_LINE(2,2,basis_local_line_node_idx)=version_idx
2577 DEALLOCATE(temp_lines)
2579 DO local_line_idx=1,decomposition_lines%NUMBER_OF_LINES
2580 decomposition_line=>decomposition_lines%LINES(local_line_idx)
2581 domain_line=>domain_lines%LINES(local_line_idx)
2582 basis=>domain_line%BASIS
2583 IF(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS==1)
THEN 2584 decomposition_line%BOUNDARY_LINE=.true.
2585 domain_line%BOUNDARY_LINE=.true.
2588 ALLOCATE(decomposition_line%SURROUNDING_ELEMENTS(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS), &
2590 IF(err/=0)
CALL flagerror(
"Could not allocate line surrounding elements.",err,error,*999)
2591 ALLOCATE(decomposition_line%ELEMENT_LINES(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS), &
2593 IF(err/=0)
CALL flagerror(
"Could not allocate line element lines.",err,error,*999)
2594 decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS=0
2595 decomposition_line%ADJACENT_LINES=0
2597 DO line_end_node_idx=0,1
2599 node_idx=domain_line%NODES_IN_LINE(line_end_node_idx*(basis%NUMBER_OF_NODES-1)+1)
2601 DO elem_idx=1,domain_nodes%NODES(node_idx)%NUMBER_OF_SURROUNDING_ELEMENTS
2602 element_idx=domain_nodes%NODES(node_idx)%SURROUNDING_ELEMENTS(elem_idx)
2603 decomposition_element=>decomposition_elements%ELEMENTS(element_idx)
2604 domain_element=>domain_elements%ELEMENTS(element_idx)
2606 DO basis_local_line_idx=1,domain_element%BASIS%NUMBER_OF_LOCAL_LINES
2607 surrounding_element_local_line_idx=decomposition_element%ELEMENT_LINES(basis_local_line_idx)
2608 IF(surrounding_element_local_line_idx/=local_line_idx)
THEN 2609 decomposition_line2=>decomposition_lines%LINES(surrounding_element_local_line_idx)
2610 domain_line2=>domain_lines%LINES(surrounding_element_local_line_idx)
2611 IF(decomposition_line2%XI_DIRECTION==decomposition_line%XI_DIRECTION)
THEN 2613 basis2=>domain_line2%BASIS
2614 IF(line_end_node_idx==0)
THEN 2615 local_node_idx=domain_line2%NODES_IN_LINE(basis2%NUMBER_OF_NODES)
2617 local_node_idx=domain_line2%NODES_IN_LINE(1)
2619 IF(local_node_idx==node_idx)
THEN 2622 IF(basis2%INTERPOLATION_ORDER(1)==basis%INTERPOLATION_ORDER(1))
THEN 2624 DO basis_node_idx=1,basis%NUMBER_OF_NODES
2625 IF(domain_line2%NODES_IN_LINE(basis_node_idx)== &
2626 & domain_line%NODES_IN_LINE(basis2%NUMBER_OF_NODES-basis_node_idx+1)) &
2629 IF(count<basis%NUMBER_OF_NODES)
THEN 2643 IF(found) decomposition_line%ADJACENT_LINES(line_end_node_idx)=surrounding_element_local_line_idx
2647 DO element_idx=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
2648 decomposition_element=>decomposition_elements%ELEMENTS(element_idx)
2649 domain_element=>domain_elements%ELEMENTS(element_idx)
2650 basis=>domain_element%BASIS
2651 DO basis_local_line_idx=1,basis%NUMBER_OF_LOCAL_LINES
2652 line_number=decomposition_element%ELEMENT_LINES(basis_local_line_idx)
2653 decomposition_line=>decomposition_lines%LINES(line_number)
2654 decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS=decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS+1
2655 decomposition_line%SURROUNDING_ELEMENTS(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS)=element_idx
2656 decomposition_line%ELEMENT_LINES(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS)=basis_local_line_idx
2660 CALL flagerror(
"Domain topology lines is not associated.",err,error,*999)
2663 CALL flagerror(
"Domain topology elements is not associated.",err,error,*999)
2666 CALL flagerror(
"Domain topology nodes is not associated.",err,error,*999)
2669 CALL flagerror(
"Topology decomposition domain topology is not associated.",err,error,*999)
2672 CALL flagerror(
"Topology decomposition domain is not associated.",err,error,*999)
2675 mesh=>decomposition%MESH
2676 IF(
ASSOCIATED(mesh))
THEN 2677 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
2678 IF(component_idx/=decomposition%MESH_COMPONENT_NUMBER)
THEN 2679 domain=>decomposition%DOMAIN(component_idx)%PTR
2680 IF(
ASSOCIATED(domain))
THEN 2681 domain_topology=>domain%TOPOLOGY
2682 IF(
ASSOCIATED(domain_topology))
THEN 2683 domain_nodes=>domain_topology%NODES
2684 IF(
ASSOCIATED(domain_nodes))
THEN 2685 domain_elements=>domain_topology%ELEMENTS
2686 IF(
ASSOCIATED(domain_elements))
THEN 2687 domain_lines=>domain_topology%LINES
2688 IF(
ASSOCIATED(domain_lines))
THEN 2689 ALLOCATE(domain_lines%LINES(decomposition_lines%NUMBER_OF_LINES),stat=err)
2690 IF(err/=0)
CALL flagerror(
"Could not allocate domain lines lines.",err,error,*999)
2691 domain_lines%NUMBER_OF_LINES=decomposition_lines%NUMBER_OF_LINES
2692 ALLOCATE(nodes_number_of_lines(domain_nodes%TOTAL_NUMBER_OF_NODES),stat=err)
2693 IF(err/=0)
CALL flagerror(
"Could not allocate nodes number of lines array.",err,error,*999)
2694 nodes_number_of_lines=0
2696 DO local_line_idx=1,decomposition_lines%NUMBER_OF_LINES
2697 decomposition_line=>decomposition_lines%LINES(local_line_idx)
2698 domain_line=>domain_lines%LINES(local_line_idx)
2699 IF(decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS>0)
THEN 2700 element_idx=decomposition_line%SURROUNDING_ELEMENTS(1)
2701 basis_local_line_idx=decomposition_line%ELEMENT_LINES(1)
2702 CALL domain_topology_line_initialise(domain_lines%LINES(local_line_idx),err,error,*999)
2703 domain_line%NUMBER=local_line_idx
2704 domain_element=>domain_elements%ELEMENTS(element_idx)
2705 basis=>domain_element%BASIS
2706 domain_line%ELEMENT_NUMBER=domain_element%NUMBER
2707 domain_line%BASIS=>basis%LINE_BASES(decomposition_line%XI_DIRECTION)%PTR
2708 ALLOCATE(domain_line%NODES_IN_LINE(basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)), &
2710 IF(err/=0)
CALL flagerror(
"Could not allocate nodes in line.",err,error,*999)
2711 ALLOCATE(domain_line%DERIVATIVES_IN_LINE(2,domain_line%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES, &
2712 & basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)),stat=err)
2713 IF(err/=0)
CALL flagerror(
"Could not allocate derivatives in line.",err,error,*999)
2714 DO basis_local_line_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_LINE(basis_local_line_idx)
2715 element_local_node_idx=basis%NODE_NUMBERS_IN_LOCAL_LINE(basis_local_line_node_idx, &
2716 & basis_local_line_idx)
2717 node_idx=domain_element%ELEMENT_NODES(element_local_node_idx)
2718 domain_line%NODES_IN_LINE(basis_local_line_node_idx)=node_idx
2720 domain_line%DERIVATIVES_IN_LINE(1,1,basis_local_line_node_idx)=
no_global_deriv 2722 version_idx=domain_element%elementVersions(1,basis%NODE_NUMBERS_IN_LOCAL_LINE( &
2723 & basis_local_line_node_idx,basis_local_line_idx))
2724 domain_line%DERIVATIVES_IN_LINE(2,1,basis_local_line_node_idx)=version_idx
2725 IF(domain_line%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES>1)
THEN 2726 derivative_idx=domain_element%ELEMENT_DERIVATIVES(basis%DERIVATIVE_NUMBERS_IN_LOCAL_LINE( &
2727 & basis_local_line_node_idx,basis_local_line_idx),element_local_node_idx)
2728 domain_line%DERIVATIVES_IN_LINE(1,2,basis_local_line_node_idx)=derivative_idx
2729 version_idx=domain_element%elementVersions(basis%DERIVATIVE_NUMBERS_IN_LOCAL_LINE( &
2730 & basis_local_line_node_idx,basis_local_line_idx),basis%NODE_NUMBERS_IN_LOCAL_LINE( &
2731 & basis_local_line_node_idx,basis_local_line_idx))
2732 domain_line%DERIVATIVES_IN_LINE(2,2,basis_local_line_node_idx)=version_idx
2734 nodes_number_of_lines(node_idx)=nodes_number_of_lines(node_idx)+1
2737 CALL flagerror(
"Line is not surrounded by any elements?",err,error,*999)
2740 DO node_idx=1,domain_nodes%TOTAL_NUMBER_OF_NODES
2741 ALLOCATE(domain_nodes%NODES(node_idx)%NODE_LINES(nodes_number_of_lines(node_idx)),stat=err)
2742 IF(err/=0)
CALL flagerror(
"Could not allocate node lines.",err,error,*999)
2743 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_LINES=0
2745 DEALLOCATE(nodes_number_of_lines)
2746 DO local_line_idx=1,domain_lines%NUMBER_OF_LINES
2747 domain_line=>domain_lines%LINES(local_line_idx)
2748 basis=>domain_line%BASIS
2749 DO basis_local_line_node_idx=1,basis%NUMBER_OF_NODES
2750 node_idx=domain_line%NODES_IN_LINE(basis_local_line_node_idx)
2751 domain_node=>domain_nodes%NODES(node_idx)
2752 domain_node%NUMBER_OF_NODE_LINES=domain_node%NUMBER_OF_NODE_LINES+1
2753 domain_node%NODE_LINES(domain_node%NUMBER_OF_NODE_LINES)=local_line_idx
2757 CALL flagerror(
"Domain lines is not associated.",err,error,*999)
2760 CALL flagerror(
"Domain elements is not associated.",err,error,*999)
2763 CALL flagerror(
"Domain nodes is not associated.",err,error,*999)
2766 CALL flagerror(
"Domain topology is not associated.",err,error,*999)
2769 CALL flagerror(
"Decomposition mesh is not associated",err,error,*999)
2774 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
2777 CALL flagerror(
"Topology decomposition is not associated.",err,error,*999)
2780 CALL flagerror(
"Topology decomposition elements is not associated.",err,error,*999)
2783 CALL flagerror(
"Topology lines is not associated.",err,error,*999)
2787 CALL flagerror(
"Topology is not associated.",err,error,*999)
2794 DO local_line_idx=1,decomposition_lines%NUMBER_OF_LINES
2795 decomposition_line=>decomposition_lines%LINES(local_line_idx)
2796 domain_line=>domain_lines%LINES(local_line_idx)
2800 & decomposition_line%NUMBER_OF_SURROUNDING_ELEMENTS,err,error,*999)
2802 & decomposition_line%SURROUNDING_ELEMENTS,
'(" Surrounding elements :",4(X,I8))',
'(28X,4(X,I8))',err,error,*999)
2804 & decomposition_line%ELEMENT_LINES,
'(" Element lines :",4(X,I8))',
'(28X,4(X,I8))',err,error,*999)
2806 &
'(" Adjacent lines :",2(X,I8))',
'(28X,2(X,I8))',err,error,*999)
2808 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
2810 domain=>decomposition%DOMAIN(component_idx)%PTR
2811 domain_line=>domain%TOPOLOGY%LINES%LINES(local_line_idx)
2817 & interpolation_type(1),err,error,*999)
2819 & interpolation_order(1),err,error,*999)
2823 &
'(" Nodes in line :",4(X,I8))',
'(30X,4(X,I8))',err,error,*999)
2824 DO basis_local_line_node_idx=1,domain_line%BASIS%NUMBER_OF_NODES
2828 & domain_line%BASIS%NUMBER_OF_DERIVATIVES(basis_local_line_node_idx),4,4, &
2829 & domain_line%DERIVATIVES_IN_LINE(1,:,basis_local_line_node_idx),
'(" Derivatives in line :",4(X,I8))', &
2830 &
'(34X,4(X,I8))',err,error,*999)
2832 & domain_line%BASIS%NUMBER_OF_DERIVATIVES(basis_local_line_node_idx),4,4, &
2833 & domain_line%DERIVATIVES_IN_LINE(2,:,basis_local_line_node_idx), &
2834 &
'(" Derivatives Versions in line :",4(X,I8))',
'(34X,4(X,I8))',err,error,*999)
2840 exits(
"DECOMPOSITION_TOPOLOGY_LINES_CALCULATE")
2842 999
IF(
ASSOCIATED(temp_lines))
DEALLOCATE(temp_lines)
2843 IF(
ASSOCIATED(new_temp_lines))
DEALLOCATE(new_temp_lines)
2844 IF(
ALLOCATED(nodes_number_of_lines))
DEALLOCATE(nodes_number_of_lines)
2845 errorsexits(
"DECOMPOSITION_TOPOLOGY_LINES_CALCULATE",err,error)
2847 END SUBROUTINE decomposition_topology_lines_calculate
2854 SUBROUTINE decomposition_topology_lines_finalise(TOPOLOGY,ERR,ERROR,*)
2858 INTEGER(INTG),
INTENT(OUT) :: err
2863 enters(
"DECOMPOSITION_TOPOLOGY_LINES_FINALISE",err,error,*999)
2865 IF(
ASSOCIATED(topology))
THEN 2866 IF(
ASSOCIATED(topology%LINES))
THEN 2867 DO nl=1,topology%LINES%NUMBER_OF_LINES
2868 CALL decomposition_topology_line_finalise(topology%LINES%LINES(nl),err,error,*999)
2870 IF(
ALLOCATED(topology%LINES%LINES))
DEALLOCATE(topology%LINES%LINES)
2871 DEALLOCATE(topology%LINES)
2874 CALL flagerror(
"Topology is not associated.",err,error,*999)
2877 exits(
"DECOMPOSITION_TOPOLOGY_LINES_FINALISE")
2879 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_LINES_FINALISE",err,error)
2881 END SUBROUTINE decomposition_topology_lines_finalise
2888 SUBROUTINE decomposition_topology_lines_initialise(TOPOLOGY,ERR,ERROR,*)
2892 INTEGER(INTG),
INTENT(OUT) :: err
2896 enters(
"DECOMPOSITION_TOPOLOGY_LINES_INITIALISE",err,error,*999)
2898 IF(
ASSOCIATED(topology))
THEN 2899 IF(
ASSOCIATED(topology%LINES))
THEN 2900 CALL flagerror(
"Decomposition already has topology lines associated.",err,error,*999)
2902 ALLOCATE(topology%LINES,stat=err)
2903 IF(err/=0)
CALL flagerror(
"Could not allocate topology lines.",err,error,*999)
2904 topology%LINES%NUMBER_OF_LINES=0
2905 topology%LINES%DECOMPOSITION=>topology%DECOMPOSITION
2908 CALL flagerror(
"Topology is not associated.",err,error,*999)
2911 exits(
"DECOMPOSITION_TOPOLOGY_LINES_INITIALISE")
2913 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_LINES_INITIALISE",err,error)
2915 END SUBROUTINE decomposition_topology_lines_initialise
2922 SUBROUTINE decompositiontopology_datapointsinitialise(TOPOLOGY,ERR,ERROR,*)
2926 INTEGER(INTG),
INTENT(OUT) :: err
2930 enters(
"DecompositionTopology_DataPointsInitialise",err,error,*999)
2932 IF(
ASSOCIATED(topology))
THEN 2933 IF(
ASSOCIATED(topology%dataPoints))
THEN 2934 CALL flagerror(
"Decomposition already has topology data points associated.",err,error,*999)
2936 ALLOCATE(topology%dataPoints,stat=err)
2937 IF(err/=0)
CALL flagerror(
"Could not allocate topology data points.",err,error,*999)
2938 topology%dataPoints%numberOfDataPoints=0
2939 topology%dataPoints%totalNumberOfDataPoints=0
2940 topology%dataPoints%numberOfGlobalDataPoints=0
2941 NULLIFY(topology%dataPoints%dataPointsTree)
2942 topology%dataPoints%DECOMPOSITION=>topology%DECOMPOSITION
2945 CALL flagerror(
"Topology is not associated.",err,error,*999)
2948 exits(
"DecompositionTopology_DataPointsInitialise")
2950 999 errorsexits(
"DecompositionTopology_DataPointsInitialise",err,error)
2952 END SUBROUTINE decompositiontopology_datapointsinitialise
2959 SUBROUTINE decomposition_topology_face_finalise(FACE,ERR,ERROR,*)
2963 INTEGER(INTG),
INTENT(OUT) :: err
2967 enters(
"DECOMPOSITION_TOPOLOGY_FACE_FINALISE",err,error,*999)
2971 face%NUMBER_OF_SURROUNDING_ELEMENTS=0
2972 IF(
ALLOCATED(face%SURROUNDING_ELEMENTS))
DEALLOCATE(face%SURROUNDING_ELEMENTS)
2973 IF(
ALLOCATED(face%ELEMENT_FACES))
DEALLOCATE(face%ELEMENT_FACES)
2976 exits(
"DECOMPOSITION_TOPOLOGY_FACE_FINALISE")
2978 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_FACE_FINALISE",err,error)
2980 END SUBROUTINE decomposition_topology_face_finalise
2987 SUBROUTINE decomposition_topology_face_initialise(FACE,ERR,ERROR,*)
2991 INTEGER(INTG),
INTENT(OUT) :: err
2995 enters(
"DECOMPOSITION_TOPOLOGY_FACE_INITIALISE",err,error,*999)
2999 face%NUMBER_OF_SURROUNDING_ELEMENTS=0
3001 face%BOUNDARY_FACE=.false.
3003 exits(
"DECOMPOSITION_TOPOLOGY_FACE_INITIALISE")
3005 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_FACE_INITIALISE",err,error)
3007 END SUBROUTINE decomposition_topology_face_initialise
3014 SUBROUTINE decomposition_topology_faces_calculate(TOPOLOGY,ERR,ERROR,*)
3018 INTEGER(INTG),
INTENT(OUT) :: err
3021 INTEGER(INTG) :: component_idx,ne,surrounding_element_idx,basis_local_face_idx,surrounding_element_basis_local_face_idx, &
3022 & element_local_node_idx,basis_local_face_node_idx,basis_local_face_derivative_idx,derivative_idx,version_idx,face_idx, &
3023 & node_idx,elem_idx,NODES_IN_FACE(16),NUMBER_OF_FACES,MAX_NUMBER_OF_FACES,NEW_MAX_NUMBER_OF_FACES,FACE_NUMBER
3024 INTEGER(INTG),
ALLOCATABLE :: nodes_number_of_faces(:)
3025 INTEGER(INTG),
POINTER :: temp_faces(:,:),new_temp_faces(:,:)
3044 NULLIFY(new_temp_faces)
3046 enters(
"DECOMPOSITION_TOPOLOGY_FACES_CALCULATE",err,error,*999)
3048 IF(
ASSOCIATED(topology))
THEN 3049 decomposition_faces=>topology%FACES
3050 IF(
ASSOCIATED(decomposition_faces))
THEN 3051 decomposition_elements=>topology%ELEMENTS
3052 IF(
ASSOCIATED(decomposition_elements))
THEN 3053 decomposition=>topology%DECOMPOSITION
3054 IF(
ASSOCIATED(decomposition))
THEN 3057 domain=>decomposition%DOMAIN(decomposition%MESH_COMPONENT_NUMBER)%PTR
3058 IF(
ASSOCIATED(domain))
THEN 3059 domain_topology=>domain%TOPOLOGY
3060 IF(
ASSOCIATED(domain_topology))
THEN 3061 domain_nodes=>domain_topology%NODES
3062 IF(
ASSOCIATED(domain_nodes))
THEN 3063 domain_elements=>domain_topology%ELEMENTS
3064 IF(
ASSOCIATED(domain_elements))
THEN 3066 SELECT CASE(domain%NUMBER_OF_DIMENSIONS)
3073 max_number_of_faces= &
3074 & nint(((
REAL(domain_elements%total_number_of_elements,
dp)*5.0_dp)+1.0_dp)*(4.0_dp/3.0_dp),
intg)
3076 domain_faces=>domain_topology%FACES
3077 IF(
ASSOCIATED(domain_faces))
THEN 3078 ALLOCATE(temp_faces(16,max_number_of_faces),stat=err)
3079 IF(err/=0)
CALL flagerror(
"Could not allocate temporary faces array",err,error,*999)
3080 ALLOCATE(nodes_number_of_faces(domain_nodes%TOTAL_NUMBER_OF_NODES),stat=err)
3081 IF(err/=0)
CALL flagerror(
"Could not allocate nodes number of faces array",err,error,*999)
3082 nodes_number_of_faces=0
3086 DO ne=1,domain_elements%TOTAL_NUMBER_OF_ELEMENTS
3087 domain_element=>domain_elements%ELEMENTS(ne)
3088 decomposition_element=>decomposition_elements%ELEMENTS(ne)
3089 basis=>domain_element%BASIS
3090 ALLOCATE(decomposition_element%ELEMENT_FACES(basis%NUMBER_OF_LOCAL_FACES),stat=err)
3091 IF(err/=0)
CALL flagerror(
"Could not allocate element faces of element",err,error,*999)
3093 DO basis_local_face_idx=1,basis%NUMBER_OF_LOCAL_FACES
3097 DO basis_local_face_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)
3099 nodes_in_face(basis_local_face_node_idx)=domain_element%ELEMENT_NODES( &
3100 & basis%NODE_NUMBERS_IN_LOCAL_FACE(basis_local_face_node_idx,basis_local_face_idx))
3104 node_idx=nodes_in_face(1)
3105 DO elem_idx=1,domain_nodes%NODES(node_idx)%NUMBER_OF_SURROUNDING_ELEMENTS
3106 surrounding_element_idx=domain_nodes%NODES(node_idx)%SURROUNDING_ELEMENTS(elem_idx)
3107 IF(surrounding_element_idx/=ne)
THEN 3108 IF(
ALLOCATED(decomposition_elements%ELEMENTS(surrounding_element_idx)%ELEMENT_FACES))
THEN 3109 basis2=>domain_elements%ELEMENTS(surrounding_element_idx)%BASIS
3110 DO surrounding_element_basis_local_face_idx=1,basis2%NUMBER_OF_LOCAL_FACES
3111 face_idx=decomposition_elements%ELEMENTS(surrounding_element_idx)%ELEMENT_FACES( &
3112 & surrounding_element_basis_local_face_idx)
3113 IF(all(nodes_in_face(1:basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx))== &
3114 & temp_faces(1:basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx),face_idx)))
THEN 3125 decomposition_element%ELEMENT_FACES(basis_local_face_idx)=face_idx
3128 IF(number_of_faces==max_number_of_faces)
THEN 3130 new_max_number_of_faces=nint(1.20_dp*
REAL(MAX_NUMBER_OF_FACES,DP),
intg)
3132 ALLOCATE(new_temp_faces(16,new_max_number_of_faces),stat=err)
3133 IF(err/=0)
CALL flagerror(
"Could not allocate new number of faces",err,error,*999)
3134 new_temp_faces(:,1:number_of_faces)=temp_faces(:,1:number_of_faces)
3135 new_temp_faces(:,number_of_faces+1:new_max_number_of_faces)=0
3136 DEALLOCATE(temp_faces)
3137 temp_faces=>new_temp_faces
3138 NULLIFY(new_temp_faces)
3139 max_number_of_faces=new_max_number_of_faces
3141 number_of_faces=number_of_faces+1
3142 temp_faces(:,number_of_faces)=nodes_in_face(:)
3143 decomposition_element%ELEMENT_FACES(basis_local_face_idx)=number_of_faces
3144 DO basis_local_face_node_idx=1,
SIZE(nodes_in_face,1)
3145 IF(nodes_in_face(basis_local_face_node_idx)/=0) &
3146 & nodes_number_of_faces(nodes_in_face(basis_local_face_node_idx))= &
3147 & nodes_number_of_faces(nodes_in_face(basis_local_face_node_idx))+1
3154 DO node_idx=1,domain_nodes%TOTAL_NUMBER_OF_NODES
3155 ALLOCATE(domain_nodes%NODES(node_idx)%NODE_FACES(nodes_number_of_faces(node_idx)),stat=err)
3156 IF(err/=0)
CALL flagerror(
"Could not allocate node faces array",err,error,*999)
3157 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_FACES=0
3159 DEALLOCATE(nodes_number_of_faces)
3160 ALLOCATE(decomposition_faces%FACES(number_of_faces),stat=err)
3161 IF(err/=0)
CALL flagerror(
"Could not allocate decomposition topology faces",err,error,*999)
3162 decomposition_faces%NUMBER_OF_FACES=number_of_faces
3163 ALLOCATE(domain_faces%FACES(number_of_faces),stat=err)
3164 IF(err/=0)
CALL flagerror(
"Could not allocate domain topology faces",err,error,*999)
3165 domain_faces%NUMBER_OF_FACES=number_of_faces
3166 DO face_idx=1,domain_faces%NUMBER_OF_FACES
3167 CALL decomposition_topology_face_initialise(decomposition_faces%FACES(face_idx),err,error,*999)
3168 CALL domain_topology_face_initialise(domain_faces%FACES(face_idx),err,error,*999)
3169 DO basis_local_face_node_idx=1,
SIZE(temp_faces,1)
3170 IF(temp_faces(basis_local_face_node_idx,face_idx)/=0)
THEN 3171 node_idx=temp_faces(basis_local_face_node_idx,face_idx)
3172 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_FACES=domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_FACES+1
3173 domain_nodes%NODES(node_idx)%NODE_FACES(domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_FACES)=face_idx
3179 DO ne=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
3180 decomposition_element=>decomposition_elements%ELEMENTS(ne)
3181 domain_element=>domain_elements%ELEMENTS(ne)
3182 basis=>domain_element%BASIS
3184 DO basis_local_face_idx=1,basis%NUMBER_OF_LOCAL_FACES
3185 face_number=decomposition_element%ELEMENT_FACES(basis_local_face_idx)
3186 decomposition_face=>decomposition_faces%FACES(face_number)
3187 domain_face=>domain_faces%FACES(face_number)
3188 decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS=decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS+1
3189 IF(.NOT.
ASSOCIATED(domain_face%BASIS))
THEN 3190 decomposition_face%NUMBER=face_number
3191 domain_face%NUMBER=face_number
3192 domain_face%ELEMENT_NUMBER=ne
3195 decomposition_face%XI_DIRECTION=basis%LOCAL_FACE_XI_DIRECTION(basis_local_face_idx)
3196 domain_face%BASIS=>basis%FACE_BASES(abs(decomposition_face%XI_DIRECTION))%PTR
3197 ALLOCATE(domain_face%NODES_IN_FACE(basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)), &
3199 IF(err/=0)
CALL flagerror(
"Could not allocate face nodes in face",err,error,*999)
3200 ALLOCATE(domain_face%DERIVATIVES_IN_FACE(2,domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES, &
3201 & basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)),stat=err)
3202 IF(err/=0)
CALL flagerror(
"Could not allocate face derivatives in face",err,error,*999)
3203 domain_face%DERIVATIVES_IN_FACE=0
3205 domain_face%NODES_IN_FACE(1:basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx))= &
3206 & temp_faces(1:basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx),face_number)
3208 DO basis_local_face_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)
3209 element_local_node_idx=basis%NODE_NUMBERS_IN_LOCAL_FACE(basis_local_face_node_idx, &
3210 & basis_local_face_idx)
3212 domain_face%DERIVATIVES_IN_FACE(1,1,basis_local_face_node_idx)=
no_global_deriv 3214 version_idx=domain_element%elementVersions(1,basis%NODE_NUMBERS_IN_LOCAL_FACE( &
3215 & basis_local_face_node_idx,basis_local_face_idx))
3216 domain_face%DERIVATIVES_IN_FACE(2,1,basis_local_face_node_idx)=version_idx
3217 IF(domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES>1)
THEN 3218 DO basis_local_face_derivative_idx=2,domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES
3219 derivative_idx=domain_element%ELEMENT_DERIVATIVES(basis%DERIVATIVE_NUMBERS_IN_LOCAL_FACE( &
3220 & basis_local_face_derivative_idx,basis_local_face_node_idx,basis_local_face_idx), &
3221 & element_local_node_idx)
3222 domain_face%DERIVATIVES_IN_FACE(1,basis_local_face_derivative_idx, &
3223 & basis_local_face_node_idx)=derivative_idx
3224 version_idx=domain_element%elementVersions(basis%DERIVATIVE_NUMBERS_IN_LOCAL_FACE( &
3225 & basis_local_face_derivative_idx,basis_local_face_node_idx,basis_local_face_idx), &
3226 & element_local_node_idx)
3227 domain_face%DERIVATIVES_IN_FACE(2,basis_local_face_derivative_idx, &
3228 & basis_local_face_node_idx)=version_idx
3236 DEALLOCATE(temp_faces)
3239 DO face_idx=1,decomposition_faces%NUMBER_OF_FACES
3240 decomposition_face=>decomposition_faces%FACES(face_idx)
3241 domain_face=>domain_faces%FACES(face_idx)
3242 basis=>domain_face%BASIS
3243 IF(decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS==1)
THEN 3244 decomposition_face%BOUNDARY_FACE=.true.
3245 domain_face%BOUNDARY_FACE=.true.
3248 ALLOCATE(decomposition_face%SURROUNDING_ELEMENTS(decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS), &
3250 IF(err/=0)
CALL flagerror(
"Could not allocate face surrounding elements",err,error,*999)
3252 ALLOCATE(decomposition_face%ELEMENT_FACES(decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS), &
3254 IF(err/=0)
CALL flagerror(
"Could not allocate face element faces",err,error,*999)
3308 DO ne=1,decomposition_elements%TOTAL_NUMBER_OF_ELEMENTS
3309 decomposition_element=>decomposition_elements%ELEMENTS(ne)
3310 domain_element=>domain_elements%ELEMENTS(ne)
3311 basis=>domain_element%BASIS
3312 DO basis_local_face_idx=1,basis%NUMBER_OF_LOCAL_FACES
3313 face_number=decomposition_element%ELEMENT_FACES(basis_local_face_idx)
3314 decomposition_face=>decomposition_faces%FACES(face_number)
3315 DO face_idx=1,decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS
3316 decomposition_face%SURROUNDING_ELEMENTS(face_idx)=ne
3317 decomposition_face%ELEMENT_FACES(face_idx)=basis_local_face_idx
3322 CALL flagerror(
"Domain topology faces is not associated",err,error,*999)
3325 CALL flagerror(
"Invalid number of dimensions for a topology domain",err,error,*999)
3328 CALL flagerror(
"Domain topology elements is not associated",err,error,*999)
3331 CALL flagerror(
"Domain topology nodes is not associated",err,error,*999)
3334 CALL flagerror(
"Topology decomposition domain topology is not associated",err,error,*999)
3337 CALL flagerror(
"Topology decomposition domain is not associated",err,error,*999)
3340 mesh=>decomposition%MESH
3341 IF(
ASSOCIATED(mesh))
THEN 3342 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
3343 IF(component_idx/=decomposition%MESH_COMPONENT_NUMBER)
THEN 3344 domain=>decomposition%DOMAIN(component_idx)%PTR
3345 IF(
ASSOCIATED(domain))
THEN 3346 domain_topology=>domain%TOPOLOGY
3347 IF(
ASSOCIATED(domain_topology))
THEN 3348 domain_nodes=>domain_topology%NODES
3349 IF(
ASSOCIATED(domain_nodes))
THEN 3350 domain_elements=>domain_topology%ELEMENTS
3351 IF(
ASSOCIATED(domain_elements))
THEN 3352 domain_faces=>domain_topology%FACES
3353 IF(
ASSOCIATED(domain_faces))
THEN 3354 ALLOCATE(domain_faces%FACES(decomposition_faces%NUMBER_OF_FACES),stat=err)
3355 IF(err/=0)
CALL flagerror(
"Could not allocate domain faces faces",err,error,*999)
3356 domain_faces%NUMBER_OF_FACES=decomposition_faces%NUMBER_OF_FACES
3357 ALLOCATE(nodes_number_of_faces(domain_nodes%TOTAL_NUMBER_OF_NODES),stat=err)
3358 IF(err/=0)
CALL flagerror(
"Could not allocate nodes number of faces array",err,error,*999)
3359 nodes_number_of_faces=0
3361 DO face_idx=1,decomposition_faces%NUMBER_OF_FACES
3362 decomposition_face=>decomposition_faces%FACES(face_idx)
3363 domain_face=>domain_faces%FACES(face_idx)
3364 IF(decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS>0)
THEN 3365 ne=decomposition_face%SURROUNDING_ELEMENTS(1)
3366 basis_local_face_idx=decomposition_face%ELEMENT_FACES(1)
3367 CALL domain_topology_face_initialise(domain_faces%FACES(face_idx),err,error,*999)
3368 domain_face%NUMBER=face_idx
3369 domain_element=>domain_elements%ELEMENTS(ne)
3370 basis=>domain_element%BASIS
3371 domain_face%BASIS=>basis%FACE_BASES(abs(decomposition_face%XI_DIRECTION))%PTR
3372 ALLOCATE(domain_face%NODES_IN_FACE(basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)), &
3374 IF(err/=0)
CALL flagerror(
"Could not allocate nodes in face",err,error,*999)
3375 ALLOCATE(domain_face%DERIVATIVES_IN_FACE(2,domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES, &
3376 & basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)),stat=err)
3377 IF(err/=0)
CALL flagerror(
"Could not allocate derivatives in face",err,error,*999)
3379 DO basis_local_face_node_idx=1,basis%NUMBER_OF_NODES_IN_LOCAL_FACE(basis_local_face_idx)
3380 element_local_node_idx=basis%NODE_NUMBERS_IN_LOCAL_FACE(basis_local_face_node_idx, &
3381 & basis_local_face_idx)
3382 node_idx=domain_element%ELEMENT_NODES(element_local_node_idx)
3383 domain_face%NODES_IN_FACE(basis_local_face_node_idx)=node_idx
3385 domain_face%DERIVATIVES_IN_FACE(1,1,basis_local_face_node_idx)=
no_global_deriv 3387 version_idx=domain_element%elementVersions(1,basis%NODE_NUMBERS_IN_LOCAL_FACE( &
3388 & basis_local_face_node_idx,basis_local_face_idx))
3389 domain_face%DERIVATIVES_IN_FACE(2,1,basis_local_face_node_idx)=version_idx
3390 IF(domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES>1)
THEN 3391 DO basis_local_face_derivative_idx=2,domain_face%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES
3392 derivative_idx=domain_element%ELEMENT_DERIVATIVES(basis%DERIVATIVE_NUMBERS_IN_LOCAL_FACE( &
3393 & basis_local_face_derivative_idx,basis_local_face_node_idx,basis_local_face_idx), &
3394 & element_local_node_idx)
3395 domain_face%DERIVATIVES_IN_FACE(1,basis_local_face_derivative_idx, &
3396 & basis_local_face_node_idx)=derivative_idx
3397 version_idx=domain_element%elementVersions(basis%DERIVATIVE_NUMBERS_IN_LOCAL_FACE( &
3398 & basis_local_face_derivative_idx,basis_local_face_node_idx,basis_local_face_idx), &
3399 & element_local_node_idx)
3400 domain_face%DERIVATIVES_IN_FACE(2,basis_local_face_derivative_idx, &
3401 & basis_local_face_node_idx)=version_idx
3404 nodes_number_of_faces(node_idx)=nodes_number_of_faces(node_idx)+1
3407 CALL flagerror(
"Face is not surrounded by any elements?",err,error,*999)
3410 DO node_idx=1,domain_nodes%TOTAL_NUMBER_OF_NODES
3411 ALLOCATE(domain_nodes%NODES(node_idx)%NODE_FACES(nodes_number_of_faces(node_idx)),stat=err)
3412 IF(err/=0)
CALL flagerror(
"Could not allocate node faces",err,error,*999)
3413 domain_nodes%NODES(node_idx)%NUMBER_OF_NODE_FACES=0
3415 DEALLOCATE(nodes_number_of_faces)
3416 DO face_idx=1,domain_faces%NUMBER_OF_FACES
3417 domain_face=>domain_faces%FACES(face_idx)
3418 basis=>domain_face%BASIS
3419 DO basis_local_face_node_idx=1,basis%NUMBER_OF_NODES
3420 node_idx=domain_face%NODES_IN_FACE(basis_local_face_node_idx)
3421 domain_node=>domain_nodes%NODES(node_idx)
3422 domain_node%NUMBER_OF_NODE_FACES=domain_node%NUMBER_OF_NODE_FACES+1
3424 domain_node%NODE_FACES(domain_node%NUMBER_OF_NODE_FACES)=face_idx
3428 CALL flagerror(
"Domain faces is not associated",err,error,*999)
3431 CALL flagerror(
"Domain elements is not associated",err,error,*999)
3434 CALL flagerror(
"Domain nodes is not associated",err,error,*999)
3437 CALL flagerror(
"Domain topology is not associated",err,error,*999)
3440 CALL flagerror(
"Decomposition mesh is not associated",err,error,*999)
3445 CALL flagerror(
"Decomposition mesh is not associated",err,error,*999)
3448 CALL flagerror(
"Topology decomposition is not associated",err,error,*999)
3451 CALL flagerror(
"Topology decomposition elements is not associated",err,error,*999)
3454 CALL flagerror(
"Topology faces is not associated",err,error,*999)
3457 CALL flagerror(
"Topology is not associated",err,error,*999)
3464 DO face_idx=1,decomposition_faces%NUMBER_OF_FACES
3465 decomposition_face=>decomposition_faces%FACES(face_idx)
3466 domain_face=>domain_faces%FACES(face_idx)
3469 &",decomposition_face%XI_DIRECTION,err,error,*999)
3471 & decomposition_face%NUMBER_OF_SURROUNDING_ELEMENTS,err,error,*999)
3473 & decomposition_face%SURROUNDING_ELEMENTS,
'(" Surrounding elements :",4(X,I8))',
'(28X,4(X,I8))',err,error,*999)
3475 & decomposition_face%ELEMENT_FACES,
'(" Element faces :",4(X,I8))',
'(28X,4(X,I8))',err,error,*999)
3479 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
3481 domain=>decomposition%DOMAIN(component_idx)%PTR
3482 domain_face=>domain%TOPOLOGY%FACES%FACES(face_idx)
3488 & interpolation_type(1),err,error,*999)
3490 & interpolation_order(1),err,error,*999)
3494 &
'(" Nodes in face :",4(X,I8))',
'(30X,4(X,I8))',err,error,*999)
3495 DO basis_local_face_node_idx=1,domain_face%BASIS%NUMBER_OF_NODES
3499 & domain_face%BASIS%NUMBER_OF_DERIVATIVES(basis_local_face_node_idx),4,4,domain_face% &
3500 & derivatives_in_face(1,:,basis_local_face_node_idx),
'(" Derivatives in face :",4(X,I8))', &
3501 &
'(34X,4(X,I8))',err,error,*999)
3503 & domain_face%BASIS%NUMBER_OF_DERIVATIVES(basis_local_face_node_idx),4,4,domain_face% &
3504 & derivatives_in_face(2,:,basis_local_face_node_idx),
'(" Derivatives Versions in face :",4(X,I8))', &
3505 &
'(34X,4(X,I8))',err,error,*999)
3511 exits(
"DECOMPOSITION_TOPOLOGY_FACES_CALCULATE")
3513 999
IF(
ASSOCIATED(temp_faces))
DEALLOCATE(temp_faces)
3514 IF(
ASSOCIATED(new_temp_faces))
DEALLOCATE(new_temp_faces)
3515 IF(
ALLOCATED(nodes_number_of_faces))
DEALLOCATE(nodes_number_of_faces)
3516 errorsexits(
"DECOMPOSITION_TOPOLOGY_FACES_CALCULATE",err,error)
3518 END SUBROUTINE decomposition_topology_faces_calculate
3525 SUBROUTINE decomposition_topology_faces_finalise(TOPOLOGY,ERR,ERROR,*)
3529 INTEGER(INTG),
INTENT(OUT) :: err
3534 enters(
"DECOMPOSITION_TOPOLOGY_FACES_FINALISE",err,error,*999)
3536 IF(
ASSOCIATED(topology))
THEN 3537 IF(
ASSOCIATED(topology%FACES))
THEN 3538 DO nf=1,topology%FACES%NUMBER_OF_FACES
3539 CALL decomposition_topology_face_finalise(topology%FACES%FACES(nf),err,error,*999)
3541 IF(
ALLOCATED(topology%FACES%FACES))
DEALLOCATE(topology%FACES%FACES)
3542 DEALLOCATE(topology%FACES)
3545 CALL flagerror(
"Topology is not associated",err,error,*999)
3548 exits(
"DECOMPOSITION_TOPOLOGY_FACES_FINALISE")
3550 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_FACES_FINALISE",err,error)
3552 END SUBROUTINE decomposition_topology_faces_finalise
3559 SUBROUTINE decomposition_topology_faces_initialise(TOPOLOGY,ERR,ERROR,*)
3563 INTEGER(INTG),
INTENT(OUT) :: err
3567 enters(
"DECOMPOSITION_TOPOLOGY_FACES_INITIALISE",err,error,*999)
3569 IF(
ASSOCIATED(topology))
THEN 3570 IF(
ASSOCIATED(topology%FACES))
THEN 3571 CALL flagerror(
"Decomposition already has topology faces associated",err,error,*999)
3573 ALLOCATE(topology%FACES,stat=err)
3574 IF(err/=0)
CALL flagerror(
"Could not allocate topology faces",err,error,*999)
3575 topology%FACES%NUMBER_OF_FACES=0
3576 topology%FACES%DECOMPOSITION=>topology%DECOMPOSITION
3579 CALL flagerror(
"Topology is not associated",err,error,*999)
3582 exits(
"DECOMPOSITION_TOPOLOGY_FACES_INITIALISE")
3584 999 errorsexits(
"DECOMPOSITION_TOPOLOGY_FACES_INITIALISE",err,error)
3586 END SUBROUTINE decomposition_topology_faces_initialise
3593 SUBROUTINE decomposition_type_get(DECOMPOSITION,TYPE,ERR,ERROR,*)
3597 INTEGER(INTG),
INTENT(OUT) ::
TYPE 3598 INTEGER(INTG),
INTENT(OUT) :: err
3602 enters(
"DECOMPOSITION_TYPE_GET",err,error,*999)
3604 IF(
ASSOCIATED(decomposition))
THEN 3605 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 3606 TYPE=decomposition%DECOMPOSITION_TYPE
3608 CALL flagerror(
"Decomposition has not finished.",err,error,*999)
3611 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3614 exits(
"DECOMPOSITION_TYPE_GET")
3616 999 errorsexits(
"DECOMPOSITION_TYPE_GET",err,error)
3618 END SUBROUTINE decomposition_type_get
3625 SUBROUTINE decomposition_type_set(DECOMPOSITION,TYPE,ERR,ERROR,*)
3629 INTEGER(INTG),
INTENT(IN) ::
TYPE 3630 INTEGER(INTG),
INTENT(OUT) :: err
3635 enters(
"DECOMPOSITION_TYPE_SET",err,error,*999)
3637 IF(
ASSOCIATED(decomposition))
THEN 3638 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 3639 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
3642 CASE(decomposition_all_type)
3644 decomposition%DECOMPOSITION_TYPE=decomposition_all_type
3645 CASE(decomposition_calculated_type)
3646 decomposition%DECOMPOSITION_TYPE=decomposition_calculated_type
3647 CASE(decomposition_user_defined_type)
3648 decomposition%DECOMPOSITION_TYPE=decomposition_user_defined_type
3651 CALL flagerror(local_error,err,error,*999)
3655 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3658 exits(
"DECOMPOSITION_TYPE_SET")
3660 999 errorsexits(
"DECOMPOSITION_TYPE_SET",err,error)
3662 END SUBROUTINE decomposition_type_set
3669 SUBROUTINE decomposition_calculate_lines_set(DECOMPOSITION,CALCULATE_LINES_FLAG,ERR,ERROR,*)
3673 LOGICAL,
INTENT(IN) :: calculate_lines_flag
3674 INTEGER(INTG),
INTENT(OUT) :: err
3677 enters(
"DECOMPOSITION_CALCULATE_LINES_SET",err,error,*999)
3679 IF(
ASSOCIATED(decomposition))
THEN 3680 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 3681 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
3683 decomposition%CALCULATE_LINES=calculate_lines_flag
3686 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3689 exits(
"DECOMPOSITION_CALCULATE_LINES_SET")
3691 999 errorsexits(
"DECOMPOSITION_CALCULATE_LINES_SET",err,error)
3693 END SUBROUTINE decomposition_calculate_lines_set
3700 SUBROUTINE decomposition_calculate_faces_set(DECOMPOSITION,CALCULATE_FACES_FLAG,ERR,ERROR,*)
3704 LOGICAL,
INTENT(IN) :: calculate_faces_flag
3705 INTEGER(INTG),
INTENT(OUT) :: err
3708 enters(
"DECOMPOSITION_CALCULATE_FACES_SET",err,error,*999)
3710 IF(
ASSOCIATED(decomposition))
THEN 3711 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 3712 CALL flagerror(
"Decomposition has been finished.",err,error,*999)
3714 decomposition%CALCULATE_FACES=calculate_faces_flag
3717 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3720 exits(
"DECOMPOSITION_CALCULATE_FACES_SET")
3722 999 errorsexits(
"DECOMPOSITION_CALCULATE_FACES_SET",err,error)
3724 END SUBROUTINE decomposition_calculate_faces_set
3731 SUBROUTINE decomposition_user_number_find(USER_NUMBER,MESH,DECOMPOSITION,ERR,ERROR,*)
3734 INTEGER(INTG),
INTENT(IN) :: user_number
3737 INTEGER(INTG),
INTENT(OUT) :: err
3740 INTEGER(INTG) :: decomposition_idx
3743 enters(
"DECOMPOSITION_USER_NUMBER_FIND",err,error,*999)
3745 NULLIFY(decomposition)
3746 IF(
ASSOCIATED(mesh))
THEN 3747 IF(
ASSOCIATED(mesh%DECOMPOSITIONS))
THEN 3749 DO WHILE(decomposition_idx<=mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS.AND..NOT.
ASSOCIATED(decomposition))
3750 IF(mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR%USER_NUMBER==user_number)
THEN 3751 decomposition=>mesh%DECOMPOSITIONS%DECOMPOSITIONS(decomposition_idx)%PTR
3753 decomposition_idx=decomposition_idx+1
3757 local_error=
"The decompositions on mesh number "//
trim(
number_to_vstring(mesh%USER_NUMBER,
"*",err,error))// &
3758 &
" are not associated." 3759 CALL flagerror(local_error,err,error,*999)
3762 CALL flagerror(
"Mesh is not associated.",err,error,*999)
3765 exits(
"DECOMPOSITION_USER_NUMBER_FIND")
3767 999 errorsexits(
"DECOMPOSITION_USER_NUMBER_FIND",err,error)
3769 END SUBROUTINE decomposition_user_number_find
3776 SUBROUTINE decompositions_finalise(MESH,ERR,ERROR,*)
3780 INTEGER(INTG),
INTENT(OUT) :: err
3784 enters(
"DECOMPOSITIONS_FINALISE",err,error,*999)
3786 IF(
ASSOCIATED(mesh))
THEN 3787 IF(
ASSOCIATED(mesh%DECOMPOSITIONS))
THEN 3788 DO WHILE(mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS>0)
3789 CALL decomposition_destroy(mesh%DECOMPOSITIONS%DECOMPOSITIONS(1)%PTR,err,error,*999)
3791 DEALLOCATE(mesh%DECOMPOSITIONS)
3794 CALL flagerror(
"Mesh is not associated.",err,error,*999)
3797 exits(
"DECOMPOSITIONS_FINALISE")
3799 999 errorsexits(
"DECOMPOSITIONS_FINALISE",err,error)
3801 END SUBROUTINE decompositions_finalise
3808 SUBROUTINE decompositions_initialise(MESH,ERR,ERROR,*)
3813 INTEGER(INTG),
INTENT(OUT) :: err
3817 enters(
"DECOMPOSITIONS_INITIALISE",err,error,*999)
3819 IF(
ASSOCIATED(mesh))
THEN 3820 IF(
ASSOCIATED(mesh%DECOMPOSITIONS))
THEN 3821 CALL flagerror(
"Mesh already has decompositions associated.",err,error,*999)
3823 ALLOCATE(mesh%DECOMPOSITIONS,stat=err)
3824 IF(err/=0)
CALL flagerror(
"Mesh decompositions could not be allocated.",err,error,*999)
3825 mesh%DECOMPOSITIONS%NUMBER_OF_DECOMPOSITIONS=0
3826 NULLIFY(mesh%DECOMPOSITIONS%DECOMPOSITIONS)
3827 mesh%DECOMPOSITIONS%MESH=>mesh
3830 CALL flagerror(
"Mesh is not associated.",err,error,*999)
3833 exits(
"DECOMPOSITIONS_INITIALISE")
3835 999 errorsexits(
"DECOMPOSITIONS_INITIALISE",err,error)
3837 END SUBROUTINE decompositions_initialise
3844 SUBROUTINE domain_finalise(DECOMPOSITION,ERR,ERROR,*)
3848 INTEGER(INTG),
INTENT(OUT) :: err
3851 INTEGER(INTG) :: component_idx
3853 enters(
"DOMAIN_FINALISE",err,error,*999)
3855 IF(
ASSOCIATED(decomposition))
THEN 3856 IF(
ASSOCIATED(decomposition%MESH))
THEN 3857 IF(
ASSOCIATED(decomposition%DOMAIN))
THEN 3858 DO component_idx=1,decomposition%MESH%NUMBER_OF_COMPONENTS
3859 IF(
ALLOCATED(decomposition%DOMAIN(component_idx)%PTR%NODE_DOMAIN)) &
3860 &
DEALLOCATE(decomposition%DOMAIN(component_idx)%PTR%NODE_DOMAIN)
3861 CALL domain_mappings_finalise(decomposition%DOMAIN(component_idx)%PTR,err,error,*999)
3862 CALL domain_topology_finalise(decomposition%DOMAIN(component_idx)%PTR,err,error,*999)
3863 DEALLOCATE(decomposition%DOMAIN(component_idx)%PTR)
3865 DEALLOCATE(decomposition%DOMAIN)
3869 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3872 exits(
"DOMAIN_FINALISE")
3874 999 errorsexits(
"DOMAIN_FINALISE",err,error)
3876 END SUBROUTINE domain_finalise
3883 SUBROUTINE domain_initialise(DECOMPOSITION,ERR,ERROR,*)
3887 INTEGER(INTG),
INTENT(OUT) :: err
3890 INTEGER(INTG) :: component_idx
3892 enters(
"DOMAIN_INITIALISE",err,error,*999)
3894 IF(
ASSOCIATED(decomposition))
THEN 3895 IF(
ASSOCIATED(decomposition%MESH))
THEN 3896 IF(
ASSOCIATED(decomposition%DOMAIN))
THEN 3897 CALL flagerror(
"Decomposition already has a domain associated.",err,error,*999)
3899 ALLOCATE(decomposition%DOMAIN(decomposition%MESH%NUMBER_OF_COMPONENTS),stat=err)
3900 IF(err/=0)
CALL flagerror(
"Decomposition domain could not be allocated.",err,error,*999)
3901 DO component_idx=1,decomposition%MESH%NUMBER_OF_COMPONENTS
3902 ALLOCATE(decomposition%DOMAIN(component_idx)%PTR,stat=err)
3903 IF(err/=0)
CALL flagerror(
"Decomposition domain component could not be allocated.",err,error,*999)
3904 decomposition%DOMAIN(component_idx)%PTR%DECOMPOSITION=>decomposition
3905 decomposition%DOMAIN(component_idx)%PTR%MESH=>decomposition%MESH
3906 decomposition%DOMAIN(component_idx)%PTR%MESH_COMPONENT_NUMBER=component_idx
3907 decomposition%DOMAIN(component_idx)%PTR%REGION=>decomposition%MESH%REGION
3908 decomposition%DOMAIN(component_idx)%PTR%NUMBER_OF_DIMENSIONS=decomposition%MESH%NUMBER_OF_DIMENSIONS
3914 NULLIFY(decomposition%DOMAIN(component_idx)%PTR%MAPPINGS)
3915 NULLIFY(decomposition%DOMAIN(component_idx)%PTR%TOPOLOGY)
3916 CALL domain_mappings_initialise(decomposition%DOMAIN(component_idx)%PTR,err,error,*999)
3917 CALL domain_topology_initialise(decomposition%DOMAIN(component_idx)%PTR,err,error,*999)
3921 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
3924 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
3927 exits(
"DOMAIN_INITIALISE")
3929 999 errorsexits(
"DOMAIN_INITIALISE",err,error)
3931 END SUBROUTINE domain_initialise
3939 SUBROUTINE domain_mappings_dofs_finalise(DOMAIN_MAPPINGS,ERR,ERROR,*)
3943 INTEGER(INTG),
INTENT(OUT) :: err
3947 enters(
"DOMAIN_MAPPINGS_DOFS_FINALISE",err,error,*999)
3954 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
3957 exits(
"DOMAIN_MAPPINGS_DOFS_FINALISE")
3959 999 errorsexits(
"DOMAIN_MAPPINGS_DOFS_FINALISE",err,error)
3962 END SUBROUTINE domain_mappings_dofs_finalise
3969 SUBROUTINE domain_mappings_dofs_initialise(DOMAIN_MAPPINGS,ERR,ERROR,*)
3973 INTEGER(INTG),
INTENT(OUT) :: err
3977 enters(
"DOMAIN_MAPPINGS_DOFS_INITIALISE",err,error,*999)
3981 CALL flagerror(
"Domain dofs mappings are already associated.",err,error,*999)
3984 IF(err/=0)
CALL flagerror(
"Could not allocate domain mappings dofs.",err,error,*999)
3989 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
3992 exits(
"DOMAIN_MAPPINGS_DOFS_INITIALISE")
3994 999 errorsexits(
"DOMAIN_MAPPINGS_DOFS_INITIALISE",err,error)
3997 END SUBROUTINE domain_mappings_dofs_initialise
4004 SUBROUTINE domain_mappings_elements_calculate(DOMAIN,ERR,ERROR,*)
4008 INTEGER(INTG),
INTENT(OUT) :: err
4011 INTEGER(INTG) :: dummy_err,no_adjacent_element,adjacent_element,domain_no,domain_idx,ne,nn,np,number_of_domains, &
4012 & NUMBER_OF_ADJACENT_ELEMENTS,my_computational_node_number,component_idx
4013 INTEGER(INTG),
ALLOCATABLE :: adjacent_elements(:),domains(:),local_element_numbers(:)
4014 TYPE(
list_type),
POINTER :: adjacent_domains_list
4015 TYPE(
list_ptr_type),
ALLOCATABLE :: adjacent_elements_list(:)
4022 enters(
"DOMAIN_MAPPINGS_ELEMENTS_CALCULATE",err,error,*999)
4024 IF(
ASSOCIATED(domain))
THEN 4025 IF(
ASSOCIATED(domain%MAPPINGS))
THEN 4026 IF(
ASSOCIATED(domain%MAPPINGS%ELEMENTS))
THEN 4027 elements_mapping=>domain%MAPPINGS%ELEMENTS
4028 IF(
ASSOCIATED(domain%DECOMPOSITION))
THEN 4029 decomposition=>domain%DECOMPOSITION
4030 IF(
ASSOCIATED(domain%MESH))
THEN 4032 component_idx=domain%MESH_COMPONENT_NUMBER
4037 ALLOCATE(elements_mapping%GLOBAL_TO_LOCAL_MAP(mesh%NUMBER_OF_ELEMENTS),stat=err)
4038 IF(err/=0)
CALL flagerror(
"Could not allocate element mapping global to local map.",err,error,*999)
4039 elements_mapping%NUMBER_OF_GLOBAL=mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%NUMBER_OF_ELEMENTS
4041 ALLOCATE(local_element_numbers(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4042 IF(err/=0)
CALL flagerror(
"Could not allocate local element numbers.",err,error,*999)
4043 local_element_numbers=0
4044 ALLOCATE(adjacent_elements_list(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4045 IF(err/=0)
CALL flagerror(
"Could not allocate adjacent elements list.",err,error,*999)
4046 DO domain_idx=0,decomposition%NUMBER_OF_DOMAINS-1
4047 NULLIFY(adjacent_elements_list(domain_idx)%PTR)
4050 CALL list_initial_size_set(adjacent_elements_list(domain_idx)%PTR,max(int(mesh%NUMBER_OF_ELEMENTS/2),1), &
4055 DO ne=1,mesh%NUMBER_OF_ELEMENTS
4057 domain_no=decomposition%ELEMENT_DOMAIN(ne)
4058 local_element_numbers(domain_no)=local_element_numbers(domain_no)+1
4060 basis=>mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS(ne)%BASIS
4061 NULLIFY(adjacent_domains_list)
4066 CALL list_item_add(adjacent_domains_list,domain_no,err,error,*999)
4067 DO nn=1,basis%NUMBER_OF_NODES
4068 np=mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS(ne)%MESH_ELEMENT_NODES(nn)
4069 DO no_adjacent_element=1,mesh%TOPOLOGY(component_idx)%PTR%NODES%NODES(np)%numberOfSurroundingElements
4070 adjacent_element=mesh%TOPOLOGY(component_idx)%PTR%NODES%NODES(np)%surroundingElements(no_adjacent_element)
4071 IF(decomposition%ELEMENT_DOMAIN(adjacent_element)/=domain_no)
THEN 4072 CALL list_item_add(adjacent_elements_list(domain_no)%PTR,adjacent_element,err,error,*999)
4073 CALL list_item_add(adjacent_domains_list,decomposition%ELEMENT_DOMAIN(adjacent_element),err,error,*999)
4081 ALLOCATE(elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%LOCAL_NUMBER(number_of_domains),stat=err)
4082 IF(err/=0)
CALL flagerror(
"Could not allocate element global to local map local number.",err,error,*999)
4083 ALLOCATE(elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%DOMAIN_NUMBER(number_of_domains),stat=err)
4084 IF(err/=0)
CALL flagerror(
"Could not allocate element global to local map domain number.",err,error,*999)
4085 ALLOCATE(elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%LOCAL_TYPE(number_of_domains),stat=err)
4086 IF(err/=0)
CALL flagerror(
"Could not allocate element global to local map local type.",err,error,*999)
4087 elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%NUMBER_OF_DOMAINS=1
4088 elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%LOCAL_NUMBER(1)=local_element_numbers(domain_no)
4089 elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%DOMAIN_NUMBER(1)=decomposition%ELEMENT_DOMAIN(ne)
4090 IF(number_of_domains==1)
THEN 4100 DO domain_idx=0,decomposition%NUMBER_OF_DOMAINS-1
4103 & adjacent_elements,err,error,*999)
4104 DO no_adjacent_element=1,number_of_adjacent_elements
4105 adjacent_element=adjacent_elements(no_adjacent_element)
4106 local_element_numbers(domain_idx)=local_element_numbers(domain_idx)+1
4107 elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS= &
4108 & elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS+1
4109 elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%LOCAL_NUMBER( &
4110 & elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS)=local_element_numbers(domain_idx)
4111 elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%DOMAIN_NUMBER( &
4112 & elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS)=domain_idx
4113 elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%LOCAL_TYPE( &
4114 & elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS)= &
4117 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
4120 DEALLOCATE(adjacent_elements_list)
4121 DEALLOCATE(local_element_numbers)
4127 CALL flagerror(
"Domain mesh is not associated.",err,error,*999)
4130 CALL flagerror(
"Domain decomposition is not associated.",err,error,*999)
4133 CALL flagerror(
"Domain mappings elements is not associated.",err,error,*999)
4136 CALL flagerror(
"Domain mappings is not associated.",err,error,*999)
4139 CALL flagerror(
"Domain is not associated.",err,error,*998)
4145 DO ne=1,mesh%NUMBER_OF_ELEMENTS
4148 & elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%NUMBER_OF_DOMAINS,err,error,*999)
4150 & number_of_domains,8,8,elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%LOCAL_NUMBER, &
4151 &
'(" Local number :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4153 & number_of_domains,8,8,elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%DOMAIN_NUMBER, &
4154 &
'(" Domain number:",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4156 & number_of_domains,8,8,elements_mapping%GLOBAL_TO_LOCAL_MAP(ne)%LOCAL_TYPE, &
4157 &
'(" Local type :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4160 DO ne=1,elements_mapping%TOTAL_NUMBER_OF_LOCAL
4163 & elements_mapping%LOCAL_TO_GLOBAL_MAP(ne),err,error,*999)
4168 & elements_mapping%NUMBER_OF_INTERNAL,err,error,*999)
4170 & elements_mapping%DOMAIN_LIST(elements_mapping%INTERNAL_START:elements_mapping%INTERNAL_FINISH), &
4171 &
'(" Internal elements:",8(X,I7))',
'(22X,8(X,I7))',err,error,*999)
4174 & elements_mapping%NUMBER_OF_BOUNDARY,err,error,*999)
4176 & elements_mapping%DOMAIN_LIST(elements_mapping%BOUNDARY_START:elements_mapping%BOUNDARY_FINISH), &
4177 &
'(" Boundary elements:",8(X,I7))',
'(22X,8(X,I7))',err,error,*999)
4180 & elements_mapping%NUMBER_OF_GHOST,err,error,*999)
4182 & elements_mapping%DOMAIN_LIST(elements_mapping%GHOST_START:elements_mapping%GHOST_FINISH), &
4183 &
'(" Ghost elements :",8(X,I7))',
'(22X,8(X,I7))',err,error,*999)
4187 & elements_mapping%NUMBER_OF_ADJACENT_DOMAINS,err,error,*999)
4189 & elements_mapping%ADJACENT_DOMAINS_PTR,
'(" Adjacent domains ptr :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4191 & elements_mapping%NUMBER_OF_DOMAINS)-1,8,8,elements_mapping%ADJACENT_DOMAINS_LIST, &
4192 '(" Adjacent domains list :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4193 DO domain_idx=1,elements_mapping%NUMBER_OF_ADJACENT_DOMAINS
4196 & elements_mapping%ADJACENT_DOMAINS(domain_idx)%DOMAIN_NUMBER,err,error,*999)
4198 & elements_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_SEND_GHOSTS,err,error,*999)
4200 & number_of_send_ghosts,6,6,elements_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_SEND_INDICES, &
4201 &
'(" Local send ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4203 & elements_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_RECEIVE_GHOSTS,err,error,*999)
4205 & number_of_receive_ghosts,6,6,elements_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_RECEIVE_INDICES, &
4206 &
'(" Local receive ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4210 exits(
"DOMAIN_MAPPINGS_ELEMENTS_CALCULATE")
4212 999
IF(
ALLOCATED(domains))
DEALLOCATE(domains)
4213 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
4214 IF(
ASSOCIATED(domain%MAPPINGS%ELEMENTS))
CALL domain_mappings_elements_finalise(domain%MAPPINGS,dummy_err,dummy_error,*998)
4215 998 errorsexits(
"DOMAIN_MAPPINGS_ELEMENTS_CALCULATE",err,error)
4217 END SUBROUTINE domain_mappings_elements_calculate
4224 SUBROUTINE domain_mappings_finalise(DOMAIN,ERR,ERROR,*)
4228 INTEGER(INTG),
INTENT(OUT) :: err
4232 enters(
"DOMAIN_MAPPINGS_FINALISE",err,error,*999)
4234 IF(
ASSOCIATED(domain))
THEN 4235 CALL domain_mappings_elements_finalise(domain%MAPPINGS,err,error,*999)
4236 CALL domain_mappings_nodes_finalise(domain%MAPPINGS,err,error,*999)
4237 CALL domain_mappings_dofs_finalise(domain%MAPPINGS,err,error,*999)
4238 DEALLOCATE(domain%MAPPINGS)
4240 CALL flagerror(
"Domain is not associated.",err,error,*999)
4243 exits(
"DOMAIN_MAPPINGS_FINALISE")
4245 999 errorsexits(
"DOMAIN_MAPPINGS_FINALISE",err,error)
4248 END SUBROUTINE domain_mappings_finalise
4255 SUBROUTINE domain_mappings_elements_finalise(DOMAIN_MAPPINGS,ERR,ERROR,*)
4259 INTEGER(INTG),
INTENT(OUT) :: err
4263 enters(
"DOMAIN_MAPPINGS_ELEMENTS_FINALISE",err,error,*999)
4270 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
4273 exits(
"DOMAIN_MAPPINGS_ELEMENTS_FINALISE")
4275 999 errorsexits(
"DOMAIN_MAPPINGS_ELEMENTS_FINALISE",err,error)
4278 END SUBROUTINE domain_mappings_elements_finalise
4285 SUBROUTINE domain_mappings_elements_initialise(DOMAIN_MAPPINGS,ERR,ERROR,*)
4289 INTEGER(INTG),
INTENT(OUT) :: err
4293 enters(
"DOMAIN_MAPPINGS_ELEMENTS_INITIALISE",err,error,*999)
4297 CALL flagerror(
"Domain elements mappings are already associated.",err,error,*999)
4300 IF(err/=0)
CALL flagerror(
"Could not allocate domain mappings elements.",err,error,*999)
4305 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
4308 exits(
"DOMAIN_MAPPINGS_ELEMENTS_INITIALISE")
4310 999 errorsexits(
"DOMAIN_MAPPINGS_ELEMENTS_INITIALISE",err,error)
4313 END SUBROUTINE domain_mappings_elements_initialise
4320 SUBROUTINE domain_mappings_initialise(DOMAIN,ERR,ERROR,*)
4324 INTEGER(INTG),
INTENT(OUT) :: err
4328 enters(
"DOMAIN_MAPPINGS_INITIALISE",err,error,*999)
4330 IF(
ASSOCIATED(domain))
THEN 4331 IF(
ASSOCIATED(domain%MAPPINGS))
THEN 4332 CALL flagerror(
"Domain already has mappings associated.",err,error,*999)
4334 ALLOCATE(domain%MAPPINGS,stat=err)
4335 IF(err/=0)
CALL flagerror(
"Could not allocate domain mappings.",err,error,*999)
4336 domain%MAPPINGS%DOMAIN=>domain
4337 NULLIFY(domain%MAPPINGS%ELEMENTS)
4338 NULLIFY(domain%MAPPINGS%NODES)
4339 NULLIFY(domain%MAPPINGS%DOFS)
4341 CALL domain_mappings_elements_initialise(domain%MAPPINGS,err,error,*999)
4342 CALL domain_mappings_nodes_initialise(domain%MAPPINGS,err,error,*999)
4343 CALL domain_mappings_dofs_initialise(domain%MAPPINGS,err,error,*999)
4344 CALL domain_mappings_elements_calculate(domain,err,error,*999)
4345 CALL domain_mappings_nodes_dofs_calculate(domain,err,error,*999)
4348 CALL flagerror(
"Domain is not associated.",err,error,*999)
4351 exits(
"DOMAIN_MAPPINGS_INITIALISE")
4353 999 errorsexits(
"DOMAIN_MAPPINGS_INITIALISE",err,error)
4355 END SUBROUTINE domain_mappings_initialise
4362 SUBROUTINE domain_mappings_nodes_dofs_calculate(DOMAIN,ERR,ERROR,*)
4366 INTEGER(INTG),
INTENT(OUT) :: err
4369 INTEGER(INTG) :: dummy_err,no_adjacent_element,no_computational_node,no_ghost_node,adjacent_element,ghost_node, &
4370 & NUMBER_OF_NODES_PER_DOMAIN,domain_idx,domain_idx2,domain_no,node_idx,derivative_idx,version_idx,ny,NUMBER_OF_DOMAINS, &
4371 & MAX_NUMBER_DOMAINS,NUMBER_OF_GHOST_NODES,my_computational_node_number,number_computational_nodes,component_idx
4372 INTEGER(INTG),
ALLOCATABLE :: local_node_numbers(:),local_dof_numbers(:),node_count(:),number_internal_nodes(:), &
4373 & NUMBER_BOUNDARY_NODES(:)
4374 INTEGER(INTG),
ALLOCATABLE :: domains(:),all_domains(:),ghost_nodes(:)
4375 LOGICAL :: boundary_domain
4376 TYPE(
list_type),
POINTER :: adjacent_domains_list,all_adjacent_domains_list
4386 enters(
"DOMAIN_MAPPINGS_NODES_DOFS_CALCULATE",err,error,*999)
4388 IF(
ASSOCIATED(domain))
THEN 4389 IF(
ASSOCIATED(domain%MAPPINGS))
THEN 4390 IF(
ASSOCIATED(domain%MAPPINGS%NODES))
THEN 4391 nodes_mapping=>domain%MAPPINGS%NODES
4392 IF(
ASSOCIATED(domain%MAPPINGS%DOFS))
THEN 4393 dofs_mapping=>domain%MAPPINGS%DOFS
4394 IF(
ASSOCIATED(domain%MAPPINGS%ELEMENTS))
THEN 4395 elements_mapping=>domain%MAPPINGS%ELEMENTS
4396 IF(
ASSOCIATED(domain%DECOMPOSITION))
THEN 4397 decomposition=>domain%DECOMPOSITION
4398 IF(
ASSOCIATED(domain%MESH))
THEN 4400 component_idx=domain%MESH_COMPONENT_NUMBER
4401 mesh_topology=>mesh%TOPOLOGY(component_idx)%PTR
4409 ALLOCATE(nodes_mapping%GLOBAL_TO_LOCAL_MAP(mesh_topology%NODES%numberOfNodes),stat=err)
4410 IF(err/=0)
CALL flagerror(
"Could not allocate node mapping global to local map.",err,error,*999)
4411 nodes_mapping%NUMBER_OF_GLOBAL=mesh_topology%NODES%numberOfNodes
4412 ALLOCATE(local_node_numbers(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4413 IF(err/=0)
CALL flagerror(
"Could not allocate local node numbers.",err,error,*999)
4414 local_node_numbers=0
4415 ALLOCATE(dofs_mapping%GLOBAL_TO_LOCAL_MAP(mesh_topology%dofs%numberOfDofs),stat=err)
4416 IF(err/=0)
CALL flagerror(
"Could not allocate dofs mapping global to local map.",err,error,*999)
4417 dofs_mapping%NUMBER_OF_GLOBAL=mesh_topology%DOFS%numberOfDofs
4418 ALLOCATE(local_dof_numbers(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4419 IF(err/=0)
CALL flagerror(
"Could not allocate local dof numbers.",err,error,*999)
4421 ALLOCATE(ghost_nodes_list(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4422 IF(err/=0)
CALL flagerror(
"Could not allocate ghost nodes list.",err,error,*999)
4423 DO domain_idx=0,decomposition%NUMBER_OF_DOMAINS-1
4424 NULLIFY(ghost_nodes_list(domain_idx)%PTR)
4427 CALL list_initial_size_set(ghost_nodes_list(domain_idx)%PTR,int(mesh_topology%NODES%numberOfNodes/2), &
4431 ALLOCATE(number_internal_nodes(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4432 IF(err/=0)
CALL flagerror(
"Could not allocate number of internal nodes.",err,error,*999)
4433 number_internal_nodes=0
4434 ALLOCATE(number_boundary_nodes(0:decomposition%NUMBER_OF_DOMAINS-1),stat=err)
4435 IF(err/=0)
CALL flagerror(
"Could not allocate number of boundary nodes.",err,error,*999)
4436 number_boundary_nodes=0
4439 DO node_idx=1,mesh_topology%NODES%numberOfNodes
4440 NULLIFY(adjacent_domains_list)
4445 NULLIFY(all_adjacent_domains_list)
4448 CALL list_initial_size_set(all_adjacent_domains_list,decomposition%NUMBER_OF_DOMAINS,err,error,*999)
4450 DO no_adjacent_element=1,mesh_topology%NODES%NODES(node_idx)%numberOfSurroundingElements
4451 adjacent_element=mesh_topology%NODES%NODES(node_idx)%surroundingElements(no_adjacent_element)
4452 domain_no=decomposition%ELEMENT_DOMAIN(adjacent_element)
4453 CALL list_item_add(adjacent_domains_list,domain_no,err,error,*999)
4454 DO domain_idx=1,elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)%NUMBER_OF_DOMAINS
4455 CALL list_item_add(all_adjacent_domains_list,elements_mapping%GLOBAL_TO_LOCAL_MAP(adjacent_element)% &
4456 & domain_number(domain_idx),err,error,*999)
4463 IF(number_of_domains/=max_number_domains)
THEN 4464 DO domain_idx=1,max_number_domains
4465 domain_no=all_domains(domain_idx)
4466 boundary_domain=.false.
4467 DO domain_idx2=1,number_of_domains
4468 IF(domain_no==domains(domain_idx2))
THEN 4469 boundary_domain=.true.
4473 IF(.NOT.boundary_domain)
CALL list_item_add(ghost_nodes_list(domain_no)%PTR,node_idx,err,error,*999)
4476 ALLOCATE(nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER(max_number_domains),stat=err)
4477 IF(err/=0)
CALL flagerror(
"Could not allocate node global to local map local number.",err,error,*999)
4478 ALLOCATE(nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(max_number_domains),stat=err)
4479 IF(err/=0)
CALL flagerror(
"Could not allocate node global to local map domain number.",err,error,*999)
4480 ALLOCATE(nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_TYPE(max_number_domains),stat=err)
4481 IF(err/=0)
CALL flagerror(
"Could not allocate node global to local map local type.",err,error,*999)
4482 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4483 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4484 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4485 ALLOCATE(dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER(max_number_domains),stat=err)
4486 IF(err/=0)
CALL flagerror(
"Could not allocate dof global to local map local number.",err,error,*999)
4487 ALLOCATE(dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER(max_number_domains),stat=err)
4488 IF(err/=0)
CALL flagerror(
"Could not allocate dof global to local map domain number.",err,error,*999)
4489 ALLOCATE(dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_TYPE(max_number_domains),stat=err)
4490 IF(err/=0)
CALL flagerror(
"Could not allocate dof global to local map local type.",err,error,*999)
4493 IF(number_of_domains==1)
THEN 4495 domain_no=domains(1)
4496 number_internal_nodes(domain_no)=number_internal_nodes(domain_no)+1
4498 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS=1
4500 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER(1)=-1
4501 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(1)=domains(1)
4503 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4504 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4505 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4506 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS=1
4507 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER(1)=-1
4508 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER(1)=domain_no
4514 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS=number_of_domains
4515 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4516 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4517 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4518 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS=number_of_domains
4521 DO domain_idx=1,number_of_domains
4522 domain_no=domains(domain_idx)
4525 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER(domain_idx)=-1
4526 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(domain_idx)=domain_no
4528 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4529 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4530 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4531 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER(domain_idx)=-1
4532 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER(domain_idx)=domain_no
4539 DEALLOCATE(all_domains)
4543 number_of_nodes_per_domain=floor(
REAL(mesh_topology%nodes%numberofnodes,
dp)/ &
4544 & REAL(DECOMPOSITION%NUMBER_OF_DOMAINS,DP))
4545 allocate(domain%node_domain(mesh_topology%nodes%numberofnodes),stat=err)
4546 IF(err/=0)
CALL flagerror(
"Could not allocate node domain",err,error,*999)
4547 domain%NODE_DOMAIN=-1
4548 DO node_idx=1,mesh_topology%NODES%numberOfNodes
4549 IF(nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS==1)
THEN 4550 domain_no=nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(1)
4551 domain%NODE_DOMAIN(node_idx)=domain_no
4552 local_node_numbers(domain_no)=local_node_numbers(domain_no)+1
4553 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER(1)=local_node_numbers(domain_no)
4554 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4555 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4556 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4557 local_dof_numbers(domain_no)=local_dof_numbers(domain_no)+1
4558 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER(1)=local_dof_numbers(domain_no)
4562 number_of_domains=nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS
4563 DO domain_idx=1,number_of_domains
4564 domain_no=nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(domain_idx)
4565 IF(domain%NODE_DOMAIN(node_idx)<0)
THEN 4566 IF((number_internal_nodes(domain_no)+number_boundary_nodes(domain_no)<number_of_nodes_per_domain).OR. &
4567 & (domain_idx==nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS))
THEN 4569 domain%NODE_DOMAIN(node_idx)=domain_no
4570 number_boundary_nodes(domain_no)=number_boundary_nodes(domain_no)+1
4571 local_node_numbers(domain_no)=local_node_numbers(domain_no)+1
4574 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS=1
4575 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER(1)=local_node_numbers(domain_no)
4576 nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER(1)=domain_no
4578 DO derivative_idx=1,mesh_topology%NODES%NODES(node_idx)%numberOfDerivatives
4579 DO version_idx=1,mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions
4580 ny=mesh_topology%NODES%NODES(node_idx)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4581 local_dof_numbers(domain_no)=local_dof_numbers(domain_no)+1
4582 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS=1
4583 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER(1)=local_dof_numbers(domain_no)
4584 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER(1)=domain_no
4590 CALL list_item_add(ghost_nodes_list(domain_no)%PTR,node_idx,err,error,*999)
4594 CALL list_item_add(ghost_nodes_list(domain_no)%PTR,node_idx,err,error,*999)
4599 DEALLOCATE(number_internal_nodes)
4602 DO domain_idx=0,decomposition%NUMBER_OF_DOMAINS-1
4604 CALL list_detach_and_destroy(ghost_nodes_list(domain_idx)%PTR,number_of_ghost_nodes,ghost_nodes,err,error,*999)
4605 DO no_ghost_node=1,number_of_ghost_nodes
4606 ghost_node=ghost_nodes(no_ghost_node)
4607 local_node_numbers(domain_idx)=local_node_numbers(domain_idx)+1
4608 nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%NUMBER_OF_DOMAINS= &
4609 & nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%NUMBER_OF_DOMAINS+1
4610 nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%LOCAL_NUMBER( &
4611 & nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%NUMBER_OF_DOMAINS)= &
4612 & local_node_numbers(domain_idx)
4613 nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%DOMAIN_NUMBER( &
4614 & nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%NUMBER_OF_DOMAINS)=domain_idx
4615 nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%LOCAL_TYPE( &
4616 & nodes_mapping%GLOBAL_TO_LOCAL_MAP(ghost_node)%NUMBER_OF_DOMAINS)= &
4618 DO derivative_idx=1,mesh_topology%NODES%NODES(ghost_node)%numberOfDerivatives
4619 DO version_idx=1,mesh_topology%NODES%NODES(ghost_node)%DERIVATIVES(derivative_idx)%numberOfVersions
4620 ny=mesh_topology%NODES%NODES(ghost_node)%DERIVATIVES(derivative_idx)%dofIndex(version_idx)
4621 local_dof_numbers(domain_idx)=local_dof_numbers(domain_idx)+1
4622 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS= &
4623 & dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS+1
4624 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER( &
4625 & dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS)= &
4626 & local_dof_numbers(domain_idx)
4627 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER( &
4628 & dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS)=domain_idx
4629 dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_TYPE( &
4630 & dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS)= &
4635 DEALLOCATE(ghost_nodes)
4639 ALLOCATE(node_count(0:number_computational_nodes-1),stat=err)
4640 IF(err/=0)
CALL flagerror(
"Could not allocate node count.",err,error,*999)
4642 DO node_idx=1,mesh_topology%NODES%numberOfNodes
4643 no_computational_node=domain%NODE_DOMAIN(node_idx)
4644 IF(no_computational_node>=0.AND.no_computational_node<number_computational_nodes)
THEN 4645 node_count(no_computational_node)=node_count(no_computational_node)+1
4647 local_error=
"The computational node number of "// &
4650 &
" is invalid. The computational node number must be between 0 and "// &
4652 CALL flagerror(local_error,err,error,*999)
4655 DO no_computational_node=0,number_computational_nodes-1
4656 IF(node_count(no_computational_node)==0)
THEN 4657 local_error=
"Invalid decomposition. There are no nodes in computational node "// &
4659 CALL flagerror(local_error,err,error,*999)
4662 DEALLOCATE(node_count)
4664 DEALLOCATE(ghost_nodes_list)
4665 DEALLOCATE(local_node_numbers)
4672 CALL flagerror(
"Domain mesh is not associated.",err,error,*999)
4675 CALL flagerror(
"Domain decomposition is not associated.",err,error,*999)
4678 CALL flagerror(
"Domain mappings elements is not associated.",err,error,*999)
4681 CALL flagerror(
"Domain mappings dofs is not associated.",err,error,*999)
4684 CALL flagerror(
"Domain mappings nodes is not associated.",err,error,*999)
4687 CALL flagerror(
"Domain mappings is not associated.",err,error,*999)
4690 CALL flagerror(
"Domain is not associated.",err,error,*998)
4695 DO node_idx=1,mesh_topology%NODES%numberOfNodes
4701 DO node_idx=1,mesh_topology%NODES%numberOfNodes
4704 & nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%NUMBER_OF_DOMAINS,err,error,*999)
4706 & number_of_domains,8,8,nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_NUMBER, &
4707 &
'(" Local number :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4709 & number_of_domains,8,8,nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%DOMAIN_NUMBER, &
4710 &
'(" Domain number:",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4712 & number_of_domains,8,8,nodes_mapping%GLOBAL_TO_LOCAL_MAP(node_idx)%LOCAL_TYPE, &
4713 &
'(" Local type :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4716 DO node_idx=1,nodes_mapping%TOTAL_NUMBER_OF_LOCAL
4719 & nodes_mapping%LOCAL_TO_GLOBAL_MAP(node_idx),err,error,*999)
4724 & nodes_mapping%NUMBER_OF_INTERNAL,err,error,*999)
4726 & nodes_mapping%DOMAIN_LIST(nodes_mapping%INTERNAL_START:nodes_mapping%INTERNAL_FINISH), &
4727 &
'(" Internal nodes:",8(X,I7))',
'(19X,8(X,I7))',err,error,*999)
4730 & nodes_mapping%NUMBER_OF_BOUNDARY,err,error,*999)
4732 & nodes_mapping%DOMAIN_LIST(nodes_mapping%BOUNDARY_START:nodes_mapping%BOUNDARY_FINISH), &
4733 &
'(" Boundary nodes:",8(X,I7))',
'(19X,8(X,I7))',err,error,*999)
4736 & nodes_mapping%NUMBER_OF_GHOST,err,error,*999)
4738 & nodes_mapping%DOMAIN_LIST(nodes_mapping%GHOST_START:nodes_mapping%GHOST_FINISH), &
4739 &
'(" Ghost nodes :",8(X,I7))',
'(19X,8(X,I7))',err,error,*999)
4743 & nodes_mapping%NUMBER_OF_ADJACENT_DOMAINS,err,error,*999)
4745 & nodes_mapping%ADJACENT_DOMAINS_PTR,
'(" Adjacent domains ptr :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4747 & nodes_mapping%NUMBER_OF_DOMAINS)-1,8,8,nodes_mapping%ADJACENT_DOMAINS_LIST, &
4748 '(" Adjacent domains list :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4749 DO domain_idx=1,nodes_mapping%NUMBER_OF_ADJACENT_DOMAINS
4752 & nodes_mapping%ADJACENT_DOMAINS(domain_idx)%DOMAIN_NUMBER,err,error,*999)
4754 & nodes_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_SEND_GHOSTS,err,error,*999)
4756 & number_of_send_ghosts,6,6,nodes_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_SEND_INDICES, &
4757 &
'(" Local send ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4759 & nodes_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_RECEIVE_GHOSTS,err,error,*999)
4761 & number_of_receive_ghosts,6,6,nodes_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_RECEIVE_INDICES, &
4762 &
'(" Local receive ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4766 DO ny=1,mesh_topology%DOFS%numberOfDofs
4769 & dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%NUMBER_OF_DOMAINS,err,error,*999)
4771 & number_of_domains,8,8,dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_NUMBER, &
4772 &
'(" Local number :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4774 & number_of_domains,8,8,dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%DOMAIN_NUMBER, &
4775 &
'(" Domain number:",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4777 & number_of_domains,8,8,dofs_mapping%GLOBAL_TO_LOCAL_MAP(ny)%LOCAL_TYPE, &
4778 &
'(" Local type :",8(X,I7))',
'(20X,8(X,I7))',err,error,*999)
4781 DO ny=1,dofs_mapping%TOTAL_NUMBER_OF_LOCAL
4784 & dofs_mapping%LOCAL_TO_GLOBAL_MAP(ny),err,error,*999)
4789 & dofs_mapping%NUMBER_OF_INTERNAL,err,error,*999)
4791 & dofs_mapping%DOMAIN_LIST(dofs_mapping%INTERNAL_START:dofs_mapping%INTERNAL_FINISH), &
4792 &
'(" Internal dofs:",8(X,I7))',
'(18X,8(X,I7))',err,error,*999)
4795 & dofs_mapping%NUMBER_OF_BOUNDARY,err,error,*999)
4797 & dofs_mapping%DOMAIN_LIST(dofs_mapping%BOUNDARY_START:dofs_mapping%BOUNDARY_FINISH), &
4798 &
'(" Boundary dofs:",8(X,I7))',
'(18X,8(X,I7))',err,error,*999)
4801 & dofs_mapping%NUMBER_OF_GHOST,err,error,*999)
4803 & dofs_mapping%DOMAIN_LIST(dofs_mapping%GHOST_START:dofs_mapping%GHOST_FINISH), &
4804 &
'(" Ghost dofs :",8(X,I7))',
'(18X,8(X,I7))',err,error,*999)
4808 & dofs_mapping%NUMBER_OF_ADJACENT_DOMAINS,err,error,*999)
4810 & dofs_mapping%ADJACENT_DOMAINS_PTR,
'(" Adjacent domains ptr :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4812 & dofs_mapping%NUMBER_OF_DOMAINS)-1,8,8,dofs_mapping%ADJACENT_DOMAINS_LIST, &
4813 '(" Adjacent domains list :",8(X,I7))',
'(27X,8(X,I7))',err,error,*999)
4814 DO domain_idx=1,dofs_mapping%NUMBER_OF_ADJACENT_DOMAINS
4817 & dofs_mapping%ADJACENT_DOMAINS(domain_idx)%DOMAIN_NUMBER,err,error,*999)
4819 & dofs_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_SEND_GHOSTS,err,error,*999)
4821 & number_of_send_ghosts,6,6,dofs_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_SEND_INDICES, &
4822 &
'(" Local send ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4824 & dofs_mapping%ADJACENT_DOMAINS(domain_idx)%NUMBER_OF_RECEIVE_GHOSTS,err,error,*999)
4826 & number_of_receive_ghosts,6,6,dofs_mapping%ADJACENT_DOMAINS(domain_idx)%LOCAL_GHOST_RECEIVE_INDICES, &
4827 &
'(" Local receive ghost indicies :",6(X,I7))',
'(39X,6(X,I7))',err,error,*999)
4831 exits(
"DOMAIN_MAPPINGS_NODES_DOFS_CALCULATE")
4833 999
IF(
ALLOCATED(domains))
DEALLOCATE(domains)
4834 IF(
ALLOCATED(all_domains))
DEALLOCATE(all_domains)
4835 IF(
ALLOCATED(ghost_nodes))
DEALLOCATE(ghost_nodes)
4836 IF(
ALLOCATED(number_internal_nodes))
DEALLOCATE(number_internal_nodes)
4837 IF(
ALLOCATED(number_boundary_nodes))
DEALLOCATE(number_boundary_nodes)
4838 IF(
ASSOCIATED(domain%MAPPINGS%NODES))
CALL domain_mappings_nodes_finalise(domain%MAPPINGS,dummy_err,dummy_error,*998)
4839 998
IF(
ASSOCIATED(domain%MAPPINGS%DOFS))
CALL domain_mappings_dofs_finalise(domain%MAPPINGS,dummy_err,dummy_error,*997)
4840 997 errorsexits(
"DOMAIN_MAPPINGS_NODES_DOFS_CALCULATE",err,error)
4842 END SUBROUTINE domain_mappings_nodes_dofs_calculate
4849 SUBROUTINE domain_mappings_nodes_finalise(DOMAIN_MAPPINGS,ERR,ERROR,*)
4853 INTEGER(INTG),
INTENT(OUT) :: err
4857 enters(
"DOMAIN_MAPPINGS_NODES_FINALISE",err,error,*999)
4864 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
4867 exits(
"DOMAIN_MAPPINGS_NODES_FINALISE")
4869 999 errorsexits(
"DOMAIN_MAPPINGS_NODES_FINALISE",err,error)
4872 END SUBROUTINE domain_mappings_nodes_finalise
4879 SUBROUTINE domain_mappings_nodes_initialise(DOMAIN_MAPPINGS,ERR,ERROR,*)
4883 INTEGER(INTG),
INTENT(OUT) :: err
4887 enters(
"DOMAIN_MAPPINGS_NODES_INITIALISE",err,error,*999)
4891 CALL flagerror(
"Domain nodes mappings are already associated.",err,error,*999)
4894 IF(err/=0)
CALL flagerror(
"Could not allocate domain mappings nodes.",err,error,*999)
4899 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
4902 exits(
"DOMAIN_MAPPINGS_NODES_INITIALISE")
4904 999 errorsexits(
"DOMAIN_MAPPINGS_NODES_INITIALISE",err,error)
4907 END SUBROUTINE domain_mappings_nodes_initialise
4914 SUBROUTINE domain_topology_calculate(TOPOLOGY,ERR,ERROR,*)
4918 INTEGER(INTG),
INTENT(OUT) :: err
4921 INTEGER(INTG) :: ne,np
4924 enters(
"DOMAIN_TOPOLOGY_CALCULATE",err,error,*999)
4926 IF(
ASSOCIATED(topology))
THEN 4928 topology%ELEMENTS%MAXIMUM_NUMBER_OF_ELEMENT_PARAMETERS=-1
4929 DO ne=1,topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS
4930 basis=>topology%ELEMENTS%ELEMENTS(ne)%BASIS
4931 IF(
ASSOCIATED(basis))
THEN 4932 IF(basis%NUMBER_OF_ELEMENT_PARAMETERS>topology%ELEMENTS%MAXIMUM_NUMBER_OF_ELEMENT_PARAMETERS) &
4933 & topology%ELEMENTS%MAXIMUM_NUMBER_OF_ELEMENT_PARAMETERS=basis%NUMBER_OF_ELEMENT_PARAMETERS
4935 CALL flagerror(
"Basis is not associated.",err,error,*999)
4939 topology%NODES%MAXIMUM_NUMBER_OF_DERIVATIVES=-1
4940 DO np=1,topology%NODES%TOTAL_NUMBER_OF_NODES
4941 IF(topology%NODES%NODES(np)%NUMBER_OF_DERIVATIVES>topology%NODES%MAXIMUM_NUMBER_OF_DERIVATIVES) &
4942 & topology%NODES%MAXIMUM_NUMBER_OF_DERIVATIVES=topology%NODES%NODES(np)%NUMBER_OF_DERIVATIVES
4945 CALL domaintopology_nodessurroundingelementscalculate(topology,err,error,*999)
4947 CALL flagerror(
"Topology is not associated.",err,error,*999)
4950 exits(
"DOMAIN_TOPOLOGY_CALCULATE")
4952 999 errorsexits(
"DOMAIN_TOPOLOGY_CALCULATE",err,error)
4954 END SUBROUTINE domain_topology_calculate
4961 SUBROUTINE domain_topology_initialise_from_mesh(DOMAIN,ERR,ERROR,*)
4965 INTEGER(INTG),
INTENT(OUT) :: err
4968 INTEGER(INTG) :: local_element,global_element,local_node,global_node,version_idx,derivative_idx,node_idx,dof_idx, &
4970 INTEGER(INTG) :: ne,nn,nkk,insert_status
4980 enters(
"DOMAIN_TOPOLOGY_INITIALISE_FROM_MESH",err,error,*999)
4982 IF(
ASSOCIATED(domain))
THEN 4983 IF(
ASSOCIATED(domain%TOPOLOGY))
THEN 4984 IF(
ASSOCIATED(domain%MAPPINGS))
THEN 4985 IF(
ASSOCIATED(domain%MESH))
THEN 4987 component_idx=domain%MESH_COMPONENT_NUMBER
4988 IF(
ASSOCIATED(mesh%TOPOLOGY(component_idx)%PTR))
THEN 4989 mesh_elements=>mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS
4990 domain_elements=>domain%TOPOLOGY%ELEMENTS
4991 mesh_nodes=>mesh%TOPOLOGY(component_idx)%PTR%NODES
4992 domain_nodes=>domain%TOPOLOGY%NODES
4993 domain_dofs=>domain%TOPOLOGY%DOFS
4994 ALLOCATE(domain_elements%ELEMENTS(domain%MAPPINGS%ELEMENTS%TOTAL_NUMBER_OF_LOCAL),stat=err)
4995 IF(err/=0)
CALL flagerror(
"Could not allocate domain elements elements.",err,error,*999)
4996 domain_elements%NUMBER_OF_ELEMENTS=domain%MAPPINGS%ELEMENTS%NUMBER_OF_LOCAL
4997 domain_elements%TOTAL_NUMBER_OF_ELEMENTS=domain%MAPPINGS%ELEMENTS%TOTAL_NUMBER_OF_LOCAL
4998 domain_elements%NUMBER_OF_GLOBAL_ELEMENTS=domain%MAPPINGS%ELEMENTS%NUMBER_OF_GLOBAL
4999 ALLOCATE(domain_nodes%NODES(domain%MAPPINGS%NODES%TOTAL_NUMBER_OF_LOCAL),stat=err)
5000 IF(err/=0)
CALL flagerror(
"Could not allocate domain nodes nodes.",err,error,*999)
5001 domain_nodes%NUMBER_OF_NODES=domain%MAPPINGS%NODES%NUMBER_OF_LOCAL
5002 domain_nodes%TOTAL_NUMBER_OF_NODES=domain%MAPPINGS%NODES%TOTAL_NUMBER_OF_LOCAL
5003 domain_nodes%NUMBER_OF_GLOBAL_NODES=domain%MAPPINGS%NODES%NUMBER_OF_GLOBAL
5004 ALLOCATE(domain_dofs%DOF_INDEX(3,domain%MAPPINGS%DOFS%TOTAL_NUMBER_OF_LOCAL),stat=err)
5005 IF(err/=0)
CALL flagerror(
"Could not allocate domain dofs dof index.",err,error,*999)
5006 domain_dofs%NUMBER_OF_DOFS=domain%MAPPINGS%DOFS%NUMBER_OF_LOCAL
5007 domain_dofs%TOTAL_NUMBER_OF_DOFS=domain%MAPPINGS%DOFS%TOTAL_NUMBER_OF_LOCAL
5008 domain_dofs%NUMBER_OF_GLOBAL_DOFS=domain%MAPPINGS%DOFS%NUMBER_OF_GLOBAL
5014 DO local_node=1,domain_nodes%TOTAL_NUMBER_OF_NODES
5015 CALL domain_topology_node_initialise(domain_nodes%NODES(local_node),err,error,*999)
5016 global_node=domain%MAPPINGS%NODES%LOCAL_TO_GLOBAL_MAP(local_node)
5017 domain_nodes%NODES(local_node)%LOCAL_NUMBER=local_node
5018 domain_nodes%NODES(local_node)%MESH_NUMBER=global_node
5019 domain_nodes%NODES(local_node)%GLOBAL_NUMBER=mesh_nodes%NODES(global_node)%globalNumber
5020 domain_nodes%NODES(local_node)%USER_NUMBER=mesh_nodes%NODES(global_node)%userNumber
5021 CALL tree_item_insert(domain_nodes%NODES_TREE,domain_nodes%NODES(local_node)%USER_NUMBER,local_node, &
5022 & insert_status,err,error,*999)
5023 domain_nodes%NODES(local_node)%NUMBER_OF_SURROUNDING_ELEMENTS=0
5024 NULLIFY(domain_nodes%NODES(local_node)%SURROUNDING_ELEMENTS)
5025 domain_nodes%NODES(local_node)%NUMBER_OF_DERIVATIVES=mesh_nodes%NODES(global_node)%numberOfDerivatives
5026 ALLOCATE(domain_nodes%NODES(local_node)%DERIVATIVES(mesh_nodes%NODES(global_node)%numberOfDerivatives),stat=err)
5027 IF(err/=0)
CALL flagerror(
"Could not allocate domain node derivatives.",err,error,*999)
5028 DO derivative_idx=1,domain_nodes%NODES(local_node)%NUMBER_OF_DERIVATIVES
5029 CALL domain_topology_node_derivative_initialise( &
5030 & domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx),err,error,*999)
5031 domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%GLOBAL_DERIVATIVE_INDEX= &
5032 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%globalDerivativeIndex
5033 domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%PARTIAL_DERIVATIVE_INDEX= &
5034 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%partialDerivativeIndex
5035 domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%numberOfVersions= &
5036 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%numberOfVersions
5037 ALLOCATE(domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%userVersionNumbers( &
5038 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%numberOfVersions),stat=err)
5039 IF(err/=0)
CALL flagerror(
"Could not allocate node derivative version numbers.",err,error,*999)
5040 domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%userVersionNumbers(1: &
5041 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%numberOfVersions)= &
5042 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%userVersionNumbers(1: &
5043 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%numberOfVersions)
5044 ALLOCATE(domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%DOF_INDEX( &
5045 & mesh_nodes%NODES(global_node)%DERIVATIVES(derivative_idx)%numberOfVersions),stat=err)
5046 IF(err/=0)
CALL flagerror(
"Could not allocate node dervative versions dof index.",err,error,*999)
5047 DO version_idx=1,domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%numberOfVersions
5049 domain_nodes%NODES(local_node)%DERIVATIVES(derivative_idx)%DOF_INDEX(version_idx)=dof_idx
5050 domain_dofs%DOF_INDEX(1,dof_idx)=version_idx
5051 domain_dofs%DOF_INDEX(2,dof_idx)=derivative_idx
5052 domain_dofs%DOF_INDEX(3,dof_idx)=local_node
5055 domain_nodes%NODES(local_node)%BOUNDARY_NODE=mesh_nodes%NODES(global_node)%boundaryNode
5058 DO local_element=1,domain_elements%TOTAL_NUMBER_OF_ELEMENTS
5059 CALL domain_topology_element_initialise(domain_elements%ELEMENTS(local_element),err,error,*999)
5060 global_element=domain%MAPPINGS%ELEMENTS%LOCAL_TO_GLOBAL_MAP(local_element)
5061 basis=>mesh_elements%ELEMENTS(global_element)%BASIS
5062 domain_elements%ELEMENTS(local_element)%NUMBER=local_element
5063 domain_elements%ELEMENTS(local_element)%BASIS=>basis
5064 ALLOCATE(domain_elements%ELEMENTS(local_element)%ELEMENT_NODES(basis%NUMBER_OF_NODES),stat=err)
5065 IF(err/=0)
CALL flagerror(
"Could not allocate domain elements element nodes.",err,error,*999)
5066 ALLOCATE(domain_elements%ELEMENTS(local_element)%ELEMENT_DERIVATIVES(basis%MAXIMUM_NUMBER_OF_DERIVATIVES, &
5067 & basis%NUMBER_OF_NODES),stat=err)
5068 IF(err/=0)
CALL flagerror(
"Could not allocate domain elements element derivatives.",err,error,*999)
5069 ALLOCATE(domain_elements%ELEMENTS(local_element)%elementVersions(basis%MAXIMUM_NUMBER_OF_DERIVATIVES, &
5070 & basis%NUMBER_OF_NODES),stat=err)
5071 IF(err/=0)
CALL flagerror(
"Could not allocate domain elements element versions.",err,error,*999)
5072 DO nn=1,basis%NUMBER_OF_NODES
5073 global_node=mesh_elements%ELEMENTS(global_element)%MESH_ELEMENT_NODES(nn)
5074 local_node=domain%MAPPINGS%NODES%GLOBAL_TO_LOCAL_MAP(global_node)%LOCAL_NUMBER(1)
5075 domain_elements%ELEMENTS(local_element)%ELEMENT_NODES(nn)=local_node
5076 DO derivative_idx=1,basis%NUMBER_OF_DERIVATIVES(nn)
5080 DO nkk=1,domain_nodes%NODES(local_node)%NUMBER_OF_DERIVATIVES
5081 IF(domain_nodes%NODES(local_node)%DERIVATIVES(nkk)%PARTIAL_DERIVATIVE_INDEX == &
5082 & basis%PARTIAL_DERIVATIVE_INDEX(derivative_idx,nn))
THEN 5088 domain_elements%ELEMENTS(local_element)%ELEMENT_DERIVATIVES(derivative_idx,nn)=nkk
5089 domain_elements%ELEMENTS(local_element)%elementVersions(derivative_idx,nn) = &
5090 & mesh_elements%ELEMENTS(global_element)%USER_ELEMENT_NODE_VERSIONS(derivative_idx,nn)
5092 CALL flagerror(
"Could not find equivalent node derivative",err,error,*999)
5098 CALL flagerror(
"Mesh topology is not associated",err,error,*999)
5101 CALL flagerror(
"Mesh is not associated",err,error,*999)
5105 CALL flagerror(
"Domain mapping is not associated",err,error,*999)
5108 CALL flagerror(
"Domain topology is not associated",err,error,*999)
5111 CALL flagerror(
"Domain is not associated",err,error,*999)
5118 DO node_idx=1,domain_nodes%TOTAL_NUMBER_OF_NODES
5128 & domain_nodes%NODES(node_idx)%NUMBER_OF_DERIVATIVES,err,error,*999)
5129 DO derivative_idx=1,domain_nodes%NODES(local_node)%NUMBER_OF_DERIVATIVES
5132 & domain_nodes%NODES(node_idx)%DERIVATIVES(derivative_idx)%GLOBAL_DERIVATIVE_INDEX,err,error,*999)
5134 & domain_nodes%NODES(node_idx)%DERIVATIVES(derivative_idx)%PARTIAL_DERIVATIVE_INDEX,err,error,*999)
5136 & domain_nodes%NODES(node_idx)%DERIVATIVES(derivative_idx)%numberOfVersions,4,4, &
5137 & domain_nodes%NODES(node_idx)%DERIVATIVES(derivative_idx)%DOF_INDEX, &
5138 &
'(" Degree-of-freedom index(version_idx) :",4(X,I9))',
'(36X,4(X,I9))',err,error,*999)
5141 & domain_nodes%NODES(node_idx)%BOUNDARY_NODE,err,error,*999)
5145 DO dof_idx=1,domain_dofs%TOTAL_NUMBER_OF_DOFS
5148 & domain_dofs%DOF_INDEX(:,dof_idx),
'(" Degree-of-freedom index :",3(X,I9))',
'(29X,3(X,I9))', &
5152 & domain_elements%TOTAL_NUMBER_OF_ELEMENTS,err,error,*999)
5153 DO ne=1,domain_elements%TOTAL_NUMBER_OF_ELEMENTS
5156 & domain_elements%ELEMENTS(ne)%BASIS%USER_NUMBER,err,error,*999)
5158 & domain_elements%ELEMENTS(ne)%BASIS%NUMBER_OF_NODES,err,error,*999)
5160 & domain_elements%ELEMENTS(ne)%ELEMENT_NODES,
'(" Element nodes(nn) :",8(X,I9))',
'(23X,8(X,I9))', &
5162 DO nn=1,domain_elements%ELEMENTS(ne)%BASIS%NUMBER_OF_NODES
5165 & domain_elements%ELEMENTS(ne)%ELEMENT_DERIVATIVES(:,nn), &
5166 &
'(" Element derivatives :",8(X,I2))',
'(29X,8(X,I2))',err,error,*999)
5168 & domain_elements%ELEMENTS(ne)%elementVersions(:,nn), &
5169 &
'(" Element versions :",8(X,I2))',
'(29X,8(X,I2))',err,error,*999)
5174 exits(
"DOMAIN_TOPOLOGY_INITIALISE_FROM_MESH")
5176 999 errorsexits(
"DOMAIN_TOPOLOGY_INITIALISE_FROM_MESH",err,error)
5178 END SUBROUTINE domain_topology_initialise_from_mesh
5185 SUBROUTINE domain_topology_dofs_finalise(TOPOLOGY,ERR,ERROR,*)
5189 INTEGER(INTG),
INTENT(OUT) :: err
5193 enters(
"DOMAIN_TOPOLOGY_DOFS_FINALISE",err,error,*999)
5195 IF(
ASSOCIATED(topology))
THEN 5196 IF(
ASSOCIATED(topology%DOFS))
THEN 5197 IF(
ALLOCATED(topology%DOFS%DOF_INDEX))
DEALLOCATE(topology%DOFS%DOF_INDEX)
5198 DEALLOCATE(topology%DOFS)
5201 CALL flagerror(
"Topology is not associated",err,error,*999)
5204 exits(
"DOMAIN_TOPOLOGY_DOFS_FINALISE")
5206 999 errorsexits(
"DOMAIN_TOPOLOGY_DOFS_FINALISE",err,error)
5209 END SUBROUTINE domain_topology_dofs_finalise
5216 SUBROUTINE domain_topology_dofs_initialise(TOPOLOGY,ERR,ERROR,*)
5220 INTEGER(INTG),
INTENT(OUT) :: err
5224 enters(
"DOMAIN_TOPOLOGY_DOFS_INITIALISE",err,error,*999)
5226 IF(
ASSOCIATED(topology))
THEN 5227 IF(
ASSOCIATED(topology%DOFS))
THEN 5228 CALL flagerror(
"Decomposition already has topology dofs associated",err,error,*999)
5230 ALLOCATE(topology%DOFS,stat=err)
5231 IF(err/=0)
CALL flagerror(
"Could not allocate topology dofs",err,error,*999)
5232 topology%DOFS%NUMBER_OF_DOFS=0
5233 topology%DOFS%TOTAL_NUMBER_OF_DOFS=0
5234 topology%DOFS%NUMBER_OF_GLOBAL_DOFS=0
5235 topology%DOFS%DOMAIN=>topology%DOMAIN
5238 CALL flagerror(
"Topology is not associated",err,error,*999)
5241 exits(
"DOMAIN_TOPOLOGY_DOFS_INITIALISE")
5243 999 errorsexits(
"DOMAIN_TOPOLOGY_DOFS_INITIALISE",err,error)
5245 END SUBROUTINE domain_topology_dofs_initialise
5252 SUBROUTINE domain_topology_element_finalise(ELEMENT,ERR,ERROR,*)
5256 INTEGER(INTG),
INTENT(OUT) :: err
5260 enters(
"DOMAIN_TOPOLOGY_ELEMENT_FINALISE",err,error,*999)
5262 IF(
ALLOCATED(element%ELEMENT_NODES))
DEALLOCATE(element%ELEMENT_NODES)
5263 IF(
ALLOCATED(element%ELEMENT_DERIVATIVES))
DEALLOCATE(element%ELEMENT_DERIVATIVES)
5264 IF(
ALLOCATED(element%elementVersions))
DEALLOCATE(element%elementVersions)
5266 exits(
"DOMAIN_TOPOLOGY_ELEMENT_FINALISE")
5268 999 errorsexits(
"DOMAIN_TOPOLOGY_ELEMENT_FINALISE",err,error)
5271 END SUBROUTINE domain_topology_element_finalise
5278 SUBROUTINE domain_topology_element_initialise(ELEMENT,ERR,ERROR,*)
5282 INTEGER(INTG),
INTENT(OUT) :: err
5286 enters(
"DOMAIN_TOPOLOGY_ELEMENT_INITIALISE",err,error,*999)
5289 NULLIFY(element%BASIS)
5291 exits(
"DOMAIN_TOPOLOGY_ELEMENT_INITALISE")
5293 999 errorsexits(
"DOMAIN_TOPOLOGY_ELEMENT_INITALISE",err,error)
5296 END SUBROUTINE domain_topology_element_initialise
5303 SUBROUTINE domain_topology_elements_finalise(TOPOLOGY,ERR,ERROR,*)
5307 INTEGER(INTG),
INTENT(OUT) :: err
5312 enters(
"DOMAIN_TOPOLOGY_ELEMENTS_FINALISE",err,error,*999)
5314 IF(
ASSOCIATED(topology))
THEN 5315 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 5316 DO ne=1,topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS
5317 CALL domain_topology_element_finalise(topology%ELEMENTS%ELEMENTS(ne),err,error,*999)
5319 IF(
ASSOCIATED(topology%ELEMENTS%ELEMENTS))
DEALLOCATE(topology%ELEMENTS%ELEMENTS)
5320 DEALLOCATE(topology%ELEMENTS)
5323 CALL flagerror(
"Topology is not associated",err,error,*999)
5326 exits(
"DOMAIN_TOPOLOGY_ELEMENTS_FINALISE")
5328 999 errorsexits(
"DOMAIN_TOPOLOGY_ELEMENTS_FINALISE",err,error)
5331 END SUBROUTINE domain_topology_elements_finalise
5338 SUBROUTINE domain_topology_elements_initialise(TOPOLOGY,ERR,ERROR,*)
5342 INTEGER(INTG),
INTENT(OUT) :: err
5346 enters(
"DOMAIN_TOPOLOGY_ELEMENTS_INITIALISE",err,error,*999)
5348 IF(
ASSOCIATED(topology))
THEN 5349 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 5350 CALL flagerror(
"Decomposition already has topology elements associated",err,error,*999)
5352 ALLOCATE(topology%ELEMENTS,stat=err)
5353 IF(err/=0)
CALL flagerror(
"Could not allocate topology elements",err,error,*999)
5354 topology%ELEMENTS%NUMBER_OF_ELEMENTS=0
5355 topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS=0
5356 topology%ELEMENTS%NUMBER_OF_GLOBAL_ELEMENTS=0
5357 topology%ELEMENTS%DOMAIN=>topology%DOMAIN
5358 NULLIFY(topology%ELEMENTS%ELEMENTS)
5359 topology%ELEMENTS%MAXIMUM_NUMBER_OF_ELEMENT_PARAMETERS=0
5362 CALL flagerror(
"Topology is not associated",err,error,*999)
5365 exits(
"DOMAIN_TOPOLOGY_ELEMENTS_INITIALISE")
5367 999 errorsexits(
"DOMAIN_TOPOLOGY_ELEMENTS_INITIALISE",err,error)
5369 END SUBROUTINE domain_topology_elements_initialise
5377 SUBROUTINE domain_topology_finalise(DOMAIN,ERR,ERROR,*)
5381 INTEGER(INTG),
INTENT(OUT) :: err
5385 enters(
"DOMAIN_TOPOLOGY_FINALISE",err,error,*999)
5387 IF(
ASSOCIATED(domain))
THEN 5388 CALL domain_topology_nodes_finalise(domain%TOPOLOGY,err,error,*999)
5389 CALL domain_topology_dofs_finalise(domain%TOPOLOGY,err,error,*999)
5390 CALL domain_topology_elements_finalise(domain%TOPOLOGY,err,error,*999)
5391 CALL domain_topology_lines_finalise(domain%TOPOLOGY,err,error,*999)
5392 CALL domain_topology_faces_finalise(domain%TOPOLOGY,err,error,*999)
5393 DEALLOCATE(domain%TOPOLOGY)
5395 CALL flagerror(
"Domain is not associated",err,error,*999)
5398 exits(
"DOMAIN_TOPOLOGY_FINALISE")
5400 999 errorsexits(
"DOMAIN_TOPOLOGY_FINALISE",err,error)
5403 END SUBROUTINE domain_topology_finalise
5410 SUBROUTINE domain_topology_initialise(DOMAIN,ERR,ERROR,*)
5414 INTEGER(INTG),
INTENT(OUT) :: err
5418 enters(
"DOMAIN_TOPOLOGY_INITIALISE",err,error,*999)
5420 IF(
ASSOCIATED(domain))
THEN 5421 IF(
ASSOCIATED(domain%TOPOLOGY))
THEN 5422 CALL flagerror(
"Domain already has topology associated",err,error,*999)
5425 ALLOCATE(domain%TOPOLOGY,stat=err)
5426 IF(err/=0)
CALL flagerror(
"Domain topology could not be allocated",err,error,*999)
5427 domain%TOPOLOGY%DOMAIN=>domain
5428 NULLIFY(domain%TOPOLOGY%ELEMENTS)
5429 NULLIFY(domain%TOPOLOGY%NODES)
5430 NULLIFY(domain%TOPOLOGY%DOFS)
5431 NULLIFY(domain%TOPOLOGY%LINES)
5432 NULLIFY(domain%TOPOLOGY%FACES)
5434 CALL domain_topology_elements_initialise(domain%TOPOLOGY,err,error,*999)
5435 CALL domain_topology_nodes_initialise(domain%TOPOLOGY,err,error,*999)
5436 CALL domain_topology_dofs_initialise(domain%TOPOLOGY,err,error,*999)
5437 CALL domain_topology_lines_initialise(domain%TOPOLOGY,err,error,*999)
5438 CALL domain_topology_faces_initialise(domain%TOPOLOGY,err,error,*999)
5440 CALL domain_topology_initialise_from_mesh(domain,err,error,*999)
5442 CALL domain_topology_calculate(domain%TOPOLOGY,err,error,*999)
5445 CALL flagerror(
"Domain is not associated",err,error,*999)
5448 exits(
"DOMAIN_TOPOLOGY_INITIALISE")
5450 999 errorsexits(
"DOMAIN_TOPOLOGY_INITIALISE",err,error)
5452 END SUBROUTINE domain_topology_initialise
5459 SUBROUTINE domain_topology_line_finalise(LINE,ERR,ERROR,*)
5463 INTEGER(INTG),
INTENT(OUT) :: err
5467 enters(
"DOMAIN_TOPOLOGY_LINE_FINALISE",err,error,*999)
5471 IF(
ALLOCATED(line%NODES_IN_LINE))
DEALLOCATE(line%NODES_IN_LINE)
5472 IF(
ALLOCATED(line%DERIVATIVES_IN_LINE))
DEALLOCATE(line%DERIVATIVES_IN_LINE)
5474 exits(
"DOMAIN_TOPOLOGY_LINE_FINALISE")
5476 999 errorsexits(
"DOMAIN_TOPOLOGY_LINE_FINALISE",err,error)
5479 END SUBROUTINE domain_topology_line_finalise
5486 SUBROUTINE domain_topology_line_initialise(LINE,ERR,ERROR,*)
5490 INTEGER(INTG),
INTENT(OUT) :: err
5494 enters(
"DOMAIN_TOPOLOGY_LINE_INITIALISE",err,error,*999)
5498 line%BOUNDARY_LINE=.false.
5500 exits(
"DOMAIN_TOPOLOGY_LINE_INITIALISE")
5502 999 errorsexits(
"DOMAIN_TOPOLOGY_LINE_INITIALISE",err,error)
5504 END SUBROUTINE domain_topology_line_initialise
5511 SUBROUTINE domain_topology_lines_finalise(TOPOLOGY,ERR,ERROR,*)
5515 INTEGER(INTG),
INTENT(OUT) :: err
5520 enters(
"DOMAIN_TOPOLOGY_LINES_FINALISE",err,error,*999)
5522 IF(
ASSOCIATED(topology))
THEN 5523 IF(
ASSOCIATED(topology%LINES))
THEN 5524 DO nl=1,topology%LINES%NUMBER_OF_LINES
5525 CALL domain_topology_line_finalise(topology%LINES%LINES(nl),err,error,*999)
5527 IF(
ALLOCATED(topology%LINES%LINES))
DEALLOCATE(topology%LINES%LINES)
5528 DEALLOCATE(topology%LINES)
5531 CALL flagerror(
"Topology is not associated",err,error,*999)
5534 exits(
"DOMAIN_TOPOLOGY_LINES_FINALISE")
5536 999 errorsexits(
"DOMAIN_TOPOLOGY_LINES_FINALISE",err,error)
5539 END SUBROUTINE domain_topology_lines_finalise
5546 SUBROUTINE domain_topology_lines_initialise(TOPOLOGY,ERR,ERROR,*)
5550 INTEGER(INTG),
INTENT(OUT) :: err
5554 enters(
"DOMAIN_TOPOLOGY_LINES_INITIALISE",err,error,*999)
5556 IF(
ASSOCIATED(topology))
THEN 5557 IF(
ASSOCIATED(topology%LINES))
THEN 5558 CALL flagerror(
"Decomposition already has topology lines associated",err,error,*999)
5560 ALLOCATE(topology%LINES,stat=err)
5561 IF(err/=0)
CALL flagerror(
"Could not allocate topology lines",err,error,*999)
5562 topology%LINES%NUMBER_OF_LINES=0
5563 topology%LINES%DOMAIN=>topology%DOMAIN
5566 CALL flagerror(
"Topology is not associated",err,error,*999)
5569 exits(
"DOMAIN_TOPOLOGY_LINES_INITIALISE")
5571 999 errorsexits(
"DOMAIN_TOPOLOGY_LINES_INITIALISE",err,error)
5573 END SUBROUTINE domain_topology_lines_initialise
5579 SUBROUTINE domain_topology_face_finalise(FACE,ERR,ERROR,*)
5583 INTEGER(INTG),
INTENT(OUT) :: err
5587 enters(
"DOMAIN_TOPOLOGY_FACE_FINALISE",err,error,*999)
5591 IF(
ALLOCATED(face%NODES_IN_FACE))
DEALLOCATE(face%NODES_IN_FACE)
5592 IF(
ALLOCATED(face%DERIVATIVES_IN_FACE))
DEALLOCATE(face%DERIVATIVES_IN_FACE)
5594 exits(
"DOMAIN_TOPOLOGY_FACE_FINALISE")
5596 999 errorsexits(
"DOMAIN_TOPOLOGY_FACE_FINALISE",err,error)
5599 END SUBROUTINE domain_topology_face_finalise
5606 SUBROUTINE domain_topology_face_initialise(FACE,ERR,ERROR,*)
5610 INTEGER(INTG),
INTENT(OUT) :: err
5614 enters(
"DOMAIN_TOPOLOGY_FACE_INITIALISE",err,error,*999)
5618 face%BOUNDARY_FACE=.false.
5620 exits(
"DOMAIN_TOPOLOGY_FACE_INITIALISE")
5622 999 errorsexits(
"DOMAIN_TOPOLOGY_FACE_INITIALISE",err,error)
5624 END SUBROUTINE domain_topology_face_initialise
5631 SUBROUTINE domain_topology_faces_finalise(TOPOLOGY,ERR,ERROR,*)
5635 INTEGER(INTG),
INTENT(OUT) :: err
5640 enters(
"DOMAIN_TOPOLOGY_FACES_FINALISE",err,error,*999)
5642 IF(
ASSOCIATED(topology))
THEN 5643 IF(
ASSOCIATED(topology%FACES))
THEN 5644 DO nf=1,topology%FACES%NUMBER_OF_FACES
5645 CALL domain_topology_face_finalise(topology%FACES%FACES(nf),err,error,*999)
5647 IF(
ALLOCATED(topology%FACES%FACES))
DEALLOCATE(topology%FACES%FACES)
5648 DEALLOCATE(topology%FACES)
5651 CALL flagerror(
"Topology is not associated",err,error,*999)
5654 exits(
"DOMAIN_TOPOLOGY_FACES_FINALISE")
5656 999 errorsexits(
"DOMAIN_TOPOLOGY_FACES_FINALISE",err,error)
5659 END SUBROUTINE domain_topology_faces_finalise
5666 SUBROUTINE domain_topology_faces_initialise(TOPOLOGY,ERR,ERROR,*)
5670 INTEGER(INTG),
INTENT(OUT) :: err
5674 enters(
"DOMAIN_TOPOLOGY_FACES_INITIALISE",err,error,*999)
5676 IF(
ASSOCIATED(topology))
THEN 5677 IF(
ASSOCIATED(topology%FACES))
THEN 5678 CALL flagerror(
"Decomposition already has topology faces associated",err,error,*999)
5680 ALLOCATE(topology%FACES,stat=err)
5681 IF(err/=0)
CALL flagerror(
"Could not allocate topology faces",err,error,*999)
5682 topology%FACES%NUMBER_OF_FACES=0
5683 topology%FACES%DOMAIN=>topology%DOMAIN
5686 CALL flagerror(
"Topology is not associated",err,error,*999)
5689 exits(
"DOMAIN_TOPOLOGY_FACES_INITIALISE")
5691 999 errorsexits(
"DOMAIN_TOPOLOGY_FACES_INITIALISE",err,error)
5693 END SUBROUTINE domain_topology_faces_initialise
5700 SUBROUTINE domain_topology_node_check_exists(DOMAIN_TOPOLOGY,USER_NODE_NUMBER,NODE_EXISTS,DOMAIN_LOCAL_NODE_NUMBER, &
5701 & ghost_node,err,error,*)
5705 INTEGER(INTG),
INTENT(IN) :: user_node_number
5706 LOGICAL,
INTENT(OUT) :: node_exists
5707 INTEGER(INTG),
INTENT(OUT) :: domain_local_node_number
5708 LOGICAL,
INTENT(OUT) :: ghost_node
5709 INTEGER(INTG),
INTENT(OUT) :: err
5715 enters(
"DOMAIN_TOPOLOGY_NODE_CHECK_EXISTS",err,error,*999)
5718 domain_local_node_number=0
5720 IF(
ASSOCIATED(domain_topology))
THEN 5721 domain_nodes=>domain_topology%NODES
5722 IF(
ASSOCIATED(domain_nodes))
THEN 5724 CALL tree_search(domain_nodes%NODES_TREE,user_node_number,tree_node,err,error,*999)
5725 IF(
ASSOCIATED(tree_node))
THEN 5726 CALL tree_node_value_get(domain_nodes%NODES_TREE,tree_node,domain_local_node_number,err,error,*999)
5728 ghost_node=domain_local_node_number>domain_nodes%NUMBER_OF_NODES
5731 CALL flagerror(
"Domain topology nodes is not associated.",err,error,*999)
5734 CALL flagerror(
"Domain topology is not associated.",err,error,*999)
5737 exits(
"DOMAIN_TOPOLOGY_NODE_CHECK_EXISTS")
5739 999 errorsexits(
"DOMAIN_TOPOLOGY_NODE_CHECK_EXISTS",err,error)
5742 END SUBROUTINE domain_topology_node_check_exists
5749 SUBROUTINE domain_topology_node_derivative_finalise(NODE_DERIVATIVE,ERR,ERROR,*)
5753 INTEGER(INTG),
INTENT(OUT) :: err
5757 enters(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_FINALISE",err,error,*999)
5759 IF(
ALLOCATED(node_derivative%userVersionNumbers))
DEALLOCATE(node_derivative%userVersionNumbers)
5760 IF(
ALLOCATED(node_derivative%DOF_INDEX))
DEALLOCATE(node_derivative%DOF_INDEX)
5762 exits(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_FINALISE")
5764 999 errorsexits(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_FINALISE",err,error)
5766 END SUBROUTINE domain_topology_node_derivative_finalise
5773 SUBROUTINE domain_topology_node_derivative_initialise(NODE_DERIVATIVE,ERR,ERROR,*)
5777 INTEGER(INTG),
INTENT(OUT) :: err
5781 enters(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_INITIALISE",err,error,*999)
5783 node_derivative%numberOfVersions=0
5784 node_derivative%GLOBAL_DERIVATIVE_INDEX=0
5785 node_derivative%PARTIAL_DERIVATIVE_INDEX=0
5787 exits(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_INITIALISE")
5789 999 errorsexits(
"DOMAIN_TOPOLOGY_NODE_DERIVATIVE_INITIALISE",err,error)
5791 END SUBROUTINE domain_topology_node_derivative_initialise
5798 SUBROUTINE domain_topology_node_finalise(NODE,ERR,ERROR,*)
5802 INTEGER(INTG),
INTENT(OUT) :: err
5805 INTEGER(INTG) :: derivative_idx
5807 enters(
"DOMAIN_TOPOLOGY_NODE_FINALISE",err,error,*999)
5809 IF(
ALLOCATED(node%DERIVATIVES))
THEN 5810 DO derivative_idx=1,node%NUMBER_OF_DERIVATIVES
5811 CALL domain_topology_node_derivative_finalise(node%DERIVATIVES(derivative_idx),err,error,*999)
5813 DEALLOCATE(node%DERIVATIVES)
5815 IF(
ASSOCIATED(node%SURROUNDING_ELEMENTS))
DEALLOCATE(node%SURROUNDING_ELEMENTS)
5816 IF(
ALLOCATED(node%NODE_LINES))
DEALLOCATE(node%NODE_LINES)
5818 exits(
"DOMAIN_TOPOLOGY_NODE_FINALISE")
5820 999 errorsexits(
"DOMAIN_TOPOLOGY_NODE_FINALISE",err,error)
5823 END SUBROUTINE domain_topology_node_finalise
5830 SUBROUTINE domain_topology_node_initialise(NODE,ERR,ERROR,*)
5834 INTEGER(INTG),
INTENT(OUT) :: err
5838 enters(
"DOMAIN_TOPOLOGY_NODE_INITIALISE",err,error,*999)
5842 node%GLOBAL_NUMBER=0
5844 node%NUMBER_OF_SURROUNDING_ELEMENTS=0
5845 node%NUMBER_OF_NODE_LINES=0
5846 node%BOUNDARY_NODE=.false.
5848 exits(
"DOMAIN_TOPOLOGY_NODE_INITIALISE")
5850 999 errorsexits(
"DOMAIN_TOPOLOGY_NODE_INITIALISE",err,error)
5853 END SUBROUTINE domain_topology_node_initialise
5860 SUBROUTINE domain_topology_nodes_finalise(TOPOLOGY,ERR,ERROR,*)
5864 INTEGER(INTG),
INTENT(OUT) :: err
5869 enters(
"DOMAIN_TOPOLOGY_NODES_FINALISE",err,error,*999)
5871 IF(
ASSOCIATED(topology))
THEN 5872 IF(
ASSOCIATED(topology%NODES))
THEN 5873 DO np=1,topology%NODES%TOTAL_NUMBER_OF_NODES
5874 CALL domain_topology_node_finalise(topology%NODES%NODES(np),err,error,*999)
5876 IF(
ASSOCIATED(topology%NODES%NODES))
DEALLOCATE(topology%NODES%NODES)
5877 IF(
ASSOCIATED(topology%NODES%NODES_TREE))
CALL tree_destroy(topology%NODES%NODES_TREE,err,error,*999)
5878 DEALLOCATE(topology%NODES)
5881 CALL flagerror(
"Topology is not associated",err,error,*999)
5884 exits(
"DOMAIN_TOPOLOGY_NODES_FINALISE")
5886 999 errorsexits(
"DOMAIN_TOPOLOGY_NODES_FINALISE",err,error)
5889 END SUBROUTINE domain_topology_nodes_finalise
5896 SUBROUTINE domain_topology_nodes_initialise(TOPOLOGY,ERR,ERROR,*)
5900 INTEGER(INTG),
INTENT(OUT) :: err
5904 enters(
"DOMAIN_TOPOLOGY_NODES_INITIALISE",err,error,*999)
5906 IF(
ASSOCIATED(topology))
THEN 5907 IF(
ASSOCIATED(topology%NODES))
THEN 5908 CALL flagerror(
"Decomposition already has topology nodes associated",err,error,*999)
5910 ALLOCATE(topology%NODES,stat=err)
5911 IF(err/=0)
CALL flagerror(
"Could not allocate topology nodes",err,error,*999)
5912 topology%NODES%NUMBER_OF_NODES=0
5913 topology%NODES%TOTAL_NUMBER_OF_NODES=0
5914 topology%NODES%NUMBER_OF_GLOBAL_NODES=0
5915 topology%NODES%MAXIMUM_NUMBER_OF_DERIVATIVES=0
5916 topology%NODES%DOMAIN=>topology%DOMAIN
5917 NULLIFY(topology%NODES%NODES)
5918 NULLIFY(topology%NODES%NODES_TREE)
5921 CALL flagerror(
"Topology is not associated",err,error,*999)
5924 exits(
"DOMAIN_TOPOLOGY_NODES_INITIALISE")
5926 999 errorsexits(
"DOMAIN_TOPOLOGY_NODES_INITIALISE",err,error)
5928 END SUBROUTINE domain_topology_nodes_initialise
5935 SUBROUTINE domaintopology_nodessurroundingelementscalculate(TOPOLOGY,ERR,ERROR,*)
5939 INTEGER(INTG),
INTENT(OUT) :: err
5942 INTEGER(INTG) :: element_no,insert_position,ne,nn,np,surrounding_elem_no
5943 INTEGER(INTG),
POINTER :: new_surrounding_elements(:)
5944 LOGICAL :: found_element
5947 NULLIFY(new_surrounding_elements)
5949 enters(
"DomainTopology_NodesSurroundingElementsCalculate",err,error,*999)
5951 IF(
ASSOCIATED(topology))
THEN 5952 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 5953 IF(
ASSOCIATED(topology%NODES))
THEN 5954 IF(
ASSOCIATED(topology%NODES%NODES))
THEN 5955 DO np=1,topology%NODES%TOTAL_NUMBER_OF_NODES
5956 topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS=0
5957 IF(
ASSOCIATED(topology%NODES%NODES(np)%SURROUNDING_ELEMENTS)) &
5958 &
DEALLOCATE(topology%NODES%NODES(np)%SURROUNDING_ELEMENTS)
5960 DO ne=1,topology%ELEMENTS%TOTAL_NUMBER_OF_ELEMENTS
5961 basis=>topology%ELEMENTS%ELEMENTS(ne)%BASIS
5962 DO nn=1,basis%NUMBER_OF_NODES
5963 np=topology%ELEMENTS%ELEMENTS(ne)%ELEMENT_NODES(nn)
5964 found_element=.false.
5967 DO WHILE(element_no<=topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS.AND..NOT.found_element)
5968 surrounding_elem_no=topology%NODES%NODES(np)%SURROUNDING_ELEMENTS(element_no)
5969 IF(surrounding_elem_no==ne)
THEN 5970 found_element=.true.
5972 element_no=element_no+1
5973 IF(ne>=surrounding_elem_no)
THEN 5974 insert_position=element_no
5977 IF(.NOT.found_element)
THEN 5979 ALLOCATE(new_surrounding_elements(topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS+1),stat=err)
5980 IF(err/=0)
CALL flagerror(
"Could not allocate new surrounding elements",err,error,*999)
5981 IF(
ASSOCIATED(topology%NODES%NODES(np)%SURROUNDING_ELEMENTS))
THEN 5982 new_surrounding_elements(1:insert_position-1)=topology%NODES%NODES(np)% &
5983 & surrounding_elements(1:insert_position-1)
5984 new_surrounding_elements(insert_position)=ne
5985 new_surrounding_elements(insert_position+1:topology%NODES%NODES(np)% &
5986 & number_of_surrounding_elements+1)=topology%NODES%NODES(np)%SURROUNDING_ELEMENTS(insert_position: &
5987 & topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS)
5988 DEALLOCATE(topology%NODES%NODES(np)%SURROUNDING_ELEMENTS)
5990 new_surrounding_elements(1)=ne
5992 topology%NODES%NODES(np)%SURROUNDING_ELEMENTS=>new_surrounding_elements
5993 topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS= &
5994 & topology%NODES%NODES(np)%NUMBER_OF_SURROUNDING_ELEMENTS+1
5999 CALL flagerror(
"Domain topology nodes nodes are not associated",err,error,*999)
6002 CALL flagerror(
"Domain topology nodes are not associated",err,error,*999)
6005 CALL flagerror(
"Domain topology elements is not associated",err,error,*999)
6008 CALL flagerror(
"Domain topology is not associated",err,error,*999)
6011 exits(
"DomainTopology_NodesSurroundingElementsCalculate")
6013 999
IF(
ASSOCIATED(new_surrounding_elements))
DEALLOCATE(new_surrounding_elements)
6014 errors(
"DomainTopology_NodesSurroundingElementsCalculate",err,error)
6015 exits(
"DomainTopology_NodesSurroundingElementsCalculate")
6017 END SUBROUTINE domaintopology_nodessurroundingelementscalculate
6024 SUBROUTINE mesh_adjacent_element_finalise(MESH_ADJACENT_ELEMENT,ERR,ERROR,*)
6028 INTEGER(INTG),
INTENT(OUT) :: err
6032 enters(
"MESH_ADJACENT_ELEMENT_FINALISE",err,error,*999)
6034 mesh_adjacent_element%NUMBER_OF_ADJACENT_ELEMENTS=0
6035 IF(
ALLOCATED(mesh_adjacent_element%ADJACENT_ELEMENTS))
DEALLOCATE(mesh_adjacent_element%ADJACENT_ELEMENTS)
6037 exits(
"MESH_ADJACENT_ELEMENT_FINALISE")
6039 999 errorsexits(
"MESH_ADJACENT_ELEMENT_FINALISE",err,error)
6042 END SUBROUTINE mesh_adjacent_element_finalise
6048 SUBROUTINE mesh_adjacent_element_initialise(MESH_ADJACENT_ELEMENT,ERR,ERROR,*)
6052 INTEGER(INTG),
INTENT(OUT) :: err
6056 enters(
"MESH_ADJACENT_ELEMENT_INITIALISE",err,error,*999)
6058 mesh_adjacent_element%NUMBER_OF_ADJACENT_ELEMENTS=0
6060 exits(
"MESH_ADJACENT_ELEMENT_INITIALISE")
6062 999 errorsexits(
"MESH_ADJACENT_ELEMENT_INITIALISE",err,error)
6065 END SUBROUTINE mesh_adjacent_element_initialise
6072 SUBROUTINE mesh_create_finish(MESH,ERR,ERROR,*)
6076 INTEGER(INTG),
INTENT(OUT) :: err
6079 INTEGER(INTG) :: component_idx
6083 enters(
"MESH_CREATE_FINISH",err,error,*999)
6085 IF(
ASSOCIATED(mesh))
THEN 6086 IF(
ASSOCIATED(mesh%TOPOLOGY))
THEN 6089 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
6090 IF(
ASSOCIATED(mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS))
THEN 6091 IF(.NOT.mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%ELEMENTS_FINISHED)
THEN 6092 local_error=
"The elements for mesh component "//
trim(
number_to_vstring(component_idx,
"*",err,error))// &
6093 &
" have not been finished" 6098 local_error=
"The elements for mesh topology component "//
trim(
number_to_vstring(component_idx,
"*",err,error))// &
6099 &
" are not associated" 6104 IF(.NOT.finished)
CALL flagerror(local_error,err,error,*999)
6105 mesh%MESH_FINISHED=.true.
6107 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
6108 CALL meshtopologycalculate(mesh%TOPOLOGY(component_idx)%PTR,err,error,*999)
6111 CALL flagerror(
"Mesh topology is not associated",err,error,*999)
6114 CALL flagerror(
"Mesh is not associated",err,error,*999)
6123 exits(
"MESH_CREATE_FINISH")
6125 999 errorsexits(
"MESH_CREATE_FINISH",err,error)
6128 END SUBROUTINE mesh_create_finish
6135 SUBROUTINE mesh_create_start_generic(MESHES,USER_NUMBER,NUMBER_OF_DIMENSIONS,MESH,ERR,ERROR,*)
6139 INTEGER(INTG),
INTENT(IN) :: user_number
6140 INTEGER(INTG),
INTENT(IN) :: number_of_dimensions
6142 INTEGER(INTG),
INTENT(OUT) :: err
6145 INTEGER(INTG) :: dummy_err,mesh_idx
6153 enters(
"MESH_CREATE_START_GENERIC",err,error,*997)
6155 IF(
ASSOCIATED(meshes))
THEN 6156 IF(
ASSOCIATED(mesh))
THEN 6157 CALL flagerror(
"Mesh is already associated.",err,error,*997)
6159 CALL mesh_initialise(new_mesh,err,error,*999)
6161 new_mesh%USER_NUMBER=user_number
6162 new_mesh%GLOBAL_NUMBER=meshes%NUMBER_OF_MESHES+1
6163 new_mesh%MESHES=>meshes
6164 new_mesh%NUMBER_OF_DIMENSIONS=number_of_dimensions
6165 new_mesh%NUMBER_OF_COMPONENTS=1
6166 new_mesh%SURROUNDING_ELEMENTS_CALCULATE=.true.
6168 CALL meshtopologyinitialise(new_mesh,err,error,*999)
6169 CALL decompositions_initialise(new_mesh,err,error,*999)
6171 ALLOCATE(new_meshes(meshes%NUMBER_OF_MESHES+1),stat=err)
6172 IF(err/=0)
CALL flagerror(
"Could not allocate new meshes",err,error,*999)
6173 DO mesh_idx=1,meshes%NUMBER_OF_MESHES
6174 new_meshes(mesh_idx)%PTR=>meshes%MESHES(mesh_idx)%PTR
6176 new_meshes(meshes%NUMBER_OF_MESHES+1)%PTR=>new_mesh
6177 IF(
ASSOCIATED(meshes%MESHES))
DEALLOCATE(meshes%MESHES)
6178 meshes%MESHES=>new_meshes
6179 meshes%NUMBER_OF_MESHES=meshes%NUMBER_OF_MESHES+1
6183 CALL flagerror(
"Meshes is not associated.",err,error,*997)
6186 exits(
"MESH_CREATE_START_GENERIC")
6188 999
CALL mesh_finalise(new_mesh,dummy_err,dummy_error,*998)
6189 998
IF(
ASSOCIATED(new_meshes))
DEALLOCATE(new_meshes)
6191 997 errorsexits(
"MESH_CREATE_START_GENERIC",err,error)
6194 END SUBROUTINE mesh_create_start_generic
6203 SUBROUTINE mesh_create_start_interface(USER_NUMBER,INTERFACE,NUMBER_OF_DIMENSIONS,MESH,ERR,ERROR,*)
6206 INTEGER(INTG),
INTENT(IN) :: user_number
6208 INTEGER(INTG),
INTENT(IN) :: number_of_dimensions
6210 INTEGER(INTG),
INTENT(OUT) :: err
6216 enters(
"MESH_CREATE_START_INTERFACE",err,error,*999)
6218 IF(
ASSOCIATED(interface))
THEN 6219 IF(
ASSOCIATED(mesh))
THEN 6220 CALL flagerror(
"Mesh is already associated.",err,error,*999)
6223 IF(
ASSOCIATED(interface%MESHES))
THEN 6224 CALL mesh_user_number_find_generic(user_number,interface%MESHES,mesh,err,error,*999)
6225 IF(
ASSOCIATED(mesh))
THEN 6227 &
" has already been created on interface number "// &
6229 CALL flagerror(local_error,err,error,*999)
6231 IF(
ASSOCIATED(interface%INTERFACES))
THEN 6232 parent_region=>interface%INTERFACES%PARENT_REGION
6233 IF(
ASSOCIATED(parent_region))
THEN 6234 IF(
ASSOCIATED(parent_region%COORDINATE_SYSTEM))
THEN 6235 IF(number_of_dimensions>0)
THEN 6236 IF(number_of_dimensions<=parent_region%COORDINATE_SYSTEM%NUMBER_OF_DIMENSIONS)
THEN 6237 CALL mesh_create_start_generic(interface%MESHES,user_number,number_of_dimensions,mesh,err,error,*999)
6238 mesh%INTERFACE=>
INTERFACE 6240 local_error=
"Number of mesh dimensions ("//
trim(
number_to_vstring(number_of_dimensions,
"*",err,error))// &
6241 &
") must be <= number of parent region dimensions ("// &
6243 CALL flagerror(local_error,err,error,*999)
6246 CALL flagerror(
"Number of mesh dimensions must be > 0.",err,error,*999)
6249 CALL flagerror(
"Parent region coordinate system is not associated.",err,error,*999)
6252 CALL flagerror(
"Interfaces parent region is not associated.",err,error,*999)
6255 CALL flagerror(
"Interface interfaces is not associated.",err,error,*999)
6259 local_error=
"The meshes on interface number "//
trim(
number_to_vstring(interface%USER_NUMBER,
"*",err,error))// &
6260 &
" are not associated." 6261 CALL flagerror(local_error,err,error,*999)
6265 CALL flagerror(
"Interface is not associated.",err,error,*999)
6268 exits(
"MESH_CREATE_START_INTERFACE")
6270 999 errorsexits(
"MESH_CREATE_START_INTERFACE",err,error)
6273 END SUBROUTINE mesh_create_start_interface
6282 SUBROUTINE mesh_create_start_region(USER_NUMBER,REGION,NUMBER_OF_DIMENSIONS,MESH,ERR,ERROR,*)
6285 INTEGER(INTG),
INTENT(IN) :: user_number
6287 INTEGER(INTG),
INTENT(IN) :: number_of_dimensions
6289 INTEGER(INTG),
INTENT(OUT) :: err
6294 enters(
"MESH_CREATE_START_REGION",err,error,*999)
6296 IF(
ASSOCIATED(region))
THEN 6297 IF(
ASSOCIATED(mesh))
THEN 6298 CALL flagerror(
"Mesh is already associated.",err,error,*999)
6301 IF(
ASSOCIATED(region%MESHES))
THEN 6302 CALL mesh_user_number_find_generic(user_number,region%MESHES,mesh,err,error,*999)
6303 IF(
ASSOCIATED(mesh))
THEN 6305 &
" has already been created on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))//
"." 6306 CALL flagerror(local_error,err,error,*999)
6308 IF(
ASSOCIATED(region%COORDINATE_SYSTEM))
THEN 6309 IF(number_of_dimensions>0)
THEN 6310 IF(number_of_dimensions<=region%COORDINATE_SYSTEM%NUMBER_OF_DIMENSIONS)
THEN 6311 CALL mesh_create_start_generic(region%MESHES,user_number,number_of_dimensions,mesh,err,error,*999)
6314 local_error=
"Number of mesh dimensions ("//
trim(
number_to_vstring(number_of_dimensions,
"*",err,error))// &
6315 &
") must be <= number of region dimensions ("// &
6317 CALL flagerror(local_error,err,error,*999)
6320 CALL flagerror(
"Number of mesh dimensions must be > 0.",err,error,*999)
6323 local_error=
"The coordinate system on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))// &
6324 &
" are not associated." 6325 CALL flagerror(local_error,err,error,*999)
6329 local_error=
"The meshes on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))// &
6330 &
" are not associated." 6331 CALL flagerror(local_error,err,error,*999)
6335 CALL flagerror(
"Region is not associated.",err,error,*999)
6338 exits(
"MESH_CREATE_START_REGION")
6340 999 errorsexits(
"MESH_CREATE_START_REGION",err,error)
6343 END SUBROUTINE mesh_create_start_region
6350 SUBROUTINE mesh_destroy_number(USER_NUMBER,REGION,ERR,ERROR,*)
6353 INTEGER(INTG),
INTENT(IN) :: user_number
6355 INTEGER(INTG),
INTENT(OUT) :: err
6358 INTEGER(INTG) :: mesh_idx,mesh_position
6366 enters(
"MESH_DESTROY_NUMBER",err,error,*999)
6368 IF(
ASSOCIATED(region))
THEN 6369 IF(
ASSOCIATED(region%MESHES))
THEN 6376 DO WHILE(mesh_position<region%MESHES%NUMBER_OF_MESHES.AND..NOT.found)
6377 mesh_position=mesh_position+1
6378 IF(region%MESHES%MESHES(mesh_position)%PTR%USER_NUMBER==user_number) found=.true.
6383 mesh=>region%MESHES%MESHES(mesh_position)%PTR
6385 CALL mesh_finalise(mesh,err,error,*999)
6388 IF(region%MESHES%NUMBER_OF_MESHES>1)
THEN 6389 ALLOCATE(new_meshes(region%MESHES%NUMBER_OF_MESHES-1),stat=err)
6390 IF(err/=0)
CALL flagerror(
"Could not allocate new meshes",err,error,*999)
6391 DO mesh_idx=1,region%MESHES%NUMBER_OF_MESHES
6392 IF(mesh_idx<mesh_position)
THEN 6393 new_meshes(mesh_idx)%PTR=>region%MESHES%MESHES(mesh_idx)%PTR
6394 ELSE IF(mesh_idx>mesh_position)
THEN 6395 region%MESHES%MESHES(mesh_idx)%PTR%GLOBAL_NUMBER=region%MESHES%MESHES(mesh_idx)%PTR%GLOBAL_NUMBER-1
6396 new_meshes(mesh_idx-1)%PTR=>region%MESHES%MESHES(mesh_idx)%PTR
6399 DEALLOCATE(region%MESHES%MESHES)
6400 region%MESHES%MESHES=>new_meshes
6401 region%MESHES%NUMBER_OF_MESHES=region%MESHES%NUMBER_OF_MESHES-1
6403 DEALLOCATE(region%MESHES%MESHES)
6404 region%MESHES%NUMBER_OF_MESHES=0
6409 &
" has not been created on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))
6410 CALL flagerror(local_error,err,error,*999)
6413 local_error=
"The meshes on region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))// &
6414 &
" are not associated" 6415 CALL flagerror(local_error,err,error,*999)
6418 CALL flagerror(
"Region is not associated",err,error,*999)
6421 exits(
"MESH_DESTROY_NUMBER")
6423 999
IF(
ASSOCIATED(new_meshes))
DEALLOCATE(new_meshes)
6424 errorsexits(
"MESH_DESTROY_NUMBER",err,error)
6426 END SUBROUTINE mesh_destroy_number
6433 SUBROUTINE mesh_destroy(MESH,ERR,ERROR,*)
6437 INTEGER(INTG),
INTENT(OUT) :: err
6440 INTEGER(INTG) :: mesh_idx,mesh_position
6446 enters(
"MESH_DESTROY",err,error,*999)
6448 IF(
ASSOCIATED(mesh))
THEN 6450 IF(
ASSOCIATED(meshes))
THEN 6451 mesh_position=mesh%GLOBAL_NUMBER
6453 CALL mesh_finalise(mesh,err,error,*999)
6456 IF(meshes%NUMBER_OF_MESHES>1)
THEN 6457 ALLOCATE(new_meshes(meshes%NUMBER_OF_MESHES-1),stat=err)
6458 IF(err/=0)
CALL flagerror(
"Could not allocate new meshes.",err,error,*999)
6459 DO mesh_idx=1,meshes%NUMBER_OF_MESHES
6460 IF(mesh_idx<mesh_position)
THEN 6461 new_meshes(mesh_idx)%PTR=>meshes%MESHES(mesh_idx)%PTR
6462 ELSE IF(mesh_idx>mesh_position)
THEN 6463 meshes%MESHES(mesh_idx)%PTR%GLOBAL_NUMBER=meshes%MESHES(mesh_idx)%PTR%GLOBAL_NUMBER-1
6464 new_meshes(mesh_idx-1)%PTR=>meshes%MESHES(mesh_idx)%PTR
6467 DEALLOCATE(meshes%MESHES)
6468 meshes%MESHES=>new_meshes
6469 meshes%NUMBER_OF_MESHES=meshes%NUMBER_OF_MESHES-1
6471 DEALLOCATE(meshes%MESHES)
6472 meshes%NUMBER_OF_MESHES=0
6475 CALL flagerror(
"The mesh meshes is not associated.",err,error,*999)
6478 CALL flagerror(
"Mesh is not associated.",err,error,*999)
6481 exits(
"MESH_DESTROY")
6483 999
IF(
ASSOCIATED(new_meshes))
DEALLOCATE(new_meshes)
6484 errorsexits(
"MESH_DESTROY",err,error)
6486 END SUBROUTINE mesh_destroy
6493 SUBROUTINE mesh_finalise(MESH,ERR,ERROR,*)
6497 INTEGER(INTG),
INTENT(OUT) :: err
6501 enters(
"MESH_FINALISE",err,error,*999)
6503 IF(
ASSOCIATED(mesh))
THEN 6504 CALL meshtopologyfinalise(mesh,err,error,*999)
6505 CALL decompositions_finalise(mesh,err,error,*999)
6510 exits(
"MESH_FINALISE")
6512 999 errorsexits(
"MESH_FINALISE",err,error)
6515 END SUBROUTINE mesh_finalise
6522 SUBROUTINE meshglobalnodesget(mesh,nodes,err,error,*)
6527 INTEGER(INTG),
INTENT(OUT) :: err
6534 enters(
"MeshGlobalNodesGet",err,error,*999)
6536 IF(
ASSOCIATED(mesh))
THEN 6537 IF(
ASSOCIATED(nodes))
THEN 6538 CALL flagerror(
"Nodes is already associated.",err,error,*999)
6542 IF(
ASSOCIATED(region))
THEN 6545 interface=>mesh%INTERFACE
6546 IF(
ASSOCIATED(interface))
THEN 6547 nodes=>interface%nodes
6550 &
" does not have an associated region or interface." 6551 CALL flagerror(localerror,err,error,*999)
6554 IF(.NOT.
ASSOCIATED(nodes))
THEN 6555 IF(
ASSOCIATED(region))
THEN 6557 &
" does not have any nodes associated with the mesh region." 6560 &
" does not have any nodes associated with the mesh interface." 6562 CALL flagerror(localerror,err,error,*999)
6566 CALL flagerror(
"Mesh is not associated.",err,error,*999)
6569 exits(
"MeshGlobalNodesGet")
6571 999 errorsexits(
"MeshGlobalNodesGet",err,error)
6574 END SUBROUTINE meshglobalnodesget
6581 SUBROUTINE mesh_initialise(MESH,ERR,ERROR,*)
6585 INTEGER(INTG),
INTENT(OUT) :: err
6589 enters(
"MESH_INITIALISE",err,error,*999)
6591 IF(
ASSOCIATED(mesh))
THEN 6592 CALL flagerror(
"Mesh is already associated.",err,error,*999)
6594 ALLOCATE(mesh,stat=err)
6595 IF(err/=0)
CALL flagerror(
"Could not allocate new mesh.",err,error,*999)
6597 mesh%GLOBAL_NUMBER=0
6598 mesh%MESH_FINISHED=.false.
6599 NULLIFY(mesh%MESHES)
6600 NULLIFY(mesh%REGION)
6601 NULLIFY(mesh%INTERFACE)
6602 NULLIFY(mesh%GENERATED_MESH)
6603 mesh%NUMBER_OF_DIMENSIONS=0
6604 mesh%NUMBER_OF_COMPONENTS=0
6605 mesh%MESH_EMBEDDED=.false.
6606 NULLIFY(mesh%EMBEDDING_MESH)
6607 mesh%NUMBER_OF_EMBEDDED_MESHES=0
6608 NULLIFY(mesh%EMBEDDED_MESHES)
6609 mesh%NUMBER_OF_ELEMENTS=0
6610 NULLIFY(mesh%TOPOLOGY)
6611 NULLIFY(mesh%DECOMPOSITIONS)
6614 exits(
"MESH_INITIALISE")
6616 999 errorsexits(
"MESH_INITIALISE",err,error)
6618 END SUBROUTINE mesh_initialise
6625 SUBROUTINE mesh_number_of_components_get(MESH,NUMBER_OF_COMPONENTS,ERR,ERROR,*)
6629 INTEGER(INTG),
INTENT(OUT) :: number_of_components
6630 INTEGER(INTG),
INTENT(OUT) :: err
6634 enters(
"MESH_NUMBER_OF_COMPONENTS_GET",err,error,*999)
6636 IF(
ASSOCIATED(mesh))
THEN 6637 IF(mesh%MESH_FINISHED)
THEN 6638 number_of_components=mesh%NUMBER_OF_COMPONENTS
6640 CALL flagerror(
"Mesh has not finished",err,error,*999)
6643 CALL flagerror(
"Mesh is not associated",err,error,*999)
6646 exits(
"MESH_NUMBER_OF_COMPONENTS_GET")
6648 999 errorsexits(
"MESH_NUMBER_OF_COMPONENTS_GET",err,error)
6650 END SUBROUTINE mesh_number_of_components_get
6657 SUBROUTINE mesh_number_of_components_set(MESH,NUMBER_OF_COMPONENTS,ERR,ERROR,*)
6661 INTEGER(INTG),
INTENT(IN) :: number_of_components
6662 INTEGER(INTG),
INTENT(OUT) :: err
6665 INTEGER(INTG) :: component_idx
6669 NULLIFY(new_topology)
6671 enters(
"MESH_NUMBER_OF_COMPONENTS_SET",err,error,*999)
6673 IF(
ASSOCIATED(mesh))
THEN 6674 IF(number_of_components>0)
THEN 6675 IF(mesh%MESH_FINISHED)
THEN 6676 CALL flagerror(
"Mesh has been finished",err,error,*999)
6678 IF(number_of_components/=mesh%NUMBER_OF_COMPONENTS)
THEN 6679 ALLOCATE(new_topology(number_of_components),stat=err)
6680 IF(err/=0)
CALL flagerror(
"Could not allocate new topology",err,error,*999)
6681 IF(number_of_components<mesh%NUMBER_OF_COMPONENTS)
THEN 6682 DO component_idx=1,number_of_components
6683 new_topology(component_idx)%PTR=>mesh%TOPOLOGY(component_idx)%PTR
6686 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
6687 new_topology(component_idx)%PTR=>mesh%TOPOLOGY(component_idx)%PTR
6690 DO component_idx=mesh%NUMBER_OF_COMPONENTS+1,number_of_components
6691 ALLOCATE(new_topology(component_idx)%PTR,stat=err)
6692 IF(err/=0)
CALL flagerror(
"Could not allocate new topology component",err,error,*999)
6693 new_topology(component_idx)%PTR%mesh=>mesh
6694 new_topology(component_idx)%PTR%meshComponentNumber=component_idx
6695 NULLIFY(new_topology(component_idx)%PTR%elements)
6696 NULLIFY(new_topology(component_idx)%PTR%nodes)
6697 NULLIFY(new_topology(component_idx)%PTR%dofs)
6698 NULLIFY(new_topology(component_idx)%PTR%dataPoints)
6700 CALL mesh_topology_elements_initialise(new_topology(component_idx)%PTR,err,error,*999)
6701 CALL meshtopologynodesinitialise(new_topology(component_idx)%PTR,err,error,*999)
6702 CALL meshtopologydofsinitialise(new_topology(component_idx)%PTR,err,error,*999)
6703 CALL mesh_topology_data_points_initialise(new_topology(component_idx)%PTR,err,error,*999)
6706 IF(
ASSOCIATED(mesh%TOPOLOGY))
DEALLOCATE(mesh%TOPOLOGY)
6707 mesh%TOPOLOGY=>new_topology
6708 mesh%NUMBER_OF_COMPONENTS=number_of_components
6712 local_error=
"The specified number of mesh components ("//
trim(
number_to_vstring(number_of_components,
"*",err,error))// &
6713 &
") is illegal. You must have >0 mesh components" 6714 CALL flagerror(local_error,err,error,*999)
6717 CALL flagerror(
"Mesh is not associated",err,error,*999)
6720 exits(
"MESH_NUMBER_OF_COMPONENTS_SET")
6723 999 errorsexits(
"MESH_NUMBER_OF_COMPONENTS_SET",err,error)
6726 END SUBROUTINE mesh_number_of_components_set
6733 SUBROUTINE mesh_number_of_elements_get(MESH,NUMBER_OF_ELEMENTS,ERR,ERROR,*)
6737 INTEGER(INTG),
INTENT(OUT) :: number_of_elements
6738 INTEGER(INTG),
INTENT(OUT) :: err
6742 enters(
"MESH_NUMBER_OF_ELEMENTS_GET",err,error,*999)
6744 IF(
ASSOCIATED(mesh))
THEN 6745 IF(mesh%MESH_FINISHED)
THEN 6746 number_of_elements=mesh%NUMBER_OF_ELEMENTS
6748 CALL flagerror(
"Mesh has not been finished",err,error,*999)
6751 CALL flagerror(
"Mesh is not associated",err,error,*999)
6754 exits(
"MESH_NUMBER_OF_ELEMENTS_GET")
6756 999 errorsexits(
"MESH_NUMBER_OF_ELEMENTS_GET",err,error)
6758 END SUBROUTINE mesh_number_of_elements_get
6765 SUBROUTINE mesh_number_of_elements_set(MESH,NUMBER_OF_ELEMENTS,ERR,ERROR,*)
6769 INTEGER(INTG),
INTENT(IN) :: number_of_elements
6770 INTEGER(INTG),
INTENT(OUT) :: err
6773 INTEGER(INTG) :: component_idx
6776 enters(
"MESH_NUMBER_OF_ELEMENTS_SET",err,error,*999)
6778 IF(
ASSOCIATED(mesh))
THEN 6779 IF(number_of_elements>0)
THEN 6780 IF(mesh%MESH_FINISHED)
THEN 6781 CALL flagerror(
"Mesh has been finished.",err,error,*999)
6783 IF(number_of_elements/=mesh%NUMBER_OF_ELEMENTS)
THEN 6784 IF(
ASSOCIATED(mesh%TOPOLOGY))
THEN 6785 DO component_idx=1,mesh%NUMBER_OF_COMPONENTS
6786 IF(
ASSOCIATED(mesh%TOPOLOGY(component_idx)%PTR))
THEN 6787 IF(
ASSOCIATED(mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS))
THEN 6788 IF(mesh%TOPOLOGY(component_idx)%PTR%ELEMENTS%NUMBER_OF_ELEMENTS>0)
THEN 6790 CALL flagerror(
"Not implemented.",err,error,*999)
6794 CALL flagerror(
"Mesh topology component pointer is not associated.",err,error,*999)
6798 CALL flagerror(
"Mesh topology is not associated.",err,error,*999)
6800 mesh%NUMBER_OF_ELEMENTS=number_of_elements
6804 local_error=
"The specified number of elements ("//
trim(
number_to_vstring(number_of_elements,
"*",err,error))// &
6805 &
") is invalid. You must have > 0 elements." 6806 CALL flagerror(local_error,err,error,*999)
6809 CALL flagerror(
"Mesh is not associated.",err,error,*999)
6812 exits(
"MESH_NUMBER_OF_ELEMENTS_SET")
6814 999 errorsexits(
"MESH_NUMBER_OF_ELEMENTS_SET",err,error)
6817 END SUBROUTINE mesh_number_of_elements_set
6824 SUBROUTINE meshregionget(mesh,region,err,error,*)
6829 INTEGER(INTG),
INTENT(OUT) :: err
6836 enters(
"MeshRegionGet",err,error,*999)
6838 IF(
ASSOCIATED(mesh))
THEN 6839 IF(
ASSOCIATED(region))
THEN 6840 CALL flagerror(
"Region is already associated.",err,error,*999)
6845 IF(.NOT.
ASSOCIATED(region))
THEN 6846 interface=>mesh%interface
6847 IF(
ASSOCIATED(interface))
THEN 6848 parentregion=>interface%PARENT_REGION
6849 IF(
ASSOCIATED(parentregion))
THEN 6850 region=>parentregion
6852 localerror=
"The parent region not associated for mesh number "// &
6855 CALL flagerror(localerror,err,error,*999)
6858 localerror=
"The region or interface is not associated for mesh number "// &
6860 CALL flagerror(localerror,err,error,*999)
6865 CALL flagerror(
"Mesh is not associated.",err,error,*999)
6868 exits(
"MeshRegionGet")
6870 999 errorsexits(
"MeshRegionGet",err,error)
6873 END SUBROUTINE meshregionget
6880 SUBROUTINE mesh_surrounding_elements_calculate_set(MESH,SURROUNDING_ELEMENTS_CALCULATE_FLAG,ERR,ERROR,*)
6884 LOGICAL,
INTENT(IN) :: surrounding_elements_calculate_flag
6885 INTEGER(INTG),
INTENT(OUT) :: err
6888 enters(
"MESH_SURROUNDING_ELEMENTS_CALCULATE_SET",err,error,*999)
6890 IF(
ASSOCIATED(mesh))
THEN 6891 IF(mesh%MESH_FINISHED)
THEN 6892 CALL flagerror(
"Mesh has been finished.",err,error,*999)
6894 mesh%SURROUNDING_ELEMENTS_CALCULATE=surrounding_elements_calculate_flag
6897 CALL flagerror(
"Mesh is not associated.",err,error,*999)
6900 exits(
"MESH_SURROUNDING_ELEMENTS_CALCULATE_SET")
6902 999 errorsexits(
"MESH_SURROUNDING_ELEMENTS_CALCULATE_SET",err,error)
6905 END SUBROUTINE mesh_surrounding_elements_calculate_set
6912 SUBROUTINE meshtopologycalculate(topology,err,error,*)
6916 INTEGER(INTG),
INTENT(OUT) :: err
6920 enters(
"MeshTopologyCalculate",err,error,*999)
6922 IF(
ASSOCIATED(topology))
THEN 6924 CALL meshtopologynodescalculate(topology,err,error,*999)
6926 CALL meshtopologysurroundingelementscalculate(topology,err,error,*999)
6928 CALL meshtopologynodesderivativescalculate(topology,err,error,*999)
6930 CALL meshtopologynodesversioncalculate(topology,err,error,*999)
6932 CALL meshtopology_elementsadjacentelementscalculate(topology,err,error,*999)
6934 CALL meshtopologyboundarycalculate(topology,err,error,*999)
6936 CALL meshtopologydofscalculate(topology,err,error,*999)
6938 CALL flagerror(
"Topology is not associated",err,error,*999)
6941 exits(
"MeshTopologyCalculate")
6943 999 errorsexits(
"MeshTopologyCalculate",err,error)
6946 END SUBROUTINE meshtopologycalculate
6953 SUBROUTINE meshtopologyboundarycalculate(topology,err,error,*)
6957 INTEGER(INTG),
INTENT(OUT) :: err
6960 INTEGER(INTG) :: elementidx,localnodeidx,matchindex,nodeidx,xicoordidx,xidirection
6966 enters(
"MeshTopologyBoundaryCalculate",err,error,*999)
6968 IF(
ASSOCIATED(topology))
THEN 6969 nodes=>topology%nodes
6970 IF(
ASSOCIATED(nodes))
THEN 6971 elements=>topology%elements
6972 IF(
ASSOCIATED(elements))
THEN 6973 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
6974 basis=>elements%elements(elementidx)%basis
6975 SELECT CASE(basis%type)
6977 DO xicoordidx=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
6978 IF(xicoordidx/=0)
THEN 6979 IF(elements%elements(elementidx)%ADJACENT_ELEMENTS(xicoordidx)%NUMBER_OF_ADJACENT_ELEMENTS==0)
THEN 6980 elements%elements(elementidx)%BOUNDARY_ELEMENT=.true.
6981 IF(xicoordidx<0)
THEN 6982 xidirection=-xicoordidx
6985 xidirection=xicoordidx
6986 matchindex=basis%NUMBER_OF_NODES_XIC(xicoordidx)
6988 DO localnodeidx=1,basis%NUMBER_OF_NODES
6989 IF(basis%NODE_POSITION_INDEX(localnodeidx,xidirection)==matchindex)
THEN 6990 nodeidx=elements%elements(elementidx)%MESH_ELEMENT_NODES(localnodeidx)
6991 nodes%nodes(nodeidx)%boundaryNode=.true.
6998 elements%elements(elementidx)%BOUNDARY_ELEMENT=.false.
6999 DO xicoordidx=1,basis%NUMBER_OF_XI_COORDINATES
7000 elements%elements(elementidx)%BOUNDARY_ELEMENT=elements%elements(elementidx)%BOUNDARY_ELEMENT.OR. &
7001 & elements%elements(elementidx)%ADJACENT_ELEMENTS(xicoordidx)%NUMBER_OF_ADJACENT_ELEMENTS==0
7002 IF(elements%elements(elementidx)%ADJACENT_ELEMENTS(xicoordidx)%NUMBER_OF_ADJACENT_ELEMENTS==0)
THEN 7003 DO localnodeidx=1,basis%NUMBER_OF_NODES
7004 IF(basis%NODE_POSITION_INDEX(localnodeidx,xicoordidx)==1)
THEN 7005 nodeidx=elements%elements(elementidx)%MESH_ELEMENT_NODES(localnodeidx)
7006 nodes%nodes(nodeidx)%boundaryNode=.true.
7012 CALL flagerror(
"Not implemented.",err,error,*999)
7014 CALL flagerror(
"Not implemented.",err,error,*999)
7016 CALL flagerror(
"Not implemented.",err,error,*999)
7018 CALL flagerror(
"Not implemented.",err,error,*999)
7020 CALL flagerror(
"Not implemented.",err,error,*999)
7022 localerror=
"The basis type of "//
trim(
numbertovstring(basis%TYPE,
"*",err,error))//
" is invalid." 7023 CALL flagerror(localerror,err,error,*999)
7027 CALL flagerror(
"Topology elements is not associated.",err,error,*999)
7030 CALL flagerror(
"Topology nodes is not associated.",err,error,*999)
7033 CALL flagerror(
"Topology is not associated.",err,error,*999)
7039 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
7046 DO nodeidx=1,nodes%numberOfNodes
7052 exits(
"MeshTopologyBoundaryCalculate")
7054 999 errorsexits(
"MeshTopologyBoundaryCalculate",err,error)
7056 END SUBROUTINE meshtopologyboundarycalculate
7063 SUBROUTINE meshtopologydofscalculate(topology,err,error,*)
7067 INTEGER(INTG),
INTENT(OUT) :: err
7070 INTEGER(INTG) :: derivativeidx,nodeidx,numberofdofs,versionidx
7074 enters(
"MeshTopologyDofsCalculate",err,error,*999)
7076 IF(
ASSOCIATED(topology))
THEN 7077 nodes=>topology%nodes
7078 IF(
ASSOCIATED(nodes))
THEN 7080 IF(
ASSOCIATED(dofs))
THEN 7082 DO nodeidx=1,nodes%numberOfNodes
7083 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
7084 ALLOCATE(nodes%nodes(nodeidx)%derivatives(derivativeidx)%dofIndex( &
7085 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%numberOfVersions),stat=err)
7086 IF(err/=0)
CALL flagerror(
"Could not allocate mesh topology node derivative version dof index.",err,error,*999)
7087 DO versionidx=1,nodes%nodes(nodeidx)%derivatives(derivativeidx)%numberOfVersions
7088 numberofdofs=numberofdofs+1
7089 nodes%nodes(nodeidx)%derivatives(derivativeidx)%dofIndex(versionidx)=numberofdofs
7093 dofs%numberOfDofs=numberofdofs
7095 CALL flagerror(
"Topology dofs is not associated.",err,error,*999)
7098 CALL flagerror(
"Topology nodes is not associated.",err,error,*999)
7101 CALL flagerror(
"Topology is not associated.",err,error,*999)
7104 exits(
"MeshTopologyDofsCalculate")
7106 999 errorsexits(
"MeshTopologyDofsCalculate",err,error)
7109 END SUBROUTINE meshtopologydofscalculate
7116 SUBROUTINE meshtopologydofsfinalise(dofs,err,error,*)
7120 INTEGER(INTG),
INTENT(OUT) :: err
7124 enters(
"MeshTopologyDofsFinalise",err,error,*999)
7126 IF(
ASSOCIATED(dofs))
THEN 7130 exits(
"MeshTopologyDofsFinalise")
7132 999 errorsexits(
"MeshTopologyDofsFinalise",err,error)
7135 END SUBROUTINE meshtopologydofsfinalise
7142 SUBROUTINE meshtopologydofsinitialise(topology,err,error,*)
7146 INTEGER(INTG),
INTENT(OUT) :: err
7149 INTEGER(INTG) :: dummyerr
7152 enters(
"MeshTopologyDofsInitialise",err,error,*998)
7154 IF(
ASSOCIATED(topology))
THEN 7155 IF(
ASSOCIATED(topology%dofs))
THEN 7156 CALL flagerror(
"Mesh already has topology dofs associated",err,error,*998)
7158 ALLOCATE(topology%dofs,stat=err)
7159 IF(err/=0)
CALL flagerror(
"Could not allocate topology dofs",err,error,*999)
7160 topology%dofs%numberOfDofs=0
7161 topology%dofs%meshComponentTopology=>topology
7164 CALL flagerror(
"Topology is not associated",err,error,*998)
7167 exits(
"MeshTopologyDofsInitialise")
7169 999
CALL meshtopologydofsfinalise(topology%dofs,dummyerr,dummyerror,*998)
7170 998 errorsexits(
"MeshTopologyDofsInitialise",err,error)
7173 END SUBROUTINE meshtopologydofsinitialise
7180 SUBROUTINE mesh_topology_elements_create_finish(ELEMENTS,ERR,ERROR,*)
7184 INTEGER(INTG),
INTENT(OUT) :: err
7191 enters(
"MESH_TOPOLOGY_ELEMENTS_CREATE_FINISH",err,error,*999)
7193 IF(
ASSOCIATED(elements))
THEN 7194 IF(elements%ELEMENTS_FINISHED)
THEN 7195 CALL flagerror(
"Mesh elements have already been finished.",err,error,*999)
7197 elements%ELEMENTS_FINISHED=.true.
7200 CALL flagerror(
"Mesh elements is not associated.",err,error,*999)
7204 meshcomponenttopology=>elements%meshComponentTopology
7205 IF(
ASSOCIATED(meshcomponenttopology))
THEN 7206 mesh=>meshcomponenttopology%mesh
7207 IF(
ASSOCIATED(mesh))
THEN 7210 DO ne=1,mesh%NUMBER_OF_ELEMENTS
7216 IF(
ASSOCIATED(elements%ELEMENTS(ne)%BASIS))
THEN 7218 & user_number,err,error,*999)
7220 CALL flagerror(
"Basis is not associated.",err,error,*999)
7222 IF(
ALLOCATED(elements%ELEMENTS(ne)%USER_ELEMENT_NODES))
THEN 7224 & elements%ELEMENTS(ne)%USER_ELEMENT_NODES,
'(" User element nodes =",8(X,I6))',
'(26X,8(X,I6))', &
7227 CALL flagerror(
"User element nodes are not associated.",err,error,*999)
7229 IF(
ALLOCATED(elements%ELEMENTS(ne)%GLOBAL_ELEMENT_NODES))
THEN 7231 & elements%ELEMENTS(ne)%GLOBAL_ELEMENT_NODES,
'(" Global element nodes =",8(X,I6))',
'(26X,8(X,I6))', &
7234 CALL flagerror(
"Global element nodes are not associated.",err,error,*999)
7238 CALL flagerror(
"Mesh component topology mesh is not associated.",err,error,*999)
7241 CALL flagerror(
"Mesh elements mesh component topology is not associated.",err,error,*999)
7245 exits(
"MESH_TOPOLOGY_ELEMENTS_CREATE_FINISH")
7247 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_CREATE_FINISH",err,error)
7250 END SUBROUTINE mesh_topology_elements_create_finish
7257 SUBROUTINE mesh_topology_elements_create_start(MESH,MESH_COMPONENT_NUMBER,BASIS,ELEMENTS,ERR,ERROR,*)
7261 INTEGER(INTG),
INTENT(IN) :: mesh_component_number
7264 INTEGER(INTG),
INTENT(OUT) :: err
7267 INTEGER(INTG) :: dummy_err,insert_status,ne
7270 enters(
"MESH_TOPOLOGY_ELEMENTS_CREATE_START",err,error,*999)
7272 IF(
ASSOCIATED(mesh))
THEN 7273 IF(mesh_component_number>0.AND.mesh_component_number<=mesh%NUMBER_OF_COMPONENTS)
THEN 7274 IF(
ASSOCIATED(elements))
THEN 7275 CALL flagerror(
"Elements is already associated.",err,error,*999)
7277 IF(
ASSOCIATED(mesh%TOPOLOGY(mesh_component_number)%PTR))
THEN 7278 IF(
ASSOCIATED(mesh%TOPOLOGY(mesh_component_number)%PTR%ELEMENTS))
THEN 7279 elements=>mesh%TOPOLOGY(mesh_component_number)%PTR%ELEMENTS
7280 IF(
ASSOCIATED(elements%ELEMENTS))
THEN 7281 CALL flagerror(
"Mesh topology already has elements associated",err,error,*998)
7283 IF(
ASSOCIATED(basis))
THEN 7284 mesh%TOPOLOGY(mesh_component_number)%PTR%meshComponentNumber=mesh_component_number
7285 ALLOCATE(elements%ELEMENTS(mesh%NUMBER_OF_ELEMENTS),stat=err)
7286 IF(err/=0)
CALL flagerror(
"Could not allocate individual elements",err,error,*999)
7287 elements%NUMBER_OF_ELEMENTS=mesh%NUMBER_OF_ELEMENTS
7291 elements%ELEMENTS_FINISHED=.false.
7293 DO ne=1,elements%NUMBER_OF_ELEMENTS
7294 CALL mesh_topology_element_initialise(elements%ELEMENTS(ne),err,error,*999)
7295 elements%ELEMENTS(ne)%GLOBAL_NUMBER=ne
7296 elements%ELEMENTS(ne)%USER_NUMBER=ne
7297 CALL tree_item_insert(elements%ELEMENTS_TREE,ne,ne,insert_status,err,error,*999)
7298 elements%ELEMENTS(ne)%BASIS=>basis
7299 ALLOCATE(elements%ELEMENTS(ne)%USER_ELEMENT_NODES(basis%NUMBER_OF_NODES),stat=err)
7300 IF(err/=0)
CALL flagerror(
"Could not allocate user element nodes",err,error,*999)
7301 ALLOCATE(elements%ELEMENTS(ne)%GLOBAL_ELEMENT_NODES(basis%NUMBER_OF_NODES),stat=err)
7302 IF(err/=0)
CALL flagerror(
"Could not allocate global element nodes",err,error,*999)
7303 elements%ELEMENTS(ne)%USER_ELEMENT_NODES=1
7304 elements%ELEMENTS(ne)%GLOBAL_ELEMENT_NODES=1
7305 ALLOCATE(elements%ELEMENTS(ne)%USER_ELEMENT_NODE_VERSIONS(basis%MAXIMUM_NUMBER_OF_DERIVATIVES, &
7306 & basis%NUMBER_OF_NODES),stat=err)
7307 IF(err/=0)
CALL flagerror(
"Could not allocate global element nodes versions",err,error,*999)
7308 elements%ELEMENTS(ne)%USER_ELEMENT_NODE_VERSIONS = 1
7311 CALL flagerror(
"Basis is not associated",err,error,*999)
7315 CALL flagerror(
"Mesh topology elements is not associated",err,error,*998)
7318 CALL flagerror(
"Mesh topology is not associated",err,error,*998)
7322 local_error=
"The specified mesh component number of "//
trim(
number_to_vstring(mesh_component_number,
"*",err,error))// &
7323 &
" is invalid. The component number must be between 1 and "// &
7325 CALL flagerror(local_error,err,error,*998)
7328 CALL flagerror(
"Mesh is not associated",err,error,*998)
7331 exits(
"MESH_TOPOLOGY_ELEMENTS_CREATE_START")
7333 999
CALL mesh_topology_elements_finalise(elements,dummy_err,dummy_error,*998)
7334 998
NULLIFY(elements)
7335 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_CREATE_START",err,error)
7338 END SUBROUTINE mesh_topology_elements_create_start
7345 SUBROUTINE mesh_topology_elements_destroy(ELEMENTS,ERR,ERROR,*)
7349 INTEGER(INTG),
INTENT(OUT) :: err
7353 enters(
"MESH_TOPOLOGY_ELEMENTS_DESTROY",err,error,*999)
7355 IF(
ASSOCIATED(elements))
THEN 7356 CALL mesh_topology_elements_finalise(elements,err,error,*999)
7358 CALL flagerror(
"Mesh topology is not associated",err,error,*999)
7361 exits(
"MESH_TOPOLOGY_ELEMENTS_DESTROY")
7363 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_DESTROY",err,error)
7365 END SUBROUTINE mesh_topology_elements_destroy
7372 SUBROUTINE mesh_topology_element_finalise(ELEMENT,ERR,ERROR,*)
7376 INTEGER(INTG),
INTENT(OUT) :: err
7379 INTEGER(INTG) :: nic
7381 enters(
"MESH_TOPOLOGY_ELEMENT_FINALISE",err,error,*999)
7383 IF(
ALLOCATED(element%USER_ELEMENT_NODE_VERSIONS))
DEALLOCATE(element%USER_ELEMENT_NODE_VERSIONS)
7384 IF(
ALLOCATED(element%USER_ELEMENT_NODES))
DEALLOCATE(element%USER_ELEMENT_NODES)
7385 IF(
ALLOCATED(element%GLOBAL_ELEMENT_NODES))
DEALLOCATE(element%GLOBAL_ELEMENT_NODES)
7386 IF(
ALLOCATED(element%MESH_ELEMENT_NODES))
DEALLOCATE(element%MESH_ELEMENT_NODES)
7387 IF(
ALLOCATED(element%ADJACENT_ELEMENTS))
THEN 7388 DO nic=lbound(element%ADJACENT_ELEMENTS,1),ubound(element%ADJACENT_ELEMENTS,1)
7389 CALL mesh_adjacent_element_finalise(element%ADJACENT_ELEMENTS(nic),err,error,*999)
7391 DEALLOCATE(element%ADJACENT_ELEMENTS)
7394 exits(
"MESH_TOPOLOGY_ELEMENT_FINALISE")
7396 999 errorsexits(
"MESH_TOPOLOGY_ELEMENT_FINALISE",err,error)
7398 END SUBROUTINE mesh_topology_element_finalise
7405 SUBROUTINE mesh_topology_elements_get(MESH,MESH_COMPONENT_NUMBER,ELEMENTS,ERR,ERROR,*)
7409 INTEGER(INTG),
INTENT(IN) :: mesh_component_number
7411 INTEGER(INTG),
INTENT(OUT) :: err
7416 enters(
"MESH_TOPOLOGY_ELEMENTS_GET",err,error,*998)
7418 IF(
ASSOCIATED(mesh))
THEN 7419 IF(mesh_component_number>0.AND.mesh_component_number<=mesh%NUMBER_OF_COMPONENTS)
THEN 7420 IF(
ASSOCIATED(elements))
THEN 7421 CALL flagerror(
"Elements is already associated.",err,error,*998)
7423 IF(
ASSOCIATED(mesh%TOPOLOGY(mesh_component_number)%PTR))
THEN 7424 IF(
ASSOCIATED(mesh%TOPOLOGY(mesh_component_number)%PTR%ELEMENTS))
THEN 7425 elements=>mesh%TOPOLOGY(mesh_component_number)%PTR%ELEMENTS
7427 CALL flagerror(
"Mesh topology elements is not associated",err,error,*999)
7430 CALL flagerror(
"Mesh topology is not associated",err,error,*999)
7434 local_error=
"The specified mesh component number of "//
trim(
number_to_vstring(mesh_component_number,
"*",err,error))// &
7435 &
" is invalid. The component number must be between 1 and "// &
7437 CALL flagerror(local_error,err,error,*999)
7440 CALL flagerror(
"Mesh is not associated",err,error,*998)
7443 exits(
"MESH_TOPOLOGY_ELEMENTS_GET")
7445 999
NULLIFY(elements)
7446 998 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_GET",err,error)
7449 END SUBROUTINE mesh_topology_elements_get
7456 SUBROUTINE mesh_topology_element_initialise(ELEMENT,ERR,ERROR,*)
7460 INTEGER(INTG),
INTENT(OUT) :: err
7464 enters(
"MESH_TOPOLOGY_ELEMENT_INITIALISE",err,error,*999)
7466 element%USER_NUMBER=0
7467 element%GLOBAL_NUMBER=0
7468 NULLIFY(element%BASIS)
7469 element%BOUNDARY_ELEMENT=.false.
7471 exits(
"MESH_TOPOLOGY_ELEMENT_INITIALISE")
7473 999 errorsexits(
"MESH_TOPOLOGY_ELEMENT_INITIALISE",err,error)
7475 END SUBROUTINE mesh_topology_element_initialise
7484 SUBROUTINE mesh_topology_elements_element_basis_get(GLOBAL_NUMBER,ELEMENTS,BASIS,ERR,ERROR,*)
7487 INTEGER(INTG),
INTENT(IN) :: global_number
7490 INTEGER(INTG),
INTENT(OUT) :: err
7496 enters(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_GET",err,error,*999)
7498 IF(
ASSOCIATED(elements))
THEN 7499 IF(.NOT.elements%ELEMENTS_FINISHED)
THEN 7500 CALL flagerror(
"Elements have been finished",err,error,*999)
7502 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7503 element=>elements%ELEMENTS(global_number)
7504 basis=>element%BASIS
7507 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))
7508 CALL flagerror(local_error,err,error,*999)
7512 CALL flagerror(
"Elements is not associated",err,error,*999)
7515 exits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_GET")
7517 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_GET",err,error)
7520 END SUBROUTINE mesh_topology_elements_element_basis_get
7527 SUBROUTINE mesh_topology_elements_element_basis_set(GLOBAL_NUMBER,ELEMENTS,BASIS,ERR,ERROR,*)
7530 INTEGER(INTG),
INTENT(IN) :: global_number
7533 INTEGER(INTG),
INTENT(OUT) :: err
7536 INTEGER(INTG),
ALLOCATABLE :: new_user_element_nodes(:),new_global_element_nodes(:),new_user_element_node_versions(:,:)
7537 INTEGER(INTG) :: overlapping_number_nodes,overlapping_number_derivatives
7541 enters(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_SET",err,error,*999)
7543 IF(
ASSOCIATED(elements))
THEN 7544 IF(elements%ELEMENTS_FINISHED)
THEN 7545 CALL flagerror(
"Elements have been finished",err,error,*999)
7547 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7548 IF(
ASSOCIATED(basis))
THEN 7549 element=>elements%ELEMENTS(global_number)
7550 IF(element%BASIS%NUMBER_OF_NODES/=basis%NUMBER_OF_NODES.OR. &
7551 & element%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES/=basis%MAXIMUM_NUMBER_OF_DERIVATIVES)
THEN 7553 ALLOCATE(new_user_element_nodes(basis%NUMBER_OF_NODES),stat=err)
7554 IF(err/=0)
CALL flagerror(
"Could not allocate new user element nodes",err,error,*999)
7555 ALLOCATE(new_global_element_nodes(basis%NUMBER_OF_NODES),stat=err)
7556 IF(err/=0)
CALL flagerror(
"Could not allocate new user element nodes",err,error,*999)
7557 ALLOCATE(new_user_element_node_versions(basis%MAXIMUM_NUMBER_OF_DERIVATIVES, &
7558 & basis%NUMBER_OF_NODES),stat=err)
7559 IF(err/=0)
CALL flagerror(
"Could not allocate element node versions",err,error,*999)
7561 overlapping_number_nodes=min(basis%NUMBER_OF_NODES,element%BASIS%NUMBER_OF_NODES)
7562 overlapping_number_derivatives=min(basis%MAXIMUM_NUMBER_OF_DERIVATIVES,element%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES)
7565 new_user_element_node_versions=1
7566 new_user_element_nodes(overlapping_number_nodes+1:)=0
7567 new_global_element_nodes(overlapping_number_nodes+1:)=0
7569 new_user_element_nodes(1:overlapping_number_nodes)=element%USER_ELEMENT_NODES(1:overlapping_number_nodes)
7570 new_global_element_nodes(1:overlapping_number_nodes)=element%GLOBAL_ELEMENT_NODES(1:overlapping_number_nodes)
7571 new_user_element_node_versions(1:overlapping_number_derivatives,1:overlapping_number_nodes)= &
7572 & element%USER_ELEMENT_NODE_VERSIONS(1:overlapping_number_derivatives,1:overlapping_number_nodes)
7575 CALL move_alloc(new_user_element_node_versions,element%USER_ELEMENT_NODE_VERSIONS)
7576 CALL move_alloc(new_user_element_nodes,element%USER_ELEMENT_NODES)
7577 CALL move_alloc(new_global_element_nodes,element%GLOBAL_ELEMENT_NODES)
7579 element%BASIS=>basis
7581 CALL flagerror(
"Basis is not associated",err,error,*999)
7585 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))
7586 CALL flagerror(local_error,err,error,*999)
7590 CALL flagerror(
"Elements is not associated",err,error,*999)
7593 exits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_SET")
7595 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_SET",err,error)
7598 END SUBROUTINE mesh_topology_elements_element_basis_set
7605 SUBROUTINE mesh_topology_elements_adjacent_element_get(GLOBAL_NUMBER,ELEMENTS,ADJACENT_ELEMENT_XI,ADJACENT_ELEMENT_NUMBER, &
7609 INTEGER(INTG),
INTENT(IN) :: global_number
7611 INTEGER(INTG),
INTENT(IN) :: adjacent_element_xi
7612 INTEGER(INTG),
INTENT(OUT) :: adjacent_element_number
7613 INTEGER(INTG),
INTENT(OUT) :: err
7618 enters(
"MESH_TOPOLOGY_ELEMENTS_ADJACENT_ELEMENT_GET",err,error,*999)
7620 IF(
ASSOCIATED(elements))
THEN 7621 IF(.NOT.elements%ELEMENTS_FINISHED)
THEN 7622 CALL flagerror(
"Elements have not been finished",err,error,*999)
7624 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7625 IF(adjacent_element_xi>=-elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_XI .AND. &
7626 & adjacent_element_xi<=elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_XI)
THEN 7627 IF(elements%ELEMENTS(global_number)%ADJACENT_ELEMENTS(adjacent_element_xi)%NUMBER_OF_ADJACENT_ELEMENTS > 0)
THEN 7628 adjacent_element_number=elements%ELEMENTS(global_number)%ADJACENT_ELEMENTS(adjacent_element_xi)%ADJACENT_ELEMENTS(1)
7630 adjacent_element_number=0
7633 local_error=
"The specified adjacent element xi is invalid. The supplied xi is "// &
7635 &
trim(
number_to_vstring(elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_XI,
"*",err,error))//
" and <="// &
7637 CALL flagerror(local_error,err,error,*999)
7641 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))
7642 CALL flagerror(local_error,err,error,*999)
7646 CALL flagerror(
"Elements is not associated",err,error,*999)
7649 exits(
"MESH_TOPOLOGY_ELEMENTS_ADJACENT_ELEMENT_GET")
7651 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_ADJACENT_ELEMENT_GET",err,error)
7654 END SUBROUTINE mesh_topology_elements_adjacent_element_get
7661 SUBROUTINE mesh_topology_elements_element_nodes_get(GLOBAL_NUMBER,ELEMENTS,USER_ELEMENT_NODES,ERR,ERROR,*)
7664 INTEGER(INTG),
INTENT(IN) :: global_number
7666 INTEGER(INTG),
INTENT(OUT) :: user_element_nodes(:)
7667 INTEGER(INTG),
INTENT(OUT) :: err
7672 enters(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_GET",err,error,*999)
7674 IF(
ASSOCIATED(elements))
THEN 7675 IF(.NOT.elements%ELEMENTS_FINISHED)
THEN 7676 CALL flagerror(
"Elements have not been finished",err,error,*999)
7678 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7679 IF(
SIZE(user_element_nodes,1)>=
SIZE(elements%ELEMENTS(global_number)%USER_ELEMENT_NODES,1))
THEN 7680 user_element_nodes=elements%ELEMENTS(global_number)%USER_ELEMENT_NODES
7682 local_error=
"The size of USER_ELEMENT_NODES is too small. The supplied size is "// &
7684 &
trim(
number_to_vstring(
SIZE(elements%ELEMENTS(global_number)%USER_ELEMENT_NODES,1),
"*",err,error))//
"." 7685 CALL flagerror(local_error,err,error,*999)
7689 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))
7690 CALL flagerror(local_error,err,error,*999)
7694 CALL flagerror(
"Elements is not associated",err,error,*999)
7697 exits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_GET")
7699 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_GET",err,error)
7702 END SUBROUTINE mesh_topology_elements_element_nodes_get
7709 SUBROUTINE mesh_topology_elements_element_nodes_set(GLOBAL_NUMBER,ELEMENTS,USER_ELEMENT_NODES,ERR,ERROR,*)
7712 INTEGER(INTG),
INTENT(IN) :: global_number
7714 INTEGER(INTG),
INTENT(IN) :: user_element_nodes(:)
7715 INTEGER(INTG),
INTENT(OUT) :: err
7718 INTEGER(INTG) :: nn,number_of_bad_nodes,global_node_number
7719 INTEGER(INTG),
ALLOCATABLE :: global_element_nodes(:),bad_nodes(:)
7720 LOGICAL :: element_nodes_ok,node_exists
7725 TYPE(
region_type),
POINTER :: parent_region,region
7728 enters(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_SET",err,error,*999)
7730 IF(
ASSOCIATED(elements))
THEN 7731 IF(elements%ELEMENTS_FINISHED)
THEN 7732 CALL flagerror(
"Elements have been finished.",err,error,*999)
7734 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7735 IF(
SIZE(user_element_nodes,1)==elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES)
THEN 7736 meshcomponenttopology=>elements%meshComponentTopology
7737 IF(
ASSOCIATED(meshcomponenttopology))
THEN 7738 mesh=>meshcomponenttopology%mesh
7739 IF(
ASSOCIATED(mesh))
THEN 7741 IF(
ASSOCIATED(region))
THEN 7744 interface=>mesh%INTERFACE
7745 IF(
ASSOCIATED(interface))
THEN 7746 nodes=>interface%NODES
7747 parent_region=>interface%PARENT_REGION
7748 IF(.NOT.
ASSOCIATED(parent_region))
CALL flagerror(
"Mesh interface has no parent region.",err,error,*999)
7750 CALL flagerror(
"Elements mesh has no associated region or interface.",err,error,*999)
7753 IF(
ASSOCIATED(nodes))
THEN 7754 element_nodes_ok=.true.
7755 ALLOCATE(global_element_nodes(elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES),stat=err)
7756 IF(err/=0)
CALL flagerror(
"Could not allocate global element nodes.",err,error,*999)
7757 ALLOCATE(bad_nodes(elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES),stat=err)
7758 IF(err/=0)
CALL flagerror(
"Could not allocate bad nodes.",err,error,*999)
7759 number_of_bad_nodes=0
7760 DO nn=1,elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES
7761 CALL node_check_exists(nodes,user_element_nodes(nn),node_exists,global_node_number,err,error,*999)
7762 IF(node_exists)
THEN 7763 global_element_nodes(nn)=global_node_number
7765 number_of_bad_nodes=number_of_bad_nodes+1
7766 bad_nodes(number_of_bad_nodes)=user_element_nodes(nn)
7767 element_nodes_ok=.false.
7770 IF(element_nodes_ok)
THEN 7771 elements%ELEMENTS(global_number)%USER_ELEMENT_NODES=user_element_nodes
7772 elements%ELEMENTS(global_number)%GLOBAL_ELEMENT_NODES=global_element_nodes
7774 IF(number_of_bad_nodes==1)
THEN 7775 IF(
ASSOCIATED(region))
THEN 7776 local_error=
"The element user node number of "//
trim(
number_to_vstring(bad_nodes(1),
"*",err,error))// &
7779 local_error=
"The element user node number of "//
trim(
number_to_vstring(bad_nodes(1),
"*",err,error))// &
7780 &
" is not defined in interface number "// &
7782 &
" of parent region number "//
trim(
number_to_vstring(parent_region%USER_NUMBER,
"*",err,error))//
"." 7786 DO nn=2,number_of_bad_nodes-1
7789 IF(
ASSOCIATED(region))
THEN 7790 local_error=local_error//
" & "//
trim(
number_to_vstring(bad_nodes(number_of_bad_nodes),
"*",err,error))// &
7791 &
" are not defined in region number "//
trim(
number_to_vstring(region%USER_NUMBER,
"*",err,error))//
"." 7793 local_error=local_error//
" & "//
trim(
number_to_vstring(bad_nodes(number_of_bad_nodes),
"*",err,error))// &
7794 &
" are not defined in interface number "// &
7799 CALL flagerror(local_error,err,error,*999)
7802 IF(
ASSOCIATED(region))
THEN 7803 CALL flagerror(
"The elements mesh region does not have any associated nodes.",err,error,*999)
7805 CALL flagerror(
"The elements mesh interface does not have any associated nodes.",err,error,*999)
7809 CALL flagerror(
"The mesh component topology mesh is not associated.",err,error,*999)
7812 CALL flagerror(
"The elements mesh component topology is not associated.",err,error,*999)
7815 CALL flagerror(
"Number of element nodes does not match number of basis nodes for this element.",err,error,*999)
7818 local_error=
"The specified global element number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
7819 &
" is invalid. The global element number should be between 1 and "// &
7821 CALL flagerror(local_error,err,error,*999)
7825 CALL flagerror(
"Elements is not associated.",err,error,*999)
7828 exits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_SET")
7830 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_ELEMENT_NODES_SET",err,error)
7833 END SUBROUTINE mesh_topology_elements_element_nodes_set
7840 SUBROUTINE meshelements_elementnodeversionset(GLOBAL_NUMBER,ELEMENTS,VERSION_NUMBER,DERIVATIVE_NUMBER, &
7841 & user_element_node_index,err,error,*)
7844 INTEGER(INTG),
INTENT(IN) :: global_number
7846 INTEGER(INTG),
INTENT(IN) :: version_number
7847 INTEGER(INTG),
INTENT(IN) :: derivative_number
7848 INTEGER(INTG),
INTENT(IN) :: user_element_node_index
7849 INTEGER(INTG),
INTENT(OUT) :: err
7857 TYPE(
region_type),
POINTER :: parent_region,region
7860 enters(
"MeshElements_ElementNodeVersionSet",err,error,*999)
7862 IF(
ASSOCIATED(elements))
THEN 7863 IF(elements%ELEMENTS_FINISHED)
THEN 7864 CALL flagerror(
"Elements have been finished.",err,error,*999)
7866 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 7867 IF(user_element_node_index>=1.AND.user_element_node_index<=elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES)
THEN 7868 meshcomponenttopology=>elements%meshComponentTopology
7869 IF(
ASSOCIATED(meshcomponenttopology))
THEN 7870 mesh=>meshcomponenttopology%mesh
7871 IF(
ASSOCIATED(mesh))
THEN 7873 IF(
ASSOCIATED(region))
THEN 7876 interface=>mesh%INTERFACE
7877 IF(
ASSOCIATED(interface))
THEN 7878 nodes=>interface%NODES
7879 parent_region=>interface%PARENT_REGION
7880 IF(.NOT.
ASSOCIATED(parent_region))
CALL flagerror(
"Mesh interface has no parent region.",err,error,*999)
7882 CALL flagerror(
"Elements mesh has no associated region or interface.",err,error,*999)
7885 IF(derivative_number>=1.AND.derivative_number<=elements%ELEMENTS(global_number)%BASIS% &
7886 & number_of_derivatives(user_element_node_index))
THEN 7887 IF(version_number>=1)
THEN 7888 elements%ELEMENTS(global_number)%USER_ELEMENT_NODE_VERSIONS(derivative_number,user_element_node_index) &
7893 & err,error))//
" is invalid. The element node index should be greater than 1." 7894 CALL flagerror(local_error,err,error,*999)
7897 local_error=
"The specified node derivative number of "//
trim(
number_to_vstring(derivative_number,
"*", &
7898 & err,error))//
" is invalid. The element node derivative index should be between 1 and "// &
7900 & user_element_node_index),
"*",err,error))//
"." 7901 CALL flagerror(local_error,err,error,*999)
7904 CALL flagerror(
"The mesh component topology mesh is not associated.",err,error,*999)
7907 CALL flagerror(
"The elements mesh component topology is not associated.",err,error,*999)
7910 local_error=
"The specified element node index of "//
trim(
number_to_vstring(user_element_node_index,
"*",err,error))// &
7911 &
" is invalid. The element node index should be between 1 and "// &
7912 &
trim(
number_to_vstring(elements%ELEMENTS(global_number)%BASIS%NUMBER_OF_NODES,
"*",err,error))//
"." 7913 CALL flagerror(local_error,err,error,*999)
7916 local_error=
"The specified global element number of "//
trim(
number_to_vstring(global_number,
"*",err,error))// &
7917 &
" is invalid. The global element number should be between 1 and "// &
7919 CALL flagerror(local_error,err,error,*999)
7923 CALL flagerror(
"Elements is not associated.",err,error,*999)
7926 exits(
"MeshElements_ElementNodeVersionSet")
7928 999 errorsexits(
"MeshElements_ElementNodeVersionSet",err,error)
7931 END SUBROUTINE meshelements_elementnodeversionset
7938 SUBROUTINE meshtopology_elementsadjacentelementscalculate(TOPOLOGY,ERR,ERROR,*)
7942 INTEGER(INTG),
INTENT(OUT) :: err
7945 INTEGER(INTG) :: j,ne,ne1,nep1,ni,nic,nn,nn1,nn2,nn3,node_idx,np,np1,dummy_err,face_xi(2),face_xic(3),node_position_index(4)
7946 INTEGER(INTG) :: xi_direction,direction_index,xi_dir_check,xi_dir_search,number_node_matches
7947 INTEGER(INTG) :: number_surrounding,number_of_nodes_xic(4)
7948 INTEGER(INTG),
ALLOCATABLE :: node_matches(:),adjacent_elements(:)
7949 LOGICAL :: xi_collapsed,face_collapsed(-3:3),subset
7950 TYPE(
list_type),
POINTER :: node_match_list
7955 NULLIFY(node_match_list)
7957 NULLIFY(adjacent_elements_list(nic)%PTR)
7960 enters(
"MeshTopology_ElementsAdjacentElementsCalculate",err,error,*999)
7962 IF(
ASSOCIATED(topology))
THEN 7963 IF(
ASSOCIATED(topology%NODES))
THEN 7964 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 7966 DO ne=1,topology%ELEMENTS%NUMBER_OF_ELEMENTS
7968 basis=>topology%ELEMENTS%ELEMENTS(ne)%BASIS
7969 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
7970 NULLIFY(adjacent_elements_list(nic)%PTR)
7976 number_of_nodes_xic=1
7977 number_of_nodes_xic(1:basis%NUMBER_OF_XI_COORDINATES)=basis%NUMBER_OF_NODES_XIC(1:basis%NUMBER_OF_XI_COORDINATES)
7979 CALL list_item_add(adjacent_elements_list(0)%PTR,topology%ELEMENTS%ELEMENTS(ne)%GLOBAL_NUMBER,err,error,*999)
7980 SELECT CASE(basis%TYPE)
7983 node_position_index=1
7985 DO ni=1,basis%NUMBER_OF_XI
7990 node_position_index(ni)=1
7992 DO direction_index=-1,1,2
7993 xi_direction=direction_index*ni
7994 face_collapsed(xi_direction)=.false.
7996 xi_dir_check=face_xi(j)
7997 IF(xi_dir_check<=basis%NUMBER_OF_XI)
THEN 7998 xi_dir_search=face_xi(3-j)
7999 node_position_index(xi_dir_search)=1
8001 DO WHILE(node_position_index(xi_dir_search)<=number_of_nodes_xic(xi_dir_search).AND.xi_collapsed)
8003 node_position_index(xi_dir_check)=1
8004 nn1=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2),node_position_index(3),1)
8006 node_position_index(xi_dir_check)=2
8007 nn2=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2),node_position_index(3),1)
8008 IF(nn1/=0.AND.nn2/=0)
THEN 8009 IF(topology%ELEMENTS%ELEMENTS(ne)%MESH_ELEMENT_NODES(nn1)/= &
8010 & topology%ELEMENTS%ELEMENTS(ne)%MESH_ELEMENT_NODES(nn2)) xi_collapsed=.true.
8012 node_position_index(xi_dir_search)=node_position_index(xi_dir_search)+1
8014 IF(xi_collapsed) face_collapsed(xi_direction)=.true.
8017 node_position_index(ni)=number_of_nodes_xic(ni)
8021 DO ni=1,basis%NUMBER_OF_XI
8026 DO direction_index=-1,1,2
8027 xi_direction=direction_index*ni
8029 NULLIFY(node_match_list)
8035 IF(direction_index==-1)
THEN 8036 node_position_index(ni)=1
8038 node_position_index(ni)=number_of_nodes_xic(ni)
8043 IF(face_collapsed(xi_direction).AND..NOT.face_collapsed(-xi_direction))
THEN 8047 DO nn1=1,number_of_nodes_xic(face_xi(1))
8048 node_position_index(face_xi(1))=nn1
8049 DO nn2=1,number_of_nodes_xic(face_xi(2))
8050 node_position_index(face_xi(2))=nn2
8051 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2),node_position_index(3),1)
8053 np=topology%ELEMENTS%ELEMENTS(ne)%MESH_ELEMENT_NODES(nn)
8061 number_surrounding=0
8062 IF(number_node_matches>0)
THEN 8065 DO nep1=1,topology%NODES%NODES(np1)%numberOfSurroundingElements
8066 ne1=topology%NODES%NODES(np1)%surroundingElements(nep1)
8072 CALL list_subset_of(node_matches(1:number_node_matches),topology%ELEMENTS%ELEMENTS(ne1)% &
8073 & mesh_element_nodes,subset,err,error,*999)
8075 CALL list_item_add(adjacent_elements_list(xi_direction)%PTR,ne1,err,error,*999)
8076 number_surrounding=number_surrounding+1
8081 IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
8086 DO nic=1,basis%NUMBER_OF_XI_COORDINATES
8092 NULLIFY(node_match_list)
8097 node_position_index(nic)=1
8099 DO nn1=1,number_of_nodes_xic(face_xic(1))
8100 node_position_index(face_xic(1))=nn1
8101 DO nn2=1,number_of_nodes_xic(face_xic(2))
8102 node_position_index(face_xic(2))=nn2
8103 DO nn3=1,number_of_nodes_xic(face_xic(3))
8104 node_position_index(face_xic(3))=nn3
8105 nn=basis%NODE_POSITION_INDEX_INV(node_position_index(1),node_position_index(2),node_position_index(3), &
8106 node_position_index(4))
8108 np=topology%ELEMENTS%ELEMENTS(ne)%MESH_ELEMENT_NODES(nn)
8116 IF(number_node_matches>0)
THEN 8118 DO node_idx=1,number_node_matches
8119 np1=node_matches(node_idx)
8120 DO nep1=1,topology%NODES%NODES(np1)%numberOfSurroundingElements
8121 ne1=topology%NODES%NODES(np1)%surroundingElements(nep1)
8127 CALL list_subset_of(node_matches(1:number_node_matches),topology%ELEMENTS%ELEMENTS(ne1)% &
8128 & mesh_element_nodes,subset,err,error,*999)
8130 CALL list_item_add(adjacent_elements_list(nic)%PTR,ne1,err,error,*999)
8136 IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
8139 CALL flagerror(
"Not implemented.",err,error,*999)
8141 CALL flagerror(
"Not implemented.",err,error,*999)
8143 CALL flagerror(
"Not implemented.",err,error,*999)
8145 CALL flagerror(
"Not implemented.",err,error,*999)
8147 CALL flagerror(
"Not implemented.",err,error,*999)
8151 CALL flagerror(local_error,err,error,*999)
8154 ALLOCATE(topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(-basis%NUMBER_OF_XI_COORDINATES: &
8155 & basis%NUMBER_OF_XI_COORDINATES),stat=err)
8156 IF(err/=0)
CALL flagerror(
"Could not allocate adjacent elements.",err,error,*999)
8157 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
8158 CALL mesh_adjacent_element_initialise(topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic),err,error,*999)
8161 & adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS,adjacent_elements,err,error,*999)
8162 ALLOCATE(topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%ADJACENT_ELEMENTS(topology%ELEMENTS%ELEMENTS(ne)% &
8163 adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS),stat=err)
8164 IF(err/=0)
CALL flagerror(
"Could not allocate element adjacent elements.",err,error,*999)
8165 topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%ADJACENT_ELEMENTS(1:topology%ELEMENTS%ELEMENTS(ne)% &
8166 adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS) = adjacent_elements(1:topology%ELEMENTS% &
8167 & elements(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS)
8168 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
8172 CALL flagerror(
"Mesh topology elements is not associated.",err,error,*999)
8175 CALL flagerror(
"Mesh topology nodes is not associated.",err,error,*999)
8178 CALL flagerror(
"Mesh topology is not allocated.",err,error,*999)
8183 DO ne=1,topology%ELEMENTS%NUMBER_OF_ELEMENTS
8184 basis=>topology%ELEMENTS%ELEMENTS(ne)%BASIS
8188 DO nic=-basis%NUMBER_OF_XI_COORDINATES,basis%NUMBER_OF_XI_COORDINATES
8191 & topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS,err,error,*999)
8192 IF(topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)%NUMBER_OF_ADJACENT_ELEMENTS>0)
THEN 8194 & adjacent_elements(nic)%NUMBER_OF_ADJACENT_ELEMENTS,8,8,topology%ELEMENTS%ELEMENTS(ne)%ADJACENT_ELEMENTS(nic)% &
8195 & adjacent_elements,
'(" Adjacent elements :",8(X,I8))',
'(30x,8(X,I8))',err,error,*999)
8201 exits(
"MeshTopology_ElementsAdjacentElementsCalculate")
8203 999
IF(
ALLOCATED(node_matches))
DEALLOCATE(node_matches)
8204 IF(
ALLOCATED(adjacent_elements))
DEALLOCATE(adjacent_elements)
8205 IF(
ASSOCIATED(node_match_list))
CALL list_destroy(node_match_list,dummy_err,dummy_error,*998)
8207 IF(
ASSOCIATED(adjacent_elements_list(nic)%PTR))
CALL list_destroy(adjacent_elements_list(nic)%PTR,dummy_err,dummy_error,*997)
8209 997
errors(
"MeshTopology_ElementsAdjacentElementsCalculate",err,error)
8210 exits(
"MeshTopology_ElementsAdjacentElementsCalculate")
8213 END SUBROUTINE meshtopology_elementsadjacentelementscalculate
8220 SUBROUTINE mesh_topology_elements_finalise(ELEMENTS,ERR,ERROR,*)
8224 INTEGER(INTG),
INTENT(OUT) :: err
8229 enters(
"MESH_TOPOLOGY_ELEMENTS_FINALISE",err,error,*999)
8231 IF(
ASSOCIATED(elements))
THEN 8232 DO ne=1,elements%NUMBER_OF_ELEMENTS
8233 CALL mesh_topology_element_finalise(elements%ELEMENTS(ne),err,error,*999)
8235 DEALLOCATE(elements%ELEMENTS)
8236 IF(
ASSOCIATED(elements%ELEMENTS_TREE))
CALL tree_destroy(elements%ELEMENTS_TREE,err,error,*999)
8237 DEALLOCATE(elements)
8240 exits(
"MESH_TOPOLOGY_ELEMENTS_FINALISE")
8242 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_FINALISE",err,error)
8244 END SUBROUTINE mesh_topology_elements_finalise
8251 SUBROUTINE mesh_topology_elements_initialise(TOPOLOGY,ERR,ERROR,*)
8255 INTEGER(INTG),
INTENT(OUT) :: err
8259 enters(
"MESH_TOPOLOGY_ELEMENTS_INITIALISE",err,error,*999)
8261 IF(
ASSOCIATED(topology))
THEN 8262 IF(
ASSOCIATED(topology%ELEMENTS))
THEN 8263 CALL flagerror(
"Mesh already has topology elements associated",err,error,*999)
8265 ALLOCATE(topology%ELEMENTS,stat=err)
8266 IF(err/=0)
CALL flagerror(
"Could not allocate topology elements",err,error,*999)
8267 topology%ELEMENTS%NUMBER_OF_ELEMENTS=0
8268 topology%ELEMENTS%meshComponentTopology=>topology
8269 NULLIFY(topology%ELEMENTS%ELEMENTS)
8270 NULLIFY(topology%ELEMENTS%ELEMENTS_TREE)
8273 CALL flagerror(
"Topology is not associated",err,error,*999)
8276 exits(
"MESH_TOPOLOGY_ELEMENTS_INITIALISE")
8278 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_INITIALISE",err,error)
8280 END SUBROUTINE mesh_topology_elements_initialise
8287 SUBROUTINE mesh_topology_data_points_initialise(TOPOLOGY,ERR,ERROR,*)
8291 INTEGER(INTG),
INTENT(OUT) :: err
8295 enters(
"MESH_TOPOLOGY_DATA_POINTS_INITIALISE",err,error,*999)
8297 IF(
ASSOCIATED(topology))
THEN 8298 IF(
ASSOCIATED(topology%dataPoints))
THEN 8299 CALL flagerror(
"Mesh already has topology data points associated",err,error,*999)
8301 ALLOCATE(topology%dataPoints,stat=err)
8302 IF(err/=0)
CALL flagerror(
"Could not allocate topology data points",err,error,*999)
8303 topology%dataPoints%totalNumberOfProjectedData=0
8304 topology%dataPoints%meshComponentTopology=>topology
8307 CALL flagerror(
"Topology is not associated",err,error,*999)
8310 exits(
"MESH_TOPOLOGY_DATA_POINTS_INITIALISE")
8312 999 errorsexits(
"MESH_TOPOLOGY_DATA_POINTS_INITIALISE",err,error)
8314 END SUBROUTINE mesh_topology_data_points_initialise
8323 SUBROUTINE mesh_topology_elements_number_get(GLOBAL_NUMBER,USER_NUMBER,ELEMENTS,ERR,ERROR,*)
8326 INTEGER(INTG),
INTENT(IN) :: global_number
8327 INTEGER(INTG),
INTENT(OUT) :: user_number
8329 INTEGER(INTG),
INTENT(OUT) :: err
8334 enters(
"MESH_TOPOLOGY_ELEMENTS_NUMBER_SET",err,error,*999)
8336 IF(
ASSOCIATED(elements))
THEN 8337 IF(elements%ELEMENTS_FINISHED)
THEN 8338 CALL flagerror(
"Elements have been finished",err,error,*999)
8340 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 8341 user_number=elements%ELEMENTS(global_number)%USER_NUMBER
8344 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))
8345 CALL flagerror(local_error,err,error,*999)
8349 CALL flagerror(
"Elements is not associated",err,error,*999)
8352 exits(
"MESH_TOPOLOGY_ELEMENTS_NUMBER_GET")
8354 999 errorsexits(
"MESH_TOPOLOGY_ELEMENTS_NUMBER_GET",err,error)
8357 END SUBROUTINE mesh_topology_elements_number_get
8364 SUBROUTINE meshelements_elementusernumberget(GLOBAL_NUMBER,USER_NUMBER,ELEMENTS,ERR,ERROR,*)
8367 INTEGER(INTG),
INTENT(IN) :: global_number
8368 INTEGER(INTG),
INTENT(OUT) :: user_number
8370 INTEGER(INTG),
INTENT(OUT) :: err
8375 enters(
"MeshElements_ElementUserNumberGet",err,error,*999)
8377 IF(
ASSOCIATED(elements))
THEN 8378 IF(elements%ELEMENTS_FINISHED)
THEN 8379 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 8380 user_number=elements%ELEMENTS(global_number)%USER_NUMBER
8383 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))//
"." 8384 CALL flagerror(local_error,err,error,*999)
8387 CALL flagerror(
"Elements have not been finished.",err,error,*999)
8390 CALL flagerror(
"Elements is not associated.",err,error,*999)
8393 exits(
"MeshElements_ElementUserNumberGet")
8395 999 errorsexits(
"MeshElements_ElementUserNumberGet",err,error)
8399 END SUBROUTINE meshelements_elementusernumberget
8406 SUBROUTINE meshelements_elementusernumberset(GLOBAL_NUMBER,USER_NUMBER,ELEMENTS,ERR,ERROR,*)
8409 INTEGER(INTG),
INTENT(IN) :: global_number
8410 INTEGER(INTG),
INTENT(IN) :: user_number
8412 INTEGER(INTG),
INTENT(OUT) :: err
8416 INTEGER(INTG) :: global_element_number,insert_status
8420 enters(
"MeshElements_ElementUserNumberSet",err,error,*999)
8422 IF(
ASSOCIATED(elements))
THEN 8423 IF(elements%ELEMENTS_FINISHED)
THEN 8424 CALL flagerror(
"Elements have been finished.",err,error,*999)
8426 IF(global_number>=1.AND.global_number<=elements%NUMBER_OF_ELEMENTS)
THEN 8428 CALL tree_search(elements%ELEMENTS_TREE,user_number,tree_node,err,error,*999)
8429 IF(
ASSOCIATED(tree_node))
THEN 8430 CALL tree_node_value_get(elements%ELEMENTS_TREE,tree_node,global_element_number,err,error,*999)
8432 &
" is already used by global element number "// &
8434 CALL flagerror(local_error,err,error,*999)
8436 CALL tree_item_delete(elements%ELEMENTS_TREE,elements%ELEMENTS(global_number)%USER_NUMBER,err,error,*999)
8437 CALL tree_item_insert(elements%ELEMENTS_TREE,user_number,global_number,insert_status,err,error,*999)
8438 elements%ELEMENTS(global_number)%USER_NUMBER=user_number
8442 &
" is invalid. The limits are 1 to "//
trim(
number_to_vstring(elements%NUMBER_OF_ELEMENTS,
"*",err,error))//
"." 8443 CALL flagerror(local_error,err,error,*999)
8447 CALL flagerror(
"Elements is not associated.",err,error,*999)
8450 exits(
"MeshElements_ElementUserNumberSet")
8452 999 errorsexits(
"MeshElements_ElementUserNumberSet",err,error)
8455 END SUBROUTINE meshelements_elementusernumberset
8462 SUBROUTINE meshtopologyelementsusernumbersallset(elements,userNumbers,err,error,*)
8466 INTEGER(INTG),
INTENT(IN) :: usernumbers(:)
8467 INTEGER(INTG),
INTENT(OUT) :: err
8470 INTEGER(INTG) :: elementidx,insertstatus
8471 TYPE(
tree_type),
POINTER :: newelementstree
8474 NULLIFY(newelementstree)
8476 enters(
"MeshTopologyElementsUserNumbersAllSet",err,error,*999)
8478 IF(
ASSOCIATED(elements))
THEN 8479 IF(elements%ELEMENTS_FINISHED)
THEN 8480 CALL flagerror(
"Elements have been finished.",err,error,*999)
8482 IF(elements%NUMBER_OF_ELEMENTS==
SIZE(usernumbers,1))
THEN 8487 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8488 CALL tree_item_insert(newelementstree,usernumbers(elementidx),elementidx,insertstatus,err,error,*999)
8490 localerror=
"The specified user number of "//
trim(
numbertovstring(usernumbers(elementidx),
"*",err,error))// &
8492 &
" is a duplicate. The user element numbers must be unique." 8493 CALL flagerror(localerror,err,error,*999)
8496 CALL tree_destroy(elements%ELEMENTS_TREE,err,error,*999)
8497 elements%ELEMENTS_TREE=>newelementstree
8498 NULLIFY(newelementstree)
8499 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8500 elements%ELEMENTS(elementidx)%GLOBAL_NUMBER=elementidx
8501 elements%ELEMENTS(elementidx)%USER_NUMBER=usernumbers(elementidx)
8504 localerror=
"The number of specified element user numbers ("// &
8506 ") does not match number of elements ("// &
8508 CALL flagerror(localerror,err,error,*999)
8512 CALL flagerror(
"Elements is not associated.",err,error,*999)
8515 exits(
"MeshTopologyElementsUserNumbersAllSet")
8517 999
IF(
ASSOCIATED(newelementstree))
CALL tree_destroy(newelementstree,err,error,*998)
8518 998 errorsexits(
"MeshTopologyElementsUserNumbersAllSet",err,error)
8521 END SUBROUTINE meshtopologyelementsusernumbersallset
8528 SUBROUTINE meshtopologydatapointscalculateprojection(mesh,dataProjection,err,error,*)
8533 INTEGER(INTG),
INTENT(OUT) :: err
8540 INTEGER(INTG) :: datapointidx,elementidx,countidx,projectionnumber,globalcountidx,elementnumber
8542 enters(
"MeshTopologyDataPointsCalculateProjection",err,error,*999)
8544 IF(
ASSOCIATED(mesh))
THEN 8545 IF(dataprojection%DATA_PROJECTION_FINISHED)
THEN 8546 datapoints=>dataprojection%DATA_POINTS
8548 datapointstopology=>mesh%TOPOLOGY(1)%PTR%dataPoints
8550 projectionnumber=dataprojection%GLOBAL_NUMBER
8553 elements=>mesh%TOPOLOGY(1)%PTR%ELEMENTS
8554 ALLOCATE(datapointstopology%elementDataPoint(elements%NUMBER_OF_ELEMENTS),stat=err)
8555 IF(err/=0)
CALL flagerror(
"Could not allocate data points topology element.",err,error,*999)
8556 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8557 datapointstopology%elementDataPoint(elementidx)%elementNumber=elements%ELEMENTS(elementidx)%GLOBAL_NUMBER
8558 datapointstopology%elementDataPoint(elementidx)%numberOfProjectedData=0
8561 DO datapointidx=1,datapoints%NUMBER_OF_DATA_POINTS
8562 dataprojectionresult=>dataprojection%DATA_PROJECTION_RESULTS(datapointidx)
8563 elementnumber=dataprojectionresult%ELEMENT_NUMBER
8564 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8565 IF(datapointstopology%elementDataPoint(elementidx)%elementNumber==elementnumber)
THEN 8566 datapointstopology%elementDataPoint(elementidx)%numberOfProjectedData= &
8567 & datapointstopology%elementDataPoint(elementidx)%numberOfProjectedData+1;
8572 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8573 ALLOCATE(datapointstopology%elementDataPoint(elementidx)%dataIndices(datapointstopology% &
8574 & elementdatapoint(elementidx)%numberOfProjectedData),stat=err)
8575 IF(err/=0)
CALL flagerror(
"Could not allocate data points topology element data points.",err,error,*999)
8576 DO countidx=1,datapointstopology%elementDataPoint(elementidx)%numberOfProjectedData
8577 datapointstopology%elementDataPoint(elementidx)%dataIndices(countidx)%userNumber=0
8578 datapointstopology%elementDataPoint(elementidx)%dataIndices(countidx)%globalNumber=0
8583 datapointstopology%totalNumberOfProjectedData=0
8584 DO datapointidx=1,datapoints%NUMBER_OF_DATA_POINTS
8585 dataprojectionresult=>dataprojection%DATA_PROJECTION_RESULTS(datapointidx)
8586 elementnumber=dataprojectionresult%ELEMENT_NUMBER
8587 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8589 IF(datapointstopology%elementDataPoint(elementidx)%elementNumber==elementnumber)
THEN 8590 globalcountidx=globalcountidx+1
8592 DO WHILE(datapointstopology%elementDataPoint(elementidx)%dataIndices(countidx)%globalNumber/=0)
8595 datapointstopology%elementDataPoint(elementidx)%dataIndices(countidx)%userNumber=datapointidx
8596 datapointstopology%elementDataPoint(elementidx)%dataIndices(countidx)%globalNumber=datapointidx
8597 datapointstopology%totalNumberOfProjectedData=datapointstopology%totalNumberOfProjectedData+1
8602 ALLOCATE(datapointstopology%dataPoints(datapointstopology%totalNumberOfProjectedData),stat=err)
8603 IF(err/=0)
CALL flagerror(
"Could not allocate data points topology data points.",err,error,*999)
8606 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
8607 DO datapointidx=1,datapointstopology%elementDataPoint(elementidx)%numberOfProjectedData
8608 datapointstopology%dataPoints(countidx)%userNumber=datapointstopology%elementDataPoint(elementidx)% &
8609 & dataindices(datapointidx)%userNumber
8610 datapointstopology%dataPoints(countidx)%globalNumber=datapointstopology%elementDataPoint(elementidx)% &
8611 & dataindices(datapointidx)%globalNumber
8612 datapointstopology%dataPoints(countidx)%elementNumber=datapointstopology%elementDataPoint(elementidx)% &
8618 CALL flagerror(
"Data projection is not finished.",err,error,*999)
8621 CALL flagerror(
"Mesh is not associated.",err,error,*999)
8624 exits(
"MeshTopologyDataPointsCalculateProjection")
8626 999 errorsexits(
"MeshTopologyDataPointsCalculateProjection",err,error)
8628 END SUBROUTINE meshtopologydatapointscalculateprojection
8635 SUBROUTINE meshtopologyfinalise(mesh,err,error,*)
8639 INTEGER(INTG),
INTENT(OUT) :: err
8642 INTEGER(INTG) :: componentidx
8644 enters(
"MeshTopologyFinalise",err,error,*999)
8646 IF(
ASSOCIATED(mesh))
THEN 8647 DO componentidx=1,mesh%NUMBER_OF_COMPONENTS
8648 CALL meshtopologycomponentfinalise(mesh%topology(componentidx)%ptr,err,error,*999)
8650 DEALLOCATE(mesh%topology)
8652 CALL flagerror(
"Mesh is not associated.",err,error,*999)
8655 exits(
"MeshTopologyFinalise")
8657 999 errorsexits(
"MeshTopologyFinalise",err,error)
8660 END SUBROUTINE meshtopologyfinalise
8667 SUBROUTINE meshtopologycomponentfinalise(meshComponent,err,error,*)
8671 INTEGER(INTG),
INTENT(OUT) :: err
8675 enters(
"MeshTopologyComponentFinalise",err,error,*999)
8677 IF(
ASSOCIATED(meshcomponent))
THEN 8678 CALL meshtopologynodesfinalise(meshcomponent%nodes,err,error,*999)
8679 CALL mesh_topology_elements_finalise(meshcomponent%elements,err,error,*999)
8680 CALL meshtopologydofsfinalise(meshcomponent%dofs,err,error,*999)
8681 DEALLOCATE(meshcomponent)
8684 exits(
"MeshTopologyComponentFinalise")
8686 999 errorsexits(
"MeshTopologyComponentFinalise",err,error)
8689 END SUBROUTINE meshtopologycomponentfinalise
8696 SUBROUTINE meshtopologyinitialise(mesh,err,error,*)
8700 INTEGER(INTG),
INTENT(OUT) :: err
8703 INTEGER(INTG) :: componentidx
8705 enters(
"MeshTopologyInitialise",err,error,*999)
8707 IF(
ASSOCIATED(mesh))
THEN 8708 IF(
ASSOCIATED(mesh%topology))
THEN 8709 CALL flagerror(
"Mesh already has topology associated.",err,error,*999)
8712 ALLOCATE(mesh%topology(mesh%NUMBER_OF_COMPONENTS),stat=err)
8713 IF(err/=0)
CALL flagerror(
"Mesh topology could not be allocated.",err,error,*999)
8714 DO componentidx=1,mesh%NUMBER_OF_COMPONENTS
8715 ALLOCATE(mesh%topology(componentidx)%ptr,stat=err)
8716 IF(err/=0)
CALL flagerror(
"Mesh topology component could not be allocated.",err,error,*999)
8717 mesh%topology(componentidx)%ptr%mesh=>mesh
8718 NULLIFY(mesh%topology(componentidx)%ptr%elements)
8719 NULLIFY(mesh%topology(componentidx)%ptr%nodes)
8720 NULLIFY(mesh%topology(componentidx)%ptr%dofs)
8721 NULLIFY(mesh%topology(componentidx)%ptr%dataPoints)
8723 CALL mesh_topology_elements_initialise(mesh%topology(componentidx)%ptr,err,error,*999)
8724 CALL meshtopologynodesinitialise(mesh%topology(componentidx)%ptr,err,error,*999)
8725 CALL meshtopologydofsinitialise(mesh%topology(componentidx)%ptr,err,error,*999)
8726 CALL mesh_topology_data_points_initialise(mesh%topology(componentidx)%ptr,err,error,*999)
8730 CALL flagerror(
"Mesh is not associated.",err,error,*999)
8733 exits(
"MeshTopologyInitialise")
8735 999 errorsexits(
"MeshTopologyInitialise",err,error)
8737 END SUBROUTINE meshtopologyinitialise
8744 SUBROUTINE meshtopologyelementcheckexistsmesh(mesh,meshComponentNumber,userElementNumber,elementExists,globalElementNumber, &
8749 INTEGER(INTG),
INTENT(IN) :: meshcomponentnumber
8750 INTEGER(INTG),
INTENT(IN) :: userelementnumber
8751 LOGICAL,
INTENT(OUT) :: elementexists
8752 INTEGER(INTG),
INTENT(OUT) :: globalelementnumber
8753 INTEGER(INTG),
INTENT(OUT) :: err
8760 enters(
"MeshTopologyElementCheckExistsMesh",err,error,*999)
8762 IF(
ASSOCIATED(mesh))
THEN 8763 IF(mesh%MESH_FINISHED)
THEN 8764 CALL mesh_topology_elements_get(mesh,meshcomponentnumber,elements,err,error,*999)
8765 CALL meshtopologyelementcheckexistsmeshelements(elements,userelementnumber,elementexists,globalelementnumber,err,error,*999)
8767 CALL flagerror(
"Mesh has not been finished.",err,error,*999)
8770 CALL flagerror(
"Mesh is not associated.",err,error,*999)
8773 exits(
"MeshTopologyElementCheckExistsMesh")
8775 999 errorsexits(
"MeshTopologyElementCheckExistsMesh",err,error)
8778 END SUBROUTINE meshtopologyelementcheckexistsmesh
8785 SUBROUTINE meshtopologyelementcheckexistsmeshelements(meshElements,userElementNumber,elementExists,globalElementNumber, &
8790 INTEGER(INTG),
INTENT(IN) :: userelementnumber
8791 LOGICAL,
INTENT(OUT) :: elementexists
8792 INTEGER(INTG),
INTENT(OUT) :: globalelementnumber
8793 INTEGER(INTG),
INTENT(OUT) :: err
8798 enters(
"MeshTopologyElementCheckExistsMesh",err,error,*999)
8800 elementexists=.false.
8801 globalelementnumber=0
8802 IF(
ASSOCIATED(meshelements))
THEN 8804 CALL tree_search(meshelements%ELEMENTS_TREE,userelementnumber,treenode,err,error,*999)
8805 IF(
ASSOCIATED(treenode))
THEN 8806 CALL tree_node_value_get(meshelements%ELEMENTS_TREE,treenode,globalelementnumber,err,error,*999)
8807 elementexists=.true.
8810 CALL flagerror(
"Mesh elements is not associated.",err,error,*999)
8813 exits(
"MeshTopologyElementCheckExistsMeshElements")
8815 999 errorsexits(
"MeshTopologyElementCheckExistsMeshElements",err,error)
8818 END SUBROUTINE meshtopologyelementcheckexistsmeshelements
8825 SUBROUTINE meshtopologynodecheckexistsmesh(mesh,meshComponentNumber,userNodeNumber,nodeExists,meshNodeNumber,err,error,*)
8829 INTEGER(INTG),
INTENT(IN) :: meshcomponentnumber
8830 INTEGER(INTG),
INTENT(IN) :: usernodenumber
8831 LOGICAL,
INTENT(OUT) :: nodeexists
8832 INTEGER(INTG),
INTENT(OUT) :: meshnodenumber
8833 INTEGER(INTG),
INTENT(OUT) :: err
8836 INTEGER(INTG) :: globalnodenumber
8846 enters(
"MeshTopologyNodeCheckExistsMesh",err,error,*999)
8850 IF(
ASSOCIATED(mesh))
THEN 8851 IF(mesh%MESH_FINISHED)
THEN 8852 CALL meshtopologynodesget(mesh,meshcomponentnumber,meshnodes,err,error,*999)
8853 CALL meshregionget(mesh,region,err,error,*999)
8855 IF(
ASSOCIATED(nodes))
THEN 8856 CALL node_check_exists(nodes,usernodenumber,nodeexists,globalnodenumber,err,error,*999)
8858 CALL tree_search(meshnodes%nodesTree,globalnodenumber,treenode,err,error,*999)
8859 IF(
ASSOCIATED(treenode))
THEN 8864 CALL flagerror(
"Region nodes is not associated.",err,error,*999)
8867 CALL flagerror(
"Mesh has not been finished.",err,error,*999)
8870 CALL flagerror(
"Mesh is not associated.",err,error,*999)
8873 exits(
"MeshTopologyNodeCheckExistsMesh")
8875 999 errorsexits(
"MeshTopologyNodeCheckExistsMesh",err,error)
8878 END SUBROUTINE meshtopologynodecheckexistsmesh
8885 SUBROUTINE meshtopologynodecheckexistsmeshnodes(meshNodes,userNodeNumber,nodeExists,meshNodeNumber,err,error,*)
8889 INTEGER(INTG),
INTENT(IN) :: usernodenumber
8890 LOGICAL,
INTENT(OUT) :: nodeexists
8891 INTEGER(INTG),
INTENT(OUT) :: meshnodenumber
8892 INTEGER(INTG),
INTENT(OUT) :: err
8895 INTEGER(INTG) :: globalnodenumber
8905 enters(
"MeshTopologyNodeCheckExistsMeshNodes",err,error,*999)
8909 IF(
ASSOCIATED(meshnodes))
THEN 8910 meshcomponenttopology=>meshnodes%meshComponentTopology
8911 IF(
ASSOCIATED(meshcomponenttopology))
THEN 8912 mesh=>meshcomponenttopology%mesh
8913 IF(
ASSOCIATED(mesh))
THEN 8914 IF(mesh%MESH_FINISHED)
THEN 8915 CALL meshregionget(mesh,region,err,error,*999)
8917 IF(
ASSOCIATED(nodes))
THEN 8918 CALL node_check_exists(nodes,usernodenumber,nodeexists,globalnodenumber,err,error,*999)
8920 CALL tree_search(meshnodes%nodesTree,globalnodenumber,treenode,err,error,*999)
8921 IF(
ASSOCIATED(treenode))
THEN 8926 CALL flagerror(
"Region nodes is not associated.",err,error,*999)
8929 CALL flagerror(
"Mesh has not been finished.",err,error,*999)
8932 CALL flagerror(
"Mesh component topology mesh is not associated.",err,error,*999)
8935 CALL flagerror(
"Mesh nodes mesh component topology is not associated.",err,error,*999)
8938 CALL flagerror(
"Mesh nodes is not associated.",err,error,*999)
8941 exits(
"MeshTopologyNodeCheckExistsMeshNodes")
8943 999 errorsexits(
"MeshTopologyNodeCheckExistsMeshNodes",err,error)
8946 END SUBROUTINE meshtopologynodecheckexistsmeshnodes
8953 SUBROUTINE meshtopologynodefinalise(node,err,error,*)
8957 INTEGER(INTG),
INTENT(OUT) :: err
8960 INTEGER(INTG) :: derivativeidx
8962 enters(
"MeshTopologyNodeFinalise",err,error,*999)
8964 IF(
ALLOCATED(node%derivatives))
THEN 8965 DO derivativeidx=1,node%numberOfDerivatives
8966 CALL meshtopologynodederivativefinalise(node%derivatives(derivativeidx),err,error,*999)
8968 DEALLOCATE(node%derivatives)
8970 IF(
ASSOCIATED(node%surroundingElements))
DEALLOCATE(node%surroundingElements)
8972 exits(
"MeshTopologyNodeFinalise")
8974 999 errorsexits(
"MeshTopologyNodeFinalise",err,error)
8977 END SUBROUTINE meshtopologynodefinalise
8984 SUBROUTINE meshtopologynodeinitialise(node,err,error,*)
8988 INTEGER(INTG),
INTENT(OUT) :: err
8992 enters(
"MeshTopologyNodeInitialise",err,error,*999)
8996 node%numberOfSurroundingElements=0
8997 NULLIFY(node%surroundingElements)
8998 node%numberOfDerivatives=0
8999 node%boundaryNode=.false.
9001 exits(
"MeshTopologyNodeInitialise")
9003 999 errorsexits(
"MeshTopologyNodeInitialise",err,error)
9005 END SUBROUTINE meshtopologynodeinitialise
9012 SUBROUTINE meshtopologynodescalculate(topology,err,error,*)
9016 INTEGER(INTG),
INTENT(OUT) :: err
9019 INTEGER(INTG) :: dummyerr,elementidx,insertstatus,localnodeidx,globalnode,meshnodeidx,meshnode,numberofnodes
9020 INTEGER(INTG),
POINTER :: globalnodenumbers(:)
9026 TYPE(
tree_type),
POINTER :: globalnodestree
9030 NULLIFY(globalnodenumbers)
9031 NULLIFY(globalnodestree)
9033 enters(
"MeshTopologyNodesCalculate",err,error,*998)
9035 IF(
ASSOCIATED(topology))
THEN 9036 elements=>topology%elements
9037 IF(
ASSOCIATED(elements))
THEN 9038 meshnodes=>topology%nodes
9039 IF(
ASSOCIATED(meshnodes))
THEN 9041 IF(
ASSOCIATED(mesh))
THEN 9043 CALL meshglobalnodesget(mesh,nodes,err,error,*999)
9044 IF(
ALLOCATED(meshnodes%nodes))
THEN 9046 &
" already has allocated mesh topology nodes." 9047 CALL flagerror(localerror,err,error,*998)
9053 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
9054 basis=>elements%elements(elementidx)%basis
9055 DO localnodeidx=1,basis%NUMBER_OF_NODES
9056 globalnode=elements%elements(elementidx)%GLOBAL_ELEMENT_NODES(localnodeidx)
9057 CALL tree_item_insert(globalnodestree,globalnode,globalnode,insertstatus,err,error,*999)
9062 ALLOCATE(meshnodes%nodes(numberofnodes),stat=err)
9063 IF(err/=0)
CALL flagerror(
"Could not allocate mesh topology nodes nodes.",err,error,*999)
9067 DO meshnodeidx=1,numberofnodes
9068 CALL meshtopologynodeinitialise(meshnodes%nodes(meshnodeidx),err,error,*999)
9069 meshnodes%nodes(meshnodeidx)%meshNumber=meshnodeidx
9070 meshnodes%nodes(meshnodeidx)%globalNumber=globalnodenumbers(meshnodeidx)
9071 meshnodes%nodes(meshnodeidx)%userNumber=nodes%nodes(globalnodenumbers(meshnodeidx))%USER_NUMBER
9072 CALL tree_item_insert(meshnodes%nodesTree,globalnodenumbers(meshnodeidx),meshnodeidx,insertstatus,err,error,*999)
9074 meshnodes%numberOfNodes=numberofnodes
9075 IF(
ASSOCIATED(globalnodenumbers))
DEALLOCATE(globalnodenumbers)
9077 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
9078 basis=>elements%elements(elementidx)%basis
9079 ALLOCATE(elements%elements(elementidx)%MESH_ELEMENT_NODES(basis%NUMBER_OF_NODES),stat=err)
9080 IF(err/=0)
CALL flagerror(
"Could not allocate mesh topology elements mesh element nodes.",err,error,*999)
9081 DO localnodeidx=1,basis%NUMBER_OF_NODES
9082 globalnode=elements%elements(elementidx)%GLOBAL_ELEMENT_NODES(localnodeidx)
9084 CALL tree_search(meshnodes%nodesTree,globalnode,treenode,err,error,*999)
9085 IF(
ASSOCIATED(treenode))
THEN 9087 elements%elements(elementidx)%MESH_ELEMENT_NODES(localnodeidx)=meshnode
9089 localerror=
"Could not find global node "//
trim(
numbertovstring(globalnode,
"*",err,error))//
" (user node "// &
9090 &
trim(
numbertovstring(nodes%nodes(globalnode)%USER_NUMBER,
"*",err,error))//
") in the mesh nodes." 9091 CALL flagerror(localerror,err,error,*999)
9097 CALL flagerror(
"Mesh topology mesh is not associated.",err,error,*998)
9100 CALL flagerror(
"Mesh topology nodes is not associated.",err,error,*998)
9103 CALL flagerror(
"Mesh topology elements is not associated.",err,error,*998)
9106 CALL flagerror(
"Mesh topology is not associated.",err,error,*998)
9111 DO meshnodeidx=1,meshnodes%numberOfNodes
9118 exits(
"MeshTopologyNodesCalculate")
9120 999
IF(
ASSOCIATED(globalnodenumbers))
DEALLOCATE(globalnodenumbers)
9121 IF(
ASSOCIATED(globalnodestree))
CALL tree_destroy(globalnodestree,dummyerr,dummyerror,*998)
9122 998 errorsexits(
"MeshTopologyNodesCalculate",err,error)
9125 END SUBROUTINE meshtopologynodescalculate
9132 SUBROUTINE meshtopologynodesdestroy(nodes,err,error,*)
9136 INTEGER(INTG),
INTENT(OUT) :: err
9140 enters(
"MeshTopologyNodesDestroy",err,error,*999)
9142 IF(
ASSOCIATED(nodes))
THEN 9143 CALL meshtopologynodesfinalise(nodes,err,error,*999)
9145 CALL flagerror(
"Mesh topology nodes is not associated",err,error,*999)
9148 exits(
"MeshTopologyNodesDestroy")
9150 999 errorsexits(
"MeshTopologyNodesDestroy",err,error)
9153 END SUBROUTINE meshtopologynodesdestroy
9160 SUBROUTINE meshtopologynodesget(mesh,meshComponentNumber,nodes,err,error,*)
9164 INTEGER(INTG),
INTENT(IN) :: meshcomponentnumber
9166 INTEGER(INTG),
INTENT(OUT) :: err
9171 enters(
"MeshTopologyNodesGet",err,error,*998)
9173 IF(
ASSOCIATED(mesh))
THEN 9174 IF(meshcomponentnumber>0.AND.meshcomponentnumber<=mesh%NUMBER_OF_COMPONENTS)
THEN 9175 IF(
ASSOCIATED(nodes))
THEN 9176 CALL flagerror(
"Nodes is already associated.",err,error,*998)
9178 IF(
ASSOCIATED(mesh%topology(meshcomponentnumber)%ptr))
THEN 9179 IF(
ASSOCIATED(mesh%topology(meshcomponentnumber)%ptr%nodes))
THEN 9180 nodes=>mesh%topology(meshcomponentnumber)%ptr%nodes
9182 CALL flagerror(
"Mesh topology nodes is not associated.",err,error,*999)
9185 CALL flagerror(
"Mesh topology is not associated.",err,error,*999)
9189 localerror=
"The specified mesh component number of "//
trim(
numbertovstring(meshcomponentnumber,
"*",err,error))// &
9190 &
" is invalid. The component number must be between 1 and "// &
9192 CALL flagerror(localerror,err,error,*999)
9195 CALL flagerror(
"Mesh is not associated",err,error,*998)
9198 exits(
"MeshTopologyNodesGet")
9201 998 errorsexits(
"MeshTopologyNodesGet",err,error)
9204 END SUBROUTINE meshtopologynodesget
9211 SUBROUTINE meshtopologynodederivativefinalise(nodeDerivative,err,error,*)
9215 INTEGER(INTG),
INTENT(OUT) :: err
9219 enters(
"MeshTopologyNodeDerivativeFinalise",err,error,*999)
9221 IF(
ALLOCATED(nodederivative%userVersionNumbers))
DEALLOCATE(nodederivative%userVersionNumbers)
9222 IF(
ALLOCATED(nodederivative%dofIndex))
DEALLOCATE(nodederivative%dofIndex)
9224 exits(
"MeshTopologyNodeDerivativeFinalise")
9226 999 errorsexits(
"MeshTopologyNodeDerivativeFinalise",err,error)
9229 END SUBROUTINE meshtopologynodederivativefinalise
9236 SUBROUTINE meshtopologynodederivativeinitialise(nodeDerivative,err,error,*)
9240 INTEGER(INTG),
INTENT(OUT) :: err
9244 enters(
"MeshTopologyNodeDerivativeInitialise",err,error,*999)
9246 nodederivative%numberOfVersions=0
9247 nodederivative%globalDerivativeIndex=0
9248 nodederivative%partialDerivativeIndex=0
9250 exits(
"MeshTopologyNodeDerivativeInitialise")
9252 999 errorsexits(
"MeshTopologyNodeDerivativeInitialise",err,error)
9255 END SUBROUTINE meshtopologynodederivativeinitialise
9262 SUBROUTINE meshtopologynodesderivativescalculate(topology,err,error,*)
9266 INTEGER(INTG),
INTENT(OUT) :: err
9269 INTEGER(INTG) :: derivativeidx,element,elementidx,globalderivative,localnodeidx,maxnumberofderivatives,nodeidx, &
9270 & numberOfDerivatives
9271 INTEGER(INTG),
ALLOCATABLE :: derivatives(:)
9273 TYPE(
list_type),
POINTER :: nodederivativelist
9279 enters(
"MeshTopologyNodesDerivativesCalculate",err,error,*999)
9281 IF(
ASSOCIATED(topology))
THEN 9282 elements=>topology%elements
9283 IF(
ASSOCIATED(elements))
THEN 9284 nodes=>topology%nodes
9285 IF(
ASSOCIATED(nodes))
THEN 9287 DO nodeidx=1,nodes%numberOfNodes
9290 NULLIFY(nodederivativelist)
9295 maxnumberofderivatives=-1
9296 DO elementidx=1,nodes%nodes(nodeidx)%numberOfSurroundingElements
9297 element=nodes%nodes(nodeidx)%surroundingElements(elementidx)
9298 basis=>elements%elements(element)%basis
9301 DO localnodeidx=1,basis%NUMBER_OF_NODES
9302 IF(elements%elements(element)%MESH_ELEMENT_NODES(localnodeidx)==nodeidx)
THEN 9308 DO derivativeidx=1,basis%NUMBER_OF_DERIVATIVES(localnodeidx)
9309 CALL list_item_add(nodederivativelist,basis%PARTIAL_DERIVATIVE_INDEX(derivativeidx,localnodeidx),err,error,*999)
9311 IF(basis%NUMBER_OF_DERIVATIVES(localnodeidx)>maxnumberofderivatives) &
9312 & maxnumberofderivatives=basis%NUMBER_OF_DERIVATIVES(localnodeidx)
9314 CALL flagerror(
"Could not find local node.",err,error,*999)
9319 IF(numberofderivatives==maxnumberofderivatives)
THEN 9321 ALLOCATE(nodes%nodes(nodeidx)%derivatives(maxnumberofderivatives),stat=err)
9322 nodes%nodes(nodeidx)%numberOfDerivatives=maxnumberofderivatives
9323 DO derivativeidx=1,numberofderivatives
9324 CALL meshtopologynodederivativeinitialise(nodes%nodes(nodeidx)%derivatives(derivativeidx),err,error,*999)
9325 nodes%nodes(nodeidx)%derivatives(derivativeidx)%partialDerivativeIndex = derivatives(derivativeidx)
9327 IF(globalderivative/=0)
THEN 9328 nodes%nodes(nodeidx)%derivatives(derivativeidx)%globalDerivativeIndex=globalderivative
9330 localerror=
"The partial derivative index of "//
trim(
numbertovstring(derivatives(derivativeidx),
"*", &
9331 & err,error))//
" for derivative number "//
trim(
numbertovstring(derivativeidx,
"*",err,error))// &
9332 &
" does not have a corresponding global derivative." 9333 CALL flagerror(localerror,err,error,*999)
9336 DEALLOCATE(derivatives)
9338 localerror=
"Invalid mesh configuration. User node "// &
9340 &
" has inconsistent derivative directions." 9341 CALL flagerror(localerror,err,error,*999)
9345 CALL flagerror(
"Mesh topology nodes is not associated.",err,error,*999)
9348 CALL flagerror(
"Mesh topology elements is not associated.",err,error,*999)
9351 CALL flagerror(
"Mesh topology is not associated.",err,error,*999)
9356 DO nodeidx=1,nodes%numberOfNodes
9360 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
9363 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%globalDerivativeIndex,err,error,*999)
9365 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%partialDerivativeIndex,err,error,*999)
9370 exits(
"MeshTopologyNodesDerivativesCalculate")
9372 999
IF(
ALLOCATED(derivatives))
DEALLOCATE(derivatives)
9373 IF(
ASSOCIATED(nodederivativelist))
CALL list_destroy(nodederivativelist,err,error,*998)
9374 998 errorsexits(
"MeshTopologyNodesDerivativesCalculate",err,error)
9377 END SUBROUTINE meshtopologynodesderivativescalculate
9384 SUBROUTINE meshtopologynodenumberofderivativesget(meshNodes,userNumber,numberOfDerivatives,err,error,*)
9388 INTEGER(INTG),
INTENT(IN) :: usernumber
9389 INTEGER(INTG),
INTENT(OUT) :: numberofderivatives
9390 INTEGER(INTG),
INTENT(OUT) :: err
9393 INTEGER(INTG) :: meshcomponentnumber,meshnumber
9394 LOGICAL :: nodeexists
9399 enters(
"MeshTopologyNodeNumberOfDerivativesGet",err,error,*999)
9401 IF(
ASSOCIATED(meshnodes))
THEN 9402 CALL meshtopologynodecheckexists(meshnodes,usernumber,nodeexists,meshnumber,err,error,*999)
9404 numberofderivatives=meshnodes%nodes(meshnumber)%numberOfDerivatives
9406 meshcomponenttopology=>meshnodes%meshComponentTopology
9407 IF(
ASSOCIATED(meshcomponenttopology))
THEN 9408 mesh=>meshcomponenttopology%mesh
9409 IF(
ASSOCIATED(mesh))
THEN 9410 meshcomponentnumber=meshcomponenttopology%meshComponentNumber
9412 &
" does not exist in mesh component number "//
trim(
numbertovstring(meshcomponentnumber,
"*",err,error))// &
9414 CALL flagerror(localerror,err,error,*999)
9416 CALL flagerror(
"Mesh component topology mesh is not associated.",err,error,*999)
9419 CALL flagerror(
"Mesh nodes mesh component topology is not associated.",err,error,*999)
9423 CALL flagerror(
"Mesh nodes is not associated.",err,error,*999)
9426 exits(
"MeshTopologyNodeNumberOfDerivativesGet")
9428 999 errorsexits(
"MeshTopologyNodeNumberOfDerivativesGet",err,error)
9431 END SUBROUTINE meshtopologynodenumberofderivativesget
9438 SUBROUTINE meshtopologynodederivativesget(meshNodes,userNumber,derivatives,err,error,*)
9442 INTEGER(INTG),
INTENT(IN) :: usernumber
9443 INTEGER(INTG),
INTENT(OUT) :: derivatives(:)
9444 INTEGER(INTG),
INTENT(OUT) :: err
9447 INTEGER(INTG) :: derivativeidx,meshcomponentnumber,meshnumber,numberofderivatives
9448 LOGICAL :: nodeexists
9453 enters(
"MeshTopologyNodeDerivativesGet",err,error,*999)
9455 IF(
ASSOCIATED(meshnodes))
THEN 9456 CALL meshtopologynodecheckexists(meshnodes,usernumber,nodeexists,meshnumber,err,error,*999)
9458 numberofderivatives=meshnodes%nodes(meshnumber)%numberOfDerivatives
9459 IF(
SIZE(derivatives,1)>=numberofderivatives)
THEN 9460 DO derivativeidx=1,numberofderivatives
9461 derivatives(derivativeidx)=meshnodes%nodes(meshnumber)%derivatives(derivativeidx)%globalDerivativeIndex
9464 localerror=
"The size of the supplied derivatives array of "// &
9466 &
" is too small. The size should be >= "// &
9468 CALL flagerror(localerror,err,error,*999)
9471 meshcomponenttopology=>meshnodes%meshComponentTopology
9472 IF(
ASSOCIATED(meshcomponenttopology))
THEN 9473 mesh=>meshcomponenttopology%mesh
9474 IF(
ASSOCIATED(mesh))
THEN 9475 meshcomponentnumber=meshcomponenttopology%meshComponentNumber
9477 &
" does not exist in mesh component number "//
trim(
numbertovstring(meshcomponentnumber,
"*",err,error))// &
9479 CALL flagerror(localerror,err,error,*999)
9481 CALL flagerror(
"Mesh component topology mesh is not associated.",err,error,*999)
9484 CALL flagerror(
"Mesh nodes mesh component topology is not associated.",err,error,*999)
9488 CALL flagerror(
"Mesh nodes is not associated.",err,error,*999)
9491 exits(
"MeshTopologyNodeDerivativesGet")
9493 999 errorsexits(
"MeshTopologyNodeDerivativesGet",err,error)
9496 END SUBROUTINE meshtopologynodederivativesget
9503 SUBROUTINE meshtopologynodenumberofversionsget(meshNodes,derivativeNumber,userNumber,numberOfVersions,err,error,*)
9507 INTEGER(INTG),
INTENT(IN) :: derivativenumber
9508 INTEGER(INTG),
INTENT(IN) :: usernumber
9509 INTEGER(INTG),
INTENT(OUT) :: numberofversions
9510 INTEGER(INTG),
INTENT(OUT) :: err
9513 INTEGER(INTG) :: meshcomponentnumber,meshnumber
9514 LOGICAL :: nodeexists
9519 enters(
"MeshTopologyNodeNumberOfVersionsGet",err,error,*999)
9521 IF(
ASSOCIATED(meshnodes))
THEN 9522 CALL meshtopologynodecheckexists(meshnodes,usernumber,nodeexists,meshnumber,err,error,*999)
9524 IF(derivativenumber>=1.AND.derivativenumber<=meshnodes%nodes(meshnumber)%numberOfDerivatives)
THEN 9525 numberofversions=meshnodes%nodes(meshnumber)%derivatives(derivativenumber)%numberOfVersions
9527 localerror=
"The specified derivative index of "// &
9529 &
" is invalid. The derivative index must be >= 1 and <= "// &
9530 &
trim(
numbertovstring(meshnodes%nodes(meshnumber)%numberOfDerivatives,
"*",err,error))// &
9532 CALL flagerror(localerror,err,error,*999)
9535 meshcomponenttopology=>meshnodes%meshComponentTopology
9536 IF(
ASSOCIATED(meshcomponenttopology))
THEN 9537 mesh=>meshcomponenttopology%mesh
9538 IF(
ASSOCIATED(mesh))
THEN 9539 meshcomponentnumber=meshcomponenttopology%meshComponentNumber
9541 &
" does not exist in mesh component number "//
trim(
numbertovstring(meshcomponentnumber,
"*",err,error))// &
9543 CALL flagerror(localerror,err,error,*999)
9545 CALL flagerror(
"Mesh component topology mesh is not associated.",err,error,*999)
9550 CALL flagerror(
"Mesh nodes is not associated.",err,error,*999)
9553 exits(
"MeshTopologyNodeNumberOfVersionsGet")
9555 999 errorsexits(
"MeshTopologyNodeNumberOfVersionsGet",err,error)
9558 END SUBROUTINE meshtopologynodenumberofversionsget
9565 SUBROUTINE meshtopologynodesnumberofnodesget(meshNodes,numberOfNodes,err,error,*)
9569 INTEGER(INTG),
INTENT(OUT) :: numberofnodes
9570 INTEGER(INTG),
INTENT(OUT) :: err
9574 enters(
"MeshTopologyNodesNumberOfNodesGet",err,error,*999)
9576 IF(
ASSOCIATED(meshnodes))
THEN 9577 numberofnodes=meshnodes%numberOfNodes
9579 CALL flagerror(
"Mesh nodes is not associated.",err,error,*999)
9582 exits(
"MeshTopologyNodesNumberOfNodesGet")
9584 999 errorsexits(
"MeshTopologyNodesNumberOfNodesGet",err,error)
9587 END SUBROUTINE meshtopologynodesnumberofnodesget
9594 SUBROUTINE meshtopologynodesversioncalculate(topology,err,error,*)
9598 INTEGER(INTG),
INTENT(OUT) :: err
9601 INTEGER(INTG) :: element,localnodeidx,derivativeidx,nodeidx,numberofversions,versionidx
9602 INTEGER(INTG),
ALLOCATABLE :: versions(:)
9608 enters(
"MeshTopologyNodesVersionCalculate",err,error,*999)
9610 IF(
ASSOCIATED(topology))
THEN 9611 elements=>topology%elements
9612 IF(
ASSOCIATED(elements))
THEN 9613 nodes=>topology%nodes
9614 IF(
ASSOCIATED(nodes))
THEN 9621 IF(err/=0)
CALL flagerror(
"Could not allocate node version list.",err,error,*999)
9622 DO nodeidx=1,nodes%numberOfNodes
9623 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
9624 NULLIFY(nodeversionlist(derivativeidx,nodeidx)%ptr)
9625 CALL list_create_start(nodeversionlist(derivativeidx,nodeidx)%ptr,err,error,*999)
9631 DO element=1,elements%NUMBER_OF_ELEMENTS
9632 basis=>elements%elements(element)%basis
9633 DO localnodeidx=1,basis%NUMBER_OF_NODES
9634 DO derivativeidx=1,basis%NUMBER_OF_DERIVATIVES(localnodeidx)
9635 CALL list_item_add(nodeversionlist(derivativeidx,elements%elements(element)% &
9636 & mesh_element_nodes(localnodeidx))%ptr,elements%elements(element)%USER_ELEMENT_NODE_VERSIONS( &
9637 & derivativeidx,localnodeidx),err,error,*999)
9641 DO nodeidx=1,nodes%numberOfNodes
9642 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
9643 CALL list_remove_duplicates(nodeversionlist(derivativeidx,nodeidx)%ptr,err,error,*999)
9644 CALL list_detach_and_destroy(nodeversionlist(derivativeidx,nodeidx)%ptr,numberofversions,versions, &
9646 nodes%nodes(nodeidx)%derivatives(derivativeidx)%numberOfVersions = maxval(versions(1:numberofversions))
9647 ALLOCATE(nodes%nodes(nodeidx)%derivatives(derivativeidx)%userVersionNumbers(nodes%nodes(nodeidx)% &
9648 & derivatives(derivativeidx)%numberOfVersions),stat=err)
9649 IF(err/=0)
CALL flagerror(
"Could not allocate node global derivative index.",err,error,*999)
9650 DO versionidx=1,nodes%nodes(nodeidx)%derivatives(derivativeidx)%numberOfVersions
9651 nodes%nodes(nodeidx)%derivatives(derivativeidx)%userVersionNumbers(versionidx) = versionidx
9653 DEALLOCATE(versions)
9656 DEALLOCATE(nodeversionlist)
9657 NULLIFY(nodeversionlist)
9659 CALL flagerror(
"Mesh topology nodes is not associated.",err,error,*999)
9662 CALL flagerror(
"Mesh topology elements is not associated.",err,error,*999)
9665 CALL flagerror(
"Mesh topology is not associated.",err,error,*999)
9668 IF(diagnostics1)
THEN 9669 CALL writestringvalue(diagnostic_output_type,
"Number of mesh global nodes = ",nodes%numberOfNodes,err,error,*999)
9670 DO nodeidx=1,nodes%numberOfNodes
9671 CALL writestringvalue(diagnostic_output_type,
" Mesh global node number = ",nodeidx,err,error,*999)
9672 CALL writestringvalue(diagnostic_output_type,
" Number of derivatives = ", &
9673 & nodes%nodes(nodeidx)%numberOfDerivatives,err,error,*999)
9674 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
9676 CALL writestringvalue(diagnostic_output_type,
" Global derivative index(derivativeIdx) = ", &
9677 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%globalDerivativeIndex,err,error,*999)
9678 CALL writestringvalue(diagnostic_output_type,
" Partial derivative index(derivativeIdx) = ", &
9679 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%partialDerivativeIndex,err,error,*999)
9680 CALL write_string_vector(diagnostic_output_type,1,1, &
9681 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%numberOfVersions,8,8, &
9682 & nodes%nodes(nodeidx)%derivatives(derivativeidx)%userVersionNumbers, &
9683 &
'(" User Version index(derivativeIdx,:) :",8(X,I2))',
'(36X,8(X,I2))',err,error,*999)
9688 exits(
"MeshTopologyNodesVersionCalculate")
9690 999
IF(
ALLOCATED(versions))
DEALLOCATE(versions)
9691 IF(
ASSOCIATED(nodeversionlist))
THEN 9692 DO nodeidx=1,nodes%numberOfNodes
9693 DO derivativeidx=1,nodes%nodes(nodeidx)%numberOfDerivatives
9694 CALL list_destroy(nodeversionlist(derivativeidx,nodeidx)%ptr,err,error,*998)
9697 DEALLOCATE(nodeversionlist)
9699 998 errorsexits(
"MeshTopologyNodesVersionCalculate",err,error)
9702 END SUBROUTINE meshtopologynodesversioncalculate
9709 SUBROUTINE meshtopologysurroundingelementscalculate(topology,err,error,*)
9712 TYPE(meshcomponenttopologytype),
POINTER :: topology
9713 INTEGER(INTG),
INTENT(OUT) :: err
9714 TYPE(varying_string),
INTENT(OUT) :: error
9716 INTEGER(INTG) :: element,elementidx,insertposition,localnodeidx,node,surroundingelementnumber
9717 INTEGER(INTG),
POINTER :: newsurroundingelements(:)
9718 LOGICAL :: foundelement
9719 TYPE(basis_type),
POINTER :: basis
9720 TYPE(meshelementstype),
POINTER :: elements
9721 TYPE(meshnodestype),
POINTER :: nodes
9723 NULLIFY(newsurroundingelements)
9725 enters(
"MeshTopologySurroundingElementsCalculate",err,error,*999)
9727 IF(
ASSOCIATED(topology))
THEN 9728 elements=>topology%elements
9729 IF(
ASSOCIATED(elements))
THEN 9730 nodes=>topology%nodes
9731 IF(
ASSOCIATED(nodes))
THEN 9732 IF(
ALLOCATED(nodes%nodes))
THEN 9733 DO elementidx=1,elements%NUMBER_OF_ELEMENTS
9734 basis=>elements%elements(elementidx)%basis
9735 DO localnodeidx=1,basis%NUMBER_OF_NODES
9736 node=elements%elements(elementidx)%MESH_ELEMENT_NODES(localnodeidx)
9737 foundelement=.false.
9740 DO WHILE(element<=nodes%nodes(node)%numberOfSurroundingElements.AND..NOT.foundelement)
9741 surroundingelementnumber=nodes%nodes(node)%surroundingElements(element)
9742 IF(surroundingelementnumber==elementidx)
THEN 9746 IF(elementidx>=surroundingelementnumber)
THEN 9747 insertposition=element
9750 IF(.NOT.foundelement)
THEN 9752 ALLOCATE(newsurroundingelements(nodes%nodes(node)%numberOfSurroundingElements+1),stat=err)
9753 IF(err/=0)
CALL flagerror(
"Could not allocate new surrounding elements.",err,error,*999)
9754 IF(
ASSOCIATED(nodes%nodes(node)%surroundingElements))
THEN 9755 newsurroundingelements(1:insertposition-1)=nodes%nodes(node)%surroundingElements(1:insertposition-1)
9756 newsurroundingelements(insertposition)=elementidx
9757 newsurroundingelements(insertposition+1:nodes%nodes(node)%numberOfSurroundingElements+1)= &
9758 & nodes%nodes(node)%surroundingElements(insertposition:nodes%nodes(node)%numberOfSurroundingElements)
9759 DEALLOCATE(nodes%nodes(node)%surroundingElements)
9761 newsurroundingelements(1)=elementidx
9763 nodes%nodes(node)%surroundingElements=>newsurroundingelements
9764 nodes%nodes(node)%numberOfSurroundingElements=nodes%nodes(node)%numberOfSurroundingElements+1
9769 CALL flagerror(
"Mesh topology nodes nodes have not been allocated.",err,error,*999)
9772 CALL flagerror(
"Mesh topology nodes are not associated.",err,error,*999)
9775 CALL flagerror(
"Mesh topology elements is not associated.",err,error,*999)
9778 CALL flagerror(
"Mesh topology not associated.",err,error,*999)
9781 exits(
"MeshTopologySurroundingElementsCalculate")
9783 999
IF(
ASSOCIATED(newsurroundingelements))
DEALLOCATE(newsurroundingelements)
9784 errorsexits(
"MeshTopologySurroundingElementsCalculate",err,error)
9786 END SUBROUTINE meshtopologysurroundingelementscalculate
9793 SUBROUTINE meshtopologynodesfinalise(nodes,err,error,*)
9796 TYPE(meshnodestype),
POINTER :: nodes
9797 INTEGER(INTG),
INTENT(OUT) :: err
9798 TYPE(varying_string),
INTENT(OUT) :: error
9800 INTEGER(INTG) :: nodeidx
9802 enters(
"MeshTopologyNodesFinalise",err,error,*999)
9804 IF(
ASSOCIATED(nodes))
THEN 9805 IF(
ALLOCATED(nodes%nodes))
THEN 9806 DO nodeidx=1,
SIZE(nodes%nodes,1)
9807 CALL meshtopologynodefinalise(nodes%nodes(nodeidx),err,error,*999)
9809 DEALLOCATE(nodes%nodes)
9811 IF(
ASSOCIATED(nodes%nodesTree))
CALL tree_destroy(nodes%nodesTree,err,error,*999)
9815 exits(
"MeshTopologyNodesFinalise")
9817 999 errorsexits(
"MeshTopologyNodesFinalise",err,error)
9820 END SUBROUTINE meshtopologynodesfinalise
9827 SUBROUTINE meshtopologynodesinitialise(topology,err,error,*)
9830 TYPE(meshcomponenttopologytype),
POINTER :: topology
9831 INTEGER(INTG),
INTENT(OUT) :: err
9832 TYPE(varying_string),
INTENT(OUT) :: error
9835 enters(
"MeshTopologyNodesInitialise",err,error,*999)
9837 IF(
ASSOCIATED(topology))
THEN 9838 IF(
ASSOCIATED(topology%nodes))
THEN 9839 CALL flagerror(
"Mesh already has topology nodes associated.",err,error,*999)
9841 ALLOCATE(topology%nodes,stat=err)
9842 IF(err/=0)
CALL flagerror(
"Could not allocate topology nodes.",err,error,*999)
9843 topology%nodes%numberOfNodes=0
9844 topology%nodes%meshComponentTopology=>topology
9845 NULLIFY(topology%nodes%nodesTree)
9848 CALL flagerror(
"Topology is not associated.",err,error,*999)
9851 exits(
"MeshTopologyNodesInitialise")
9853 999 errorsexits(
"MeshTopologyNodesInitialise",err,error)
9855 END SUBROUTINE meshtopologynodesinitialise
9862 SUBROUTINE mesh_user_number_find_generic(USER_NUMBER,MESHES,MESH,ERR,ERROR,*)
9865 INTEGER(INTG),
INTENT(IN) :: user_number
9866 TYPE(meshes_type),
POINTER :: meshes
9867 TYPE(mesh_type),
POINTER :: mesh
9868 INTEGER(INTG),
INTENT(OUT) :: err
9869 TYPE(varying_string),
INTENT(OUT) :: error
9871 INTEGER(INTG) :: mesh_idx
9873 enters(
"MESH_USER_NUMBER_FIND_GENERIC",err,error,*999)
9875 IF(
ASSOCIATED(meshes))
THEN 9876 IF(
ASSOCIATED(mesh))
THEN 9877 CALL flagerror(
"Mesh is already associated.",err,error,*999)
9881 DO WHILE(mesh_idx<=meshes%NUMBER_OF_MESHES.AND..NOT.
ASSOCIATED(mesh))
9882 IF(meshes%MESHES(mesh_idx)%PTR%USER_NUMBER==user_number)
THEN 9883 mesh=>meshes%MESHES(mesh_idx)%PTR
9890 CALL flagerror(
"Meshes is not associated",err,error,*999)
9893 exits(
"MESH_USER_NUMBER_FIND_GENERIC")
9895 999 errorsexits(
"MESH_USER_NUMBER_FIND_GENERIC",err,error)
9897 END SUBROUTINE mesh_user_number_find_generic
9904 SUBROUTINE mesh_user_number_find_interface(USER_NUMBER,INTERFACE,MESH,ERR,ERROR,*)
9907 INTEGER(INTG),
INTENT(IN) :: user_number
9908 TYPE(interface_type),
POINTER :: interface
9909 TYPE(mesh_type),
POINTER :: mesh
9910 INTEGER(INTG),
INTENT(OUT) :: err
9911 TYPE(varying_string),
INTENT(OUT) :: error
9914 enters(
"MESH_USER_NUMBER_FIND_INTERFACE",err,error,*999)
9916 IF(
ASSOCIATED(interface))
THEN 9917 CALL mesh_user_number_find_generic(user_number,interface%MESHES,mesh,err,error,*999)
9919 CALL flagerror(
"Interface is not associated",err,error,*999)
9922 exits(
"MESH_USER_NUMBER_FIND_INTERFACE")
9924 999 errorsexits(
"MESH_USER_NUMBER_FIND_INTERFACE",err,error)
9927 END SUBROUTINE mesh_user_number_find_interface
9934 SUBROUTINE mesh_user_number_find_region(USER_NUMBER,REGION,MESH,ERR,ERROR,*)
9937 INTEGER(INTG),
INTENT(IN) :: user_number
9938 TYPE(region_type),
POINTER :: region
9939 TYPE(mesh_type),
POINTER :: mesh
9940 INTEGER(INTG),
INTENT(OUT) :: err
9941 TYPE(varying_string),
INTENT(OUT) :: error
9944 enters(
"MESH_USER_NUMBER_FIND_REGION",err,error,*999)
9946 IF(
ASSOCIATED(region))
THEN 9947 CALL mesh_user_number_find_generic(user_number,region%MESHES,mesh,err,error,*999)
9949 CALL flagerror(
"Region is not associated",err,error,*999)
9952 exits(
"MESH_USER_NUMBER_FIND_REGION")
9954 999 errorsexits(
"MESH_USER_NUMBER_FIND_REGION",err,error)
9956 END SUBROUTINE mesh_user_number_find_region
9963 SUBROUTINE meshes_finalise(MESHES,ERR,ERROR,*)
9966 TYPE(meshes_type),
POINTER :: meshes
9967 INTEGER(INTG),
INTENT(OUT) :: err
9968 TYPE(varying_string),
INTENT(OUT) :: error
9970 TYPE(mesh_type),
POINTER :: mesh
9972 enters(
"MESHES_FINALISE",err,error,*999)
9974 IF(
ASSOCIATED(meshes))
THEN 9975 DO WHILE(meshes%NUMBER_OF_MESHES>0)
9976 mesh=>meshes%MESHES(1)%PTR
9977 CALL mesh_destroy(mesh,err,error,*999)
9981 CALL flagerror(
"Meshes is not associated.",err,error,*999)
9984 exits(
"MESHES_FINALISE")
9986 999 errorsexits(
"MESHES_FINALISE",err,error)
9989 END SUBROUTINE meshes_finalise
9996 SUBROUTINE meshes_initialise_generic(MESHES,ERR,ERROR,*)
9999 TYPE(meshes_type),
POINTER :: meshes
10000 INTEGER(INTG),
INTENT(OUT) :: err
10001 TYPE(varying_string),
INTENT(OUT) :: error
10003 INTEGER(INTG) :: dummy_err
10004 TYPE(varying_string) :: dummy_error
10006 enters(
"MESHES_INITIALISE_GENERIC",err,error,*998)
10008 IF(
ASSOCIATED(meshes))
THEN 10009 CALL flagerror(
"Meshes is already associated.",err,error,*998)
10011 ALLOCATE(meshes,stat=err)
10012 IF(err/=0)
CALL flagerror(
"Meshes could not be allocated",err,error,*999)
10013 NULLIFY(meshes%REGION)
10014 NULLIFY(meshes%INTERFACE)
10015 meshes%NUMBER_OF_MESHES=0
10016 NULLIFY(meshes%MESHES)
10019 exits(
"MESHES_INITIALISE_GENERIC")
10021 999
CALL meshes_finalise(meshes,dummy_err,dummy_error,*998)
10022 998 errorsexits(
"MESHES_INITIALISE_GENERIC",err,error)
10024 END SUBROUTINE meshes_initialise_generic
10031 SUBROUTINE meshes_initialise_interface(INTERFACE,ERR,ERROR,*)
10034 TYPE(interface_type),
POINTER :: interface
10035 INTEGER(INTG),
INTENT(OUT) :: err
10036 TYPE(varying_string),
INTENT(OUT) :: error
10038 TYPE(varying_string) :: local_error
10040 enters(
"MESHES_INITIALISE_INTERFACE",err,error,*999)
10042 IF(
ASSOCIATED(interface))
THEN 10043 IF(
ASSOCIATED(interface%MESHES))
THEN 10044 local_error=
"Interface number "//trim(numbertovstring(interface%USER_NUMBER,
"*",err,error))// &
10045 &
" already has a mesh associated" 10046 CALL flagerror(local_error,err,error,*999)
10048 CALL meshes_initialise_generic(interface%MESHES,err,error,*999)
10049 interface%MESHES%INTERFACE=>
INTERFACE 10052 CALL flagerror(
"Interface is not associated",err,error,*999)
10055 exits(
"MESHES_INITIALISE_INTERFACE")
10057 999 errorsexits(
"MESHES_INITIALISE_INTERFACE",err,error)
10059 END SUBROUTINE meshes_initialise_interface
10066 SUBROUTINE meshes_initialise_region(REGION,ERR,ERROR,*)
10069 TYPE(region_type),
POINTER :: region
10070 INTEGER(INTG),
INTENT(OUT) :: err
10071 TYPE(varying_string),
INTENT(OUT) :: error
10073 TYPE(varying_string) :: local_error
10075 enters(
"MESHES_INITIALISE_REGION",err,error,*999)
10077 IF(
ASSOCIATED(region))
THEN 10078 IF(
ASSOCIATED(region%MESHES))
THEN 10079 local_error=
"Region number "//trim(numbertovstring(region%USER_NUMBER,
"*",err,error))// &
10080 &
" already has a mesh associated" 10081 CALL flagerror(local_error,err,error,*999)
10083 CALL meshes_initialise_generic(region%MESHES,err,error,*999)
10084 region%MESHES%REGION=>region
10087 CALL flagerror(
"Region is not associated",err,error,*999)
10090 exits(
"MESHES_INITIALISE_REGION")
10092 999 errorsexits(
"MESHES_INITIALISE_REGION",err,error)
10094 END SUBROUTINE meshes_initialise_region
10101 SUBROUTINE decomposition_node_domain_get(DECOMPOSITION,USER_NODE_NUMBER,MESH_COMPONENT_NUMBER,DOMAIN_NUMBER,ERR,ERROR,*)
10104 TYPE(decomposition_type),
POINTER :: decomposition
10105 INTEGER(INTG),
INTENT(IN) :: user_node_number
10106 INTEGER(INTG),
INTENT(IN) :: mesh_component_number
10107 INTEGER(INTG),
INTENT(OUT) :: domain_number
10108 INTEGER(INTG),
INTENT(OUT) :: err
10109 TYPE(varying_string),
INTENT(OUT) :: error
10111 TYPE(mesh_type),
POINTER :: mesh
10112 TYPE(meshcomponenttopologytype),
POINTER :: mesh_topology
10113 TYPE(varying_string) :: local_error
10114 INTEGER(INTG) :: global_node_number
10115 TYPE(tree_node_type),
POINTER :: tree_node
10116 TYPE(meshnodestype),
POINTER :: mesh_nodes
10117 TYPE(domain_type),
POINTER :: mesh_domain
10119 enters(
"DECOMPOSITION_NODE_DOMAIN_GET",err,error,*999)
10122 global_node_number=0
10123 IF(
ASSOCIATED(decomposition))
THEN 10124 IF(decomposition%DECOMPOSITION_FINISHED)
THEN 10125 mesh=>decomposition%MESH
10126 IF(
ASSOCIATED(mesh))
THEN 10127 mesh_topology=>mesh%TOPOLOGY(mesh_component_number)%PTR
10128 IF(
ASSOCIATED(mesh_topology))
THEN 10129 mesh_nodes=>mesh_topology%nodes
10130 IF(
ASSOCIATED(mesh_nodes))
THEN 10132 CALL tree_search(mesh_nodes%nodesTree,user_node_number,tree_node,err,error,*999)
10133 IF(
ASSOCIATED(tree_node))
THEN 10134 CALL tree_node_value_get(mesh_nodes%nodesTree,tree_node,global_node_number,err,error,*999)
10135 IF(global_node_number>0.AND.global_node_number<=mesh_topology%NODES%numberOfNodes)
THEN 10136 IF(mesh_component_number>0.AND.mesh_component_number<=mesh%NUMBER_OF_COMPONENTS)
THEN 10137 mesh_domain=>decomposition%DOMAIN(mesh_component_number)%PTR
10138 IF(
ASSOCIATED(mesh_domain))
THEN 10139 domain_number=mesh_domain%NODE_DOMAIN(global_node_number)
10141 CALL flagerror(
"Decomposition domain is not associated.",err,error,*999)
10144 local_error=
"Mesh Component number "//trim(numbertovstring(mesh_component_number,
"*",err,error))// &
10145 &
" is invalid. The limits are 1 to "// &
10146 & trim(numbertovstring(mesh%NUMBER_OF_COMPONENTS,
"*",err,error))//
"." 10147 CALL flagerror(local_error,err,error,*999)
10150 local_error=
"Global element number found "//trim(numbertovstring(global_node_number,
"*",err,error))// &
10151 &
" is invalid. The limits are 1 to "// &
10152 & trim(numbertovstring(mesh_topology%NODES%numberOfNodes,
"*",err,error))//
"." 10153 CALL flagerror(local_error,err,error,*999)
10156 CALL flagerror(
"Decomposition mesh node corresponding to user number not found.",err,error,*999)
10159 CALL flagerror(
"Decomposition mesh nodes are not associated.",err,error,*999)
10162 CALL flagerror(
"Decomposition mesh topology is not associated.",err,error,*999)
10165 CALL flagerror(
"Decomposition mesh is not associated.",err,error,*999)
10168 CALL flagerror(
"Decomposition has not been finished.",err,error,*999)
10171 CALL flagerror(
"Decomposition is not associated.",err,error,*999)
10174 exits(
"DECOMPOSITION_NODE_DOMAIN_GET")
10176 999 errorsexits(
"DECOMPOSITION_NODE_DOMAIN_GET",err,error)
10178 END SUBROUTINE decomposition_node_domain_get
10185 SUBROUTINE embedded_mesh_initialise(MESH_EMBEDDING,ERR,ERROR,*)
10189 TYPE(mesh_embedding_type),
POINTER :: mesh_embedding
10190 INTEGER(INTG),
INTENT(OUT) :: err
10191 TYPE(varying_string),
INTENT(OUT) :: error
10194 enters(
"EMBEDDED_MESH_INITIALISE",err,error,*998)
10196 ALLOCATE(mesh_embedding,stat=err)
10197 NULLIFY(mesh_embedding%PARENT_MESH)
10198 NULLIFY(mesh_embedding%CHILD_MESH)
10200 exits(
"EMBEDDED_MESH_INITIALISE")
10203 998 errorsexits(
"EMBEDDED_MESH_INITIALISE",err,error)
10205 END SUBROUTINE embedded_mesh_initialise
10212 SUBROUTINE mesh_embedding_create(MESH_EMBEDDING, PARENT_MESH, CHILD_MESH,ERR,ERROR,*)
10214 TYPE(mesh_embedding_type),
POINTER :: mesh_embedding
10215 TYPE(mesh_type),
POINTER,
INTENT(IN) :: parent_mesh
10216 TYPE(mesh_type),
POINTER,
INTENT(IN) :: child_mesh
10217 INTEGER(INTG),
INTENT(OUT) :: err
10218 TYPE(varying_string),
INTENT(OUT) :: error
10220 INTEGER(INTG) :: ngp = 0, ne
10222 enters(
"MESH_EMBEDDING_CREATE",err,error,*999)
10224 WRITE(*,*)
'parent mesh', parent_mesh%NUMBER_OF_ELEMENTS
10225 WRITE(*,*)
'child mesh', child_mesh%NUMBER_OF_ELEMENTS
10226 CALL embedded_mesh_initialise(mesh_embedding,err,error,*999)
10228 DO ne=1,parent_mesh%NUMBER_OF_ELEMENTS
10229 ngp = max(ngp,parent_mesh%TOPOLOGY(1)%PTR%ELEMENTS%ELEMENTS(ne)%BASIS%QUADRATURE%&
10230 & quadrature_scheme_map(basis_default_quadrature_scheme)%PTR%NUMBER_OF_GAUSS)
10233 mesh_embedding%PARENT_MESH => parent_mesh
10234 mesh_embedding%CHILD_MESH => child_mesh
10235 ALLOCATE(mesh_embedding%CHILD_NODE_XI_POSITION(parent_mesh%NUMBER_OF_ELEMENTS),stat=err)
10236 IF(err/=0)
CALL flagerror(
"Could not allocate child node positions.",err,error,*999)
10237 ALLOCATE(mesh_embedding%GAUSS_POINT_XI_POSITION(ngp,parent_mesh%NUMBER_OF_ELEMENTS),stat=err)
10238 IF(err/=0)
CALL flagerror(
"Could not allocate gauss point positions.",err,error,*999)
10240 exits(
"MESH_EMBEDDING_CREATE")
10243 999 errorsexits(
"MESH_EMBEDDING_CREATE",err,error)
10245 END SUBROUTINE mesh_embedding_create
10252 SUBROUTINE mesh_embedding_set_child_node_position(MESH_EMBEDDING, ELEMENT_NUMBER, NODE_NUMBERS, XI_COORDS,ERR,ERROR,*)
10253 TYPE(mesh_embedding_type),
INTENT(INOUT) :: mesh_embedding
10254 INTEGER(INTG),
INTENT(IN) :: element_number
10255 INTEGER(INTG),
INTENT(IN) :: node_numbers(:)
10256 REAL(DP),
INTENT(IN) :: xi_coords(:,:)
10258 INTEGER(INTG),
INTENT(OUT) :: err
10259 TYPE(varying_string),
INTENT(OUT) :: error
10261 enters(
"MESH_EMBEDDING_SET_CHILD_NODE_POSITION",err,error,*999)
10263 IF(element_number<1 .OR. element_number > mesh_embedding%PARENT_MESH%NUMBER_OF_ELEMENTS)
THEN 10264 CALL flagerror(
"Element number out of range",err,error,*999)
10267 mesh_embedding%CHILD_NODE_XI_POSITION(element_number)%NUMBER_OF_NODES =
SIZE(node_numbers)
10269 ALLOCATE(mesh_embedding%CHILD_NODE_XI_POSITION(element_number)%NODE_NUMBERS(
SIZE(node_numbers)))
10270 mesh_embedding%CHILD_NODE_XI_POSITION(element_number)%NODE_NUMBERS(1:
SIZE(node_numbers)) = node_numbers(1:
SIZE(node_numbers))
10272 ALLOCATE(mesh_embedding%CHILD_NODE_XI_POSITION(element_number)%XI_COORDS(
SIZE(xi_coords,1),
SIZE(xi_coords,2)))
10273 mesh_embedding%CHILD_NODE_XI_POSITION(element_number)%XI_COORDS(1:
SIZE(xi_coords,1),1:
SIZE(xi_coords,2)) = &
10274 & xi_coords(1:
SIZE(xi_coords,1),1:
SIZE(xi_coords,2))
10277 999 errorsexits(
"MESH_EMBEDDING_SET_CHILD_NODE_POSITION",err,error)
10279 END SUBROUTINE mesh_embedding_set_child_node_position
10286 SUBROUTINE mesh_embedding_set_gauss_point_data(MESH_EMBEDDING, PARENT_ELEMENT_NUMBER, GAUSSPT_NUMBER,&
10287 & parent_xi_coord, child_element_number, child_xi_coord,err,error,*)
10288 TYPE(mesh_embedding_type),
INTENT(INOUT) :: mesh_embedding
10289 INTEGER(INTG),
INTENT(IN) :: parent_element_number
10290 INTEGER(INTG),
INTENT(IN) :: gausspt_number
10291 REAL(DP),
INTENT(IN) :: parent_xi_coord(:)
10293 INTEGER(INTG),
INTENT(IN) :: child_element_number
10294 REAL(DP),
INTENT(IN) :: child_xi_coord(:)
10296 INTEGER(INTG),
INTENT(OUT) :: err
10297 TYPE(varying_string),
INTENT(OUT) :: error
10299 enters(
"MESH_EMBEDDING_SET_GAUSS_POINT_DATA",err,error,*999)
10301 IF(parent_element_number<1 .OR. parent_element_number > mesh_embedding%PARENT_MESH%NUMBER_OF_ELEMENTS)
THEN 10302 CALL flagerror(
"Parent element number out of range",err,error,*999)
10304 IF(child_element_number<1 .OR. child_element_number > mesh_embedding%CHILD_MESH%NUMBER_OF_ELEMENTS)
THEN 10305 CALL flagerror(
"Child element number out of range",err,error,*999)
10307 IF(gausspt_number<1 .OR. gausspt_number >
SIZE(mesh_embedding%GAUSS_POINT_XI_POSITION,1))
THEN 10308 CALL flagerror(
"Gauss point number out of range",err,error,*999)
10311 ALLOCATE(mesh_embedding%GAUSS_POINT_XI_POSITION(gausspt_number,parent_element_number)&
10312 & %PARENT_XI_COORD(
SIZE(parent_xi_coord)))
10313 ALLOCATE(mesh_embedding%GAUSS_POINT_XI_POSITION(gausspt_number,parent_element_number)&
10314 & %CHILD_XI_COORD(
SIZE(child_xi_coord)))
10317 mesh_embedding%GAUSS_POINT_XI_POSITION(gausspt_number,parent_element_number)%PARENT_XI_COORD(1:
SIZE(parent_xi_coord)) = &
10318 & parent_xi_coord(1:
SIZE(parent_xi_coord))
10319 mesh_embedding%GAUSS_POINT_XI_POSITION(gausspt_number,parent_element_number)%CHILD_XI_COORD(1:
SIZE(child_xi_coord)) = &
10320 & child_xi_coord(1:
SIZE(child_xi_coord))
10321 mesh_embedding%GAUSS_POINT_XI_POSITION(gausspt_number,parent_element_number)%ELEMENT_NUMBER = child_element_number
10324 999 errorsexits(
"MESH_EMBEDDING_SET_GAUSS_POINT_DATA",err,error)
10326 END SUBROUTINE mesh_embedding_set_gauss_point_data
10334 SUBROUTINE mesh_user_number_to_mesh( USER_NUMBER, REGION, MESH, ERR, ERROR, * )
10336 INTEGER(INTG),
INTENT(IN) :: user_number
10337 TYPE(region_type),
POINTER :: region
10338 TYPE(mesh_type),
POINTER :: mesh
10339 INTEGER(INTG),
INTENT(OUT) :: err
10340 TYPE(varying_string),
INTENT(OUT) :: error
10343 TYPE(varying_string) :: local_error
10345 enters(
"MESH_USER_NUMBER_TO_MESH", err, error, *999 )
10348 CALL mesh_user_number_find( user_number, region, mesh, err, error, *999 )
10349 IF( .NOT.
ASSOCIATED( mesh ) )
THEN 10350 local_error =
"A mesh with an user number of "//trim(numbertovstring( user_number,
"*", err, error ))// &
10351 &
" does not exist on region number "//trim(numbertovstring( region%USER_NUMBER,
"*", err, error ))//
"." 10352 CALL flagerror( local_error, err, error, *999 )
10355 exits(
"MESH_USER_NUMBER_TO_MESH" )
10357 999 errorsexits(
"MESH_USER_NUMBER_TO_MESH", err, error )
10360 END SUBROUTINE mesh_user_number_to_mesh
10368 SUBROUTINE decomposition_user_number_to_decomposition( USER_NUMBER, MESH, DECOMPOSITION, ERR, ERROR, * )
10370 INTEGER(INTG),
INTENT(IN) :: user_number
10371 TYPE(mesh_type),
POINTER :: mesh
10372 TYPE(decomposition_type),
POINTER :: decomposition
10373 INTEGER(INTG),
INTENT(OUT) :: err
10374 TYPE(varying_string),
INTENT(OUT) :: error
10377 TYPE(varying_string) :: local_error
10379 enters(
"DECOMPOSITION_USER_NUMBER_TO_DECOMPOSITION", err, error, *999 )
10381 NULLIFY( decomposition )
10382 CALL decomposition_user_number_find( user_number, mesh, decomposition, err, error, *999 )
10383 IF( .NOT.
ASSOCIATED( decomposition ) )
THEN 10384 local_error =
"A decomposition with an user number of "//trim(numbertovstring( user_number,
"*", err, error ))// &
10385 &
" does not exist on mesh number "//trim(numbertovstring( mesh%USER_NUMBER,
"*", err, error ))//
"." 10386 CALL flagerror( local_error, err, error, *999 )
10389 exits(
"DECOMPOSITION_USER_NUMBER_TO_DECOMPOSITION" )
10391 999 errors(
"DECOMPOSITION_USER_NUMBER_TO_DECOMPOSITION", err, error )
10392 exits(
"DECOMPOSITION_USER_NUMBER_TO_DECOMPOSITION")
10395 END SUBROUTINE decomposition_user_number_to_decomposition
10401 END MODULE mesh_routines
This module contains all basis function routines.
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
subroutine, public tree_insert_type_set(TREE, INSERT_TYPE, ERR, ERROR,)
Sets/changes the insert type for a tree.
This module contains all coordinate transformation and support routines.
Contains information for a region.
Contains the information for a face in a domain.
Contains the topology information for a global node of a mesh.
integer(intg), dimension(:), allocatable, public cmiss_random_seeds
The current error handling seeds for OpenCMISS.
integer(intg), dimension(20) partial_derivative_global_derivative_map
PARTIAL_DERIVATIVE_GLOBAL_DERIVATIVE_MAP(nu) gives the global derivative index for the the nu'th part...
integer(intg), parameter no_global_deriv
No global derivative i.e., u.
Converts a number to its equivalent varying string representation.
Implements trees of base types.
A buffer type to allow for an array of pointers to a DECOMPOSITION_TYPE.
Contains information on the mesh decomposition.
integer, parameter idx
Integer index kind.
integer(intg), parameter, public tree_node_insert_sucessful
Successful insert status.
Contains the topology information for a domain.
integer(intg), parameter, public domain_local_boundary
The domain item is on the boundary of the domain.
integer, parameter intg
Standard integer kind.
Contains information on the data points defined on a region.
Contains the information for a node derivative of a mesh.
subroutine, public tree_search(TREE, KEY, X, ERR, ERROR,)
Searches a tree to see if it contains a key.
This module contains all string manipulation and transformation routines.
Contains the topology information for a local node derivative of a domain.
A buffer type to allow for an array of pointers to a MeshComponentTopologyType.
integer(intg), parameter, public basis_b_spline_tp_type
B-spline basis type.
integer(intg), parameter, public basis_simplex_type
Simplex basis type.
subroutine, public tree_detach_and_destroy(TREE, NUMBER_IN_TREE, TREE_VALUES, ERR, ERROR,)
Detaches the tree values and returns them as a pointer to the an array and then destroys the tree...
integer(intg), parameter, public list_intg_type
Integer data type for a list.
logical, save, public diagnostics2
.TRUE. if level 2 diagnostic output is active in the current routine
Contains information on the domain decompositions defined on a mesh.
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
subroutine, public list_remove_duplicates(LIST, ERR, ERROR,)
Removes duplicate entries from a list. A side effect of this is that the list is sorted.
Contains the information for an element in a domain.
integer(intg), parameter, public domain_local_ghost
The domain item is ghosted from another domain.
Contains the information for a face in a decomposition.
Contains the information for a line in a domain.
integer(intg), parameter, public basis_serendipity_type
Serendipity basis type.
Contains the topology information for the elements of a domain.
Detaches the list values from a list and returns them as a pointer to a array of base type before des...
Contains the information for a line in a decomposition.
Contains information on the degrees-of-freedom (dofs) for a domain.
integer, parameter dp
Double precision real kind.
Contains the topology information for a decomposition.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
Contains information about a data projection result.
integer(intg), parameter, public basis_extended_lagrange_tp_type
Extendend Lagrange tensor product basis type.
This module contains all type definitions in order to avoid cyclic module references.
Contains the topology information for a local node of a domain.
integer(intg), parameter, public basis_fourier_lagrange_hermite_tp_type
Fourier-Lagrange tensor product basis type.
Contains the topology information for the faces of a decomposition.
integer(intg), dimension(3, 3, 2) other_xi_directions3
OTHER_XI_DIRECTIONS3(ni,nii,type) gives the other xi directions for direction ni for a three dimensio...
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
Contains information on the dofs for a mesh.
subroutine, public tree_item_delete(TREE, KEY, ERR, ERROR,)
Deletes a tree node specified by a key from a tree.
subroutine, public domain_mappings_local_from_global_calculate(DOMAIN_MAPPING, ERR, ERROR,)
Calculates the domain mappings local map from a domain mappings global map.
subroutine, public list_create_finish(LIST, ERR, ERROR,)
Finishes the creation of a list created with LIST_CREATE_START.
integer(intg) function, public computational_nodes_number_get(ERR, ERROR)
Returns the number of computational nodes.
Contains information on the domain decomposition mappings.
Contains data point decompostion topology.
subroutine, public tree_create_finish(TREE, ERR, ERROR,)
Finishes the creation of a tree created with TREE_CREATE_START.
Contains information on a list.
This module contains all computational environment variables.
Contains the information for an element in a mesh.
This module contains CMISS MPI routines.
Contains information on the meshes defined on a region.
This module handles all domain mappings routines.
integer(intg), save my_computational_node_number
The computational rank for this node.
Contains the topology information for the faces of a domain.
type(computational_environment_type), target, public computational_environment
The computational environment the program is running in.
integer(intg), parameter, public domain_local_internal
The domain item is internal to the domain.
Contains the topology information for the elements of a decomposition.
Contains the information for the nodes of a mesh.
integer(intg), parameter, public tree_no_duplicates_allowed
No duplicate keys allowed tree type.
Contains information on a mesh defined on a region.
subroutine, public domain_mappings_mapping_initialise(DOMAIN_MAPPING, NUMBER_OF_DOMAINS, ERR, ERROR,)
Initialises the mapping for a domain mappings mapping.
integer(intg), dimension(4, 3) other_xi_directions4
OTHER_XI_DIRECTIONS4(nic,nii) gives the other xi coordinates for coordinate nic for a simplex element...
Contains the topology information for the nodes of a domain.
Contains information on the decomposition adjacent elements for a xi coordinate.
integer(intg), parameter, public basis_lagrange_hermite_tp_type
Lagrange-Hermite tensor product basis type.
logical, save, public diagnostics1
.TRUE. if level 1 diagnostic output is active in the current routine
Contains the topology information for the lines of a decomposition.
subroutine, public domain_mappings_mapping_finalise(DOMAIN_MAPPING, ERR, ERROR,)
Finalises the mapping for a domain mappings mapping and deallocates all memory.
subroutine, public tree_destroy(TREE, ERR, ERROR,)
Destroys a tree.
integer(intg), parameter, public basis_auxilliary_type
Auxillary basis type.
integer(intg), parameter, public diagnostic_output_type
Diagnostic output type.
subroutine, public parmetis_partmeshkway(ELEMENT_DISTANCE, ELEMENT_PTR, ELEMENT_INDEX, ELEMENT_WEIGHT, WEIGHT_FLAG, NUM_FLAG, NCON, NUMBER_COMMON_NODES, NUMBER_PARTS, TP_WEIGHTS, UB_VEC, OPTIONS, NUMBER_EDGES_CUT, PARTITION, COMMUNICATOR, ERR, ERROR,)
Buffer routine to the ParMetis ParMETIS_V3_PartMeshKway routine.
This module is a CMISS buffer module to the ParMETIS library.
Contains information on the nodes defined on a region.
subroutine, public list_create_start(LIST, ERR, ERROR,)
Starts the creation of a list and returns a pointer to the created list.
Checks whether an array is a subset of another array.
Contains information on the domain mappings (i.e., local and global numberings).
integer(intg), parameter maximum_global_deriv_number
The maximum global derivative number.
A pointer to the domain decomposition for this domain.
A buffer type to allow for an array of pointers to a MESH_TYPE.
subroutine, public tree_item_insert(TREE, KEY, VALUE, INSERT_STATUS, ERR, ERROR,)
Inserts a tree node into a red-black tree.
Adds an item to the end of a list.
subroutine, public domain_mappings_mapping_global_initialise(MAPPING_GLOBAL_MAP, ERR, ERROR,)
Finalises the global mapping in the given domain mappings.
subroutine, public errors(NAME, ERR, ERROR)
Records the exiting error of the subroutine.
Contains information for the interface data.
Implements lists of base types.
subroutine, public list_data_type_set(LIST, DATA_TYPE, ERR, ERROR,)
Sets/changes the data type for a list.
subroutine, public list_destroy(LIST, ERR, ERROR,)
Destroys a list.
subroutine, public tree_node_value_get(TREE, TREE_NODE, VALUE, ERR, ERROR,)
Gets the value at a specified tree node.
Contains all information about a basis .
Contains information on the (global) topology of a mesh.
Flags an error condition.
subroutine, public tree_create_start(TREE, ERR, ERROR,)
Starts the creation of a tree and returns a pointer to the created tree.
Contains information on the mesh adjacent elements for a xi coordinate.
Buffer type to allow arrays of pointers to a list.
subroutine, public list_initial_size_set(LIST, INITIAL_SIZE, ERR, ERROR,)
Sets/changes the initial size for a list.
integer(intg), save number_of_computational_nodes
The number of computational nodes.
integer(intg) function, public computational_node_number_get(ERR, ERROR)
Returns the number/rank of the computational nodes.
Contains the information for the elements of a mesh.
This module contains all kind definitions.
Contains the topology information for the lines of a domain.
Contains the information for an element in a decomposition.
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...