Skip to content

Commit

Permalink
WIP documenting the structure
Browse files Browse the repository at this point in the history
  • Loading branch information
haykh committed Apr 12, 2024
1 parent d44d473 commit 982cf6c
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 9 deletions.
83 changes: 83 additions & 0 deletions docs/code/domains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
hide:
- footer
---

# Domains and meshes

The main object which contains the information on global geometry of the domain including domain decomposition, the discretization, and the physical mesh is the `Metadomain<Metric<D>>` class.

```mermaid
classDiagram
class Metadomain~Metric~{
+Dimension D$
-uint g_ndomains
-vector~int~ g_decomposition
-vector~uint~ g_ndomains_per_dim
-vector~vector~uint~~ g_domain_offsets
-map~vector|uint~ g_domain_offset2index
-vector~Domain~Metric~~ g_subdomains
-vector~size_t~ g_ncells
-vector~pair~real_t~~ g_extent
-vector~pair~FldsBC~~ g_flds_bc
-vector~pair~PrtlBC~~ g_prtl_bc
-Metric g_metric
-const map~str|real_t~ g_metric_params
+idx2subdomain(uint) &Domain
+createEmptyDomains()
+redefineNeighbors()
+redefineBoundaries()
+initialValidityCheck()
+finalValidityCheck()
+metricCompatibilityCheck()
}
class Domain~Metric~{
+Dimension D$
-int m_index
-vector~uint~ m_offset_ndomains
-vector~size_t~ m_offset_ncells
-map~dir_t|CommBC~ m_comm_bc
-map~dir_t|*Domain~ m_neighbors
+Mesh~Metric~ mesh
+index() int
+offset_ndomains() vector~uint~
+offset_ncells() vector~size_t~
+comm_bc_in(dir_t d) CommBC
+neighbor_in(dir_t d) *Domain
+setCommBc(dir_t d, CommBC bc)
+setNeighbor(dir_t d, *Domain neighbor)
}
class Grid~Dimension~{
#vector~size_t~ m_resolution
+i_min(ushort) size_t
+i_max(ushort) size_t
+n_active(ushort) size_t
+n_all(ushort) real_t
+rangeActiveCells[|OnHost]() range_t~D~
+rangeAllCells[|OnHost]() range_t~D~
+rangeCells[|OnHost](boxRegion_t~D~) range_t~D~
}
class Mesh~Metric~{
+Dimension D$
+bool is_mesh$
-vector~pair~real_t~~ m_extents
-map~dir_t|FldsBC~ m_flds_bc
-map~dir_t|PrtlBC~ m_prtl_bc
-const map~str|real_t~ m_metric_params
+Metric metric
+extent(ushort d) pair~real_t~
+flds_bc_in(dir_t d) FldsBC
+prtl_bc_in(dir_t d) PrtlBC
+setFldsBc(dir_t d, FldsBC bc)
+setPrtlBc(dir_t d, PrtlBC bc)
}
class Metric~Dimension~{
see metrics...*
}
Domain --* Mesh : contains
Grid <|-- Mesh : inherits
Mesh --* Metric : contains
Metadomain --* Domain : contains many
note "+: public\n-: private\n#: protected\nunderline: static constexpr\nitalic: virtual"
```
146 changes: 146 additions & 0 deletions docs/code/metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
hide:
- footer
---

# Metrics

Metrics are key objects of the Entity framework. Superimposed on the discretized mesh, they define the spacetime geometry of the simulation and provide necessary functions for converting coordinates and transforming vectors from one basis to another.

Each metric has a number of distinct attributes. These are:

- `D`: the dimensionality of the metric:
- `Dim::_1D`, `Dim::_2D`, `Dim::_3D`
- `Label`: a string that identifies the metric;
- `CoordType`: the type of coordinates used in the metric;
- `Coord::Cart`, `Coord::Sph`, `Coord::Qsph`
- `PrtlDim`: the dimensionality of the particle coordinates (1)
{ .annotate }

