This repository was archived by the owner on May 15, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathexplicitFunctions.f90
More file actions
101 lines (73 loc) · 3.22 KB
/
Copy pathexplicitFunctions.f90
File metadata and controls
101 lines (73 loc) · 3.22 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
!! SPDX-FileCopyrightText: 2023 SAP SE
!!
!! SPDX-License-Identifier: Apache-2.0
!!
!! This file is part of FEDEM - https://openfedem.org
!!==============================================================================
!> @file explicitFunctions.f90
!> @brief Global functions callable from C++ code.
!>
!> @details This file contains global function wrappers of subroutines from the
!> explicitfunctionsmodule, such that they can be invoked from C++ or python.
!!==============================================================================
!> @brief Evaluates an explicit function.
!> @param[in] baseID Base Id of the explicit function to evaluate
!> @param[in] intParams Integer function parameters (constant)
!> @param[in] realParams Double precision function parameters (constant)
!> @param[in] nip Number of integer parameters
!> @param[in] nrp Number of double precision parameters
!> @param[in] xArg Function argument value
!> @param[out] ierr Error flag
!> @return The function value
function getFunctionValue (baseID, intParams, realParams, nip, nrp, xArg, ierr)
use ExplicitFunctionsModule, only : funcValue
implicit none
integer , parameter :: dp = kind(1.0D0) ! 8-byte real (double)
integer , intent(in) :: nip, nrp, baseID, intParams(nip)
real(dp), intent(in) :: xArg, realParams(nrp)
integer , intent(out) :: ierr
real(dp) :: getFunctionValue
!! --- Logic section ---
ierr = 0
call funcValue (baseID,intParams,realParams,xArg,getFunctionValue,ierr)
end function getFunctionValue
!!==============================================================================
!> @brief Evaluates the derivative of an explicit function.
!> @param[in] baseID Base Id of the explicit function to evaluate
!> @param[in] intParams Integer function parameters (constant)
!> @param[in] realParams Double precision function parameters (constant)
!> @param[in] nip Number of integer parameters
!> @param[in] nrp Number of double precision parameters
!> @param[in] xArg Function argument value
!> @param[out] ierr Error flag
!> @return The function derivative
function getFunctionDeriv (baseID, intParams, realParams, nip, nrp, xArg, ierr)
use ExplicitFunctionsModule, only : funcDerivative
implicit none
integer , parameter :: dp = kind(1.0D0) ! 8-byte real (double)
integer , intent(in) :: nip, nrp, baseID, intParams(nip)
real(dp), intent(in) :: xArg, realParams(nrp)
integer , intent(out) :: ierr
real(dp) :: getFunctionDeriv
!! --- Logic section ---
ierr = 0
call funcDerivative (baseID,1,intParams,realParams,xArg,getFunctionDeriv,ierr)
end function getFunctionDeriv
!!==============================================================================
!> @brief Returns the function type Id (enum) of the specified @a functionName.
function getFunctionTypeID (functionName)
use ExplicitFunctionsModule, only : maxFunc_p, funcType_p
implicit none
character(len=*), intent(in) :: functionName
integer :: getFunctionTypeID
!! Local variables
integer :: i
!! --- Logic section ---
do i = 1, maxFunc_p
if (trim(funcType_p(i)) == functionName) then
getFunctionTypeID = i
return
end if
end do
getFunctionTypeID = -1
end function getFunctionTypeID