ICFERST  22-06
Reservoir simulator based on DCVFEM, Dynamic Mesh optimisation and Surface-based modelling
multi_tools Module Reference

This module contains the generic subroutines required by ICFERST, for example quicksort. More...

Functions/Subroutines

real function r2norm (VEC, NVEC)
 
real function ptolfun (value)
 :This function is a tolerance function for strictly positive values used as a denominator. If the value of VALUE less than 1E-10, then it returns TOLERANCE otherwise VALUE. More...
 
pure real function tolfun (value)
 :This function is a tolerance function for a value which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE. More...
 
pure real function, dimension(size(val)) tolfun_many (val)
 :This function is a tolerance function for a scalar which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE. More...
 
real function tetvolume (x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3)
 
pure real function, dimension(size(val)) vtolfun (val)
 :This function is a tolerance function for a vector which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE. More...
 
subroutine nan_check (a, k)
 :Checks if a number is a Nan More...
 
subroutine nan_check_arr (a, k)
 :Checks if an array is a Nan More...
 
pure real function, dimension(size(uc)) nvdfunnew_many (UF, UC, XI_LIMIT)
 : The function computes NVDFUNNEW, the normalised value of the advected variable on the face of the control volume, based on the normalised value of the advected variable in the donor CV, UC, and the high-order estimate of the face value UF. NVDFUNNEW is limited so that it is in the non-oscillatory region of normalised variable diagram (NVD). More...
 
real function, dimension(size(uc)) nvdfunnew_many_sqrt (UF, UC, XI_LIMIT)
 : The function computes NVDFUNNEW, the normalised value of the advected variable on the face of the control volume, based on the normalised value of the advected variable in the donor CV, UC, and the high-order estimate of the face value UF. NVDFUNNEW is limited so that it is in the non-oscillatory region of normalised variable diagram (NVD). More...
 
integer function, dimension(:), pointer get_ndglno (mesh)
 
recursive subroutine quicksort (vec, n)
 :Sort a list in increasing order Vec is the vector to sort and n is an starting point, like 1 More...
 
subroutine calc_face_ele (FACE_ELE, TOTELE, STOTEL, NFACE, FINELE, COLELE, CV_NLOC, CV_SNLOC, CV_NONODS, CV_NDGLN, CV_SNDGLN, CV_SLOCLIST, X_NLOC, X_NDGLN)
 : Calculate FACE_ELE - the list of elements surrounding an element and referenced with a face -ve values correspond to surface elements. More...
 
subroutine assign_val (outval, inval)
 :Copies the data from inval to outval safely. If the sizes are different outval is populated using the first value of inval More...
 
real function table_interpolation (X_points, Y_points, input_X)
 X_points, Y_points to form a linear (size == 2) or quadratic (size == 3) interpolation. More...
 
subroutine read_csv_table (data_array, path_to_table, extra_data)
 :Template of csv table OPTIONAL section (header) real1,real2,real3,..., size(extra_data) rows,columns 2,3 Pressure,Saturation 1000,0.9 250,0.5 100,0.1 More...
 
subroutine extract_strings_from_csv_file (csv_table_strings, path_to_table, Nentries)
 :This subroutine reads a csv file and returns them in an array More...
 
subroutine printmatrix (Matrix)
 :Subroutine to print Arrays by (columns,rows) Matrix = 2D Array More...
 
subroutine rotationmatrix (a, R)
 : Roates a matrix A using the toration matrix R???? More...
 
subroutine read_nastran_file (filepath, node, edges)
 :This subroutine reads a nastran file that contains the information defining the 1D path of a well the input relative filepath should include the file format, for example: well.bdf More...
 
subroutine least_squares_solver (A, b, rank)
 Subroutine that solves the least squares problem |Ax-b|2 using LAPACK and blas Subroutine tested and compared with Matlab (not recommended changing it since it is a pain!) Only for serial: The best option is to solve in each processor the optimisation system by performing A' * A = A' *b; so the system becomes very small as COLUMS <<< ROWS. More...
 
