Skip to content

Commit 84e185b

Browse files
committed
Add DG discretizations for LRM, LRMP and GRM
1 parent 59806c0 commit 84e185b

36 files changed

+17507
-62
lines changed

.github/workflows/ci.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
path: |
3636
${{ github.workspace }}/hdf5
3737
${{ github.workspace }}/suitesparse/install
38-
key: ${{ runner.os }}-deps-${{ steps.get-msvc.outputs.version }}
38+
${{ github.workspace }}/eigen/install
39+
key: ${{ runner.os }}-deps-${{ steps.get-msvc.outputs.version }}-1
3940
- name: Download MKL and TBB
4041
run: |
4142
cd "${env:BASE_DIR}"
@@ -44,7 +45,7 @@ jobs:
4445
nuget install intelmkl.static.win-x64 -Version 2023.0.0.25930
4546
Invoke-WebRequest -Uri "https://gitlab.com/libeigen/eigen/-/archive/master/eigen-master.zip" -OutFile eigen.zip
4647
7z x eigen.zip
47-
- name: Build UMFPACK and HDF5
48+
- name: Build UMFPACK and HDF5 and Eigen3
4849
if: steps.cache.outputs.cache-hit != 'true'
4950
run: |
5051
$base_dir = $($env:BASE_DIR.Replace('\', '/'))
@@ -69,6 +70,14 @@ jobs:
6970
$ENV:MKLROOT="${env:BASE_DIR}/intelmkl.static.win-x64.2023.0.0.25930/lib/native/win-x64".Replace('\', '/')
7071
cmake -DCMAKE_INSTALL_PREFIX="${base_dir}\suitesparse\install" -DBLA_VENDOR=Intel10_64lp_seq -DBLA_STATIC=ON -G "Ninja" -DCMAKE_C_FLAGS="/GL" -DCMAKE_STATIC_LINKER_FLAGS="/LTCG" -DCMAKE_BUILD_TYPE=Release -DBUILD_METIS=OFF ..\suitesparse-metis-for-windows-e8d953dffb8a99aa8b65ff3ff03e12a3ed72f90c\
7172
ninja install
73+
cd "${env:BASE_DIR}"
74+
Invoke-WebRequest -Uri "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip" -OutFile eigen.zip
75+
7z x eigen.zip -oeigen\code -y
76+
cd eigen
77+
mkdir build
78+
cd build
79+
cmake ../code/eigen-3.4.0 -DCMAKE_INSTALL_PREFIX="../install"
80+
cmake --build . --target install
7281
- name: Build and Install
7382
run: |
7483
cd "${env:BASE_DIR}"
@@ -78,6 +87,7 @@ jobs:
7887
$ENV:MKLROOT="${env:BASE_DIR}/intelmkl.static.win-x64.2023.0.0.25930/lib/native/win-x64".Replace('\', '/')
7988
$ENV:TBB_ROOT="${env:BASE_DIR}/inteltbb.devel.win.2021.8.0.25874/lib/native".Replace('\', '/')
8089
$ENV:UMFPACK_ROOT="${env:BASE_DIR}/suitesparse/install".Replace('\', '/')
90+
$ENV:Eigen3_DIR="${env:BASE_DIR}/eigen/install".Replace('\', '/')
8191
$install_prefix = $($env:INSTALL_PREFIX.Replace('\', '/'))
8292
$src_dir = $($env:SRC_DIR.Replace('\', '/'))
8393
$base_dir = $($env:BASE_DIR.Replace('\', '/'))

CMakeLists.txt

+26
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ add_feature_info(ENABLE_DEBUG_THREADING ENABLE_DEBUG_THREADING "Use multi-thread
105105
option(ENABLE_GRM_2D "Build 2D general rate model" ON)
106106
add_feature_info(ENABLE_GRM_2D ENABLE_GRM_2D "Build 2D general rate model")
107107

108+
option(ENABLE_DG "Build DG variants of models" ON)
109+
add_feature_info(ENABLE_DG ENABLE_DG "Build DG variants of models")
110+
108111
option(ENABLE_SUNDIALS_OPENMP "Prefer OpenMP vector implementation of SUNDIALS if available (for large problems)" OFF)
109112
add_feature_info(ENABLE_SUNDIALS_OPENMP ENABLE_SUNDIALS_OPENMP "Prefer OpenMP vector implementation of SUNDIALS if available (for large problems)")
110113

@@ -394,6 +397,21 @@ if (ENABLE_GRM_2D)
394397
)
395398
endif()
396399

400+
set(EIGEN_TARGET "")
401+
if (ENABLE_DG)
402+
find_package(Eigen3 3.4 NO_MODULE)
403+
404+
# Disable DG if Eigen is not present
405+
if (NOT TARGET Eigen3::Eigen)
406+
message(STATUS "Disabling DG support because Eigen3 could not be found")
407+
set(ENABLE_DG OFF)
408+
else()
409+
set(EIGEN_TARGET "Eigen3::Eigen")
410+
get_target_property(Eigen3_INCLUDE_DIRS Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
411+
include_directories(${Eigen3_INCLUDE_DIRS} "${Eigen3_INCLUDE_DIRS}/..")
412+
endif()
413+
endif()
414+
397415
set(IPO_AVAILABLE OFF)
398416
if (ENABLE_IPO)
399417
include(CheckIPOSupported)
@@ -592,6 +610,14 @@ if (ENABLE_GRM_2D)
592610
endif()
593611
endif()
594612

613+
if (ENABLE_DG)
614+
message("Found Eigen3: ${Eigen3_FOUND}")
615+
if (TARGET Eigen3::Eigen)
616+
message(" Version ${Eigen3_VERSION}")
617+
message(" Includes ${Eigen3_INCLUDE_DIRS}")
618+
endif()
619+
endif()
620+
595621
message("Found HDF5: ${HDF5_FOUND}")
596622
if (HDF5_FOUND)
597623
message(" Version ${HDF5_VERSION}")

doc/interface/sensitivities.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Group /input/sensitivity/param_XXX
3939

4040
``SENS_NAME``
4141

42-
Name of the parameter
42+
Name of the parameter (Note that ``PAR_RADIUS`` and ``PAR_CORE_RADIUS`` sensitivities are only available for Finite Volume discretization)
4343

4444
================ ===========================
4545
**Type:** string **Length:** :math:`\geq 1`

doc/interface/unit_operations/general_rate_model.rst

+87-12
Original file line numberDiff line numberDiff line change
@@ -454,21 +454,36 @@ For information on model equations, refer to :ref:`general_rate_model_model`.
454454
================ ======================== =============================================================================
455455

456456

457+
Discretization Methods
458+
----------------------
459+
460+
CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.
461+
457462
Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
458-
---------------------------------------------------------------------------
463+
----------------------------------------------------------------------------------------
464+
465+
``USE_ANALYTIC_JACOBIAN``
466+
467+
Determines whether analytically computed Jacobian matrix (faster) is used (value is 1) instead of Jacobians generated by algorithmic differentiation (slower, value is 0)
468+
469+
============= =========================== =============
470+
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
471+
============= =========================== =============
459472

473+
Finite Volumes (Default)
474+
------------------------
460475

461476
``NCOL``
462477

463-
Number of axial column discretization cells
478+
Number of axial column discretization points
464479

465480
============= ========================= =============
466481
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
467482
============= ========================= =============
468483

469484
``NPAR``
470485

471-
Number of particle (radial) discretization cells for each particle type
486+
Number of particle (radial) discretization points for each particle type
472487

473488
============= ========================= =================================================
474489
**Type:** int **Range:** :math:`\geq 1` **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
@@ -498,14 +513,6 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
498513
**Type:** int **Range:** :math:`\{ 1,2 \}` **Length:** 1
499514
============= ============================ =============
500515

501-
``USE_ANALYTIC_JACOBIAN``
502-
503-
Determines whether analytically computed Jacobian matrix (faster) is used (value is :math:`1`) instead of Jacobians generated by algorithmic differentiation (slower, value is :math:`0`)
504-
505-
============= =========================== =============
506-
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
507-
============= =========================== =============
508-
509516
``RECONSTRUCTION``
510517

511518
Type of reconstruction method for fluxes
@@ -554,5 +561,73 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL
554561
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
555562
============= =========================== =============
556563

557-
For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
564+
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
565+
566+
Group /input/model/unit_XXX/discretization - UNIT_TYPE - GENERAL_RATE_MODEL_DG
567+
----------------------------------------------------------------------------------------
568+
Discontinuous Galerkin
569+
----------------------
570+
571+
``POLYDEG``
558572

573+
DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
574+
575+
============= ========================= =============
576+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
577+
============= ========================= =============
578+
579+
``NCOL``
580+
581+
Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
582+
583+
============= ========================= =============
584+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
585+
============= ========================= =============
586+
587+
``EXACT_INTEGRATION``
588+
589+
Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).
590+
591+
============= =========================== =============
592+
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
593+
============= =========================== =============
594+
595+
``NPARTYPE``
596+
597+
Number of particle types. Optional, inferred from the length of :math:`\texttt{NPAR}` or :math:`\texttt{NBOUND}` if left out.
598+
599+
============= ========================= =============
600+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
601+
============= ========================= =============
602+
603+
``PARPOLYDEG``
604+
605+
DG particle (radial) polynomial degree. Optional, defaults to 3. The total number of particle (radial) discrete points is given by (``PARPOLYDEG`` + 1 ) * ``NPARCELL``.
606+
607+
============= ========================= =============
608+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
609+
============= ========================= =============
610+
611+
``NPARCELL``
612+
613+
Number of particle (radial) discretization DG cells for each particle type. For the particle discretization, it is usually most performant to fix ``NPARCELL`` = 1 and to increase the polynomial degree for more accuracy.
614+
615+
============= ========================= =================================================
616+
**Type:** int **Range:** :math:`\geq 1` **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
617+
============= ========================= =================================================
618+
619+
``PAR_DISC_TYPE``
620+
621+
Specifies the DG element-spacing inside the particles for all or each particle type. Valid values are :math:`\texttt{EQUIDISTANT_PAR}`, :math:`\texttt{EQUIVOLUME_PAR}`, and :math:`\texttt{USER_DEFINED_PAR}`.
622+
623+
================ =================================================
624+
**Type:** string **Length:** :math:`1` / :math:`\texttt{NPARTYPE}`
625+
================ =================================================
626+
627+
``PAR_DISC_VECTOR``
628+
629+
Node coordinates for the element boundaries (ignored if :math:`\texttt{PAR_DISC_TYPE} \neq \texttt{USER_DEFINED_PAR}`). The coordinates are relative and have to include the endpoints :math:`0` and :math:`1`. They are later linearly mapped to the true radial range :math:`[r_{c,j}, r_{p,j}]`. The coordinates for each particle type are appended to one long vector in type-major ordering.
630+
631+
================ ======================== ================================================
632+
**Type:** double **Range:** :math:`[0,1]` **Length:** :math:`\sum_i (\texttt{NPAR}_i + 1)`
633+
================ ======================== ================================================

doc/interface/unit_operations/lumped_rate_model_with_pores.rst

+47-10
Original file line numberDiff line numberDiff line change
@@ -247,26 +247,33 @@ For information on model equations, refer to :ref:`lumped_rate_model_with_pores_
247247
================ ======================== =======================================================================
248248

249249

250+
Discretization Methods
251+
----------------------
252+
253+
CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.
254+
250255
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_PORES
251256
-------------------------------------------------------------------------------------
257+
258+
``USE_ANALYTIC_JACOBIAN``
252259

260+
Determines whether analytically computed Jacobian matrix (faster) is used (value is 1) instead of Jacobians generated by algorithmic differentiation (slower, value is 0)
253261

262+
============= =========================== =============
263+
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
264+
============= =========================== =============
265+
266+
Finite Volumes (Default)
267+
------------------------
268+
254269
``NCOL``
255270

256-
Number of axial column discretization cells
271+
Number of axial column discretization points
257272

258273
============= ========================= =============
259274
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
260275
============= ========================= =============
261276

262-
``USE_ANALYTIC_JACOBIAN``
263-
264-
Determines whether analytically computed Jacobian matrix (faster) is used (value is :math:`1`) instead of Jacobians generated by algorithmic differentiation (slower, value is :math:`0`)
265-
266-
============= =========================== =============
267-
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
268-
============= =========================== =============
269-
270277
``RECONSTRUCTION``
271278

272279
Type of reconstruction method for fluxes
@@ -307,4 +314,34 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_
307314
**Type:** double **Range:** :math:`\geq 0` **Length:** 1
308315
================ ========================= =============
309316

310-
For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
317+
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
318+
319+
320+
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITH_PORES_DG
321+
----------------------------------------------------------------------------------------
322+
Discontinuous Galerkin
323+
----------------------
324+
325+
``POLYDEG``
326+
327+
DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
328+
329+
============= ========================= =============
330+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
331+
============= ========================= =============
332+
333+
``NCOL``
334+
335+
Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
336+
337+
============= ========================= =============
338+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
339+
============= ========================= =============
340+
341+
``EXACT_INTEGRATION``
342+
343+
Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).
344+
345+
============= =========================== =============
346+
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
347+
============= =========================== =============

doc/interface/unit_operations/lumped_rate_model_without_pores.rst

+46-11
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,13 @@ For information on model equations, refer to :ref:`lumped_rate_model_without_por
141141
================ ===================== =============
142142

143143

144-
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES
145-
----------------------------------------------------------------------------------------
144+
Discretization Methods
145+
----------------------
146146

147+
CADET has two discretization frameworks available, Finite Volumes (FV) and Discontinuous Galerkin (DG), only one needs to be specified. Both methods approximate the same solution to the same underlying model but can differ regarding computational performance.
147148

148-
``NCOL``
149-
150-
Number of axial column discretization cells
151-
152-
============= ========================= =============
153-
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
154-
============= ========================= =============
149+
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES
150+
----------------------------------------------------------------------------------------
155151

156152
``USE_ANALYTIC_JACOBIAN``
157153

@@ -160,14 +156,53 @@ Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHO
160156
============= =========================== =============
161157
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
162158
============= =========================== =============
159+
160+
Finite Volumes (Default)
161+
------------------------
162+
163+
``NCOL``
164+
165+
Number of axial column discretization points
166+
167+
============= ========================= =============
168+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
169+
============= ========================= =============
163170

164171
``RECONSTRUCTION``
165172

166-
Type of reconstruction method for fluxes
173+
Type of reconstruction method for fluxes only (only needs to be specified for FV)
167174

168175
================ ================================ =============
169176
**Type:** string **Range:** :math:`\texttt{WENO}` **Length:** 1
170177
================ ================================ =============
171178

172-
For further discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
179+
For further Finite Volume discretization parameters, see also :ref:`flux_restruction_methods`, and :ref:`non_consistency_solver_parameters`.
180+
181+
Group /input/model/unit_XXX/discretization - UNIT_TYPE = LUMPED_RATE_MODEL_WITHOUT_PORES_DG
182+
-------------------------------------------------------------------------------------------
183+
Discontinuous Galerkin
184+
----------------------
173185

186+
``POLYDEG``
187+
188+
DG polynomial degree. Optional, defaults to 4. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
189+
190+
============= ========================= =============
191+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
192+
============= ========================= =============
193+
194+
``NCOL``
195+
196+
Number of axial column discretization DG cells\elements. The total number of axial discrete points is given by (``POLYDEG`` + 1 ) * ``NCOL``.
197+
198+
============= ========================= =============
199+
**Type:** int **Range:** :math:`\geq 1` **Length:** 1
200+
============= ========================= =============
201+
202+
``EXACT_INTEGRATION``
203+
204+
Specifies the DG integration method. Optional, defaults to 0: Choose 1 for exact integration (more accurate but slower), 0 for LGL quadrature (less accurate but faster, typically more performant).
205+
206+
============= =========================== =============
207+
**Type:** int **Range:** :math:`\{0, 1\}` **Length:** 1
208+
============= =========================== =============

0 commit comments

Comments
 (0)