wiki:ProjectionObjects

Version 4 (modified by Jonathan, 12 years ago) ( diff )

Back

Projection Objects

Projection Objects can be created within the ProblemModuleInit routine in problem.f90. To create projections you first need to add two USE statements to your problem.f90

  USE Projections
  USE Fields
  USE Cameras

Then in ProblemModuleInit declare a variable pointer of type ProjectionDef

  TYPE(ProjectionDef), POINTER :: Projection

Then create the Projection and set the various parameters as in the following example

    CALL CreateProjection(Projection)
    Projection%Field%id=CoolingStrength_Field
    Projection%Field%component=GASCOMP
    Projection%Field%name='Cooling_Strength'
    Projection%dim=3d0

  • For more information on the Field sub-object's properties see ProcessingFields
  • If you are making several projections, you can reuse the Projection Pointer (with or without Nullifying it) by calling CreateProjection(Projection) for each new projection.
  • If instead of projecting along one of the axis, you wish to use a particular camera viewpoint you can setup a camera object as follows:
       ALLOCATE(Projection%Camera)
       Projection%Camera%pos=(/4d0,-10d0,4d0/)
       Projection%Camera%UpVector=(/0d0,0d0,1d0/)
       Projection%Camera%Focus=(/4d0,4d0,4d0/)
       Projection%Camera%FOV=30d0
       Projection%Camera%Aspect=1d0
    
  • If instead of just one camera angle, you would like a sequence of camera angles for every frame you can read in a camera list. If Projection%lReadCameraList == .true. then a file camera.data should be present in the run directory. The first line contains the number of cameras and then there should be that many camera namelists each with properties for the camera for each image should be shown. The camera%id will be present in the filename… and only the camera properties that change need to be present… (ie focus, up vector, are inherited from the previous camera - but can be changed)
     60
     &CameraData
     Camera%pos=  0.0000000E+00   50.00000       50.00000
     Camera%id=           0
     /
     &CameraData
     Camera%pos=  0.2739029       44.77357       50.00000
     Camera%id=           1
     /
     &CameraData
     Camera%pos=   1.092617       39.60442       50.00000
     Camera%id=           2
     /
     &CameraData
     Camera%pos=   2.447174       34.54915       50.00000
     Camera%id=           3
     /
     &CameraData
     Camera%pos=   4.322727       29.66317       50.00000
     Camera%id=           4
     /
    ...
    

The above camera.data file was generated with a fortran code

program moviescript
   implicit none
   INTEGER :: i, nframes
   REAL :: theta, focus(3), r
   r=50d0
   focus=(/50d0,50d0,50d0/)
   nFrames=60
   write(*,*) nframes
   DO i=0,nframes-1
      theta=2d0*acos(-1d0)*real(i)/real(nframes)
      write(*,*) '&CameraData'
      write(*,*) 'Camera%pos=', focus(1)-r*cos(theta), focus(2)-r*sin(theta), focus(3)
      write(*,*) 'Camera%id=', i
      write(*,*) '/'
   END DO
end program moviescript

  • And finally if you want to make a movie where the camera position changes in time, you can create a movie object.
   NAMELIST /CameraData/ pos, focus, upvector, time
   CALL InitMovie(Projection%movie, nCameras)                                                                                                        
   DO i=1,nCameras                                                                                                                                   
      READ(PROBLEM_DATA_HANDLE,NML=CameraData)                                                                                                       
      CALL AddMovieCamera(Projection%movie, pos, focus, upvector, time)                                                                                            
   END DO                                                                                                                                            
   CALL FinalizeMovie(Projection%Movie)                                                                                                              
END IF                            

where the data file would have

&CameraData
 pos=  0.0000000E+00   50.00000       50.00000
 focus = 0.0 0.0 0.0
 upvector = 0.0 1.0 0.0
 time=0
/
&CameraData
 pos=  0.0000000E+00   0.00000       50.00000
 focus = 0.0 0.0 0.0
 upvector = 0.0 1.0 0.0
 time=1
/

Other camera attributes like field of view, aspect, etc… should be set for the projection's camera object.

  • Here is a full list of the various Projection parameters with the default values
    TYPE(FieldDef) :: Field                                ! Field to use
    REAL(KIND=qPREC), DIMENSION(:,:), ALLOCATABLE :: Data  ! column density of field
    REAL(KIND=qPREC) :: pow=1d0                            ! Power to raise field value to
    INTEGER :: PlotLevel=MAXIMUMPLOTLEVEL                  ! Sets resolution of output to that of PlotLevel.  
    TYPE(ShapeDef), POINTER :: Shape => NULL()             ! Optional Shape object which can be used to exclude points outside of shape.
    INTEGER :: dim=3                                       ! projection axis
    TYPE(CameraDef), POINTER :: Camera => NULL()           ! Optional camera if image is not along principal axis
    LOGICAL :: lReadCameraList=.false.                     ! Can be used instead of a single camera to make a sequence of projections for each frame
    TYPE(ImageDef), POINTER :: Movie => NULL()             ! Optional movie object which will produce a sequence of projections from different viewpoints.
    TYPE(ImageDef), POINTER :: Image => NULL()             ! Optional image object which will produce a ppm file in addition to the bov file.
    TYPE(ProjectionDef), POINTER :: next    
    
  • At each process event (currently each frame) a bov/dat file pair will be generated in the out directory ie. out/cooling_strength_along_3_00014.bov and out/cooling_strength_along_3_00014.dat. The .bov file contains information about the data as well as the location of the actual data file .dat which contains the raw unformatted binary data. Visit will only recognize the .bov files. After opening the file, there will be a 2D dataset with a single variable projection that contains the integrated values.
  • If you want .ppm files which can be converted to .jpeg using ImageMagick's convert program, then you need to create the projection's image object
  • You can also use the bov2jpeg program to quickly turn your bov files into jpeg's outside of astrobear.

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.