subroutine multi_compute_python_field (states, iphase, option_path_python, scalar_result, sfield, vfield, tfield)
 : This subroutine uses python run string to run the python_scalar_diagnostic to read a field the only difference with the normal approach is that here the Dummy field is used and the returned field is an array. IMPORTANT: state is used here, NOT packed_state It can be used for a given array, scalar_result, scalar fields, vector fields or tensor fields, but only one at a time More...
 
subroutine petsc_logging (func, stage, ierr, default, push_no, stage_name)
 Subroutines that can initialise, register and start/end a petsc performance profiling routin. The defauly behaviour is initiliased for time-loop profiling. More...
 
logical function is_tracer_field (input_name)
 : Returns true if the input name is a Tracer type:PassiveTracer, Tracer, Species, Concentration or any other reserved word This function is used to easily identify Tracers that may have diffusion, sources/sinks, dispersion, etc. More...
 
logical function is_active_tracer_field (input_name, ignore_concentration)
 : Returns true if the input name is an Active Tracer type, Tracer, Species, Concentration or any other reserved word This function is used to easily identify Tracers that may have diffusion, sources/sinks, dispersion, etc. More...
 
logical function is_passivetracer_field (input_name)
 : Returns true if the input name is a PassievTracer type. More...
 

Detailed Description

This module contains the generic subroutines required by ICFERST, for example quicksort.

Function/Subroutine Documentation

◆ assign_val()

subroutine multi_tools::assign_val ( real, dimension(:), intent(inout)  outval,
real, dimension(:), intent(in)  inval 
)

:Copies the data from inval to outval safely. If the sizes are different outval is populated using the first value of inval

Here is the caller graph for this function:

◆ calc_face_ele()

subroutine multi_tools::calc_face_ele ( integer, dimension( :, : ), intent(inout)  FACE_ELE,
integer, intent(in)  TOTELE,
integer, intent(in)  STOTEL,
integer, intent(in)  NFACE,
integer, dimension( : ), intent(in)  FINELE,
integer, dimension( : ), intent(in)  COLELE,
integer, intent(in)  CV_NLOC,
integer, intent(in)  CV_SNLOC,
integer, intent(in)  CV_NONODS,
integer, dimension( : ), intent(in)  CV_NDGLN,
integer, dimension( : ), intent(in)  CV_SNDGLN,
integer, dimension( :, : ), intent(in)  CV_SLOCLIST,
integer, intent(in)  X_NLOC,
integer, dimension( : ), intent(in)  X_NDGLN 
)

: Calculate FACE_ELE - the list of elements surrounding an element and referenced with a face -ve values correspond to surface elements.

Here is the caller graph for this function:

◆ extract_strings_from_csv_file()

subroutine multi_tools::extract_strings_from_csv_file ( character(len=option_path_len), dimension(:,:), intent(out), allocatable  csv_table_strings,
character( len = option_path_len ), intent(in)  path_to_table,
integer, intent(out)  Nentries 
)

:This subroutine reads a csv file and returns them in an array

Parameters
csv_table_stringsINOUT Allocated array of characters to be used to read the CVS file
path_to_tableabsolute/relative path to the .csv file
NentriesOUT Number of entries in the table
Here is the caller graph for this function:

◆ get_ndglno()

integer function, dimension(:), pointer multi_tools::get_ndglno ( type(mesh_type)  mesh)
Here is the caller graph for this function:

◆ is_active_tracer_field()

logical function multi_tools::is_active_tracer_field ( character( len = * ), intent(in)  input_name,
logical, intent(in), optional  ignore_concentration 
)

: Returns true if the input name is an Active Tracer type, Tracer, Species, Concentration or any other reserved word This function is used to easily identify Tracers that may have diffusion, sources/sinks, dispersion, etc.

Here is the caller graph for this function:

◆ is_passivetracer_field()

logical function multi_tools::is_passivetracer_field ( character( len = * ), intent(in)  input_name)

: Returns true if the input name is a PassievTracer type.

Here is the caller graph for this function:

◆ is_tracer_field()

logical function multi_tools::is_tracer_field ( character( len = * ), intent(in)  input_name)