1. :man_raising_hand: In 2D axisymmetric SR simulations, particles carry all three coordinates to recover their full Cartesian position, and transform fields to/from the global Cartesian basis.



```mermaid
classDiagram
direction LR
class MetricBase~Dimension~{
+bool is_metric$
+Dimension Dim$
#const real_t nx1
#const real_t nx2
#const real_t nx3
#const real_t x1_min
#const real_t x1_max
#const real_t x2_min
#const real_t x2_max
#const real_t x3_min
#const real_t x3_max
#real_t dx_min
+find_dxMin() real_t*
+dxMin() real_t
+set_dxMin(real_t)
}
class Metric~Dimension~{
+string_view Label$
+Dimension PrtlDim$
+Coord CoordType$
+find_dxMin() real_t
+h_~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_det_h(coord_t~D~) real_t
+convert~idx_t|Crd|Crd~(real_t) real_t
+convert~Crd|Crd~(coord_t~D~, coord_t~D~)
+transform~idx_t|Idx|Idx~(coord_t~D~, real_t) real_t
+transform~Idx|Idx~(coord_t~D~, vec_t, vec_t)
}
class Minkowski~Dimension~ {
-const real_t dx, dx_inv
+sqrt_h_~idx_t|idx_t~(coord_t~D~) real_t
+convert_xyz~Crd|Crd~(coord_t~D~, coord_t~D~)
+transform_xyz~Idx|Idx~(coord_t~D~, vec_t, vec_t)
}
class Spherical~Dimension~ {
-const real_t dr, dtheta, dphi
-const real_t dr_inv, dtheta_inv, dphi_inv
+sqrt_h_~idx_t|idx_t~(coord_t~D~) real_t
+convert_xyz~Crd|Crd~(coord_t~D~, coord_t~D~)
+transform_xyz~Idx|Idx~(coord_t~D~, vec_t, vec_t)
+polar_area(real_t) real_t
}
class QSpherical~Dimension~ {
-const real_t r0, h, chi_min, eta_min, phi_min
-const real_t dchi, deta, dphi
-const real_t dchi_inv, deta_inv, dphi_inv
-const real_t dchi_sqr, deta_sqr, dphi_sqr
+sqrt_h_~idx_t|idx_t~(coord_t~D~) real_t
+convert_xyz~Crd|Crd~(coord_t~D~, coord_t~D~)
+transform_xyz~Idx|Idx~(coord_t~D~, vec_t, vec_t)
+polar_area(real_t) real_t
-dtheta_deta(real_t) real_t
-eta2theta(real_t) real_t
-theta2eta(real_t) real_t
}
class KerrSchild~Dimension~ {
-const real_t a, rg_, rh_
-const real_t dr, dtheta, dphi
-const real_t dr_inv, dtheta_inv, dphi_inv
+h~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_det_h_tilde(coord_t~D~) real_t
+alpha(coord_t~D~) real_t
+beta1(coord_t~D~) real_t
+polar_area(real_t) real_t
}
class KerrSchild0~Dimension~ {
-const real_t dr, dtheta, dphi
-const real_t dr_inv, dtheta_inv, dphi_inv
+h~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_det_h_tilde(coord_t~D~) real_t
+alpha(coord_t~D~) real_t
+beta1(coord_t~D~) real_t
+polar_area(real_t) real_t
}
class QKerrSchild~Dimension~ {
-const real_t a, rg_, rh_
-const real_t chi_min, eta_min, phi_min
-const real_t dchi, deta, dphi
-const real_t dchi_inv, deta_inv, dphi_inv
+h~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_det_h_tilde(coord_t~D~) real_t
+alpha(coord_t~D~) real_t
+beta1(coord_t~D~) real_t
+polar_area(real_t) real_t
-dtheta_deta(real_t) real_t
-eta2theta(real_t) real_t
-theta2eta(real_t) real_t
}
MetricBase <|-- Metric : inherits
Metric <|-- Minkowski : implements
Metric <|-- Spherical : implements
Metric <|-- QSpherical : implements
Metric <|-- KerrSchild : implements
Metric <|-- QKerrSchild : implements
Metric <|-- KerrSchild0 : implements
note "+: public\n-: private\n#: protected\nunderline: static constexpr\nitalic: virtual"
```

