Outputs
Outputs
Section titled “Outputs”Various outputs can be generated. One can create output files with the following formats :
- Tecplot files : Output files describing the state of the domain (2D) or the evolution of some variables at a specific point. These files can be written in ASCII or binary format and read by Tecplot.
- VTK files : 2D output files describing the state of the domain. These files can be written in ASCII or binary format and read by Paraview for example.
- Gnuplot files : Output files describing the evolution of various variables. These files can be read by Gnuplot.
- CSV files : Output files describing the evolution of various variables. These files can be read by Microsoft Excel for example.
- Binary files : 2D output files describing the state of the domain in a binary format. These files can be read and post-treated by a Python post-treatment tool PyTolosa.
All these outputs will be generated in a res directory inside the bin directory.
Generic file
Section titled “Generic file”Initialization
Section titled “Initialization”To write in a generic file, one needs to initialize the Generic_file object first by calling the init procedure. One has to specify the file’s name, and can specify the name of an eventual /res subdirectory where the file(s) will be placed.
For example, to initialize a new Generic_File object to create a result.txt file, one can write :
type(Generic_File ) :: generic
[...]
call generic%init( name = 'result.txt' )This initialization also opens the generic file by calling the open procedure, but if one needs to open an already initialized generic file, one can write :
call generic%openThis operation will append data in the generic file. To replace the former content, one has to make sure the file is closed and then specify reset = .true. when opening :
call generic%close
call generic%open( reset = .true. )Write data
Section titled “Write data”When the generic file is opened, and the Generic_File structure initialized, one can begin to write data. The data can be written by specifying all the entries to be written separately, or by specifying an array. Either way, the procedure to call is write.
For example, one can choose to write the time evolution of the sea surface height at a specific mesh cell identified by its index ic.
type(Generic_File ) :: generic
type(date_time) :: datetimetype(unk) :: dofinteger(ip) :: ic
[...]
call generic%write( datetime%date_current%julian_cnes_date , & dof%ssh(ic) )with dof a structure of arrays (SoA) of the model primitive variables, and datetime a date_time structure handling the time and the date of the simulation.
When the data is written, one can close the generic file by calling the close procedure.
call generic%closeSummary
Section titled “Summary”To summarize :
type(Generic_File ) :: generictype(unk) :: dofinteger(ip) :: it, ntcharacter(len=1028) :: buffer = ''
[...]
do it = 1 , nt write(buffer,'(A,I6.6)') 'ssh_' , it write(buffer,'(A)') trim(buffer)//'.txt'
call generic%init( name = trim(buffer) , dir = 'generic') call generic%write( dof%ssh(:) ) call generic%closeend doX-Y Datafile
Section titled “X-Y Datafile”This paragraph will present the Data_File structure, its features and its implementation.
Supported format
Section titled “Supported format”With the Data_File structure, one can create X-Y outputs in various formats :
- CSV, readable by Microsoft Excel
- Gnuplot files (
.dat), readable by Gnuplot - Tecplot files (
.plt), readable by Tecplot - Default text files (
.txt)
The generated file contains the evolution of several datas. One can for example write the time evolution of the sea surface height at a specific cell of the domain.
Initialization
Section titled “Initialization”To write in a data file, one needs to initialize the Data_file object first by calling the init procedure. This routine defines the structure’s parameters and opens the data file. To initialize this Data_File object, one has to specify the name of the file. One can also give the name of the /res subdirectory containing the data file, the format of the file, the time step at which data should be written, the process handling the writting. One can also specify if the data is time dependant, and the data name(s). If the data name(s) are given, init also fills the file’s header out with data_names.
type(Data_File) :: datafile
[...]
call datafile%init( name = 'result' , & dir = 'data' , & format = 'csv' , & data_names = 'julian_cnes/ssh/u/v' , & in_time = .true. , & dt = 0. , & which_proc = 3 )Here the initialization allows the process 3 to open the file res/datafiles/result.csv and write the header containing all the data names respecting a .csv file format. Data will be written at each computation time step since dt = 0..
Write data
Section titled “Write data”When the Data_File structure is initialized, one can start either writting the file’s header if not already written, or if it is already written, write the data values. One can call the write procedure by giving the various values one by one (d1, d2, etc.) or the array of values to be written.
Here, one has chosen to write the time evolution of the sea surface height, and the horizontal and vertical velocity components. The following commands enable to write the time evolution of these variables in a mesh cell ic.
type(Data_File) :: datafile
type(date_time) :: datetimetype(unk) :: dofreal(rp), allocatable :: bathy_cell(:) ! Bathymetry at mesh cells centerinteger(ip) :: ic
[...]
call datafile%write( datetime%date_current%julian_cnes_date , & bathy_cell( ic ) + dof%h( ic ) , & dof%u( ic ) , & dof%v( ic ) )with dof a structure of arrays (SoA) of the model primitive variables, and datetime a date_time structure handling the time and the date of the simulation.
When the data file is complete, one can close the file by calling the close procedure.
call datafile%closeSummary
Section titled “Summary”To summarize :
type(Data_File), allocatable :: datafile(:)type(date_time) :: datetimetype(unk) :: dofreal(rp), allocatable :: bathy_cell(:) ! Bathymetry at mesh cells centerinteger(ip) :: ic, it, nt
[...]!===============================================================================================!! Initialization : initializes the Data_File structure!===============================================================================================!
call datafile%init( name = 'result' , & dir = 'data' , & format = 'csv' , & data_names = 'julian_cnes/ssh/u/v' , & in_time = .true. , & dt = 0. , & which_proc = 3 )
!===============================================================================================!! Write time independant data!===============================================================================================!
do it = 1 , nt [...] call datafile%write( datetime%date_current%julian_cnes_date , & bathy_cell( ic ) + dof%h( ic ) , & dof%u( ic ) , & dof%v( ic ) )end doThe Visualization Toolkit is an open-source, freely available software system for 3D computer graphics, modeling, image processing, volume rendering, scientific visualization, and 2D plotting. Here, one can plot his 2D results by reading the .vtk files with Paraview. The VTK_File structure enables one to get simulation data in .vtk files.
This paragraph will present the VTK_File structure, its features and its implementation.
See Summary to have the general use of this structure.
Initialization
Section titled “Initialization”To be able to write .vtk files, one needs to initialize the file structure by calling the init procedure. One can specify the base name of the file, the subdirectory containing this file, the title of the VTK file, its type (Legacy or XML) and its format (Binary or ASCII). If one wishes to get the time evolution of certain fields, one has to define timeseries = .true.
The data written in VTK files represents the state of the domain. Therefore, the data contained in these files depends on the domain’s mesh. Here, if the parameter mesh (and if a smaller window with the nc parameter) is given, this procedure will write the VTK file header with the mesh connectivity by calling the write_geo procedure.
For example, to initialize a new VTK_File object in binary format with time independant data describing the state of the whole domain, one has to write :
type(msh) :: meshtype(VTK_file) :: vtk
[...]
call vtk%init( name = 'result' , & dir = 'vtk' , & format = 'Binary' , & mesh = mesh , & timeseries = .false. )As mentionned before, by specifying the mesh at the initialization, the write_geo procedure will be called. However, one can also write the mesh connectivity separately from the initialization. This is in fact mandatory if the data is time dependant.
call vtk%init( name = 'result' , & dir = 'vtk' , & format = 'Binary' , & timeseries = .true. )
[...]
call vtk%write_geo( mesh = mesh , & nc = window%cell )Write data
Section titled “Write data”When the VTK_File initialization is done, one can begin to write data in the file by calling the write_scalar procedure.
Here, if one wants to write the state of the sea surface height and the horizontal and vertical speed components on the entire domain, one can write :
type(unk) :: dof
[...]
call vtk%write_scalar( dof%ssh(:) , name = 'ssh' )call vtk%write_scalar( dof%u(:) , name = 'u' )call vtk%write_scalar( dof%v(:) , name = 'v' )with dof a structure of arrays (SoA) of the model primitive variables. The name variable is optional.
The file is closed automatically at the end of the write_scalar procedure.
Summary
Section titled “Summary”To summarize :
=== “Write time independant data” ```fortran linenums=“1” type(msh) :: mesh type(VTK_File) :: vtk real(rp), allocatable :: bathy_cell(:) ! Bathymetry at mesh cells center
[...]!===============================================================================================!! Initialization : initializes the VTK_file structure and writes mesh! connectivity (write_geo) since 'mesh' is specified!===============================================================================================!
call vtk%init( name = 'result' , & dir = 'vtk' , & format = 'Binary' , & mesh = mesh , & timeseries = .false. )
!===============================================================================================!! Write time independant data!===============================================================================================!
call vtk%write_scalar( bathy_cell(:) , name = 'bathymetry' )```=== “Write time dependant data” ```fortran linenums=“1” type(msh) :: mesh type(VTK_File) :: vtk type(unk) :: dof integer(ip) :: it, nt
[...]!===============================================================================================!! Initialization : initializes the VTK_file structure!===============================================================================================!
call vtk%init( name = 'result' , & dir = 'vtk' , & format = 'Binary' , & timeseries = .true. )
!===============================================================================================!! Write time dependant data!===============================================================================================!
do it = 1 , nt
[...] call vtk%write_geo ( mesh = mesh ) call vtk%write_scalar( dof%ssh(:) , name = 'ssh' ) call vtk%write_scalar( dof%u(:) , name = 'u' ) call vtk%write_scalar( dof%v(:) , name = 'v' )
end do```Tecplot
Section titled “Tecplot”Tecplot is a Computational Fluid Dynamics (CFD) and numerical simulation software package used in post-processing simulation results.
This paragraph will present the Tecplot_File structure, its features and its implementation.
Initialization
Section titled “Initialization”The Tecplot_File structure enables one to get simulation data in .plt Tecplot files. To be able to write those .plt files, one needs to initialize the file structure by calling the init procedure. One needs to specify the mesh of the domain. Moreover, one can specify the base name of the file, the subdirectory containing this file, the title of the Tecplot file, its connectivity type (Orig is the original Gmsh mesh indexation or Part is the partionned mesh indexation) and its format (Binary or ASCII).
The data written in Tecplot files represents the state of the domain. Therefore, the data contained in these files depends on the domain’s mesh. Here, the parameter mesh enables one to write the mesh connectivity in a Tecplot file at the Tecplot_File object initialization. This mesh Tecplot file is named XXXX_grid.plt.
type(msh) :: meshtype(Tecplot_File) :: tecplot
[...]
call tecplot%init( mesh = mesh , & name = 'result' , & dir = 'tecplot' , & format = 'Binary' , & typ = 'Part' )The initialization creates a result_grid.plt file in a tecplot subdirectory and writes the partitionned mesh connectivity in a binary format. One can also specify the title of the file that will be written as a header :
call tecplot%init( mesh = mesh , & name = 'result' , & dir = 'tecplot' , & format = 'Binary' , & title = 'Tolosa tecplot file' , & typ = 'Part' )Write data
Section titled “Write data”When the mesh connectivity is written, one can write data in the tecplot file. One can write data that describe the state of the domain, specify their names, and the time. One can call the write procedure at each time step for example without having to initialize the Tecplot_File structure every time, since the mesh connectivity is written in a separate XXXX_grid.plt Tecplot file.
The Tecplot file containing the data is named XXXX_t_TT.plt where XXXX is the name chosen, and TT the time.
Here, one can write the distribution of the sea surface height with the horizontal and vertical speed components by writting :
type(unk) :: dofreal(rp) :: tc = 0._rp ! Simulation Time
[...]
call tecplot%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & names = 'ssh/u/v' , & time = tc )The file is automatically closed at the end of the write procedure.
Summary
Section titled “Summary”To summarize :
type(msh) :: meshtype(Tecplot_File) :: tecplottype(unk) :: dofinteger(ip) :: it, ntreal(rp) :: tc = 0._rp ! Simulation Time
!===============================================================================================!! Initialization : initializes the Tecplot_File structure!===============================================================================================!
call tecplot%init( mesh = mesh , & name = 'result' , & dir = 'tecplot' , & format = 'Binary' , & typ = 'Part' )[...]
!===============================================================================================!! Write time dependant data!===============================================================================================!
do it = 1 , nt [...] call tecplot%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & names = 'ssh/u/v' , & time = tc )end doBinary
Section titled “Binary”One can also obtain the simulation results in binary files. The Binary_File structure enables one to extract data in binary files. The content of these binary files is documented in an information file in the same repertory. The data extracted in these binary files can be the mesh connectivity of the considered domain as well of various fields’ distribution.
This paragraph will present the Binary_File structure, its features and its implementation.
Initialization
Section titled “Initialization”The Binary_File enables one to get simulation data in binary files. To be able to write in binary files, one needs to initialize the file structure by calling the init procedure. If the mesh connectivity (and the optional window nc) are given, init will call the write_mesh subroutine. The withinfo variable enables one to write an information file ; this information file enables the user to know the detailed structure of each binary file. One can also define the dir directory to generate binary file(s).
type(msh) :: meshtype(Binary_File) :: bin
[...]
call bin%init( name = 'result' , & dir = 'bin' , & mesh = mesh , & withinfo = .true. )where mesh is a type(msh) object (see Mesh). Here, one has stated the base name of the binary file(s) result, the binary file(s)’ directory bin, the mesh of the domain. Moreover, one has specified that an information file should be written.
Write mesh connectivity
Section titled “Write mesh connectivity”One can write the mesh connectivity of the whole domain or of a smaller part of the domain by calling the write_mesh procedure. The mesh cells contained in this smaller window are listed in the nc table. As mentionned before, if the mesh variable is specified, the initialization will also write the mesh connectivity in a binary file.
=== “Write mesh connectivity separately from the initialization” ```fortran call bin%init( name = ‘result’ , & dir = ‘bin’ , & withinfo = .true. )
[...]
call bin%write_mesh( mesh = mesh )```=== “Write mesh connectivity at the initialization”
fortran call bin%init( name = 'result' , & dir = 'bin' , & mesh = mesh , & withinfo = .true. )
One can choose to consider a smaller part of the domain and only write the mesh connectivity of this smaller domain. One should define this smaller domain by creating a window_in_mesh object, and then consider the window%cell variable to give it to the write_mesh procedure.
type(msh) :: mesh
type(Binary_File) :: bin
type(window_in_mesh) :: windowtype(vec2d) :: node(4)
[...]
call window%init( [ node(1) , node(2) , node(3) , node(4) ] )call window%search( mesh = mesh )
[...]
call bin%init( name = 'result' , & ! EQUIVALENT ! dir = 'bin' , & ! call bin%init( name = 'result' , & withinfo = .true. ) ! dir = 'bin' , & ! withinfo = .true. , &call bin%write_mesh( mesh = mesh , & ! mesh = mesh , & nc = window%cell ) ! nc = window%cell )Write data
Section titled “Write data”One can also choose to write data in binary file(s) by calling the write procedure. One has to state if the field’s values are located at mesh nodes or cells (elt). One can write data in one binary file and choose to specify the current date at the time step (withdate and date_to_write = datetime%date_current) and the minimum and maximum values of each field (withminmax).
real(rp), allocatable :: lon_node_degrees(:) ! Geographic longitude at nodereal(rp), allocatable :: lat_node_degrees(:) ! Geographic latitude at node
[...]
call bin%write( lon_node_degrees , & lat_node_degrees , & elt = 'node' , & name = 'lon_lat_degrees' , & varnames = 'lon/lat' )If the data varies in time, and one wishes to extract the data distribution at each time step, one has to specify that istimeserie = .true.. Moreover, one can choose to extract all the primitive variables’ distribution in one file per time step or in only one file by changing the withconcact option.
=== “Data split in different files for each time step” ```fortran type(date_time) :: datetime type(unk) :: dof integer(ip) :: it, nt
[...]
do it = 1 , nt [...] call bin%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & elt = 'cell' , & name = 'data' , & varnames = 'ssh/u/v' , & istimeserie = .true. , & withdate = .true. , & date_to_write = datetime%date_current , & withminmax = .true. )
end do```=== “Data concatenation” ```fortran type(date_time) :: datetime type(unk) :: dof integer(ip) :: it, nt
[...]
do it = 1 , nt [...] call bin%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & elt = 'cell' , & name = 'data' , & varnames = 'ssh/u/v' , & istimeserie = .true. , & withconcact = .true. , & withdate = .true. , & date_to_write = datetime%date_current , & withminmax = .true. )
end do```with dof a structure of arrays (SoA) of the model primitive variables, and datetime a date_time structure handling the time and the date of the simulation. Before writting the fields’s distribution, this subroutine writes a key (defining the content of the file(s)), the date and the fields’ minimum and maximum values.
Summary
Section titled “Summary”To summarize :
=== “Data distribution on the entire domain” ```fortran linenums=“1” type(msh) :: mesh type(Binary_File) :: bin type(date_time) :: datetime type(unk) :: dof integer(ip) :: it, nt
!===============================================================================================!! Initialization : initializes the Binary_File structure!===============================================================================================!
call bin%init( name = 'result' , & dir = 'bin' , & mesh = mesh , & withinfo = .true. )
[...]
!===============================================================================================!! Write time dependant data!===============================================================================================!
do it = 1 , nt [...] call bin%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & elt = 'cell' , & name = 'data' , & varnames = 'ssh/u/v' , & istimeserie = .true. , & withdate = .true. , & date_to_write = datetime%date_current , & withminmax = .true. )
end do```=== “Data distribution on a smaller part of the domain” ```fortran linenums=“1” type(msh) :: mesh type(Binary_File) :: bin type(date_time) :: datetime type(unk) :: dof integer(ip) :: it, nt type(window_in_mesh) :: window type(vec2d) :: node(4)
!===============================================================================================!! Initialization : initializes the Binary_File structure!===============================================================================================!
call window%init( [ node(1) , node(2) , node(3) , node(4) ] )call window%search( mesh = mesh )
call bin%init( name = 'result' , & dir = 'bin' , & mesh = mesh , & nc = window%cell , & withinfo = .true. )
[...]
!===============================================================================================!! Write time dependant data!===============================================================================================!
do it = 1 , nt [...] call bin%write( dof%ssh(:) , & dof%u(:) , & dof%v(:) , & elt = 'cell' , & name = 'data' , & varnames = 'ssh/u/v' , & istimeserie = .true. , & withdate = .true. , & date_to_write = datetime%date_current , & withminmax = .true. )
end do```