Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update element node versions when changing an element basis

Previously only the node numbers were updated, which caused errors
when running the Meshes/MoreComplexMesh example.
Also changed the rest of the mesh_topology_elements_element_basis_set
routine to use move_alloc.
Tracker item 3284.
  • Loading branch information...
commit 37719b183ee51fc55ada748354670a9e6dea928d 1 parent 6824556
@adamreeve adamreeve authored
Showing with 30 additions and 27 deletions.
  1. +30 −27 src/mesh_routines.f90
View
57 src/mesh_routines.f90
@@ -6959,7 +6959,8 @@ SUBROUTINE MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_SET(GLOBAL_NUMBER,ELEMENTS,BASIS
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
- INTEGER(INTG), ALLOCATABLE :: OLD_USER_ELEMENT_NODES(:),OLD_GLOBAL_ELEMENT_NODES(:)
+ INTEGER(INTG), ALLOCATABLE :: NEW_USER_ELEMENT_NODES(:),NEW_GLOBAL_ELEMENT_NODES(:),NEW_USER_ELEMENT_NODE_VERSIONS(:,:)
+ INTEGER(INTG) :: OVERLAPPING_NUMBER_NODES,OVERLAPPING_NUMBER_DERIVATIVES
TYPE(MESH_ELEMENT_TYPE), POINTER :: ELEMENT
TYPE(VARYING_STRING) :: LOCAL_ERROR
@@ -6972,32 +6973,34 @@ SUBROUTINE MESH_TOPOLOGY_ELEMENTS_ELEMENT_BASIS_SET(GLOBAL_NUMBER,ELEMENTS,BASIS
IF(GLOBAL_NUMBER>=1.AND.GLOBAL_NUMBER<=ELEMENTS%NUMBER_OF_ELEMENTS) THEN
IF(ASSOCIATED(BASIS)) THEN
ELEMENT=>ELEMENTS%ELEMENTS(GLOBAL_NUMBER)
- IF(ELEMENT%BASIS%NUMBER_OF_NODES/=BASIS%NUMBER_OF_NODES) THEN
- !Reallocate the user and global element nodes
- ALLOCATE(OLD_USER_ELEMENT_NODES(ELEMENT%BASIS%NUMBER_OF_NODES),STAT=ERR)
- IF(ERR/=0) CALL FLAG_ERROR("Could not allocate old user element nodes",ERR,ERROR,*999)
- ALLOCATE(OLD_GLOBAL_ELEMENT_NODES(ELEMENT%BASIS%NUMBER_OF_NODES),STAT=ERR)
- IF(ERR/=0) CALL FLAG_ERROR("Could not allocate old user element nodes",ERR,ERROR,*999)
- OLD_USER_ELEMENT_NODES=ELEMENT%USER_ELEMENT_NODES
- OLD_GLOBAL_ELEMENT_NODES=ELEMENT%GLOBAL_ELEMENT_NODES
- DEALLOCATE(ELEMENT%USER_ELEMENT_NODES)
- DEALLOCATE(ELEMENT%GLOBAL_ELEMENT_NODES)
- ALLOCATE(ELEMENT%USER_ELEMENT_NODES(BASIS%NUMBER_OF_NODES),STAT=ERR)
- IF(ERR/=0) CALL FLAG_ERROR("Could not allocate user element nodes",ERR,ERROR,*999)
- ALLOCATE(ELEMENT%GLOBAL_ELEMENT_NODES(BASIS%NUMBER_OF_NODES),STAT=ERR)
- IF(ERR/=0) CALL FLAG_ERROR("Could not allocate global element nodes",ERR,ERROR,*999)
- IF(ELEMENT%BASIS%NUMBER_OF_NODES<BASIS%NUMBER_OF_NODES) THEN
- ELEMENT%USER_ELEMENT_NODES(1:ELEMENT%BASIS%NUMBER_OF_NODES)=OLD_USER_ELEMENT_NODES(1:ELEMENT%BASIS%NUMBER_OF_NODES)
- ELEMENT%GLOBAL_ELEMENT_NODES(1:ELEMENT%BASIS%NUMBER_OF_NODES)= &
- & OLD_GLOBAL_ELEMENT_NODES(1:ELEMENT%BASIS%NUMBER_OF_NODES)
- ELEMENT%USER_ELEMENT_NODES(ELEMENT%BASIS%NUMBER_OF_NODES+1:BASIS%NUMBER_OF_NODES)=OLD_USER_ELEMENT_NODES(1)
- ELEMENT%GLOBAL_ELEMENT_NODES(ELEMENT%BASIS%NUMBER_OF_NODES+1:BASIS%NUMBER_OF_NODES)=OLD_GLOBAL_ELEMENT_NODES(1)
- ELSE !ELEMENT%BASIS%NUMBER_OF_NODES>BASIS%NUMBER_OF_NODES
- ELEMENT%USER_ELEMENT_NODES(1:BASIS%NUMBER_OF_NODES)=OLD_USER_ELEMENT_NODES(1:BASIS%NUMBER_OF_NODES)
- ELEMENT%GLOBAL_ELEMENT_NODES(1:BASIS%NUMBER_OF_NODES)=OLD_GLOBAL_ELEMENT_NODES(1:BASIS%NUMBER_OF_NODES)
- ENDIF
- DEALLOCATE(OLD_USER_ELEMENT_NODES)
- DEALLOCATE(OLD_GLOBAL_ELEMENT_NODES)
+ IF(ELEMENT%BASIS%NUMBER_OF_NODES/=BASIS%NUMBER_OF_NODES.OR. &
+ & ELEMENT%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES/=BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES) THEN
+ !Allocate new user and global element nodes
+ ALLOCATE(NEW_USER_ELEMENT_NODES(BASIS%NUMBER_OF_NODES),STAT=ERR)
+ IF(ERR/=0) CALL FLAG_ERROR("Could not allocate new user element nodes",ERR,ERROR,*999)
+ ALLOCATE(NEW_GLOBAL_ELEMENT_NODES(BASIS%NUMBER_OF_NODES),STAT=ERR)
+ IF(ERR/=0) CALL FLAG_ERROR("Could not allocate new user element nodes",ERR,ERROR,*999)
+ ALLOCATE(NEW_USER_ELEMENT_NODE_VERSIONS(BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES, &
+ & BASIS%NUMBER_OF_NODES),STAT=ERR)
+ IF(ERR/=0) CALL FLAG_ERROR("Could not allocate element node versions",ERR,ERROR,*999)
+
+ OVERLAPPING_NUMBER_NODES=MIN(BASIS%NUMBER_OF_NODES,ELEMENT%BASIS%NUMBER_OF_NODES)
+ OVERLAPPING_NUMBER_DERIVATIVES=MIN(BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES,ELEMENT%BASIS%MAXIMUM_NUMBER_OF_DERIVATIVES)
+
+ !Set default values
+ NEW_USER_ELEMENT_NODE_VERSIONS=1
+ NEW_USER_ELEMENT_NODES(OVERLAPPING_NUMBER_NODES+1:)=0
+ NEW_GLOBAL_ELEMENT_NODES(OVERLAPPING_NUMBER_NODES+1:)=0
+ !Copy previous values
+ NEW_USER_ELEMENT_NODES(1:OVERLAPPING_NUMBER_NODES)=ELEMENT%USER_ELEMENT_NODES(1:OVERLAPPING_NUMBER_NODES)
+ NEW_GLOBAL_ELEMENT_NODES(1:OVERLAPPING_NUMBER_NODES)=ELEMENT%GLOBAL_ELEMENT_NODES(1:OVERLAPPING_NUMBER_NODES)
+ NEW_USER_ELEMENT_NODE_VERSIONS(1:OVERLAPPING_NUMBER_DERIVATIVES,1:OVERLAPPING_NUMBER_NODES)= &
+ & ELEMENT%USER_ELEMENT_NODE_VERSIONS(1:OVERLAPPING_NUMBER_DERIVATIVES,1:OVERLAPPING_NUMBER_NODES)
+
+ !Replace arrays with new ones
+ CALL MOVE_ALLOC(NEW_USER_ELEMENT_NODE_VERSIONS,ELEMENT%USER_ELEMENT_NODE_VERSIONS)
+ CALL MOVE_ALLOC(NEW_USER_ELEMENT_NODES,ELEMENT%USER_ELEMENT_NODES)
+ CALL MOVE_ALLOC(NEW_GLOBAL_ELEMENT_NODES,ELEMENT%GLOBAL_ELEMENT_NODES)
ENDIF
ELEMENT%BASIS=>BASIS
ELSE
Please sign in to comment.
Something went wrong with that request. Please try again.