<!-- namespace SRMetrics {
class Minkowski~Dimension~ {
-const real_t dx, dx_sqr, dx_inv
}
class Spherical~Dimension~ {
+h_~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_h_~idx_t|idx_t~(coord_t~D~) real_t
+sqrt_det_h(coord_t~D~) real_t
+convert~idx_t|Crd|Crd~(real_t) real_t
+convert~Crd|Crd~(coord_t~D~, coord_t~D~)
+transform~idx_t|Idx|Idx~(coord_t~D~, real_t) real_t
+transform~Idx|Idx~(coord_t~D~, vec_t, vec_t)
}
} -->

[^1]: Some say yes
8 changes: 5 additions & 3 deletions docs/code/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ hide:
- footer
---

### Current code structure in the `dev/bcs` branch
# Code structure

<div id="code-structure"></div>
Current code structure in the `dev/bcs` branch.

!!! hint "The diagram is interactive!"

The code structure diagram is clickable and hoverable.
The code structure diagram is clickable and hoverable.

<div id="d3-code-structure"></div>
10 changes: 7 additions & 3 deletions docs/css/extra.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
:root>* {
--md-mermaid-font-family: 'JetBrains Mono', monospace;
}

:root {
font-variant-ligatures: normal;
font-size: 1.25em;
Expand Down Expand Up @@ -355,15 +359,15 @@ figure.under-construction:before {
-ms-text-shadow: 0 0 0.5rem #000000;
}

#code-structure text {
#d3-code-structure text {
font-family: 'JetBrains Mono', monospace;
font-size: 1.0em;
}

[data-md-color-scheme="slate"] #code-structure text tspan {
[data-md-color-scheme="slate"] #d3-code-structure text tspan {
fill: white;
}

[data-md-color-scheme="default"] #code-structure text tspan {
[data-md-color-scheme="default"] #d3-code-structure text tspan {
fill: black;
}
2 changes: 1 addition & 1 deletion docs/js/code/structure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const parentID = "code-structure";
const parentID = "d3-code-structure";

if (document.getElementById(parentID)) {
document.addEventListener("DOMContentLoaded", () => {
Expand Down
9 changes: 7 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
site_name: "Entity: wiki"
repo_url: https://github.com/entity-toolkit/entity
repo_name: entity
site_url: https://entity-toolkit.github.io/entity
site_url: https://entity-toolkit.github.io/wiki

nav:
- Home: index.md
Expand All @@ -20,6 +20,8 @@ nav:
- Floating point comparison: "tech-details/ulps.md"
- Code API:
- "code/structure.md"
- "code/metrics.md"
- "code/domains.md"
- Fun:
- Cubed sphere: "fun/cubed_sphere.md"
- '"Reconnection"': "fun/reconnection.md"
Expand Down Expand Up @@ -69,6 +71,8 @@ theme:
repo: simple/git
admonition:
abstract: material/code-json
annotation: material/plus-circle-outline

palette:
- media: "(prefers-color-scheme: light)"
scheme: default
Expand All @@ -91,6 +95,7 @@ theme:
- content.code.annotate
- content.code.copy
- navigation.indexes
- content.tooltips

extra_javascript:
- js/init.js
Expand Down Expand Up @@ -120,6 +125,6 @@ extra_css:
extra:
social:
- icon: fontawesome/brands/github
link: https://github.com/haykh/entity/
link: https://github.com/entity-toolkit/entity/

copyright: Copyright &copy; 2021++, Entity dev team

0 comments on commit 982cf6c

Please sign in to comment.