diff --git a/src/formal/divergence_1D_s.F90 b/src/formal/divergence_1D_s.F90 index b7aa0d4..1c12aa1 100644 --- a/src/formal/divergence_1D_s.F90 +++ b/src/formal/divergence_1D_s.F90 @@ -27,6 +27,11 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) #endif + ! PURPOSE: Definition of procedure to compute the product of a scalar and a divergence + ! KEYWORDS: scalar multiplication + ! CONTEXT: Invoke this function via the binary infix operator "*" with scalar and divergence left- and + ! right-hand operands, respectively + module procedure premultiply_scalar_1D call_julienne_assert(size(scalar_1D%values_) .equalsExpected. size(divergence_1D%values_) + 2) scalar_x_divergence_1D%tensor_1D_t = & @@ -38,18 +43,42 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) #endif call_julienne_assert(size(scalar_x_divergence_1D%weights_) .equalsExpected. size(divergence_1D%values_)+2) end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute the product of a divergence and a scalar + ! KEYWORDS: scalar multiplication + ! CONTEXT: Invoke this function via the binary infix operator "*" with divergence and scalar left- and + ! right-hand operands, respectively module procedure postmultiply_scalar_1D scalar_x_divergence_1D = premultiply_scalar_1D(scalar_1D, divergence_1D) end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to provide the cell-centered values of divergences. + ! KEYWORDS: staggered grid, divergence + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete divergence values. module procedure divergence_1D_values cell_centered_values = self%values_ end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to provide staggered-grid locations at which divergence values are stored: cell centers. + ! KEYWORDS: cell centers, staggered grid, divergence + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete gradient-vector locations for + ! initialization-function sampling, printing, or plotting. module procedure divergence_1D_grid cell_centers = cell_center_locations(self%x_min_, self%x_max_, self%cells_) end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute the quadrature weights for use in the mimetic inner products of a scalar + ! and the divergence of a vector. + ! KEYWORDS: quadrature, numerical integration, coefficients, weights + ! CONTEXT: Invoke this function via the "weights" generic binding to produce the quadrature weights + ! associated with mimetic approximations to divergences. module procedure divergence_1D_weights integer c @@ -72,5 +101,5 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) call_julienne_assert(self%cells_ .isAtLeast. 2*size(skin)) call_julienne_assert(size(weights) .equalsExpected. self%cells_+2) end procedure - -end submodule divergence_1D_s \ No newline at end of file + ! END CODE CHUNK +end submodule divergence_1D_s diff --git a/src/formal/divergence_operator_1D_s.F90 b/src/formal/divergence_operator_1D_s.F90 index fd0fc18..780b003 100644 --- a/src/formal/divergence_operator_1D_s.F90 +++ b/src/formal/divergence_operator_1D_s.F90 @@ -36,6 +36,10 @@ pure function negate_and_flip(A) result(Ap) #endif + ! PURPOSE: Definition of procedure to construct an object representing a 1D mimetic divergence operator. + ! KEYWORDS: 1D, divergence operator, sparse matrix, constructor + ! CONTEXT: Use this type to assemble a divergence-operator matrix for printing. + module procedure construct_1D_divergence_operator double precision, allocatable :: Ap(:,:) @@ -100,6 +104,7 @@ pure function M(k, dx) result(row) end function end procedure construct_1D_divergence_operator + ! END CODE CHUNK module procedure submatrix_A_rows call_julienne_assert(allocated(self%upper_)) @@ -186,4 +191,4 @@ pure function e(dir, length) result(unit_vector) end procedure -end submodule divergence_operator_1D_s \ No newline at end of file +end submodule divergence_operator_1D_s diff --git a/src/formal/gradient_1D_s.F90 b/src/formal/gradient_1D_s.F90 index e3589f1..bbd7f60 100644 --- a/src/formal/gradient_1D_s.F90 +++ b/src/formal/gradient_1D_s.F90 @@ -16,6 +16,12 @@ contains + ! PURPOSE: Definition of procedure to compute the quadrature weights for use in the mimetic inner products of a vector + ! and the gradient of a scalar. + ! KEYWORDS: quadrature, numerical integration, coefficients, weights + ! CONTEXT: Inovke this function via the "weights" generic binding to produce the quadrature weights + ! associated with mimetic approximations to gradients. + module procedure gradient_1D_weights integer face @@ -38,6 +44,12 @@ call_julienne_assert(size(weights) .equalsExpected. self%cells_ + 1) end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute the scalar (dot) product of a vector and the gradient of a scalar. + ! KEYWORDS: scalar product, dot product, inner product + ! CONTEXT: Inovke this function via the .dot. binary infix operator in expressions of the form + ! g .dot. b with a gradient_1D_t g and a vector_1D_t b. module procedure dot call_julienne_assert(size(gradient_1D%values_) .equalsExpected. size(vector_1D%values_)) @@ -59,5 +71,5 @@ vector_dot_gradient_1D%weights_ = gradient_1D%gradient_1D_weights() #endif end procedure - + ! END CODE CHUNK end submodule gradient_1D_s diff --git a/src/formal/gradient_operator_1D_s.F90 b/src/formal/gradient_operator_1D_s.F90 index 0298e58..2c22e39 100644 --- a/src/formal/gradient_operator_1D_s.F90 +++ b/src/formal/gradient_operator_1D_s.F90 @@ -36,7 +36,11 @@ pure function negate_and_flip(A) result(Ap) end function #endif - + + ! PURPOSE: Definition of procedure to construct a new mimetic gradient-operator matrix representation of kth order for 1D cells of width dx. + ! KEYWORDS: 1D, gradient-operator constructor, sparse matrix + ! CONTEXT: Use this function to construct a sparse-matrix represntation of a mimetic gradient operator. + module procedure construct_1D_gradient_operator call_julienne_assert(cells .isAtLeast. 2*k) @@ -92,6 +96,7 @@ pure function corbino_castillo_M(k, dx) result(row) end function end procedure construct_1D_gradient_operator + ! END CODE CHUNK module procedure gradient_matrix_multiply @@ -168,4 +173,4 @@ pure function e(dir, length) result(unit_vector) end procedure -end submodule gradient_operator_1D_s \ No newline at end of file +end submodule gradient_operator_1D_s diff --git a/src/formal/laplacian_s.f90 b/src/formal/laplacian_s.f90 index a8a4eaa..8bfa87e 100644 --- a/src/formal/laplacian_s.f90 +++ b/src/formal/laplacian_s.f90 @@ -5,8 +5,13 @@ implicit none contains + ! PURPOSE: Definition of procedure to report the number of boundary-adjacent locations at which the Laplacian has reduced-order accuracy. + ! KEYWORDS: Laplacian, boundary, order of accuracy + ! CONTEXT: Use this function to determine the region of slightly slower convergence for mimetic Laplacian approximations. + module procedure reduced_order_boundary_depth num_nodes = self%boundary_depth_ end procedure + ! END CODE CHUNK end submodule laplacian_s diff --git a/src/formal/mimetic_operators_1D_m.F90 b/src/formal/mimetic_operators_1D_m.F90 index 22a4670..5241c2b 100644 --- a/src/formal/mimetic_operators_1D_m.F90 +++ b/src/formal/mimetic_operators_1D_m.F90 @@ -36,6 +36,10 @@ pure module function construct_matrix_operator(upper, inner, lower) result(mimet end interface + ! PURPOSE: Definition of type to encapsulate a one-dimenstional (1D) mimetic gradient operator matrix. + ! KEYWORDS: type definition, 1D gradient operator matrix + ! CONTEXT: Use this type to assemble gradient-operator matrix for printing. + type, extends(mimetic_matrix_1D_t) :: gradient_operator_1D_t !! Encapsulate a 1D mimetic gradient operator private @@ -48,9 +52,14 @@ pure module function construct_matrix_operator(upper, inner, lower) result(mimet generic :: assemble => assemble_gradient procedure, non_overridable, private :: assemble_gradient end type + ! END CODE CHUNK interface gradient_operator_1D_t + ! PURPOSE: Interface for procedure to construct a new mimetic gradient-operator matrix representation of kth order for 1D cells of width dx. + ! KEYWORDS: 1D, gradient-operator constructor, sparse matrix + ! CONTEXT: Use this function to construct a sparse-matrix represntation of a mimetic gradient operator. + pure module function construct_1D_gradient_operator(k, dx, cells) result(gradient_operator_1D) !! Construct a mimetic gradient operator implicit none @@ -59,9 +68,14 @@ pure module function construct_1D_gradient_operator(k, dx, cells) result(gradien integer, intent(in) :: cells !! number of grid cells type(gradient_operator_1D_t) gradient_operator_1D end function + ! END CODE CHUNK end interface + ! PURPOSE: Interface for procedure to encapsulate a 1D mimetic divergence operator matrix. + ! KEYWORDS: 1D, divergence operator, sparse matrix + ! CONTEXT: Use this type to assemble divergence-operator matrix for printing. + type, extends(mimetic_matrix_1D_t) :: divergence_operator_1D_t !! Encapsulate kth-order mimetic divergence operator on m_ cells of width dx private @@ -74,9 +88,14 @@ pure module function construct_1D_gradient_operator(k, dx, cells) result(gradien procedure, non_overridable, private :: assemble_divergence procedure, non_overridable :: submatrix_A_rows end type + ! END CODE CHUNK interface divergence_operator_1D_t + ! PURPOSE: Interface for procedure to construct an object representing a 1D mimetic divergence operator. + ! KEYWORDS: 1D, divergence operator, sparse matrix, constructor + ! CONTEXT: Use this type to assemble a divergence-operator matrix for printing. + pure module function construct_1D_divergence_operator(k, dx, cells) result(divergence_operator_1D) !! Construct a mimetic gradient operator implicit none @@ -85,6 +104,7 @@ pure module function construct_1D_divergence_operator(k, dx, cells) result(diver integer, intent(in) :: cells !! number of grid cells type(divergence_operator_1D_t) divergence_operator_1D end function + ! END CODE CHUNK end interface diff --git a/src/formal/scalar_1D_s.F90 b/src/formal/scalar_1D_s.F90 index 47fa585..06a9774 100644 --- a/src/formal/scalar_1D_s.F90 +++ b/src/formal/scalar_1D_s.F90 @@ -23,6 +23,12 @@ #ifndef __GFORTRAN__ + ! PURPOSE: Definition of procedure to construct a new scalar_1D_t object by assigning each argument to a corresponding + ! corresponding component of the new object. + ! KEYWORDS: 1D scalar field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell centers along one spatial dimension bounded by x_min and x_max. + module procedure construct_1D_scalar_from_function call_julienne_assert(x_max .greaterThan. x_min) call_julienne_assert(cells .isAtLeast. 2*order) @@ -32,9 +38,15 @@ end associate scalar_1D%gradient_operator_1D_ = gradient_operator_1D_t(k=order, dx=(x_max - x_min)/cells, cells=cells) end procedure - + ! END CODE CHUNK #else + ! PURPOSE: Definition of procedure to construct a new scalar_1D_t object by assigning each argument to a corresponding + ! corresponding component of the new object. + ! KEYWORDS: 1D scalar field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell centers along one spatial dimension bounded by x_min and x_max. + pure module function construct_1D_scalar_from_function(initializer, order, cells, x_min, x_max) result(scalar_1D) procedure(scalar_1D_initializer_i), pointer :: initializer integer, intent(in) :: order !! order of accuracy @@ -51,6 +63,7 @@ pure module function construct_1D_scalar_from_function(initializer, order, cells end associate scalar_1D%gradient_operator_1D_ = gradient_operator_1D_t(k=order, dx=(x_max - x_min)/cells, cells=cells) end function + ! END CODE CHUNK pure function cell_center_locations(x_min, x_max, cells) result(x) double precision, intent(in) :: x_min, x_max @@ -65,6 +78,10 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) #endif + ! PURPOSE: Definition of procedure to compute mimetic approximations to the gradient of scalar fields. + ! KEYWORDS: gradient, differential operator + ! CONTEXT: Invoke this function via the unary .grad. operator with a right-hand-side, scalar-field operand. + module procedure grad integer c @@ -81,6 +98,11 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) end associate end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute mimetic approximations to the Laplacian of a scalar field. + ! KEYWORDS: Laplacian, differential operator + ! CONTEXT: Invoke this function via the unary .laplacian. operator with a right-hand-side, scalar-field operand. module procedure laplacian @@ -95,10 +117,16 @@ pure function cell_center_locations(x_min, x_max, cells) result(x) end associate end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to provide the cell-centered values of scalar quantities. + ! KEYWORDS: cell centers, staggered grid, scalar field + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete scalar values. module procedure scalar_1D_values cell_centers_extended_values = self%values_ end procedure + ! END CODE CHUNK pure function scalar_1D_grid_locations(x_min, x_max, cells) result(x) double precision, intent(in) :: x_min, x_max @@ -111,8 +139,14 @@ pure function scalar_1D_grid_locations(x_min, x_max, cells) result(x) end associate end function + ! PURPOSE: Definition of procedure to provide the staggered-grid locations at which scalar values are stored: cell centers plus domain boundaries. + ! KEYWORDS: staggered grid, scalar field, cell centers + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete scalar locations for + ! initialization-function sampling, printing, or plotting. + module procedure scalar_1D_grid cell_centers_extended = scalar_1D_grid_locations(self%x_min_, self%x_max_, self%cells_) end procedure + ! END CODE CHUNK -end submodule scalar_1D_s \ No newline at end of file +end submodule scalar_1D_s diff --git a/src/formal/scalar_x_divergence_1D_s.F90 b/src/formal/scalar_x_divergence_1D_s.F90 index 93b9b04..1d3ea8d 100644 --- a/src/formal/scalar_x_divergence_1D_s.F90 +++ b/src/formal/scalar_x_divergence_1D_s.F90 @@ -9,9 +9,15 @@ contains + ! PURPOSE: Definition of procedure to perform mimetic volume integration of a scalar/divergence dot product. + ! KEYWORDS: triple integral, volume integral + ! CONTEXT: Invoke this function in expressions of the form .SSS. (f * .div. v) * dV + ! with a vector_1D_t v, a scalar f, and a differential volume dV. + module procedure volume_integrate_scalar_x_divergence_1D call_julienne_assert(size(integrand%weights_ ) .equalsExpected. size(integrand%values_)+2) integral = sum(integrand%weights_ * [0D0, integrand%values_, 0D0]) end procedure + ! END CODE CHUNK end submodule scalar_x_divergence_1D_s diff --git a/src/formal/tensor_1D_s.f90 b/src/formal/tensor_1D_s.f90 index c67558b..f7a6f09 100644 --- a/src/formal/tensor_1D_s.f90 +++ b/src/formal/tensor_1D_s.f90 @@ -5,6 +5,11 @@ implicit none contains + ! PURPOSE: Definition of procedure to construct a new tensor_1D_t object by assigning each argument to a corresponding + ! corresponding component of the new object. + ! KEYWORDS: 1D tensor constructor + ! CONTEXT: Constructors for child types assign this function's result to to the child object's parent component. + module procedure construct_1D_tensor_from_components tensor_1D%values_ = values tensor_1D%x_min_ = x_min @@ -12,10 +17,15 @@ tensor_1D%cells_ = cells tensor_1D%order_ = order end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to provide a uniform cell width along the x-coordinate spatial direction. + ! KEYWORDS: abcissa, mesh spacing + ! CONTEXT: Use this function to produce cell widths for uniform 1D meshes. module procedure dx dx = (self%x_max_ - self%x_min_)/self%cells_ end procedure - + ! END CODE CHUNK end submodule tensor_1D_s diff --git a/src/formal/tensors_1D_m.F90 b/src/formal/tensors_1D_m.F90 index 2615a7c..3c817d1 100644 --- a/src/formal/tensors_1D_m.F90 +++ b/src/formal/tensors_1D_m.F90 @@ -24,12 +24,27 @@ module tensors_1D_m abstract interface + ! PURPOSE: Interface for procedure to provide values for initializing a scalar_1D_t object at the cell centers and boundaries + ! for use in the mimetic discretization scheme of Corbino-Castillo (2020) + ! KEYWORDS: mimetic discretization, scalar function, sampling, one-dimensional (1D) + ! CONTEXT: This abstract interface is used to declare a procedure pointer that can be associated with + ! a user-defined function. The user's function can be invoked via this abstract interface + ! to sample the function at the appropriate grid locations. + pure function scalar_1D_initializer_i(x) result(f) !! Sampling function for initializing a scalar_1D_t object implicit none double precision, intent(in) :: x(:) double precision, allocatable :: f(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide values for initializing a vector function of one spatial dimension at cell faces + ! as defined in the mimetic discretization scheme of Corbino-Castillo (2020). + ! KEYWORDS: mimetic discretization, vector function, sampling, 1D + ! CONTEXT: This abstract interface is used to declare a procedure pointer that can be associated with + ! a user-defined function. The user's function can be invoked via this abstract interface + ! to sample the function at the appropriate grid locations. pure function vector_1D_initializer_i(x) result(v) !! Sampling function for initializing a vector_1D_t object @@ -37,9 +52,15 @@ pure function vector_1D_initializer_i(x) result(v) double precision, intent(in) :: x(:) double precision, allocatable :: v(:) end function + ! END CODE CHUNK end interface + ! PURPOSE: Definition for type to encapsulate the data and operations that are common to most or all tensor_1D_t child types + ! KEYWORDS: type definition, mimetic discretization, grid values, grid functions, 1D + ! CONTEXT: Child types extend this derived type to define specific types of tensors such as scalars, + ! vectors, gradients, and divergences. + type tensor_1D_t !! Encapsulate the components that are common to all 1D tensors. !! Child types define the operations supported by each child, including @@ -56,9 +77,15 @@ pure function vector_1D_initializer_i(x) result(v) generic :: dV => dx procedure, non_overridable :: dx end type + ! END CODE CHUNK interface tensor_1D_t + ! PURPOSE: Interface for procedure to construct a new tensor_1D_t object by assigning each argument to a corresponding + ! corresponding component of the new object. + ! KEYWORDS: 1D tensor constructor + ! CONTEXT: Constructors for child types assign this function's result to to the child object's parent component. + pure module function construct_1D_tensor_from_components(values, x_min, x_max, cells, order) result(tensor_1D) !! User-defined constructor: result is a 1D tensor defined by assigning the dummy arguments to corresponding components implicit none @@ -69,9 +96,14 @@ pure module function construct_1D_tensor_from_components(values, x_min, x_max, c integer, intent(in) :: order !! order of accuracy type(tensor_1D_t) tensor_1D end function + ! END CODE CHUNK end interface + ! PURPOSE: Definition for type to encapsulate a scalar function of one spatial dimension as a tensor with a gradient operator. + ! KEYWORDS: type definition, 1D scalar field abstraction + ! CONTEXT: Combine with other tensors via expressions that may include differential operators + type, extends(tensor_1D_t) :: scalar_1D_t !! Encapsulate scalar values at cell centers and boundaries private @@ -86,9 +118,16 @@ pure module function construct_1D_tensor_from_components(values, x_min, x_max, c procedure, non_overridable, private :: scalar_1D_values procedure, non_overridable, private :: scalar_1D_grid end type + ! END CODE CHUNK interface scalar_1D_t + ! PURPOSE: Interface for procedure to construct a new scalar_1D_t object by assigning each argument to a corresponding + ! corresponding component of the new object. + ! KEYWORDS: 1D scalar field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell centers along one spatial dimension bounded by x_min and x_max. + pure module function construct_1D_scalar_from_function(initializer, order, cells, x_min, x_max) result(scalar_1D) !! Result is a collection of cell-centered-extended values with a corresponding mimetic gradient operator implicit none @@ -99,9 +138,14 @@ pure module function construct_1D_scalar_from_function(initializer, order, cells double precision, intent(in) :: x_max !! grid location maximum type(scalar_1D_t) scalar_1D end function + ! END CODE CHUNK end interface + ! PURPOSE: Definition for type to encapsulate a vector function of one spatial dimension as a tensor with a divergence operator. + ! KEYWORDS: type definition, 1D vector field abstraction + ! CONTEXT: Combine with other tensors via expressions that may include differential operators + type, extends(tensor_1D_t) :: vector_1D_t !! Encapsulate 1D vector values at cell faces (of unit area for 1D) and corresponding operators private @@ -122,15 +166,26 @@ pure module function construct_1D_scalar_from_function(initializer, order, cells procedure, non_overridable, private :: vector_1D_grid procedure, non_overridable, private :: vector_1D_values end type + ! END CODE CHUNK + + ! PURPOSE: Definition of type to encapsulate a scalar/vector product weighted for integration on a surface + ! KEYWORDS: type definition, 1D product abstraction + ! CONTEXT: Combine with other tensors via expressions that may include the double integrals type, extends(tensor_1D_t) :: weighted_product_1D_t contains generic :: operator(.SS.) => surface_integrate_vector_x_scalar_1D procedure, non_overridable, private :: surface_integrate_vector_x_scalar_1D end type + ! END CODE CHUNK interface vector_1D_t + ! PURPOSE: Interface for procedure to construct a new vector_1D_t object by sampling a function of one spatial dimension. + ! KEYWORDS: 1D vector field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell faces along one spatial dimension bounded by x_min and x_max. + pure module function construct_1D_vector_from_function(initializer, order, cells, x_min, x_max) result(vector_1D) !! Result is a 1D vector with values initialized by the provided procedure pointer sampled on the specified !! number of evenly spaced cells covering [x_min, x_max] @@ -142,16 +197,27 @@ pure module function construct_1D_vector_from_function(initializer, order, cells double precision, intent(in) :: x_max !! grid location maximum type(vector_1D_t) vector_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to construct a new vector_1D_t object from a parent tensor and a divergence operator object. + ! KEYWORDS: 1D vector field constructor + ! CONTEXT: Invoke this constructor with a an object to be used to define the constructed parent component + ! divergence-operator matrix component. pure module function construct_from_components(tensor_1D, divergence_operator_1D) result(vector_1D) - !! Result is a 1D vector with the provided parent component tensor_1D and the provided divergence operatror + !! Result is a 1D vector with the provided parent component tensor_1D and the provided divergence operator type(tensor_1D_t), intent(in) :: tensor_1D type(divergence_operator_1D_t), intent(in) :: divergence_operator_1D type(vector_1D_t) vector_1D end function + ! END CODE CHUNK end interface + ! PURPOSE: Definition of type for a vector child type for capturing gradient data and a scalar (dot) product operator. + ! KEYWORDS: type definition, 1D gradient vector field abstraction + ! CONTEXT: The scalar_1D_t .grad. operator produces this type as a result. + type, extends(vector_1D_t) :: gradient_1D_t !! A 1D mimetic gradient vector field abstraction with a public method that produces corresponding numerical quadrature weights contains @@ -161,6 +227,11 @@ pure module function construct_from_components(tensor_1D, divergence_operator_1D #endif procedure, non_overridable, private, pass(gradient_1D) :: dot end type + ! END CODE CHUNK + + ! PURPOSE: Definition of type for a tensor child type for capturing the scalar (dot) product of a vector and a gradient vector data + ! KEYWORDS: type definition, 1D vector/gradient scalar product + ! CONTEXT: An instance of this type can serve as an integrand in a .SSS. triple-integral operator. type, extends(tensor_1D_t) :: vector_dot_gradient_1D_t !! Result is the dot product of a 1D vector field and a 1D gradient field @@ -170,6 +241,12 @@ pure module function construct_from_components(tensor_1D, divergence_operator_1D generic :: operator(.SSS.) => volume_integrate_vector_dot_grad_scalar_1D procedure, non_overridable, private, pass(integrand) ::volume_integrate_vector_dot_grad_scalar_1D end type + ! END CODE CHUNK + + ! PURPOSE: Definition of type for a tensor child type capturing the divergence of a vector function of one spatial dimension. + ! KEYWORDS: type definition, 1D, divergence + ! CONTEXT: Although a mathematical scalar, this type differs from scalar_1D_t in that the values are stored + ! _only_ at cell centers, whereas a scalar_1D_t object additionally has values at domain boundaries. type, extends(tensor_1D_t) :: divergence_1D_t !! Encapsulate divergences at cell centers @@ -183,6 +260,11 @@ pure module function construct_from_components(tensor_1D, divergence_operator_1D procedure, non_overridable, private :: divergence_1D_values procedure, non_overridable, private :: divergence_1D_grid end type + ! END CODE CHUNK + + ! PURPOSE: Definition of type for a tensor child type for capturing the product of a scalar and divergence + ! KEYWORDS: type definition, 1D scalar/divergence product + ! CONTEXT: An instance of this type can serve as an integrand in a .SSS. triple-integral operator. type, extends(tensor_1D_t) :: scalar_x_divergence_1D_t !! product of a 1D scalar field and a 1D divergence field @@ -192,6 +274,13 @@ pure module function construct_from_components(tensor_1D, divergence_operator_1D generic :: operator(.SSS.) => volume_integrate_scalar_x_divergence_1D procedure, non_overridable, private, pass(integrand) :: volume_integrate_scalar_x_divergence_1D end type + ! END CODE CHUNK + + ! PURPOSE: Definition of type for a divergence child type capturing the result of applying a divergence operator to a gradient. + ! KEYWORDS: type definition, 1D, laplacian + ! CONTEXT: Although a mathematical a divergence, this type additionally provides a type-bound procedure that + ! returns the number of boundary-adjacent points at which the Laplacian approximation's accuracy drops by + ! by one order relative to the parent divergence type. type, extends(divergence_1D_t) :: laplacian_1D_t private @@ -199,9 +288,14 @@ pure module function construct_from_components(tensor_1D, divergence_operator_1D contains procedure reduced_order_boundary_depth end type + ! END CODE CHUNK interface + ! PURPOSE: Interface for procedure to provide the differential area for use in surface integrals. + ! KEYWORDS: surface integral, area integral, double integral, numerical quadrature, mimetic discretization + ! CONTEXT: Use this in expressions of the form .SS. (f .x. (v .dot. dA)) with a scalar_1D_t f and vector_1D_t v + pure module function dA(self) !! Result is the grid's discrete surface-area differential for use in surface integrals of the form !! .SS. (f .x. (v .dot. dA)) @@ -209,6 +303,11 @@ pure module function dA(self) class(vector_1D_t), intent(in) :: self double precision dA end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide a uniform cell width along the x-coordinate spatial direction. + ! KEYWORDS: abcissa, mesh spacing + ! CONTEXT: Use this function to produce cell widths for uniform 1D meshes. pure module function dx(self) !! Result is the uniform cell width @@ -216,13 +315,25 @@ pure module function dx(self) class(tensor_1D_t), intent(in) :: self double precision dx end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide the staggered-grid locations at which scalar values are stored: cell centers plus domain boundaries. + ! KEYWORDS: staggered grid, scalar field, cell centers + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete scalar locations for + ! initialization-function sampling, printing, or plotting. pure module function scalar_1D_grid(self) result(cell_centers_extended) - !! Result is the array of locations at which 1D scalars are defined: cell centers agumented by spatial boundaries + !! Result is the array of locations at which 1D scalars are defined: cell centers augmented by spatial boundaries implicit none class(scalar_1D_t), intent(in) :: self double precision, allocatable :: cell_centers_extended(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide staggered-grid locations at which vector values are stored: cell faces. + ! KEYWORDS: abcissa, cell faces + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete vector locations for + ! initialization-function sampling, printing, or plotting. pure module function vector_1D_grid(self) result(cell_faces) !! Result is the array of cell face locations (of unit area for 1D) at which 1D vectors are defined @@ -230,6 +341,12 @@ pure module function vector_1D_grid(self) result(cell_faces) class(vector_1D_t), intent(in) :: self double precision, allocatable :: cell_faces(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide staggered-grid locations at which divergence values are stored: cell centers. + ! KEYWORDS: cell centers, staggered grid, divergence + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete gradient-vector locations for + ! initialization-function sampling, printing, or plotting. pure module function divergence_1D_grid(self) result(cell_centers) !! Result is the array of cell centers at which 1D divergences are defined @@ -237,6 +354,11 @@ pure module function divergence_1D_grid(self) result(cell_centers) class(divergence_1D_t), intent(in) :: self double precision, allocatable :: cell_centers(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide the cell-centered values of scalar quantities. + ! KEYWORDS: cell centers, staggered grid, scalar field + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete scalar values. pure module function scalar_1D_values(self) result(cell_centers_extended_values) !! Result is an array of 1D scalar values at boundaries and cell centers @@ -244,6 +366,11 @@ pure module function scalar_1D_values(self) result(cell_centers_extended_values) class(scalar_1D_t), intent(in) :: self double precision, allocatable :: cell_centers_extended_values(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide the cell face-centered values of vector quantities. + ! KEYWORDS: staggered grid, vector field + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete vector values. pure module function vector_1D_values(self) result(face_centered_values) !! Result is an array of the 1D vector values at cell faces (of unit area 1D) @@ -251,6 +378,11 @@ pure module function vector_1D_values(self) result(face_centered_values) class(vector_1D_t), intent(in) :: self double precision, allocatable :: face_centered_values(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to provide the cell-centered values of divergences. + ! KEYWORDS: staggered grid, divergence + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete divergence values. pure module function divergence_1D_values(self) result(cell_centered_values) !! Result is an array of 1D divergences at cell centers @@ -258,6 +390,11 @@ pure module function divergence_1D_values(self) result(cell_centered_values) class(divergence_1D_t), intent(in) :: self double precision, allocatable :: cell_centered_values(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute mimetic approximations to the gradient of scalar fields. + ! KEYWORDS: gradient, differential operator + ! CONTEXT: Invoke this function via the unary .grad. operator with a right-hand-side, scalar-field operand. pure module function grad(self) result(gradient_1D) !! Result is mimetic gradient of the scalar_1D_t "self" @@ -265,6 +402,11 @@ pure module function grad(self) result(gradient_1D) class(scalar_1D_t), intent(in) :: self type(gradient_1D_t) gradient_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute mimetic approximations to the Laplacian of a scalar field. + ! KEYWORDS: Laplacian, differential operator + ! CONTEXT: Invoke this function via the unary .laplacian. operator with a right-hand-side, scalar-field operand. pure module function laplacian(self) result(laplacian_1D) !! Result is mimetic Laplacian of the scalar_1D_t "self" @@ -272,6 +414,11 @@ pure module function laplacian(self) result(laplacian_1D) class(scalar_1D_t), intent(in) :: self type(laplacian_1D_t) laplacian_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to report the number of boundary-adjacent locations at which the Laplacian has reduced-order accuracy. + ! KEYWORDS: Laplacian, boundary, order of accuracy + ! CONTEXT: Use this function to determine the region of slightly slower convergence for mimetic Laplacian approximations. pure module function reduced_order_boundary_depth(self) result(num_nodes) !! Result is number of nodes away from the boundary for which convergence rate is one degree lower @@ -279,6 +426,11 @@ pure module function reduced_order_boundary_depth(self) result(num_nodes) class(laplacian_1D_t), intent(in) :: self integer num_nodes end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute mimetic approximations to the divergence of a vector field. + ! KEYWORDS: divergence, vector field + ! CONTEXT: Invoke this function via the unary .div. operator with a right-hand-side vector-field operand. pure module function div(self) result(divergence_1D) !! Result is mimetic divergence of the vector_1D_t "self" @@ -286,6 +438,12 @@ pure module function div(self) result(divergence_1D) class(vector_1D_t), intent(in) :: self type(divergence_1D_t) divergence_1D !! discrete divergence end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to perform mimetic volume integration of a vector/scalar-gradient dot product. + ! KEYWORDS: triple integral, volume integral + ! CONTEXT: Invoke this function in expressions of the form .SSS. (v .dot. .grad. f) * dV + ! with a vector_1D_t v, a scalar f, and a differential volume dV. pure module function volume_integrate_vector_dot_grad_scalar_1D(integrand) result(integral) !! Result is the mimetic quadrature corresponding to a volume integral of a vector-gradient dot product @@ -293,6 +451,12 @@ pure module function volume_integrate_vector_dot_grad_scalar_1D(integrand) resul class(vector_dot_gradient_1D_t), intent(in) :: integrand double precision integral end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to perform mimetic volume integration of a scalar/divergence dot product. + ! KEYWORDS: triple integral, volume integral + ! CONTEXT: Invoke this function in expressions of the form .SSS. (f * .div. v) * dV + ! with a vector_1D_t v, a scalar f, and a differential volume dV. pure module function volume_integrate_scalar_x_divergence_1D(integrand) result(integral) !! Result is the mimetic quadrature corresponding to a volume integral of a scalar-divergence product @@ -300,13 +464,25 @@ pure module function volume_integrate_scalar_x_divergence_1D(integrand) result(i class(scalar_x_divergence_1D_t), intent(in) :: integrand double precision integral end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to perform mimetic surface integration of a scalar/vector product. + ! KEYWORDS: double integral, surface integral, flux + ! CONTEXT: Invoke this function in expressions of the form -.SS. (f .x. (v .dot. dA)) + ! with a vector_1D_t v, a scalar_1D_t f, and a differential area dA. pure module function surface_integrate_vector_x_scalar_1D(integrand) result(integral) - !! Result is the mimetic quadrature correspondingto a surface integral of a scalar-vector product + !! Result is the mimetic quadrature corresponding to a surface integral of a scalar-vector product implicit none class(weighted_product_1D_t), intent(in) :: integrand double precision integral end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the scalar (dot) product of a vector and the gradient of a scalar. + ! KEYWORDS: scalar product, dot product, inner product + ! CONTEXT: Inovke this function via the .dot. binary infix operator in expressions of the form + ! g .dot. b with a gradient_1D_t g and a vector_1D_t b. pure module function dot(vector_1D, gradient_1D) result(vector_dot_gradient_1D) !! Result is the mimetic divergence of the vector_1D_t "self" @@ -315,6 +491,12 @@ pure module function dot(vector_1D, gradient_1D) result(vector_dot_gradient_1D) type(vector_1D_t), intent(in) :: vector_1D type(vector_dot_gradient_1D_t) vector_dot_gradient_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the scalar (not) product of a vector and a differential area. + ! KEYWORDS: dot product, flux, surface-normal + ! CONTEXT: Inovke this function via the .dot. binary infix operator in expressions of the form + ! .SS. (f .x. (v .dot. dA)) with a saclar_1D_t f, a vector_1D_t v, and a differential area A. pure module function dot_surface_normal(vector_1D, dS) result(v_dot_dS) !! Result is magnitude of a vector/surface-normal dot product for use in surface integrals of the form @@ -325,6 +507,12 @@ pure module function dot_surface_normal(vector_1D, dS) result(v_dot_dS) double precision, intent(in) :: dS type(vector_1D_t) v_dot_dS end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute a scalar/vector product weighted for subsequent surface integration. + ! KEYWORDS: integrand, surface integral, double integral + ! CONTEXT: Inovke this function .x. binary infix operator in expressions of the form + ! .SS. (f .x. (v .dot. dA)) with a saclar_1D_t f, a vector_1D_t v, and a differential area A. pure module function weighted_premultiply(scalar_1D, vector_1D) result(weighted_product_1D) !! Result is the product of a boundary-weighted vector_1D_t with a scalar_1D_t @@ -333,6 +521,13 @@ pure module function weighted_premultiply(scalar_1D, vector_1D) result(weighted_ class(vector_1D_t), intent(in) :: vector_1D type(weighted_product_1D_t) weighted_product_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the quadrature weights for use in the mimetic inner products of a vector + ! and the gradient of a scalar. + ! KEYWORDS: quadrature, numerical integration, coefficients, weights + ! CONTEXT: Inovke this function via the "weights" generic binding to produce the quadrature weights + ! associated with mimetic approximations to gradients. pure module function gradient_1D_weights(self) result(weights) !! Result is an array of quadrature coefficients that can be used to compute a weighted @@ -341,14 +536,27 @@ pure module function gradient_1D_weights(self) result(weights) class(tensor_1D_t), intent(in) :: self double precision, allocatable :: weights(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the quadrature weights for use in the mimetic inner products of a scalar + ! and the divergence of a vector. + ! KEYWORDS: quadrature, numerical integration, coefficients, weights + ! CONTEXT: Invoke this function via the "weights" generic binding to produce the quadrature weights + ! associated with mimetic approximations to divergences. pure module function divergence_1D_weights(self) result(weights) !! Result is an array of quadrature coefficients that can be used to compute a weighted - !! inner product of a vector_1D_t object and a gradient_1D_t object. + !! inner product of a scalar_1D_t object and a divergence_1D_t object. implicit none class(tensor_1D_t), intent(in) :: self double precision, allocatable :: weights(:) end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the product of a scalar and a divergence + ! KEYWORDS: scalar multiplication + ! CONTEXT: Invoke this function via the binary infix operator "*" with scalar and divergence left- and + ! right-hand operands, respectively pure module function premultiply_scalar_1D(scalar_1D, divergence_1D) result(scalar_x_divergence_1D) !! Result is the point-wise product of a 1D scalar field and the divergence of a 1D vector field @@ -357,6 +565,12 @@ pure module function premultiply_scalar_1D(scalar_1D, divergence_1D) result(scal class(divergence_1D_t), intent(in) :: divergence_1D type(scalar_x_divergence_1D_t) scalar_x_divergence_1D end function + ! END CODE CHUNK + + ! PURPOSE: Interface for procedure to compute the product of a divergence and a scalar + ! KEYWORDS: scalar multiplication + ! CONTEXT: Invoke this function via the binary infix operator "*" with divergence and scalar left- and + ! right-hand operands, respectively pure module function postmultiply_scalar_1D(divergence_1D, scalar_1D) result(scalar_x_divergence_1D) !! Result is the point-wise product of a 1D scalar field and the divergence of a 1D vector field @@ -365,6 +579,7 @@ pure module function postmultiply_scalar_1D(divergence_1D, scalar_1D) result(sca type(scalar_1D_t), intent(in) :: scalar_1D type(scalar_x_divergence_1D_t) scalar_x_divergence_1D end function + ! END CODE CHUNK end interface diff --git a/src/formal/vector_1D_s.F90 b/src/formal/vector_1D_s.F90 index 6410b31..65bbf25 100644 --- a/src/formal/vector_1D_s.F90 +++ b/src/formal/vector_1D_s.F90 @@ -22,13 +22,24 @@ contains + ! PURPOSE: Definition of procedure to compute the scalar (not) product of a vector and a differential area. + ! KEYWORDS: dot product, flux, surface-normal + ! CONTEXT: Inovke this function via the .dot. binary infix operator in expressions of the form + ! .SS. (f .x. (v .dot. dA)) with a saclar_1D_t f, a vector_1D_t v, and a differential area A. + module procedure dot_surface_normal v_dot_dS%tensor_1D_t = tensor_1D_t(vector_1D%values_*dS, vector_1D%x_min_, vector_1D%x_max_, vector_1D%cells_, vector_1D%order_) v_dot_dS%divergence_operator_1D_ = vector_1D%divergence_operator_1D_ end procedure + ! END CODE CHUNK #ifndef __GFORTRAN__ + ! PURPOSE: Definition of procedure to construct a new vector_1D_t object by sampling a function of one spatial dimension. + ! KEYWORDS: 1D vector field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell faces along one spatial dimension bounded by x_min and x_max. + module procedure construct_1D_vector_from_function call_julienne_assert(x_max .greaterThan. x_min) call_julienne_assert(cells .isAtLeast. 2*order+1) @@ -38,9 +49,15 @@ end associate vector_1D%divergence_operator_1D_ = divergence_operator_1D_t(k=order, dx=(x_max - x_min)/cells, cells=cells) end procedure + ! END CODE CHUNK #else + ! PURPOSE: Definition of procedure to construct a new vector_1D_t object by sampling a function of one spatial dimension. + ! KEYWORDS: 1D vector field constructor + ! CONTEXT: Invoke this constructor with a pointer associated with a function to be sampled at a set + ! of uniformly-spaced cell faces along one spatial dimension bounded by x_min and x_max. + pure module function construct_1D_vector_from_function(initializer, order, cells, x_min, x_max) result(vector_1D) procedure(vector_1D_initializer_i), pointer :: initializer integer, intent(in) :: order !! order of accuracy @@ -57,13 +74,24 @@ pure module function construct_1D_vector_from_function(initializer, order, cells end associate vector_1D%divergence_operator_1D_ = divergence_operator_1D_t(k=order, dx=(x_max - x_min)/cells, cells=cells) end function + ! END CODE CHUNK #endif + ! PURPOSE: Definition of procedure to construct a new vector_1D_t object from a parent tensor and a divergence operator object. + ! KEYWORDS: 1D vector field constructor + ! CONTEXT: Invoke this constructor with a an object to be used to define the constructed parent component + ! divergence-operator matrix component. + module procedure construct_from_components vector_1D%tensor_1D_t = tensor_1D vector_1D%divergence_operator_1D_ = divergence_operator_1D end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute mimetic approximations to the divergence of a vector field. + ! KEYWORDS: divergence, vector field + ! CONTEXT: Invoke this function via the unary .div. operator with a right-hand-side vector-field operand. module procedure div @@ -89,10 +117,16 @@ pure module function construct_1D_vector_from_function(initializer, order, cells end associate end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to provide the cell face-centered values of vector quantities. + ! KEYWORDS: staggered grid, vector field + ! CONTEXT: Invoke this function via the "values" generic binding to produce discrete vector values. module procedure vector_1D_values face_centered_values = self%values_ end procedure + ! END CODE CHUNK pure function faces(x_min, x_max, cells) result(x) double precision, intent(in) :: x_min, x_max @@ -105,9 +139,20 @@ pure function faces(x_min, x_max, cells) result(x) end associate end function + ! PURPOSE: Definition of procedure to provide staggered-grid locations at which vector values are stored: cell faces. + ! KEYWORDS: abcissa, cell faces + ! CONTEXT: Invoke this function via the "grid" generic binding to produce discrete vector locations for + ! initialization-function sampling, printing, or plotting. + module procedure vector_1D_grid cell_faces = faces(self%x_min_, self%x_max_, self%cells_) end procedure + ! END CODE CHUNK + + ! PURPOSE: Definition of procedure to compute a scalar/vector product weighted for subsequent surface integration. + ! KEYWORDS: integrand, surface integral, double integral + ! CONTEXT: Inovke this function .x. binary infix operator in expressions of the form + ! .SS. (f .x. (v .dot. dA)) with a saclar_1D_t f, a vector_1D_t v, and a differential area A. module procedure weighted_premultiply @@ -190,8 +235,12 @@ pure function postmultiply_diagonal(A,d) result(AD) end procedure + ! PURPOSE: Definition of procedure to provide the differential area for use in surface integrals. + ! KEYWORDS: surface integral, area integral, double integral, numerical quadrature, mimetic discretization + ! CONTEXT: Use this in expressions of the form .SS. (f .x. (v .dot. dA)) with a scalar_1D_t f and vector_1D_t v module procedure dA dA = 1D0 end procedure + ! END CODE CHUNK -end submodule vector_1D_s \ No newline at end of file +end submodule vector_1D_s diff --git a/src/formal/vector_dot_gradient_1D_s.F90 b/src/formal/vector_dot_gradient_1D_s.F90 index f91e460..93a4149 100644 --- a/src/formal/vector_dot_gradient_1D_s.F90 +++ b/src/formal/vector_dot_gradient_1D_s.F90 @@ -9,9 +9,15 @@ contains + ! PURPOSE: Definition of procedure to perform mimetic volume integration of a vector/scalar-gradient dot product. + ! KEYWORDS: triple integral, volume integral + ! CONTEXT: Invoke this function in expressions of the form .SSS. (v .dot. .grad. f) * dV + ! with a vector_1D_t v, a scalar f, and a differential volume dV. + module procedure volume_integrate_vector_dot_grad_scalar_1D call_julienne_assert(size(integrand%weights_ ) .equalsExpected. size(integrand%values_)) integral = sum(integrand%weights_ * integrand%values_) end procedure + ! END CODE CHUNK end submodule vector_dot_gradient_1D_s diff --git a/src/formal/weighted_product_1D_s.F90 b/src/formal/weighted_product_1D_s.F90 index a802b59..23fcd4c 100644 --- a/src/formal/weighted_product_1D_s.F90 +++ b/src/formal/weighted_product_1D_s.F90 @@ -6,8 +6,14 @@ contains + ! PURPOSE: Definition of procedure to perform mimetic surface integration of a scalar/vector product. + ! KEYWORDS: double integral, surface integral, flux + ! CONTEXT: Invoke this function in expressions of the form -.SS. (f .x. (v .dot. dA)) + ! with a vector_1D_t v, a scalar_1D_t f, and a differential area dA. + module procedure surface_integrate_vector_x_scalar_1D integral = sum(integrand%values_) end procedure + ! END CODE CHUNK end submodule weighted_product_s