: Returns true if the input name is a Tracer type:PassiveTracer, Tracer, Species, Concentration or any other reserved word This function is used to easily identify Tracers that may have diffusion, sources/sinks, dispersion, etc.

Here is the caller graph for this function:

◆ least_squares_solver()

subroutine multi_tools::least_squares_solver ( real, dimension(:,:), intent(inout)  A,
real, dimension(:,:), intent(inout)  b,
integer, intent(inout)  rank 
)

Subroutine that solves the least squares problem |Ax-b|2 using LAPACK and blas Subroutine tested and compared with Matlab (not recommended changing it since it is a pain!) Only for serial: The best option is to solve in each processor the optimisation system by performing A' * A = A' *b; so the system becomes very small as COLUMS <<< ROWS.

Author
Pablo Salinas
Parameters
AInput matrix to decompose, returns the Q and R combined
bInput RHS term, returns the X that minimise the system

◆ multi_compute_python_field()

subroutine multi_tools::multi_compute_python_field ( type( state_type ), dimension(:), intent(inout)  states,
integer, intent(in)  iphase,
character( len = * ), intent(in)  option_path_python,
real, dimension(:), intent(inout), optional  scalar_result,
type (scalar_field), intent(inout), optional  sfield,
type (vector_field), intent(inout), optional  vfield,
type (tensor_field), intent(inout), optional  tfield 
)

: This subroutine uses python run string to run the python_scalar_diagnostic to read a field the only difference with the normal approach is that here the Dummy field is used and the returned field is an array. IMPORTANT: state is used here, NOT packed_state It can be used for a given array, scalar_result, scalar fields, vector fields or tensor fields, but only one at a time

Parameters
statesArray of Linked list containing all the fields
iphaseCurrent phase
option_path_pythonPath in the input file to the python code
scalar_resultField to be provided to the python code as initial value
sfieldOptional Only one can be picked, depending on the type of field to be used!
vfieldOptional Only one can be picked, depending on the type of field to be used!
tfieldOptional Only one can be picked, depending on the type of field to be used!
Here is the caller graph for this function:

◆ nan_check()

subroutine multi_tools::nan_check ( real  a,
integer  k 
)

:Checks if a number is a Nan

◆ nan_check_arr()

subroutine multi_tools::nan_check_arr ( real, dimension(:,:)  a,
integer  k 
)

:Checks if an array is a Nan

◆ nvdfunnew_many()

pure real function, dimension(size(uc)) multi_tools::nvdfunnew_many ( real, dimension( : ), intent(in)  UF,
real, dimension( : ), intent(in)  UC,
real, dimension( : ), intent(in)  XI_LIMIT 
)

: The function computes NVDFUNNEW, the normalised value of the advected variable on the face of the control volume, based on the normalised value of the advected variable in the donor CV, UC, and the high-order estimate of the face value UF. NVDFUNNEW is limited so that it is in the non-oscillatory region of normalised variable diagram (NVD).

XI is the parameter in equation 38 of the Riemann paper. If XI is equal to 2 then this corresponds to a TVD condition in 1-D, a value of XI equal to 3 has been recommended elsewhere

Here is the caller graph for this function:

◆ nvdfunnew_many_sqrt()

real function, dimension(size(uc)) multi_tools::nvdfunnew_many_sqrt ( real, dimension( : ), intent(in)  UF,
real, dimension( : ), intent(in)  UC,
real, dimension( : ), intent(in)  XI_LIMIT 
)

: The function computes NVDFUNNEW, the normalised value of the advected variable on the face of the control volume, based on the normalised value of the advected variable in the donor CV, UC, and the high-order estimate of the face value UF. NVDFUNNEW is limited so that it is in the non-oscillatory region of normalised variable diagram (NVD).

XI is the parameter in equation 38 of the Riemann paper. If XI is equal to 2 then this corresponds to a TVD condition in 1-D, a value of XI equal to 3 has been recommended elsewhere

◆ petsc_logging()

subroutine multi_tools::petsc_logging ( integer, intent(in)  func,
dimension(0:9)  stage,
intent(inout)  ierr,
logical, intent(in), optional  default,
integer, intent(in), optional  push_no,
character(len=*), dimension(1), optional  stage_name 
)

