Skip to content

Commit 5da9985

Browse files
authored
TokaMaker: Coupled TokaMaker/MUG time-dependent evolution (OpenFUSIONToolkit#320)
1 parent 09ef6f5 commit 5da9985

17 files changed

Lines changed: 4132 additions & 250 deletions

File tree

Binary file not shown.

src/examples/TokaMaker/AdvancedWorkflows/Blanket/vde_blanket.ipynb

Lines changed: 806 additions & 0 deletions
Large diffs are not rendered by default.

src/fem/fem_composite.F90

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,20 +304,22 @@ subroutine fem_vec_load(self,source,filename,path,err_flag)
304304
NULLIFY(lge)
305305
DEBUG_STACK_POP
306306
end subroutine fem_vec_load
307+
307308
!------------------------------------------------------------------------------
308-
!> Needs docs
309+
!> Generate graph structure for composite FE representation
309310
!------------------------------------------------------------------------------
310-
subroutine fem_mat_create(self,new,mask)
311+
subroutine fem_graph_create(self, graphs, known_graphs, nknown_graphs, mask)
311312
CLASS(oft_fem_comp_type), INTENT(inout) :: self
312-
CLASS(oft_matrix), POINTER, INTENT(out) :: new
313+
TYPE(oft_graph_ptr), ALLOCATABLE, INTENT(out) :: graphs(:,:)
314+
TYPE(oft_graph_ptr), ALLOCATABLE, INTENT(out) :: known_graphs(:)
315+
INTEGER(i4), INTENT(out) :: nknown_graphs
313316
INTEGER(i4), OPTIONAL, INTENT(in) :: mask(:,:)
314-
INTEGER(i4) :: i,j,k,nknown_graphs
317+
INTEGER(i4) :: i,j,k
315318
INTEGER(i4), ALLOCATABLE, DIMENSION(:,:) :: mat_mask,graph_ids
316319
CLASS(oft_vector), POINTER :: tmp_vec
317-
TYPE(oft_graph_ptr), ALLOCATABLE :: graphs(:,:),known_graphs(:)
318320
DEBUG_STACK_PUSH
319321
!---
320-
IF(oft_debug_print(2))WRITE(*,'(2X,A)')'Building composite FE matrix'
322+
IF(oft_debug_print(2))WRITE(*,'(2X,A)')'Building composite FE graph'
321323
ALLOCATE(mat_mask(self%nfields,self%nfields))
322324
mat_mask=1
323325
IF(PRESENT(mask))mat_mask=mask
@@ -351,7 +353,7 @@ subroutine fem_mat_create(self,new,mask)
351353
IF(mat_mask(i,j)==0)CYCLE
352354
IF(mat_mask(i,j)==2)THEN
353355
IF(i/=j)CALL oft_abort('Identity only valid on diagonal.', &
354-
'fem_mat_create',__FILE__)
356+
'fem_graph_create',__FILE__)
355357
!---Setup identity graph
356358
CALL self%fields(i)%fe%vec_create(tmp_vec)
357359
CALL create_identity_graph(graphs(i,j)%g,tmp_vec)
@@ -383,14 +385,41 @@ subroutine fem_mat_create(self,new,mask)
383385
END IF
384386
END DO
385387
END DO
388+
DEALLOCATE(mat_mask,graph_ids)
389+
DEBUG_STACK_POP
390+
end subroutine fem_graph_create
391+
392+
!------------------------------------------------------------------------------
393+
!> Generate composite FE matrix from user-provided (or default) graph structure
394+
!------------------------------------------------------------------------------
395+
subroutine fem_mat_create(self,new,mask, graphs_in)
396+
CLASS(oft_fem_comp_type), INTENT(inout) :: self
397+
CLASS(oft_matrix), POINTER, INTENT(out) :: new
398+
INTEGER(i4), OPTIONAL, INTENT(in) :: mask(:,:)
399+
TYPE(oft_graph_ptr), OPTIONAL, INTENT(in) :: graphs_in(:,:)
400+
INTEGER(i4) :: i,nknown_graphs
401+
CLASS(oft_vector), POINTER :: tmp_vec
402+
TYPE(oft_graph_ptr), ALLOCATABLE :: graphs(:,:), known_graphs(:)
403+
DEBUG_STACK_PUSH
404+
!---
405+
IF (PRESENT(graphs_in)) THEN
406+
IF(oft_debug_print(2))WRITE(*,'(2X,A)')'Using user-provided graphs for FE matrix'
407+
graphs = graphs_in
408+
ELSE
409+
IF(oft_debug_print(2))WRITE(*,'(2X,A)')'Building composite FE matrix'
410+
CALL fem_graph_create(self, graphs, known_graphs, nknown_graphs, mask)
411+
END IF
386412
!---
387413
CALL self%vec_create(tmp_vec)
388414
CALL create_matrix(new,graphs,tmp_vec,tmp_vec)
389415
CALL tmp_vec%delete
390-
DO i=1,nknown_graphs
391-
DEALLOCATE(known_graphs(i)%g)
392-
END DO
393-
DEALLOCATE(graphs,known_graphs,mat_mask,graph_ids,tmp_vec)
416+
IF (.NOT. PRESENT(graphs_in)) THEN
417+
DO i=1,nknown_graphs
418+
DEALLOCATE(known_graphs(i)%g)
419+
END DO
420+
DEALLOCATE(known_graphs)
421+
END IF
422+
DEALLOCATE(graphs,tmp_vec)
394423
DEBUG_STACK_POP
395424
end subroutine fem_mat_create
396425
!------------------------------------------------------------------------------

