wiki:PFFT

Version 2 (modified by trac, 12 years ago) ( diff )

BackLinksMenu()

PFFT module

The PFFT module allows you to do parallel FFT's of fixed grid data. In order to perform parallel FFTs you need to add one USE statement to your problem.f90

  USE PFFT

Then in ProblemModuleInit declare a variable pointer of type !PFFTPlanDef

  TYPE(PFFTPlanDef), POINTER :: Plan

Then create the Plan where level is the 'level' of the fixed grid, GmGlobal is the bounding box for the data (can be a subregion of the level's grid), and nFields is the number of fields to transform.

    CALL CreatePlan(plan, level, GmGlobal, nFields)

Then each processor can populate it's local subsection of GmGlobal found in plan%lmB ie…

        DO i=plan%lmB(1,1),plan%lmB(1,2)
           DO j=plan%lmB(2,1),plan%lmB(2,2)
              DO k=plan%lmB(3,1),plan%lmB(3,2)
                 kvec=SpectraK((/i,j,k/),plan%mB)
                 k2=sum(kvec**2)
                 IF (k2 > 0d0 .AND. k2 <= 4.0001) THEN
                    ! want to choose random complex components for vk(:)
                    ! 3 real angles - 3 real amplitudes
                    ! want ampiltudes to be evenly distributed on a unit sphere
                    IF (nDim == 2) THEN
                       CALL random_circle(A(1:2))
                    ELSE
                       CALL random_sphere(A)
                    END IF
                    DO l=1,nDim
                       CALL random_number(rand)
                       B(l)=A(l)*exp(2d0*pi*rand*cmplx(0,1))
                    END DO
                    B=B-DOT_PRODUCT(Kvec,B)*Kvec/k2 !subtract off dilational component
                    plan%data(i,j,k,:)=B(1:nDim)*k2**(beta/2d0)
                 ELSE
                    plan%data(i,j,k,:)=0d0
                 END IF
              END DO
           END DO
        END DO

Or the plan's data can be loaded from the AMR data set by calling

  LoadFieldIntoPFFT(plan, FieldIDs)

which will perform all the necessary communication to transfer data from the AMR dataset into each processors subsection of the fixed grid.

Then the plan can be executed by calling

  CALL ExecutePlan(plan, direction)

where direction is either FORWARD or BACKWARD

Then data can be unloaded the same way (ie each processor can access it's own plan%data or it can use UnLoadFieldFromPFFT(plan, FieldID) to populate the AMR dataset.

In general when unloading data their are both real and complex parts to the data set, so FieldID is an nField x 2 integer array that specifies which entries in Info%q should be populated with the results of the calculation. For example:

CALL UnloadFieldFromPFFT(plan, reshape((/ivx,ivy,ivz,0,0,0/),(/3,2/)))

PFFT's use LayoutObjects to store a fixed grid dataset in parallel

Note: See TracWiki for help on using the wiki.