OFF block object definition and implementation.
block_object is a Finite Volume block-structured class.
It allows the easy handling of metrics data for the robust and efficient computation of numerical spatial operators in the framework of Finite Volume Methods (FVM).
Let us assume that the fluid domain \(D\) is decomposed in \(N_b\) structured blocks \(D^b\), each subdivided in \(N_i \times N_j \times N_k\) disjoint hexahedrons \(D_{ijk}^b\) such that \(\bigcup D_{ijk}^b = D^b\). The block class is designed to aid the computations of the spatial operators into each block: $$ \frac{\partial}{{\partial t}}\int\limits_{V_{ijk}} {\overrightarrow U dV} = -\sum\limits_{s = 1}^6 {\int\limits_{S_s} {\left(\overline{\overline {F}}\right) \cdot \overrightarrow n dS}} + \int\limits_{V_{ijk}} {\overrightarrow {{Q}} dV}\label{eq:rans-cons-num} $$ where \(S_s\) is the \(s^{th}\) face of the finite volume \(D_{ijk}\) whose measure is \(V_{ijk}\).
A structured block is composed of hexahedron finite volumes with quadrilateral faces using the following internal numeration for nodes and faces:
/|\Z | F(4) _ F(6) | /|\ /! | 7 | / 8 | *------------------* | /| | / /| | / | | / / | | / | | / / | | / | | / / | | / | | + / | | / | | / | | / | + / | | / 3| / |4 | / * --------/--------* | F(1)<----/----+ / / / | *------------------* +-------->F(2) | 5| / |6 / | | / | / | | / + | / | | / | | / | | / + | | / | | / / | | / | | / / | | / | |/ / | |/ | *------------------* | 1 / | 2 | / \|/ | _ Y |/_ F(3) | /| F(5) | / | / |/ X O----------------------------------------------------->
Each hexadron cells is faces-connected to its neighboring, thus the cells build a structured block with implicit connectivity, e.g. in 2D space a block could be as the following:
_ J /| _____ 5+ ...*----*----*----*----*... | / / / / / / | / / / / / / | 4+ ...*----*----*----*----*... | / / / / / / | / / / / / / | 3+ ...*----*----*----*----*... | Structured block of 4x4 Finite Volumes / / / FV / / / | / / / / / / | 2+ ...*----*----*----*----*... | / / / / / / | / / / / / / | 1+ ...*----*----*----*----*... | / . . . . . | / . . . . . _____ O-------+----+----+----+----+-------------> I 1 2 3 4 5
The nodes of cells are not required to be on the Cartesian coordinates, thus allowing a general curvilinear mesh: the are 3 implicit coordinate lines, i, j and k that are not required to be orthogonal.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=I4P), | private, | parameter | :: | ERROR_BLOCK_COMPUTE_EXTENTS_FAILED | = | 1 | Failed to compute block extents. |
integer(kind=I4P), | private, | parameter | :: | ERROR_BLOCK_CREATE_FAILED | = | 2 | Failed to create block. |
integer(kind=I4P), | private, | parameter | :: | ERROR_BLOCK_CREATE_LINSPACE_FAILED | = | 4 | Failed to create a uniform-spaced linear block. |
integer(kind=I4P), | private, | parameter | :: | ERROR_BLOCK_DESTROY_FAILED | = | 3 | Failed to destroy block. |
integer(kind=I4P), | private, | parameter | :: | NO_ERROR | = | 0 | No errors occurred. |
Block object class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(cell_object), | public, | allocatable | :: | cell(:,:,:) | Cell. |
||
type(error_object), | public | :: | error | Errors handler. |
|||
type(face_object), | public, | allocatable | :: | face_i(:,:,:) | Faces along I direction. |
||
type(face_object), | public, | allocatable | :: | face_j(:,:,:) | Faces along I direction. |
||
type(face_object), | public, | allocatable | :: | face_k(:,:,:) | Faces along I direction. |
||
type(node_object), | public, | allocatable | :: | node(:,:,:) | Cell. |
||
type(block_signature_object), | public | :: | signature | Signature, namely id, level, dimensions, etc… |
generic, public :: assignment(=) => block_assign_block | Overload |
procedure, private, pass(lhs) :: block_assign_block | Operator |
procedure, public, pass(self) :: cells_number | Return the number of cells. |
procedure, private, pass(self) :: compute_extents | Compute block extents. |
procedure, private, pass(self) :: compute_faces_metrics | Compute block faces metrics. |
procedure, private, pass(self) :: compute_metrics | Compute block metrics. |
procedure, public, pass(self) :: compute_space_operator | Compute space operator. |
procedure, private, pass(self) :: compute_volumes | Compute block volumes. |
procedure, private, pass(self) :: correct_metrics | Correct block metrics. |
procedure, public, pass(self) :: create_linspace | Create a Cartesian block with linearly spaced nodes. |
procedure, public, pass(self) :: destroy | Destroy block. |
procedure, public, pass(self) :: initialize | Initialize block. |
procedure, public, pass(self) :: interpolate_at_nodes | Interpolate cell-centered variable at nodes. |
procedure, public, pass(self) :: load_nodes_from_file | Load nodes from file. |
procedure, private, pass(self) :: node_to_center | Compute cell centers coordinates from cell nodes. |
procedure, public, pass(self) :: nodes_number | Return the number of nodes. |
procedure, private, pass(self) :: nullify_normals | Nullify normals for 2D or 1D domains. |
procedure, public, pass(self) :: save_file_grid | Save gird file. |
procedure, private, pass(self) :: save_file_grid_tec | Save grid file in Tecplot format. |
procedure, private, pass(self) :: save_file_grid_vtk | Save grid file in VTK format. |
procedure, public, pass(self) :: save_nodes_into_file | Save nodes into file. |
Return the number of cells.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(in) | :: | self | Block. |
||
logical, | intent(in), | optional | :: | with_ghosts | Take into account ghost cells. |
Number of cells.
Compute cell centers coordinates from cell nodes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(in) | :: | self | Block. |
Cell centers coordinates.
Return the number of nodes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(in) | :: | self | Block. |
||
logical, | intent(in), | optional | :: | with_ghosts | Take into account ghost cells. |
Number of cells.
Operator =
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | lhs | Left hand side. |
||
type(block_object), | intent(in) | :: | rhs | Right hand side. |
Compute block extents.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Compute block faces metrics.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Compute block metrics.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Compute space operator.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(in) | :: | self | Block. |
Compute block volumes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Correct the metrics. |
Create a Cartesian block with linearly spaced nodes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
type(vector), | intent(in), | optional | :: | emin | Coordinates of minimum abscissa of the block. |
|
type(vector), | intent(in), | optional | :: | emax | Coordinates of maximum abscissa of the block. |
Destroy block.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Initialize block.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
type(block_signature_object), | intent(in), | optional | :: | signature | Signature, namely id, level, dimensions, etc… |
|
integer(kind=I8P), | intent(in), | optional | :: | id | Unique (Morton) identification code. |
|
integer(kind=I4P), | intent(in), | optional | :: | level | Grid refinement level. |
|
integer(kind=I4P), | intent(in), | optional | :: | gc(1:) | Number of ghost cells along each frame. |
|
integer(kind=I4P), | intent(in), | optional | :: | ni | Number of cells in I direction. |
|
integer(kind=I4P), | intent(in), | optional | :: | nj | Number of cells in J direction. |
|
integer(kind=I4P), | intent(in), | optional | :: | nk | Number of cells in K direction. |
|
type(vector), | intent(in), | optional | :: | emin | Coordinates of minimum abscissa of the block. |
|
type(vector), | intent(in), | optional | :: | emax | Coordinates of maximum abscissa of the block. |
|
logical, | intent(in), | optional | :: | is_cartesian | Flag for checking if the block is Cartesian. |
|
logical, | intent(in), | optional | :: | is_null_x | Nullify X direction (2D yz, 1D y or z domain). |
|
logical, | intent(in), | optional | :: | is_null_y | Nullify Y direction (2D xy, 1D x or y domain). |
|
logical, | intent(in), | optional | :: | is_null_z | Nullify Z direction (2D xy, 1D x or y domain). |
Interpolate cell-centered variable at nodes.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(in) | :: | self | Block. |
||
real(kind=R8P), | intent(in) | :: | var_cell(1-self%signature%gc(1):,1-self%signature%gc(3):,1-self%signature%gc(5):) | Cell-centered variable. |
||
real(kind=R8P), | intent(out) | :: | var_node(0-self%signature%gc(1):,0-self%signature%gc(3):,0-self%signature%gc(5):) | Node-centered variable. |
Load nodes from file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
integer(kind=I4P), | intent(in) | :: | file_unit | File unit. |
||
integer(kind=I4P), | intent(in) | :: | pos | Position to start the loading. |
Nullify normals for 2D or 1D domains.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
Save grid file file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
character(len=*), | intent(in) | :: | file_name | File name. |
||
logical, | intent(in), | optional | :: | ascii | Ascii/binary output. |
|
logical, | intent(in), | optional | :: | metrics | Save also metrics data. |
|
logical, | intent(in), | optional | :: | tecplot | Tecplot output format sentinel. |
|
logical, | intent(in), | optional | :: | vtk | VTK output format sentinel. |
Save grid file in Tecplot format.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
character(len=*), | intent(in) | :: | file_name | Output file name. |
||
logical, | intent(in), | optional | :: | ascii | Ascii/binary output. |
|
logical, | intent(in), | optional | :: | metrics | Save also metrics data. |
Save mesh data into VTK file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
character(len=*), | intent(in) | :: | file_name | Output file name. |
||
logical, | intent(in), | optional | :: | ascii | Ascii/binary output. |
|
logical, | intent(in), | optional | :: | metrics | Save also metrics data. |
Save nodes into file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(block_object), | intent(inout) | :: | self | Block. |
||
integer(kind=I4P), | intent(in) | :: | file_unit | File unit. |
||
integer(kind=I4P), | intent(in) | :: | pos | Position to start the loading. |