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¶
Source
More information on the Generic_File
structure in Tolosa-lib/src/submodule/m_out_generic.f90
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' )
Note
One can specify a subdirectory named generic
to put the result.txt
file in. fortran
call generic%init( name = 'result.txt' , dir = 'generic')
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%open
This 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¶
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) :: datetime
type(unk) :: dof
integer(ip) :: ic
[...]
call generic%write( datetime%date_current%julian_cnes_date , &
dof%ssh(ic) )
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.
Write an array
One can write the sea surface height at every mesh cell by simply writting :
call generic%write( dof%ssh(:) )
Close¶
When the data is written, one can close the generic file by calling the close
procedure.
call generic%close
Summary¶
To summarize :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
X-Y Datafile¶
This paragraph will present the Data_File
structure, its features and its implementation.
Source
More information on the Data_File
structure in Tolosa-lib/src/submodule/m_out_datafile.f90
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¶
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.
.
open
and header
procedures
- One can open the data file separately from the initialization by calling the
open
procedure. One can specifyreset = .true.
if all the previously written data should be overridden
call datafile%open( reset = .true. )
or simply write
call datafile%open
otherwise.
- One can also write the file header separately from the initialization by calling :
call datafile%header( data_names = 'time/ssh/u/v' )
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) :: datetime
type(unk) :: dof
real(rp), allocatable :: bathy_cell(:) ! Bathymetry at mesh cells center
integer(ip) :: ic
[...]
call datafile%write( datetime%date_current%julian_cnes_date , &
bathy_cell( ic ) + dof%h( ic ) , &
dof%u( ic ) , &
dof%v( ic ) )
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.
write an array of values
As explained before, one can also write all the values in an array :
call datafile%write( dof%h(:) )
Close¶
When the data file is complete, one can close the file by calling the close
procedure.
call datafile%close
Summary¶
To summarize :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
VTK¶
The 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.
Source
More information on the VTK_File
structure in Tolosa-lib/src/submodule/m_out_vtk.f90
See Summary to have the general use of this structure.
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) :: mesh
type(VTK_file) :: vtk
[...]
call vtk%init( name = 'result' , &
dir = 'vtk' , &
format = 'Binary' , &
mesh = mesh , &
timeseries = .false. )
Initialization with a mesh subdomain
If one wants to write time independant data on a smaller part of the domain, one has to write :
type(msh) :: mesh
type(VTK_file) :: bin
type(window_in_mesh) :: window
type(vec2d) :: node(4)
[...]
call window%init( [ node(1) , node(2) , node(3) , node(4) ] )
call window%search( mesh = mesh )
[...]
call vtk%init( name = 'result' , &
dir = 'vtk' , &
format = 'Binary' , &
mesh = mesh , &
nc = window%cell , &
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 )
Warning
The mesh connectivity needs to be written before proceeding with the data. Therefore, one has to call write_geo
or specify the mesh
(and eventually nc
) variable(s) in the initialization to proceed.
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' )
dof
a structure of arrays (SoA) of the model primitive variables. The name
variable is optional.
Warning
If the data is time dependant, the write_geo
and write_scalar
procedures need to be called at each time step. However, one does not need to initialize a new structure at each time step ; a new .vtk
file will be created simply by calling write_geo
and write_scalar
.
The file is closed automatically at the end of the write_scalar
procedure.
Summary¶
To summarize :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
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.
Source
More information on the Tecplot_File
structure in Tolosa-lib/src/submodule/m_out_tecplot.f90
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) :: mesh
type(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' )
Note
dir
, format
, title
and typ
are optional.
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) :: dof
real(rp) :: tc = 0._rp ! Simulation Time
[...]
call tecplot%write( dof%ssh(:) , &
dof%u(:) , &
dof%v(:) , &
names = 'ssh/u/v' , &
time = tc )
Note
names
and time
are optional, and one can write a maximum of eight arrays.
The file is automatically closed at the end of the write
procedure.
Summary¶
To summarize :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
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.
Source
More information on the Binary_File
structure in Tolosa-lib/src/submodule/m_out_bin.f90
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) :: mesh
type(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¶
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.
call bin%init( name = 'result' , &
dir = 'bin' , &
withinfo = .true. )
[...]
call bin%write_mesh( mesh = mesh )
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) :: window
type(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¶
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 node
real(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' )
Warning
The data written in a binary file is data attached to each node or cell of the mesh. Therefore, one needs to specify and write the mesh before extracting any data in a binary file.
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.
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
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¶
To summarize :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|