Choral
choral.F90
Go to the documentation of this file.
1 
26 
27 module choral
28 
29  use basic_tools
30  use choral_env
31  use real_type
32 
33  use io
34  use funclib
36  use csr_mod
37  use graph_mod
38  use algebra_lin
39 
40  use mumps_mod
41  use fe_mod
42  use quad_mod
43  use mesh_mod
44  use eigen_mod
45  use precond_mod
46  use ionicmodel_mod
47  use stimulation_mod
48 
49  use fespace_mod
50  use mesh_interfaces
51  use quadmesh_mod
52  use mesh_tools
53  use mesh_mmg
54 
55  use ode_def
56  use ode_problem_mod
58  use ode_output_mod
59  use krylov_mod
60  use integral
61  use diffusion
62  use fespacexk_mod
63 
64  use ode_opsplt_mod
65  use newton_mod
66  use cardiomodel_mod
67  use elasticity
68 
69  use ode_solver_mod
70 
71  implicit none
72  private
73 
74 
75  !! !!!!!!!!!!!!!!!!!!!!!!
76  !!
77  !! DERIVED TYPES
78  !!
80  public :: quadmesh, precond, graph, newton, fespacexk
82  public :: mumps, eigen, stimulation
83 
84  !! !!!!!!!!!!!!!!!!!!!!!!
85  !!
86  !! GENERIC ROUTINES
87  !!
88  public :: re, equal
89  public :: clear, set, assemble, valid
90  public :: print, write, read, solve
91  public :: allocmem, freemem
92  public :: matvecprod, add, transpose
93  public :: l2_product, l2_dist, l2_dist_grad
94 
95 
96  !! !!!!!!!!!!!!!!!!!!!!!!
97  !!
98  !! ROUTINES
99  !!
100  public :: crossprod_3d
101  public :: choral_init
102  public :: clock, quit, warning, inttostring
103  public :: one_r3, emetric, vector_field_e_x
104  public :: f_c0, f_c1, f_c2, f_c3, f_c4, f_c5
105  public :: graph_prod
106  public :: scale, copy
107  public :: add_submatrix, gmsh_addview
108  public :: eval_scal_fe_at_points
112  public :: diffusion_matrix_pattern
116  public :: maxedgelength, minedgelength
117  public :: elasticity_matrix_pattern
121  public :: initialcond
124  public :: name_ode_method_opsplt
127  public :: mesh_analyse
128  public :: remesh_levelset
130 
131 
132 
133  !! !!!!!!!!!!!!!!!!!!!!!!
134  !!
135  !! GLOBAL VARIABLES
136  !!
137  public :: choral_dir, home_dir, gmsh_dir, app_dir
138  public :: sp, dp, rp, real_tol, pi
139  public :: fe_name, quad_name
140 
141  !! !!!!!!!!!!!!!!!!!!!!!!
142  !!
143  !! ABSTRACT INTERFACES
144  !!
145  public :: r3tor3, r3tor, rtor, rntornxl
146 
147 
148 contains
149 
165  subroutine choral_init(verb)
167  use choral_variables
168  use fe_mod
169  use cell_mod
170  use quad_mod
171  use mumps_mod
172  !$ use OMP_LIB
173 
174  integer, intent(in), optional :: verb
175 
176  integer :: rang
177  logical :: b
178 
179  if (present(verb)) then
180  choral_verb = verb
181  end if
182 
183  if (choral_verb>0) then
184  write(*,*)"choral : choral_init = &
185  &INITIALISATION "
186 
187  write(*,*)" PREPROCESSOR OPTIONS"
188 
189 #if RPC==4
190  write(*,*)" REAL NUMBER PRECISION = SIMPLE"
191 
192 #elif RPC==8
193  write(*,*)" REAL NUMBER PRECISION = DOUBLE"
194 
195 #elif RPC==12
196  write(*,*)" REAL NUMBER PRECISION = TRIPLE"
197 
198 #elif RPC==16
199  write(*,*)" REAL NUMBER PRECISION = QUADRUPLE"
200 
201 #else
202  write(*,*)" REAL NUMBER PRECISION = DOUBLE"
203  call warning("VARIABLE 'RPC' reset", 1)
204 #endif
205 
206 #if DBG>0
207  write(*,*)" DEBUG MODE = ON"
208 #else
209  write(*,*)" DEBUG MODE = OFF"
210 #endif
211 
212 #ifdef WOMP
213  write(*,*)" OPENMP = ON"
214  !$OMP PARALLEL
215  rang = omp_get_num_threads()
216  !$OMP END PARALLEL
217  write(*,*)" number of threads =", int(rang,1)
218  if (choral_verb>2) then
219  !$OMP PARALLEL PRIVATE(rang)
220  rang = omp_get_thread_num()
221  write(*,*)" Thread number ",&
222  & int(rang,1), " = acitve"
223  !$OMP END PARALLEL
224  end if
225 #else
226  write(*,*)" OPENMP = OFF"
227 #endif
228 
229 #ifdef WMMG
230  write(*,*)" MMG = ON"
231 #endif
232 
233 #ifdef WARPACK
234  write(*,*)" ARPACK = ON"
235 #endif
236 
237 #ifdef WMUMPS
238  write(*,*)" MUMPS = ON"
239 #endif
240 
241 #ifdef NOWARN
242  write(*,*)" NO WARNING ALLOWED = ON"
243 #else
244  write(*,*)" NO WARNING ALLOWED = OFF"
245 #endif
246 
247  end if
248 
249 
250  if (choral_verb>1) then
251  write(*,*)" GLOBAL VARIABLES"
252  write(*,*)" REAL PRECISION (RP), KIND RP =", int(rp,1)
253  write(*,*)" VERBOSITY, CHORAL_VERB =", int(choral_verb,1)
254  end if
255 
256  b = ( choral_verb > 1 )
257 
258  call cell_init(b)
259  call fe_init(b)
260  call quad_init(b)
261  call mumps_init()
262 
263  if (choral_verb>0) write(*,*)
264 
265  end subroutine choral_init
266 
267 
268 
269 end module choral
270 
271 
allocate memory for allocatable arrays
Definition: basic_tools.F90:24
subroutine, public fe_init(b)
initialise FE_XXX arrays
Definition: fe_mod.F90:252
Derived type mesh.
Definition: mesh_mod.F90:92
subroutine, public diffusion_matrix_pattern(g, X_h, qdm)
Define the sparsity pattern for diffusion matrices
Definition: diffusion.F90:96
subroutine, public elasticity_massmat(mass, a, Y, qdm, dofToDof)
Assemble the mass matrix of the bilinear product:
Definition: elasticity.F90:175
is the csr matrix well defined ?
Definition: csr_mod.F90:101
DEFINITION OF ABSTRACT_INTERFACES FOR THE LIBRARY CHORAL
Type ode_solution: data structure to solve ODE/PDE problems.
scale the matrix entries
Definition: csr_mod.F90:150
DERIVED TYPE graph: sparse matrices of boolean in CSR format
Definition: graph_mod.F90:33
HANDLE THE COMMUNICATION WITH THE LIBRARY MMG
Definition: mesh_mmg.F90:17
LINEAR ALGEBRA TOOLS
Definition: algebra_lin.F90:9
M2 = M1.
Definition: csr_mod.F90:161
BASIC TOOLS
Definition: basic_tools.F90:8
DERIVED TYPE eigen for eigenvalue / eigenvector problems
Definition: eigen_mod.F90:73
subroutine, public eval_scal_fe_at_points(val, P, u, X_h)
u is a finite element function on the finite element space X_h
real(rp) function, public f_c3(t)
C3 function with support [-1,1].
Definition: funcLib.f90:164
real(rp) function, public maxedgelength(m)
Returns the mesh size.
Definition: mesh_tools.f90:34
double precision function, public clock()
Returns the internal clock time
Definition: basic_tools.F90:94
real(rp) function, public minedgelength(m)
Returns the minimal edge length of the mesh.
Definition: mesh_tools.f90:110
character(len=15) function, public name_ode_method_opsplt(method)
Get operator splitting method name.
subroutine, public choral_init(verb)
Initialisation for the CHORAL library
Definition: choral.F90:166
DERIVED TYPE ode_problem: definition of ODE/PDE problems
L2 product of a function with the basis functions.
Definition: diffusion.F90:64
TOP-LEVEL MODULE FOR THE LIBRARY CHORAL
Definition: choral.F90:27
The type precond defines preconditioning for linear systems.
Definition: precond_mod.F90:56
real(rp) function, public s_prefactor(method, dt)
When discretising with two matrices, this function returns the prefactor Cs for the matrix S...
Definition: ode_def.f90:205
subroutine, public interp_scal_fe(u2, X_h2, u1, X_h1)
Interpolate a scalar finite element function u1 on a second finite element space X_h2.
QUADRATURE RULES ON REFERENCE CELLS
Definition: quad_mod.f90:31
DERIVED TYPE ionicModel: cellular ionic models in electrophysiology
DEFINITION OF FINITE ELEMENT METHODS
Definition: fe_mod.F90:19
subroutine, public diffusion_mixed_divmat(divMat, X_s, X_v, qdm)
Assemble the matrix of the bilinear product:
Definition: diffusion.F90:1164
The type krylov defines the settings of a linear solver.
Definition: krylov_mod.f90:63
integer, parameter, public rp
real(kind=RP) = real precision in the code REAL_TOL = epsilon to test real equality ...
Definition: real_type.F90:90
Derived type for tissue properties in cardiac electrophysiology.
subroutine, public cell_init(b)
Initialisation of all the arrays CELL_XXX.
Definition: cell_mod.f90:163
real(rp) function, public l2_dist_vect(phi, phi_h, X_h, qdm)
Returns .
Definition: integral.F90:986
subroutine, public graph_prod(g, A, B)
Matrix product g = A*B.
Definition: graph_mod.F90:679
subroutine, public quit(message)
Stop program execution, display an error messahe.
subroutine, public define_interfaces(m)
Defines the mesh interfaces.
real(rp) function, public one_r3(x)
The function .
Definition: funcLib.f90:67
integer, parameter, public sp
simple precision for real numbers
Definition: real_type.F90:60
solve LU x = b
Definition: mumps_mod.F90:88
Test real equality.
Definition: real_type.F90:146
The type feSpacexk defines for a finite element space.
real(rp) function, public f_c2(t)
C2 function with support [-1,1].
Definition: funcLib.f90:143
DERIVED TYPE cardioModel
PRE-DEFINED NUMERIC FUNCTIONS
Definition: funcLib.f90:25
subroutine, public diffusion_massmat(mass, a, X_h, qdm, dofToDof)
Assemble the mass matrix of the bilinear product:
Definition: diffusion.F90:168
subroutine, public quad_init(b)
initialise QUAD_XXX arrays:
Definition: quad_mod.f90:97
NEWTON NON LINEAR SOLVER.
Definition: newton_mod.f90:6
addition of csr matrices (with the same pattern)
Definition: csr_mod.F90:138
real(rp) function f_c1(t)
C1 function with support [-1,1].
Definition: funcLib.f90:123
real(rp) function, public celerity_l2_dist(u1, u2, X_h, qdm, weight)
returns || (c(u1) - c(u2)) * weight(x) ||_L2()
character(len=15) function, public name_ode_method(method)
Get ODE method name.
Definition: ode_def.f90:68
destructor
Definition: real_type.F90:127
character(len=150), parameter, public gmsh_dir
path to 'gmsh' directory = CHORAL_DIR/ress/gmsh
Definition: choral_env.f90:33
conversion integers or rational to real
Definition: real_type.F90:153
DERIVED TYPE feSpacexk: define for a finite element space.
real(rp) function, dimension(3), public vector_field_e_x(x)
constant vector field
Definition: funcLib.f90:56
character(len=100), parameter, public choral_dir
CHORAL_DIR = path to choral.
Definition: choral_env.f90:27
REAL NUMBERS PRECISION IN CHORAL: selects simple/double/quad
Definition: real_type.F90:33
transpose matrix of a sparse csr matrix
Definition: csr_mod.F90:166
integer function, dimension(4, 6), public mesh_analyse(m, verb)
Analyse the cells in the mesh for every dimension.
Definition: mesh_tools.f90:200
DERIVED TYPE quadMesh: integration methods on meshes
IO: module for input/output
Definition: io.f90:8
character(len=100), parameter, public home_dir
HOME_DIR = $HOME.
Definition: choral_env.f90:30
Derived type stimulation.
subroutine, public elasticity_dirichlet(K, rhs, Y, g1, g2, g3, f)
DIRICHLET BOUNDARY CONDITION FOR AN ELASTICITY PROBLEM
Definition: elasticity.F90:992
subroutine, public extract_component(u_c, u, Y, c)
Extract the component of a finite element function .
DERIVED TYPE feSpace: finite element spaces
Definition: feSpace_mod.F90:58
DERIVED TYPE ode_solution: data straucture to solve ODEs
subroutine, public elasticity_stiffmat(stiff, lambda, mu, Y, qdm, dofToDof)
Assemble the stiffness matrix of the bilinear product:
Definition: elasticity.F90:402
MODULE FOR DIFFUSION PROBLEMS
Definition: diffusion.F90:24
integral L2 distance
Definition: integral.F90:63
logical function, public check_ode_method(method, pb_type, slv_type)
check whether the ode method 'method' is available for the problem type 'pb_type' and for the solver ...
Derived type for sparse matrices in CSR format.
Definition: csr_mod.F90:62
real(rp) function, public celerity_l2_norm(u1, X_h, qdm, weight)
returns || c(u1) * weight(x) ||_L2
Integration of scalar functions.
Definition: integral.F90:54
real(rp) function, public l2_dist_grad_proj(phi, uh, X_h, qdm)
Returns .
Definition: integral.F90:956
subroutine, public diffusion_neumann_rhs(rhs, g, X_h, quad_type, f)
L2 scalar product of a scalar function with the basis functions fo the finite element space on a...
Definition: diffusion.F90:590
real(rp), parameter, public pi
REAL CONSTANT Pi.
Definition: real_type.F90:96
deallocate memory fo allocatable arrays
Definition: basic_tools.F90:30
MODULE FOR LINEAR ELASTICITY PROBLEMS
Definition: elasticity.F90:31
subroutine, public diffusion_dirichlet(K, rhs, g, X_h, rho, f)
DIRICHLET BOUNDARY CONDITION FOR A DIFFUSION PROBLEM
Definition: diffusion.F90:656
subroutine, public mumps_init()
Initialisation.
Definition: mumps_mod.F90:97
DERIVED TYPE ode_output: handles output for PDE/ODE simulations
DEFINE THE INTERFACES AND THE BOUNDARY CELLS OF A mesh
DERIVED TYPE mesh
Definition: mesh_mod.F90:57
Derived type for eigenvalue problem resolution.
Definition: eigen_mod.F90:106
set initial conditions
DERIVED TYPE stimulation
Derived type feSpace: finite element space on a mesh.
COMPUTATION OF INTEGRALS using a quadrature methods on a mesh.
Definition: integral.F90:21
real(rp) function, public f_c5(t)
C5 function with support [-1,1].
Definition: funcLib.f90:216
add a CSR matrix M1 with pattern P1 to a CSR matrix M with pattern P such that P1 is included in P ...
Definition: csr_mod.F90:145
BOTTOM LEVEL MODULE FOR ODEs
Definition: ode_def.f90:12
TOP LEVEL MODULE FOR ODEs, derived type ode_solver
integer choral_verb
Verbosity level.
subroutine, public elasticity_neumann_rhs(rhs, Y, quad_type, g_1, g_2, g_3, f)
L2 scalar product of a vector function with the basis functions fo the finite element space on a...
Definition: elasticity.F90:886
matrix vector product
Definition: csr_mod.F90:132
subroutine, public scale_conductivities(cm, sc)
rescale the conductivities
DEFINITION OF DIRECTORY PATHS
Definition: choral_env.f90:16
integer, parameter, public dp
double precision for real numbers
Definition: real_type.F90:63
character(len=20) function, public name_ode_solver_type(type)
name the type of ode_solver
subroutine, public diffusion_stiffmat(stiff, b, X_h, qdm, dofToDof)
Assemble the stiffness matrix of the bilinear product:
Definition: diffusion.F90:366
subroutine, public interp_scal_func(uh, u, X_h)
Interpolation of a scalar function to a scalar finite element function.
character(len=16), dimension(0:fe_tot_nb), public fe_name
Name for each fe method.
Definition: fe_mod.F90:65
The type ode_output handles output for ODE simulations.
set the solver
Definition: eigen_mod.F90:199
DERIVED TYPE mumps: to use the library MUMPS
Definition: mumps_mod.F90:31
real(rp) function, public f_c4(t)
C4 function with support [-1,1].
Definition: funcLib.f90:189
real(rp), parameter, public real_tol
Definition: real_type.F90:91
DERIVED TYPE ionicModel: cellular ionic models in electrophysiology
subroutine, public set_ode_solver_output(slv, output)
Load a user defined output for ODE resolution
subroutine, public closest_node(V, dist, pt, m, nDToNd, start)
For each point X=pt(:,ii), determines a node V in the mesh m that minimises |X-V|.
Definition: mesh_mod.F90:698
DEFINITION OF GLOBAL VARIABLES FOR THE LIBRARY CHORAL
Factorisation of csr matrices with MUMPS.
Definition: mumps_mod.F90:58
short description for real arrays
Definition: real_type.F90:141
The type quadMesh defines integration methods on meshes.
character(len=13), dimension(0:quad_tot_nb), public quad_name
QUAD_ARRAY.
Definition: quad_mod.f90:70
DERIVED TYPE precond: preconditioning for linear systems
Definition: precond_mod.F90:25
character(len=15) function, public name_ode_problem(type)
ode_problem name
subroutine, public diffusion_massmat_vect(mass, b, X_h, qdm, dofToDof)
Assemble the mass matrix of the bilinear product:
Definition: diffusion.F90:899
DERIVED TYPE ode_opSplt: operator splitting methods for ODEs.
real(rp) function, public f_c0(t)
Definition: funcLib.f90:105
real(rp) function, dimension(3), public crossprod_3d(u, v)
Cross product in R**3.
Type ode_problem: definition of ODE/PDE problems.
DERIVED TYPE csr for sparse matrices
Definition: csr_mod.F90:13
subroutine, public inttostring(str, ii)
convert an integer to a string
Definition: basic_tools.F90:42
subroutine, public elasticity_matrix_pattern(g, Y, qdm)
Define the sparsity pattern for elasticity matrices
Definition: elasticity.F90:103
character(len=150), parameter, public app_dir
path to 'applications' directory = CHORAL_DIR/applications
Definition: choral_env.f90:36
The type graph stores sparse matrices of boolean in CSR format.
Definition: graph_mod.F90:78
DERIVED TYPE krylov: for the resolution of linear systems
Definition: krylov_mod.f90:25
TOOLS TO GET mesh INFORMATIONS
Definition: mesh_tools.f90:10
DEFINITION OF GEOMETRICAL CELLS (for meshes)
Definition: cell_mod.f90:82
subroutine, public remesh_levelset(m, val, verb, hausd, hMax)
Definition: mesh_mmg.F90:54
subroutine, public warning(message, verb)
Warning message.
real(rp) function, public emetric(x, u, v)
Euclidian metric on : This is the isotropic homogeneous metric equal to the usual scalar product ...
Definition: funcLib.f90:80
subroutine, public monodomain_assemble(M, S, cm, X_h, qd_M, qd_S)
Assemble the monodomain diffusion matrices.
subroutine, public gmsh_addview(X_h, v, fileName, vname, time, idx)
add a view to X_h output file gmesh file format
integer function, public order_ode_method(method)
order associated with a method
Definition: ode_def.f90:159