src/lin_alg/native_la.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ subroutine native_matrix_setup_full(self,u)
25902590
jp=1
25912591
last=0
25922592
do mm=1,netmp ! Loop over input points
2593-
IF(letmp(1,mm)==last.AND.periodic)THEN
2593+
IF(letmp(1,mm)==last)THEN
25942594
m=jp
25952595
ELSE
25962596
last=letmp(1,mm)
@@ -2631,7 +2631,7 @@ subroutine native_matrix_setup_full(self,u)
26312631
jp=1
26322632
last=0
26332633
do mm=1,neout ! Loop over input points
2634-
IF(leout(1,mm)==last.AND.periodic)THEN
2634+
IF(leout(1,mm)==last)THEN
26352635
m=jp
26362636
ELSE
26372637
last=leout(1,mm)

src/physics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set( OBJS
2020
thin_wall.F90
2121
thin_wall_solvers.F90
2222
thin_wall_hodlr.F90
23+
mugtok_td.F90
2324
)
2425

2526
add_library( oftphysics ${OBJS} )

src/physics/grad_shaf.F90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ MODULE oft_gs
188188
LOGICAL, POINTER, DIMENSION(:) :: saddle_pmask => NULL() !< Point mask for saddle search
189189
LOGICAL, POINTER, DIMENSION(:) :: saddle_cmask => NULL() !< Cell mask for saddle search
190190
LOGICAL, POINTER, DIMENSION(:) :: saddle_rmask => NULL() !< Region mask for saddle search
191+
LOGICAL, POINTER, DIMENSION(:) :: ignore_rmask => NULL() !< Mask for regions to ignore when populating physics (defaults to false)
191192
INTEGER(i4), POINTER, DIMENSION(:) :: limiter_nds => NULL() !< List of limiter nodes
192193
INTEGER(i4), POINTER, DIMENSION(:) :: bc_rhs_list => NULL() !< List of terms interacting with free-boundary BC
193194
INTEGER(i4), POINTER, DIMENSION(:) :: olbp => NULL() !< Oriented list of boundary points
@@ -809,6 +810,10 @@ subroutine gs_init(self)
809810
END DO
810811
END DO
811812
!---Build operators
813+
IF(.NOT.ASSOCIATED(self%ignore_rmask))THEN
814+
ALLOCATE(self%ignore_rmask(smesh%nreg))
815+
self%ignore_rmask=.FALSE.
816+
END IF
812817
IF(.NOT.ASSOCIATED(self%dels))THEN
813818
IF(self%free)THEN
814819
CALL compute_bcmat(self)
@@ -5462,6 +5467,8 @@ subroutine build_dels(mat,self,bc,dt,scale)
54625467
IF(nnonaxi>0)allocate(nonaxi_tmp(self%fe_rep%nce))
54635468
!$omp do schedule(dynamic,1) ordered
54645469
do i=1,self%fe_rep%mesh%nc
5470+
!---Skip cell if in 'ignore' region
5471+
IF(self%ignore_rmask(self%fe_rep%mesh%reg(i))) CYCLE
54655472
!---Get local reconstructed operators
54665473
lop=0.d0
54675474
IF(nnonaxi>0)nonaxi_tmp=0.d0
@@ -5668,6 +5675,8 @@ subroutine dels_coil_part(self,mat,iCoil,dt_in,bc,main_scale,nonaxi_vals)
56685675
allocate(j_lag(self%fe_rep%nce),col_tmp(1,self%fe_rep%nce))
56695676
!!$omp do schedule(static)
56705677
DO j=1,smesh%nc
5678+
!---Skip cell if in 'ignore' region
5679+
IF(self%ignore_rmask(self%fe_rep%mesh%reg(j))) CYCLE
56715680
nturns=self%coil_nturns(smesh%reg(j),iCoil)
56725681
eta_wt=0.d0
56735682
IF(eta_reg(smesh%reg(j))>0.d0)eta_wt=1.d0/(dt_in*eta_reg(smesh%reg(j)))

src/physics/grad_shaf_td.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ subroutine apply_rhs(self,a,b)
538538
allocate(rop(lag_rep%nce),gop(3,lag_rep%nce)) ! Reconstructed gradient operator
539539
!$omp do schedule(static)
540540
do i=1,mesh%nc
541+
!---Skip cell if in 'ignore' region
542+
IF(self%gs_device%ignore_rmask(mesh%reg(i))) CYCLE
541543
IF(mesh%reg(i)==1)CYCLE
542544
!---Get local to global DOF mapping
543545
call lag_rep%ncdofs(i,j)

0 commit comments

Comments
 (0)