Subroutines that can initialise, register and start/end a petsc performance profiling routin. The defauly behaviour is initiliased for time-loop profiling.

Author
Asiri Obeysekara
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printmatrix()

subroutine multi_tools::printmatrix ( real, dimension(:,:), intent(in)  Matrix)

:Subroutine to print Arrays by (columns,rows) Matrix = 2D Array

Here is the caller graph for this function:

◆ ptolfun()

real function multi_tools::ptolfun ( real, intent(in)  value)

:This function is a tolerance function for strictly positive values used as a denominator. If the value of VALUE less than 1E-10, then it returns TOLERANCE otherwise VALUE.

Here is the caller graph for this function:

◆ quicksort()

recursive subroutine multi_tools::quicksort ( integer, dimension(n), intent(inout)  vec,
integer, intent(in)  n 
)

:Sort a list in increasing order Vec is the vector to sort and n is an starting point, like 1

Here is the call graph for this function:
Here is the caller graph for this function:

◆ r2norm()

real function multi_tools::r2norm ( real, dimension( nvec )  VEC,
integer  NVEC 
)
Here is the caller graph for this function:

◆ read_csv_table()

subroutine multi_tools::read_csv_table ( real, dimension(:,:), intent(inout), allocatable  data_array,
character( len = option_path_len ), intent(in)  path_to_table,
real, dimension(:), intent(inout), optional  extra_data 
)

:Template of csv table OPTIONAL section (header) real1,real2,real3,..., size(extra_data) rows,columns 2,3 Pressure,Saturation 1000,0.9 250,0.5 100,0.1

Parameters
data_arrayINOUT the data in memory
path_to_tableabsolute/relative path to the .csv file
extra_dataThe extra data is composed of one line of headers that we ignore plus one extra line with the data

◆ read_nastran_file()

subroutine multi_tools::read_nastran_file ( character( len = * ), intent(in)  filepath,
real, dimension(:,:), intent(inout), allocatable  node,
integer, dimension(:,:), intent(inout), allocatable  edges 
)

:This subroutine reads a nastran file that contains the information defining the 1D path of a well the input relative filepath should include the file format, for example: well.bdf

Parameters
filepathRelative path to the .bdf file
nodeINOUT. Nodes stored
edgesEdges connecting nodes
Here is the call graph for this function:

◆ rotationmatrix()

subroutine multi_tools::rotationmatrix ( real, dimension(3), intent(in)  a,
real, dimension(3,3), intent(out)  R 
)

: Roates a matrix A using the toration matrix R????

◆ table_interpolation()

real function multi_tools::table_interpolation ( real, dimension(:), intent(in)  X_points,
real, dimension(:), intent(in)  Y_points,
real, intent(in)  input_X 
)

X_points, Y_points to form a linear (size == 2) or quadratic (size == 3) interpolation.

◆ tetvolume()

real function multi_tools::tetvolume ( real, intent(in)  x0,
real, intent(in)  y0,
real, intent(in)  z0,
real, intent(in)  x1,
real, intent(in)  y1,
real, intent(in)  z1,
real, intent(in)  x2,
real, intent(in)  y2,
real, intent(in)  z2,
real, intent(in)  x3,
real, intent(in)  y3,
real, intent(in)  z3 
)
Here is the caller graph for this function:

◆ tolfun()

pure real function multi_tools::tolfun ( real, intent(in)  value)

:This function is a tolerance function for a value which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE.

Here is the caller graph for this function:

◆ tolfun_many()

pure real function, dimension(size(val)) multi_tools::tolfun_many ( real, dimension(:), intent(in)  val)

:This function is a tolerance function for a scalar which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE.

Here is the caller graph for this function:

◆ vtolfun()

pure real function, dimension(size(val)) multi_tools::vtolfun ( real, dimension(:), intent(in)  val)

:This function is a tolerance function for a vector which is used as a denominator. If the absolute value of VALUE less than 1E-10, then it returns SIGN(A,B) i.e. the absolute value of A times the sign of B where A is TOLERANCE and B is VALUE.

Here is the caller graph for this function: