From 1f604d24ce9bde0e47b1bfb096611555b9416322 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 10:40:31 -0500 Subject: [PATCH 1/8] Fix empty bibliography by installing texlive-binaries in CI Doxygen uses bib2xhtml.pl which shells out to bibtex to format the bibliography. Without bibtex installed, citelist.html is empty and all \cite references render as plain text. Also removes duplicate graphviz entry. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 91a44e0eaf..35da5ba3c5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,7 +21,7 @@ jobs: - name: Build Doxygen run: | sudo apt update -y - sudo apt install -y cmake ninja-build graphviz graphviz + sudo apt install -y cmake ninja-build graphviz texlive-binaries git clone https://github.com/doxygen/doxygen.git ../doxygen cd ../doxygen git checkout Release_1_16_1 From 5bec893f0f1a1e650ed5ac8c962a9607c9d27d66 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 11:44:15 -0500 Subject: [PATCH 2/8] Add math symbols to parameter registry, cross-ref validation, and doc fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add math_symbol field to ParamDef for LaTeX symbol mapping (e.g. gamma -> γ_k) - Define ~70 symbols inline on _r() calls in definitions.py (single source of truth) - Show Symbol column in auto-generated parameters.md for physics parameters - Extend lint_docs.py to validate param refs in case.md (518 refs, was unchecked) - Add @ref cross-link validation between doc pages - Fix doc bugs: radiue->radius, t_step_end->t_step_stop, remove stale tau_wrt row - Add cross-page @ref links between equations.md, case.md, and parameters.md - Update contributing guide Step 1 to document math= and desc= kwargs Co-Authored-By: Claude Opus 4.6 --- docs/documentation/case.md | 11 +- docs/documentation/contributing.md | 21 ++- docs/documentation/equations.md | 2 + toolchain/mfc/lint_docs.py | 155 ++++++++++++++++---- toolchain/mfc/params/definitions.py | 100 ++++++++----- toolchain/mfc/params/descriptions.py | 11 ++ toolchain/mfc/params/generators/docs_gen.py | 55 +++++-- toolchain/mfc/params/schema.py | 1 + 8 files changed, 267 insertions(+), 89 deletions(-) diff --git a/docs/documentation/case.md b/docs/documentation/case.md index d0c6431839..50ed396d7c 100644 --- a/docs/documentation/case.md +++ b/docs/documentation/case.md @@ -388,7 +388,9 @@ Details of implementation of viscosity in MFC can be found in \cite Coralic15. - `fluid_pp(i)%%G` is required for `hypoelasticity`. ### 6. Simulation Algorithm - + +See @ref equations "Equations" for the mathematical models these parameters control. + | Parameter | Type | Description | | ---: | :----: | :--- | | `bc_[x,y,z]%%beg[end]` | Integer | Beginning [ending] boundary condition in the $[x,y,z]$-direction (negative integer, see table [Boundary Conditions](#boundary-conditions)) | @@ -545,7 +547,7 @@ This option requires `weno_Re_flux` to be true because cell boundary values are | `type`* | Integer | The geometry of the patch. [1]: Line [2]: Circle [3]: Rectangle | | `x[y,z]_centroid`* | Real | Centroid of the boundary patch in the x[y,z]-direction | | `length_x[y,z]`* | Real | Length of the boundary patch in the x[y,z]-direction | -| `radiue`* | Real | Radius of the boundary patch | +| `radius`* | Real | Radius of the boundary patch | *: These parameters should be prepended with `patch_bc(j)%` where $j$ is the patch index. Boundary condition patches can be used with the following boundary condition types: @@ -563,7 +565,7 @@ Squares and circles on each face are supported for 3D simulations. - `dt` specifies the constant time step size used in the simulation. The value of `dt` needs to be sufficiently small to satisfy the Courant-Friedrichs-Lewy (CFL) condition. -- `t_step_start` and `t_step_end` define the time steps at which the simulation starts and ends. +- `t_step_start` and `t_step_stop` define the time steps at which the simulation starts and ends. `t_step_save` is the time step interval for data output during simulation. To newly start the simulation, set `t_step_start = 0`. @@ -612,7 +614,6 @@ To restart the simulation from $k$-th time step, see @ref running "Restarting Ca | `schlieren_wrt` | Logical | Add the numerical schlieren to the database| | `qm_wrt` | Logical | Add the Q-criterion to the database| | `liutex_wrt` | Logical | Add the Liutex to the database| -| `tau_wrt` | Logical | Add the elastic stress components to the database| | `fd_order` | Integer | Order of finite differences for computing the vorticity and the numerical Schlieren function [1,2,4] | | `schlieren_alpha(i)` | Real | Intensity of the numerical Schlieren computed via `alpha(i)` | | `probe_wrt` | Logical | Write the flow chosen probes data files for each time step | @@ -797,6 +798,8 @@ This table lists the sub-grid bubble model parameters, which can be utilized in Implementation of the parameters into the model follows \cite Ando10. +See @ref equations "Equations" Section 9 for the bubble dynamics equations. + #### 9.1 Ensemble-Averaged Bubble Model | Parameter | Type | Description | diff --git a/docs/documentation/contributing.md b/docs/documentation/contributing.md index 0f2cbf9db7..705815b2d3 100644 --- a/docs/documentation/contributing.md +++ b/docs/documentation/contributing.md @@ -212,10 +212,27 @@ Adding a parameter touches both the Python toolchain and Fortran source. Follow Add a call to `_r()` inside the `_load()` function: ```python -_r("my_param", REAL, {"my_feature_tag"}) +_r("my_param", REAL, {"my_feature_tag"}, + desc="Description of the parameter", + math=r"\f$\xi\f$") ``` -The arguments are: name, type (`INT`, `REAL`, `LOG`, `STR`), and a set of feature tags. You can add an explicit description with `desc="..."`, otherwise one is auto-generated from `_SIMPLE_DESCS` or `_ATTR_DESCS`. +The arguments are: +- **name**: parameter name (must match the Fortran namelist variable) +- **type**: `INT`, `REAL`, `LOG`, `STR`, or `A_REAL` (analytic expression) +- **tags**: set of feature tags for grouping (e.g. `{"bubbles"}`, `{"mhd"}`) +- **desc**: human-readable description (optional; auto-generated from `_SIMPLE_DESCS` or `_ATTR_DESCS` if omitted) +- **math**: LaTeX math symbol in Doxygen format (optional; shown in the Symbol column of @ref parameters) + +For indexed families like `fluid_pp`, put the symbol next to its attribute name using tuples: + +```python +for f in range(1, NF + 1): + px = f"fluid_pp({f})%" + for a, sym in [("gamma", r"\f$\gamma_k\f$"), + ("my_attr", r"\f$\xi_k\f$")]: # <-- add here + _r(f"{px}{a}", REAL, math=sym) +``` **Step 2: Add constraints** (same file, `CONSTRAINTS` dict) diff --git a/docs/documentation/equations.md b/docs/documentation/equations.md index 59c6a5c776..efa881f570 100644 --- a/docs/documentation/equations.md +++ b/docs/documentation/equations.md @@ -7,6 +7,8 @@ Each section notes the input parameter(s) that activate the corresponding physic The models and algorithms described here are detailed in \cite Wilfong26 (MFC 5.0) and \cite Bryngelson21. Foundational references for each model are cited inline; see the \ref citelist "Bibliography" for full details. +For parameter details and allowed values, see @ref case "Case Files" and the @ref parameters "Case Parameters" reference. + --- ## 1. Overview diff --git a/toolchain/mfc/lint_docs.py b/toolchain/mfc/lint_docs.py index f6318b8f03..8a7d90a487 100644 --- a/toolchain/mfc/lint_docs.py +++ b/toolchain/mfc/lint_docs.py @@ -1,4 +1,4 @@ -"""Check that file paths, cite keys, and parameters in docs still exist.""" +"""Check that file paths, cite keys, parameters, and @ref targets in docs still exist.""" import re import sys @@ -34,6 +34,28 @@ r"|^[A-Z]" # constants/types (uppercase start) ) +# Backtick tokens in case.md that are not real parameters (analytical shorthands, +# stress tensor component names, prose identifiers, hardcoded constants) +CASE_MD_SKIP = { + # Analytical shorthand variables (stretching formulas, "Analytical Definition" table) + "eps", "lx", "ly", "lz", "xc", "yc", "zc", "x_cb", + # Stress tensor component names (descriptive, not params) + "tau_xx", "tau_xy", "tau_xz", "tau_yy", "tau_yz", "tau_zz", + # Prose identifiers (example names, math symbols) + "scaling", "c_h", "thickness", + # Hardcoded Fortran constants (not case-file params) + "init_dir", "zeros_default", +} + +# Docs to check for parameter references, with per-file skip sets +PARAM_DOCS = { + "docs/documentation/equations.md": set(), + "docs/documentation/case.md": CASE_MD_SKIP, +} + +# Match @ref page_id patterns +REF_RE = re.compile(r"@ref\s+(\w+)") + def check_docs(repo_root: Path) -> list[str]: """Check that file paths referenced in documentation still exist.""" @@ -84,12 +106,45 @@ def check_cite_keys(repo_root: Path) -> list[str]: return errors -def check_param_refs(repo_root: Path) -> list[str]: - """Check that parameter names in equations.md exist in the MFC registry.""" - eq_path = repo_root / "docs" / "documentation" / "equations.md" - if not eq_path.exists(): - return [] +def _strip_code_blocks(text: str) -> str: + """Remove fenced code blocks (``` ... ```) from markdown text.""" + lines = text.split("\n") + result = [] + in_block = False + for line in lines: + if line.strip().startswith("```"): + in_block = not in_block + continue + if not in_block: + result.append(line) + return "\n".join(result) + + +def _is_valid_param(param: str, valid_params: set, sub_params: set) -> bool: + """Check if a param name (possibly with %) is valid against REGISTRY.""" + if "(" in param or ")" in param: + return True # Skip indexed refs like patch_icpp(i)%vel(j) + + base = param.split("%")[0] if "%" in param else param + + if base in valid_params or base in sub_params: + return True + + # Check sub-param part after % + if "%" in param: + sub = param.split("%")[-1] + if sub in sub_params: + return True + + # Family prefix check + if any(p.startswith(base) for p in valid_params): + return True + + return False + +def check_param_refs(repo_root: Path) -> list[str]: # pylint: disable=too-many-locals + """Check that parameter names in documentation exist in the MFC registry.""" # Import REGISTRY from the toolchain toolchain_dir = str(repo_root / "toolchain") if toolchain_dir not in sys.path: @@ -101,36 +156,73 @@ def check_param_refs(repo_root: Path) -> list[str]: return [] valid_params = set(REGISTRY.all_params.keys()) - # Build set of sub-parameter suffixes (the part after %) - sub_params = {p.split("%")[-1] for p in valid_params if "%" in p} - text = eq_path.read_text(encoding="utf-8") + # Build set of sub-parameter base names (strip trailing (N) indexes) + _sub_raw = {p.split("%")[-1] for p in valid_params if "%" in p} + sub_params = set() + for s in _sub_raw: + sub_params.add(s) + base = re.sub(r"\(\d+(?:,\s*\d+)*\)$", "", s) + if base != s: + sub_params.add(base) + errors = [] - seen = set() - for match in PARAM_RE.finditer(text): - param = match.group(1) - if param in seen: + for doc_rel, extra_skip in PARAM_DOCS.items(): + doc_path = repo_root / doc_rel + if not doc_path.exists(): continue - seen.add(param) - # Skip non-parameter identifiers - if PARAM_SKIP.search(param): - continue - # Skip single-character names (too ambiguous: m, n, p are grid dims) - if len(param) <= 1: - continue - # Skip names containing % (struct members like x_domain%beg are valid - # but the base name before % is what matters) - base = param.split("%")[0] if "%" in param else param - # Check for indexed parameters: strip trailing _N (e.g., patch_icpp(1)%alpha(1)) - # In docs these appear as e.g. `patch_icpp(i)%vel(j)` — skip indexed refs - if "(" in param or ")" in param: - continue + text = _strip_code_blocks(doc_path.read_text(encoding="utf-8")) + seen = set() + + # Check plain params + for match in PARAM_RE.finditer(text): + param = match.group(1) + if param in seen: + continue + seen.add(param) - if base not in valid_params and base not in sub_params: - # Check if it's a known parameter family prefix - if not any(p.startswith(base) for p in valid_params): - errors.append(f" equations.md references parameter '{param}' not in REGISTRY") + if PARAM_SKIP.search(param): + continue + if len(param) <= 1: + continue + if param in extra_skip: + continue + if "(" in param or ")" in param: + continue + if "[" in param: + continue # Bracket shorthand (e.g., x[y,z]_domain%%beg[end]) + + # Normalize %% to % for lookup + normalized = param.replace("%%", "%") + if not _is_valid_param(normalized, valid_params, sub_params): + errors.append(f" {doc_rel} references parameter '{param}' not in REGISTRY") + + return errors + + +def check_page_refs(repo_root: Path) -> list[str]: + """Check that @ref targets in docs reference existing page identifiers.""" + doc_dir = repo_root / "docs" / "documentation" + if not doc_dir.exists(): + return [] + + # Collect all @page identifiers + page_ids = {"citelist"} # Doxygen built-in + for md_file in doc_dir.glob("*.md"): + text = md_file.read_text(encoding="utf-8") + m = re.match(r"@page\s+(\w+)", text) + if m: + page_ids.add(m.group(1)) + + errors = [] + for md_file in sorted(doc_dir.glob("*.md")): + text = md_file.read_text(encoding="utf-8") + rel = md_file.relative_to(repo_root) + for match in REF_RE.finditer(text): + ref_target = match.group(1) + if ref_target not in page_ids: + errors.append(f" {rel} uses @ref {ref_target} but no @page with that ID exists") return errors @@ -142,6 +234,7 @@ def main(): all_errors.extend(check_docs(repo_root)) all_errors.extend(check_cite_keys(repo_root)) all_errors.extend(check_param_refs(repo_root)) + all_errors.extend(check_page_refs(repo_root)) if all_errors: print("Doc reference check failed:") diff --git a/toolchain/mfc/params/definitions.py b/toolchain/mfc/params/definitions.py index c08249c3d8..104f3dcfc3 100644 --- a/toolchain/mfc/params/definitions.py +++ b/toolchain/mfc/params/definitions.py @@ -808,7 +808,7 @@ def get_value_label(param_name: str, value: int) -> str: }, } -def _r(name, ptype, tags=None, desc=None, hint=None): +def _r(name, ptype, tags=None, desc=None, hint=None, math=None): # pylint: disable=too-many-arguments,too-many-positional-arguments """Register a parameter with optional feature tags and description.""" if hint is None: hint = _lookup_hint(name) @@ -827,6 +827,7 @@ def _r(name, ptype, tags=None, desc=None, hint=None): dependencies=DEPENDENCIES.get(name), tags=tags if tags else set(), hint=hint, + math_symbol=math or "", )) @@ -857,7 +858,9 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements for n in ["time_stepper", "t_step_old", "t_step_start", "t_step_stop", "t_step_save", "t_step_print", "adap_dt_max_iters"]: _r(n, INT, {"time"}) - for n in ["dt", "cfl_target", "cfl_max", "t_tol", "adap_dt_tol", "t_stop", "t_save"]: + _r("dt", REAL, {"time"}, math=r"\f$\Delta t\f$") + _r("cfl_target", REAL, {"time"}, math=r"\f$\mathrm{CFL}\f$") + for n in ["cfl_max", "t_tol", "adap_dt_tol", "t_stop", "t_save"]: _r(n, REAL, {"time"}) for n in ["cfl_adap_dt", "cfl_const_dt", "cfl_dt", "adap_dt"]: _r(n, LOG, {"time"}) @@ -867,8 +870,9 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements _r("recon_type", INT) _r("muscl_order", INT) _r("muscl_lim", INT) - for n in ["weno_eps", "teno_CT", "wenoz_q"]: - _r(n, REAL, {"weno"}) + _r("weno_eps", REAL, {"weno"}, math=r"\f$\varepsilon\f$") + _r("teno_CT", REAL, {"weno"}, math=r"\f$C_T\f$") + _r("wenoz_q", REAL, {"weno"}) for n in ["mapped_weno", "wenoz", "teno", "weno_avg", "mp_weno", "null_weights"]: _r(n, LOG, {"weno"}) _r("weno_Re_flux", LOG, {"weno", "viscosity"}) @@ -878,16 +882,18 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements _r(n, INT, {"riemann"}) # --- MHD --- - _r("Bx0", REAL, {"mhd"}) - for n in ["hyper_cleaning_speed", "hyper_cleaning_tau"]: - _r(n, REAL, {"mhd"}) + _r("Bx0", REAL, {"mhd"}, math=r"\f$B_{x,0}\f$") + _r("hyper_cleaning_speed", REAL, {"mhd"}, math=r"\f$c_h\f$") + _r("hyper_cleaning_tau", REAL, {"mhd"}) for n in ["mhd", "hyper_cleaning", "powell"]: _r(n, LOG, {"mhd"}) # --- Bubbles --- - for n in ["R0ref", "nb", "Web", "Ca"]: - _r(n, REAL, {"bubbles"}) - _r("Re_inv", REAL, {"bubbles", "viscosity"}) + _r("R0ref", REAL, {"bubbles"}, math=r"\f$R_0\f$") + _r("nb", REAL, {"bubbles"}, math=r"\f$N_b\f$") + _r("Web", REAL, {"bubbles"}, math=r"\f$\mathrm{We}\f$") + _r("Ca", REAL, {"bubbles"}, math=r"\f$\mathrm{Ca}\f$") + _r("Re_inv", REAL, {"bubbles", "viscosity"}, math=r"\f$\mathrm{Re}^{-1}\f$") _r("bubble_model", INT, {"bubbles"}) for n in ["polytropic", "bubbles_euler", "polydisperse", "qbmm", "bubbles_lagrange"]: _r(n, LOG, {"bubbles"}) @@ -900,7 +906,7 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements _r(n, LOG, {"elasticity"}) # --- Surface tension --- - _r("sigma", REAL, {"surface_tension"}) + _r("sigma", REAL, {"surface_tension"}, math=r"\f$\sigma\f$") _r("surface_tension", LOG, {"surface_tension"}) # --- Chemistry --- @@ -959,10 +965,16 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements "num_igr_warm_start_iters", "igr_iter_solver", "nv_uvm_igr_temps_on_gpu", "flux_lim"]: _r(n, INT) - for n in ["pref", "poly_sigma", "rhoref", "mixlayer_vel_coef", "mixlayer_domain", - "mixlayer_perturb_k0", "perturb_flow_mag", "fluid_rho", "sigR", "sigV", - "rhoRV", "palpha_eps", "ptgalpha_eps", "pi_fac", "tau_star", - "cont_damage_s", "alpha_bar", "alf_factor", "ic_eps", "ic_beta"]: + _r("pref", REAL, math=r"\f$p_\text{ref}\f$") + _r("poly_sigma", REAL, math=r"\f$\sigma_\text{poly}\f$") + _r("rhoref", REAL, math=r"\f$\rho_\text{ref}\f$") + _r("palpha_eps", REAL, math=r"\f$\varepsilon_\alpha\f$") + _r("ptgalpha_eps", REAL, math=r"\f$\varepsilon_\alpha\f$") + _r("pi_fac", REAL, math=r"\f$\pi\text{-factor}\f$") + for n in ["mixlayer_vel_coef", "mixlayer_domain", "mixlayer_perturb_k0", + "perturb_flow_mag", "fluid_rho", "sigR", "sigV", "rhoRV", + "tau_star", "cont_damage_s", "alpha_bar", "alf_factor", + "ic_eps", "ic_beta"]: _r(n, REAL) for n in ["mpp_lim", "relax", "adv_n", "cont_damage", "igr", "down_sample", "old_grid", "old_ic", "mixlayer_vel_profile", "mixlayer_perturb", @@ -974,8 +986,10 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements # Body force for d in ["x", "y", "z"]: - for v in ["k", "w", "p", "g"]: - _r(f"{v}_{d}", REAL) + _r(f"g_{d}", REAL, math=r"\f$g_" + d + r"\f$") + _r(f"k_{d}", REAL, math=r"\f$k_" + d + r"\f$") + _r(f"w_{d}", REAL, math=r"\f$\omega_" + d + r"\f$") + _r(f"p_{d}", REAL, math=r"\f$\phi_" + d + r"\f$") _r(f"bf_{d}", LOG) # ========================================================================== @@ -989,20 +1003,23 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements _r(f"{px}{a}", INT) for a in ["smoothen", "alter_patch"] if i >= 2 else ["smoothen"]: _r(f"{px}{a}", LOG) + for a, sym in [("rho", r"\f$\rho\f$"), ("gamma", r"\f$\gamma\f$"), + ("pi_inf", r"\f$\pi_\infty\f$"), ("cv", r"\f$c_v\f$"), + ("qv", r"\f$q_v\f$"), ("qvp", r"\f$q'_v\f$")]: + _r(f"{px}{a}", REAL, math=sym) for a in ["radius", "radii", "epsilon", "beta", "normal", "alpha_rho", - "non_axis_sym", "smooth_coeff", "rho", "vel", "alpha", "gamma", - "pi_inf", "cv", "qv", "qvp", "model_threshold"]: + "non_axis_sym", "smooth_coeff", "vel", "alpha", "model_threshold"]: _r(f"{px}{a}", REAL) # Bubble fields for a in ["r0", "v0", "p0", "m0"]: _r(f"{px}{a}", REAL, {"bubbles"}) for j in range(2, 10): _r(f"{px}a({j})", REAL) - _r(f"{px}pres", A_REAL) + _r(f"{px}pres", A_REAL, math=r"\f$p\f$") _r(f"{px}cf_val", A_REAL) # MHD fields - for a in ["Bx", "By", "Bz"]: - _r(f"{px}{a}", A_REAL, {"mhd"}) + for a, sym in [("Bx", r"\f$B_x\f$"), ("By", r"\f$B_y\f$"), ("Bz", r"\f$B_z\f$")]: + _r(f"{px}{a}", A_REAL, {"mhd"}, math=sym) # Chemistry species for j in range(1, 101): _r(f"{px}Y({j})", A_REAL, {"chemistry"}) @@ -1016,13 +1033,13 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements for j in range(1, 4): _r(f"{px}radii({j})", REAL) _r(f"{px}normal({j})", REAL) - _r(f"{px}vel({j})", A_REAL) + _r(f"{px}vel({j})", A_REAL, math=r"\f$u_" + str(j) + r"\f$") for f in range(1, NF + 1): - _r(f"{px}alpha({f})", A_REAL) - _r(f"{px}alpha_rho({f})", A_REAL) + _r(f"{px}alpha({f})", A_REAL, math=r"\f$\alpha_" + str(f) + r"\f$") + _r(f"{px}alpha_rho({f})", A_REAL, math=r"\f$\alpha \rho\f$") # Elasticity stress tensor for j in range(1, 7): - _r(f"{px}tau_e({j})", A_REAL, {"elasticity"}) + _r(f"{px}tau_e({j})", A_REAL, {"elasticity"}, math=r"\f$\tau_e\f$") if i >= 2: for j in range(1, i): _r(f"{px}alter_patch({j})", LOG) @@ -1030,21 +1047,30 @@ def _load(): # pylint: disable=too-many-locals,too-many-statements # --- fluid_pp (10 fluids) --- for f in range(1, NF + 1): px = f"fluid_pp({f})%" - for a in ["gamma", "pi_inf", "cv", "qv", "qvp"]: - _r(f"{px}{a}", REAL) - _r(f"{px}mul0", REAL, {"viscosity"}) - _r(f"{px}ss", REAL, {"surface_tension"}) + for a, sym in [("gamma", r"\f$\gamma_k\f$"), ("pi_inf", r"\f$\pi_{\infty,k}\f$"), + ("cv", r"\f$c_{v,k}\f$"), ("qv", r"\f$q_{v,k}\f$"), + ("qvp", r"\f$q'_{v,k}\f$")]: + _r(f"{px}{a}", REAL, math=sym) + _r(f"{px}mul0", REAL, {"viscosity"}, math=r"\f$\mu_{l,k}\f$") + _r(f"{px}ss", REAL, {"surface_tension"}, math=r"\f$\sigma_k\f$") for a in ["pv", "gamma_v", "M_v", "mu_v", "k_v", "cp_v", "D_v"]: _r(f"{px}{a}", REAL, {"bubbles"}) - _r(f"{px}G", REAL, {"elasticity"}) - for j in [1, 2]: - _r(f"{px}Re({j})", REAL, {"viscosity"}) + _r(f"{px}G", REAL, {"elasticity"}, math=r"\f$G_k\f$") + _r(f"{px}Re(1)", REAL, {"viscosity"}, math=r"\f$\mathrm{Re}_k\f$ (shear)") + _r(f"{px}Re(2)", REAL, {"viscosity"}, math=r"\f$\mathrm{Re}_k\f$ (bulk)") # --- bub_pp (bubble properties) --- - for a in ["R0ref", "p0ref", "rho0ref", "T0ref", "ss", "pv", "vd", - "mu_l", "mu_v", "mu_g", "gam_v", "gam_g", - "M_v", "M_g", "k_v", "k_g", "cp_v", "cp_g", "R_v", "R_g"]: - _r(f"bub_pp%{a}", REAL, {"bubbles"}) + for a, sym in [("R0ref", r"\f$R_0\f$"), ("p0ref", r"\f$p_0\f$"), + ("rho0ref", r"\f$\rho_l\f$"), ("T0ref", r"\f$T_0\f$"), + ("ss", r"\f$\sigma\f$"), ("pv", r"\f$p_v\f$"), + ("vd", r"\f$D\f$"), ("mu_l", r"\f$\mu_l\f$"), + ("mu_v", r"\f$\mu_v\f$"), ("mu_g", r"\f$\mu_g\f$"), + ("gam_v", r"\f$\gamma_v\f$"), ("gam_g", r"\f$\gamma_g\f$"), + ("M_v", r"\f$M_v\f$"), ("M_g", r"\f$M_g\f$"), + ("k_v", r"\f$k_v\f$"), ("k_g", r"\f$k_g\f$"), + ("cp_v", r"\f$c_{p,v}\f$"), ("cp_g", r"\f$c_{p,g}\f$"), + ("R_v", r"\f$R_v\f$"), ("R_g", r"\f$R_g\f$")]: + _r(f"bub_pp%{a}", REAL, {"bubbles"}, math=sym) # --- patch_ib (10 immersed boundaries) --- for i in range(1, NI + 1): diff --git a/toolchain/mfc/params/descriptions.py b/toolchain/mfc/params/descriptions.py index b689e3a536..af437c28a2 100644 --- a/toolchain/mfc/params/descriptions.py +++ b/toolchain/mfc/params/descriptions.py @@ -638,6 +638,17 @@ def get_pattern_description(pattern_name: str) -> str: return desc +def get_math_symbol(param_name: str) -> str: + """Get the LaTeX math symbol for a parameter, if one is defined. + + Looks up the math_symbol field from the parameter registry (single source of truth). + Symbols are defined via math= in the _r() calls in definitions.py. + """ + from . import REGISTRY # pylint: disable=import-outside-toplevel + param = REGISTRY.all_params.get(param_name) + return param.math_symbol if param else "" + + # Feature group descriptions (for display purposes) # The actual parameter-to-tag mapping is in definitions.py (single source of truth) FEATURE_DESCRIPTIONS = { diff --git a/toolchain/mfc/params/generators/docs_gen.py b/toolchain/mfc/params/generators/docs_gen.py index 6849c8a01d..13295f3ed8 100644 --- a/toolchain/mfc/params/generators/docs_gen.py +++ b/toolchain/mfc/params/generators/docs_gen.py @@ -11,7 +11,7 @@ from ..schema import ParamType from ..registry import REGISTRY -from ..descriptions import get_description +from ..descriptions import get_description, get_math_symbol from ..ast_analyzer import analyze_case_validator, classify_message from .. import definitions # noqa: F401 pylint: disable=unused-import @@ -441,25 +441,32 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man # Use pattern view if it reduces rows, otherwise show full table if len(patterns) < len(params): # Pattern view - shows collapsed patterns - # Check if any member of a pattern has constraints + # Check if any member of a pattern has constraints or math symbols pattern_has_constraints = False + pattern_has_symbols = False for _pattern, examples in patterns.items(): for ex in examples: p = REGISTRY.all_params[ex] if p.constraints or ex in by_trigger or ex in by_param: pattern_has_constraints = True - break - if pattern_has_constraints: + if get_math_symbol(ex): + pattern_has_symbols = True + if pattern_has_constraints and pattern_has_symbols: break lines.append("### Patterns") lines.append("") + # Build header dynamically based on which optional columns are needed + hdr = "| Pattern | Example | Description" + sep = "|---------|---------|------------" + if pattern_has_symbols: + hdr += " | Symbol" + sep += "-|-------" if pattern_has_constraints: - lines.append("| Pattern | Example | Description | Constraints |") - lines.append("|---------|---------|-------------|-------------|") - else: - lines.append("| Pattern | Example | Description |") - lines.append("|---------|---------|-------------|") + hdr += " | Constraints" + sep += "-|------------" + lines.append(hdr + " |") + lines.append(sep + "-|") for pattern, examples in sorted(patterns.items()): example = examples[0] @@ -471,6 +478,10 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man pattern_escaped = _escape_percent(pattern) example_escaped = _escape_percent(example) desc = _escape_percent(desc) + row = f"| `{pattern_escaped}` | `{example_escaped}` | {desc}" + if pattern_has_symbols: + sym = get_math_symbol(example) + row += f" | {sym}" if pattern_has_constraints: p = REGISTRY.all_params[example] constraints = _format_constraints(p) @@ -479,15 +490,24 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man if not extra: extra = _format_tag_annotation(example, p) extra = _escape_pct_outside_backticks(extra) - lines.append(f"| `{pattern_escaped}` | `{example_escaped}` | {desc} | {extra} |") - else: - lines.append(f"| `{pattern_escaped}` | `{example_escaped}` | {desc} |") + row += f" | {extra}" + lines.append(row + " |") lines.append("") else: # Full table - no patterns to collapse - lines.append("| Parameter | Type | Description | Constraints |") - lines.append("|-----------|------|-------------|-------------|") + # Check if any param in this family has a math symbol + full_has_symbols = any(get_math_symbol(n) for n, _ in params) + + hdr = "| Parameter | Type | Description" + sep = "|-----------|------|------------" + if full_has_symbols: + hdr += " | Symbol" + sep += "-|-------" + hdr += " | Constraints" + sep += "-|------------" + lines.append(hdr + " |") + lines.append(sep + "-|") for name, param in params: type_str = _type_to_str(param.param_type) @@ -504,7 +524,12 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man # Escape % for Doxygen (even inside backtick code spans) name_escaped = _escape_percent(name) desc = _escape_percent(desc) - lines.append(f"| `{name_escaped}` | {type_str} | {desc} | {extra} |") + row = f"| `{name_escaped}` | {type_str} | {desc}" + if full_has_symbols: + sym = get_math_symbol(name) + row += f" | {sym}" + row += f" | {extra}" + lines.append(row + " |") lines.append("") diff --git a/toolchain/mfc/params/schema.py b/toolchain/mfc/params/schema.py index 8999dc903a..08ef309254 100644 --- a/toolchain/mfc/params/schema.py +++ b/toolchain/mfc/params/schema.py @@ -61,6 +61,7 @@ class ParamDef: # pylint: disable=too-many-instance-attributes dependencies: Optional[Dict[str, Any]] = None # {"requires": [...], "recommends": [...]} tags: Set[str] = field(default_factory=set) # Feature tags: "mhd", "bubbles", etc. hint: str = "" # Constraint/usage hint for docs (e.g. "Used with grcbc_in") + math_symbol: str = "" # LaTeX math symbol (Doxygen format, e.g. "\\f$\\gamma_k\\f$") def __post_init__(self): # Validate name From 298c7a8697256f74beea175629d763efeda20ef2 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 11:49:39 -0500 Subject: [PATCH 3/8] Address review: list-based table headers, robust @page/@ref checks - Build markdown table headers from column lists instead of string concat - Use re.search with MULTILINE for @page detection (handles leading whitespace) - Strip code blocks before scanning for @ref targets (avoids false positives) Co-Authored-By: Claude Opus 4.6 --- toolchain/mfc/lint_docs.py | 4 ++-- toolchain/mfc/params/generators/docs_gen.py | 26 ++++++++------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/toolchain/mfc/lint_docs.py b/toolchain/mfc/lint_docs.py index 8a7d90a487..02cf85b643 100644 --- a/toolchain/mfc/lint_docs.py +++ b/toolchain/mfc/lint_docs.py @@ -211,13 +211,13 @@ def check_page_refs(repo_root: Path) -> list[str]: page_ids = {"citelist"} # Doxygen built-in for md_file in doc_dir.glob("*.md"): text = md_file.read_text(encoding="utf-8") - m = re.match(r"@page\s+(\w+)", text) + m = re.search(r"^\s*@page\s+(\w+)", text, flags=re.MULTILINE) if m: page_ids.add(m.group(1)) errors = [] for md_file in sorted(doc_dir.glob("*.md")): - text = md_file.read_text(encoding="utf-8") + text = _strip_code_blocks(md_file.read_text(encoding="utf-8")) rel = md_file.relative_to(repo_root) for match in REF_RE.finditer(text): ref_target = match.group(1) diff --git a/toolchain/mfc/params/generators/docs_gen.py b/toolchain/mfc/params/generators/docs_gen.py index 13295f3ed8..e26c42a50c 100644 --- a/toolchain/mfc/params/generators/docs_gen.py +++ b/toolchain/mfc/params/generators/docs_gen.py @@ -457,16 +457,13 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man lines.append("### Patterns") lines.append("") # Build header dynamically based on which optional columns are needed - hdr = "| Pattern | Example | Description" - sep = "|---------|---------|------------" + cols = ["Pattern", "Example", "Description"] if pattern_has_symbols: - hdr += " | Symbol" - sep += "-|-------" + cols.append("Symbol") if pattern_has_constraints: - hdr += " | Constraints" - sep += "-|------------" - lines.append(hdr + " |") - lines.append(sep + "-|") + cols.append("Constraints") + lines.append("| " + " | ".join(cols) + " |") + lines.append("| " + " | ".join("-" * max(3, len(c)) for c in cols) + " |") for pattern, examples in sorted(patterns.items()): example = examples[0] @@ -499,15 +496,12 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man # Check if any param in this family has a math symbol full_has_symbols = any(get_math_symbol(n) for n, _ in params) - hdr = "| Parameter | Type | Description" - sep = "|-----------|------|------------" + cols = ["Parameter", "Type", "Description"] if full_has_symbols: - hdr += " | Symbol" - sep += "-|-------" - hdr += " | Constraints" - sep += "-|------------" - lines.append(hdr + " |") - lines.append(sep + "-|") + cols.append("Symbol") + cols.append("Constraints") + lines.append("| " + " | ".join(cols) + " |") + lines.append("| " + " | ".join("-" * max(3, len(c)) for c in cols) + " |") for name, param in params: type_str = _type_to_str(param.param_type) From 62a65837a258b091c2d41452e6a4d091099a0eb8 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 11:53:58 -0500 Subject: [PATCH 4/8] Tighten param prefix check to require structural boundary Match family prefixes only at structural boundaries to avoid silently accepting typos like patch_ic as valid. Co-Authored-By: Claude Opus 4.6 --- toolchain/mfc/lint_docs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/mfc/lint_docs.py b/toolchain/mfc/lint_docs.py index 02cf85b643..deca2c3efb 100644 --- a/toolchain/mfc/lint_docs.py +++ b/toolchain/mfc/lint_docs.py @@ -136,8 +136,8 @@ def _is_valid_param(param: str, valid_params: set, sub_params: set) -> bool: if sub in sub_params: return True - # Family prefix check - if any(p.startswith(base) for p in valid_params): + # Family prefix check (only accept at a boundary to avoid prefix-typo matches) + if any(p.startswith(base + b) for b in ("(", "%", "_") for p in valid_params): return True return False From 520e67988fcccbe37a620ee269c3b06c85be8749 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 12:03:33 -0500 Subject: [PATCH 5/8] Validate both family and attribute for compound params Tighten compound-param validation to require both a known family prefix and a known attribute. Immediately caught two doc bugs: z_comain -> z_domain typo, model%%filepath -> model_filepath. Co-Authored-By: Claude Opus 4.6 --- docs/documentation/case.md | 4 ++-- toolchain/mfc/lint_docs.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/documentation/case.md b/docs/documentation/case.md index 50ed396d7c..a753b2fa7c 100644 --- a/docs/documentation/case.md +++ b/docs/documentation/case.md @@ -997,7 +997,7 @@ When ``cyl_coord = 'T'`` is set in 3D the following constraints must be met: - `z_domain%beg = 0` sets the azimuthal starting point to 0 -- `z_comain%end = 2*math.pi` to set the azimuthal ending point to $2\pi$ (note, requires `import math` in the case file) +- `z_domain%end = 2*math.pi` to set the azimuthal ending point to $2\pi$ (note, requires `import math` in the case file) When ``cyl_coord = 'T'`` is set in 2D the following constraints must be met: @@ -1087,7 +1087,7 @@ This boundary condition can be used for subsonic inflow (`bc_[x,y,z]%[beg,end]` | 18 | 2D Varcircle | 2 | Y | Requires `[x,y]_centroid`, `radius`, and `thickness` | | 19 | 3D Varcircle | 3 | Y | Requires `[x,y,z]_centroid`, `length_z`, `radius`, and `thickness` | | 20 | 2D Taylor-Green Vortex | 2 | N | Requires `[x,y]_centroid`, `length_x`, `length_y`, `vel(1)`, and `vel(2)` | -| 21 | Model | 2 & 3 | Y | Imports a Model (STL/OBJ). Requires `model%%filepath`. | +| 21 | Model | 2 & 3 | Y | Imports a Model (STL/OBJ). Requires `model_filepath`. | The patch types supported by the MFC are listed in table [Patch Types](#patch-types). This includes types exclusive to one-, two-, and three-dimensional problems. diff --git a/toolchain/mfc/lint_docs.py b/toolchain/mfc/lint_docs.py index deca2c3efb..c5e49753e2 100644 --- a/toolchain/mfc/lint_docs.py +++ b/toolchain/mfc/lint_docs.py @@ -130,13 +130,13 @@ def _is_valid_param(param: str, valid_params: set, sub_params: set) -> bool: if base in valid_params or base in sub_params: return True - # Check sub-param part after % + # Compound params (with %): validate both family prefix and attribute if "%" in param: sub = param.split("%")[-1] - if sub in sub_params: - return True + family_ok = any(p.startswith(base + "%") for p in valid_params) + return family_ok and sub in sub_params - # Family prefix check (only accept at a boundary to avoid prefix-typo matches) + # Simple params: family prefix check at structural boundaries if any(p.startswith(base + b) for b in ("(", "%", "_") for p in valid_params): return True From 5c279c163bf5ffe6daa5641876f5f97e3c5e69e8 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 13:01:34 -0500 Subject: [PATCH 6/8] =?UTF-8?q?Fix=20Doxygen=20warnings=20across=20docs=20?= =?UTF-8?q?and=20Fortran=20sources=20(510=20=E2=86=92=205)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove filename args from @file directives in all 52 .fpp files - Add @param docs to 13 undocumented subroutines, remove duplicate !< inline comments - Convert raw $...$ math to Doxygen \f$...\f$ in m_riemann_solvers.fpp - Add @cond/@endcond around #ifdef blocks that confuse Doxygen parser - Fix getting-started.md HTML (

in ), contributing.md (@: escaping) - Fix stale @param names in m_data_input.f90 - Remove obsolete Doxyfile tags (HTML_TIMESTAMP, LATEX_TIMESTAMP), fix PROJECT_NAME quoting - Add stable {#id} anchors to generated case_constraints.md and cli-reference.md - Add _escape_doxygen() helper for CLI help text, add missing precheck command - Extend lint_docs.py with math syntax and section anchor checks Co-Authored-By: Claude Opus 4.6 --- docs/Doxyfile.in | 19 +- docs/documentation/case.md | 94 +- docs/documentation/contributing.md | 2 +- docs/documentation/getting-started.md | 8 +- docs/documentation/visualization.md | 10 +- src/common/include/1dHardcodedIC.fpp | 18 +- src/common/include/2dHardcodedIC.fpp | 122 +-- src/common/include/3dHardcodedIC.fpp | 16 +- src/common/include/ExtrusionHardcodedIC.fpp | 18 +- src/common/include/acc_macros.fpp | 2 +- src/common/include/case.fpp | 10 +- src/common/include/macros.fpp | 28 +- src/common/include/omp_macros.fpp | 2 +- src/common/include/parallel_macros.fpp | 2 +- src/common/include/shared_parallel_macros.fpp | 2 +- src/common/m_boundary_common.fpp | 74 +- src/common/m_checker_common.fpp | 6 +- src/common/m_chemistry.fpp | 70 +- src/common/m_compute_levelset.fpp | 42 +- src/common/m_constants.fpp | 42 +- src/common/m_derived_types.fpp | 118 +-- src/common/m_finite_differences.fpp | 24 +- src/common/m_helper.fpp | 170 ++-- src/common/m_helper_basic.fpp | 54 +- src/common/m_ib_patches.fpp | 348 +++---- src/common/m_model.fpp | 240 ++--- src/common/m_mpi_common.fpp | 434 ++++----- src/common/m_phase_change.fpp | 352 +++---- src/common/m_variables_conversion.fpp | 300 +++--- src/post_process/m_checker.fpp | 4 +- src/post_process/m_data_input.f90 | 7 +- src/post_process/m_data_output.fpp | 522 +++++----- src/post_process/m_derived_variables.fpp | 322 +++---- src/post_process/m_global_parameters.fpp | 234 ++--- src/post_process/m_mpi_proxy.fpp | 140 +-- src/post_process/m_start_up.fpp | 180 ++-- src/post_process/p_main.fpp | 50 +- src/pre_process/m_assign_variables.fpp | 220 ++--- src/pre_process/m_boundary_conditions.fpp | 20 +- src/pre_process/m_check_ib_patches.fpp | 66 +- src/pre_process/m_check_patches.fpp | 74 +- src/pre_process/m_checker.fpp | 4 +- src/pre_process/m_data_output.fpp | 164 ++-- src/pre_process/m_global_parameters.fpp | 222 ++--- src/pre_process/m_icpp_patches.fpp | 700 +++++++------- src/pre_process/m_initial_condition.fpp | 105 +- src/pre_process/m_mpi_proxy.fpp | 32 +- src/pre_process/m_perturbation.fpp | 62 +- src/pre_process/m_start_up.fpp | 304 +++--- src/simulation/include/inline_riemann.fpp | 8 +- src/simulation/m_acoustic_src.fpp | 156 ++- src/simulation/m_body_forces.fpp | 22 +- src/simulation/m_bubbles.fpp | 431 ++++----- src/simulation/m_bubbles_EE.fpp | 26 +- src/simulation/m_bubbles_EL.fpp | 240 ++--- src/simulation/m_bubbles_EL_kernels.fpp | 62 +- src/simulation/m_cbc.fpp | 284 +++--- src/simulation/m_checker.fpp | 6 +- src/simulation/m_compute_cbc.fpp | 12 +- src/simulation/m_data_output.fpp | 230 ++--- src/simulation/m_derived_variables.fpp | 128 +-- src/simulation/m_fftw.fpp | 44 +- src/simulation/m_global_parameters.fpp | 266 ++--- src/simulation/m_hyperelastic.fpp | 130 +-- src/simulation/m_hypoelastic.fpp | 36 +- src/simulation/m_ibm.fpp | 198 ++-- src/simulation/m_igr.fpp | 10 +- src/simulation/m_mpi_proxy.fpp | 52 +- src/simulation/m_muscl.fpp | 42 +- src/simulation/m_pressure_relaxation.fpp | 32 +- src/simulation/m_qbmm.fpp | 62 +- src/simulation/m_rhs.fpp | 174 ++-- src/simulation/m_riemann_solvers.fpp | 906 +++++++++--------- src/simulation/m_sim_helpers.fpp | 94 +- src/simulation/m_start_up.fpp | 216 ++--- src/simulation/m_surface_tension.fpp | 8 +- src/simulation/m_time_steppers.fpp | 123 +-- src/simulation/m_viscous.fpp | 120 +-- src/simulation/m_weno.fpp | 272 +++--- src/simulation/p_main.fpp | 26 +- toolchain/mfc/cli/docs_gen.py | 18 +- toolchain/mfc/gen_case_constraints_docs.py | 29 +- toolchain/mfc/lint_docs.py | 127 ++- toolchain/mfc/params/generators/docs_gen.py | 2 +- 84 files changed, 5406 insertions(+), 5245 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 5a32db918d..4fe3c2c6e5 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -35,7 +35,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "@DOXYGEN_PROJECT_NAME@" +PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -970,7 +970,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = readme.md +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -1205,14 +1205,6 @@ HTML_COLORSTYLE_SAT = 255 HTML_COLORSTYLE_GAMMA = 113 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that @@ -1801,13 +1793,6 @@ LATEX_HIDE_INDICES = NO LATEX_BIB_STYLE = plain -# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_TIMESTAMP = NO # The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) # path from which the emoji images will be read. If a relative path is entered, diff --git a/docs/documentation/case.md b/docs/documentation/case.md index a753b2fa7c..d7b5b800a0 100644 --- a/docs/documentation/case.md +++ b/docs/documentation/case.md @@ -82,23 +82,23 @@ Before diving into parameter details, check the **@ref case_constraints "Feature - Full reference: **@ref parameters "Case Parameters"** - Complete parameter documentation There are multiple sets of parameters that must be specified in the python input file: -1. [Runtime Parameters](#1-runtime) -2. [Computational Domain Parameters](#2-computational-domain) -3. [Patch Parameters](#3-patches) -4. [Immersed Boundary Patches](#4-immersed-boundary-patches) -5. [Fluid Material's Parameters](#5-fluid-materials) -6. [Simulation Algorithm Parameters](#6-simulation-algorithm) -7. [Formatted Database and Structure Parameters](#7-formatted-output) -8. [(Optional) Acoustic Source Parameters](#8-acoustic-source) -9. [(Optional) Ensemble-Averaged Bubble Model Parameters](#9-ensemble-averaged-bubble-model) -10. [(Optional) Velocity Field Setup Parameters](#10-velocity-field-setup) -11. [(Optional) Phase Change Parameters](#11-Phase-Change-Model) -12. [(Optional) Artificial Mach Number Parameters](#12-artificial-Mach-number) +1. [Runtime Parameters](#sec-runtime) +2. [Computational Domain Parameters](#sec-computational-domain) +3. [Patch Parameters](#sec-patches) +4. [Immersed Boundary Patches](#sec-immersed-boundary-patches) +5. [Fluid Material's Parameters](#sec-fluid-materials) +6. [Simulation Algorithm Parameters](#sec-simulation-algorithm) +7. [Formatted Database and Structure Parameters](#sec-formatted-output) +8. [(Optional) Acoustic Source Parameters](#sec-acoustic-source) +9. [(Optional) Ensemble-Averaged Bubble Model Parameters](#sec-bubble-models) +10. [(Optional) Velocity Field Setup Parameters](#sec-velocity-field-setup) +11. [(Optional) Phase Change Parameters](#sec-phase-change) +12. [(Optional) Artificial Mach Number Parameters](#sec-artificial-mach-number) Items 8, 9, 10, 11 and 12 are optional sets of parameters that activate the acoustic source model, ensemble-averaged bubble model, initial velocity field setup, phase change, artificial Mach number respectively. Definition of the parameters is described in the following subsections. -### 1. Runtime +### 1. Runtime {#sec-runtime} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -110,7 +110,7 @@ Definition of the parameters is described in the following subsections. The underlying MPI implementation and communication infrastructure must support this feature, detecting GPU pointers and performing RDMA accordingly. -### 2. Computational Domain +### 2. Computational Domain {#sec-computational-domain} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -129,7 +129,7 @@ The parameters define the boundaries of the spatial and temporal domains, and th - `[x,y,z]_domain%[beg,end]` define the spatial domain in $x$, $y$, and $z$ Cartesian coordinates: -$$ x \in \left[ x \\_ domain \\% beg, x \\_ domain \\% end \right], y \in \left[ y \\_ domain \\% beg, y \\_ domain \\% end \right], z \in \left[ z \\_ domain \\% beg, z \\_ domain \\% end \right] $$ +\f[ x \in \left[ x\_domain\%beg, \; x\_domain\%end \right], \quad y \in \left[ y\_domain\%beg, \; y\_domain\%end \right], \quad z \in \left[ z\_domain\%beg, \; z\_domain\%end \right] \f] - $m$, $n$, and $p$ define the number of finite volume cells that uniformly discretize the domain along the $x$, $y$, and $z$ axes, respectively. Note that the actual number of cells in each coordinate axis is given as $[m,n,p]+1$. @@ -141,7 +141,7 @@ The grid is gradually stretched such that the domain boundaries are pushed away - `a_[x,y,z]`, `[x,y,z]_a`, and `[x,y,z]_b` are parameters that define the grid stretching function. When grid stretching along the $x$ axis is considered, the stretching function is given as: -$$ x_{cb,stretch} = x_{cb} + \frac{x_{cb}}{a_x} \Bigg[ \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_{cb}-x_a)}{L} \right) \right] + \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_{cb}-x_b)}{L} \right) \right] -2 \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_b-x_a)}{2L} \right) \right] \Bigg] $$ +\f[ x_{cb,stretch} = x_{cb} + \frac{x_{cb}}{a_x} \Bigg[ \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_{cb}-x_a)}{L} \right) \right] + \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_{cb}-x_b)}{L} \right) \right] -2 \mathrm{log}\left[\mathrm{cosh} \left( \frac{a_x(x_b-x_a)}{2L} \right) \right] \Bigg] \f] where `x_cb` and `x_[cb,stretch]` are the coordinates of a cell boundary at the original and stretched domains, respectively. `L` is the domain length along the `x` axis: `L`=`x_domain%%end`-`x_domain%%beg`. @@ -158,7 +158,7 @@ When $p=0$, the domain is defined on $x$-$y$ axi-symmetric coordinates. In both Coordinates, mesh stretching can be defined along the $x$- and $y$-axes. MPI topology is automatically optimized to maximize the parallel efficiency for given choice of coordinate systems. -### 3. Patches +### 3. Patches {#sec-patches} | Parameter | Type | Analytical Definition | Description | | ---: | :----: | :----: | :--- | @@ -220,7 +220,7 @@ Additionally, the following variables are made available as shorthand: | `y` | `y_cc(j)` | `ly` | The patch's `length_y` | `yc` | The patch's `y_centroid` | | `z` | `z_cc(k)` | `lz` | The patch's `length_z` | `zc` | The patch's `z_centroid` | | `eps` | The patch's `epsilon` | `beta` | The patch's `beta` | `radii` | The patch's `radii` | -| `tau_e` | The patch's `tau_e` | `r` | The patch's `radius` | `pi` and `e` | $\pi$ and $e$ | +| `tau_e` | The patch's `tau_e` | `r` | The patch's `radius` | `pi` and `e` | \f$\pi\f$ and \f$e\f$ | where $(i,j,k)$ are the grid-indices of the current cell in each coordinate direction. @@ -300,7 +300,7 @@ These physical parameters must be consistent with fluid material's parameters de Initial conditions in which not all patches support the `patch_icpp(j)%smoothen` parameter can still be smoothed by applying iterations of the heat equation to the initial condition. This is enabled by adding `'elliptic_smoothing': "T",` and `'elliptic_smoothing_iters': N,` to the case dictionary, where `N` is the number of smoothing iterations to apply. -### 4. Immersed Boundary Patches +### 4. Immersed Boundary Patches {#sec-immersed-boundary-patches} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -345,7 +345,7 @@ Additional details on this specification can be found in [The Naca Airfoil Serie - `slip` applies a slip boundary to the surface of the patch if true and a no-slip boundary condition to the surface if false. -- Please see [Patch Parameters](#3-patches) for the descriptions of `model_filepath`, `model_scale`, `model_rotate`, `model_translate`, `model_spc`, and `model_threshold`. +- Please see [Patch Parameters](#sec-patches) for the descriptions of `model_filepath`, `model_scale`, `model_rotate`, `model_translate`, `model_spc`, and `model_threshold`. - `moving_ibm` sets the method by which movement will be applied to the immersed boundary. Using 0 will result in no movement. Using 1 will result 1-way coupling where the boundary moves at a constant rate and applied forces to the fluid based upon it's own motion. In 1-way coupling, the fluid does not apply forces back onto the IB. @@ -353,12 +353,12 @@ Additional details on this specification can be found in [The Naca Airfoil Serie - `angular_vel(i)` is the initial angular velocity of the IB about the x, y, z axes for i=1, 2, 3 in radians per second. When `moving_ibm` equals 1, this angular velocity is constant. -### 5. Fluid Material’s +### 5. Fluid Material's {#sec-fluid-materials} | Parameter | Type | Description | | ---: | :----: | :--- | -| `gamma` | Real | Stiffened-gas parameter $\Gamma$ of fluid. | -| `pi_inf` | Real | Stiffened-gas parameter $\Pi_\infty$ of fluid. | +| `gamma` | Real | Stiffened-gas parameter \f$\Gamma\f$ of fluid. | +| `pi_inf` | Real | Stiffened-gas parameter \f$\Pi_\infty\f$ of fluid. | | `Re(1)` * | Real | Shear viscosity of fluid. | | `Re(2)` * | Real | Volume viscosity of fluid. | | `cv` ** | Real | Sffened-gas parameter $c_v$ of fluid. | @@ -376,7 +376,7 @@ Fluid material's parameters. All parameters except for sigma should be prepended The table lists the fluid material's parameters. The parameters define material's property of compressible fluids that are used in simulation. -- `fluid_pp(i)%%gamma` and `fluid_pp(i)%%pi_inf` define $\Gamma$ and $\Pi$ as parameters of $i$-th fluid that are used in stiffened gas equation of state. +- `fluid_pp(i)%%gamma` and `fluid_pp(i)%%pi_inf` define \f$\Gamma\f$ and \f$\Pi\f$ as parameters of $i$-th fluid that are used in stiffened gas equation of state. - `fluid_pp(i)%%Re(1)` and `fluid_pp(i)%%Re(2)` define the shear and volume viscosities of $i$-th fluid, respectively. @@ -387,7 +387,7 @@ Details of implementation of viscosity in MFC can be found in \cite Coralic15. - `fluid_pp(i)%%G` is required for `hypoelasticity`. -### 6. Simulation Algorithm +### 6. Simulation Algorithm {#sec-simulation-algorithm} See @ref equations "Equations" for the mathematical models these parameters control. @@ -396,8 +396,8 @@ See @ref equations "Equations" for the mathematical models these parameters cont | `bc_[x,y,z]%%beg[end]` | Integer | Beginning [ending] boundary condition in the $[x,y,z]$-direction (negative integer, see table [Boundary Conditions](#boundary-conditions)) | | `bc_[x,y,z]%%vb[1,2,3]`‡ | Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%%beg` | | `bc_[x,y,z]%%ve[1,2,3]`‡ | Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%%end` | -| `model_eqns` | Integer | Multicomponent model: [1] $\Gamma/\Pi_\infty$; [2] 5-equation; [3] 6-equation; [4] 4-equation | -| `alt_soundspeed` * | Logical | Alternate sound speed and $K \nabla \cdot u$ for 5-equation model | +| `model_eqns` | Integer | Multicomponent model: [1] \f$\Gamma/\Pi_\infty\f$; [2] 5-equation; [3] 6-equation; [4] 4-equation | +| `alt_soundspeed` * | Logical | Alternate sound speed and \f$K \nabla \cdot u\f$ for 5-equation model | | `adv_n` | Logical | Solving directly for the number density (in the method of classes) and compute void fraction from the number density | | `mpp_lim` | Logical | Mixture physical parameters limits | | `mixture_err` | Logical | Mixture properties correction | @@ -469,16 +469,16 @@ Tangential velocities require viscosity, `weno_avg = T`, and `bc_[x,y,z]%%beg = Tangential velocities require viscosity, `weno_avg = T`, and `bc_[x,y,z]%%end = 16` to work properly. Normal velocities require `bc_[x,y,z]%%end = -15` or `\bc_[x,y,z]%%end = -16` to work properly. - `model_eqns` specifies the choice of the multi-component model that is used to formulate the dynamics of the flow using integers from 1 through 3. -`model_eqns = 1`, `2`, and `3` correspond to $\Gamma$-$\Pi_\infty$ model (\cite Johnsen08), 5-equation model (\cite Allaire02), and 6-equation model (\cite Saurel09), respectively. +`model_eqns = 1`, `2`, and `3` correspond to \f$\Gamma\f$-\f$\Pi_\infty\f$ model (\cite Johnsen08), 5-equation model (\cite Allaire02), and 6-equation model (\cite Saurel09), respectively. The difference of the two models is assessed by (\cite Schmidmayer20). Note that some code parameters are only compatible with 5-equation model. -- `alt_soundspeed` activates the source term in the advection equations for the volume fractions, $K\nabla\cdot \underline{u}$, that regularizes the speed of sound in the mixture region when the 5-equation model is used. +- `alt_soundspeed` activates the source term in the advection equations for the volume fractions, \f$K\nabla\cdot \underline{u}\f$, that regularizes the speed of sound in the mixture region when the 5-equation model is used. The effect and use of the source term are assessed by \cite Schmidmayer20. - `adv_n` activates the direct computation of number density by the Riemann solver instead of computing number density from the void fraction in the method of classes. -- `mpp_lim` activates correction of solutions to avoid a negative void fraction of each component in each grid cell, such that $\alpha_i>\varepsilon$ is satisfied at each time step. +- `mpp_lim` activates correction of solutions to avoid a negative void fraction of each component in each grid cell, such that \f$\alpha_i>\varepsilon\f$ is satisfied at each time step. - `mixture_err` activates correction of solutions to avoid imaginary speed of sound at each grid cell. @@ -537,7 +537,7 @@ This option requires `weno_Re_flux` to be true because cell boundary values are - `hypoelasticity` activates elastic stress calculations for fluid-solid interactions. Requires `G` to be set in the fluid material's parameters. -#### Boundary Condition Patches +#### Boundary Condition Patches {#boundary-condition-patches} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -588,7 +588,7 @@ To restart the simulation from $k$-th time step, set `t_step_start = k`; see @re To newly start the simulation, set `n_start = 0`. To restart the simulation from $k$-th time step, see @ref running "Restarting Cases". -### 7. Formatted Output +### 7. Formatted Output {#sec-formatted-output} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -672,7 +672,7 @@ This is useful for large domains where only a portion of the domain is of intere It is not supported when `precision = 1` and `format = 1`. It also cannot be enabled with `flux_wrt`, `heat_ratio_wrt`, `pres_inf_wrt`, `c_wrt`, `omega_wrt`, `ib`, `schlieren_wrt`, `qm_wrt`, or 'liutex_wrt'. -### 8. Acoustic Source {#acoustic-source} +### 8. Acoustic Source {#sec-acoustic-source} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -753,7 +753,7 @@ Details of the transducer acoustic source model can be found in \cite Maeda17. - `%%bb_lowest_freq` specifies the lower frequency bound of the broadband acoustic wave. The upper frequency bound will be calculated as `%%bb_lowest_freq + %%bb_num_freq * %%bb_bandwidth`. The wave is no longer broadband below the lower bound and above the upper bound. -### 9. Sub-grid Bubble Models +### 9. Sub-grid Bubble Models {#sec-bubble-models} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -870,7 +870,7 @@ When ``polytropic = 'F'``, the gas compression is modeled as non-polytropic due - `massTransfer_model` Activates the mass transfer model at the bubble's interface based on (\cite Preston07). -### 10. Velocity Field Setup +### 10. Velocity Field Setup {#sec-velocity-field-setup} | Parameter | Type | Description | | ---: | :----: | :--- | @@ -900,11 +900,11 @@ The parameters are optionally used to define initial velocity profiles and pertu - `mixlayer_vel_coef` is a parameter for the hyperbolic tangent profile of a mixing layer when `mixlayer_vel_profile = 'T'`. The mean streamwise velocity profile is given as: -$$ u = \mbox{patch\_icpp(1)\%vel(1)} * \tanh( y_{cc} * \mbox{mixlayer\_vel\_coef}) $$ +\f[ u = \text{patch\_icpp(1)\%vel(1)} \cdot \tanh( y_{cc} \cdot \text{mixlayer\_vel\_coef}) \f] - `mixlayer_perturb` activates the velocity perturbation for a temporal mixing layer with hyperbolic tangent mean streamwise velocity profile, using an inverter version of the spectrum-based synthetic turbulence generation method proposed by \cite Guo23. This option only works for `p > 0` and `mixlayer_vel_profile = 'T'`. -### 11. Phase Change Model +### 11. Phase Change Model {#sec-phase-change} | Parameter | Type | Description | | ---: | :----: | :--- | | `relax` | Logical | Activates Phase Change model | @@ -920,7 +920,7 @@ $$ u = \mbox{patch\_icpp(1)\%vel(1)} * \tanh( y_{cc} * \mbox{mixlayer\_vel\_coef - `ptgalpha_eps` Specifies the tolerance used for the Newton Solvers used in the pTg-equilibrium model. -### 12. Artificial Mach Number +### 12. Artificial Mach Number {#sec-artificial-mach-number} | Parameter | Type | Description | | ---: | :----: | :--- | | `pi_fac` | Real | Ratio of artificial and true `pi_\infty` values| @@ -940,7 +940,7 @@ This parameter enables the use of true `pi_\infty` in bubble dynamics models whe `k_x[y,z]`, `w_x[y,z]`, `p_x[y,z]`, and `g_x[y,z]` define an oscillating acceleration in the `x[y,z]` direction with the form -$$ a_{x[y,z]} = g_{x[y,z]} + k_{x[y,z]}\sin\left(w_{x[y,z]}t + p_{x[y,z]}\right). $$ +\f[ a_{x[y,z]} = g_{x[y,z]} + k_{x[y,z]}\sin\left(w_{x[y,z]}t + p_{x[y,z]}\right). \f] By convention, positive accelerations in the `x[y,z]` direction are in the positive `x[y,z]` direction. @@ -997,7 +997,7 @@ When ``cyl_coord = 'T'`` is set in 3D the following constraints must be met: - `z_domain%beg = 0` sets the azimuthal starting point to 0 -- `z_domain%end = 2*math.pi` to set the azimuthal ending point to $2\pi$ (note, requires `import math` in the case file) +- `z_domain%end = 2*math.pi` to set the azimuthal ending point to \f$2\pi\f$ (note, requires `import math` in the case file) When ``cyl_coord = 'T'`` is set in 2D the following constraints must be met: @@ -1021,7 +1021,7 @@ When ``cyl_coord = 'T'`` is set in 2D the following constraints must be met: ## Enumerations -### Boundary conditions +### Boundary conditions {#boundary-conditions} | # | Type | Description | | ---: | :----: | :--- | @@ -1044,7 +1044,7 @@ When ``cyl_coord = 'T'`` is set in 2D the following constraints must be met: *: This boundary condition is only used for `bc_y%%beg` when using cylindrical coordinates (``cyl_coord = 'T'`` and 3D). For axisymmetric problems, use `bc_y%%beg = -2` with ``cyl_coord = 'T'`` in 2D. The boundary condition supported by the MFC are listed in table [Boundary Conditions](#boundary-conditions). -Their number (`#`) corresponds to the input value in `input.py` labeled `bc_[x,y,z]%[beg,end]` (see table [Simulation Algorithm Parameters](#5-simulation-algorithm)). +Their number (`#`) corresponds to the input value in `input.py` labeled `bc_[x,y,z]%[beg,end]` (see table [Simulation Algorithm Parameters](#sec-simulation-algorithm)). The entries labeled "Characteristic." are characteristic boundary conditions based on \cite Thompson87 and \cite Thompson90. ### Generalized Characteristic Boundary conditions @@ -1063,7 +1063,7 @@ The entries labeled "Characteristic." are characteristic boundary conditions bas This boundary condition can be used for subsonic inflow (`bc_[x,y,z]%[beg,end]` = -7) and subsonic outflow (`bc_[x,y,z]%[beg,end]` = -8) characteristic boundary conditions. These are based on \cite Pirozzoli13. This enables to provide inflow and outflow conditions outside the computational domain. -### Patch types +### Patch types {#patch-types} | # | Name | Dim. | Smooth | Description | | ---: | :----: | :---: | :---: | :--- | @@ -1094,7 +1094,7 @@ This includes types exclusive to one-, two-, and three-dimensional problems. The patch type number (`#`) corresponds to the input value in `input.py` labeled `patch_icpp(j)%%geometry` where $j$ is the patch index. Each patch requires a different set of parameters, which are also listed in this table. -### Immersed Boundary Patch Types +### Immersed Boundary Patch Types {#immersed-boundary-patch-types} | # | Name | Dim. | | ---: | :----: | :--- | @@ -1119,7 +1119,7 @@ Each patch requires a different set of parameters, which are also listed in this | 10 | Annular Transducer Array | 2D-Axisym | #9 requirements | | 11 | Circular Transducer Array | 3D | #7 requirements, `%%element_polygon_ratio`, and `%%rotate_angle` | -The required parameters for each acoustic support type are listed in [Acoustic Source](#acoustic-source). +The required parameters for each acoustic support type are listed in [Acoustic Source](#sec-acoustic-source). The acoustic support number (`#`) corresponds to the acoustic support type `Acoustic(i)%%support`, where $i$ is the acoustic source index. For each `%%parameter`, prepend the parameter with `acoustic(i)%`. @@ -1140,10 +1140,10 @@ Description of the acoustic support types: - `%%support = 1` specifies an infinite source plane that is normal to the $x$-axis and intersects with the axis at $x=$ `%%loc(1)` in 1D simulation. `%%dir > 0` specifies a rightward propagating wave, and `%%dir < 0` specifies a leftward propagating wave. `%%dir = 0` is not allowed. - `%%support = 2` specifies a semi-infinite source plane in 2D simulation. -The midplane location is [`%%loc(1)`, `%%loc(2)`] and the normal vector is [$\mathrm{cos}$(`%%dir`), $\mathrm{sin}$(`%%dir`)]. The length of the source plane is `%%length`, and the plane is perpendicular to the direction of wave propagation (defined by `%%dir`). +The midplane location is [`%%loc(1)`, `%%loc(2)`] and the normal vector is [\f$\mathrm{cos}\f$(`%%dir`), \f$\mathrm{sin}\f$(`%%dir`)]. The length of the source plane is `%%length`, and the plane is perpendicular to the direction of wave propagation (defined by `%%dir`). - `%%support = 3` specifies a semi-infinite source plane in 3D simulation. -The midplane location is [`%%loc(1)`, `%%loc(2)`] and the normal vector is [$\mathrm{cos}$(`%%dir`), $\mathrm{sin}$(`%%dir`)]. The length of the source plane is `%%length`, and the plane is perpendicular to the direction of wave propagation (defined by `%%dir`). Note that the plane is infinite in the $z$-direction, so `%%loc(3)` is not required. +The midplane location is [`%%loc(1)`, `%%loc(2)`] and the normal vector is [\f$\mathrm{cos}\f$(`%%dir`), \f$\mathrm{sin}\f$(`%%dir`)]. The length of the source plane is `%%length`, and the plane is perpendicular to the direction of wave propagation (defined by `%%dir`). Note that the plane is infinite in the $z$-direction, so `%%loc(3)` is not required. - `%%support = 5` specifies a circular transducer in 2D simulation. The transducer is centered at [`%%loc(1)`, `%%loc(2)`] with a focal length of `%%foc_length` and an aperture of `%%aperture`. The center location is not the focal point; it is the tip of the circular arc (intersection of the arc and the x-axis). The aperture is the length of the projection of the circular arc onto the y-axis. If a semi-circle is desired, set the aperture to double the focal length. Note that this is physically a cylindrical transducer, and due to the complexity of Green's function for 2D wave, no closed-form solution is available for the 2D circular transducer, and an approximate is used (see \cite Maeda17 for details). For the mass source term correction factor, the theoretical approximation factor of -0.5 in ($r_{foc}^{-0.5}$) is replaced by an empirically determined factor of -0.85. diff --git a/docs/documentation/contributing.md b/docs/documentation/contributing.md index 705815b2d3..8b1ba8fcdd 100644 --- a/docs/documentation/contributing.md +++ b/docs/documentation/contributing.md @@ -148,7 +148,7 @@ Both human reviewers and AI code reviewers reference this section. ### Memory and Allocation - **ALLOCATE/DEALLOCATE pairing:** Every `@:ALLOCATE()` must have a matching `@:DEALLOCATE()`. Missing deallocations leak GPU memory. -- **@:ACC_SETUP_VFs / @:ACC_SETUP_SFs:** Vector/scalar fields must have GPU pointer setup before use in kernels. +- **`@:ACC_SETUP_VFs` / `@:ACC_SETUP_SFs`:** Vector/scalar fields must have GPU pointer setup before use in kernels. - **Conditional allocation:** If an array is allocated inside an `if` block, its deallocation must follow the same condition. - **Out-of-bounds access:** Fortran is permissive with assumed-shape arrays. Check that index arithmetic stays within declared bounds. diff --git a/docs/documentation/getting-started.md b/docs/documentation/getting-started.md index 47befe309f..0e305023b5 100644 --- a/docs/documentation/getting-started.md +++ b/docs/documentation/getting-started.md @@ -70,7 +70,7 @@ for a Linux experience.
-

Windows + WSL (Recommended)

+ Windows + WSL (Recommended) Install [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/) on Windows 11: Either @@ -92,7 +92,7 @@ Once you have WSL installed, you can follow the instructions for *nix systems ab
-

Native Windows (Intel)

+ Native Windows (Intel) Install the latest version of: - [Microsoft Visual Studio Community](https://visualstudio.microsoft.com/) @@ -118,7 +118,9 @@ You will also have access to the `.sln` Microsoft Visual Studio solution files f
-

MacOS

+
+ + MacOS Using [Homebrew](https://brew.sh/) you can install the necessary dependencies before configuring your environment: diff --git a/docs/documentation/visualization.md b/docs/documentation/visualization.md index 10c1fca271..955465a3b8 100644 --- a/docs/documentation/visualization.md +++ b/docs/documentation/visualization.md @@ -54,17 +54,17 @@ For analysis and processing of the database using VisIt's capability, the user i ## Serial data output If ``parallel_io = 'F'``, MFC will output the conservative variables to a directory `D/`. -If multiple cores are used ($\mathtt{ppn > 1}$), then a separate file is created for each core. +If multiple cores are used (\f$\mathtt{ppn > 1}\f$), then a separate file is created for each core. If only one coordinate dimension (`n = 0` and `p = 0`) exists, the primitive variables will also be written to `D/`. The file names correspond to the variables associated with each equation solved by MFC. They are written at every `t_step_save` time step. The conservative variables are -$$ {(\rho \alpha)}\_{1}, \dots, (\rho\alpha)\_{N\_c}, \rho u\_{1}, \dots, \rho u\_{N\_d}, E, \alpha\_1, \dots, \alpha\_{N\_c} $$ +\f[ (\rho \alpha)_{1}, \dots, (\rho\alpha)_{N_c}, \rho u_{1}, \dots, \rho u_{N_d}, E, \alpha_1, \dots, \alpha_{N_c} \f] and the primitive variables are -$$ {(\rho \alpha)}\_1, \dots, (\rho\alpha)\_{N\_c}, u\_1, \dots, u\_{N\_d}, p, \alpha\_1, \dots, \alpha\_{N\_c} $$ +\f[ (\rho \alpha)_1, \dots, (\rho\alpha)_{N_c}, u_1, \dots, u_{N_d}, p, \alpha_1, \dots, \alpha_{N_c} \f] where $N_c$ are the number of components `num_fluids` and $N_d$ is the number of spatial dimensions. There are exceptions: if `model_eqns = 3`, then the six-equation model appends these variables with the internal energies of each component. @@ -72,12 +72,12 @@ If there are sub-grid bubbles `bubbles = T`, then the bubble variables are also These depend on the bubble dynamics model used. If ``polytropic = 'T'``, then the conservative variables are appended by -$$ n\_b R\_1, n\_b {\\dot R}\_1, \dots, n\_b R\_{N\_b}, n\_b {\\dot R}\_{N\_b} $$ +\f[ n_b R_1, n_b \dot{R}_1, \dots, n_b R_{N_b}, n_b \dot{R}_{N_b} \f] where $n_B$ is the bubble number density, and $N_b$ is the number of bubble sizes (see the matching variable in the input file, `Nb`). The primitive bubble variables do not include $n_B$: -$$ R\_1, {\\dot R}\_1, \dots, R\_{N\_b}, {\\dot R}\_{N\_b} $$ +\f[ R_1, \dot{R}_1, \dots, R_{N_b}, \dot{R}_{N_b} \f] ## Remote Visualization on PACE Phoenix diff --git a/src/common/include/1dHardcodedIC.fpp b/src/common/include/1dHardcodedIC.fpp index 4359528a3f..83784a1fa5 100644 --- a/src/common/include/1dHardcodedIC.fpp +++ b/src/common/include/1dHardcodedIC.fpp @@ -1,37 +1,37 @@ #:def Hardcoded1DVariables() - ! Place any declaration of intermediate variables here + ! any declaration of intermediate variables here real(wp) :: x_mid_diffu, width_sq, profile_shape, temp, molar_mass_inv, y1, y2, y3, y4 #:enddef #:def Hardcoded1D() select case (patch_icpp(patch_id)%hcid) case (150) ! 1D Smooth Alfven Case for MHD - ! velocity + ! q_prim_vf(momxb + 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i)) q_prim_vf(momxb + 2)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i)) - ! magnetic field + ! field q_prim_vf(B_idx%end - 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i)) q_prim_vf(B_idx%end)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i)) case (170) - ! This hardcoded case can be used to start a simulation with initial conditions given from a known 1D profile (e.g. Cantera, SDtoolbox) + ! hardcoded case can be used to start a simulation with initial conditions given from a known 1D profile (e.g. Cantera, SDtoolbox) @: HardcodedReadValues() case (180) - ! This is patch is hard-coded for test suite optimization used in the - ! 1D_shuoser cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.2*sin(5*x)" + ! is patch is hard-coded for test suite optimization used in the + ! cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.2*sin(5*x)" if (patch_id == 2) then q_prim_vf(contxb + 0)%sf(i, 0, 0) = 1 + 0.2*sin(5*x_cc(i)) end if case (181) - ! This is patch is hard-coded for test suite optimization used in the - ! 1D_titarevtorro cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.1*sin(20*x*pi)" + ! is patch is hard-coded for test suite optimization used in the + ! cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.1*sin(20*x*pi)" q_prim_vf(contxb + 0)%sf(i, 0, 0) = 1 + 0.1*sin(20*x_cc(i)*pi) case (182) - ! This patch is a hard-coded for test suite optimization (multiple component diffusion) + ! patch is a hard-coded for test suite optimization (multiple component diffusion) x_mid_diffu = 0.05_wp/2.0_wp width_sq = (2.5_wp*10.0_wp**(-3.0_wp))**2 profile_shape = 1.0_wp - 0.5_wp*exp(-(x_cc(i) - x_mid_diffu)**2/width_sq) diff --git a/src/common/include/2dHardcodedIC.fpp b/src/common/include/2dHardcodedIC.fpp index a35633bca1..40136e823d 100644 --- a/src/common/include/2dHardcodedIC.fpp +++ b/src/common/include/2dHardcodedIC.fpp @@ -1,5 +1,5 @@ #:def Hardcoded2DVariables() - ! Place any declaration of intermediate variables here + ! any declaration of intermediate variables here real(wp) :: eps, eps_mhd, C_mhd real(wp) :: r, rmax, gam, umax, p0 real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, intL, alph @@ -9,9 +9,9 @@ real(wp) :: r_sq - ! # 207 + ! 207 real(wp) :: sigma, gauss1, gauss2 - ! # 208 + ! 208 real(wp) :: ei, d, fsm, alpha_air, alpha_sf6 eps = 1.e-9_wp @@ -23,13 +23,13 @@ case (200) if (y_cc(j) <= (-x_cc(i)**3 + 1)**(1._wp/3._wp)) then - ! Volume Fractions + ! Fractions q_prim_vf(advxb)%sf(i, j, 0) = eps q_prim_vf(advxe)%sf(i, j, 0) = 1._wp - eps - ! Denssities + ! q_prim_vf(contxb)%sf(i, j, 0) = eps*1000._wp q_prim_vf(contxe)%sf(i, j, 0) = (1._wp - eps)*1._wp - ! Pressure + ! q_prim_vf(E_idx)%sf(i, j, 0) = 1000._wp end if case (202) ! Gresho vortex (Gouasmi et al 2022 JCP) @@ -149,7 +149,7 @@ lam = 1.0_wp eps = 1.0e-6_wp ei = 5.0_wp - ! Smoothening function to smooth out sharp discontinuity in the interface + ! function to smooth out sharp discontinuity in the interface if (x_cc(i) <= 0.7_wp*lam) then d = x_cc(i) - lam*(0.4_wp - 0.1_wp*sin(2.0_wp*pi*(y_cc(j)/lam + 0.25_wp))) fsm = 0.5_wp*(1.0_wp + erf(d/(ei*sqrt(dx*dy)))) @@ -162,11 +162,11 @@ end if case (250) ! MHD Orszag-Tang vortex - ! gamma = 5/3 - ! rho = 25/(36*pi) - ! p = 5/(12*pi) - ! v = (-sin(2*pi*y), sin(2*pi*x), 0) - ! B = (-sin(2*pi*y)/sqrt(4*pi), sin(4*pi*x)/sqrt(4*pi), 0) + ! = 5/3 + ! = 25/(36*pi) + ! = 5/(12*pi) + ! = (-sin(2*pi*y), sin(2*pi*x), 0) + ! = (-sin(2*pi*y)/sqrt(4*pi), sin(4*pi*x)/sqrt(4*pi), 0) q_prim_vf(momxb)%sf(i, j, 0) = -sin(2._wp*pi*y_cc(j)) q_prim_vf(momxb + 1)%sf(i, j, 0) = sin(2._wp*pi*x_cc(i)) @@ -179,7 +179,7 @@ q_prim_vf(contxb)%sf(i, j, 0) = 0.01 q_prim_vf(E_idx)%sf(i, j, 0) = 1.0 elseif (x_cc(i)**2 + y_cc(j)**2 <= 1._wp**2) then - ! Linear interpolation between r=0.08 and r=1.0 + ! interpolation between r=0.08 and r=1.0 factor = (1.0_wp - sqrt(x_cc(i)**2 + y_cc(j)**2))/(1.0_wp - 0.08_wp) q_prim_vf(contxb)%sf(i, j, 0) = 0.01_wp*factor + 1.e-4_wp*(1.0_wp - factor) q_prim_vf(E_idx)%sf(i, j, 0) = 1.0_wp*factor + 3.e-5_wp*(1.0_wp - factor) @@ -188,36 +188,36 @@ q_prim_vf(E_idx)%sf(i, j, 0) = 3.e-5_wp end if - ! case 252 is for the 2D MHD Rotor problem + ! 252 is for the 2D MHD Rotor problem case (252) ! 2D MHD Rotor Problem - ! Ambient conditions are set in the JSON file. - ! This case imposes the dense, rotating cylinder. + ! conditions are set in the JSON file. + ! case imposes the dense, rotating cylinder. ! - ! gamma = 1.4 - ! Ambient medium (r > 0.1): - ! rho = 1, p = 1, v = 0, B = (1,0,0) - ! Rotor (r <= 0.1): - ! rho = 10, p = 1 - ! v has angular velocity w=20, giving v_tan=2 at r=0.1 - - ! Calculate distance squared from the center + ! = 1.4 + ! medium (r > 0.1): + ! = 1, p = 1, v = 0, B = (1,0,0) + ! (r <= 0.1): + ! = 10, p = 1 + ! has angular velocity w=20, giving v_tan=2 at r=0.1 + + ! distance squared from the center r_sq = (x_cc(i) - 0.5_wp)**2 + (y_cc(j) - 0.5_wp)**2 - ! inner radius of 0.1 + ! radius of 0.1 if (r_sq <= 0.1**2) then - ! -- Inside the rotor -- - ! Set density uniformly to 10 + ! Inside the rotor -- + ! density uniformly to 10 q_prim_vf(contxb)%sf(i, j, 0) = 10._wp - ! Set vup constant rotation of rate v=2 - ! v_x = -omega * (y - y_c) - ! v_y = omega * (x - x_c) + ! vup constant rotation of rate v=2 + ! = -omega * (y - y_c) + ! = omega * (x - x_c) q_prim_vf(momxb)%sf(i, j, 0) = -20._wp*(y_cc(j) - 0.5_wp) q_prim_vf(momxb + 1)%sf(i, j, 0) = 20._wp*(x_cc(i) - 0.5_wp) - ! taper width of 0.015 + ! width of 0.015 else if (r_sq <= 0.115**2) then - ! linearly smooth the function between r = 0.1 and 0.115 + ! smooth the function between r = 0.1 and 0.115 q_prim_vf(contxb)%sf(i, j, 0) = 1._wp + 9._wp*(0.115_wp - sqrt(r_sq))/(0.015_wp) q_prim_vf(momxb)%sf(i, j, 0) = -(2._wp/sqrt(r_sq))*(y_cc(j) - 0.5_wp)*(0.115_wp - sqrt(r_sq))/(0.015_wp) @@ -225,32 +225,32 @@ end if case (253) ! MHD Smooth Magnetic Vortex - ! Section 5.2 of - ! Implicit hybridized discontinuous Galerkin methods for compressible magnetohydrodynamics - ! C. Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire + ! 5.2 of + ! hybridized discontinuous Galerkin methods for compressible magnetohydrodynamics + ! Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire - ! velocity + ! q_prim_vf(momxb)%sf(i, j, 0) = 1._wp - (y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)) q_prim_vf(momxb + 1)%sf(i, j, 0) = 1._wp + (x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)) - ! magnetic field + ! field q_prim_vf(B_idx%beg)%sf(i, j, 0) = -y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi) q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi) - ! pressure + ! q_prim_vf(E_idx)%sf(i, j, 0) = 1._wp + (1 - 2._wp*(x_cc(i)**2 + y_cc(j)**2))*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/((2._wp*pi)**3) case (260) ! Gaussian Divergence Pulse - ! Bx(x) = 1 + C * erf((x-0.5)/σ) - ! ⇒ ∂Bx/∂x = C * (2/√π) * exp[-((x-0.5)/σ)**2] * (1/σ) - ! Choose C = ε * σ * √π / 2 ⇒ ∂Bx/∂x = ε * exp[-((x-0.5)/σ)**2] - ! ψ is initialized to zero everywhere. + ! = 1 + C * erf((x-0.5)/σ) + ! ∂Bx/∂x = C * (2/√π) * exp[-((x-0.5)/σ)**2] * (1/σ) + ! C = ε * σ * √π / 2 ⇒ ∂Bx/∂x = ε * exp[-((x-0.5)/σ)**2] + ! is initialized to zero everywhere. eps_mhd = patch_icpp(patch_id)%a(2) sigma = patch_icpp(patch_id)%a(3) C_mhd = eps_mhd*sigma*sqrt(pi)*0.5_wp - ! B-field + ! q_prim_vf(B_idx%beg)%sf(i, j, 0) = 1._wp + C_mhd*erf((x_cc(i) - 0.5_wp)/sigma) case (261) ! Blob @@ -260,21 +260,21 @@ alpha = r/r0 if (alpha < 1) then q_prim_vf(B_idx%beg)%sf(i, j, 0) = 1._wp/sqrt(4._wp*pi)*(alpha**8 - 2._wp*alpha**4 + 1._wp) - ! q_prim_vf(B_idx%beg)%sf(i,j,0) = 1._wp/sqrt(4000._wp*pi) * (4096._wp*r2**4 - 128._wp*r2**2 + 1._wp) - ! q_prim_vf(B_idx%beg)%sf(i,j,0) = 1._wp/(4._wp*pi) * (alpha**8 - 2._wp*alpha**4 + 1._wp) - ! q_prim_vf(E_idx)%sf(i,j,0) = 6._wp - q_prim_vf(B_idx%beg)%sf(i,j,0)**2/2._wp + ! = 1._wp/sqrt(4000._wp*pi) * (4096._wp*r2**4 - 128._wp*r2**2 + 1._wp) + ! = 1._wp/(4._wp*pi) * (alpha**8 - 2._wp*alpha**4 + 1._wp) + ! = 6._wp - q_prim_vf(B_idx%beg)%sf(i,j,0)**2/2._wp end if case (262) ! Tilted 2D MHD shock‐tube at α = arctan2 (≈63.4°) - ! rotate by α = atan(2) + ! by α = atan(2) alpha = atan(2._wp) cosA = cos(alpha) sinA = sin(alpha) - ! projection along shock normal + ! along shock normal r = x_cc(i)*cosA + y_cc(j)*sinA if (r <= 0.5_wp) then - ! LEFT state: ρ=1, v∥=+10, v⊥=0, p=20, B∥=B⊥=5/√(4π) + ! state: ρ=1, v∥=+10, v⊥=0, p=20, B∥=B⊥=5/√(4π) q_prim_vf(contxb)%sf(i, j, 0) = 1._wp q_prim_vf(momxb)%sf(i, j, 0) = 10._wp*cosA q_prim_vf(momxb + 1)%sf(i, j, 0) = 10._wp*sinA @@ -284,7 +284,7 @@ q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = (5._wp/sqrt(4._wp*pi))*sinA & + (5._wp/sqrt(4._wp*pi))*cosA else - ! RIGHT state: ρ=1, v∥=−10, v⊥=0, p=1, B∥=B⊥=5/√(4π) + ! state: ρ=1, v∥=−10, v⊥=0, p=1, B∥=B⊥=5/√(4π) q_prim_vf(contxb)%sf(i, j, 0) = 1._wp q_prim_vf(momxb)%sf(i, j, 0) = -10._wp*cosA q_prim_vf(momxb + 1)%sf(i, j, 0) = -10._wp*sinA @@ -294,16 +294,16 @@ q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = (5._wp/sqrt(4._wp*pi))*sinA & + (5._wp/sqrt(4._wp*pi))*cosA end if - ! v^z and B^z remain zero by default + ! and B^z remain zero by default case (270) - ! This hardcoded case extrudes a 1D profile to initialize a 2D simulation domain + ! hardcoded case extrudes a 1D profile to initialize a 2D simulation domain @: HardcodedReadValues() case (280) - ! This is patch is hard-coded for test suite optimization used in the - ! 2D_isentropicvortex case: - ! This analytic patch uses geometry 2 + ! is patch is hard-coded for test suite optimization used in the + ! case: + ! analytic patch uses geometry 2 if (patch_id == 1) then q_prim_vf(E_idx)%sf(i, j, 0) = 1.0*(1.0 - (1.0/1.0)*(5.0/(2.0*pi))*(5.0/(8.0*1.0*(1.4 + 1.0)*pi))*exp(2.0*1.0*(1.0 - (x_cc(i) - patch_icpp(1)%x_centroid)**2.0 - (y_cc(j) - patch_icpp(1)%y_centroid)**2.0)))**(1.4 + 1.0) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1.0*(1.0 - (1.0/1.0)*(5.0/(2.0*pi))*(5.0/(8.0*1.0*(1.4 + 1.0)*pi))*exp(2.0*1.0*(1.0 - (x_cc(i) - patch_icpp(1)%x_centroid)**2.0 - (y_cc(j) - patch_icpp(1)%y_centroid)**2.0)))**1.4 @@ -312,18 +312,18 @@ end if case (281) - ! This is patch is hard-coded for test suite optimization used in the - ! 2D_acoustic_pulse case: - ! This analytic patch uses geometry 2 + ! is patch is hard-coded for test suite optimization used in the + ! case: + ! analytic patch uses geometry 2 if (patch_id == 2) then q_prim_vf(E_idx)%sf(i, j, 0) = 101325*(1 - 0.5*(1.4 - 1)*(0.4)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1.4/(1.4 - 1)) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1*(1 - 0.5*(1.4 - 1)*(0.4)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1/(1.4 - 1)) end if case (282) - ! This is patch is hard-coded for test suite optimization used in the - ! 2D_zero_circ_vortex case: - ! This analytic patch uses geometry 2 + ! is patch is hard-coded for test suite optimization used in the + ! case: + ! analytic patch uses geometry 2 if (patch_id == 2) then q_prim_vf(E_idx)%sf(i, j, 0) = 101325*(1 - 0.5*(1.4 - 1)*(0.1/0.3)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1.4/(1.4 - 1)) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1*(1 - 0.5*(1.4 - 1)*(0.1/0.3)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1/(1.4 - 1)) diff --git a/src/common/include/3dHardcodedIC.fpp b/src/common/include/3dHardcodedIC.fpp index 40d5f03ad3..1844efd3ac 100644 --- a/src/common/include/3dHardcodedIC.fpp +++ b/src/common/include/3dHardcodedIC.fpp @@ -1,12 +1,12 @@ #:def Hardcoded3DVariables() - ! Place any declaration of intermediate variables here + ! any declaration of intermediate variables here real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, alph, Mach real(wp) :: eps - ! IGR Jets - ! Arrays to stor position and radii of jets from input file + ! Jets + ! to stor position and radii of jets from input file real(wp), dimension(:), allocatable :: y_th_arr, z_th_arr, r_th_arr - ! Variables to describe initial condition of jet + ! to describe initial condition of jet real(wp) :: r, ux_th, ux_am, p_th, p_am, rho_th, rho_am, y_th, z_th, r_th, eps_smooth real(wp) :: rcut, xcut ! Intermediate variables for creating smooth initial condition @@ -175,13 +175,13 @@ q_prim_vf(E_idx)%sf(i, j, k) = p_th*rcut*xcut + p_am case (370) - ! This hardcoded case extrudes a 2D profile to initialize a 3D simulation domain + ! hardcoded case extrudes a 2D profile to initialize a 3D simulation domain @: HardcodedReadValues() case (380) - ! This is patch is hard-coded for test suite optimization used in the - ! 3D_TaylorGreenVortex case: - ! This analytic patch used geometry 9 + ! is patch is hard-coded for test suite optimization used in the + ! case: + ! analytic patch used geometry 9 Mach = 0.1 if (patch_id == 1) then q_prim_vf(E_idx)%sf(i, j, k) = 101325 + (Mach**2*376.636429464809**2/16)*(cos(2*x_cc(i)/1) + cos(2*y_cc(j)/1))*(cos(2*z_cc(k)/1) + 2) diff --git a/src/common/include/ExtrusionHardcodedIC.fpp b/src/common/include/ExtrusionHardcodedIC.fpp index 264b227f21..4391c34b88 100644 --- a/src/common/include/ExtrusionHardcodedIC.fpp +++ b/src/common/include/ExtrusionHardcodedIC.fpp @@ -63,13 +63,13 @@ fileNames(f) = trim(init_dir)//"prim."//trim(file_num_str)//".00."//zeros_default//".dat" end do - ! Common file reading setup + ! file reading setup open (newunit=unit2, file=trim(fileNames(1)), status='old', action='read', iostat=ios2) if (ios2 /= 0) call s_mpi_abort("Error opening file: "//trim(fileNames(1))) select case (num_dims) case (1, 2) ! 1D and 2D cases are similar - ! Count lines + ! lines line_count = 0 do read (unit2, *, iostat=ios2) dummy_x, dummy_y @@ -84,7 +84,7 @@ if (num_dims == 2) index_x = i @:ALLOCATE (x_coords(xRows), stored_values(xRows, 1, sys_size)) - ! Read data from all files + ! data from all files do f = 1, max_files open (newunit=unit, file=trim(fileNames(f)), status='old', action='read', iostat=ios) if (ios /= 0) call s_mpi_abort("Error opening file: "//trim(fileNames(f))) @@ -96,7 +96,7 @@ close (unit) end do - ! Calculate offsets + ! offsets domain_xstart = x_coords(1) x_step = x_cc(1) - x_cc(0) delta_x = merge(x_cc(0) - domain_xstart + x_step/2.0, & @@ -104,7 +104,7 @@ global_offset_x = nint(abs(delta_x)/x_step) case (3) ! 3D case - determine grid structure - ! Find yRows by counting rows with same x + ! yRows by counting rows with same x read (unit2, *, iostat=ios2) x0, y0, dummy_z if (ios2 /= 0) call s_mpi_abort("Error reading first line") @@ -120,7 +120,7 @@ end do close (unit2) - ! Count total rows + ! total rows open (newunit=unit2, file=trim(fileNames(1)), status='old', action='read', iostat=ios2) nrows = 0 do @@ -135,7 +135,7 @@ index_x = i index_y = j - ! Read all files + ! all files do f = 1, max_files open (newunit=unit, file=trim(fileNames(f)), status='old', action='read', iostat=ios) if (ios /= 0) then @@ -158,7 +158,7 @@ close (unit) end do - ! Calculate offsets + ! offsets x_step = x_cc(1) - x_cc(0) y_step = y_cc(1) - y_cc(0) delta_x = x_cc(index_x) - x_coords(1) + x_step/2.0_wp @@ -170,7 +170,7 @@ files_loaded = .true. end if - ! Data assignment + ! assignment select case (num_dims) case (1) idx = i + 1 + global_offset_x diff --git a/src/common/include/acc_macros.fpp b/src/common/include/acc_macros.fpp index 771ee976db..8e16f43e05 100644 --- a/src/common/include/acc_macros.fpp +++ b/src/common/include/acc_macros.fpp @@ -305,4 +305,4 @@ #:set acc_directive = '!$acc wait ' + clause_val + extraAccArgs_val.strip('\n') $:acc_directive #:enddef -! New line at end of file is required for FYPP +! line at end of file is required for FYPP diff --git a/src/common/include/case.fpp b/src/common/include/case.fpp index aa0e0637b9..f50c291d8b 100644 --- a/src/common/include/case.fpp +++ b/src/common/include/case.fpp @@ -1,13 +1,13 @@ -! This file exists so that Fypp can be run without generating case.fpp files for -! each target. This is useful when generating documentation, for example. This -! should also let MFC be built with CMake directly, without invoking mfc.sh. +! file exists so that Fypp can be run without generating case.fpp files for +! target. This is useful when generating documentation, for example. This +! also let MFC be built with CMake directly, without invoking mfc.sh. -! For pre-process. +! pre-process. #:def analytical() #:enddef -! For moving immersed boundaries in simulation +! moving immersed boundaries in simulation #:def mib_analytical() #:enddef diff --git a/src/common/include/macros.fpp b/src/common/include/macros.fpp index 03d812f53d..54dd957bfb 100644 --- a/src/common/include/macros.fpp +++ b/src/common/include/macros.fpp @@ -12,20 +12,20 @@ #endif #:enddef -! Caution: -! This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank. -! That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. -! For an example see misc/nvidia_uvm/bind.sh. +! +! macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank. +! because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. +! an example see misc/nvidia_uvm/bind.sh. #:def PREFER_GPU(*args) #ifdef MFC_SIMULATION #ifdef __NVCOMPILER_GPU_UNIFIED_MEM block -! Beginning in the 25.3 release, the structure of the cudafor module has been changed slightly. -! The module now includes, or “uses” 3 submodules: cuda_runtime_api, gpu_reductions, and sort. -! The cudafor functionality has not changed. But for new users, or users who have needed to -! work-around name conflicts in the module, it may be better to use cuda_runtime_api to expose -! interfaces to the CUDA runtime calls described in Chapter 4 of this guide. -! https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#fortran-host-modules +! in the 25.3 release, the structure of the cudafor module has been changed slightly. +! module now includes, or “uses” 3 submodules: cuda_runtime_api, gpu_reductions, and sort. +! cudafor functionality has not changed. But for new users, or users who have needed to +! name conflicts in the module, it may be better to use cuda_runtime_api to expose +! to the CUDA runtime calls described in Chapter 4 of this guide. +! #if __NVCOMPILER_MAJOR__ < 25 || (__NVCOMPILER_MAJOR__ == 25 && __NVCOMPILER_MINOR__ < 3) use cudafor, gpu_sum => sum, gpu_maxval => maxval, gpu_minval => minval #else @@ -36,19 +36,19 @@ if (nv_uvm_pref_gpu) then #:for arg in args !print*, "Moving ${arg}$ to GPU => ", SHAPE(${arg}$) - ! set preferred location GPU + ! preferred location GPU istat = cudaMemAdvise(c_devloc(${arg}$), SIZEOF(${arg}$), cudaMemAdviseSetPreferredLocation, 0) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat !write(*,*) cudaGetErrorString(istat) end if - ! set accessed by CPU + ! accessed by CPU istat = cudaMemAdvise(c_devloc(${arg}$), SIZEOF(${arg}$), cudaMemAdviseSetAccessedBy, cudaCpuDeviceId) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat !write(*,*) cudaGetErrorString(istat) end if - ! prefetch to GPU - physically populate memory pages + ! to GPU - physically populate memory pages istat = cudaMemPrefetchAsync(c_devloc(${arg}$), SIZEOF(${arg}$), 0, 0) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat @@ -164,4 +164,4 @@ //${message or '"No error description."'}$) end if #:enddef -! New line at end of file is required for FYPP +! line at end of file is required for FYPP diff --git a/src/common/include/omp_macros.fpp b/src/common/include/omp_macros.fpp index 2e1df1dd8a..c59f45567a 100644 --- a/src/common/include/omp_macros.fpp +++ b/src/common/include/omp_macros.fpp @@ -373,4 +373,4 @@ $:code #:endif #:enddef -! New line at end of file is required for FYPP +! line at end of file is required for FYPP diff --git a/src/common/include/parallel_macros.fpp b/src/common/include/parallel_macros.fpp index bfe4b3beaf..d722adeb78 100644 --- a/src/common/include/parallel_macros.fpp +++ b/src/common/include/parallel_macros.fpp @@ -232,4 +232,4 @@ #:set USING_NVHPC = (MFC_COMPILER == NVIDIA_COMPILER_ID or MFC_COMPILER == PGI_COMPILER_ID) #:set USING_CCE = (MFC_COMPILER == CCE_COMPILER_ID) -! New line at end of file is required for FYPP +! line at end of file is required for FYPP diff --git a/src/common/include/shared_parallel_macros.fpp b/src/common/include/shared_parallel_macros.fpp index 36bee0a23a..4fb47d98a7 100644 --- a/src/common/include/shared_parallel_macros.fpp +++ b/src/common/include/shared_parallel_macros.fpp @@ -117,4 +117,4 @@ #:endif $:extraArgs_val #:enddef -! New line at end of file is required for FYPP +! line at end of file is required for FYPP diff --git a/src/common/m_boundary_common.fpp b/src/common/m_boundary_common.fpp index 4b5f660bd6..a588494b50 100644 --- a/src/common/m_boundary_common.fpp +++ b/src/common/m_boundary_common.fpp @@ -1,9 +1,9 @@ !> -!! @file m_boundary_conditions_common.fpp -!! @brief Contains module m_boundary_conditions_common +!! +!! module m_boundary_conditions_common !> @brief The purpose of the module is to apply noncharacteristic and processor -!! boundary conditions +!! #:include 'case.fpp' #:include 'macros.fpp' @@ -84,8 +84,8 @@ contains end subroutine s_initialize_boundary_common_module !> The purpose of this procedure is to populate the buffers - !! of the primitive variables, depending on the selected - !! boundary conditions. + !! primitive variables, depending on the selected + !! impure subroutine s_populate_variables_buffers(bc_type, q_prim_vf, pb_in, mv_in) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -94,7 +94,7 @@ contains integer :: k, l - ! Population of Buffers in x-direction + ! of Buffers in x-direction if (bc_x%beg >= 0) then call s_mpi_sendrecv_variables_buffers(q_prim_vf, 1, -1, sys_size, pb_in, mv_in) else @@ -155,7 +155,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Population of Buffers in y-direction + ! of Buffers in y-direction if (n == 0) return @@ -226,7 +226,7 @@ contains #:endif - ! Population of Buffers in z-direction + ! of Buffers in z-direction if (p == 0) return @@ -292,7 +292,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if #:endif - ! END: Population of Buffers in z-direction + ! Population of Buffers in z-direction end subroutine s_populate_variables_buffers @@ -1784,7 +1784,7 @@ contains offset = 0 - ! Write bc_types + ! bc_types do dir = 1, num_dims do loc = 1, 2 #ifdef MFC_MIXED_PRECISION @@ -1797,7 +1797,7 @@ contains end do end do - ! Write bc_buffers + ! bc_buffers do dir = 1, num_dims do loc = 1, 2 nelements = sizeof(bc_buffers(dir, loc)%sf)*mpi_io_type/stp @@ -1822,7 +1822,7 @@ contains character(len=10) :: status - ! Read bc_types + ! bc_types file_path = trim(step_dirpath)//'/bc_type.dat' inquire (FILE=trim(file_path), EXIST=file_exist) if (.not. file_exist) then @@ -1838,7 +1838,7 @@ contains end do close (1) - ! Read bc_buffers + ! bc_buffers file_path = trim(step_dirpath)//'/bc_buffers.dat' inquire (FILE=trim(file_path), EXIST=file_exist) if (.not. file_exist) then @@ -1894,7 +1894,7 @@ contains offset = 0 - ! Read bc_types + ! bc_types do dir = 1, num_dims do loc = 1, 2 #ifdef MFC_MIXED_PRECISION @@ -1908,7 +1908,7 @@ contains end do end do - ! Read bc_buffers + ! bc_buffers do dir = 1, num_dims do loc = 1, 2 nelements = sizeof(bc_buffers(dir, loc)%sf)*mpi_io_type/stp @@ -1994,15 +1994,15 @@ contains end subroutine s_assign_default_bc_type !> The purpose of this subroutine is to populate the buffers - !! of the grid variables, which are constituted of the cell- - !! boundary locations and cell-width distributions, based on - !! the boundary conditions. + !! grid variables, which are constituted of the cell- + !! and cell-width distributions, based on + !! conditions. subroutine s_populate_grid_variables_buffers integer :: i !< Generic loop iterator #ifdef MFC_SIMULATION - ! Required for compatibility between codes + ! for compatibility between codes type(int_bounds_info) :: offset_x, offset_y, offset_z offset_x%beg = buff_size; offset_x%end = buff_size offset_y%beg = buff_size; offset_y%end = buff_size @@ -2010,9 +2010,9 @@ contains #endif #ifndef MFC_PRE_PROCESS - ! Population of Buffers in x-direction + ! of Buffers in x-direction - ! Populating cell-width distribution buffer at bc_x%beg + ! cell-width distribution buffer at bc_x%beg if (bc_x%beg >= 0) then call s_mpi_sendrecv_grid_variables_buffers(1, -1) elseif (bc_x%beg <= BC_GHOST_EXTRAP) then @@ -2029,7 +2029,7 @@ contains end do end if - ! Computing the cell-boundary and center locations buffer at bc_x%beg + ! the cell-boundary and center locations buffer at bc_x%beg do i = 1, offset_x%beg x_cb(-1 - i) = x_cb(-i) - dx(-i) end do @@ -2038,7 +2038,7 @@ contains x_cc(-i) = x_cc(1 - i) - (dx(1 - i) + dx(-i))/2._wp end do - ! Populating the cell-width distribution buffer at bc_x%end + ! the cell-width distribution buffer at bc_x%end if (bc_x%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(1, 1) elseif (bc_x%end <= BC_GHOST_EXTRAP) then @@ -2055,7 +2055,7 @@ contains end do end if - ! Populating the cell-boundary and center locations buffer at bc_x%end + ! the cell-boundary and center locations buffer at bc_x%end do i = 1, offset_x%end x_cb(m + i) = x_cb(m + (i - 1)) + dx(m + i) end do @@ -2063,11 +2063,11 @@ contains do i = 1, buff_size x_cc(m + i) = x_cc(m + (i - 1)) + (dx(m + (i - 1)) + dx(m + i))/2._wp end do - ! END: Population of Buffers in x-direction + ! Population of Buffers in x-direction - ! Population of Buffers in y-direction + ! of Buffers in y-direction - ! Populating cell-width distribution buffer at bc_y%beg + ! cell-width distribution buffer at bc_y%beg if (n == 0) then return elseif (bc_y%beg >= 0) then @@ -2086,7 +2086,7 @@ contains end do end if - ! Computing the cell-boundary and center locations buffer at bc_y%beg + ! the cell-boundary and center locations buffer at bc_y%beg do i = 1, offset_y%beg y_cb(-1 - i) = y_cb(-i) - dy(-i) end do @@ -2095,7 +2095,7 @@ contains y_cc(-i) = y_cc(1 - i) - (dy(1 - i) + dy(-i))/2._wp end do - ! Populating the cell-width distribution buffer at bc_y%end + ! the cell-width distribution buffer at bc_y%end if (bc_y%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(2, 1) elseif (bc_y%end <= BC_GHOST_EXTRAP) then @@ -2112,7 +2112,7 @@ contains end do end if - ! Populating the cell-boundary and center locations buffer at bc_y%end + ! the cell-boundary and center locations buffer at bc_y%end do i = 1, offset_y%end y_cb(n + i) = y_cb(n + (i - 1)) + dy(n + i) end do @@ -2120,11 +2120,11 @@ contains do i = 1, buff_size y_cc(n + i) = y_cc(n + (i - 1)) + (dy(n + (i - 1)) + dy(n + i))/2._wp end do - ! END: Population of Buffers in y-direction + ! Population of Buffers in y-direction - ! Population of Buffers in z-direction + ! of Buffers in z-direction - ! Populating cell-width distribution buffer at bc_z%beg + ! cell-width distribution buffer at bc_z%beg if (p == 0) then return elseif (Bc_z%beg >= 0) then @@ -2143,7 +2143,7 @@ contains end do end if - ! Computing the cell-boundary and center locations buffer at bc_z%beg + ! the cell-boundary and center locations buffer at bc_z%beg do i = 1, offset_z%beg z_cb(-1 - i) = z_cb(-i) - dz(-i) end do @@ -2152,7 +2152,7 @@ contains z_cc(-i) = z_cc(1 - i) - (dz(1 - i) + dz(-i))/2._wp end do - ! Populating the cell-width distribution buffer at bc_z%end + ! the cell-width distribution buffer at bc_z%end if (bc_z%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(3, 1) elseif (bc_z%end <= BC_GHOST_EXTRAP) then @@ -2169,7 +2169,7 @@ contains end do end if - ! Populating the cell-boundary and center locations buffer at bc_z%end + ! the cell-boundary and center locations buffer at bc_z%end do i = 1, offset_z%end z_cb(p + i) = z_cb(p + (i - 1)) + dz(p + i) end do @@ -2177,7 +2177,7 @@ contains do i = 1, buff_size z_cc(p + i) = z_cc(p + (i - 1)) + (dz(p + (i - 1)) + dz(p + i))/2._wp end do - ! END: Population of Buffers in z-direction + ! Population of Buffers in z-direction #endif diff --git a/src/common/m_checker_common.fpp b/src/common/m_checker_common.fpp index ff4af7bd20..ac83108fc4 100644 --- a/src/common/m_checker_common.fpp +++ b/src/common/m_checker_common.fpp @@ -1,12 +1,12 @@ !> -!!@file m_checker_common.f90 +!!@file !!@brief Contains module m_checker_common #:include 'case.fpp' #:include 'macros.fpp' !> @brief The purpose of the module is to check for compatible input files for. -!! inputs common to pre-processing, post-processing and simulation +!! to pre-processing, post-processing and simulation module m_checker_common use m_global_parameters !< Definitions of the global parameters @@ -24,7 +24,7 @@ module m_checker_common contains !> Checks compatibility of parameters in the input file. - !! Used by all three stages + !! all three stages impure subroutine s_check_inputs_common #ifndef MFC_SIMULATION diff --git a/src/common/m_chemistry.fpp b/src/common/m_chemistry.fpp index 69aba788db..6de98b4894 100644 --- a/src/common/m_chemistry.fpp +++ b/src/common/m_chemistry.fpp @@ -1,7 +1,7 @@ !!> -!! @file m_chemistry.f90 -!! @brief Contains module m_chemistry -!! @author Henry Le Berre +!! +!! module m_chemistry +!! Le Berre #:include 'macros.fpp' #:include 'case.fpp' @@ -50,9 +50,9 @@ contains subroutine s_compute_q_T_sf(q_T_sf, q_cons_vf, bounds) - ! Initialize the temperature field at the start of the simulation to - ! reasonable values. Temperature is computed the regular way using the - ! conservative variables. + ! the temperature field at the start of the simulation to + ! values. Temperature is computed the regular way using the + ! variables. type(scalar_field), intent(inout) :: q_T_sf type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -70,10 +70,10 @@ contains q_cons_vf(eqn)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z) end do - ! e = E - 1/2*|u|^2 - ! cons. E_idx = \rho E - ! cons. contxb = \rho (1-fluid model) - ! cons. momxb + i = \rho u_i + ! = E - 1/2*|u|^2 + ! E_idx = \rho E + ! contxb = \rho (1-fluid model) + ! momxb + i = \rho u_i energy = q_cons_vf(E_idx)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z) do eqn = momxb, momxe energy = energy - & @@ -202,17 +202,17 @@ contains if (chemistry .or. dummy) then - ! Set offsets based on direction using array indexing + ! offsets based on direction using array indexing offsets = 0 offsets(idir) = 1 - ! Model 1: Mixture-Average Transport + ! 1: Mixture-Average Transport if (chem_params%transport_model == 1) then - ! Note: Added 'i' and 'eqn' to private list. + ! Added 'i' and 'eqn' to private list. $:GPU_PARALLEL_LOOP(collapse=3, private='[x,y,z,i,eqn,Ys_L, Ys_R, Ys_cell, Xs_L, Xs_R, mass_diffusivities_mixavg1, mass_diffusivities_mixavg2, mass_diffusivities_mixavg_Cell, h_l, h_r, Xs_cell, h_k, dXk_dxi,Mass_Diffu_Flux, Mass_Diffu_Energy, MW_L, MW_R, MW_cell, Rgas_L, Rgas_R, T_L, T_R, P_L, P_R, rho_L, rho_R, rho_cell, rho_Vic, lambda_L, lambda_R, lambda_Cell, dT_dxi, grid_spacing]', copyin='[offsets]') do z = isc3%beg, isc3%end do y = isc2%beg, isc2%end do x = isc1%beg, isc1%end - ! Calculate grid spacing using direction-based indexing + ! grid spacing using direction-based indexing select case (idir) case (1) grid_spacing = x_cc(x + 1) - x_cc(x) @@ -222,7 +222,7 @@ contains grid_spacing = z_cc(z + 1) - z_cc(z) end select - ! Extract species mass fractions + ! species mass fractions $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe Ys_L(i - chemxb + 1) = q_prim_qp(i)%sf(x, y, z) @@ -230,7 +230,7 @@ contains Ys_cell(i - chemxb + 1) = 0.5_wp*(Ys_L(i - chemxb + 1) + Ys_R(i - chemxb + 1)) end do - ! Calculate molecular weights and mole fractions + ! molecular weights and mole fractions call get_mixture_molecular_weight(Ys_L, MW_L) call get_mixture_molecular_weight(Ys_R, MW_R) MW_cell = 0.5_wp*(MW_L + MW_R) @@ -238,7 +238,7 @@ contains call get_mole_fractions(MW_L, Ys_L, Xs_L) call get_mole_fractions(MW_R, Ys_R, Xs_R) - ! Calculate gas constants and thermodynamic properties + ! gas constants and thermodynamic properties Rgas_L = gas_constant/MW_L Rgas_R = gas_constant/MW_R @@ -254,7 +254,7 @@ contains rho_cell = 0.5_wp*(rho_L + rho_R) dT_dxi = (T_R - T_L)/grid_spacing - ! Get transport properties + ! transport properties call get_species_mass_diffusivities_mixavg(P_L, T_L, Ys_L, mass_diffusivities_mixavg1) call get_species_mass_diffusivities_mixavg(P_R, T_R, Ys_R, mass_diffusivities_mixavg2) @@ -264,7 +264,7 @@ contains call get_species_enthalpies_rt(T_L, h_l) call get_species_enthalpies_rt(T_R, h_r) - ! Calculate species properties and gradients + ! species properties and gradients $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe #:if USING_AMD @@ -279,7 +279,7 @@ contains dXk_dxi(i - chemxb + 1) = (Xs_R(i - chemxb + 1) - Xs_L(i - chemxb + 1))/grid_spacing end do - ! Calculate mixture-averaged diffusivities + ! mixture-averaged diffusivities $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe mass_diffusivities_mixavg_Cell(i - chemxb + 1) = & @@ -288,7 +288,7 @@ contains lambda_Cell = 0.5_wp*(lambda_R + lambda_L) - ! Calculate mass diffusion fluxes + ! mass diffusion fluxes rho_Vic = 0.0_wp Mass_Diffu_Energy = 0.0_wp @@ -305,17 +305,17 @@ contains Mass_Diffu_Energy = Mass_Diffu_Energy + h_k(eqn - chemxb + 1)*Mass_Diffu_Flux(eqn - chemxb + 1) end do - ! Apply corrections for mass conservation + ! corrections for mass conservation $:GPU_LOOP(parallelism='[seq]') do eqn = chemxb, chemxe Mass_Diffu_Energy = Mass_Diffu_Energy - h_k(eqn - chemxb + 1)*Ys_cell(eqn - chemxb + 1)*rho_Vic Mass_Diffu_Flux(eqn - chemxb + 1) = Mass_Diffu_Flux(eqn - chemxb + 1) - rho_Vic*Ys_cell(eqn - chemxb + 1) end do - ! Add thermal conduction contribution + ! thermal conduction contribution Mass_Diffu_Energy = lambda_Cell*dT_dxi + Mass_Diffu_Energy - ! Update flux arrays + ! flux arrays flux_src_vf(E_idx)%sf(x, y, z) = flux_src_vf(E_idx)%sf(x, y, z) - Mass_Diffu_Energy $:GPU_LOOP(parallelism='[seq]') @@ -327,14 +327,14 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! Model 2: Unity Lewis Number + ! 2: Unity Lewis Number else if (chem_params%transport_model == 2) then - ! Note: Added ALL scalars and 'i'/'eqn' to private list to prevent race conditions. + ! Added ALL scalars and 'i'/'eqn' to private list to prevent race conditions. $:GPU_PARALLEL_LOOP(collapse=3, private='[x,y,z,i,eqn,Ys_L, Ys_R, Ys_cell, dYk_dxi, Mass_Diffu_Flux, grid_spacing, MW_L, MW_R, MW_cell, Rgas_L, Rgas_R, P_L, P_R, rho_L, rho_R, rho_cell, T_L, T_R, Cp_L, Cp_R, hmix_L, hmix_R, dh_dxi, lambda_L, lambda_R, lambda_Cell, diffusivity_L, diffusivity_R, diffusivity_cell, Mass_Diffu_Energy]', copyin='[offsets]') do z = isc3%beg, isc3%end do y = isc2%beg, isc2%end do x = isc1%beg, isc1%end - ! Calculate grid spacing using direction-based indexing + ! grid spacing using direction-based indexing select case (idir) case (1) grid_spacing = x_cc(x + 1) - x_cc(x) @@ -344,7 +344,7 @@ contains grid_spacing = z_cc(z + 1) - z_cc(z) end select - ! Extract species mass fractions + ! species mass fractions $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe Ys_L(i - chemxb + 1) = q_prim_qp(i)%sf(x, y, z) @@ -352,12 +352,12 @@ contains Ys_cell(i - chemxb + 1) = 0.5_wp*(Ys_L(i - chemxb + 1) + Ys_R(i - chemxb + 1)) end do - ! Calculate molecular weights and mole fractions + ! molecular weights and mole fractions call get_mixture_molecular_weight(Ys_L, MW_L) call get_mixture_molecular_weight(Ys_R, MW_R) MW_cell = 0.5_wp*(MW_L + MW_R) - ! Calculate gas constants and thermodynamic properties + ! gas constants and thermodynamic properties Rgas_L = gas_constant/MW_L Rgas_R = gas_constant/MW_R @@ -378,25 +378,25 @@ contains call get_mixture_enthalpy_mass(T_R, Ys_R, hmix_R) dh_dxi = (hmix_R - hmix_L)/grid_spacing - ! Get transport properties + ! transport properties call get_mixture_thermal_conductivity_mixavg(T_L, Ys_L, lambda_L) call get_mixture_thermal_conductivity_mixavg(T_R, Ys_R, lambda_R) - ! Calculate species properties and gradients + ! species properties and gradients $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe dYk_dxi(i - chemxb + 1) = (Ys_R(i - chemxb + 1) - & Ys_L(i - chemxb + 1))/grid_spacing end do - ! Calculate mixture-averaged diffusivities + ! mixture-averaged diffusivities diffusivity_L = lambda_L/rho_L/Cp_L diffusivity_R = lambda_R/rho_R/Cp_R lambda_Cell = 0.5_wp*(lambda_R + lambda_L) diffusivity_cell = 0.5_wp*(diffusivity_R + diffusivity_L) - ! Calculate mass diffusion fluxes + ! mass diffusion fluxes Mass_Diffu_Energy = 0.0_wp $:GPU_LOOP(parallelism='[seq]') @@ -407,7 +407,7 @@ contains end do Mass_Diffu_Energy = rho_cell*diffusivity_cell*dh_dxi - ! Update flux arrays + ! flux arrays flux_src_vf(E_idx)%sf(x, y, z) = flux_src_vf(E_idx)%sf(x, y, z) - Mass_Diffu_Energy $:GPU_LOOP(parallelism='[seq]') diff --git a/src/common/m_compute_levelset.fpp b/src/common/m_compute_levelset.fpp index 7473c19deb..d6f5dbd643 100644 --- a/src/common/m_compute_levelset.fpp +++ b/src/common/m_compute_levelset.fpp @@ -1,11 +1,11 @@ !> -!! @file m_compute_levelset.fpp -!! @brief Contains module m_compute_levelset +!! +!! module m_compute_levelset #:include 'macros.fpp' !> @brief This module is used to handle all operations related to immersed -!! boundary methods (IBMs) +!! (IBMs) module m_compute_levelset use m_derived_types !< Definitions of the derived types @@ -97,7 +97,7 @@ contains xy_local = xy_local - patch_ib(ib_patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset if (xy_local(2) >= 0._wp) then - ! finds the location on the airfoil grid with the minimum distance (closest) + ! the location on the airfoil grid with the minimum distance (closest) do k = 1, Np dist_vec(1) = xy_local(1) - airfoil_grid_u(k)%x dist_vec(2) = xy_local(2) - airfoil_grid_u(k)%y @@ -118,7 +118,7 @@ contains dist_vec(3) = 0 dist = global_dist else - ! TODO :: This looks identical to the above code but using the lower array. Refactor this. + ! :: This looks identical to the above code but using the lower array. Refactor this. do k = 1, Np dist_vec(1) = xy_local(1) - airfoil_grid_l(k)%x dist_vec(2) = xy_local(2) - airfoil_grid_l(k)%y @@ -321,13 +321,13 @@ contains dist_vec = 0._wp if (.not. f_approx_equal(side_dists(idx), 0._wp)) then if (idx == 1 .or. idx == 2) then - ! vector points along the x axis + ! points along the x axis dist_vec(1) = side_dists(idx)/abs(side_dists(idx)) else - ! vector points along the y axis + ! points along the y axis dist_vec(2) = side_dists(idx)/abs(side_dists(idx)) end if - ! convert the normal vector back into the global coordinate system + ! the normal vector back into the global coordinate system levelset_norm%sf(i, j, 0, ib_patch_id, :) = matmul(rotation, dist_vec) else levelset_norm%sf(i, j, 0, ib_patch_id, :) = 0._wp @@ -373,7 +373,7 @@ contains xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) - ! we will get NaNs in the levelset if we compute this outside the ellipse + ! will get NaNs in the levelset if we compute this outside the ellipse if ((xy_local(1)/ellipse_coeffs(1))**2 + (xy_local(2)/ellipse_coeffs(2))**2 <= 1._wp) then normal_vector = xy_local @@ -381,12 +381,12 @@ contains normal_vector = normal_vector/sqrt(dot_product(normal_vector, normal_vector)) ! normalize the vector levelset_norm%sf(i, j, 0, ib_patch_id, :) = matmul(rotation, normal_vector) ! save after rotating the vector to the global frame - ! use the normal vector to set up the quadratic equation for the levelset, using A, B, and C in indices 1, 2, and 3 + ! the normal vector to set up the quadratic equation for the levelset, using A, B, and C in indices 1, 2, and 3 quadratic_coeffs(1) = (normal_vector(1)/ellipse_coeffs(1))**2 + (normal_vector(2)/ellipse_coeffs(2))**2 quadratic_coeffs(2) = 2._wp*((xy_local(1)*normal_vector(1)/(ellipse_coeffs(1)**2)) + (xy_local(2)*normal_vector(2)/(ellipse_coeffs(2)**2))) quadratic_coeffs(3) = (xy_local(1)/ellipse_coeffs(1))**2._wp + (xy_local(2)/ellipse_coeffs(2))**2._wp - 1._wp - ! compute the levelset with the quadratic equation [ -B + sqrt(B^2 - 4AC) ] / 2A + ! the levelset with the quadratic equation [ -B + sqrt(B^2 - 4AC) ] / 2A levelset%sf(i, j, 0, ib_patch_id) = -0.5_wp*(-quadratic_coeffs(2) + sqrt(quadratic_coeffs(2)**2._wp - 4._wp*quadratic_coeffs(1)*quadratic_coeffs(3)))/quadratic_coeffs(1) end if end do @@ -451,13 +451,13 @@ contains side_dists(6) = xyz_local(3) - Front min_dist = minval(abs(side_dists)) - ! TODO :: The way that this is written, it looks like we will - ! trigger at the first size that is close to the minimum distance, - ! meaning corners where side_dists are the same will - ! trigger on what may not actually be the minimum, - ! leading to undesired behavior. This should be resolved - ! and this code should be cleaned up. It also means that - ! rotating the box 90 degrees will cause tests to fail. + ! :: The way that this is written, it looks like we will + ! at the first size that is close to the minimum distance, + ! corners where side_dists are the same will + ! on what may not actually be the minimum, + ! to undesired behavior. This should be resolved + ! this code should be cleaned up. It also means that + ! the box 90 degrees will cause tests to fail. dist_vec = 0._wp if (f_approx_equal(min_dist, abs(side_dists(1)))) then levelset%sf(i, j, k, ib_patch_id) = side_dists(1) @@ -593,16 +593,16 @@ contains xyz_local = [x_cc(i), y_cc(j), z_cc(k)] - center ! get coordinate frame centered on IB xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates - ! get distance to flat edge of cylinder + ! distance to flat edge of cylinder side_pos = dot_product(xyz_local, dist_sides_vec) dist_side = min(abs(side_pos - boundary(1)), & abs(boundary(2) - side_pos)) - ! get distance to curved side of cylinder + ! distance to curved side of cylinder dist_surface = norm2(xyz_local*dist_surface_vec) & - radius if (dist_side < abs(dist_surface)) then - ! if the closest edge is flat + ! the closest edge is flat levelset%sf(i, j, k, ib_patch_id) = -dist_side if (f_approx_equal(dist_side, abs(side_pos - boundary(1)))) then levelset_norm%sf(i, j, k, ib_patch_id, :) = matmul(rotation, -dist_sides_vec) diff --git a/src/common/m_constants.fpp b/src/common/m_constants.fpp index b4d5982aa5..e33d4c977e 100644 --- a/src/common/m_constants.fpp +++ b/src/common/m_constants.fpp @@ -1,6 +1,6 @@ !> -!! @file m_constants.f90 -!! @brief Contains constant values used throughout the code(s). +!! +!! constant values used throughout the code(s). module m_constants @@ -36,19 +36,19 @@ module m_constants real(wp), parameter :: broadband_spectral_level_constant = 20._wp !< The constant to scale the spectral level at the lower frequency bound real(wp), parameter :: broadband_spectral_level_growth_rate = 10._wp !< The spectral level constant to correct the magnitude at each frequency to ensure the source is overall broadband - ! Reconstruction Types + ! Types integer, parameter :: WENO_TYPE = 1 !< Using WENO for reconstruction type integer, parameter :: MUSCL_TYPE = 2 !< Using MUSCL for reconstruction type - ! Interface Compression + ! Compression real(wp), parameter :: dflt_ic_eps = 1e-4_wp !< Ensure compression is only applied to surface cells in THINC real(wp), parameter :: dflt_ic_beta = 1.6_wp !< Sharpness parameter's default value used in THINC integer, parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC - ! Chemistry + ! real(wp), parameter :: dflt_T_guess = 1200._wp ! Default guess for temperature (when a previous value is not available) - ! IBM+STL interpolation constants + ! interpolation constants integer, parameter :: Ifactor_2D = 50 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 2D models integer, parameter :: Ifactor_3D = 5 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 3D models integer, parameter :: Ifactor_bary_3D = 20 !< Multiple factor of the ratio (triangle area to cell face area) for interpolation on triangle facets for 3D models @@ -59,44 +59,44 @@ module m_constants real(wp), parameter :: threshold_bary = 1.e-1_wp !< Threshold to interpolate a barycentric facet real(wp), parameter :: initial_distance_buffer = 1.e12_wp !< Initialized levelset distance for the shortest path pair algorithm - ! Lagrange bubbles constants + ! bubbles constants integer, parameter :: mapCells = 3 !< Number of cells around the bubble where the smoothening function will have effect real(wp), parameter :: R_uni = 8314._wp !< Universal gas constant - J/kmol/K integer, parameter :: lag_io_vars = 21 ! Number of variables per particle for MPI_IO - ! Strang Splitting constants + ! Splitting constants real(wp), parameter :: dflt_adap_dt_tol = 1.e-4_wp !< Default tolerance for adaptive step size integer, parameter :: dflt_adap_dt_max_iters = 100 !< Default max iteration for adaptive step size - ! Constants of the algorithm described by Heirer, E. Hairer, S. P.Nørsett, G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4 - ! to choose the initial time step size for the adaptive time stepping routine + ! of the algorithm described by Heirer, E. Hairer, S. P.Nørsett, G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4 + ! choose the initial time step size for the adaptive time stepping routine real(wp), parameter :: threshold_first_guess = 1.e-5_wp real(wp), parameter :: threshold_second_guess = 1.e-15_wp real(wp), parameter :: scale_first_guess = 1.e-3_wp real(wp), parameter :: scale_guess = 1.e-2_wp real(wp), parameter :: small_guess = 1.e-6_wp - ! Relativity + ! integer, parameter :: relativity_cons_to_prim_max_iter = 100 - ! Pseudo-random number generator + ! number generator integer, parameter :: modulus = 2**30 - 1 integer, parameter :: multiplier = 1664525 integer, parameter :: increment = 1013904223 integer, parameter :: amplifier = 3**13 real(wp), parameter :: decimal_trim = 1.e5_wp - ! System constants + ! constants integer, parameter :: CASE_FILE_ERROR_CODE = 22 - ! Boundary condition enumeration - ! Abbreviations - ! CHAR - Characteristic - ! NR - Non-reflecting - ! SUB - subsonic - ! SUP - supersonic - ! FF - Force-free - ! CP - Constant pressure + ! condition enumeration + ! + ! - Characteristic + ! - Non-reflecting + ! - subsonic + ! - supersonic + ! - Force-free + ! - Constant pressure integer, parameter :: BC_PERIODIC = -1 integer, parameter :: BC_REFLECTIVE = -2 integer, parameter :: BC_GHOST_EXTRAP = -3 diff --git a/src/common/m_derived_types.fpp b/src/common/m_derived_types.fpp index 5c36a7ae11..c88dfa20d2 100644 --- a/src/common/m_derived_types.fpp +++ b/src/common/m_derived_types.fpp @@ -1,11 +1,11 @@ !> -!! @file m_derived_types.f90 -!! @brief Contains module m_derived_types +!! +!! module m_derived_types #:include "macros.fpp" !> @brief This file contains the definitions of all of the custom-defined -!! types used in the pre-process code. +!! in the pre-process code. module m_derived_types use m_constants !< Constants @@ -75,7 +75,7 @@ module m_derived_types end type vector_field !> Generic 3-component vector (e.g., spatial coordinates or field components) - !! Named _dt (derived types: x,y,z) to differentiate from t_vec3 (3-component vector) + !! (derived types: x,y,z) to differentiate from t_vec3 (3-component vector) type vec3_dt ! dt for derived types real(wp) :: x real(wp) :: y @@ -143,23 +143,23 @@ module m_derived_types !> Defines parameters for a Model Patch type ic_model_parameters character(LEN=pathlen_max) :: filepath !< - !! Path the STL file relative to case_dir. + !! STL file relative to case_dir. real(wp), dimension(1:3) :: translate !< - !! Translation of the STL object. + !! the STL object. real(wp), dimension(1:3) :: scale !< - !! Scale factor for the STL object. + !! for the STL object. real(wp), dimension(1:3) :: rotate !< - !! Angle to rotate the STL object along each cartesian coordinate axis, - !! in radians. + !! rotate the STL object along each cartesian coordinate axis, + !! integer :: spc !< - !! Number of samples per cell to use when discretizing the STL object. + !! samples per cell to use when discretizing the STL object. real(wp) :: threshold !< - !! Threshold to turn on smoothen STL patch. + !! turn on smoothen STL patch. end type ic_model_parameters type :: t_triangle @@ -183,54 +183,54 @@ module m_derived_types end type t_model !> Derived type adding initial condition (ic) patch parameters as attributes - !! NOTE: The requirements for the specification of the above parameters - !! are strongly dependent on both the choice of the multicomponent flow - !! model as well as the choice of the patch geometry. + !! requirements for the specification of the above parameters + !! dependent on both the choice of the multicomponent flow + !! well as the choice of the patch geometry. type ic_patch_parameters integer :: geometry !< Type of geometry for the patch real(wp) :: x_centroid, y_centroid, z_centroid !< - !! Location of the geometric center, i.e. the centroid, of the patch. It - !! is specified through its x-, y- and z-coordinates, respectively. + !! the geometric center, i.e. the centroid, of the patch. It + !! through its x-, y- and z-coordinates, respectively. real(wp) :: length_x, length_y, length_z !< Dimensions of the patch. x,y,z Lengths. real(wp) :: radius !< Dimensions of the patch. radius. real(wp), dimension(3) :: radii !< - !! Vector indicating the various radii for the elliptical and ellipsoidal - !! patch geometries. It is specified through its x-, y-, and z-components - !! respectively. + !! the various radii for the elliptical and ellipsoidal + !! It is specified through its x-, y-, and z-components + !! real(wp) :: epsilon, beta !< - !! The isentropic vortex parameters for the amplitude of the disturbance and - !! domain of influence. + !! vortex parameters for the amplitude of the disturbance and + !! influence. real(wp), dimension(2:9) :: a !< - !! The parameters needed for the spherical harmonic patch + !! needed for the spherical harmonic patch logical :: non_axis_sym real(wp), dimension(3) :: normal !< - !! Normal vector indicating the orientation of the patch. It is specified - !! through its x-, y- and z-components, respectively. + !! indicating the orientation of the patch. It is specified + !! x-, y- and z-components, respectively. logical, dimension(0:num_patches_max - 1) :: alter_patch !< - !! List of permissions that indicate to the current patch which preceding - !! patches it is allowed to overwrite when it is in process of being laid - !! out in the domain + !! permissions that indicate to the current patch which preceding + !! is allowed to overwrite when it is in process of being laid + !! the domain logical :: smoothen !< - !! Permission indicating to the current patch whether its boundaries will - !! be smoothed out across a few cells or whether they are to remain sharp + !! to the current patch whether its boundaries will + !! out across a few cells or whether they are to remain sharp integer :: smooth_patch_id !< - !! Identity (id) of the patch with which current patch is to get smoothed + !! of the patch with which current patch is to get smoothed real(wp) :: smooth_coeff !< - !! Smoothing coefficient (coeff) for the size of the stencil of - !! cells across which boundaries of the current patch will be smeared out + !! (coeff) for the size of the stencil of + !! which boundaries of the current patch will be smeared out real(wp), dimension(num_fluids_max) :: alpha_rho real(wp) :: rho @@ -243,15 +243,15 @@ module m_derived_types real(wp) :: qv !< real(wp) :: qvp !< - !! Primitive variables associated with the patch. In order, these include - !! the partial densities, density, velocity, pressure, volume fractions, - !! specific heat ratio function and the liquid stiffness function. + !! associated with the patch. In order, these include + !! densities, density, velocity, pressure, volume fractions, + !! ratio function and the liquid stiffness function. real(wp) :: Bx, By, Bz !< - !! Magnetic field components; B%x is not used for 1D + !! components; B%x is not used for 1D real(wp), dimension(6) :: tau_e !< - !! Elastic stresses added to primitive variables if hypoelasticity = True + !! added to primitive variables if hypoelasticity = True real(wp) :: R0 !< Bubble size real(wp) :: V0 !< Bubble velocity @@ -260,30 +260,30 @@ module m_derived_types real(wp) :: m0 !< Bubble velocity integer :: hcid - !! id for hard coded initial condition + !! hard coded initial condition real(wp) :: cf_val !! color function value real(wp) :: Y(1:num_species) - !! STL or OBJ model input parameter + !! OBJ model input parameter character(LEN=pathlen_max) :: model_filepath !< - !! Path the STL file relative to case_dir. + !! STL file relative to case_dir. real(wp), dimension(1:3) :: model_translate !< - !! Translation of the STL object. + !! the STL object. real(wp), dimension(1:3) :: model_scale !< - !! Scale factor for the STL object. + !! for the STL object. real(wp), dimension(1:3) :: model_rotate !< - !! Angle to rotate the STL object along each cartesian coordinate axis, - !! in radians. + !! rotate the STL object along each cartesian coordinate axis, + !! integer :: model_spc !< - !! Number of samples per cell to use when discretizing the STL object. + !! samples per cell to use when discretizing the STL object. real(wp) :: model_threshold !< - !! Threshold to turn on smoothen STL patch. + !! turn on smoothen STL patch. end type ic_patch_parameters @@ -292,10 +292,10 @@ module m_derived_types integer :: geometry !< Type of geometry for the patch real(wp) :: x_centroid, y_centroid, z_centroid !< - !! Location of the geometric center, i.e. the centroid, of the patch. It - !! is specified through its x-, y- and z-coordinates, respectively. + !! the geometric center, i.e. the centroid, of the patch. It + !! through its x-, y- and z-coordinates, respectively. real(wp) :: step_x_centroid, step_y_centroid, step_z_centroid !< - !! Centroid locations of intermediate steps in the time_stepper module + !! of intermediate steps in the time_stepper module real(wp), dimension(1:3) :: centroid_offset ! offset of center of mass from computed cell center for odd-shaped IBs real(wp), dimension(1:3) :: angles @@ -311,27 +311,27 @@ module m_derived_types logical :: slip - !! STL or OBJ model input parameter + !! OBJ model input parameter character(LEN=pathlen_max) :: model_filepath !< - !! Path the STL file relative to case_dir. + !! STL file relative to case_dir. real(wp), dimension(1:3) :: model_translate !< - !! Translation of the STL object. + !! the STL object. real(wp), dimension(1:3) :: model_scale !< - !! Scale factor for the STL object. + !! for the STL object. real(wp), dimension(1:3) :: model_rotate !< - !! Angle to rotate the STL object along each cartesian coordinate axis, - !! in radians. + !! rotate the STL object along each cartesian coordinate axis, + !! integer :: model_spc !< - !! Number of samples per cell to use when discretizing the STL object. + !! samples per cell to use when discretizing the STL object. real(wp) :: model_threshold !< - !! Threshold to turn on smoothen STL patch. + !! turn on smoothen STL patch. - !! Patch conditions for moving imersed boundaries + !! for moving imersed boundaries integer :: moving_ibm ! 0 for no moving, 1 for moving, 2 for moving on forced path real(wp) :: mass, moment ! mass and moment of inertia of object used to compute forces in 2-way coupling real(wp), dimension(1:3) :: force, torque ! vectors for the computed force and torque values applied to an IB @@ -343,7 +343,7 @@ module m_derived_types end type ib_patch_parameters !> Derived type annexing the physical parameters (PP) of the fluids. These - !! include the specific heat ratio function and liquid stiffness function. + !! specific heat ratio function and liquid stiffness function. type physical_parameters real(wp) :: gamma !< Sp. heat ratio real(wp) :: pi_inf !< Liquid stiffness diff --git a/src/common/m_finite_differences.fpp b/src/common/m_finite_differences.fpp index f85d46944b..b3b23cd70e 100644 --- a/src/common/m_finite_differences.fpp +++ b/src/common/m_finite_differences.fpp @@ -61,15 +61,15 @@ contains end subroutine s_compute_fd_divergence !> The purpose of this subroutine is to compute the finite- - !! difference coefficients for the centered schemes utilized - !! in computations of first order spatial derivatives in the - !! s-coordinate direction. The s-coordinate direction refers - !! to the x-, y- or z-coordinate direction, depending on the - !! subroutine's inputs. Note that coefficients of up to 4th - !! order accuracy are available. - !! @param q Number of cells in the s-coordinate direction - !! @param s_cc Locations of the cell-centers in the s-coordinate direction - !! @param fd_coeff_s Finite-diff. coefficients in the s-coordinate direction + !! for the centered schemes utilized + !! of first order spatial derivatives in the + !! The s-coordinate direction refers + !! x-, y- or z-coordinate direction, depending on the + !! Note that coefficients of up to 4th + !! are available. + !! Number of cells in the s-coordinate direction + !! Locations of the cell-centers in the s-coordinate direction + !! Finite-diff. coefficients in the s-coordinate direction subroutine s_compute_finite_difference_coefficients(q, s_cc, fd_coeff_s, local_buff_size, & fd_number_in, fd_order_in, offset_s) @@ -98,7 +98,7 @@ contains allocate (fd_coeff_s(-fd_number_in:fd_number_in, lb:lE)) #endif - ! Computing the 1st order finite-difference coefficients + ! the 1st order finite-difference coefficients if (fd_order_in == 1) then do i = lB, lE fd_coeff_s(-1, i) = 0._wp @@ -106,7 +106,7 @@ contains fd_coeff_s(1, i) = -fd_coeff_s(0, i) end do - ! Computing the 2nd order finite-difference coefficients + ! the 2nd order finite-difference coefficients elseif (fd_order_in == 2) then do i = lB, lE fd_coeff_s(-1, i) = -1._wp/(s_cc(i + 1) - s_cc(i - 1)) @@ -114,7 +114,7 @@ contains fd_coeff_s(1, i) = -fd_coeff_s(-1, i) end do - ! Computing the 4th order finite-difference coefficients + ! the 4th order finite-difference coefficients else do i = lB, lE fd_coeff_s(-2, i) = 1._wp/(s_cc(i - 2) - 8._wp*s_cc(i - 1) - s_cc(i + 2) + 8._wp*s_cc(i + 1)) diff --git a/src/common/m_helper.fpp b/src/common/m_helper.fpp index 5ee39f7aab..12ac552429 100644 --- a/src/common/m_helper.fpp +++ b/src/common/m_helper.fpp @@ -2,8 +2,8 @@ #:include 'macros.fpp' !> -!! @file m_helper.f90 -!! @brief Contains module m_helper +!! +!! module m_helper module m_helper @@ -46,9 +46,9 @@ module m_helper contains !> Computes the bubble number density n from the primitive variables - !! @param vftmp is the void fraction - !! @param Rtmp is the bubble radii - !! @param ntmp is the output number bubble density + !! is the void fraction + !! is the bubble radii + !! is the output number bubble density subroutine s_comp_n_from_prim(vftmp, Rtmp, ntmp, weights) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: vftmp @@ -108,12 +108,12 @@ contains end subroutine s_print_2D_array !> - !! bubbles_euler + polytropic - !! bubbles_euler + non-polytropic - !! bubbles_lagrange + non-polytropic + !! polytropic + !! non-polytropic + !! non-polytropic impure subroutine s_initialize_bubbles_model() - ! Allocate memory + ! memory if (bubbles_euler) then @:ALLOCATE(weight(nb), R0(nb)) if (.not. polytropic) then @@ -123,7 +123,7 @@ contains @:ALLOCATE(pb0(nb)) end if - ! Compute quadrature weights and nodes for polydisperse simulations + ! quadrature weights and nodes for polydisperse simulations if (nb > 1) then call s_simpson(weight, R0) else if (nb == 1) then @@ -135,7 +135,7 @@ contains R0 = R0*bub_pp%R0ref end if - ! Initialize bubble variables + ! bubble variables call s_initialize_bubble_vars() end subroutine s_initialize_bubbles_model @@ -161,7 +161,7 @@ contains k_vl = bub_pp%k_v; k_gl = bub_pp%k_g end if - ! Input quantities + ! quantities if (bubbles_euler .and. (.not. polytropic)) then if (thermal == 2) then gam_m = 1._wp @@ -170,7 +170,7 @@ contains end if end if - ! Nondimensional numbers + ! numbers Eu = p0ref Ca = Eu - pv if (.not. f_is_default(bub_pp%ss)) Web = 1._wp/ss @@ -178,11 +178,11 @@ contains if (.not. polytropic) Pe_c = 1._wp/vd if (bubbles_euler) then - ! Initialize variables for non-polytropic (Preston) model + ! variables for non-polytropic (Preston) model if (.not. polytropic) then call s_initialize_nonpoly() end if - ! Initialize pb based on surface tension for qbmm (polytropic) + ! pb based on surface tension for qbmm (polytropic) if (qbmm .and. polytropic) then pb0 = Eu if (.not. f_is_default(Web)) then @@ -199,44 +199,44 @@ contains real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN, rhol0 real(wp), parameter :: k_poly = 1._wp !< - !! polytropic index used to compute isothermal natural frequency + !! used to compute isothermal natural frequency - ! phi_vg & phi_gv (phi_gg = phi_vv = 1) (Eq. 2.22 in Ando 2010) + ! & phi_gv (phi_gg = phi_vv = 1) (Eq. 2.22 in Ando 2010) phi_vg = (1._wp + sqrt(mu_v/mu_g)*(M_g/M_v)**(0.25_wp))**2 & /(sqrt(8._wp)*sqrt(1._wp + M_v/M_g)) phi_gv = (1._wp + sqrt(mu_g/mu_v)*(M_v/M_g)**(0.25_wp))**2 & /(sqrt(8._wp)*sqrt(1._wp + M_g/M_v)) - ! internal bubble pressure + ! bubble pressure pb0 = Eu + 2._wp/Web/R0 - ! mass fraction of vapor (Eq. 2.19 in Ando 2010) + ! fraction of vapor (Eq. 2.19 in Ando 2010) chi_vw0 = 1._wp/(1._wp + R_v/R_g*(pb0/pv - 1._wp)) - ! specific heat for gas/vapor mixture + ! heat for gas/vapor mixture cp_m0 = chi_vw0*R_v*gam_v/(gam_v - 1._wp) & + (1._wp - chi_vw0)*R_g*gam_g/(gam_g - 1._wp) - ! mole fraction of vapor (Eq. 2.23 in Ando 2010) + ! fraction of vapor (Eq. 2.23 in Ando 2010) x_vw = M_g*chi_vw0/(M_v + (M_g - M_v)*chi_vw0) - ! thermal conductivity for gas/vapor mixture (Eq. 2.21 in Ando 2010) + ! conductivity for gas/vapor mixture (Eq. 2.21 in Ando 2010) k_m0 = x_vw*k_v/(x_vw + (1._wp - x_vw)*phi_vg) & + (1._wp - x_vw)*k_g/(x_vw*phi_gv + 1._wp - x_vw) k_g(:) = k_g(:)/k_m0(:) k_v(:) = k_v(:)/k_m0(:) - ! mixture density (Eq. 2.20 in Ando 2010) + ! density (Eq. 2.20 in Ando 2010) rho_m0 = pv/(chi_vw0*R_v*Tw) - ! mass of gas/vapor + ! of gas/vapor mass_g0(:) = (4._wp*pi/3._wp)*(pb0(:) - pv)/(R_g*Tw)*R0(:)**3 mass_v0(:) = (4._wp*pi/3._wp)*pv/(R_v*Tw)*R0(:)**3 - ! Peclet numbers + ! numbers Pe_T(:) = rho_m0*cp_m0(:)/k_m0(:) - ! natural frequencies (Eq. B.1) + ! frequencies (Eq. B.1) omegaN(:) = sqrt(3._wp*k_poly*Ca + 2._wp*(3._wp*k_poly - 1._wp)/(Web*R0))/R0/sqrt(rho0ref) do ir = 1, nb call s_transcoeff(omegaN(ir)*R0(ir), Pe_T(ir)*R0(ir), & @@ -249,10 +249,10 @@ contains end subroutine s_initialize_nonpoly !> Computes the transfer coefficient for the non-polytropic bubble compression process - !! @param omega natural frequencies - !! @param peclet Peclet number - !! @param Re_trans Real part of the transport coefficients - !! @param Im_trans Imaginary part of the transport coefficients + !! natural frequencies + !! Peclet number + !! Real part of the transport coefficients + !! Imaginary part of the transport coefficients elemental subroutine s_transcoeff(omega, peclet, Re_trans, Im_trans) real(wp), intent(in) :: omega, peclet @@ -294,7 +294,7 @@ contains R0mn = 0.8_wp*exp(-2.8_wp*sd) R0mx = 0.2_wp*exp(9.5_wp*sd) + 1._wp - ! phi = ln( R0 ) & return R0 + ! = ln( R0 ) & return R0 do ir = 1, nb phi(ir) = log(R0mn) & + (ir - 1._wp)*log(R0mx/R0mn)/(nb - 1._wp) @@ -305,9 +305,9 @@ contains dphi = phi(2) - phi(1) #:endif - ! weights for quadrature using Simpson's rule + ! for quadrature using Simpson's rule do ir = 2, nb - 1 - ! Gaussian + ! tmp = exp(-0.5_wp*(phi(ir)/sd)**2)/sqrt(2._wp*pi)/sd if (mod(ir, 2) == 0) then local_weight(ir) = tmp*4._wp*dphi/3._wp @@ -323,9 +323,9 @@ contains end subroutine s_simpson !> This procedure computes the cross product of two vectors. - !! @param a First vector. - !! @param b Second vector. - !! @return The cross product of the two vectors. + !! First vector. + !! Second vector. + !! cross product of the two vectors. pure function f_cross(a, b) result(c) real(wp), dimension(3), intent(in) :: a, b @@ -337,8 +337,8 @@ contains end function f_cross !> This procedure swaps two real numbers. - !! @param lhs Left-hand side. - !! @param rhs Right-hand side. + !! Left-hand side. + !! Right-hand side. elemental subroutine s_swap(lhs, rhs) real(wp), intent(inout) :: lhs, rhs @@ -350,8 +350,8 @@ contains end subroutine s_swap !> This procedure creates a transformation matrix. - !! @param p Parameters for the transformation. - !! @return Transformation matrix. + !! Parameters for the transformation. + !! matrix. function f_create_transform_matrix(param, center) result(out_matrix) type(ic_model_parameters), intent(in) :: param @@ -389,14 +389,14 @@ contains 0._wp, 0._wp, 0._wp, 1._wp], shape(tr))) if (present(center)) then - ! Translation matrix to move center to the origin + ! matrix to move center to the origin t_to_origin = transpose(reshape([ & 1._wp, 0._wp, 0._wp, -center(1), & 0._wp, 1._wp, 0._wp, -center(2), & 0._wp, 0._wp, 1._wp, -center(3), & 0._wp, 0._wp, 0._wp, 1._wp], shape(tr))) - ! Translation matrix to move center back to original position + ! matrix to move center back to original position t_back = transpose(reshape([ & 1._wp, 0._wp, 0._wp, center(1), & 0._wp, 1._wp, 0._wp, center(2), & @@ -411,8 +411,8 @@ contains end function f_create_transform_matrix !> This procedure transforms a vector by a matrix. - !! @param vec Vector to transform. - !! @param matrix Transformation matrix. + !! Vector to transform. + !! Transformation matrix. subroutine s_transform_vec(vec, matrix) real(wp), dimension(1:3), intent(inout) :: vec @@ -426,8 +426,8 @@ contains end subroutine s_transform_vec !> This procedure transforms a triangle by a matrix, one vertex at a time. - !! @param triangle Triangle to transform. - !! @param matrix Transformation matrix. + !! Triangle to transform. + !! Transformation matrix. subroutine s_transform_triangle(triangle, matrix, matrix_n) type(t_triangle), intent(inout) :: triangle @@ -444,8 +444,8 @@ contains end subroutine s_transform_triangle !> This procedure transforms a model by a matrix, one triangle at a time. - !! @param model Model to transform. - !! @param matrix Transformation matrix. + !! Model to transform. + !! Transformation matrix. subroutine s_transform_model(model, matrix, matrix_n) type(t_model), intent(inout) :: model @@ -460,8 +460,8 @@ contains end subroutine s_transform_model !> This procedure creates a bounding box for a model. - !! @param model Model to create bounding box for. - !! @return Bounding box. + !! Model to create bounding box for. + !! box. function f_create_bbox(model) result(bbox) type(t_model), intent(in) :: model @@ -488,9 +488,9 @@ contains end function f_create_bbox !> This procedure performs xor on lhs and rhs. - !! @param lhs logical input. - !! @param rhs other logical input. - !! @return xored result. + !! logical input. + !! other logical input. + !! result. elemental function f_xor(lhs, rhs) result(res) logical, intent(in) :: lhs, rhs @@ -500,8 +500,8 @@ contains end function f_xor !> This procedure converts logical to 1 or 0. - !! @param perdicate A Logical argument. - !! @return 1 if .true., 0 if .false.. + !! A Logical argument. + !! if .true., 0 if .false.. elemental function f_logical_to_int(predicate) result(int) logical, intent(in) :: predicate @@ -515,9 +515,9 @@ contains end function f_logical_to_int !> This function generates the unassociated legendre poynomials - !! @param x is the input value - !! @param l is the degree - !! @return P is the unassociated legendre polynomial evaluated at x + !! is the input value + !! is the degree + !! is the unassociated legendre polynomial evaluated at x recursive function unassociated_legendre(x, l) result(result_P) integer, intent(in) :: l @@ -535,11 +535,11 @@ contains end function unassociated_legendre !> This function calculates the spherical harmonic function evaluated at x and phi - !! @param x is the x coordinate - !! @param phi is the phi coordinate - !! @param l is the degree - !! @param m_order is the order - !! @return Y is the spherical harmonic function evaluated at x and phi + !! is the x coordinate + !! is the phi coordinate + !! is the degree + !! is the order + !! is the spherical harmonic function evaluated at x and phi recursive function spherical_harmonic_func(x, phi, l, m_order) result(Y) integer, intent(in) :: l, m_order @@ -557,11 +557,11 @@ contains end function spherical_harmonic_func !> This function generates the associated legendre polynomials evaluated - !! at x with inputs l and m - !! @param x is the input value - !! @param l is the degree - !! @param m_order is the order - !! @return P is the associated legendre polynomial evaluated at x + !! with inputs l and m + !! is the input value + !! is the degree + !! is the order + !! is the associated legendre polynomial evaluated at x recursive function associated_legendre(x, l, m_order) result(result_P) integer, intent(in) :: l, m_order @@ -585,8 +585,8 @@ contains end function associated_legendre !> This function calculates the double factorial value of an integer - !! @param n_in is the input integer - !! @return R is the double factorial value of n + !! is the input integer + !! is the double factorial value of n elemental function double_factorial(n_in) result(R_result) integer, intent(in) :: n_in @@ -599,8 +599,8 @@ contains end function double_factorial !> The following function calculates the factorial value of an integer - !! @param n_in is the input integer - !! @return R is the factorial value of n + !! is the input integer + !! is the factorial value of n elemental function factorial(n_in) result(R_result) integer, intent(in) :: n_in @@ -614,11 +614,11 @@ contains end function factorial !> This function calculates a smooth cut-on function that is zero for x values - !! smaller than zero and goes to one. It can be used for generating smooth - !! initial conditions - !! @param x is the input value - !! @param eps is the smoothing parameter - !! @return fx is the cut-on function evaluated at x + !! zero and goes to one. It can be used for generating smooth + !! + !! is the input value + !! is the smoothing parameter + !! is the cut-on function evaluated at x function f_cut_on(x, eps) result(fx) real(wp), intent(in) :: x, eps @@ -629,11 +629,11 @@ contains end function f_cut_on !> This function calculates a smooth cut-off function that is one for x values - !! smaller than zero and goes to zero. It can be used for generating smooth - !! initial conditions - !! @param x is the input value - !! @param eps is the smoothing parameter - !! @return fx is the cut-ff function evaluated at x + !! zero and goes to zero. It can be used for generating smooth + !! + !! is the input value + !! is the smoothing parameter + !! is the cut-ff function evaluated at x function f_cut_off(x, eps) result(fx) real(wp), intent(in) :: x, eps @@ -644,8 +644,8 @@ contains end function f_cut_off !> This function is a helper function for the functions f_cut_on and f_cut_off - !! @param x is the input value - !! @return gx is the result + !! is the input value + !! is the result function f_gx(x) result(gx) real(wp), intent(in) :: x @@ -663,7 +663,7 @@ contains type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf, q_cons_temp - ! Down sampling variables + ! sampling variables integer :: i, j, k, l integer :: ix, iy, iz, x_id, y_id, z_id integer, intent(inout) :: m_ds, n_ds, p_ds, m_glb_ds, n_glb_ds, p_glb_ds diff --git a/src/common/m_helper_basic.fpp b/src/common/m_helper_basic.fpp index eca8c3ccb7..895f13b899 100644 --- a/src/common/m_helper_basic.fpp +++ b/src/common/m_helper_basic.fpp @@ -1,6 +1,6 @@ -!! @file m_helper_basic.f90 -!! @brief Contains module m_helper_basic +!! +!! module m_helper_basic #:include 'macros.fpp' @@ -22,10 +22,10 @@ module m_helper_basic contains !> This procedure checks if two floating point numbers of wp are within tolerance. - !! @param a First number. - !! @param b Second number. - !! @param tol_input Relative error (default = 1.e-10_wp). - !! @return Result of the comparison. + !! First number. + !! Second number. + !! Relative error (default = 1.e-10_wp). + !! of the comparison. logical elemental function f_approx_equal(a, b, tol_input) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: a, b @@ -48,10 +48,10 @@ contains end function f_approx_equal !> This procedure checks if the point numbers of wp belongs to another array are within tolerance. - !! @param a First number. - !! @param b Array that contains several point numbers. - !! @param tol_input Relative error (default = 1e-10_wp). - !! @return Result of the comparison. + !! First number. + !! Array that contains several point numbers. + !! Relative error (default = 1e-10_wp). + !! of the comparison. logical function f_approx_in_array(a, b, tol_input) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: a @@ -77,7 +77,7 @@ contains end function f_approx_in_array !> Checks if a real(wp) variable is of default value. - !! @param var Variable to check. + !! Variable to check. logical elemental function f_is_default(var) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: var @@ -86,7 +86,7 @@ contains end function f_is_default !> Checks if ALL elements of a real(wp) array are of default value. - !! @param var_array Array to check. + !! Array to check. logical function f_all_default(var_array) result(res) real(wp), intent(in) :: var_array(:) @@ -95,15 +95,15 @@ contains !logical :: res_array(size(var_array)) !integer :: i - ! do i = 1, size(var_array) - ! res_array(i) = f_is_default(var_array(i)) - ! end do + ! i = 1, size(var_array) + ! = f_is_default(var_array(i)) + ! do - ! res = all(res_array) + ! = all(res_array) end function f_all_default !> Checks if a real(wp) variable is an integer. - !! @param var Variable to check. + !! Variable to check. logical elemental function f_is_integer(var) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: var @@ -123,10 +123,10 @@ contains logical, intent(in) :: igr logical, intent(in) :: ib - ! Determining the number of cells that are needed in order to store - ! sufficient boundary conditions data as to iterate the solution in - ! the physical computational domain from one time-step iteration to - ! the next one + ! the number of cells that are needed in order to store + ! boundary conditions data as to iterate the solution in + ! physical computational domain from one time-step iteration to + ! next one if (igr) then buff_size = (igr_order - 1)/2 + 2 elseif (recon_type == WENO_TYPE) then @@ -139,7 +139,7 @@ contains buff_size = muscl_polyn + 2 end if - ! Correction for smearing function in the lagrangian subgrid bubble model + ! for smearing function in the lagrangian subgrid bubble model if (bubbles_lagrange) then buff_size = max(buff_size, 6) end if @@ -148,7 +148,7 @@ contains buff_size = max(buff_size, 10) end if - ! Configuring Coordinate Direction Indexes + ! Coordinate Direction Indexes idwint(1)%beg = 0; idwint(2)%beg = 0; idwint(3)%beg = 0 idwint(1)%end = m; idwint(2)%end = n; idwint(3)%end = p @@ -163,10 +163,10 @@ contains end subroutine s_configure_coordinate_bounds !> Updates the min and max number of cells in each set of axes - !! @param bounds Min ans max values to update - !! @param m Number of cells in x-axis - !! @param n Number of cells in y-axis - !! @param p Number of cells in z-axis + !! Min ans max values to update + !! Number of cells in x-axis + !! Number of cells in y-axis + !! Number of cells in z-axis elemental subroutine s_update_cell_bounds(bounds, m, n, p) type(cell_num_bounds), intent(out) :: bounds integer, intent(in) :: m, n, p diff --git a/src/common/m_ib_patches.fpp b/src/common/m_ib_patches.fpp index 3db86ceab5..ece2c9e49f 100644 --- a/src/common/m_ib_patches.fpp +++ b/src/common/m_ib_patches.fpp @@ -1,6 +1,6 @@ !> -!! @file m_patches.fpp -!! @brief Contains module m_patches +!! +!! module m_patches #:include 'case.fpp' #:include 'ExtrusionHardcodedIC.fpp' @@ -37,49 +37,53 @@ module m_ib_patches integer :: smooth_patch_id real(wp) :: smooth_coeff $:GPU_DECLARE(create='[smooth_patch_id, smooth_coeff]') - !! These variables are analogous in both meaning and use to the similarly - !! named components in the ic_patch_parameters type (see m_derived_types.f90 - !! for additional details). They are employed as a means to more concisely - !! perform the actions necessary to lay out a particular patch on the grid. + !! are analogous in both meaning and use to the similarly + !! in the ic_patch_parameters type (see m_derived_types.f90 + !! details). They are employed as a means to more concisely + !! actions necessary to lay out a particular patch on the grid. real(wp) :: eta $:GPU_DECLARE(create='[eta]') - !! In the case that smoothing of patch boundaries is enabled and the boundary - !! between two adjacent patches is to be smeared out, this variable's purpose - !! is to act as a pseudo volume fraction to indicate the contribution of each - !! patch toward the composition of a cell's fluid state. + !! case that smoothing of patch boundaries is enabled and the boundary + !! adjacent patches is to be smeared out, this variable's purpose + !! act as a pseudo volume fraction to indicate the contribution of each + !! the composition of a cell's fluid state. real(wp) :: cart_x, cart_y, cart_z real(wp) :: sph_phi !< $:GPU_DECLARE(create='[cart_x, cart_y, cart_z, sph_phi]') - !! Variables to be used to hold cell locations in Cartesian coordinates if - !! 3D simulation is using cylindrical coordinates + !! be used to hold cell locations in Cartesian coordinates if + !! is using cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary $:GPU_DECLARE(create='[x_boundary, y_boundary, z_boundary]') - !! These variables combine the centroid and length parameters associated with - !! a particular patch to yield the locations of the patch boundaries in the - !! x-, y- and z-coordinate directions. They are used as a means to concisely - !! perform the actions necessary to lay out a particular patch on the grid. + !! combine the centroid and length parameters associated with + !! patch to yield the locations of the patch boundaries in the + !! and z-coordinate directions. They are used as a means to concisely + !! actions necessary to lay out a particular patch on the grid. character(len=5) :: istr ! string to store int to string result for error checking contains + !> Applies all immersed boundary patches to the grid. + !! @param[inout] ib_markers_sf IB marker field storing patch IDs at grid cells. + !! @param[inout] levelset Levelset distance field for IB geometry. + !! @param[inout] levelset_norm Levelset normal vector field for IB geometry. impure subroutine s_apply_ib_patches(ib_markers_sf, levelset, levelset_norm) integer, dimension(:, :, :), intent(inout), optional :: ib_markers_sf - type(levelset_field), intent(inout), optional :: levelset !< Levelset determined by models - type(levelset_norm_field), intent(inout), optional :: levelset_norm !< Levelset_norm determined by models + type(levelset_field), intent(inout), optional :: levelset + type(levelset_norm_field), intent(inout), optional :: levelset_norm integer :: i - ! 3D Patch Geometries + ! Patch Geometries if (p > 0) then !> IB Patches !> @{ - ! Spherical patch + ! patch do i = 1, num_ibs if (patch_ib(i)%geometry == 8) then @@ -94,14 +98,14 @@ contains elseif (patch_ib(i)%geometry == 11) then call s_ib_3D_airfoil(i, ib_markers_sf) call s_3D_airfoil_levelset(i, levelset, levelset_norm) - ! STL+IBM patch + ! patch elseif (patch_ib(i)%geometry == 12) then call s_ib_model(i, ib_markers_sf, levelset, levelset_norm) end if end do !> @} - ! 2D Patch Geometries + ! Patch Geometries elseif (n > 0) then !> IB Patches @@ -116,7 +120,7 @@ contains elseif (patch_ib(i)%geometry == 4) then call s_ib_airfoil(i, ib_markers_sf) call s_airfoil_levelset(i, levelset, levelset_norm) - ! STL+IBM patch + ! patch elseif (patch_ib(i)%geometry == 5) then call s_ib_model(i, ib_markers_sf, levelset, levelset_norm) elseif (patch_ib(i)%geometry == 6) then @@ -131,13 +135,13 @@ contains end subroutine s_apply_ib_patches !> The circular patch is a 2D geometry that may be used, for - !! example, in creating a bubble or a droplet. The geometry - !! of the patch is well-defined when its centroid and radius - !! are provided. Note that the circular patch DOES allow for - !! the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param ib True if this patch is an immersed boundary + !! creating a bubble or a droplet. The geometry + !! patch is well-defined when its centroid and radius + !! Note that the circular patch DOES allow for + !! of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! True if this patch is an immersed boundary subroutine s_ib_circle(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -148,22 +152,22 @@ contains integer :: i, j, k !< Generic loop iterators - ! Transferring the circular patch's radius, centroid, smearing patch - ! identity and smearing coefficient information + ! the circular patch's radius, centroid, smearing patch + ! and smearing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid radius = patch_ib(patch_id)%radius - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the circular patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! Checking whether the circle covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the circle covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,radius]', collapse=2) @@ -180,8 +184,8 @@ contains end subroutine s_ib_circle - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids + !! is the patch identifier + !! Array to track patch ids subroutine s_ib_airfoil(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -204,7 +208,7 @@ contains ta = patch_ib(patch_id)%t inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors + ! is not consistent between pre_process and simulation. This IFDEF prevents compilation errors #ifdef MFC_PRE_PROCESS Np1 = int((pa*ca_in/dx)*20) Np2 = int(((ca_in - pa*ca_in)/dx)*20) @@ -218,7 +222,7 @@ contains allocate (airfoil_grid_u(1:Np)) allocate (airfoil_grid_l(1:Np)) - ! TODO :: The below instantiations are already handles by the loop below + ! :: The below instantiations are already handles by the loop below airfoil_grid_u(1)%x = 0._wp airfoil_grid_u(1)%y = 0._wp @@ -228,7 +232,7 @@ contains eta = 1._wp do i = 1, Np1 + Np2 - 1 - ! TODO :: This allocated the upper and lower airfoil arrays, and does not need to be performed each time the IB markers are updated. Place this as a separate subroutine. + ! :: This allocated the upper and lower airfoil arrays, and does not need to be performed each time the IB markers are updated. Place this as a separate subroutine. if (i <= Np1) then xc = i*(pa*ca_in/Np1) xa = xc/ca_in @@ -333,9 +337,9 @@ contains end subroutine s_ib_airfoil - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param ib True if this patch is an immersed boundary + !! is the patch identifier + !! Array to track patch ids + !! True if this patch is an immersed boundary subroutine s_ib_3D_airfoil(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -358,7 +362,7 @@ contains ta = patch_ib(patch_id)%t inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors + ! is not consistent between pre_process and simulation. This IFDEF prevents compilation errors #ifdef MFC_PRE_PROCESS Np1 = int((pa*ca_in/dx)*20) Np2 = int(((ca_in - pa*ca_in)/dx)*20) @@ -485,16 +489,16 @@ contains end subroutine s_ib_3D_airfoil !> The rectangular patch is a 2D geometry that may be used, - !! for example, in creating a solid boundary, or pre-/post- - !! shock region, in alignment with the axes of the Cartesian - !! coordinate system. The geometry of such a patch is well- - !! defined when its centroid and lengths in the x- and y- - !! coordinate directions are provided. Please note that the - !! rectangular patch DOES NOT allow for the smoothing of its - !! boundaries. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param ib True if this patch is an immersed boundary + !! in creating a solid boundary, or pre-/post- + !! in alignment with the axes of the Cartesian + !! The geometry of such a patch is well- + !! its centroid and lengths in the x- and y- + !! are provided. Please note that the + !! DOES NOT allow for the smoothing of its + !! + !! is the patch identifier + !! Array to track patch ids + !! True if this patch is an immersed boundary subroutine s_ib_rectangle(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -510,28 +514,28 @@ contains gamma = fluid_pp(1)%gamma lit_gamma = (1._wp + gamma)/gamma - ! Transferring the rectangle's centroid and length information + ! the rectangle's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid length(1) = patch_ib(patch_id)%length_x length(2) = patch_ib(patch_id)%length_y inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! Since the rectangular patch does not allow for its boundaries to - ! be smoothed out, the pseudo volume fraction is set to 1 to ensure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the rectangular patch does not allow for its boundaries to + ! smoothed out, the pseudo volume fraction is set to 1 to ensure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta = 1._wp - ! Checking whether the rectangle covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the rectangle covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j, xy_local]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,inverse_rotation,x_cc,y_cc]', collapse=2) do j = 0, n do i = 0, m - ! get the x and y coordinates in the local IB frame + ! the x and y coordinates in the local IB frame xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) @@ -540,7 +544,7 @@ contains -0.5_wp*length(2) <= xy_local(2) .and. & 0.5_wp*length(2) >= xy_local(2)) then - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable ib_markers_sf(i, j, 0) = patch_id end if @@ -551,42 +555,42 @@ contains end subroutine s_ib_rectangle !> The spherical patch is a 3D geometry that may be used, - !! for example, in creating a bubble or a droplet. The patch - !! geometry is well-defined when its centroid and radius are - !! provided. Please note that the spherical patch DOES allow - !! for the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param ib True if this patch is an immersed boundary + !! in creating a bubble or a droplet. The patch + !! well-defined when its centroid and radius are + !! note that the spherical patch DOES allow + !! smoothing of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! True if this patch is an immersed boundary subroutine s_ib_sphere(patch_id, ib_markers_sf) integer, intent(in) :: patch_id integer, dimension(0:m, 0:n, 0:p), intent(inout) :: ib_markers_sf - ! Generic loop iterators + ! loop iterators integer :: i, j, k real(wp) :: radius real(wp), dimension(1:3) :: center - !! Variables to initialize the pressure field that corresponds to the - !! bubble-collapse test case found in Tiwari et al. (2013) + !! initialize the pressure field that corresponds to the + !! case found in Tiwari et al. (2013) - ! Transferring spherical patch's radius, centroid, smoothing patch - ! identity and smoothing coefficient information + ! spherical patch's radius, centroid, smoothing patch + ! and smoothing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid center(3) = patch_ib(patch_id)%z_centroid radius = patch_ib(patch_id)%radius - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the spherical patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the spherical patch's boundary is enabled. eta = 1._wp - ! Checking whether the sphere covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the sphere covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,radius]', collapse=3) do k = 0, p @@ -598,7 +602,7 @@ contains cart_y = y_cc(j) cart_z = z_cc(k) end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (((x_cc(i) - center(1))**2 & + (cart_y - center(2))**2 & + (cart_z - center(3))**2 <= radius**2)) then @@ -612,15 +616,15 @@ contains end subroutine s_ib_sphere !> The cuboidal patch is a 3D geometry that may be used, for - !! example, in creating a solid boundary, or pre-/post-shock - !! region, which is aligned with the axes of the Cartesian - !! coordinate system. The geometry of such a patch is well- - !! defined when its centroid and lengths in the x-, y- and - !! z-coordinate directions are provided. Please notice that - !! the cuboidal patch DOES NOT allow for the smearing of its - !! boundaries. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids + !! creating a solid boundary, or pre-/post-shock + !! is aligned with the axes of the Cartesian + !! The geometry of such a patch is well- + !! its centroid and lengths in the x-, y- and + !! are provided. Please notice that + !! patch DOES NOT allow for the smearing of its + !! + !! is the patch identifier + !! Array to track patch ids subroutine s_ib_cuboid(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -630,7 +634,7 @@ contains real(wp), dimension(1:3) :: xyz_local, center, length !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! Transferring the cuboid's centroid and length information + ! the cuboid's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid center(3) = patch_ib(patch_id)%z_centroid @@ -639,16 +643,16 @@ contains length(3) = patch_ib(patch_id)%length_z inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! Since the cuboidal patch does not allow for its boundaries to get - ! smoothed out, the pseudo volume fraction is set to 1 to make sure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the cuboidal patch does not allow for its boundaries to get + ! out, the pseudo volume fraction is set to 1 to make sure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta = 1._wp - ! Checking whether the cuboid covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! to that cell. If both queries check out, the primitive variables - ! of the current patch are assigned to this cell. + ! whether the cuboid covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables + ! the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,xyz_local,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,inverse_rotation]', collapse=3) do k = 0, p @@ -656,7 +660,7 @@ contains do i = 0, m if (grid_geometry == 3) then - ! TODO :: This does not work and is not covered by any tests. This should be fixed + ! :: This does not work and is not covered by any tests. This should be fixed call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k)) else cart_y = y_cc(j) @@ -672,7 +676,7 @@ contains -0.5*length(3) <= xyz_local(3) .and. & 0.5*length(3) >= xyz_local(3)) then - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable ib_markers_sf(i, j, k) = patch_id end if end do @@ -683,16 +687,16 @@ contains end subroutine s_ib_cuboid !> The cylindrical patch is a 3D geometry that may be used, - !! for example, in setting up a cylindrical solid boundary - !! confinement, like a blood vessel. The geometry of this - !! patch is well-defined when the centroid, the radius and - !! the length along the cylinder's axis, parallel to the x-, - !! y- or z-coordinate direction, are provided. Please note - !! that the cylindrical patch DOES allow for the smoothing - !! of its lateral boundary. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param ib True if this patch is an immersed boundary + !! in setting up a cylindrical solid boundary + !! a blood vessel. The geometry of this + !! well-defined when the centroid, the radius and + !! along the cylinder's axis, parallel to the x-, + !! z-coordinate direction, are provided. Please note + !! cylindrical patch DOES allow for the smoothing + !! lateral boundary. + !! is the patch identifier + !! Array to track patch ids + !! True if this patch is an immersed boundary subroutine s_ib_cylinder(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -703,8 +707,8 @@ contains real(wp), dimension(1:3) :: xyz_local, center, length !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! Transferring the cylindrical patch's centroid, length, radius, - ! smoothing patch identity and smoothing coefficient information + ! the cylindrical patch's centroid, length, radius, + ! patch identity and smoothing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid @@ -715,15 +719,15 @@ contains radius = patch_ib(patch_id)%radius inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smearing of the cylindrical patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smearing of the cylindrical patch's boundary is enabled. eta = 1._wp - ! Checking whether the cylinder covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the cylinder covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,xyz_local,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,radius,inverse_rotation]', collapse=3) do k = 0, p @@ -757,7 +761,7 @@ contains -0.5_wp*length(3) <= xyz_local(3) .and. & 0.5_wp*length(3) >= xyz_local(3)))) then - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable ib_markers_sf(i, j, k) = patch_id end if end do @@ -778,26 +782,26 @@ contains real(wp), dimension(1:2) :: center !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! Transferring the ellipse's centroid and length information + ! the ellipse's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid ellipse_coeffs(1) = 0.5_wp*patch_ib(patch_id)%length_x ellipse_coeffs(2) = 0.5_wp*patch_ib(patch_id)%length_y inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! Checking whether the ellipse covers a particular cell in the - ! domain + ! whether the ellipse covers a particular cell in the + ! $:GPU_PARALLEL_LOOP(private='[i,j, xy_local]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,ellipse_coeffs,inverse_rotation,x_cc,y_cc]', collapse=2) do j = 0, n do i = 0, m - ! get the x and y coordinates in the local IB frame + ! the x and y coordinates in the local IB frame xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) - ! Ellipse condition (x/a)^2 + (y/b)^2 <= 1 + ! condition (x/a)^2 + (y/b)^2 <= 1 if ((xy_local(1)/ellipse_coeffs(1))**2 + (xy_local(2)/ellipse_coeffs(2))**2 <= 1._wp) then - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable ib_markers_sf(i, j, 0) = patch_id end if end do @@ -807,18 +811,18 @@ contains end subroutine s_ib_ellipse !> The STL patch is a 2/3D geometry that is imported from an STL file. - !! @param patch_id is the patch identifier - !! @param ib_markers_sf Array to track patch ids - !! @param STL_levelset STL levelset - !! @param STL_levelset_norm STL levelset normals + !! @param[in] patch_id Patch identifier index. + !! @param[inout] ib_markers_sf Array to track patch IDs at grid cells. + !! @param[inout] STL_levelset Levelset distance field for the STL model. + !! @param[inout] STL_levelset_norm Levelset normal field for the STL model. subroutine s_ib_model(patch_id, ib_markers_sf, STL_levelset, STL_levelset_norm) integer, intent(in) :: patch_id integer, dimension(0:m, 0:n, 0:p), intent(inout) :: ib_markers_sf - ! Variables for IBM+STL - type(levelset_field), optional, intent(inout) :: STL_levelset !< Levelset determined by models - type(levelset_norm_field), optional, intent(inout) :: STL_levelset_norm !< Levelset_norm determined by models + ! for IBM+STL + type(levelset_field), optional, intent(inout) :: STL_levelset + type(levelset_norm_field), optional, intent(inout) :: STL_levelset_norm real(wp) :: normals(1:3) !< Boundary normal buffer integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex real(wp), allocatable, dimension(:, :, :) :: boundary_v !< Boundary vertex buffer @@ -854,39 +858,39 @@ contains print *, " * Transforming model." end if - ! Get the model center before transforming the model + ! the model center before transforming the model bbox_old = f_create_bbox(model) model_center(1:3) = (bbox_old%min(1:3) + bbox_old%max(1:3))/2._wp - ! Compute the transform matrices for vertices and normals + ! the transform matrices for vertices and normals transform = f_create_transform_matrix(params, model_center) transform_n = f_create_transform_matrix(params) call s_transform_model(model, transform, transform_n) - ! Recreate the bounding box after transformation + ! the bounding box after transformation bbox = f_create_bbox(model) - ! Show the number of vertices in the original STL model + ! the number of vertices in the original STL model if (proc_rank == 0) then print *, ' * Number of input model vertices:', 3*model%ntrs end if call f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) - ! Check if the model needs interpolation + ! if the model needs interpolation if (p > 0) then call f_check_interpolation_3D(model, (/dx, dy, dz/), interpolate) else call f_check_interpolation_2D(boundary_v, boundary_edge_count, (/dx, dy, dz/), interpolate) end if - ! Show the number of edges and boundary edges in 2D STL models + ! the number of edges and boundary edges in 2D STL models if (proc_rank == 0 .and. p == 0) then print *, ' * Number of 2D model boundary edges:', boundary_edge_count end if - ! Interpolate the STL model along the edges (2D) and on triangle facets (3D) + ! the STL model along the edges (2D) and on triangle facets (3D) if (interpolate) then if (proc_rank == 0) then print *, ' * Interpolating STL vertices.' @@ -946,18 +950,18 @@ contains eta = f_model_is_inside(model, point, (/dx, dy, dz/), patch_ib(patch_id)%model_spc) - ! Reading STL boundary vertices and compute the levelset and levelset_norm + ! STL boundary vertices and compute the levelset and levelset_norm if (eta > patch_ib(patch_id)%model_threshold) then ib_markers_sf(i, j, k) = patch_id end if - ! 3D models + ! models if (p > 0) then - ! Get the boundary normals and shortest distance between the cell center and the model boundary + ! the boundary normals and shortest distance between the cell center and the model boundary call f_distance_normals_3D(model, point, normals, distance) - ! Get the shortest distance between the cell center and the interpolated model boundary + ! the shortest distance between the cell center and the interpolated model boundary if (interpolate) then STL_levelset%sf(i, j, k, patch_id) = f_interpolated_distance(interpolated_boundary_v, & total_vertices, & @@ -966,49 +970,49 @@ contains STL_levelset%sf(i, j, k, patch_id) = distance end if - ! Correct the sign of the levelset + ! the sign of the levelset if (ib_markers_sf(i, j, k) > 0) then STL_levelset%sf(i, j, k, patch_id) = -abs(STL_levelset%sf(i, j, k, patch_id)) end if - ! Correct the sign of the levelset_norm + ! the sign of the levelset_norm if (ib_markers_sf(i, j, k) == 0) then normals(1:3) = -normals(1:3) end if - ! Assign the levelset_norm + ! the levelset_norm STL_levelset_norm%sf(i, j, k, patch_id, 1:3) = normals(1:3) else - ! 2D models + ! models if (interpolate) then - ! Get the shortest distance between the cell center and the model boundary + ! the shortest distance between the cell center and the model boundary STL_levelset%sf(i, j, 0, patch_id) = f_interpolated_distance(interpolated_boundary_v, & total_vertices, & point) else - ! Get the shortest distance between the cell center and the interpolated model boundary + ! the shortest distance between the cell center and the interpolated model boundary STL_levelset%sf(i, j, 0, patch_id) = f_distance(boundary_v, & boundary_edge_count, & point) end if - ! Correct the sign of the levelset + ! the sign of the levelset if (ib_markers_sf(i, j, k) > 0) then STL_levelset%sf(i, j, 0, patch_id) = -abs(STL_levelset%sf(i, j, 0, patch_id)) end if - ! Get the boundary normals + ! the boundary normals call f_normals(boundary_v, & boundary_edge_count, & point, & normals) - ! Correct the sign of the levelset_norm + ! the sign of the levelset_norm if (ib_markers_sf(i, j, k) == 0) then normals(1:3) = -normals(1:3) end if - ! Assign the levelset_norm + ! the levelset_norm STL_levelset_norm%sf(i, j, k, patch_id, 1:3) = normals(1:3) end if @@ -1032,9 +1036,9 @@ contains real(wp), dimension(3, 3, 3) :: rotation real(wp) :: angle - ! construct the x, y, and z rotation matrices + ! the x, y, and z rotation matrices if (num_dims == 3) then - ! also compute the x and y axes in 3D + ! compute the x and y axes in 3D angle = patch_ib(patch_id)%angles(1) rotation(1, 1, :) = [1._wp, 0._wp, 0._wp] rotation(1, 2, :) = [0._wp, cos(angle), -sin(angle)] @@ -1045,23 +1049,23 @@ contains rotation(2, 2, :) = [0._wp, 1._wp, 0._wp] rotation(2, 3, :) = [-sin(angle), 0._wp, cos(angle)] - ! apply the y rotation to the x rotation + ! the y rotation to the x rotation patch_ib(patch_id)%rotation_matrix(:, :) = matmul(rotation(1, :, :), rotation(2, :, :)) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(2, :, :)), transpose(rotation(1, :, :))) end if - ! z component first, since it applies in 2D and 3D + ! component first, since it applies in 2D and 3D angle = patch_ib(patch_id)%angles(3) rotation(3, 1, :) = [cos(angle), -sin(angle), 0._wp] rotation(3, 2, :) = [sin(angle), cos(angle), 0._wp] rotation(3, 3, :) = [0._wp, 0._wp, 1._wp] if (num_dims == 3) then - ! apply the z rotation to the xy rotation in 3D + ! the z rotation to the xy rotation in 3D patch_ib(patch_id)%rotation_matrix(:, :) = matmul(patch_ib(patch_id)%rotation_matrix(:, :), rotation(3, :, :)) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(3, :, :)), patch_ib(patch_id)%rotation_matrix_inverse(:, :)) else - ! write out only the z rotation in 2D + ! out only the z rotation in 2D patch_ib(patch_id)%rotation_matrix(:, :) = rotation(3, :, :) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = transpose(rotation(3, :, :)) end if @@ -1101,9 +1105,9 @@ contains end subroutine s_convert_cylindrical_to_spherical_coord !> Archimedes spiral function - !! @param myth Angle - !! @param offset Thickness - !! @param a Starting position + !! Angle + !! Thickness + !! Starting position pure elemental function f_r(myth, offset, a) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: myth, offset, a diff --git a/src/common/m_model.fpp b/src/common/m_model.fpp index dd8f2204f7..8890c41c1a 100644 --- a/src/common/m_model.fpp +++ b/src/common/m_model.fpp @@ -1,7 +1,7 @@ !> -!! @file m_model.fpp -!! @author Henry Le Berre -!! @brief Contains module m_model +!! +!! Le Berre +!! module m_model #:include 'macros.fpp' @@ -19,7 +19,7 @@ module m_model public :: f_model_read, s_model_write, s_model_free, f_model_is_inside - ! Subroutines for STL immersed boundaries + ! for STL immersed boundaries public :: f_check_boundary, f_register_edge, f_check_interpolation_2D, & f_check_interpolation_3D, f_interpolate_2D, f_interpolate_3D, & f_interpolated_distance, f_normals, f_distance, f_distance_normals_3D, f_tri_area @@ -27,8 +27,8 @@ module m_model contains !> This procedure reads a binary STL file. - !! @param filepath Path to the STL file. - !! @param model The binary of the STL file. + !! Path to the STL file. + !! The binary of the STL file. impure subroutine s_read_stl_binary(filepath, model) character(LEN=*), intent(in) :: filepath @@ -76,8 +76,8 @@ contains end subroutine s_read_stl_binary !> This procedure reads an ASCII STL file. - !! @param filepath Path to the STL file. - !! @param model the STL file. + !! Path to the STL file. + !! the STL file. impure subroutine s_read_stl_ascii(filepath, model) character(LEN=*), intent(in) :: filepath type(t_model), intent(out) :: model @@ -184,8 +184,8 @@ contains end subroutine s_read_stl_ascii !> This procedure reads an STL file. - !! @param filepath Path to the STL file. - !! @param model the STL file. + !! Path to the STL file. + !! the STL file. impure subroutine s_read_stl(filepath, model) character(LEN=*), intent(in) :: filepath @@ -218,8 +218,8 @@ contains end subroutine s_read_stl !> This procedure reads an OBJ file. - !! @param filepath Path to the odj file. - !! @param model The obj file. + !! Path to the odj file. + !! The obj file. impure subroutine s_read_obj(filepath, model) character(LEN=*), intent(in) :: filepath @@ -294,8 +294,8 @@ contains end subroutine s_read_obj !> This procedure reads a mesh from a file. - !! @param filepath Path to the file to read. - !! @return The model read from the file. + !! Path to the file to read. + !! model read from the file. impure function f_model_read(filepath) result(model) character(LEN=*), intent(in) :: filepath @@ -316,8 +316,8 @@ contains end function f_model_read !> This procedure writes a binary STL file. - !! @param filepath Path to the STL file. - !! @param model STL to write + !! Path to the STL file. + !! STL to write impure subroutine s_write_stl(filepath, model) character(LEN=*), intent(in) :: filepath @@ -366,8 +366,8 @@ contains end subroutine s_write_stl !> This procedure writes an OBJ file. - !! @param filepath Path to the obj file. - !! @param model obj to write. + !! Path to the obj file. + !! obj to write. impure subroutine s_write_obj(filepath, model) character(LEN=*), intent(in) :: filepath @@ -403,8 +403,8 @@ contains end subroutine s_write_obj !> This procedure writes a binary STL file. - !! @param filepath Path to the file to write. - !! @param model Model to write. + !! Path to the file to write. + !! Model to write. impure subroutine s_model_write(filepath, model) character(LEN=*), intent(in) :: filepath @@ -480,11 +480,11 @@ contains end subroutine s_skip_ignored_lines !> This procedure, recursively, finds whether a point is inside an octree. - !! @param model Model to search in. - !! @param point Point to test. - !! @param spacing Space around the point to search in (grid spacing). - !! @param spc Number of samples per cell. - !! @return True if the point is inside the octree, false otherwise. + !! Model to search in. + !! Point to test. + !! Space around the point to search in (grid spacing). + !! Number of samples per cell. + !! if the point is inside the octree, false otherwise. impure function f_model_is_inside(model, point, spacing, spc) result(fraction) type(t_model), intent(in) :: model @@ -527,11 +527,11 @@ contains end function f_model_is_inside - ! From https://www.scratchapixel.com/lessons/3e-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution.html + ! https://www.scratchapixel.com/lessons/3e-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution.html !> This procedure checks if a ray intersects a triangle. - !! @param ray Ray. - !! @param triangle Triangle. - !! @return True if the ray intersects the triangle, false otherwise. + !! Ray. + !! Triangle. + !! if the ray intersects the triangle, false otherwise. elemental function f_intersects_triangle(ray, triangle) result(intersects) type(t_ray), intent(in) :: ray @@ -588,15 +588,15 @@ contains end function f_intersects_triangle !> This procedure checks and labels edges shared by two or more triangles facets of the 2D STL model. - !! @param model Model to search in. - !! @param boundary_v Output boundary vertices/normals. - !! @param boundary_vertex_count Output total boundary vertex count - !! @param boundary_edge_count Output total boundary edge counts + !! @param[in] model Model to search in. + !! @param[out] boundary_v Output boundary vertices and normals. + !! @param[out] boundary_vertex_count Total boundary vertex count. + !! @param[out] boundary_edge_count Total boundary edge count. subroutine f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) type(t_model), intent(in) :: model - real(wp), allocatable, intent(out), dimension(:, :, :) :: boundary_v !< Output boundary vertices/normals - integer, intent(out) :: boundary_vertex_count, boundary_edge_count !< Output boundary vertex/edge count + real(wp), allocatable, intent(out), dimension(:, :, :) :: boundary_v + integer, intent(out) :: boundary_vertex_count, boundary_edge_count integer :: i, j !< Model index iterator integer :: edge_count, edge_index, store_index !< Boundary edge index iterator @@ -606,32 +606,32 @@ contains integer, dimension(1:(3*model%ntrs)) :: edge_occurrence !< The manifoldness of the edges real(wp) :: edgetan, initial, v_norm, xnormal, ynormal !< The manifoldness of the edges - ! Total number of edges in 2D STL + ! number of edges in 2D STL edge_count = 3*model%ntrs - ! Initialize edge_occurrence array to zero + ! edge_occurrence array to zero edge_occurrence = 0 edge_index = 0 - ! Collect all edges of all triangles and store them + ! all edges of all triangles and store them do i = 1, model%ntrs - ! First edge (v1, v2) + ! edge (v1, v2) edge(1, 1:2) = model%trs(i)%v(1, 1:2) edge(2, 1:2) = model%trs(i)%v(2, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) - ! Second edge (v2, v3) + ! edge (v2, v3) edge(1, 1:2) = model%trs(i)%v(2, 1:2) edge(2, 1:2) = model%trs(i)%v(3, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) - ! Third edge (v3, v1) + ! edge (v3, v1) edge(1, 1:2) = model%trs(i)%v(3, 1:2) edge(2, 1:2) = model%trs(i)%v(1, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) end do - ! Check all edges and count repeated edges + ! all edges and count repeated edges do i = 1, edge_count do j = 1, edge_count if (i /= j) then @@ -650,7 +650,7 @@ contains end do end do - ! Count the number of boundary vertices/edges + ! the number of boundary vertices/edges boundary_vertex_count = 0 boundary_edge_count = 0 @@ -661,10 +661,10 @@ contains end if end do - ! Allocate the boundary_v array based on the number of boundary edges + ! the boundary_v array based on the number of boundary edges allocate (boundary_v(boundary_edge_count, 1:3, 1:2)) - ! Store boundary vertices + ! boundary vertices store_index = 0 do i = 1, edge_count if (edge_occurrence(i) == 0) then @@ -674,7 +674,7 @@ contains end if end do - ! Find/store the normal vector of the boundary edges + ! the normal vector of the boundary edges do i = 1, boundary_edge_count boundary_edge(1) = boundary_v(i, 2, 1) - boundary_v(i, 1, 1) boundary_edge(2) = boundary_v(i, 2, 2) - boundary_v(i, 1, 2) @@ -702,10 +702,10 @@ contains end subroutine f_check_boundary !> This procedure appends the edge end vertices to a temporary buffer. - !! @param temp_boundary_v Temporary edge end vertex buffer - !! @param edge Edges end points to be registered - !! @param edge_index Edge index iterator - !! @param edge_count Total number of edges + !! Temporary edge end vertex buffer + !! Edges end points to be registered + !! Edge index iterator + !! Total number of edges subroutine f_register_edge(temp_boundary_v, edge, edge_index, edge_count) integer, intent(inout) :: edge_index !< Edge index iterator @@ -713,7 +713,7 @@ contains real(wp), intent(in), dimension(1:2, 1:2) :: edge !< Edges end points to be registered real(wp), dimension(1:edge_count, 1:2, 1:2), intent(inout) :: temp_boundary_v !< Temporary edge end vertex buffer - ! Increment edge index and store the edge + ! edge index and store the edge edge_index = edge_index + 1 temp_boundary_v(edge_index, 1, 1:2) = edge(1, 1:2) temp_boundary_v(edge_index, 2, 1:2) = edge(2, 1:2) @@ -721,14 +721,14 @@ contains end subroutine f_register_edge !> This procedure check if interpolates is needed for 2D models. - !! @param boundary_v Temporary edge end vertex buffer - !! @param boundary_edge_count Output total number of boundary edges - !! @param spacing Dimensions of the current levelset cell - !! @param interpolate Logical output + !! @param[in] boundary_v Boundary edge vertex buffer. + !! @param[in] boundary_edge_count Number of boundary edges. + !! @param[in] spacing Grid cell spacing in each dimension. + !! @param[inout] interpolate Set to true if edge interpolation is needed. subroutine f_check_interpolation_2D(boundary_v, boundary_edge_count, spacing, interpolate) - logical, intent(inout) :: interpolate !< Logical indicator of interpolation - integer, intent(in) :: boundary_edge_count !< Number of boundary edges + logical, intent(inout) :: interpolate + integer, intent(in) :: boundary_edge_count real(wp), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v real(wp), dimension(1:3), intent(in) :: spacing @@ -753,9 +753,9 @@ contains end subroutine f_check_interpolation_2D !> This procedure check if interpolates is needed for 3D models. - !! @param model Model to search in. - !! @param spacing Dimensions of the current levelset cell - !! @param interpolate Logical output + !! Model to search in. + !! Dimensions of the current levelset cell + !! Logical output subroutine f_check_interpolation_3D(model, spacing, interpolate) logical, intent(inout) :: interpolate @@ -798,11 +798,11 @@ contains end subroutine f_check_interpolation_3D !> This procedure interpolates 2D models. - !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation - !! @param boundary_edge_count Output total number of boundary edges - !! @param spacing Dimensions of the current levelset cell - !! @param interpolated_boundary_v Output all the boundary vertices of the interpolated 2D model - !! @param total_vertices Total number of vertices after interpolation + !! Group of all the boundary vertices of the 2D model without interpolation + !! Output total number of boundary edges + !! Dimensions of the current levelset cell + !! Output all the boundary vertices of the interpolated 2D model + !! Total number of vertices after interpolation subroutine f_interpolate_2D(boundary_v, boundary_edge_count, spacing, interpolated_boundary_v, total_vertices) real(wp), intent(in), dimension(:, :, :) :: boundary_v @@ -816,51 +816,51 @@ contains real(wp) :: edge_length, cell_width real(wp), dimension(1:2) :: edge_x, edge_y, edge_del - ! Get the number of boundary edges + ! the number of boundary edges cell_width = minval(spacing(1:2)) num_segments = 0 - ! First pass: Calculate the total number of vertices including interpolated ones + ! pass: Calculate the total number of vertices including interpolated ones total_vertices = 1 do i = 1, boundary_edge_count - ! Get the coordinates of the two ends of the current edge + ! the coordinates of the two ends of the current edge edge_x(1) = boundary_v(i, 1, 1) edge_y(1) = boundary_v(i, 1, 2) edge_x(2) = boundary_v(i, 2, 1) edge_y(2) = boundary_v(i, 2, 2) - ! Compute the length of the edge + ! the length of the edge edge_length = sqrt((edge_x(2) - edge_x(1))**2 + & (edge_y(2) - edge_y(1))**2) - ! Determine the number of segments + ! the number of segments if (edge_length > cell_width) then num_segments = Ifactor_2D*ceiling(edge_length/cell_width) else num_segments = 1 end if - ! Each edge contributes num_segments vertices + ! edge contributes num_segments vertices total_vertices = total_vertices + num_segments end do - ! Allocate memory for the new boundary vertices array + ! memory for the new boundary vertices array allocate (interpolated_boundary_v(1:total_vertices, 1:3)) - ! Fill the new boundary vertices array with original and interpolated vertices + ! the new boundary vertices array with original and interpolated vertices total_vertices = 1 do i = 1, boundary_edge_count - ! Get the coordinates of the two ends of the current edge + ! the coordinates of the two ends of the current edge edge_x(1) = boundary_v(i, 1, 1) edge_y(1) = boundary_v(i, 1, 2) edge_x(2) = boundary_v(i, 2, 1) edge_y(2) = boundary_v(i, 2, 2) - ! Compute the length of the edge + ! the length of the edge edge_length = sqrt((edge_x(2) - edge_x(1))**2 + & (edge_y(2) - edge_y(1))**2) - ! Determine the number of segments and interpolation step + ! the number of segments and interpolation step if (edge_length > cell_width) then num_segments = Ifactor_2D*ceiling(edge_length/cell_width) edge_del(1) = (edge_x(2) - edge_x(1))/num_segments @@ -875,14 +875,14 @@ contains interpolated_boundary_v(1, 2) = edge_y(1) interpolated_boundary_v(1, 3) = 0._wp - ! Add original and interpolated vertices to the output array + ! original and interpolated vertices to the output array do j = 1, num_segments - 1 total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = edge_x(1) + j*edge_del(1) interpolated_boundary_v(total_vertices, 2) = edge_y(1) + j*edge_del(2) end do - ! Add the last vertex of the edge + ! the last vertex of the edge if (num_segments > 0) then total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = edge_x(2) @@ -893,10 +893,10 @@ contains end subroutine f_interpolate_2D !> This procedure interpolates 3D models. - !! @param model Model to search in. - !! @param spacing Dimensions of the current levelset cell - !! @param interpolated_boundary_v Output all the boundary vertices of the interpolated 3D model - !! @param total_vertices Total number of vertices after interpolation + !! Model to search in. + !! Dimensions of the current levelset cell + !! Output all the boundary vertices of the interpolated 3D model + !! Total number of vertices after interpolation impure subroutine f_interpolate_3D(model, spacing, interpolated_boundary_v, total_vertices) real(wp), dimension(1:3), intent(in) :: spacing type(t_model), intent(in) :: model @@ -909,47 +909,47 @@ contains real(wp), dimension(1:3) :: bary_coord !< Barycentric coordinates real(wp) :: edge_length, cell_width, cell_area_min, tri_area - ! Number of triangles in the model + ! of triangles in the model num_triangles = model%ntrs cell_width = minval(spacing) - ! Find the minimum surface area + ! the minimum surface area cell_area(1) = spacing(1)*spacing(2) cell_area(2) = spacing(1)*spacing(3) cell_area(3) = spacing(2)*spacing(3) cell_area_min = minval(cell_area) num_inner_vertices = 0 - ! Calculate the total number of vertices including interpolated ones + ! the total number of vertices including interpolated ones total_vertices = 0 do i = 1, num_triangles do j = 1, 3 - ! Get the coordinates of the two vertices of the current edge + ! the coordinates of the two vertices of the current edge tri(1, 1) = model%trs(i)%v(j, 1) tri(1, 2) = model%trs(i)%v(j, 2) tri(1, 3) = model%trs(i)%v(j, 3) - ! Next vertex in the triangle (cyclic) + ! vertex in the triangle (cyclic) tri(2, 1) = model%trs(i)%v(mod(j, 3) + 1, 1) tri(2, 2) = model%trs(i)%v(mod(j, 3) + 1, 2) tri(2, 3) = model%trs(i)%v(mod(j, 3) + 1, 3) - ! Compute the length of the edge + ! the length of the edge edge_length = sqrt((tri(2, 1) - tri(1, 1))**2 + & (tri(2, 2) - tri(1, 2))**2 + & (tri(2, 3) - tri(1, 3))**2) - ! Determine the number of segments + ! the number of segments if (edge_length > cell_width) then num_segments = Ifactor_3D*ceiling(edge_length/cell_width) else num_segments = 1 end if - ! Each edge contributes num_segments vertices + ! edge contributes num_segments vertices total_vertices = total_vertices + num_segments + 1 end do - ! Add vertices inside the triangle + ! vertices inside the triangle do k = 1, 3 tri(k, 1) = model%trs(i)%v(k, 1) tri(k, 2) = model%trs(i)%v(k, 2) @@ -963,29 +963,29 @@ contains end if end do - ! Allocate memory for the new boundary vertices array + ! memory for the new boundary vertices array allocate (interpolated_boundary_v(1:total_vertices, 1:3)) - ! Fill the new boundary vertices array with original and interpolated vertices + ! the new boundary vertices array with original and interpolated vertices total_vertices = 0 do i = 1, num_triangles - ! Loop through the 3 edges of each triangle + ! through the 3 edges of each triangle do j = 1, 3 - ! Get the coordinates of the two vertices of the current edge + ! the coordinates of the two vertices of the current edge tri(1, 1) = model%trs(i)%v(j, 1) tri(1, 2) = model%trs(i)%v(j, 2) tri(1, 3) = model%trs(i)%v(j, 3) - ! Next vertex in the triangle (cyclic) + ! vertex in the triangle (cyclic) tri(2, 1) = model%trs(i)%v(mod(j, 3) + 1, 1) tri(2, 2) = model%trs(i)%v(mod(j, 3) + 1, 2) tri(2, 3) = model%trs(i)%v(mod(j, 3) + 1, 3) - ! Compute the length of the edge + ! the length of the edge edge_length = sqrt((tri(2, 1) - tri(1, 1))**2 + & (tri(2, 2) - tri(1, 2))**2 + & (tri(2, 3) - tri(1, 3))**2) - ! Determine the number of segments and interpolation step + ! the number of segments and interpolation step if (edge_length > cell_width) then num_segments = Ifactor_3D*ceiling(edge_length/cell_width) edge_del(1) = (tri(2, 1) - tri(1, 1))/num_segments @@ -996,7 +996,7 @@ contains edge_del = 0._wp end if - ! Add original and interpolated vertices to the output array + ! original and interpolated vertices to the output array do k = 0, num_segments - 1 total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = tri(1, 1) + k*edge_del(1) @@ -1004,14 +1004,14 @@ contains interpolated_boundary_v(total_vertices, 3) = tri(1, 3) + k*edge_del(3) end do - ! Add the last vertex of the edge + ! the last vertex of the edge total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = tri(2, 1) interpolated_boundary_v(total_vertices, 2) = tri(2, 2) interpolated_boundary_v(total_vertices, 3) = tri(2, 3) end do - ! Interpolate verties that are not on edges + ! verties that are not on edges do k = 1, 3 tri(k, 1) = model%trs(i)%v(k, 1) tri(k, 2) = model%trs(i)%v(k, 2) @@ -1043,10 +1043,10 @@ contains end subroutine f_interpolate_3D !> This procedure determines the levelset distance and normals of the 3D models without interpolation. - !! @param model Model to search in. - !! @param point The cell centers of the current level cell - !! @param normals The output levelset normals - !! @param distance The output levelset distance + !! Model to search in. + !! The cell centers of the current level cell + !! The output levelset normals + !! The output levelset distance subroutine f_distance_normals_3D(model, point, normals, distance) type(t_model), intent(IN) :: model @@ -1076,7 +1076,7 @@ contains (point(3) - tri(j, 3))**2) end do - ! Get the surface center of each triangle facet + ! the surface center of each triangle facet do j = 1, 3 midp(j) = (tri(1, j) + tri(2, j) + tri(3, j))/3 end do @@ -1104,12 +1104,12 @@ contains end subroutine f_distance_normals_3D !> This procedure determines the levelset distance of 2D models without interpolation. - !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation - !! @param boundary_vertex_count Output the total number of boundary vertices - !! @param boundary_edge_count Output the total number of boundary edges - !! @param point The cell centers of the current levelset cell - !! @param spacing Dimensions of the current levelset cell - !! @return Distance which the levelset distance without interpolation + !! Group of all the boundary vertices of the 2D model without interpolation + !! Output the total number of boundary vertices + !! Output the total number of boundary edges + !! The cell centers of the current levelset cell + !! Dimensions of the current levelset cell + !! which the levelset distance without interpolation function f_distance(boundary_v, boundary_edge_count, point) result(distance) integer, intent(in) :: boundary_edge_count @@ -1137,10 +1137,10 @@ contains end function f_distance !> This procedure determines the levelset normals of 2D models without interpolation. - !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation - !! @param boundary_edge_count Output the total number of boundary edges - !! @param point The cell centers of the current levelset cell - !! @param normals Output levelset normals without interpolation + !! Group of all the boundary vertices of the 2D model without interpolation + !! Output the total number of boundary edges + !! The cell centers of the current levelset cell + !! Output levelset normals without interpolation subroutine f_normals(boundary_v, boundary_edge_count, point, normals) integer, intent(in) :: boundary_edge_count @@ -1197,10 +1197,10 @@ contains end subroutine f_tri_area !> This procedure determines the levelset of interpolated 2D models. - !! @param interpolated_boundary_v Group of all the boundary vertices of the interpolated 2D model - !! @param total_vertices Total number of vertices after interpolation - !! @param point The cell centers of the current levelset cell - !! @return Distance which the levelset distance without interpolation + !! Group of all the boundary vertices of the interpolated 2D model + !! Total number of vertices after interpolation + !! The cell centers of the current levelset cell + !! which the levelset distance without interpolation function f_interpolated_distance(interpolated_boundary_v, total_vertices, point) result(distance) integer, intent(in) :: total_vertices diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index f0b3d6654c..a344a32446 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -2,10 +2,10 @@ #:include 'macros.fpp' !> @brief The module serves as a proxy to the parameters and subroutines -!! available in the MPI implementation's MPI module. Specifically, -!! the purpose of the proxy is to harness basic MPI commands into -!! more complicated procedures as to accomplish the communication -!! goals for the simulation. +!! the MPI implementation's MPI module. Specifically, +!! of the proxy is to harness basic MPI commands into +!! procedures as to accomplish the communication +!! the simulation. module m_mpi_common #ifdef MFC_MPI @@ -26,17 +26,17 @@ module m_mpi_common integer, private :: v_size $:GPU_DECLARE(create='[v_size]') - !! Generic flags used to identify and report MPI errors + !! used to identify and report MPI errors real(wp), private, allocatable, dimension(:) :: buff_send !< - !! This variable is utilized to pack and send the buffer of the cell-average - !! primitive variables, for a single computational domain boundary at the - !! time, to the relevant neighboring processor. + !! is utilized to pack and send the buffer of the cell-average + !! for a single computational domain boundary at the + !! the relevant neighboring processor. real(wp), private, allocatable, dimension(:) :: buff_recv !< - !! buff_recv is utilized to receive and unpack the buffer of the cell- - !! average primitive variables, for a single computational domain boundary - !! at the time, from the relevant neighboring processor. + !! utilized to receive and unpack the buffer of the cell- + !! variables, for a single computational domain boundary + !! time, from the relevant neighboring processor. #ifndef __NVCOMPILER_GPU_UNIFIED_MEM $:GPU_DECLARE(create='[buff_send, buff_recv]') @@ -48,14 +48,14 @@ module m_mpi_common contains !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_mpi_common_module #ifdef MFC_MPI - ! Allocating buff_send/recv and. Please note that for the sake of - ! simplicity, both variables are provided sufficient storage to hold - ! the largest buffer in the computational domain. + ! buff_send/recv and. Please note that for the sake of + ! both variables are provided sufficient storage to hold + ! largest buffer in the computational domain. if (qbmm .and. .not. polytropic) then v_size = sys_size + 2*nb*4 @@ -92,41 +92,41 @@ contains end subroutine s_initialize_mpi_common_module !> The subroutine initializes the MPI execution environment - !! and queries both the number of processors which will be - !! available for the job and the local processor rank. + !! both the number of processors which will be + !! the job and the local processor rank. impure subroutine s_mpi_initialize #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Initializing the MPI environment + ! the MPI environment call MPI_INIT(ierr) - ! Checking whether the MPI environment has been properly initialized + ! whether the MPI environment has been properly initialized if (ierr /= MPI_SUCCESS) then print '(A)', 'Unable to initialize MPI environment. Exiting.' call MPI_ABORT(MPI_COMM_WORLD, 1, ierr) end if - ! Querying the number of processors available for the job + ! the number of processors available for the job call MPI_COMM_SIZE(MPI_COMM_WORLD, num_procs, ierr) - ! Querying the rank of the local processor + ! the rank of the local processor call MPI_COMM_RANK(MPI_COMM_WORLD, proc_rank, ierr) #else - ! Serial run only has 1 processor + ! run only has 1 processor num_procs = 1 - ! Local processor rank is 0 + ! processor rank is 0 proc_rank = 0 #endif end subroutine s_mpi_initialize - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary - !! @param levelset closest distance from every cell to the IB - !! @param levelset_norm normalized vector from every cell to the closest point to the IB - !! @param beta Eulerian void fraction from lagrangian bubbles + !! Conservative variables + !! track if a cell is within the immersed boundary + !! closest distance from every cell to the IB + !! normalized vector from every cell to the closest point to the IB + !! Eulerian void fraction from lagrangian bubbles impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, levelset, levelset_norm, beta) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -140,7 +140,7 @@ contains #ifdef MFC_MPI - ! Generic loop iterator + ! loop iterator integer :: i, j integer :: ierr !< Generic flag used to identify and report MPI errors @@ -176,7 +176,7 @@ contains end do end if - ! Define global(g) and local(l) sizes for flow variables + ! global(g) and local(l) sizes for flow variables sizes_glb(1) = m_glb + 1; sizes_loc(1) = m + 1 if (n > 0) then sizes_glb(2) = n_glb + 1; sizes_loc(2) = n + 1 @@ -185,7 +185,7 @@ contains end if end if - ! Define the view for each variable + ! the view for each variable do i = 1, alt_sys call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_glb, sizes_loc, start_idx, & MPI_ORDER_FORTRAN, mpi_p, MPI_IO_DATA%view(i), ierr) @@ -277,7 +277,7 @@ contains end subroutine s_initialize_mpi_data - !! @param q_cons_vf Conservative variables + !! Conservative variables subroutine s_initialize_mpi_data_ds(q_cons_vf) type(scalar_field), & @@ -289,7 +289,7 @@ contains #ifdef MFC_MPI - ! Generic loop iterator + ! loop iterator integer :: i, j, q, k, l, m_ds, n_ds, p_ds, ierr sf_start_idx = (/0, 0, 0/) @@ -309,7 +309,7 @@ contains MPI_IO_DATA%var(i)%sf => q_cons_vf(i)%sf(-1:m_ds + 1, -1:n_ds + 1, -1:p_ds + 1) end do #endif - ! Define global(g) and local(l) sizes for flow variables + ! global(g) and local(l) sizes for flow variables sizes_loc(1) = m_ds + 3 if (n > 0) then sizes_loc(2) = n_ds + 3 @@ -318,7 +318,7 @@ contains end if end if - ! Define the view for each variable + ! the view for each variable do i = 1, sys_size call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_loc, sizes_loc, sf_start_idx, & MPI_ORDER_FORTRAN, mpi_p, MPI_IO_DATA%view(i), ierr) @@ -388,19 +388,19 @@ contains end subroutine s_prohibit_abort !> The goal of this subroutine is to determine the global - !! extrema of the stability criteria in the computational - !! domain. This is performed by sifting through the local - !! extrema of each stability criterion. Note that each of - !! the local extrema is from a single process, within its - !! assigned section of the computational domain. Finally, - !! note that the global extrema values are only bookkeept - !! on the rank 0 processor. - !! @param icfl_max_loc Local maximum ICFL stability criterion - !! @param vcfl_max_loc Local maximum VCFL stability criterion - !! @param Rc_min_loc Local minimum Rc stability criterion - !! @param icfl_max_glb Global maximum ICFL stability criterion - !! @param vcfl_max_glb Global maximum VCFL stability criterion - !! @param Rc_min_glb Global minimum Rc stability criterion + !! the stability criteria in the computational + !! is performed by sifting through the local + !! each stability criterion. Note that each of + !! extrema is from a single process, within its + !! of the computational domain. Finally, + !! the global extrema values are only bookkeept + !! rank 0 processor. + !! Local maximum ICFL stability criterion + !! Local maximum VCFL stability criterion + !! Local minimum Rc stability criterion + !! Global maximum ICFL stability criterion + !! Global maximum VCFL stability criterion + !! Global minimum Rc stability criterion impure subroutine s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, & vcfl_max_loc, & Rc_min_loc, & @@ -420,8 +420,8 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Reducing local extrema of ICFL, VCFL, CCFL and Rc numbers to their - ! global extrema and bookkeeping the results on the rank 0 processor + ! local extrema of ICFL, VCFL, CCFL and Rc numbers to their + ! extrema and bookkeeping the results on the rank 0 processor call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, & mpi_p, MPI_MAX, 0, & MPI_COMM_WORLD, ierr) @@ -450,12 +450,12 @@ contains end subroutine s_mpi_reduce_stability_criteria_extrema !> The following subroutine takes the input local variable - !! from all processors and reduces to the sum of all - !! values. The reduced variable is recorded back onto the - !! original local variable on each processor. - !! @param var_loc Some variable containing the local value which should be - !! reduced amongst all the processors in the communicator. - !! @param var_glb The globally reduced value + !! processors and reduces to the sum of all + !! reduced variable is recorded back onto the + !! variable on each processor. + !! Some variable containing the local value which should be + !! all the processors in the communicator. + !! The globally reduced value impure subroutine s_mpi_allreduce_sum(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -464,7 +464,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Performing the reduction procedure + ! the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_SUM, MPI_COMM_WORLD, ierr) @@ -483,7 +483,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Performing the reduction procedure + ! the reduction procedure if (loc(var_loc) == loc(var_glb)) then call MPI_Allreduce(MPI_IN_PLACE, var_glb, num_vectors*vector_length, & mpi_p, MPI_SUM, MPI_COMM_WORLD, ierr) @@ -499,12 +499,12 @@ contains end subroutine s_mpi_allreduce_vectors_sum !> The following subroutine takes the input local variable - !! from all processors and reduces to the sum of all - !! values. The reduced variable is recorded back onto the - !! original local variable on each processor. - !! @param var_loc Some variable containing the local value which should be - !! reduced amongst all the processors in the communicator. - !! @param var_glb The globally reduced value + !! processors and reduces to the sum of all + !! reduced variable is recorded back onto the + !! variable on each processor. + !! Some variable containing the local value which should be + !! all the processors in the communicator. + !! The globally reduced value impure subroutine s_mpi_allreduce_integer_sum(var_loc, var_glb) integer, intent(in) :: var_loc @@ -513,7 +513,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Performing the reduction procedure + ! the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, MPI_INTEGER, & MPI_SUM, MPI_COMM_WORLD, ierr) #else @@ -523,12 +523,12 @@ contains end subroutine s_mpi_allreduce_integer_sum !> The following subroutine takes the input local variable - !! from all processors and reduces to the minimum of all - !! values. The reduced variable is recorded back onto the - !! original local variable on each processor. - !! @param var_loc Some variable containing the local value which should be - !! reduced amongst all the processors in the communicator. - !! @param var_glb The globally reduced value + !! processors and reduces to the minimum of all + !! reduced variable is recorded back onto the + !! variable on each processor. + !! Some variable containing the local value which should be + !! all the processors in the communicator. + !! The globally reduced value impure subroutine s_mpi_allreduce_min(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -537,7 +537,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Performing the reduction procedure + ! the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MIN, MPI_COMM_WORLD, ierr) @@ -546,12 +546,12 @@ contains end subroutine s_mpi_allreduce_min !> The following subroutine takes the input local variable - !! from all processors and reduces to the maximum of all - !! values. The reduced variable is recorded back onto the - !! original local variable on each processor. - !! @param var_loc Some variable containing the local value which should be - !! reduced amongst all the processors in the communicator. - !! @param var_glb The globally reduced value + !! processors and reduces to the maximum of all + !! reduced variable is recorded back onto the + !! variable on each processor. + !! Some variable containing the local value which should be + !! all the processors in the communicator. + !! The globally reduced value impure subroutine s_mpi_allreduce_max(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -560,7 +560,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Performing the reduction procedure + ! the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MAX, MPI_COMM_WORLD, ierr) @@ -569,11 +569,11 @@ contains end subroutine s_mpi_allreduce_max !> The following subroutine takes the inputted variable and - !! determines its minimum value on the entire computational - !! domain. The result is stored back into inputted variable. - !! @param var_loc holds the local value to be reduced among - !! all the processors in communicator. On output, the variable holds - !! the minimum value, reduced amongst all of the local values. + !! minimum value on the entire computational + !! result is stored back into inputted variable. + !! holds the local value to be reduced among + !! processors in communicator. On output, the variable holds + !! value, reduced amongst all of the local values. impure subroutine s_mpi_reduce_min(var_loc) real(wp), intent(inout) :: var_loc @@ -581,11 +581,11 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Temporary storage variable that holds the reduced minimum value + ! storage variable that holds the reduced minimum value real(wp) :: var_glb - ! Performing reduction procedure and eventually storing its result - ! into the variable that was initially inputted into the subroutine + ! reduction procedure and eventually storing its result + ! the variable that was initially inputted into the subroutine call MPI_REDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MIN, 0, MPI_COMM_WORLD, ierr) @@ -599,17 +599,17 @@ contains end subroutine s_mpi_reduce_min !> The following subroutine takes the first element of the - !! 2-element inputted variable and determines its maximum - !! value on the entire computational domain. The result is - !! stored back into the first element of the variable while - !! the rank of the processor that is in charge of the sub- - !! domain containing the maximum is stored into the second - !! element of the variable. - !! @param var_loc On input, this variable holds the local value and processor rank, - !! which are to be reduced among all the processors in communicator. - !! On output, this variable holds the maximum value, reduced amongst - !! all of the local values, and the process rank to which the value - !! belongs. + !! variable and determines its maximum + !! the entire computational domain. The result is + !! into the first element of the variable while + !! of the processor that is in charge of the sub- + !! the maximum is stored into the second + !! the variable. + !! On input, this variable holds the local value and processor rank, + !! to be reduced among all the processors in communicator. + !! this variable holds the maximum value, reduced amongst + !! the local values, and the process rank to which the value + !! impure subroutine s_mpi_reduce_maxloc(var_loc) real(wp), dimension(2), intent(inout) :: var_loc @@ -618,11 +618,11 @@ contains integer :: ierr !< Generic flag used to identify and report MPI errors real(wp), dimension(2) :: var_glb !< - !! Temporary storage variable that holds the reduced maximum value - !! and the rank of the processor with which the value is associated + !! variable that holds the reduced maximum value + !! rank of the processor with which the value is associated - ! Performing reduction procedure and eventually storing its result - ! into the variable that was initially inputted into the subroutine + ! reduction procedure and eventually storing its result + ! the variable that was initially inputted into the subroutine call MPI_REDUCE(var_loc, var_glb, 1, mpi_2p, & MPI_MAXLOC, 0, MPI_COMM_WORLD, ierr) @@ -636,7 +636,7 @@ contains end subroutine s_mpi_reduce_maxloc !> The subroutine terminates the MPI execution environment. - !! @param prnt error message to be printed + !! error message to be printed impure subroutine s_mpi_abort(prnt, code) character(len=*), intent(in), optional :: prnt @@ -659,7 +659,7 @@ contains stop 1 end if #else - ! Terminating the MPI environment + ! the MPI environment if (present(code)) then call MPI_ABORT(MPI_COMM_WORLD, code, ierr) else @@ -675,7 +675,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Calling MPI_BARRIER + ! MPI_BARRIER call MPI_BARRIER(MPI_COMM_WORLD, ierr) #endif @@ -688,7 +688,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Finalizing the MPI environment + ! the MPI environment call MPI_FINALIZE(ierr) #endif @@ -696,11 +696,11 @@ contains end subroutine s_mpi_finalize !> The goal of this procedure is to populate the buffers of - !! the cell-average conservative variables by communicating - !! with the neighboring processors. - !! @param q_cons_vf Cell-average conservative variables - !! @param mpi_dir MPI communication coordinate direction - !! @param pbc_loc Processor boundary condition (PBC) location + !! conservative variables by communicating + !! neighboring processors. + !! Cell-average conservative variables + !! MPI communication coordinate direction + !! Processor boundary condition (PBC) location subroutine s_mpi_sendrecv_variables_buffers(q_comm, & mpi_dir, & pbc_loc, & @@ -754,12 +754,12 @@ contains beg_end = (/boundary_conditions(mpi_dir)%beg, boundary_conditions(mpi_dir)%end/) beg_end_geq_0 = beg_end(max(pbc_loc, 0) - pbc_loc + 1) >= 0 - ! Implements: - ! pbc_loc bc_x >= 0 -> [send/recv]_tag [dst/src]_proc - ! -1 (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] - ! -1 (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] - ! +1 (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] - ! +1 (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] + ! + ! bc_x >= 0 -> [send/recv]_tag [dst/src]_proc + ! (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] + ! (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] + ! (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] + ! (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] send_tag = f_logical_to_int(.not. f_xor(beg_end_geq_0, pbc_loc == 1)) recv_tag = f_logical_to_int(pbc_loc == 1) @@ -779,7 +779,7 @@ contains unpack_offset = grid_dims(mpi_dir) + buff_size + 1 end if - ! Pack Buffer to Send + ! Buffer to Send #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then #:if mpi_dir == 1 @@ -936,7 +936,7 @@ contains #:endfor call nvtxEndRange ! Packbuf - ! Send/Recv + ! #ifdef MFC_SIMULATION #:for rdma_mpi in [False, True] if (rdma_mpi .eqv. ${'.true.' if rdma_mpi else '.false.'}$) then @@ -979,7 +979,7 @@ contains MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr) #endif - ! Unpack Received Buffer + ! Received Buffer call nvtxStartRange("RHS-COMM-UNPACKBUF") #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then @@ -1095,7 +1095,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if #:else - ! Unpacking buffer from bc_z%beg + ! buffer from bc_z%beg $:GPU_PARALLEL_LOOP(collapse=4,private='[r]') do i = 1, nVar do l = -buff_size, -1 @@ -1164,33 +1164,33 @@ contains end subroutine s_mpi_sendrecv_variables_buffers !> The purpose of this procedure is to optimally decompose - !! the computational domain among the available processors. - !! This is performed by attempting to award each processor, - !! in each of the coordinate directions, approximately the - !! same number of cells, and then recomputing the affected - !! global parameters. + !! domain among the available processors. + !! performed by attempting to award each processor, + !! of the coordinate directions, approximately the + !! of cells, and then recomputing the affected + !! subroutine s_mpi_decompose_computational_domain #ifdef MFC_MPI integer :: num_procs_x, num_procs_y, num_procs_z !< - !! Optimal number of processors in the x-, y- and z-directions + !! of processors in the x-, y- and z-directions real(wp) :: tmp_num_procs_x, tmp_num_procs_y, tmp_num_procs_z !< - !! Non-optimal number of processors in the x-, y- and z-directions + !! of processors in the x-, y- and z-directions real(wp) :: fct_min !< - !! Processor factorization (fct) minimization parameter + !! (fct) minimization parameter integer :: MPI_COMM_CART !< - !! Cartesian processor topology communicator + !! topology communicator integer :: rem_cells !< - !! Remaining number of cells, in a particular coordinate direction, - !! after the majority is divided up among the available processors + !! of cells, in a particular coordinate direction, + !! majority is divided up among the available processors integer :: recon_order !< - !! WENO or MUSCL reconstruction order + !! MUSCL reconstruction order integer :: i, j !< Generic loop iterators integer :: ierr !< Generic flag used to identify and report MPI errors @@ -1214,25 +1214,25 @@ contains recon_order = weno_order end if - ! 3D Cartesian Processor Topology + ! Cartesian Processor Topology if (n > 0) then if (p > 0) then if (fft_wrt) then - ! Initial estimate of optimal processor topology + ! estimate of optimal processor topology num_procs_x = 1 num_procs_y = 1 num_procs_z = num_procs ierr = -1 - ! Benchmarking the quality of this initial guess + ! the quality of this initial guess tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z fct_min = 10._wp*abs((n + 1)/tmp_num_procs_y & - (p + 1)/tmp_num_procs_z) - ! Optimization of the initial processor topology + ! of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1263,24 +1263,24 @@ contains else if (cyl_coord .and. p > 0) then - ! Implement pencil processor blocking if using cylindrical coordinates so - ! that all cells in azimuthal direction are stored on a single processor. - ! This is necessary for efficient application of Fourier filter near axis. + ! pencil processor blocking if using cylindrical coordinates so + ! all cells in azimuthal direction are stored on a single processor. + ! is necessary for efficient application of Fourier filter near axis. - ! Initial values of the processor factorization optimization + ! values of the processor factorization optimization num_procs_x = 1 num_procs_y = num_procs num_procs_z = 1 ierr = -1 - ! Computing minimization variable for these initial values + ! minimization variable for these initial values tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z fct_min = 10._wp*abs((m + 1)/tmp_num_procs_x & - (n + 1)/tmp_num_procs_y) - ! Searching for optimal computational domain distribution + ! for optimal computational domain distribution do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1311,13 +1311,13 @@ contains else - ! Initial estimate of optimal processor topology + ! estimate of optimal processor topology num_procs_x = 1 num_procs_y = 1 num_procs_z = num_procs ierr = -1 - ! Benchmarking the quality of this initial guess + ! the quality of this initial guess tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z @@ -1326,7 +1326,7 @@ contains + 10._wp*abs((n + 1)/tmp_num_procs_y & - (p + 1)/tmp_num_procs_z) - ! Optimization of the initial processor topology + ! of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1375,41 +1375,41 @@ contains end if end if - ! Verifying that a valid decomposition of the computational - ! domain has been established. If not, the simulation exits. + ! that a valid decomposition of the computational + ! has been established. If not, the simulation exits. if (proc_rank == 0 .and. ierr == -1) then call s_mpi_abort('Unsupported combination of values '// & 'of num_procs, m, n, p and '// & 'weno/muscl/igr_order. Exiting.') end if - ! Creating new communicator using the Cartesian topology + ! new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 3, (/num_procs_x, & num_procs_y, num_procs_z/), & (/.true., .true., .true./), & .false., MPI_COMM_CART, ierr) - ! Finding the Cartesian coordinates of the local process + ! the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 3, & proc_coords, ierr) - ! END: 3D Cartesian Processor Topology + ! 3D Cartesian Processor Topology - ! Global Parameters for z-direction + ! Parameters for z-direction - ! Number of remaining cells + ! of remaining cells rem_cells = mod(p + 1, num_procs_z) - ! Optimal number of cells per processor + ! number of cells per processor p = (p + 1)/num_procs_z - 1 - ! Distributing the remaining cells + ! the remaining cells do i = 1, rem_cells if (proc_coords(3) == i - 1) then p = p + 1; exit end if end do - ! Boundary condition at the beginning + ! condition at the beginning if (proc_coords(3) > 0 .or. (bc_z%beg == BC_PERIODIC .and. num_procs_z > 1)) then proc_coords(3) = proc_coords(3) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1417,7 +1417,7 @@ contains proc_coords(3) = proc_coords(3) + 1 end if - ! Boundary condition at the end + ! condition at the end if (proc_coords(3) < num_procs_z - 1 .or. (bc_z%end == BC_PERIODIC .and. num_procs_z > 1)) then proc_coords(3) = proc_coords(3) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1426,14 +1426,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! Ghost zone at the beginning + ! zone at the beginning if (proc_coords(3) > 0 .and. format == 1) then offset_z%beg = 2 else offset_z%beg = 0 end if - ! Ghost zone at the end + ! zone at the end if (proc_coords(3) < num_procs_z - 1 .and. format == 1) then offset_z%end = 2 else @@ -1441,7 +1441,7 @@ contains end if #endif - ! Beginning and end sub-domain boundary locations + ! and end sub-domain boundary locations if (parallel_io) then if (proc_coords(3) < rem_cells) then start_idx(3) = (p + 1)*proc_coords(3) @@ -1469,21 +1469,21 @@ contains #endif end if - ! 2D Cartesian Processor Topology + ! Cartesian Processor Topology else - ! Initial estimate of optimal processor topology + ! estimate of optimal processor topology num_procs_x = 1 num_procs_y = num_procs ierr = -1 - ! Benchmarking the quality of this initial guess + ! the quality of this initial guess tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y fct_min = 10._wp*abs((m + 1)/tmp_num_procs_x & - (n + 1)/tmp_num_procs_y) - ! Optimization of the initial processor topology + ! of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1512,43 +1512,43 @@ contains end do - ! Verifying that a valid decomposition of the computational - ! domain has been established. If not, the simulation exits. + ! that a valid decomposition of the computational + ! has been established. If not, the simulation exits. if (proc_rank == 0 .and. ierr == -1) then call s_mpi_abort('Unsupported combination of values '// & 'of num_procs, m, n and '// & 'weno/muscl/igr_order. Exiting.') end if - ! Creating new communicator using the Cartesian topology + ! new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 2, (/num_procs_x, & num_procs_y/), (/.true., & .true./), .false., MPI_COMM_CART, & ierr) - ! Finding the Cartesian coordinates of the local process + ! the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 2, & proc_coords, ierr) end if - ! END: 2D Cartesian Processor Topology + ! 2D Cartesian Processor Topology - ! Global Parameters for y-direction + ! Parameters for y-direction - ! Number of remaining cells + ! of remaining cells rem_cells = mod(n + 1, num_procs_y) - ! Optimal number of cells per processor + ! number of cells per processor n = (n + 1)/num_procs_y - 1 - ! Distributing the remaining cells + ! the remaining cells do i = 1, rem_cells if (proc_coords(2) == i - 1) then n = n + 1; exit end if end do - ! Boundary condition at the beginning + ! condition at the beginning if (proc_coords(2) > 0 .or. (bc_y%beg == BC_PERIODIC .and. num_procs_y > 1)) then proc_coords(2) = proc_coords(2) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1556,7 +1556,7 @@ contains proc_coords(2) = proc_coords(2) + 1 end if - ! Boundary condition at the end + ! condition at the end if (proc_coords(2) < num_procs_y - 1 .or. (bc_y%end == BC_PERIODIC .and. num_procs_y > 1)) then proc_coords(2) = proc_coords(2) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1565,14 +1565,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! Ghost zone at the beginning + ! zone at the beginning if (proc_coords(2) > 0 .and. format == 1) then offset_y%beg = 2 else offset_y%beg = 0 end if - ! Ghost zone at the end + ! zone at the end if (proc_coords(2) < num_procs_y - 1 .and. format == 1) then offset_y%end = 2 else @@ -1580,7 +1580,7 @@ contains end if #endif - ! Beginning and end sub-domain boundary locations + ! and end sub-domain boundary locations if (parallel_io) then if (proc_coords(2) < rem_cells) then start_idx(2) = (n + 1)*proc_coords(2) @@ -1608,32 +1608,32 @@ contains #endif end if - ! 1D Cartesian Processor Topology + ! Cartesian Processor Topology else - ! Optimal processor topology + ! processor topology num_procs_x = num_procs - ! Creating new communicator using the Cartesian topology + ! new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 1, (/num_procs_x/), & (/.true./), .false., MPI_COMM_CART, & ierr) - ! Finding the Cartesian coordinates of the local process + ! the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 1, & proc_coords, ierr) end if - ! Global Parameters for x-direction + ! Parameters for x-direction - ! Number of remaining cells + ! of remaining cells rem_cells = mod(m + 1, num_procs_x) - ! Optimal number of cells per processor + ! number of cells per processor m = (m + 1)/num_procs_x - 1 - ! Distributing the remaining cells + ! the remaining cells do i = 1, rem_cells if (proc_coords(1) == i - 1) then m = m + 1; exit @@ -1642,14 +1642,14 @@ contains call s_update_cell_bounds(cells_bounds, m, n, p) - ! Boundary condition at the beginning + ! condition at the beginning if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%beg, ierr) proc_coords(1) = proc_coords(1) + 1 end if - ! Boundary condition at the end + ! condition at the end if (proc_coords(1) < num_procs_x - 1 .or. (bc_x%end == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%end, ierr) @@ -1657,14 +1657,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! Ghost zone at the beginning + ! zone at the beginning if (proc_coords(1) > 0 .and. format == 1) then offset_x%beg = 2 else offset_x%beg = 0 end if - ! Ghost zone at the end + ! zone at the end if (proc_coords(1) < num_procs_x - 1 .and. format == 1) then offset_x%end = 2 else @@ -1672,7 +1672,7 @@ contains end if #endif - ! Beginning and end sub-domain boundary locations + ! and end sub-domain boundary locations if (parallel_io) then if (proc_coords(1) < rem_cells) then start_idx(1) = (m + 1)*proc_coords(1) @@ -1704,13 +1704,13 @@ contains end subroutine s_mpi_decompose_computational_domain !> The goal of this procedure is to populate the buffers of - !! the grid variables by communicating with the neighboring - !! processors. Note that only the buffers of the cell-width - !! distributions are handled in such a way. This is because - !! the buffers of cell-boundary locations may be calculated - !! directly from those of the cell-width distributions. - !! @param mpi_dir MPI communication coordinate direction - !! @param pbc_loc Processor boundary condition (PBC) location + !! variables by communicating with the neighboring + !! that only the buffers of the cell-width + !! handled in such a way. This is because + !! of cell-boundary locations may be calculated + !! those of the cell-width distributions. + !! MPI communication coordinate direction + !! Processor boundary condition (PBC) location #ifndef MFC_PRE_PROCESS subroutine s_mpi_sendrecv_grid_variables_buffers(mpi_dir, pbc_loc) @@ -1720,14 +1720,14 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! MPI Communication in x-direction + ! Communication in x-direction if (mpi_dir == 1) then if (pbc_loc == -1) then ! PBC at the beginning if (bc_x%end >= 0) then ! PBC at the beginning and end - ! Send/receive buffer to/from bc_x%end/bc_x%beg + ! buffer to/from bc_x%end/bc_x%beg call MPI_SENDRECV( & dx(m - buff_size + 1), buff_size, & mpi_p, bc_x%end, 0, & @@ -1737,7 +1737,7 @@ contains else ! PBC at the beginning only - ! Send/receive buffer to/from bc_x%beg/bc_x%beg + ! buffer to/from bc_x%beg/bc_x%beg call MPI_SENDRECV( & dx(0), buff_size, & mpi_p, bc_x%beg, 1, & @@ -1751,7 +1751,7 @@ contains if (bc_x%beg >= 0) then ! PBC at the end and beginning - ! Send/receive buffer to/from bc_x%beg/bc_x%end + ! buffer to/from bc_x%beg/bc_x%end call MPI_SENDRECV( & dx(0), buff_size, & mpi_p, bc_x%beg, 1, & @@ -1761,7 +1761,7 @@ contains else ! PBC at the end only - ! Send/receive buffer to/from bc_x%end/bc_x%end + ! buffer to/from bc_x%end/bc_x%end call MPI_SENDRECV( & dx(m - buff_size + 1), buff_size, & mpi_p, bc_x%end, 0, & @@ -1772,16 +1772,16 @@ contains end if end if - ! END: MPI Communication in x-direction + ! MPI Communication in x-direction - ! MPI Communication in y-direction + ! Communication in y-direction elseif (mpi_dir == 2) then if (pbc_loc == -1) then ! PBC at the beginning if (bc_y%end >= 0) then ! PBC at the beginning and end - ! Send/receive buffer to/from bc_y%end/bc_y%beg + ! buffer to/from bc_y%end/bc_y%beg call MPI_SENDRECV( & dy(n - buff_size + 1), buff_size, & mpi_p, bc_y%end, 0, & @@ -1791,7 +1791,7 @@ contains else ! PBC at the beginning only - ! Send/receive buffer to/from bc_y%beg/bc_y%beg + ! buffer to/from bc_y%beg/bc_y%beg call MPI_SENDRECV( & dy(0), buff_size, & mpi_p, bc_y%beg, 1, & @@ -1805,7 +1805,7 @@ contains if (bc_y%beg >= 0) then ! PBC at the end and beginning - ! Send/receive buffer to/from bc_y%beg/bc_y%end + ! buffer to/from bc_y%beg/bc_y%end call MPI_SENDRECV( & dy(0), buff_size, & mpi_p, bc_y%beg, 1, & @@ -1815,7 +1815,7 @@ contains else ! PBC at the end only - ! Send/receive buffer to/from bc_y%end/bc_y%end + ! buffer to/from bc_y%end/bc_y%end call MPI_SENDRECV( & dy(n - buff_size + 1), buff_size, & mpi_p, bc_y%end, 0, & @@ -1826,16 +1826,16 @@ contains end if end if - ! END: MPI Communication in y-direction + ! MPI Communication in y-direction - ! MPI Communication in z-direction + ! Communication in z-direction else if (pbc_loc == -1) then ! PBC at the beginning if (bc_z%end >= 0) then ! PBC at the beginning and end - ! Send/receive buffer to/from bc_z%end/bc_z%beg + ! buffer to/from bc_z%end/bc_z%beg call MPI_SENDRECV( & dz(p - buff_size + 1), buff_size, & mpi_p, bc_z%end, 0, & @@ -1845,7 +1845,7 @@ contains else ! PBC at the beginning only - ! Send/receive buffer to/from bc_z%beg/bc_z%beg + ! buffer to/from bc_z%beg/bc_z%beg call MPI_SENDRECV( & dz(0), buff_size, & mpi_p, bc_z%beg, 1, & @@ -1859,7 +1859,7 @@ contains if (bc_z%beg >= 0) then ! PBC at the end and beginning - ! Send/receive buffer to/from bc_z%beg/bc_z%end + ! buffer to/from bc_z%beg/bc_z%end call MPI_SENDRECV( & dz(0), buff_size, & mpi_p, bc_z%beg, 1, & @@ -1869,7 +1869,7 @@ contains else ! PBC at the end only - ! Send/receive buffer to/from bc_z%end/bc_z%end + ! buffer to/from bc_z%end/bc_z%end call MPI_SENDRECV( & dz(p - buff_size + 1), buff_size, & mpi_p, bc_z%end, 0, & @@ -1882,7 +1882,7 @@ contains end if end if - ! END: MPI Communication in z-direction + ! MPI Communication in z-direction #endif end subroutine s_mpi_sendrecv_grid_variables_buffers diff --git a/src/common/m_phase_change.fpp b/src/common/m_phase_change.fpp index 703b78c430..e10428175f 100644 --- a/src/common/m_phase_change.fpp +++ b/src/common/m_phase_change.fpp @@ -47,21 +47,21 @@ module m_phase_change contains !> This subroutine should dispatch to the correct relaxation solver based - !! some parameter. It replaces the procedure pointer, which CCE - !! is breaking on. + !! It replaces the procedure pointer, which CCE + !! on. impure subroutine s_relaxation_solver(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf - ! This is empty because in current master the procedure pointer - ! was never assigned + ! is empty because in current master the procedure pointer + ! never assigned @:ASSERT(.false., "s_relaxation_solver called but it currently does nothing") end subroutine s_relaxation_solver !> The purpose of this subroutine is to initialize the phase change module - !! by setting the parameters needed for phase change and - !! selecting the phase change module that will be used - !! (pT- or pTg-equilibrium) + !! the parameters needed for phase change and + !! phase change module that will be used + !! pTg-equilibrium) impure subroutine s_initialize_phasechange_module - ! variables used in the calculation of the saturation curves for fluids 1 and 2 + ! used in the calculation of the saturation curves for fluids 1 and 2 A = (gs_min(lp)*cvs(lp) - gs_min(vp)*cvs(vp) & + qvps(vp) - qvps(lp))/((gs_min(vp) - 1.0_wp)*cvs(vp)) @@ -76,10 +76,10 @@ contains end subroutine s_initialize_phasechange_module !> This subroutine is created to activate either the pT- (N fluids) or the - !! pTg-equilibrium (2 fluids for g-equilibrium) - !! model, also considering mass depletion, depending on the incoming - !! state conditions. - !! @param q_cons_vf Cell-average conservative variables + !! fluids for g-equilibrium) + !! considering mass depletion, depending on the incoming + !! + !! Cell-average conservative variables subroutine s_infinite_relaxation_k(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -89,19 +89,19 @@ contains real(wp) :: rho, rM, m1, m2, MCT !< total density, total reacting mass, individual reacting masses real(wp) :: TvF !< total volume fraction - ! $:GPU_DECLARE(create='[pS,pSOV,pSSL,TS,TSOV,TSSL,TSatOV,TSatSL]') - ! $:GPU_DECLARE(create='[rhoe,dynE,rhos,rho,rM,m1,m2,MCT,TvF]') + ! + ! #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok #:else real(wp), dimension(num_fluids) :: p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok #:endif - ! $:GPU_DECLARE(create='[p_infOV,p_infpT,p_infSL,sk,hk,gk,ek,rhok]') + ! !< Generic loop iterators integer :: i, j, k, l - ! starting equilibrium solver + ! equilibrium solver $:GPU_PARALLEL_LOOP(collapse=3, private='[i,j,k,l,p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok,pS, pSOV, pSSL, TS, TSOV, TSatOV, TSatSL, TSSL, rhoe, dynE, rhos, rho, rM, m1, m2, MCT, TvF]') do j = 0, m do k = 0, n @@ -111,28 +111,28 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! Mixture density + ! density rho = rho + q_cons_vf(i + contxb - 1)%sf(j, k, l) - ! Total Volume Fraction + ! Volume Fraction TvF = TvF + q_cons_vf(i + advxb - 1)%sf(j, k, l) end do - ! calculating the total reacting mass for the phase change process. By hypothesis, this should not change - ! throughout the phase-change process. + ! the total reacting mass for the phase change process. By hypothesis, this should not change + ! the phase-change process. rM = q_cons_vf(lp + contxb - 1)%sf(j, k, l) + q_cons_vf(vp + contxb - 1)%sf(j, k, l) - ! correcting negative (reacting) mass fraction values in case they happen + ! negative (reacting) mass fraction values in case they happen call s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l) - ! fixing m1 and m2 AFTER correcting the partial densities. Note that these values must be stored for the phase - ! change process that will happen a posteriori + ! m1 and m2 AFTER correcting the partial densities. Note that these values must be stored for the phase + ! process that will happen a posteriori m1 = q_cons_vf(lp + contxb - 1)%sf(j, k, l) m2 = q_cons_vf(vp + contxb - 1)%sf(j, k, l) - ! kinetic energy as an auxiliary variable to the calculation of the total internal energy + ! energy as an auxiliary variable to the calculation of the total internal energy dynE = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = momxb, momxe @@ -141,136 +141,136 @@ contains end do - ! calculating the total energy that MUST be preserved throughout the pT- and pTg-relaxation procedures - ! at each of the cells. The internal energy is calculated as the total energy minus the kinetic - ! energy to preserved its value at sharp interfaces + ! the total energy that MUST be preserved throughout the pT- and pTg-relaxation procedures + ! each of the cells. The internal energy is calculated as the total energy minus the kinetic + ! to preserved its value at sharp interfaces rhoe = q_cons_vf(E_idx)%sf(j, k, l) - dynE - ! Calling pT-equilibrium for either finishing phase-change module, or as an IC for the pTg-equilibrium - ! for this case, MFL cannot be either 0 or 1, so I chose it to be 2 + ! pT-equilibrium for either finishing phase-change module, or as an IC for the pTg-equilibrium + ! this case, MFL cannot be either 0 or 1, so I chose it to be 2 call s_infinite_pt_relaxation_k(j, k, l, 2, pS, p_infpT, q_cons_vf, rhoe, TS) - ! check if pTg-equilibrium is required - ! NOTE that NOTHING else needs to be updated OTHER than the individual partial densities - ! given the outputs from the pT- and pTg-equilibrium solvers are just p and one of the partial masses - ! (pTg- case) + ! if pTg-equilibrium is required + ! that NOTHING else needs to be updated OTHER than the individual partial densities + ! the outputs from the pT- and pTg-equilibrium solvers are just p and one of the partial masses + ! case) if ((relax_model == 6) .and. ((q_cons_vf(lp + contxb - 1)%sf(j, k, l) > mixM*rM) & .and. (q_cons_vf(vp + contxb - 1)%sf(j, k, l) > mixM*rM)) & .and. (pS < pCr) .and. (TS < TCr)) then - ! Checking if phase change is needed, by checking whether the final solution is either subcoooled - ! liquid or overheated vapor. + ! if phase change is needed, by checking whether the final solution is either subcoooled + ! or overheated vapor. - ! overheated vapor case - ! depleting the mass of liquid + ! vapor case + ! the mass of liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = mixM*rM - ! transferring the total mass to vapor + ! the total mass to vapor q_cons_vf(vp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! calling pT-equilibrium for overheated vapor, which is MFL = 0 + ! pT-equilibrium for overheated vapor, which is MFL = 0 call s_infinite_pt_relaxation_k(j, k, l, 0, pSOV, p_infOV, q_cons_vf, rhoe, TSOV) - ! calculating Saturation temperature + ! Saturation temperature call s_TSat(pSOV, TSatOV, TSOV) - ! subcooled liquid case - ! transferring the total mass to liquid + ! liquid case + ! the total mass to liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! depleting the mass of vapor + ! the mass of vapor q_cons_vf(vp + contxb - 1)%sf(j, k, l) = mixM*rM - ! calling pT-equilibrium for subcooled liquid, which is MFL = 1 + ! pT-equilibrium for subcooled liquid, which is MFL = 1 call s_infinite_pt_relaxation_k(j, k, l, 1, pSSL, p_infSL, q_cons_vf, rhoe, TSSL) - ! calculating Saturation temperature + ! Saturation temperature call s_TSat(pSSL, TSatSL, TSSL) - ! checking the conditions for overheated vapor and subcooled liquide + ! the conditions for overheated vapor and subcooled liquide if (TSOV > TSatOV) then - ! Assigning pressure + ! pressure pS = pSOV - ! Assigning Temperature + ! Temperature TS = TSOV - ! correcting the liquid partial density + ! the liquid partial density q_cons_vf(lp + contxb - 1)%sf(j, k, l) = mixM*rM - ! correcting the vapor partial density + ! the vapor partial density q_cons_vf(vp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM elseif (TSSL < TSatSL) then - ! Assigning pressure + ! pressure pS = pSSL - ! Assigning Temperature + ! Temperature TS = TSSL - ! correcting the liquid partial density + ! the liquid partial density q_cons_vf(lp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! correcting the vapor partial density + ! the vapor partial density q_cons_vf(vp + contxb - 1)%sf(j, k, l) = mixM*rM else - ! returning partial pressures to what they were from the homogeneous solver - ! liquid + ! partial pressures to what they were from the homogeneous solver + ! q_cons_vf(lp + contxb - 1)%sf(j, k, l) = m1 - ! vapor + ! q_cons_vf(vp + contxb - 1)%sf(j, k, l) = m2 - ! calling the pTg-equilibrium solver + ! the pTg-equilibrium solver call s_infinite_ptg_relaxation_k(j, k, l, pS, p_infpT, rhoe, q_cons_vf, TS) end if end if - ! Calculations AFTER equilibrium + ! AFTER equilibrium $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! entropy + ! sk(i) = cvs(i)*log((TS**gs_min(i)) & /((pS + ps_inf(i))**(gs_min(i) - 1.0_wp))) + qvps(i) - ! enthalpy + ! hk(i) = gs_min(i)*cvs(i)*TS & + qvs(i) - ! Gibbs-free energy + ! energy gk(i) = hk(i) - TS*sk(i) - ! densities + ! rhok(i) = (pS + ps_inf(i)) & /((gs_min(i) - 1)*cvs(i)*TS) - ! internal energy + ! energy ek(i) = (pS + gs_min(i) & *ps_inf(i))/(pS + ps_inf(i)) & *cvs(i)*TS + qvs(i) end do - ! calculating volume fractions, internal energies, and total entropy + ! volume fractions, internal energies, and total entropy rhos = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! volume fractions + ! fractions q_cons_vf(i + advxb - 1)%sf(j, k, l) = q_cons_vf(i + contxb - 1)%sf(j, k, l)/rhok(i) - ! alpha*rho*e + ! if (model_eqns == 3) then q_cons_vf(i + intxb - 1)%sf(j, k, l) = q_cons_vf(i + contxb - 1)%sf(j, k, l)*ek(i) end if - ! Total entropy + ! entropy rhos = rhos + q_cons_vf(i + contxb - 1)%sf(j, k, l)*sk(i) end do @@ -282,21 +282,21 @@ contains end subroutine s_infinite_relaxation_k !> This auxiliary subroutine is created to activate the pT-equilibrium for N fluids - !! @param j generic loop iterator for x direction - !! @param k generic loop iterator for y direction - !! @param l generic loop iterator for z direction - !! @param MFL flag that tells whether the fluid is gas (0), liquid (1), or a mixture (2) - !! @param pS equilibrium pressure at the interface - !! @param p_infpT stiffness for the participating fluids under pT-equilibrium - !! @param rM sum of the reacting masses - !! @param q_cons_vf Cell-average conservative variables - !! @param rhoe mixture energy - !! @param TS equilibrium temperature at the interface + !! generic loop iterator for x direction + !! generic loop iterator for y direction + !! generic loop iterator for z direction + !! flag that tells whether the fluid is gas (0), liquid (1), or a mixture (2) + !! equilibrium pressure at the interface + !! stiffness for the participating fluids under pT-equilibrium + !! sum of the reacting masses + !! Cell-average conservative variables + !! mixture energy + !! equilibrium temperature at the interface subroutine s_infinite_pt_relaxation_k(j, k, l, MFL, pS, p_infpT, q_cons_vf, rhoe, TS) $:GPU_ROUTINE(function_name='s_infinite_pt_relaxation_k', & & parallelism='[seq]', cray_inline=True) - ! initializing variables + ! variables integer, intent(in) :: j, k, l, MFL real(wp), intent(out) :: pS real(wp), dimension(1:), intent(out) :: p_infpT @@ -308,21 +308,21 @@ contains integer :: i, ns !< generic loop iterators - ! auxiliary variables for the pT-equilibrium solver + ! variables for the pT-equilibrium solver mCP = 0.0_wp; mQ = 0.0_wp; p_infpT_sum = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids p_infpT(i) = ps_inf(i) p_infpT_sum = p_infpT_sum + abs(p_infpT(i)) end do - ! Performing tests before initializing the pT-equilibrium + ! tests before initializing the pT-equilibrium $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! sum of the total alpha*rho*cp of the system + ! of the total alpha*rho*cp of the system mCP = mCP + q_cons_vf(i + contxb - 1)%sf(j, k, l)*cvs(i)*gs_min(i) - ! sum of the total alpha*rho*q of the system + ! of the total alpha*rho*q of the system mQ = mQ + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) end do @@ -336,16 +336,16 @@ contains end if #:endif - ! Checking energy constraint + ! energy constraint if ((rhoe - mQ - minval(p_infpT)) < 0.0_wp) then if ((MFL == 0) .or. (MFL == 1)) then - ! Assigning zero values for mass depletion cases - ! pressure + ! zero values for mass depletion cases + ! pS = 0.0_wp - ! temperature + ! TS = 0.0_wp return @@ -353,26 +353,26 @@ contains end if - ! calculating initial estimate for pressure in the pT-relaxation procedure. I will also use this variable to - ! iterate over the Newton's solver + ! initial estimate for pressure in the pT-relaxation procedure. I will also use this variable to + ! over the Newton's solver pO = 0.0_wp - ! Maybe improve this condition afterwards. As long as the initial guess is in between -min(ps_inf) - ! and infinity, a solution should be able to be found. + ! improve this condition afterwards. As long as the initial guess is in between -min(ps_inf) + ! infinity, a solution should be able to be found. pS = 1.0e4_wp - ! Newton Solver for the pT-equilibrium + ! Solver for the pT-equilibrium ns = 0 - ! change this relative error metric. 1.e4_wp is just arbitrary + ! this relative error metric. 1.e4_wp is just arbitrary do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1.e4_wp) .or. (ns == 0)) - ! increasing counter + ! counter ns = ns + 1 - ! updating old pressure + ! old pressure pO = pS - ! updating functions used in the Newton's solver + ! functions used in the Newton's solver gpp = 0.0_wp; gp = 0.0_wp; hp = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -387,26 +387,26 @@ contains hp = 1.0_wp/(rhoe + pS - mQ) + 1.0_wp/(pS + minval(p_infpT)) - ! updating common pressure for the newton solver + ! common pressure for the newton solver pS = pO + ((1.0_wp - gp)/gpp)/(1.0_wp - (1.0_wp - gp + abs(1.0_wp - gp)) & /(2.0_wp*gpp)*hp) end do - ! common temperature + ! temperature TS = (rhoe + pS - mQ)/mCP end subroutine s_infinite_pt_relaxation_k !> This auxiliary subroutine is created to activate the pTg-equilibrium for N fluids under pT - !! and 2 fluids under pTg-equilibrium. There is a final common p and T during relaxation - !! @param j generic loop iterator for x direction - !! @param k generic loop iterator for y direction - !! @param l generic loop iterator for z direction - !! @param pS equilibrium pressure at the interface - !! @param p_infpT stiffness for the participating fluids under pT-equilibrium - !! @param rhoe mixture energy - !! @param q_cons_vf Cell-average conservative variables - !! @param TS equilibrium temperature at the interface + !! fluids under pTg-equilibrium. There is a final common p and T during relaxation + !! generic loop iterator for x direction + !! generic loop iterator for y direction + !! generic loop iterator for z direction + !! equilibrium pressure at the interface + !! stiffness for the participating fluids under pT-equilibrium + !! mixture energy + !! Cell-average conservative variables + !! equilibrium temperature at the interface subroutine s_infinite_ptg_relaxation_k(j, k, l, pS, p_infpT, rhoe, q_cons_vf, TS) $:GPU_ROUTINE(function_name='s_infinite_ptg_relaxation_k', & & parallelism='[seq]', cray_inline=True) @@ -430,12 +430,12 @@ contains !< Generic loop iterators integer :: i, ns - ! pTg-equilibrium solution procedure - ! Newton Solver parameters - ! counter + ! solution procedure + ! Solver parameters + ! ns = 0 - ! Relaxation factor + ! factor Om = 1.0e-3_wp p_infpTg = p_infpT @@ -445,41 +445,41 @@ contains - gs_min(lp)*ps_inf(lp)/(gs_min(lp) - 1))/qvs(lp)))) .or. & ((pS >= 0.0_wp) .and. (pS < 1.0e-1_wp))) then - ! improve this initial condition + ! this initial condition pS = 1.0e4_wp end if - ! Loop until the solution for F(X) is satisfied - ! Check whether I need to use both absolute and relative values - ! for the residual, and how to do it adequately. - ! Dummy guess to start the pTg-equilibrium problem. - ! improve this initial condition + ! until the solution for F(X) is satisfied + ! whether I need to use both absolute and relative values + ! the residual, and how to do it adequately. + ! guess to start the pTg-equilibrium problem. + ! this initial condition R2D(1) = 0.0_wp; R2D(2) = 0.0_wp DeltamP(1) = 0.0_wp; DeltamP(2) = 0.0_wp do while (((sqrt(R2D(1)**2 + R2D(2)**2) > ptgalpha_eps) & .and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1.e6_wp))) & .or. (ns == 0)) - ! Updating counter for the iterative procedure + ! counter for the iterative procedure ns = ns + 1 - ! Auxiliary variables to help in the calculation of the residue + ! variables to help in the calculation of the residue mCP = 0.0_wp; mCPD = 0.0_wp; mCVGP = 0.0_wp; mCVGP2 = 0.0_wp; mQ = 0.0_wp; mQD = 0.0_wp - ! Those must be updated through the iterations, as they either depend on - ! the partial masses for all fluids, or on the equilibrium pressure + ! must be updated through the iterations, as they either depend on + ! partial masses for all fluids, or on the equilibrium pressure $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! sum of the total alpha*rho*cp of the system + ! of the total alpha*rho*cp of the system mCP = mCP + q_cons_vf(i + contxb - 1)%sf(j, k, l) & *cvs(i)*gs_min(i) - ! sum of the total alpha*rho*q of the system + ! of the total alpha*rho*q of the system mQ = mQ + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) - ! These auxiliary variables now need to be updated, as the partial densities now - ! vary at every iteration + ! auxiliary variables now need to be updated, as the partial densities now + ! at every iteration if ((i /= lp) .and. (i /= vp)) then mCVGP = mCVGP + q_cons_vf(i + contxb - 1)%sf(j, k, l) & @@ -490,7 +490,7 @@ contains mQD = mQD + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) - ! sum of the total alpha*rho*cp of the system + ! of the total alpha*rho*cp of the system mCPD = mCPD + q_cons_vf(i + contxb - 1)%sf(j, k, l)*cvs(i) & *gs_min(i) @@ -498,12 +498,12 @@ contains end do - ! calculating the (2D) Jacobian Matrix used in the solution of the pTg-quilibrium model + ! the (2D) Jacobian Matrix used in the solution of the pTg-quilibrium model - ! mass of the reacting liquid + ! of the reacting liquid ml = q_cons_vf(lp + contxb - 1)%sf(j, k, l) - ! mass of the two participating fluids + ! of the two participating fluids mT = q_cons_vf(lp + contxb - 1)%sf(j, k, l) & + q_cons_vf(vp + contxb - 1)%sf(j, k, l) @@ -526,19 +526,19 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))**2) & + mCVGP2)*TS**2 - ! F = (F1,F2) is the function whose roots we are looking for - ! x = (m1, p) are the independent variables. m1 = mass of the first participant fluid, p = pressure - ! F1 = 0 is the Gibbs free energy quality - ! F2 = 0 is the enforcement of the thermodynamic (total - kinectic) energy - ! dF1dm + ! = (F1,F2) is the function whose roots we are looking for + ! = (m1, p) are the independent variables. m1 = mass of the first participant fluid, p = pressure + ! = 0 is the Gibbs free energy quality + ! = 0 is the enforcement of the thermodynamic (total - kinectic) energy + ! Jac(1, 1) = dFdT*dTdm - ! dF1dp + ! Jac(1, 2) = dFdT*dTdp + TS & *(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) - ! dF2dm + ! Jac(2, 1) = (qvs(vp) - qvs(lp) & + (cvs(vp)*gs_min(vp) - cvs(lp)*gs_min(lp)) & /(ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & @@ -551,7 +551,7 @@ contains /((ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mT*cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp)) + mCVGP)**2))/1 - ! dF2dp + ! Jac(2, 2) = (1 + (ml*(cvs(vp)*gs_min(vp) - cvs(lp)*gs_min(lp)) & - mT*cvs(vp)*gs_min(vp) - mCPD) & *(ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp))**2 & @@ -561,41 +561,41 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mT*cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp)) + mCVGP)**2)/1 - ! intermediate elements of J^{-1} + ! elements of J^{-1} InvJac(1, 1) = Jac(2, 2) InvJac(1, 2) = -1.0_wp*Jac(1, 2) InvJac(2, 1) = -1.0_wp*Jac(2, 1) InvJac(2, 2) = Jac(1, 1) - ! elements of J^{T} + ! of J^{T} TJac(1, 1) = Jac(1, 1) TJac(1, 2) = Jac(2, 1) TJac(2, 1) = Jac(1, 2) TJac(2, 2) = Jac(2, 2) - ! dividing by det(J) + ! by det(J) InvJac = InvJac/(Jac(1, 1)*Jac(2, 2) - Jac(1, 2)*Jac(2, 1)) - ! calculating correction array for Newton's method + ! correction array for Newton's method DeltamP = -1.0_wp*(matmul(InvJac, R2D)) - ! updating two reacting 'masses'. Recall that inert 'masses' do not change during the phase change - ! liquid + ! two reacting 'masses'. Recall that inert 'masses' do not change during the phase change + ! q_cons_vf(lp + contxb - 1)%sf(j, k, l) = q_cons_vf(lp + contxb - 1)%sf(j, k, l) + Om*DeltamP(1) - ! gas + ! q_cons_vf(vp + contxb - 1)%sf(j, k, l) = q_cons_vf(vp + contxb - 1)%sf(j, k, l) - Om*DeltamP(1) - ! updating pressure + ! pressure pS = pS + Om*DeltamP(2) - ! calculating residuals, which are (i) the difference between the Gibbs Free energy of the gas and the liquid - ! and (ii) the energy before and after the phase-change process. + ! residuals, which are (i) the difference between the Gibbs Free energy of the gas and the liquid + ! (ii) the energy before and after the phase-change process. - ! mass of the reacting liquid + ! of the reacting liquid ml = q_cons_vf(lp + contxb - 1)%sf(j, k, l) - ! mass of the two participating fluids + ! of the two participating fluids mT = q_cons_vf(lp + contxb - 1)%sf(j, k, l) & + q_cons_vf(vp + contxb - 1)%sf(j, k, l) @@ -604,14 +604,14 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mCVGP) - ! Gibbs Free Energy Equality condition (DG) + ! Free Energy Equality condition (DG) R2D(1) = TS*((cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp)) & *(1 - log(TS)) - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pS + ps_inf(vp))) & + qvs(lp) - qvs(vp) - ! Constant Energy Process condition (DE) + ! Energy Process condition (DE) R2D(2) = (rhoe + pS & + ml*(qvs(vp) - qvs(lp)) - mT*qvs(vp) - mQD & + (ml*(gs_min(vp)*cvs(vp) - gs_min(lp)*cvs(lp)) & @@ -622,18 +622,18 @@ contains end do - ! common temperature + ! temperature TS = (rhoe + pS - mQ)/mCP end subroutine s_infinite_ptg_relaxation_k !> This auxiliary subroutine corrects the partial densities of the REACTING fluids in case one of them is negative - !! but their sum is positive. Inert phases are not corrected at this moment - !! @param MCT partial density correction parameter - !! @param q_cons_vf Cell-average conservative variables - !! @param rM sum of the reacting masses - !! @param j generic loop iterator for x direction - !! @param k generic loop iterator for y direction - !! @param l generic loop iterator for z direction + !! sum is positive. Inert phases are not corrected at this moment + !! partial density correction parameter + !! Cell-average conservative variables + !! sum of the reacting masses + !! generic loop iterator for x direction + !! generic loop iterator for y direction + !! generic loop iterator for z direction subroutine s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l) $:GPU_ROUTINE(function_name='s_correct_partial_densities', & & parallelism='[seq]', cray_inline=True) @@ -660,11 +660,11 @@ contains end if - ! Defining the correction in terms of an absolute value might not be the best practice. - ! Maybe a good way to do this is to partition the partial densities, giving a small percentage of the total reacting density + ! the correction in terms of an absolute value might not be the best practice. + ! a good way to do this is to partition the partial densities, giving a small percentage of the total reacting density MCT = 2*mixM - ! correcting the partial densities of the reacting fluids. What to do for the nonreacting ones? + ! the partial densities of the reacting fluids. What to do for the nonreacting ones? if (q_cons_vf(lp + contxb - 1)%sf(j, k, l) < 0.0_wp) then q_cons_vf(lp + contxb - 1)%sf(j, k, l) = MCT*rM @@ -681,10 +681,10 @@ contains end subroutine s_correct_partial_densities !> This auxiliary subroutine finds the Saturation temperature for a given - !! saturation pressure through a newton solver - !! @param pSat Saturation Pressure - !! @param TSat Saturation Temperature - !! @param TSIn equilibrium Temperature + !! through a newton solver + !! Saturation Pressure + !! Saturation Temperature + !! equilibrium Temperature elemental subroutine s_TSat(pSat, TSat, TSIn) $:GPU_ROUTINE(function_name='s_TSat',parallelism='[seq]', & & cray_inline=True) @@ -695,44 +695,44 @@ contains real(wp) :: dFdT, FT, Om !< auxiliary variables - ! Generic loop iterators + ! loop iterators integer :: ns if ((f_approx_equal(pSat, 0.0_wp)) .and. (f_approx_equal(TSIn, 0.0_wp))) then - ! assigning Saturation temperature + ! Saturation temperature TSat = 0.0_wp else - ! calculating initial estimate for temperature in the TSat procedure. I will also use this variable to - ! iterate over the Newton's solver + ! initial estimate for temperature in the TSat procedure. I will also use this variable to + ! over the Newton's solver TSat = TSIn - ! iteration counter + ! counter ns = 0 - ! underrelaxation factor + ! factor Om = 1.0e-3_wp do while ((abs(FT) > ptgalpha_eps) .or. (ns == 0)) - ! increasing counter + ! counter ns = ns + 1 - ! calculating residual + ! residual FT = TSat*((cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp)) & *(1 - log(TSat)) - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pSat + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pSat + ps_inf(vp))) & + qvs(lp) - qvs(vp) - ! calculating the jacobian + ! the jacobian dFdT = & -(cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp))*log(TSat) & - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pSat + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pSat + ps_inf(vp)) - ! updating saturation temperature + ! saturation temperature TSat = TSat - Om*FT/dFdT end do diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index d322810e84..502af29e38 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -1,14 +1,14 @@ !> -!! @file m_variables_conversion.f90 -!! @brief Contains module m_variables_conversion +!! +!! module m_variables_conversion #:include 'macros.fpp' #:include 'case.fpp' !> @brief This module consists of subroutines used in the conversion of the -!! conservative variables into the primitive ones and vice versa. In -!! addition, the module also contains the subroutines used to obtain -!! the mixture variables and the subroutines used to compute pressure. +!! into the primitive ones and vice versa. In +!! module also contains the subroutines used to obtain +!! variables and the subroutines used to compute pressure. module m_variables_conversion use m_derived_types !< Definitions of the derived types @@ -46,7 +46,7 @@ module m_variables_conversion #endif s_finalize_variables_conversion_module - !! In simulation, gammas, pi_infs, and qvs are already declared in m_global_variables + !! gammas, pi_infs, and qvs are already declared in m_global_variables #ifndef MFC_SIMULATION real(wp), allocatable, public, dimension(:) :: gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps $:GPU_DECLARE(create='[gammas,gs_min,pi_infs,ps_inf,cvs,qvs,qvps]') @@ -68,16 +68,16 @@ module m_variables_conversion contains !> Dispatch to the s_convert_mixture_to_mixture_variables - !! and s_convert_species_to_mixture_variables subroutines. - !! Replaces a procedure pointer. - !! @param q_vf Conservative or primitive variables - !! @param i First-coordinate cell index - !! @param j First-coordinate cell index - !! @param k First-coordinate cell index - !! @param rho Density - !! @param gamma Specific heat ratio function - !! @param pi_inf Liquid stiffness function - !! @param qv Fluid reference energy + !! subroutines. + !! procedure pointer. + !! Conservative or primitive variables + !! First-coordinate cell index + !! First-coordinate cell index + !! First-coordinate cell index + !! Density + !! Specific heat ratio function + !! Liquid stiffness function + !! Fluid reference energy subroutine s_convert_to_mixture_variables(q_vf, i, j, k, & rho, gamma, pi_inf, qv, Re_K, G_K, G) @@ -100,16 +100,16 @@ contains end subroutine s_convert_to_mixture_variables !> This procedure conditionally calculates the appropriate pressure - !! @param energy Energy - !! @param alf Void Fraction - !! @param dyn_p Dynamic Pressure - !! @param pi_inf Liquid Stiffness - !! @param gamma Specific Heat Ratio - !! @param rho Density - !! @param qv fluid reference energy - !! @param pres Pressure to calculate - !! @param stress Shear Stress - !! @param mom Momentum + !! Energy + !! Void Fraction + !! Dynamic Pressure + !! Liquid Stiffness + !! Specific Heat Ratio + !! Density + !! fluid reference energy + !! Pressure to calculate + !! Shear Stress + !! Momentum subroutine s_compute_pressure(energy, alf, dyn_p, pi_inf, gamma, rho, qv, rhoYks, pres, T, stress, mom, G, pres_mag) $:GPU_ROUTINE(function_name='s_compute_pressure',parallelism='[seq]', & & cray_inline=True) @@ -122,7 +122,7 @@ contains real(stp), intent(in), optional :: stress, mom real(wp), intent(in), optional :: G, pres_mag - ! Chemistry + ! real(wp), dimension(1:num_species), intent(in) :: rhoYks real(wp), dimension(1:num_species) :: Y_rs real(wp) :: E_e @@ -132,8 +132,8 @@ contains integer :: s !< Generic loop iterator #:if not chemistry - ! Depending on model_eqns and bubbles_euler, the appropriate procedure - ! for computing pressure is targeted by the procedure pointer + ! on model_eqns and bubbles_euler, the appropriate procedure + ! computing pressure is targeted by the procedure pointer if (mhd) then pres = (energy - dyn_p - pi_inf - qv - pres_mag)/gamma @@ -149,12 +149,12 @@ contains end if if (hypoelasticity .and. present(G)) then - ! calculate elastic contribution to Energy + ! elastic contribution to Energy E_e = 0._wp do s = stress_idx%beg, stress_idx%end if (G > 0) then E_e = E_e + ((stress/rho)**2._wp)/(4._wp*G) - ! Double for shear stresses + ! for shear stresses if (any(s == shear_indices)) then E_e = E_e + ((stress/rho)**2._wp)/(4._wp*G) end if @@ -185,18 +185,18 @@ contains end subroutine s_compute_pressure !> This subroutine is designed for the gamma/pi_inf model - !! and provided a set of either conservative or primitive - !! variables, transfers the density, specific heat ratio - !! function and the liquid stiffness function from q_vf to - !! rho, gamma and pi_inf. - !! @param q_vf conservative or primitive variables - !! @param i cell index to transfer mixture variables - !! @param j cell index to transfer mixture variables - !! @param k cell index to transfer mixture variables - !! @param rho density - !! @param gamma specific heat ratio function - !! @param pi_inf liquid stiffness - !! @param qv fluid reference energy + !! a set of either conservative or primitive + !! the density, specific heat ratio + !! the liquid stiffness function from q_vf to + !! and pi_inf. + !! conservative or primitive variables + !! cell index to transfer mixture variables + !! cell index to transfer mixture variables + !! cell index to transfer mixture variables + !! density + !! specific heat ratio function + !! liquid stiffness + !! fluid reference energy subroutine s_convert_mixture_to_mixture_variables(q_vf, i, j, k, & rho, gamma, pi_inf, qv) @@ -208,14 +208,14 @@ contains real(wp), intent(out), target :: pi_inf real(wp), intent(out), target :: qv - ! Transferring the density, the specific heat ratio function and the - ! liquid stiffness function, respectively + ! the density, the specific heat ratio function and the + ! stiffness function, respectively rho = q_vf(1)%sf(i, j, k) gamma = q_vf(gamma_idx)%sf(i, j, k) pi_inf = q_vf(pi_inf_idx)%sf(i, j, k) qv = 0._wp ! keep this value nill for now. For future adjustment - ! Post process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated + ! process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated #ifdef MFC_POST_PROCESS rho_sf(i, j, k) = rho gamma_sf(i, j, k) = gamma @@ -226,18 +226,18 @@ contains end subroutine s_convert_mixture_to_mixture_variables !> This subroutine is designed for the volume fraction model - !! and provided a set of either conservative or primitive - !! variables, computes the density, the specific heat ratio - !! function and the liquid stiffness function from q_vf and - !! stores the results into rho, gamma and pi_inf. - !! @param q_vf primitive variables - !! @param k Cell index - !! @param l Cell index - !! @param r Cell index - !! @param rho density - !! @param gamma specific heat ratio - !! @param pi_inf liquid stiffness - !! @param qv fluid reference energy + !! a set of either conservative or primitive + !! the density, the specific heat ratio + !! the liquid stiffness function from q_vf and + !! results into rho, gamma and pi_inf. + !! primitive variables + !! Cell index + !! Cell index + !! Cell index + !! density + !! specific heat ratio + !! liquid stiffness + !! fluid reference energy subroutine s_convert_species_to_mixture_variables(q_vf, k, l, r, rho, & gamma, pi_inf, qv, Re_K, G_K, G) @@ -257,13 +257,13 @@ contains integer :: i, j !< Generic loop iterator - ! Computing the density, the specific heat ratio function and the - ! liquid stiffness function, respectively + ! the density, the specific heat ratio function and the + ! stiffness function, respectively call s_compute_species_fraction(q_vf, k, l, r, alpha_rho_K, alpha_K) - ! Calculating the density, the specific heat ratio function, the - ! liquid stiffness function, and the energy reference function, - ! respectively, from the species analogs + ! the density, the specific heat ratio function, the + ! stiffness function, and the energy reference function, + ! from the species analogs if (num_fluids == 1 .and. bubbles_euler) then rho = alpha_rho_K(1) gamma = gammas(1) @@ -280,7 +280,7 @@ contains end if #ifdef MFC_SIMULATION - ! Computing the shear and bulk Reynolds numbers from species analogs + ! the shear and bulk Reynolds numbers from species analogs if (viscous) then do i = 1, 2 Re_K(i) = dflt_real; if (Re_size(i) > 0) Re_K(i) = 0._wp @@ -303,7 +303,7 @@ contains G_K = max(0._wp, G_K) end if - ! Post process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated + ! process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated #ifdef MFC_POST_PROCESS rho_sf(k, l, r) = rho gamma_sf(k, l, r) = gamma @@ -335,10 +335,10 @@ contains integer :: i, j !< Generic loop iterators #ifdef MFC_SIMULATION - ! Constraining the partial densities and the volume fractions within - ! their physical bounds to make sure that any mixture variables that - ! are derived from them result within the limits that are set by the - ! fluids physical parameters that make up the mixture + ! the partial densities and the volume fractions within + ! physical bounds to make sure that any mixture variables that + ! derived from them result within the limits that are set by the + ! physical parameters that make up the mixture if (num_fluids == 1 .and. bubbles_euler) then rho_K = alpha_rho_K(1) gamma_K = gammas(1) @@ -392,8 +392,8 @@ contains end subroutine s_convert_species_to_mixture_variables_acc !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_variables_conversion_module integer :: i, j @@ -444,13 +444,13 @@ contains end if #ifdef MFC_POST_PROCESS - ! Allocating the density, the specific heat ratio function and the - ! liquid stiffness function, respectively + ! the density, the specific heat ratio function and the + ! stiffness function, respectively - ! Simulation is at least 2D + ! is at least 2D if (n > 0) then - ! Simulation is 3D + ! is 3D if (p > 0) then allocate (rho_sf(-buff_size:m + buff_size, & @@ -466,7 +466,7 @@ contains -buff_size:n + buff_size, & -buff_size:p + buff_size)) - ! Simulation is 2D + ! is 2D else allocate (rho_sf(-buff_size:m + buff_size, & @@ -483,7 +483,7 @@ contains 0:0)) end if - ! Simulation is 1D + ! is 1D else allocate (rho_sf(-buff_size:m + buff_size, & @@ -571,13 +571,13 @@ contains end subroutine s_initialize_pb !> The following procedure handles the conversion between - !! the conservative variables and the primitive variables. - !! @param qK_cons_vf Conservative variables - !! @param qK_prim_vf Primitive variables - !! @param gm_alphaK_vf Gradient magnitude of the volume fraction - !! @param ix Index bounds in first coordinate direction - !! @param iy Index bounds in second coordinate direction - !! @param iz Index bounds in third coordinate direction + !! variables and the primitive variables. + !! Conservative variables + !! Primitive variables + !! Gradient magnitude of the volume fraction + !! Index bounds in first coordinate direction + !! Index bounds in second coordinate direction + !! Index bounds in third coordinate direction subroutine s_convert_conservative_to_primitive_variables(qK_cons_vf, & q_T_sf, & qK_prim_vf, & @@ -630,7 +630,7 @@ contains if (model_eqns /= 4) then #ifdef MFC_SIMULATION - ! If in simulation, use acc mixture subroutines + ! in simulation, use acc mixture subroutines if (elasticity) then call s_convert_species_to_mixture_variables_acc(rho_K, gamma_K, pi_inf_K, qv_K, alpha_K, & alpha_rho_K, Re_K, G_K, Gs_vc) @@ -639,7 +639,7 @@ contains alpha_K, alpha_rho_K, Re_K) end if #else - ! If pre-processing, use non acc mixture subroutines + ! pre-processing, use non acc mixture subroutines if (elasticity) then call s_convert_to_mixture_variables(qK_cons_vf, j, k, l, & rho_K, gamma_K, pi_inf_K, qv_K, Re_K, G_K, fluid_pp(:)%G) @@ -682,7 +682,7 @@ contains D = D + qK_cons_vf(i)%sf(j, k, l) end do - ! Newton-Raphson + ! W = E + D $:GPU_LOOP(parallelism='[seq]') do iter = 1, relativity_cons_to_prim_max_iter @@ -690,11 +690,11 @@ contains pres = (W - D*Ga)/((gamma_K + 1)*Ga**2) ! Thermal pressure from EOS f = W - pres + (1 - 1/(2*Ga**2))*B2 - S**2/(2*W**2) - E - D - ! The first equation below corrects a typo in (Mignone & Bodo, 2006) - ! m2*W**2 → 2*m2*W**2, which would cancel with the 2* in other terms - ! This corrected version is not used as the second equation empirically converges faster. - ! First equation is kept for further investigation. - ! dGa_dW = -Ga**3 * ( S**2*(3*W**2+3*W*B2+B2**2) + m2*W**2 ) / (W**3 * (W+B2)**3) ! first (corrected) + ! first equation below corrects a typo in (Mignone & Bodo, 2006) + ! → 2*m2*W**2, which would cancel with the 2* in other terms + ! corrected version is not used as the second equation empirically converges faster. + ! equation is kept for further investigation. + ! = -Ga**3 * ( S**2*(3*W**2+3*W*B2+B2**2) + m2*W**2 ) / (W**3 * (W+B2)**3) ! first (corrected) dGa_dW = -Ga**3*(2*S**2*(3*W**2 + 3*W*B2 + B2**2) + m2*W**2)/(2*W**3*(W + B2)**3) ! second (in paper) dp_dW = (Ga*(1 + D*dGa_dW) - 2*W*dGa_dW)/((gamma_K + 1)*Ga**3) @@ -705,11 +705,11 @@ contains if (abs(dW) < 1.e-12_wp*W) exit end do - ! Recalculate pressure using converged W + ! pressure using converged W Ga = (W + B2)*W/sqrt((W + B2)**2*W**2 - (m2*W**2 + S**2*(2*W + B2))) qK_prim_vf(E_idx)%sf(j, k, l) = (W - D*Ga)/((gamma_K + 1)*Ga**2) - ! Recover the other primitive variables + ! the other primitive variables $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 qK_prim_vf(momxb + i - 1)%sf(j, k, l) = (qK_cons_vf(momxb + i - 1)%sf(j, k, l) + (S/W)*B(i))/(W + B2) @@ -848,12 +848,12 @@ contains if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = strxb, strxe - ! subtracting elastic contribution for pressure calculation + ! elastic contribution for pressure calculation if (G_K > verysmall) then if (cont_damage) G_K = G_K*max((1._wp - qK_cons_vf(damage_idx)%sf(j, k, l)), 0._wp) qK_prim_vf(E_idx)%sf(j, k, l) = qK_prim_vf(E_idx)%sf(j, k, l) - & ((qK_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G_K))/gamma_K - ! Double for shear stresses + ! for shear stresses if (any(i == shear_indices)) then qK_prim_vf(E_idx)%sf(j, k, l) = qK_prim_vf(E_idx)%sf(j, k, l) - & ((qK_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G_K))/gamma_K @@ -895,22 +895,22 @@ contains end subroutine s_convert_conservative_to_primitive_variables !> The following procedure handles the conversion between - !! the primitive variables and the conservative variables. - !! @param qK_prim_vf Primitive variables - !! @param qK_cons_vf Conservative variables - !! @param gm_alphaK_vf Gradient magnitude of the volume fractions - !! @param ix Index bounds in the first coordinate direction - !! @param iy Index bounds in the second coordinate direction - !! @param iz Index bounds in the third coordinate direction + !! variables and the conservative variables. + !! Primitive variables + !! Conservative variables + !! Gradient magnitude of the volume fractions + !! Index bounds in the first coordinate direction + !! Index bounds in the second coordinate direction + !! Index bounds in the third coordinate direction impure subroutine s_convert_primitive_to_conservative_variables(q_prim_vf, & q_cons_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf - ! Density, specific heat ratio function, liquid stiffness function - ! and dynamic pressure, as defined in the incompressible flow sense, - ! respectively + ! specific heat ratio function, liquid stiffness function + ! dynamic pressure, as defined in the incompressible flow sense, + ! real(wp) :: rho real(wp) :: gamma real(wp) :: pi_inf @@ -939,18 +939,18 @@ contains G = 0._wp #ifndef MFC_SIMULATION - ! Converting the primitive variables to the conservative variables + ! the primitive variables to the conservative variables do l = 0, p do k = 0, n do j = 0, m - ! Obtaining the density, specific heat ratio function - ! and the liquid stiffness function, respectively + ! the density, specific heat ratio function + ! the liquid stiffness function, respectively call s_convert_to_mixture_variables(q_prim_vf, j, k, l, & rho, gamma, pi_inf, qv, Re_K, G, fluid_pp(:)%G) if (.not. igr .or. num_fluids > 1) then - ! Transferring the advection equation(s) variable(s) + ! the advection equation(s) variable(s) do i = adv_idx%beg, adv_idx%end q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l) end do @@ -1000,7 +1000,7 @@ contains q_cons_vf(E_idx)%sf(j, k, l) = rho*h*Ga**2 - q_prim_vf(E_idx)%sf(j, k, l) & + 0.5_wp*(B2 + v2*B2 - vdotB**2) - ! Remove rest energy + ! rest energy do i = 1, contxe q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) - q_cons_vf(i)%sf(j, k, l) end do @@ -1013,16 +1013,16 @@ contains end if - ! Transferring the continuity equation(s) variable(s) + ! the continuity equation(s) variable(s) do i = 1, contxe q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l) end do - ! Zeroing out the dynamic pressure since it is computed - ! iteratively by cycling through the velocity equations + ! out the dynamic pressure since it is computed + ! by cycling through the velocity equations dyn_pres = 0._wp - ! Computing momenta and dynamic pressure from velocity + ! momenta and dynamic pressure from velocity do i = momxb, momxe q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) dyn_pres = dyn_pres + q_cons_vf(i)%sf(j, k, l)* & @@ -1042,7 +1042,7 @@ contains q_cons_vf(E_idx)%sf(j, k, l) = & dyn_pres + rho*e_mix else - ! Computing the energy from the pressure + ! the energy from the pressure if (mhd) then if (n == 0) then pres_mag = 0.5_wp*(Bx0**2 + q_prim_vf(B_idx%beg)%sf(j, k, l)**2 + q_prim_vf(B_idx%beg + 1)%sf(j, k, l)**2) @@ -1053,11 +1053,11 @@ contains gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pres_mag & + pi_inf + qv elseif ((model_eqns /= 4) .and. (bubbles_euler .neqv. .true.)) then - ! E = Gamma*P + \rho u u /2 + \pi_inf + (\alpha\rho qv) + ! = Gamma*P + \rho u u /2 + \pi_inf + (\alpha\rho qv) q_cons_vf(E_idx)%sf(j, k, l) = & gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pi_inf + qv else if ((model_eqns /= 4) .and. (bubbles_euler)) then - ! \tilde{E} = dyn_pres + (1-\alf)(\Gamma p_l + \Pi_inf) + ! = dyn_pres + (1-\alf)(\Gamma p_l + \Pi_inf) q_cons_vf(E_idx)%sf(j, k, l) = dyn_pres + & (1._wp - q_prim_vf(alf_idx)%sf(j, k, l))* & (gamma*q_prim_vf(E_idx)%sf(j, k, l) + pi_inf) @@ -1067,10 +1067,10 @@ contains end if end if - ! Computing the internal energies from the pressure and continuities + ! the internal energies from the pressure and continuities if (model_eqns == 3) then do i = 1, num_fluids - ! internal energy calculation for each of the fluids + ! energy calculation for each of the fluids q_cons_vf(i + intxb - 1)%sf(j, k, l) = q_cons_vf(i + advxb - 1)%sf(j, k, l)* & (gammas(i)*q_prim_vf(E_idx)%sf(j, k, l) + pi_infs(i)) + & q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) @@ -1078,7 +1078,7 @@ contains end if if (bubbles_euler) then - ! From prim: Compute nbub = (3/4pi) * \alpha / \bar{R^3} + ! prim: Compute nbub = (3/4pi) * \alpha / \bar{R^3} do i = 1, nb Rtmp(i) = q_prim_vf(bub_idx%rs(i))%sf(j, k, l) end do @@ -1115,8 +1115,8 @@ contains end if if (elasticity) then - ! adding the elastic contribution - ! Multiply \tau to \rho \tau + ! the elastic contribution + ! \tau to \rho \tau do i = strxb, strxe q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) end do @@ -1124,13 +1124,13 @@ contains if (hypoelasticity) then do i = strxb, strxe - ! adding elastic contribution + ! elastic contribution if (G > verysmall) then if (cont_damage) G = G*max((1._wp - q_prim_vf(damage_idx)%sf(j, k, l)), 0._wp) q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) + & (q_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G) - ! Double for shear stresses + ! for shear stresses if (any(i == shear_indices)) then q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) + & (q_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G) @@ -1139,9 +1139,9 @@ contains end do end if - ! using \rho xi as the conservative formulation stated in Kamrin et al. JFM 2022 + ! \rho xi as the conservative formulation stated in Kamrin et al. JFM 2022 if (hyperelasticity) then - ! Multiply \xi to \rho \xi + ! \xi to \rho \xi do i = xibeg, xiend q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) end do @@ -1168,13 +1168,13 @@ contains end subroutine s_convert_primitive_to_conservative_variables !> The following subroutine handles the conversion between - !! the primitive variables and the Eulerian flux variables. - !! @param qK_prim_vf Primitive variables - !! @param FK_vf Flux variables - !! @param FK_src_vf Flux source variables - !! @param ix Index bounds in the first coordinate direction - !! @param iy Index bounds in the second coordinate direction - !! @param iz Index bounds in the third coordinate direction + !! variables and the Eulerian flux variables. + !! Primitive variables + !! Flux variables + !! Flux source variables + !! Index bounds in the first coordinate direction + !! Index bounds in the second coordinate direction + !! Index bounds in the third coordinate direction subroutine s_convert_primitive_to_flux_variables(qK_prim_vf, & FK_vf, & FK_src_vf, & @@ -1187,9 +1187,9 @@ contains type(int_bounds_info), intent(in) :: is1, is2, is3 - ! Partial densities, density, velocity, pressure, energy, advection - ! variables, the specific heat ratio and liquid stiffness functions, - ! the shear and volume Reynolds numbers and the Weber numbers + ! densities, density, velocity, pressure, energy, advection + ! the specific heat ratio and liquid stiffness functions, + ! shear and volume Reynolds numbers and the Weber numbers #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: alpha_rho_K real(wp), dimension(3) :: alpha_K @@ -1220,8 +1220,8 @@ contains $:GPU_UPDATE(device='[is1b,is2b,is3b,is1e,is2e,is3e]') - ! Computing the flux variables from the primitive variables, without - ! accounting for the contribution of either viscosity or capillarity + ! the flux variables from the primitive variables, without + ! for the contribution of either viscosity or capillarity #ifdef MFC_SIMULATION $:GPU_PARALLEL_LOOP(collapse=3, private='[alpha_rho_K, vel_K, alpha_K, Re_K, Y_K, rho_K, vel_K_sum, pres_K, E_K, gamma_K, pi_inf_K, qv_K, G_K, T_K, mix_mol_weight, R_gas]') do l = is3b, is3e @@ -1259,7 +1259,7 @@ contains alpha_K, alpha_rho_K, Re_K) end if - ! Computing the energy from the pressure + ! the energy from the pressure if (chemistry) then $:GPU_LOOP(parallelism='[seq]') @@ -1273,12 +1273,12 @@ contains call get_mixture_energy_mass(T_K, Y_K, E_K) E_K = rho_K*E_K + 5.e-1_wp*rho_K*vel_K_sum else - ! Computing the energy from the pressure + ! the energy from the pressure E_K = gamma_K*pres_K + pi_inf_K & + 5.e-1_wp*rho_K*vel_K_sum + qv_K end if - ! mass flux, this should be \alpha_i \rho_i u_i + ! flux, this should be \alpha_i \rho_i u_i $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe FK_vf(j, k, l, i) = alpha_rho_K(i)*vel_K(dir_idx(1)) @@ -1292,10 +1292,10 @@ contains + pres_K*dir_flg(dir_idx(i)) end do - ! energy flux, u(E+p) + ! flux, u(E+p) FK_vf(j, k, l, E_idx) = vel_K(dir_idx(1))*(E_K + pres_K) - ! Species advection Flux, \rho*u*Y + ! advection Flux, \rho*u*Y if (chemistry) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_species @@ -1311,7 +1311,7 @@ contains end do else - ! Could be bubbles_euler! + ! be bubbles_euler! $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe FK_vf(j, k, l, i) = vel_K(dir_idx(1))*alpha_K(i - E_idx) @@ -1384,8 +1384,8 @@ contains impure subroutine s_finalize_variables_conversion_module() - ! Deallocating the density, the specific heat ratio function and the - ! liquid stiffness function + ! the density, the specific heat ratio function and the + ! stiffness function #ifdef MFC_POST_PROCESS deallocate (rho_sf, gamma_sf, pi_inf_sf, qv_sf) #endif @@ -1431,7 +1431,7 @@ contains c = sqrt((1.0_wp + 1.0_wp/gamma)*pres/rho) end if elseif (relativity) then - ! Only supports perfect gas for now + ! supports perfect gas for now c = sqrt((1._wp + 1._wp/gamma)*pres/rho/H) else if (alt_soundspeed) then @@ -1449,7 +1449,7 @@ contains end do c = c/rho elseif (((model_eqns == 4) .or. (model_eqns == 2 .and. bubbles_euler))) then - ! Sound speed for bubble mixture to order O(\alpha) + ! speed for bubble mixture to order O(\alpha) if (mpp_lim .and. (num_fluids > 1)) then c = (1._wp/gamma + 1._wp)* & @@ -1491,7 +1491,7 @@ contains term = c**2 + B2/rho disc = term**2 - 4*c**2*(B(norm)**2/rho) else - ! Note: this is approximation for the non-relatisitic limit; accurate solution requires solving a quartic equation + ! this is approximation for the non-relatisitic limit; accurate solution requires solving a quartic equation term = (c**2*(B(norm)**2 + rho*h) + B2)/(rho*h + B2) disc = term**2 - 4*c**2*B(norm)**2/(rho*h + B2) end if diff --git a/src/post_process/m_checker.fpp b/src/post_process/m_checker.fpp index 291b9f5979..883e1406d8 100644 --- a/src/post_process/m_checker.fpp +++ b/src/post_process/m_checker.fpp @@ -1,5 +1,5 @@ !> -!!@file m_checker.f90 +!!@file !!@brief Contains module m_checker #:include 'macros.fpp' @@ -22,7 +22,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! Used by the post_process stage + !! the post_process stage impure subroutine s_check_inputs call s_check_inputs_output_format diff --git a/src/post_process/m_data_input.f90 b/src/post_process/m_data_input.f90 index 98c85e8612..1b07d591cc 100644 --- a/src/post_process/m_data_input.f90 +++ b/src/post_process/m_data_input.f90 @@ -145,6 +145,7 @@ end subroutine s_setup_mpi_io_params !> Helper subroutine to read IB data files !! @param file_loc_base Base file location for IB data + !! @param t_step Optional time step index for restart data impure subroutine s_read_ib_data_files(file_loc_base, t_step) character(len=*), intent(in) :: file_loc_base @@ -211,8 +212,10 @@ impure subroutine s_read_ib_data_files(file_loc_base, t_step) end subroutine s_read_ib_data_files !> Helper subroutine to allocate field arrays for given dimensionality - !! @param start_idx Starting index for allocation - !! @param end_x, end_y, end_z End indices for each dimension + !! @param local_start_idx Starting index for allocation + !! @param end_x End index for x dimension + !! @param end_y End index for y dimension + !! @param end_z End index for z dimension impure subroutine s_allocate_field_arrays(local_start_idx, end_x, end_y, end_z) integer, intent(in) :: local_start_idx, end_x, end_y, end_z diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index def195a61d..2f549e6342 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -1,12 +1,12 @@ !> -!! @file m_data_output.f90 -!! @brief Contains module m_data_output +!! +!! module m_data_output !> @brief This module enables the restructuring of the raw simulation data -!! file(s) into formatted database file(s). The formats that may be -!! chosen from include Silo-HDF5 and Binary. Each of these database -!! structures contains information about the grid as well as each of -!! the flow variable(s) that were chosen by the user to be included. +!! formatted database file(s). The formats that may be +!! include Silo-HDF5 and Binary. Each of these database +!! information about the grid as well as each of +!! variable(s) that were chosen by the user to be included. module m_data_output use m_derived_types ! Definitions of the derived types @@ -41,92 +41,92 @@ module m_data_output s_close_energy_data_file, & s_finalize_data_output_module - ! Including the Silo Fortran interface library that features the subroutines - ! and parameters that are required to write in the Silo-HDF5 database format - ! INCLUDE 'silo.inc' + ! the Silo Fortran interface library that features the subroutines + ! parameters that are required to write in the Silo-HDF5 database format + ! 'silo.inc' include 'silo_f9x.inc' - ! Generic storage for flow variable(s) that are to be written to formatted - ! database file(s). Note that for 1D simulations, q_root_sf is employed to - ! gather the flow variable(s) from all sub-domains on to the root process. - ! If the run is not parallel, but serial, then q_root_sf is equal to q_sf. + ! storage for flow variable(s) that are to be written to formatted + ! file(s). Note that for 1D simulations, q_root_sf is employed to + ! the flow variable(s) from all sub-domains on to the root process. + ! the run is not parallel, but serial, then q_root_sf is equal to q_sf. real(wp), allocatable, dimension(:, :, :), public :: q_sf real(wp), allocatable, dimension(:, :, :) :: q_root_sf real(wp), allocatable, dimension(:, :, :) :: cyl_q_sf - ! Single precision storage for flow variables + ! precision storage for flow variables real(sp), allocatable, dimension(:, :, :), public :: q_sf_s real(sp), allocatable, dimension(:, :, :) :: q_root_sf_s real(sp), allocatable, dimension(:, :, :) :: cyl_q_sf_s - ! The spatial and data extents array variables contain information about the - ! minimum and maximum values of the grid and flow variable(s), respectively. - ! The purpose of bookkeeping this information is to boost the visualization - ! of the Silo-HDF5 database file(s) in VisIt. + ! spatial and data extents array variables contain information about the + ! and maximum values of the grid and flow variable(s), respectively. + ! purpose of bookkeeping this information is to boost the visualization + ! the Silo-HDF5 database file(s) in VisIt. real(wp), allocatable, dimension(:, :) :: spatial_extents real(wp), allocatable, dimension(:, :) :: data_extents - ! The size of the ghost zone layer at beginning of each coordinate direction - ! (lo) and at end of each coordinate direction (hi). Adding this information - ! to Silo-HDF5 database file(s) is recommended since it supplies VisIt with - ! connectivity information between the sub-domains of a parallel data set. + ! size of the ghost zone layer at beginning of each coordinate direction + ! and at end of each coordinate direction (hi). Adding this information + ! Silo-HDF5 database file(s) is recommended since it supplies VisIt with + ! information between the sub-domains of a parallel data set. integer, allocatable, dimension(:) :: lo_offset integer, allocatable, dimension(:) :: hi_offset - ! For Silo-HDF5 database format, this variable is used to keep track of the - ! number of cell-boundaries, for the grid associated with the local process, - ! in each of the active coordinate directions. + ! Silo-HDF5 database format, this variable is used to keep track of the + ! of cell-boundaries, for the grid associated with the local process, + ! each of the active coordinate directions. integer, allocatable, dimension(:) :: dims - ! Locations of various folders in the case's directory tree, associated with - ! the choice of the formatted database format. These include, in order, the - ! location of the folder named after the selected formatted database format, - ! and the locations of two sub-directories of the latter, the first of which - ! is named after the local processor rank, while the second is named 'root'. - ! The folder associated with the local processor rank contains only the data - ! pertaining to the part of the domain taken care of by the local processor. - ! The root directory, on the other hand, will contain either the information - ! about the connectivity required to put the entire domain back together, or - ! the actual data associated with the entire computational domain. This all - ! depends on dimensionality and the choice of the formatted database format. + ! of various folders in the case's directory tree, associated with + ! choice of the formatted database format. These include, in order, the + ! of the folder named after the selected formatted database format, + ! the locations of two sub-directories of the latter, the first of which + ! named after the local processor rank, while the second is named 'root'. + ! folder associated with the local processor rank contains only the data + ! to the part of the domain taken care of by the local processor. + ! root directory, on the other hand, will contain either the information + ! the connectivity required to put the entire domain back together, or + ! actual data associated with the entire computational domain. This all + ! on dimensionality and the choice of the formatted database format. character(LEN=path_len + name_len) :: dbdir character(LEN=path_len + 2*name_len) :: proc_rank_dir character(LEN=path_len + 2*name_len) :: rootdir - ! Handles of the formatted database master/root file, slave/local processor - ! file and options list. The list of options is explicitly used in the Silo- - ! HDF5 database format to provide additional details about the contents of a - ! formatted database file, such as the previously described spatial and data - ! extents. + ! of the formatted database master/root file, slave/local processor + ! and options list. The list of options is explicitly used in the Silo- + ! database format to provide additional details about the contents of a + ! database file, such as the previously described spatial and data + ! integer :: dbroot integer :: dbfile integer :: optlist - ! The total number of flow variable(s) to be stored in a formatted database - ! file. Note that this is only needed when using the Binary format. + ! total number of flow variable(s) to be stored in a formatted database + ! Note that this is only needed when using the Binary format. integer :: dbvars - ! Generic error flags utilized in the handling, checking and the reporting - ! of the input and output operations errors with a formatted database file + ! error flags utilized in the handling, checking and the reporting + ! the input and output operations errors with a formatted database file integer, private :: err contains impure subroutine s_initialize_data_output_module() - ! Description: Computation of parameters, allocation procedures, and/or - ! any other tasks needed to properly setup the module + ! Computation of parameters, allocation procedures, and/or + ! other tasks needed to properly setup the module - ! Generic string used to store the location of a particular file + ! string used to store the location of a particular file character(LEN=len_trim(case_dir) + 2*name_len) :: file_loc - ! Generic logical used to test the existence of a particular folder + ! logical used to test the existence of a particular folder logical :: dir_check integer :: i - ! Allocating the generic storage for the flow variable(s) that are - ! going to be written to the formatted database file(s). Note once - ! more that the root variable is only required for 1D computations. + ! the generic storage for the flow variable(s) that are + ! to be written to the formatted database file(s). Note once + ! that the root variable is only required for 1D computations. allocate (q_sf(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end)) @@ -154,10 +154,10 @@ contains end if end if - ! Allocating the spatial and data extents and also the variables for - ! the offsets and the one bookkeeping the number of cell-boundaries - ! in each active coordinate direction. Note that all these variables - ! are only needed by the Silo-HDF5 format for multidimensional data. + ! the spatial and data extents and also the variables for + ! offsets and the one bookkeeping the number of cell-boundaries + ! each active coordinate direction. Note that all these variables + ! only needed by the Silo-HDF5 format for multidimensional data. if (format == 1) then allocate (data_extents(1:2, 0:num_procs - 1)) @@ -181,13 +181,13 @@ contains end if - ! The size of the ghost zone layer in each of the active coordinate - ! directions was set in the module m_mpi_proxy.f90. The results are - ! now transferred to the local variables of this module when they are - ! required by the Silo-HDF5 format, for multidimensional data sets. - ! With the same, latter, requirements, the variables bookkeeping the - ! number of cell-boundaries in each active coordinate direction are - ! also set here. + ! size of the ghost zone layer in each of the active coordinate + ! was set in the module m_mpi_proxy.f90. The results are + ! transferred to the local variables of this module when they are + ! by the Silo-HDF5 format, for multidimensional data sets. + ! the same, latter, requirements, the variables bookkeeping the + ! of cell-boundaries in each active coordinate direction are + ! set here. if (format == 1) then if (p > 0) then if (grid_geometry == 3) then @@ -220,10 +220,10 @@ contains end if end if - ! Generating Silo-HDF5 Directory Tree + ! Silo-HDF5 Directory Tree if (format == 1) then - ! Creating the directory associated with the local process + ! the directory associated with the local process dbdir = trim(case_dir)//'/silo_hdf5' write (proc_rank_dir, '(A,I0)') '/p', proc_rank @@ -237,7 +237,7 @@ contains call s_create_directory(trim(proc_rank_dir)) end if - ! Creating the directory associated with the root process + ! the directory associated with the root process if (proc_rank == 0) then rootdir = trim(dbdir)//'/root' @@ -251,11 +251,11 @@ contains end if - ! Generating Binary Directory Tree + ! Binary Directory Tree else - ! Creating the directory associated with the local process + ! the directory associated with the local process dbdir = trim(case_dir)//'/binary' write (proc_rank_dir, '(A,I0)') '/p', proc_rank @@ -270,7 +270,7 @@ contains call s_create_directory(trim(proc_rank_dir)) end if - ! Creating the directory associated with the root process + ! the directory associated with the root process if (n == 0 .and. proc_rank == 0) then rootdir = trim(dbdir)//'/root' @@ -299,24 +299,24 @@ contains end if end if - ! Contrary to the Silo-HDF5 database format, handles of the Binary - ! database master/root and slave/local process files are perfectly - ! static throughout post-process. Hence, they are set here so that - ! they do not have to be repetitively computed in later procedures. + ! to the Silo-HDF5 database format, handles of the Binary + ! master/root and slave/local process files are perfectly + ! throughout post-process. Hence, they are set here so that + ! do not have to be repetitively computed in later procedures. if (format == 2) then if (n == 0 .and. proc_rank == 0) dbroot = 2 dbfile = 1 end if - ! Querying Number of Flow Variable(s) in Binary Output + ! Number of Flow Variable(s) in Binary Output if (format == 2) then - ! Initializing the counter of the number of flow variable(s) to - ! be written to the formatted database file(s) + ! the counter of the number of flow variable(s) to + ! written to the formatted database file(s) dbvars = 0 - ! Partial densities + ! densities if ((model_eqns == 2) .or. (model_eqns == 3)) then do i = 1, num_fluids if (alpha_rho_wrt(i) & @@ -327,7 +327,7 @@ contains end do end if - ! Density + ! if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & .and. (.not. relativity)) then dbvars = dbvars + 1 @@ -336,37 +336,37 @@ contains if (relativity .and. (rho_wrt .or. prim_vars_wrt)) dbvars = dbvars + 1 if (relativity .and. (rho_wrt .or. cons_vars_wrt)) dbvars = dbvars + 1 - ! Momentum + ! do i = 1, E_idx - mom_idx%beg if (mom_wrt(i) .or. cons_vars_wrt) dbvars = dbvars + 1 end do - ! Velocity + ! do i = 1, E_idx - mom_idx%beg if (vel_wrt(i) .or. prim_vars_wrt) dbvars = dbvars + 1 end do - ! Flux limiter function + ! limiter function do i = 1, E_idx - mom_idx%beg if (flux_wrt(i)) dbvars = dbvars + 1 end do - ! Energy + ! if (E_wrt .or. cons_vars_wrt) dbvars = dbvars + 1 - ! Pressure + ! if (pres_wrt .or. prim_vars_wrt) dbvars = dbvars + 1 - ! Elastic stresses + ! stresses if (hypoelasticity) dbvars = dbvars + (num_dims*(num_dims + 1))/2 - ! Damage state variable + ! state variable if (cont_damage) dbvars = dbvars + 1 - ! Hyperbolic cleaning for MHD + ! cleaning for MHD if (hyper_cleaning) dbvars = dbvars + 1 - ! Magnetic field + ! field if (mhd) then if (n == 0) then dbvars = dbvars + 2 @@ -375,7 +375,7 @@ contains end if end if - ! Volume fraction(s) + ! fraction(s) if ((model_eqns == 2) .or. (model_eqns == 3)) then do i = 1, num_fluids - 1 @@ -395,7 +395,7 @@ contains end if - ! Specific heat ratio function + ! heat ratio function if (gamma_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & @@ -403,10 +403,10 @@ contains dbvars = dbvars + 1 end if - ! Specific heat ratio + ! heat ratio if (heat_ratio_wrt) dbvars = dbvars + 1 - ! Liquid stiffness function + ! stiffness function if (pi_inf_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & @@ -414,13 +414,13 @@ contains dbvars = dbvars + 1 end if - ! Liquid stiffness + ! stiffness if (pres_inf_wrt) dbvars = dbvars + 1 - ! Speed of sound + ! of sound if (c_wrt) dbvars = dbvars + 1 - ! Vorticity + ! if (p > 0) then do i = 1, num_vels if (omega_wrt(i)) dbvars = dbvars + 1 @@ -431,12 +431,12 @@ contains end do end if - ! Numerical Schlieren function + ! Schlieren function if (schlieren_wrt) dbvars = dbvars + 1 end if - ! END: Querying Number of Flow Variable(s) in Binary Output + ! Querying Number of Flow Variable(s) in Binary Output end subroutine s_initialize_data_output_module @@ -466,7 +466,7 @@ contains end if end do - ! If no grid points are within the output region + ! no grid points are within the output region if ((${X}$_cc(lower_bound) > ${X}$_output%end) .or. (${X}$_cc(upper_bound) < ${X}$_output%beg)) then ${X}$_output_idx%beg = 0 ${X}$_output_idx%end = 0 @@ -477,52 +477,52 @@ contains end subroutine s_define_output_region impure subroutine s_open_formatted_database_file(t_step) - ! Description: This subroutine opens a new formatted database file, or - ! replaces an old one, and readies it for the data storage - ! of the grid and the flow variable(s) associated with the - ! current time-step, t_step. This is performed by all the - ! local process(es). The root processor, in addition, must - ! also generate a master formatted database file whose job - ! will be to link, and thus combine, the data from all of - ! the local process(es). Note that for the Binary format, - ! this extra task that is assigned to the root process is - ! not performed in multidimensions. - - ! Time-step that is currently being post-processed + ! This subroutine opens a new formatted database file, or + ! an old one, and readies it for the data storage + ! the grid and the flow variable(s) associated with the + ! time-step, t_step. This is performed by all the + ! process(es). The root processor, in addition, must + ! generate a master formatted database file whose job + ! be to link, and thus combine, the data from all of + ! local process(es). Note that for the Binary format, + ! extra task that is assigned to the root process is + ! performed in multidimensions. + + ! that is currently being post-processed integer, intent(IN) :: t_step - ! Generic string used to store the location of a particular file + ! string used to store the location of a particular file character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc integer :: ierr !< Generic flag used to identify and report database errors - ! Silo-HDF5 Database Format + ! Database Format if (format == 1) then - ! Generating the relative path to the formatted database slave - ! file, that is to be opened for the current time-step, t_step + ! the relative path to the formatted database slave + ! that is to be opened for the current time-step, t_step write (file_loc, '(A,I0,A)') '/', t_step, '.silo' file_loc = trim(proc_rank_dir)//trim(file_loc) - ! Creating formatted database slave file at the above location - ! and setting up the structure of the file and its header info + ! formatted database slave file at the above location + ! setting up the structure of the file and its header info ierr = DBCREATE(trim(file_loc), len_trim(file_loc), & DB_CLOBBER, DB_LOCAL, 'MFC v3.0', 8, & DB_HDF5, dbfile) - ! Verifying that the creation and setup process of the formatted - ! database slave file has been performed without errors. If this - ! is not the case, the post-process exits. + ! that the creation and setup process of the formatted + ! slave file has been performed without errors. If this + ! not the case, the post-process exits. if (dbfile == -1) then call s_mpi_abort('Unable to create Silo-HDF5 database '// & 'slave file '//trim(file_loc)//'. '// & 'Exiting.') end if - ! Next, analogous steps to the ones above are carried out by the - ! root process to create and setup the formatted database master - ! file. + ! analogous steps to the ones above are carried out by the + ! process to create and setup the formatted database master + ! if (proc_rank == 0) then write (file_loc, '(A,I0,A)') '/collection_', t_step, '.silo' @@ -540,32 +540,32 @@ contains end if - ! Binary Database Format + ! Database Format else - ! Generating the relative path to the formatted database slave - ! file, that is to be opened for the current time-step, t_step + ! the relative path to the formatted database slave + ! that is to be opened for the current time-step, t_step write (file_loc, '(A,I0,A)') '/', t_step, '.dat' file_loc = trim(proc_rank_dir)//trim(file_loc) - ! Creating the formatted database slave file, at the previously - ! precised relative path location, and setting up its structure + ! the formatted database slave file, at the previously + ! relative path location, and setting up its structure open (dbfile, IOSTAT=err, FILE=trim(file_loc), & FORM='unformatted', STATUS='replace') - ! Verifying that the creation and setup process of the formatted - ! database slave file has been performed without errors. If this - ! is not the case, the post-process exits. + ! that the creation and setup process of the formatted + ! slave file has been performed without errors. If this + ! not the case, the post-process exits. if (err /= 0) then call s_mpi_abort('Unable to create Binary database slave '// & 'file '//trim(file_loc)//'. Exiting.') end if - ! Further defining the structure of the formatted database slave - ! file by describing in it the dimensionality of post-processed - ! data as well as the total number of flow variable(s) that will - ! eventually be stored in it + ! defining the structure of the formatted database slave + ! by describing in it the dimensionality of post-processed + ! as well as the total number of flow variable(s) that will + ! be stored in it if (output_partial_domain) then write (dbfile) x_output_idx%end - x_output_idx%beg, & y_output_idx%end - y_output_idx%beg, & @@ -575,9 +575,9 @@ contains write (dbfile) m, n, p, dbvars end if - ! Next, analogous steps to the ones above are carried out by the - ! root process to create and setup the formatted database master - ! file. Note that this is only done in multidimensional cases. + ! analogous steps to the ones above are carried out by the + ! process to create and setup the formatted database master + ! Note that this is only done in multidimensional cases. if (n == 0 .and. proc_rank == 0) then write (file_loc, '(A,I0,A)') '/', t_step, '.dat' @@ -607,12 +607,12 @@ contains impure subroutine s_open_intf_data_file() character(LEN=path_len + 3*name_len) :: file_path !< - !! Relative path to a file in the case directory + !! to a file in the case directory write (file_path, '(A)') '/intf_data.dat' file_path = trim(case_dir)//trim(file_path) - ! Opening the simulation data file + ! the simulation data file open (211, FILE=trim(file_path), & FORM='formatted', & POSITION='append', & @@ -623,12 +623,12 @@ contains impure subroutine s_open_energy_data_file() character(LEN=path_len + 3*name_len) :: file_path !< - !! Relative path to a file in the case directory + !! to a file in the case directory write (file_path, '(A)') '/eng_data.dat' file_path = trim(case_dir)//trim(file_path) - ! Opening the simulation data file + ! the simulation data file open (251, FILE=trim(file_path), & FORM='formatted', & POSITION='append', & @@ -637,48 +637,48 @@ contains end subroutine s_open_energy_data_file impure subroutine s_write_grid_to_formatted_database_file(t_step) - ! Description: The general objective of this subroutine is to write the - ! necessary grid data to the formatted database file, for - ! the current time-step, t_step. The local processor will - ! write the grid data of the domain segment that it is in - ! charge of to the formatted database slave file. The root - ! process will additionally take care of linking that grid - ! data in the formatted database master file. In the Silo- - ! HDF5 database format, the spatial extents of each local - ! process grid are also written to the master file. In the - ! Binary format, note that no master file is maintained in - ! multidimensions. Finally, in 1D, no grid data is written - ! within this subroutine for the Silo-HDF5 format because - ! curve objects rather than quadrilateral meshes are used. - ! For curve objects, in contrast to the quadrilateral mesh - ! objects, the grid data is included side by side with the - ! flow variable data. Then, in this case, we take care of - ! writing both the grid and the flow variable data in the - ! subroutine s_write_variable_to_formatted_database_file. - - ! Time-step that is currently being post-processed + ! The general objective of this subroutine is to write the + ! grid data to the formatted database file, for + ! current time-step, t_step. The local processor will + ! the grid data of the domain segment that it is in + ! of to the formatted database slave file. The root + ! will additionally take care of linking that grid + ! in the formatted database master file. In the Silo- + ! database format, the spatial extents of each local + ! grid are also written to the master file. In the + ! format, note that no master file is maintained in + ! Finally, in 1D, no grid data is written + ! this subroutine for the Silo-HDF5 format because + ! objects rather than quadrilateral meshes are used. + ! curve objects, in contrast to the quadrilateral mesh + ! the grid data is included side by side with the + ! variable data. Then, in this case, we take care of + ! both the grid and the flow variable data in the + ! s_write_variable_to_formatted_database_file. + + ! that is currently being post-processed integer, intent(IN) :: t_step - ! Bookkeeping variables storing the name and type of mesh that is - ! handled by the local processor(s). Note that due to an internal - ! NAG Fortran compiler problem, these two variables could not be - ! allocated dynamically. + ! variables storing the name and type of mesh that is + ! by the local processor(s). Note that due to an internal + ! Fortran compiler problem, these two variables could not be + ! dynamically. character(LEN=4*name_len), dimension(num_procs) :: meshnames integer, dimension(num_procs) :: meshtypes - ! Generic loop iterator + ! loop iterator integer :: i integer :: ierr !< Generic flag used to identify and report database errors - ! Silo-HDF5 Database Format + ! Database Format if (format == 1) then - ! For multidimensional data sets, the spatial extents of all of - ! the grid(s) handled by the local processor(s) are recorded so - ! that they may be written, by root processor, to the formatted - ! database master file. + ! multidimensional data sets, the spatial extents of all of + ! grid(s) handled by the local processor(s) are recorded so + ! they may be written, by root processor, to the formatted + ! master file. if (num_procs > 1) then call s_mpi_gather_spatial_extents(spatial_extents) elseif (p > 0) then @@ -698,10 +698,10 @@ contains spatial_extents(:, 0) = (/minval(x_cb), maxval(x_cb)/) end if - ! Next, the root processor proceeds to record all of the spatial - ! extents in the formatted database master file. In addition, it - ! also records a sub-domain connectivity map so that the entire - ! grid may be reassembled by looking at the master file. + ! the root processor proceeds to record all of the spatial + ! in the formatted database master file. In addition, it + ! records a sub-domain connectivity map so that the entire + ! may be reassembled by looking at the master file. if (proc_rank == 0) then do i = 1, num_procs @@ -724,9 +724,9 @@ contains end if - ! Finally, the local quadrilateral mesh, either 2D or 3D, along - ! with its offsets that indicate the presence and size of ghost - ! zone layer(s), are put in the formatted database slave file. + ! the local quadrilateral mesh, either 2D or 3D, along + ! its offsets that indicate the presence and size of ghost + ! layer(s), are put in the formatted database slave file. if (p > 0) then err = DBMKOPTLIST(2, optlist) @@ -767,15 +767,15 @@ contains optlist, ierr) err = DBFREEOPTLIST(optlist) end if - ! END: Silo-HDF5 Database Format + ! Silo-HDF5 Database Format - ! Binary Database Format + ! Database Format elseif (format == 2) then - ! Multidimensional local grid data is written to the formatted - ! database slave file. Recall that no master file to maintained - ! in multidimensions. + ! local grid data is written to the formatted + ! slave file. Recall that no master file to maintained + ! multidimensions. if (p > 0) then if (precision == 1) then write (dbfile) real(x_cb, sp), & @@ -804,9 +804,9 @@ contains end if end if - ! One-dimensional local grid data is written to the formatted - ! database slave file. In addition, the local grid data is put - ! together by the root process and written to the master file. + ! local grid data is written to the formatted + ! slave file. In addition, the local grid data is put + ! by the root process and written to the master file. else if (precision == 1) then @@ -844,55 +844,55 @@ contains end subroutine s_write_grid_to_formatted_database_file impure subroutine s_write_variable_to_formatted_database_file(varname, t_step) - ! Description: The goal of this subroutine is to write to the formatted - ! database file the flow variable at the current time-step, - ! t_step. The local process(es) write the part of the flow - ! variable that they handle to the formatted database slave - ! file. The root process, on the other hand, will also take - ! care of connecting all of the flow variable data in the - ! formatted database master file. In the Silo-HDF5 database - ! format, the extents of each local process flow variable - ! are also written to the master file. Note that in Binary - ! format, no master file is maintained in multidimensions. - ! Finally note that in 1D, grid data is also written within - ! this subroutine for Silo-HDF5 database format since curve - ! and not the quadrilateral variable objects are used, see - ! description of s_write_grid_to_formatted_database_file - ! for more details on this topic. - - ! Name of the flow variable, which will be written to the formatted - ! database file at the current time-step, t_step + ! The goal of this subroutine is to write to the formatted + ! file the flow variable at the current time-step, + ! The local process(es) write the part of the flow + ! that they handle to the formatted database slave + ! The root process, on the other hand, will also take + ! of connecting all of the flow variable data in the + ! database master file. In the Silo-HDF5 database + ! the extents of each local process flow variable + ! also written to the master file. Note that in Binary + ! no master file is maintained in multidimensions. + ! note that in 1D, grid data is also written within + ! subroutine for Silo-HDF5 database format since curve + ! not the quadrilateral variable objects are used, see + ! of s_write_grid_to_formatted_database_file + ! more details on this topic. + + ! of the flow variable, which will be written to the formatted + ! file at the current time-step, t_step character(LEN=*), intent(IN) :: varname - ! Time-step that is currently being post-processed + ! that is currently being post-processed integer, intent(IN) :: t_step - ! Bookkeeping variables storing the name and type of flow variable - ! that is about to be handled by the local processor(s). Note that - ! due to an internal NAG Fortran compiler problem, these variables - ! could not be allocated dynamically. + ! variables storing the name and type of flow variable + ! is about to be handled by the local processor(s). Note that + ! to an internal NAG Fortran compiler problem, these variables + ! not be allocated dynamically. character(LEN=4*name_len), dimension(num_procs) :: varnames integer, dimension(num_procs) :: vartypes - ! Generic loop iterator + ! loop iterator integer :: i, j, k integer :: ierr !< Generic flag used to identify and report database errors - ! Silo-HDF5 Database Format + ! Database Format if (format == 1) then - ! Determining the extents of the flow variable on each local - ! process and gathering all this information on root process + ! the extents of the flow variable on each local + ! and gathering all this information on root process if (num_procs > 1) then call s_mpi_gather_data_extents(q_sf, data_extents) else data_extents(:, 0) = (/minval(q_sf), maxval(q_sf)/) end if - ! Next, the root process proceeds to write the gathered flow - ! variable data extents to formatted database master file. + ! the root process proceeds to write the gathered flow + ! data extents to formatted database master file. if (proc_rank == 0) then do i = 1, num_procs @@ -914,9 +914,9 @@ contains end if - ! Finally, each of the local processor(s) proceeds to write - ! the flow variable data that it is responsible for to the - ! formatted database slave file. + ! each of the local processor(s) proceeds to write + ! flow variable data that it is responsible for to the + ! database slave file. if (wp == dp) then if (precision == 1) then do i = -offset_x%beg, m + offset_x%end @@ -1002,23 +1002,23 @@ contains end if #:endfor - ! END: Silo-HDF5 Database Format + ! Silo-HDF5 Database Format - ! Binary Database Format + ! Database Format else - ! Writing the name of the flow variable and its data, associated - ! with the local processor, to the formatted database slave file + ! the name of the flow variable and its data, associated + ! the local processor, to the formatted database slave file if (precision == 1) then write (dbfile) varname, real(q_sf, wp) else write (dbfile) varname, q_sf end if - ! In 1D, the root process also takes care of gathering the flow - ! variable data from all of the local processor(s) and writes it - ! to the formatted database master file. + ! 1D, the root process also takes care of gathering the flow + ! data from all of the local processor(s) and writes it + ! the formatted database master file. if (n == 0) then if (num_procs > 1) then @@ -1042,7 +1042,7 @@ contains end subroutine s_write_variable_to_formatted_database_file !> Subroutine that writes the post processed results in the folder 'lag_bubbles_data' - !! @param t_step Current time step + !! Current time step impure subroutine s_write_lag_bubbles_results_to_text(t_step) integer, intent(in) :: t_step @@ -1071,11 +1071,11 @@ contains real(wp), dimension(1:1, 1:lag_io_vars) :: lag_io_null lag_io_null = 0._wp - ! Construct file path + ! file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! Check if file exists + ! if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -1106,7 +1106,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip to processor counts position + ! to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -1239,11 +1239,11 @@ contains dummy = 0._wp dummy_data = 0._wp - ! Construct file path + ! file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! Check if file exists + ! if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -1274,7 +1274,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip to processor counts position + ! to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -1285,7 +1285,7 @@ contains call MPI_BCAST(proc_bubble_counts, file_num_procs, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - ! Set time variables from file + ! time variables from file nBub = proc_bubble_counts(proc_rank + 1) @@ -1317,7 +1317,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip extended header + ! extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1328,8 +1328,8 @@ contains call MPI_FILE_CLOSE(ifile, ierr) call MPI_TYPE_FREE(view, ierr) - ! Extract data from MPI_IO_DATA_lg_bubbles array - ! Adjust these indices based on your actual data layout + ! data from MPI_IO_DATA_lg_bubbles array + ! these indices based on your actual data layout #:for VAR, IDX in [('bub_id', 1), ('px', 2), ('py',3), ('pz',4), ('ppx',5), ('ppy',6), ('ppz',7), & ('vx',8), ('vy',9), ('vz',10), ('radius',11), ('rvel',12), & ('rnot',13), ('rmax',14), ('rmin',15), ('dphidt',16), & @@ -1337,10 +1337,10 @@ contains ${VAR}$ (:) = MPI_IO_DATA_lg_bubbles(:, ${IDX}$) #:endfor - ! Next, the root processor proceeds to record all of the spatial - ! extents in the formatted database master file. In addition, it - ! also records a sub-domain connectivity map so that the entire - ! grid may be reassembled by looking at the master file. + ! the root processor proceeds to record all of the spatial + ! in the formatted database master file. In addition, it + ! records a sub-domain connectivity map so that the entire + ! may be reassembled by looking at the master file. if (proc_rank == 0) then do i = 1, num_procs @@ -1388,7 +1388,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip extended header + ! extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1685,26 +1685,26 @@ contains end subroutine s_write_energy_data_file impure subroutine s_close_formatted_database_file() - ! Description: The purpose of this subroutine is to close any formatted - ! database file(s) that may be opened at the time-step that - ! is currently being post-processed. The root process must - ! typically close two files, one associated with the local - ! sub-domain and the other with the entire domain. The non- - ! root process(es) must close one file, which is associated - ! with the local sub-domain. Note that for the Binary data- - ! base format and multidimensional data, the root process - ! only has to close the file associated with the local sub- - ! domain, because one associated with the entire domain is - ! not generated. + ! The purpose of this subroutine is to close any formatted + ! file(s) that may be opened at the time-step that + ! currently being post-processed. The root process must + ! close two files, one associated with the local + ! and the other with the entire domain. The non- + ! process(es) must close one file, which is associated + ! the local sub-domain. Note that for the Binary data- + ! format and multidimensional data, the root process + ! has to close the file associated with the local sub- + ! because one associated with the entire domain is + ! generated. integer :: ierr !< Generic flag used to identify and report database errors - ! Silo-HDF5 database format + ! database format if (format == 1) then ierr = DBCLOSE(dbfile) if (proc_rank == 0) ierr = DBCLOSE(dbroot) - ! Binary database format + ! database format else close (dbfile) if (n == 0 .and. proc_rank == 0) close (dbroot) @@ -1726,21 +1726,21 @@ contains end subroutine s_close_energy_data_file impure subroutine s_finalize_data_output_module() - ! Description: Deallocation procedures for the module + ! Deallocation procedures for the module - ! Deallocating the generic storage employed for the flow variable(s) - ! that were written to the formatted database file(s). Note that the - ! root variable is only deallocated in the case of a 1D computation. + ! the generic storage employed for the flow variable(s) + ! were written to the formatted database file(s). Note that the + ! variable is only deallocated in the case of a 1D computation. deallocate (q_sf) if (n == 0) deallocate (q_root_sf) if (grid_geometry == 3) then deallocate (cyl_q_sf) end if - ! Deallocating spatial and data extents and also the variables for - ! the offsets and the one bookkeeping the number of cell-boundaries - ! in each active coordinate direction. Note that all these variables - ! were only needed by Silo-HDF5 format for multidimensional data. + ! spatial and data extents and also the variables for + ! offsets and the one bookkeeping the number of cell-boundaries + ! each active coordinate direction. Note that all these variables + ! only needed by Silo-HDF5 format for multidimensional data. if (format == 1) then deallocate (spatial_extents) deallocate (data_extents) diff --git a/src/post_process/m_derived_variables.fpp b/src/post_process/m_derived_variables.fpp index 497178ccf3..8e7d9a9ca8 100644 --- a/src/post_process/m_derived_variables.fpp +++ b/src/post_process/m_derived_variables.fpp @@ -1,12 +1,12 @@ !> -!! @file m_derived_variables.f90 -!! @brief Contains module m_derived_variables +!! +!! module m_derived_variables !> @brief This module features subroutines that allow for the derivation of -!! numerous flow variables from the conservative and primitive ones. -!! Currently, the available derived variables include the unadvected -!! volume fraction, specific heat ratio, liquid stiffness, speed of -!! sound, vorticity and the numerical Schlieren function. +!! variables from the conservative and primitive ones. +!! available derived variables include the unadvected +!! specific heat ratio, liquid stiffness, speed of +!! and the numerical Schlieren function. module m_derived_variables @@ -35,14 +35,14 @@ module m_derived_variables s_finalize_derived_variables_module real(wp), allocatable, dimension(:, :, :) :: gm_rho_sf !< - !! Gradient magnitude (gm) of the density for each cell of the computational - !! sub-domain. This variable is employed in the calculation of the numerical - !! Schlieren function. + !! (gm) of the density for each cell of the computational + !! variable is employed in the calculation of the numerical + !! !> @name Finite-difference (fd) coefficients in x-, y- and z-coordinate directions. - !! Note that because sufficient boundary information is available for all the - !! active coordinate directions, the centered family of the finite-difference - !! schemes is used. + !! because sufficient boundary information is available for all the + !! directions, the centered family of the finite-difference + !! used. !> @{ real(wp), allocatable, dimension(:, :), public :: fd_coeff_x real(wp), allocatable, dimension(:, :), public :: fd_coeff_y @@ -50,43 +50,43 @@ module m_derived_variables !> @} integer, private :: flg !< - !! Flagging (flg) variable used to annotate the dimensionality of the dataset - !! that is undergoing the post-process. A flag value of 1 indicates that the - !! dataset is 3D, while a flag value of 0 indicates that it is not. This flg - !! variable is necessary to avoid cycling through the third dimension of the - !! flow variable(s) when the simulation is not 3D and the size of the buffer - !! is non-zero. Note that a similar procedure does not have to be applied to - !! the second dimension since in 1D, the buffer size is always zero. + !! variable used to annotate the dimensionality of the dataset + !! undergoing the post-process. A flag value of 1 indicates that the + !! 3D, while a flag value of 0 indicates that it is not. This flg + !! necessary to avoid cycling through the third dimension of the + !! when the simulation is not 3D and the size of the buffer + !! Note that a similar procedure does not have to be applied to + !! dimension since in 1D, the buffer size is always zero. contains !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_derived_variables_module - ! Allocating the gradient magnitude of the density variable provided - ! that numerical Schlieren function is outputted during post-process + ! the gradient magnitude of the density variable provided + ! numerical Schlieren function is outputted during post-process if (schlieren_wrt) then allocate (gm_rho_sf(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end)) end if - ! Allocating the variables which will store the coefficients of the - ! centered family of finite-difference schemes. Note that sufficient - ! space is allocated so that the coefficients up to any chosen order - ! of accuracy may be bookkept. However, if higher than fourth-order - ! accuracy coefficients are wanted, the formulae required to compute - ! these coefficients will have to be implemented in the subroutine - ! s_compute_finite_difference_coefficients. + ! the variables which will store the coefficients of the + ! family of finite-difference schemes. Note that sufficient + ! is allocated so that the coefficients up to any chosen order + ! accuracy may be bookkept. However, if higher than fourth-order + ! coefficients are wanted, the formulae required to compute + ! coefficients will have to be implemented in the subroutine + ! - ! Allocating centered finite-difference coefficients in x-direction + ! centered finite-difference coefficients in x-direction if (omega_wrt(2) .or. omega_wrt(3) .or. schlieren_wrt .or. liutex_wrt) then allocate (fd_coeff_x(-fd_number:fd_number, & -offset_x%beg:m + offset_x%end)) end if - ! Allocating centered finite-difference coefficients in y-direction + ! centered finite-difference coefficients in y-direction if (omega_wrt(1) .or. omega_wrt(3) .or. liutex_wrt & .or. & (n > 0 .and. schlieren_wrt)) then @@ -94,7 +94,7 @@ contains -offset_y%beg:n + offset_y%end)) end if - ! Allocating centered finite-difference coefficients in z-direction + ! centered finite-difference coefficients in z-direction if (omega_wrt(1) .or. omega_wrt(2) .or. liutex_wrt & .or. & (p > 0 .and. schlieren_wrt)) then @@ -102,9 +102,9 @@ contains -offset_z%beg:p + offset_z%end)) end if - ! Annotating the dimensionality of the dataset undergoing the post- - ! process. A flag value of 1 indicates that the dataset is 3D, while - ! a flag value of 0 indicates that it is not. + ! the dimensionality of the dataset undergoing the post- + ! A flag value of 1 indicates that the dataset is 3D, while + ! flag value of 0 indicates that it is not. if (p > 0) then flg = 1 else @@ -114,10 +114,10 @@ contains end subroutine s_initialize_derived_variables_module !> This subroutine receives as input the specific heat ratio - !! function, gamma_sf, and derives from it the specific heat - !! ratio. The latter is stored in the derived flow quantity - !! storage variable, q_sf. - !! @param q_sf Specific heat ratio + !! and derives from it the specific heat + !! latter is stored in the derived flow quantity + !! q_sf. + !! Specific heat ratio subroutine s_derive_specific_heat_ratio(q_sf) real(wp), & @@ -128,7 +128,7 @@ contains integer :: i, j, k !< Generic loop iterators - ! Computing specific heat ratio from specific heat ratio function + ! specific heat ratio from specific heat ratio function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end @@ -140,11 +140,11 @@ contains end subroutine s_derive_specific_heat_ratio !> This subroutine admits as inputs the specific heat ratio - !! function and the liquid stiffness function, gamma_sf and - !! pi_inf_sf, respectively. These are used to calculate the - !! values of the liquid stiffness, which are stored in the - !! derived flow quantity storage variable, q_sf. - !! @param q_sf Liquid stiffness + !! the liquid stiffness function, gamma_sf and + !! These are used to calculate the + !! the liquid stiffness, which are stored in the + !! quantity storage variable, q_sf. + !! Liquid stiffness subroutine s_derive_liquid_stiffness(q_sf) real(wp), & @@ -155,8 +155,8 @@ contains integer :: i, j, k !< Generic loop iterators - ! Calculating the values of the liquid stiffness from those of the - ! specific heat ratio function and the liquid stiffness function + ! the values of the liquid stiffness from those of the + ! heat ratio function and the liquid stiffness function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end @@ -168,12 +168,12 @@ contains end subroutine s_derive_liquid_stiffness !> This subroutine admits as inputs the primitive variables, - !! the density, the specific heat ratio function and liquid - !! stiffness function. It then computes from those variables - !! the values of the speed of sound, which are stored in the - !! derived flow quantity storage variable, q_sf. - !! @param q_prim_vf Primitive variables - !! @param q_sf Speed of sound + !! the specific heat ratio function and liquid + !! It then computes from those variables + !! of the speed of sound, which are stored in the + !! quantity storage variable, q_sf. + !! Primitive variables + !! Speed of sound subroutine s_derive_sound_speed(q_prim_vf, q_sf) type(scalar_field), & @@ -188,16 +188,16 @@ contains integer :: i, j, k !< Generic loop iterators - ! Fluid bulk modulus for alternate sound speed + ! bulk modulus for alternate sound speed real(wp) :: blkmod1, blkmod2 - ! Computing speed of sound values from those of pressure, density, - ! specific heat ratio function and the liquid stiffness function + ! speed of sound values from those of pressure, density, + ! heat ratio function and the liquid stiffness function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end - ! Compute mixture sound speed + ! mixture sound speed if (alt_soundspeed .neqv. .true.) then q_sf(i, j, k) = (((gamma_sf(i, j, k) + 1._wp)* & q_prim_vf(E_idx)%sf(i, j, k) + & @@ -224,13 +224,13 @@ contains end subroutine s_derive_sound_speed !> This subroutine derives the flux_limiter at cell boundary - !! i+1/2. This is an approximation because the velocity used - !! to determine the upwind direction is the velocity at the - !! cell center i instead of the contact velocity at the cell - !! boundary from the Riemann solver. - !! @param i Component indicator - !! @param q_prim_vf Primitive variables - !! @param q_sf Flux limiter + !! is an approximation because the velocity used + !! the upwind direction is the velocity at the + !! i instead of the contact velocity at the cell + !! the Riemann solver. + !! Component indicator + !! Primitive variables + !! Flux limiter subroutine s_derive_flux_limiter(i, q_prim_vf, q_sf) integer, intent(in) :: i @@ -291,15 +291,15 @@ contains if (f_approx_equal(top, bottom)) then slope = 1._wp - ! ELSEIF((top == 0._wp .AND. bottom /= 0._wp) & - ! .OR. & - ! (bottom == 0._wp .AND. top /= 0._wp)) THEN - ! slope = 0._wp + ! == 0._wp .AND. bottom /= 0._wp) & + ! & + ! == 0._wp .AND. top /= 0._wp)) THEN + ! = 0._wp else slope = (top*bottom)/(bottom**2._wp + 1.e-16_wp) end if - ! Flux limiter function + ! limiter function if (flux_lim == 1) then ! MINMOD (MM) q_sf(j, k, l) = max(0._wp, min(1._wp, slope)) elseif (flux_lim == 2) then ! MUSCL (MC) @@ -321,10 +321,10 @@ contains end subroutine s_derive_flux_limiter !> Computes the solution to the linear system Ax=b w/ sol = x - !! @param A Input matrix - !! @param b right-hane-side - !! @param sol Solution - !! @param ndim Problem size + !! Input matrix + !! right-hane-side + !! Solution + !! Problem size subroutine s_solve_linear_system(A, b, sol, ndim) integer, intent(in) :: ndim @@ -336,10 +336,10 @@ contains integer :: i, j, k - ! Solve linear system using own linear solver (Thomson/Darter/Comet/Stampede) - ! Forward elimination + ! linear system using own linear solver (Thomson/Darter/Comet/Stampede) + ! elimination do i = 1, ndim - ! Pivoting + ! j = i - 1 + maxloc(abs(A(i:ndim, i)), 1) sol = A(i, :) A(i, :) = A(j, :) @@ -347,7 +347,7 @@ contains sol(1) = b(i) b(i) = b(j) b(j) = sol(1) - ! Elimination + ! b(i) = b(i)/A(i, i) A(i, :) = A(i, :)/A(i, i) do k = i + 1, ndim @@ -356,7 +356,7 @@ contains end do end do - ! Backward substitution + ! substitution do i = ndim, 1, -1 sol(i) = b(i) do k = i + 1, ndim @@ -367,14 +367,14 @@ contains end subroutine s_solve_linear_system !> This subroutine receives as inputs the indicator of the - !! component of the vorticity that should be outputted and - !! the primitive variables. From those inputs, it proceeds - !! to calculate values of the desired vorticity component, - !! which are subsequently stored in derived flow quantity - !! storage variable, q_sf. - !! @param i Vorticity component indicator - !! @param q_prim_vf Primitive variables - !! @param q_sf Vorticity component + !! the vorticity that should be outputted and + !! variables. From those inputs, it proceeds + !! values of the desired vorticity component, + !! subsequently stored in derived flow quantity + !! q_sf. + !! Vorticity component indicator + !! Primitive variables + !! Vorticity component subroutine s_derive_vorticity_component(i, q_prim_vf, q_sf) integer, intent(in) :: i @@ -391,7 +391,7 @@ contains integer :: j, k, l, r !< Generic loop iterators - ! Computing the vorticity component in the x-coordinate direction + ! the vorticity component in the x-coordinate direction if (i == 1) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -420,7 +420,7 @@ contains end do end do - ! Computing the vorticity component in the y-coordinate direction + ! the vorticity component in the y-coordinate direction elseif (i == 2) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -448,7 +448,7 @@ contains end do end do - ! Computing the vorticity component in the z-coordinate direction + ! the vorticity component in the z-coordinate direction else do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -472,11 +472,11 @@ contains end subroutine s_derive_vorticity_component !> This subroutine gets as inputs the primitive variables. From those - !! inputs, it proceeds to calculate the value of the Q_M - !! function, which are subsequently stored in the derived flow - !! quantity storage variable, q_sf. - !! @param q_prim_vf Primitive variables - !! @param q_sf Q_M + !! proceeds to calculate the value of the Q_M + !! are subsequently stored in the derived flow + !! variable, q_sf. + !! Primitive variables + !! Q_M subroutine s_derive_qm(q_prim_vf, q_sf) type(scalar_field), & dimension(sys_size), & @@ -498,22 +498,22 @@ contains do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end - ! Get velocity gradient tensor + ! velocity gradient tensor q_jacobian_sf(:, :) = 0._wp do r = -fd_number, fd_number do jj = 1, 3 - ! d()/dx + ! q_jacobian_sf(jj, 1) = & q_jacobian_sf(jj, 1) + & fd_coeff_x(r, j)* & q_prim_vf(mom_idx%beg + jj - 1)%sf(r + j, k, l) - ! d()/dy + ! q_jacobian_sf(jj, 2) = & q_jacobian_sf(jj, 2) + & fd_coeff_y(r, k)* & q_prim_vf(mom_idx%beg + jj - 1)%sf(j, r + k, l) - ! d()/dz + ! q_jacobian_sf(jj, 3) = & q_jacobian_sf(jj, 3) + & fd_coeff_z(r, l)* & @@ -521,7 +521,7 @@ contains end do end do - ! Decompose J into asymmetric matrix, S, and a skew-symmetric matrix, O + ! J into asymmetric matrix, S, and a skew-symmetric matrix, O do jj = 1, 3 do kk = 1, 3 S(jj, kk) = 0.5_wp* & @@ -531,7 +531,7 @@ contains end do end do - ! Compute S2 = S*S' + ! S2 = S*S' do jj = 1, 3 do kk = 1, 3 O2(jj, kk) = O(jj, 1)*O(kk, 1) + & @@ -543,7 +543,7 @@ contains end do end do - ! Compute Q + ! Q Q = 0.5_wp*((O2(1, 1) + O2(2, 2) + O2(3, 3)) - & (S2(1, 1) + S2(2, 2) + S2(3, 3))) trS = S(1, 1) + S(2, 2) + S(3, 3) @@ -558,11 +558,11 @@ contains end subroutine s_derive_qm !> This subroutine gets as inputs the primitive variables. From those - !! inputs, it proceeds to calculate the Liutex vector and its - !! magnitude based on Xu et al. (2019). - !! @param q_prim_vf Primitive variables - !! @param liutex_mag Liutex magnitude - !! @param liutex_axis Liutex axis + !! proceeds to calculate the Liutex vector and its + !! on Xu et al. (2019). + !! @param[in] q_prim_vf Primitive variables + !! @param[out] liutex_mag Liutex magnitude + !! @param[out] liutex_axis Liutex rotation axis (3D vector field) impure subroutine s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis) integer, parameter :: nm = 3 type(scalar_field), & @@ -573,13 +573,13 @@ contains dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end), & - intent(out) :: liutex_mag !< Liutex magnitude + intent(out) :: liutex_mag real(wp), & dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end, nm), & - intent(out) :: liutex_axis !< Liutex rigid rotation axis + intent(out) :: liutex_axis character, parameter :: ivl = 'N' !< compute left eigenvectors character, parameter :: ivr = 'V' !< compute right eigenvectors @@ -603,22 +603,22 @@ contains do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end - ! Get velocity gradient tensor (VGT) + ! velocity gradient tensor (VGT) vgt(:, :) = 0._wp do r = -fd_number, fd_number do i = 1, 3 - ! d()/dx + ! vgt(i, 1) = & vgt(i, 1) + & fd_coeff_x(r, j)* & q_prim_vf(mom_idx%beg + i - 1)%sf(r + j, k, l) - ! d()/dy + ! vgt(i, 2) = & vgt(i, 2) + & fd_coeff_y(r, k)* & q_prim_vf(mom_idx%beg + i - 1)%sf(j, r + k, l) - ! d()/dz + ! vgt(i, 3) = & vgt(i, 3) + & fd_coeff_z(r, l)* & @@ -626,14 +626,14 @@ contains end do end do - ! Call appropriate LAPACK routine based on precision + ! appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call sgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info) #else call dgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info) #endif - ! Find real eigenvector + ! real eigenvector idx = 1 do r = 2, 3 if (abs(li(r)) < abs(li(idx))) then @@ -642,7 +642,7 @@ contains end do eigvec = vr(:, idx) - ! Normalize real eigenvector if it is effectively non-zero + ! real eigenvector if it is effectively non-zero eigvec_mag = sqrt(eigvec(1)**2._wp & + eigvec(2)**2._wp & + eigvec(3)**2._wp) @@ -652,22 +652,22 @@ contains eigvec = 0._wp end if - ! Compute vorticity projected on the eigenvector + ! vorticity projected on the eigenvector omega_proj = (vgt(3, 2) - vgt(2, 3))*eigvec(1) & + (vgt(1, 3) - vgt(3, 1))*eigvec(2) & + (vgt(2, 1) - vgt(1, 2))*eigvec(3) - ! As eigenvector can have +/- signs, we can choose the sign - ! so that omega_proj is positive + ! eigenvector can have +/- signs, we can choose the sign + ! that omega_proj is positive if (omega_proj < 0._wp) then eigvec = -eigvec omega_proj = -omega_proj end if - ! Find imaginary part of complex eigenvalue + ! imaginary part of complex eigenvalue lci = li(mod(idx, 3) + 1) - ! Compute Liutex magnitude + ! Liutex magnitude alpha = omega_proj**2._wp - 4._wp*lci**2._wp ! (2*alpha)^2 if (alpha > 0._wp) then liutex_mag(j, k, l) = omega_proj - sqrt(alpha) @@ -675,7 +675,7 @@ contains liutex_mag(j, k, l) = omega_proj end if - ! Compute Liutex axis + ! Liutex axis liutex_axis(j, k, l, 1) = eigvec(1) liutex_axis(j, k, l, 2) = eigvec(2) liutex_axis(j, k, l, 3) = eigvec(3) @@ -687,12 +687,12 @@ contains end subroutine s_derive_liutex !> This subroutine gets as inputs the conservative variables - !! and density. From those inputs, it proceeds to calculate - !! the values of the numerical Schlieren function, which are - !! subsequently stored in the derived flow quantity storage - !! variable, q_sf. - !! @param q_cons_vf Conservative variables - !! @param q_sf Numerical Schlieren function + !! From those inputs, it proceeds to calculate + !! of the numerical Schlieren function, which are + !! in the derived flow quantity storage + !! + !! Conservative variables + !! Numerical Schlieren function impure subroutine s_derive_numerical_schlieren_function(q_cons_vf, q_sf) type(scalar_field), & @@ -706,19 +706,19 @@ contains intent(inout) :: q_sf real(wp) :: drho_dx, drho_dy, drho_dz !< - !! Spatial derivatives of the density in the x-, y- and z-directions + !! of the density in the x-, y- and z-directions real(wp), dimension(2) :: gm_rho_max !< - !! Maximum value of the gradient magnitude (gm) of the density field - !! in entire computational domain and not just the local sub-domain. - !! The first position in the variable contains the maximum value and - !! the second contains the rank of the processor on which it occurred. + !! of the gradient magnitude (gm) of the density field + !! computational domain and not just the local sub-domain. + !! position in the variable contains the maximum value and + !! contains the rank of the processor on which it occurred. integer :: i, j, k, l !< Generic loop iterators - ! Computing Gradient Magnitude of Density + ! Gradient Magnitude of Density - ! Contributions from the x- and y-coordinate directions + ! from the x- and y-coordinate directions do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end @@ -737,7 +737,7 @@ contains end do end do - ! Contribution from the z-coordinate direction + ! from the z-coordinate direction if (p > 0) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -763,31 +763,31 @@ contains end do end if - ! Up until now, only the dot product of the gradient of the density - ! field has been calculated and stored in the gradient magnitude of - ! density variable. So now we proceed to take the square-root as to - ! complete the desired calculation. + ! until now, only the dot product of the gradient of the density + ! has been calculated and stored in the gradient magnitude of + ! variable. So now we proceed to take the square-root as to + ! the desired calculation. gm_rho_sf = sqrt(gm_rho_sf) - ! Determining the local maximum of the gradient magnitude of density - ! and bookkeeping the result, along with rank of the local processor + ! the local maximum of the gradient magnitude of density + ! bookkeeping the result, along with rank of the local processor gm_rho_max = (/maxval(gm_rho_sf), real(proc_rank, wp)/) - ! Comparing the local maximum gradient magnitude of the density on - ! this processor to the those computed on the remaining processors. - ! This allows for the global maximum to be computed and the rank of - ! the processor on which it has occurred to be recorded. + ! the local maximum gradient magnitude of the density on + ! processor to the those computed on the remaining processors. + ! allows for the global maximum to be computed and the rank of + ! processor on which it has occurred to be recorded. if (num_procs > 1) call s_mpi_reduce_maxloc(gm_rho_max) - ! Computing Numerical Schlieren Function + ! Numerical Schlieren Function - ! The form of the numerical Schlieren function depends on the choice - ! of the multicomponent flow model. For the gamma/pi_inf model, the - ! exponential of the negative, normalized, gradient magnitude of the - ! density is computed. For the volume fraction model, the amplitude - ! of the exponential's inside is also modulated with respect to the - ! identity of the fluid in which the function is evaluated. For more - ! information, refer to Marquina and Mulet (2003). + ! form of the numerical Schlieren function depends on the choice + ! the multicomponent flow model. For the gamma/pi_inf model, the + ! of the negative, normalized, gradient magnitude of the + ! is computed. For the volume fraction model, the amplitude + ! the exponential's inside is also modulated with respect to the + ! of the fluid in which the function is evaluated. For more + ! refer to Marquina and Mulet (2003). if (model_eqns == 1) then ! Gamma/pi_inf model q_sf = -gm_rho_sf/gm_rho_max(1) @@ -810,9 +810,9 @@ contains end do end if - ! Up until now, only the inside of the exponential of the numerical - ! Schlieren function has been evaluated and stored. Then, to finish - ! the computation, the exponential of the inside quantity is taken. + ! until now, only the inside of the exponential of the numerical + ! function has been evaluated and stored. Then, to finish + ! computation, the exponential of the inside quantity is taken. q_sf = exp(q_sf) end subroutine s_derive_numerical_schlieren_function @@ -820,13 +820,13 @@ contains !> Deallocation procedures for the module impure subroutine s_finalize_derived_variables_module - ! Deallocating the variable containing the gradient magnitude of the - ! density field provided that the numerical Schlieren function was - ! was outputted during the post-process + ! the variable containing the gradient magnitude of the + ! field provided that the numerical Schlieren function was + ! outputted during the post-process if (schlieren_wrt) deallocate (gm_rho_sf) - ! Deallocating the variables that might have been used to bookkeep - ! the finite-difference coefficients in the x-, y- and z-directions + ! the variables that might have been used to bookkeep + ! finite-difference coefficients in the x-, y- and z-directions if (allocated(fd_coeff_x)) deallocate (fd_coeff_x) if (allocated(fd_coeff_y)) deallocate (fd_coeff_y) if (allocated(fd_coeff_z)) deallocate (fd_coeff_z) diff --git a/src/post_process/m_global_parameters.fpp b/src/post_process/m_global_parameters.fpp index b21af0fad6..9e1d96789a 100644 --- a/src/post_process/m_global_parameters.fpp +++ b/src/post_process/m_global_parameters.fpp @@ -1,12 +1,12 @@ !> -!! @file m_global_parameters.f90 -!! @brief Contains module m_global_parameters +!! +!! module m_global_parameters #:include 'case.fpp' !> @brief This module contains all of the parameters characterizing the -!! computational domain, simulation algorithm, stiffened equation of -!! state and finally, the formatted database file(s) structure. +!! simulation algorithm, stiffened equation of +!! finally, the formatted database file(s) structure. module m_global_parameters #ifdef MFC_MPI @@ -27,7 +27,7 @@ module m_global_parameters character(LEN=path_len) :: case_dir !< Case folder location !> @} - ! Computational Domain Parameters + ! Domain Parameters integer :: proc_rank !< Rank of the local processor @@ -74,9 +74,9 @@ module m_global_parameters !> @} integer :: buff_size !< - !! Number of cells in buffer region. For the variables which feature a buffer - !! region, this region is used to store information outside the computational - !! domain based on the boundary conditions. + !! cells in buffer region. For the variables which feature a buffer + !! region is used to store information outside the computational + !! on the boundary conditions. integer :: t_step_start !< First time-step directory integer :: t_step_stop !< Last time-step directory @@ -92,9 +92,9 @@ module m_global_parameters integer :: n_start !> @} - ! NOTE: The variables m_root, x_root_cb and x_root_cc contain the grid data - ! of the defragmented computational domain. They are only used in 1D. For - ! serial simulations, they are equal to m, x_cb and x_cc, respectively. + ! The variables m_root, x_root_cb and x_root_cc contain the grid data + ! the defragmented computational domain. They are only used in 1D. For + ! simulations, they are equal to m, x_cb and x_cc, respectively. !> @name Simulation Algorithm Parameters !> @{ @@ -147,13 +147,13 @@ module m_global_parameters integer :: psi_idx !< Index of hyperbolic cleaning state variable for MHD !> @} - ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). - ! Stands for "InDices With BUFFer". + ! Indices for the (local) interior points (O-m, O-n, 0-p). + ! for "InDices With BUFFer". type(int_bounds_info) :: idwint(1:3) - ! Cell Indices for the entire (local) domain. In simulation, this includes - ! the buffer region. idwbuff and idwint are the same otherwise. - ! Stands for "InDices With BUFFer". + ! Indices for the entire (local) domain. In simulation, this includes + ! buffer region. idwbuff and idwint are the same otherwise. + ! for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) integer :: num_bc_patches @@ -165,22 +165,22 @@ module m_global_parameters integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! Indices of the stress components that represent shear stress + !! the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! Number of shear stress components to reflect for boundary conditions + !! shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! Indices of shear stress components to reflect for boundary conditions. - !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! shear stress components to reflect for boundary conditions. + !! 1:shear_BC_flip_num) for (x/y/z, [indices]) logical :: parallel_io !< Format of the data files logical :: sim_data logical :: file_per_process !< output format integer, allocatable, dimension(:) :: proc_coords !< - !! Processor coordinates in MPI_CART_COMM + !! in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! Starting cell-center index of local processor in global grid + !! index of local processor in global grid integer :: num_ibs !< Number of immersed boundaries @@ -201,16 +201,16 @@ module m_global_parameters !> @} type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! Database of the physical parameters of each of the fluids that is present - !! in the flow. These include the stiffened gas equation of state parameters, - !! and the Reynolds numbers. + !! the physical parameters of each of the fluids that is present + !! flow. These include the stiffened gas equation of state parameters, + !! Reynolds numbers. - ! Subgrid Bubble Parameters + ! Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp real(wp), allocatable, dimension(:) :: adv !< Advection variables - ! Formatted Database File(s) Structure Parameters + ! Database File(s) Structure Parameters integer :: format !< Format of the database file(s) @@ -223,20 +223,20 @@ module m_global_parameters type(int_bounds_info) :: x_output_idx, y_output_idx, z_output_idx !< Indices of domain to output for post-processing !> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions. - !! The definition of the ghost zone layers is only necessary when using the - !! Silo database file format in multidimensions. These zones provide VisIt - !! with the subdomain connectivity information that it requires in order to - !! produce smooth plots. + !! of the ghost zone layers is only necessary when using the + !! file format in multidimensions. These zones provide VisIt + !! subdomain connectivity information that it requires in order to + !! plots. !> @{ type(int_bounds_info) :: offset_x, offset_y, offset_z !> @} !> @name The list of all possible flow variables that may be written to a database - !! file. It includes partial densities, density, momentum, velocity, energy, - !! pressure, volume fraction(s), specific heat ratio function, specific heat - !! ratio, liquid stiffness function, liquid stiffness, primitive variables, - !! conservative variables, speed of sound, the vorticity, - !! and the numerical Schlieren function. + !! includes partial densities, density, momentum, velocity, energy, + !! fraction(s), specific heat ratio function, specific heat + !! stiffness function, liquid stiffness, primitive variables, + !! speed of sound, the vorticity, + !! numerical Schlieren function. !> @{ logical, dimension(num_fluids_max) :: alpha_rho_wrt logical :: rho_wrt @@ -286,20 +286,20 @@ module m_global_parameters !> @} real(wp), dimension(num_fluids_max) :: schlieren_alpha !< - !! Amplitude coefficients of the numerical Schlieren function that are used - !! to adjust the intensity of numerical Schlieren renderings for individual - !! fluids. This enables waves and interfaces of varying strengths and in all - !! of the fluids to be made simultaneously visible on a single plot. + !! of the numerical Schlieren function that are used + !! the intensity of numerical Schlieren renderings for individual + !! enables waves and interfaces of varying strengths and in all + !! fluids to be made simultaneously visible on a single plot. integer :: fd_order !< - !! The order of the finite-difference (fd) approximations of the first-order - !! derivatives that need to be evaluated when vorticity and/or the numerical - !! Schlieren function are to be outputted to the formatted database file(s). + !! of the finite-difference (fd) approximations of the first-order + !! need to be evaluated when vorticity and/or the numerical + !! are to be outputted to the formatted database file(s). integer :: fd_number !< - !! The finite-difference number is given by MAX(1, fd_order/2). Essentially, - !! it is a measure of the half-size of the finite-difference stencil for the - !! selected order of accuracy. + !! number is given by MAX(1, fd_order/2). Essentially, + !! a measure of the half-size of the finite-difference stencil for the + !! of accuracy. !> @name Reference parameters for Tait EOS !> @{ @@ -361,16 +361,16 @@ module m_global_parameters contains !> Assigns default values to user inputs prior to reading - !! them in. This allows for an easier consistency check of - !! these parameters once they are read from the input file. + !! This allows for an easier consistency check of + !! once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i !< Generic loop iterator - ! Logistics + ! case_dir = '.' - ! Computational domain parameters + ! domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -389,7 +389,7 @@ contains n_start = dflt_int t_stop = dflt_real - ! Simulation algorithm parameters + ! algorithm parameters model_eqns = dflt_int num_fluids = dflt_int recon_type = WENO_TYPE @@ -428,7 +428,7 @@ contains chem_params%gamma_method = 1 chem_params%transport_model = 1 - ! Fluids physical parameters + ! physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -438,7 +438,7 @@ contains fluid_pp(i)%G = dflt_real end do - ! Subgrid bubble parameters + ! bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -460,7 +460,7 @@ contains bub_pp%R_v = dflt_real; R_v = dflt_real bub_pp%R_g = dflt_real; R_g = dflt_real - ! Formatted database file(s) structure parameters + ! database file(s) structure parameters format = dflt_int precision = dflt_int @@ -520,11 +520,11 @@ contains fd_order = dflt_int avg_state = dflt_int - ! Tait EOS + ! EOS rhoref = dflt_real pref = dflt_real - ! Bubble modeling + ! modeling bubbles_euler = .false. qbmm = .false. R0ref = dflt_real @@ -536,13 +536,13 @@ contains surface_tension = .false. adv_n = .false. - ! Lagrangian bubbles modeling + ! bubbles modeling bubbles_lagrange = .false. - ! IBM + ! num_ibs = dflt_int - ! Output partial domain + ! partial domain output_partial_domain = .false. x_output%beg = dflt_real x_output%end = dflt_real @@ -551,29 +551,29 @@ contains z_output%beg = dflt_real z_output%end = dflt_real - ! MHD + ! Bx0 = dflt_real end subroutine s_assign_default_values_to_user_inputs !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_global_parameters_module integer :: i, j, fac - ! Setting m_root equal to m in the case of a 1D serial simulation + ! m_root equal to m in the case of a 1D serial simulation if (n == 0) m_root = m_glb - ! Gamma/Pi_inf Model + ! Model if (model_eqns == 1) then - ! Setting number of fluids + ! number of fluids num_fluids = 1 - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the gamma/pi_inf model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -585,12 +585,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Volume Fraction Model (5-equation model) + ! Fraction Model (5-equation model) else if (model_eqns == 2) then - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the volume fraction model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -598,17 +598,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! Volume fractions are stored in the indices immediately following - ! the energy equation. IGR tracks a total of (N-1) volume fractions - ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! then adv_idx%end < adv_idx%beg, which skips all loops over the - ! volume fractions since there is no volume fraction to track + ! fractions are stored in the indices immediately following + ! energy equation. IGR tracks a total of (N-1) volume fractions + ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! adv_idx%end < adv_idx%beg, which skips all loops over the + ! fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 ! Alpha for fluid 1 adv_idx%end = E_idx + num_fluids - 1 else - ! Volume fractions are stored in the indices immediately following - ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! fractions are stored in the indices immediately following + ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -690,12 +690,12 @@ contains sys_size = B_idx%end end if - ! Volume Fraction Model (6-equation model) + ! Fraction Model (6-equation model) else if (model_eqns == 3) then - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the volume fraction model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -768,10 +768,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! shear stress index is 2 for 2D and 2,4,5 for 3D + ! stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -779,7 +779,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! Both x-dir and y-dir: flip tau_xy only + ! x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -787,18 +787,18 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! x-dir: flip tau_xy and tau_xz - ! y-dir: flip tau_xy and tau_yz - ! z-dir: flip tau_xz and tau_yz + ! flip tau_xy and tau_xz + ! flip tau_xy and tau_yz + ! flip tau_xz and tau_yz end if end if if (hyperelasticity) then xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! adding three more equations for the \xi field and the elastic energy + ! three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 - ! number of entries in the symmetric btensor plus the jacobian + ! of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 tensor_size = num_dims**2 + 1 end if @@ -874,11 +874,11 @@ contains if (ib) allocate (MPI_IO_IB_DATA%var%sf(0:m, 0:n, 0:p)) #endif - ! Size of the ghost zone layer is non-zero only when post-processing - ! the raw simulation data of a parallel multidimensional computation - ! in the Silo-HDF5 format. If this is the case, one must also verify - ! whether the raw simulation data is 2D or 3D. In the 2D case, size - ! of the z-coordinate direction ghost zone layer must be zeroed out. + ! of the ghost zone layer is non-zero only when post-processing + ! raw simulation data of a parallel multidimensional computation + ! the Silo-HDF5 format. If this is the case, one must also verify + ! the raw simulation data is 2D or 3D. In the 2D case, size + ! the z-coordinate direction ghost zone layer must be zeroed out. if (num_procs == 1 .or. format /= 1) then offset_x%beg = 0 @@ -902,12 +902,12 @@ contains end if - ! Determining the finite-difference number and the buffer size. Note - ! that the size of the buffer is unrelated to the order of the WENO - ! scheme. Rather, it is directly dependent on maximum size of ghost - ! zone layers and possibly the order of the finite difference scheme - ! used for the computation of vorticity and/or numerical Schlieren - ! function. + ! the finite-difference number and the buffer size. Note + ! the size of the buffer is unrelated to the order of the WENO + ! Rather, it is directly dependent on maximum size of ghost + ! layers and possibly the order of the finite difference scheme + ! for the computation of vorticity and/or numerical Schlieren + ! buff_size = max(offset_x%beg, offset_x%end, offset_y%beg, & offset_y%end, offset_z%beg, offset_z%end) @@ -916,7 +916,7 @@ contains buff_size = buff_size + fd_number end if - ! Configuring Coordinate Direction Indexes + ! Coordinate Direction Indexes idwint(1)%beg = 0; idwint(2)%beg = 0; idwint(3)%beg = 0 idwint(1)%end = m; idwint(2)%end = n; idwint(3)%end = p @@ -928,15 +928,15 @@ contains idwbuff(2)%end = idwint(2)%end - idwbuff(2)%beg idwbuff(3)%end = idwint(3)%end - idwbuff(3)%beg - ! Allocating single precision grid variables if needed + ! single precision grid variables if needed allocate (x_cc_s(-buff_size:m + buff_size)) - ! Allocating the grid variables in the x-coordinate direction + ! the grid variables in the x-coordinate direction allocate (x_cb(-1 - offset_x%beg:m + offset_x%end)) allocate (x_cc(-buff_size:m + buff_size)) allocate (dx(-buff_size:m + buff_size)) - ! Allocating grid variables in the y- and z-coordinate directions + ! grid variables in the y- and z-coordinate directions if (n > 0) then allocate (y_cb(-1 - offset_y%beg:n + offset_y%end)) @@ -949,8 +949,8 @@ contains allocate (dz(-buff_size:p + buff_size)) end if - ! Allocating the grid variables, only used for the 1D simulations, - ! and containing the defragmented computational domain grid data + ! the grid variables, only used for the 1D simulations, + ! containing the defragmented computational domain grid data else allocate (x_root_cb(-1:m_root)) @@ -995,16 +995,16 @@ contains #ifdef MFC_MPI - ! Option for Lustre file system (Darter/Comet/Stampede) + ! for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! Option for UNIX file system (Hooke/Thomson) - ! WRITE(mpiiofs, '(A)') '/ufs_' - ! mpiiofs = TRIM(mpiiofs) - ! mpi_info_int = MPI_INFO_NULL + ! for UNIX file system (Hooke/Thomson) + ! '(A)') '/ufs_' + ! = TRIM(mpiiofs) + ! = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1017,18 +1017,18 @@ contains integer :: i - ! Deallocating the grid variables for the x-coordinate direction + ! the grid variables for the x-coordinate direction deallocate (x_cc, x_cb, dx) - ! Deallocating grid variables for the y- and z-coordinate directions + ! grid variables for the y- and z-coordinate directions if (n > 0) then deallocate (y_cc, y_cb, dy) if (p > 0) then deallocate (z_cc, z_cb, dz) end if else - ! Deallocating the grid variables, only used for the 1D simulations, - ! and containing the defragmented computational domain grid data + ! the grid variables, only used for the 1D simulations, + ! containing the defragmented computational domain grid data deallocate (x_root_cb, x_root_cc) end if diff --git a/src/post_process/m_mpi_proxy.fpp b/src/post_process/m_mpi_proxy.fpp index bb9bea6b4e..1420274812 100644 --- a/src/post_process/m_mpi_proxy.fpp +++ b/src/post_process/m_mpi_proxy.fpp @@ -1,12 +1,12 @@ !> -!! @file m_mpi_proxy.f90 -!! @brief Contains module m_mpi_proxy +!! +!! module m_mpi_proxy !> @brief This module serves as a proxy to the parameters and subroutines -!! available in the MPI implementation's MPI module. Specifically, -!! the role of the proxy is to harness basic MPI commands into more -!! complex procedures as to achieve the required communication goals -!! for the post-process. +!! the MPI implementation's MPI module. Specifically, +!! of the proxy is to harness basic MPI commands into more +!! as to achieve the required communication goals +!! post-process. module m_mpi_proxy #ifdef MFC_MPI @@ -24,8 +24,8 @@ module m_mpi_proxy implicit none !> @name Receive counts and displacement vector variables, respectively, used in - !! enabling MPI to gather varying amounts of data from all processes to the - !! root process + !! to gather varying amounts of data from all processes to the + !! !> @{ integer, allocatable, dimension(:) :: recvcounts integer, allocatable, dimension(:) :: displs @@ -34,7 +34,7 @@ module m_mpi_proxy contains !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_mpi_proxy_module #ifdef MFC_MPI @@ -42,10 +42,10 @@ contains integer :: i !< Generic loop iterator integer :: ierr !< Generic flag used to identify and report MPI errors - ! Allocating and configuring the receive counts and the displacement - ! vector variables used in variable-gather communication procedures. - ! Note that these are only needed for either multidimensional runs - ! that utilize the Silo database file format or for 1D simulations. + ! and configuring the receive counts and the displacement + ! variables used in variable-gather communication procedures. + ! that these are only needed for either multidimensional runs + ! utilize the Silo database file format or for 1D simulations. if ((format == 1 .and. n > 0) .or. n == 0) then allocate (recvcounts(0:num_procs - 1)) @@ -73,17 +73,17 @@ contains end subroutine s_initialize_mpi_proxy_module !> Since only processor with rank 0 is in charge of reading - !! and checking the consistency of the user provided inputs, - !! these are not available to the remaining processors. This - !! subroutine is then in charge of broadcasting the required - !! information. + !! the consistency of the user provided inputs, + !! not available to the remaining processors. This + !! then in charge of broadcasting the required + !! impure subroutine s_mpi_bcast_user_inputs #ifdef MFC_MPI integer :: i !< Generic loop iterator integer :: ierr !< Generic flag used to identify and report MPI errors - ! Logistics + ! call MPI_BCAST(case_dir, len(case_dir), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) #:for VAR in [ 'm', 'n', 'p', 'm_glb', 'n_glb', 'p_glb', & @@ -136,7 +136,7 @@ contains call MPI_BCAST(fluid_pp(i)%G, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) end do - ! Subgrid bubble parameters + ! bubble parameters if (bubbles_euler .or. bubbles_lagrange) then #:for VAR in [ 'R0ref','p0ref','rho0ref','T0ref', & 'ss','pv','vd','mu_l','mu_v','mu_g','gam_v','gam_g', & @@ -157,11 +157,11 @@ contains end subroutine s_mpi_bcast_user_inputs !> This subroutine gathers the Silo database metadata for - !! the spatial extents in order to boost the performance of - !! the multidimensional visualization. - !! @param spatial_extents Spatial extents for each processor's sub-domain. First dimension - !! corresponds to the minimum and maximum values, respectively, while - !! the second dimension corresponds to the processor rank. + !! extents in order to boost the performance of + !! visualization. + !! Spatial extents for each processor's sub-domain. First dimension + !! the minimum and maximum values, respectively, while + !! dimension corresponds to the processor rank. impure subroutine s_mpi_gather_spatial_extents(spatial_extents) real(wp), dimension(1:, 0:), intent(INOUT) :: spatial_extents @@ -169,117 +169,117 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Simulation is 3D + ! is 3D if (p > 0) then if (grid_geometry == 3) then - ! Minimum spatial extent in the r-direction + ! spatial extent in the r-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Minimum spatial extent in the theta-direction + ! spatial extent in the theta-direction call MPI_GATHERV(minval(z_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Minimum spatial extent in the z-direction + ! spatial extent in the z-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the r-direction + ! spatial extent in the r-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the theta-direction + ! spatial extent in the theta-direction call MPI_GATHERV(maxval(z_cb), 1, mpi_p, & spatial_extents(5, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the z-direction + ! spatial extent in the z-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(6, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) else - ! Minimum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Minimum spatial extent in the y-direction + ! spatial extent in the y-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Minimum spatial extent in the z-direction + ! spatial extent in the z-direction call MPI_GATHERV(minval(z_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the y-direction + ! spatial extent in the y-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(5, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the z-direction + ! spatial extent in the z-direction call MPI_GATHERV(maxval(z_cb), 1, mpi_p, & spatial_extents(6, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) end if - ! Simulation is 2D + ! is 2D elseif (n > 0) then - ! Minimum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Minimum spatial extent in the y-direction + ! spatial extent in the y-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the y-direction + ! spatial extent in the y-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Simulation is 1D + ! is 1D else - ! Minimum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Maximum spatial extent in the x-direction + ! spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & @@ -291,16 +291,16 @@ contains end subroutine s_mpi_gather_spatial_extents !> This subroutine collects the sub-domain cell-boundary or - !! cell-center locations data from all of the processors and - !! puts back together the grid of the entire computational - !! domain on the rank 0 processor. This is only done for 1D - !! simulations. + !! data from all of the processors and + !! together the grid of the entire computational + !! the rank 0 processor. This is only done for 1D + !! impure subroutine s_mpi_defragment_1d_grid_variable #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Silo-HDF5 database format + ! database format if (format == 1) then call MPI_GATHERV(x_cc(0), m + 1, mpi_p, & @@ -308,7 +308,7 @@ contains mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! Binary database format + ! database format else call MPI_GATHERV(x_cb(0), m + 1, mpi_p, & @@ -325,13 +325,13 @@ contains end subroutine s_mpi_defragment_1d_grid_variable !> This subroutine gathers the Silo database metadata for - !! the flow variable's extents as to boost performance of - !! the multidimensional visualization. - !! @param q_sf Flow variable defined on a single computational sub-domain - !! @param data_extents The flow variable extents on each of the processor's sub-domain. - !! First dimension of array corresponds to the former's minimum and - !! maximum values, respectively, while second dimension corresponds - !! to each processor's rank. + !! variable's extents as to boost performance of + !! visualization. + !! Flow variable defined on a single computational sub-domain + !! The flow variable extents on each of the processor's sub-domain. + !! of array corresponds to the former's minimum and + !! respectively, while second dimension corresponds + !! processor's rank. impure subroutine s_mpi_gather_data_extents(q_sf, data_extents) real(wp), dimension(:, :, :), intent(in) :: q_sf @@ -340,12 +340,12 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Minimum flow variable extent + ! flow variable extent call MPI_GATHERV(minval(q_sf), 1, mpi_p, & data_extents(1, 0), recvcounts, 2*displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) - ! Maximum flow variable extent + ! flow variable extent call MPI_GATHERV(maxval(q_sf), 1, mpi_p, & data_extents(2, 0), recvcounts, 2*displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -355,11 +355,11 @@ contains end subroutine s_mpi_gather_data_extents !> This subroutine gathers the sub-domain flow variable data - !! from all of the processors and puts it back together for - !! the entire computational domain on the rank 0 processor. - !! This is only done for 1D simulations. - !! @param q_sf Flow variable defined on a single computational sub-domain - !! @param q_root_sf Flow variable defined on the entire computational domain + !! of the processors and puts it back together for + !! computational domain on the rank 0 processor. + !! only done for 1D simulations. + !! Flow variable defined on a single computational sub-domain + !! Flow variable defined on the entire computational domain impure subroutine s_mpi_defragment_1d_flow_variable(q_sf, q_root_sf) real(wp), dimension(0:m), intent(in) :: q_sf @@ -368,9 +368,9 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Gathering the sub-domain flow variable data from all the processes - ! and putting it back together for the entire computational domain - ! on the process with rank 0 + ! the sub-domain flow variable data from all the processes + ! putting it back together for the entire computational domain + ! the process with rank 0 call MPI_GATHERV(q_sf(0), m + 1, mpi_p, & q_root_sf(0), recvcounts, displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -384,8 +384,8 @@ contains #ifdef MFC_MPI - ! Deallocating the receive counts and the displacement vector - ! variables used in variable-gather communication procedures + ! the receive counts and the displacement vector + ! used in variable-gather communication procedures if ((format == 1 .and. n > 0) .or. n == 0) then deallocate (recvcounts) deallocate (displs) diff --git a/src/post_process/m_start_up.fpp b/src/post_process/m_start_up.fpp index 329a85f433..3f10c05bfb 100644 --- a/src/post_process/m_start_up.fpp +++ b/src/post_process/m_start_up.fpp @@ -1,17 +1,17 @@ #:include 'macros.fpp' !> -!! @file m_start_up.f90 -!! @brief Contains module m_start_up +!! +!! module m_start_up !> @brief This module contains the subroutines that read in and check the -!! consistency of the user provided inputs. This module also allocates, initializes and -!! deallocates the relevant variables and sets up the time stepping, -!! MPI decomposition and I/O procedures +!! the user provided inputs. This module also allocates, initializes and +!! relevant variables and sets up the time stepping, +!! and I/O procedures module m_start_up - ! Dependencies + ! use, intrinsic :: iso_c_binding @@ -26,16 +26,16 @@ module m_start_up use m_boundary_common !< Common boundary conditions subroutines use m_variables_conversion !< Subroutines to change the state variables from - !! one form to another + !! to another use m_data_input !< Procedures reading raw simulation data to fill - !! the conservative, primitive and grid variables + !! primitive and grid variables use m_data_output !< Procedures that write the grid and chosen flow - !! variable(s) to the formatted database file(s) + !! the formatted database file(s) use m_derived_variables !< Procedures used to compute quantities derived - !! from the conservative and primitive variables + !! conservative and primitive variables use m_helper use m_compile_specific @@ -74,23 +74,23 @@ module m_start_up contains !> Reads the configuration file post_process.inp, in order - !! to populate parameters in module m_global_parameters.f90 - !! with the user provided inputs + !! parameters in module m_global_parameters.f90 + !! user provided inputs impure subroutine s_read_input_file character(LEN=name_len) :: file_loc !< - !! Generic string used to store the address of a particular file + !! used to store the address of a particular file logical :: file_check !< - !! Generic logical used for the purpose of asserting whether a file - !! is or is not present in the designated location + !! used for the purpose of asserting whether a file + !! is not present in the designated location integer :: iostatus - !! Integer to check iostat of file read + !! check iostat of file read character(len=1000) :: line - ! Namelist for all of the parameters to be inputted by the user + ! for all of the parameters to be inputted by the user namelist /user_inputs/ case_dir, m, n, p, t_step_start, & t_step_stop, t_step_save, model_eqns, & num_fluids, mpp_lim, & @@ -121,12 +121,12 @@ contains lag_mg_wrt, lag_betaT_wrt, lag_betaC_wrt, & alpha_rho_e_wrt - ! Inquiring the status of the post_process.inp file + ! the status of the post_process.inp file file_loc = 'post_process.inp' inquire (FILE=trim(file_loc), EXIST=file_check) - ! Checking whether the input file is there. If it is, the input file - ! is read. If not, the program is terminated. + ! whether the input file is there. If it is, the input file + ! read. If not, the program is terminated. if (file_check) then open (1, FILE=trim(file_loc), FORM='formatted', & STATUS='old', ACTION='read') @@ -150,7 +150,7 @@ contains p = int((p + 1)/3) - 1 end if - ! Store m,n,p into global m,n,p + ! m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -171,25 +171,25 @@ contains end subroutine s_read_input_file !> Checking that the user inputs make sense, i.e. that the - !! individual choices are compatible with the code's options - !! and that the combination of these choices results into a - !! valid configuration for the post-process + !! are compatible with the code's options + !! the combination of these choices results into a + !! for the post-process impure subroutine s_check_input_file character(LEN=len_trim(case_dir)) :: file_loc !< - !! Generic string used to store the address of a particular file + !! used to store the address of a particular file logical :: dir_check !< - !! Logical variable used to test the existence of folders + !! used to test the existence of folders - ! Checking the existence of the case folder + ! the existence of the case folder case_dir = adjustl(case_dir) file_loc = trim(case_dir)//'/.' call my_inquire(file_loc, dir_check) - ! Constraint on the location of the case directory + ! on the location of the case directory if (dir_check .neqv. .true.) then call s_mpi_abort('Unsupported choice for the value of '// & 'case_dir. Exiting.') @@ -217,19 +217,19 @@ contains end if end if - ! Populating the grid and conservative variables + ! the grid and conservative variables call s_read_data_files(t_step) - ! Populating the buffer regions of the grid and conservative variables + ! the buffer regions of the grid and conservative variables if (buff_size > 0) then call s_populate_grid_variables_buffers() call s_populate_variables_buffers(bc_type, q_cons_vf) end if - ! Initialize the Temperature cache. + ! the Temperature cache. if (chemistry) call s_compute_q_T_sf(q_T_sf, q_cons_vf, idwbuff) - ! Converting the conservative variables to the primitive ones + ! the conservative variables to the primitive ones call s_convert_conservative_to_primitive_variables(q_cons_vf, q_T_sf, q_prim_vf, idwbuff) end subroutine s_perform_time_step @@ -269,7 +269,7 @@ contains z_end = offset_z%end + p end if - ! Opening a new formatted database file + ! a new formatted database file call s_open_formatted_database_file(t_step) if (sim_data .and. proc_rank == 0) then @@ -282,31 +282,31 @@ contains call s_write_energy_data_file(q_prim_vf, q_cons_vf) end if - ! Adding the grid to the formatted database file + ! the grid to the formatted database file call s_write_grid_to_formatted_database_file(t_step) - ! Computing centered finite-difference coefficients in x-direction + ! centered finite-difference coefficients in x-direction if (omega_wrt(2) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. schlieren_wrt) then call s_compute_finite_difference_coefficients(m, x_cc, & fd_coeff_x, buff_size, & fd_number, fd_order, offset_x) end if - ! Computing centered finite-difference coefficients in y-direction + ! centered finite-difference coefficients in y-direction if (omega_wrt(1) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. (n > 0 .and. schlieren_wrt)) then call s_compute_finite_difference_coefficients(n, y_cc, & fd_coeff_y, buff_size, & fd_number, fd_order, offset_y) end if - ! Computing centered finite-difference coefficients in z-direction + ! centered finite-difference coefficients in z-direction if (omega_wrt(1) .or. omega_wrt(2) .or. qm_wrt .or. liutex_wrt .or. (p > 0 .and. schlieren_wrt)) then call s_compute_finite_difference_coefficients(p, z_cc, & fd_coeff_z, buff_size, & fd_number, fd_order, offset_z) end if - ! Adding the partial densities to the formatted database file + ! the partial densities to the formatted database file if ((model_eqns == 2) .or. (model_eqns == 3) .or. (model_eqns == 4)) then do i = 1, num_fluids if (alpha_rho_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then @@ -324,7 +324,7 @@ contains end do end if - ! Adding the density to the formatted database file + ! the density to the formatted database file if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) .and. (.not. relativity)) then q_sf(:, :, :) = rho_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'rho' @@ -342,8 +342,8 @@ contains end if if (relativity .and. (rho_wrt .or. cons_vars_wrt)) then - ! For relativistic flow, conservative and primitive densities are different - ! Hard-coded single-component for now + ! relativistic flow, conservative and primitive densities are different + ! single-component for now q_sf(:, :, :) = q_cons_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'D' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -351,7 +351,7 @@ contains varname(:) = ' ' end if - ! Adding the momentum to the formatted database file + ! the momentum to the formatted database file do i = 1, E_idx - mom_idx%beg if (mom_wrt(i) .or. cons_vars_wrt) then q_sf(:, :, :) = q_cons_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -363,7 +363,7 @@ contains end if end do - ! Adding the velocity to the formatted database file + ! the velocity to the formatted database file do i = 1, E_idx - mom_idx%beg if (vel_wrt(i) .or. prim_vars_wrt) then q_sf(:, :, :) = q_prim_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -375,7 +375,7 @@ contains end if end do - ! Adding the species' concentrations to the formatted database file + ! the species' concentrations to the formatted database file if (chemistry) then do i = 1, num_species if (chem_wrt_Y(i) .or. prim_vars_wrt) then @@ -397,7 +397,7 @@ contains end if end if - ! Adding the flux limiter function to the formatted database file + ! the flux limiter function to the formatted database file do i = 1, E_idx - mom_idx%beg if (flux_wrt(i)) then @@ -410,7 +410,7 @@ contains end if end do - ! Adding the energy to the formatted database file + ! the energy to the formatted database file if (E_wrt .or. cons_vars_wrt) then q_sf(:, :, :) = q_cons_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'E' @@ -420,7 +420,7 @@ contains end if - ! Adding the individual energies to the formatted database file + ! the individual energies to the formatted database file if (model_eqns == 3) then do i = 1, num_fluids if (alpha_rho_e_wrt(i) .or. cons_vars_wrt) then @@ -541,19 +541,19 @@ contains end if - ! Adding the magnetic field to the formatted database file + ! the magnetic field to the formatted database file if (mhd .and. prim_vars_wrt) then do i = B_idx%beg, B_idx%end q_sf(:, :, :) = q_prim_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) - ! 1D: output By, Bz + ! output By, Bz if (n == 0) then if (i == B_idx%beg) then write (varname, '(A)') 'By' else write (varname, '(A)') 'Bz' end if - ! 2D/3D: output Bx, By, Bz + ! output Bx, By, Bz else if (i == B_idx%beg) then write (varname, '(A)') 'Bx' @@ -569,7 +569,7 @@ contains end do end if - ! Adding the elastic shear stresses to the formatted database file + ! the elastic shear stresses to the formatted database file if (elasticity) then do i = 1, stress_idx%end - stress_idx%beg + 1 if (prim_vars_wrt) then @@ -608,7 +608,7 @@ contains varname(:) = ' ' end if - ! Adding the pressure to the formatted database file + ! the pressure to the formatted database file if (pres_wrt .or. prim_vars_wrt) then q_sf(:, :, :) = q_prim_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'pres' @@ -618,7 +618,7 @@ contains end if - ! Adding the volume fraction(s) to the formatted database file + ! the volume fraction(s) to the formatted database file if (((model_eqns == 2) .and. (bubbles_euler .neqv. .true.)) & .or. (model_eqns == 3) & ) then @@ -660,7 +660,7 @@ contains end if - ! Adding specific heat ratio function to formatted database file + ! specific heat ratio function to formatted database file if (gamma_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then @@ -672,7 +672,7 @@ contains end if - ! Adding the specific heat ratio to the formatted database file + ! the specific heat ratio to the formatted database file if (heat_ratio_wrt) then call s_derive_specific_heat_ratio(q_sf) @@ -684,7 +684,7 @@ contains end if - ! Adding liquid stiffness function to formatted database file + ! liquid stiffness function to formatted database file if (pi_inf_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then @@ -696,7 +696,7 @@ contains end if - ! Adding the liquid stiffness to the formatted database file + ! the liquid stiffness to the formatted database file if (pres_inf_wrt) then call s_derive_liquid_stiffness(q_sf) @@ -708,7 +708,7 @@ contains end if - ! Adding the sound speed to the formatted database file + ! the sound speed to the formatted database file if (c_wrt) then do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end @@ -738,7 +738,7 @@ contains end if - ! Adding the vorticity to the formatted database file + ! the vorticity to the formatted database file do i = 1, 3 if (omega_wrt(i)) then @@ -757,7 +757,7 @@ contains call s_write_variable_to_formatted_database_file(varname, t_step) end if - ! Adding Q_M to the formatted database file + ! Q_M to the formatted database file if (p > 0 .and. qm_wrt) then call s_derive_qm(q_prim_vf, q_sf) @@ -767,13 +767,13 @@ contains varname(:) = ' ' end if - ! Adding Liutex magnitude to the formatted database file + ! Liutex magnitude to the formatted database file if (liutex_wrt) then - ! Compute Liutex vector and its magnitude + ! Liutex vector and its magnitude call s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis) - ! Liutex magnitude + ! magnitude q_sf = liutex_mag write (varname, '(A)') 'liutex_mag' @@ -781,7 +781,7 @@ contains varname(:) = ' ' - ! Liutex axis + ! axis do i = 1, 3 q_sf = liutex_axis(:, :, :, i) @@ -793,7 +793,7 @@ contains end if - ! Adding numerical Schlieren function to formatted database file + ! numerical Schlieren function to formatted database file if (schlieren_wrt) then call s_derive_numerical_schlieren_function(q_cons_vf, q_sf) @@ -805,7 +805,7 @@ contains end if - ! Adding the color function to formatted database file + ! the color function to formatted database file if (cf_wrt) then q_sf(:, :, :) = q_cons_vf(c_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'color_function' @@ -814,7 +814,7 @@ contains end if - ! Adding the volume fraction(s) to the formatted database file + ! the volume fraction(s) to the formatted database file if (bubbles_euler) then do i = adv_idx%beg, adv_idx%end q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -824,7 +824,7 @@ contains end do end if - ! Adding the bubble variables to the formatted database file + ! the bubble variables to the formatted database file if (bubbles_euler) then !nR do i = 1, nb @@ -859,7 +859,7 @@ contains end do end if - ! number density + ! density if (adv_n) then q_sf(:, :, :) = q_cons_vf(n_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'n' @@ -868,9 +868,9 @@ contains end if end if - ! Adding the lagrangian subgrid variables to the formatted database file + ! the lagrangian subgrid variables to the formatted database file if (bubbles_lagrange) then - !! Void fraction field + !! field q_sf(:, :, :) = 1._wp - q_cons_vf(beta_idx)%sf( & -offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & @@ -888,7 +888,7 @@ contains call s_close_energy_data_file() end if - ! Closing the formatted database file + ! the formatted database file call s_close_formatted_database_file() end subroutine s_save_data @@ -974,8 +974,8 @@ contains end subroutine s_mpi_transpose_y2z impure subroutine s_initialize_modules - ! Computation of parameters, allocation procedures, and/or any other tasks - ! needed to properly setup the modules + ! of parameters, allocation procedures, and/or any other tasks + ! to properly setup the modules integer :: size_n(1), inembed(1), onembed(1) call s_initialize_global_parameters_module() @@ -992,7 +992,7 @@ contains call s_initialize_derived_variables_module() call s_initialize_data_output_module() - ! Associate pointers for serial or parallel I/O + ! pointers for serial or parallel I/O if (parallel_io .neqv. .true.) then s_read_data_files => s_read_serial_data_files else @@ -1146,13 +1146,13 @@ contains num_dims = 1 + min(1, n) + min(1, p) #ifdef MFC_MPI - ! Initialization of the MPI environment + ! of the MPI environment call s_mpi_initialize() - ! Processor with rank 0 assigns default user input values prior to reading - ! those in from the input file. Next, the user inputs are read in and their - ! consistency is checked. The detection of any inconsistencies automatically - ! leads to the termination of the post-process. + ! with rank 0 assigns default user input values prior to reading + ! in from the input file. Next, the user inputs are read in and their + ! is checked. The detection of any inconsistencies automatically + ! to the termination of the post-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() call s_read_input_file() @@ -1161,9 +1161,9 @@ contains print '(" Post-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs end if - ! Broadcasting the user inputs to all of the processors and performing the - ! parallel computational domain decomposition. Neither procedure has to be - ! carried out if the simulation is in fact not truly executed in parallel. + ! the user inputs to all of the processors and performing the + ! computational domain decomposition. Neither procedure has to be + ! out if the simulation is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() call s_initialize_parallel_io() call s_mpi_decompose_computational_domain() @@ -1174,13 +1174,13 @@ contains end subroutine s_initialize_mpi_domain impure subroutine s_finalize_modules - ! Disassociate pointers for serial and parallel I/O + ! pointers for serial and parallel I/O s_read_data_files => null() -! if (sim_data .and. proc_rank == 0) then -! call s_close_intf_data_file() -! call s_close_energy_data_file() -! end if +! (sim_data .and. proc_rank == 0) then +! s_close_intf_data_file() +! s_close_energy_data_file() +! if if (fft_wrt) then if (c_associated(fwd_plan_x)) call fftw_destroy_plan(fwd_plan_x) @@ -1204,7 +1204,7 @@ contains end if #endif - ! Deallocation procedures for the modules + ! procedures for the modules call s_finalize_data_output_module() call s_finalize_derived_variables_module() call s_finalize_data_input_module() @@ -1215,7 +1215,7 @@ contains end if call s_finalize_global_parameters_module() - ! Finalizing the MPI environment + ! the MPI environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/post_process/p_main.fpp b/src/post_process/p_main.fpp index 12d6353c67..78e7773d2b 100644 --- a/src/post_process/p_main.fpp +++ b/src/post_process/p_main.fpp @@ -1,15 +1,15 @@ !> -!! @file p_main.f90 -!! @brief Contains program p_main +!! +!! program p_main !> @brief The post-process restructures raw unformatted data, outputted by -!! the simulation, into a formatted database, Silo-HDF5 or Binary, -!! chosen by the user. The user may also specify which variables to -!! include in the database. The choices range from any one of the -!! primitive and conservative variables, as well as quantities that -!! can be derived from those such as the unadvected volume fraction, -!! specific heat ratio, liquid stiffness, speed of sound, vorticity -!! and the numerical Schlieren function. +!! into a formatted database, Silo-HDF5 or Binary, +!! the user. The user may also specify which variables to +!! the database. The choices range from any one of the +!! conservative variables, as well as quantities that +!! derived from those such as the unadvected volume fraction, +!! ratio, liquid stiffness, speed of sound, vorticity +!! numerical Schlieren function. program p_main use m_global_parameters !< Global parameters for the code @@ -20,8 +20,8 @@ program p_main integer :: t_step !< Iterator for the main time-stepping loop character(LEN=name_len) :: varname !< - !! Generic storage for the name(s) of the flow variable(s) that will be added - !! to the formatted database file(s) + !! for the name(s) of the flow variable(s) that will be added + !! formatted database file(s) real(wp) :: pres real(wp) :: c @@ -36,18 +36,18 @@ program p_main t_step = n_start n_save = int(t_stop/t_save) + 1 else - ! Setting the time-step iterator to the first time step to be post-processed + ! the time-step iterator to the first time step to be post-processed t_step = t_step_start end if - ! Time-Marching Loop + ! Loop do - ! If all time-steps are not ready to be post-processed and one rank is - ! faster than another, the slower rank processing the last available - ! step might be killed when the faster rank attempts to process the - ! first missing step, before the slower rank finishes writing the last - ! available step. To avoid this, we force synchronization here. + ! all time-steps are not ready to be post-processed and one rank is + ! than another, the slower rank processing the last available + ! might be killed when the faster rank attempts to process the + ! missing step, before the slower rank finishes writing the last + ! step. To avoid this, we force synchronization here. call s_mpi_barrier() call cpu_time(start) @@ -71,11 +71,11 @@ program p_main exit end if else - ! Modifies the time-step iterator so that it may reach the final time- - ! step to be post-processed, in the case that this one is not originally - ! attainable through constant incrementation from the first time-step. - ! This modification is performed upon reaching the final time-step. In - ! case that it is not needed, the post-processor is done and may exit. + ! the time-step iterator so that it may reach the final time- + ! to be post-processed, in the case that this one is not originally + ! through constant incrementation from the first time-step. + ! modification is performed upon reaching the final time-step. In + ! that it is not needed, the post-processor is done and may exit. if ((t_step_stop - t_step) < t_step_save .and. t_step_stop /= t_step) then t_step = t_step_stop - t_step_save elseif (t_step == t_step_stop) then @@ -86,12 +86,12 @@ program p_main if (cfl_dt) then t_step = t_step + 1 else - ! Incrementing time-step iterator to next time-step to be post-processed + ! time-step iterator to next time-step to be post-processed t_step = t_step + t_step_save end if end do - ! END: Time-Marching Loop + ! Time-Marching Loop close (11) diff --git a/src/pre_process/m_assign_variables.fpp b/src/pre_process/m_assign_variables.fpp index 95473be145..58015d61f3 100644 --- a/src/pre_process/m_assign_variables.fpp +++ b/src/pre_process/m_assign_variables.fpp @@ -1,6 +1,6 @@ !> -!! @file m_assign_variables.f90 -!! @brief Contains module m_assign_variables +!! +!! module m_assign_variables #:include 'case.fpp' #:include 'macros.fpp' @@ -25,24 +25,24 @@ module m_assign_variables procedure(s_assign_patch_xxxxx_primitive_variables), & pointer :: s_assign_patch_primitive_variables => null() !< - !! Depending on the multicomponent flow model, this variable is a pointer to - !! either the subroutine s_assign_patch_mixture_primitive_variables, or the - !! subroutine s_assign_patch_species_primitive_variables + !! the multicomponent flow model, this variable is a pointer to + !! subroutine s_assign_patch_mixture_primitive_variables, or the + !! !> Abstract interface to the two subroutines that assign the patch primitive - !! variables, either mixture or species, depending on the subroutine, to a - !! particular cell in the computational domain + !! mixture or species, depending on the subroutine, to a + !! in the computational domain abstract interface !> Skeleton of s_assign_patch_mixture_primitive_variables - !! and s_assign_patch_species_primitive_variables - !! @param patch_id is the patch identifier - !! @param j (x) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! @param k (y,th) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! @param l (z) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! @param eta pseudo volume fraction - !! @param q_prim_vf Primitive variables - !! @param patch_id_fp Array to track patch ids + !! + !! is the patch identifier + !! (x) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! (y,th) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! (z) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! pseudo volume fraction + !! Primitive variables + !! Array to track patch ids subroutine s_assign_patch_xxxxx_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) @@ -77,9 +77,9 @@ contains allocate (alf_sum%sf(0:m, 0:n, 0:p)) end if - ! Depending on multicomponent flow model, the appropriate procedure - ! for assignment of the patch mixture or species primitive variables - ! to a cell in the domain is targeted by the procedure pointer + ! on multicomponent flow model, the appropriate procedure + ! assignment of the patch mixture or species primitive variables + ! a cell in the domain is targeted by the procedure pointer if (model_eqns == 1) then ! Gamma/pi_inf model s_assign_patch_primitive_variables => & @@ -92,22 +92,22 @@ contains end subroutine s_initialize_assign_variables_module !> This subroutine assigns the mixture primitive variables - !! of the patch designated by the patch_id, to the cell that - !! is designated by the indexes (j,k,l). In addition, the - !! variable bookkeeping the patch identities in the entire - !! domain is updated with the new assignment. Note that if - !! the smoothing of the patch's boundaries is employed, the - !! ensuing primitive variables in the cell will be a type of - !! combination of the current patch's primitive variables - !! with those of the smoothing patch. The specific details - !! of the combination may be found in Shyue's work (1998). - !! @param patch_id the patch identifier - !! @param j the x-dir node index - !! @param k the y-dir node index - !! @param l the z-dir node index - !! @param eta pseudo volume fraction - !! @param q_prim_vf Primitive variables - !! @param patch_id_fp Array to track patch ids + !! patch designated by the patch_id, to the cell that + !! by the indexes (j,k,l). In addition, the + !! the patch identities in the entire + !! updated with the new assignment. Note that if + !! of the patch's boundaries is employed, the + !! variables in the cell will be a type of + !! the current patch's primitive variables + !! of the smoothing patch. The specific details + !! combination may be found in Shyue's work (1998). + !! the patch identifier + !! the x-dir node index + !! the y-dir node index + !! the z-dir node index + !! pseudo volume fraction + !! Primitive variables + !! Array to track patch ids subroutine s_assign_patch_mixture_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) $:GPU_ROUTINE(parallelism='[seq]') @@ -127,17 +127,17 @@ contains integer :: smooth_patch_id integer :: i !< generic loop operator - ! Assigning the mixture primitive variables of a uniform state patch + ! the mixture primitive variables of a uniform state patch - ! Transferring the identity of the smoothing patch + ! the identity of the smoothing patch smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id - ! Density + ! q_prim_vf(1)%sf(j, k, l) = & eta*patch_icpp(patch_id)%rho & + (1._wp - eta)*patch_icpp(smooth_patch_id)%rho - ! Velocity + ! do i = 1, E_idx - mom_idx%beg q_prim_vf(i + 1)%sf(j, k, l) = & 1._wp/q_prim_vf(1)%sf(j, k, l)* & @@ -147,12 +147,12 @@ contains *patch_icpp(smooth_patch_id)%vel(i)) end do - ! Specific heat ratio function + ! heat ratio function q_prim_vf(gamma_idx)%sf(j, k, l) = & eta*patch_icpp(patch_id)%gamma & + (1._wp - eta)*patch_icpp(smooth_patch_id)%gamma - ! Pressure + ! q_prim_vf(E_idx)%sf(j, k, l) = & 1._wp/q_prim_vf(gamma_idx)%sf(j, k, l)* & (eta*patch_icpp(patch_id)%gamma & @@ -160,17 +160,17 @@ contains + (1._wp - eta)*patch_icpp(smooth_patch_id)%gamma & *patch_icpp(smooth_patch_id)%pres) - ! Liquid stiffness function + ! stiffness function q_prim_vf(pi_inf_idx)%sf(j, k, l) = & eta*patch_icpp(patch_id)%pi_inf & + (1._wp - eta)*patch_icpp(smooth_patch_id)%pi_inf - ! Species Concentrations + ! Concentrations if (chemistry) then block real(wp) :: sum, term - ! Accumulating the species concentrations + ! the species concentrations sum = 0._wp do i = 1, num_species term = & @@ -182,7 +182,7 @@ contains sum = max(sum, verysmall) - ! Normalizing the species concentrations + ! the species concentrations do i = 1, num_species q_prim_vf(chemxb + i - 1)%sf(j, k, l) = & q_prim_vf(chemxb + i - 1)%sf(j, k, l)/sum @@ -191,16 +191,16 @@ contains end block end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < 1.e-16_wp) patch_id_fp(j, k, l) = patch_id end subroutine s_assign_patch_mixture_primitive_variables !Stable perturbation in pressure (Ando) - !! @param j the x-dir node index - !! @param k the y-dir node index - !! @param l the z-dir node index - !! @param q_prim_vf Primitive variables + !! the x-dir node index + !! the y-dir node index + !! the z-dir node index + !! Primitive variables subroutine s_perturb_primitive(j, k, l, q_prim_vf) integer, intent(in) :: j, k, l @@ -273,15 +273,15 @@ contains end subroutine s_perturb_primitive !> This subroutine assigns the species primitive variables. This follows - !! s_assign_patch_species_primitive_variables with adaptation for - !! ensemble-averaged bubble modeling - !! @param patch_id the patch identifier - !! @param j the x-dir node index - !! @param k the y-dir node index - !! @param l the z-dir node index - !! @param eta pseudo volume fraction - !! @param q_prim_vf Primitive variables - !! @param patch_id_fp Array to track patch ids + !! adaptation for + !! modeling + !! the patch identifier + !! the x-dir node index + !! the y-dir node index + !! the z-dir node index + !! pseudo volume fraction + !! Primitive variables + !! Array to track patch ids impure subroutine s_assign_patch_species_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) $:GPU_ROUTINE(parallelism='[seq]') @@ -296,9 +296,9 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Density, the specific heat ratio function and the liquid stiffness - ! function, respectively, obtained from the combination of primitive - ! variables of the current and smoothing patches + ! the specific heat ratio function and the liquid stiffness + ! respectively, obtained from the combination of primitive + ! of the current and smoothing patches real(wp) :: rho !< density real(wp) :: gamma real(wp) :: lit_gamma !< specific heat ratio @@ -316,15 +316,15 @@ contains real(wp) :: Ys(1:num_species) real(stp), dimension(sys_size) :: orig_prim_vf !< - !! Vector to hold original values of cell for smoothing purposes + !! hold original values of cell for smoothing purposes integer :: i !< Generic loop iterator integer :: smooth_patch_id - ! Transferring the identity of the smoothing patch + ! the identity of the smoothing patch smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id - ! Transferring original primitive variables + ! original primitive variables do i = 1, sys_size orig_prim_vf(i) = q_prim_vf(i)%sf(j, k, l) end do @@ -342,18 +342,18 @@ contains end do end if - ! Computing Mixture Variables from Original Primitive Variables - ! call s_convert_species_to_mixture_variables( & + ! Mixture Variables from Original Primitive Variables + ! s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & orig_rho, & orig_gamma, & orig_pi_inf, orig_qv) - ! Computing Mixture Variables of Current Patch + ! Mixture Variables of Current Patch if (.not. igr .or. num_fluids > 1) then - ! Volume fraction(s) + ! fraction(s) do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(patch_id)%alpha(i - E_idx) end do @@ -372,15 +372,15 @@ contains end do end if - ! Partial densities + ! densities if (model_eqns /= 4) then do i = 1, cont_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(patch_id)%alpha_rho(i) end do end if - ! Density and the specific heat ratio and liquid stiffness functions - ! call s_convert_species_to_mixture_variables( & + ! and the specific heat ratio and liquid stiffness functions + ! s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & patch_icpp(patch_id)%rho, & @@ -388,17 +388,17 @@ contains patch_icpp(patch_id)%pi_inf, & patch_icpp(patch_id)%qv) - ! Computing Mixture Variables of Smoothing Patch + ! Mixture Variables of Smoothing Patch if (model_eqns /= 4) then - ! Partial densities + ! densities do i = 1, cont_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(smooth_patch_id)%alpha_rho(i) end do end if if (.not. igr .or. num_fluids > 1) then - ! Volume fraction(s) + ! fraction(s) do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(smooth_patch_id)%alpha(i - E_idx) end do @@ -417,13 +417,13 @@ contains end do end if - ! Bubbles euler variables + ! euler variables if (bubbles_euler) then do i = 1, nb muR = R0(i)*patch_icpp(smooth_patch_id)%r0/R0ref muV = patch_icpp(smooth_patch_id)%v0 if (qbmm) then - ! Initialize the moment set + ! the moment set if (dist_type == 1) then q_prim_vf(bub_idx%fullmom(i, 0, 0))%sf(j, k, l) = 1._wp q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l) = muR @@ -450,7 +450,7 @@ contains end do if (adv_n) then - ! Initialize number density + ! number density R3bar = 0._wp do i = 1, nb R3bar = R3bar + weight(i)*(q_prim_vf(bub_idx%rs(i))%sf(j, k, l))**3._wp @@ -459,8 +459,8 @@ contains end if end if - ! Density and the specific heat ratio and liquid stiffness functions - ! call s_convert_species_to_mixture_variables( & + ! and the specific heat ratio and liquid stiffness functions + ! s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & patch_icpp(smooth_patch_id)%rho, & @@ -468,13 +468,13 @@ contains patch_icpp(smooth_patch_id)%pi_inf, & patch_icpp(smooth_patch_id)%qv) - ! Pressure + ! q_prim_vf(E_idx)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%pres & + (1._wp - eta)*orig_prim_vf(E_idx)) if (.not. igr .or. num_fluids > 1) then - ! Volume fractions \alpha + ! fractions \alpha do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = & eta*patch_icpp(patch_id)%alpha(i - E_idx) & @@ -503,7 +503,7 @@ contains end if end if - ! Elastic Shear Stress + ! Shear Stress if (elasticity) then do i = 1, (stress_idx%end - stress_idx%beg) + 1 q_prim_vf(i + stress_idx%beg - 1)%sf(j, k, l) = & @@ -512,7 +512,7 @@ contains end do end if - ! Elastic Shear Stress + ! Shear Stress if (hyperelasticity) then if (pre_stress) then ! pre stressed initial condition in spatial domain @@ -530,7 +530,7 @@ contains xi_cart(3) = z_cc(l) end if - ! assigning the reference map to the q_prim vector field + ! the reference map to the q_prim vector field do i = 1, num_dims q_prim_vf(i + xibeg - 1)%sf(j, k, l) = eta*xi_cart(i) + & (1._wp - eta)*orig_prim_vf(i + xibeg - 1) @@ -550,7 +550,7 @@ contains end do end if - ! Partial densities \alpha \rho + ! densities \alpha \rho if (model_eqns /= 4) then !mixture density is an input do i = 1, cont_idx%end @@ -564,30 +564,30 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! \rho = (( p_l + pi_inf)/( p_ref + pi_inf))**(1/little_gam) * rhoref(1-alf) + ! = (( p_l + pi_inf)/( p_ref + pi_inf))**(1/little_gam) * rhoref(1-alf) q_prim_vf(1)%sf(j, k, l) = & (((q_prim_vf(E_idx)%sf(j, k, l) + pi_inf)/(pref + pi_inf))**(1/lit_gamma))* & rhoref*(1 - q_prim_vf(alf_idx)%sf(j, k, l)) end if - ! Density and the specific heat ratio and liquid stiffness functions - ! call s_convert_species_to_mixture_variables(q_prim_vf, j, k, l, & + ! and the specific heat ratio and liquid stiffness functions + ! s_convert_species_to_mixture_variables(q_prim_vf, j, k, l, & call s_convert_to_mixture_variables(q_prim_vf, j, k, l, & rho, gamma, pi_inf, qv) - ! Velocity + ! do i = 1, E_idx - mom_idx%beg q_prim_vf(i + cont_idx%end)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%vel(i) & + (1._wp - eta)*orig_prim_vf(i + cont_idx%end)) end do - ! Species Concentrations + ! Concentrations if (chemistry) then block real(wp) :: sum, term - ! Accumulating the species concentrations + ! the species concentrations sum = 0._wp do i = 1, num_species term = & @@ -601,7 +601,7 @@ contains sum = 1._wp end if - ! Normalizing the species concentrations + ! the species concentrations do i = 1, num_species q_prim_vf(chemxb + i - 1)%sf(j, k, l) = & q_prim_vf(chemxb + i - 1)%sf(j, k, l)/sum @@ -610,27 +610,27 @@ contains end block end if - ! Set streamwise velocity to hyperbolic tangent function of y + ! streamwise velocity to hyperbolic tangent function of y if (mixlayer_vel_profile) then q_prim_vf(1 + cont_idx%end)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%vel(1)*tanh(y_cc(k)*mixlayer_vel_coef) & + (1._wp - eta)*orig_prim_vf(1 + cont_idx%end)) end if - ! Set partial pressures to mixture pressure for the 6-eqn model + ! partial pressures to mixture pressure for the 6-eqn model if (model_eqns == 3) then do i = internalEnergies_idx%beg, internalEnergies_idx%end q_prim_vf(i)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) end do end if - ! Smoothed bubble variables + ! bubble variables if (bubbles_euler) then do i = 1, nb muR = R0(i)*patch_icpp(patch_id)%r0/R0ref muV = patch_icpp(patch_id)%v0 if (qbmm) then - ! Initialize the moment set + ! the moment set if (dist_type == 1) then q_prim_vf(bub_idx%fullmom(i, 0, 0))%sf(j, k, l) = 1._wp q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l) = muR @@ -659,7 +659,7 @@ contains end do if (adv_n) then - ! Initialize number density + ! number density R3bar = 0._wp do i = 1, nb R3bar = R3bar + weight(i)*(q_prim_vf(bub_idx%rs(i))%sf(j, k, l))**3._wp @@ -685,7 +685,7 @@ contains do i = 1, nb if (f_is_default(real(q_prim_vf(bub_idx%ps(i))%sf(j, k, l), kind=wp))) then q_prim_vf(bub_idx%ps(i))%sf(j, k, l) = pb0(i) - ! print *, 'setting to pb0' + ! *, 'setting to pb0' end if if (f_is_default(real(q_prim_vf(bub_idx%ms(i))%sf(j, k, l), kind=wp))) then q_prim_vf(bub_idx%ms(i))%sf(j, k, l) = mass_v0(i) @@ -698,25 +698,25 @@ contains (1._wp - eta)*orig_prim_vf(c_idx) end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < 1.e-16_wp) patch_id_fp(j, k, l) = patch_id - ! if (j == 1) then - ! print *, (q_prim_vf(bub_idx%rs(i))%sf(j, k, l), i = 1, nb) - ! print *, (q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l), i = 1, nb) - ! print *, (R0(i), i = 1, nb) - ! print *, patch_icpp(patch_id)%r0 - ! print *, (bub_idx%rs(i), i = 1, nb) - ! print *, (bub_idx%fullmom(i, 1, 0), i = 1, nb) - ! end if + ! (j == 1) then + ! *, (q_prim_vf(bub_idx%rs(i))%sf(j, k, l), i = 1, nb) + ! *, (q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l), i = 1, nb) + ! *, (R0(i), i = 1, nb) + ! *, patch_icpp(patch_id)%r0 + ! *, (bub_idx%rs(i), i = 1, nb) + ! *, (bub_idx%fullmom(i, 1, 0), i = 1, nb) + ! if end subroutine s_assign_patch_species_primitive_variables impure subroutine s_finalize_assign_variables_module - ! Nullifying procedure pointer to the subroutine assigning either - ! the patch mixture or species primitive variables to a cell in the - ! computational domain + ! procedure pointer to the subroutine assigning either + ! patch mixture or species primitive variables to a cell in the + ! domain s_assign_patch_primitive_variables => null() end subroutine s_finalize_assign_variables_module diff --git a/src/pre_process/m_boundary_conditions.fpp b/src/pre_process/m_boundary_conditions.fpp index 66ef57cbef..d02622bd9f 100644 --- a/src/pre_process/m_boundary_conditions.fpp +++ b/src/pre_process/m_boundary_conditions.fpp @@ -1,6 +1,6 @@ !> -!! @file m_boundary_conditions.fpp -!! @brief Contains module m_boundary_conditions +!! +!! module m_boundary_conditions !> @brief This module contains module m_boundary_conditions @@ -34,7 +34,7 @@ contains integer :: j - ! Patch is a vertical line at x_beg or x_end + ! is a vertical line at x_beg or x_end if (patch_bc(patch_id)%dir == 1) then y_centroid = patch_bc(patch_id)%centroid(2) length_y = patch_bc(patch_id)%length(2) @@ -42,7 +42,7 @@ contains y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! Patch is a vertical line at x_beg and x_beg is a domain boundary + ! is a vertical line at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do j = 0, n @@ -54,7 +54,7 @@ contains #:endfor end if - ! Patch is a vertical line at y_beg or y_end + ! is a vertical line at y_beg or y_end if (patch_bc(patch_id)%dir == 2) then x_centroid = patch_bc(patch_id)%centroid(1) length_x = patch_bc(patch_id)%length(1) @@ -62,7 +62,7 @@ contains x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! Patch is a vertical line at x_beg and x_beg is a domain boundary + ! is a vertical line at x_beg and x_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do j = 0, m @@ -87,7 +87,7 @@ contains y_centroid = patch_bc(patch_id)%centroid(2) z_centroid = patch_bc(patch_id)%centroid(3) radius = patch_bc(patch_id)%radius - ! Patch is a circle at x_beg and x_beg is a domain boundary + ! is a circle at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do k = 0, p @@ -105,7 +105,7 @@ contains x_centroid = patch_bc(patch_id)%centroid(1) z_centroid = patch_bc(patch_id)%centroid(3) radius = patch_bc(patch_id)%radius - ! Patch is a circle at y_beg and y_beg is a domain boundary + ! is a circle at y_beg and y_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do k = 0, p @@ -156,7 +156,7 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! Patch is a circle at x_beg and x_beg is a domain boundary + ! is a circle at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do k = 0, p @@ -183,7 +183,7 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! Patch is a circle at y_beg and y_beg is a domain boundary + ! is a circle at y_beg and y_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do k = 0, p diff --git a/src/pre_process/m_check_ib_patches.fpp b/src/pre_process/m_check_ib_patches.fpp index 1b09929dda..20ee3cd71a 100644 --- a/src/pre_process/m_check_ib_patches.fpp +++ b/src/pre_process/m_check_ib_patches.fpp @@ -1,5 +1,5 @@ !> @brief This module contains subroutines that read, and check consistency -!! of, the user provided inputs and data. +!! user provided inputs and data. #:include 'macros.fpp' @@ -12,7 +12,7 @@ module m_check_ib_patches use m_mpi_proxy !< Message passing interface (MPI) module proxy use m_data_output !< Procedures to write the grid data and the - !! conservative variables to files + !! to files #ifdef MFC_MPI use mpi !< Message passing interface (MPI) module @@ -39,12 +39,12 @@ contains do i = 1, num_patches_max if (i <= num_ibs) then - ! call s_check_patch_geometry(i) + ! s_check_patch_geometry(i) call s_int_to_str(i, iStr) @:PROHIBIT(patch_ib(i)%geometry == dflt_int, "IB patch undefined. & patch_ib("//trim(iStr)//")%geometry must be set.") - ! Constraints on the geometric initial condition patch parameters + ! on the geometric initial condition patch parameters if (patch_ib(i)%geometry == 2) then call s_check_circle_ib_patch_geometry(i) else if (patch_ib(i)%geometry == 3) then @@ -79,9 +79,9 @@ contains end subroutine s_check_ib_patches !> This subroutine verifies that the geometric parameters of - !! the circle patch have consistently been inputted by the - !! user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by the + !! + !! Patch identifier impure subroutine s_check_circle_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -97,9 +97,9 @@ contains end subroutine s_check_circle_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the ellipse patch have consistently been inputted by the - !! user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by the + !! + !! Patch identifier impure subroutine s_check_ellipse_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -116,9 +116,9 @@ contains end subroutine s_check_ellipse_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the airfoil patch have consistently been inputted by the - !! user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by the + !! + !! Patch identifier impure subroutine s_check_airfoil_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -137,9 +137,9 @@ contains end subroutine s_check_airfoil_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the 3d airfoil patch have consistently been inputted by the - !! user. - !! @param patch_id Patch identifier + !! airfoil patch have consistently been inputted by the + !! + !! Patch identifier impure subroutine s_check_3d_airfoil_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -160,9 +160,9 @@ contains end subroutine s_check_3d_airfoil_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the rectangle patch have consistently been inputted by - !! the user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by + !! + !! Patch identifier impure subroutine s_check_rectangle_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -183,9 +183,9 @@ contains end subroutine s_check_rectangle_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the sphere patch have consistently been inputted by - !! the user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by + !! + !! Patch identifier impure subroutine s_check_sphere_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -206,9 +206,9 @@ contains end subroutine s_check_sphere_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the cuboid patch have consistently been inputted by - !! the user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by + !! + !! Patch identifier impure subroutine s_check_cuboid_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -233,9 +233,9 @@ contains end subroutine s_check_cuboid_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the cylinder patch have consistently been inputted by - !! the user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by + !! + !! Patch identifier impure subroutine s_check_cylinder_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -274,9 +274,9 @@ contains end subroutine s_check_cylinder_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! the model patch have consistently been inputted by - !! the user. - !! @param patch_id Patch identifier + !! patch have consistently been inputted by + !! + !! Patch identifier impure subroutine s_check_model_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -296,8 +296,8 @@ contains end subroutine s_check_model_ib_patch_geometry !!> This subroutine verifies that the geometric parameters of - !! the inactive patch remain unaltered by the user inputs. - !! @param patch_id Patch identifier + !! patch remain unaltered by the user inputs. + !! Patch identifier impure subroutine s_check_inactive_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id diff --git a/src/pre_process/m_check_patches.fpp b/src/pre_process/m_check_patches.fpp index 2a73bd98c0..cbe1647656 100644 --- a/src/pre_process/m_check_patches.fpp +++ b/src/pre_process/m_check_patches.fpp @@ -1,13 +1,13 @@ #:include 'macros.fpp' !> @brief This module contains subroutines that read, and check consistency -!! of, the user provided inputs and data. +!! user provided inputs and data. #:include 'macros.fpp' module m_check_patches - ! Dependencies + ! use m_derived_types !< Definitions of the derived types use m_global_parameters !< Global parameters for the code @@ -15,7 +15,7 @@ module m_check_patches use m_mpi_proxy !< Message passing interface (MPI) module proxy use m_data_output !< Procedures to write the grid data and the - !! conservative variables to files + !! to files #ifdef MFC_MPI use mpi !< Message passing interface (MPI) module @@ -44,7 +44,7 @@ contains do i = 1, num_patches_max if (i <= num_patches) then - ! call s_check_patch_geometry(i) + ! s_check_patch_geometry(i) call s_int_to_str(i, iStr) @:PROHIBIT(patch_icpp(i)%geometry == 6, "Invalid patch geometry number. "// & "patch_icpp("//trim(iStr)//")%geometry is deprecated.") @@ -57,7 +57,7 @@ contains @:PROHIBIT(patch_icpp(i)%geometry == dflt_int, "Invalid patch geometry number. "// & "patch_icpp("//trim(iStr)//")%geometry must be set.") - ! Constraints on the geometric initial condition patch parameters + ! on the geometric initial condition patch parameters if (patch_icpp(i)%geometry == 1) then call s_check_line_segment_patch_geometry(i) elseif (patch_icpp(i)%geometry == 2) then @@ -96,7 +96,7 @@ contains end if end do - ! Constraints on overwrite rights initial condition patch parameters + ! on overwrite rights initial condition patch parameters do i = 1, num_patches if (i <= num_patches) then call s_check_active_patch_alteration_rights(i) @@ -105,7 +105,7 @@ contains end if end do - ! Constraints on smoothing initial condition patch parameters + ! on smoothing initial condition patch parameters do i = 1, num_patches if (i > 1 .and. (patch_icpp(i)%geometry == 2 .or. & patch_icpp(i)%geometry == 3 .or. & @@ -125,7 +125,7 @@ contains end if end do - ! Constraints on flow variables initial condition patch parameters + ! on flow variables initial condition patch parameters do i = 1, num_patches if (i <= num_patches) then call s_check_active_patch_primitive_variables(i) @@ -137,7 +137,7 @@ contains end subroutine s_check_patches !> This subroutine checks the line segment patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_line_segment_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -151,7 +151,7 @@ contains end subroutine s_check_line_segment_patch_geometry !> This subroutine checks the circle patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_circle_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -166,7 +166,7 @@ contains end subroutine s_check_circle_patch_geometry !> This subroutine checks the rectangle patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_rectangle_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -182,7 +182,7 @@ contains end subroutine s_check_rectangle_patch_geometry !> This subroutine checks the line sweep patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_line_sweep_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -199,7 +199,7 @@ contains end subroutine s_check_line_sweep_patch_geometry !> This subroutine checks the ellipse patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_ellipse_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -216,7 +216,7 @@ contains end subroutine s_check_ellipse_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_2D_TaylorGreen_vortex_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -233,7 +233,7 @@ contains end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_sphere_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -248,7 +248,7 @@ contains end subroutine s_check_sphere_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_spherical_harmonic_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -269,10 +269,10 @@ contains end subroutine s_check_spherical_harmonic_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_cuboid_patch_geometry(patch_id) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -287,10 +287,10 @@ contains end subroutine s_check_cuboid_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_cylinder_patch_geometry(patch_id) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -300,14 +300,14 @@ contains @:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cylinder patch "//trim(iStr)//": z_centroid must be set") @:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Cylinder patch "//trim(iStr)//": radius must be greater than zero") - ! Check if exactly one length is defined + ! if exactly one length is defined @:PROHIBIT(count([ & patch_icpp(patch_id)%length_x > 0._wp, & patch_icpp(patch_id)%length_y > 0._wp, & patch_icpp(patch_id)%length_z > 0._wp & ]) /= 1, "Cylinder patch "//trim(iStr)//": Exactly one of length_x, length_y, or length_z must be defined and positive") - ! Ensure the defined length is positive + ! the defined length is positive @:PROHIBIT( & (.not. f_is_default(patch_icpp(patch_id)%length_x) .and. patch_icpp(patch_id)%length_x <= 0._wp) .or. & (.not. f_is_default(patch_icpp(patch_id)%length_y) .and. patch_icpp(patch_id)%length_y <= 0._wp) .or. & @@ -317,10 +317,10 @@ contains end subroutine s_check_cylinder_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_plane_sweep_patch_geometry(patch_id) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -335,7 +335,7 @@ contains end subroutine s_check_plane_sweep_patch_geometry !> This subroutine checks the model patch input - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_ellipsoid_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -352,8 +352,8 @@ contains end subroutine s_check_ellipsoid_patch_geometry !!> This subroutine verifies that the geometric parameters of - !! the inactive patch remain unaltered by the user inputs. - !! @param patch_id Patch identifier + !! patch remain unaltered by the user inputs. + !! Patch identifier impure subroutine s_check_inactive_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -378,7 +378,7 @@ contains end subroutine s_check_inactive_patch_geometry !> This subroutine verifies the active patch's right to overwrite the preceding patches - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_active_patch_alteration_rights(patch_id) integer, intent(in) :: patch_id @@ -391,10 +391,10 @@ contains end subroutine s_check_active_patch_alteration_rights !> This subroutine verifies that inactive patches cannot overwrite other patches - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_inactive_patch_alteration_rights(patch_id) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -404,7 +404,7 @@ contains end subroutine s_check_inactive_patch_alteration_rights !> This subroutine checks the smoothing parameters - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_supported_patch_smoothing(patch_id) integer, intent(in) :: patch_id @@ -427,10 +427,10 @@ contains end subroutine s_check_supported_patch_smoothing !> This subroutine verifies that inactive patches cannot be smoothed - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_unsupported_patch_smoothing(patch_id) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -444,7 +444,7 @@ contains end subroutine s_check_unsupported_patch_smoothing !> This subroutine checks the primitive variables - !! @param patch_id Patch identifier + !! Patch identifier impure subroutine s_check_active_patch_primitive_variables(patch_id) integer, intent(in) :: patch_id @@ -503,9 +503,9 @@ contains end subroutine s_check_active_patch_primitive_variables !> This subroutine verifies that the primitive variables - !! associated with the given inactive patch remain unaltered - !! by the user inputs. - !! @param patch_id Patch identifier + !! the given inactive patch remain unaltered + !! user inputs. + !! Patch identifier impure subroutine s_check_inactive_patch_primitive_variables(patch_id) integer, intent(in) :: patch_id diff --git a/src/pre_process/m_checker.fpp b/src/pre_process/m_checker.fpp index 5499262c61..6f4d7eff97 100644 --- a/src/pre_process/m_checker.fpp +++ b/src/pre_process/m_checker.fpp @@ -1,5 +1,5 @@ !> -!!@file m_checker.f90 +!!@file !!@brief Contains module m_checker #:include 'macros.fpp' @@ -22,7 +22,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! Used by the pre_process stage + !! the pre_process stage impure subroutine s_check_inputs call s_check_parallel_io diff --git a/src/pre_process/m_data_output.fpp b/src/pre_process/m_data_output.fpp index ca5fb3c56a..61f2727961 100644 --- a/src/pre_process/m_data_output.fpp +++ b/src/pre_process/m_data_output.fpp @@ -1,12 +1,12 @@ !> -!! @file m_data_output.f90 -!! @brief Contains module m_data_output +!! +!! module m_data_output !> @brief This module takes care of writing the grid and initial condition -!! data files into the "0" time-step directory located in the folder -!! associated with the rank of the local processor, which is a sub- -!! directory of the case folder specified by the user in the input -!! file pre_process.inp. +!! into the "0" time-step directory located in the folder +!! the rank of the local processor, which is a sub- +!! the case folder specified by the user in the input +!! module m_data_output use m_derived_types !< Definitions of the derived types @@ -51,16 +51,16 @@ module m_data_output abstract interface !> Interface for the conservative data - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary - !! @param levelset closest distance from every cell to the IB - !! @param levelset_norm normalized vector from every cell to the closest point to the IB + !! Conservative variables + !! track if a cell is within the immersed boundary + !! closest distance from every cell to the IB + !! normalized vector from every cell to the closest point to the IB impure subroutine s_write_abstract_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) import :: scalar_field, integer_field, sys_size, m, n, p, & pres_field, levelset_field, levelset_norm_field, num_dims - ! Conservative variables + ! variables type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf @@ -69,15 +69,15 @@ module m_data_output dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! IB markers + ! markers type(integer_field), & intent(in), optional :: ib_markers - ! Levelset + ! type(levelset_field), & intent(IN), optional :: levelset - ! Levelset Norm + ! Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -85,40 +85,40 @@ module m_data_output end interface character(LEN=path_len + 2*name_len), private :: t_step_dir !< - !! Time-step folder into which grid and initial condition data will be placed + !! into which grid and initial condition data will be placed character(LEN=path_len + 2*name_len), public :: restart_dir !< - !! Restart data folder + !! folder procedure(s_write_abstract_data_files), pointer :: s_write_data_files => null() contains !> Writes grid and initial condition data files to the "0" - !! time-step directory in the local processor rank folder - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary - !! @param levelset closest distance from every cell to the IB - !! @param levelset_norm normalized vector from every cell to the closest point to the IB + !! in the local processor rank folder + !! Conservative variables + !! track if a cell is within the immersed boundary + !! closest distance from every cell to the IB + !! normalized vector from every cell to the closest point to the IB impure subroutine s_write_serial_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf - ! BC types + ! types type(integer_field), & dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! IB markers + ! markers type(integer_field), & intent(in), optional :: ib_markers - ! Levelset + ! type(levelset_field), & intent(IN), optional :: levelset - ! Levelset Norm + ! Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -129,11 +129,11 @@ contains character(LEN= & int(floor(log10(real(sys_size, wp)))) + 1) :: file_num !< Used to store - !! the number, in character form, of the currently - !! manipulated conservative variable data file + !! in character form, of the currently + !! variable data file character(LEN=len_trim(t_step_dir) + name_len) :: file_loc !< - !! Generic string used to store the address of a particular file + !! used to store the address of a particular file integer :: i, j, k, l, r, c !< Generic loop iterator integer :: t_step @@ -154,7 +154,7 @@ contains t_step = 0 - ! Outputting the Locations of the Cell-boundaries + ! the Locations of the Cell-boundaries if (old_grid) then status = 'old' @@ -170,22 +170,22 @@ contains end if end if - ! x-coordinate direction + ! direction file_loc = trim(t_step_dir)//'/x_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) write (1) x_cb(-1:m) close (1) - ! y- and z-coordinate directions + ! and z-coordinate directions if (n > 0) then - ! y-coordinate direction + ! direction file_loc = trim(t_step_dir)//'/y_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS=status) write (1) y_cb(-1:n) close (1) - ! z-coordinate direction + ! direction if (p > 0) then file_loc = trim(t_step_dir)//'/z_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', & @@ -197,7 +197,7 @@ contains if (ib) then - ! Outputting IB Markers + ! IB Markers file_loc = trim(t_step_dir)//'/ib.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) @@ -221,7 +221,7 @@ contains end if end do - ! Outtputting Levelset Info + ! Levelset Info file_loc = trim(t_step_dir)//'/levelset.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) @@ -235,7 +235,7 @@ contains close (1) end if - ! Outputting Conservative Variables + ! Conservative Variables do i = 1, sys_size write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/q_cons_vf'//trim(file_num) & @@ -414,7 +414,7 @@ contains FMT = "(3F40.14)" end if - ! 2D + ! if ((n > 0) .and. (p == 0)) then do i = 1, sys_size write (file_loc, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -464,7 +464,7 @@ contains FMT = "(4F40.14)" end if - ! 3D + ! if (p > 0) then do i = 1, sys_size write (file_loc, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -517,7 +517,7 @@ contains if (ib) then - ! Write IB Markers + ! IB Markers write (file_loc, '(A,I2.2,A)') trim(t_step_dir)//'/ib_markers.', proc_rank, '.dat' open (2, FILE=trim(file_loc)) do j = 0, m @@ -557,14 +557,14 @@ contains end subroutine s_write_serial_data_files !> Writes grid and initial condition data files in parallel to the "0" - !! time-step directory in the local processor rank folder - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary - !! @param levelset closest distance from every cell to the IB - !! @param levelset_norm normalized vector from every cell to the closest point to the IB + !! in the local processor rank folder + !! Conservative variables + !! track if a cell is within the immersed boundary + !! closest distance from every cell to the IB + !! normalized vector from every cell to the closest point to the IB impure subroutine s_write_parallel_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) - ! Conservative variables + ! variables type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf @@ -573,15 +573,15 @@ contains dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! IB markers + ! markers type(integer_field), & intent(in), optional :: ib_markers - ! Levelset + ! type(levelset_field), & intent(IN), optional :: levelset - ! Levelset Norm + ! Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -598,11 +598,11 @@ contains character(LEN=path_len + 2*name_len) :: file_loc logical :: file_exist, dir_check - ! Generic loop iterators + ! loop iterators integer :: i, j, k, l real(wp) :: loc_violations, glb_violations - ! Downsample variables + ! variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_save, n_glb_save, p_glb_save ! Size of array being saved @@ -633,7 +633,7 @@ contains call s_mpi_barrier() call DelayFileAccess(proc_rank) - ! Initialize MPI data I/O + ! MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_temp) else @@ -645,7 +645,7 @@ contains end if end if - ! Open the file to write all flow variables + ! the file to write all flow variables if (cfl_dt) then write (file_loc, '(I0,A,i7.7,A)') n_start, '_', proc_rank, '.dat' else @@ -661,20 +661,20 @@ contains mpi_info_int, ifile, ierr) if (down_sample) then - ! Size of local arrays + ! of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_save = m_glb_ds + 3 n_glb_save = n_glb_ds + 3 p_glb_save = p_glb_ds + 3 else - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_save = m_glb + 1 n_glb_save = n_glb + 1 p_glb_save = p_glb + 1 end if - ! Resize some integers so MPI can write even the biggest files + ! some integers so MPI can write even the biggest files m_MOK = int(m_glb_save, MPI_OFFSET_KIND) n_MOK = int(n_glb_save, MPI_OFFSET_KIND) p_MOK = int(p_glb_save, MPI_OFFSET_KIND) @@ -683,7 +683,7 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! Write the data for each variable + ! the data for each variable if (bubbles_euler) then do i = 1, sys_size! adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) @@ -721,7 +721,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) else - ! Initialize MPI data I/O + ! MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, & levelset, levelset_norm) @@ -729,7 +729,7 @@ contains call s_initialize_mpi_data(q_cons_vf) end if - ! Open the file to write all flow variables + ! the file to write all flow variables if (cfl_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -743,10 +743,10 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! Resize some integers so MPI can write even the biggest files + ! some integers so MPI can write even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -755,12 +755,12 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! Write the data for each variable + ! the data for each variable if (bubbles_euler) then do i = 1, sys_size! adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -773,7 +773,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -784,10 +784,10 @@ contains end if else do i = 1, sys_size !TODO: check if this is right - ! do i = 1, adv_idx%end + ! i = 1, adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -801,7 +801,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) end if - ! IB Markers + ! Markers if (ib) then write (file_loc, '(A)') 'ib.dat' @@ -813,7 +813,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, & @@ -823,7 +823,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) - ! Levelset + ! write (file_loc, '(A)') 'levelset.dat' file_loc = trim(restart_dir)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -833,7 +833,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_levelset_DATA%view, & @@ -843,7 +843,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) - ! Levelset Norm + ! Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(restart_dir)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -853,7 +853,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_levelsetnorm_DATA%view, & @@ -879,7 +879,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(1), & @@ -898,7 +898,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(2), & @@ -924,29 +924,29 @@ contains end subroutine s_write_parallel_data_files !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_data_output_module - ! Generic string used to store the address of a particular file + ! string used to store the address of a particular file character(LEN=len_trim(case_dir) + 2*name_len) :: file_loc character(len=15) :: temp character(LEN=1), dimension(3), parameter :: coord = (/'x', 'y', 'z'/) - ! Generic logical used to check the existence of directories + ! logical used to check the existence of directories logical :: dir_check integer :: i integer :: m_ds, n_ds, p_ds !< down sample dimensions if (parallel_io .neqv. .true.) then - ! Setting the address of the time-step directory + ! the address of the time-step directory write (t_step_dir, '(A,I0,A)') '/p_all/p', proc_rank, '/0' t_step_dir = trim(case_dir)//trim(t_step_dir) - ! Checking the existence of the time-step directory, removing it, if - ! it exists, and creating a new copy. Note that if preexisting grid - ! and/or initial condition data are to be read in from the very same - ! location, then the above described steps are not executed here but - ! rather in the module m_start_up.f90. + ! the existence of the time-step directory, removing it, if + ! exists, and creating a new copy. Note that if preexisting grid + ! initial condition data are to be read in from the very same + ! then the above described steps are not executed here but + ! in the module m_start_up.f90. if (old_grid .neqv. .true.) then file_loc = trim(t_step_dir)//'/' diff --git a/src/pre_process/m_global_parameters.fpp b/src/pre_process/m_global_parameters.fpp index 9dd5cebb42..0a1272b505 100644 --- a/src/pre_process/m_global_parameters.fpp +++ b/src/pre_process/m_global_parameters.fpp @@ -1,12 +1,12 @@ !> -!! @file m_global_parameters.f90 -!! @brief Contains module m_global_parameters +!! +!! module m_global_parameters #:include 'case.fpp' !> @brief This module contains all of the parameters characterizing the -!! computational domain, simulation algorithm, initial condition -!! and the stiffened equation of state. +!! simulation algorithm, initial condition +!! stiffened equation of state. module m_global_parameters #ifdef MFC_MPI @@ -21,7 +21,7 @@ module m_global_parameters implicit none - ! Logistics + ! integer :: num_procs !< Number of processors character(LEN=path_len) :: case_dir !< Case folder location logical :: old_grid !< Use existing grid data @@ -31,11 +31,11 @@ module m_global_parameters logical :: cfl_adap_dt, cfl_const_dt, cfl_dt integer :: n_start, n_start_old - ! Computational Domain Parameters + ! Domain Parameters integer :: proc_rank !< Rank of the local processor - !! Number of cells in the x-, y- and z-coordinate directions + !! cells in the x-, y- and z-coordinate directions integer :: m integer :: n integer :: p @@ -54,30 +54,30 @@ module m_global_parameters integer :: grid_geometry !< Cylindrical coordinates (either axisymmetric or full 3D) real(wp), allocatable, dimension(:) :: x_cc, y_cc, z_cc !< - !! Locations of cell-centers (cc) in x-, y- and z-directions, respectively + !! cell-centers (cc) in x-, y- and z-directions, respectively real(wp), allocatable, dimension(:) :: x_cb, y_cb, z_cb !< - !! Locations of cell-boundaries (cb) in x-, y- and z-directions, respectively + !! cell-boundaries (cb) in x-, y- and z-directions, respectively real(wp) :: dx, dy, dz !< - !! Minimum cell-widths in the x-, y- and z-coordinate directions + !! in the x-, y- and z-coordinate directions type(bounds_info) :: x_domain, y_domain, z_domain !< - !! Locations of the domain bounds in the x-, y- and z-coordinate directions + !! the domain bounds in the x-, y- and z-coordinate directions logical :: stretch_x, stretch_y, stretch_z !< - !! Grid stretching flags for the x-, y- and z-coordinate directions + !! flags for the x-, y- and z-coordinate directions - ! Parameters of the grid stretching function for the x-, y- and z-coordinate - ! directions. The "a" parameters are a measure of the rate at which the grid - ! is stretched while the remaining parameters are indicative of the location - ! on the grid at which the stretching begins. + ! of the grid stretching function for the x-, y- and z-coordinate + ! The "a" parameters are a measure of the rate at which the grid + ! stretched while the remaining parameters are indicative of the location + ! the grid at which the stretching begins. real(wp) :: a_x, a_y, a_z integer :: loops_x, loops_y, loops_z real(wp) :: x_a, y_a, z_a real(wp) :: x_b, y_b, z_b - ! Simulation Algorithm Parameters + ! Algorithm Parameters integer :: model_eqns !< Multicomponent flow model logical :: relax !< activate phase change integer :: relax_model !< Relax Model @@ -105,7 +105,7 @@ module m_global_parameters integer :: igr_order !< IGR reconstruction order logical, parameter :: chemistry = .${chemistry}$. !< Chemistry modeling - ! Annotations of the structure, i.e. the organization, of the state vectors + ! of the structure, i.e. the organization, of the state vectors type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns. type(int_bounds_info) :: mom_idx !< Indexes of first & last momentum eqns. integer :: E_idx !< Index of total energy equation @@ -124,26 +124,26 @@ module m_global_parameters integer :: damage_idx !< Index of damage state variable (D) for continuum damage model integer :: psi_idx !< Index of hyperbolic cleaning state variable for MHD - ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). - ! Stands for "InDices With BUFFer". + ! Indices for the (local) interior points (O-m, O-n, 0-p). + ! for "InDices With BUFFer". type(int_bounds_info) :: idwint(1:3) - ! Cell Indices for the entire (local) domain. In simulation and post_process, - ! this includes the buffer region. idwbuff and idwint are the same otherwise. - ! Stands for "InDices With BUFFer". + ! Indices for the entire (local) domain. In simulation and post_process, + ! includes the buffer region. idwbuff and idwint are the same otherwise. + ! for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) type(int_bounds_info) :: bc_x, bc_y, bc_z !< - !! Boundary conditions in the x-, y- and z-coordinate directions + !! in the x-, y- and z-coordinate directions integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! Indices of the stress components that represent shear stress + !! the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! Number of shear stress components to reflect for boundary conditions + !! shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! Indices of shear stress components to reflect for boundary conditions. - !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! shear stress components to reflect for boundary conditions. + !! 1:shear_BC_flip_num) for (x/y/z, [indices]) logical :: parallel_io !< Format of the data files logical :: file_per_process !< type of data output @@ -155,8 +155,8 @@ module m_global_parameters logical :: mixlayer_perturb !< Superimpose instability waves to surrounding fluid flow integer :: mixlayer_perturb_nk !< Number of Fourier modes for perturbation with mixlayer_perturb flag real(wp) :: mixlayer_perturb_k0 !< Peak wavenumber of prescribed energy spectra with mixlayer_perturb flag - !! Default value (k0 = 0.4446) is most unstable mode obtained from linear stability analysis - !! See Michalke (1964, JFM) for details + !! (k0 = 0.4446) is most unstable mode obtained from linear stability analysis + !! (1964, JFM) for details logical :: simplex_perturb type(simplex_noise_params) :: simplex_params @@ -165,7 +165,7 @@ module m_global_parameters logical :: viscous logical :: bubbles_lagrange - ! Perturb density of surrounding air so as to break symmetry of grid + ! density of surrounding air so as to break symmetry of grid logical :: perturb_flow integer :: perturb_flow_fluid !< Fluid to be perturbed with perturb_flow flag real(wp) :: perturb_flow_mag !< Magnitude of perturbation with perturb_flow flag @@ -177,10 +177,10 @@ module m_global_parameters integer :: elliptic_smoothing_iters integer, allocatable, dimension(:) :: proc_coords !< - !! Processor coordinates in MPI_CART_COMM + !! in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! Starting cell-center index of local processor in global grid + !! index of local processor in global grid #ifdef MFC_MPI @@ -192,32 +192,32 @@ module m_global_parameters character(LEN=name_len) :: mpiiofs integer :: mpi_info_int !< - !! MPI info for parallel IO with Lustre file systems + !! for parallel IO with Lustre file systems #endif - ! Initial Condition Parameters + ! Condition Parameters integer :: num_patches !< Number of patches composing initial condition type(ic_patch_parameters), dimension(num_patches_max) :: patch_icpp !< - !! Database of the initial condition patch parameters (icpp) for each of the - !! patches employed in the configuration of the initial condition. Note that - !! the maximum allowable number of patches, num_patches_max, may be changed - !! in the module m_derived_types.f90. + !! the initial condition patch parameters (icpp) for each of the + !! in the configuration of the initial condition. Note that + !! allowable number of patches, num_patches_max, may be changed + !! module m_derived_types.f90. integer :: num_bc_patches !< Number of boundary condition patches logical :: bc_io !< whether or not to save BC data type(bc_patch_parameters), dimension(num_bc_patches_max) :: patch_bc - !! Database of the boundary condition patch parameters for each of the patches - !! employed in the configuration of the boundary conditions + !! the boundary condition patch parameters for each of the patches + !! the configuration of the boundary conditions - ! Fluids Physical Parameters + ! Physical Parameters type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! Database of the physical parameters of each of the fluids that is present - !! in the flow. These include the stiffened gas equation of state parameters, - !! and the Reynolds numbers. + !! the physical parameters of each of the fluids that is present + !! flow. These include the stiffened gas equation of state parameters, + !! Reynolds numbers. - ! Subgrid Bubble Parameters + ! Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp real(wp) :: rhoref, pref !< Reference parameters for Tait EOS @@ -244,10 +244,10 @@ module m_global_parameters type(ib_patch_parameters), dimension(num_patches_max) :: patch_ib type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l - !! Database of the immersed boundary patch parameters for each of the - !! patches employed in the configuration of the initial condition. Note that - !! the maximum allowable number of patches, num_patches_max, may be changed - !! in the module m_derived_types.f90. + !! the immersed boundary patch parameters for each of the + !! in the configuration of the initial condition. Note that + !! allowable number of patches, num_patches_max, may be changed + !! module m_derived_types.f90. !> @} @@ -297,9 +297,9 @@ module m_global_parameters real(wp) :: Bx0 !< Constant magnetic field in the x-direction (1D) integer :: buff_size !< - !! The number of cells that are necessary to be able to store enough boundary - !! conditions data to march the solution in the physical computational domain - !! to the next time-step. + !! of cells that are necessary to be able to store enough boundary + !! to march the solution in the physical computational domain + !! next time-step. logical :: fft_wrt logical :: dummy !< AMDFlang workaround: keep a dummy logical to avoid a compiler case-optimization bug when a parameter+GPU-kernel conditional is false @@ -307,13 +307,13 @@ module m_global_parameters contains !> Assigns default values to user inputs prior to reading - !! them in. This allows for an easier consistency check of - !! these parameters once they are read from the input file. + !! This allows for an easier consistency check of + !! once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i !< Generic loop operator - ! Logistics + ! case_dir = '.' old_grid = .false. old_ic = .false. @@ -325,7 +325,7 @@ contains cfl_dt = .false. n_start = dflt_int - ! Computational domain parameters + ! domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -356,7 +356,7 @@ contains z_a = dflt_real z_b = dflt_real - ! Simulation algorithm parameters + ! algorithm parameters model_eqns = dflt_int relax = .false. relax_model = dflt_int @@ -425,7 +425,7 @@ contains simplex_params%perturb_dens_scale(:) = dflt_real simplex_params%perturb_dens_offset(:, :) = dflt_real - ! Initial condition parameters + ! condition parameters num_patches = dflt_int do i = 1, num_patches_max @@ -502,11 +502,11 @@ contains patch_bc(i)%radius = dflt_real end do - ! Tait EOS + ! EOS rhoref = dflt_real pref = dflt_real - ! Bubble modeling + ! modeling bubbles_euler = .false. polytropic = .true. polydisperse = .false. @@ -538,11 +538,11 @@ contains Pe_c = dflt_real Tw = dflt_real - ! surface tension modeling + ! tension modeling sigma = dflt_real pi_fac = 1._wp - ! Immersed Boundaries + ! Boundaries ib = .false. num_ibs = dflt_int @@ -562,7 +562,7 @@ contains patch_ib(i)%p = dflt_real patch_ib(i)%slip = .false. - ! Proper default values for translating STL models + ! default values for translating STL models patch_ib(i)%model_scale(:) = 1._wp patch_ib(i)%model_translate(:) = 0._wp patch_ib(i)%model_rotate(:) = 0._wp @@ -570,7 +570,7 @@ contains patch_ib(i)%model_spc = num_ray patch_ib(i)%model_threshold = ray_tracing_threshold - ! Variables to handle moving imersed boundaries, defaulting to no movement + ! to handle moving imersed boundaries, defaulting to no movement patch_ib(i)%moving_ibm = 0 patch_ib(i)%vel(:) = 0._wp patch_ib(i)%angles(:) = 0._wp @@ -579,7 +579,7 @@ contains patch_ib(i)%moment = dflt_real patch_ib(i)%centroid_offset(:) = 0._wp - ! sets values of a rotation matrix which can be used when calculating rotations + ! values of a rotation matrix which can be used when calculating rotations patch_ib(i)%rotation_matrix = 0._wp patch_ib(i)%rotation_matrix(1, 1) = 1._wp patch_ib(i)%rotation_matrix(2, 2) = 1._wp @@ -590,7 +590,7 @@ contains chem_params%gamma_method = 1 chem_params%transport_model = 1 - ! Fluids physical parameters + ! physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -602,7 +602,7 @@ contains Bx0 = dflt_real - ! Subgrid bubble parameters + ! bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -627,7 +627,7 @@ contains end subroutine s_assign_default_values_to_user_inputs !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_global_parameters_module integer :: i, j, fac @@ -638,19 +638,19 @@ contains muscl_polyn = muscl_order end if - ! Determining the layout of the state vectors and overall size of - ! the system of equations, given the dimensionality and choice of - ! the equations of motion + ! the layout of the state vectors and overall size of + ! system of equations, given the dimensionality and choice of + ! equations of motion - ! Gamma/Pi_inf Model + ! Model if (model_eqns == 1) then - ! Setting number of fluids + ! number of fluids num_fluids = 1 - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the gamma/pi_inf model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -662,12 +662,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Volume Fraction Model (5-equation model) + ! Fraction Model (5-equation model) else if (model_eqns == 2) then - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the volume fraction model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -675,17 +675,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! Volume fractions are stored in the indices immediately following - ! the energy equation. IGR tracks a total of (N-1) volume fractions - ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! then adv_idx%end < adv_idx%beg, which skips all loops over the - ! volume fractions since there is no volume fraction to track + ! fractions are stored in the indices immediately following + ! energy equation. IGR tracks a total of (N-1) volume fractions + ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! adv_idx%end < adv_idx%beg, which skips all loops over the + ! fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids - 1 else - ! Volume fractions are stored in the indices immediately following - ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! fractions are stored in the indices immediately following + ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -767,12 +767,12 @@ contains sys_size = B_idx%end end if - ! Volume Fraction Model (6-equation model) + ! Fraction Model (6-equation model) else if (model_eqns == 3) then - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the volume fraction model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -785,7 +785,7 @@ contains sys_size = internalEnergies_idx%end else if (model_eqns == 4) then - ! 4 equation model with subgrid bubbles_euler + ! equation model with subgrid bubbles_euler cont_idx%beg = 1 ! one continuity equation cont_idx%end = 1 ! num_fluids mom_idx%beg = cont_idx%end + 1 ! one momentum equation in each direction @@ -846,10 +846,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! shear stress index is 2 for 2D and 2,4,5 for 3D + ! stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -857,7 +857,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! Both x-dir and y-dir: flip tau_xy only + ! x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -865,19 +865,19 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! x-dir: flip tau_xy and tau_xz - ! y-dir: flip tau_xy and tau_yz - ! z-dir: flip tau_xz and tau_yz + ! flip tau_xy and tau_xz + ! flip tau_xy and tau_yz + ! flip tau_xz and tau_yz end if end if if (hyperelasticity) then - ! number of entries in the symmetric btensor plus the jacobian + ! of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 tensor_size = num_dims**2 + 1 xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! adding three more equations for the \xi field and the elastic energy + ! three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 end if @@ -957,9 +957,9 @@ contains end if #endif - ! Allocating grid variables for the x-direction + ! grid variables for the x-direction allocate (x_cc(0:m), x_cb(-1:m)) - ! Allocating grid variables for the y- and z-directions + ! grid variables for the y- and z-directions if (n > 0) then allocate (y_cc(0:n), y_cb(-1:n)) if (p > 0) then @@ -1001,16 +1001,16 @@ contains #ifdef MFC_MPI - ! Option for Lustre file system (Darter/Comet/Stampede) + ! for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! Option for UNIX file system (Hooke/Thomson) - ! WRITE(mpiiofs, '(A)') '/ufs_' - ! mpiiofs = TRIM(mpiiofs) - ! mpi_info_int = MPI_INFO_NULL + ! for UNIX file system (Hooke/Thomson) + ! '(A)') '/ufs_' + ! = TRIM(mpiiofs) + ! = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1022,9 +1022,9 @@ contains integer :: i - ! Deallocating grid variables for the x-direction + ! grid variables for the x-direction deallocate (x_cc, x_cb) - ! Deallocating grid variables for the y- and z-directions + ! grid variables for the y- and z-directions if (n > 0) then deallocate (y_cc, y_cb) if (p > 0) then diff --git a/src/pre_process/m_icpp_patches.fpp b/src/pre_process/m_icpp_patches.fpp index fc0afdeec6..87062e1913 100644 --- a/src/pre_process/m_icpp_patches.fpp +++ b/src/pre_process/m_icpp_patches.fpp @@ -1,6 +1,6 @@ !> -!! @file m_patches.fpp -!! @brief Contains module m_patches +!! +!! module m_patches #:include 'case.fpp' #:include 'ExtrusionHardcodedIC.fpp' @@ -42,27 +42,27 @@ module m_icpp_patches integer :: smooth_patch_id real(wp) :: smooth_coeff !< - !! These variables are analogous in both meaning and use to the similarly - !! named components in the ic_patch_parameters type (see m_derived_types.f90 - !! for additional details). They are employed as a means to more concisely - !! perform the actions necessary to lay out a particular patch on the grid. + !! are analogous in both meaning and use to the similarly + !! in the ic_patch_parameters type (see m_derived_types.f90 + !! details). They are employed as a means to more concisely + !! actions necessary to lay out a particular patch on the grid. real(wp) :: eta !< - !! In the case that smoothing of patch boundaries is enabled and the boundary - !! between two adjacent patches is to be smeared out, this variable's purpose - !! is to act as a pseudo volume fraction to indicate the contribution of each - !! patch toward the composition of a cell's fluid state. + !! case that smoothing of patch boundaries is enabled and the boundary + !! adjacent patches is to be smeared out, this variable's purpose + !! act as a pseudo volume fraction to indicate the contribution of each + !! the composition of a cell's fluid state. real(wp) :: cart_x, cart_y, cart_z real(wp) :: sph_phi !< - !! Variables to be used to hold cell locations in Cartesian coordinates if - !! 3D simulation is using cylindrical coordinates + !! be used to hold cell locations in Cartesian coordinates if + !! is using cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary !< - !! These variables combine the centroid and length parameters associated with - !! a particular patch to yield the locations of the patch boundaries in the - !! x-, y- and z-coordinate directions. They are used as a means to concisely - !! perform the actions necessary to lay out a particular patch on the grid. + !! combine the centroid and length parameters associated with + !! patch to yield the locations of the patch boundaries in the + !! and z-coordinate directions. They are used as a means to concisely + !! actions necessary to lay out a particular patch on the grid. character(len=5) :: istr ! string to store int to string result for error checking @@ -78,7 +78,7 @@ contains #endif integer :: i - ! 3D Patch Geometries + ! Patch Geometries if (p > 0) then do i = 1, num_patches @@ -89,35 +89,35 @@ contains !> ICPP Patches !> @{ - ! Spherical patch + ! patch if (patch_icpp(i)%geometry == 8) then call s_icpp_sphere(i, patch_id_fp, q_prim_vf) - ! Cuboidal patch + ! patch elseif (patch_icpp(i)%geometry == 9) then call s_icpp_cuboid(i, patch_id_fp, q_prim_vf) - ! Cylindrical patch + ! patch elseif (patch_icpp(i)%geometry == 10) then call s_icpp_cylinder(i, patch_id_fp, q_prim_vf) - ! Swept plane patch + ! plane patch elseif (patch_icpp(i)%geometry == 11) then call s_icpp_sweep_plane(i, patch_id_fp, q_prim_vf) - ! Ellipsoidal patch + ! patch elseif (patch_icpp(i)%geometry == 12) then call s_icpp_ellipsoid(i, patch_id_fp, q_prim_vf) - ! Spherical harmonic patch + ! harmonic patch elseif (patch_icpp(i)%geometry == 14) then call s_icpp_spherical_harmonic(i, patch_id_fp, q_prim_vf) - ! 3D Modified circular patch + ! Modified circular patch elseif (patch_icpp(i)%geometry == 19) then call s_icpp_3dvarcircle(i, patch_id_fp, q_prim_vf) - ! 3D STL patch + ! STL patch elseif (patch_icpp(i)%geometry == 21) then call s_icpp_model(i, patch_id_fp, q_prim_vf) end if end do !> @} - ! 2D Patch Geometries + ! Patch Geometries elseif (n > 0) then do i = 1, num_patches @@ -128,42 +128,42 @@ contains !> ICPP Patches !> @{ - ! Circular patch + ! patch if (patch_icpp(i)%geometry == 2) then call s_icpp_circle(i, patch_id_fp, q_prim_vf) - ! Rectangular patch + ! patch elseif (patch_icpp(i)%geometry == 3) then call s_icpp_rectangle(i, patch_id_fp, q_prim_vf) - ! Swept line patch + ! line patch elseif (patch_icpp(i)%geometry == 4) then call s_icpp_sweep_line(i, patch_id_fp, q_prim_vf) - ! Elliptical patch + ! patch elseif (patch_icpp(i)%geometry == 5) then call s_icpp_ellipse(i, patch_id_fp, q_prim_vf) - ! Unimplemented patch (formerly isentropic vortex) + ! patch (formerly isentropic vortex) elseif (patch_icpp(i)%geometry == 6) then call s_mpi_abort('This used to be the isentropic vortex patch, '// & 'which no longer exists. See Examples. Exiting.') - ! Spherical Harmonic Patch + ! Harmonic Patch elseif (patch_icpp(i)%geometry == 14) then call s_icpp_spherical_harmonic(i, patch_id_fp, q_prim_vf) - ! Spiral patch + ! patch elseif (patch_icpp(i)%geometry == 17) then call s_icpp_spiral(i, patch_id_fp, q_prim_vf) - ! Modified circular patch + ! circular patch elseif (patch_icpp(i)%geometry == 18) then call s_icpp_varcircle(i, patch_id_fp, q_prim_vf) - ! TaylorGreen vortex patch + ! vortex patch elseif (patch_icpp(i)%geometry == 20) then call s_icpp_2D_TaylorGreen_vortex(i, patch_id_fp, q_prim_vf) - ! STL patch + ! patch elseif (patch_icpp(i)%geometry == 21) then call s_icpp_model(i, patch_id_fp, q_prim_vf) end if !> @} end do - ! 1D Patch Geometries + ! Patch Geometries else do i = 1, num_patches @@ -172,10 +172,10 @@ contains print *, 'Processing patch', i end if - ! Line segment patch + ! segment patch if (patch_icpp(i)%geometry == 1) then call s_icpp_line_segment(i, patch_id_fp, q_prim_vf) - ! 1d analytical + ! analytical elseif (patch_icpp(i)%geometry == 16) then call s_icpp_1d_bubble_pulse(i, patch_id_fp, q_prim_vf) end if @@ -186,14 +186,14 @@ contains end subroutine s_apply_icpp_patches !> The line segment patch is a 1D geometry that may be used, - !! for example, in creating a Riemann problem. The geometry - !! of the patch is well-defined when its centroid and length - !! in the x-coordinate direction are provided. Note that the - !! line segment patch DOES NOT allow for the smearing of its - !! boundaries. - !! @param patch_id patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! in creating a Riemann problem. The geometry + !! patch is well-defined when its centroid and length + !! x-coordinate direction are provided. Note that the + !! patch DOES NOT allow for the smearing of its + !! + !! patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_line_segment(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -204,10 +204,10 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k - ! Placeholders for the cell boundary values + ! for the cell boundary values real(wp) :: pi_inf, gamma, lit_gamma @:HardcodedDimensionsExtrusion() @:Hardcoded1DVariables() @@ -218,25 +218,25 @@ contains j = 0 k = 0 - ! Transferring the line segment's centroid and length information + ! the line segment's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid length_x = patch_icpp(patch_id)%length_x - ! Computing the beginning and end x-coordinates of the line segment - ! based on its centroid and length + ! the beginning and end x-coordinates of the line segment + ! on its centroid and length x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! Since the line segment patch does not allow for its boundaries to - ! be smoothed out, the pseudo volume fraction is set to 1 to ensure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the line segment patch does not allow for its boundaries to + ! smoothed out, the pseudo volume fraction is set to 1 to ensure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta = 1._wp - ! Checking whether the line segment covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the line segment covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & x_boundary%end >= x_cc(i) .and. & @@ -247,12 +247,12 @@ contains @:analytical() - ! check if this should load a hardcoded patch + ! if this should load a hardcoded patch if (patch_icpp(patch_id)%hcid /= dflt_int) then @:Hardcoded1D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, 0, 0) = patch_id end if @@ -262,12 +262,12 @@ contains end subroutine s_icpp_line_segment !> The spiral patch is a 2D geometry that may be used, The geometry - !! of the patch is well-defined when its centroid and radius - !! are provided. Note that the circular patch DOES allow for - !! the smoothing of its boundary. - !! @param patch_id patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! patch is well-defined when its centroid and radius + !! Note that the circular patch DOES allow for + !! of its boundary. + !! patch identifier + !! Array to track patch ids + !! Array of primitive variables impure subroutine s_icpp_spiral(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -284,8 +284,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! Transferring the circular patch's radius, centroid, smearing patch - ! identity and smearing coefficient information + ! the circular patch's radius, centroid, smearing patch + ! and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid mya = patch_icpp(patch_id)%radius @@ -326,7 +326,7 @@ contains @:Hardcoded2D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end do @@ -336,13 +336,13 @@ contains end subroutine s_icpp_spiral !> The circular patch is a 2D geometry that may be used, for - !! example, in creating a bubble or a droplet. The geometry - !! of the patch is well-defined when its centroid and radius - !! are provided. Note that the circular patch DOES allow for - !! the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! creating a bubble or a droplet. The geometry + !! patch is well-defined when its centroid and radius + !! Note that the circular patch DOES allow for + !! of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_circle(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -359,8 +359,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! Transferring the circular patch's radius, centroid, smearing patch - ! identity and smearing coefficient information + ! the circular patch's radius, centroid, smearing patch + ! and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid @@ -368,15 +368,15 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the circular patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! Checking whether the circle covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the circle covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. do j = 0, n do i = 0, m @@ -414,13 +414,13 @@ contains end subroutine s_icpp_circle !> The varcircle patch is a 2D geometry that may be used - !! . It generatres an annulus - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! generatres an annulus + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_varcircle(patch_id, patch_id_fp, q_prim_vf) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -429,14 +429,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k real(wp) :: radius, myr, thickness @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! Transferring the circular patch's radius, centroid, smearing patch - ! identity and smearing coefficient information + ! the circular patch's radius, centroid, smearing patch + ! and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid radius = patch_icpp(patch_id)%radius @@ -444,15 +444,15 @@ contains smooth_coeff = patch_icpp(patch_id)%smooth_coeff thickness = patch_icpp(patch_id)%epsilon - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the circular patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! Checking whether the circle covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the circle covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. do j = 0, n do i = 0, m myr = sqrt((x_cc(i) - x_centroid)**2 & @@ -470,7 +470,7 @@ contains @:Hardcoded2D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id q_prim_vf(alf_idx)%sf(i, j, 0) = patch_icpp(patch_id)%alpha(1)* & @@ -483,12 +483,12 @@ contains end subroutine s_icpp_varcircle - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_3dvarcircle(patch_id, patch_id_fp, q_prim_vf) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -497,14 +497,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k real(wp) :: radius, myr, thickness @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the circular patch's radius, centroid, smearing patch - ! identity and smearing coefficient information + ! the circular patch's radius, centroid, smearing patch + ! and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -514,17 +514,17 @@ contains smooth_coeff = patch_icpp(patch_id)%smooth_coeff thickness = patch_icpp(patch_id)%epsilon - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the circular patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! write for all z + ! for all z - ! Checking whether the circle covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the circle covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -543,7 +543,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id q_prim_vf(alf_idx)%sf(i, j, k) = patch_icpp(patch_id)%alpha(1)* & @@ -558,12 +558,12 @@ contains end subroutine s_icpp_3dvarcircle !> The elliptical patch is a 2D geometry. The geometry of - !! the patch is well-defined when its centroid and radii - !! are provided. Note that the elliptical patch DOES allow - !! for the smoothing of its boundary - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! is well-defined when its centroid and radii + !! Note that the elliptical patch DOES allow + !! smoothing of its boundary + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_ellipse(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -579,8 +579,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! Transferring the elliptical patch's radii, centroid, smearing - ! patch identity, and smearing coefficient information + ! the elliptical patch's radii, centroid, smearing + ! identity, and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid a = patch_icpp(patch_id)%radii(1) @@ -588,16 +588,16 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Initializing the pseudo volume fraction value to 1. The value - ! be modified as the patch is laid out on the grid, but only in - ! the case that smoothing of the elliptical patch's boundary is - ! enabled. + ! the pseudo volume fraction value to 1. The value + ! modified as the patch is laid out on the grid, but only in + ! case that smoothing of the elliptical patch's boundary is + ! eta = 1._wp - ! Checking whether the ellipse covers a particular cell in the - ! domain and verifying whether the current patch has permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the ellipse covers a particular cell in the + ! and verifying whether the current patch has permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do j = 0, n do i = 0, m @@ -624,7 +624,7 @@ contains @:Hardcoded2D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end do @@ -634,15 +634,15 @@ contains end subroutine s_icpp_ellipse !> The ellipsoidal patch is a 3D geometry. The geometry of - !! the patch is well-defined when its centroid and radii - !! are provided. Note that the ellipsoidal patch DOES allow - !! for the smoothing of its boundary - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! is well-defined when its centroid and radii + !! Note that the ellipsoidal patch DOES allow + !! smoothing of its boundary + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_ellipsoid(patch_id, patch_id_fp, q_prim_vf) - ! Patch identifier + ! identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -651,14 +651,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k real(wp) :: a, b, c @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the ellipsoidal patch's radii, centroid, smearing - ! patch identity, and smearing coefficient information + ! the ellipsoidal patch's radii, centroid, smearing + ! identity, and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -668,16 +668,16 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Initializing the pseudo volume fraction value to 1. The value - ! be modified as the patch is laid out on the grid, but only in - ! the case that smoothing of the ellipsoidal patch's boundary is - ! enabled. + ! the pseudo volume fraction value to 1. The value + ! modified as the patch is laid out on the grid, but only in + ! case that smoothing of the ellipsoidal patch's boundary is + ! eta = 1._wp - ! Checking whether the ellipsoid covers a particular cell in the - ! domain and verifying whether the current patch has permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the ellipsoid covers a particular cell in the + ! and verifying whether the current patch has permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -714,7 +714,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if end do @@ -725,16 +725,16 @@ contains end subroutine s_icpp_ellipsoid !> The rectangular patch is a 2D geometry that may be used, - !! for example, in creating a solid boundary, or pre-/post- - !! shock region, in alignment with the axes of the Cartesian - !! coordinate system. The geometry of such a patch is well- - !! defined when its centroid and lengths in the x- and y- - !! coordinate directions are provided. Please note that the - !! rectangular patch DOES NOT allow for the smoothing of its - !! boundaries. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! in creating a solid boundary, or pre-/post- + !! in alignment with the axes of the Cartesian + !! The geometry of such a patch is well- + !! its centroid and lengths in the x- and y- + !! are provided. Please note that the + !! DOES NOT allow for the smoothing of its + !! + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_rectangle(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -754,29 +754,29 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! Transferring the rectangle's centroid and length information + ! the rectangle's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid length_x = patch_icpp(patch_id)%length_x length_y = patch_icpp(patch_id)%length_y - ! Computing the beginning and the end x- and y-coordinates of the - ! rectangle based on its centroid and lengths + ! the beginning and the end x- and y-coordinates of the + ! based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! Since the rectangular patch does not allow for its boundaries to - ! be smoothed out, the pseudo volume fraction is set to 1 to ensure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the rectangular patch does not allow for its boundaries to + ! smoothed out, the pseudo volume fraction is set to 1 to ensure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta = 1._wp - ! Checking whether the rectangle covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the rectangle covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do j = 0, n do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & @@ -802,7 +802,7 @@ contains rhoref*(1._wp - q_prim_vf(alf_idx)%sf(i, j, 0)) end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end if @@ -813,15 +813,15 @@ contains end subroutine s_icpp_rectangle !> The swept line patch is a 2D geometry that may be used, - !! for example, in creating a solid boundary, or pre-/post- - !! shock region, at an angle with respect to the axes of the - !! Cartesian coordinate system. The geometry of the patch is - !! well-defined when its centroid and normal vector, aimed - !! in the sweep direction, are provided. Note that the sweep - !! line patch DOES allow the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! in creating a solid boundary, or pre-/post- + !! at an angle with respect to the axes of the + !! system. The geometry of the patch is + !! its centroid and normal vector, aimed + !! sweep direction, are provided. Note that the sweep + !! DOES allow the smoothing of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_sweep_line(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -837,26 +837,26 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the centroid information of the line to be swept + ! the centroid information of the line to be swept x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Obtaining coefficients of the equation describing the sweep line + ! coefficients of the equation describing the sweep line a = patch_icpp(patch_id)%normal(1) b = patch_icpp(patch_id)%normal(2) c = -a*x_centroid - b*y_centroid - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the sweep line patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the sweep line patch's boundary is enabled. eta = 1._wp - ! Checking whether the region swept by the line covers a particular - ! cell in the domain and verifying whether the current patch has the - ! permission to write to that cell. If both queries check out, the - ! primitive variables of the current patch are written to this cell. + ! whether the region swept by the line covers a particular + ! in the domain and verifying whether the current patch has the + ! to write to that cell. If both queries check out, the + ! variables of the current patch are written to this cell. do j = 0, n do i = 0, m @@ -880,7 +880,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if @@ -891,12 +891,12 @@ contains end subroutine s_icpp_sweep_line !> The Taylor Green vortex is 2D decaying vortex that may be used, - !! for example, to verify the effects of viscous attenuation. - !! Geometry of the patch is well-defined when its centroid - !! are provided. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! to verify the effects of viscous attenuation. + !! the patch is well-defined when its centroid + !! + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_2D_TaylorGreen_Vortex(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -917,33 +917,33 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! Transferring the patch's centroid and length information + ! the patch's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid length_x = patch_icpp(patch_id)%length_x length_y = patch_icpp(patch_id)%length_y - ! Computing the beginning and the end x- and y-coordinates - ! of the patch based on its centroid and lengths + ! the beginning and the end x- and y-coordinates + ! the patch based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! Since the patch doesn't allow for its boundaries to be - ! smoothed out, the pseudo volume fraction is set to 1 to - ! ensure that only the current patch contributes to the fluid - ! state in the cells that this patch covers. + ! the patch doesn't allow for its boundaries to be + ! out, the pseudo volume fraction is set to 1 to + ! that only the current patch contributes to the fluid + ! in the cells that this patch covers. eta = 1._wp - ! U0 is the characteristic velocity of the vortex + ! is the characteristic velocity of the vortex U0 = patch_icpp(patch_id)%vel(1) - ! L0 is the characteristic length of the vortex + ! is the characteristic length of the vortex L0 = patch_icpp(patch_id)%vel(2) - ! Checking whether the patch covers a particular cell in the - ! domain and verifying whether the current patch has the - ! permission to write to that cell. If both queries check out, - ! the primitive variables of the current patch are assigned - ! to this cell. + ! whether the patch covers a particular cell in the + ! and verifying whether the current patch has the + ! to write to that cell. If both queries check out, + ! primitive variables of the current patch are assigned + ! this cell. do j = 0, n do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & @@ -960,10 +960,10 @@ contains @:Hardcoded2D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id - ! Assign Parameters + ! Parameters q_prim_vf(mom_idx%beg)%sf(i, j, 0) = U0*sin(x_cc(i)/L0)*cos(y_cc(j)/L0) q_prim_vf(mom_idx%end)%sf(i, j, 0) = -U0*cos(x_cc(i)/L0)*sin(y_cc(j)/L0) q_prim_vf(E_idx)%sf(i, j, 0) = patch_icpp(patch_id)%pres + (cos(2*x_cc(i))/L0 + & @@ -976,14 +976,14 @@ contains end subroutine s_icpp_2D_TaylorGreen_Vortex - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_1d_bubble_pulse(patch_id, patch_id_fp, q_prim_vf) - ! Description: This patch assigns the primitive variables as analytical - ! functions such that the code can be verified. + ! This patch assigns the primitive variables as analytical + ! such that the code can be verified. - ! Patch identifier + ! identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -992,9 +992,9 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k - ! Placeholders for the cell boundary values + ! for the cell boundary values real(wp) :: pi_inf, gamma, lit_gamma @:HardcodedDimensionsExtrusion() @:Hardcoded1DVariables() @@ -1003,25 +1003,25 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! Transferring the patch's centroid and length information + ! the patch's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid length_x = patch_icpp(patch_id)%length_x - ! Computing the beginning and the end x- and y-coordinates - ! of the patch based on its centroid and lengths + ! the beginning and the end x- and y-coordinates + ! the patch based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! Since the patch doesn't allow for its boundaries to be - ! smoothed out, the pseudo volume fraction is set to 1 to - ! ensure that only the current patch contributes to the fluid - ! state in the cells that this patch covers. + ! the patch doesn't allow for its boundaries to be + ! out, the pseudo volume fraction is set to 1 to + ! that only the current patch contributes to the fluid + ! in the cells that this patch covers. eta = 1._wp - ! Checking whether the line segment covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the line segment covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & x_boundary%end >= x_cc(i) .and. & @@ -1042,10 +1042,10 @@ contains end subroutine s_icpp_1D_bubble_pulse !> This patch generates the shape of the spherical harmonics - !! as a perturbation to a perfect sphere - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! perturbation to a perfect sphere + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_spherical_harmonic(patch_id, patch_id_fp, q_prim_vf) integer, intent(IN) :: patch_id @@ -1063,7 +1063,7 @@ contains integer :: i, j, k !< generic loop iterators - ! Transferring the patch's centroid and radius information + ! the patch's centroid and radius information x_centroid_local = patch_icpp(patch_id)%x_centroid y_centroid_local = patch_icpp(patch_id)%y_centroid z_centroid_local = patch_icpp(patch_id)%z_centroid @@ -1080,17 +1080,17 @@ contains as(9) = patch_icpp(patch_id)%a(9) non_axis_sym_in = patch_icpp(patch_id)%non_axis_sym - ! Since the analytical patch does not allow for its boundaries to get - ! smoothed out, the pseudo volume fraction is set to 1 to make sure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the analytical patch does not allow for its boundaries to get + ! out, the pseudo volume fraction is set to 1 to make sure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta_local = 1._wp eps = 1.e-32_wp - ! Checking whether the patch covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! to that cell. If both queries check out, the primitive variables - ! of the current patch are assigned to this cell. + ! whether the patch covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables + ! the current patch are assigned to this cell. if (p > 0 .and. .not. non_axis_sym_in) then do k = 0, p do j = 0, n @@ -1190,13 +1190,13 @@ contains end subroutine s_icpp_spherical_harmonic !> The spherical patch is a 3D geometry that may be used, - !! for example, in creating a bubble or a droplet. The patch - !! geometry is well-defined when its centroid and radius are - !! provided. Please note that the spherical patch DOES allow - !! for the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! in creating a bubble or a droplet. The patch + !! well-defined when its centroid and radius are + !! note that the spherical patch DOES allow + !! smoothing of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_sphere(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1207,17 +1207,17 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Generic loop iterators + ! loop iterators integer :: i, j, k real(wp) :: radius @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - !! Variables to initialize the pressure field that corresponds to the - !! bubble-collapse test case found in Tiwari et al. (2013) + !! initialize the pressure field that corresponds to the + !! case found in Tiwari et al. (2013) - ! Transferring spherical patch's radius, centroid, smoothing patch - ! identity and smoothing coefficient information + ! spherical patch's radius, centroid, smoothing patch + ! and smoothing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1225,15 +1225,15 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smoothing of the spherical patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smoothing of the spherical patch's boundary is enabled. eta = 1._wp - ! Checking whether the sphere covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables of - ! the current patch are assigned to this cell. + ! whether the sphere covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! cell. If both queries check out, the primitive variables of + ! current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1276,16 +1276,16 @@ contains end subroutine s_icpp_sphere !> The cuboidal patch is a 3D geometry that may be used, for - !! example, in creating a solid boundary, or pre-/post-shock - !! region, which is aligned with the axes of the Cartesian - !! coordinate system. The geometry of such a patch is well- - !! defined when its centroid and lengths in the x-, y- and - !! z-coordinate directions are provided. Please notice that - !! the cuboidal patch DOES NOT allow for the smearing of its - !! boundaries. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! creating a solid boundary, or pre-/post-shock + !! is aligned with the axes of the Cartesian + !! The geometry of such a patch is well- + !! its centroid and lengths in the x-, y- and + !! are provided. Please notice that + !! patch DOES NOT allow for the smearing of its + !! + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_cuboid(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1300,7 +1300,7 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the cuboid's centroid and length information + ! the cuboid's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1308,8 +1308,8 @@ contains length_y = patch_icpp(patch_id)%length_y length_z = patch_icpp(patch_id)%length_z - ! Computing the beginning and the end x-, y- and z-coordinates of - ! the cuboid based on its centroid and lengths + ! the beginning and the end x-, y- and z-coordinates of + ! cuboid based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y @@ -1317,16 +1317,16 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! Since the cuboidal patch does not allow for its boundaries to get - ! smoothed out, the pseudo volume fraction is set to 1 to make sure - ! that only the current patch contributes to the fluid state in the - ! cells that this patch covers. + ! the cuboidal patch does not allow for its boundaries to get + ! out, the pseudo volume fraction is set to 1 to make sure + ! only the current patch contributes to the fluid state in the + ! that this patch covers. eta = 1._wp - ! Checking whether the cuboid covers a particular cell in the domain - ! and verifying whether the current patch has permission to write to - ! to that cell. If both queries check out, the primitive variables - ! of the current patch are assigned to this cell. + ! whether the cuboid covers a particular cell in the domain + ! verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables + ! the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1355,7 +1355,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if @@ -1368,16 +1368,16 @@ contains end subroutine s_icpp_cuboid !> The cylindrical patch is a 3D geometry that may be used, - !! for example, in setting up a cylindrical solid boundary - !! confinement, like a blood vessel. The geometry of this - !! patch is well-defined when the centroid, the radius and - !! the length along the cylinder's axis, parallel to the x-, - !! y- or z-coordinate direction, are provided. Please note - !! that the cylindrical patch DOES allow for the smoothing - !! of its lateral boundary. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Array of primitive variables + !! in setting up a cylindrical solid boundary + !! a blood vessel. The geometry of this + !! well-defined when the centroid, the radius and + !! along the cylinder's axis, parallel to the x-, + !! z-coordinate direction, are provided. Please note + !! cylindrical patch DOES allow for the smoothing + !! lateral boundary. + !! is the patch identifier + !! Array to track patch ids + !! Array of primitive variables subroutine s_icpp_cylinder(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1393,8 +1393,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the cylindrical patch's centroid, length, radius, - ! smoothing patch identity and smoothing coefficient information + ! the cylindrical patch's centroid, length, radius, + ! patch identity and smoothing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1405,8 +1405,8 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Computing the beginning and the end x-, y- and z-coordinates of - ! the cylinder based on its centroid and lengths + ! the beginning and the end x-, y- and z-coordinates of + ! cylinder based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y @@ -1414,15 +1414,15 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smearing of the cylindrical patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smearing of the cylindrical patch's boundary is enabled. eta = 1._wp - ! Checking whether the cylinder covers a particular cell in the - ! domain and verifying whether the current patch has the permission - ! to write to that cell. If both queries check out, the primitive - ! variables of the current patch are assigned to this cell. + ! whether the cylinder covers a particular cell in the + ! and verifying whether the current patch has the permission + ! write to that cell. If both queries check out, the primitive + ! of the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1481,7 +1481,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if end do @@ -1492,15 +1492,15 @@ contains end subroutine s_icpp_cylinder !> The swept plane patch is a 3D geometry that may be used, - !! for example, in creating a solid boundary, or pre-/post- - !! shock region, at an angle with respect to the axes of the - !! Cartesian coordinate system. The geometry of the patch is - !! well-defined when its centroid and normal vector, aimed - !! in the sweep direction, are provided. Note that the sweep - !! plane patch DOES allow the smoothing of its boundary. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Primitive variables + !! in creating a solid boundary, or pre-/post- + !! at an angle with respect to the axes of the + !! system. The geometry of the patch is + !! its centroid and normal vector, aimed + !! sweep direction, are provided. Note that the sweep + !! DOES allow the smoothing of its boundary. + !! is the patch identifier + !! Array to track patch ids + !! Primitive variables subroutine s_icpp_sweep_plane(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1516,28 +1516,28 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! Transferring the centroid information of the plane to be swept + ! the centroid information of the plane to be swept x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! Obtaining coefficients of the equation describing the sweep plane + ! coefficients of the equation describing the sweep plane a = patch_icpp(patch_id)%normal(1) b = patch_icpp(patch_id)%normal(2) c = patch_icpp(patch_id)%normal(3) d = -a*x_centroid - b*y_centroid - c*z_centroid - ! Initializing the pseudo volume fraction value to 1. The value will - ! be modified as the patch is laid out on the grid, but only in the - ! case that smearing of the sweep plane patch's boundary is enabled. + ! the pseudo volume fraction value to 1. The value will + ! modified as the patch is laid out on the grid, but only in the + ! that smearing of the sweep plane patch's boundary is enabled. eta = 1._wp - ! Checking whether the region swept by the plane covers a particular - ! cell in the domain and verifying whether the current patch has the - ! permission to write to that cell. If both queries check out, the - ! primitive variables of the current patch are written to this cell. + ! whether the region swept by the plane covers a particular + ! in the domain and verifying whether the current patch has the + ! to write to that cell. If both queries check out, the + ! variables of the current patch are written to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1572,7 +1572,7 @@ contains @:Hardcoded3D() end if - ! Updating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if @@ -1584,11 +1584,11 @@ contains end subroutine s_icpp_sweep_plane !> The STL patch is a 2/3D geometry that is imported from an STL file. - !! @param patch_id is the patch identifier - !! @param patch_id_fp Array to track patch ids - !! @param q_prim_vf Primitive variables - !! @param STL_levelset STL levelset - !! @param STL_levelset_norm STL levelset normals + !! is the patch identifier + !! Array to track patch ids + !! Primitive variables + !! STL levelset + !! STL levelset normals subroutine s_icpp_model(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1599,7 +1599,7 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! Variables for IBM+STL + ! for IBM+STL real(wp) :: normals(1:3) !< Boundary normal buffer integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex real(wp), allocatable, dimension(:, :, :) :: boundary_v !< Boundary vertex buffer @@ -1637,39 +1637,39 @@ contains print *, " * Transforming model." end if - ! Get the model center before transforming the model + ! the model center before transforming the model bbox_old = f_create_bbox(model) model_center(1:3) = (bbox_old%min(1:3) + bbox_old%max(1:3))/2._wp - ! Compute the transform matrices for vertices and normals + ! the transform matrices for vertices and normals transform = f_create_transform_matrix(params, model_center) transform_n = f_create_transform_matrix(params) call s_transform_model(model, transform, transform_n) - ! Recreate the bounding box after transformation + ! the bounding box after transformation bbox = f_create_bbox(model) - ! Show the number of vertices in the original STL model + ! the number of vertices in the original STL model if (proc_rank == 0) then print *, ' * Number of input model vertices:', 3*model%ntrs end if call f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) - ! Check if the model needs interpolation + ! if the model needs interpolation if (p > 0) then call f_check_interpolation_3D(model, (/dx, dy, dz/), interpolate) else call f_check_interpolation_2D(boundary_v, boundary_edge_count, (/dx, dy, dz/), interpolate) end if - ! Show the number of edges and boundary edges in 2D STL models + ! the number of edges and boundary edges in 2D STL models if (proc_rank == 0 .and. p == 0) then print *, ' * Number of 2D model boundary edges:', boundary_edge_count end if - ! Interpolate the STL model along the edges (2D) and on triangle facets (3D) + ! the STL model along the edges (2D) and on triangle facets (3D) if (interpolate) then if (proc_rank == 0) then print *, ' * Interpolating STL vertices.' @@ -1738,8 +1738,8 @@ contains call s_assign_patch_primitive_variables(patch_id, i, j, k, & eta, q_prim_vf, patch_id_fp) - ! Note: Should probably use *eta* to compute primitive variables - ! if defining them analytically. + ! Should probably use *eta* to compute primitive variables + ! defining them analytically. @:analytical() end do; end do; end do @@ -1785,9 +1785,9 @@ contains end subroutine s_convert_cylindrical_to_spherical_coord !> Archimedes spiral function - !! @param myth Angle - !! @param offset Thickness - !! @param a Starting position + !! Angle + !! Thickness + !! Starting position elemental function f_r(myth, offset, a) $:GPU_ROUTINE(parallelism='[seq]') diff --git a/src/pre_process/m_initial_condition.fpp b/src/pre_process/m_initial_condition.fpp index 35f8bec0db..22406649ce 100644 --- a/src/pre_process/m_initial_condition.fpp +++ b/src/pre_process/m_initial_condition.fpp @@ -1,19 +1,19 @@ !> -!! @file m_initial_condition.f90 -!! @brief Contains module m_initial_condition +!! +!! module m_initial_condition !> @brief This module provides a platform that is analogous to constructive -!! solid geometry techniques and in this way allows for the creation -!! of a wide variety of initial conditions. Several 1D, 2D and 3D -!! fundamental geometries are included that may further be combined -!! into more complex shapes. This is achieved by carefully setting -!! up the order in which the patches are laid out in the domain and -!! specifying the priority that each patch has over the preceding -!! ones. The resulting shapes may be identified both by the values -!! of their primitive variables and the associated patch identities. -!! Note that the user may choose to read in and modify a preexisting -!! initial condition. The module m_start_up.f90 is responsible for -!! reading in the relevant data files. +!! techniques and in this way allows for the creation +!! wide variety of initial conditions. Several 1D, 2D and 3D +!! are included that may further be combined +!! complex shapes. This is achieved by carefully setting +!! order in which the patches are laid out in the domain and +!! priority that each patch has over the preceding +!! resulting shapes may be identified both by the values +!! primitive variables and the associated patch identities. +!! the user may choose to read in and modify a preexisting +!! The module m_start_up.f90 is responsible for +!! the relevant data files. module m_initial_condition use m_derived_types ! Definitions of the derived types @@ -25,7 +25,7 @@ module m_initial_condition use m_helper use m_variables_conversion ! Subroutines to change the state variables from - ! one form to another + ! form to another use m_ib_patches @@ -41,10 +41,10 @@ module m_initial_condition implicit none - ! NOTE: The abstract interface allows for the declaration of a pointer to - ! a procedure such that the choice of the model equations does not have to - ! be queried every time the patch primitive variables are to be assigned in - ! a cell in the computational domain. + ! The abstract interface allows for the declaration of a pointer to + ! procedure such that the choice of the model equations does not have to + ! queried every time the patch primitive variables are to be assigned in + ! cell in the computational domain. type(scalar_field), allocatable, dimension(:) :: q_prim_vf !< primitive variables type(scalar_field), allocatable, dimension(:) :: q_cons_vf !< conservative variables @@ -53,20 +53,23 @@ module m_initial_condition type(integer_field), dimension(:, :), allocatable :: bc_type !< bc_type fields +!> @cond #ifdef MFC_MIXED_PRECISION integer(kind=1), allocatable, dimension(:, :, :) :: patch_id_fp #else - integer, allocatable, dimension(:, :, :) :: patch_id_fp -#endif - - !! Bookkepping variable used to track the patch identities (id) associated +!> @endcond + integer, allocatable, dimension(:, :, :) :: patch_id_fp !< + !! Bookkeeping variable used to track the patch identities (id) associated !! with each of the cells in the computational domain. Note that only one !! patch identity may be associated with any one cell. +!> @cond +#endif +!> @endcond type(integer_field) :: ib_markers !< - !! Bookkepping variable used to track whether a given cell is within an - !! immersed boundary. The default is 0, otherwise the value is assigned - !! to the patch ID of the immersed boundary. + !! used to track whether a given cell is within an + !! The default is 0, otherwise the value is assigned + !! patch ID of the immersed boundary. type(levelset_field) :: levelset type(levelset_norm_field) :: levelset_norm @@ -74,12 +77,12 @@ module m_initial_condition contains !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_initial_condition_module integer :: i, j, k, l !< generic loop iterators - ! Allocating the primitive and conservative variables + ! the primitive and conservative variables allocate (q_prim_vf(1:sys_size)) allocate (q_cons_vf(1:sys_size)) @@ -96,7 +99,7 @@ contains allocate (q_T_sf%sf(0:m, 0:n, 0:p)) end if - ! Allocating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable allocate (patch_id_fp(0:m, 0:n, 0:p)) if (ib) then @@ -116,17 +119,17 @@ contains 0:p, 1:nnode, 1:nb)) end if - ! Setting default values for conservative and primitive variables so - ! that in the case that the initial condition is wrongly laid out on - ! the grid the simulation component will catch the problem on start- - ! up. The conservative variables do not need to be similarly treated - ! since they are computed directly from the primitive variables. + ! default values for conservative and primitive variables so + ! in the case that the initial condition is wrongly laid out on + ! grid the simulation component will catch the problem on start- + ! The conservative variables do not need to be similarly treated + ! they are computed directly from the primitive variables. do i = 1, sys_size q_cons_vf(i)%sf = -1.e-6_stp ! real(dflt_real, kind=stp) ! TODO :: remove this magic number q_prim_vf(i)%sf = -1.e-6_stp ! real(dflt_real, kind=stp) end do - ! Allocating arrays to store the bc types + ! arrays to store the bc types allocate (bc_type(1:num_dims, 1:2)) allocate (bc_type(1, 1)%sf(0:0, 0:n, 0:p)) @@ -163,39 +166,39 @@ contains end if end if - ! Initial damage state is always zero + ! damage state is always zero if (cont_damage) then q_cons_vf(damage_idx)%sf = 0._wp q_prim_vf(damage_idx)%sf = 0._wp end if - ! Initial hyper_cleaning state is always zero - ! TODO more general + ! hyper_cleaning state is always zero + ! more general if (hyper_cleaning) then q_cons_vf(psi_idx)%sf = 0._wp q_prim_vf(psi_idx)%sf = 0._wp end if - ! Setting default values for patch identities bookkeeping variable. - ! This is necessary to avoid any confusion in the assessment of the - ! extent of application that the overwrite permissions give a patch - ! when it is being applied in the domain. + ! default values for patch identities bookkeeping variable. + ! is necessary to avoid any confusion in the assessment of the + ! of application that the overwrite permissions give a patch + ! it is being applied in the domain. patch_id_fp = 0 end subroutine s_initialize_initial_condition_module !> This subroutine peruses the patches and depending on the - !! type of geometry associated with a particular patch, it - !! calls the related subroutine to setup the said geometry - !! on the grid using the primitive variables included with - !! the patch parameters. The subroutine is complete once the - !! primitive variables are converted to conservative ones. + !! geometry associated with a particular patch, it + !! related subroutine to setup the said geometry + !! grid using the primitive variables included with + !! parameters. The subroutine is complete once the + !! are converted to conservative ones. impure subroutine s_generate_initial_condition integer :: i - ! Converting the conservative variables to the primitive ones given - ! preexisting initial condition data files were read in on start-up + ! the conservative variables to the primitive ones given + ! initial condition data files were read in on start-up if (old_ic) then call s_convert_conservative_to_primitive_variables(q_cons_vf, & q_T_sf, & @@ -219,7 +222,7 @@ contains if (simplex_perturb) call s_perturb_simplex(q_prim_vf) if (elliptic_smoothing) call s_elliptic_smoothing(q_prim_vf, bc_type) - ! Converting the primitive variables to the conservative ones + ! the primitive variables to the conservative ones call s_convert_primitive_to_conservative_variables(q_prim_vf, q_cons_vf) if (chemistry) call s_compute_T_from_primitives(q_T_sf, q_prim_vf, idwint) @@ -237,7 +240,7 @@ contains integer :: i !< Generic loop iterator - ! Dellocating the primitive and conservative variables + ! the primitive and conservative variables do i = 1, sys_size deallocate (q_prim_vf(i)%sf) deallocate (q_cons_vf(i)%sf) @@ -250,7 +253,7 @@ contains deallocate (q_T_sf%sf) end if - ! Deallocating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable deallocate (patch_id_fp) if (ib) then diff --git a/src/pre_process/m_mpi_proxy.fpp b/src/pre_process/m_mpi_proxy.fpp index 050929a9e3..449fe2ad42 100644 --- a/src/pre_process/m_mpi_proxy.fpp +++ b/src/pre_process/m_mpi_proxy.fpp @@ -1,12 +1,12 @@ !> -!! @file m_mpi_proxy.f90 -!! @brief Contains module m_mpi_proxy +!! +!! module m_mpi_proxy !> @brief This module serves as a proxy to the parameters and subroutines -!! available in the MPI implementation's MPI module. Specifically, -!! the role of the proxy is to harness basic MPI commands into more -!! complex procedures as to achieve the required pre-processing -!! communication goals. +!! the MPI implementation's MPI module. Specifically, +!! of the proxy is to harness basic MPI commands into more +!! as to achieve the required pre-processing +!! module m_mpi_proxy #ifdef MFC_MPI @@ -25,20 +25,20 @@ module m_mpi_proxy contains !> Since only processor with rank 0 is in charge of reading - !! and checking the consistency of the user provided inputs, - !! these are not available to the remaining processors. This - !! subroutine is then in charge of broadcasting the required - !! information. + !! the consistency of the user provided inputs, + !! not available to the remaining processors. This + !! then in charge of broadcasting the required + !! impure subroutine s_mpi_bcast_user_inputs #ifdef MFC_MPI - ! Generic loop iterator + ! loop iterator integer :: i, j - ! Generic flag used to identify and report MPI errors + ! flag used to identify and report MPI errors integer :: ierr - ! Logistics + ! call MPI_BCAST(case_dir, len(case_dir), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) #:for VAR in ['t_step_old', 't_step_start', 'm', 'n', 'p', 'm_glb', 'n_glb', 'p_glb', & @@ -124,7 +124,7 @@ contains if (chemistry) then call MPI_BCAST(patch_icpp(i)%Y, size(patch_icpp(i)%Y), mpi_p, 0, MPI_COMM_WORLD, ierr) end if - ! Broadcast IB variables + ! IB variables call MPI_BCAST(patch_ib(i)%geometry, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(patch_ib(i)%model_filepath, len(patch_ib(i)%model_filepath), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(patch_ib(i)%model_threshold, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -141,7 +141,7 @@ contains #:endfor end do - ! Simplex noise and fluid physical parameters + ! noise and fluid physical parameters do i = 1, num_fluids_max #:for VAR in [ 'gamma','pi_inf', 'G', 'cv', 'qv', 'qvp' ] call MPI_BCAST(fluid_pp(i)%${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -156,7 +156,7 @@ contains end do end do - ! Subgrid bubble parameters + ! bubble parameters if (bubbles_euler .or. bubbles_lagrange) then #:for VAR in [ 'R0ref','p0ref','rho0ref','T0ref', & 'ss','pv','vd','mu_l','mu_v','mu_g','gam_v','gam_g', & diff --git a/src/pre_process/m_perturbation.fpp b/src/pre_process/m_perturbation.fpp index 2ea291c27f..52abd7c097 100644 --- a/src/pre_process/m_perturbation.fpp +++ b/src/pre_process/m_perturbation.fpp @@ -1,9 +1,9 @@ !> -!! @file m_perturbation.fpp -!! @brief Contains module m_perturbation +!! +!! module m_perturbation !> @brief This module contains subroutines that compute perturbations to the -!! initial mean flow fields. +!! flow fields. module m_perturbation use m_derived_types ! Definitions of the derived types @@ -50,11 +50,11 @@ contains perturb_alpha = q_prim_vf(E_idx + perturb_sph_fluid)%sf(i, j, k) - ! Perturb partial density fields to match perturbed volume fraction fields - ! IF ((perturb_alpha >= 25e-2_wp) .AND. (perturb_alpha <= 75e-2_wp)) THEN + ! partial density fields to match perturbed volume fraction fields + ! ((perturb_alpha >= 25e-2_wp) .AND. (perturb_alpha <= 75e-2_wp)) THEN if ((.not. f_approx_equal(perturb_alpha, 0._wp)) .and. (.not. f_approx_equal(perturb_alpha, 1._wp))) then - ! Derive new partial densities + ! new partial densities do l = 1, num_fluids q_prim_vf(l)%sf(i, j, k) = q_prim_vf(E_idx + l)%sf(i, j, k)*fluid_rho(l) end do @@ -74,7 +74,7 @@ contains real(wp) :: rand_real call random_seed() - ! Perturb partial density or velocity of surrounding flow by some random small amount of noise + ! partial density or velocity of surrounding flow by some random small amount of noise do k = 0, p do j = 0, n do i = 0, m @@ -99,10 +99,10 @@ contains do q = 1, elliptic_smoothing_iters - ! Communication of buffer regions and apply boundary conditions + ! of buffer regions and apply boundary conditions call s_populate_variables_buffers(bc_type, q_prim_vf, pb%sf, mv%sf) - ! Perform smoothing and store in temp array + ! smoothing and store in temp array if (n == 0) then do j = 0, m do i = 1, sys_size @@ -138,7 +138,7 @@ contains end do end if - ! Copy smoothed data back to array of scalar fields + ! smoothed data back to array of scalar fields do l = 0, p do k = 0, n do j = 0, m @@ -166,14 +166,14 @@ contains allocate (ofs(nOffsets, num_dims)) - ! Store offsets + ! offsets do i = 1, num_dims do j = 1, num_dims ofs(j, i) = simplex_params%perturb_vel_offset(j, i) end do end do - ! Perturb velocities + ! velocities do i = 1, num_dims if (simplex_params%perturb_vel(i)) then freq = simplex_params%perturb_vel_freq(i) @@ -204,14 +204,14 @@ contains end if end do - ! Store offsets + ! offsets do i = 1, num_dims do j = 1, num_fluids ofs(j, i) = simplex_params%perturb_dens_offset(j, i) end do end do - ! Perturb densities + ! densities do i = 1, num_fluids if (simplex_params%perturb_dens(i)) then freq = simplex_params%perturb_dens_freq(i) @@ -240,10 +240,10 @@ contains end subroutine s_perturb_simplex !> This subroutine computes velocity perturbations for a temporal mixing - !! layer with a hyperbolic tangent mean streamwise velocity - !! profile, using an inverter version of the spectrum-based - !! synthetic turbulence generation method proposed by - !! Guo et al. (2023, JFM). + !! a hyperbolic tangent mean streamwise velocity + !! an inverter version of the spectrum-based + !! generation method proposed by + !! al. (2023, JFM). subroutine s_perturb_mixlayer(q_prim_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf real(wp), dimension(mixlayer_perturb_nk) :: k, Ek @@ -252,10 +252,10 @@ contains real(wp) :: dk, alpha, Eksum, q, uu0, phi integer :: i, j, l, r, ierr - ! Initialize parameters + ! parameters dk = 1._wp/mixlayer_perturb_nk - ! Compute prescribed energy spectra + ! prescribed energy spectra Eksum = 0._wp do i = 1, mixlayer_perturb_nk k(i) = dk*i @@ -263,10 +263,10 @@ contains Eksum = Eksum + Ek(i) end do - ! Main loop + ! loop do r = 0, n - ! Compute prescribed Reynolds stress tensor with about half - ! magnitude of its self-similar value + ! prescribed Reynolds stress tensor with about half + ! of its self-similar value Rij(:, :) = 0._wp uu0 = patch_icpp(1)%vel(1)**2._wp & *(1._wp - tanh(y_cc(r)*mixlayer_vel_coef)**2._wp) @@ -276,7 +276,7 @@ contains Rij(1, 2) = -0.02_wp*uu0 Rij(2, 1) = Rij(1, 2) - ! Cholesky decomposition for inhomogeneity and anisotropy + ! decomposition for inhomogeneity and anisotropy Lmat = 0._wp Lmat(1, 1) = sqrt(Rij(1, 1)) if (abs(Lmat(1, 1)) < sgm_eps) Lmat(1, 1) = sgm_eps @@ -287,10 +287,10 @@ contains Lmat(3, 2) = (Rij(3, 2) - Lmat(3, 1)*Lmat(2, 1))/Lmat(2, 2) Lmat(3, 3) = sqrt(Rij(3, 3) - Lmat(3, 1)**2._wp - Lmat(3, 2)**2._wp) - ! Compute perturbation for each Fourier component + ! perturbation for each Fourier component do i = 1, mixlayer_perturb_nk - ! Generate random numbers for unit wavevector khat, - ! random unit vector xi, and random mode phase phi + ! random numbers for unit wavevector khat, + ! unit vector xi, and random mode phase phi if (proc_rank == 0) then call s_generate_random_perturbation(khat, xi, phi, i, y_cc(r)) end if @@ -301,12 +301,12 @@ contains call MPI_BCAST(phi, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) #endif - ! Compute mode direction by two-time cross product + ! mode direction by two-time cross product sig_tmp = f_cross(xi, khat) sig_tmp = sig_tmp/sqrt(sum(sig_tmp**2._wp)) sig = f_cross(khat, sig_tmp) - ! Compute perturbation for each grid + ! perturbation for each grid do l = 0, p do j = 0, m q = sqrt(Ek(i)/Eksum) @@ -347,7 +347,7 @@ contains end subroutine s_generate_random_perturbation - ! Generate a random unit vector (spherical distribution) + ! a random unit vector (spherical distribution) function f_unit_vector(theta, eta) result(vec) real(wp), intent(in) :: theta, eta real(wp) :: zeta, xi @@ -362,7 +362,7 @@ contains end function f_unit_vector !> This function generates a pseudo-random number between 0 and 1 based on - !! linear congruential generator. + !! generator. subroutine s_prng(var, seed) integer, intent(inout) :: seed real(wp), intent(out) :: var diff --git a/src/pre_process/m_start_up.fpp b/src/pre_process/m_start_up.fpp index 614f628d49..3c19809c52 100644 --- a/src/pre_process/m_start_up.fpp +++ b/src/pre_process/m_start_up.fpp @@ -1,11 +1,11 @@ !> -!! @file m_start_up.f90 -!! @brief Contains module m_start_up +!! +!! module m_start_up !> @brief This module contains subroutines that read, and check consistency -!! of, the user provided inputs, grid and data. This module also allocates -!! and initializes the relevant variables sets up the mpi decomposition and -!! initial condition procedures. +!! user provided inputs, grid and data. This module also allocates +!! the relevant variables sets up the mpi decomposition and +!! procedures. module m_start_up use m_derived_types !< Definitions of the derived types @@ -17,14 +17,14 @@ module m_start_up use m_mpi_common use m_variables_conversion !< Subroutines to change the state variables from - !! one form to another + !! to another use m_grid !< Procedures to generate (non-)uniform grids use m_initial_condition !< Procedures to generate initial condition use m_data_output !< Procedures to write the grid data and the - !! conservative variables to files + !! to files use m_compile_specific !< Compile-specific procedures @@ -82,8 +82,8 @@ module m_start_up end subroutine s_read_abstract_grid_data_files - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary + !! Conservative variables + !! track if a cell is within the immersed boundary impure subroutine s_read_abstract_ic_data_files(q_cons_vf_in, ib_markers_in) import :: scalar_field, integer_field, sys_size, pres_field @@ -100,11 +100,11 @@ module m_start_up end interface character(LEN=path_len + name_len) :: proc_rank_dir !< - !! Location of the folder associated with the rank of the local processor + !! the folder associated with the rank of the local processor character(LEN=path_len + 2*name_len), private :: t_step_dir !< - !! Possible location of time-step folder containing preexisting grid and/or - !! conservative variables data to be used as starting point for pre-process + !! of time-step folder containing preexisting grid and/or + !! data to be used as starting point for pre-process procedure(s_read_abstract_grid_data_files), pointer :: s_read_grid_data_files => null() procedure(s_read_abstract_ic_data_files), pointer :: s_read_ic_data_files => null() @@ -112,23 +112,23 @@ module m_start_up contains !> Reads the configuration file pre_process.inp, in order to - !! populate the parameters in module m_global_parameters.f90 - !! with the user provided inputs + !! parameters in module m_global_parameters.f90 + !! user provided inputs impure subroutine s_read_input_file character(LEN=name_len) :: file_loc !< - !! Generic string used to store the address of a particular file + !! used to store the address of a particular file logical :: file_check !< - !! Generic logical used for the purpose of asserting whether a file - !! is or is not present in the designated location + !! used for the purpose of asserting whether a file + !! is not present in the designated location integer :: iostatus - !! Integer to check iostat of file read + !! check iostat of file read character(len=1000) :: line - ! Namelist for all of the parameters to be inputted by the user + ! for all of the parameters to be inputted by the user namelist /user_inputs/ case_dir, old_grid, old_ic, & t_step_old, t_step_start, m, n, p, x_domain, y_domain, z_domain, & stretch_x, stretch_y, stretch_z, a_x, a_y, & @@ -155,12 +155,12 @@ contains down_sample, recon_type, muscl_order, hyper_cleaning, & simplex_perturb, simplex_params, fft_wrt - ! Inquiring the status of the pre_process.inp file + ! the status of the pre_process.inp file file_loc = 'pre_process.inp' inquire (FILE=trim(file_loc), EXIST=file_check) - ! Checking whether the input file is there. If it is, the input file - ! is read. If not, the program is terminated. + ! whether the input file is there. If it is, the input file + ! read. If not, the program is terminated. if (file_check) then open (1, FILE=trim(file_loc), FORM='formatted', & STATUS='old', ACTION='read') @@ -176,7 +176,7 @@ contains call s_update_cell_bounds(cells_bounds, m, n, p) - ! Store m,n,p into global m,n,p + ! m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -197,18 +197,18 @@ contains end subroutine s_read_input_file !> Checking that the user inputs make sense, i.e. that the - !! individual choices are compatible with the code's options - !! and that the combination of these choices results into a - !! valid configuration for the pre-process + !! are compatible with the code's options + !! the combination of these choices results into a + !! for the pre-process impure subroutine s_check_input_file character(LEN=len_trim(case_dir)) :: file_loc !< - !! Generic string used to store the address of a particular file + !! used to store the address of a particular file logical :: dir_check !< - !! Logical variable used to test the existence of folders + !! used to test the existence of folders - ! Checking the existence of the case folder + ! the existence of the case folder case_dir = adjustl(case_dir) file_loc = trim(case_dir)//'/.' @@ -225,7 +225,7 @@ contains call s_check_inputs_common() call s_check_inputs() - ! Check all the patch properties + ! all the patch properties call s_check_patches() if (ib) call s_check_ib_patches() @@ -233,44 +233,44 @@ contains end subroutine s_check_input_file !> The goal of this subroutine is to read in any preexisting - !! grid data as well as based on the imported grid, complete - !! the necessary global computational domain parameters. + !! as well as based on the imported grid, complete + !! global computational domain parameters. impure subroutine s_read_serial_grid_data_files - ! Generic string used to store the address of a particular file + ! string used to store the address of a particular file character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc - ! Logical variable used to test the existence of folders + ! variable used to test the existence of folders logical :: dir_check - ! Generic logical used for the purpose of asserting whether a file - ! is or is not present in the designated location + ! logical used for the purpose of asserting whether a file + ! or is not present in the designated location logical :: file_check - ! Setting address of the local processor rank and time-step directory + ! address of the local processor rank and time-step directory write (proc_rank_dir, '(A,I0)') '/p_all/p', proc_rank proc_rank_dir = trim(case_dir)//trim(proc_rank_dir) write (t_step_dir, '(A,I0)') '/', t_step_start t_step_dir = trim(proc_rank_dir)//trim(t_step_dir) - ! Inquiring as to the existence of the time-step directory + ! as to the existence of the time-step directory file_loc = trim(t_step_dir)//'/.' call my_inquire(file_loc, dir_check) - ! If the time-step directory is missing, the pre-process exits + ! the time-step directory is missing, the pre-process exits if (dir_check .neqv. .true.) then call s_mpi_abort('Time-step folder '//trim(t_step_dir)// & ' is missing. Exiting.') end if - ! Reading the Grid Data File for the x-direction + ! the Grid Data File for the x-direction - ! Checking whether x_cb.dat exists + ! whether x_cb.dat exists file_loc = trim(t_step_dir)//'/x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, x_cb.dat is read + ! it exists, x_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -281,26 +281,26 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! Computing cell-center locations + ! cell-center locations x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp - ! Computing minimum cell-width + ! minimum cell-width dx = minval(x_cb(0:m) - x_cb(-1:m - 1)) if (num_procs > 1) call s_mpi_reduce_min(dx) - ! Setting locations of domain bounds + ! locations of domain bounds x_domain%beg = x_cb(-1) x_domain%end = x_cb(m) - ! Reading the Grid Data File for the y-direction + ! the Grid Data File for the y-direction if (n > 0) then - ! Checking whether y_cb.dat exists + ! whether y_cb.dat exists file_loc = trim(t_step_dir)//'/y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, y_cb.dat is read + ! it exists, y_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -311,25 +311,25 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! Computing cell-center locations + ! cell-center locations y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp - ! Computing minimum cell-width + ! minimum cell-width dy = minval(y_cb(0:n) - y_cb(-1:n - 1)) if (num_procs > 1) call s_mpi_reduce_min(dy) - ! Setting locations of domain bounds + ! locations of domain bounds y_domain%beg = y_cb(-1) y_domain%end = y_cb(n) - ! Reading the Grid Data File for the z-direction + ! the Grid Data File for the z-direction if (p > 0) then - ! Checking whether z_cb.dat exists + ! whether z_cb.dat exists file_loc = trim(t_step_dir)//'/z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, z_cb.dat is read + ! it exists, z_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -340,14 +340,14 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! Computing cell-center locations + ! cell-center locations z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp - ! Computing minimum cell-width + ! minimum cell-width dz = minval(z_cb(0:p) - z_cb(-1:p - 1)) if (num_procs > 1) call s_mpi_reduce_min(dz) - ! Setting locations of domain bounds + ! locations of domain bounds z_domain%beg = z_cb(-1) z_domain%end = z_cb(p) @@ -355,12 +355,12 @@ contains end if - ! If only the preexisting grid data files are read in and there will - ! not be any preexisting initial condition data files imported, then - ! the directory associated with the rank of the local processor may - ! be cleaned to make room for the new pre-process data. In addition, - ! the time-step directory that will contain the new grid and initial - ! condition data are also generated. + ! only the preexisting grid data files are read in and there will + ! be any preexisting initial condition data files imported, then + ! directory associated with the rank of the local processor may + ! cleaned to make room for the new pre-process data. In addition, + ! time-step directory that will contain the new grid and initial + ! data are also generated. if (old_ic .neqv. .true.) then call s_delete_directory(trim(proc_rank_dir)//'/*') call s_create_directory(trim(proc_rank_dir)//'/0') @@ -369,19 +369,19 @@ contains end subroutine s_read_serial_grid_data_files !> Cell-boundary data are checked for consistency by looking - !! at the (non-)uniform cell-width distributions for all the - !! active coordinate directions and making sure that all of - !! the cell-widths are positively valued + !! (non-)uniform cell-width distributions for all the + !! directions and making sure that all of + !! are positively valued impure subroutine s_check_grid_data_files - ! Cell-boundary Data Consistency Check in x-direction + ! Data Consistency Check in x-direction if (any(x_cb(0:m) - x_cb(-1:m - 1) <= 0._wp)) then call s_mpi_abort('x_cb.dat in '//trim(t_step_dir)// & ' contains non-positive cell-spacings. Exiting.') end if - ! Cell-boundary Data Consistency Check in y-direction + ! Data Consistency Check in y-direction if (n > 0) then @@ -391,7 +391,7 @@ contains 'Exiting.') end if - ! Cell-boundary Data Consistency Check in z-direction + ! Data Consistency Check in z-direction if (p > 0) then @@ -408,11 +408,11 @@ contains end subroutine s_check_grid_data_files !> The goal of this subroutine is to read in any preexisting - !! initial condition data files so that they may be used by - !! the pre-process as a starting point in the creation of an - !! all new initial condition. - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary + !! data files so that they may be used by + !! as a starting point in the creation of an + !! initial condition. + !! Conservative variables + !! track if a cell is within the immersed boundary impure subroutine s_read_serial_ic_data_files(q_cons_vf_in, ib_markers_in) type(scalar_field), & @@ -423,30 +423,30 @@ contains intent(inout) :: ib_markers_in character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc !< - ! Generic string used to store the address of a particular file + ! string used to store the address of a particular file character(LEN= & int(floor(log10(real(sys_size, wp)))) + 1) :: file_num !< - !! Used to store the variable position, in character form, of the - !! currently manipulated conservative variable file + !! store the variable position, in character form, of the + !! conservative variable file logical :: file_check !< - !! Generic logical used for the purpose of asserting whether a file - !! is or is not present in the designated location + !! used for the purpose of asserting whether a file + !! is not present in the designated location integer :: i, r !< Generic loop iterator - ! Reading the Conservative Variables Data Files + ! the Conservative Variables Data Files do i = 1, sys_size - ! Checking whether data file associated with variable position - ! of the currently manipulated conservative variable exists + ! whether data file associated with variable position + ! the currently manipulated conservative variable exists write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/q_cons_vf'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, the data file is read + ! it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -464,14 +464,14 @@ contains if (qbmm .and. .not. polytropic) then do i = 1, nb do r = 1, nnode - ! Checking whether data file associated with variable position - ! of the currently manipulated bubble variable exists + ! whether data file associated with variable position + ! the currently manipulated bubble variable exists write (file_num, '(I0)') sys_size + r + (i - 1)*nnode file_loc = trim(t_step_dir)//'/pb'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, the data file is read + ! it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -488,14 +488,14 @@ contains do i = 1, nb do r = 1, 4 - ! Checking whether data file associated with variable position - ! of the currently manipulated bubble variable exists + ! whether data file associated with variable position + ! the currently manipulated bubble variable exists write (file_num, '(I0)') sys_size + r + (i - 1)*4 file_loc = trim(t_step_dir)//'/mv'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, the data file is read + ! it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -511,13 +511,13 @@ contains end do end if - ! Reading the IB markers + ! the IB markers if (ib) then write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/ib.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! If it exists, the data file is read + ! it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -530,20 +530,20 @@ contains end if end if - ! Since the preexisting grid and initial condition data files have - ! been read in, the directory associated with the rank of the local - ! process may be cleaned out to make room for new pre-process data. - ! In addition, the time-step folder that will contain the new grid - ! and initial condition data are also generated. + ! the preexisting grid and initial condition data files have + ! read in, the directory associated with the rank of the local + ! may be cleaned out to make room for new pre-process data. + ! addition, the time-step folder that will contain the new grid + ! initial condition data are also generated. call s_create_directory(trim(proc_rank_dir)//'/*') call s_create_directory(trim(proc_rank_dir)//'/0') end subroutine s_read_serial_ic_data_files !> Cell-boundary data are checked for consistency by looking - !! at the (non-)uniform cell-width distributions for all the - !! active coordinate directions and making sure that all of - !! the cell-widths are positively valued + !! (non-)uniform cell-width distributions for all the + !! directions and making sure that all of + !! are positively valued impure subroutine s_read_parallel_grid_data_files #ifdef MFC_MPI @@ -560,7 +560,7 @@ contains allocate (y_cb_glb(-1:n_glb)) allocate (z_cb_glb(-1:p_glb)) - ! Read in cell boundary locations in x-direction + ! in cell boundary locations in x-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -573,19 +573,19 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! Assigning local cell boundary locations + ! local cell boundary locations x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m)) - ! Computing cell center locations + ! cell center locations x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp - ! Computing minimum cell width + ! minimum cell width dx = minval(x_cb(0:m) - x_cb(-1:(m - 1))) if (num_procs > 1) call s_mpi_reduce_min(dx) - ! Setting locations of domain bounds + ! locations of domain bounds x_domain%beg = x_cb(-1) x_domain%end = x_cb(m) if (n > 0) then - ! Read in cell boundary locations in y-direction + ! in cell boundary locations in y-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -598,19 +598,19 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! Assigning local cell boundary locations + ! local cell boundary locations y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n)) - ! Computing cell center locations + ! cell center locations y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp - ! Computing minimum cell width + ! minimum cell width dy = minval(y_cb(0:n) - y_cb(-1:(n - 1))) if (num_procs > 1) call s_mpi_reduce_min(dy) - ! Setting locations of domain bounds + ! locations of domain bounds y_domain%beg = y_cb(-1) y_domain%end = y_cb(n) if (p > 0) then - ! Read in cell boundary locations in z-direction + ! in cell boundary locations in z-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -623,14 +623,14 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! Assigning local cell boundary locations + ! local cell boundary locations z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p)) - ! Computing cell center locations + ! cell center locations z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp - ! Computing minimum cell width + ! minimum cell width dz = minval(z_cb(0:p) - z_cb(-1:(p - 1))) if (num_procs > 1) call s_mpi_reduce_min(dz) - ! Setting locations of domain bounds + ! locations of domain bounds z_domain%beg = z_cb(-1) z_domain%end = z_cb(p) @@ -644,11 +644,11 @@ contains end subroutine s_read_parallel_grid_data_files !> The goal of this subroutine is to read in any preexisting - !! initial condition data files so that they may be used by - !! the pre-process as a starting point in the creation of an - !! all new initial condition. - !! @param q_cons_vf Conservative variables - !! @param ib_markers track if a cell is within the immersed boundary + !! data files so that they may be used by + !! as a starting point in the creation of an + !! initial condition. + !! Conservative variables + !! track if a cell is within the immersed boundary impure subroutine s_read_parallel_ic_data_files(q_cons_vf_in, ib_markers_in) type(scalar_field), & @@ -673,7 +673,7 @@ contains integer :: i - ! Open the file to read + ! the file to read if (cfl_adap_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -685,17 +685,17 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! Initialize MPI data I/O + ! MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf_in, ib_markers_in, levelset, levelset_norm) else call s_initialize_mpi_data(q_cons_vf_in) end if - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! Resize some integers so MPI can read even the biggest files + ! some integers so MPI can read even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -704,11 +704,11 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! Read the data for each variable + ! the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -721,7 +721,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*4 var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -769,8 +769,8 @@ contains end subroutine s_read_parallel_ic_data_files impure subroutine s_initialize_modules - ! Computation of parameters, allocation procedures, and/or any other tasks - ! needed to properly setup the modules + ! of parameters, allocation procedures, and/or any other tasks + ! to properly setup the modules call s_initialize_global_parameters_module() if (bubbles_euler .or. bubbles_lagrange) then call s_initialize_bubbles_model() @@ -785,11 +785,11 @@ contains call s_initialize_boundary_common_module() if (relax) call s_initialize_phasechange_module() - ! Create the D directory if it doesn't exit, to store - ! the serial data files + ! the D directory if it doesn't exit, to store + ! serial data files call s_create_directory('D') - ! Associate pointers for serial or parallel I/O + ! pointers for serial or parallel I/O if (parallel_io .neqv. .true.) then s_generate_grid => s_generate_serial_grid s_read_grid_data_files => s_read_serial_grid_data_files @@ -828,23 +828,23 @@ contains integer :: j, k - ! Setting up the grid and the initial condition. If the grid is read in from - ! preexisting grid data files, it is checked for consistency. If the grid is - ! not read in, it is generated from scratch according to the inputs provided - ! by the user. The initial condition may also be read in. It in turn is not - ! checked for consistency since it WILL further be edited by the pre-process - ! and also because it may be incomplete at the time it is read in. Finally, - ! when the grid and initial condition are completely setup, they are written - ! to their respective data files. + ! up the grid and the initial condition. If the grid is read in from + ! grid data files, it is checked for consistency. If the grid is + ! read in, it is generated from scratch according to the inputs provided + ! the user. The initial condition may also be read in. It in turn is not + ! for consistency since it WILL further be edited by the pre-process + ! also because it may be incomplete at the time it is read in. Finally, + ! the grid and initial condition are completely setup, they are written + ! their respective data files. - ! Setting up grid and initial condition + ! up grid and initial condition call cpu_time(start) if (old_ic) call s_read_ic_data_files(q_cons_vf, ib_markers) call s_generate_initial_condition() - ! hard-coded psi + ! psi if (hyper_cleaning) then do j = 0, m do k = 0, n @@ -907,14 +907,14 @@ contains end subroutine s_save_data impure subroutine s_initialize_mpi_domain - ! Initialization of the MPI environment + ! of the MPI environment call s_mpi_initialize() - ! Rank 0 processor assigns default values to user inputs prior to reading - ! those in from the input file. Next, the user inputs are read in and their - ! consistency is checked. The detection of any inconsistencies automatically - ! leads to the termination of the pre-process. + ! 0 processor assigns default values to user inputs prior to reading + ! in from the input file. Next, the user inputs are read in and their + ! is checked. The detection of any inconsistencies automatically + ! to the termination of the pre-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() @@ -924,22 +924,22 @@ contains print '(" Pre-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs end if - ! Broadcasting the user inputs to all of the processors and performing the - ! parallel computational domain decomposition. Neither procedure has to be - ! carried out if pre-process is in fact not truly executed in parallel. + ! the user inputs to all of the processors and performing the + ! computational domain decomposition. Neither procedure has to be + ! out if pre-process is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() call s_initialize_parallel_io() call s_mpi_decompose_computational_domain() end subroutine s_initialize_mpi_domain impure subroutine s_finalize_modules - ! Disassociate pointers for serial and parallel I/O + ! pointers for serial and parallel I/O s_generate_grid => null() s_read_grid_data_files => null() s_read_ic_data_files => null() s_write_data_files => null() - ! Deallocation procedures for the modules + ! procedures for the modules call s_finalize_mpi_common_module() call s_finalize_grid_module() call s_finalize_variables_conversion_module() @@ -950,7 +950,7 @@ contains call s_finalize_boundary_common_module() if (relax) call s_finalize_relaxation_solver_module() call s_finalize_initial_condition_module() - ! Finalization of the MPI environment + ! of the MPI environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/simulation/include/inline_riemann.fpp b/src/simulation/include/inline_riemann.fpp index d8d0cc87c7..b05438ef94 100644 --- a/src/simulation/include/inline_riemann.fpp +++ b/src/simulation/include/inline_riemann.fpp @@ -55,11 +55,11 @@ T_avg = (sqrt(rho_L)*T_L + sqrt(rho_R)*T_R)/(sqrt(rho_L) + sqrt(rho_R)) #:if USING_AMD if (abs(T_L - T_R) < eps) then - ! Case when T_L and T_R are very close + ! when T_L and T_R are very close Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights_nonparameter(:)) Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights_nonparameter(:) - gas_constant/molecular_weights_nonparameter(:))) else - ! Normal calculation when T_L and T_R are sufficiently different + ! calculation when T_L and T_R are sufficiently different Cp_avg = sum(Yi_avg(:)*(h_iR(:) - h_iL(:))/(T_R - T_L)) Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/molecular_weights_nonparameter(:))) end if @@ -69,11 +69,11 @@ c_sum_Yi_Phi = sum(Yi_avg(:)*Phi_avg(:)) #:else if (abs(T_L - T_R) < eps) then - ! Case when T_L and T_R are very close + ! when T_L and T_R are very close Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:)) Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:) - gas_constant/molecular_weights(:))) else - ! Normal calculation when T_L and T_R are sufficiently different + ! calculation when T_L and T_R are sufficiently different Cp_avg = sum(Yi_avg(:)*(h_iR(:) - h_iL(:))/(T_R - T_L)) Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/molecular_weights(:))) end if diff --git a/src/simulation/m_acoustic_src.fpp b/src/simulation/m_acoustic_src.fpp index 75a61104da..63c7ee0ae6 100644 --- a/src/simulation/m_acoustic_src.fpp +++ b/src/simulation/m_acoustic_src.fpp @@ -1,6 +1,6 @@ !> -!! @file m_acoustic_src.fpp -!! @brief Contains module m_acoustic_src +!! +!! module m_acoustic_src #:include 'macros.fpp' @@ -124,21 +124,15 @@ contains end subroutine s_initialize_acoustic_src !> This subroutine updates the rhs by computing the mass, mom, energy sources - !! @param q_cons_vf Conservative variables - !! @param q_prim_vf Primitive variables - !! @param t_step Current time step - !! @param rhs_vf rhs variables + !! @param[inout] q_cons_vf Conservative variables. + !! @param[inout] q_prim_vf Primitive variables. + !! @param[in] t_step Current time step. + !! @param[inout] rhs_vf Right-hand side source terms. impure subroutine s_acoustic_src_calculations(q_cons_vf, q_prim_vf, t_step, rhs_vf) - type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf !< - !! This variable contains the WENO-reconstructed values of the cell-average - !! conservative variables, which are located in q_cons_vf, at cell-interior - !! Gaussian quadrature points (QP). + type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf - type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf !< - !! The primitive variables at cell-interior Gaussian quadrature points. These - !! are calculated from the conservative variables and gradient magnitude (GM) - !! of the volume fractions, q_cons_qp and gm_alpha_qp, respectively. + type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf @@ -183,41 +177,41 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! Keep outer loop sequel because different sources can have very different number of points + ! outer loop sequel because different sources can have very different number of points do ai = 1, num_source - ! Skip if the pulse has not started yet for sine and square waves + ! if the pulse has not started yet for sine and square waves if (.not. (sim_time < delay(ai) .and. (pulse(ai) == 1 .or. pulse(ai) == 3))) then - ! Decide if frequency need to be converted from wavelength + ! if frequency need to be converted from wavelength freq_conv_flag = f_is_default(frequency(ai)) gauss_conv_flag = f_is_default(gauss_sigma_time(ai)) num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug - ! Calculate the broadband source + ! the broadband source period_BB = 0._wp sl_BB = 0._wp ffre_BB = 0._wp sum_BB = 0._wp - ! Allocate buffers for random phase shift + ! buffers for random phase shift allocate (phi_rn(1:bb_num_freq(ai))) phi_rn(1:bb_num_freq(ai)) = 0._wp if (pulse(ai) == 4) then call random_number(phi_rn(1:bb_num_freq(ai))) - ! Ensure all the ranks have the same random phase shift + ! all the ranks have the same random phase shift call s_mpi_send_random_number(phi_rn, bb_num_freq(ai)) end if do k = 1, bb_num_freq(ai) - ! Acoustic period of the wave at each discrete frequency + ! period of the wave at each discrete frequency period_BB = 1._wp/(bb_lowest_freq(ai) + k*bb_bandwidth(ai)) - ! Spectral level at each frequency + ! level at each frequency sl_BB = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate - ! Source term corresponding to each frequencies + ! term corresponding to each frequencies ffre_BB = sqrt((2._wp*sl_BB*bb_bandwidth(ai)))*cos((sim_time)*2._wp*pi/period_BB + 2._wp*pi*phi_rn(k)) - ! Sum up the source term of each frequency to obtain the total source term for broadband wave + ! up the source term of each frequency to obtain the total source term for broadband wave sum_BB = sum_BB + ffre_BB end do @@ -229,7 +223,7 @@ contains k = source_spatials(ai)%coord(2, i) l = source_spatials(ai)%coord(3, i) - ! Compute speed of sound + ! speed of sound myRho = 0._wp B_tait = 0._wp small_gamma = 0._wp @@ -267,11 +261,11 @@ contains small_gamma = 1._wp/small_gamma + 1._wp c = sqrt(small_gamma*(q_prim_vf(E_idx)%sf(j, k, l) + ((small_gamma - 1._wp)/small_gamma)*B_tait)/myRho) - ! Wavelength to frequency conversion + ! to frequency conversion if (pulse(ai) == 1 .or. pulse(ai) == 3) frequency_local = f_frequency_local(freq_conv_flag, ai, c) if (pulse(ai) == 2) gauss_sigma_time_local = f_gauss_sigma_time_local(gauss_conv_flag, ai, c) - ! Update momentum source term + ! momentum source term call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB) mom_src_diff = source_temporal*source_spatials(ai)%val(i) @@ -304,17 +298,17 @@ contains end if end if - ! Update mass source term + ! mass source term if (support(ai) < 5) then ! Planar mass_src_diff = mom_src_diff/c else ! Spherical or cylindrical support - ! Mass source term must be calculated differently using a correction term for spherical and cylindrical support + ! source term must be calculated differently using a correction term for spherical and cylindrical support call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB) mass_src_diff = source_temporal*source_spatials(ai)%val(i) end if mass_src(j, k, l) = mass_src(j, k, l) + mass_src_diff - ! Update energy source term + ! energy source term if (model_eqns /= 4) then E_src(j, k, l) = E_src(j, k, l) + mass_src_diff*c**2._wp/(small_gamma - 1._wp) end if @@ -324,7 +318,7 @@ contains end if end do - ! Update the rhs variables + ! the rhs variables $:GPU_PARALLEL_LOOP(private='[j,k,l]',collapse=3) do l = 0, p do k = 0, n @@ -345,13 +339,13 @@ contains end subroutine s_acoustic_src_calculations !> This subroutine gives the temporally varying amplitude of the pulse - !! @param sim_time Simulation time - !! @param c Sound speed - !! @param ai Acoustic source index - !! @param term_index Index of the term to be calculated (1: mass source, 2: momentum source) - !! @param frequency_local Frequency at the spatial location for sine and square waves - !! @param gauss_sigma_time_local sigma in time for Gaussian pulse - !! @param source Source term amplitude + !! Simulation time + !! Sound speed + !! Acoustic source index + !! Index of the term to be calculated (1: mass source, 2: momentum source) + !! Frequency at the spatial location for sine and square waves + !! sigma in time for Gaussian pulse + !! Source term amplitude elemental subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source, sum_BB) $:GPU_ROUTINE(parallelism='[seq]') integer, intent(in) :: ai, term_index @@ -362,7 +356,7 @@ contains real(wp) :: omega ! angular frequency real(wp) :: sine_wave ! sine function for square wave real(wp) :: foc_length_factor ! Scale amplitude with radius for spherical support - ! i.e. Spherical support -> 1/r scaling; Cylindrical support -> 1/sqrt(r) [empirical correction: ^-0.5 -> ^-0.85] + ! Spherical support -> 1/r scaling; Cylindrical support -> 1/sqrt(r) [empirical correction: ^-0.5 -> ^-0.85] integer, parameter :: mass_label = 1 if (n == 0) then @@ -401,7 +395,7 @@ contains sine_wave = sin((sim_time - delay(ai))*omega) source = mag(ai)*sign(1._wp, sine_wave) - ! Prevent max-norm differences due to compilers to pass CI + ! max-norm differences due to compilers to pass CI if (abs(sine_wave) < 1.e-2_wp) then source = mag(ai)*sine_wave*1.e2_wp end if @@ -431,7 +425,7 @@ contains @:ALLOCATE(source_spatials(1:num_source)) do ai = 1, num_source - ! First pass: Count the number of points for each source + ! pass: Count the number of points for each source count = 0 do l = 0, p do k = 0, n @@ -444,7 +438,7 @@ contains end do source_spatials_num_points(ai) = count - ! Allocate arrays with the correct size + ! arrays with the correct size @:ALLOCATE(source_spatials(ai)%coord(1:3, 1:count)) @:ALLOCATE(source_spatials(ai)%val(1:count)) @@ -453,7 +447,7 @@ contains @:ACC_SETUP_source_spatials(source_spatials(ai)) - ! Second pass: Store the values + ! pass: Store the values count = 0 ! Reset counter do l = 0, p do k = 0, n @@ -500,14 +494,14 @@ contains end subroutine s_precalculate_acoustic_spatial_sources !> This subroutine gives the spatial support of the acoustic source - !! @param j x-index - !! @param k y-index - !! @param l z-index - !! @param loc Nominal source term location - !! @param ai Acoustic source index - !! @param source Source term amplitude - !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! x-index + !! y-index + !! z-index + !! Nominal source term location + !! Acoustic source index + !! Source term amplitude + !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial(j, k, l, loc, ai, source, angle, xyz_to_r_ratios) integer, intent(in) :: j, k, l, ai real(wp), dimension(3), intent(in) :: loc @@ -515,7 +509,7 @@ contains real(wp) :: sig, r(3) - ! Calculate sig spatial support width + ! sig spatial support width if (n == 0) then sig = dx(j) elseif (p == 0) then @@ -525,7 +519,7 @@ contains end if sig = sig*acoustic_spatial_support_width - ! Calculate displacement from acoustic source location + ! displacement from acoustic source location r(1) = x_cc(j) - loc(1) if (n /= 0) r(2) = y_cc(k) - loc(2) if (p /= 0) r(3) = z_cc(l) - loc(3) @@ -540,10 +534,10 @@ contains end subroutine s_source_spatial !> This subroutine calculates the spatial support for planar acoustic sources in 1D, 2D, and 3D - !! @param ai Acoustic source index - !! @param sig Sigma value for the Gaussian distribution - !! @param r Displacement from source to current point - !! @param source Source term amplitude + !! Acoustic source index + !! Sigma value for the Gaussian distribution + !! Displacement from source to current point + !! Source term amplitude subroutine s_source_spatial_planar(ai, sig, r, source) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -557,7 +551,7 @@ contains source = 1._wp/(sqrt(2._wp*pi)*sig/2._wp)*exp(-0.5_wp*(r(1)/(sig/2._wp))**2._wp) elseif (support(ai) == 2 .or. support(ai) == 3) then ! 2D or 3D - ! If we let unit vector e = (cos(dir), sin(dir)), + ! we let unit vector e = (cos(dir), sin(dir)), dist = r(1)*cos(dir(ai)) + r(2)*sin(dir(ai)) ! dot(r,e) if ((r(1) - dist*cos(dir(ai)))**2._wp + (r(2) - dist*sin(dir(ai)))**2._wp < 0.25_wp*length(ai)**2._wp) then ! |r - dist*e| < length/2 if (support(ai) /= 3 .or. abs(r(3)) < 0.25_wp*height(ai)) then ! additional height constraint for 3D @@ -568,12 +562,12 @@ contains end subroutine s_source_spatial_planar !> This subroutine calculates the spatial support for a single transducer in 2D, 2D axisymmetric, and 3D - !! @param ai Acoustic source index - !! @param sig Sigma value for the Gaussian distribution - !! @param r Displacement from source to current point - !! @param source Source term amplitude - !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! Acoustic source index + !! Sigma value for the Gaussian distribution + !! Displacement from source to current point + !! Source term amplitude + !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial_transducer(ai, sig, r, source, angle, xyz_to_r_ratios) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -613,12 +607,12 @@ contains end subroutine s_source_spatial_transducer !> This subroutine calculates the spatial support for multiple transducers in 2D, 2D axisymmetric, and 3D - !! @param ai Acoustic source index - !! @param sig Sigma value for the Gaussian distribution - !! @param r Displacement from source to current point - !! @param source Source term amplitude - !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! Acoustic source index + !! Sigma value for the Gaussian distribution + !! Displacement from source to current point + !! Source term amplitude + !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial_transducer_array(ai, sig, r, source, angle, xyz_to_r_ratios) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -668,13 +662,13 @@ contains do elem = elem_min, elem_max angle_elem = 2._wp*pi*real(elem, wp)/real(num_elements(ai), wp) + rotate_angle(ai) - ! Point 2 is the elem center + ! 2 is the elem center x2 = f - sqrt(f**2 - half_apert**2) y2 = half_apert*cos(angle_elem) z2 = half_apert*sin(angle_elem) - ! Construct a plane normal to the line from the focal point to the elem center, - ! Point 3 is the intercept of the plane and the line from the focal point to the current location + ! a plane normal to the line from the focal point to the elem center, + ! 3 is the intercept of the plane and the line from the focal point to the current location C = f**2._wp/((r(1) - f)*(x2 - f) + r(2)*y2 + r(3)*z2) ! Constant for intermediate step x3 = C*(r(1) - f) + f y3 = C*r(2) @@ -697,10 +691,10 @@ contains end subroutine s_source_spatial_transducer_array !> This function performs wavelength to frequency conversion - !! @param freq_conv_flag Determines if frequency is given or wavelength - !! @param ai Acoustic source index - !! @param c Speed of sound - !! @return frequency_local Converted frequency + !! Determines if frequency is given or wavelength + !! Acoustic source index + !! Speed of sound + !! Converted frequency elemental function f_frequency_local(freq_conv_flag, ai, c) $:GPU_ROUTINE(parallelism='[seq]') logical, intent(in) :: freq_conv_flag @@ -716,10 +710,10 @@ contains end function f_frequency_local !> This function performs Gaussian sigma dist to time conversion - !! @param gauss_conv_flag Determines if sigma_dist is given or sigma_time - !! @param c Speed of sound - !! @param ai Acoustic source index - !! @return gauss_sigma_time_local Converted Gaussian sigma time + !! Determines if sigma_dist is given or sigma_time + !! Speed of sound + !! Acoustic source index + !! Converted Gaussian sigma time function f_gauss_sigma_time_local(gauss_conv_flag, ai, c) $:GPU_ROUTINE(parallelism='[seq]') logical, intent(in) :: gauss_conv_flag diff --git a/src/simulation/m_body_forces.fpp b/src/simulation/m_body_forces.fpp index cdf35fd366..f53e42113e 100644 --- a/src/simulation/m_body_forces.fpp +++ b/src/simulation/m_body_forces.fpp @@ -10,7 +10,7 @@ module m_body_forces use m_nvtx -! $:USE_GPU_MODULE() +! implicit none @@ -25,23 +25,23 @@ module m_body_forces contains !> This subroutine initializes the module global array of mixture - !! densities in each grid cell + !! each grid cell impure subroutine s_initialize_body_forces_module - ! Simulation is at least 2D + ! is at least 2D if (n > 0) then - ! Simulation is 3D + ! is 3D if (p > 0) then @:ALLOCATE (rhoM(-buff_size:buff_size + m, & -buff_size:buff_size + n, & -buff_size:buff_size + p)) - ! Simulation is 2D + ! is 2D else @:ALLOCATE (rhoM(-buff_size:buff_size + m, & -buff_size:buff_size + n, & 0:0)) end if - ! Simulation is 1D + ! is 1D else @:ALLOCATE (rhoM(-buff_size:buff_size + m, & 0:0, & @@ -66,8 +66,8 @@ contains end subroutine s_compute_acceleration !> This subroutine calculates the mixture density at each cell - !! center - !! param q_cons_vf Conservative variable + !! + !! Conservative variable subroutine s_compute_mixture_density(q_cons_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -90,9 +90,9 @@ contains end subroutine s_compute_mixture_density !> This subroutine calculates the source term due to body forces - !! so the system can be advanced in time - !! @param q_cons_vf Conservative variables - !! @param q_prim_vf Primitive variables + !! system can be advanced in time + !! Conservative variables + !! Primitive variables subroutine s_compute_body_forces_rhs(q_prim_vf, q_cons_vf, rhs_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf diff --git a/src/simulation/m_bubbles.fpp b/src/simulation/m_bubbles.fpp index db29e90cdc..f024294e84 100644 --- a/src/simulation/m_bubbles.fpp +++ b/src/simulation/m_bubbles.fpp @@ -1,6 +1,6 @@ !> -!! @file m_bubbles.f90 -!! @brief Contains module m_bubbles +!! +!! module m_bubbles #:include 'macros.fpp' @@ -27,19 +27,19 @@ module m_bubbles contains !> Function that computes the bubble radial acceleration based on bubble models - !! @param fRho Current density - !! @param fP Current driving pressure - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fpb Internal bubble pressure - !! @param fpbdot Time-derivative of internal bubble pressure - !! @param alf bubble volume fraction - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param f_bub_adv_src Source for bubble volume fraction - !! @param f_divu Divergence of velocity - !! @param fCson Speed of sound from fP (EL) + !! Current density + !! Current driving pressure + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Internal bubble pressure + !! Time-derivative of internal bubble pressure + !! bubble volume fraction + !! Tait EOS parameter + !! Tait EOS parameter + !! Source for bubble volume fraction + !! Divergence of velocity + !! Speed of sound from fP (EL) elemental function f_rddot(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, fntait, fBtait, f_bub_adv_src, f_divu, fCson) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf @@ -50,7 +50,7 @@ contains real(wp) :: f_rddot if (bubble_model == 1) then - ! Gilmore bubbles + ! bubbles fCpinf = fP - Eu fCpbw = f_cpbw(fR0, fR, fV, fpb) fH = f_H(fCpbw, fCpinf, fntait, fBtait) @@ -59,7 +59,7 @@ contains fHdot = f_Hdot(fCpbw, fCpinf, fCpinf_dot, fntait, fBtait, fR, fV, fR0, fpbdot) f_rddot = f_rddot_G(fCpbw, fR, fV, fH, fHdot, c_gas, fntait, fBtait) else if (bubble_model == 2) then - ! Keller-Miksis bubbles + ! bubbles fCpinf = fP fCpbw = f_cpbw_KM(fR0, fR, fV, fpb) if (bubbles_euler) then @@ -69,21 +69,21 @@ contains end if f_rddot = f_rddot_KM(fpbdot, fCpinf, fCpbw, fRho, fR, fV, fR0, c_liquid) else if (bubble_model == 3) then - ! Rayleigh-Plesset bubbles + ! bubbles fCpbw = f_cpbw_KM(fR0, fR, fV, fpb) f_rddot = f_rddot_RP(fP, fRho, fR, fV, fCpbw) else - ! Default: No bubble dynamics + ! No bubble dynamics f_rddot = 0._wp end if end function f_rddot !> Function that computes that bubble wall pressure for Gilmore bubbles - !! @param fR0 Equilibrium bubble radius - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fpb Internal bubble pressure + !! Equilibrium bubble radius + !! Current bubble radius + !! Current bubble velocity + !! Internal bubble pressure elemental function f_cpbw(fR0, fR, fV, fpb) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR0, fR, fV, fpb @@ -99,10 +99,10 @@ contains end function f_cpbw !> Function that computes the bubble enthalpy - !! @param fCpbw Bubble wall pressure - !! @param fCpinf Driving bubble pressure - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter + !! Bubble wall pressure + !! Driving bubble pressure + !! Tait EOS parameter + !! Tait EOS parameter elemental function f_H(fCpbw, fCpinf, fntait, fBtait) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fCpinf, fntait, fBtait @@ -119,10 +119,10 @@ contains end function f_H !> Function that computes the sound speed for the bubble - !! @param fCpinf Driving bubble pressure - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param fH Bubble enthalpy + !! Driving bubble pressure + !! Tait EOS parameter + !! Tait EOS parameter + !! Bubble enthalpy elemental function f_cgas(fCpinf, fntait, fBtait, fH) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpinf, fntait, fBtait, fH @@ -130,7 +130,7 @@ contains real(wp) :: tmp real(wp) :: f_cgas - ! get sound speed for Gilmore equations "C" -> c_gas + ! sound speed for Gilmore equations "C" -> c_gas tmp = (fCpinf/(1._wp + fBtait) + 1._wp)**((fntait - 1._wp)/fntait) tmp = fntait*(1._wp + fBtait)*tmp @@ -139,13 +139,13 @@ contains end function f_cgas !> Function that computes the time derivative of the driving pressure - !! @param fRho Local liquid density - !! @param fP Local pressure - !! @param falf Local void fraction - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param advsrc Advection equation source term - !! @param divu Divergence of velocity + !! Local liquid density + !! Local pressure + !! Local void fraction + !! Tait EOS parameter + !! Tait EOS parameter + !! Advection equation source term + !! Divergence of velocity elemental function f_cpinfdot(fRho, fP, falf, fntait, fBtait, advsrc, divu) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fRho, fP, falf, fntait, fBtait, advsrc, divu @@ -153,29 +153,29 @@ contains real(wp) :: c2_liquid real(wp) :: f_cpinfdot - ! get sound speed squared for liquid (only needed for pbdot) - ! c_l^2 = gam (p+B) / (rho*(1-alf)) + ! sound speed squared for liquid (only needed for pbdot) + ! = gam (p+B) / (rho*(1-alf)) if (mpp_lim) then c2_liquid = fntait*(fP + fBtait)/fRho else c2_liquid = fntait*(fP + fBtait)/(fRho*(1._wp - falf)) end if - ! \dot{Cp_inf} = rho sound^2 (alf_src - divu) + ! = rho sound^2 (alf_src - divu) f_cpinfdot = fRho*c2_liquid*(advsrc - divu) end function f_cpinfdot !> Function that computes the time derivative of the enthalpy - !! @param fCpbw Bubble wall pressure - !! @param fCpinf Driving bubble pressure - !! @param fCpinf_dot Time derivative of the driving pressure - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fpbdot Time derivative of the internal bubble pressure + !! Bubble wall pressure + !! Driving bubble pressure + !! Time derivative of the driving pressure + !! Tait EOS parameter + !! Tait EOS parameter + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Time derivative of the internal bubble pressure elemental function f_Hdot(fCpbw, fCpinf, fCpinf_dot, fntait, fBtait, fR, fV, fR0, fpbdot) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fCpinf, fCpinf_dot, fntait, fBtait @@ -196,45 +196,45 @@ contains (fCpbw/(1._wp + fBtait) + 1._wp)**(-1._wp/fntait)*(tmp1 + tmp2) & - (fCpinf/(1._wp + fBtait) + 1._wp)**(-1._wp/fntait)*fCpinf_dot - ! Hdot = (Cpbw/(1+B) + 1)^(-1/n_tait)*(-3 gam)*(R0/R)^(3gam) V/R + ! = (Cpbw/(1+B) + 1)^(-1/n_tait)*(-3 gam)*(R0/R)^(3gam) V/R !f_Hdot = ((fCpbw/(1._wp+fBtait)+1._wp)**(-1._wp/fntait))*(-3._wp)*gam * & - ! ( (fR0/fR)**(3._wp*gam ))*(fV/fR) + ! (fR0/fR)**(3._wp*gam ))*(fV/fR) - ! Hdot = Hdot - (Cpinf/(1+B) + 1)^(-1/n_tait) Cpinfdot + ! = Hdot - (Cpinf/(1+B) + 1)^(-1/n_tait) Cpinfdot !f_Hdot = f_Hdot - ((fCpinf/(1._wp+fBtait)+1._wp)**(-1._wp/fntait))*fCpinf_dot end function f_Hdot !> Function that computes the bubble radial acceleration for Rayleigh-Plesset bubbles - !! @param fCp Driving pressure - !! @param fRho Current density - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fCpbw Boundary wall pressure + !! Driving pressure + !! Current density + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Boundary wall pressure elemental function f_rddot_RP(fCp, fRho, fR, fV, fCpbw) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCp, fRho, fR, fV, fCpbw real(wp) :: f_rddot_RP - !! rddot = (1/r) ( -3/2 rdot^2 + ((r0/r)^3\gamma - Cp)/rho ) - !! rddot = (1/r) ( -3/2 rdot^2 + (tmp1 - Cp)/rho ) - !! rddot = (1/r) ( tmp2 ) + !! (1/r) ( -3/2 rdot^2 + ((r0/r)^3\gamma - Cp)/rho ) + !! (1/r) ( -3/2 rdot^2 + (tmp1 - Cp)/rho ) + !! (1/r) ( tmp2 ) f_rddot_RP = (-1.5_wp*(fV**2._wp) + (fCpbw - fCp)/fRho)/fR end function f_rddot_RP !> Function that computes the bubble radial acceleration - !! @param fCpbw Bubble wall pressure - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fH Current enthalpy - !! @param fHdot Current time derivative of the enthalpy - !! @param fcgas Current gas sound speed - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter + !! Bubble wall pressure + !! Current bubble radius + !! Current bubble velocity + !! Current enthalpy + !! Current time derivative of the enthalpy + !! Current gas sound speed + !! Tait EOS parameter + !! Tait EOS parameter elemental function f_rddot_G(fCpbw, fR, fV, fH, fHdot, fcgas, fntait, fBtait) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fR, fV, fH, fHdot @@ -254,10 +254,10 @@ contains end function f_rddot_G !> Function that computes the bubble wall pressure for Keller--Miksis bubbles - !! @param fR0 Equilibrium bubble radius - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fpb Internal bubble pressure + !! Equilibrium bubble radius + !! Current bubble radius + !! Current bubble velocity + !! Internal bubble pressure elemental function f_cpbw_KM(fR0, fR, fV, fpb) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR0, fR, fV, fpb @@ -277,14 +277,14 @@ contains end function f_cpbw_KM !> Function that computes the bubble radial acceleration for Keller--Miksis bubbles - !! @param fpbdot Time-derivative of internal bubble pressure - !! @param fCp Driving pressure - !! @param fCpbw Bubble wall pressure - !! @param fRho Current density - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fC Current sound speed + !! Time-derivative of internal bubble pressure + !! Driving pressure + !! Bubble wall pressure + !! Current density + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Current sound speed elemental function f_rddot_KM(fpbdot, fCp, fCpbw, fRho, fR, fV, fR0, fC) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fpbdot, fCp, fCpbw @@ -317,38 +317,41 @@ contains end function f_rddot_KM !> Subroutine that computes bubble wall properties for vapor bubbles - !! @param pb Internal bubble pressure - !! @param iR0 Current bubble size index + !! @param[in] pb_in Internal bubble pressure. + !! @param[in] iR0 Current bubble size index. + !! @param[out] chi_vw_out Bubble wall vapor mass fraction. + !! @param[out] k_mw_out Thermal conductivity of gas mixture at bubble wall. + !! @param[out] rho_mw_out Density of mixture at bubble wall. elemental subroutine s_bwproperty(pb_in, iR0, chi_vw_out, k_mw_out, rho_mw_out) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: pb_in integer, intent(in) :: iR0 - real(wp), intent(out) :: chi_vw_out !< Bubble wall properties (Ando 2010) - real(wp), intent(out) :: k_mw_out !< Bubble wall properties (Ando 2010) - real(wp), intent(out) :: rho_mw_out !< Bubble wall properties (Ando 2010) + real(wp), intent(out) :: chi_vw_out + real(wp), intent(out) :: k_mw_out + real(wp), intent(out) :: rho_mw_out real(wp) :: x_vw - ! mass fraction of vapor + ! fraction of vapor chi_vw_out = 1._wp/(1._wp + R_v/R_g*(pb_in/pv - 1._wp)) - ! mole fraction of vapor & thermal conductivity of gas mixture + ! fraction of vapor & thermal conductivity of gas mixture x_vw = M_g*chi_vw_out/(M_v + (M_g - M_v)*chi_vw_out) k_mw_out = x_vw*k_v(iR0)/(x_vw + (1._wp - x_vw)*phi_vg) & + (1._wp - x_vw)*k_g(iR0)/(x_vw*phi_gv + 1._wp - x_vw) - ! gas mixture density + ! mixture density rho_mw_out = pv/(chi_vw_out*R_v*Tw) end subroutine s_bwproperty !> Function that computes the vapour flux - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fpb - !! @param fmass_v Current mass of vapour - !! @param iR0 Bubble size index (EE) or bubble identifier (EL) - !! @param fmass_g Current gas mass (EL) - !! @param fbeta_c Mass transfer coefficient (EL) - !! @param fR_m Mixture gas constant (EL) - !! @param fgamma_m Mixture gamma (EL) + !! Current bubble radius + !! Current bubble velocity + !! + !! Current mass of vapour + !! Bubble size index (EE) or bubble identifier (EL) + !! Current gas mass (EL) + !! Mass transfer coefficient (EL) + !! Mixture gas constant (EL) + !! Mixture gamma (EL) elemental subroutine s_vflux(fR, fV, fpb, fmass_v, iR0, vflux, fmass_g, fbeta_c, fR_m, fgamma_m) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR @@ -366,9 +369,9 @@ contains real(wp) :: conc_v if (thermal == 3) then !transfer - ! constant transfer model + ! transfer model if (bubbles_lagrange) then - ! Mixture properties (gas+vapor) in the bubble + ! properties (gas+vapor) in the bubble conc_v = fmass_v/(fmass_v + fmass_g) if (lag_params%massTransfer_model) then conc_v = 1._wp/(1._wp + (R_v/R_g)*(fpb/pv - 1._wp)) @@ -376,7 +379,7 @@ contains fR_m = (fmass_g*R_g + fmass_v*R_v) fgamma_m = conc_v*gam_v + (1._wp - conc_v)*gam_g - ! Vapor flux + ! flux chi_bar = fmass_v/(fmass_v + fmass_g) grad_chi = (chi_bar - conc_v) rho_mw_lag = (fmass_g + fmass_v)/(4._wp/3._wp*pi*fR**3._wp) @@ -390,23 +393,23 @@ contains vflux = rho_mw*grad_chi/Pe_c/(1._wp - chi_vw)/fR end if else - ! polytropic + ! vflux = pv*fV/(R_v*Tw) end if end subroutine s_vflux !> Function that computes the time derivative of - !! the internal bubble pressure - !! @param fvflux Vapour flux - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fpb Current internal bubble pressure - !! @param fmass_v Current mass of vapour - !! @param iR0 Bubble size index (EE) or bubble identifier (EL) - !! @param fbeta_t Mass transfer coefficient (EL) - !! @param fR_m Mixture gas constant (EL) - !! @param fgamma_m Mixture gamma (EL) + !! bubble pressure + !! Vapour flux + !! Current bubble radius + !! Current bubble velocity + !! Current internal bubble pressure + !! Current mass of vapour + !! Bubble size index (EE) or bubble identifier (EL) + !! Mass transfer coefficient (EL) + !! Mixture gas constant (EL) + !! Mixture gamma (EL) elemental function f_bpres_dot(fvflux, fR, fV, fpb, fmass_v, iR0, fbeta_t, fR_m, fgamma_m) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fvflux @@ -442,27 +445,27 @@ contains end function f_bpres_dot !> Adaptive time stepping routine for subgrid bubbles - !! (See Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary - !! Differential Equations I, Chapter II.4) - !! @param fRho Current density - !! @param fP Current driving pressure - !! @param fR Current bubble radius - !! @param fV Current bubble radial velocity - !! @param fR0 Equilibrium bubble radius - !! @param fpb Internal bubble pressure - !! @param fpbdot Time-derivative of internal bubble pressure - !! @param alf bubble volume fraction - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param f_bub_adv_src Source for bubble volume fraction - !! @param f_divu Divergence of velocity - !! @param bub_id Bubble identifier (EL) - !! @param fmass_v Current mass of vapour (EL) - !! @param fmass_g Current mass of gas (EL) - !! @param fbeta_c Mass transfer coefficient (EL) - !! @param fbeta_t Heat transfer coefficient (EL) - !! @param fCson Speed of sound (EL) - !! @param adap_dt_stop Fail-safe exit if max iteration count reached + !! E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary + !! I, Chapter II.4) + !! Current density + !! Current driving pressure + !! Current bubble radius + !! Current bubble radial velocity + !! Equilibrium bubble radius + !! Internal bubble pressure + !! Time-derivative of internal bubble pressure + !! bubble volume fraction + !! Tait EOS parameter + !! Tait EOS parameter + !! Source for bubble volume fraction + !! Divergence of velocity + !! Bubble identifier (EL) + !! Current mass of vapour (EL) + !! Current mass of gas (EL) + !! Mass transfer coefficient (EL) + !! Heat transfer coefficient (EL) + !! Speed of sound (EL) + !! Fail-safe exit if max iteration count reached subroutine s_advance_step(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & bub_id, fmass_v, fmass_g, fbeta_c, & @@ -488,7 +491,7 @@ contains call s_initial_substep_h(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, fCson, h0) h = h0 - ! Advancing one step + ! one step t_new = 0._wp iter_count = 0 adap_dt_stop = 0 @@ -498,12 +501,12 @@ contains h = 0.5_wp*dt - t_new end if - ! Advancing one sub-step + ! one sub-step do while (iter_count < adap_dt_max_iters) iter_count = iter_count + 1 - ! Advance one sub-step + ! one sub-step call s_advance_substep(err(1), & fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & @@ -515,7 +518,7 @@ contains cycle end if - ! Advance one sub-step by advancing two half steps + ! one sub-step by advancing two half steps call s_advance_substep(err(2), & fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & @@ -545,34 +548,34 @@ contains err(5) = abs((myV_tmp1(4) - myV_tmp2(4))/myV_tmp1(4)) if (abs(myV_tmp1(4)) < verysmall) err(5) = 0._wp - ! Determine acceptance/rejection and update step size - ! Rule 1: err1, err2, err3 < tol - ! Rule 2: myR_tmp1(4) > 0._wp - ! Rule 3: abs((myR_tmp1(4) - myR_tmp2(4))/fR) < tol - ! Rule 4: abs((myV_tmp1(4) - myV_tmp2(4))/fV) < tol + ! acceptance/rejection and update step size + ! 1: err1, err2, err3 < tol + ! 2: myR_tmp1(4) > 0._wp + ! 3: abs((myR_tmp1(4) - myR_tmp2(4))/fR) < tol + ! 4: abs((myV_tmp1(4) - myV_tmp2(4))/fV) < tol if ((err(1) <= adap_dt_tol) .and. (err(2) <= adap_dt_tol) .and. & (err(3) <= adap_dt_tol) .and. (err(4) <= adap_dt_tol) .and. & (err(5) <= adap_dt_tol) .and. myR_tmp1(4) > 0._wp) then - ! Accepted. Finalize the sub-step + ! Finalize the sub-step t_new = t_new + h - ! Update R and V + ! R and V fR = myR_tmp1(4) fV = myV_tmp1(4) if (bubbles_lagrange) then - ! Update pb and mass_v + ! pb and mass_v fpb = myPb_tmp1(4) fmass_v = myMv_tmp1(4) end if - ! Update step size for the next sub-step + ! step size for the next sub-step h = h*min(2._wp, max(0.5_wp, (adap_dt_tol/err(1))**(1._wp/3._wp))) exit else - ! Rejected. Update step size for the next try on sub-step + ! Update step size for the next try on sub-step if (err(2) <= adap_dt_tol) then h = 0.5_wp*h else @@ -581,7 +584,7 @@ contains end if end do - ! Exit the loop if the final time reached dt + ! the loop if the final time reached dt if (f_approx_equal(t_new, 0.5_wp*dt) .or. iter_count >= adap_dt_max_iters) exit end do @@ -591,22 +594,22 @@ contains end subroutine s_advance_step !> Choose the initial time step size for the adaptive time stepping routine - !! (See Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary - !! Differential Equations I, Chapter II.4) - !! @param fRho Current density - !! @param fP Current driving pressure - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fpb Internal bubble pressure - !! @param fpbdot Time-derivative of internal bubble pressure - !! @param alf bubble volume fraction - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param f_bub_adv_src Source for bubble volume fraction - !! @param f_divu Divergence of velocity - !! @param fCson Speed of sound (EL) - !! @param h Time step size + !! E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary + !! I, Chapter II.4) + !! Current density + !! Current driving pressure + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Internal bubble pressure + !! Time-derivative of internal bubble pressure + !! bubble volume fraction + !! Tait EOS parameter + !! Tait EOS parameter + !! Source for bubble volume fraction + !! Divergence of velocity + !! Speed of sound (EL) + !! Time step size subroutine s_initial_substep_h(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & fCson, h) @@ -622,8 +625,8 @@ contains real(wp), dimension(3) :: d_norms !< norms (d_0, d_1, d_2) real(wp), dimension(2) :: myR_tmp, myV_tmp, myA_tmp !< Bubble radius, radial velocity, and radial acceleration - ! Determine the starting time step - ! Evaluate f(x0,y0) + ! the starting time step + ! f(x0,y0) myR_tmp(1) = fR myV_tmp(1) = fV myA_tmp(1) = f_rddot(fRho, fP, myR_tmp(1), myV_tmp(1), fR0, & @@ -631,7 +634,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Compute d_0 = ||y0|| and d_1 = ||f(x0,y0)|| + ! d_0 = ||y0|| and d_1 = ||f(x0,y0)|| d_norms(1) = sqrt((myR_tmp(1)**2._wp + myV_tmp(1)**2._wp)/2._wp) d_norms(2) = sqrt((myV_tmp(1)**2._wp + myA_tmp(1)**2._wp)/2._wp) if (d_norms(1) < threshold_first_guess .or. d_norms(2) < threshold_first_guess) then @@ -640,7 +643,7 @@ contains h_size(1) = scale_guess*(d_norms(1)/d_norms(2)) end if - ! Evaluate f(x0+h0,y0+h0*f(x0,y0)) + ! f(x0+h0,y0+h0*f(x0,y0)) myR_tmp(2) = myR_tmp(1) + h_size(1)*myV_tmp(1) myV_tmp(2) = myV_tmp(1) + h_size(1)*myA_tmp(1) myA_tmp(2) = f_rddot(fRho, fP, myR_tmp(2), myV_tmp(2), fR0, & @@ -648,11 +651,11 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Compute d_2 = ||f(x0+h0,y0+h0*f(x0,y0))-f(x0,y0)||/h0 + ! d_2 = ||f(x0+h0,y0+h0*f(x0,y0))-f(x0,y0)||/h0 d_norms(3) = sqrt(((myV_tmp(2) - myV_tmp(1))**2._wp + (myA_tmp(2) - myA_tmp(1))**2._wp)/2._wp)/h_size(1) - ! Set h1 = (0.01/max(d_1,d_2))^{1/(p+1)} - ! if max(d_1,d_2) < 1.e-15_wp, h_size(2) = max(1.e-6_wp, h0*1.e-3_wp) + ! h1 = (0.01/max(d_1,d_2))^{1/(p+1)} + ! max(d_1,d_2) < 1.e-15_wp, h_size(2) = max(1.e-6_wp, h0*1.e-3_wp) if (max(d_norms(2), d_norms(3)) < threshold_second_guess) then h_size(2) = max(small_guess, h_size(1)*scale_first_guess) else @@ -664,31 +667,31 @@ contains end subroutine s_initial_substep_h !> Integrate bubble variables over the given time step size, h, using a - !! third-order accurate embedded Runge–Kutta scheme. - !! @param err Estimated error - !! @param fRho Current density - !! @param fP Current driving pressure - !! @param fR Current bubble radius - !! @param fV Current bubble velocity - !! @param fR0 Equilibrium bubble radius - !! @param fpb Internal bubble pressure - !! @param fpbdot Time-derivative of internal bubble pressure - !! @param alf bubble volume fraction - !! @param fntait Tait EOS parameter - !! @param fBtait Tait EOS parameter - !! @param f_bub_adv_src Source for bubble volume fraction - !! @param f_divu Divergence of velocity - !! @param bub_id Bubble identifier (EL) - !! @param fmass_v Current mass of vapour (EL) - !! @param fmass_g Current mass of gas (EL) - !! @param fbeta_c Mass transfer coefficient (EL) - !! @param fbeta_t Heat transfer coefficient (EL) - !! @param fCson Speed of sound (EL) - !! @param h Time step size - !! @param myR_tmp Bubble radius at each stage - !! @param myV_tmp Bubble radial velocity at each stage - !! @param myPb_tmp Internal bubble pressure at each stage (EL) - !! @param myMv_tmp Mass of vapor in the bubble at each stage (EL) + !! embedded Runge–Kutta scheme. + !! Estimated error + !! Current density + !! Current driving pressure + !! Current bubble radius + !! Current bubble velocity + !! Equilibrium bubble radius + !! Internal bubble pressure + !! Time-derivative of internal bubble pressure + !! bubble volume fraction + !! Tait EOS parameter + !! Tait EOS parameter + !! Source for bubble volume fraction + !! Divergence of velocity + !! Bubble identifier (EL) + !! Current mass of vapour (EL) + !! Current mass of gas (EL) + !! Mass transfer coefficient (EL) + !! Heat transfer coefficient (EL) + !! Speed of sound (EL) + !! Time step size + !! Bubble radius at each stage + !! Bubble radial velocity at each stage + !! Internal bubble pressure at each stage (EL) + !! Mass of vapor in the bubble at each stage (EL) subroutine s_advance_substep(err, fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & bub_id, fmass_v, fmass_g, fbeta_c, & @@ -710,7 +713,7 @@ contains myPb_tmp(1:4) = fpb mydPbdt_tmp(1:4) = fpbdot - ! Stage 0 + ! 0 myR_tmp(1) = fR myV_tmp(1) = fV if (bubbles_lagrange) then @@ -724,7 +727,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Stage 1 + ! 1 myR_tmp(2) = myR_tmp(1) + h*myV_tmp(1) if (myR_tmp(2) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -741,7 +744,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Stage 2 + ! 2 myR_tmp(3) = myR_tmp(1) + (h/4._wp)*(myV_tmp(1) + myV_tmp(2)) if (myR_tmp(3) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -758,7 +761,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Stage 3 + ! 3 myR_tmp(4) = myR_tmp(1) + (h/6._wp)*(myV_tmp(1) + myV_tmp(2) + 4._wp*myV_tmp(3)) if (myR_tmp(4) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -775,12 +778,12 @@ contains f_bub_adv_src, f_divu, & fCson) - ! Estimate error + ! error err_R = (-5._wp*h/24._wp)*(myV_tmp(2) + myV_tmp(3) - 2._wp*myV_tmp(4)) & /max(abs(myR_tmp(1)), abs(myR_tmp(4))) err_V = (-5._wp*h/24._wp)*(myA_tmp(2) + myA_tmp(3) - 2._wp*myA_tmp(4)) & /max(abs(myV_tmp(1)), abs(myV_tmp(4))) - ! Error correction for non-oscillating bubbles + ! correction for non-oscillating bubbles if (max(abs(myV_tmp(1)), abs(myV_tmp(4))) < 1.e-12_wp) then err_V = 0._wp end if @@ -793,16 +796,16 @@ contains end subroutine s_advance_substep !> Changes of pressure and vapor mass in the lagrange bubbles. - !! @param bub_id Bubble identifier - !! @param fmass_g Current mass of gas - !! @param fbeta_c Mass transfer coefficient - !! @param fbeta_t Heat transfer coefficient - !! @param fR_tmp Bubble radius - !! @param fV_tmp Bubble radial velocity - !! @param fPb_tmp Internal bubble pressure - !! @param fMv_tmp Mass of vapor in the bubble - !! @param fdPbdt_tmp Rate of change of the internal bubble pressure - !! @param fdMvdt_tmp Rate of change of the mass of vapor in the bubble + !! Bubble identifier + !! Current mass of gas + !! Mass transfer coefficient + !! Heat transfer coefficient + !! Bubble radius + !! Bubble radial velocity + !! Internal bubble pressure + !! Mass of vapor in the bubble + !! Rate of change of the internal bubble pressure + !! Rate of change of the mass of vapor in the bubble elemental subroutine s_advance_EL(fR_tmp, fV_tmp, fPb_tmp, fMv_tmp, bub_id, & fmass_g, fbeta_c, fbeta_t, fdPbdt_tmp, advance_EL) $:GPU_ROUTINE(parallelism='[seq]') diff --git a/src/simulation/m_bubbles_EE.fpp b/src/simulation/m_bubbles_EE.fpp index dfc36f2a32..0ea63842ce 100644 --- a/src/simulation/m_bubbles_EE.fpp +++ b/src/simulation/m_bubbles_EE.fpp @@ -1,6 +1,6 @@ !> -!! @file m_bubbles_EE.f90 -!! @brief Contains module m_bubbles_EE +!! +!! module m_bubbles_EE #:include 'macros.fpp' @@ -68,8 +68,8 @@ contains end subroutine s_initialize_bubbles_EE_module - ! Compute the bubble volume fraction alpha from the bubble number density n - !! @param q_cons_vf is the conservative variable + ! the bubble volume fraction alpha from the bubble number density n + !! is the conservative variable subroutine s_comp_alpha_from_n(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf real(wp) :: nR3bar @@ -92,11 +92,15 @@ contains end subroutine s_comp_alpha_from_n + !> Computes one directional component of velocity divergence for bubble dynamics. + !! @param[in] idir Spatial direction (1=x, 2=y, 3=z). + !! @param[in] q_prim_vf Primitive variables containing velocity components. + !! @param[inout] divu_in Velocity divergence field, accumulated across directions. subroutine s_compute_bubbles_EE_rhs(idir, q_prim_vf, divu_in) integer, intent(in) :: idir type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf - type(scalar_field), intent(inout) :: divu_in !< matrix for div(u) + type(scalar_field), intent(inout) :: divu_in integer :: j, k, l @@ -153,14 +157,16 @@ contains end subroutine s_compute_bubbles_EE_rhs !> The purpose of this procedure is to compute the source terms - !! that are needed for the bubble modeling - !! @param q_prim_vf Primitive variables - !! @param q_cons_vf Conservative variables + !! needed for the bubble modeling. + !! @param[inout] q_cons_vf Conservative variables. + !! @param[in] q_prim_vf Primitive variables. + !! @param[inout] rhs_vf Right-hand side source terms. + !! @param[in] divu_in Velocity divergence field. impure subroutine s_compute_bubble_EE_source(q_cons_vf, q_prim_vf, rhs_vf, divu_in) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf - type(scalar_field), intent(in) :: divu_in !< matrix for div(u) + type(scalar_field), intent(in) :: divu_in real(wp) :: rddot real(wp) :: pb_local, mv_local, vflux, pbdot @@ -293,7 +299,7 @@ contains pb_local = 0._wp; mv_local = 0._wp; vflux = 0._wp; pbdot = 0._wp end if - ! Adaptive time stepping + ! time stepping if (adap_dt) then adap_dt_stop = 0 diff --git a/src/simulation/m_bubbles_EL.fpp b/src/simulation/m_bubbles_EL.fpp index ec84e95c65..6c1223ae45 100644 --- a/src/simulation/m_bubbles_EL.fpp +++ b/src/simulation/m_bubbles_EL.fpp @@ -1,6 +1,6 @@ !> -!! @file m_bubbles_EL.fpp -!! @brief Contains module m_bubbles_EL +!! +!! module m_bubbles_EL #:include 'macros.fpp' @@ -78,22 +78,22 @@ module m_bubbles_EL contains !> Initializes the lagrangian subgrid bubble solver - !! @param q_cons_vf Initial conservative variables + !! Initial conservative variables impure subroutine s_initialize_bubbles_EL_module(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer :: nBubs_glb, i - ! Setting number of time-stages for selected time-stepping scheme + ! number of time-stages for selected time-stepping scheme lag_num_ts = time_stepper - ! Allocate space for the Eulerian fields needed to map the effect of the bubbles + ! space for the Eulerian fields needed to map the effect of the bubbles if (lag_params%solver_approach == 1) then - ! One-way coupling + ! coupling q_beta_idx = 3 elseif (lag_params%solver_approach == 2) then - ! Two-way coupling + ! coupling q_beta_idx = 4 if (p == 0) then !Subgrid noise model for 2D approximation @@ -117,7 +117,7 @@ contains @:ACC_SETUP_SFs(q_beta(i)) end do - ! Allocating space for lagrangian variables + ! space for lagrangian variables nBubs_glb = lag_params%nBubs_glb @:ALLOCATE(lag_id(1:nBubs_glb, 1:2)) @@ -145,13 +145,13 @@ contains if (adap_dt .and. f_is_default(adap_dt_tol)) adap_dt_tol = dflt_adap_dt_tol - ! Starting bubbles + ! bubbles call s_read_input_bubbles(q_cons_vf) end subroutine s_initialize_bubbles_EL_module !> The purpose of this procedure is to obtain the initial bubbles' information - !! @param q_cons_vf Conservative variables + !! Conservative variables impure subroutine s_read_input_bubbles(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -164,11 +164,11 @@ contains character(LEN=path_len + 2*name_len) :: path_D_dir !< - ! Initialize number of particles + ! number of particles bub_id = 0 id = 0 - ! Read the input lag_bubble file or restart point + ! the input lag_bubble file or restart point if (cfl_dt) then save_count = n_start qtime = n_start*t_save @@ -230,7 +230,7 @@ contains if (lag_params%write_bubbles) call s_write_lag_particles(qtime) if (save_count == 0) then - ! Create ./D directory + ! ./D directory write (path_D_dir, '(A,I0,A,I0)') trim(case_dir)//'/D' call my_inquire(path_D_dir, file_exist) if (.not. file_exist) call s_create_directory(trim(path_D_dir)) @@ -241,9 +241,9 @@ contains end subroutine s_read_input_bubbles !> The purpose of this procedure is to obtain the information of the bubbles when starting fresh - !! @param inputBubble Bubble information - !! @param q_cons_vf Conservative variables - !! @param bub_id Local id of the bubble + !! Bubble information + !! Conservative variables + !! Local id of the bubble impure subroutine s_add_bubbles(inputBubble, q_cons_vf, bub_id) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -283,7 +283,7 @@ contains cell = -buff_size call s_locate_cell(mtn_pos(bub_id, 1:3, 1), cell, mtn_s(bub_id, 1:3, 1)) - ! Check if the bubble is located in the ghost cell of a symmetric, or wall boundary + ! if the bubble is located in the ghost cell of a symmetric, or wall boundary if ((any(bc_x%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(1) < 0) .or. & (any(bc_x%end == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(1) > m) .or. & (any(bc_y%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(2) < 0) .or. & @@ -308,7 +308,7 @@ contains if (pliq < 0) print *, "Negative pressure", proc_rank, & q_cons_vf(E_idx)%sf(cell(1), cell(2), cell(3)), pi_inf, gamma, pliq, cell, dynP - ! Initial particle pressure + ! particle pressure gas_p(bub_id, 1) = pliq + 2._wp*(1._wp/Web)/bub_R0(bub_id) if (.not. f_approx_equal((1._wp/Web), 0._wp)) then pcrit = pv - 4._wp*(1._wp/Web)/(3._wp*sqrt(3._wp*gas_p(bub_id, 1)*bub_R0(bub_id)**3._wp/(2._wp*(1._wp/Web)))) @@ -317,7 +317,7 @@ contains pcrit = 0._wp end if - ! Initial particle mass + ! particle mass volparticle = 4._wp/3._wp*pi*bub_R0(bub_id)**3._wp ! volume gas_mv(bub_id, 1) = pv*volparticle*(1._wp/(R_v*Tw))*(massflag) ! vapermass gas_mg(bub_id) = (gas_p(bub_id, 1) - pv*(massflag))*volparticle*(1._wp/(R_g*Tw)) ! gasmass @@ -326,7 +326,7 @@ contains end if totalmass = gas_mg(bub_id) + gas_mv(bub_id, 1) ! totalmass - ! Bubble natural frequency + ! natural frequency concvap = gas_mv(bub_id, 1)/(gas_mv(bub_id, 1) + gas_mg(bub_id)) omegaN_local = (3._wp*(gas_p(bub_id, 1) - pv*(massflag)) + 4._wp*(1._wp/Web)/bub_R0(bub_id))/rhol if (pv*(massflag) > gas_p(bub_id, 1)) then @@ -337,7 +337,7 @@ contains cpparticle = concvap*cp_v + (1._wp - concvap)*cp_g kparticle = concvap*k_vl + (1._wp - concvap)*k_gl - ! Mass and heat transfer coefficients (based on Preston 2007) + ! and heat transfer coefficients (based on Preston 2007) PeT = totalmass/volparticle*cpparticle*bub_R0(bub_id)**2._wp*omegaN_local/kparticle call s_transcoeff(1._wp, PeT, Re_trans, Im_trans) gas_betaT(bub_id) = Re_trans*(heatflag)*kparticle @@ -353,8 +353,8 @@ contains end subroutine s_add_bubbles !> The purpose of this procedure is to obtain the information of the bubbles from a restart point. - !! @param bub_id Local ID of the particle - !! @param save_count File identifier + !! Local ID of the particle + !! File identifier impure subroutine s_restart_bubbles(bub_id, save_count) integer, intent(inout) :: bub_id, save_count @@ -380,11 +380,11 @@ contains real(wp), dimension(1:1, 1:lag_io_vars) :: dummy dummy = 0._wp - ! Construct file path + ! file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', save_count, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! Check if file exists + ! if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -415,7 +415,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip to processor counts position + ! to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -426,7 +426,7 @@ contains call MPI_BCAST(proc_bubble_counts, file_num_procs, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - ! Set time variables from file + ! time variables from file mytime = file_time dt = file_dt @@ -455,7 +455,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip extended header + ! extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -499,7 +499,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! Skip extended header + ! extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -521,11 +521,11 @@ contains end subroutine s_restart_bubbles !> Contains the bubble dynamics subroutines. - !! @param q_cons_vf Conservative variables - !! @param q_prim_vf Primitive variables - !! @param rhs_vf Calculated change of conservative variables - !! @param t_step Current time step - !! @param stage Current stage in the time-stepper algorithm + !! Conservative variables + !! Primitive variables + !! Calculated change of conservative variables + !! Current time step + !! Current stage in the time-stepper algorithm subroutine s_compute_bubble_EL_dynamics(q_prim_vf, stage) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -552,9 +552,9 @@ contains call nvtxStartRange("LAGRANGE-BUBBLE-DYNAMICS") - ! Subgrid p_inf model based on Maeda and Colonius (2018). + ! p_inf model based on Maeda and Colonius (2018). if (lag_params%pressure_corrector) then - ! Calculate velocity potentials (valid for one bubble per cell) + ! velocity potentials (valid for one bubble per cell) $:GPU_PARALLEL_LOOP(private='[k,cell,paux,preterm1,term2,Romega,myR0,myR,myV,myPb,pint,term1_fac]') do k = 1, nBubs call s_get_pinf(k, q_prim_vf, 2, paux, cell, preterm1, term2, Romega) @@ -566,8 +566,8 @@ contains pint = pint + 0.5_wp*myV**2._wp if (lag_params%cluster_type == 2) then bub_dphidt(k) = (paux - pint) + term2 - ! Accounting for the potential induced by the bubble averaged over the control volume - ! Note that this is based on the incompressible flow assumption near the bubble. + ! for the potential induced by the bubble averaged over the control volume + ! that this is based on the incompressible flow assumption near the bubble. term1_fac = 3._wp/2._wp*(myR*(Romega**2._wp - myR**2._wp))/(Romega**3._wp - myR**3._wp) bub_dphidt(k) = bub_dphidt(k)/(1._wp - term1_fac) end if @@ -575,15 +575,15 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Radial motion model + ! motion model adap_dt_stop_max = 0 $:GPU_PARALLEL_LOOP(private='[k,i,myalpha_rho,myalpha,Re,cell,myVapFlux,preterm1, term2, paux, pint, Romega, term1_fac,myR_m, mygamma_m, myPb, myMass_n, myMass_v,myR, myV, myBeta_c, myBeta_t, myR0, myPbdot, myMvdot,myPinf, aux1, aux2, myCson, myRho,gamma,pi_inf,qv,dmalf, dmntait, dmBtait, dm_bub_adv_src, dm_divu,adap_dt_stop]', & & reduction='[[adap_dt_stop_max]]',reductionOp='[MAX]', & & copy='[adap_dt_stop_max]',copyin='[stage]') do k = 1, nBubs - ! Keller-Miksis model + ! model - ! Current bubble state + ! bubble state myPb = gas_p(k, 2) myMass_n = gas_mg(k) myMass_v = gas_mv(k, 2) @@ -593,21 +593,21 @@ contains myBeta_t = gas_betaT(k) myR0 = bub_R0(k) - ! Vapor and heat fluxes + ! and heat fluxes call s_vflux(myR, myV, myPb, myMass_v, k, myVapFlux, myMass_n, myBeta_c, myR_m, mygamma_m) myPbdot = f_bpres_dot(myVapFlux, myR, myV, myPb, myMass_v, k, myBeta_t, myR_m, mygamma_m) myMvdot = 4._wp*pi*myR**2._wp*myVapFlux - ! Obtaining driving pressure + ! driving pressure call s_get_pinf(k, q_prim_vf, 1, myPinf, cell, aux1, aux2) - ! Obtain liquid density and computing speed of sound from pinf + ! liquid density and computing speed of sound from pinf call s_compute_species_fraction(q_prim_vf, cell(1), cell(2), cell(3), myalpha_rho, myalpha) call s_convert_species_to_mixture_variables_acc(myRho, gamma, pi_inf, qv, myalpha, & myalpha_rho, Re) call s_compute_cson_from_pinf(q_prim_vf, myPinf, cell, myRho, gamma, pi_inf, myCson) - ! Adaptive time stepping + ! time stepping adap_dt_stop = 0 if (adap_dt) then @@ -617,7 +617,7 @@ contains k, myMass_v, myMass_n, myBeta_c, & myBeta_t, myCson, adap_dt_stop) - ! Update bubble state + ! bubble state intfc_rad(k, 1) = myR intfc_vel(k, 1) = myV gas_p(k, 1) = myPb @@ -625,7 +625,7 @@ contains else - ! Radial acceleration from bubble models + ! acceleration from bubble models intfc_dveldt(k, stage) = f_rddot(myRho, myPinf, myR, myV, myR0, & myPb, myPbdot, dmalf, dmntait, dmBtait, & dm_bub_adv_src, dm_divu, & @@ -643,7 +643,7 @@ contains if (adap_dt .and. adap_dt_stop_max > 0) call s_mpi_abort("Adaptive time stepping failed to converge.") - ! Bubbles remain in a fixed position + ! remain in a fixed position $:GPU_PARALLEL_LOOP(collapse=2, private='[k,l]', copyin='[stage]') do k = 1, nBubs do l = 1, 3 @@ -658,10 +658,10 @@ contains end subroutine s_compute_bubble_EL_dynamics !> The purpose of this subroutine is to obtain the bubble source terms based on Maeda and Colonius (2018) - !! and add them to the RHS scalar field. - !! @param q_cons_vf Conservative variables - !! @param q_prim_vf Conservative variables - !! @param rhs_vf Time derivative of the conservative variables + !! them to the RHS scalar field. + !! Conservative variables + !! Conservative variables + !! Time derivative of the conservative variables subroutine s_compute_bubbles_EL_source(q_cons_vf, q_prim_vf, rhs_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -674,7 +674,7 @@ contains if (lag_params%solver_approach == 2) then - ! (q / (1 - beta)) * d(beta)/dt source + ! / (1 - beta)) * d(beta)/dt source if (p == 0) then $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=4) do k = 0, p @@ -714,7 +714,7 @@ contains call s_gradient_dir(q_prim_vf(E_idx)%sf, q_beta(3)%sf, l) - ! (q / (1 - beta)) * d(beta)/dt source + ! / (1 - beta)) * d(beta)/dt source $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -743,7 +743,7 @@ contains call s_gradient_dir(q_beta(3)%sf, q_beta(4)%sf, l) - ! (beta / (1 - beta)) * d(Pu)/dl source + ! / (1 - beta)) * d(Pu)/dl source $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -764,14 +764,14 @@ contains end subroutine s_compute_bubbles_EL_source !> This procedure computes the speed of sound from a given driving pressure - !! @param bub_id Bubble id - !! @param q_prim_vf Primitive variables - !! @param pinf Driving pressure - !! @param cell Bubble cell - !! @param rhol Liquid density - !! @param gamma Liquid specific heat ratio - !! @param pi_inf Liquid stiffness - !! @param cson Calculated speed of sound + !! Bubble id + !! Primitive variables + !! Driving pressure + !! Bubble cell + !! Liquid density + !! Liquid specific heat ratio + !! Liquid stiffness + !! Calculated speed of sound subroutine s_compute_cson_from_pinf(q_prim_vf, pinf, cell, rhol, gamma, pi_inf, cson) $:GPU_ROUTINE(function_name='s_compute_cson_from_pinf', & & parallelism='[seq]', cray_inline=True) @@ -828,7 +828,7 @@ contains do k = idwbuff(2)%beg, idwbuff(2)%end do j = idwbuff(1)%beg, idwbuff(1)%end q_beta(1)%sf(j, k, l) = 1._wp - q_beta(1)%sf(j, k, l) - ! Limiting void fraction given max value + ! void fraction given max value q_beta(1)%sf(j, k, l) = max(q_beta(1)%sf(j, k, l), & 1._wp - lag_params%valmaxvoid) end do @@ -841,12 +841,12 @@ contains end subroutine s_smear_voidfraction !> The purpose of this procedure is obtain the bubble driving pressure p_inf - !! @param bub_id Particle identifier - !! @param q_prim_vf Primitive variables - !! @param ptype 1: p at infinity, 2: averaged P at the bubble location - !! @param f_pinfl Driving pressure - !! @param cell Bubble cell - !! @param Romega Control volume radius + !! Particle identifier + !! Primitive variables + !! 1: p at infinity, 2: averaged P at the bubble location + !! Driving pressure + !! Bubble cell + !! Control volume radius subroutine s_get_pinf(bub_id, q_prim_vf, ptype, f_pinfl, cell, preterm1, term2, Romega) $:GPU_ROUTINE(function_name='s_get_pinf',parallelism='[seq]', & & cray_inline=True) @@ -949,9 +949,9 @@ contains dc = (3._wp*vol/(4._wp*pi))**(1._wp/3._wp) else if (lag_params%cluster_type >= 2) then - ! Bubble dynamic closure from Maeda and Colonius (2018) + ! dynamic closure from Maeda and Colonius (2018) - ! Include the cell that contains the bubble (mapCells+1+mapCells) + ! the cell that contains the bubble (mapCells+1+mapCells) smearGrid = mapCells - (-mapCells) + 1 smearGridz = smearGrid if (p == 0) smearGridz = 1 @@ -1046,7 +1046,7 @@ contains !Control volume radius if (ptype == 2) Romega = dc - ! Getting p_inf + ! p_inf if (ptype == 1) then f_pinfl = f_pinfl + preterm1*term1 + term2 end if @@ -1056,8 +1056,8 @@ contains end subroutine s_get_pinf !> This subroutine updates the Lagrange variables using the tvd RK time steppers. - !! The time derivative of the bubble variables must be stored at every stage to avoid precision errors. - !! @param stage Current tvd RK stage + !! derivative of the bubble variables must be stored at every stage to avoid precision errors. + !! Current tvd RK stage impure subroutine s_update_lagrange_tdv_rk(stage) integer, intent(in) :: stage @@ -1179,9 +1179,9 @@ contains end subroutine s_update_lagrange_tdv_rk !> This subroutine returns the computational coordinate of the cell for the given position. - !! @param pos Input coordinates - !! @param cell Computational coordinate of the cell - !! @param scoord Calculated particle coordinates + !! Input coordinates + !! Computational coordinate of the cell + !! Calculated particle coordinates subroutine s_locate_cell(pos, cell, scoord) real(wp), dimension(3), intent(in) :: pos @@ -1215,11 +1215,11 @@ contains end do end if - ! The numbering of the cell of which left boundary is the domain boundary is 0. - ! if comp.coord of the pos is s, the real coordinate of s is - ! (the coordinate of the left boundary of the Floor(s)-th cell) - ! + (s-(int(s))*(cell-width). - ! In other words, the coordinate of the center of the cell is x_cc(cell). + ! numbering of the cell of which left boundary is the domain boundary is 0. + ! comp.coord of the pos is s, the real coordinate of s is + ! coordinate of the left boundary of the Floor(s)-th cell) + ! (s-(int(s))*(cell-width). + ! other words, the coordinate of the center of the cell is x_cc(cell). !coordinates in computational space scoord(1) = cell(1) + (pos(1) - x_cb(cell(1) - 1))/dx(cell(1)) @@ -1254,34 +1254,34 @@ contains end subroutine s_transfer_data_to_tmp !> The purpose of this procedure is to determine if the global coordinates of the bubbles - !! are present in the current MPI processor (including ghost cells). - !! @param pos_part Spatial coordinates of the bubble + !! in the current MPI processor (including ghost cells). + !! Spatial coordinates of the bubble function particle_in_domain(pos_part) logical :: particle_in_domain real(wp), dimension(3), intent(in) :: pos_part - ! 2D + ! if (p == 0 .and. cyl_coord .neqv. .true.) then - ! Defining a virtual z-axis that has the same dimensions as y-axis - ! defined in the input file + ! a virtual z-axis that has the same dimensions as y-axis + ! in the input file particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (pos_part(2) < y_cb(n + buff_size)) .and. (pos_part(2) >= y_cb(-buff_size - 1)) .and. & (pos_part(3) < lag_params%charwidth/2._wp) .and. (pos_part(3) >= -lag_params%charwidth/2._wp)) else - ! cyl_coord + ! particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (abs(pos_part(2)) < y_cb(n + buff_size)) .and. (abs(pos_part(2)) >= max(y_cb(-buff_size - 1), 0._wp))) end if - ! 3D + ! if (p > 0) then particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (pos_part(2) < y_cb(n + buff_size)) .and. (pos_part(2) >= y_cb(-buff_size - 1)) .and. & (pos_part(3) < z_cb(p + buff_size)) .and. (pos_part(3) >= z_cb(-buff_size - 1))) end if - ! For symmetric and wall boundary condition + ! symmetric and wall boundary condition if (any(bc_x%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/))) then particle_in_domain = (particle_in_domain .and. (pos_part(1) >= x_cb(-1))) end if @@ -1306,8 +1306,8 @@ contains end function particle_in_domain !> The purpose of this procedure is to determine if the lagrangian bubble is located in the - !! physical domain. The ghost cells are not part of the physical domain. - !! @param pos_part Spatial coordinates of the bubble + !! The ghost cells are not part of the physical domain. + !! Spatial coordinates of the bubble function particle_in_domain_physical(pos_part) logical :: particle_in_domain_physical @@ -1323,10 +1323,10 @@ contains end function particle_in_domain_physical !> The purpose of this procedure is to calculate the gradient of a scalar field along the x, y and z directions - !! following a second-order central difference considering uneven widths - !! @param q Input scalar field - !! @param dq Output gradient of q - !! @param dir Gradient spatial direction + !! second-order central difference considering uneven widths + !! Input scalar field + !! Output gradient of q + !! Gradient spatial direction subroutine s_gradient_dir(q, dq, dir) real(stp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:), intent(inout) :: q, dq @@ -1335,7 +1335,7 @@ contains integer :: i, j, k if (dir == 1) then - ! Gradient in x dir. + ! in x dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1350,7 +1350,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() elseif (dir == 2) then - ! Gradient in y dir. + ! in y dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1365,7 +1365,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() elseif (dir == 3) then - ! Gradient in z dir. + ! in z dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1384,7 +1384,7 @@ contains end subroutine s_gradient_dir !> Subroutine that writes on each time step the changes of the lagrangian bubbles. - !! @param q_time Current time + !! Current time impure subroutine s_write_lag_particles(qtime) real(wp), intent(in) :: qtime @@ -1420,7 +1420,7 @@ contains FMT = "(F24.16,I14,8F24.16)" end if - ! Cycle through list + ! through list do k = 1, nBubs write (11, FMT) & qtime, & @@ -1440,9 +1440,9 @@ contains end subroutine s_write_lag_particles !> Subroutine that writes some useful statistics related to the volume fraction - !! of the particles (void fraction) in the computatioational domain - !! on each time step. - !! @param q_time Current time + !! particles (void fraction) in the computatioational domain + !! time step. + !! Current time impure subroutine s_write_void_evol(qtime) real(wp), intent(in) :: qtime @@ -1462,10 +1462,10 @@ contains if (.not. file_exist) then open (12, FILE=trim(file_loc), FORM='formatted', position='rewind') !write (12, *) 'currentTime, averageVoidFraction, ', & - ! 'maximumVoidFraction, totalParticlesVolume' + ! totalParticlesVolume' !write (12, *) 'The averageVoidFraction value does ', & - ! 'not reflect the real void fraction in the cloud since the ', & - ! 'cells which do not have bubbles are not accounted' + ! reflect the real void fraction in the cloud since the ', & + ! which do not have bubbles are not accounted' else open (12, FILE=trim(file_loc), FORM='formatted', position='append') end if @@ -1500,8 +1500,8 @@ contains end if #endif voltot = lag_void_avg - ! This voidavg value does not reflect the real void fraction in the cloud - ! since the cell which does not have bubbles are not accounted + ! voidavg value does not reflect the real void fraction in the cloud + ! the cell which does not have bubbles are not accounted if (lag_vol > 0._wp) lag_void_avg = lag_void_avg/lag_vol if (proc_rank == 0) then @@ -1516,10 +1516,10 @@ contains end subroutine s_write_void_evol !> Subroutine that writes the restarting files for the particles in the lagrangian solver. - !! @param t_step Current time step + !! Current time step impure subroutine s_write_restart_lag_bubbles(t_step) - ! Generic string used to store the address of a particular file + ! string used to store the address of a particular file integer, intent(in) :: t_step character(LEN=path_len + 2*name_len) :: file_loc @@ -1528,7 +1528,7 @@ contains integer :: i, k #ifdef MFC_MPI - ! For Parallel I/O + ! Parallel I/O integer :: ifile, ierr integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp @@ -1553,14 +1553,14 @@ contains lsizes(1) = bub_id lsizes(2) = lag_io_vars - ! Total number of particles + ! number of particles call MPI_ALLREDUCE(bub_id, tot_part, 1, MPI_integer, & MPI_SUM, MPI_COMM_WORLD, ierr) call MPI_ALLGATHER(bub_id, 1, MPI_INTEGER, proc_bubble_counts, 1, MPI_INTEGER, & MPI_COMM_WORLD, ierr) - ! Calculate starting index for this processor's particles + ! starting index for this processor's particles call MPI_EXSCAN(lsizes(1), start_idx_part(1), 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr) if (proc_rank == 0) start_idx_part(1) = 0 start_idx_part(2) = 0 @@ -1571,7 +1571,7 @@ contains write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! Clean up existing file + ! up existing file if (proc_rank == 0) then inquire (FILE=trim(file_loc), EXIST=file_exist) if (file_exist) then @@ -1586,7 +1586,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Write header using MPI I/O for consistency + ! header using MPI I/O for consistency call MPI_FILE_WRITE(ifile, tot_part, 1, MPI_INTEGER, status, ierr) call MPI_FILE_WRITE(ifile, mytime, 1, mpi_p, status, ierr) call MPI_FILE_WRITE(ifile, dt, 1, mpi_p, status, ierr) @@ -1631,7 +1631,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Skip header (written by rank 0) + ! header (written by rank 0) disp = int(sizeof(tot_part) + 2*sizeof(mytime) + sizeof(num_procs) + & num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1651,7 +1651,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Skip header (written by rank 0) + ! header (written by rank 0) disp = int(sizeof(tot_part) + 2*sizeof(mytime) + sizeof(num_procs) + & num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1726,7 +1726,7 @@ contains end subroutine s_write_lag_bubble_stats !> The purpose of this subroutine is to remove one specific particle if dt is too small. - !! @param bub_id Particle id + !! Particle id impure subroutine s_remove_lag_bubble(bub_id) integer, intent(in) :: bub_id diff --git a/src/simulation/m_bubbles_EL_kernels.fpp b/src/simulation/m_bubbles_EL_kernels.fpp index 5d709d6913..3795dfa78a 100644 --- a/src/simulation/m_bubbles_EL_kernels.fpp +++ b/src/simulation/m_bubbles_EL_kernels.fpp @@ -1,11 +1,11 @@ !> -!! @file m_bubbles_EL_kernels.f90 -!! @brief Contains module m_bubbles_EL_kernels +!! +!! module m_bubbles_EL_kernels #:include 'macros.fpp' !> @brief This module contains kernel functions used to map the effect of the lagrangian bubbles -!! in the Eulerian framework. +!! Eulerian framework. module m_bubbles_EL_kernels use m_mpi_proxy !< Message passing interface (MPI) module proxy @@ -15,13 +15,13 @@ module m_bubbles_EL_kernels contains !> The purpose of this subroutine is to smear the strength of the lagrangian - !! bubbles into the Eulerian framework using different approaches. - !! @param nBubs Number of lagrangian bubbles in the current domain - !! @param lbk_rad Radius of the bubbles - !! @param lbk_vel Interface velocity of the bubbles - !! @param lbk_s Computational coordinates of the bubbles - !! @param lbk_pos Spatial coordinates of the bubbles - !! @param updatedvar Eulerian variable to be updated + !! the Eulerian framework using different approaches. + !! Number of lagrangian bubbles in the current domain + !! Radius of the bubbles + !! Interface velocity of the bubbles + !! Computational coordinates of the bubbles + !! Spatial coordinates of the bubbles + !! Eulerian variable to be updated subroutine s_smoothfunction(nBubs, lbk_rad, lbk_vel, lbk_s, lbk_pos, updatedvar) integer, intent(in) :: nBubs @@ -39,7 +39,7 @@ contains end subroutine s_smoothfunction !> The purpose of this procedure contains the algorithm to use the delta kernel function to map the effect of the bubbles. - !! The effect of the bubbles only affects the cell where the bubble is located. + !! of the bubbles only affects the cell where the bubble is located. subroutine s_deltafunc(nBubs, lbk_rad, lbk_vel, lbk_s, updatedvar) integer, intent(in) :: nBubs @@ -95,7 +95,7 @@ contains end subroutine s_deltafunc !> The purpose of this procedure contains the algorithm to use the gaussian kernel function to map the effect of the bubbles. - !! The effect of the bubbles affects the 3X3x3 cells that surround the bubble. + !! of the bubbles affects the 3X3x3 cells that surround the bubble. subroutine s_gaussian(nBubs, lbk_rad, lbk_vel, lbk_s, lbk_pos, updatedvar) integer, intent(in) :: nBubs @@ -156,7 +156,7 @@ contains call s_applygaussian(center, cellaux, nodecoord, stddsv, 0._wp, func) if (lag_params%cluster_type >= 4) call s_applygaussian(center, cellaux, nodecoord, stddsv, 1._wp, func2) - ! Relocate cells for bubbles intersecting symmetric boundaries + ! cells for bubbles intersecting symmetric boundaries if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == BC_REFLECTIVE)) then call s_shift_cell_symmetric_bc(cellaux, cell) end if @@ -224,29 +224,29 @@ contains else if (cyl_coord) then !< 2D cylindrical function: - ! We smear particles in the azimuthal direction for given r + ! smear particles in the azimuthal direction for given r theta = 0._wp Nr = ceiling(2._wp*pi*nodecoord(2)/(y_cb(cellaux(2)) - y_cb(cellaux(2) - 1))) dtheta = 2._wp*pi/Nr L2 = center(2)**2._wp + nodecoord(2)**2._wp - 2._wp*center(2)*nodecoord(2)*cos(theta) distance = sqrt((center(1) - nodecoord(1))**2._wp + L2) - ! Factor 2._wp is for symmetry (upper half of the 2D field (+r) is considered) + ! 2._wp is for symmetry (upper half of the 2D field (+r) is considered) func = dtheta/2._wp/pi*exp(-0.5_wp*(distance/stddsv)**2._wp)/(sqrt(2._wp*pi)*stddsv)**3._wp Nr_count = 0._wp do while (Nr_count < Nr - 1._wp) Nr_count = Nr_count + 1._wp theta = Nr_count*dtheta - ! trigonometric relation + ! relation L2 = center(2)**2._wp + nodecoord(2)**2._wp - 2._wp*center(2)*nodecoord(2)*cos(theta) distance = sqrt((center(1) - nodecoord(1))**2._wp + L2) - ! nodecoord(2)*dtheta is the azimuthal width of the cell + ! is the azimuthal width of the cell func = func + & dtheta/2._wp/pi*exp(-0.5_wp*(distance/stddsv)**2._wp)/(sqrt(2._wp*pi)*stddsv)**(3._wp*(strength_idx + 1._wp)) end do else !< 2D cartesian function: - ! We smear particles considering a virtual depth (lag_params%charwidth) + ! smear particles considering a virtual depth (lag_params%charwidth) theta = 0._wp Nr = ceiling(lag_params%charwidth/(y_cb(cellaux(2)) - y_cb(cellaux(2) - 1))) Nr_count = 1._wp - mapCells*1._wp @@ -267,8 +267,8 @@ contains end subroutine s_applygaussian !> The purpose of this subroutine is to check if the current cell is outside the computational domain or not (including ghost cells). - !! @param cellaux Tested cell to smear the bubble effect in. - !! @param celloutside If true, then cellaux is outside the computational domain. + !! Tested cell to smear the bubble effect in. + !! If true, then cellaux is outside the computational domain. subroutine s_check_celloutside(cellaux, celloutside) $:GPU_ROUTINE(function_name='s_check_celloutside',parallelism='[seq]', & & cray_inline=True) @@ -301,8 +301,8 @@ contains end subroutine s_check_celloutside !> This subroutine relocates the current cell, if it intersects a symmetric boundary. - !! @param cell Cell of the current bubble - !! @param cellaux Cell to map the bubble effect in. + !! Cell of the current bubble + !! Cell to map the bubble effect in. subroutine s_shift_cell_symmetric_bc(cellaux, cell) $:GPU_ROUTINE(function_name='s_shift_cell_symmetric_bc', & & parallelism='[seq]', cray_inline=True) @@ -310,7 +310,7 @@ contains integer, dimension(3), intent(inout) :: cellaux integer, dimension(3), intent(in) :: cell - ! x-dir + ! if (bc_x%beg == BC_REFLECTIVE .and. (cell(1) <= mapCells - 1)) then cellaux(1) = abs(cellaux(1)) - 1 end if @@ -339,9 +339,9 @@ contains end subroutine s_shift_cell_symmetric_bc !> Calculates the standard deviation of the bubble being smeared in the Eulerian framework. - !! @param cell Cell where the bubble is located - !! @param volpart Volume of the bubble - !! @param stddsv Standard deviaton + !! Cell where the bubble is located + !! Volume of the bubble + !! Standard deviaton subroutine s_compute_stddsv(cell, volpart, stddsv) $:GPU_ROUTINE(function_name='s_compute_stddsv',parallelism='[seq]', & & cray_inline=True) @@ -379,8 +379,8 @@ contains end subroutine s_compute_stddsv !> The purpose of this procedure is to calculate the characteristic cell volume - !! @param cell Computational coordinates (x, y, z) - !! @param Charvol Characteristic volume + !! Computational coordinates (x, y, z) + !! Characteristic volume subroutine s_get_char_vol(cellx, celly, cellz, Charvol) $:GPU_ROUTINE(function_name='s_get_char_vol',parallelism='[seq]', & & cray_inline=True) @@ -401,9 +401,9 @@ contains end subroutine s_get_char_vol !> This subroutine transforms the computational coordinates of the bubble from - !! real type into integer. - !! @param s Computational coordinates of the bubble, real type - !! @param get_cell Computational coordinates of the bubble, integer type + !! into integer. + !! Computational coordinates of the bubble, real type + !! Computational coordinates of the bubble, integer type subroutine s_get_cell(s_cell, get_cell) $:GPU_ROUTINE(function_name='s_get_cell',parallelism='[seq]', & & cray_inline=True) diff --git a/src/simulation/m_cbc.fpp b/src/simulation/m_cbc.fpp index 012d2358f2..18d0a4ffb5 100644 --- a/src/simulation/m_cbc.fpp +++ b/src/simulation/m_cbc.fpp @@ -1,22 +1,22 @@ !> -!! @file m_cbc.f90 -!! @brief Contains module m_cbc +!! +!! module m_cbc !> @brief The module features a large database of characteristic boundary -!! conditions (CBC) for the Euler system of equations. This system -!! is augmented by the appropriate advection equations utilized to -!! capture the material interfaces. The closure is achieved by the -!! stiffened equation of state and mixture relations. At this time, -!! the following CBC are available: -!! 1) Slip Wall -!! 2) Nonreflecting Subsonic Buffer -!! 3) Nonreflecting Subsonic Inflow -!! 4) Nonreflecting Subsonic Outflow -!! 5) Force-Free Subsonic Outflow -!! 6) Constant Pressure Subsonic Outflow -!! 7) Supersonic Inflow -!! 8) Supersonic Outflow -!! Please refer to Thompson (1987, 1990) for detailed descriptions. +!! for the Euler system of equations. This system +!! by the appropriate advection equations utilized to +!! material interfaces. The closure is achieved by the +!! of state and mixture relations. At this time, +!! CBC are available: +!! Wall +!! Subsonic Buffer +!! Subsonic Inflow +!! Subsonic Outflow +!! Subsonic Outflow +!! Pressure Subsonic Outflow +!! Inflow +!! Outflow +!! to Thompson (1987, 1990) for detailed descriptions. #:include 'case.fpp' #:include 'macros.fpp' @@ -44,28 +44,28 @@ module m_cbc private; public :: s_initialize_cbc_module, s_cbc, s_finalize_cbc_module - !! The cell-average primitive variables. They are obtained by reshaping (RS) - !! q_prim_vf in the coordinate direction normal to the domain boundary along - !! which the CBC is applied. + !! primitive variables. They are obtained by reshaping (RS) + !! the coordinate direction normal to the domain boundary along + !! CBC is applied. real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsx_vf real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsy_vf real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsz_vf $:GPU_DECLARE(create='[q_prim_rsx_vf,q_prim_rsy_vf,q_prim_rsz_vf]') - !! Cell-average fluxes (src - source). These are directly determined from the - !! cell-average primitive variables, q_prims_rs_vf, and not a Riemann solver. + !! (src - source). These are directly determined from the + !! variables, q_prims_rs_vf, and not a Riemann solver. real(wp), allocatable, dimension(:, :, :, :) :: F_rsx_vf, F_src_rsx_vf !< real(wp), allocatable, dimension(:, :, :, :) :: F_rsy_vf, F_src_rsy_vf !< real(wp), allocatable, dimension(:, :, :, :) :: F_rsz_vf, F_src_rsz_vf !< $:GPU_DECLARE(create='[F_rsx_vf,F_src_rsx_vf,F_rsy_vf,F_src_rsy_vf,F_rsz_vf,F_src_rsz_vf]') - !! There is a CCE bug that is causing some subset of these variables to interfere - !! with variables of the same name in m_riemann_solvers.fpp, and giving this versions - !! unique "_l" names works around the bug. Other private module allocatable arrays - !! in `acc declare create` clauses don't have this problem, so we still need to - !! isolate this bug. + !! a CCE bug that is causing some subset of these variables to interfere + !! of the same name in m_riemann_solvers.fpp, and giving this versions + !! names works around the bug. Other private module allocatable arrays + !! declare create` clauses don't have this problem, so we still need to + !! bug. real(wp), allocatable, dimension(:, :, :, :) :: flux_rsx_vf_l, flux_src_rsx_vf_l !< real(wp), allocatable, dimension(:, :, :, :) :: flux_rsy_vf_l, flux_src_rsy_vf_l @@ -74,17 +74,17 @@ module m_cbc real(wp), allocatable, dimension(:) :: ds !< Cell-width distribution in the s-direction - ! CBC Coefficients + ! Coefficients real(wp), allocatable, dimension(:, :) :: fd_coef_x !< Finite diff. coefficients x-dir real(wp), allocatable, dimension(:, :) :: fd_coef_y !< Finite diff. coefficients y-dir real(wp), allocatable, dimension(:, :) :: fd_coef_z !< Finite diff. coefficients z-dir - !! The first dimension identifies the location of a coefficient in the FD - !! formula, while the last dimension denotes the location of the CBC. + !! dimension identifies the location of a coefficient in the FD + !! the last dimension denotes the location of the CBC. - ! Bug with NVHPC when using nullified pointers in a declare create - ! real(wp), pointer, dimension(:, :) :: fd_coef => null() + ! with NVHPC when using nullified pointers in a declare create + ! pointer, dimension(:, :) :: fd_coef => null() real(wp), allocatable, dimension(:, :, :) :: pi_coef_x !< Polynomial interpolant coefficients in x-dir real(wp), allocatable, dimension(:, :, :) :: pi_coef_y !< Polynomial interpolant coefficients in y-dir @@ -92,9 +92,9 @@ module m_cbc $:GPU_DECLARE(create='[ds,fd_coef_x,fd_coef_y,fd_coef_z,pi_coef_x,pi_coef_y,pi_coef_z]') - !! The first dimension of the array identifies the polynomial, the - !! second dimension identifies the position of its coefficients and the last - !! dimension denotes the location of the CBC. + !! dimension of the array identifies the polynomial, the + !! identifies the position of its coefficients and the last + !! the location of the CBC. type(int_bounds_info) :: is1, is2, is3 !< Indical bounds in the s1-, s2- and s3-directions $:GPU_DECLARE(create='[is1,is2,is3]') @@ -106,9 +106,9 @@ module m_cbc $:GPU_DECLARE(create='[dj,bcxb,bcxe,bcyb,bcye,bczb,bcze]') $:GPU_DECLARE(create='[cbc_dir, cbc_loc,flux_cbc_index]') - !! GRCBC inputs for subsonic inflow and outflow conditions consisting of - !! inflow velocities, pressure, density and void fraction as well as - !! outflow velocities and pressure + !! for subsonic inflow and outflow conditions consisting of + !! pressure, density and void fraction as well as + !! and pressure real(wp), allocatable, dimension(:) :: pres_in, pres_out, Del_in, Del_out real(wp), allocatable, dimension(:, :) :: vel_in, vel_out @@ -120,8 +120,8 @@ module m_cbc contains !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_cbc_module integer :: i @@ -270,7 +270,7 @@ contains end if - ! Allocating the cell-width distribution in the s-direction + ! the cell-width distribution in the s-direction @:ALLOCATE(ds(0:buff_size)) if (recon_type == WENO_TYPE) then @@ -284,7 +284,7 @@ contains idx2%beg = 0 idx2%end = muscl_order - 1 end if - ! Allocating/Computing CBC Coefficients in x-direction + ! CBC Coefficients in x-direction if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13)) then @:ALLOCATE(fd_coef_x(0:buff_size, -1:1)) @@ -318,7 +318,7 @@ contains end if - ! Allocating/Computing CBC Coefficients in y-direction + ! CBC Coefficients in y-direction if (n > 0) then if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13)) then @@ -356,7 +356,7 @@ contains end if - ! Allocating/Computing CBC Coefficients in z-direction + ! CBC Coefficients in z-direction if (p > 0) then if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13)) then @@ -397,8 +397,8 @@ contains $:GPU_UPDATE(device='[fd_coef_x,fd_coef_y,fd_coef_z, & & pi_coef_x,pi_coef_y,pi_coef_z]') - ! Associating the procedural pointer to the appropriate subroutine - ! that will be utilized in the conversion to the mixture variables + ! the procedural pointer to the appropriate subroutine + ! will be utilized in the conversion to the mixture variables bcxb = bc_x%beg bcxe = bc_x%end @@ -419,13 +419,13 @@ contains $:GPU_UPDATE(device='[bczb, bcze]') end if - ! Allocate GRCBC inputs + ! GRCBC inputs @:ALLOCATE(pres_in(1:num_dims), pres_out(1:num_dims)) @:ALLOCATE(Del_in(1:num_dims), Del_out(1:num_dims)) @:ALLOCATE(vel_in(1:num_dims, 1:num_dims), vel_out(1:num_dims, 1:num_dims)) @:ALLOCATE(alpha_rho_in(1:num_fluids, 1:num_dims), alpha_in(1:num_fluids, 1:num_dims)) - ! Assign and update GRCBC inputs + ! and update GRCBC inputs #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (${CBC_DIR}$ <= num_dims) then vel_in(${CBC_DIR}$, 1) = bc_${XYZ}$%vel_in(1) @@ -453,33 +453,33 @@ contains end subroutine s_initialize_cbc_module !> Compute CBC coefficients - !! @param cbc_dir_in CBC coordinate direction - !! @param cbc_loc_in CBC coordinate location + !! CBC coordinate direction + !! CBC coordinate location subroutine s_compute_cbc_coefficients(cbc_dir_in, cbc_loc_in) - ! Description: The purpose of this subroutine is to compute the grid - ! dependent FD and PI coefficients, or CBC coefficients, - ! provided the CBC coordinate direction and location. + ! The purpose of this subroutine is to compute the grid + ! FD and PI coefficients, or CBC coefficients, + ! the CBC coordinate direction and location. - ! CBC coordinate direction and location + ! coordinate direction and location integer, intent(in) :: cbc_dir_in, cbc_loc_in - ! Cell-boundary locations in the s-direction + ! locations in the s-direction real(wp), dimension(0:buff_size + 1) :: s_cb - ! Generic loop iterator + ! loop iterator integer :: i - ! Associating CBC coefficients pointers + ! CBC coefficients pointers call s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in) - ! Determining the cell-boundary locations in the s-direction + ! the cell-boundary locations in the s-direction s_cb(0) = 0._wp do i = 0, buff_size s_cb(i + 1) = s_cb(i) + ds(i) end do - ! Computing CBC1 Coefficients + ! CBC1 Coefficients #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (cbc_dir_in == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then if (weno_order == 1) then @@ -488,7 +488,7 @@ contains fd_coef_${XYZ}$ (0, cbc_loc_in) = -2._wp/(ds(0) + ds(1)) fd_coef_${XYZ}$ (1, cbc_loc_in) = -fd_coef_${XYZ}$ (0, cbc_loc_in) - ! Computing CBC2 Coefficients + ! CBC2 Coefficients elseif (weno_order == 3) then fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp @@ -498,7 +498,7 @@ contains pi_coef_${XYZ}$ (0, 0, cbc_loc_in) = (s_cb(0) - s_cb(1))/(s_cb(0) - s_cb(2)) - ! Computing CBC4 Coefficients + ! CBC4 Coefficients else fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp @@ -547,25 +547,25 @@ contains end if #:endfor - ! END: Computing CBC4 Coefficients + ! Computing CBC4 Coefficients - ! Nullifying CBC coefficients + ! CBC coefficients end subroutine s_compute_cbc_coefficients - !! The goal of the procedure is to associate the FD and PI - !! coefficients, or CBC coefficients, with the appropriate - !! targets, based on the coordinate direction and location - !! of the CBC. - !! @param cbc_dir_in CBC coordinate direction - !! @param cbc_loc_in CBC coordinate location + !! of the procedure is to associate the FD and PI + !! CBC coefficients, with the appropriate + !! on the coordinate direction and location + !! CBC. + !! CBC coordinate direction + !! CBC coordinate location subroutine s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in) integer, intent(in) :: cbc_dir_in, cbc_loc_in integer :: i !< Generic loop iterator - ! Associating CBC Coefficients in x-direction + ! CBC Coefficients in x-direction if (cbc_dir_in == 1) then !fd_coef => fd_coef_x; if (weno_order > 1) pi_coef => pi_coef_x @@ -580,7 +580,7 @@ contains end do end if - ! Associating CBC Coefficients in y-direction + ! CBC Coefficients in y-direction elseif (cbc_dir_in == 2) then !fd_coef => fd_coef_y; if (weno_order > 1) pi_coef => pi_coef_y @@ -595,7 +595,7 @@ contains end do end if - ! Associating CBC Coefficients in z-direction + ! CBC Coefficients in z-direction else !fd_coef => fd_coef_z; if (weno_order > 1) pi_coef => pi_coef_z @@ -617,18 +617,18 @@ contains end subroutine s_associate_cbc_coefficients_pointers !> The following is the implementation of the CBC based on - !! the work of Thompson (1987, 1990) on hyperbolic systems. - !! The CBC is indirectly applied in the computation of the - !! right-hand-side (RHS) near the relevant domain boundary - !! through the modification of the fluxes. - !! @param q_prim_vf Cell-average primitive variables - !! @param flux_vf Cell-boundary-average fluxes - !! @param flux_src_vf Cell-boundary-average flux sources - !! @param cbc_dir_norm CBC coordinate direction - !! @param cbc_loc_norm CBC coordinate location - !! @param ix Index bound in the first coordinate direction - !! @param iy Index bound in the second coordinate direction - !! @param iz Index bound in the third coordinate direction + !! of Thompson (1987, 1990) on hyperbolic systems. + !! is indirectly applied in the computation of the + !! near the relevant domain boundary + !! modification of the fluxes. + !! Cell-average primitive variables + !! Cell-boundary-average fluxes + !! Cell-boundary-average flux sources + !! CBC coordinate direction + !! CBC coordinate location + !! Index bound in the first coordinate direction + !! Index bound in the second coordinate direction + !! Index bound in the third coordinate direction subroutine s_cbc(q_prim_vf, flux_vf, flux_src_vf, & cbc_dir_norm, cbc_loc_norm, & ix, iy, iz) @@ -691,9 +691,9 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! Reshaping of inputted data and association of the FD and PI - ! coefficients, or CBC coefficients, respectively, hinging on - ! selected CBC coordinate direction + ! of inputted data and association of the FD and PI + ! or CBC coefficients, respectively, hinging on + ! CBC coordinate direction cbc_dir = cbc_dir_norm cbc_loc = cbc_loc_norm @@ -708,7 +708,7 @@ contains #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (cbc_dir == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then - ! PI2 of flux_rs_vf and flux_src_rs_vf at j = 1/2 + ! of flux_rs_vf and flux_src_rs_vf at j = 1/2 if (weno_order == 3 .or. dummy) then call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, & @@ -743,7 +743,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! PI4 of flux_rs_vf and flux_src_rs_vf at j = 1/2, 3/2 + ! of flux_rs_vf and flux_src_rs_vf at j = 1/2, 3/2 if (weno_order == 5 .or. dummy) then call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, & F_rs${XYZ}$_vf, & @@ -794,12 +794,12 @@ contains end if - ! FD2 or FD4 of RHS at j = 0 + ! or FD4 of RHS at j = 0 $:GPU_PARALLEL_LOOP(collapse=2, private='[r,k,alpha_rho, vel, adv_local, mf, dvel_ds, dadv_ds, Re_cbc, dalpha_rho_ds, dpres_ds, dvel_dt, dadv_dt, dalpha_rho_dt, L, lambda, Ys, dYs_dt, dYs_ds, h_k, Cp_i, Gamma_i, Xs, drho_dt, dpres_dt, dpi_inf_dt, dqv_dt, dgamma_dt, rho, pres, E, H, gamma, pi_inf, qv, c, Ma, T, sum_Enthalpies, Cv, Cp, e_mix, Mw, R_gas, vel_K_sum, vel_dv_dt_sum, i, j]', copyin='[dir_idx]') do r = is3%beg, is3%end do k = is2%beg, is2%end - ! Transferring the Primitive Variables + ! the Primitive Variables $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe alpha_rho(i) = q_prim_rs${XYZ}$_vf(0, k, r, i) @@ -859,10 +859,10 @@ contains H = (E + pres)/rho - ! Compute mixture sound speed + ! mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv_local, vel_K_sum, 0._wp, c, qv) - ! First-Order Spatial Derivatives of Primitive Variables + ! Spatial Derivatives of Primitive Variables $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -923,7 +923,7 @@ contains end if end do - ! First-Order Temporal Derivatives of Primitive Variables + ! Temporal Derivatives of Primitive Variables lambda(1) = vel(dir_idx(1)) - c lambda(2) = vel(dir_idx(1)) lambda(3) = vel(dir_idx(1)) + c @@ -939,7 +939,7 @@ contains else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_INFLOW) .or. & (cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_INFLOW)) then call s_compute_nonreflecting_subsonic_inflow_L(lambda, L, rho, c, dpres_ds, dvel_ds) - ! Add GRCBC for Subsonic Inflow + ! GRCBC for Subsonic Inflow if (bc_${XYZ}$%grcbc_in) then $:GPU_LOOP(parallelism='[seq]') do i = 2, momxb @@ -960,11 +960,11 @@ contains else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_OUTFLOW) .or. & (cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_OUTFLOW)) then call s_compute_nonreflecting_subsonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds) - ! Add GRCBC for Subsonic Outflow (Pressure) + ! GRCBC for Subsonic Outflow (Pressure) if (bc_${XYZ}$%grcbc_out) then L(advxe) = c*(1._wp - Ma)*(pres - pres_out(${CBC_DIR}$))/Del_out(${CBC_DIR}$) - ! Add GRCBC for Subsonic Outflow (Normal Velocity) + ! GRCBC for Subsonic Outflow (Normal Velocity) if (bc_${XYZ}$%grcbc_vel_out) then L(advxe) = L(advxe) + rho*c**2._wp*(1._wp - Ma)*(vel(dir_idx(1)) + vel_out(${CBC_DIR}$, dir_idx(1))*sign(1, cbc_loc))/Del_out(${CBC_DIR}$) end if @@ -983,7 +983,7 @@ contains call s_compute_supersonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds) end if - ! Be careful about the cylindrical coordinate! + ! careful about the cylindrical coordinate! if (cyl_coord .and. cbc_dir == 2 .and. cbc_loc == 1) then dpres_dt = -5.e-1_wp*(L(advxe) + L(1)) + rho*c*c*vel(dir_idx(1)) & /y_cc(n) @@ -1018,7 +1018,7 @@ contains end do end if - ! The treatment of void fraction source is unclear + ! treatment of void fraction source is unclear if (cyl_coord .and. cbc_dir == 2 .and. cbc_loc == 1) then $:GPU_LOOP(parallelism='[seq]') do i = 1, advxe - E_idx @@ -1049,7 +1049,7 @@ contains end do end if - ! flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 + ! and flux_src_rs_vf_l at j = -1/2 $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf_l(-1, k, r, i) = flux_rs${XYZ}$_vf_l(0, k, r, i) & @@ -1064,7 +1064,7 @@ contains end do if (chemistry) then - ! Evolution of LODI equation of energy for real gases adjusted to perfect gas, doi:10.1006/jcph.2002.6990 + ! of LODI equation of energy for real gases adjusted to perfect gas, doi:10.1006/jcph.2002.6990 call get_species_enthalpies_rt(T, h_k) sum_Enthalpies = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -1126,7 +1126,7 @@ contains end do end if - ! END: flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 + ! flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 end do end do @@ -1134,24 +1134,24 @@ contains end if #:endfor - ! END: FD2 or FD4 of RHS at j = 0 + ! FD2 or FD4 of RHS at j = 0 - ! The reshaping of outputted data and disssociation of the FD and PI - ! coefficients, or CBC coefficients, respectively, based on selected - ! CBC coordinate direction. + ! reshaping of outputted data and disssociation of the FD and PI + ! or CBC coefficients, respectively, based on selected + ! coordinate direction. call s_finalize_cbc(flux_vf, flux_src_vf) end subroutine s_cbc !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are required for the setup of the - !! selected CBC. - !! @param q_prim_vf Cell-average primitive variables - !! @param flux_vf Cell-boundary-average fluxes - !! @param flux_src_vf Cell-boundary-average flux sources - !! @param ix Index bound in the first coordinate direction - !! @param iy Index bound in the second coordinate direction - !! @param iz Index bound in the third coordinate direction + !! of pointers and/or the execution of any + !! that are required for the setup of the + !! + !! Cell-average primitive variables + !! Cell-boundary-average fluxes + !! Cell-boundary-average flux sources + !! Index bound in the first coordinate direction + !! Index bound in the second coordinate direction + !! Index bound in the third coordinate direction subroutine s_initialize_cbc(q_prim_vf, flux_vf, flux_src_vf, & ix, iy, iz) @@ -1167,11 +1167,11 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! Configuring the coordinate direction indexes and flags + ! the coordinate direction indexes and flags - ! Determining the indicial shift based on CBC location + ! the indicial shift based on CBC location - ! END: Allocation/Association of Primitive and Flux Variables + ! Allocation/Association of Primitive and Flux Variables if (cbc_dir == 1) then is1%beg = 0; is1%end = buff_size; is2 = iy; is3 = iz @@ -1188,7 +1188,7 @@ contains $:GPU_UPDATE(device='[is1,is2,is3,dj]') $:GPU_UPDATE(device='[dir_idx,dir_flg]') - ! Reshaping Inputted Data in x-direction + ! Inputted Data in x-direction if (cbc_dir == 1) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1268,9 +1268,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! END: Reshaping Inputted Data in x-direction + ! Reshaping Inputted Data in x-direction - ! Reshaping Inputted Data in y-direction + ! Inputted Data in y-direction elseif (cbc_dir == 2) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1350,9 +1350,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! END: Reshaping Inputted Data in y-direction + ! Reshaping Inputted Data in y-direction - ! Reshaping Inputted Data in z-direction + ! Inputted Data in z-direction else $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1433,17 +1433,17 @@ contains end if end if - ! END: Reshaping Inputted Data in z-direction + ! Reshaping Inputted Data in z-direction - ! Association of the procedural pointer to the appropriate procedure - ! that will be utilized in the evaluation of L variables for the CBC + ! of the procedural pointer to the appropriate procedure + ! will be utilized in the evaluation of L variables for the CBC end subroutine s_initialize_cbc !> Deallocation and/or the disassociation procedures that - !! are necessary in order to finalize the CBC application - !! @param flux_vf Cell-boundary-average fluxes - !! @param flux_src_vf Cell-boundary-average flux sources + !! in order to finalize the CBC application + !! Cell-boundary-average fluxes + !! Cell-boundary-average flux sources subroutine s_finalize_cbc(flux_vf, flux_src_vf) type(scalar_field), & @@ -1452,11 +1452,11 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! Determining the indicial shift based on CBC location + ! the indicial shift based on CBC location dj = max(0, cbc_loc) $:GPU_UPDATE(device='[dj]') - ! Reshaping Outputted Data in x-direction + ! Outputted Data in x-direction if (cbc_dir == 1) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1509,9 +1509,9 @@ contains end do $:END_GPU_PARALLEL_LOOP() end if - ! END: Reshaping Outputted Data in x-direction + ! Reshaping Outputted Data in x-direction - ! Reshaping Outputted Data in y-direction + ! Outputted Data in y-direction elseif (cbc_dir == 2) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1566,9 +1566,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! END: Reshaping Outputted Data in y-direction + ! Reshaping Outputted Data in y-direction - ! Reshaping Outputted Data in z-direction + ! Outputted Data in z-direction else $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1624,11 +1624,11 @@ contains end if end if - ! END: Reshaping Outputted Data in z-direction + ! Reshaping Outputted Data in z-direction end subroutine s_finalize_cbc - ! Detext if the problem has any characteristic boundary conditions + ! if the problem has any characteristic boundary conditions elemental subroutine s_any_cbc_boundaries(toggle) logical, intent(inout) :: toggle @@ -1652,7 +1652,7 @@ contains if (is_cbc .eqv. .false.) return - ! Deallocating the cell-average primitive variables + ! the cell-average primitive variables @:DEALLOCATE(q_prim_rsx_vf) if (weno_order > 1 .or. muscl_order > 1) then @:DEALLOCATE(F_rsx_vf, F_src_rsx_vf) @@ -1674,13 +1674,13 @@ contains @:DEALLOCATE(flux_rsz_vf_l, flux_src_rsz_vf_l) end if - ! Deallocating the cell-width distribution in the s-direction + ! the cell-width distribution in the s-direction @:DEALLOCATE(ds) - ! Deallocating GRCBC inputs + ! GRCBC inputs @:DEALLOCATE(vel_in, vel_out, pres_in, pres_out, Del_in, Del_out, alpha_rho_in, alpha_in) - ! Deallocating CBC Coefficients in x-direction + ! CBC Coefficients in x-direction if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13) .or. & bc_x%beg <= -5 .and. bc_x%beg >= -13 .or. & bc_x%end <= -5 .and. bc_x%end >= -13) then @@ -1690,7 +1690,7 @@ contains end if end if - ! Deallocating CBC Coefficients in y-direction + ! CBC Coefficients in y-direction if (n > 0) then if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13) .or. & bc_y%beg <= -5 .and. bc_y%beg >= -13 .or. & @@ -1702,7 +1702,7 @@ contains end if end if - ! Deallocating CBC Coefficients in z-direction + ! CBC Coefficients in z-direction if (p > 0) then if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13) .or. & bc_z%beg <= -5 .and. bc_z%beg >= -13 .or. & diff --git a/src/simulation/m_checker.fpp b/src/simulation/m_checker.fpp index 9ec3c6981f..436cbc59ac 100644 --- a/src/simulation/m_checker.fpp +++ b/src/simulation/m_checker.fpp @@ -1,5 +1,5 @@ !> -!!@file m_start_up.f90 +!!@file !!@brief Contains module m_checker #:include 'macros.fpp' @@ -23,7 +23,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! Used by the simulation stage + !! the simulation stage impure subroutine s_check_inputs call s_check_inputs_compilers @@ -77,7 +77,7 @@ contains !> Checks constraints on geometry and precision impure subroutine s_check_inputs_geometry_precision - ! Prevent spherical geometry in single precision + ! spherical geometry in single precision #ifdef MFC_SINGLE_PRECISION @:PROHIBIT(.not. (cyl_coord .neqv. .true. .or. (cyl_coord .and. p == 0)), "Fully 3D cylindrical grid (geometry = 3) is not supported in single precision.") #endif diff --git a/src/simulation/m_compute_cbc.fpp b/src/simulation/m_compute_cbc.fpp index 13bd6a8209..ea0290f560 100644 --- a/src/simulation/m_compute_cbc.fpp +++ b/src/simulation/m_compute_cbc.fpp @@ -1,6 +1,6 @@ !> -!! @file m_compute_cbc.f90 -!! @brief CBC computation module +!! +!! computation module #:include 'case.fpp' #:include 'macros.fpp' @@ -49,7 +49,7 @@ contains real(wp), intent(in) :: dpres_ds integer :: i - ! $:GPU_LOOP(parallelism='[seq]') + ! do i = 2, momxb L(i) = lambda_factor*lambda2*(c*c*dalpha_rho_ds(i - 1) - mf(i - 1)*dpres_ds) end do @@ -71,7 +71,7 @@ contains real(wp), intent(in) :: lambda_factor, lambda2 integer :: i - ! $:GPU_LOOP(parallelism='[seq]') + ! do i = momxb + 1, momxe L(i) = lambda_factor*lambda2*dvel_ds(dir_idx(i - contxe)) end do @@ -93,7 +93,7 @@ contains real(wp), intent(in) :: lambda_factor, lambda2 integer :: i - ! $:GPU_LOOP(parallelism='[seq]') + ! do i = E_idx, advxe - 1 L(i) = lambda_factor*lambda2*dadv_ds(i - momxe) end do @@ -117,7 +117,7 @@ contains if (.not. chemistry) return - ! $:GPU_LOOP(parallelism='[seq]') + ! do i = chemxb, chemxe L(i) = lambda_factor*lambda2*dYs_ds(i - chemxb + 1) end do diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 6e97af027c..8faf749d67 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -1,16 +1,16 @@ -!! @file m_data_output.f90 -!! @brief Contains module m_data_output +!! +!! module m_data_output #:include 'macros.fpp' #:include 'case.fpp' !> @brief The primary purpose of this module is to output the grid and the -!! conservative variables data at the chosen time-step interval. In -!! addition, this module is also in charge of outputting a run-time -!! information file which summarizes the time-dependent behavior !of -!! the stability criteria. The latter include the inviscid Courant– -!! Friedrichs–Lewy (ICFL), viscous CFL (VCFL), capillary CFL (CCFL) -!! and cell Reynolds (Rc) numbers. +!! data at the chosen time-step interval. In +!! module is also in charge of outputting a run-time +!! which summarizes the time-dependent behavior !of +!! criteria. The latter include the inviscid Courant– +!! viscous CFL (VCFL), capillary CFL (CCFL) +!! Reynolds (Rc) numbers. module m_data_output use m_derived_types !< Definitions of the derived types @@ -80,9 +80,9 @@ module m_data_output contains !> Write data files. Dispatch subroutine that replaces procedure pointer. - !! @param q_cons_vf Conservative variables - !! @param q_prim_vf Primitive variables - !! @param t_step Current time step + !! Conservative variables + !! Primitive variables + !! Current time step impure subroutine s_write_data_files(q_cons_vf, q_T_sf, q_prim_vf, t_step, bc_type, beta) type(scalar_field), & @@ -114,23 +114,23 @@ contains end subroutine s_write_data_files !> The purpose of this subroutine is to open a new or pre- - !! existing run-time information file and append to it the - !! basic header information relevant to current simulation. - !! In general, this requires generating a table header for - !! those stability criteria which will be written at every - !! time-step. + !! information file and append to it the + !! information relevant to current simulation. + !! this requires generating a table header for + !! criteria which will be written at every + !! impure subroutine s_open_run_time_information_file character(LEN=name_len), parameter :: file_name = 'run_time.inf' !< - !! Name of the run-time information file + !! the run-time information file character(LEN=path_len + name_len) :: file_path !< - !! Relative path to a file in the case directory + !! to a file in the case directory character(LEN=8) :: file_date !< - !! Creation date of the run-time information file + !! of the run-time information file - ! Opening the run-time information file + ! the run-time information file file_path = trim(case_dir)//'/'//trim(file_name) open (3, FILE=trim(file_path), & @@ -157,7 +157,7 @@ contains write (3, '(A)') ''; write (3, '(A)') '' - ! Generating table header for the stability criteria to be outputted + ! table header for the stability criteria to be outputted write (3, '(13X,A9,13X,A10,13X,A10,13X,A10)', advance="no") & trim('Time-step'), trim('dt'), trim('Time'), trim('ICFL Max') @@ -171,19 +171,19 @@ contains end subroutine s_open_run_time_information_file !> This opens a formatted data file where the root processor - !! can write out the CoM information + !! out the CoM information impure subroutine s_open_com_files() character(len=path_len + 3*name_len) :: file_path !< - !! Relative path to the CoM file in the case directory + !! to the CoM file in the case directory integer :: i !< Generic loop iterator do i = 1, num_fluids - ! Generating the relative path to the CoM data file + ! the relative path to the CoM data file write (file_path, '(A,I0,A)') '/fluid', i, '_com.dat' file_path = trim(case_dir)//trim(file_path) - ! Creating the formatted data file and setting up its - ! structure + ! the formatted data file and setting up its + ! open (i + 120, file=trim(file_path), & form='formatted', & position='append', & @@ -211,22 +211,22 @@ contains end subroutine s_open_com_files !> This opens a formatted data file where the root processor - !! can write out flow probe information + !! out flow probe information impure subroutine s_open_probe_files character(LEN=path_len + 3*name_len) :: file_path !< - !! Relative path to the probe data file in the case directory + !! to the probe data file in the case directory integer :: i !< Generic loop iterator logical :: file_exist do i = 1, num_probes - ! Generating the relative path to the data file + ! the relative path to the data file write (file_path, '(A,I0,A)') '/D/probe', i, '_prim.dat' file_path = trim(case_dir)//trim(file_path) - ! Creating the formatted data file and setting up its - ! structure + ! the formatted data file and setting up its + ! inquire (file=trim(file_path), exist=file_exist) if (file_exist) then @@ -256,12 +256,12 @@ contains end subroutine s_open_probe_files !> The goal of the procedure is to output to the run-time - !! information file the stability criteria extrema in the - !! entire computational domain and at the given time-step. - !! Moreover, the subroutine is also in charge of tracking - !! these stability criteria extrema over all time-steps. - !! @param q_prim_vf Cell-average primitive variables - !! @param t_step Current time step + !! the stability criteria extrema in the + !! domain and at the given time-step. + !! subroutine is also in charge of tracking + !! criteria extrema over all time-steps. + !! Cell-average primitive variables + !! Current time step impure subroutine s_write_run_time_information(q_prim_vf, t_step) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf @@ -285,7 +285,7 @@ contains real(wp), dimension(2) :: Re !< Cell-avg. Reynolds numbers integer :: j, k, l - ! Computing Stability Criteria at Current Time-step + ! Stability Criteria at Current Time-step $:GPU_PARALLEL_LOOP(collapse=3, private='[j,k,l,vel, alpha, Re, rho, vel_sum, pres, gamma, pi_inf, c, H, qv]') do l = 0, p do k = 0, n @@ -305,9 +305,9 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! end: Computing Stability Criteria at Current Time-step + ! Computing Stability Criteria at Current Time-step - ! Determining local stability criteria extrema at current time-step + ! local stability criteria extrema at current time-step #ifdef _CRAYFTN $:GPU_UPDATE(host='[icfl_sf]') @@ -334,7 +334,7 @@ contains end if #endif - ! Determining global stability criteria extrema at current time-step + ! global stability criteria extrema at current time-step if (num_procs > 1) then call s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, & vcfl_max_loc, & @@ -348,7 +348,7 @@ contains if (viscous) Rc_min_glb = Rc_min_loc end if - ! Determining the stability criteria extrema over all the time-steps + ! the stability criteria extrema over all the time-steps if (icfl_max_glb > icfl_max) icfl_max = icfl_max_glb if (viscous) then @@ -356,7 +356,7 @@ contains if (Rc_min_glb < Rc_min) Rc_min = Rc_min_glb end if - ! Outputting global stability criteria extrema at current time-step + ! global stability criteria extrema at current time-step if (proc_rank == 0) then write (3, '(13X,I9,13X,F10.6,13X,F10.6,13X,F10.6)', advance="no") & t_step, dt, mytime, icfl_max_glb @@ -391,10 +391,10 @@ contains end subroutine s_write_run_time_information !> The goal of this subroutine is to output the grid and - !! conservative variables data files for given time-step. - !! @param q_cons_vf Cell-average conservative variables - !! @param q_prim_vf Cell-average primitive variables - !! @param t_step Current time-step + !! data files for given time-step. + !! Cell-average conservative variables + !! Cell-average primitive variables + !! Current time-step impure subroutine s_write_serial_data_files(q_cons_vf, q_T_sf, q_prim_vf, t_step, bc_type, beta) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -405,13 +405,13 @@ contains type(integer_field), dimension(1:num_dims, -1:1), intent(in) :: bc_type character(LEN=path_len + 2*name_len) :: t_step_dir !< - !! Relative path to the current time-step directory + !! to the current time-step directory character(LEN=path_len + 3*name_len) :: file_path !< - !! Relative path to the grid and conservative variables data files + !! to the grid and conservative variables data files logical :: file_exist !< - !! Logical used to check existence of current time-step directory + !! to check existence of current time-step directory character(LEN=15) :: FMT @@ -419,10 +419,10 @@ contains real(wp) :: gamma, lit_gamma, pi_inf, qv !< Temporary EOS params - ! Creating or overwriting the time-step root directory + ! or overwriting the time-step root directory write (t_step_dir, '(A,I0,A,I0)') trim(case_dir)//'/p_all' - ! Creating or overwriting the current time-step directory + ! or overwriting the current time-step directory write (t_step_dir, '(a,i0,a,i0)') trim(case_dir)//'/p_all/p', & proc_rank, '/', t_step @@ -431,7 +431,7 @@ contains if (file_exist) call s_delete_directory(trim(t_step_dir)) call s_create_directory(trim(t_step_dir)) - ! Writing the grid data file in the x-direction + ! the grid data file in the x-direction file_path = trim(t_step_dir)//'/x_cb.dat' open (2, FILE=trim(file_path), & @@ -439,7 +439,7 @@ contains STATUS='new') write (2) x_cb(-1:m); close (2) - ! Writing the grid data files in the y- and z-directions + ! the grid data files in the y- and z-directions if (n > 0) then file_path = trim(t_step_dir)//'/y_cb.dat' @@ -462,7 +462,7 @@ contains end if - ! Writing the conservative variables data files + ! the conservative variables data files do i = 1, sys_size write (file_path, '(A,I0,A)') trim(t_step_dir)//'/q_cons_vf', & i, '.dat' @@ -502,7 +502,7 @@ contains end do end if - ! Writing the IB markers + ! the IB markers if (ib) then write (file_path, '(A,I0,A)') trim(t_step_dir)//'/ib.dat' @@ -524,7 +524,7 @@ contains FMT = "(2F40.14)" end if - ! writing an output directory + ! an output directory write (t_step_dir, '(A,I0,A,I0)') trim(case_dir)//'/D' file_path = trim(t_step_dir)//'/.' @@ -537,7 +537,7 @@ contains do i = 1, sys_size $:GPU_UPDATE(host='[q_prim_vf(i)%sf(:,:,:)]') end do - ! q_prim_vf(bubxb) stores the value of nb needed in riemann solvers, so replace with true primitive value (=1._wp) + ! stores the value of nb needed in riemann solvers, so replace with true primitive value (=1._wp) if (qbmm) then q_prim_vf(bubxb)%sf = 1._wp end if @@ -552,7 +552,7 @@ contains open (2, FILE=trim(file_path)) do j = 0, m - ! todo: revisit change here + ! revisit change here if (((i >= adv_idx%beg) .and. (i <= adv_idx%end))) then write (2, FMT) x_cb(j), q_cons_vf(i)%sf(j, 0, 0) else @@ -605,7 +605,7 @@ contains FMT = "(3F40.14)" end if - ! 2D + ! if ((n > 0) .and. (p == 0)) then do i = 1, sys_size write (file_path, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -690,7 +690,7 @@ contains FMT = "(4F40.14)" end if - ! 3D + ! if (p > 0) then do i = 1, sys_size write (file_path, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -787,10 +787,10 @@ contains end subroutine s_write_serial_data_files !> The goal of this subroutine is to output the grid and - !! conservative variables data files for given time-step. - !! @param q_cons_vf Cell-average conservative variables - !! @param t_step Current time-step - !! @param beta Eulerian void fraction from lagrangian bubbles + !! data files for given time-step. + !! Cell-average conservative variables + !! Current time-step + !! Eulerian void fraction from lagrangian bubbles impure subroutine s_write_parallel_data_files(q_cons_vf, t_step, bc_type, beta) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -818,7 +818,7 @@ contains integer :: alt_sys !< Altered system size for the lagrangian subgrid bubble model - ! Down sampling variables + ! sampling variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_save, n_glb_save, p_glb_save ! Global save size @@ -838,7 +838,7 @@ contains call s_int_to_str(t_step, t_step_string) - ! Initialize MPI data I/O + ! MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_temp_ds) else @@ -860,10 +860,10 @@ contains call s_mpi_barrier() call DelayFileAccess(proc_rank) - ! Initialize MPI data I/O + ! MPI data I/O call s_initialize_mpi_data(q_cons_vf) - ! Open the file to write all flow variables + ! the file to write all flow variables write (file_loc, '(I0,A,i7.7,A)') t_step, '_', proc_rank, '.dat' file_loc = trim(case_dir)//'/restart_data/lustre_'//trim(t_step_string)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -874,20 +874,20 @@ contains mpi_info_int, ifile, ierr) if (down_sample) then - ! Size of local arrays + ! of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_save = m_glb_ds + 1 n_glb_save = n_glb_ds + 1 p_glb_save = p_glb_ds + 1 else - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_save = m_glb + 1 n_glb_save = n_glb + 1 p_glb_save = p_glb + 1 end if - ! Resize some integers so MPI can write even the biggest files + ! some integers so MPI can write even the biggest files m_MOK = int(m_glb_save + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb_save + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb_save + 1, MPI_OFFSET_KIND) @@ -897,7 +897,7 @@ contains NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) if (bubbles_euler) then - ! Write the data for each variable + ! the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) @@ -933,7 +933,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) else - ! Initialize MPI data I/O + ! MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, levelset, levelset_norm) @@ -952,10 +952,10 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! Resize some integers so MPI can write even the biggest files + ! some integers so MPI can write even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -965,11 +965,11 @@ contains NVARS_MOK = int(alt_sys, MPI_OFFSET_KIND) if (bubbles_euler) then - ! Write the data for each variable + ! the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -982,7 +982,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -995,7 +995,7 @@ contains do i = 1, sys_size !TODO: check if correct (sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -1005,11 +1005,11 @@ contains end do end if - ! Correction for the lagrangian subgrid bubble model + ! for the lagrangian subgrid bubble model if (present(beta)) then var_MOK = int(sys_size + 1, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(sys_size + 1), & @@ -1043,10 +1043,10 @@ contains end subroutine s_write_parallel_data_files !> This writes a formatted data file where the root processor - !! can write out the CoM information - !! @param t_step Current time-step - !! @param q_com Center of mass information - !! @param moments Higher moment information + !! out the CoM information + !! Current time-step + !! Center of mass information + !! Higher moment information impure subroutine s_write_com_files(t_step, c_mass_in) integer, intent(in) :: t_step @@ -1054,7 +1054,7 @@ contains integer :: i !< Generic loop iterator real(wp) :: nondim_time !< Non-dimensional time - ! Non-dimensional time calculation + ! time calculation if (t_step_old /= dflt_int) then nondim_time = real(t_step + t_step_old, wp)*dt else @@ -1095,9 +1095,9 @@ contains end subroutine s_write_com_files !> This writes a formatted data file for the flow probe information - !! @param t_step Current time-step - !! @param q_cons_vf Conservative variables - !! @param accel_mag Acceleration magnitude information + !! Current time-step + !! Conservative variables + !! Acceleration magnitude information impure subroutine s_write_probe_files(t_step, q_cons_vf, accel_mag) integer, intent(in) :: t_step @@ -1108,9 +1108,9 @@ contains real(wp), dimension(-1:n) :: disty real(wp), dimension(-1:p) :: distz - ! The cell-averaged partial densities, density, velocity, pressure, - ! volume fractions, specific heat ratio function, liquid stiffness - ! function, and sound speed. + ! cell-averaged partial densities, density, velocity, pressure, + ! fractions, specific heat ratio function, liquid stiffness + ! and sound speed. real(wp) :: lit_gamma, nbub real(wp) :: rho real(wp), dimension(num_vels) :: vel @@ -1142,7 +1142,7 @@ contains real(wp) :: nondim_time !< Non-dimensional time real(wp) :: tmp !< - !! Temporary variable to store quantity for mpi_allreduce + !! to store quantity for mpi_allreduce integer :: npts !< Number of included integral points real(wp) :: rad, thickness !< For integral quantities @@ -1152,7 +1152,7 @@ contains T = dflt_T_guess - ! Non-dimensional time calculation + ! time calculation if (time_stepper == 23) then nondim_time = mytime else @@ -1164,7 +1164,7 @@ contains end if do i = 1, num_probes - ! Zeroing out flow variables for all processors + ! out flow variables for all processors rho = 0._wp do s = 1, num_vels vel(s) = 0._wp @@ -1191,8 +1191,8 @@ contains end do damage_state = 0._wp - ! Find probe location in terms of indices on a - ! specific processor + ! probe location in terms of indices on a + ! processor if (n == 0) then ! 1D simulation if ((probe(i)%x >= x_cb(-1)) .and. (probe(i)%x <= x_cb(m))) then do s = -1, m @@ -1210,7 +1210,7 @@ contains end do end if - ! Computing/Sharing necessary state variables + ! necessary state variables if (elasticity) then call s_convert_to_mixture_variables(q_cons_vf, j - 2, k, l, & rho, gamma, pi_inf, qv, & @@ -1297,7 +1297,7 @@ contains ptot = pres - ptilde end if - ! Compute mixture sound Speed + ! mixture sound Speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1326,7 +1326,7 @@ contains if (k == 1) k = 2 ! Pick first point if probe is at edge l = 0 - ! Computing/Sharing necessary state variables + ! necessary state variables call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l, & rho, gamma, pi_inf, qv, & Re, G_local, fluid_pp(:)%G) @@ -1387,7 +1387,7 @@ contains R(:) = nR(:)/nbub Rdot(:) = nRdot(:)/nbub end if - ! Compute mixture sound speed + ! mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1416,7 +1416,7 @@ contains if (k == 1) k = 2 ! Pick first point if probe is at edge if (l == 1) l = 2 ! Pick first point if probe is at edge - ! Computing/Sharing necessary state variables + ! necessary state variables call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l - 2, & rho, gamma, pi_inf, qv, & Re, G_local, fluid_pp(:)%G) @@ -1452,7 +1452,7 @@ contains rhoYks, pres, T) end if - ! Compute mixture sound speed + ! mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1529,8 +1529,8 @@ contains Rdot(1), & nR(1), & nRdot(1) - ! ptilde, & - ! ptot + ! & + ! end if else if (bubbles_euler .and. (num_fluids == 3)) then write (i + 30, '(6x,f12.6,f24.8,f24.8,f24.8,f24.8,f24.8,'// & @@ -1766,15 +1766,15 @@ contains end subroutine s_write_probe_files !> The goal of this subroutine is to write to the run-time - !! information file basic footer information applicable to - !! the current computation and to close the file when done. - !! The footer contains the stability criteria extrema over - !! all of the time-steps and the simulation run-time. + !! basic footer information applicable to + !! computation and to close the file when done. + !! contains the stability criteria extrema over + !! the time-steps and the simulation run-time. impure subroutine s_close_run_time_information_file real(wp) :: run_time !< Run-time of the simulation - ! Writing the footer of and closing the run-time information file + ! the footer of and closing the run-time information file write (3, '(A)') ' ' write (3, '(A)') '' @@ -1813,13 +1813,13 @@ contains end subroutine s_close_probe_files !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_data_output_module integer :: i, m_ds, n_ds, p_ds - ! Allocating/initializing ICFL, VCFL, CCFL and Rc stability criteria + ! ICFL, VCFL, CCFL and Rc stability criteria if (run_time_info) then @:ALLOCATE(icfl_sf(0:m, 0:n, 0:p)) icfl_max = 0._wp @@ -1860,7 +1860,7 @@ contains end if if (run_time_info) then - ! Deallocating the ICFL, VCFL, CCFL, and Rc stability criteria + ! the ICFL, VCFL, CCFL, and Rc stability criteria @:DEALLOCATE(icfl_sf) if (viscous) then @:DEALLOCATE(vcfl_sf, Rc_sf) diff --git a/src/simulation/m_derived_variables.fpp b/src/simulation/m_derived_variables.fpp index 81cd185c4c..86cd7a5ac9 100644 --- a/src/simulation/m_derived_variables.fpp +++ b/src/simulation/m_derived_variables.fpp @@ -1,12 +1,12 @@ !> -!! @file m_derived_variables.f90 -!! @brief Contains module m_derived_variables +!! +!! module m_derived_variables !> @brief This module features subroutines that allow for the derivation of -!! numerous flow variables from the conservative and primitive ones. -!! Currently, the available derived variables include the unadvected -!! volume fraction, specific heat ratio, liquid stiffness, speed of -!! sound, vorticity and the numerical Schlieren function. +!! variables from the conservative and primitive ones. +!! available derived variables include the unadvected +!! specific heat ratio, liquid stiffness, speed of +!! and the numerical Schlieren function. #:include 'macros.fpp' module m_derived_variables @@ -33,10 +33,10 @@ module m_derived_variables s_finalize_derived_variables_module !> @name Finite-difference coefficients - !! Finite-difference (fd) coefficients in x-, y- and z-coordinate directions. - !! Note that because sufficient boundary information is available for all the - !! active coordinate directions, the centered family of the finite-difference - !! schemes is used. + !! coefficients in x-, y- and z-coordinate directions. + !! because sufficient boundary information is available for all the + !! directions, the centered family of the finite-difference + !! used. !> @{ real(wp), public, allocatable, dimension(:, :) :: fd_coeff_x real(wp), public, allocatable, dimension(:, :) :: fd_coeff_y @@ -45,7 +45,7 @@ module m_derived_variables $:GPU_DECLARE(create='[fd_coeff_x,fd_coeff_y,fd_coeff_z]') - ! @name Variables for computing acceleration + ! Variables for computing acceleration !> @{ real(wp), public, allocatable, dimension(:, :, :) :: accel_mag real(wp), public, allocatable, dimension(:, :, :) :: x_accel, y_accel, z_accel @@ -55,18 +55,18 @@ module m_derived_variables contains !> Computation of parameters, allocation procedures, and/or - !! any other tasks needed to properly setup the module + !! tasks needed to properly setup the module impure subroutine s_initialize_derived_variables_module - ! Allocating the variables which will store the coefficients of the - ! centered family of finite-difference schemes. Note that sufficient - ! space is allocated so that the coefficients up to any chosen order - ! of accuracy may be bookkept. However, if higher than fourth-order - ! accuracy coefficients are wanted, the formulae required to compute - ! these coefficients will have to be implemented in the subroutine - ! s_compute_finite_difference_coefficients. + ! the variables which will store the coefficients of the + ! family of finite-difference schemes. Note that sufficient + ! is allocated so that the coefficients up to any chosen order + ! accuracy may be bookkept. However, if higher than fourth-order + ! coefficients are wanted, the formulae required to compute + ! coefficients will have to be implemented in the subroutine + ! - ! Allocating centered finite-difference coefficients + ! centered finite-difference coefficients if (probe_wrt) then @:ALLOCATE(fd_coeff_x(-fd_number:fd_number, 0:m)) if (n > 0) then @@ -92,12 +92,12 @@ contains impure subroutine s_initialize_derived_variables if (probe_wrt) then - ! Opening and writing header of flow probe files + ! and writing header of flow probe files if (proc_rank == 0) then call s_open_probe_files() call s_open_com_files() end if - ! Computing centered finite difference coefficients + ! centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x]') @@ -117,7 +117,7 @@ contains end subroutine s_initialize_derived_variables !> Writes coherent body information, communication files, and probes. - !! @param t_step Current time-step + !! Current time-step subroutine s_compute_derived_variables(t_step, q_cons_vf, q_prim_ts1, q_prim_ts2) integer, intent(in) :: t_step @@ -177,17 +177,17 @@ contains end subroutine s_compute_derived_variables !> This subroutine receives as inputs the indicator of the - !! component of the acceleration that should be outputted and - !! the primitive variables. From those inputs, it proceeds - !! to calculate values of the desired acceleration component, - !! which are subsequently stored in derived flow quantity - !! storage variable, q_sf. - !! @param i Acceleration component indicator - !! @param q_prim_vf0 Primitive variables - !! @param q_prim_vf1 Primitive variables - !! @param q_prim_vf2 Primitive variables - !! @param q_prim_vf3 Primitive variables - !! @param q_sf Acceleration component + !! the acceleration that should be outputted and + !! variables. From those inputs, it proceeds + !! values of the desired acceleration component, + !! subsequently stored in derived flow quantity + !! q_sf. + !! Acceleration component indicator + !! Primitive variables + !! Primitive variables + !! Primitive variables + !! Primitive variables + !! Acceleration component subroutine s_derive_acceleration_component(i, q_prim_vf0, q_prim_vf1, & q_prim_vf2, q_prim_vf3, q_sf) @@ -202,7 +202,7 @@ contains integer :: j, k, l, r !< Generic loop iterators - ! Computing the acceleration component in the x-coordinate direction + ! the acceleration component in the x-coordinate direction if (i == 1) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -286,7 +286,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if end if - ! Computing the acceleration component in the y-coordinate direction + ! the acceleration component in the y-coordinate direction elseif (i == 2) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -357,7 +357,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if end if - ! Computing the acceleration component in the z-coordinate direction + ! the acceleration component in the z-coordinate direction else $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -416,12 +416,12 @@ contains end subroutine s_derive_acceleration_component !> This subroutine is used together with the volume fraction - !! model and when called upon, it computes the location of - !! of the center of mass for each fluid from the inputted - !! primitive variables, q_prim_vf. The computed location - !! is then written to a formatted data file by the root process. - !! @param q_prim_vf Primitive variables - !! @param c_m Mass,x-location,y-location,z-location + !! when called upon, it computes the location of + !! center of mass for each fluid from the inputted + !! q_prim_vf. The computed location + !! written to a formatted data file by the root process. + !! Primitive variables + !! Mass,x-location,y-location,z-location impure subroutine s_derive_center_of_mass(q_vf, c_m) type(scalar_field), dimension(sys_size), intent(IN) :: q_vf real(wp), dimension(1:num_fluids, 1:5), intent(INOUT) :: c_m @@ -447,13 +447,13 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids !Loop over individual fluids dV = dx(j) - ! Mass + ! $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! Volume fraction + ! fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -469,16 +469,16 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids !Loop over individual fluids dV = dx(j)*dy(k) - ! Mass + ! $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! y-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! Volume fraction + ! fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -495,19 +495,19 @@ contains do i = 1, num_fluids !Loop over individual fluids dV = dx(j)*dy(k)*dz(l) - ! Mass + ! $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! y-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! z-location weighted + ! weighted $:GPU_ATOMIC(atomic='update') c_m(i, 4) = c_m(i, 4) + q_vf(i)%sf(j, k, l)*dV*z_cc(l) - ! Volume fraction + ! fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -521,7 +521,7 @@ contains if (n == 0) then !1D simulation do i = 1, num_fluids !Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE + ! all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -533,12 +533,12 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! Compute quotients + ! quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) end do elseif (p == 0) then !2D simulation do i = 1, num_fluids !Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE + ! all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -553,13 +553,13 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! Compute quotients + ! quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) c_m(i, 3) = c_m(i, 3)/c_m(i, 1) end do else !3D simulation do i = 1, num_fluids !Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE + ! all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -577,7 +577,7 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! Compute quotients + ! quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) c_m(i, 3) = c_m(i, 3)/c_m(i, 1) c_m(i, 4) = c_m(i, 4)/c_m(i, 1) @@ -589,7 +589,7 @@ contains !> Deallocation procedures for the module impure subroutine s_finalize_derived_variables_module - ! Closing CoM and flow probe files + ! CoM and flow probe files if (proc_rank == 0) then call s_close_com_files() if (probe_wrt) then @@ -607,8 +607,8 @@ contains end if end if - ! Deallocating the variables that might have been used to bookkeep - ! the finite-difference coefficients in the x-, y- and z-directions + ! the variables that might have been used to bookkeep + ! finite-difference coefficients in the x-, y- and z-directions if (allocated(fd_coeff_x)) deallocate (fd_coeff_x) if (allocated(fd_coeff_y)) deallocate (fd_coeff_y) if (allocated(fd_coeff_z)) deallocate (fd_coeff_z) diff --git a/src/simulation/m_fftw.fpp b/src/simulation/m_fftw.fpp index 411485af10..c90b0a9d83 100644 --- a/src/simulation/m_fftw.fpp +++ b/src/simulation/m_fftw.fpp @@ -1,6 +1,6 @@ !> -!! @file m_fftw.f90 -!! @brief Contains module m_fftw +!! +!! module m_fftw #:include 'macros.fpp' @@ -39,10 +39,10 @@ module m_fftw real(c_double), pointer :: data_real(:) !< Real data complex(c_double_complex), pointer :: data_cmplx(:) !< - !! Complex data in Fourier space + !! in Fourier space complex(c_double_complex), pointer :: data_fltr_cmplx(:) !< - !! Filtered complex data in Fourier space + !! data in Fourier space #if defined(MFC_GPU) $:GPU_DECLARE(create='[real_size,cmplx_size,x_size,batch_size,Nfq]') @@ -52,11 +52,15 @@ module m_fftw complex(dp), allocatable, target :: data_fltr_cmplx_gpu(:) $:GPU_DECLARE(create='[data_real_gpu,data_cmplx_gpu,data_fltr_cmplx_gpu]') +!> @cond #if defined(__PGI) integer :: fwd_plan_gpu, bwd_plan_gpu #else - type(c_ptr) :: fwd_plan_gpu, bwd_plan_gpu +!> @endcond + type(c_ptr) :: fwd_plan_gpu, bwd_plan_gpu !< GPU FFT plan handles +!> @cond #endif +!> @endcond integer, allocatable :: gpu_fft_size(:), iembed(:), oembed(:) @@ -66,15 +70,15 @@ module m_fftw contains !> The purpose of this subroutine is to create the fftw plan - !! that will be used in the forward and backward DFTs when - !! applying the Fourier filter in the azimuthal direction. + !! be used in the forward and backward DFTs when + !! Fourier filter in the azimuthal direction. impure subroutine s_initialize_fftw_module integer :: ierr !< Generic flag used to identify and report GPU errors - ! Size of input array going into DFT + ! of input array going into DFT real_size = p + 1 - ! Size of output array coming out of DFT + ! of output array coming out of DFT cmplx_size = (p + 1)/2 + 1 x_size = m + 1 @@ -91,16 +95,16 @@ contains $:GPU_ENTER_DATA(copyin='[real_size,cmplx_size,x_size,sys_size,batch_size,Nfq]') $:GPU_UPDATE(device='[real_size,cmplx_size,x_size,sys_size,batch_size]') #else - ! Allocate input and output DFT data sizes + ! input and output DFT data sizes fftw_real_data = fftw_alloc_real(int(real_size, c_size_t)) fftw_cmplx_data = fftw_alloc_complex(int(cmplx_size, c_size_t)) fftw_fltr_cmplx_data = fftw_alloc_complex(int(cmplx_size, c_size_t)) - ! Associate input and output data pointers with allocated memory + ! input and output data pointers with allocated memory call c_f_pointer(fftw_real_data, data_real, [real_size]) call c_f_pointer(fftw_cmplx_data, data_cmplx, [cmplx_size]) call c_f_pointer(fftw_fltr_cmplx_data, data_fltr_cmplx, [cmplx_size]) - ! Generate plans for forward and backward DFTs + ! plans for forward and backward DFTs fwd_plan = fftw_plan_dft_r2c_1d(real_size, data_real, data_cmplx, FFTW_ESTIMATE) bwd_plan = fftw_plan_dft_c2r_1d(real_size, data_fltr_cmplx, data_real, FFTW_ESTIMATE) #endif @@ -123,17 +127,17 @@ contains end subroutine s_initialize_fftw_module !> The purpose of this subroutine is to apply a Fourier low- - !! pass filter to the flow variables in the azimuthal direction - !! to remove the high-frequency content. This alleviates the - !! restrictive CFL condition arising from cells near the axis. - !! @param q_cons_vf Conservative variables + !! to the flow variables in the azimuthal direction + !! the high-frequency content. This alleviates the + !! condition arising from cells near the axis. + !! Conservative variables impure subroutine s_apply_fourier_filter(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer :: i, j, k, l !< Generic loop iterators integer :: ierr !< Generic flag used to identify and report GPU errors - ! Restrict filter to processors that have cells adjacent to axis + ! filter to processors that have cells adjacent to axis if (bc_y%beg >= 0) return #if defined(MFC_GPU) @@ -277,7 +281,7 @@ contains end do end do - ! Apply Fourier filter to additional rings + ! Fourier filter to additional rings do i = 1, fourier_rings Nfq = min(floor(2_dp*real(i, dp)*pi), cmplx_size) do j = 0, m @@ -297,8 +301,8 @@ contains end subroutine s_apply_fourier_filter !> The purpose of this subroutine is to destroy the fftw plan - !! that will be used in the forward and backward DFTs when - !! applying the Fourier filter in the azimuthal direction. + !! be used in the forward and backward DFTs when + !! Fourier filter in the azimuthal direction. impure subroutine s_finalize_fftw_module #if defined(MFC_GPU) diff --git a/src/simulation/m_global_parameters.fpp b/src/simulation/m_global_parameters.fpp index 78d8d1a7c0..7d23d6751c 100644 --- a/src/simulation/m_global_parameters.fpp +++ b/src/simulation/m_global_parameters.fpp @@ -1,16 +1,16 @@ !> -!! @file m_global_parameters.f90 -!! @brief Contains module m_global_parameters +!! +!! module m_global_parameters #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains all of the parameters describing the program -!! logistics, the computational domain and the simulation algorithm. -!! Additionally, for the volume fraction model, physical parameters -!! of each of the fluids present in the flow are located here. They -!! include stiffened gas equation of state parameters, the Reynolds -!! numbers and the Weber numbers. +!! computational domain and the simulation algorithm. +!! the volume fraction model, physical parameters +!! of the fluids present in the flow are located here. They +!! gas equation of state parameters, the Reynolds +!! the Weber numbers. module m_global_parameters #ifdef MFC_MPI @@ -21,20 +21,20 @@ module m_global_parameters use m_helper_basic !< Functions to compare floating point numbers - ! $:USE_GPU_MODULE() + ! implicit none real(wp) :: wall_time = 0 real(wp) :: wall_time_avg = 0 - ! Logistics + ! integer :: num_procs !< Number of processors character(LEN=path_len) :: case_dir !< Case folder location logical :: run_time_info !< Run-time output flag integer :: t_step_old !< Existing IC/grid folder - ! Computational Domain Parameters + ! Domain Parameters integer :: proc_rank !< Rank of the local processor !> @name Number of cells in the x-, y- and z-directions, respectively @@ -69,7 +69,7 @@ module m_global_parameters real(wp), target, allocatable, dimension(:) :: x_cc, y_cc, z_cc !> @} !type(bounds_info) :: x_domain, y_domain, z_domain !< - !! Locations of the domain bounds in the x-, y- and z-coordinate directions + !! the domain bounds in the x-, y- and z-coordinate directions !> @name Cell-width distributions in the x-, y- and z-directions, respectively !> @{ @@ -81,13 +81,13 @@ module m_global_parameters $:GPU_DECLARE(create='[x_cb,y_cb,z_cb,x_cc,y_cc,z_cc,dx,dy,dz,dt,m,n,p]') !> @name Starting time-step iteration, stopping time-step iteration and the number - !! of time-step iterations between successive solution backups, respectively + !! iterations between successive solution backups, respectively !> @{ integer :: t_step_start, t_step_stop, t_step_save !> @} !> @name Starting time, stopping time, and time between backups, simulation time, - !! and prescribed cfl respectively + !! cfl respectively !> @{ real(wp) :: t_stop, t_save, cfl_target integer :: n_start @@ -98,7 +98,7 @@ module m_global_parameters integer :: t_step_print !< Number of time-steps between printouts - ! Simulation Algorithm Parameters + ! Algorithm Parameters integer :: model_eqns !< Multicomponent flow model #:if MFC_CASE_OPTIMIZATION integer, parameter :: num_dims = ${num_dims}$ !< Number of spatial dimensions @@ -159,9 +159,9 @@ module m_global_parameters !> @{ logical :: nv_uvm_out_of_core ! Enable out-of-core storage of q_cons_ts(2) in timestepping (default FALSE) integer :: nv_uvm_igr_temps_on_gpu ! 0 => jac, jac_rhs, and jac_old on CPU - ! 1 => jac on GPU, jac_rhs and jac_old on CPU - ! 2 => jac and jac_rhs on GPU, jac_old on CPU - ! 3 => jac, jac_rhs, and jac_old on GPU (default) + ! => jac on GPU, jac_rhs and jac_old on CPU + ! => jac and jac_rhs on GPU, jac_old on CPU + ! => jac, jac_rhs, and jac_old on GPU (default) logical :: nv_uvm_pref_gpu ! Enable explicit gpu memory hints (default FALSE) !> @} @@ -203,7 +203,7 @@ module m_global_parameters #:endfor real(wp), dimension(3) :: accel_bf $:GPU_DECLARE(create='[accel_bf]') - ! $:GPU_DECLARE(create='[k_x,w_x,p_x,g_x,k_y,w_y,p_y,g_y,k_z,w_z,p_z,g_z]') + ! integer :: cpu_start, cpu_end, cpu_rate @@ -251,10 +251,10 @@ module m_global_parameters $:GPU_DECLARE(create='[down_sample]') integer, allocatable, dimension(:) :: proc_coords !< - !! Processor coordinates in MPI_CART_COMM + !! in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! Starting cell-center index of local processor in global grid + !! index of local processor in global grid type(mpi_io_var), public :: MPI_IO_DATA type(mpi_io_ib_var), public :: MPI_IO_IB_DATA @@ -270,7 +270,7 @@ module m_global_parameters !> @} !> @name Annotations of the structure of the state and flux vectors in terms of the - !! size and the configuration of the system of equations to which they belong + !! the configuration of the system of equations to which they belong !> @{ integer :: sys_size !< Number of unknowns in system of eqns. type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns. @@ -297,20 +297,20 @@ module m_global_parameters $:GPU_DECLARE(create='[pi_inf_idx,B_idx,stress_idx,xi_idx,b_size]') $:GPU_DECLARE(create='[tensor_size,species_idx,c_idx]') - ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). - ! Stands for "InDices With INTerior". + ! Indices for the (local) interior points (O-m, O-n, 0-p). + ! for "InDices With INTerior". type(int_bounds_info) :: idwint(1:3) $:GPU_DECLARE(create='[idwint]') - ! Cell Indices for the entire (local) domain. In simulation and post_process, - ! this includes the buffer region. idwbuff and idwint are the same otherwise. - ! Stands for "InDices With BUFFer". + ! Indices for the entire (local) domain. In simulation and post_process, + ! includes the buffer region. idwbuff and idwint are the same otherwise. + ! for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) $:GPU_DECLARE(create='[idwbuff]') !> @name The number of fluids, along with their identifying indexes, respectively, - !! for which viscous effects, e.g. the shear and/or the volume Reynolds (Re) - !! numbers, will be non-negligible. + !! viscous effects, e.g. the shear and/or the volume Reynolds (Re) + !! be non-negligible. !> @{ integer, dimension(2) :: Re_size integer :: Re_size_max @@ -319,11 +319,11 @@ module m_global_parameters $:GPU_DECLARE(create='[Re_size,Re_size_max,Re_idx]') - ! The WENO average (WA) flag regulates whether the calculation of any cell- - ! average spatial derivatives is carried out in each cell by utilizing the - ! arithmetic mean of the left and right, WENO-reconstructed, cell-boundary - ! values or simply, the unaltered left and right, WENO-reconstructed, cell- - ! boundary values. + ! WENO average (WA) flag regulates whether the calculation of any cell- + ! spatial derivatives is carried out in each cell by utilizing the + ! mean of the left and right, WENO-reconstructed, cell-boundary + ! or simply, the unaltered left and right, WENO-reconstructed, cell- + ! values. !> @{ real(wp) :: wa_flg !> @{ @@ -331,9 +331,9 @@ module m_global_parameters $:GPU_DECLARE(create='[wa_flg]') !> @name The coordinate direction indexes and flags (flg), respectively, for which - !! the configurations will be determined with respect to a working direction - !! and that will be used to isolate the contributions, in that direction, in - !! the dimensionally split system of equations. + !! will be determined with respect to a working direction + !! will be used to isolate the contributions, in that direction, in + !! split system of equations. !> @{ integer, dimension(3) :: dir_idx real(wp), dimension(3) :: dir_flg @@ -343,44 +343,44 @@ module m_global_parameters $:GPU_DECLARE(create='[dir_idx,dir_flg,dir_idx_tau]') integer :: buff_size !< - !! The number of cells that are necessary to be able to store enough boundary - !! conditions data to march the solution in the physical computational domain - !! to the next time-step. + !! of cells that are necessary to be able to store enough boundary + !! to march the solution in the physical computational domain + !! next time-step. $:GPU_DECLARE(create='[buff_size]') integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! Indices of the stress components that represent shear stress + !! the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! Number of shear stress components to reflect for boundary conditions + !! shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! Indices of shear stress components to reflect for boundary conditions. - !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! shear stress components to reflect for boundary conditions. + !! 1:shear_BC_flip_num) for (x/y/z, [indices]) $:GPU_DECLARE(create='[shear_num,shear_indices,shear_BC_flip_num,shear_BC_flip_indices]') - ! END: Simulation Algorithm Parameters + ! Simulation Algorithm Parameters - ! Fluids Physical Parameters + ! Physical Parameters type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! Database of the physical parameters of each of the fluids that is present - !! in the flow. These include the stiffened gas equation of state parameters, - !! and the Reynolds numbers. + !! the physical parameters of each of the fluids that is present + !! flow. These include the stiffened gas equation of state parameters, + !! Reynolds numbers. - ! Subgrid Bubble Parameters + ! Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp integer :: fd_order !< - !! The order of the finite-difference (fd) approximations of the first-order - !! derivatives that need to be evaluated when the CoM or flow probe data - !! files are to be written at each time step + !! of the finite-difference (fd) approximations of the first-order + !! need to be evaluated when the CoM or flow probe data + !! to be written at each time step integer :: fd_number !< - !! The finite-difference number is given by MAX(1, fd_order/2). Essentially, - !! it is a measure of the half-size of the finite-difference stencil for the - !! selected order of accuracy. + !! number is given by MAX(1, fd_order/2). Essentially, + !! a measure of the half-size of the finite-difference stencil for the + !! of accuracy. $:GPU_DECLARE(create='[fd_order,fd_number]') logical :: probe_wrt @@ -404,10 +404,10 @@ module m_global_parameters type(ib_patch_parameters), dimension(num_patches_max) :: patch_ib type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l integer :: Np - !! Database of the immersed boundary patch parameters for each of the - !! patches employed in the configuration of the initial condition. Note that - !! the maximum allowable number of patches, num_patches_max, may be changed - !! in the module m_derived_types.f90. + !! the immersed boundary patch parameters for each of the + !! in the configuration of the initial condition. Note that + !! allowable number of patches, num_patches_max, may be changed + !! module m_derived_types.f90. $:GPU_DECLARE(create='[ib,num_ibs,patch_ib]') !> @} @@ -564,18 +564,18 @@ module m_global_parameters contains !> Assigns default values to the user inputs before reading - !! them in. This enables for an easier consistency check of - !! these parameters once they are read from the input file. + !! This enables for an easier consistency check of + !! once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i, j !< Generic loop iterator - ! Logistics + ! case_dir = '.' run_time_info = .false. t_step_old = dflt_int - ! Computational domain parameters + ! domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -597,12 +597,12 @@ contains t_stop = dflt_real t_save = dflt_real - ! NVIDIA UVM options + ! UVM options nv_uvm_out_of_core = .false. nv_uvm_igr_temps_on_gpu = 3 ! => jac, jac_rhs, and jac_old on GPU (default) nv_uvm_pref_gpu = .false. - ! Simulation algorithm parameters + ! algorithm parameters model_eqns = dflt_int mpp_lim = .false. time_stepper = dflt_int @@ -679,7 +679,7 @@ contains y_domain%beg = dflt_real; y_domain%end = dflt_real z_domain%beg = dflt_real; z_domain%end = dflt_real - ! Fluids physical parameters + ! physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -690,7 +690,7 @@ contains fluid_pp(i)%G = 0._wp end do - ! Subgrid bubble parameters + ! bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -712,15 +712,15 @@ contains bub_pp%R_v = dflt_real; R_v = dflt_real bub_pp%R_g = dflt_real; R_g = dflt_real - ! Tait EOS + ! EOS rhoref = dflt_real pref = dflt_real - ! Immersed Boundaries + ! Boundaries ib = .false. num_ibs = dflt_int - ! Bubble modeling + ! modeling bubbles_euler = .false. bubble_model = 1 polytropic = .true. @@ -744,7 +744,7 @@ contains pi_fac = 1._wp - ! User inputs for qbmm for simulation code + ! inputs for qbmm for simulation code qbmm = .false. Eu = dflt_real @@ -753,11 +753,11 @@ contains Web = dflt_real poly_sigma = dflt_real - ! Acoustic source + ! source acoustic_source = .false. num_source = dflt_int - ! Surface tension + ! tension sigma = dflt_real surface_tension = .false. @@ -823,14 +823,14 @@ contains integral(i)%ymax = dflt_real end do - ! GRCBC flags + ! flags #:for dir in {'x', 'y', 'z'} bc_${dir}$%grcbc_in = .false. bc_${dir}$%grcbc_out = .false. bc_${dir}$%grcbc_vel_out = .false. #:endfor - ! Lagrangian subgrid bubble model + ! subgrid bubble model bubbles_lagrange = .false. lag_params%solver_approach = dflt_int lag_params%cluster_type = dflt_int @@ -845,12 +845,12 @@ contains lag_params%charwidth = dflt_real lag_params%valmaxvoid = dflt_real - ! Continuum damage model + ! damage model tau_star = dflt_real cont_damage_s = dflt_real alpha_bar = dflt_real - ! MHD + ! Bx0 = dflt_real hyper_cleaning_speed = dflt_real hyper_cleaning_tau = dflt_real @@ -863,15 +863,15 @@ contains end subroutine s_assign_default_values_to_user_inputs !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_global_parameters_module integer :: i, j, k integer :: fac #:if not MFC_CASE_OPTIMIZATION - ! Determining the degree of the WENO polynomials + ! the degree of the WENO polynomials if (recon_type == WENO_TYPE) then weno_polyn = (weno_order - 1)/2 if (teno) then @@ -889,20 +889,20 @@ contains $:GPU_UPDATE(device='[igr,igr_order,igr_iter_solver]') #:endif - ! Initializing the number of fluids for which viscous effects will - ! be non-negligible, the number of distinctive material interfaces - ! for which surface tension will be important and also, the number - ! of fluids for which the physical and geometric curvatures of the - ! interfaces will be computed + ! the number of fluids for which viscous effects will + ! non-negligible, the number of distinctive material interfaces + ! which surface tension will be important and also, the number + ! fluids for which the physical and geometric curvatures of the + ! will be computed Re_size = 0 Re_size_max = 0 - ! Gamma/Pi_inf Model + ! Model if (model_eqns == 1) then - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the gamma/pi_inf model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -914,12 +914,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Volume Fraction Model + ! Fraction Model else - ! Annotating structure of the state and flux vectors belonging - ! to the system of equations defined by the selected number of - ! spatial dimensions and the volume fraction model + ! structure of the state and flux vectors belonging + ! the system of equations defined by the selected number of + ! dimensions and the volume fraction model if (model_eqns == 2) then cont_idx%beg = 1 cont_idx%end = num_fluids @@ -928,17 +928,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! Volume fractions are stored in the indices immediately following - ! the energy equation. IGR tracks a total of (N-1) volume fractions - ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! then adv_idx%end < adv_idx%beg, which skips all loops over the - ! volume fractions since there is no volume fraction to track + ! fractions are stored in the indices immediately following + ! energy equation. IGR tracks a total of (N-1) volume fractions + ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! adv_idx%end < adv_idx%beg, which skips all loops over the + ! fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 ! Alpha for fluid 1 adv_idx%end = E_idx + num_fluids - 1 else - ! Volume fractions are stored in the indices immediately following - ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! fractions are stored in the indices immediately following + ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -956,7 +956,7 @@ contains if (qbmm) then nmomsp = 4 !number of special moments if (nnode == 4) then - ! nmom = 6 : It is already a parameter + ! = 6 : It is already a parameter nmomtot = nmom*nb end if bub_idx%end = adv_idx%end + nb*nmom @@ -1071,8 +1071,8 @@ contains end if end if - ! Determining the number of fluids for which the shear and the - ! volume Reynolds numbers, e.g. viscous effects, are important + ! the number of fluids for which the shear and the + ! Reynolds numbers, e.g. viscous effects, are important do i = 1, num_fluids if (fluid_pp(i)%Re(1) > 0) Re_size(1) = Re_size(1) + 1 if (fluid_pp(i)%Re(2) > 0) Re_size(2) = Re_size(2) + 1 @@ -1085,8 +1085,8 @@ contains $:GPU_UPDATE(device='[Re_size,Re_size_max,shear_stress,bulk_stress]') - ! Bookkeeping the indexes of any viscous fluids and any pairs of - ! fluids whose interface will support effects of surface tension + ! the indexes of any viscous fluids and any pairs of + ! whose interface will support effects of surface tension if (viscous) then @:ALLOCATE(Re_idx(1:2, 1:Re_size_max)) @@ -1116,10 +1116,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! shear stress index is 2 for 2D and 2,4,5 for 3D + ! stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -1127,7 +1127,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! Both x-dir and y-dir: flip tau_xy only + ! x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -1135,21 +1135,21 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! x-dir: flip tau_xy and tau_xz - ! y-dir: flip tau_xy and tau_yz - ! z-dir: flip tau_xz and tau_yz + ! flip tau_xy and tau_xz + ! flip tau_xy and tau_yz + ! flip tau_xz and tau_yz end if $:GPU_UPDATE(device='[shear_num,shear_indices,shear_BC_flip_num,shear_BC_flip_indices]') end if if (hyperelasticity) then - ! number of entries in the symmetric btensor plus the jacobian + ! of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 - ! storing the jacobian in the last entry + ! the jacobian in the last entry tensor_size = num_dims**2 + 1 xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! adding three more equations for the \xi field and the elastic energy + ! three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 end if @@ -1170,7 +1170,7 @@ contains end if - ! END: Volume Fraction Model + ! Volume Fraction Model if (chemistry) then species_idx%beg = sys_size + 1 @@ -1207,15 +1207,15 @@ contains end do end if - ! Configuring the WENO average flag that will be used to regulate - ! whether any spatial derivatives are to computed in each cell by - ! using the arithmetic mean of left and right, WENO-reconstructed, - ! cell-boundary values or otherwise, the unaltered left and right, - ! WENO-reconstructed, cell-boundary values + ! the WENO average flag that will be used to regulate + ! any spatial derivatives are to computed in each cell by + ! the arithmetic mean of left and right, WENO-reconstructed, + ! values or otherwise, the unaltered left and right, + ! cell-boundary values wa_flg = 0._wp; if (weno_avg) wa_flg = 1._wp $:GPU_UPDATE(device='[wa_flg]') - ! Resort to default WENO-JS if no other WENO scheme is selected + ! to default WENO-JS if no other WENO scheme is selected #:if not MFC_CASE_OPTIMIZATION wenojs = .not. (mapped_weno .or. wenoz .or. teno) #:endif @@ -1242,7 +1242,7 @@ contains num_dims, igr, ib) $:GPU_UPDATE(device='[idwint, idwbuff]') - ! Configuring Coordinate Direction Indexes + ! Coordinate Direction Indexes if (bubbles_euler) then @:ALLOCATE(ptil(& & idwbuff(1)%beg:idwbuff(1)%end, & @@ -1316,7 +1316,7 @@ contains $:GPU_UPDATE(device='[relax,relax_model,palpha_eps,ptgalpha_eps]') - ! Allocating grid variables for the x-, y- and z-directions + ! grid variables for the x-, y- and z-directions @:ALLOCATE(x_cb(-1 - buff_size:m + buff_size)) @:ALLOCATE(x_cc(-buff_size:m + buff_size)) @:ALLOCATE(dx(-buff_size:m + buff_size)) @@ -1365,17 +1365,17 @@ contains #ifdef MFC_MPI - ! Option for Lustre file system (Darter/Comet/Stampede) + ! for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! Option for UNIX file system (Hooke/Thomson) - ! WRITE(mpiiofs, '(A)') '/ufs_' - ! mpiiofs = TRIM(mpiiofs) - ! mpi_info_int = MPI_INFO_NULL + ! for UNIX file system (Hooke/Thomson) + ! '(A)') '/ufs_' + ! = TRIM(mpiiofs) + ! = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1388,9 +1388,9 @@ contains integer :: i - ! Deallocating the variables bookkeeping the indexes of any viscous - ! fluids and any pairs of fluids whose interfaces supported effects - ! of surface tension + ! the variables bookkeeping the indexes of any viscous + ! and any pairs of fluids whose interfaces supported effects + ! surface tension if (viscous) then @:DEALLOCATE(Re_idx) end if @@ -1415,7 +1415,7 @@ contains if (ib) MPI_IO_IB_DATA%var%sf => null() - ! Deallocating grid variables for the x-, y- and z-directions + ! grid variables for the x-, y- and z-directions @:DEALLOCATE(x_cb, x_cc, dx) if (n == 0) return; diff --git a/src/simulation/m_hyperelastic.fpp b/src/simulation/m_hyperelastic.fpp index 9efc638ab9..cbc2eba49c 100644 --- a/src/simulation/m_hyperelastic.fpp +++ b/src/simulation/m_hyperelastic.fpp @@ -1,11 +1,11 @@ !> -!! @file m_hyperelastic.f90 -!! @brief Contains module m_hyperelastic +!! +!! module m_hyperelastic #:include 'macros.fpp' !> @brief This module consists of subroutines used in the calculation -!! of the cauchy tensor +!! cauchy tensor module m_hyperelastic @@ -23,8 +23,8 @@ module m_hyperelastic s_initialize_hyperelastic_module, & s_finalize_hyperelastic_module - !! The btensor at the cell-interior Gaussian quadrature points. - !! These tensor is needed to be calculated once and make the code DRY. + !! at the cell-interior Gaussian quadrature points. + !! is needed to be calculated once and make the code DRY. type(vector_field) :: btensor !< $:GPU_DECLARE(create='[btensor]') @@ -38,13 +38,13 @@ module m_hyperelastic contains !> The following subroutine handles the calculation of the btensor. - !! The calculation of the btensor takes qprimvf. - !! @param q_prim_vf Primitive variables - !! @param btensor is the output - !! calculate the grad_xi, grad_xi is a nxn tensor - !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor - !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor - !! btensor is symmetric, save the data space + !! of the btensor takes qprimvf. + !! Primitive variables + !! is the output + !! grad_xi, grad_xi is a nxn tensor + !! inverse of grad_xi to obtain F, F is a nxn tensor + !! FFtranspose to obtain the btensor, btensor is nxn tensor + !! symmetric, save the data space impure subroutine s_initialize_hyperelastic_module integer :: i !< generic iterator @@ -69,7 +69,7 @@ contains @:ALLOCATE(fd_coeff_z_hyper(-fd_number:fd_number, 0:p)) end if - ! Computing centered finite difference coefficients + ! centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x_hyper, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x_hyper]') @@ -87,13 +87,13 @@ contains end subroutine s_initialize_hyperelastic_module !> The following subroutine handles the calculation of the btensor. - !! The calculation of the btensor takes qprimvf. - !! @param q_prim_vf Primitive variables - !! @param btensor is the output - !! calculate the grad_xi, grad_xi is a nxn tensor - !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor - !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor - !! btensor is symmetric, save the data space + !! of the btensor takes qprimvf. + !! Primitive variables + !! is the output + !! grad_xi, grad_xi is a nxn tensor + !! inverse of grad_xi to obtain F, F is a nxn tensor + !! FFtranspose to obtain the btensor, btensor is nxn tensor + !! symmetric, save the data space subroutine s_hyperelastic_rmt_stress_update(q_cons_vf, q_prim_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -121,7 +121,7 @@ contains call s_compute_species_fraction(q_cons_vf, j, k, l, alpha_rho_k, alpha_k) - ! If in simulation, use acc mixture subroutines + ! in simulation, use acc mixture subroutines call s_convert_species_to_mixture_variables_acc(rho, gamma, pi_inf, qv, alpha_k, & alpha_rho_k, Re, G_local, Gs_hyper) rho = max(rho, sgm_eps) @@ -133,27 +133,27 @@ contains do i = 1, tensor_size tensora(i) = 0._wp end do - ! STEP 1: computing the grad_xi tensor using finite differences - ! grad_xi definition / organization - ! number for the tensor 1-3: dxix_dx, dxiy_dx, dxiz_dx - ! 4-6 : dxix_dy, dxiy_dy, dxiz_dy - ! 7-9 : dxix_dz, dxiy_dz, dxiz_dz + ! 1: computing the grad_xi tensor using finite differences + ! definition / organization + ! for the tensor 1-3: dxix_dx, dxiy_dx, dxiz_dx + ! : dxix_dy, dxiy_dy, dxiz_dy + ! : dxix_dz, dxiy_dz, dxiz_dz $:GPU_LOOP(parallelism='[seq]') do r = -fd_number, fd_number - ! derivatives in the x-direction + ! in the x-direction tensora(1) = tensora(1) + q_prim_vf(xibeg)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) tensora(2) = tensora(2) + q_prim_vf(xibeg + 1)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) tensora(3) = tensora(3) + q_prim_vf(xiend)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) - ! derivatives in the y-direction + ! in the y-direction tensora(4) = tensora(4) + q_prim_vf(xibeg)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) tensora(5) = tensora(5) + q_prim_vf(xibeg + 1)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) tensora(6) = tensora(6) + q_prim_vf(xiend)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) - ! derivatives in the z-direction + ! in the z-direction tensora(7) = tensora(7) + q_prim_vf(xibeg)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) tensora(8) = tensora(8) + q_prim_vf(xibeg + 1)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) tensora(9) = tensora(9) + q_prim_vf(xiend)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) end do - ! STEP 2a: computing the adjoint of the grad_xi tensor for the inverse + ! 2a: computing the adjoint of the grad_xi tensor for the inverse tensorb(1) = tensora(5)*tensora(9) - tensora(6)*tensora(8) tensorb(2) = -(tensora(2)*tensora(9) - tensora(3)*tensora(8)) tensorb(3) = tensora(2)*tensora(6) - tensora(3)*tensora(5) @@ -164,45 +164,45 @@ contains tensorb(8) = -(tensora(1)*tensora(8) - tensora(2)*tensora(7)) tensorb(9) = tensora(1)*tensora(5) - tensora(2)*tensora(4) - ! STEP 2b: computing the determinant of the grad_xi tensor + ! 2b: computing the determinant of the grad_xi tensor tensorb(tensor_size) = tensora(1)*(tensora(5)*tensora(9) - tensora(6)*tensora(8)) & - tensora(2)*(tensora(4)*tensora(9) - tensora(6)*tensora(7)) & + tensora(3)*(tensora(4)*tensora(8) - tensora(5)*tensora(7)) if (tensorb(tensor_size) > verysmall) then - ! STEP 2c: computing the inverse of grad_xi tensor = F - ! tensorb is the adjoint, tensora becomes F + ! 2c: computing the inverse of grad_xi tensor = F + ! is the adjoint, tensora becomes F $:GPU_LOOP(parallelism='[seq]') do i = 1, tensor_size - 1 tensora(i) = tensorb(i)/tensorb(tensor_size) end do - ! STEP 2d: computing the J = det(F) = 1/det(\grad{\xi}) + ! 2d: computing the J = det(F) = 1/det(\grad{\xi}) tensorb(tensor_size) = 1._wp/tensorb(tensor_size) - ! STEP 3: computing F transpose F + ! 3: computing F transpose F tensorb(1) = tensora(1)**2 + tensora(2)**2 + tensora(3)**2 tensorb(5) = tensora(4)**2 + tensora(5)**2 + tensora(6)**2 tensorb(9) = tensora(7)**2 + tensora(8)**2 + tensora(9)**2 tensorb(2) = tensora(1)*tensora(4) + tensora(2)*tensora(5) + tensora(3)*tensora(6) tensorb(3) = tensora(1)*tensora(7) + tensora(2)*tensora(8) + tensora(3)*tensora(9) tensorb(6) = tensora(4)*tensora(7) + tensora(5)*tensora(8) + tensora(6)*tensora(9) - ! STEP 4: update the btensor, this is consistent with Riemann solvers + ! 4: update the btensor, this is consistent with Riemann solvers #:for BIJ, TXY in [(1,1),(2,2),(3,5),(4,3),(5,6),(6,9)] btensor%vf(${BIJ}$)%sf(j, k, l) = tensorb(${TXY}$) #:endfor - ! store the determinant at the last entry of the btensor + ! the determinant at the last entry of the btensor btensor%vf(b_size)%sf(j, k, l) = tensorb(tensor_size) - ! STEP 5a: updating the Cauchy stress primitive scalar field + ! 5a: updating the Cauchy stress primitive scalar field if (hyper_model == 1) then call s_neoHookean_cauchy_solver(btensor%vf, q_prim_vf, G_local, j, k, l) elseif (hyper_model == 2) then call s_Mooney_Rivlin_cauchy_solver(btensor%vf, q_prim_vf, G_local, j, k, l) end if - ! STEP 5b: updating the pressure field + ! 5b: updating the pressure field q_prim_vf(E_idx)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) - & G_local*q_prim_vf(xiend + 1)%sf(j, k, l)/gamma - ! STEP 5c: updating the Cauchy stress conservative scalar field + ! 5c: updating the Cauchy stress conservative scalar field $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_cons_vf(strxb + i - 1)%sf(j, k, l) = & @@ -217,13 +217,13 @@ contains end subroutine s_hyperelastic_rmt_stress_update !> The following subroutine handles the calculation of the btensor. - !! The calculation of the btensor takes qprimvf. - !! @param q_prim_vf Primitive variables - !! @param btensor is the output - !! calculate the grad_xi, grad_xi is a nxn tensor - !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor - !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor - !! btensor is symmetric, save the data space + !! of the btensor takes qprimvf. + !! Primitive variables + !! is the output + !! grad_xi, grad_xi is a nxn tensor + !! inverse of grad_xi to obtain F, F is a nxn tensor + !! FFtranspose to obtain the btensor, btensor is nxn tensor + !! symmetric, save the data space subroutine s_neoHookean_cauchy_solver(btensor_in, q_prim_vf, G_param, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -235,34 +235,34 @@ contains real(wp), parameter :: f13 = 1._wp/3._wp integer :: i !< Generic loop iterators - ! tensor is the symmetric tensor & calculate the trace of the tensor + ! is the symmetric tensor & calculate the trace of the tensor trace = btensor_in(1)%sf(j, k, l) + btensor_in(3)%sf(j, k, l) + btensor_in(6)%sf(j, k, l) - ! calculate the deviatoric of the tensor + ! the deviatoric of the tensor #:for IJ in [1,3,6] btensor_in(${IJ}$)%sf(j, k, l) = btensor_in(${IJ}$)%sf(j, k, l) - f13*trace #:endfor - ! dividing by the jacobian for neo-Hookean model - ! setting the tensor to the stresses for riemann solver + ! by the jacobian for neo-Hookean model + ! the tensor to the stresses for riemann solver $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_prim_vf(strxb + i - 1)%sf(j, k, l) = & G_param*btensor_in(i)%sf(j, k, l)/btensor_in(b_size)%sf(j, k, l) end do - ! compute the invariant without the elastic modulus + ! the invariant without the elastic modulus q_prim_vf(xiend + 1)%sf(j, k, l) = & 0.5_wp*(trace - 3.0_wp)/btensor_in(b_size)%sf(j, k, l) end subroutine s_neoHookean_cauchy_solver !> The following subroutine handles the calculation of the btensor. - !! The calculation of the btensor takes qprimvf. - !! @param q_prim_vf Primitive variables - !! @param btensor is the output - !! calculate the grad_xi, grad_xi is a nxn tensor - !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor - !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor - !! btensor is symmetric, save the data space + !! of the btensor takes qprimvf. + !! Primitive variables + !! is the output + !! grad_xi, grad_xi is a nxn tensor + !! inverse of grad_xi to obtain F, F is a nxn tensor + !! FFtranspose to obtain the btensor, btensor is nxn tensor + !! symmetric, save the data space subroutine s_Mooney_Rivlin_cauchy_solver(btensor_in, q_prim_vf, G_param, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -275,22 +275,22 @@ contains integer :: i !< Generic loop iterators !TODO Make this 1D and 2D capable - ! tensor is the symmetric tensor & calculate the trace of the tensor + ! is the symmetric tensor & calculate the trace of the tensor trace = btensor_in(1)%sf(j, k, l) + btensor_in(3)%sf(j, k, l) + btensor_in(6)%sf(j, k, l) - ! calculate the deviatoric of the tensor + ! the deviatoric of the tensor btensor_in(1)%sf(j, k, l) = btensor_in(1)%sf(j, k, l) - f13*trace btensor_in(3)%sf(j, k, l) = btensor_in(3)%sf(j, k, l) - f13*trace btensor_in(6)%sf(j, k, l) = btensor_in(6)%sf(j, k, l) - f13*trace - ! dividing by the jacobian for neo-Hookean model - ! setting the tensor to the stresses for riemann solver + ! by the jacobian for neo-Hookean model + ! the tensor to the stresses for riemann solver $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_prim_vf(strxb + i - 1)%sf(j, k, l) = & G_param*btensor_in(i)%sf(j, k, l)/btensor_in(b_size)%sf(j, k, l) end do - ! compute the invariant without the elastic modulus + ! the invariant without the elastic modulus q_prim_vf(xiend + 1)%sf(j, k, l) = & 0.5_wp*(trace - 3.0_wp)/btensor_in(b_size)%sf(j, k, l) @@ -300,7 +300,7 @@ contains integer :: i !< iterator - ! Deallocating memory + ! memory do i = 1, b_size @:DEALLOCATE(btensor%vf(i)%sf) end do diff --git a/src/simulation/m_hypoelastic.fpp b/src/simulation/m_hypoelastic.fpp index a265b9bdd6..8832be0f13 100644 --- a/src/simulation/m_hypoelastic.fpp +++ b/src/simulation/m_hypoelastic.fpp @@ -1,6 +1,6 @@ !> -!! @file m_hypoelastic.f90 -!! @brief Contains module m_hypoelastic +!! +!! module m_hypoelastic #:include 'macros.fpp' @@ -65,7 +65,7 @@ contains @:ALLOCATE(fd_coeff_z_hypo(-fd_number:fd_number, 0:p)) end if - ! Computing centered finite difference coefficients + ! centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x_hypo, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x_hypo]') @@ -83,10 +83,10 @@ contains end subroutine s_initialize_hypoelastic_module !> The purpose of this procedure is to compute the source terms - !! that are needed for the elastic stress equations - !! @param idir Dimension splitting index - !! @param q_prim_vf Primitive variables - !! @param rhs_vf rhs variables + !! needed for the elastic stress equations + !! Dimension splitting index + !! Primitive variables + !! rhs variables subroutine s_compute_hypoelastic_rhs(idir, q_prim_vf, rhs_vf) integer, intent(in) :: idir @@ -101,8 +101,8 @@ contains ndirs = 1; if (n > 0) ndirs = 2; if (p > 0) ndirs = 3 if (idir == 1) then - ! calculate velocity gradients + rho_K and G_K - ! TODO: re-organize these loops one by one for GPU efficiency if possible? + ! velocity gradients + rho_K and G_K + ! re-organize these loops one by one for GPU efficiency if possible? $:GPU_PARALLEL_LOOP(collapse=3) do q = 0, p @@ -158,7 +158,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! 3D + ! if (ndirs == 3) then $:GPU_PARALLEL_LOOP(collapse=3) @@ -220,7 +220,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! apply rhs source term to elastic stress equation + ! rhs source term to elastic stress equation $:GPU_PARALLEL_LOOP(collapse=3) do q = 0, p do l = 0, n @@ -345,22 +345,22 @@ contains do q = 0, p do l = 0, n do k = 0, m - ! S_xx -= rho * v/r * (tau_xx + 2/3*G) + ! -= rho * v/r * (tau_xx + 2/3*G) rhs_vf(strxb)%sf(k, l, q) = rhs_vf(strxb)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & (q_prim_vf(strxb)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q)) ! tau_xx + 2/3*G - ! S_xr -= rho * v/r * tau_xr + ! -= rho * v/r * tau_xr rhs_vf(strxb + 1)%sf(k, l, q) = rhs_vf(strxb + 1)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & q_prim_vf(strxb + 1)%sf(k, l, q) ! tau_xx - ! S_rr -= rho * v/r * (tau_rr + 2/3*G) + ! -= rho * v/r * (tau_rr + 2/3*G) rhs_vf(strxb + 2)%sf(k, l, q) = rhs_vf(strxb + 2)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & (q_prim_vf(strxb + 2)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q)) ! tau_rr + 2/3*G - ! S_thetatheta += rho * ( -(tau_thetatheta + 2/3*G)*(du/dx + dv/dr + v/r) + 2*(tau_thetatheta + G)*v/r ) + ! += rho * ( -(tau_thetatheta + 2/3*G)*(du/dx + dv/dr + v/r) + 2*(tau_thetatheta + G)*v/r ) rhs_vf(strxb + 3)%sf(k, l, q) = rhs_vf(strxb + 3)%sf(k, l, q) + & rho_K_field(k, l, q)*( & -(q_prim_vf(strxb + 3)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q))* & @@ -414,7 +414,7 @@ contains $:GPU_PARALLEL_LOOP(collapse=2, private='[tau_p]') do l = 0, n do k = 0, m - ! Maximum principal stress + ! principal stress tau_p = 0.5_wp*(q_cons_vf(stress_idx%beg)%sf(k, l, q) + & q_cons_vf(stress_idx%beg + 2)%sf(k, l, q)) + & sqrt((q_cons_vf(stress_idx%beg)%sf(k, l, q) - & @@ -437,14 +437,14 @@ contains tau_yz = q_cons_vf(stress_idx%beg + 4)%sf(k, l, q) tau_zz = q_cons_vf(stress_idx%beg + 5)%sf(k, l, q) - ! Invariants of the stress tensor + ! of the stress tensor I1 = tau_xx + tau_yy + tau_zz I2 = tau_xx*tau_yy + tau_xx*tau_zz + tau_yy*tau_zz - & (tau_xy**2.0_wp + tau_xz**2.0_wp + tau_yz**2.0_wp) I3 = tau_xx*tau_yy*tau_zz + 2.0_wp*tau_xy*tau_xz*tau_yz - & tau_xx*tau_yz**2.0_wp - tau_yy*tau_xz**2.0_wp - tau_zz*tau_xy**2.0_wp - ! Maximum principal stress + ! principal stress temp = I1**2.0_wp - 3.0_wp*I2 sqrt_term_1 = sqrt(max(temp, 0.0_wp)) if (sqrt_term_1 > verysmall) then ! Avoid 0/0 diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 5e5e136629..6aa7931f03 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -1,11 +1,11 @@ !> -!! @file m_ibm.fpp -!! @brief Contains module m_ibm +!! +!! module m_ibm #:include 'macros.fpp' !> @brief This module is used to handle all operations related to immersed -!! boundary methods (IBMs) +!! (IBMs) module m_ibm use m_derived_types !< Definitions of the derived types @@ -89,13 +89,13 @@ contains end subroutine s_initialize_ibm_module !> Initializes the values of various IBM variables, such as ghost points and - !! image points. + !! impure subroutine s_ibm_setup() integer :: i, j, k integer :: max_num_gps, max_num_inner_gps - ! do all set up for moving immersed boundaries + ! all set up for moving immersed boundaries moving_immersed_boundary_flag = .false. do i = 1, num_ibs if (patch_ib(i)%moving_ibm /= 0) then @@ -107,24 +107,24 @@ contains end do $:GPU_ENTER_DATA(copyin='[patch_ib]') - ! Allocating the patch identities bookkeeping variable + ! the patch identities bookkeeping variable allocate (patch_id_fp(0:m, 0:n, 0:p)) $:GPU_UPDATE(device='[ib_markers%sf]') $:GPU_UPDATE(device='[levelset%sf]') $:GPU_UPDATE(device='[levelset_norm%sf]') - ! Get neighboring IB variables from other processors + ! neighboring IB variables from other processors call s_populate_ib_buffers() $:GPU_UPDATE(host='[ib_markers%sf]') - ! find the number of ghost points and set them to be the maximum total across ranks + ! the number of ghost points and set them to be the maximum total across ranks call s_find_num_ghost_points(num_gps, num_inner_gps) call s_mpi_allreduce_integer_sum(num_gps, max_num_gps) call s_mpi_allreduce_integer_sum(num_inner_gps, max_num_inner_gps) - ! set the size of the ghost point arrays to be the amount of points total, plus a factor of 2 buffer + ! the size of the ghost point arrays to be the amount of points total, plus a factor of 2 buffer $:GPU_UPDATE(device='[num_gps, num_inner_gps]') @:ALLOCATE(ghost_points(1:int((max_num_gps + max_num_inner_gps) * 2.0))) @:ALLOCATE(inner_points(1:int((max_num_gps + max_num_inner_gps) * 2.0))) @@ -155,19 +155,19 @@ contains end subroutine s_populate_ib_buffers !> Subroutine that updates the conservative variables at the ghost points - !! @param q_cons_vf Conservative Variables - !! @param q_prim_vf Primitive variables - !! @param pb Internal bubble pressure - !! @param mv Mass of vapor in bubble + !! @param[inout] q_cons_vf Conservative variables. + !! @param[inout] q_prim_vf Primitive variables. + !! @param[inout] pb_in Internal bubble pressure (optional, for QBMM). + !! @param[inout] mv_in Mass of vapor in bubble (optional, for QBMM). subroutine s_ibm_correct_state(q_cons_vf, q_prim_vf, pb_in, mv_in) type(scalar_field), & dimension(sys_size), & - intent(INOUT) :: q_cons_vf !< Primitive Variables + intent(INOUT) :: q_cons_vf type(scalar_field), & dimension(sys_size), & - intent(INOUT) :: q_prim_vf !< Primitive Variables + intent(INOUT) :: q_prim_vf real(stp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:, 1:), optional, intent(INOUT) :: pb_in, mv_in @@ -194,8 +194,8 @@ contains real(wp), dimension(nb*nmom) :: nmom_IP real(wp), dimension(nb*nnode) :: presb_IP, massv_IP #:endif - !! Primitive variables at the image point associated with a ghost point, - !! interpolated from surrounding fluid cells. + !! at the image point associated with a ghost point, + !! surrounding fluid cells. real(wp), dimension(3) :: norm !< Normal vector from GP to IP real(wp), dimension(3) :: physical_loc !< Physical loc of GP @@ -208,7 +208,7 @@ contains type(ghost_point) :: gp type(ghost_point) :: innerp - ! set the Moving IBM interior Pressure Values + ! the Moving IBM interior Pressure Values $:GPU_PARALLEL_LOOP(private='[i,j,k,patch_id,rho]', copyin='[E_idx,momxb]', collapse=3) do l = 0, p do k = 0, n @@ -222,7 +222,7 @@ contains rho = rho + q_prim_vf(contxb + i - 1)%sf(j, k, l) end do - ! Sets the momentum + ! the momentum do i = 1, num_dims q_cons_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i)*rho q_prim_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i) @@ -244,7 +244,7 @@ contains l = gp%loc(3) patch_id = ghost_points(i)%ib_patch_id - ! Calculate physical location of GP + ! physical location of GP if (p > 0) then physical_loc = [x_cc(j), y_cc(k), z_cc(l)] else @@ -271,7 +271,7 @@ contains dyn_pres = 0._wp - ! Set q_prim_vf params at GP so that mixture vars calculated properly + ! q_prim_vf params at GP so that mixture vars calculated properly $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids q_prim_vf(q)%sf(j, k, l) = alpha_rho_IP(q) @@ -282,20 +282,20 @@ contains q_prim_vf(c_idx)%sf(j, k, l) = c_IP end if - ! set the pressure + ! the pressure if (patch_ib(patch_id)%moving_ibm <= 1) then q_prim_vf(E_idx)%sf(j, k, l) = pres_IP else q_prim_vf(E_idx)%sf(j, k, l) = 0._wp $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids - ! Se the pressure inside a moving immersed boundary based upon the pressure of the image point. acceleration, and normal vector direction + ! the pressure inside a moving immersed boundary based upon the pressure of the image point. acceleration, and normal vector direction q_prim_vf(E_idx)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) + pres_IP/(1._wp - 2._wp*abs(levelset%sf(j, k, l, patch_id)*alpha_rho_IP(q)/pres_IP)*dot_product(patch_ib(patch_id)%force/patch_ib(patch_id)%mass, levelset_norm%sf(j, k, l, patch_id, :))) end do end if if (model_eqns /= 4) then - ! If in simulation, use acc mixture subroutines + ! in simulation, use acc mixture subroutines if (elasticity) then call s_convert_species_to_mixture_variables_acc(rho, gamma, pi_inf, qv_K, alpha_IP, & alpha_rho_IP, Re_K, G_K, Gs) @@ -305,7 +305,7 @@ contains end if end if - ! Calculate velocity of ghost cell + ! velocity of ghost cell if (gp%slip) then norm(1:3) = levelset_norm%sf(gp%loc(1), gp%loc(2), gp%loc(3), gp%ib_patch_id, 1:3) buf = sqrt(sum(norm**2)) @@ -313,33 +313,33 @@ contains vel_norm_IP = sum(vel_IP*norm)*norm vel_g = vel_IP - vel_norm_IP if (patch_ib(patch_id)%moving_ibm /= 0) then - ! compute the linear velocity of the ghost point due to rotation + ! the linear velocity of the ghost point due to rotation radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, & patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid] call s_cross_product(matmul(patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector, rotation_velocity) - ! add only the component of the IB's motion that is normal to the surface + ! only the component of the IB's motion that is normal to the surface vel_g = vel_g + sum((patch_ib(patch_id)%vel + rotation_velocity)*norm)*norm end if else if (patch_ib(patch_id)%moving_ibm == 0) then - ! we know the object is not moving if moving_ibm is 0 (false) + ! know the object is not moving if moving_ibm is 0 (false) vel_g = 0._wp else - ! get the vector that points from the centroid to the ghost + ! the vector that points from the centroid to the ghost radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, & patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid] - ! convert the angular velocity from the inertial reference frame to the fluids frame, then convert to linear velocity + ! the angular velocity from the inertial reference frame to the fluids frame, then convert to linear velocity call s_cross_product(matmul(patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector, rotation_velocity) do q = 1, 3 - ! if mibm is 1 or 2, then the boundary may be moving + ! mibm is 1 or 2, then the boundary may be moving vel_g(q) = patch_ib(patch_id)%vel(q) ! add the linear velocity vel_g(q) = vel_g(q) + rotation_velocity(q) ! add the rotational velocity end do end if end if - ! Set momentum + ! momentum $:GPU_LOOP(parallelism='[seq]') do q = momxb, momxe q_cons_vf(q)%sf(j, k, l) = rho*vel_g(q - momxb + 1) @@ -347,25 +347,25 @@ contains vel_g(q - momxb + 1)/2._wp end do - ! Set continuity and adv vars + ! continuity and adv vars $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids q_cons_vf(q)%sf(j, k, l) = alpha_rho_IP(q) q_cons_vf(advxb + q - 1)%sf(j, k, l) = alpha_IP(q) end do - ! Set color function + ! color function if (surface_tension) then q_cons_vf(c_idx)%sf(j, k, l) = c_IP end if - ! Set Energy + ! Energy if (bubbles_euler) then q_cons_vf(E_idx)%sf(j, k, l) = (1 - alpha_IP(1))*(gamma*pres_IP + pi_inf + dyn_pres) else q_cons_vf(E_idx)%sf(j, k, l) = gamma*pres_IP + pi_inf + dyn_pres end if - ! Set bubble vars + ! bubble vars if (bubbles_euler .and. .not. qbmm) then call s_comp_n_from_prim(alpha_IP(1), r_IP, nbub, weight) $:GPU_LOOP(parallelism='[seq]') @@ -438,9 +438,9 @@ contains end subroutine s_ibm_correct_state !> Function that computes the image points for each ghost point - !! @param ghost_points Ghost Points - !! @param levelset Closest distance from each grid cell to IB - !! @param levelset_norm Vector pointing in the direction of the closest distance + !! Ghost Points + !! Closest distance from each grid cell to IB + !! Vector pointing in the direction of the closest distance impure subroutine s_compute_image_points(ghost_points_in, levelset_in, levelset_norm_in) type(ghost_point), dimension(num_gps), intent(INOUT) :: ghost_points_in @@ -467,23 +467,23 @@ contains j = gp%loc(2) k = gp%loc(3) - ! Calculate physical location of ghost point + ! physical location of ghost point if (p > 0) then physical_loc = [x_cc(i), y_cc(j), z_cc(k)] else physical_loc = [x_cc(i), y_cc(j), 0._wp] end if - ! Calculate and store the precise location of the image point + ! and store the precise location of the image point patch_id = gp%ib_patch_id dist = abs(real(levelset_in%sf(i, j, k, patch_id), kind=wp)) norm(:) = levelset_norm_in%sf(i, j, k, patch_id, :) ghost_points_in(q)%ip_loc(:) = physical_loc(:) + 2*dist*norm(:) - ! Find the closest grid point to the image point + ! the closest grid point to the image point do dim = 1, num_dims - ! s_cc points to the dim array we need + ! points to the dim array we need if (dim == 1) then s_cc => x_cc bound = m + buff_size - 1 @@ -496,7 +496,7 @@ contains end if if (f_approx_equal(norm(dim), 0._wp)) then - ! if the ghost point is almost equal to a cell location, we set it equal and continue + ! the ghost point is almost equal to a cell location, we set it equal and continue ghost_points_in(q)%ip_grid(dim) = ghost_points_in(q)%loc(dim) else if (norm(dim) > 0) then @@ -529,7 +529,7 @@ contains end subroutine s_compute_image_points !> Function that finds the number of ghost points, used for allocating - !! memory. + !! subroutine s_find_num_ghost_points(num_gps_out, num_inner_gps_out) integer, intent(out) :: num_gps_out @@ -596,7 +596,7 @@ contains do i = 0, m do j = 0, n if (p == 0) then - ! 2D + ! if (ib_markers%sf(i, j, 0) /= 0) then subsection_2D = ib_markers%sf( & i - gp_layers:i + gp_layers, & @@ -608,7 +608,7 @@ contains patch_id ghost_points_in(count)%slip = patch_ib(patch_id)%slip - ! ghost_points(count)%rank = proc_rank + ! = proc_rank if ((x_cc(i) - dx(i)) < x_domain%beg) then ghost_points_in(count)%DB(1) = -1 @@ -639,7 +639,7 @@ contains end if end if else - ! 3D + ! do k = 0, p if (ib_markers%sf(i, j, k) /= 0) then subsection_3D = ib_markers%sf( & @@ -710,11 +710,11 @@ contains integer :: i1, i2, j1, j2, k1, k2 !< Grid indexes integer :: patch_id - ! 2D + ! if (p <= 0) then do i = 1, num_gps gp = ghost_points_in(i) - ! Get the interpolation points + ! the interpolation points i1 = gp%ip_grid(1); i2 = i1 + 1 j1 = gp%ip_grid(2); j2 = j1 + 1 @@ -766,12 +766,12 @@ contains else do i = 1, num_gps gp = ghost_points_in(i) - ! Get the interpolation points + ! the interpolation points i1 = gp%ip_grid(1); i2 = i1 + 1 j1 = gp%ip_grid(2); j2 = j1 + 1 k1 = gp%ip_grid(3); k2 = k1 + 1 - ! Get interpolation weights (Chaudhuri et al. 2011, JCP) + ! interpolation weights (Chaudhuri et al. 2011, JCP) dist(1, 1, 1) = sqrt( & (x_cc(i1) - gp%ip_loc(1))**2 + & (y_cc(j1) - gp%ip_loc(2))**2 + & @@ -848,15 +848,30 @@ contains end subroutine s_compute_interpolation_coeffs - !> Function that uses the interpolation coefficients and the current state - !! at the cell centers in order to estimate the state at the image point + !> Interpolates flow state at an image point using surrounding cell data. + !! @param[in] q_prim_vf Primitive variables at cell centers. + !! @param[in] gp Ghost point with image point location and interpolation coefficients. + !! @param[inout] alpha_rho_IP Interpolated partial densities at image point. + !! @param[inout] alpha_IP Interpolated volume fractions at image point. + !! @param[inout] pres_IP Interpolated pressure at image point. + !! @param[inout] vel_IP Interpolated velocity vector at image point. + !! @param[inout] c_IP Interpolated color function at image point. + !! @param[inout] r_IP Interpolated bubble radii (optional, Euler bubbles). + !! @param[inout] v_IP Interpolated bubble velocities (optional, Euler bubbles). + !! @param[inout] pb_IP Interpolated bubble pressures (optional, Euler bubbles). + !! @param[inout] mv_IP Interpolated vapor masses (optional, Euler bubbles). + !! @param[inout] nmom_IP Interpolated moments (optional, QBMM). + !! @param[in] pb_in Bubble pressure field (optional, non-polytropic QBMM). + !! @param[in] mv_in Vapor mass field (optional, non-polytropic QBMM). + !! @param[inout] presb_IP Interpolated bubble pressures (optional, QBMM). + !! @param[inout] massv_IP Interpolated vapor masses (optional, QBMM). subroutine s_interpolate_image_point(q_prim_vf, gp, alpha_rho_IP, alpha_IP, & pres_IP, vel_IP, c_IP, r_IP, v_IP, pb_IP, & mv_IP, nmom_IP, pb_in, mv_in, presb_IP, massv_IP) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), & dimension(sys_size), & - intent(IN) :: q_prim_vf !< Primitive Variables + intent(IN) :: q_prim_vf real(stp), optional, dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:, 1:), intent(IN) :: pb_in, mv_in @@ -988,12 +1003,12 @@ contains integer :: i, ierr - ! Clears the existing immersed boundary indices + ! the existing immersed boundary indices ib_markers%sf = 0._wp levelset%sf = 0._wp levelset_norm%sf = 0._wp - ! recalulcate the rotation matrix based upon the new angles + ! the rotation matrix based upon the new angles do i = 1, num_ibs if (patch_ib(i)%moving_ibm /= 0) then call s_update_ib_rotation_matrix(i) @@ -1002,13 +1017,13 @@ contains $:GPU_UPDATE(device='[patch_ib]') - ! recompute the new ib_patch locations and broadcast them. + ! the new ib_patch locations and broadcast them. call s_apply_ib_patches(ib_markers%sf(0:m, 0:n, 0:p), levelset, levelset_norm) call s_populate_ib_buffers() ! transmits the new IB markers via MPI $:GPU_UPDATE(device='[ib_markers%sf]') $:GPU_UPDATE(host='[levelset%sf, levelset_norm%sf]') - ! recalculate the ghost point locations and coefficients + ! the ghost point locations and coefficients call s_find_num_ghost_points(num_gps, num_inner_gps) $:GPU_UPDATE(device='[num_gps, num_inner_gps]') @@ -1023,14 +1038,14 @@ contains end subroutine s_update_mib - ! compute the surface integrals of the IB via a volume integraion method described in - ! "A coupled IBM/Euler-Lagrange framework for simulating shock-induced particle size segregation" - ! by Archana Sridhar and Jesse Capecelatro + ! the surface integrals of the IB via a volume integraion method described in + ! coupled IBM/Euler-Lagrange framework for simulating shock-induced particle size segregation" + ! Archana Sridhar and Jesse Capecelatro subroutine s_compute_ib_forces(q_prim_vf, fluid_pp) - ! real(wp), dimension(idwbuff(1)%beg:idwbuff(1)%end, & - ! idwbuff(2)%beg:idwbuff(2)%end, & - ! idwbuff(3)%beg:idwbuff(3)%end), intent(in) :: pressure + ! dimension(idwbuff(1)%beg:idwbuff(1)%end, & + ! & + ! intent(in) :: pressure type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp @@ -1063,7 +1078,7 @@ contains do k = 0, p ib_idx = ib_markers%sf(i, j, k) if (ib_idx /= 0) then - ! get the vector pointing to the grid cell from the IB centroid + ! the vector pointing to the grid cell from the IB centroid if (num_dims == 3) then radial_vector = [x_cc(i), y_cc(j), z_cc(k)] - [patch_ib(ib_idx)%x_centroid, patch_ib(ib_idx)%y_centroid, patch_ib(ib_idx)%z_centroid] else @@ -1074,11 +1089,11 @@ contains local_force_contribution(:) = 0._wp do fluid_idx = 0, num_fluids - 1 - ! Get the pressure contribution to force via a finite difference to compute the 2D components of the gradient of the pressure and cell volume + ! the pressure contribution to force via a finite difference to compute the 2D components of the gradient of the pressure and cell volume local_force_contribution(1) = local_force_contribution(1) - (q_prim_vf(E_idx + fluid_idx)%sf(i + 1, j, k) - q_prim_vf(E_idx + fluid_idx)%sf(i - 1, j, k))/(2._wp*dx) ! force is the negative pressure gradient local_force_contribution(2) = local_force_contribution(2) - (q_prim_vf(E_idx + fluid_idx)%sf(i, j + 1, k) - q_prim_vf(E_idx + fluid_idx)%sf(i, j - 1, k))/(2._wp*dy) cell_volume = abs(dx*dy) - ! add the 3D component of the pressure gradient, if we are working in 3 dimensions + ! the 3D component of the pressure gradient, if we are working in 3 dimensions if (num_dims == 3) then dz = z_cc(k + 1) - z_cc(k) local_force_contribution(3) = local_force_contribution(3) - (q_prim_vf(E_idx + fluid_idx)%sf(i, j, k + 1) - q_prim_vf(E_idx + fluid_idx)%sf(i, j, k - 1))/(2._wp*dz) @@ -1086,26 +1101,26 @@ contains end if end do - ! Update the force values atomically to prevent race conditions + ! the force values atomically to prevent race conditions call s_cross_product(radial_vector, local_force_contribution, local_torque_contribution) - ! get the viscous stress and add its contribution if that is considered - ! TODO :: This is really bad code + ! the viscous stress and add its contribution if that is considered + ! :: This is really bad code if (viscous) then - ! compute the volume-weighted local dynamic viscosity + ! the volume-weighted local dynamic viscosity dynamic_viscosity = 0._wp do fluid_idx = 1, num_fluids - ! local dynamic viscosity is the dynamic viscosity of the fluid times alpha of the fluid + ! dynamic viscosity is the dynamic viscosity of the fluid times alpha of the fluid dynamic_viscosity = dynamic_viscosity + (q_prim_vf(fluid_idx + advxb - 1)%sf(i, j, k)*dynamic_viscosities(fluid_idx)) end do - ! get the linear force component first + ! the linear force component first call s_compute_viscous_stress_tensor(viscous_stress_div_1, q_prim_vf, dynamic_viscosity, i - 1, j, k) call s_compute_viscous_stress_tensor(viscous_stress_div_2, q_prim_vf, dynamic_viscosity, i + 1, j, k) viscous_stress_div = (viscous_stress_div_2 - viscous_stress_div_1)/(2._wp*dx) ! get the x derivative of the viscous stress tensor local_force_contribution(1:3) = local_force_contribution(1:3) + viscous_stress_div(1, 1:3) ! add te x components of the derivative to the force do l = 1, 3 - ! take the cross products for the torque component + ! the cross products for the torque component call s_cross_product(radial_vector, viscous_stress_div_1(l, 1:3), viscous_cross_1(l, 1:3)) call s_cross_product(radial_vector, viscous_stress_div_2(l, 1:3), viscous_cross_2(l, 1:3)) end do @@ -1151,11 +1166,11 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! reduce the forces across all MPI ranks + ! the forces across all MPI ranks call s_mpi_allreduce_vectors_sum(forces, forces, num_ibs, 3) call s_mpi_allreduce_vectors_sum(torques, torques, num_ibs, 3) - ! consider body forces after reducing to avoid double counting + ! body forces after reducing to avoid double counting do i = 1, num_ibs if (bf_x) then forces(i, 1) = forces(i, 1) + accel_bf(1)*patch_ib(i)%mass @@ -1168,7 +1183,7 @@ contains end if end do - ! apply the summed forces + ! the summed forces do i = 1, num_ibs patch_ib(i)%force(:) = forces(i, :) patch_ib(i)%torque(:) = matmul(patch_ib(i)%rotation_matrix_inverse, torques(i, :)) ! torques must be converted to the local coordinates of the IB @@ -1194,7 +1209,7 @@ contains integer :: i, j, k, num_cells, num_cells_local real(wp), dimension(1:3) :: center_of_mass, center_of_mass_local - ! Offset only needs to be computes for specific geometries + ! only needs to be computes for specific geometries if (patch_ib(ib_marker)%geometry == 4 .or. & patch_ib(ib_marker)%geometry == 5 .or. & patch_ib(ib_marker)%geometry == 11 .or. & @@ -1203,7 +1218,7 @@ contains center_of_mass_local = [0._wp, 0._wp, 0._wp] num_cells_local = 0 - ! get the summed mass distribution and number of cells to divide by + ! the summed mass distribution and number of cells to divide by do i = 0, m do j = 0, n do k = 0, p @@ -1216,7 +1231,7 @@ contains end do end do - ! reduce the mass contribution over all MPI ranks and compute COM + ! the mass contribution over all MPI ranks and compute COM call s_mpi_allreduce_integer_sum(num_cells_local, num_cells) if (num_cells /= 0) then call s_mpi_allreduce_sum(center_of_mass_local(1), center_of_mass(1)) @@ -1228,14 +1243,14 @@ contains return end if - ! assign the centroid offset as a vector pointing from the true COM to the "centroid" in the input file and replace the current centroid + ! the centroid offset as a vector pointing from the true COM to the "centroid" in the input file and replace the current centroid patch_ib(ib_marker)%centroid_offset = [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, patch_ib(ib_marker)%z_centroid] & - center_of_mass patch_ib(ib_marker)%x_centroid = center_of_mass(1) patch_ib(ib_marker)%y_centroid = center_of_mass(2) patch_ib(ib_marker)%z_centroid = center_of_mass(3) - ! rotate the centroid offset back into the local coords of the IB + ! the centroid offset back into the local coords of the IB patch_ib(ib_marker)%centroid_offset = matmul(patch_ib(ib_marker)%rotation_matrix_inverse, patch_ib(ib_marker)%centroid_offset) else patch_ib(ib_marker)%centroid_offset(:) = [0._wp, 0._wp, 0._wp] @@ -1243,9 +1258,12 @@ contains end subroutine s_compute_centroid_offset + !> Computes the moment of inertia of an immersed boundary about an axis. + !! @param[in] ib_marker Immersed boundary patch ID. + !! @param[in] axis Rotation axis vector (used in 3D; defaults to z-axis in 2D). subroutine s_compute_moment_of_inertia(ib_marker, axis) - real(wp), dimension(3), intent(in) :: axis !< the axis about which we compute the moment. Only required in 3D. + real(wp), dimension(3), intent(in) :: axis integer, intent(in) :: ib_marker real(wp) :: moment, distance_to_axis, cell_volume @@ -1255,14 +1273,14 @@ contains if (p == 0) then normal_axis = [0, 0, 1] else if (sqrt(sum(axis**2)) == 0) then - ! if the object is not actually rotating at this time, return a dummy value and exit + ! the object is not actually rotating at this time, return a dummy value and exit patch_ib(ib_marker)%moment = 1._wp return else normal_axis = axis/sqrt(sum(axis)) end if - ! if the IB is in 2D or a 3D sphere, we can compute this exactly + ! the IB is in 2D or a 3D sphere, we can compute this exactly if (patch_ib(ib_marker)%geometry == 2) then ! circle patch_ib(ib_marker)%moment = 0.5_wp*patch_ib(ib_marker)%mass*(patch_ib(ib_marker)%radius)**2 elseif (patch_ib(ib_marker)%geometry == 3) then ! rectangle @@ -1288,19 +1306,19 @@ contains $:GPU_ATOMIC(atomic='update') count = count + 1 ! increment the count of total cells in the boundary - ! get the position in local coordinates so that the axis passes through 0, 0, 0 + ! the position in local coordinates so that the axis passes through 0, 0, 0 if (p == 0) then position = [x_cc(i), y_cc(j), 0._wp] - [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, 0._wp] else position = [x_cc(i), y_cc(j), z_cc(k)] - [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, patch_ib(ib_marker)%z_centroid] end if - ! project the position along the axis to find the closest distance to the rotation axis + ! the position along the axis to find the closest distance to the rotation axis closest_point_along_axis = normal_axis*dot_product(normal_axis, position) vector_to_axis = position - closest_point_along_axis distance_to_axis = dot_product(vector_to_axis, vector_to_axis) ! saves the distance to the axis squared - ! compute the position component of the moment + ! the position component of the moment $:GPU_ATOMIC(atomic='update') moment = moment + distance_to_axis end if @@ -1309,7 +1327,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! write the final moment assuming the points are all uniform density + ! the final moment assuming the points are all uniform density patch_ib(ib_marker)%moment = moment*patch_ib(ib_marker)%mass/(count*cell_volume) $:GPU_UPDATE(device='[patch_ib(ib_marker)%moment]') end if diff --git a/src/simulation/m_igr.fpp b/src/simulation/m_igr.fpp index 8aff221313..699b638269 100644 --- a/src/simulation/m_igr.fpp +++ b/src/simulation/m_igr.fpp @@ -24,6 +24,7 @@ module m_igr s_igr_flux_add, & s_finalize_igr_module +!> @cond #ifdef __NVCOMPILER_GPU_UNIFIED_MEM integer, dimension(3) :: nv_uvm_temp_on_gpu real(wp), pointer, contiguous, dimension(:, :, :) :: jac, jac_rhs, jac_old @@ -31,10 +32,13 @@ module m_igr real(wp), allocatable, dimension(:, :, :), pinned, target :: jac_rhs_host real(wp), allocatable, dimension(:, :, :), pinned, target :: jac_old_host #else - real(wp), allocatable, target, dimension(:, :, :) :: jac - real(wp), allocatable, dimension(:, :, :) :: jac_rhs, jac_old +!> @endcond + real(wp), allocatable, target, dimension(:, :, :) :: jac !< IGR Jacobian field + real(wp), allocatable, dimension(:, :, :) :: jac_rhs, jac_old !< IGR RHS and previous Jacobian $:GPU_DECLARE(create='[jac, jac_rhs, jac_old]') +!> @cond #endif +!> @endcond type(scalar_field), dimension(1) :: jac_sf $:GPU_DECLARE(create='[jac_sf]') @@ -152,7 +156,7 @@ contains idwbuff(3)%beg:idwbuff(3)%end)) end if #else - ! create map + ! map nv_uvm_temp_on_gpu(1:3) = 0 nv_uvm_temp_on_gpu(1:nv_uvm_igr_temps_on_gpu) = 1 diff --git a/src/simulation/m_mpi_proxy.fpp b/src/simulation/m_mpi_proxy.fpp index 515f599390..4a634e5988 100644 --- a/src/simulation/m_mpi_proxy.fpp +++ b/src/simulation/m_mpi_proxy.fpp @@ -1,15 +1,15 @@ !> -!! @file m_mpi_proxy.f90 -!! @brief Contains module m_mpi_proxy +!! +!! module m_mpi_proxy #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module serves as a proxy to the parameters and subroutines -!! available in the MPI implementation's MPI module. Specifically, -!! the purpose of the proxy is to harness basic MPI commands into -!! more complicated procedures as to accomplish the communication -!! goals for the simulation. +!! the MPI implementation's MPI module. Specifically, +!! of the proxy is to harness basic MPI commands into +!! procedures as to accomplish the communication +!! the simulation. module m_mpi_proxy #ifdef MFC_MPI @@ -33,14 +33,14 @@ module m_mpi_proxy implicit none integer, private, allocatable, dimension(:) :: ib_buff_send !< - !! This variable is utilized to pack and send the buffer of the immersed - !! boundary markers, for a single computational domain boundary at the - !! time, to the relevant neighboring processor. + !! is utilized to pack and send the buffer of the immersed + !! for a single computational domain boundary at the + !! the relevant neighboring processor. integer, private, allocatable, dimension(:) :: ib_buff_recv !< - !! q_cons_buff_recv is utilized to receive and unpack the buffer of the - !! immersed boundary markers, for a single computational domain boundary - !! at the time, from the relevant neighboring processor. + !! utilized to receive and unpack the buffer of the + !! markers, for a single computational domain boundary + !! time, from the relevant neighboring processor. integer :: i_halo_size $:GPU_DECLARE(create='[i_halo_size]') @@ -74,10 +74,10 @@ contains end subroutine s_initialize_mpi_proxy_module !> Since only the processor with rank 0 reads and verifies - !! the consistency of user inputs, these are initially not - !! available to the other processors. Then, the purpose of - !! this subroutine is to distribute the user inputs to the - !! remaining processors in the communicator. + !! of user inputs, these are initially not + !! the other processors. Then, the purpose of + !! is to distribute the user inputs to the + !! in the communicator. impure subroutine s_mpi_bcast_user_inputs() #ifdef MFC_MPI @@ -249,7 +249,7 @@ contains #:endfor end do - ! NVIDIA UVM variables + ! UVM variables call MPI_BCAST(nv_uvm_out_of_core, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(nv_uvm_igr_temps_on_gpu, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(nv_uvm_pref_gpu, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr) @@ -292,12 +292,12 @@ contains beg_end = (/boundary_conditions(mpi_dir)%beg, boundary_conditions(mpi_dir)%end/) beg_end_geq_0 = beg_end(max(pbc_loc, 0) - pbc_loc + 1) >= 0 - ! Implements: - ! pbc_loc bc_x >= 0 -> [send/recv]_tag [dst/src]_proc - ! -1 (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] - ! -1 (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] - ! +1 (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] - ! +1 (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] + ! + ! bc_x >= 0 -> [send/recv]_tag [dst/src]_proc + ! (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] + ! (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] + ! (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] + ! (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] send_tag = f_logical_to_int(.not. f_xor(beg_end_geq_0, pbc_loc == 1)) recv_tag = f_logical_to_int(pbc_loc == 1) @@ -317,7 +317,7 @@ contains unpack_offset = grid_dims(mpi_dir) + buff_size + 1 end if - ! Pack Buffer to Send + ! Buffer to Send #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then #:if mpi_dir == 1 @@ -393,7 +393,7 @@ contains end if #:endfor - ! Unpack Received Buffer + ! Received Buffer call nvtxStartRange("IB-MARKER-COMM-UNPACKBUF") #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then @@ -421,7 +421,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() #:else - ! Unpacking buffer from bc_z%beg + ! buffer from bc_z%beg $:GPU_PARALLEL_LOOP(collapse=3,private='[j,k,l,r]') do l = -buff_size, -1 do k = -buff_size, n + buff_size diff --git a/src/simulation/m_muscl.fpp b/src/simulation/m_muscl.fpp index 91e32a7c6a..6fd907c2eb 100644 --- a/src/simulation/m_muscl.fpp +++ b/src/simulation/m_muscl.fpp @@ -27,12 +27,12 @@ module m_muscl $:GPU_DECLARE(create='[is1_muscl,is2_muscl,is3_muscl]') !> @name The cell-average variables that will be MUSCL-reconstructed. Formerly, they - !! are stored in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR - !! as to be reshaped (RS) and/or characteristically decomposed. The reshaping - !! allows the muscl procedure to be independent of the coordinate direction of - !! the reconstruction. Lastly, notice that the left (L) and right (R) results - !! of the characteristic decomposition are stored in custom-constructed muscl- - !! stencils (WS) that are annexed to each position of a given scalar field. + !! in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR + !! be reshaped (RS) and/or characteristically decomposed. The reshaping + !! muscl procedure to be independent of the coordinate direction of + !! Lastly, notice that the left (L) and right (R) results + !! characteristic decomposition are stored in custom-constructed muscl- + !! that are annexed to each position of a given scalar field. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: v_rs_ws_x_muscl, v_rs_ws_y_muscl, v_rs_ws_z_muscl !> @} @@ -42,7 +42,7 @@ contains subroutine s_initialize_muscl_module() - ! Initializing in x-direction + ! in x-direction is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg if (n == 0) then is2_muscl%beg = 0 @@ -65,7 +65,7 @@ contains if (n == 0) return - ! initializing in y-direction + ! in y-direction is2_muscl%beg = -buff_size; is2_muscl%end = n - is2_muscl%beg is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg @@ -82,7 +82,7 @@ contains if (p == 0) return - ! initializing in z-direction + ! in z-direction is2_muscl%beg = -buff_size; is2_muscl%end = n - is2_muscl%beg is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg is3_muscl%beg = -buff_size; is3_muscl%end = p - is3_muscl%beg @@ -160,7 +160,7 @@ contains end if if (muscl_order == 2 .or. dummy) then - ! MUSCL Reconstruction + ! Reconstruction #:for MUSCL_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (muscl_dir == ${MUSCL_DIR}$) then $:GPU_PARALLEL_LOOP(collapse=4,private='[i,j,k,l,slopeL,slopeR,slope]') @@ -201,11 +201,11 @@ contains end if end if - ! reconstruct from left side + ! from left side vL_rs_vf_${XYZ}$ (j, k, l, i) = & v_rs_ws_${XYZ}$_muscl(j, k, l, i) - (5.e-1_wp*slope) - ! reconstruct from the right side + ! from the right side vR_rs_vf_${XYZ}$ (j, k, l, i) = & v_rs_ws_${XYZ}$_muscl(j, k, l, i) + (5.e-1_wp*slope) @@ -270,7 +270,7 @@ contains B = exp(sign*ic_beta*(2._wp*C - 1._wp)) A = (B/cosh(ic_beta) - 1._wp)/tanh(ic_beta) - ! Left reconstruction + ! reconstruction aTHINC = qmin + 5e-1_wp*qmax*(1._wp + sign*A) if (aTHINC < ic_eps) aTHINC = ic_eps if (aTHINC > 1 - ic_eps) aTHINC = 1 - ic_eps @@ -281,7 +281,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, advxb) = aTHINC vL_rs_vf_${XYZ}$ (j, k, l, advxe) = 1 - aTHINC - ! Right reconstruction + ! reconstruction aTHINC = qmin + 5e-1_wp*qmax*(1._wp + sign*(tanh(ic_beta) + A)/(1._wp + A*tanh(ic_beta))) if (aTHINC < ic_eps) aTHINC = ic_eps if (aTHINC > 1 - ic_eps) aTHINC = 1 - ic_eps @@ -310,11 +310,11 @@ contains integer :: j, k, l, q !< Generic loop iterators - ! Determining the number of cell-average variables which will be - ! muscl-reconstructed and mapping their indical bounds in the x-, - ! y- and z-directions to those in the s1-, s2- and s3-directions - ! as to reshape the inputted data in the coordinate direction of - ! the muscl reconstruction + ! the number of cell-average variables which will be + ! and mapping their indical bounds in the x-, + ! and z-directions to those in the s1-, s2- and s3-directions + ! to reshape the inputted data in the coordinate direction of + ! muscl reconstruction v_size = ubound(v_vf, 1) $:GPU_UPDATE(device='[v_size]') @@ -332,7 +332,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping/Projecting onto Characteristic Fields in y-direction + ! onto Characteristic Fields in y-direction if (n == 0) return if (muscl_dir == 2) then @@ -349,7 +349,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping/Projecting onto Characteristic Fields in z-direction + ! onto Characteristic Fields in z-direction if (p == 0) return if (muscl_dir == 3) then $:GPU_PARALLEL_LOOP(private='[j,k,l,q]', collapse=4) diff --git a/src/simulation/m_pressure_relaxation.fpp b/src/simulation/m_pressure_relaxation.fpp index b94871044c..c4e57ef8c7 100644 --- a/src/simulation/m_pressure_relaxation.fpp +++ b/src/simulation/m_pressure_relaxation.fpp @@ -1,14 +1,14 @@ !> -!! @file m_pressure_relaxation.fpp -!! @brief Contains module m_pressure_relaxation +!! +!! module m_pressure_relaxation #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains the subroutines used to perform pressure relaxation -!! for multi-component flows using the 6-equation model. This includes -!! volume fraction correction, Newton-Raphson pressure equilibration, and -!! internal energy correction to maintain thermodynamic consistency. +!! flows using the 6-equation model. This includes +!! correction, Newton-Raphson pressure equilibration, and +!! correction to maintain thermodynamic consistency. module m_pressure_relaxation use m_derived_types !< Definitions of the derived types @@ -52,7 +52,7 @@ contains end subroutine s_finalize_pressure_relaxation_module !> The main pressure relaxation procedure - !! @param q_cons_vf Cell-average conservative variables + !! Cell-average conservative variables subroutine s_pressure_relaxation_procedure(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -77,15 +77,15 @@ contains type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer, intent(in) :: j, k, l - ! Volume fraction correction + ! fraction correction if (mpp_lim) call s_correct_volume_fractions(q_cons_vf, j, k, l) - ! Pressure equilibration + ! equilibration if (s_needs_pressure_relaxation(q_cons_vf, j, k, l)) then call s_equilibrate_pressure(q_cons_vf, j, k, l) end if - ! Internal energy correction + ! energy correction call s_correct_internal_energies(q_cons_vf, j, k, l) end subroutine s_relax_cell_pressure @@ -155,7 +155,7 @@ contains real(wp), parameter :: TOLERANCE = 1.e-10_wp integer :: iter, i - ! Initialize pressures + ! pressures pres_relax = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -170,7 +170,7 @@ contains pres_relax = pres_relax + q_cons_vf(i + advxb - 1)%sf(j, k, l)*pres_K_init(i) end do - ! Newton-Raphson iteration + ! iteration f_pres = 1.e-9_wp df_pres = 1.e9_wp $:GPU_LOOP(parallelism='[seq]') @@ -178,13 +178,13 @@ contains if (abs(f_pres) > TOLERANCE) then pres_relax = pres_relax - f_pres/df_pres - ! Enforce pressure bounds + ! pressure bounds do i = 1, num_fluids if (pres_relax <= -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp) & pres_relax = -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp end do - ! Newton-Raphson step + ! step f_pres = -1._wp df_pres = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -202,7 +202,7 @@ contains end if end do - ! Update volume fractions + ! volume fractions $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids if (q_cons_vf(i + advxb - 1)%sf(j, k, l) > sgm_eps) & @@ -232,7 +232,7 @@ contains alpha(i) = q_cons_vf(E_idx + i)%sf(j, k, l) end do - ! Compute mixture properties (combined bubble and standard logic) + ! mixture properties (combined bubble and standard logic) rho = 0._wp gamma = 0._wp pi_inf = 0._wp @@ -290,7 +290,7 @@ contains end if end if - ! Compute dynamic pressure and update internal energies + ! dynamic pressure and update internal energies dyn_pres = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = momxb, momxe diff --git a/src/simulation/m_qbmm.fpp b/src/simulation/m_qbmm.fpp index 84f95af557..eeb274d48f 100644 --- a/src/simulation/m_qbmm.fpp +++ b/src/simulation/m_qbmm.fpp @@ -1,6 +1,6 @@ !> -!! @file m_qbmm.f90 -!! @brief Contains module m_qbmm +!! +!! module m_qbmm #:include 'case.fpp' #:include 'macros.fpp' @@ -50,10 +50,10 @@ contains #:if not MFC_CASE_OPTIMIZATION if (bubble_model == 2) then - ! Keller-Miksis without viscosity/surface tension + ! without viscosity/surface tension nterms = 32 else if (bubble_model == 3) then - ! Rayleigh-Plesset with viscosity/surface tension + ! with viscosity/surface tension nterms = 7 end if @@ -65,9 +65,9 @@ contains @:ALLOCATE(momrhs(1:3, 0:2, 0:2, 1:nterms, 1:nb)) momrhs = 0._wp - ! Assigns the required RHS moments for moment transport equations - ! The rhs%(:,3) is only to be used for R0 quadrature, not for computing X/Y indices - ! Accounts for different governing equations in polytropic and non-polytropic models + ! the required RHS moments for moment transport equations + ! rhs%(:,3) is only to be used for R0 quadrature, not for computing X/Y indices + ! for different governing equations in polytropic and non-polytropic models if (.not. polytropic) then do q = 1, nb do i1 = 0, 2; do i2 = 0, 2 @@ -90,14 +90,14 @@ contains momrhs(3, i1, i2, 4, q) = 0._wp if (.not. f_is_default(Re_inv)) then - ! add viscosity + ! viscosity momrhs(1, i1, i2, 5, q) = -2._wp + i1 momrhs(2, i1, i2, 5, q) = i2 momrhs(3, i1, i2, 5, q) = 0._wp end if if (.not. f_is_default(Web)) then - ! add surface tension + ! surface tension momrhs(1, i1, i2, 6, q) = -2._wp + i1 momrhs(2, i1, i2, 6, q) = -1._wp + i2 momrhs(3, i1, i2, 6, q) = 0._wp @@ -108,7 +108,7 @@ contains momrhs(3, i1, i2, 7, q) = 0._wp else if (bubble_model == 2) then - ! KM with approximation of 1/(1-V/C) = 1+V/C + ! with approximation of 1/(1-V/C) = 1+V/C momrhs(1, i1, i2, 1, q) = -1._wp + i1 momrhs(2, i1, i2, 1, q) = 1._wp + i2 momrhs(3, i1, i2, 1, q) = 0._wp @@ -263,14 +263,14 @@ contains momrhs(3, i1, i2, 4, q) = 0._wp if (.not. f_is_default(Re_inv)) then - ! add viscosity + ! viscosity momrhs(1, i1, i2, 5, q) = -2._wp + i1 momrhs(2, i1, i2, 5, q) = i2 momrhs(3, i1, i2, 5, q) = 0._wp end if if (.not. f_is_default(Web)) then - ! add surface tension + ! surface tension momrhs(1, i1, i2, 6, q) = -2._wp + i1 momrhs(2, i1, i2, 6, q) = -1._wp + i2 momrhs(3, i1, i2, 6, q) = 0._wp @@ -281,7 +281,7 @@ contains momrhs(3, i1, i2, 7, q) = 0._wp else if (bubble_model == 2) then - ! KM with approximation of 1/(1-V/C) = 1+V/C + ! with approximation of 1/(1-V/C) = 1+V/C momrhs(1, i1, i2, 1, q) = -1._wp + i1 momrhs(2, i1, i2, 1, q) = 1._wp + i2 momrhs(3, i1, i2, 1, q) = 0._wp @@ -539,7 +539,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! The following block is not repeated and is left as is + ! following block is not repeated and is left as is if (idir == 1) then $:GPU_PARALLEL_LOOP(private='[i,l,q]', collapse=3) do l = 0, p @@ -585,7 +585,7 @@ contains if ((i1 + i2) <= 2) then if (bubble_model == 3) then #:if not MFC_CASE_OPTIMIZATION or nterms > 1 - ! RPE + ! coeffs(1, i1, i2) = -1._wp*i2*pres/rho coeffs(2, i1, i2) = -3._wp*i2/2._wp coeffs(3, i1, i2) = i2/rho @@ -595,7 +595,7 @@ contains coeffs(7, i1, i2) = 0._wp #:endif else if (bubble_model == 2) then - ! KM with approximation of 1/(1-V/C) = 1+V/C + ! with approximation of 1/(1-V/C) = 1+V/C #:if not MFC_CASE_OPTIMIZATION or nterms > 7 coeffs(1, i1, i2) = -3._wp*i2/2._wp coeffs(2, i1, i2) = -i2/c @@ -663,7 +663,7 @@ contains do i2 = 0, 2; do i1 = 0, 2 if ((i1 + i2) <= 2) then if (bubble_model == 3) then - ! RPE + ! #:if not MFC_CASE_OPTIMIZATION or nterms > 1 coeffs(1, i1, i2) = -1._wp*i2*pres/rho coeffs(2, i1, i2) = -3._wp*i2/2._wp @@ -674,7 +674,7 @@ contains coeffs(7, i1, i2) = i2*pv/rho #:endif else if (bubble_model == 2) then - ! KM with approximation of 1/(1-V/C) = 1+V/C + ! with approximation of 1/(1-V/C) = 1+V/C #:if not MFC_CASE_OPTIMIZATION or nterms > 7 coeffs(1, i1, i2) = -3._wp*i2/2._wp coeffs(2, i1, i2) = -i2/c @@ -764,7 +764,7 @@ contains nbub = q_cons_vf(bubxb)%sf(id1, id2, id3) $:GPU_LOOP(parallelism='[seq]') do q = 1, nb - ! Gather moments for this bubble bin + ! moments for this bubble bin $:GPU_LOOP(parallelism='[seq]') do r = 2, nmom moms(r) = q_prim_vf(bubmoms(q, r))%sf(id1, id2, id3) @@ -794,7 +794,7 @@ contains end do end if - ! Compute change in moments due to bubble dynamics + ! change in moments due to bubble dynamics r = 1 $:GPU_LOOP(parallelism='[seq]') do i2 = 0, 2 @@ -830,7 +830,7 @@ contains end do end do - ! Compute change in pb and mv for non-polytropic model + ! change in pb and mv for non-polytropic model if (.not. polytropic) then $:GPU_LOOP(parallelism='[seq]') do j = 1, nnode @@ -847,7 +847,7 @@ contains end if end do - ! Compute special high-order moments + ! special high-order moments momsp(1)%sf(id1, id2, id3) = f_quad(abscX, abscY, wght, 3._wp, 0._wp, 0._wp) momsp(2)%sf(id1, id2, id3) = 4._wp*pi*nbub*f_quad(abscX, abscY, wght, 2._wp, 1._wp, 0._wp) momsp(3)%sf(id1, id2, id3) = f_quad(abscX, abscY, wght, 3._wp, 2._wp, 0._wp) @@ -882,7 +882,7 @@ contains $:END_GPU_PARALLEL_LOOP() contains - ! Helper to select the correct coefficient routine + ! to select the correct coefficient routine subroutine s_coeff_selector(pres, rho, c, coeff, polytropic) $:GPU_ROUTINE(function_name='s_coeff_selector',parallelism='[seq]', & & cray_inline=True) @@ -907,14 +907,14 @@ contains real(wp), dimension(nmom), intent(in) :: momin real(wp), dimension(nnode), intent(inout) :: wght, abscX, abscY - ! Local variables + ! variables real(wp), dimension(0:2, 0:2) :: moms real(wp), dimension(3) :: M1, M3 real(wp), dimension(2) :: myrho, myrho3, up, up3, Vf real(wp) :: bu, bv, d20, d11, d_02, c20, c11, c02 real(wp) :: mu2, vp21, vp22, rho21, rho22 - ! Assign moments to 2D array for clarity + ! moments to 2D array for clarity moms(0, 0) = momin(1) moms(1, 0) = momin(2) moms(0, 1) = momin(3) @@ -922,7 +922,7 @@ contains moms(1, 1) = momin(5) moms(0, 2) = momin(6) - ! Compute means and central moments + ! means and central moments bu = moms(1, 0)/moms(0, 0) bv = moms(0, 1)/moms(0, 0) d20 = moms(2, 0)/moms(0, 0) @@ -933,26 +933,26 @@ contains c11 = d11 - bu*bv c02 = d_02 - bv**2._wp - ! First 1D quadrature (X direction) + ! 1D quadrature (X direction) M1 = (/1._wp, 0._wp, c20/) call s_hyqmom(myrho, up, M1) Vf = c11*up/c20 - ! Second 1D quadrature (Y direction, conditional on X) + ! 1D quadrature (Y direction, conditional on X) mu2 = max(0._wp, c02 - sum(myrho*(Vf**2._wp))) M3 = (/1._wp, 0._wp, mu2/) call s_hyqmom(myrho3, up3, M3) - ! Assign roots and weights for 2D quadrature + ! roots and weights for 2D quadrature vp21 = up3(1) vp22 = up3(2) rho21 = myrho3(1) rho22 = myrho3(2) - ! Compute weights (vectorized) + ! weights (vectorized) wght = moms(0, 0)*[myrho(1)*rho21, myrho(1)*rho22, myrho(2)*rho21, myrho(2)*rho22] - ! Compute abscissas (vectorized) + ! abscissas (vectorized) abscX = bu + [up(1), up(1), up(2), up(2)] abscY = bv + [Vf(1) + vp21, Vf(1) + vp22, Vf(2) + vp21, Vf(2) + vp22] diff --git a/src/simulation/m_rhs.fpp b/src/simulation/m_rhs.fpp index 56b5e30665..1813efe5f5 100644 --- a/src/simulation/m_rhs.fpp +++ b/src/simulation/m_rhs.fpp @@ -1,22 +1,22 @@ !> -!! @file m_rhs.f90 -!! @brief Contains module m_rhs +!! +!! module m_rhs #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains the subroutines used to calculate the right- -!! hane-side (RHS) in the quasi-conservative, shock- and interface- -!! capturing finite-volume framework for the multicomponent Navier- -!! Stokes equations supplemented by appropriate advection equations -!! used to capture the material interfaces. The system of equations -!! is closed by the stiffened gas equation of state, as well as any -!! required mixture relationships. Capillarity effects are included -!! and are modeled by the means of a volume force acting across the -!! diffuse material interface region. The implementation details of -!! surface tension may be found in Perigaud and Saurel (2005). Note -!! that both viscous and surface tension effects are only available -!! in the volume fraction model. +!! in the quasi-conservative, shock- and interface- +!! framework for the multicomponent Navier- +!! supplemented by appropriate advection equations +!! capture the material interfaces. The system of equations +!! by the stiffened gas equation of state, as well as any +!! relationships. Capillarity effects are included +!! modeled by the means of a volume force acting across the +!! interface region. The implementation details of +!! may be found in Perigaud and Saurel (2005). Note +!! viscous and surface tension effects are only available +!! volume fraction model. module m_rhs use m_derived_types !< Definitions of the derived types @@ -28,10 +28,10 @@ module m_rhs use m_variables_conversion !< State variables type conversion procedures use m_weno !< Weighted and essentially non-oscillatory (WENO) - !! schemes for spatial reconstruction of variables + !! spatial reconstruction of variables use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! schemes for conservation laws + !! conservation laws use m_riemann_solvers !< Exact and approximate Riemann problem solvers @@ -75,32 +75,32 @@ module m_rhs s_compute_rhs, & s_finalize_rhs_module - !! This variable contains the WENO-reconstructed values of the cell-average - !! conservative variables, which are located in q_cons_vf, at cell-interior - !! Gaussian quadrature points (QP). + !! contains the WENO-reconstructed values of the cell-average + !! which are located in q_cons_vf, at cell-interior + !! points (QP). type(vector_field) :: q_cons_qp !< $:GPU_DECLARE(create='[q_cons_qp]') - !! The primitive variables at cell-interior Gaussian quadrature points. These - !! are calculated from the conservative variables and gradient magnitude (GM) - !! of the volume fractions, q_cons_qp and gm_alpha_qp, respectively. + !! variables at cell-interior Gaussian quadrature points. These + !! from the conservative variables and gradient magnitude (GM) + !! volume fractions, q_cons_qp and gm_alpha_qp, respectively. type(vector_field) :: q_prim_qp !< $:GPU_DECLARE(create='[q_prim_qp]') !> @name The first-order spatial derivatives of the primitive variables at cell- - !! interior Gaussian quadrature points. These are WENO-reconstructed from - !! their respective cell-average values, obtained through the application - !! of the divergence theorem on the integral-average cell-boundary values - !! of the primitive variables, located in qK_prim_n, where K = L or R. + !! quadrature points. These are WENO-reconstructed from + !! cell-average values, obtained through the application + !! divergence theorem on the integral-average cell-boundary values + !! primitive variables, located in qK_prim_n, where K = L or R. !> @{ type(vector_field), allocatable, dimension(:) :: dq_prim_dx_qp, dq_prim_dy_qp, dq_prim_dz_qp $:GPU_DECLARE(create='[dq_prim_dx_qp,dq_prim_dy_qp,dq_prim_dz_qp]') !> @} !> @name The left and right WENO-reconstructed cell-boundary values of the cell- - !! average first-order spatial derivatives of the primitive variables. The - !! cell-average of the first-order spatial derivatives may be found in the - !! variables dq_prim_ds_qp, where s = x, y or z. + !! spatial derivatives of the primitive variables. The + !! the first-order spatial derivatives may be found in the + !! where s = x, y or z. !> @{ type(vector_field), allocatable, dimension(:) :: dqL_prim_dx_n, dqL_prim_dy_n, dqL_prim_dz_n type(vector_field), allocatable, dimension(:) :: dqR_prim_dx_n, dqR_prim_dy_n, dqR_prim_dz_n @@ -114,14 +114,14 @@ module m_rhs $:GPU_DECLARE(create='[tau_Re_vf]') type(vector_field) :: gm_alpha_qp !< - !! The gradient magnitude of the volume fractions at cell-interior Gaussian - !! quadrature points. gm_alpha_qp is calculated from individual first-order - !! spatial derivatives located in dq_prim_ds_qp. + !! magnitude of the volume fractions at cell-interior Gaussian + !! gm_alpha_qp is calculated from individual first-order + !! located in dq_prim_ds_qp. $:GPU_DECLARE(create='[gm_alpha_qp]') !> @name The left and right WENO-reconstructed cell-boundary values of the cell- - !! average gradient magnitude of volume fractions, located in gm_alpha_qp. + !! magnitude of volume fractions, located in gm_alpha_qp. !> @{ type(vector_field), allocatable, dimension(:) :: gm_alphaL_n type(vector_field), allocatable, dimension(:) :: gm_alphaR_n @@ -131,8 +131,8 @@ module m_rhs !> @} !> @name The cell-boundary values of the fluxes (src - source, gsrc - geometrical - !! source). These are computed by applying the chosen Riemann problem solver - !! .on the left and right cell-boundary values of the primitive variables + !! are computed by applying the chosen Riemann problem solver + !! left and right cell-boundary values of the primitive variables !> @{ type(vector_field), allocatable, dimension(:) :: flux_n type(vector_field), allocatable, dimension(:) :: flux_src_n @@ -179,8 +179,8 @@ module m_rhs contains !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_rhs_module integer :: i, j, k, l, id !< Generic loop iterators @@ -202,9 +202,9 @@ contains end if if (surface_tension) then - ! This assumes that the color function advection equation is - ! the last equation. If this changes then this logic will - ! need updated + ! assumes that the color function advection equation is + ! last equation. If this changes then this logic will + ! updated do l = adv_idx%end + 1, sys_size - 1 @:ALLOCATE(q_prim_qp%vf(l)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) end do @@ -220,7 +220,7 @@ contains do l = 1, cont_idx%end if (relativity) then - ! Cons and Prim densities are different for relativity + ! and Prim densities are different for relativity @:ALLOCATE(q_prim_qp%vf(l)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) else q_prim_qp%vf(l)%sf => q_cons_qp%vf(l)%sf @@ -250,7 +250,7 @@ contains $:GPU_ENTER_DATA(attach='[q_prim_qp%vf(psi_idx)%sf]') end if - ! Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n + ! of flux_n, flux_src_n, and flux_gsrc_n if (.not. igr) then @:ALLOCATE(flux_n(1:num_dims)) @:ALLOCATE(flux_src_n(1:num_dims)) @@ -341,12 +341,12 @@ contains end if end do - ! END: Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n + ! Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n end if if ((.not. igr) .or. dummy) then - ! Allocation of dq_prim_ds_qp + ! of dq_prim_ds_qp @:ALLOCATE(dq_prim_dx_qp(1:1)) @:ALLOCATE(dq_prim_dy_qp(1:1)) @:ALLOCATE(dq_prim_dz_qp(1:1)) @@ -354,7 +354,7 @@ contains @:ALLOCATE(qL_prim(1:num_dims)) @:ALLOCATE(qR_prim(1:num_dims)) - ! Allocation/Association of dqK_prim_ds_n + ! of dqK_prim_ds_n @:ALLOCATE(dqL_prim_dx_n(1:num_dims)) @:ALLOCATE(dqL_prim_dy_n(1:num_dims)) @:ALLOCATE(dqL_prim_dz_n(1:num_dims)) @@ -621,9 +621,9 @@ contains if (mpp_lim .and. bubbles_euler) then @:ALLOCATE(alf_sum%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) end if - ! END: Allocation/Association of qK_cons_n and qK_prim_n + ! Allocation/Association of qK_cons_n and qK_prim_n - ! Allocation of gm_alphaK_n + ! of gm_alphaK_n if (.not. igr) then @:ALLOCATE(gm_alphaL_n(1:num_dims)) @:ALLOCATE(gm_alphaR_n(1:num_dims)) @@ -665,7 +665,7 @@ contains call cpu_time(t_start) if (.not. igr .or. dummy) then - ! Association/Population of Working Variables + ! of Working Variables $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=4) do i = 1, sys_size do l = idwbuff(3)%beg, idwbuff(3)%end @@ -678,7 +678,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! Converting Conservative to Primitive Variables + ! Conservative to Primitive Variables if (mpp_lim .and. bubbles_euler) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) @@ -753,7 +753,7 @@ contains call nvtxEndRange end if - ! Dimensional Splitting Loop + ! Splitting Loop do id = 1, num_dims if (igr .or. dummy) then @@ -788,12 +788,12 @@ contains end if if ((.not. igr) .or. dummy) then! Finite volume solve - ! Reconstructing Primitive/Conservative Variables + ! Primitive/Conservative Variables call nvtxStartRange("RHS-WENO") if (.not. surface_tension) then if (all(Re_size == 0)) then - ! Reconstruct densitiess + ! densitiess iv%beg = 1; iv%end = sys_size call s_reconstruct_cell_boundary_values( & q_prim_qp%vf(1:sys_size), & @@ -863,7 +863,7 @@ contains end if - ! Reconstruct viscous derivatives for viscosity + ! viscous derivatives for viscosity if (weno_Re_flux) then iv%beg = momxb; iv%end = momxe call s_reconstruct_cell_boundary_values_visc_deriv( & @@ -892,7 +892,7 @@ contains call nvtxEndRange ! WENO - ! Configuring Coordinate Direction Indexes + ! Coordinate Direction Indexes if (id == 1) then irx%beg = -1; iry%beg = 0; irz%beg = 0 elseif (id == 2) then @@ -901,9 +901,9 @@ contains irx%beg = 0; iry%beg = 0; irz%beg = -1 end if irx%end = m; iry%end = n; irz%end = p - ! $:GPU_UPDATE(host='[qL_rsx_vf,qR_rsx_vf]') - ! print *, "L", qL_rsx_vf(100:300, 0, 0, 1) - ! print *, "R", qR_rsx_vf(100:300, 0, 0, 1) + ! + ! *, "L", qL_rsx_vf(100:300, 0, 0, 1) + ! *, "R", qR_rsx_vf(100:300, 0, 0, 1) !Computing Riemann Solver Flux and Source Flux call nvtxStartRange("RHS-RIEMANN-SOLVER") @@ -927,8 +927,8 @@ contains !$:GPU_UPDATE(host='[flux_n(1)%vf(1)%sf]') !print *, "FLUX", flux_n(1)%vf(1)%sf(100:300, 0, 0) - ! Additional physics and source terms - ! RHS addition for advection source + ! physics and source terms + ! addition for advection source call nvtxStartRange("RHS-ADVECTION-SRC") call s_compute_advection_source_term(id, & rhs_vf, & @@ -937,21 +937,21 @@ contains flux_src_n(id)) call nvtxEndRange - ! RHS additions for hypoelasticity + ! additions for hypoelasticity call nvtxStartRange("RHS-HYPOELASTICITY") if (hypoelasticity) call s_compute_hypoelastic_rhs(id, & q_prim_qp%vf, & rhs_vf) call nvtxEndRange - ! RHS for diffusion + ! for diffusion if (chemistry .and. chem_params%diffusion) then call nvtxStartRange("RHS-CHEM-DIFFUSION") call s_compute_chemistry_diffusion_flux(id, q_prim_qp%vf, flux_src_n(id)%vf, irx, iry, irz) call nvtxEndRange end if - ! RHS additions for viscosity + ! additions for viscosity if (viscous .or. surface_tension .or. chem_params%diffusion) then call nvtxStartRange("RHS-ADD-PHYSICS") call s_compute_additional_physics_rhs(id, & @@ -964,14 +964,14 @@ contains call nvtxEndRange end if - ! RHS additions for sub-grid bubbles_euler + ! additions for sub-grid bubbles_euler if (bubbles_euler) then call nvtxStartRange("RHS-BUBBLES-COMPUTE") call s_compute_bubbles_EE_rhs(id, q_prim_qp%vf, divu) call nvtxEndRange end if - ! RHS additions for qbmm bubbles + ! additions for qbmm bubbles if (qbmm) then call nvtxStartRange("RHS-QBMM") call s_compute_qbmm_rhs(id, & @@ -983,7 +983,7 @@ contains rhs_pb) call nvtxEndRange end if - ! END: Additional physics and source terms + ! Additional physics and source terms if (hyper_cleaning) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) @@ -998,10 +998,10 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! END: Additional physics and source terms + ! Additional physics and source terms end if end do - ! END: Dimensional Splitting Loop + ! Dimensional Splitting Loop if (ib) then $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=3) @@ -1019,8 +1019,8 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Additional Physics and Source Temrs - ! Additions for acoustic_source + ! Physics and Source Temrs + ! for acoustic_source if (acoustic_source) then call nvtxStartRange("RHS-ACOUSTIC-SRC") call s_acoustic_src_calculations(q_cons_qp%vf(1:sys_size), & @@ -1030,7 +1030,7 @@ contains call nvtxEndRange end if - ! Add bubbles source term + ! bubbles source term if (bubbles_euler .and. (.not. adap_dt) .and. (.not. qbmm)) then call nvtxStartRange("RHS-BUBBLES-SRC") call s_compute_bubble_EE_source( & @@ -1042,14 +1042,14 @@ contains end if if (bubbles_lagrange) then - ! RHS additions for sub-grid bubbles_lagrange + ! additions for sub-grid bubbles_lagrange call nvtxStartRange("RHS-EL-BUBBLES-SRC") call s_compute_bubbles_EL_source( & q_cons_qp%vf(1:sys_size), & q_prim_qp%vf(1:sys_size), & rhs_vf) call nvtxEndRange - ! Compute bubble dynamics + ! bubble dynamics if (.not. adap_dt) then call nvtxStartRange("RHS-EL-BUBBLES-DYN") call s_compute_bubble_EL_dynamics( & @@ -1067,7 +1067,7 @@ contains if (cont_damage) call s_compute_damage_state(q_cons_qp%vf, rhs_vf) - ! END: Additional pphysics and source terms + ! Additional pphysics and source terms if (run_time_info .or. probe_wrt .or. ib .or. bubbles_lagrange) then if (.not. igr .or. dummy) then @@ -1344,7 +1344,7 @@ contains type(vector_field), intent(in) :: q_cons_vf_arg type(vector_field), intent(in) :: q_prim_vf_arg type(vector_field), intent(in) :: flux_src_n_vf_arg - ! CORRECTED DECLARATION FOR Kterm_arg: + ! DECLARATION FOR Kterm_arg: real(wp), allocatable, dimension(:, :, :), intent(in) :: Kterm_arg integer :: j_adv, k_idx, l_idx, q_idx @@ -1735,8 +1735,8 @@ contains end if end if - ! Applying the geometrical viscous Riemann source fluxes calculated as average - ! of values at cell boundaries + ! the geometrical viscous Riemann source fluxes calculated as average + ! values at cell boundaries if (cyl_coord) then if ((bc_y%beg == -2) .or. (bc_y%beg == -14)) then @@ -1868,15 +1868,15 @@ contains end subroutine s_compute_additional_physics_rhs !> The purpose of this subroutine is to WENO-reconstruct the - !! left and the right cell-boundary values, including values - !! at the Gaussian quadrature points, from the cell-averaged - !! variables. - !! @param v_vf Cell-average variables - !! @param vL_qp Left WENO-reconstructed, cell-boundary values including - !! the values at the quadrature points, of the cell-average variables - !! @param vR_qp Right WENO-reconstructed, cell-boundary values including - !! the values at the quadrature points, of the cell-average variables - !! @param norm_dir Splitting coordinate direction + !! the right cell-boundary values, including values + !! Gaussian quadrature points, from the cell-averaged + !! + !! Cell-average variables + !! Left WENO-reconstructed, cell-boundary values including + !! at the quadrature points, of the cell-average variables + !! Right WENO-reconstructed, cell-boundary values including + !! at the quadrature points, of the cell-average variables + !! Splitting coordinate direction subroutine s_reconstruct_cell_boundary_values(v_vf, vL_x, vL_y, vL_z, vR_x, vR_y, vR_z, & norm_dir) @@ -1891,7 +1891,7 @@ contains #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! Reconstruction in s1-direction + ! in s1-direction if (norm_dir == 1) then is1 = idwbuff(1); is2 = idwbuff(2); is3 = idwbuff(3) recon_dir = 1; is1%beg = is1%beg + ${SCHEME}$_polyn @@ -1942,7 +1942,7 @@ contains integer :: recon_dir !< Coordinate direction of the WENO reconstruction integer :: i, j, k, l - ! Reconstruction in s1-direction + ! in s1-direction #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl', 'MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then @@ -2020,7 +2020,7 @@ contains if (.not. igr) then do j = cont_idx%beg, cont_idx%end if (relativity) then - ! Cons and Prim densities are different for relativity + ! and Prim densities are different for relativity @:DEALLOCATE(q_cons_qp%vf(j)%sf) @:DEALLOCATE(q_prim_qp%vf(j)%sf) else diff --git a/src/simulation/m_riemann_solvers.fpp b/src/simulation/m_riemann_solvers.fpp index 378c0c54c2..22f5a0b46e 100644 --- a/src/simulation/m_riemann_solvers.fpp +++ b/src/simulation/m_riemann_solvers.fpp @@ -1,23 +1,23 @@ !> -!! @file m_riemann_solvers.f90 -!! @brief Contains module m_riemann_solvers +!! +!! module m_riemann_solvers !> @brief This module features a database of approximate and exact Riemann -!! problem solvers for the Navier-Stokes system of equations, which -!! is supplemented by appropriate advection equations that are used -!! to capture the material interfaces. The closure of the system is -!! achieved by the stiffened gas equation of state and any required -!! mixture relations. Surface tension effects are accounted for and -!! are modeled by means of a volume force acting across the diffuse -!! material interface region. The implementation details of viscous -!! and capillary effects, into the Riemann solvers, may be found in -!! Perigaud and Saurel (2005). Note that both effects are available -!! only in the volume fraction model. At this time, the approximate -!! and exact Riemann solvers that are listed below are available: -!! 1) Harten-Lax-van Leer (HLL) -!! 2) Harten-Lax-van Leer-Contact (HLLC) -!! 3) Exact -!! 4) Harten-Lax-van Leer Discontinuities (HLLD) - for MHD only +!! for the Navier-Stokes system of equations, which +!! by appropriate advection equations that are used +!! the material interfaces. The closure of the system is +!! the stiffened gas equation of state and any required +!! Surface tension effects are accounted for and +!! by means of a volume force acting across the diffuse +!! region. The implementation details of viscous +!! effects, into the Riemann solvers, may be found in +!! Saurel (2005). Note that both effects are available +!! the volume fraction model. At this time, the approximate +!! Riemann solvers that are listed below are available: +!! Leer (HLL) +!! Leer-Contact (HLLC) +!! +!! Leer Discontinuities (HLLD) - for MHD only #:include 'case.fpp' #:include 'macros.fpp' @@ -64,9 +64,9 @@ module m_riemann_solvers s_finalize_riemann_solvers_module !> The cell-boundary values of the fluxes (src - source) that are computed - !! through the chosen Riemann problem solver, and the direct evaluation of - !! source terms, by using the left and right states given in qK_prim_rs_vf, - !! dqK_prim_ds_vf where ds = dx, dy or dz. + !! chosen Riemann problem solver, and the direct evaluation of + !! by using the left and right states given in qK_prim_rs_vf, + !! ds = dx, dy or dz. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: flux_rsx_vf, flux_src_rsx_vf @@ -76,8 +76,8 @@ module m_riemann_solvers !> @} !> The cell-boundary values of the geometrical source flux that are computed - !! through the chosen Riemann problem solver by using the left and right - !! states given in qK_prim_rs_vf. Currently 2D axisymmetric for inviscid only. + !! chosen Riemann problem solver by using the left and right + !! in qK_prim_rs_vf. Currently 2D axisymmetric for inviscid only. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: flux_gsrc_rsx_vf !< @@ -86,8 +86,8 @@ module m_riemann_solvers $:GPU_DECLARE(create='[flux_gsrc_rsx_vf,flux_gsrc_rsy_vf,flux_gsrc_rsz_vf]') !> @} - ! The cell-boundary values of the velocity. vel_src_rs_vf is determined as - ! part of Riemann problem solution and is used to evaluate the source flux. + ! cell-boundary values of the velocity. vel_src_rs_vf is determined as + ! of Riemann problem solution and is used to evaluate the source flux. real(wp), allocatable, dimension(:, :, :, :) :: vel_src_rsx_vf real(wp), allocatable, dimension(:, :, :, :) :: vel_src_rsy_vf @@ -121,37 +121,37 @@ module m_riemann_solvers contains !> Dispatch to the subroutines that are utilized to compute the - !! Riemann problem solution. For additional information please reference: - !! 1) s_hll_riemann_solver - !! 2) s_hllc_riemann_solver - !! 3) s_exact_riemann_solver - !! 4) s_hlld_riemann_solver - !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param gm_alphaL_vf Left averaged gradient magnitude - !! @param gm_alphaR_vf Right averaged gradient magnitude - !! @param flux_vf Intra-cell fluxes - !! @param flux_src_vf Intra-cell fluxes sources - !! @param flux_gsrc_vf Intra-cell geometric fluxes sources - !! @param norm_dir Dir. splitting direction - !! @param ix Index bounds in the x-dir - !! @param iy Index bounds in the y-dir - !! @param iz Index bounds in the z-dir - !! @param q_prim_vf Cell-averaged primitive variables + !! solution. For additional information please reference: + !! + !! + !! + !! + !! The left WENO-reconstructed cell-boundary values of the + !! variables + !! The right WENO-reconstructed cell-boundary values of the + !! variables + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! Left averaged gradient magnitude + !! Right averaged gradient magnitude + !! Intra-cell fluxes + !! Intra-cell fluxes sources + !! Intra-cell geometric fluxes sources + !! Dir. splitting direction + !! Index bounds in the x-dir + !! Index bounds in the y-dir + !! Index bounds in the z-dir + !! Cell-averaged primitive variables subroutine s_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & dqL_prim_dz_vf, & @@ -204,10 +204,10 @@ contains end subroutine s_riemann_solver !> Dispatch to the subroutines that are utilized to compute - !! the viscous source fluxes for either Cartesian or cylindrical geometries. - !! For more information please refer to: - !! 1) s_compute_cartesian_viscous_source_flux - !! 2) s_compute_cylindrical_viscous_source_flux + !! source fluxes for either Cartesian or cylindrical geometries. + !! information please refer to: + !! + !! subroutine s_compute_viscous_source_flux(velL_vf, & dvelL_dx_vf, & dvelL_dy_vf, & @@ -283,7 +283,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! Intercell fluxes + ! fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -353,8 +353,8 @@ contains integer :: i, j, k, l, q !< Generic loop iterators - ! Populating the buffers of the left and right Riemann problem - ! states variables, based on the choice of boundary conditions + ! the buffers of the left and right Riemann problem + ! variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -364,7 +364,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! Reshaping inputted data based on dimensional splitting direction + ! inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -510,14 +510,14 @@ contains call get_species_specific_heats_r(T_R, Cp_iR) if (chem_params%gamma_method == 1) then - ! gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. + ! = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. Gamma_iL = Cp_iL/(Cp_iL - 1.0_wp) Gamma_iR = Cp_iR/(Cp_iR - 1.0_wp) gamma_L = sum(Xs_L(:)/(Gamma_iL(:) - 1.0_wp)) gamma_R = sum(Xs_R(:)/(Gamma_iR(:) - 1.0_wp)) else if (chem_params%gamma_method == 2) then - ! gamma_method = 2: c_p / c_v where c_p, c_v are specific heats. + ! = 2: c_p / c_v where c_p, c_v are specific heats. call get_mixture_specific_heat_cp_mass(T_L, Ys_L, Cp_L) call get_mixture_specific_heat_cp_mass(T_R, Ys_R, Cp_R) call get_mixture_specific_heat_cv_mass(T_L, Ys_L, Cv_L) @@ -552,7 +552,7 @@ contains pres_mag%L = 0.5_wp*(B2%L/Ga%L**2._wp + vdotB%L**2._wp) pres_mag%R = 0.5_wp*(B2%R/Ga%R**2._wp + vdotB%R**2._wp) - ! Hard-coded EOS + ! EOS H_L = 1._wp + (gamma_L + 1)*pres_L/rho_L H_R = 1._wp + (gamma_R + 1)*pres_R/rho_R #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 @@ -578,7 +578,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! elastic energy update + ! energy update if (hypoelasticity) then G_L = 0._wp; G_R = 0._wp @@ -597,12 +597,12 @@ contains do i = 1, strxe - strxb + 1 tau_e_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) tau_e_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough !TODO take out if statement if stable without if ((G_L > 1000) .and. (G_R > 1000)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! Double for shear stresses + ! for shear stresses if (any(strxb - 1 + i == shear_indices)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -611,36 +611,36 @@ contains end do end if - ! elastic energy update + ! energy update !if ( hyperelasticity ) then - ! G_L = 0._wp - ! G_R = 0._wp + ! = 0._wp + ! = 0._wp ! - ! $:GPU_LOOP(parallelism='[seq]') - ! do i = 1, num_fluids - ! G_L = G_L + alpha_L(i)*Gs_rs(i) - ! G_R = G_R + alpha_R(i)*Gs_rs(i) - ! end do - ! ! Elastic contribution to energy if G large enough - ! if ((G_L > 1.e-3_wp) .and. (G_R > 1.e-3_wp)) then - ! E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) - ! E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) - ! $:GPU_LOOP(parallelism='[seq]') - ! do i = 1, b_size-1 - ! tau_e_L(i) = G_L*qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) - ! tau_e_R(i) = G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! end do - ! $:GPU_LOOP(parallelism='[seq]') - ! do i = 1, b_size-1 - ! tau_e_L(i) = 0._wp - ! tau_e_R(i) = 0._wp - ! end do - ! $:GPU_LOOP(parallelism='[seq]') - ! do i = 1, num_dims - ! xi_field_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, xibeg - 1 + i) - ! xi_field_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, xibeg - 1 + i) - ! end do - ! end if + ! + ! i = 1, num_fluids + ! = G_L + alpha_L(i)*Gs_rs(i) + ! = G_R + alpha_R(i)*Gs_rs(i) + ! do + ! Elastic contribution to energy if G large enough + ! ((G_L > 1.e-3_wp) .and. (G_R > 1.e-3_wp)) then + ! = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) + ! = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) + ! + ! i = 1, b_size-1 + ! = G_L*qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) + ! = G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) + ! do + ! + ! i = 1, b_size-1 + ! = 0._wp + ! = 0._wp + ! do + ! + ! i = 1, num_dims + ! = qL_prim_rs${XYZ}$_vf(j, k, l, xibeg - 1 + i) + ! = qR_prim_rs${XYZ}$_vf(j + 1, k, l, xibeg - 1 + i) + ! do + ! if !end if @:compute_average_state() @@ -652,7 +652,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! variables are placeholders to call the subroutine. + ! are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, c_sum_Yi_Phi, c_avg, qv_avg) @@ -741,14 +741,14 @@ contains + (5.e-1_wp - sign(5.e-1_wp, s_L)) & *(5.e-1_wp + sign(5.e-1_wp, s_R)) - ! Low Mach correction + ! Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! Mass + ! if (.not. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -771,12 +771,12 @@ contains end do end if - ! Momentum + ! if (mhd .and. (.not. relativity)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! Flux of rho*v_i in the ${XYZ}$ direction - ! = rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! of rho*v_i in the ${XYZ}$ direction + ! rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(rho_R*vel_R(i)*vel_R(norm_dir) & - B%R(i)*B%R(norm_dir) & @@ -790,8 +790,8 @@ contains elseif (mhd .and. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! Flux of m_i in the ${XYZ}$ direction - ! = m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! of m_i in the ${XYZ}$ direction + ! m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(cm%R(i)*vel_R(norm_dir) & - b4%R(i)/Ga%R*B%R(norm_dir) & @@ -850,9 +850,9 @@ contains end do end if - ! Energy + ! if (mhd .and. (.not. relativity)) then - ! energy flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) + ! flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(vel_R(norm_dir)*(E_R + pres_R + pres_mag%R) - B%R(norm_dir)*(vel_R(1)*B%R(1) + vel_R(2)*B%R(2) + vel_R(3)*B%R(3))) & @@ -861,8 +861,8 @@ contains /(s_M - s_P) #:endif elseif (mhd .and. relativity) then - ! energy flux = m_${XYZ}$ - mass flux - ! Hard-coded for single-component for now + ! flux = m_${XYZ}$ - mass flux + ! for single-component for now flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(cm%R(norm_dir) - Ga%R*alpha_rho_R(1)*vel_R(norm_dir)) & - s_P*(cm%L(norm_dir) - Ga%L*alpha_rho_L(1)*vel_L(norm_dir)) & @@ -895,7 +895,7 @@ contains + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp end if - ! Elastic Stresses + ! Stresses if (hypoelasticity) then do i = 1, strxe - strxb + 1 !TODO: this indexing may be slow flux_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) = & @@ -909,7 +909,7 @@ contains end do end if - ! Advection + ! $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -923,7 +923,7 @@ contains end do if (bubbles_euler) then - ! From HLLC: Kills mass transport @ bubble gas density + ! HLLC: Kills mass transport @ bubble gas density if (num_fluids > 1) then flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if @@ -945,8 +945,8 @@ contains if (mhd) then if (n == 0) then ! 1D: d/dx flux only & Bx = Bx0 = const. - ! B_y flux = v_x * B_y - v_y * Bx0 - ! B_z flux = v_x * B_z - v_z * Bx0 + ! flux = v_x * B_y - v_y * Bx0 + ! flux = v_x * B_z - v_z * Bx0 $:GPU_LOOP(parallelism='[seq]') do i = 0, 1 flux_rsx_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(1)*B%R(2 + i) - vel_R(2 + i)*Bx0) & @@ -954,9 +954,9 @@ contains + s_M*s_P*(B%L(2 + i) - B%R(2 + i)))/(s_M - s_P) end do else ! 2D/3D: Bx, By, Bz /= const. but zero flux component in the same direction - ! B_x d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) - ! B_y d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) - ! B_z d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) $:GPU_LOOP(parallelism='[seq]') do i = 0, 2 flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(dir_idx(1))*B%R(i + 1) - vel_R(i + 1)*B%R(norm_dir)) - & @@ -965,7 +965,7 @@ contains end do if (hyper_cleaning) then - ! propagate magnetic field divergence as a wave + ! magnetic field divergence as a wave flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + norm_dir - 1) = flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + norm_dir - 1) + & (s_M*qR_prim_rs${XYZ}$_vf(j + 1, k, l, psi_idx) - s_P*qL_prim_rs${XYZ}$_vf(j, k, l, psi_idx))/(s_M - s_P) @@ -984,11 +984,11 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_rs${XYZ}$_vf(j, k, l, contxe + 2) & - (s_M*pres_R - s_P*pres_L)/(s_M - s_P) - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) @@ -996,7 +996,7 @@ contains end if if (cyl_coord .and. hypoelasticity) then - ! += tau_sigmasigma using HLL + ! tau_sigmasigma using HLL flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) + & (s_M*tau_e_R(4) - s_P*tau_e_L(4)) & @@ -1074,7 +1074,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! Intercell fluxes + ! fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -1147,8 +1147,8 @@ contains integer :: i, j, k, l, q !< Generic loop iterators integer, dimension(3) :: idx_right_phys !< Physical (j,k,l) indices for right state. - ! Populating the buffers of the left and right Riemann problem - ! states variables, based on the choice of boundary conditions + ! the buffers of the left and right Riemann problem + ! variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -1158,7 +1158,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! Reshaping inputted data based on dimensional splitting direction + ! inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -1305,14 +1305,14 @@ contains call get_species_specific_heats_r(T_R, Cp_iR) if (chem_params%gamma_method == 1) then - ! gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. + ! = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. Gamma_iL = Cp_iL/(Cp_iL - 1.0_wp) Gamma_iR = Cp_iR/(Cp_iR - 1.0_wp) gamma_L = sum(Xs_L(:)/(Gamma_iL(:) - 1.0_wp)) gamma_R = sum(Xs_R(:)/(Gamma_iR(:) - 1.0_wp)) else if (chem_params%gamma_method == 2) then - ! gamma_method = 2: c_p / c_v where c_p, c_v are specific heats. + ! = 2: c_p / c_v where c_p, c_v are specific heats. call get_mixture_specific_heat_cp_mass(T_L, Ys_L, Cp_L) call get_mixture_specific_heat_cp_mass(T_R, Ys_R, Cp_R) call get_mixture_specific_heat_cv_mass(T_L, Ys_L, Cv_L) @@ -1346,7 +1346,7 @@ contains pres_mag%L = 0.5_wp*(B2%L/Ga%L**2._wp + vdotB%L**2._wp) pres_mag%R = 0.5_wp*(B2%R/Ga%R**2._wp + vdotB%R**2._wp) - ! Hard-coded EOS + ! EOS H_L = 1._wp + (gamma_L + 1)*pres_L/rho_L H_R = 1._wp + (gamma_R + 1)*pres_R/rho_R @@ -1370,7 +1370,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! elastic energy update + ! energy update if (hypoelasticity) then G_L = 0._wp; G_R = 0._wp @@ -1388,12 +1388,12 @@ contains do i = 1, strxe - strxb + 1 tau_e_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) tau_e_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough !TODO take out if statement if stable without if ((G_L > 1000) .and. (G_R > 1000)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! Double for shear stresses + ! for shear stresses if (any(strxb - 1 + i == shear_indices)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -1430,14 +1430,14 @@ contains s_L = s_M s_R = s_P - ! Low Mach correction + ! Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! Mass + ! if (.not. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -1460,12 +1460,12 @@ contains end do end if - ! Momentum + ! if (mhd .and. (.not. relativity)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! Flux of rho*v_i in the ${XYZ}$ direction - ! = rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! of rho*v_i in the ${XYZ}$ direction + ! rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(rho_R*vel_R(i)*vel_R(norm_dir) & - B%R(i)*B%R(norm_dir) & @@ -1479,8 +1479,8 @@ contains elseif (mhd .and. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! Flux of m_i in the ${XYZ}$ direction - ! = m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! of m_i in the ${XYZ}$ direction + ! m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(cm%R(i)*vel_R(norm_dir) & - b4%R(i)/Ga%R*B%R(norm_dir) & @@ -1539,9 +1539,9 @@ contains end do end if - ! Energy + ! if (mhd .and. (.not. relativity)) then - ! energy flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) + ! flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) #:if not MFC_CASE_OPTIMIZATION or num_dims > 1 flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(vel_R(norm_dir)*(E_R + pres_R + pres_mag%R) - B%R(norm_dir)*(vel_R(1)*B%R(1) + vel_R(2)*B%R(2) + vel_R(3)*B%R(3))) & @@ -1550,8 +1550,8 @@ contains /(s_M - s_P) #:endif elseif (mhd .and. relativity) then - ! energy flux = m_${XYZ}$ - mass flux - ! Hard-coded for single-component for now + ! flux = m_${XYZ}$ - mass flux + ! for single-component for now flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(cm%R(norm_dir) - Ga%R*alpha_rho_R(1)*vel_R(norm_dir)) & - s_P*(cm%L(norm_dir) - Ga%L*alpha_rho_L(1)*vel_L(norm_dir)) & @@ -1584,7 +1584,7 @@ contains + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp end if - ! Elastic Stresses + ! Stresses if (hypoelasticity) then do i = 1, strxe - strxb + 1 !TODO: this indexing may be slow flux_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) = & @@ -1598,7 +1598,7 @@ contains end do end if - ! Advection + ! $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -1612,7 +1612,7 @@ contains end do if (bubbles_euler) then - ! From HLLC: Kills mass transport @ bubble gas density + ! HLLC: Kills mass transport @ bubble gas density if (num_fluids > 1) then flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if @@ -1634,8 +1634,8 @@ contains if (mhd) then if (n == 0) then ! 1D: d/dx flux only & Bx = Bx0 = const. - ! B_y flux = v_x * B_y - v_y * Bx0 - ! B_z flux = v_x * B_z - v_z * Bx0 + ! flux = v_x * B_y - v_y * Bx0 + ! flux = v_x * B_z - v_z * Bx0 $:GPU_LOOP(parallelism='[seq]') do i = 0, 1 flux_rsx_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(1)*B%R(2 + i) - vel_R(2 + i)*Bx0) & @@ -1643,9 +1643,9 @@ contains + s_M*s_P*(B%L(2 + i) - B%R(2 + i)))/(s_M - s_P) end do else ! 2D/3D: Bx, By, Bz /= const. but zero flux component in the same direction - ! B_x d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) - ! B_y d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) - ! B_z d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) + ! d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) $:GPU_LOOP(parallelism='[seq]') do i = 0, 2 flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + i) = (1 - dir_flg(i + 1))*( & @@ -1664,11 +1664,11 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_rs${XYZ}$_vf(j, k, l, contxe + 2) & - (s_M*pres_R - s_P*pres_L)/(s_M - s_P) - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) @@ -1676,7 +1676,7 @@ contains end if if (cyl_coord .and. hypoelasticity) then - ! += tau_sigmasigma using HLL + ! tau_sigmasigma using HLL flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) + & (s_M*tau_e_R(4) - s_P*tau_e_L(4)) & @@ -1925,36 +1925,36 @@ contains end subroutine s_lf_riemann_solver !> This procedure is the implementation of the Harten, Lax, - !! van Leer, and contact (HLLC) approximate Riemann solver, - !! see Toro (1999) and Johnsen (2007). The viscous and the - !! surface tension effects have been included by modifying - !! the exact Riemann solver of Perigaud and Saurel (2005). - !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param gm_alphaL_vf Left averaged gradient magnitude - !! @param gm_alphaR_vf Right averaged gradient magnitude - !! @param flux_vf Intra-cell fluxes - !! @param flux_src_vf Intra-cell fluxes sources - !! @param flux_gsrc_vf Intra-cell geometric fluxes sources - !! @param norm_dir Dir. splitting direction - !! @param ix Index bounds in the x-dir - !! @param iy Index bounds in the y-dir - !! @param iz Index bounds in the z-dir - !! @param q_prim_vf Cell-averaged primitive variables + !! and contact (HLLC) approximate Riemann solver, + !! (1999) and Johnsen (2007). The viscous and the + !! effects have been included by modifying + !! Riemann solver of Perigaud and Saurel (2005). + !! The left WENO-reconstructed cell-boundary values of the + !! variables + !! The right WENO-reconstructed cell-boundary values of the + !! variables + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! Left averaged gradient magnitude + !! Right averaged gradient magnitude + !! Intra-cell fluxes + !! Intra-cell fluxes sources + !! Intra-cell geometric fluxes sources + !! Dir. splitting direction + !! Index bounds in the x-dir + !! Index bounds in the y-dir + !! Index bounds in the z-dir + !! Cell-averaged primitive variables subroutine s_hllc_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & dqL_prim_dz_vf, & @@ -1978,7 +1978,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! Intercell fluxes + ! fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -2067,8 +2067,8 @@ contains integer :: Re_max, i, j, k, l, q !< Generic loop iterators - ! Populating the buffers of the left and right Riemann problem - ! states variables, based on the choice of boundary conditions + ! the buffers of the left and right Riemann problem + ! variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & @@ -2079,7 +2079,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! Reshaping inputted data based on dimensional splitting direction + ! inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & @@ -2089,7 +2089,7 @@ contains if (norm_dir == ${NORM_DIR}$) then - ! 6-EQUATION MODEL WITH HLLC + ! MODEL WITH HLLC if (model_eqns == 3) then !ME3 $:GPU_PARALLEL_LOOP(collapse=3, private='[i,j,k,l, q, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, Yi_avg, Phi_avg, h_iL, h_iR, h_avg_2, tau_e_L, tau_e_R, flux_ene_e, xi_field_L, xi_field_R, pcorr, zcoef, rho_L, rho_R, pres_L, pres_R, E_L, E_R, H_L, H_R, Cp_avg, Cv_avg, T_avg, eps, c_sum_Yi_Phi, T_L, T_R, Y_L, Y_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, Gamm_L, Gamm_R, gamma_L, gamma_R, pi_inf_L, pi_inf_R, qv_L, qv_R, qv_avg, c_L, c_R, G_L, G_R, rho_avg, H_avg, c_avg, gamma_avg, ptilde_L, ptilde_R, vel_L_rms, vel_R_rms, vel_avg_rms, vel_L_tmp, vel_R_tmp, Ms_L, Ms_R, pres_SL, pres_SR, alpha_L_sum, alpha_R_sum, rho_Star, E_Star, p_Star, p_K_Star, vel_K_star, s_L, s_R, s_M, s_P, s_S, xi_M, xi_P, xi_L, xi_R, xi_MP, xi_PP]') @@ -2188,7 +2188,7 @@ contains E_L = gamma_L*pres_L + pi_inf_L + 5.e-1_wp*rho_L*vel_L_rms + qv_L E_R = gamma_R*pres_R + pi_inf_R + 5.e-1_wp*rho_R*vel_R_rms + qv_R - ! ENERGY ADJUSTMENTS FOR HYPOELASTIC ENERGY + ! ADJUSTMENTS FOR HYPOELASTIC ENERGY if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -2203,11 +2203,11 @@ contains end do $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough if ((G_L > verysmall) .and. (G_R > verysmall)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! Additional terms in 2D and 3D + ! terms in 2D and 3D if ((i == 2) .or. (i == 4) .or. (i == 5)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -2216,7 +2216,7 @@ contains end do end if - ! ENERGY ADJUSTMENTS FOR HYPERELASTIC ENERGY + ! ADJUSTMENTS FOR HYPERELASTIC ENERGY if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2226,11 +2226,11 @@ contains G_L = 0._wp; G_R = 0._wp; $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! Mixture left and right shear modulus + ! left and right shear modulus G_L = G_L + alpha_L(i)*Gs_rs(i) G_R = G_R + alpha_R(i)*Gs_rs(i) end do - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough if (G_L > verysmall .and. G_R > verysmall) then E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) @@ -2254,7 +2254,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! variables are placeholders to call the subroutine. + ! are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2265,12 +2265,12 @@ contains end do end if - ! Low Mach correction + ! Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if - ! COMPUTING THE DIRECT WAVE SPEEDS + ! THE DIRECT WAVE SPEEDS if (wave_speeds == 1) then if (elasticity) then s_L = min(vel_L(dir_idx(1)) - sqrt(c_L*c_L + & @@ -2313,22 +2313,22 @@ contains (rho_avg*c_avg)) end if - ! follows Einfeldt et al. - ! s_M/P = min/max(0.,s_L/R) + ! Einfeldt et al. + ! = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! goes with q_star_L/R = xi_L/R * (variable) - ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! with q_star_L/R = xi_L/R * (variable) + ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! goes with numerical star velocity in x/y/z directions - ! xi_P/M = 0.5 +/m sgn(0.5,s_star) + ! with numerical star velocity in x/y/z directions + ! = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(0.5_wp, s_S)) xi_P = (5.e-1_wp - sign(0.5_wp, s_S)) - ! goes with the numerical velocity in x/y/z directions - ! xi_P/M (pressure) = min/max(0. sgn(1,sL/sR)) + ! with the numerical velocity in x/y/z directions + ! (pressure) = min/max(0. sgn(1,sL/sR)) xi_MP = -min(0._wp, sign(1._wp, s_L)) xi_PP = max(0._wp, sign(1._wp, s_R)) @@ -2345,15 +2345,15 @@ contains vel_K_Star = vel_L(dir_idx(1))*(1._wp - xi_MP) + xi_MP*vel_R(dir_idx(1)) + & xi_MP*xi_PP*(s_S - vel_R(dir_idx(1))) - ! Low Mach correction + ! Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! COMPUTING FLUXES - ! MASS FLUX. + ! FLUXES + ! FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -2361,8 +2361,8 @@ contains xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)*(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! MOMENTUM FLUX. - ! f = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! FLUX. + ! = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = rho_Star*vel_K_Star* & @@ -2370,21 +2370,21 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! ENERGY FLUX. - ! f = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) + ! FLUX. + ! = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = (E_star + p_Star)*vel_K_Star & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! ELASTICITY. Elastic shear stress additions for the momentum and energy flux + ! Elastic shear stress additions for the momentum and energy flux if (elasticity) then flux_ene_e = 0._wp; $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims - ! MOMENTUM ELASTIC FLUX. + ! ELASTIC FLUX. flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) & - xi_M*tau_e_L(dir_idx_tau(i)) - xi_P*tau_e_R(dir_idx_tau(i)) - ! ENERGY ELASTIC FLUX. + ! ELASTIC FLUX. flux_ene_e = flux_ene_e - & xi_M*(vel_L(dir_idx(i))*tau_e_L(dir_idx_tau(i)) + & s_M*(xi_L*((s_S - vel_L(i))*(tau_e_L(dir_idx_tau(i))/(s_L - vel_L(i)))))) - & @@ -2394,7 +2394,7 @@ contains flux_rs${XYZ}$_vf(j, k, l, E_idx) = flux_rs${XYZ}$_vf(j, k, l, E_idx) + flux_ene_e end if - ! VOLUME FRACTION FLUX. + ! FRACTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -2402,7 +2402,7 @@ contains xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)*s_S end do - ! SOURCE TERM FOR VOLUME FRACTION ADVECTION FLUX. + ! TERM FOR VOLUME FRACTION ADVECTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -2410,8 +2410,8 @@ contains xi_P*(vel_R(dir_idx(i)) + dir_flg(dir_idx(i))*(s_S*(xi_PP*(xi_R - 1) + 1) - vel_R(dir_idx(i)))) end do - ! INTERNAL ENERGIES ADVECTION FLUX. - ! K-th pressure and velocity in preparation for the internal energy flux + ! ENERGIES ADVECTION FLUX. + ! pressure and velocity in preparation for the internal energy flux $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids p_K_Star = xi_M*(xi_MP*((pres_L + pi_infs(i)/(1._wp + gammas(i)))* & @@ -2429,7 +2429,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! HYPOELASTIC STRESS EVOLUTION FLUX. + ! STRESS EVOLUTION FLUX. if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -2439,7 +2439,7 @@ contains end do end if - ! REFERENCE MAP FLUX. + ! MAP FLUX. if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2451,14 +2451,14 @@ contains end do end if - ! COLOR FUNCTION FLUX + ! FUNCTION FLUX if (surface_tension) then flux_rs${XYZ}$_vf(j, k, l, c_idx) = & (xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, c_idx) + & xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, c_idx))*s_S end if - ! Geometrical source flux for cylindrical coordinates + ! source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then !Substituting the advective flux into the inviscid geometrical source flux @@ -2470,10 +2470,10 @@ contains do i = intxb, intxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, momxb - 1 + dir_idx(1)) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, momxb - 1 + dir_idx(1)) - p_Star - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -2567,7 +2567,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! variables are placeholders to call the subroutine. + ! are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2604,17 +2604,17 @@ contains (rho_avg*c_avg)) end if - ! follows Einfeldt et al. - ! s_M/P = min/max(0.,s_L/R) + ! Einfeldt et al. + ! = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! goes with q_star_L/R = xi_L/R * (variable) - ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! with q_star_L/R = xi_L/R * (variable) + ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! goes with numerical velocity in x/y/z directions - ! xi_P/M = 0.5 +/m sgn(0.5,s_star) + ! with numerical velocity in x/y/z directions + ! = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) @@ -2627,8 +2627,8 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! Momentum flux. - ! f = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! flux. + ! = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -2647,7 +2647,7 @@ contains end do if (bubbles_euler) then - ! Put p_tilde in + ! p_tilde in $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -2668,7 +2668,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! Source for volume fraction advection equation + ! for volume fraction advection equation $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2678,7 +2678,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! Add advection flux for bubble variables + ! advection flux for bubble variables if (bubbles_euler) then $:GPU_LOOP(parallelism='[seq]') do i = bubxb, bubxe @@ -2690,16 +2690,16 @@ contains end do end if - ! Geometrical source flux for cylindrical coordinates + ! source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then - ! Substituting the advective flux into the inviscid geometrical source flux + ! the advective flux into the inviscid geometrical source flux $:GPU_LOOP(parallelism='[seq]') do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -2711,7 +2711,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -2771,7 +2771,7 @@ contains vel_R_rms = vel_R_rms + vel_R(i)**2._wp end do - ! Retain this in the refactor + ! this in the refactor if (mpp_lim .and. (num_fluids > 2)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -2938,7 +2938,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! variables are placeholders to call the subroutine. + ! are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2949,7 +2949,7 @@ contains end do end if - ! Low Mach correction + ! Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if @@ -2986,21 +2986,21 @@ contains (rho_avg*c_avg)) end if - ! follows Einfeldt et al. - ! s_M/P = min/max(0.,s_L/R) + ! Einfeldt et al. + ! = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! goes with q_star_L/R = xi_L/R * (variable) - ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! with q_star_L/R = xi_L/R * (variable) + ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! goes with numerical velocity in x/y/z directions - ! xi_P/M = 0.5 +/m sgn(0.5,s_star) + ! with numerical velocity in x/y/z directions + ! = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) - ! Low Mach correction + ! Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else @@ -3017,14 +3017,14 @@ contains end do if (bubbles_euler .and. (num_fluids > 1)) then - ! Kill mass transport @ gas density + ! mass transport @ gas density flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if - ! Momentum flux. - ! f = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! flux. + ! = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) - ! Include p_tilde + ! p_tilde if (avg_state == 2) then if (alpha_L(num_fluids) < small_alf .or. R3Lbar < small_alf) then @@ -3060,8 +3060,8 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! Energy flux. - ! f = u*(E+p), q = E, q_star = \xi*E+(s-u)(\rho s_star + p/(s-u)) + ! flux. + ! = u*(E+p), q = E, q_star = \xi*E+(s-u)(\rho s_star + p/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = & xi_M*(vel_L(dir_idx(1))*(E_L + pres_L) + & s_M*(xi_L*(E_L + (s_S - vel_L(dir_idx(1)))* & @@ -3073,7 +3073,7 @@ contains (s_R - vel_R(dir_idx(1))))) - E_R)) & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! Volume fraction flux + ! fraction flux $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3083,7 +3083,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! Source for volume fraction advection equation + ! for volume fraction advection equation $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -3099,7 +3099,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! Add advection flux for bubble variables + ! advection flux for bubble variables $:GPU_LOOP(parallelism='[seq]') do i = bubxb, bubxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3125,15 +3125,15 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end if - ! Geometrical source flux for cylindrical coordinates + ! source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then - ! Substituting the advective flux into the inviscid geometrical source flux + ! the advective flux into the inviscid geometrical source flux $:GPU_LOOP(parallelism='[seq]') do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -3145,7 +3145,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -3179,7 +3179,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() else - ! 5-EQUATION MODEL WITH HLLC + ! MODEL WITH HLLC $:GPU_PARALLEL_LOOP(collapse=3, private='[Re_max, i, q, T_L, T_R, vel_L_rms, vel_R_rms, pres_L, pres_R, rho_L, gamma_L, pi_inf_L, qv_L, rho_R, gamma_R, pi_inf_R, qv_R, alpha_L_sum, alpha_R_sum, E_L, E_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, Gamm_L, Gamm_R, Y_L, Y_R, H_L, H_R, qv_avg, rho_avg, gamma_avg, H_avg, c_L, c_R, c_avg, s_P, s_M, xi_P, xi_M, xi_L, xi_R, Ms_L, Ms_R, pres_SL, pres_SR, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, s_L, s_R, s_S, vel_avg_rms, pcorr, zcoef, vel_L_tmp, vel_R_tmp, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, tau_e_L, tau_e_R, xi_field_L, xi_field_R, Yi_avg,Phi_avg, h_iL, h_iR, h_avg_2, G_L, G_R]', copyin='[is1, is2, is3]') do l = is3%beg, is3%end do k = is2%beg, is2%end @@ -3209,8 +3209,8 @@ contains pres_L = qL_prim_rs${XYZ}$_vf(j, k, l, E_idx) pres_R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, E_idx) - ! Change this by splitting it into the cases - ! present in the bubbles_euler + ! this by splitting it into the cases + ! in the bubbles_euler if (mpp_lim) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -3326,7 +3326,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! ENERGY ADJUSTMENTS FOR HYPOELASTIC ENERGY + ! ADJUSTMENTS FOR HYPOELASTIC ENERGY if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -3342,11 +3342,11 @@ contains end do $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough if ((G_L > verysmall) .and. (G_R > verysmall)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! Additional terms in 2D and 3D + ! terms in 2D and 3D if ((i == 2) .or. (i == 4) .or. (i == 5)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -3355,7 +3355,7 @@ contains end do end if - ! ENERGY ADJUSTMENTS FOR HYPERELASTIC ENERGY + ! ADJUSTMENTS FOR HYPERELASTIC ENERGY if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -3366,11 +3366,11 @@ contains G_R = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! Mixture left and right shear modulus + ! left and right shear modulus G_L = G_L + alpha_L(i)*Gs_rs(i) G_R = G_R + alpha_R(i)*Gs_rs(i) end do - ! Elastic contribution to energy if G large enough + ! contribution to energy if G large enough if (G_L > verysmall .and. G_R > verysmall) then E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) @@ -3394,7 +3394,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! variables are placeholders to call the subroutine. + ! are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, c_sum_Yi_Phi, c_avg, qv_avg) @@ -3408,7 +3408,7 @@ contains end do end if - ! Low Mach correction + ! Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if @@ -3455,29 +3455,29 @@ contains (rho_avg*c_avg)) end if - ! follows Einfeldt et al. - ! s_M/P = min/max(0.,s_L/R) + ! Einfeldt et al. + ! = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! goes with q_star_L/R = xi_L/R * (variable) - ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! with q_star_L/R = xi_L/R * (variable) + ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! goes with numerical velocity in x/y/z directions - ! xi_P/M = 0.5 +/m sgn(0.5,s_star) + ! with numerical velocity in x/y/z directions + ! = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) - ! Low Mach correction + ! Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! COMPUTING THE HLLC FLUXES - ! MASS FLUX. + ! THE HLLC FLUXES + ! FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3487,8 +3487,8 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! MOMENTUM FLUX. - ! f = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! FLUX. + ! = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -3507,8 +3507,8 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! ENERGY FLUX. - ! f = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) + ! FLUX. + ! = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = & xi_M*(vel_L(dir_idx(1))*(E_L + pres_L) + & s_M*(xi_L*(E_L + (s_S - vel_L(dir_idx(1)))* & @@ -3520,16 +3520,16 @@ contains (s_R - vel_R(dir_idx(1))))) - E_R)) & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! ELASTICITY. Elastic shear stress additions for the momentum and energy flux + ! Elastic shear stress additions for the momentum and energy flux if (elasticity) then flux_ene_e = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims - ! MOMENTUM ELASTIC FLUX. + ! ELASTIC FLUX. flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) & - xi_M*tau_e_L(dir_idx_tau(i)) - xi_P*tau_e_R(dir_idx_tau(i)) - ! ENERGY ELASTIC FLUX. + ! ELASTIC FLUX. flux_ene_e = flux_ene_e - & xi_M*(vel_L(dir_idx(i))*tau_e_L(dir_idx_tau(i)) + & s_M*(xi_L*((s_S - vel_L(i))*(tau_e_L(dir_idx_tau(i))/(s_L - vel_L(i)))))) - & @@ -3539,7 +3539,7 @@ contains flux_rs${XYZ}$_vf(j, k, l, E_idx) = flux_rs${XYZ}$_vf(j, k, l, E_idx) + flux_ene_e end if - ! HYPOELASTIC STRESS EVOLUTION FLUX. + ! STRESS EVOLUTION FLUX. if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -3549,7 +3549,7 @@ contains end do end if - ! VOLUME FRACTION FLUX. + ! FRACTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3559,7 +3559,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! VOLUME FRACTION SOURCE FLUX. + ! FRACTION SOURCE FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -3571,7 +3571,7 @@ contains s_P*(xi_R - 1._wp)) end do - ! COLOR FUNCTION FLUX + ! FUNCTION FLUX if (surface_tension) then flux_rs${XYZ}$_vf(j, k, l, c_idx) = & xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, c_idx) & @@ -3580,7 +3580,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end if - ! REFERENCE MAP FLUX. + ! MAP FLUX. if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -3606,7 +3606,7 @@ contains end do end if - ! Geometrical source flux for cylindrical coordinates + ! source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then !Substituting the advective flux into the inviscid geometrical source flux @@ -3614,7 +3614,7 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! Recalculating the radial momentum geometric source flux + ! the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -3626,7 +3626,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! Geometrical source of the void fraction(s) is zero + ! source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -3663,7 +3663,7 @@ contains end if end if #:endfor - ! Computing HLLC flux and source flux for Euler system of equations + ! HLLC flux and source flux for Euler system of equations if (viscous .or. dummy) then if (weno_Re_flux) then @@ -3707,7 +3707,7 @@ contains end subroutine s_hllc_riemann_solver !> HLLD Riemann solver resolves 5 of the 7 waves of MHD equations: - !! 1 entropy wave, 2 Alfvén waves, 2 fast magnetosonic waves. + !! wave, 2 Alfvén waves, 2 fast magnetosonic waves. subroutine s_hlld_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, & dqL_prim_dx_vf, dqL_prim_dy_vf, dqL_prim_dz_vf, & qL_prim_vf, & @@ -3733,7 +3733,7 @@ contains integer, intent(in) :: norm_dir type(int_bounds_info), intent(in) :: ix, iy, iz - ! Local variables: + ! variables: #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: alpha_L, alpha_R, alpha_rho_L, alpha_rho_R #:else @@ -3747,16 +3747,16 @@ contains type(riemann_states_vec3) :: B type(riemann_states) :: c, c_fast, pres_mag - ! HLLD speeds and intermediate state variables: + ! speeds and intermediate state variables: real(wp) :: s_L, s_R, s_M, s_starL, s_starR real(wp) :: pTot_L, pTot_R, p_star, rhoL_star, rhoR_star, E_starL, E_starR real(wp), dimension(7) :: U_L, U_R, U_starL, U_starR, U_doubleL, U_doubleR real(wp), dimension(7) :: F_L, F_R, F_starL, F_starR, F_hlld - ! Indices for U and F: (rho, rho*vel(1), rho*vel(2), rho*vel(3), By, Bz, E) - ! Note: vel and B are permutated, so vel(1) is the normal velocity, and x is the normal direction - ! Note: Bx is omitted as the magnetic flux is always zero in the normal direction + ! for U and F: (rho, rho*vel(1), rho*vel(2), rho*vel(3), By, Bz, E) + ! vel and B are permutated, so vel(1) is the normal velocity, and x is the normal direction + ! Bx is omitted as the magnetic flux is always zero in the normal direction real(wp) :: sqrt_rhoL_star, sqrt_rhoR_star, denom_ds, sign_Bx real(wp) :: vL_star, vR_star, wL_star, wR_star @@ -3781,13 +3781,13 @@ contains do k = is2%beg, is2%end do j = is1%beg, is1%end - ! (1) Extract the left/right primitive states + ! Extract the left/right primitive states do i = 1, contxe alpha_rho_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, i) alpha_rho_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, i) end do - ! NOTE: unlike HLL & HLLC, vel_L here is permutated by dir_idx for simpler logic + ! unlike HLL & HLLC, vel_L here is permutated by dir_idx for simpler logic do i = 1, num_vels vel%L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) vel%R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, contxe + dir_idx(i)) @@ -3804,7 +3804,7 @@ contains pres%L = qL_prim_rs${XYZ}$_vf(j, k, l, E_idx) pres%R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, E_idx) - ! NOTE: unlike HLL, Bx, By, Bz are permutated by dir_idx for simpler logic + ! unlike HLL, Bx, By, Bz are permutated by dir_idx for simpler logic if (mhd) then if (n == 0) then ! 1D: constant Bx; By, Bz as variables; only in x so not permutated B%L = [Bx0, qL_prim_rs${XYZ}$_vf(j, k, l, B_idx%beg), qL_prim_rs${XYZ}$_vf(j, k, l, B_idx%beg + 1)] @@ -3819,7 +3819,7 @@ contains end if end if - ! Sum properties of all fluid components + ! properties of all fluid components rho%L = 0._wp; gamma%L = 0._wp; pi_inf%L = 0._wp; qv%L = 0._wp rho%R = 0._wp; gamma%R = 0._wp; pi_inf%R = 0._wp; qv%R = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -3842,13 +3842,13 @@ contains H_no_mag%L = (E%L + pres%L - pres_mag%L)/rho%L H_no_mag%R = (E%R + pres%R - pres_mag%R)/rho%R ! stagnation enthalpy here excludes magnetic energy (only used to find speed of sound) - ! (2) Compute fast wave speeds + ! Compute fast wave speeds call s_compute_speed_of_sound(pres%L, rho%L, gamma%L, pi_inf%L, H_no_mag%L, alpha_L, vel_rms%L, 0._wp, c%L, qv%L) call s_compute_speed_of_sound(pres%R, rho%R, gamma%R, pi_inf%R, H_no_mag%R, alpha_R, vel_rms%R, 0._wp, c%R, qv%R) call s_compute_fast_magnetosonic_speed(rho%L, c%L, B%L, norm_dir, c_fast%L, H_no_mag%L) call s_compute_fast_magnetosonic_speed(rho%R, c%R, B%R, norm_dir, c_fast%R, H_no_mag%R) - ! (3) Compute contact speed s_M [Miyoshi Equ. (38)] + ! Compute contact speed s_M [Miyoshi Equ. (38)] s_L = min(vel%L(1) - c_fast%L, vel%R(1) - c_fast%R) s_R = max(vel%R(1) + c_fast%R, vel%L(1) + c_fast%L) @@ -3859,20 +3859,20 @@ contains (s_L - vel%L(1))*rho%L*vel%L(1) - pTot_R + pTot_L)/ & ((s_R - vel%R(1))*rho%R - (s_L - vel%L(1))*rho%L)) - ! (4) Compute star state variables + ! Compute star state variables rhoL_star = rho%L*(s_L - vel%L(1))/(s_L - s_M) rhoR_star = rho%R*(s_R - vel%R(1))/(s_R - s_M) p_star = pTot_L + rho%L*(s_L - vel%L(1))*(s_M - vel%L(1))/(s_L - s_M) E_starL = ((s_L - vel%L(1))*E%L - pTot_L*vel%L(1) + p_star*s_M)/(s_L - s_M) E_starR = ((s_R - vel%R(1))*E%R - pTot_R*vel%R(1) + p_star*s_M)/(s_R - s_M) - ! (5) Compute left/right state vectors and fluxes + ! Compute left/right state vectors and fluxes U_L = [rho%L, rho%L*vel%L(1:3), B%L(2:3), E%L] U_starL = [rhoL_star, rhoL_star*s_M, rhoL_star*vel%L(2:3), B%L(2:3), E_starL] U_R = [rho%R, rho%R*vel%R(1:3), B%R(2:3), E%R] U_starR = [rhoR_star, rhoR_star*s_M, rhoR_star*vel%R(2:3), B%R(2:3), E_starR] - ! Compute the left/right fluxes + ! the left/right fluxes F_L(1) = U_L(2) F_L(2) = U_L(2)*vel%L(1) - B%L(1)*B%L(1) + pTot_L F_L(3:4) = U_L(2)*vel%L(2:3) - B%L(1)*B%L(2:3) @@ -3884,18 +3884,18 @@ contains F_R(3:4) = U_R(2)*vel%R(2:3) - B%R(1)*B%R(2:3) F_R(5:6) = vel%R(1)*B%R(2:3) - vel%R(2:3)*B%R(1) F_R(7) = (E%R + pTot_R)*vel%R(1) - B%R(1)*(vel%R(1)*B%R(1) + vel%R(2)*B%R(2) + vel%R(3)*B%R(3)) - ! Compute the star flux using HLL relation + ! the star flux using HLL relation F_starL = F_L + s_L*(U_starL - U_L) F_starR = F_R + s_R*(U_starR - U_R) - ! Compute the rotational (Alfvén) speeds + ! the rotational (Alfvén) speeds s_starL = s_M - abs(B%L(1))/sqrt(rhoL_star) s_starR = s_M + abs(B%L(1))/sqrt(rhoR_star) - ! Compute the double–star states [Miyoshi Eqns. (59)-(62)] + ! the double–star states [Miyoshi Eqns. (59)-(62)] sqrt_rhoL_star = sqrt(rhoL_star); sqrt_rhoR_star = sqrt(rhoR_star) vL_star = vel%L(2); wL_star = vel%L(3) vR_star = vel%R(2); wR_star = vel%R(3) - ! (6) Compute the double–star states [Miyoshi Eqns. (59)-(62)] + ! Compute the double–star states [Miyoshi Eqns. (59)-(62)] denom_ds = sqrt_rhoL_star + sqrt_rhoR_star sign_Bx = sign(1._wp, B%L(1)) v_double = (sqrt_rhoL_star*vL_star + sqrt_rhoR_star*vR_star + (B%R(2) - B%L(2))*sign_Bx)/denom_ds @@ -3910,7 +3910,7 @@ contains U_doubleL = [rhoL_star, rhoL_star*s_M, rhoL_star*v_double, rhoL_star*w_double, By_double, Bz_double, E_double] U_doubleR = [rhoR_star, rhoR_star*s_M, rhoR_star*v_double, rhoR_star*w_double, By_double, Bz_double, E_double] - ! (11) Choose HLLD flux based on wave-speed regions + ! Choose HLLD flux based on wave-speed regions if (0.0_wp <= s_L) then F_hlld = F_L else if (0.0_wp <= s_starL) then @@ -3925,14 +3925,14 @@ contains F_hlld = F_R end if - ! (12) Reorder and write temporary variables to the flux array - ! Mass + ! Reorder and write temporary variables to the flux array + ! flux_rs${XYZ}$_vf(j, k, l, 1) = F_hlld(1) ! TODO multi-component - ! Momentum + ! flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = F_hlld(2) flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(2)) = F_hlld(3) flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(3)) = F_hlld(4) - ! Magnetic field + ! field if (n == 0) then flux_rs${XYZ}$_vf(j, k, l, B_idx%beg) = F_hlld(5) flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + 1) = F_hlld(6) @@ -3940,9 +3940,9 @@ contains flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + dir_idx(2) - 1) = F_hlld(5) flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + dir_idx(3) - 1) = F_hlld(6) end if - ! Energy + ! flux_rs${XYZ}$_vf(j, k, l, E_idx) = F_hlld(7) - ! Partial fraction + ! fraction $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = 0._wp ! TODO multi-component (zero for now) @@ -3961,13 +3961,13 @@ contains end subroutine s_hlld_riemann_solver !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_riemann_solvers_module - ! Allocating the variables that will be utilized to formulate the - ! left, right, and average states of the Riemann problem, as well - ! the Riemann problem solution + ! the variables that will be utilized to formulate the + ! right, and average states of the Riemann problem, as well + ! Riemann problem solution integer :: i, j @:ALLOCATE(Gs_rs(1:num_fluids)) @@ -4076,30 +4076,30 @@ contains end subroutine s_initialize_riemann_solvers_module !> The purpose of this subroutine is to populate the buffers - !! of the left and right Riemann states variables, depending - !! on the boundary conditions. - !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the - !! first-order x-dir spatial derivatives - !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the - !! first-order y-dir spatial derivatives - !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the - !! first-order z-dir spatial derivatives - !! @param gm_alphaL_vf Left averaged gradient magnitude - !! @param gm_alphaR_vf Right averaged gradient magnitude - !! @param norm_dir Dir. splitting direction - !! @param ix Index bounds in the x-dir - !! @param iy Index bounds in the y-dir - !! @param iz Index bounds in the z-dir + !! left and right Riemann states variables, depending + !! boundary conditions. + !! The left WENO-reconstructed cell-boundary values of the + !! variables + !! The right WENO-reconstructed cell-boundary values of the + !! variables + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The left WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! The right WENO-reconstructed cell-boundary values of the + !! spatial derivatives + !! Left averaged gradient magnitude + !! Right averaged gradient magnitude + !! Dir. splitting direction + !! Index bounds in the x-dir + !! Index bounds in the y-dir + !! Index bounds in the z-dir subroutine s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -4146,12 +4146,12 @@ contains end if isx = ix; isy = iy; isz = iz - ! for stuff in the same module + ! stuff in the same module $:GPU_UPDATE(device='[isx,isy,isz]') - ! for stuff in different modules + ! stuff in different modules $:GPU_UPDATE(device='[dir_idx,dir_flg,dir_idx_tau]') - ! Population of Buffers in x-direction + ! of Buffers in x-direction if (norm_dir == 1) then if (bc_x%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4271,9 +4271,9 @@ contains end if end if - ! END: Population of Buffers in x-direction + ! Population of Buffers in x-direction - ! Population of Buffers in y-direction + ! of Buffers in y-direction elseif (norm_dir == 2) then if (bc_y%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4382,9 +4382,9 @@ contains end if end if - ! END: Population of Buffers in y-direction + ! Population of Buffers in y-direction - ! Population of Buffers in z-direction + ! of Buffers in z-direction else if (bc_z%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4485,26 +4485,26 @@ contains end if end if - ! END: Population of Buffers in z-direction + ! Population of Buffers in z-direction end subroutine s_populate_riemann_states_variables_buffers !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures needed to configure the chosen Riemann - !! solver algorithm. - !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the - !! cell-average primitive variables - !! @param flux_vf Intra-cell fluxes - !! @param flux_src_vf Intra-cell fluxes sources - !! @param flux_gsrc_vf Intra-cell geometric fluxes sources - !! @param norm_dir Dir. splitting direction - !! @param ix Index bounds in the x-dir - !! @param iy Index bounds in the y-dir - !! @param iz Index bounds in the z-dir - !! @param q_prim_vf Cell-averaged primitive variables + !! of pointers and/or the execution of any + !! needed to configure the chosen Riemann + !! + !! The left WENO-reconstructed cell-boundary values of the + !! variables + !! The right WENO-reconstructed cell-boundary values of the + !! variables + !! Intra-cell fluxes + !! Intra-cell fluxes sources + !! Intra-cell geometric fluxes sources + !! Dir. splitting direction + !! Index bounds in the x-dir + !! Index bounds in the y-dir + !! Index bounds in the z-dir + !! Cell-averaged primitive variables subroutine s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -4517,7 +4517,7 @@ contains integer :: i, j, k, l ! Generic loop iterators - ! Reshaping Inputted Data in x-direction + ! Inputted Data in x-direction if (norm_dir == 1) then @@ -4566,7 +4566,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Inputted Data in y-direction + ! Inputted Data in y-direction elseif (norm_dir == 2) then if (viscous .or. (surface_tension) .or. dummy) then @@ -4613,7 +4613,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Inputted Data in z-direction + ! Inputted Data in z-direction else if (viscous .or. (surface_tension) .or. dummy) then @@ -4665,22 +4665,22 @@ contains end subroutine s_initialize_riemann_solver !> @brief Computes cylindrical viscous source flux contributions for momentum and energy. - !! Calculates Cartesian components of the stress tensor using averaged velocity derivatives - !! and cylindrical geometric factors, then updates `flux_src_vf`. - !! Assumes x-dir is axial (z_cyl), y-dir is radial (r_cyl), z-dir is azimuthal (theta_cyl for derivatives). - !! @param[in] velL_vf Left boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). - !! @param[in] dvelL_dx_vf Left boundary $\partial v_i/\partial x$ (num_dims scalar_field). - !! @param[in] dvelL_dy_vf Left boundary $\partial v_i/\partial y$ (num_dims scalar_field). - !! @param[in] dvelL_dz_vf Left boundary $\partial v_i/\partial z$ (num_dims scalar_field). - !! @param[in] velR_vf Right boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). - !! @param[in] dvelR_dx_vf Right boundary $\partial v_i/\partial x$ (num_dims scalar_field). - !! @param[in] dvelR_dy_vf Right boundary $\partial v_i/\partial y$ (num_dims scalar_field). - !! @param[in] dvelR_dz_vf Right boundary $\partial v_i/\partial z$ (num_dims scalar_field). - !! @param[inout] flux_src_vf Intercell source flux array to update (sys_size scalar_field). - !! @param[in] norm_dir Interface normal direction (1=x-face, 2=y-face, 3=z-face). - !! @param[in] ix Global X-direction loop bounds (int_bounds_info). - !! @param[in] iy Global Y-direction loop bounds (int_bounds_info). - !! @param[in] iz Global Z-direction loop bounds (int_bounds_info). + !! components of the stress tensor using averaged velocity derivatives + !! geometric factors, then updates `flux_src_vf`. + !! is axial (z_cyl), y-dir is radial (r_cyl), z-dir is azimuthal (theta_cyl for derivatives). + !! Left boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). + !! Left boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). + !! Left boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). + !! Left boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). + !! Right boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). + !! Right boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). + !! Right boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). + !! Right boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). + !! Intercell source flux array to update (sys_size scalar_field). + !! Interface normal direction (1=x-face, 2=y-face, 3=z-face). + !! Global X-direction loop bounds (int_bounds_info). + !! Global Y-direction loop bounds (int_bounds_info). + !! Global Z-direction loop bounds (int_bounds_info). subroutine s_compute_cylindrical_viscous_source_flux(velL_vf, & dvelL_dx_vf, dvelL_dy_vf, dvelL_dz_vf, & velR_vf, & @@ -4695,28 +4695,28 @@ contains integer, intent(in) :: norm_dir type(int_bounds_info), intent(in) :: ix, iy, iz - ! Local variables + ! variables #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: avg_v_int !!< Averaged interface velocity $(v_x, v_y, v_z)$ (grid directions). - real(wp), dimension(3) :: avg_dvdx_int !!< Averaged interface $\partial v_i/\partial x$ (grid dir 1). - real(wp), dimension(3) :: avg_dvdy_int !!< Averaged interface $\partial v_i/\partial y$ (grid dir 2). - real(wp), dimension(3) :: avg_dvdz_int !!< Averaged interface $\partial v_i/\partial z$ (grid dir 3). + real(wp), dimension(3) :: avg_dvdx_int !!< Averaged interface \f$\partial v_i/\partial x\f$ (grid dir 1). + real(wp), dimension(3) :: avg_dvdy_int !!< Averaged interface \f$\partial v_i/\partial y\f$ (grid dir 2). + real(wp), dimension(3) :: avg_dvdz_int !!< Averaged interface \f$\partial v_i/\partial z\f$ (grid dir 3). real(wp), dimension(3) :: vel_src_int !!< Interface velocity $(v_1,v_2,v_3)$ (grid directions) for viscous work. - real(wp), dimension(3) :: stress_vector_shear !!< Shear stress vector $(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})$ on N-face (grid directions). + real(wp), dimension(3) :: stress_vector_shear !!< Shear stress vector \f$(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})\f$ on N-face (grid directions). #:else real(wp), dimension(num_dims) :: avg_v_int !!< Averaged interface velocity $(v_x, v_y, v_z)$ (grid directions). - real(wp), dimension(num_dims) :: avg_dvdx_int !!< Averaged interface $\partial v_i/\partial x$ (grid dir 1). - real(wp), dimension(num_dims) :: avg_dvdy_int !!< Averaged interface $\partial v_i/\partial y$ (grid dir 2). - real(wp), dimension(num_dims) :: avg_dvdz_int !!< Averaged interface $\partial v_i/\partial z$ (grid dir 3). + real(wp), dimension(num_dims) :: avg_dvdx_int !!< Averaged interface \f$\partial v_i/\partial x\f$ (grid dir 1). + real(wp), dimension(num_dims) :: avg_dvdy_int !!< Averaged interface \f$\partial v_i/\partial y\f$ (grid dir 2). + real(wp), dimension(num_dims) :: avg_dvdz_int !!< Averaged interface \f$\partial v_i/\partial z\f$ (grid dir 3). real(wp), dimension(num_dims) :: vel_src_int !!< Interface velocity $(v_1,v_2,v_3)$ (grid directions) for viscous work. - real(wp), dimension(num_dims) :: stress_vector_shear !!< Shear stress vector $(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})$ on N-face (grid directions). + real(wp), dimension(num_dims) :: stress_vector_shear !!< Shear stress vector \f$(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})\f$ on N-face (grid directions). #:endif - real(wp) :: stress_normal_bulk !!< Normal bulk stress component $\sigma_{NN}$ on N-face. + real(wp) :: stress_normal_bulk !!< Normal bulk stress component \f$\sigma_{NN}\f$ on N-face. real(wp) :: Re_s, Re_b !!< Effective interface shear and bulk Reynolds numbers. real(wp) :: r_eff !!< Effective radius at interface for cylindrical terms. - real(wp) :: div_v_term_const !!< Common term $-(2/3)(\nabla \cdot \mathbf{v}) / \text{Re}_s$ for shear stress diagonal. - real(wp) :: divergence_cyl !!< Full divergence $\nabla \cdot \mathbf{v}$ in cylindrical coordinates. + real(wp) :: div_v_term_const !!< Common term \f$-(2/3)(\nabla \cdot \mathbf{v}) / \text{Re}_s\f$ for shear stress diagonal. + real(wp) :: divergence_cyl !!< Full divergence \f$\nabla \cdot \mathbf{v}\f$ in cylindrical coordinates. integer :: j, k, l !!< Loop iterators for $x, y, z$ grid directions. integer :: i_vel !!< Loop iterator for velocity components. @@ -4727,12 +4727,12 @@ contains do k = iy%beg, iy%end do j = ix%beg, ix%end - ! Determine indices for the 'right' state for averaging across the interface + ! indices for the 'right' state for averaging across the interface idx_rp = [j, k, l] idx_rp(norm_dir) = idx_rp(norm_dir) + 1 - ! Average velocities and their derivatives at the interface - ! For cylindrical: x-dir ~ axial (z_cyl), y-dir ~ radial (r_cyl), z-dir ~ azimuthal (theta_cyl) + ! velocities and their derivatives at the interface + ! cylindrical: x-dir ~ axial (z_cyl), y-dir ~ radial (r_cyl), z-dir ~ azimuthal (theta_cyl) $:GPU_LOOP(parallelism='[seq]') do i_vel = 1, num_dims avg_v_int(i_vel) = 0.5_wp*(velL_vf(i_vel)%sf(j, k, l) + velR_vf(i_vel)%sf(idx_rp(1), idx_rp(2), idx_rp(3))) @@ -4753,7 +4753,7 @@ contains end if end do - ! Get Re numbers and interface velocity for viscous work + ! Re numbers and interface velocity for viscous work select case (norm_dir) case (1) ! x-face (axial face in z_cyl direction) Re_s = Re_avg_rsx_vf(j, k, l, 1) @@ -4772,7 +4772,7 @@ contains r_eff = y_cc(k) end select - ! Divergence in cylindrical coordinates (vx=vz_cyl, vy=vr_cyl, vz=vtheta_cyl) + ! in cylindrical coordinates (vx=vz_cyl, vy=vr_cyl, vz=vtheta_cyl) #:if not MFC_CASE_OPTIMIZATION or num_dims > 1 divergence_cyl = avg_dvdx_int(1) + avg_dvdy_int(2) + avg_v_int(2)/r_eff if (num_dims > 2) then @@ -4847,21 +4847,21 @@ contains end subroutine s_compute_cylindrical_viscous_source_flux !> @brief Computes Cartesian viscous source flux contributions for momentum and energy. - !! Calculates averaged velocity gradients, gets Re and interface velocities, - !! calls helpers for shear/bulk stress, then updates `flux_src_vf`. - !! @param[in] velL_vf Left boundary velocity (num_dims scalar_field). - !! @param[in] dvelL_dx_vf Left boundary d(vel)/dx (num_dims scalar_field). - !! @param[in] dvelL_dy_vf Left boundary d(vel)/dy (num_dims scalar_field). - !! @param[in] dvelL_dz_vf Left boundary d(vel)/dz (num_dims scalar_field). - !! @param[in] velR_vf Right boundary velocity (num_dims scalar_field). - !! @param[in] dvelR_dx_vf Right boundary d(vel)/dx (num_dims scalar_field). - !! @param[in] dvelR_dy_vf Right boundary d(vel)/dy (num_dims scalar_field). - !! @param[in] dvelR_dz_vf Right boundary d(vel)/dz (num_dims scalar_field). - !! @param[inout] flux_src_vf Intercell source flux array to update (sys_size scalar_field). - !! @param[in] norm_dir Interface normal direction (1=x, 2=y, 3=z). - !! @param[in] ix X-direction loop bounds (int_bounds_info). - !! @param[in] iy Y-direction loop bounds (int_bounds_info). - !! @param[in] iz Z-direction loop bounds (int_bounds_info). + !! velocity gradients, gets Re and interface velocities, + !! for shear/bulk stress, then updates `flux_src_vf`. + !! Left boundary velocity (num_dims scalar_field). + !! Left boundary d(vel)/dx (num_dims scalar_field). + !! Left boundary d(vel)/dy (num_dims scalar_field). + !! Left boundary d(vel)/dz (num_dims scalar_field). + !! Right boundary velocity (num_dims scalar_field). + !! Right boundary d(vel)/dx (num_dims scalar_field). + !! Right boundary d(vel)/dy (num_dims scalar_field). + !! Right boundary d(vel)/dz (num_dims scalar_field). + !! Intercell source flux array to update (sys_size scalar_field). + !! Interface normal direction (1=x, 2=y, 3=z). + !! X-direction loop bounds (int_bounds_info). + !! Y-direction loop bounds (int_bounds_info). + !! Z-direction loop bounds (int_bounds_info). subroutine s_compute_cartesian_viscous_source_flux(dvelL_dx_vf, & dvelL_dy_vf, & dvelL_dz_vf, & @@ -4871,14 +4871,14 @@ contains flux_src_vf, & norm_dir) - ! Arguments + ! type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dx_vf, dvelR_dx_vf type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dy_vf, dvelR_dy_vf type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dz_vf, dvelR_dz_vf type(scalar_field), dimension(sys_size), intent(inout) :: flux_src_vf integer, intent(in) :: norm_dir - ! Local variables + ! variables #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3, 3) :: vel_grad_avg !< Averaged velocity gradient tensor `d(vel_i)/d(coord_j)`. real(wp), dimension(3, 3) :: current_tau_shear !< Current shear stress tensor. @@ -4958,7 +4958,7 @@ contains end if if (shear_stress) then - ! current_tau_shear = 0.0_wp + ! = 0.0_wp call s_calculate_shear_stress_tensor(vel_grad_avg, Re_shear, divergence_v, current_tau_shear) do i_dim = 1, num_dims @@ -4972,7 +4972,7 @@ contains end if if (bulk_stress) then - ! current_tau_bulk = 0.0_wp + ! = 0.0_wp call s_calculate_bulk_stress_tensor(Re_bulk, divergence_v, current_tau_bulk) do i_dim = 1, num_dims @@ -4993,15 +4993,15 @@ contains end subroutine s_compute_cartesian_viscous_source_flux !> @brief Calculates shear stress tensor components. - !! tau_ij_shear = ( (dui/dxj + duj/dxi) - (2/3)*(div_v)*delta_ij ) / Re_shear - !! @param[in] vel_grad_avg Averaged velocity gradient tensor (d(vel_i)/d(coord_j)). - !! @param[in] Re_shear Shear Reynolds number. - !! @param[in] divergence_v Velocity divergence (du/dx + dv/dy + dw/dz). - !! @param[out] tau_shear_out Calculated shear stress tensor (stress on i-face, j-direction). + !! ( (dui/dxj + duj/dxi) - (2/3)*(div_v)*delta_ij ) / Re_shear + !! Averaged velocity gradient tensor (d(vel_i)/d(coord_j)). + !! Shear Reynolds number. + !! Velocity divergence (du/dx + dv/dy + dw/dz). + !! Calculated shear stress tensor (stress on i-face, j-direction). subroutine s_calculate_shear_stress_tensor(vel_grad_avg, Re_shear, divergence_v, tau_shear_out) $:GPU_ROUTINE(parallelism='[seq]') - ! Arguments + ! #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3, 3), intent(in) :: vel_grad_avg real(wp), dimension(3, 3), intent(out) :: tau_shear_out @@ -5012,7 +5012,7 @@ contains real(wp), intent(in) :: Re_shear real(wp), intent(in) :: divergence_v - ! Local variables + ! variables integer :: i_dim !< Loop iterator for face normal. integer :: j_dim !< Loop iterator for force component direction. @@ -5031,14 +5031,14 @@ contains end subroutine s_calculate_shear_stress_tensor !> @brief Calculates bulk stress tensor components (diagonal only). - !! tau_ii_bulk = (div_v) / Re_bulk. Off-diagonals are zero. - !! @param[in] Re_bulk Bulk Reynolds number. - !! @param[in] divergence_v Velocity divergence (du/dx + dv/dy + dw/dz). - !! @param[out] tau_bulk_out Calculated bulk stress tensor (stress on i-face, i-direction). + !! (div_v) / Re_bulk. Off-diagonals are zero. + !! Bulk Reynolds number. + !! Velocity divergence (du/dx + dv/dy + dw/dz). + !! Calculated bulk stress tensor (stress on i-face, i-direction). subroutine s_calculate_bulk_stress_tensor(Re_bulk, divergence_v, tau_bulk_out) $:GPU_ROUTINE(parallelism='[seq]') - ! Arguments + ! real(wp), intent(in) :: Re_bulk real(wp), intent(in) :: divergence_v #:if not MFC_CASE_OPTIMIZATION and USING_AMD @@ -5047,7 +5047,7 @@ contains real(wp), dimension(num_dims, num_dims), intent(out) :: tau_bulk_out #:endif - ! Local variables + ! variables integer :: i_dim !< Loop iterator for diagonal components. tau_bulk_out = 0.0_wp @@ -5059,11 +5059,11 @@ contains end subroutine s_calculate_bulk_stress_tensor !> Deallocation and/or disassociation procedures that are - !! needed to finalize the selected Riemann problem solver - !! @param flux_vf Intercell fluxes - !! @param flux_src_vf Intercell source fluxes - !! @param flux_gsrc_vf Intercell geometric source fluxes - !! @param norm_dir Dimensional splitting coordinate direction + !! finalize the selected Riemann problem solver + !! Intercell fluxes + !! Intercell source fluxes + !! Intercell geometric source fluxes + !! Dimensional splitting coordinate direction subroutine s_finalize_riemann_solver(flux_vf, flux_src_vf, & flux_gsrc_vf, & norm_dir) @@ -5076,7 +5076,7 @@ contains integer :: i, j, k, l !< Generic loop iterators - ! Reshaping Outputted Data in y-direction + ! Outputted Data in y-direction if (norm_dir == 2) then $:GPU_PARALLEL_LOOP(collapse=4) do i = 1, sys_size @@ -5132,7 +5132,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Outputted Data in z-direction + ! Outputted Data in z-direction elseif (norm_dir == 3) then $:GPU_PARALLEL_LOOP(collapse=4) do i = 1, sys_size diff --git a/src/simulation/m_sim_helpers.fpp b/src/simulation/m_sim_helpers.fpp index f5d75aa148..d77dcc6088 100644 --- a/src/simulation/m_sim_helpers.fpp +++ b/src/simulation/m_sim_helpers.fpp @@ -18,9 +18,9 @@ module m_sim_helpers contains !> Computes the modified dtheta for Fourier filtering in azimuthal direction - !! @param k y coordinate index - !! @param l z coordinate index - !! @return fltr_dtheta Modified dtheta value for cylindrical coordinates + !! y coordinate index + !! z coordinate index + !! Modified dtheta value for cylindrical coordinates function f_compute_filtered_dtheta(k, l) result(fltr_dtheta) $:GPU_ROUTINE(parallelism='[seq]') integer, intent(in) :: k, l @@ -42,12 +42,12 @@ contains end function f_compute_filtered_dtheta !> Computes inviscid CFL terms for multi-dimensional cases (2D/3D only) - !! @param vel directional velocities - !! @param c mixture speed of sound - !! @param j x coordinate index - !! @param k y coordinate index - !! @param l z coordinate index - !! @return cfl_terms computed CFL terms for 2D/3D cases + !! directional velocities + !! mixture speed of sound + !! x coordinate index + !! y coordinate index + !! z coordinate index + !! computed CFL terms for 2D/3D cases function f_compute_multidim_cfl_terms(vel, c, j, k, l) result(cfl_terms) $:GPU_ROUTINE(parallelism='[seq]') real(wp), dimension(num_vels), intent(in) :: vel @@ -79,19 +79,19 @@ contains end function f_compute_multidim_cfl_terms !> Computes enthalpy - !! @param q_prim_vf cell centered primitive variables - !! @param pres mixture pressure - !! @param rho mixture density - !! @param gamma mixture gamma - !! @param pi_inf mixture pi_inf - !! @param Re mixture reynolds number - !! @param H mixture enthalpy - !! @param alpha component alphas - !! @param vel directional velocities - !! @param vel_sum squard sum of velocity components - !! @param j x index - !! @param k y index - !! @param l z index + !! cell centered primitive variables + !! mixture pressure + !! mixture density + !! mixture gamma + !! mixture pi_inf + !! mixture reynolds number + !! mixture enthalpy + !! component alphas + !! directional velocities + !! squard sum of velocity components + !! x index + !! y index + !! z index subroutine s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, qv, j, k, l) $:GPU_ROUTINE(function_name='s_compute_enthalpy',parallelism='[seq]', & & cray_inline=True) @@ -152,7 +152,7 @@ contains E = gamma*pres + pi_inf + 5.e-1_wp*rho*vel_sum + qv end if - ! Adjust energy for hyperelasticity + ! energy for hyperelasticity if (hyperelasticity) then E = E + G_local*q_prim_vf(xiend + 1)%sf(j, k, l) end if @@ -162,15 +162,15 @@ contains end subroutine s_compute_enthalpy !> Computes stability criterion for a specified dt - !! @param vel directional velocities - !! @param c mixture speed of sound - !! @param Re_l mixture Reynolds number - !! @param j x index - !! @param k y index - !! @param l z index - !! @param icfl_sf cell-centered inviscid cfl number - !! @param vcfl_sf (optional) cell-centered viscous CFL number - !! @param Rc_sf (optional) cell centered Rc + !! directional velocities + !! mixture speed of sound + !! mixture Reynolds number + !! x index + !! y index + !! z index + !! cell-centered inviscid cfl number + !! (optional) cell-centered viscous CFL number + !! (optional) cell centered Rc subroutine s_compute_stability_from_dt(vel, c, rho, Re_l, j, k, l, icfl_sf, vcfl_sf, Rc_sf) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in), dimension(num_vels) :: vel @@ -182,16 +182,16 @@ contains real(wp) :: fltr_dtheta - ! Inviscid CFL calculation + ! CFL calculation if (p > 0 .or. n > 0) then - ! 2D/3D + ! icfl_sf(j, k, l) = dt/f_compute_multidim_cfl_terms(vel, c, j, k, l) else - ! 1D + ! icfl_sf(j, k, l) = (dt/dx(j))*(abs(vel(1)) + c) end if - ! Viscous calculations + ! calculations if (viscous) then if (p > 0) then #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 @@ -229,13 +229,13 @@ contains end subroutine s_compute_stability_from_dt !> Computes dt for a specified CFL number - !! @param vel directional velocities - !! @param max_dt cell centered maximum dt - !! @param rho cell centered density - !! @param Re_l cell centered Reynolds number - !! @param j x coordinate - !! @param k y coordinate - !! @param l z coordinate + !! directional velocities + !! cell centered maximum dt + !! cell centered density + !! cell centered Reynolds number + !! x coordinate + !! y coordinate + !! z coordinate subroutine s_compute_dt_from_cfl(vel, c, max_dt, rho, Re_l, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') real(wp), dimension(num_vels), intent(in) :: vel @@ -247,16 +247,16 @@ contains real(wp) :: icfl_dt, vcfl_dt real(wp) :: fltr_dtheta - ! Inviscid CFL calculation + ! CFL calculation if (p > 0 .or. n > 0) then - ! 2D/3D cases + ! cases icfl_dt = cfl_target*f_compute_multidim_cfl_terms(vel, c, j, k, l) else - ! 1D case + ! case icfl_dt = cfl_target*(dx(j)/(abs(vel(1)) + c)) end if - ! Viscous calculations + ! calculations if (viscous) then if (p > 0) then !3D diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index 9a0ecd9f79..db772642f5 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -1,22 +1,22 @@ !> -!! @file m_start_up.f90 -!! @brief Contains module m_start_up +!! +!! module m_start_up #:include 'case.fpp' #:include 'macros.fpp' !> @brief The purpose of the module is primarily to read in the files that -!! contain the inputs, the initial condition data and the grid data -!! that are provided by the user. The module is additionally tasked -!! with verifying the consistency of the user inputs and completing -!! the grid variablesThe purpose of the module is primarily to read -!! in the files that -!! contain the inputs, the initial condition data and the grid data -!! that are provided by the user. The module is additionally tasked -!! with verifying the consistency of the user inputs and completing -!! the grid variables. This module also also allocating, initializing -!! I/O, and deallocating the relevant variables on both cpus and gpus as well as -!! setting up the time stepping, domain decomposition and I/O procedures. +!! inputs, the initial condition data and the grid data +!! provided by the user. The module is additionally tasked +!! the consistency of the user inputs and completing +!! variablesThe purpose of the module is primarily to read +!! files that +!! inputs, the initial condition data and the grid data +!! provided by the user. The module is additionally tasked +!! the consistency of the user inputs and completing +!! variables. This module also also allocating, initializing +!! deallocating the relevant variables on both cpus and gpus as well as +!! the time stepping, domain decomposition and I/O procedures. module m_start_up use m_derived_types !< Definitions of the derived types @@ -30,10 +30,10 @@ module m_start_up use m_variables_conversion !< State variables type conversion procedures use m_weno !< Weighted and essentially non-oscillatory (WENO) - !! schemes for spatial reconstruction of variables + !! spatial reconstruction of variables use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! schemes for convservation laws + !! convservation laws use m_riemann_solvers !< Exact and approximate Riemann problem solvers @@ -54,7 +54,7 @@ module m_start_up use m_qbmm !< Quadrature MOM use m_derived_variables !< Procedures used to compute quantities derived - !! from the conservative and primitive variables + !! conservative and primitive variables use m_hypoelastic use m_hyperelastic @@ -113,7 +113,7 @@ module m_start_up contains !> Read data files. Dispatch subroutine that replaces procedure pointer. - !! @param q_cons_vf Conservative variables + !! Conservative variables impure subroutine s_read_data_files(q_cons_vf) type(scalar_field), & @@ -129,22 +129,22 @@ contains end subroutine s_read_data_files !> The purpose of this procedure is to first verify that an - !! input file has been made available by the user. Provided - !! that this is so, the input file is then read in. + !! has been made available by the user. Provided + !! is so, the input file is then read in. impure subroutine s_read_input_file - ! Relative path to the input file provided by the user + ! path to the input file provided by the user character(LEN=name_len), parameter :: file_path = './simulation.inp' logical :: file_exist !< - !! Logical used to check the existence of the input file + !! to check the existence of the input file integer :: iostatus - !! Integer to check iostat of file read + !! check iostat of file read character(len=1000) :: line - ! Namelist of the global parameters which may be specified by user + ! of the global parameters which may be specified by user namelist /user_inputs/ case_dir, run_time_info, m, n, p, dt, & t_step_start, t_step_stop, t_step_save, t_step_print, & model_eqns, mpp_lim, time_stepper, weno_eps, & @@ -188,8 +188,8 @@ contains int_comp, ic_eps, ic_beta, nv_uvm_out_of_core, & nv_uvm_igr_temps_on_gpu, nv_uvm_pref_gpu, down_sample, fft_wrt - ! Checking that an input file has been provided by the user. If it - ! has, then the input file is read in, otherwise, simulation exits. + ! that an input file has been provided by the user. If it + ! then the input file is read in, otherwise, simulation exits. inquire (FILE=trim(file_path), EXIST=file_exist) if (file_exist) then @@ -213,7 +213,7 @@ contains bodyForces = .true. end if - ! Store m,n,p into global m,n,p + ! m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -234,17 +234,17 @@ contains end subroutine s_read_input_file !> The goal of this procedure is to verify that each of the - !! user provided inputs is valid and that their combination - !! constitutes a meaningful configuration for the simulation. + !! inputs is valid and that their combination + !! meaningful configuration for the simulation. impure subroutine s_check_input_file - ! Relative path to the current directory file in the case directory + ! path to the current directory file in the case directory character(LEN=path_len) :: file_path - ! Logical used to check the existence of the current directory file + ! used to check the existence of the current directory file logical :: file_exist - ! Logistics + ! file_path = trim(case_dir)//'/.' call my_inquire(file_path, file_exist) @@ -258,29 +258,29 @@ contains end subroutine s_check_input_file - !! initial condition and grid data files. The cell-average - !! conservative variables constitute the former, while the - !! cell-boundary locations in x-, y- and z-directions make - !! up the latter. This procedure also calculates the cell- - !! width distributions from the cell-boundary locations. - !! @param q_cons_vf Cell-averaged conservative variables + !! and grid data files. The cell-average + !! constitute the former, while the + !! in x-, y- and z-directions make + !! latter. This procedure also calculates the cell- + !! from the cell-boundary locations. + !! Cell-averaged conservative variables impure subroutine s_read_serial_data_files(q_cons_vf) type(scalar_field), dimension(sys_size), intent(INOUT) :: q_cons_vf character(LEN=path_len + 2*name_len) :: t_step_dir !< - !! Relative path to the starting time-step directory + !! to the starting time-step directory character(LEN=path_len + 3*name_len) :: file_path !< - !! Relative path to the grid and conservative variables data files + !! to the grid and conservative variables data files logical :: file_exist !< - ! Logical used to check the existence of the data files + ! used to check the existence of the data files integer :: i, r !< Generic loop iterator - ! Confirming that the directory from which the initial condition and - ! the grid data files are to be read in exists and exiting otherwise + ! that the directory from which the initial condition and + ! grid data files are to be read in exists and exiting otherwise if (cfl_dt) then write (t_step_dir, '(A,I0,A,I0)') & trim(case_dir)//'/p_all/p', proc_rank, '/', n_start @@ -302,7 +302,7 @@ contains call s_assign_default_bc_type(bc_type) end if - ! Cell-boundary Locations in x-direction + ! Locations in x-direction file_path = trim(t_step_dir)//'/x_cb.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -328,7 +328,7 @@ contains end do end if - ! Cell-boundary Locations in y-direction + ! Locations in y-direction if (n > 0) then file_path = trim(t_step_dir)//'/y_cb.dat' @@ -350,7 +350,7 @@ contains end if - ! Cell-boundary Locations in z-direction + ! Locations in z-direction if (p > 0) then file_path = trim(t_step_dir)//'/z_cb.dat' @@ -388,7 +388,7 @@ contains end do if (bubbles_euler .or. elasticity) then - ! Read pb and mv for non-polytropic qbmm + ! pb and mv for non-polytropic qbmm if (qbmm .and. .not. polytropic) then do i = 1, nb do r = 1, nnode @@ -425,9 +425,9 @@ contains end if end if - ! Read IBM Data + ! IBM Data if (ib) then - ! Read IB markers + ! IB markers write (file_path, '(A,I0,A)') & trim(t_step_dir)//'/ib.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -441,7 +441,7 @@ contains call s_mpi_abort(trim(file_path)//' is missing. Exiting.') end if - ! Read Levelset + ! Levelset write (file_path, '(A)') & trim(t_step_dir)//'/levelset.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -451,12 +451,12 @@ contains ACTION='read', & STATUS='old') read (2) levelset%sf(0:m, 0:n, 0:p, 1:num_ibs); close (2) - ! print*, 'check', STL_levelset(106, 50, 0, 1) + ! 'check', STL_levelset(106, 50, 0, 1) else call s_mpi_abort(trim(file_path)//' is missing. Exiting.') end if - ! Read Levelset Norm + ! Levelset Norm write (file_path, '(A)') & trim(t_step_dir)//'/levelset_norm.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -507,7 +507,7 @@ contains end subroutine s_read_serial_data_files - !! @param q_cons_vf Conservative variables + !! Conservative variables impure subroutine s_read_parallel_data_files(q_cons_vf) type(scalar_field), & @@ -533,7 +533,7 @@ contains integer :: i, j - ! Downsampled data variables + ! data variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_read, n_glb_read, p_glb_read ! data size of read @@ -542,7 +542,7 @@ contains allocate (y_cb_glb(-1:n_glb)) allocate (z_cb_glb(-1:p_glb)) - ! Read in cell boundary locations in x-direction + ! in cell boundary locations in x-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -565,11 +565,11 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Assigning local cell boundary locations + ! local cell boundary locations x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m)) - ! Computing the cell width distribution + ! the cell width distribution dx(0:m) = x_cb(0:m) - x_cb(-1:m - 1) - ! Computing the cell center locations + ! the cell center locations x_cc(0:m) = x_cb(-1:m - 1) + dx(0:m)/2._wp if (ib) then @@ -582,7 +582,7 @@ contains end if if (n > 0) then - ! Read in cell boundary locations in y-direction + ! in cell boundary locations in y-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -595,15 +595,15 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Assigning local cell boundary locations + ! local cell boundary locations y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n)) - ! Computing the cell width distribution + ! the cell width distribution dy(0:n) = y_cb(0:n) - y_cb(-1:n - 1) - ! Computing the cell center locations + ! the cell center locations y_cc(0:n) = y_cb(-1:n - 1) + dy(0:n)/2._wp if (p > 0) then - ! Read in cell boundary locations in z-direction + ! in cell boundary locations in z-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -616,11 +616,11 @@ contains call s_mpi_abort('File '//trim(file_loc)//'is missing. Exiting.') end if - ! Assigning local cell boundary locations + ! local cell boundary locations z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p)) - ! Computing the cell width distribution + ! the cell width distribution dz(0:p) = z_cb(0:p) - z_cb(-1:p - 1) - ! Computing the cell center locations + ! the cell center locations z_cc(0:p) = z_cb(-1:p - 1) + dz(0:p)/2._wp end if @@ -640,7 +640,7 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! Initialize MPI data I/O + ! MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_vf) else @@ -653,20 +653,20 @@ contains end if if (down_sample) then - ! Size of local arrays + ! of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_read = m_glb_ds + 1 n_glb_read = n_glb_ds + 1 p_glb_read = p_glb_ds + 1 else - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_read = m_glb + 1 n_glb_read = n_glb + 1 p_glb_read = p_glb + 1 end if - ! Resize some integers so MPI can read even the biggest file + ! some integers so MPI can read even the biggest file m_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) n_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) p_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) @@ -675,7 +675,7 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! Read the data for each variable + ! the data for each variable if (bubbles_euler .or. elasticity) then do i = 1, sys_size!adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) @@ -715,7 +715,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) if (ib) then - ! Read IB Markers + ! IB Markers write (file_loc, '(A)') 'ib.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -735,7 +735,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Read Levelset + ! Levelset write (file_loc, '(A)') 'levelset.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -755,7 +755,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Read Levelset Norm + ! Levelset Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -781,7 +781,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if else - ! Open the file to read conservative variables + ! the file to read conservative variables if (cfl_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -793,7 +793,7 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! Initialize MPI data I/O + ! MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, & @@ -804,10 +804,10 @@ contains end if - ! Size of local arrays + ! of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! Resize some integers so MPI can read even the biggest file + ! some integers so MPI can read even the biggest file m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -816,11 +816,11 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! Read the data for each variable + ! the data for each variable if (bubbles_euler .or. elasticity) then do i = 1, sys_size !adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -832,7 +832,7 @@ contains if (qbmm .and. .not. polytropic) then do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -845,7 +845,7 @@ contains do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -861,7 +861,7 @@ contains if (ib) then - ! Read IB Markers + ! IB Markers write (file_loc, '(A)') 'ib.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -881,7 +881,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Read Levelset + ! Levelset write (file_loc, '(A)') 'levelset.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -901,7 +901,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Read Levelset Norm + ! Levelset Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -944,7 +944,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(1), & @@ -961,7 +961,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! Initial displacement to skip at beginning of file + ! displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(2), & @@ -997,10 +997,10 @@ contains end subroutine s_read_parallel_data_files !> The purpose of this procedure is to initialize the - !! values of the internal-energy equations of each phase - !! from the mass of each phase, the mixture momentum and - !! mixture-total-energy equations. - !! @param v_vf conservative variables + !! the internal-energy equations of each phase + !! mass of each phase, the mixture momentum and + !! + !! conservative variables subroutine s_initialize_internal_energy_equations(v_vf) type(scalar_field), dimension(sys_size), intent(inout) :: v_vf @@ -1124,14 +1124,14 @@ contains mytime = mytime + dt - ! Total-variation-diminishing (TVD) Runge-Kutta (RK) time-steppers + ! (TVD) Runge-Kutta (RK) time-steppers if (any(time_stepper == (/1, 2, 3/))) then call s_tvd_rk(t_step, time_avg, time_stepper) end if if (relax) call s_infinite_relaxation_k(q_cons_ts(1)%vf) - ! Time-stepping loop controls + ! loop controls t_step = t_step + 1 end subroutine s_perform_time_step @@ -1349,7 +1349,7 @@ contains end do end if - ! Reading in the user provided initial condition and grid data + ! in the user provided initial condition and grid data if (down_sample) then call s_read_data_files(q_cons_temp) call s_upsample_data(q_cons_ts(1)%vf, q_cons_temp) @@ -1364,7 +1364,7 @@ contains call s_read_data_files(q_cons_ts(1)%vf) end if - ! Populating the buffers of the grid variables using the boundary conditions + ! the buffers of the grid variables using the boundary conditions call s_populate_grid_variables_buffers() if (model_eqns == 3) call s_initialize_internal_energy_equations(q_cons_ts(1)%vf) @@ -1372,12 +1372,12 @@ contains if (bodyForces) call s_initialize_body_forces_module() if (acoustic_source) call s_precalculate_acoustic_spatial_sources() - ! Initialize the Temperature cache. + ! the Temperature cache. if (chemistry) call s_compute_q_T_sf(q_T_sf, q_cons_ts(1)%vf, idwint) - ! Computation of parameters, allocation of memory, association of pointers, - ! and/or execution of any other tasks that are needed to properly configure - ! the modules. The preparations below DO DEPEND on the grid being complete. + ! of parameters, allocation of memory, association of pointers, + ! execution of any other tasks that are needed to properly configure + ! modules. The preparations below DO DEPEND on the grid being complete. if (igr .or. dummy) then call s_initialize_igr_module() end if @@ -1413,11 +1413,11 @@ contains #endif #endif - ! Initializing MPI execution environment + ! MPI execution environment call s_mpi_initialize() - ! Bind GPUs if OpenACC is enabled + ! GPUs if OpenACC is enabled #ifdef MFC_GPU #ifndef MFC_MPI local_size = 1 @@ -1441,10 +1441,10 @@ contains #endif #endif - ! The rank 0 processor assigns default values to the user inputs prior to - ! reading them in from the input file. Next, the user inputs are read and - ! their consistency is checked. The identification of any inconsistencies - ! will result in the termination of the simulation. + ! rank 0 processor assigns default values to the user inputs prior to + ! them in from the input file. Next, the user inputs are read and + ! consistency is checked. The identification of any inconsistencies + ! result in the termination of the simulation. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() call s_read_input_file() @@ -1466,9 +1466,9 @@ contains #endif end if - ! Broadcasting the user inputs to all of the processors and performing the - ! parallel computational domain decomposition. Neither procedure has to be - ! carried out if the simulation is in fact not truly executed in parallel. + ! the user inputs to all of the processors and performing the + ! computational domain decomposition. Neither procedure has to be + ! out if the simulation is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() @@ -1583,7 +1583,7 @@ contains if (surface_tension) call s_finalize_surface_tension_module() if (bodyForces) call s_finalize_body_forces_module() - ! Terminating MPI execution environment + ! MPI execution environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/simulation/m_surface_tension.fpp b/src/simulation/m_surface_tension.fpp index 99bac7d722..183a730bc9 100644 --- a/src/simulation/m_surface_tension.fpp +++ b/src/simulation/m_surface_tension.fpp @@ -16,7 +16,7 @@ module m_surface_tension use m_weno use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! schemes for conservation laws + !! conservation laws use m_helper @@ -248,7 +248,7 @@ contains isx%end = m; isy%end = n; isz%end = p - ! compute gradient components + ! gradient components $:GPU_PARALLEL_LOOP(collapse=3) do l = 0, p do k = 0, n @@ -308,7 +308,7 @@ contains iv%beg = 1; iv%end = num_dims + 1 - ! reconstruct gradient components at cell boundaries + ! gradient components at cell boundaries do i = 1, num_dims call s_reconstruct_cell_boundary_values_capillary(c_divs, gL_x, gL_y, gL_z, gR_x, gR_y, gR_z, i) end do @@ -329,7 +329,7 @@ contains #:for SCHEME, TYPE in [('weno', 'WENO_TYPE'),('muscl', 'MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! Reconstruction in s1-direction + ! in s1-direction if (norm_dir == 1) then is1 = idwbuff(1); is2 = idwbuff(2); is3 = idwbuff(3) diff --git a/src/simulation/m_time_steppers.fpp b/src/simulation/m_time_steppers.fpp index 274fb7ff7c..dc46e2b073 100644 --- a/src/simulation/m_time_steppers.fpp +++ b/src/simulation/m_time_steppers.fpp @@ -1,16 +1,16 @@ !> -!! @file m_time_steppers.f90 -!! @brief Contains module m_time_steppers +!! +!! module m_time_steppers #:include 'macros.fpp' #:include 'case.fpp' !> @brief The following module features a variety of time-stepping schemes. -!! Currently, it includes the following Runge-Kutta (RK) algorithms: -!! 1) 1st Order TVD RK -!! 2) 2nd Order TVD RK -!! 3) 3rd Order TVD RK -!! where TVD designates a total-variation-diminishing time-stepper. +!! includes the following Runge-Kutta (RK) algorithms: +!! Order TVD RK +!! Order TVD RK +!! Order TVD RK +!! designates a total-variation-diminishing time-stepper. module m_time_steppers use m_derived_types !< Definitions of the derived types @@ -52,31 +52,31 @@ module m_time_steppers implicit none type(vector_field), allocatable, dimension(:) :: q_cons_ts !< - !! Cell-average conservative variables at each time-stage (TS) + !! variables at each time-stage (TS) type(scalar_field), allocatable, dimension(:) :: q_prim_vf !< - !! Cell-average primitive variables at the current time-stage + !! variables at the current time-stage type(scalar_field), allocatable, dimension(:) :: rhs_vf !< - !! Cell-average RHS variables at the current time-stage + !! variables at the current time-stage type(integer_field), allocatable, dimension(:, :) :: bc_type !< - !! Boundary condition identifiers + !! identifiers type(vector_field), allocatable, dimension(:) :: q_prim_ts1, q_prim_ts2 !< - !! Cell-average primitive variables at consecutive TIMESTEPS + !! variables at consecutive TIMESTEPS real(wp), allocatable, dimension(:, :, :, :, :) :: rhs_pb type(scalar_field) :: q_T_sf !< - !! Cell-average temperature variables at the current time-stage + !! variables at the current time-stage real(wp), allocatable, dimension(:, :, :, :, :) :: rhs_mv real(wp), allocatable, dimension(:, :, :) :: max_dt integer, private :: num_ts !< - !! Number of time stages in the time-stepping scheme + !! time stages in the time-stepping scheme integer :: stor !< storage index real(wp), allocatable, dimension(:, :) :: rk_coef @@ -84,6 +84,7 @@ module m_time_steppers $:GPU_DECLARE(create='[q_cons_ts,q_prim_vf,q_T_sf,rhs_vf,q_prim_ts1,q_prim_ts2,rhs_mv,rhs_pb,max_dt,rk_coef,stor,bc_type]') +!> @cond #if defined(__NVCOMPILER_GPU_UNIFIED_MEM) real(stp), allocatable, dimension(:, :, :, :), pinned, target :: q_cons_ts_pool_host #elif defined(FRONTIER_UNIFIED) @@ -92,12 +93,13 @@ module m_time_steppers integer(kind=8) :: pool_size type(c_ptr) :: cptr_host, cptr_device #endif +!> @endcond contains !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_time_steppers_module #ifdef FRONTIER_UNIFIED use hipfort @@ -109,7 +111,7 @@ contains #endif integer :: i, j !< Generic loop iterators - ! Setting number of time-stages for selected time-stepping scheme + ! number of time-stages for selected time-stepping scheme if (time_stepper == 1) then num_ts = 1 elseif (any(time_stepper == (/2, 3/))) then @@ -120,7 +122,7 @@ contains num_probe_ts = 2 end if - ! Allocating the cell-average conservative variables + ! the cell-average conservative variables @:ALLOCATE(q_cons_ts(1:num_ts)) @:PREFER_GPU(q_cons_ts) @@ -131,7 +133,7 @@ contains #if defined(__NVCOMPILER_GPU_UNIFIED_MEM) if (num_ts == 2 .and. nv_uvm_out_of_core) then - ! host allocation for q_cons_ts(2)%vf(j)%sf for all j + ! allocation for q_cons_ts(2)%vf(j)%sf for all j allocate (q_cons_ts_pool_host(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end, & @@ -139,14 +141,14 @@ contains end if do j = 1, sys_size - ! q_cons_ts(1) lives on the device + ! lives on the device @:ALLOCATE(q_cons_ts(1)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end)) @:PREFER_GPU(q_cons_ts(1)%vf(j)%sf) if (num_ts == 2) then if (nv_uvm_out_of_core) then - ! q_cons_ts(2) lives on the host + ! lives on the host q_cons_ts(2)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_host(:, :, :, j) @@ -163,8 +165,8 @@ contains @:ACC_SETUP_VFs(q_cons_ts(i)) end do #elif defined(FRONTIER_UNIFIED) - ! Allocate to memory regions using hip calls - ! that we will attach pointers to + ! to memory regions using hip calls + ! we will attach pointers to do i = 1, 3 pool_dims(i) = idwbuff(i)%end - idwbuff(i)%beg + 1 pool_starts(i) = idwbuff(i)%beg @@ -181,15 +183,15 @@ contains call c_f_pointer(cptr_host, q_cons_ts_pool_host, shape=pool_dims) q_cons_ts_pool_host(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:) => q_cons_ts_pool_host #else - ! Doing hipMalloc then mapping should be most performant + ! hipMalloc then mapping should be most performant call hipCheck(hipMalloc(q_cons_ts_pool_device, dims8=pool_dims, lbounds8=pool_starts)) - ! Without this map CCE will still create a device copy, because it's silly like that + ! this map CCE will still create a device copy, because it's silly like that #if defined(MFC_OpenACC) call acc_map_data(q_cons_ts_pool_device, c_loc(q_cons_ts_pool_device), c_sizeof(q_cons_ts_pool_device)) #endif - ! CCE see it can access this and will leave it on the host. It will stay on the host so long as HSA_XNACK=1 - ! NOTE: WE CANNOT DO ATOMICS INTO THIS MEMORY. We have to change a property to use atomics here - ! Otherwise leaving this as fine-grained will actually help performance since it can't be cached in GPU L2 + ! see it can access this and will leave it on the host. It will stay on the host so long as HSA_XNACK=1 + ! WE CANNOT DO ATOMICS INTO THIS MEMORY. We have to change a property to use atomics here + ! leaving this as fine-grained will actually help performance since it can't be cached in GPU L2 if (num_ts == 2) then call hipCheck(hipMallocManaged(q_cons_ts_pool_host, dims8=pool_dims, lbounds8=pool_starts, flags=hipMemAttachGlobal)) #if defined(MFC_OpenMP) @@ -199,12 +201,12 @@ contains #endif do j = 1, sys_size - ! q_cons_ts(1) lives on the device + ! lives on the device q_cons_ts(1)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_device(:, :, :, j) if (num_ts == 2) then - ! q_cons_ts(2) lives on the host + ! lives on the host q_cons_ts(2)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_host(:, :, :, j) @@ -228,7 +230,7 @@ contains end do #endif - ! Allocating the cell-average primitive ts variables + ! the cell-average primitive ts variables if (probe_wrt) then @:ALLOCATE(q_prim_ts1(1:num_probe_ts)) @@ -261,7 +263,7 @@ contains end do end if - ! Allocating the cell-average primitive variables + ! the cell-average primitive variables @:ALLOCATE(q_prim_vf(1:sys_size)) if (.not. igr) then @@ -440,7 +442,7 @@ contains @:ALLOCATE(rhs_mv(0,0,0,0,0)) end if - ! Allocating the cell-average RHS variables + ! the cell-average RHS variables @:ALLOCATE(rhs_vf(1:sys_size)) @:PREFER_GPU(rhs_vf) @@ -457,7 +459,7 @@ contains end do end if - ! Opening and writing the header of the run-time information file + ! and writing the header of the run-time information file if (proc_rank == 0 .and. run_time_info) then call s_open_run_time_information_file() end if @@ -466,7 +468,7 @@ contains @:ALLOCATE(max_dt(0:m, 0:n, 0:p)) end if - ! Allocating arrays to store the bc types + ! arrays to store the bc types @:ALLOCATE(bc_type(1:num_dims,1:2)) @:ALLOCATE(bc_type(1,1)%sf(0:0,0:n,0:p)) @@ -491,14 +493,14 @@ contains end do if (any(time_stepper == (/1, 2, 3/))) then - ! temporary array index for TVD RK + ! array index for TVD RK if (time_stepper == 1) then stor = 1 else stor = 2 end if - ! TVD RK coefficients + ! RK coefficients @:ALLOCATE (rk_coef(time_stepper, 4)) if (time_stepper == 1) then rk_coef(1, :) = (/1._wp, 0._wp, 1._wp, 1._wp/) @@ -530,7 +532,7 @@ contains call cpu_time(start) call nvtxStartRange("TIMESTEP") - ! Adaptive dt: initial stage + ! dt: initial stage if (adap_dt) call s_adaptive_dt_bubble(1) do s = 1, nstage @@ -625,12 +627,12 @@ contains if (adv_n) call s_comp_alpha_from_n(q_cons_ts(1)%vf) if (ib) then - ! check if any IBMS are moving, and if so, update the markers, ghost points, levelsets, and levelset norms + ! if any IBMS are moving, and if so, update the markers, ghost points, levelsets, and levelset norms if (moving_immersed_boundary_flag) then call s_propagate_immersed_boundaries(s) end if - ! update the ghost fluid properties point values based on IB state + ! the ghost fluid properties point values based on IB state if (qbmm .and. .not. polytropic) then call s_ibm_correct_state(q_cons_ts(1)%vf, q_prim_vf, pb_ts(1)%sf, mv_ts(1)%sf) else @@ -640,7 +642,7 @@ contains end do - ! Adaptive dt: final stage + ! dt: final stage if (adap_dt) call s_adaptive_dt_bubble(3) call nvtxEndRange @@ -657,7 +659,7 @@ contains end subroutine s_tvd_rk !> Bubble source part in Strang operator splitting scheme - !! @param t_step Current time-step + !! Current time-step impure subroutine s_adaptive_dt_bubble(stage) integer, intent(in) :: stage @@ -735,7 +737,7 @@ contains call s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, qv, j, k, l) end if - ! Compute mixture sound speed + ! mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, alpha, vel_sum, 0._wp, c, qv) call s_compute_dt_from_cfl(vel, c, max_dt, rho, Re, j, k, l) @@ -758,15 +760,18 @@ contains end subroutine s_compute_dt - !> This subroutine applies the body forces source term at each - !! Runge-Kutta stage + !> This subroutine applies the body forces source term at each Runge-Kutta stage. + !! @param[inout] q_cons_vf Conservative variables to update. + !! @param[in] q_prim_vf_in Primitive variables for computing source terms. + !! @param[inout] rhs_vf_in Right-hand side vector for body force terms. + !! @param[in] ldt Local time step size. subroutine s_apply_bodyforces(q_cons_vf, q_prim_vf_in, rhs_vf_in, ldt) type(scalar_field), dimension(1:sys_size), intent(inout) :: q_cons_vf type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf_in type(scalar_field), dimension(1:sys_size), intent(inout) :: rhs_vf_in - real(wp), intent(in) :: ldt !< local dt + real(wp), intent(in) :: ldt integer :: i, j, k, l @@ -813,28 +818,28 @@ contains patch_ib(i)%angular_vel = (rk_coef(s, 1)*patch_ib(i)%step_angular_vel + rk_coef(s, 2)*patch_ib(i)%angular_vel)/rk_coef(s, 4) if (patch_ib(i)%moving_ibm == 1) then - ! plug in analytic velocities for 1-way coupling, if it exists + ! in analytic velocities for 1-way coupling, if it exists @:mib_analytical() else if (patch_ib(i)%moving_ibm == 2) then ! if we are using two-way coupling, apply force and torque - ! compute the force and torque on the IB from the fluid + ! the force and torque on the IB from the fluid if (.not. forces_computed) then call s_compute_ib_forces(q_prim_vf, fluid_pp) forces_computed = .true. end if - ! update the velocity from the force value + ! the velocity from the force value patch_ib(i)%vel = patch_ib(i)%vel + rk_coef(s, 3)*dt*(patch_ib(i)%force/patch_ib(i)%mass)/rk_coef(s, 4) - ! update the angular velocity with the torque value + ! the angular velocity with the torque value patch_ib(i)%angular_vel = (patch_ib(i)%angular_vel*patch_ib(i)%moment) + (rk_coef(s, 3)*dt*patch_ib(i)%torque/rk_coef(s, 4)) ! add the torque to the angular momentum call s_compute_moment_of_inertia(i, patch_ib(i)%angular_vel) ! update the moment of inertia to be based on the direction of the angular momentum patch_ib(i)%angular_vel = patch_ib(i)%angular_vel/patch_ib(i)%moment ! convert back to angular velocity with the new moment of inertia end if - ! Update the angle of the IB + ! the angle of the IB patch_ib(i)%angles = (rk_coef(s, 1)*patch_ib(i)%step_angles + rk_coef(s, 2)*patch_ib(i)%angles + rk_coef(s, 3)*patch_ib(i)%angular_vel*dt)/rk_coef(s, 4) - ! Update the position of the IB + ! the position of the IB patch_ib(i)%x_centroid = (rk_coef(s, 1)*patch_ib(i)%step_x_centroid + rk_coef(s, 2)*patch_ib(i)%x_centroid + rk_coef(s, 3)*patch_ib(i)%vel(1)*dt)/rk_coef(s, 4) patch_ib(i)%y_centroid = (rk_coef(s, 1)*patch_ib(i)%step_y_centroid + rk_coef(s, 2)*patch_ib(i)%y_centroid + rk_coef(s, 3)*patch_ib(i)%vel(2)*dt)/rk_coef(s, 4) patch_ib(i)%z_centroid = (rk_coef(s, 1)*patch_ib(i)%step_z_centroid + rk_coef(s, 2)*patch_ib(i)%z_centroid + rk_coef(s, 3)*patch_ib(i)%vel(3)*dt)/rk_coef(s, 4) @@ -846,8 +851,8 @@ contains end subroutine s_propagate_immersed_boundaries !> This subroutine saves the temporary q_prim_vf vector - !! into the q_prim_ts vector that is then used in p_main - !! @param t_step current time-step + !! q_prim_ts vector that is then used in p_main + !! current time-step subroutine s_time_step_cycling(t_step) integer, intent(in) :: t_step @@ -930,7 +935,7 @@ contains #endif integer :: i, j !< Generic loop iterators - ! Deallocating the cell-average conservative variables + ! the cell-average conservative variables #if defined(__NVCOMPILER_GPU_UNIFIED_MEM) do j = 1, sys_size @:DEALLOCATE(q_cons_ts(1)%vf(j)%sf) @@ -973,7 +978,7 @@ contains @:DEALLOCATE(q_cons_ts) - ! Deallocating the cell-average primitive ts variables + ! the cell-average primitive ts variables if (probe_wrt) then do i = 1, num_probe_ts do j = 1, sys_size @@ -985,7 +990,7 @@ contains end if if (.not. igr) then - ! Deallocating the cell-average primitive variables + ! the cell-average primitive variables do i = 1, adv_idx%end @:DEALLOCATE(q_prim_vf(i)%sf) end do @@ -1031,14 +1036,14 @@ contains @:DEALLOCATE(q_prim_vf) - ! Deallocating the cell-average RHS variables + ! the cell-average RHS variables do i = 1, sys_size @:DEALLOCATE(rhs_vf(i)%sf) end do @:DEALLOCATE(rhs_vf) - ! Writing the footer of and closing the run-time information file + ! the footer of and closing the run-time information file if (proc_rank == 0 .and. run_time_info) then call s_close_run_time_information_file() end if diff --git a/src/simulation/m_viscous.fpp b/src/simulation/m_viscous.fpp index e81a243373..c507b7bf3d 100644 --- a/src/simulation/m_viscous.fpp +++ b/src/simulation/m_viscous.fpp @@ -1,6 +1,6 @@ !> -!! @file m_viscous.f90 -!! @brief Contains module m_viscous +!! +!! module m_viscous #:include 'case.fpp' #:include 'macros.fpp' @@ -14,7 +14,7 @@ module m_viscous use m_weno use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! schemes for conservation laws + !! conservation laws use m_helper @@ -53,14 +53,14 @@ contains end subroutine s_initialize_viscous_module !> The purpose of this subroutine is to compute the viscous - ! stress tensor for the cells directly next to the axis in - ! cylindrical coordinates. This is necessary to avoid the - ! 1/r singularity that arises at the cell boundary coinciding - ! with the axis, i.e., y_cb(-1) = 0. - ! @param q_prim_vf Cell-average primitive variables - ! @param grad_x_vf Cell-average primitive variable derivatives, x-dir - ! @param grad_y_vf Cell-average primitive variable derivatives, y-dir - ! @param grad_z_vf Cell-average primitive variable derivatives, z-dir + ! tensor for the cells directly next to the axis in + ! coordinates. This is necessary to avoid the + ! singularity that arises at the cell boundary coinciding + ! the axis, i.e., y_cb(-1) = 0. + ! q_prim_vf Cell-average primitive variables + ! grad_x_vf Cell-average primitive variable derivatives, x-dir + ! grad_y_vf Cell-average primitive variable derivatives, y-dir + ! grad_z_vf Cell-average primitive variable derivatives, z-dir subroutine s_compute_viscous_stress_cylindrical_boundary(q_prim_vf, grad_x_vf, grad_y_vf, grad_z_vf, & tau_Re_vf, & ix, iy, iz) @@ -530,9 +530,9 @@ contains end subroutine s_compute_viscous_stress_cylindrical_boundary !> Computes viscous terms - !! @param q_cons_vf Cell-averaged conservative variables - !! @param q_prim_vf Cell-averaged primitive variables - !! @param rhs_vf Cell-averaged RHS variables + !! Cell-averaged conservative variables + !! Cell-averaged primitive variables + !! Cell-averaged RHS variables subroutine s_get_viscous(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, & dqL_prim_dx_n, dqL_prim_dy_n, dqL_prim_dz_n, & qL_prim, & @@ -577,8 +577,8 @@ contains end do if (weno_Re_flux) then - ! Compute velocity gradient at cell centers using scalar - ! divergence theorem + ! velocity gradient at cell centers using scalar + ! theorem do i = 1, num_dims if (i == 1) then call s_apply_scalar_divergence_theorem( & @@ -1021,7 +1021,7 @@ contains #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! Reconstruction in s1-direction + ! in s1-direction if (norm_dir == 1) then is1_viscous = ix; is2_viscous = iy; is3_viscous = iz @@ -1123,7 +1123,7 @@ contains integer :: i, j, k, l #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$) then - ! Reconstruction in s1-direction + ! in s1-direction if (norm_dir == 1) then is1_viscous = ix; is2_viscous = iy; is3_viscous = iz @@ -1213,21 +1213,21 @@ contains end subroutine s_reconstruct_cell_boundary_values_visc_deriv !> The purpose of this subroutine is to employ the inputted - !! left and right cell-boundary integral-averaged variables - !! to compute the relevant cell-average first-order spatial - !! derivatives in the x-, y- or z-direction by means of the - !! scalar divergence theorem. - !! @param vL_vf Left cell-boundary integral averages - !! @param vR_vf Right cell-boundary integral averages - !! @param dv_ds_vf Cell-average first-order spatial derivatives - !! @param norm_dir Splitting coordinate direction + !! right cell-boundary integral-averaged variables + !! the relevant cell-average first-order spatial + !! the x-, y- or z-direction by means of the + !! theorem. + !! Left cell-boundary integral averages + !! Right cell-boundary integral averages + !! Cell-average first-order spatial derivatives + !! Splitting coordinate direction subroutine s_apply_scalar_divergence_theorem(vL_vf, vR_vf, & dv_ds_vf, & norm_dir, & ix, iy, iz, iv_in, & dL, dim, buff_size_in) - ! arrays of cell widths + ! of cell widths type(scalar_field), & dimension(iv%beg:iv%end), & intent(in) :: vL_vf, vR_vf @@ -1250,14 +1250,14 @@ contains $:GPU_UPDATE(device='[is1_viscous, is2_viscous, is3_viscous, iv]') - ! First-Order Spatial Derivatives in x-direction + ! Spatial Derivatives in x-direction if (norm_dir == 1) then - ! A general application of the scalar divergence theorem that - ! utilizes the left and right cell-boundary integral-averages, - ! inside each cell, or an arithmetic mean of these two at the - ! cell-boundaries, to calculate the cell-averaged first-order - ! spatial derivatives inside the cell. + ! general application of the scalar divergence theorem that + ! the left and right cell-boundary integral-averages, + ! each cell, or an arithmetic mean of these two at the + ! to calculate the cell-averaged first-order + ! derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg, is3_viscous%end @@ -1277,16 +1277,16 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! END: First-Order Spatial Derivatives in x-direction + ! First-Order Spatial Derivatives in x-direction - ! First-Order Spatial Derivatives in y-direction + ! Spatial Derivatives in y-direction elseif (norm_dir == 2) then - ! A general application of the scalar divergence theorem that - ! utilizes the left and right cell-boundary integral-averages, - ! inside each cell, or an arithmetic mean of these two at the - ! cell-boundaries, to calculate the cell-averaged first-order - ! spatial derivatives inside the cell. + ! general application of the scalar divergence theorem that + ! the left and right cell-boundary integral-averages, + ! each cell, or an arithmetic mean of these two at the + ! to calculate the cell-averaged first-order + ! derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg, is3_viscous%end @@ -1306,16 +1306,16 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! END: First-Order Spatial Derivatives in y-direction + ! First-Order Spatial Derivatives in y-direction - ! First-Order Spatial Derivatives in z-direction + ! Spatial Derivatives in z-direction else - ! A general application of the scalar divergence theorem that - ! utilizes the left and right cell-boundary integral-averages, - ! inside each cell, or an arithmetic mean of these two at the - ! cell-boundaries, to calculate the cell-averaged first-order - ! spatial derivatives inside the cell. + ! general application of the scalar divergence theorem that + ! the left and right cell-boundary integral-averages, + ! each cell, or an arithmetic mean of these two at the + ! to calculate the cell-averaged first-order + ! derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg + 1, is3_viscous%end - 1 @@ -1336,16 +1336,16 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! END: First-Order Spatial Derivatives in z-direction + ! First-Order Spatial Derivatives in z-direction end subroutine s_apply_scalar_divergence_theorem !> Computes the scalar gradient fields via finite differences - !! @param var Variable to compute derivative of - !! @param grad_x First coordinate direction component of the derivative - !! @param grad_y Second coordinate direction component of the derivative - !! @param grad_z Third coordinate direction component of the derivative - !! @param norm Norm of the gradient vector + !! Variable to compute derivative of + !! First coordinate direction component of the derivative + !! Second coordinate direction component of the derivative + !! Third coordinate direction component of the derivative + !! Norm of the gradient vector subroutine s_compute_fd_gradient(var, grad_x, grad_y, grad_z) type(scalar_field), intent(in) :: var @@ -1523,7 +1523,7 @@ contains end subroutine s_compute_fd_gradient - ! computes the viscous stress tensor at a particule i, j, k element + ! the viscous stress tensor at a particule i, j, k element subroutine s_compute_viscous_stress_tensor(viscous_stress_tensor, q_prim_vf, dynamic_viscosity, i, j, k) $:GPU_ROUTINE(parallelism='[seq]') @@ -1537,19 +1537,19 @@ contains real(wp) :: divergence integer :: l, q ! iterators - ! zero the viscous stress, collection of velocity diriviatives, and spacial finite differences + ! the viscous stress, collection of velocity diriviatives, and spacial finite differences viscous_stress_tensor = 0._wp velocity_gradient_tensor = 0._wp dx = 0._wp - ! get the change in x used in the finite difference equaiont + ! the change in x used in the finite difference equaiont dx(1) = 0.5_wp*(x_cc(i + 1) - x_cc(i - 1)) dx(2) = 0.5_wp*(y_cc(j + 1) - y_cc(j - 1)) if (num_dims == 3) then dx(3) = 0.5_wp*(z_cc(k + 1) - z_cc(k - 1)) end if - ! compute the velocity gradient tensor + ! the velocity gradient tensor do l = 1, num_dims velocity_gradient_tensor(l, 1) = (q_prim_vf(momxb + l - 1)%sf(i + 1, j, k) - q_prim_vf(momxb + l - 1)%sf(i - 1, j, k))/(2._wp*dx(1)) velocity_gradient_tensor(l, 2) = (q_prim_vf(momxb + l - 1)%sf(i, j + 1, k) - q_prim_vf(momxb + l - 1)%sf(i, j - 1, k))/(2._wp*dx(2)) @@ -1558,20 +1558,20 @@ contains end if end do - ! compute divergence + ! divergence divergence = 0._wp do l = 1, num_dims divergence = divergence + velocity_gradient_tensor(l, l) end do - ! set up the shear stress tensor + ! up the shear stress tensor do l = 1, num_dims do q = 1, num_dims viscous_stress_tensor(l, q) = dynamic_viscosity*(velocity_gradient_tensor(l, q) + velocity_gradient_tensor(q, l)) end do end do - ! populate the viscous_stress_tensor + ! the viscous_stress_tensor do l = 1, num_dims viscous_stress_tensor(l, l) = viscous_stress_tensor(l, l) - 2._wp*divergence*dynamic_viscosity/3._wp end do diff --git a/src/simulation/m_weno.fpp b/src/simulation/m_weno.fpp index 32bd2a2d6e..77e02dbdc0 100644 --- a/src/simulation/m_weno.fpp +++ b/src/simulation/m_weno.fpp @@ -1,22 +1,22 @@ !> -!! @file m_weno.f90 -!! @brief Contains module m_weno +!! +!! module m_weno #:include 'case.fpp' #:include 'macros.fpp' !> @brief Weighted essentially non-oscillatory (WENO) reconstruction scheme -!! that is supplemented with monotonicity preserving bounds (MPWENO) -!! and a mapping function that boosts the accuracy of the non-linear -!! weights (WENOM). MPWENO, see Balsara and Shu (2000), prevents the -!! reconstructed values to lay outside the range set by the stencil, -!! while WENOM, see Henrick et al. (2005), recovers the formal order -!! of accuracy of the reconstruction at critical points. Please note -!! that the basic WENO approach is implemented according to the work -!! of Jiang and Shu (1996). WENO-Z, which is less dissipative than -!! WENO-JS and WENO-M, is implemented according to the work of -!! Borges, et al. (2008). TENO, which is even less dissipative than -!! WENO-Z but is less robust, is implemented according to the work -!! of Fu et al. (2016). +!! supplemented with monotonicity preserving bounds (MPWENO) +!! mapping function that boosts the accuracy of the non-linear +!! MPWENO, see Balsara and Shu (2000), prevents the +!! to lay outside the range set by the stencil, +!! see Henrick et al. (2005), recovers the formal order +!! of the reconstruction at critical points. Please note +!! basic WENO approach is implemented according to the work +!! and Shu (1996). WENO-Z, which is less dissipative than +!! WENO-M, is implemented according to the work of +!! al. (2008). TENO, which is even less dissipative than +!! is less robust, is implemented according to the work +!! et al. (2016). module m_weno use m_derived_types !< Definitions of the derived types @@ -25,7 +25,7 @@ module m_weno use m_variables_conversion !< State variables type conversion procedures - ! $:USE_GPU_MODULE() + ! use m_mpi_proxy @@ -34,24 +34,24 @@ module m_weno private; public :: s_initialize_weno_module, s_initialize_weno, s_finalize_weno_module, s_weno !> @name The cell-average variables that will be WENO-reconstructed. Formerly, they - !! are stored in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR - !! as to be reshaped (RS) and/or characteristically decomposed. The reshaping - !! allows the WENO procedure to be independent of the coordinate direction of - !! the reconstruction. Lastly, notice that the left (L) and right (R) results - !! of the characteristic decomposition are stored in custom-constructed WENO- - !! stencils (WS) that are annexed to each position of a given scalar field. + !! in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR + !! be reshaped (RS) and/or characteristically decomposed. The reshaping + !! WENO procedure to be independent of the coordinate direction of + !! Lastly, notice that the left (L) and right (R) results + !! characteristic decomposition are stored in custom-constructed WENO- + !! that are annexed to each position of a given scalar field. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: v_rs_ws_x, v_rs_ws_y, v_rs_ws_z !> @} $:GPU_DECLARE(create='[v_rs_ws_x,v_rs_ws_y,v_rs_ws_z]') - ! WENO Coefficients + ! Coefficients !> @name Polynomial coefficients at the left and right cell-boundaries (CB) and at - !! the left and right quadrature points (QP), in the x-, y- and z-directions. - !! Note that the first dimension of the array identifies the polynomial, the - !! second dimension identifies the position of its coefficients and the last - !! dimension denotes the cell-location in the relevant coordinate direction. + !! and right quadrature points (QP), in the x-, y- and z-directions. + !! the first dimension of the array identifies the polynomial, the + !! identifies the position of its coefficients and the last + !! the cell-location in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :, :) :: poly_coef_cbL_x real(wp), target, allocatable, dimension(:, :, :) :: poly_coef_cbL_y @@ -64,9 +64,9 @@ module m_weno $:GPU_DECLARE(create='[poly_coef_cbR_x,poly_coef_cbR_y,poly_coef_cbR_z]') !> @name The ideal weights at the left and the right cell-boundaries and at the - !! left and the right quadrature points, in x-, y- and z-directions. Note - !! that the first dimension of the array identifies the weight, while the - !! last denotes the cell-location in the relevant coordinate direction. + !! the right quadrature points, in x-, y- and z-directions. Note + !! first dimension of the array identifies the weight, while the + !! the cell-location in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :) :: d_cbL_x real(wp), target, allocatable, dimension(:, :) :: d_cbL_y @@ -79,9 +79,9 @@ module m_weno $:GPU_DECLARE(create='[d_cbL_x,d_cbL_y,d_cbL_z,d_cbR_x,d_cbR_y,d_cbR_z]') !> @name Smoothness indicator coefficients in the x-, y-, and z-directions. Note - !! that the first array dimension identifies the smoothness indicator, the - !! second identifies the position of its coefficients and the last denotes - !! the cell-location in the relevant coordinate direction. + !! first array dimension identifies the smoothness indicator, the + !! the position of its coefficients and the last denotes + !! in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :, :) :: beta_coef_x real(wp), target, allocatable, dimension(:, :, :) :: beta_coef_y @@ -89,7 +89,7 @@ module m_weno !> @} $:GPU_DECLARE(create='[beta_coef_x,beta_coef_y,beta_coef_z]') - ! END: WENO Coefficients + ! WENO Coefficients integer :: v_size !< Number of WENO-reconstructed cell-average variables $:GPU_DECLARE(create='[v_size]') @@ -106,13 +106,13 @@ module m_weno contains !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are necessary to setup the module. + !! of pointers and/or the execution of any + !! that are necessary to setup the module. impure subroutine s_initialize_weno_module if (weno_order == 1) return - ! Allocating/Computing WENO Coefficients in x-direction + ! WENO Coefficients in x-direction is1_weno%beg = -buff_size; is1_weno%end = m - is1_weno%beg if (n == 0) then is2_weno%beg = 0 @@ -140,15 +140,15 @@ contains @:ALLOCATE(beta_coef_x(is1_weno%beg + weno_polyn:is1_weno%end - weno_polyn, 0:weno_polyn, & 0:weno_polyn*(weno_polyn + 1)/2 - 1)) - ! Number of cross terms for dvd = (k-1)(k-1+1)/2, where weno_polyn = k-1 - ! Note: k-1 not k because we are using value differences (dvd) not the values themselves + ! of cross terms for dvd = (k-1)(k-1+1)/2, where weno_polyn = k-1 + ! k-1 not k because we are using value differences (dvd) not the values themselves call s_compute_weno_coefficients(1, is1_weno) @:ALLOCATE(v_rs_ws_x(is1_weno%beg:is1_weno%end, & is2_weno%beg:is2_weno%end, is3_weno%beg:is3_weno%end, 1:sys_size)) - ! Allocating/Computing WENO Coefficients in y-direction + ! WENO Coefficients in y-direction if (n == 0) return is2_weno%beg = -buff_size; is2_weno%end = n - is2_weno%beg @@ -178,7 +178,7 @@ contains @:ALLOCATE(v_rs_ws_y(is2_weno%beg:is2_weno%end, & is1_weno%beg:is1_weno%end, is3_weno%beg:is3_weno%end, 1:sys_size)) - ! Allocating/Computing WENO Coefficients in z-direction + ! WENO Coefficients in z-direction if (p == 0) return is2_weno%beg = -buff_size; is2_weno%end = n - is2_weno%beg @@ -204,12 +204,12 @@ contains end subroutine s_initialize_weno_module !> The purpose of this subroutine is to compute the grid - !! dependent coefficients of the WENO polynomials, ideal - !! weights and smoothness indicators, provided the order, - !! the coordinate direction and the location of the WENO - !! reconstruction. - !! @param weno_dir Coordinate direction of the WENO reconstruction - !! @param is Index bounds in the s-direction + !! of the WENO polynomials, ideal + !! smoothness indicators, provided the order, + !! direction and the location of the WENO + !! + !! Coordinate direction of the WENO reconstruction + !! Index bounds in the s-direction subroutine s_compute_weno_coefficients(weno_dir, is) integer, intent(in) :: weno_dir @@ -217,7 +217,7 @@ contains integer :: s real(wp), pointer, dimension(:) :: s_cb => null() !< - !! Cell-boundary locations in the s-direction + !! in the s-direction type(int_bounds_info) :: bc_s !< Boundary conditions (BC) in the s-direction @@ -226,9 +226,9 @@ contains real(wp) :: w(1:8) ! Intermediate var for ideal weights: s_cb across overall stencil real(wp) :: y(1:4) ! Intermediate var for poly & beta: diff(s_cb) across sub-stencil - ! Determining the number of cells, the cell-boundary locations and - ! the boundary conditions in the coordinate direction selected for - ! the WENO reconstruction + ! the number of cells, the cell-boundary locations and + ! boundary conditions in the coordinate direction selected for + ! WENO reconstruction if (weno_dir == 1) then s = m; s_cb => x_cb; bc_s = bc_x elseif (weno_dir == 2) then @@ -238,7 +238,7 @@ contains end if #:for WENO_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] - ! Computing WENO3 Coefficients + ! WENO3 Coefficients if (weno_dir == ${WENO_DIR}$) then if (weno_order == 3) then do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn @@ -266,10 +266,10 @@ contains end do - ! Modifying the ideal weights coefficients in the neighborhood - ! of beginning and end Riemann state extrapolation BC to avoid - ! any contributions from outside of the physical domain during - ! the WENO reconstruction + ! the ideal weights coefficients in the neighborhood + ! beginning and end Riemann state extrapolation BC to avoid + ! contributions from outside of the physical domain during + ! WENO reconstruction if (null_weights) then if (bc_s%beg == BC_RIEMANN_EXTRAP) then d_cbR_${XYZ}$ (1, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp @@ -281,9 +281,9 @@ contains d_cbL_${XYZ}$ (0, s) = 0._wp; d_cbL_${XYZ}$ (1, s) = 1._wp end if end if - ! END: Computing WENO3 Coefficients + ! Computing WENO3 Coefficients - ! Computing WENO5 Coefficients + ! WENO5 Coefficients elseif (weno_order == 5) then do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn @@ -412,10 +412,10 @@ contains end do - ! Modifying the ideal weights coefficients in the neighborhood - ! of beginning and end Riemann state extrapolation BC to avoid - ! any contributions from outside of the physical domain during - ! the WENO reconstruction + ! the ideal weights coefficients in the neighborhood + ! beginning and end Riemann state extrapolation BC to avoid + ! contributions from outside of the physical domain during + ! WENO reconstruction if (null_weights) then if (bc_s%beg == BC_RIEMANN_EXTRAP) then d_cbR_${XYZ}$ (1:2, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp @@ -438,16 +438,16 @@ contains do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn - ! Reference: Shu (1997) "Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory Schemes for Hyperbolic Conservation Laws" - ! Equation 2.20: Polynomial Coefficients (poly_coef_cb) - ! Equation 2.61: Smoothness Indicators (beta_coef) - ! To reduce computational cost, we leverage the fact that all polynomial coefficients in a stencil sum to 1 - ! and compute the polynomial coefficients (poly_coef_cb) for the cell value differences (dvd) instead of the values themselves. - ! The computation of coefficients is further simplified by using grid spacing (y or w) rather than the grid locations (s_cb) directly. - ! Ideal weights (d_cb) are obtained by comparing the grid location coefficients of the polynomial coefficients. - ! The smoothness indicators (beta_coef) are calculated through numerical differentiation and integration of each cross term of the polynomial coefficients, - ! using the cell value differences (dvd) instead of the values themselves. - ! While the polynomial coefficients sum to 1, the derivative of 1 is 0, which means it does not create additional cross terms in the smoothness indicators. + ! Shu (1997) "Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory Schemes for Hyperbolic Conservation Laws" + ! 2.20: Polynomial Coefficients (poly_coef_cb) + ! 2.61: Smoothness Indicators (beta_coef) + ! reduce computational cost, we leverage the fact that all polynomial coefficients in a stencil sum to 1 + ! compute the polynomial coefficients (poly_coef_cb) for the cell value differences (dvd) instead of the values themselves. + ! computation of coefficients is further simplified by using grid spacing (y or w) rather than the grid locations (s_cb) directly. + ! weights (d_cb) are obtained by comparing the grid location coefficients of the polynomial coefficients. + ! smoothness indicators (beta_coef) are calculated through numerical differentiation and integration of each cross term of the polynomial coefficients, + ! the cell value differences (dvd) instead of the values themselves. + ! the polynomial coefficients sum to 1, the derivative of 1 is 0, which means it does not create additional cross terms in the smoothness indicators. w = s_cb(i - 3:i + 4) - s_cb(i) ! Offset using s_cb(i) to reduce floating point error d_cbR_${XYZ}$ (0, i + 1) = ((w(5) - w(6))*(w(5) - w(7))*(w(5) - w(8)))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))) !& @@ -460,7 +460,7 @@ contains d_cbL_${XYZ}$ (1, i + 1) = ((w(1) - w(5))*(w(2) - w(5))*(w(5) - w(8))*(w(1)*w(2) + w(1)*w(3) + w(2)*w(3) - w(1)*w(7) - w(1)*w(8) - w(2)*w(7) - w(2)*w(8) - w(3)*w(7) - w(3)*w(8) + w(7)*w(8) + w(7)**2 + w(8)**2))/((w(1) - w(7))*(w(1) - w(8))*(w(2) - w(7))*(w(2) - w(8))*(w(3) - w(8))) !& d_cbL_${XYZ}$ (2, i + 1) = ((w(1) - w(5))*(w(5) - w(7))*(w(5) - w(8))*(w(1)*w(2) - w(1)*w(6) - w(1)*w(7) - w(2)*w(6) - w(1)*w(8) - w(2)*w(7) - w(2)*w(8) + w(6)*w(7) + w(6)*w(8) + w(7)*w(8) + w(1)**2 + w(2)**2))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))*(w(2) - w(7))*(w(2) - w(8))) !& d_cbL_${XYZ}$ (3, i + 1) = ((w(5) - w(6))*(w(5) - w(7))*(w(5) - w(8)))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))) !& - ! Note: Left has the reversed order of both points and coefficients compared to the right + ! Left has the reversed order of both points and coefficients compared to the right y = s_cb(i + 1:i + 4) - s_cb(i:i + 3) poly_coef_cbR_${XYZ}$ (i + 1, 0, 0) = (y(1)*y(2)*(y(2) + y(3)))/((y(3) + y(4))*(y(2) + y(3) + y(4))*(y(1) + y(2) + y(3) + y(4))) !& @@ -503,7 +503,7 @@ contains poly_coef_cbL_${XYZ}$ (i + 1, 0, 0) = (y(4)*(y(3) + y(4))*(y(2) + y(3) + y(4)))/((y(1) + y(2))*(y(1) + y(2) + y(3))*(y(1) + y(2) + y(3) + y(4))) !& poly_coef_cbL_${XYZ}$ (i + 1, :, :) = -poly_coef_cbL_${XYZ}$ (i + 1, :, :) - ! Note: negative sign as the direction of taking the difference (dvd) is reversed + ! negative sign as the direction of taking the difference (dvd) is reversed y = s_cb(i - 2:i + 1) - s_cb(i - 3:i) beta_coef_${XYZ}$ (i + 1, 3, 0) = (4*y(4)**2*(5*y(1)**2*y(2)**2 + 20*y(1)**2*y(2)*y(3) + 15*y(1)**2*y(2)*y(4) + 20*y(1)**2*y(3)**2 + 30*y(1)**2*y(3)*y(4) + 60*y(1)**2*y(4)**2 + 10*y(1)*y(2)**3 + 60*y(1)*y(2)**2*y(3) + 45*y(1)*y(2)**2*y(4) + 110*y(1)*y(2)*y(3)**2 + 165*y(1)*y(2)*y(3)*y(4) & !& @@ -604,7 +604,7 @@ contains end do else ! TENO (only supports uniform grid) - ! (Fu, et al., 2016) Table 2 (for right flux) + ! et al., 2016) Table 2 (for right flux) d_cbL_${XYZ}$ (0, :) = 18._wp/35._wp d_cbL_${XYZ}$ (1, :) = 3._wp/35._wp d_cbL_${XYZ}$ (2, :) = 9._wp/35._wp @@ -631,7 +631,7 @@ contains $:GPU_UPDATE(device='[poly_coef_cbL_z,poly_coef_cbR_z,d_cbL_z,d_cbR_z,beta_coef_z]') end if - ! Nullifying WENO coefficients and cell-boundary locations pointers + ! WENO coefficients and cell-boundary locations pointers nullify (s_cb) @@ -728,7 +728,7 @@ contains do k = is2_weno%beg, is2_weno%end do j = is1_weno%beg, is1_weno%end do i = 1, v_size - ! reconstruct from left side + ! from left side alpha(:) = 0._wp omega(:) = 0._wp @@ -759,7 +759,7 @@ contains *(omega(0:weno_num_stencils)/(d_cbL_${XYZ}$ (0:weno_num_stencils, j)**2._wp + omega(0:weno_num_stencils)*(1._wp - 2._wp*d_cbL_${XYZ}$ (0:weno_num_stencils, j)))) elseif (wenoz) then - ! Borges, et al. (2008) + ! et al. (2008) tau = abs(beta(1) - beta(0)) alpha(0:weno_num_stencils) = d_cbL_${XYZ}$ (0:weno_num_stencils, j)*(1._wp + tau/beta(0:weno_num_stencils)) @@ -770,7 +770,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, i) = omega(0)*poly(0) + omega(1)*poly(1) - ! reconstruct from right side + ! from right side poly(0) = v_rs_ws_${XYZ}$ (j, k, l, i) & + poly_coef_cbR_${XYZ}$ (j, 0, 0)*dvd(0) @@ -814,7 +814,7 @@ contains do j = is1_weno%beg, is1_weno%end $:GPU_LOOP(parallelism='[seq]') do i = 1, v_size - ! reconstruct from left side + ! from left side alpha(:) = 0._wp omega(:) = 0._wp @@ -864,7 +864,7 @@ contains elseif (wenoz) then - ! Borges, et al. (2008) + ! et al. (2008) tau = abs(beta(2) - beta(0)) ! Equation 25 $:GPU_LOOP(parallelism='[seq]') @@ -873,8 +873,8 @@ contains end do elseif (teno) then - ! Fu, et al. (2016) - ! Fu''s code: https://dx.doi.org/10.13140/RG.2.2.36250.34247 + ! et al. (2016) + ! code: https://dx.doi.org/10.13140/RG.2.2.36250.34247 tau = abs(beta(2) - beta(0)) $:GPU_LOOP(parallelism='[seq]') do q = 0, weno_num_stencils @@ -898,7 +898,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, i) = omega(0)*poly(0) + omega(1)*poly(1) + omega(2)*poly(2) - ! reconstruct from right side + ! from right side poly(0) = v_rs_ws_${XYZ}$ (j, k, l, i) & + poly_coef_cbR_${XYZ}$ (j, 0, 0)*dvd(1) & @@ -1002,11 +1002,11 @@ contains else #:if not MFC_CASE_OPTIMIZATION or weno_num_stencils > 3 - ! (Fu, et al., 2016) Table 1 - ! Note: Unlike TENO5, TENO7 stencils differ from WENO7 stencils - ! See Figure 2 (right) for right-sided flux (at i+1/2) - ! Here we need the left-sided flux, so we flip the weights with respect to the x=i point - ! But we need to keep the stencil order to reuse the beta coefficients + ! et al., 2016) Table 1 + ! Unlike TENO5, TENO7 stencils differ from WENO7 stencils + ! Figure 2 (right) for right-sided flux (at i+1/2) + ! we need the left-sided flux, so we flip the weights with respect to the x=i point + ! we need to keep the stencil order to reuse the beta coefficients poly(0) = ( 2._wp*v(-1) + 5._wp*v( 0) - 1._wp*v( 1)) / 6._wp !& poly(1) = (11._wp*v( 0) - 7._wp*v( 1) + 2._wp*v( 2)) / 6._wp !& poly(2) = (-1._wp*v(-2) + 5._wp*v(-1) + 2._wp*v( 0)) / 6._wp !& @@ -1051,7 +1051,7 @@ contains else ! TENO #:if not MFC_CASE_OPTIMIZATION or weno_num_stencils > 3 - ! High-Order Low-Dissipation Targeted ENO Schemes for Ideal Magnetohydrodynamics (Fu & Tang, 2019) Section 3.2 + ! Low-Dissipation Targeted ENO Schemes for Ideal Magnetohydrodynamics (Fu & Tang, 2019) Section 3.2 beta(0) = 13._wp/12._wp*(v(-1) - 2._wp*v( 0) + v( 1))**2._wp + (( v(-1) - v( 1))**2._wp)/4._wp + weno_eps !& beta(1) = 13._wp/12._wp*(v( 0) - 2._wp*v( 1) + v( 2))**2._wp + ((3._wp*v( 0) - 4._wp*v( 1) + v( 2))**2._wp)/4._wp + weno_eps !& beta(2) = 13._wp/12._wp*(v(-2) - 2._wp*v(-1) + v( 0))**2._wp + (( v(-2) - 4._wp*v(-1) + 3._wp*v( 0))**2._wp)/4._wp + weno_eps !& @@ -1080,8 +1080,8 @@ contains *(omega(0:weno_num_stencils)/(d_cbL_${XYZ}$ (0:weno_num_stencils, j)**2._wp + omega(0:weno_num_stencils)*(1._wp - 2._wp*d_cbL_${XYZ}$ (0:weno_num_stencils, j)))) elseif (wenoz) then - ! Castro, et al. (2010) - ! Don & Borges (2013) also helps + ! et al. (2010) + ! & Borges (2013) also helps tau = abs(beta(3) - beta(0)) ! Equation 50 $:GPU_LOOP(parallelism='[seq]') do q = 0, weno_num_stencils @@ -1196,17 +1196,17 @@ contains end subroutine s_weno !> The computation of parameters, the allocation of memory, - !! the association of pointers and/or the execution of any - !! other procedures that are required for the setup of the - !! WENO reconstruction. - !! @param v_vf Cell-averaged variables - !! @param vL_vf Left WENO reconstructed cell-boundary values - !! @param vR_vf Right WENO reconstructed cell-boundary values - !! @param norm_dir Characteristic decommposition coordinate direction - !! @param weno_dir Coordinate direction of the WENO reconstruction - !! @param is1_weno Index bounds in first coordinate direction - !! @param is2_weno Index bounds in second coordinate direction - !! @param is3_weno Index bounds in third coordinate direction + !! of pointers and/or the execution of any + !! that are required for the setup of the + !! + !! Cell-averaged variables + !! Left WENO reconstructed cell-boundary values + !! Right WENO reconstructed cell-boundary values + !! Characteristic decommposition coordinate direction + !! Coordinate direction of the WENO reconstruction + !! Index bounds in first coordinate direction + !! Index bounds in second coordinate direction + !! Index bounds in third coordinate direction subroutine s_initialize_weno(v_vf, & weno_dir) @@ -1216,11 +1216,11 @@ contains integer :: j, k, l, q - ! Determining the number of cell-average variables which will be - ! WENO-reconstructed and mapping their indical bounds in the x-, - ! y- and z-directions to those in the s1-, s2- and s3-directions - ! as to reshape the inputted data in the coordinate direction of - ! the WENO reconstruction + ! the number of cell-average variables which will be + ! and mapping their indical bounds in the x-, + ! and z-directions to those in the s1-, s2- and s3-directions + ! to reshape the inputted data in the coordinate direction of + ! WENO reconstruction v_size = ubound(v_vf, 1) $:GPU_UPDATE(device='[v_size]') @@ -1238,7 +1238,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping/Projecting onto Characteristic Fields in y-direction + ! onto Characteristic Fields in y-direction if (n == 0) return if (weno_dir == 2) then @@ -1255,7 +1255,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping/Projecting onto Characteristic Fields in z-direction + ! onto Characteristic Fields in z-direction if (p == 0) return if (weno_dir == 3) then @@ -1275,16 +1275,16 @@ contains end subroutine s_initialize_weno !> The goal of this subroutine is to ensure that the WENO - !! reconstruction is monotonic. The latter is achieved by - !! enforcing monotonicity preserving bounds of Suresh and - !! Huynh (1997). The resulting MPWENO reconstruction, see - !! Balsara and Shu (2000), ensures that the reconstructed - !! values do not reside outside the range spanned by WENO - !! stencil. - !! @param i Equation number - !! @param j First-coordinate cell index - !! @param k Secone-coordinate cell index - !! @param l Thire-coordinate cell index + !! monotonic. The latter is achieved by + !! preserving bounds of Suresh and + !! The resulting MPWENO reconstruction, see + !! Shu (2000), ensures that the reconstructed + !! not reside outside the range spanned by WENO + !! + !! Equation number + !! First-coordinate cell index + !! Secone-coordinate cell index + !! Thire-coordinate cell index subroutine s_preserve_monotonicity(v_rs_ws, vL_rs_vf, vR_rs_vf) real(wp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:), intent(IN) :: v_rs_ws @@ -1295,11 +1295,11 @@ contains real(wp), dimension(-1:1) :: d !< Curvature measures at the zone centers real(wp) :: d_MD, d_LC !< - !! Median (md) curvature and large curvature (LC) measures + !! curvature and large curvature (LC) measures - ! The left and right upper bounds (UL), medians, large curvatures, - ! minima, and maxima of the WENO-reconstructed values of the cell- - ! average variables. + ! left and right upper bounds (UL), medians, large curvatures, + ! and maxima of the WENO-reconstructed values of the cell- + ! variables. real(wp) :: vL_UL, vR_UL real(wp) :: vL_MD, vR_MD real(wp) :: vL_LC, vR_LC @@ -1307,14 +1307,14 @@ contains real(wp) :: vL_max, vR_max real(wp), parameter :: alpha = 2._wp !> - !! Determines the maximum Courant–Friedrichs–Lewy (CFL) number that - !! may be utilized with the scheme. In theory, for stability, a CFL - !! number less than 1/(1+alpha) is necessary. The default value for - !! alpha is 2. + !! maximum Courant–Friedrichs–Lewy (CFL) number that + !! utilized with the scheme. In theory, for stability, a CFL + !! than 1/(1+alpha) is necessary. The default value for + !! 2. real(wp), parameter :: beta = 4._wp/3._wp !< - !! Determines the amount of freedom available from utilizing a large - !! value for the local curvature. The default value for beta is 4/3. + !! amount of freedom available from utilizing a large + !! the local curvature. The default value for beta is 4/3. real(wp), parameter :: alpha_mp = 2._wp real(wp), parameter :: beta_mp = 4._wp/3._wp @@ -1380,9 +1380,9 @@ contains + sign(5.e-1_wp, vL_max - vL_rs_vf(j, k, l, i))) & *min(abs(vL_min - vL_rs_vf(j, k, l, i)), & abs(vL_max - vL_rs_vf(j, k, l, i))) - ! END: Left Monotonicity Preserving Bound + ! Left Monotonicity Preserving Bound - ! Right Monotonicity Preserving Bound + ! Monotonicity Preserving Bound d(-1) = v_rs_ws(j, k, l, i) & + v_rs_ws(j - 2, k, l, i) & - v_rs_ws(j - 1, k, l, i) & @@ -1439,7 +1439,7 @@ contains + sign(5.e-1_wp, vR_max - vR_rs_vf(j, k, l, i))) & *min(abs(vR_min - vR_rs_vf(j, k, l, i)), & abs(vR_max - vR_rs_vf(j, k, l, i))) - ! END: Right Monotonicity Preserving Bound + ! Right Monotonicity Preserving Bound end do end do end do @@ -1453,17 +1453,17 @@ contains if (weno_order == 1) return - ! Deallocating the WENO-stencil of the WENO-reconstructed variables + ! the WENO-stencil of the WENO-reconstructed variables !deallocate(vL_rs_vf_x, vR_rs_vf_x) @:DEALLOCATE(v_rs_ws_x) - ! Deallocating WENO coefficients in x-direction + ! WENO coefficients in x-direction @:DEALLOCATE(poly_coef_cbL_x, poly_coef_cbR_x) @:DEALLOCATE(d_cbL_x, d_cbR_x) @:DEALLOCATE(beta_coef_x) - ! Deallocating WENO coefficients in y-direction + ! WENO coefficients in y-direction if (n == 0) return !deallocate(vL_rs_vf_y, vR_rs_vf_y) @@ -1473,7 +1473,7 @@ contains @:DEALLOCATE(d_cbL_y, d_cbR_y) @:DEALLOCATE(beta_coef_y) - ! Deallocating WENO coefficients in z-direction + ! WENO coefficients in z-direction if (p == 0) return !deallocate(vL_rs_vf_z, vR_rs_vf_z) diff --git a/src/simulation/p_main.fpp b/src/simulation/p_main.fpp index 29cb3b8281..ba3aa3235b 100644 --- a/src/simulation/p_main.fpp +++ b/src/simulation/p_main.fpp @@ -1,17 +1,17 @@ !> -!! @file p_main.f90 -!! @brief Contains program p_main +!! +!! program p_main !> @brief Quasi-conservative, shock- and interface- capturing finite-volume -!! scheme for the multicomponent Navier-Stokes equations. The system -!! is augmented with the relevant advection equations to capture the -!! material interfaces and closed by the stiffened equation of state -!! as well as any required mixture relations. The effects of surface -!! tension are included and modeled through a volume force that acts -!! across the diffuse material interface regions. The implementation -!! specifics of surface tension may be found in the work by Perigaud -!! and Saurel (2005). Note that both viscous and capillarity effects -!! are only available in the volume fraction model. +!! the multicomponent Navier-Stokes equations. The system +!! with the relevant advection equations to capture the +!! and closed by the stiffened equation of state +!! as any required mixture relations. The effects of surface +!! included and modeled through a volume force that acts +!! diffuse material interface regions. The implementation +!! surface tension may be found in the work by Perigaud +!! (2005). Note that both viscous and capillarity effects +!! available in the volume fraction model. program p_main use m_global_parameters !< Definitions of the global parameters @@ -54,7 +54,7 @@ program p_main call s_initialize_gpu_vars() call nvtxEndRange - ! Setting the time-step iterator to the first time-step + ! the time-step iterator to the first time-step if (cfl_dt) then t_step = 0 mytime = t_save*n_start @@ -71,7 +71,7 @@ program p_main call nvtxEndRange ! INIT call nvtxStartRange("SIMULATION-TIME-MARCH") - ! Time-stepping Loop + ! Loop do if (cfl_dt) then diff --git a/toolchain/mfc/cli/docs_gen.py b/toolchain/mfc/cli/docs_gen.py index cf120fc07f..f568476081 100644 --- a/toolchain/mfc/cli/docs_gen.py +++ b/toolchain/mfc/cli/docs_gen.py @@ -5,10 +5,20 @@ in sync with the CLI schema definitions. """ +import re from typing import List from .schema import CLISchema, Command, Argument +def _escape_doxygen(text: str) -> str: + """Escape text for Doxygen markdown (avoid unintended refs/tags).""" + # Escape # followed by a letter (Doxygen interprets as section ref) + text = re.sub(r"#([a-zA-Z])", r"\#\1", text) + # Escape bare that aren't HTML (Doxygen treats as XML tag) + text = re.sub(r"<(?!/?(?:code|b|i|em|strong|br|details|summary|p|ul|li|ol|a|pre|table|tr|td|th|sup|sub|hr)\b)(\w+)>", r"\\<\1>", text) + return text + + def _format_argument_row(arg: Argument) -> str: """Format a single argument as a markdown table row.""" flags = [] @@ -20,8 +30,8 @@ def _format_argument_row(arg: Argument) -> str: # Format default value default_str = _format_default(arg.default) - # Escape pipes in help text - help_text = arg.help.replace("|", "\\|") + # Escape pipes and Doxygen-sensitive patterns in help text + help_text = _escape_doxygen(arg.help).replace("|", "\\|") return f"| {flag_str} | {help_text} | {default_str} |" @@ -128,7 +138,7 @@ def _generate_command_section(cmd: Command, schema: CLISchema) -> List[str]: lines = [] # Command header (no alias in heading to keep anchor simple) - lines.append(f"### {cmd.name}") + lines.append(f"### {cmd.name} {{#{cmd.name}}}") lines.append("") # Alias note if present @@ -234,7 +244,7 @@ def generate_cli_reference(schema: CLISchema) -> str: # Command categories core_commands = ["build", "run", "test", "clean", "validate"] utility_commands = ["new", "params", "packer", "completion", "generate", "help"] - dev_commands = ["lint", "format", "spelling", "count", "count_diff"] + dev_commands = ["lint", "format", "spelling", "precheck", "count", "count_diff"] ci_commands = ["bench", "bench_diff"] other_commands = ["load", "interactive"] diff --git a/toolchain/mfc/gen_case_constraints_docs.py b/toolchain/mfc/gen_case_constraints_docs.py index 982c50da01..d2398673ba 100644 --- a/toolchain/mfc/gen_case_constraints_docs.py +++ b/toolchain/mfc/gen_case_constraints_docs.py @@ -282,22 +282,22 @@ def render_playbook_card(entry: PlaybookEntry, summary: Dict[str, Any]) -> str: # Links lines.append("\n**Related Documentation:**") - lines.append(f"- [Model Equations (model_eqns = {summary['model_eqns']})](#-model-equations)") + lines.append(f"- [Model Equations (model_eqns = {summary['model_eqns']})](#model-equations)") if summary['riemann_solver']: - lines.append("- [Riemann Solvers](#️-riemann-solvers)") + lines.append("- [Riemann Solvers](#riemann-solvers)") if summary['bubbles_euler'] or summary['bubbles_lagrange']: - lines.append("- [Bubble Models](#-bubble-models)") + lines.append("- [Bubble Models](#bubble-models)") if summary['mhd']: - lines.append("- [MHD](#magnetohydrodynamics-mhd-mhd)") + lines.append("- [MHD](#compat-physics-models)") if summary['ib']: - lines.append("- [Immersed Boundaries](#immersed-boundaries-ib)") + lines.append("- [Immersed Boundaries](#compat-geometry)") if summary['viscous']: - lines.append("- [Viscosity](#viscosity-viscous)") + lines.append("- [Viscosity](#compat-physics-models)") lines.append("\n
\n") return "\n".join(lines) @@ -310,7 +310,7 @@ def generate_playbook() -> str: # Validate examples - will exit(1) if any are missing validate_playbook_examples() - lines.append("## 🧩 Case Design Playbook\n") + lines.append("## 🧩 Case Design Playbook {#case-design-playbook}\n") lines.append( "> **Learn by example:** The cases below are curated from MFC's `examples/` " "directory and are validated, working configurations. " @@ -382,7 +382,7 @@ def render_markdown(rules: Iterable[Rule]) -> str: # pylint: disable=too-many-l } # 1. Quick Start: Common Configurations - lines.append("## 🚀 Common Configuration Patterns\n") + lines.append("## 🚀 Common Configuration Patterns {#common-configuration-patterns}\n") lines.append("Start with these proven combinations:\n") lines.append("") lines.append("
") @@ -426,11 +426,12 @@ def render_markdown(rules: Iterable[Rule]) -> str: # pylint: disable=too-many-l lines.append("
\n") # 2. Feature Compatibility Matrix (simplified, no IGR column) - lines.append("## 📊 Feature Compatibility\n") + lines.append("## 📊 Feature Compatibility {#feature-compatibility}\n") lines.append("What works together:\n") for category, features in major_features.items(): # pylint: disable=too-many-nested-blocks - lines.append(f"\n### {category}\n") + cat_id = "compat-" + category.lower().replace(" ", "-") + lines.append(f"\n### {category} {{#{cat_id}}}\n") # Build compatibility info (exclude IGR from incompatibilities) compat_info = {} @@ -492,7 +493,7 @@ def render_markdown(rules: Iterable[Rule]) -> str: # pylint: disable=too-many-l lines.append("") # 3. Model Equations (data-driven from schema) - lines.append("## 🔢 Model Equations\n") + lines.append("## 🔢 Model Equations {#model-equations}\n") lines.append("Choose your governing equations:\n") lines.append("") @@ -561,7 +562,7 @@ def _format_model_requirements(val: int) -> str: 5: {"best_for": "Robust fallback", "requirements": "Not with cylindrical+viscous"}, } - lines.append("## ⚙️ Riemann Solvers\n") + lines.append("## ⚙️ Riemann Solvers {#riemann-solvers}\n") lines.append("| Solver | `riemann_solver` | Best For | Requirements |") lines.append("|--------|-----------------|----------|-------------|") @@ -577,7 +578,7 @@ def _format_model_requirements(val: int) -> str: # 5. Bubble Models (data-driven from schema dependencies + curated notes) if "bubbles_euler" in by_param or "bubbles_lagrange" in by_param: - lines.append("## 💧 Bubble Models\n") + lines.append("## 💧 Bubble Models {#bubble-models}\n") lines.append("") # Euler-Euler: inject schema dependency info (data-driven) @@ -618,7 +619,7 @@ def _format_model_requirements(val: int) -> str: lines.append("
\n") # 6. Condensed Parameter Reference (auto-collected from schema) - lines.append("## 📖 Quick Parameter Reference\n") + lines.append("## 📖 Quick Parameter Reference {#quick-parameter-reference}\n") lines.append("Key parameters and their constraints:\n") # Auto-collect all params that have CONSTRAINTS or DEPENDENCIES entries diff --git a/toolchain/mfc/lint_docs.py b/toolchain/mfc/lint_docs.py index c5e49753e2..783ac22c66 100644 --- a/toolchain/mfc/lint_docs.py +++ b/toolchain/mfc/lint_docs.py @@ -72,7 +72,10 @@ def check_docs(repo_root: Path) -> list[str]: # Strip trailing punctuation that may have leaked in path_str = path_str.rstrip(".,;:!?") if not (repo_root / path_str).exists(): - errors.append(f" {doc} references '{path_str}' but it does not exist") + errors.append( + f" {doc} references '{path_str}' but it does not exist." + " Fix: update the path or remove the reference" + ) return errors @@ -101,7 +104,10 @@ def check_cite_keys(repo_root: Path) -> list[str]: for match in CITE_RE.finditer(text): key = match.group(1) if key.lower() not in valid_keys: - errors.append(f" {rel} uses \\cite {key} but no bib entry found") + errors.append( + f" {rel} uses \\cite {key} but no bib entry found." + " Fix: add entry to docs/references.bib or fix the key" + ) return errors @@ -196,7 +202,115 @@ def check_param_refs(repo_root: Path) -> list[str]: # pylint: disable=too-many- # Normalize %% to % for lookup normalized = param.replace("%%", "%") if not _is_valid_param(normalized, valid_params, sub_params): - errors.append(f" {doc_rel} references parameter '{param}' not in REGISTRY") + errors.append( + f" {doc_rel} references parameter '{param}' not in REGISTRY." + " Fix: check spelling or add to definitions.py" + ) + + return errors + + +def check_math_syntax(repo_root: Path) -> list[str]: + """Check that docs use Doxygen math syntax (\\f$, \\f[) not raw $$/$.""" + doc_dir = repo_root / "docs" / "documentation" + if not doc_dir.exists(): + return [] + + errors = [] + for md_file in sorted(doc_dir.glob("*.md")): + text = md_file.read_text(encoding="utf-8") + rel = md_file.relative_to(repo_root) + in_code = False + + for i, line in enumerate(text.split("\n"), 1): + if line.strip().startswith("```"): + in_code = not in_code + continue + if in_code: + continue + + # Strip inline code and Doxygen math before checking + cleaned = re.sub(r"`[^`\n]+`", "", line) + cleaned = re.sub(r"\\f\$.*?\\f\$", "", cleaned) + cleaned = re.sub(r"\\f\[.*?\\f\]", "", cleaned) + + if "$$" in cleaned: + errors.append( + f" {rel}:{i} uses $$...$$ display math." + " Fix: replace $$ with \\f[ and \\f]" + ) + continue + + for m in re.finditer(r"\$([^$\n]+?)\$", cleaned): + if re.search(r"\\[a-zA-Z]", m.group(1)): + errors.append( + f" {rel}:{i} uses $...$ with LaTeX commands." + " Fix: replace $ delimiters with \\f$ and \\f$" + ) + break # one error per line + + return errors + + +def _gitignored_docs(repo_root: Path) -> set[str]: + """Return set of gitignored doc file basenames.""" + import subprocess # pylint: disable=import-outside-toplevel + + doc_dir = repo_root / "docs" / "documentation" + try: + result = subprocess.run( + ["git", "ls-files", "--ignored", "--exclude-standard", "-o"], + capture_output=True, text=True, cwd=repo_root, check=False, + ) + return { + Path(f).name for f in result.stdout.splitlines() + if f.startswith(str(doc_dir.relative_to(repo_root))) + } + except FileNotFoundError: + return set() + + +def check_section_anchors(repo_root: Path) -> list[str]: + """Check that markdown ](#id) links have matching {#id} definitions.""" + doc_dir = repo_root / "docs" / "documentation" + if not doc_dir.exists(): + return [] + + ignored = _gitignored_docs(repo_root) + + errors = [] + for md_file in sorted(doc_dir.glob("*.md")): + if md_file.name in ignored: + continue + text = md_file.read_text(encoding="utf-8") + rel = md_file.relative_to(repo_root) + + # Collect all {#id} anchors (outside code blocks) + anchors = set() + in_code = False + for line in text.split("\n"): + if line.strip().startswith("```"): + in_code = not in_code + continue + if not in_code: + anchors.update(re.findall(r"\{#([\w-]+)\}", line)) + + # Check all ](#id) links + in_code = False + for i, line in enumerate(text.split("\n"), 1): + if line.strip().startswith("```"): + in_code = not in_code + continue + if in_code: + continue + for m in re.finditer(r"\]\(#([\w-]+)\)", line): + if m.group(1) not in anchors: + errors.append( + f" {rel}:{i} links to #{m.group(1)}" + f" but no {{#{m.group(1)}}} anchor exists." + f" Fix: add {{#{m.group(1)}}} to the target" + " section header" + ) return errors @@ -222,7 +336,10 @@ def check_page_refs(repo_root: Path) -> list[str]: for match in REF_RE.finditer(text): ref_target = match.group(1) if ref_target not in page_ids: - errors.append(f" {rel} uses @ref {ref_target} but no @page with that ID exists") + errors.append( + f" {rel} uses @ref {ref_target} but no @page with that ID exists." + " Fix: check the page ID or add @page declaration" + ) return errors @@ -235,6 +352,8 @@ def main(): all_errors.extend(check_cite_keys(repo_root)) all_errors.extend(check_param_refs(repo_root)) all_errors.extend(check_page_refs(repo_root)) + all_errors.extend(check_math_syntax(repo_root)) + all_errors.extend(check_section_anchors(repo_root)) if all_errors: print("Doc reference check failed:") diff --git a/toolchain/mfc/params/generators/docs_gen.py b/toolchain/mfc/params/generators/docs_gen.py index e26c42a50c..b982de610a 100644 --- a/toolchain/mfc/params/generators/docs_gen.py +++ b/toolchain/mfc/params/generators/docs_gen.py @@ -421,7 +421,7 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man # Document each family for family, params in sorted_families: - lines.append(f"## {family}") + lines.append(f"## {family} {{#{family}}}") lines.append("") desc = family_descriptions.get(family, "") From e04506b91c2f2cc4925343ad35e249e3a9a95d3c Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 13:04:13 -0500 Subject: [PATCH 7/8] Remove duplicate References page, link directly to Bibliography The manual references.md page just redirected to the auto-generated Bibliography (citelist). Remove it and point the sidebar link directly to \ref citelist to avoid two near-identical sidebar entries. Co-Authored-By: Claude Opus 4.6 --- docs/documentation/readme.md | 2 +- docs/documentation/references.md | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 docs/documentation/references.md diff --git a/docs/documentation/readme.md b/docs/documentation/readme.md index d72395cae0..83673ed81e 100644 --- a/docs/documentation/readme.md +++ b/docs/documentation/readme.md @@ -35,5 +35,5 @@ Welcome to the Multi-component Flow Code (MFC) documentation. ## About - @ref papers "Papers" - Publications using MFC -- @ref references "References" - Bibliography +- \ref citelist "Bibliography" - Cited references - @ref authors "Authors" - Contributors diff --git a/docs/documentation/references.md b/docs/documentation/references.md deleted file mode 100644 index 7a9f1cfe6c..0000000000 --- a/docs/documentation/references.md +++ /dev/null @@ -1,7 +0,0 @@ -@page references References - -# References - -All references cited throughout the MFC documentation are managed via BibTeX and rendered automatically by Doxygen. - -See the \ref citelist "Bibliography" for the full list of cited works. From f362a790c9660cc7332c7774775cf0320f2cb16a Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Fri, 13 Feb 2026 14:26:25 -0500 Subject: [PATCH 8/8] Redo Fortran source doc fixes without comment mangling Previous commit used an overly broad regex that stripped @param, @brief, and first words from comments across all .fpp files. Restore all source files from master and re-apply only: - Remove filename args from @file directives (58 files) - Convert raw $...$ math to \f$...\f$ in m_riemann_solvers.fpp - Add @cond/@endcond for #ifdef blocks with vendor attributes - Fix stale @param name in m_data_input.f90 Co-Authored-By: Claude Opus 4.6 --- src/common/include/1dHardcodedIC.fpp | 18 +- src/common/include/2dHardcodedIC.fpp | 122 +-- src/common/include/3dHardcodedIC.fpp | 16 +- src/common/include/ExtrusionHardcodedIC.fpp | 18 +- src/common/include/acc_macros.fpp | 2 +- src/common/include/case.fpp | 10 +- src/common/include/macros.fpp | 28 +- src/common/include/omp_macros.fpp | 2 +- src/common/include/parallel_macros.fpp | 2 +- src/common/include/shared_parallel_macros.fpp | 2 +- src/common/m_boundary_common.fpp | 74 +- src/common/m_checker_common.fpp | 4 +- src/common/m_chemistry.fpp | 70 +- src/common/m_compile_specific.f90 | 2 +- src/common/m_compute_levelset.fpp | 42 +- src/common/m_constants.fpp | 42 +- src/common/m_derived_types.fpp | 118 +-- src/common/m_finite_differences.fpp | 24 +- src/common/m_helper.fpp | 170 ++-- src/common/m_helper_basic.fpp | 54 +- src/common/m_ib_patches.fpp | 348 ++++--- src/common/m_model.fpp | 240 ++--- src/common/m_mpi_common.fpp | 434 ++++----- src/common/m_phase_change.fpp | 352 +++---- src/common/m_variables_conversion.fpp | 300 +++--- src/post_process/m_checker.fpp | 2 +- src/post_process/m_data_input.f90 | 3 +- src/post_process/m_data_output.fpp | 522 +++++----- src/post_process/m_derived_variables.fpp | 322 +++---- src/post_process/m_global_parameters.fpp | 234 ++--- src/post_process/m_mpi_proxy.fpp | 140 +-- src/post_process/m_start_up.fpp | 180 ++-- src/post_process/p_main.fpp | 50 +- src/pre_process/m_assign_variables.fpp | 220 ++--- src/pre_process/m_boundary_conditions.fpp | 20 +- src/pre_process/m_check_ib_patches.fpp | 66 +- src/pre_process/m_check_patches.fpp | 74 +- src/pre_process/m_checker.fpp | 2 +- src/pre_process/m_data_output.fpp | 164 ++-- src/pre_process/m_global_parameters.fpp | 222 ++--- src/pre_process/m_grid.f90 | 2 +- src/pre_process/m_icpp_patches.fpp | 700 +++++++------- src/pre_process/m_initial_condition.fpp | 103 +- src/pre_process/m_mpi_proxy.fpp | 32 +- src/pre_process/m_perturbation.fpp | 62 +- src/pre_process/m_start_up.fpp | 304 +++--- src/pre_process/p_main.f90 | 2 +- src/simulation/include/inline_riemann.fpp | 8 +- src/simulation/m_acoustic_src.fpp | 156 +-- src/simulation/m_body_forces.fpp | 22 +- src/simulation/m_bubbles.fpp | 431 +++++---- src/simulation/m_bubbles_EE.fpp | 26 +- src/simulation/m_bubbles_EL.fpp | 240 ++--- src/simulation/m_bubbles_EL_kernels.fpp | 62 +- src/simulation/m_cbc.fpp | 284 +++--- src/simulation/m_checker.fpp | 4 +- src/simulation/m_compute_cbc.fpp | 12 +- src/simulation/m_data_output.fpp | 230 ++--- src/simulation/m_derived_variables.fpp | 128 +-- src/simulation/m_fftw.fpp | 40 +- src/simulation/m_global_parameters.fpp | 266 +++--- src/simulation/m_hyperelastic.fpp | 130 +-- src/simulation/m_hypoelastic.fpp | 36 +- src/simulation/m_ibm.fpp | 198 ++-- src/simulation/m_igr.fpp | 6 +- src/simulation/m_mpi_proxy.fpp | 52 +- src/simulation/m_muscl.fpp | 42 +- src/simulation/m_pressure_relaxation.fpp | 32 +- src/simulation/m_qbmm.fpp | 62 +- src/simulation/m_rhs.fpp | 174 ++-- src/simulation/m_riemann_solvers.fpp | 900 +++++++++--------- src/simulation/m_sim_helpers.fpp | 94 +- src/simulation/m_start_up.fpp | 216 ++--- src/simulation/m_surface_tension.fpp | 8 +- src/simulation/m_time_steppers.fpp | 125 +-- src/simulation/m_viscous.fpp | 120 +-- src/simulation/m_weno.fpp | 272 +++--- src/simulation/p_main.fpp | 26 +- 78 files changed, 5149 insertions(+), 5173 deletions(-) diff --git a/src/common/include/1dHardcodedIC.fpp b/src/common/include/1dHardcodedIC.fpp index 83784a1fa5..4359528a3f 100644 --- a/src/common/include/1dHardcodedIC.fpp +++ b/src/common/include/1dHardcodedIC.fpp @@ -1,37 +1,37 @@ #:def Hardcoded1DVariables() - ! any declaration of intermediate variables here + ! Place any declaration of intermediate variables here real(wp) :: x_mid_diffu, width_sq, profile_shape, temp, molar_mass_inv, y1, y2, y3, y4 #:enddef #:def Hardcoded1D() select case (patch_icpp(patch_id)%hcid) case (150) ! 1D Smooth Alfven Case for MHD - ! + ! velocity q_prim_vf(momxb + 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i)) q_prim_vf(momxb + 2)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i)) - ! field + ! magnetic field q_prim_vf(B_idx%end - 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i)) q_prim_vf(B_idx%end)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i)) case (170) - ! hardcoded case can be used to start a simulation with initial conditions given from a known 1D profile (e.g. Cantera, SDtoolbox) + ! This hardcoded case can be used to start a simulation with initial conditions given from a known 1D profile (e.g. Cantera, SDtoolbox) @: HardcodedReadValues() case (180) - ! is patch is hard-coded for test suite optimization used in the - ! cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.2*sin(5*x)" + ! This is patch is hard-coded for test suite optimization used in the + ! 1D_shuoser cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.2*sin(5*x)" if (patch_id == 2) then q_prim_vf(contxb + 0)%sf(i, 0, 0) = 1 + 0.2*sin(5*x_cc(i)) end if case (181) - ! is patch is hard-coded for test suite optimization used in the - ! cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.1*sin(20*x*pi)" + ! This is patch is hard-coded for test suite optimization used in the + ! 1D_titarevtorro cases: "patch_icpp(2)%alpha_rho(1)": "1 + 0.1*sin(20*x*pi)" q_prim_vf(contxb + 0)%sf(i, 0, 0) = 1 + 0.1*sin(20*x_cc(i)*pi) case (182) - ! patch is a hard-coded for test suite optimization (multiple component diffusion) + ! This patch is a hard-coded for test suite optimization (multiple component diffusion) x_mid_diffu = 0.05_wp/2.0_wp width_sq = (2.5_wp*10.0_wp**(-3.0_wp))**2 profile_shape = 1.0_wp - 0.5_wp*exp(-(x_cc(i) - x_mid_diffu)**2/width_sq) diff --git a/src/common/include/2dHardcodedIC.fpp b/src/common/include/2dHardcodedIC.fpp index 40136e823d..a35633bca1 100644 --- a/src/common/include/2dHardcodedIC.fpp +++ b/src/common/include/2dHardcodedIC.fpp @@ -1,5 +1,5 @@ #:def Hardcoded2DVariables() - ! any declaration of intermediate variables here + ! Place any declaration of intermediate variables here real(wp) :: eps, eps_mhd, C_mhd real(wp) :: r, rmax, gam, umax, p0 real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, intL, alph @@ -9,9 +9,9 @@ real(wp) :: r_sq - ! 207 + ! # 207 real(wp) :: sigma, gauss1, gauss2 - ! 208 + ! # 208 real(wp) :: ei, d, fsm, alpha_air, alpha_sf6 eps = 1.e-9_wp @@ -23,13 +23,13 @@ case (200) if (y_cc(j) <= (-x_cc(i)**3 + 1)**(1._wp/3._wp)) then - ! Fractions + ! Volume Fractions q_prim_vf(advxb)%sf(i, j, 0) = eps q_prim_vf(advxe)%sf(i, j, 0) = 1._wp - eps - ! + ! Denssities q_prim_vf(contxb)%sf(i, j, 0) = eps*1000._wp q_prim_vf(contxe)%sf(i, j, 0) = (1._wp - eps)*1._wp - ! + ! Pressure q_prim_vf(E_idx)%sf(i, j, 0) = 1000._wp end if case (202) ! Gresho vortex (Gouasmi et al 2022 JCP) @@ -149,7 +149,7 @@ lam = 1.0_wp eps = 1.0e-6_wp ei = 5.0_wp - ! function to smooth out sharp discontinuity in the interface + ! Smoothening function to smooth out sharp discontinuity in the interface if (x_cc(i) <= 0.7_wp*lam) then d = x_cc(i) - lam*(0.4_wp - 0.1_wp*sin(2.0_wp*pi*(y_cc(j)/lam + 0.25_wp))) fsm = 0.5_wp*(1.0_wp + erf(d/(ei*sqrt(dx*dy)))) @@ -162,11 +162,11 @@ end if case (250) ! MHD Orszag-Tang vortex - ! = 5/3 - ! = 25/(36*pi) - ! = 5/(12*pi) - ! = (-sin(2*pi*y), sin(2*pi*x), 0) - ! = (-sin(2*pi*y)/sqrt(4*pi), sin(4*pi*x)/sqrt(4*pi), 0) + ! gamma = 5/3 + ! rho = 25/(36*pi) + ! p = 5/(12*pi) + ! v = (-sin(2*pi*y), sin(2*pi*x), 0) + ! B = (-sin(2*pi*y)/sqrt(4*pi), sin(4*pi*x)/sqrt(4*pi), 0) q_prim_vf(momxb)%sf(i, j, 0) = -sin(2._wp*pi*y_cc(j)) q_prim_vf(momxb + 1)%sf(i, j, 0) = sin(2._wp*pi*x_cc(i)) @@ -179,7 +179,7 @@ q_prim_vf(contxb)%sf(i, j, 0) = 0.01 q_prim_vf(E_idx)%sf(i, j, 0) = 1.0 elseif (x_cc(i)**2 + y_cc(j)**2 <= 1._wp**2) then - ! interpolation between r=0.08 and r=1.0 + ! Linear interpolation between r=0.08 and r=1.0 factor = (1.0_wp - sqrt(x_cc(i)**2 + y_cc(j)**2))/(1.0_wp - 0.08_wp) q_prim_vf(contxb)%sf(i, j, 0) = 0.01_wp*factor + 1.e-4_wp*(1.0_wp - factor) q_prim_vf(E_idx)%sf(i, j, 0) = 1.0_wp*factor + 3.e-5_wp*(1.0_wp - factor) @@ -188,36 +188,36 @@ q_prim_vf(E_idx)%sf(i, j, 0) = 3.e-5_wp end if - ! 252 is for the 2D MHD Rotor problem + ! case 252 is for the 2D MHD Rotor problem case (252) ! 2D MHD Rotor Problem - ! conditions are set in the JSON file. - ! case imposes the dense, rotating cylinder. + ! Ambient conditions are set in the JSON file. + ! This case imposes the dense, rotating cylinder. ! - ! = 1.4 - ! medium (r > 0.1): - ! = 1, p = 1, v = 0, B = (1,0,0) - ! (r <= 0.1): - ! = 10, p = 1 - ! has angular velocity w=20, giving v_tan=2 at r=0.1 - - ! distance squared from the center + ! gamma = 1.4 + ! Ambient medium (r > 0.1): + ! rho = 1, p = 1, v = 0, B = (1,0,0) + ! Rotor (r <= 0.1): + ! rho = 10, p = 1 + ! v has angular velocity w=20, giving v_tan=2 at r=0.1 + + ! Calculate distance squared from the center r_sq = (x_cc(i) - 0.5_wp)**2 + (y_cc(j) - 0.5_wp)**2 - ! radius of 0.1 + ! inner radius of 0.1 if (r_sq <= 0.1**2) then - ! Inside the rotor -- - ! density uniformly to 10 + ! -- Inside the rotor -- + ! Set density uniformly to 10 q_prim_vf(contxb)%sf(i, j, 0) = 10._wp - ! vup constant rotation of rate v=2 - ! = -omega * (y - y_c) - ! = omega * (x - x_c) + ! Set vup constant rotation of rate v=2 + ! v_x = -omega * (y - y_c) + ! v_y = omega * (x - x_c) q_prim_vf(momxb)%sf(i, j, 0) = -20._wp*(y_cc(j) - 0.5_wp) q_prim_vf(momxb + 1)%sf(i, j, 0) = 20._wp*(x_cc(i) - 0.5_wp) - ! width of 0.015 + ! taper width of 0.015 else if (r_sq <= 0.115**2) then - ! smooth the function between r = 0.1 and 0.115 + ! linearly smooth the function between r = 0.1 and 0.115 q_prim_vf(contxb)%sf(i, j, 0) = 1._wp + 9._wp*(0.115_wp - sqrt(r_sq))/(0.015_wp) q_prim_vf(momxb)%sf(i, j, 0) = -(2._wp/sqrt(r_sq))*(y_cc(j) - 0.5_wp)*(0.115_wp - sqrt(r_sq))/(0.015_wp) @@ -225,32 +225,32 @@ end if case (253) ! MHD Smooth Magnetic Vortex - ! 5.2 of - ! hybridized discontinuous Galerkin methods for compressible magnetohydrodynamics - ! Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire + ! Section 5.2 of + ! Implicit hybridized discontinuous Galerkin methods for compressible magnetohydrodynamics + ! C. Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire - ! + ! velocity q_prim_vf(momxb)%sf(i, j, 0) = 1._wp - (y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)) q_prim_vf(momxb + 1)%sf(i, j, 0) = 1._wp + (x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)) - ! field + ! magnetic field q_prim_vf(B_idx%beg)%sf(i, j, 0) = -y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi) q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi) - ! + ! pressure q_prim_vf(E_idx)%sf(i, j, 0) = 1._wp + (1 - 2._wp*(x_cc(i)**2 + y_cc(j)**2))*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/((2._wp*pi)**3) case (260) ! Gaussian Divergence Pulse - ! = 1 + C * erf((x-0.5)/σ) - ! ∂Bx/∂x = C * (2/√π) * exp[-((x-0.5)/σ)**2] * (1/σ) - ! C = ε * σ * √π / 2 ⇒ ∂Bx/∂x = ε * exp[-((x-0.5)/σ)**2] - ! is initialized to zero everywhere. + ! Bx(x) = 1 + C * erf((x-0.5)/σ) + ! ⇒ ∂Bx/∂x = C * (2/√π) * exp[-((x-0.5)/σ)**2] * (1/σ) + ! Choose C = ε * σ * √π / 2 ⇒ ∂Bx/∂x = ε * exp[-((x-0.5)/σ)**2] + ! ψ is initialized to zero everywhere. eps_mhd = patch_icpp(patch_id)%a(2) sigma = patch_icpp(patch_id)%a(3) C_mhd = eps_mhd*sigma*sqrt(pi)*0.5_wp - ! + ! B-field q_prim_vf(B_idx%beg)%sf(i, j, 0) = 1._wp + C_mhd*erf((x_cc(i) - 0.5_wp)/sigma) case (261) ! Blob @@ -260,21 +260,21 @@ alpha = r/r0 if (alpha < 1) then q_prim_vf(B_idx%beg)%sf(i, j, 0) = 1._wp/sqrt(4._wp*pi)*(alpha**8 - 2._wp*alpha**4 + 1._wp) - ! = 1._wp/sqrt(4000._wp*pi) * (4096._wp*r2**4 - 128._wp*r2**2 + 1._wp) - ! = 1._wp/(4._wp*pi) * (alpha**8 - 2._wp*alpha**4 + 1._wp) - ! = 6._wp - q_prim_vf(B_idx%beg)%sf(i,j,0)**2/2._wp + ! q_prim_vf(B_idx%beg)%sf(i,j,0) = 1._wp/sqrt(4000._wp*pi) * (4096._wp*r2**4 - 128._wp*r2**2 + 1._wp) + ! q_prim_vf(B_idx%beg)%sf(i,j,0) = 1._wp/(4._wp*pi) * (alpha**8 - 2._wp*alpha**4 + 1._wp) + ! q_prim_vf(E_idx)%sf(i,j,0) = 6._wp - q_prim_vf(B_idx%beg)%sf(i,j,0)**2/2._wp end if case (262) ! Tilted 2D MHD shock‐tube at α = arctan2 (≈63.4°) - ! by α = atan(2) + ! rotate by α = atan(2) alpha = atan(2._wp) cosA = cos(alpha) sinA = sin(alpha) - ! along shock normal + ! projection along shock normal r = x_cc(i)*cosA + y_cc(j)*sinA if (r <= 0.5_wp) then - ! state: ρ=1, v∥=+10, v⊥=0, p=20, B∥=B⊥=5/√(4π) + ! LEFT state: ρ=1, v∥=+10, v⊥=0, p=20, B∥=B⊥=5/√(4π) q_prim_vf(contxb)%sf(i, j, 0) = 1._wp q_prim_vf(momxb)%sf(i, j, 0) = 10._wp*cosA q_prim_vf(momxb + 1)%sf(i, j, 0) = 10._wp*sinA @@ -284,7 +284,7 @@ q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = (5._wp/sqrt(4._wp*pi))*sinA & + (5._wp/sqrt(4._wp*pi))*cosA else - ! state: ρ=1, v∥=−10, v⊥=0, p=1, B∥=B⊥=5/√(4π) + ! RIGHT state: ρ=1, v∥=−10, v⊥=0, p=1, B∥=B⊥=5/√(4π) q_prim_vf(contxb)%sf(i, j, 0) = 1._wp q_prim_vf(momxb)%sf(i, j, 0) = -10._wp*cosA q_prim_vf(momxb + 1)%sf(i, j, 0) = -10._wp*sinA @@ -294,16 +294,16 @@ q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = (5._wp/sqrt(4._wp*pi))*sinA & + (5._wp/sqrt(4._wp*pi))*cosA end if - ! and B^z remain zero by default + ! v^z and B^z remain zero by default case (270) - ! hardcoded case extrudes a 1D profile to initialize a 2D simulation domain + ! This hardcoded case extrudes a 1D profile to initialize a 2D simulation domain @: HardcodedReadValues() case (280) - ! is patch is hard-coded for test suite optimization used in the - ! case: - ! analytic patch uses geometry 2 + ! This is patch is hard-coded for test suite optimization used in the + ! 2D_isentropicvortex case: + ! This analytic patch uses geometry 2 if (patch_id == 1) then q_prim_vf(E_idx)%sf(i, j, 0) = 1.0*(1.0 - (1.0/1.0)*(5.0/(2.0*pi))*(5.0/(8.0*1.0*(1.4 + 1.0)*pi))*exp(2.0*1.0*(1.0 - (x_cc(i) - patch_icpp(1)%x_centroid)**2.0 - (y_cc(j) - patch_icpp(1)%y_centroid)**2.0)))**(1.4 + 1.0) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1.0*(1.0 - (1.0/1.0)*(5.0/(2.0*pi))*(5.0/(8.0*1.0*(1.4 + 1.0)*pi))*exp(2.0*1.0*(1.0 - (x_cc(i) - patch_icpp(1)%x_centroid)**2.0 - (y_cc(j) - patch_icpp(1)%y_centroid)**2.0)))**1.4 @@ -312,18 +312,18 @@ end if case (281) - ! is patch is hard-coded for test suite optimization used in the - ! case: - ! analytic patch uses geometry 2 + ! This is patch is hard-coded for test suite optimization used in the + ! 2D_acoustic_pulse case: + ! This analytic patch uses geometry 2 if (patch_id == 2) then q_prim_vf(E_idx)%sf(i, j, 0) = 101325*(1 - 0.5*(1.4 - 1)*(0.4)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1.4/(1.4 - 1)) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1*(1 - 0.5*(1.4 - 1)*(0.4)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1/(1.4 - 1)) end if case (282) - ! is patch is hard-coded for test suite optimization used in the - ! case: - ! analytic patch uses geometry 2 + ! This is patch is hard-coded for test suite optimization used in the + ! 2D_zero_circ_vortex case: + ! This analytic patch uses geometry 2 if (patch_id == 2) then q_prim_vf(E_idx)%sf(i, j, 0) = 101325*(1 - 0.5*(1.4 - 1)*(0.1/0.3)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1.4/(1.4 - 1)) q_prim_vf(contxb + 0)%sf(i, j, 0) = 1*(1 - 0.5*(1.4 - 1)*(0.1/0.3)**2*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2))))**(1/(1.4 - 1)) diff --git a/src/common/include/3dHardcodedIC.fpp b/src/common/include/3dHardcodedIC.fpp index 1844efd3ac..40d5f03ad3 100644 --- a/src/common/include/3dHardcodedIC.fpp +++ b/src/common/include/3dHardcodedIC.fpp @@ -1,12 +1,12 @@ #:def Hardcoded3DVariables() - ! any declaration of intermediate variables here + ! Place any declaration of intermediate variables here real(wp) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, alph, Mach real(wp) :: eps - ! Jets - ! to stor position and radii of jets from input file + ! IGR Jets + ! Arrays to stor position and radii of jets from input file real(wp), dimension(:), allocatable :: y_th_arr, z_th_arr, r_th_arr - ! to describe initial condition of jet + ! Variables to describe initial condition of jet real(wp) :: r, ux_th, ux_am, p_th, p_am, rho_th, rho_am, y_th, z_th, r_th, eps_smooth real(wp) :: rcut, xcut ! Intermediate variables for creating smooth initial condition @@ -175,13 +175,13 @@ q_prim_vf(E_idx)%sf(i, j, k) = p_th*rcut*xcut + p_am case (370) - ! hardcoded case extrudes a 2D profile to initialize a 3D simulation domain + ! This hardcoded case extrudes a 2D profile to initialize a 3D simulation domain @: HardcodedReadValues() case (380) - ! is patch is hard-coded for test suite optimization used in the - ! case: - ! analytic patch used geometry 9 + ! This is patch is hard-coded for test suite optimization used in the + ! 3D_TaylorGreenVortex case: + ! This analytic patch used geometry 9 Mach = 0.1 if (patch_id == 1) then q_prim_vf(E_idx)%sf(i, j, k) = 101325 + (Mach**2*376.636429464809**2/16)*(cos(2*x_cc(i)/1) + cos(2*y_cc(j)/1))*(cos(2*z_cc(k)/1) + 2) diff --git a/src/common/include/ExtrusionHardcodedIC.fpp b/src/common/include/ExtrusionHardcodedIC.fpp index 4391c34b88..264b227f21 100644 --- a/src/common/include/ExtrusionHardcodedIC.fpp +++ b/src/common/include/ExtrusionHardcodedIC.fpp @@ -63,13 +63,13 @@ fileNames(f) = trim(init_dir)//"prim."//trim(file_num_str)//".00."//zeros_default//".dat" end do - ! file reading setup + ! Common file reading setup open (newunit=unit2, file=trim(fileNames(1)), status='old', action='read', iostat=ios2) if (ios2 /= 0) call s_mpi_abort("Error opening file: "//trim(fileNames(1))) select case (num_dims) case (1, 2) ! 1D and 2D cases are similar - ! lines + ! Count lines line_count = 0 do read (unit2, *, iostat=ios2) dummy_x, dummy_y @@ -84,7 +84,7 @@ if (num_dims == 2) index_x = i @:ALLOCATE (x_coords(xRows), stored_values(xRows, 1, sys_size)) - ! data from all files + ! Read data from all files do f = 1, max_files open (newunit=unit, file=trim(fileNames(f)), status='old', action='read', iostat=ios) if (ios /= 0) call s_mpi_abort("Error opening file: "//trim(fileNames(f))) @@ -96,7 +96,7 @@ close (unit) end do - ! offsets + ! Calculate offsets domain_xstart = x_coords(1) x_step = x_cc(1) - x_cc(0) delta_x = merge(x_cc(0) - domain_xstart + x_step/2.0, & @@ -104,7 +104,7 @@ global_offset_x = nint(abs(delta_x)/x_step) case (3) ! 3D case - determine grid structure - ! yRows by counting rows with same x + ! Find yRows by counting rows with same x read (unit2, *, iostat=ios2) x0, y0, dummy_z if (ios2 /= 0) call s_mpi_abort("Error reading first line") @@ -120,7 +120,7 @@ end do close (unit2) - ! total rows + ! Count total rows open (newunit=unit2, file=trim(fileNames(1)), status='old', action='read', iostat=ios2) nrows = 0 do @@ -135,7 +135,7 @@ index_x = i index_y = j - ! all files + ! Read all files do f = 1, max_files open (newunit=unit, file=trim(fileNames(f)), status='old', action='read', iostat=ios) if (ios /= 0) then @@ -158,7 +158,7 @@ close (unit) end do - ! offsets + ! Calculate offsets x_step = x_cc(1) - x_cc(0) y_step = y_cc(1) - y_cc(0) delta_x = x_cc(index_x) - x_coords(1) + x_step/2.0_wp @@ -170,7 +170,7 @@ files_loaded = .true. end if - ! assignment + ! Data assignment select case (num_dims) case (1) idx = i + 1 + global_offset_x diff --git a/src/common/include/acc_macros.fpp b/src/common/include/acc_macros.fpp index 8e16f43e05..771ee976db 100644 --- a/src/common/include/acc_macros.fpp +++ b/src/common/include/acc_macros.fpp @@ -305,4 +305,4 @@ #:set acc_directive = '!$acc wait ' + clause_val + extraAccArgs_val.strip('\n') $:acc_directive #:enddef -! line at end of file is required for FYPP +! New line at end of file is required for FYPP diff --git a/src/common/include/case.fpp b/src/common/include/case.fpp index f50c291d8b..aa0e0637b9 100644 --- a/src/common/include/case.fpp +++ b/src/common/include/case.fpp @@ -1,13 +1,13 @@ -! file exists so that Fypp can be run without generating case.fpp files for -! target. This is useful when generating documentation, for example. This -! also let MFC be built with CMake directly, without invoking mfc.sh. +! This file exists so that Fypp can be run without generating case.fpp files for +! each target. This is useful when generating documentation, for example. This +! should also let MFC be built with CMake directly, without invoking mfc.sh. -! pre-process. +! For pre-process. #:def analytical() #:enddef -! moving immersed boundaries in simulation +! For moving immersed boundaries in simulation #:def mib_analytical() #:enddef diff --git a/src/common/include/macros.fpp b/src/common/include/macros.fpp index 54dd957bfb..03d812f53d 100644 --- a/src/common/include/macros.fpp +++ b/src/common/include/macros.fpp @@ -12,20 +12,20 @@ #endif #:enddef -! -! macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank. -! because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. -! an example see misc/nvidia_uvm/bind.sh. +! Caution: +! This macro requires the use of a binding script to set CUDA_VISIBLE_DEVICES, such that we have one GPU device per MPI rank. +! That's because for both cudaMemAdvise (preferred location) and cudaMemPrefetchAsync we use location = device_id = 0. +! For an example see misc/nvidia_uvm/bind.sh. #:def PREFER_GPU(*args) #ifdef MFC_SIMULATION #ifdef __NVCOMPILER_GPU_UNIFIED_MEM block -! in the 25.3 release, the structure of the cudafor module has been changed slightly. -! module now includes, or “uses” 3 submodules: cuda_runtime_api, gpu_reductions, and sort. -! cudafor functionality has not changed. But for new users, or users who have needed to -! name conflicts in the module, it may be better to use cuda_runtime_api to expose -! to the CUDA runtime calls described in Chapter 4 of this guide. -! +! Beginning in the 25.3 release, the structure of the cudafor module has been changed slightly. +! The module now includes, or “uses” 3 submodules: cuda_runtime_api, gpu_reductions, and sort. +! The cudafor functionality has not changed. But for new users, or users who have needed to +! work-around name conflicts in the module, it may be better to use cuda_runtime_api to expose +! interfaces to the CUDA runtime calls described in Chapter 4 of this guide. +! https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#fortran-host-modules #if __NVCOMPILER_MAJOR__ < 25 || (__NVCOMPILER_MAJOR__ == 25 && __NVCOMPILER_MINOR__ < 3) use cudafor, gpu_sum => sum, gpu_maxval => maxval, gpu_minval => minval #else @@ -36,19 +36,19 @@ if (nv_uvm_pref_gpu) then #:for arg in args !print*, "Moving ${arg}$ to GPU => ", SHAPE(${arg}$) - ! preferred location GPU + ! set preferred location GPU istat = cudaMemAdvise(c_devloc(${arg}$), SIZEOF(${arg}$), cudaMemAdviseSetPreferredLocation, 0) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat !write(*,*) cudaGetErrorString(istat) end if - ! accessed by CPU + ! set accessed by CPU istat = cudaMemAdvise(c_devloc(${arg}$), SIZEOF(${arg}$), cudaMemAdviseSetAccessedBy, cudaCpuDeviceId) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat !write(*,*) cudaGetErrorString(istat) end if - ! to GPU - physically populate memory pages + ! prefetch to GPU - physically populate memory pages istat = cudaMemPrefetchAsync(c_devloc(${arg}$), SIZEOF(${arg}$), 0, 0) if (istat /= cudaSuccess) then write (*, "('Error code: ',I0, ': ')") istat @@ -164,4 +164,4 @@ //${message or '"No error description."'}$) end if #:enddef -! line at end of file is required for FYPP +! New line at end of file is required for FYPP diff --git a/src/common/include/omp_macros.fpp b/src/common/include/omp_macros.fpp index c59f45567a..2e1df1dd8a 100644 --- a/src/common/include/omp_macros.fpp +++ b/src/common/include/omp_macros.fpp @@ -373,4 +373,4 @@ $:code #:endif #:enddef -! line at end of file is required for FYPP +! New line at end of file is required for FYPP diff --git a/src/common/include/parallel_macros.fpp b/src/common/include/parallel_macros.fpp index d722adeb78..bfe4b3beaf 100644 --- a/src/common/include/parallel_macros.fpp +++ b/src/common/include/parallel_macros.fpp @@ -232,4 +232,4 @@ #:set USING_NVHPC = (MFC_COMPILER == NVIDIA_COMPILER_ID or MFC_COMPILER == PGI_COMPILER_ID) #:set USING_CCE = (MFC_COMPILER == CCE_COMPILER_ID) -! line at end of file is required for FYPP +! New line at end of file is required for FYPP diff --git a/src/common/include/shared_parallel_macros.fpp b/src/common/include/shared_parallel_macros.fpp index 4fb47d98a7..36bee0a23a 100644 --- a/src/common/include/shared_parallel_macros.fpp +++ b/src/common/include/shared_parallel_macros.fpp @@ -117,4 +117,4 @@ #:endif $:extraArgs_val #:enddef -! line at end of file is required for FYPP +! New line at end of file is required for FYPP diff --git a/src/common/m_boundary_common.fpp b/src/common/m_boundary_common.fpp index a588494b50..8b8d301123 100644 --- a/src/common/m_boundary_common.fpp +++ b/src/common/m_boundary_common.fpp @@ -1,9 +1,9 @@ !> -!! -!! module m_boundary_conditions_common +!! @file +!! @brief Contains module m_boundary_conditions_common !> @brief The purpose of the module is to apply noncharacteristic and processor -!! +!! boundary conditions #:include 'case.fpp' #:include 'macros.fpp' @@ -84,8 +84,8 @@ contains end subroutine s_initialize_boundary_common_module !> The purpose of this procedure is to populate the buffers - !! primitive variables, depending on the selected - !! + !! of the primitive variables, depending on the selected + !! boundary conditions. impure subroutine s_populate_variables_buffers(bc_type, q_prim_vf, pb_in, mv_in) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -94,7 +94,7 @@ contains integer :: k, l - ! of Buffers in x-direction + ! Population of Buffers in x-direction if (bc_x%beg >= 0) then call s_mpi_sendrecv_variables_buffers(q_prim_vf, 1, -1, sys_size, pb_in, mv_in) else @@ -155,7 +155,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! of Buffers in y-direction + ! Population of Buffers in y-direction if (n == 0) return @@ -226,7 +226,7 @@ contains #:endif - ! of Buffers in z-direction + ! Population of Buffers in z-direction if (p == 0) return @@ -292,7 +292,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if #:endif - ! Population of Buffers in z-direction + ! END: Population of Buffers in z-direction end subroutine s_populate_variables_buffers @@ -1784,7 +1784,7 @@ contains offset = 0 - ! bc_types + ! Write bc_types do dir = 1, num_dims do loc = 1, 2 #ifdef MFC_MIXED_PRECISION @@ -1797,7 +1797,7 @@ contains end do end do - ! bc_buffers + ! Write bc_buffers do dir = 1, num_dims do loc = 1, 2 nelements = sizeof(bc_buffers(dir, loc)%sf)*mpi_io_type/stp @@ -1822,7 +1822,7 @@ contains character(len=10) :: status - ! bc_types + ! Read bc_types file_path = trim(step_dirpath)//'/bc_type.dat' inquire (FILE=trim(file_path), EXIST=file_exist) if (.not. file_exist) then @@ -1838,7 +1838,7 @@ contains end do close (1) - ! bc_buffers + ! Read bc_buffers file_path = trim(step_dirpath)//'/bc_buffers.dat' inquire (FILE=trim(file_path), EXIST=file_exist) if (.not. file_exist) then @@ -1894,7 +1894,7 @@ contains offset = 0 - ! bc_types + ! Read bc_types do dir = 1, num_dims do loc = 1, 2 #ifdef MFC_MIXED_PRECISION @@ -1908,7 +1908,7 @@ contains end do end do - ! bc_buffers + ! Read bc_buffers do dir = 1, num_dims do loc = 1, 2 nelements = sizeof(bc_buffers(dir, loc)%sf)*mpi_io_type/stp @@ -1994,15 +1994,15 @@ contains end subroutine s_assign_default_bc_type !> The purpose of this subroutine is to populate the buffers - !! grid variables, which are constituted of the cell- - !! and cell-width distributions, based on - !! conditions. + !! of the grid variables, which are constituted of the cell- + !! boundary locations and cell-width distributions, based on + !! the boundary conditions. subroutine s_populate_grid_variables_buffers integer :: i !< Generic loop iterator #ifdef MFC_SIMULATION - ! for compatibility between codes + ! Required for compatibility between codes type(int_bounds_info) :: offset_x, offset_y, offset_z offset_x%beg = buff_size; offset_x%end = buff_size offset_y%beg = buff_size; offset_y%end = buff_size @@ -2010,9 +2010,9 @@ contains #endif #ifndef MFC_PRE_PROCESS - ! of Buffers in x-direction + ! Population of Buffers in x-direction - ! cell-width distribution buffer at bc_x%beg + ! Populating cell-width distribution buffer at bc_x%beg if (bc_x%beg >= 0) then call s_mpi_sendrecv_grid_variables_buffers(1, -1) elseif (bc_x%beg <= BC_GHOST_EXTRAP) then @@ -2029,7 +2029,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_x%beg + ! Computing the cell-boundary and center locations buffer at bc_x%beg do i = 1, offset_x%beg x_cb(-1 - i) = x_cb(-i) - dx(-i) end do @@ -2038,7 +2038,7 @@ contains x_cc(-i) = x_cc(1 - i) - (dx(1 - i) + dx(-i))/2._wp end do - ! the cell-width distribution buffer at bc_x%end + ! Populating the cell-width distribution buffer at bc_x%end if (bc_x%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(1, 1) elseif (bc_x%end <= BC_GHOST_EXTRAP) then @@ -2055,7 +2055,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_x%end + ! Populating the cell-boundary and center locations buffer at bc_x%end do i = 1, offset_x%end x_cb(m + i) = x_cb(m + (i - 1)) + dx(m + i) end do @@ -2063,11 +2063,11 @@ contains do i = 1, buff_size x_cc(m + i) = x_cc(m + (i - 1)) + (dx(m + (i - 1)) + dx(m + i))/2._wp end do - ! Population of Buffers in x-direction + ! END: Population of Buffers in x-direction - ! of Buffers in y-direction + ! Population of Buffers in y-direction - ! cell-width distribution buffer at bc_y%beg + ! Populating cell-width distribution buffer at bc_y%beg if (n == 0) then return elseif (bc_y%beg >= 0) then @@ -2086,7 +2086,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_y%beg + ! Computing the cell-boundary and center locations buffer at bc_y%beg do i = 1, offset_y%beg y_cb(-1 - i) = y_cb(-i) - dy(-i) end do @@ -2095,7 +2095,7 @@ contains y_cc(-i) = y_cc(1 - i) - (dy(1 - i) + dy(-i))/2._wp end do - ! the cell-width distribution buffer at bc_y%end + ! Populating the cell-width distribution buffer at bc_y%end if (bc_y%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(2, 1) elseif (bc_y%end <= BC_GHOST_EXTRAP) then @@ -2112,7 +2112,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_y%end + ! Populating the cell-boundary and center locations buffer at bc_y%end do i = 1, offset_y%end y_cb(n + i) = y_cb(n + (i - 1)) + dy(n + i) end do @@ -2120,11 +2120,11 @@ contains do i = 1, buff_size y_cc(n + i) = y_cc(n + (i - 1)) + (dy(n + (i - 1)) + dy(n + i))/2._wp end do - ! Population of Buffers in y-direction + ! END: Population of Buffers in y-direction - ! of Buffers in z-direction + ! Population of Buffers in z-direction - ! cell-width distribution buffer at bc_z%beg + ! Populating cell-width distribution buffer at bc_z%beg if (p == 0) then return elseif (Bc_z%beg >= 0) then @@ -2143,7 +2143,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_z%beg + ! Computing the cell-boundary and center locations buffer at bc_z%beg do i = 1, offset_z%beg z_cb(-1 - i) = z_cb(-i) - dz(-i) end do @@ -2152,7 +2152,7 @@ contains z_cc(-i) = z_cc(1 - i) - (dz(1 - i) + dz(-i))/2._wp end do - ! the cell-width distribution buffer at bc_z%end + ! Populating the cell-width distribution buffer at bc_z%end if (bc_z%end >= 0) then call s_mpi_sendrecv_grid_variables_buffers(3, 1) elseif (bc_z%end <= BC_GHOST_EXTRAP) then @@ -2169,7 +2169,7 @@ contains end do end if - ! the cell-boundary and center locations buffer at bc_z%end + ! Populating the cell-boundary and center locations buffer at bc_z%end do i = 1, offset_z%end z_cb(p + i) = z_cb(p + (i - 1)) + dz(p + i) end do @@ -2177,7 +2177,7 @@ contains do i = 1, buff_size z_cc(p + i) = z_cc(p + (i - 1)) + (dz(p + (i - 1)) + dz(p + i))/2._wp end do - ! Population of Buffers in z-direction + ! END: Population of Buffers in z-direction #endif diff --git a/src/common/m_checker_common.fpp b/src/common/m_checker_common.fpp index ac83108fc4..52549e7a10 100644 --- a/src/common/m_checker_common.fpp +++ b/src/common/m_checker_common.fpp @@ -6,7 +6,7 @@ #:include 'macros.fpp' !> @brief The purpose of the module is to check for compatible input files for. -!! to pre-processing, post-processing and simulation +!! inputs common to pre-processing, post-processing and simulation module m_checker_common use m_global_parameters !< Definitions of the global parameters @@ -24,7 +24,7 @@ module m_checker_common contains !> Checks compatibility of parameters in the input file. - !! all three stages + !! Used by all three stages impure subroutine s_check_inputs_common #ifndef MFC_SIMULATION diff --git a/src/common/m_chemistry.fpp b/src/common/m_chemistry.fpp index 6de98b4894..a6ca8da449 100644 --- a/src/common/m_chemistry.fpp +++ b/src/common/m_chemistry.fpp @@ -1,7 +1,7 @@ !!> -!! -!! module m_chemistry -!! Le Berre +!! @file +!! @brief Contains module m_chemistry +!! @author Henry Le Berre #:include 'macros.fpp' #:include 'case.fpp' @@ -50,9 +50,9 @@ contains subroutine s_compute_q_T_sf(q_T_sf, q_cons_vf, bounds) - ! the temperature field at the start of the simulation to - ! values. Temperature is computed the regular way using the - ! variables. + ! Initialize the temperature field at the start of the simulation to + ! reasonable values. Temperature is computed the regular way using the + ! conservative variables. type(scalar_field), intent(inout) :: q_T_sf type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -70,10 +70,10 @@ contains q_cons_vf(eqn)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z) end do - ! = E - 1/2*|u|^2 - ! E_idx = \rho E - ! contxb = \rho (1-fluid model) - ! momxb + i = \rho u_i + ! e = E - 1/2*|u|^2 + ! cons. E_idx = \rho E + ! cons. contxb = \rho (1-fluid model) + ! cons. momxb + i = \rho u_i energy = q_cons_vf(E_idx)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z) do eqn = momxb, momxe energy = energy - & @@ -202,17 +202,17 @@ contains if (chemistry .or. dummy) then - ! offsets based on direction using array indexing + ! Set offsets based on direction using array indexing offsets = 0 offsets(idir) = 1 - ! 1: Mixture-Average Transport + ! Model 1: Mixture-Average Transport if (chem_params%transport_model == 1) then - ! Added 'i' and 'eqn' to private list. + ! Note: Added 'i' and 'eqn' to private list. $:GPU_PARALLEL_LOOP(collapse=3, private='[x,y,z,i,eqn,Ys_L, Ys_R, Ys_cell, Xs_L, Xs_R, mass_diffusivities_mixavg1, mass_diffusivities_mixavg2, mass_diffusivities_mixavg_Cell, h_l, h_r, Xs_cell, h_k, dXk_dxi,Mass_Diffu_Flux, Mass_Diffu_Energy, MW_L, MW_R, MW_cell, Rgas_L, Rgas_R, T_L, T_R, P_L, P_R, rho_L, rho_R, rho_cell, rho_Vic, lambda_L, lambda_R, lambda_Cell, dT_dxi, grid_spacing]', copyin='[offsets]') do z = isc3%beg, isc3%end do y = isc2%beg, isc2%end do x = isc1%beg, isc1%end - ! grid spacing using direction-based indexing + ! Calculate grid spacing using direction-based indexing select case (idir) case (1) grid_spacing = x_cc(x + 1) - x_cc(x) @@ -222,7 +222,7 @@ contains grid_spacing = z_cc(z + 1) - z_cc(z) end select - ! species mass fractions + ! Extract species mass fractions $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe Ys_L(i - chemxb + 1) = q_prim_qp(i)%sf(x, y, z) @@ -230,7 +230,7 @@ contains Ys_cell(i - chemxb + 1) = 0.5_wp*(Ys_L(i - chemxb + 1) + Ys_R(i - chemxb + 1)) end do - ! molecular weights and mole fractions + ! Calculate molecular weights and mole fractions call get_mixture_molecular_weight(Ys_L, MW_L) call get_mixture_molecular_weight(Ys_R, MW_R) MW_cell = 0.5_wp*(MW_L + MW_R) @@ -238,7 +238,7 @@ contains call get_mole_fractions(MW_L, Ys_L, Xs_L) call get_mole_fractions(MW_R, Ys_R, Xs_R) - ! gas constants and thermodynamic properties + ! Calculate gas constants and thermodynamic properties Rgas_L = gas_constant/MW_L Rgas_R = gas_constant/MW_R @@ -254,7 +254,7 @@ contains rho_cell = 0.5_wp*(rho_L + rho_R) dT_dxi = (T_R - T_L)/grid_spacing - ! transport properties + ! Get transport properties call get_species_mass_diffusivities_mixavg(P_L, T_L, Ys_L, mass_diffusivities_mixavg1) call get_species_mass_diffusivities_mixavg(P_R, T_R, Ys_R, mass_diffusivities_mixavg2) @@ -264,7 +264,7 @@ contains call get_species_enthalpies_rt(T_L, h_l) call get_species_enthalpies_rt(T_R, h_r) - ! species properties and gradients + ! Calculate species properties and gradients $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe #:if USING_AMD @@ -279,7 +279,7 @@ contains dXk_dxi(i - chemxb + 1) = (Xs_R(i - chemxb + 1) - Xs_L(i - chemxb + 1))/grid_spacing end do - ! mixture-averaged diffusivities + ! Calculate mixture-averaged diffusivities $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe mass_diffusivities_mixavg_Cell(i - chemxb + 1) = & @@ -288,7 +288,7 @@ contains lambda_Cell = 0.5_wp*(lambda_R + lambda_L) - ! mass diffusion fluxes + ! Calculate mass diffusion fluxes rho_Vic = 0.0_wp Mass_Diffu_Energy = 0.0_wp @@ -305,17 +305,17 @@ contains Mass_Diffu_Energy = Mass_Diffu_Energy + h_k(eqn - chemxb + 1)*Mass_Diffu_Flux(eqn - chemxb + 1) end do - ! corrections for mass conservation + ! Apply corrections for mass conservation $:GPU_LOOP(parallelism='[seq]') do eqn = chemxb, chemxe Mass_Diffu_Energy = Mass_Diffu_Energy - h_k(eqn - chemxb + 1)*Ys_cell(eqn - chemxb + 1)*rho_Vic Mass_Diffu_Flux(eqn - chemxb + 1) = Mass_Diffu_Flux(eqn - chemxb + 1) - rho_Vic*Ys_cell(eqn - chemxb + 1) end do - ! thermal conduction contribution + ! Add thermal conduction contribution Mass_Diffu_Energy = lambda_Cell*dT_dxi + Mass_Diffu_Energy - ! flux arrays + ! Update flux arrays flux_src_vf(E_idx)%sf(x, y, z) = flux_src_vf(E_idx)%sf(x, y, z) - Mass_Diffu_Energy $:GPU_LOOP(parallelism='[seq]') @@ -327,14 +327,14 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! 2: Unity Lewis Number + ! Model 2: Unity Lewis Number else if (chem_params%transport_model == 2) then - ! Added ALL scalars and 'i'/'eqn' to private list to prevent race conditions. + ! Note: Added ALL scalars and 'i'/'eqn' to private list to prevent race conditions. $:GPU_PARALLEL_LOOP(collapse=3, private='[x,y,z,i,eqn,Ys_L, Ys_R, Ys_cell, dYk_dxi, Mass_Diffu_Flux, grid_spacing, MW_L, MW_R, MW_cell, Rgas_L, Rgas_R, P_L, P_R, rho_L, rho_R, rho_cell, T_L, T_R, Cp_L, Cp_R, hmix_L, hmix_R, dh_dxi, lambda_L, lambda_R, lambda_Cell, diffusivity_L, diffusivity_R, diffusivity_cell, Mass_Diffu_Energy]', copyin='[offsets]') do z = isc3%beg, isc3%end do y = isc2%beg, isc2%end do x = isc1%beg, isc1%end - ! grid spacing using direction-based indexing + ! Calculate grid spacing using direction-based indexing select case (idir) case (1) grid_spacing = x_cc(x + 1) - x_cc(x) @@ -344,7 +344,7 @@ contains grid_spacing = z_cc(z + 1) - z_cc(z) end select - ! species mass fractions + ! Extract species mass fractions $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe Ys_L(i - chemxb + 1) = q_prim_qp(i)%sf(x, y, z) @@ -352,12 +352,12 @@ contains Ys_cell(i - chemxb + 1) = 0.5_wp*(Ys_L(i - chemxb + 1) + Ys_R(i - chemxb + 1)) end do - ! molecular weights and mole fractions + ! Calculate molecular weights and mole fractions call get_mixture_molecular_weight(Ys_L, MW_L) call get_mixture_molecular_weight(Ys_R, MW_R) MW_cell = 0.5_wp*(MW_L + MW_R) - ! gas constants and thermodynamic properties + ! Calculate gas constants and thermodynamic properties Rgas_L = gas_constant/MW_L Rgas_R = gas_constant/MW_R @@ -378,25 +378,25 @@ contains call get_mixture_enthalpy_mass(T_R, Ys_R, hmix_R) dh_dxi = (hmix_R - hmix_L)/grid_spacing - ! transport properties + ! Get transport properties call get_mixture_thermal_conductivity_mixavg(T_L, Ys_L, lambda_L) call get_mixture_thermal_conductivity_mixavg(T_R, Ys_R, lambda_R) - ! species properties and gradients + ! Calculate species properties and gradients $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe dYk_dxi(i - chemxb + 1) = (Ys_R(i - chemxb + 1) - & Ys_L(i - chemxb + 1))/grid_spacing end do - ! mixture-averaged diffusivities + ! Calculate mixture-averaged diffusivities diffusivity_L = lambda_L/rho_L/Cp_L diffusivity_R = lambda_R/rho_R/Cp_R lambda_Cell = 0.5_wp*(lambda_R + lambda_L) diffusivity_cell = 0.5_wp*(diffusivity_R + diffusivity_L) - ! mass diffusion fluxes + ! Calculate mass diffusion fluxes Mass_Diffu_Energy = 0.0_wp $:GPU_LOOP(parallelism='[seq]') @@ -407,7 +407,7 @@ contains end do Mass_Diffu_Energy = rho_cell*diffusivity_cell*dh_dxi - ! flux arrays + ! Update flux arrays flux_src_vf(E_idx)%sf(x, y, z) = flux_src_vf(E_idx)%sf(x, y, z) - Mass_Diffu_Energy $:GPU_LOOP(parallelism='[seq]') diff --git a/src/common/m_compile_specific.f90 b/src/common/m_compile_specific.f90 index 8479755961..87e1849abf 100644 --- a/src/common/m_compile_specific.f90 +++ b/src/common/m_compile_specific.f90 @@ -1,5 +1,5 @@ !> -!! @file m_compile_specific.f90 +!! @file !! @brief Contains module m_compile_specific !> @brief This module contains subroutines that are compiler specific diff --git a/src/common/m_compute_levelset.fpp b/src/common/m_compute_levelset.fpp index d6f5dbd643..2037418f51 100644 --- a/src/common/m_compute_levelset.fpp +++ b/src/common/m_compute_levelset.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_compute_levelset +!! @file +!! @brief Contains module m_compute_levelset #:include 'macros.fpp' !> @brief This module is used to handle all operations related to immersed -!! (IBMs) +!! boundary methods (IBMs) module m_compute_levelset use m_derived_types !< Definitions of the derived types @@ -97,7 +97,7 @@ contains xy_local = xy_local - patch_ib(ib_patch_id)%centroid_offset ! airfoils are a patch that require a centroid offset if (xy_local(2) >= 0._wp) then - ! the location on the airfoil grid with the minimum distance (closest) + ! finds the location on the airfoil grid with the minimum distance (closest) do k = 1, Np dist_vec(1) = xy_local(1) - airfoil_grid_u(k)%x dist_vec(2) = xy_local(2) - airfoil_grid_u(k)%y @@ -118,7 +118,7 @@ contains dist_vec(3) = 0 dist = global_dist else - ! :: This looks identical to the above code but using the lower array. Refactor this. + ! TODO :: This looks identical to the above code but using the lower array. Refactor this. do k = 1, Np dist_vec(1) = xy_local(1) - airfoil_grid_l(k)%x dist_vec(2) = xy_local(2) - airfoil_grid_l(k)%y @@ -321,13 +321,13 @@ contains dist_vec = 0._wp if (.not. f_approx_equal(side_dists(idx), 0._wp)) then if (idx == 1 .or. idx == 2) then - ! points along the x axis + ! vector points along the x axis dist_vec(1) = side_dists(idx)/abs(side_dists(idx)) else - ! points along the y axis + ! vector points along the y axis dist_vec(2) = side_dists(idx)/abs(side_dists(idx)) end if - ! the normal vector back into the global coordinate system + ! convert the normal vector back into the global coordinate system levelset_norm%sf(i, j, 0, ib_patch_id, :) = matmul(rotation, dist_vec) else levelset_norm%sf(i, j, 0, ib_patch_id, :) = 0._wp @@ -373,7 +373,7 @@ contains xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) - ! will get NaNs in the levelset if we compute this outside the ellipse + ! we will get NaNs in the levelset if we compute this outside the ellipse if ((xy_local(1)/ellipse_coeffs(1))**2 + (xy_local(2)/ellipse_coeffs(2))**2 <= 1._wp) then normal_vector = xy_local @@ -381,12 +381,12 @@ contains normal_vector = normal_vector/sqrt(dot_product(normal_vector, normal_vector)) ! normalize the vector levelset_norm%sf(i, j, 0, ib_patch_id, :) = matmul(rotation, normal_vector) ! save after rotating the vector to the global frame - ! the normal vector to set up the quadratic equation for the levelset, using A, B, and C in indices 1, 2, and 3 + ! use the normal vector to set up the quadratic equation for the levelset, using A, B, and C in indices 1, 2, and 3 quadratic_coeffs(1) = (normal_vector(1)/ellipse_coeffs(1))**2 + (normal_vector(2)/ellipse_coeffs(2))**2 quadratic_coeffs(2) = 2._wp*((xy_local(1)*normal_vector(1)/(ellipse_coeffs(1)**2)) + (xy_local(2)*normal_vector(2)/(ellipse_coeffs(2)**2))) quadratic_coeffs(3) = (xy_local(1)/ellipse_coeffs(1))**2._wp + (xy_local(2)/ellipse_coeffs(2))**2._wp - 1._wp - ! the levelset with the quadratic equation [ -B + sqrt(B^2 - 4AC) ] / 2A + ! compute the levelset with the quadratic equation [ -B + sqrt(B^2 - 4AC) ] / 2A levelset%sf(i, j, 0, ib_patch_id) = -0.5_wp*(-quadratic_coeffs(2) + sqrt(quadratic_coeffs(2)**2._wp - 4._wp*quadratic_coeffs(1)*quadratic_coeffs(3)))/quadratic_coeffs(1) end if end do @@ -451,13 +451,13 @@ contains side_dists(6) = xyz_local(3) - Front min_dist = minval(abs(side_dists)) - ! :: The way that this is written, it looks like we will - ! at the first size that is close to the minimum distance, - ! corners where side_dists are the same will - ! on what may not actually be the minimum, - ! to undesired behavior. This should be resolved - ! this code should be cleaned up. It also means that - ! the box 90 degrees will cause tests to fail. + ! TODO :: The way that this is written, it looks like we will + ! trigger at the first size that is close to the minimum distance, + ! meaning corners where side_dists are the same will + ! trigger on what may not actually be the minimum, + ! leading to undesired behavior. This should be resolved + ! and this code should be cleaned up. It also means that + ! rotating the box 90 degrees will cause tests to fail. dist_vec = 0._wp if (f_approx_equal(min_dist, abs(side_dists(1)))) then levelset%sf(i, j, k, ib_patch_id) = side_dists(1) @@ -593,16 +593,16 @@ contains xyz_local = [x_cc(i), y_cc(j), z_cc(k)] - center ! get coordinate frame centered on IB xyz_local = matmul(inverse_rotation, xyz_local) ! rotate the frame into the IB's coordinates - ! distance to flat edge of cylinder + ! get distance to flat edge of cylinder side_pos = dot_product(xyz_local, dist_sides_vec) dist_side = min(abs(side_pos - boundary(1)), & abs(boundary(2) - side_pos)) - ! distance to curved side of cylinder + ! get distance to curved side of cylinder dist_surface = norm2(xyz_local*dist_surface_vec) & - radius if (dist_side < abs(dist_surface)) then - ! the closest edge is flat + ! if the closest edge is flat levelset%sf(i, j, k, ib_patch_id) = -dist_side if (f_approx_equal(dist_side, abs(side_pos - boundary(1)))) then levelset_norm%sf(i, j, k, ib_patch_id, :) = matmul(rotation, -dist_sides_vec) diff --git a/src/common/m_constants.fpp b/src/common/m_constants.fpp index e33d4c977e..d728447f5f 100644 --- a/src/common/m_constants.fpp +++ b/src/common/m_constants.fpp @@ -1,6 +1,6 @@ !> -!! -!! constant values used throughout the code(s). +!! @file +!! @brief Contains constant values used throughout the code(s). module m_constants @@ -36,19 +36,19 @@ module m_constants real(wp), parameter :: broadband_spectral_level_constant = 20._wp !< The constant to scale the spectral level at the lower frequency bound real(wp), parameter :: broadband_spectral_level_growth_rate = 10._wp !< The spectral level constant to correct the magnitude at each frequency to ensure the source is overall broadband - ! Types + ! Reconstruction Types integer, parameter :: WENO_TYPE = 1 !< Using WENO for reconstruction type integer, parameter :: MUSCL_TYPE = 2 !< Using MUSCL for reconstruction type - ! Compression + ! Interface Compression real(wp), parameter :: dflt_ic_eps = 1e-4_wp !< Ensure compression is only applied to surface cells in THINC real(wp), parameter :: dflt_ic_beta = 1.6_wp !< Sharpness parameter's default value used in THINC integer, parameter :: moncon_cutoff = 1e-8_wp !< Monotonicity constraint's limiter to prevent extremas in THINC - ! + ! Chemistry real(wp), parameter :: dflt_T_guess = 1200._wp ! Default guess for temperature (when a previous value is not available) - ! interpolation constants + ! IBM+STL interpolation constants integer, parameter :: Ifactor_2D = 50 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 2D models integer, parameter :: Ifactor_3D = 5 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 3D models integer, parameter :: Ifactor_bary_3D = 20 !< Multiple factor of the ratio (triangle area to cell face area) for interpolation on triangle facets for 3D models @@ -59,44 +59,44 @@ module m_constants real(wp), parameter :: threshold_bary = 1.e-1_wp !< Threshold to interpolate a barycentric facet real(wp), parameter :: initial_distance_buffer = 1.e12_wp !< Initialized levelset distance for the shortest path pair algorithm - ! bubbles constants + ! Lagrange bubbles constants integer, parameter :: mapCells = 3 !< Number of cells around the bubble where the smoothening function will have effect real(wp), parameter :: R_uni = 8314._wp !< Universal gas constant - J/kmol/K integer, parameter :: lag_io_vars = 21 ! Number of variables per particle for MPI_IO - ! Splitting constants + ! Strang Splitting constants real(wp), parameter :: dflt_adap_dt_tol = 1.e-4_wp !< Default tolerance for adaptive step size integer, parameter :: dflt_adap_dt_max_iters = 100 !< Default max iteration for adaptive step size - ! of the algorithm described by Heirer, E. Hairer, S. P.Nørsett, G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4 - ! choose the initial time step size for the adaptive time stepping routine + ! Constants of the algorithm described by Heirer, E. Hairer, S. P.Nørsett, G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4 + ! to choose the initial time step size for the adaptive time stepping routine real(wp), parameter :: threshold_first_guess = 1.e-5_wp real(wp), parameter :: threshold_second_guess = 1.e-15_wp real(wp), parameter :: scale_first_guess = 1.e-3_wp real(wp), parameter :: scale_guess = 1.e-2_wp real(wp), parameter :: small_guess = 1.e-6_wp - ! + ! Relativity integer, parameter :: relativity_cons_to_prim_max_iter = 100 - ! number generator + ! Pseudo-random number generator integer, parameter :: modulus = 2**30 - 1 integer, parameter :: multiplier = 1664525 integer, parameter :: increment = 1013904223 integer, parameter :: amplifier = 3**13 real(wp), parameter :: decimal_trim = 1.e5_wp - ! constants + ! System constants integer, parameter :: CASE_FILE_ERROR_CODE = 22 - ! condition enumeration - ! - ! - Characteristic - ! - Non-reflecting - ! - subsonic - ! - supersonic - ! - Force-free - ! - Constant pressure + ! Boundary condition enumeration + ! Abbreviations + ! CHAR - Characteristic + ! NR - Non-reflecting + ! SUB - subsonic + ! SUP - supersonic + ! FF - Force-free + ! CP - Constant pressure integer, parameter :: BC_PERIODIC = -1 integer, parameter :: BC_REFLECTIVE = -2 integer, parameter :: BC_GHOST_EXTRAP = -3 diff --git a/src/common/m_derived_types.fpp b/src/common/m_derived_types.fpp index c88dfa20d2..ddded5740d 100644 --- a/src/common/m_derived_types.fpp +++ b/src/common/m_derived_types.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_derived_types +!! @file +!! @brief Contains module m_derived_types #:include "macros.fpp" !> @brief This file contains the definitions of all of the custom-defined -!! in the pre-process code. +!! types used in the pre-process code. module m_derived_types use m_constants !< Constants @@ -75,7 +75,7 @@ module m_derived_types end type vector_field !> Generic 3-component vector (e.g., spatial coordinates or field components) - !! (derived types: x,y,z) to differentiate from t_vec3 (3-component vector) + !! Named _dt (derived types: x,y,z) to differentiate from t_vec3 (3-component vector) type vec3_dt ! dt for derived types real(wp) :: x real(wp) :: y @@ -143,23 +143,23 @@ module m_derived_types !> Defines parameters for a Model Patch type ic_model_parameters character(LEN=pathlen_max) :: filepath !< - !! STL file relative to case_dir. + !! Path the STL file relative to case_dir. real(wp), dimension(1:3) :: translate !< - !! the STL object. + !! Translation of the STL object. real(wp), dimension(1:3) :: scale !< - !! for the STL object. + !! Scale factor for the STL object. real(wp), dimension(1:3) :: rotate !< - !! rotate the STL object along each cartesian coordinate axis, - !! + !! Angle to rotate the STL object along each cartesian coordinate axis, + !! in radians. integer :: spc !< - !! samples per cell to use when discretizing the STL object. + !! Number of samples per cell to use when discretizing the STL object. real(wp) :: threshold !< - !! turn on smoothen STL patch. + !! Threshold to turn on smoothen STL patch. end type ic_model_parameters type :: t_triangle @@ -183,54 +183,54 @@ module m_derived_types end type t_model !> Derived type adding initial condition (ic) patch parameters as attributes - !! requirements for the specification of the above parameters - !! dependent on both the choice of the multicomponent flow - !! well as the choice of the patch geometry. + !! NOTE: The requirements for the specification of the above parameters + !! are strongly dependent on both the choice of the multicomponent flow + !! model as well as the choice of the patch geometry. type ic_patch_parameters integer :: geometry !< Type of geometry for the patch real(wp) :: x_centroid, y_centroid, z_centroid !< - !! the geometric center, i.e. the centroid, of the patch. It - !! through its x-, y- and z-coordinates, respectively. + !! Location of the geometric center, i.e. the centroid, of the patch. It + !! is specified through its x-, y- and z-coordinates, respectively. real(wp) :: length_x, length_y, length_z !< Dimensions of the patch. x,y,z Lengths. real(wp) :: radius !< Dimensions of the patch. radius. real(wp), dimension(3) :: radii !< - !! the various radii for the elliptical and ellipsoidal - !! It is specified through its x-, y-, and z-components - !! + !! Vector indicating the various radii for the elliptical and ellipsoidal + !! patch geometries. It is specified through its x-, y-, and z-components + !! respectively. real(wp) :: epsilon, beta !< - !! vortex parameters for the amplitude of the disturbance and - !! influence. + !! The isentropic vortex parameters for the amplitude of the disturbance and + !! domain of influence. real(wp), dimension(2:9) :: a !< - !! needed for the spherical harmonic patch + !! The parameters needed for the spherical harmonic patch logical :: non_axis_sym real(wp), dimension(3) :: normal !< - !! indicating the orientation of the patch. It is specified - !! x-, y- and z-components, respectively. + !! Normal vector indicating the orientation of the patch. It is specified + !! through its x-, y- and z-components, respectively. logical, dimension(0:num_patches_max - 1) :: alter_patch !< - !! permissions that indicate to the current patch which preceding - !! is allowed to overwrite when it is in process of being laid - !! the domain + !! List of permissions that indicate to the current patch which preceding + !! patches it is allowed to overwrite when it is in process of being laid + !! out in the domain logical :: smoothen !< - !! to the current patch whether its boundaries will - !! out across a few cells or whether they are to remain sharp + !! Permission indicating to the current patch whether its boundaries will + !! be smoothed out across a few cells or whether they are to remain sharp integer :: smooth_patch_id !< - !! of the patch with which current patch is to get smoothed + !! Identity (id) of the patch with which current patch is to get smoothed real(wp) :: smooth_coeff !< - !! (coeff) for the size of the stencil of - !! which boundaries of the current patch will be smeared out + !! Smoothing coefficient (coeff) for the size of the stencil of + !! cells across which boundaries of the current patch will be smeared out real(wp), dimension(num_fluids_max) :: alpha_rho real(wp) :: rho @@ -243,15 +243,15 @@ module m_derived_types real(wp) :: qv !< real(wp) :: qvp !< - !! associated with the patch. In order, these include - !! densities, density, velocity, pressure, volume fractions, - !! ratio function and the liquid stiffness function. + !! Primitive variables associated with the patch. In order, these include + !! the partial densities, density, velocity, pressure, volume fractions, + !! specific heat ratio function and the liquid stiffness function. real(wp) :: Bx, By, Bz !< - !! components; B%x is not used for 1D + !! Magnetic field components; B%x is not used for 1D real(wp), dimension(6) :: tau_e !< - !! added to primitive variables if hypoelasticity = True + !! Elastic stresses added to primitive variables if hypoelasticity = True real(wp) :: R0 !< Bubble size real(wp) :: V0 !< Bubble velocity @@ -260,30 +260,30 @@ module m_derived_types real(wp) :: m0 !< Bubble velocity integer :: hcid - !! hard coded initial condition + !! id for hard coded initial condition real(wp) :: cf_val !! color function value real(wp) :: Y(1:num_species) - !! OBJ model input parameter + !! STL or OBJ model input parameter character(LEN=pathlen_max) :: model_filepath !< - !! STL file relative to case_dir. + !! Path the STL file relative to case_dir. real(wp), dimension(1:3) :: model_translate !< - !! the STL object. + !! Translation of the STL object. real(wp), dimension(1:3) :: model_scale !< - !! for the STL object. + !! Scale factor for the STL object. real(wp), dimension(1:3) :: model_rotate !< - !! rotate the STL object along each cartesian coordinate axis, - !! + !! Angle to rotate the STL object along each cartesian coordinate axis, + !! in radians. integer :: model_spc !< - !! samples per cell to use when discretizing the STL object. + !! Number of samples per cell to use when discretizing the STL object. real(wp) :: model_threshold !< - !! turn on smoothen STL patch. + !! Threshold to turn on smoothen STL patch. end type ic_patch_parameters @@ -292,10 +292,10 @@ module m_derived_types integer :: geometry !< Type of geometry for the patch real(wp) :: x_centroid, y_centroid, z_centroid !< - !! the geometric center, i.e. the centroid, of the patch. It - !! through its x-, y- and z-coordinates, respectively. + !! Location of the geometric center, i.e. the centroid, of the patch. It + !! is specified through its x-, y- and z-coordinates, respectively. real(wp) :: step_x_centroid, step_y_centroid, step_z_centroid !< - !! of intermediate steps in the time_stepper module + !! Centroid locations of intermediate steps in the time_stepper module real(wp), dimension(1:3) :: centroid_offset ! offset of center of mass from computed cell center for odd-shaped IBs real(wp), dimension(1:3) :: angles @@ -311,27 +311,27 @@ module m_derived_types logical :: slip - !! OBJ model input parameter + !! STL or OBJ model input parameter character(LEN=pathlen_max) :: model_filepath !< - !! STL file relative to case_dir. + !! Path the STL file relative to case_dir. real(wp), dimension(1:3) :: model_translate !< - !! the STL object. + !! Translation of the STL object. real(wp), dimension(1:3) :: model_scale !< - !! for the STL object. + !! Scale factor for the STL object. real(wp), dimension(1:3) :: model_rotate !< - !! rotate the STL object along each cartesian coordinate axis, - !! + !! Angle to rotate the STL object along each cartesian coordinate axis, + !! in radians. integer :: model_spc !< - !! samples per cell to use when discretizing the STL object. + !! Number of samples per cell to use when discretizing the STL object. real(wp) :: model_threshold !< - !! turn on smoothen STL patch. + !! Threshold to turn on smoothen STL patch. - !! for moving imersed boundaries + !! Patch conditions for moving imersed boundaries integer :: moving_ibm ! 0 for no moving, 1 for moving, 2 for moving on forced path real(wp) :: mass, moment ! mass and moment of inertia of object used to compute forces in 2-way coupling real(wp), dimension(1:3) :: force, torque ! vectors for the computed force and torque values applied to an IB @@ -343,7 +343,7 @@ module m_derived_types end type ib_patch_parameters !> Derived type annexing the physical parameters (PP) of the fluids. These - !! specific heat ratio function and liquid stiffness function. + !! include the specific heat ratio function and liquid stiffness function. type physical_parameters real(wp) :: gamma !< Sp. heat ratio real(wp) :: pi_inf !< Liquid stiffness diff --git a/src/common/m_finite_differences.fpp b/src/common/m_finite_differences.fpp index b3b23cd70e..f85d46944b 100644 --- a/src/common/m_finite_differences.fpp +++ b/src/common/m_finite_differences.fpp @@ -61,15 +61,15 @@ contains end subroutine s_compute_fd_divergence !> The purpose of this subroutine is to compute the finite- - !! for the centered schemes utilized - !! of first order spatial derivatives in the - !! The s-coordinate direction refers - !! x-, y- or z-coordinate direction, depending on the - !! Note that coefficients of up to 4th - !! are available. - !! Number of cells in the s-coordinate direction - !! Locations of the cell-centers in the s-coordinate direction - !! Finite-diff. coefficients in the s-coordinate direction + !! difference coefficients for the centered schemes utilized + !! in computations of first order spatial derivatives in the + !! s-coordinate direction. The s-coordinate direction refers + !! to the x-, y- or z-coordinate direction, depending on the + !! subroutine's inputs. Note that coefficients of up to 4th + !! order accuracy are available. + !! @param q Number of cells in the s-coordinate direction + !! @param s_cc Locations of the cell-centers in the s-coordinate direction + !! @param fd_coeff_s Finite-diff. coefficients in the s-coordinate direction subroutine s_compute_finite_difference_coefficients(q, s_cc, fd_coeff_s, local_buff_size, & fd_number_in, fd_order_in, offset_s) @@ -98,7 +98,7 @@ contains allocate (fd_coeff_s(-fd_number_in:fd_number_in, lb:lE)) #endif - ! the 1st order finite-difference coefficients + ! Computing the 1st order finite-difference coefficients if (fd_order_in == 1) then do i = lB, lE fd_coeff_s(-1, i) = 0._wp @@ -106,7 +106,7 @@ contains fd_coeff_s(1, i) = -fd_coeff_s(0, i) end do - ! the 2nd order finite-difference coefficients + ! Computing the 2nd order finite-difference coefficients elseif (fd_order_in == 2) then do i = lB, lE fd_coeff_s(-1, i) = -1._wp/(s_cc(i + 1) - s_cc(i - 1)) @@ -114,7 +114,7 @@ contains fd_coeff_s(1, i) = -fd_coeff_s(-1, i) end do - ! the 4th order finite-difference coefficients + ! Computing the 4th order finite-difference coefficients else do i = lB, lE fd_coeff_s(-2, i) = 1._wp/(s_cc(i - 2) - 8._wp*s_cc(i - 1) - s_cc(i + 2) + 8._wp*s_cc(i + 1)) diff --git a/src/common/m_helper.fpp b/src/common/m_helper.fpp index 12ac552429..d990a83345 100644 --- a/src/common/m_helper.fpp +++ b/src/common/m_helper.fpp @@ -2,8 +2,8 @@ #:include 'macros.fpp' !> -!! -!! module m_helper +!! @file +!! @brief Contains module m_helper module m_helper @@ -46,9 +46,9 @@ module m_helper contains !> Computes the bubble number density n from the primitive variables - !! is the void fraction - !! is the bubble radii - !! is the output number bubble density + !! @param vftmp is the void fraction + !! @param Rtmp is the bubble radii + !! @param ntmp is the output number bubble density subroutine s_comp_n_from_prim(vftmp, Rtmp, ntmp, weights) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: vftmp @@ -108,12 +108,12 @@ contains end subroutine s_print_2D_array !> - !! polytropic - !! non-polytropic - !! non-polytropic + !! bubbles_euler + polytropic + !! bubbles_euler + non-polytropic + !! bubbles_lagrange + non-polytropic impure subroutine s_initialize_bubbles_model() - ! memory + ! Allocate memory if (bubbles_euler) then @:ALLOCATE(weight(nb), R0(nb)) if (.not. polytropic) then @@ -123,7 +123,7 @@ contains @:ALLOCATE(pb0(nb)) end if - ! quadrature weights and nodes for polydisperse simulations + ! Compute quadrature weights and nodes for polydisperse simulations if (nb > 1) then call s_simpson(weight, R0) else if (nb == 1) then @@ -135,7 +135,7 @@ contains R0 = R0*bub_pp%R0ref end if - ! bubble variables + ! Initialize bubble variables call s_initialize_bubble_vars() end subroutine s_initialize_bubbles_model @@ -161,7 +161,7 @@ contains k_vl = bub_pp%k_v; k_gl = bub_pp%k_g end if - ! quantities + ! Input quantities if (bubbles_euler .and. (.not. polytropic)) then if (thermal == 2) then gam_m = 1._wp @@ -170,7 +170,7 @@ contains end if end if - ! numbers + ! Nondimensional numbers Eu = p0ref Ca = Eu - pv if (.not. f_is_default(bub_pp%ss)) Web = 1._wp/ss @@ -178,11 +178,11 @@ contains if (.not. polytropic) Pe_c = 1._wp/vd if (bubbles_euler) then - ! variables for non-polytropic (Preston) model + ! Initialize variables for non-polytropic (Preston) model if (.not. polytropic) then call s_initialize_nonpoly() end if - ! pb based on surface tension for qbmm (polytropic) + ! Initialize pb based on surface tension for qbmm (polytropic) if (qbmm .and. polytropic) then pb0 = Eu if (.not. f_is_default(Web)) then @@ -199,44 +199,44 @@ contains real(wp), dimension(nb) :: chi_vw0, cp_m0, k_m0, rho_m0, x_vw, omegaN, rhol0 real(wp), parameter :: k_poly = 1._wp !< - !! used to compute isothermal natural frequency + !! polytropic index used to compute isothermal natural frequency - ! & phi_gv (phi_gg = phi_vv = 1) (Eq. 2.22 in Ando 2010) + ! phi_vg & phi_gv (phi_gg = phi_vv = 1) (Eq. 2.22 in Ando 2010) phi_vg = (1._wp + sqrt(mu_v/mu_g)*(M_g/M_v)**(0.25_wp))**2 & /(sqrt(8._wp)*sqrt(1._wp + M_v/M_g)) phi_gv = (1._wp + sqrt(mu_g/mu_v)*(M_v/M_g)**(0.25_wp))**2 & /(sqrt(8._wp)*sqrt(1._wp + M_g/M_v)) - ! bubble pressure + ! internal bubble pressure pb0 = Eu + 2._wp/Web/R0 - ! fraction of vapor (Eq. 2.19 in Ando 2010) + ! mass fraction of vapor (Eq. 2.19 in Ando 2010) chi_vw0 = 1._wp/(1._wp + R_v/R_g*(pb0/pv - 1._wp)) - ! heat for gas/vapor mixture + ! specific heat for gas/vapor mixture cp_m0 = chi_vw0*R_v*gam_v/(gam_v - 1._wp) & + (1._wp - chi_vw0)*R_g*gam_g/(gam_g - 1._wp) - ! fraction of vapor (Eq. 2.23 in Ando 2010) + ! mole fraction of vapor (Eq. 2.23 in Ando 2010) x_vw = M_g*chi_vw0/(M_v + (M_g - M_v)*chi_vw0) - ! conductivity for gas/vapor mixture (Eq. 2.21 in Ando 2010) + ! thermal conductivity for gas/vapor mixture (Eq. 2.21 in Ando 2010) k_m0 = x_vw*k_v/(x_vw + (1._wp - x_vw)*phi_vg) & + (1._wp - x_vw)*k_g/(x_vw*phi_gv + 1._wp - x_vw) k_g(:) = k_g(:)/k_m0(:) k_v(:) = k_v(:)/k_m0(:) - ! density (Eq. 2.20 in Ando 2010) + ! mixture density (Eq. 2.20 in Ando 2010) rho_m0 = pv/(chi_vw0*R_v*Tw) - ! of gas/vapor + ! mass of gas/vapor mass_g0(:) = (4._wp*pi/3._wp)*(pb0(:) - pv)/(R_g*Tw)*R0(:)**3 mass_v0(:) = (4._wp*pi/3._wp)*pv/(R_v*Tw)*R0(:)**3 - ! numbers + ! Peclet numbers Pe_T(:) = rho_m0*cp_m0(:)/k_m0(:) - ! frequencies (Eq. B.1) + ! natural frequencies (Eq. B.1) omegaN(:) = sqrt(3._wp*k_poly*Ca + 2._wp*(3._wp*k_poly - 1._wp)/(Web*R0))/R0/sqrt(rho0ref) do ir = 1, nb call s_transcoeff(omegaN(ir)*R0(ir), Pe_T(ir)*R0(ir), & @@ -249,10 +249,10 @@ contains end subroutine s_initialize_nonpoly !> Computes the transfer coefficient for the non-polytropic bubble compression process - !! natural frequencies - !! Peclet number - !! Real part of the transport coefficients - !! Imaginary part of the transport coefficients + !! @param omega natural frequencies + !! @param peclet Peclet number + !! @param Re_trans Real part of the transport coefficients + !! @param Im_trans Imaginary part of the transport coefficients elemental subroutine s_transcoeff(omega, peclet, Re_trans, Im_trans) real(wp), intent(in) :: omega, peclet @@ -294,7 +294,7 @@ contains R0mn = 0.8_wp*exp(-2.8_wp*sd) R0mx = 0.2_wp*exp(9.5_wp*sd) + 1._wp - ! = ln( R0 ) & return R0 + ! phi = ln( R0 ) & return R0 do ir = 1, nb phi(ir) = log(R0mn) & + (ir - 1._wp)*log(R0mx/R0mn)/(nb - 1._wp) @@ -305,9 +305,9 @@ contains dphi = phi(2) - phi(1) #:endif - ! for quadrature using Simpson's rule + ! weights for quadrature using Simpson's rule do ir = 2, nb - 1 - ! + ! Gaussian tmp = exp(-0.5_wp*(phi(ir)/sd)**2)/sqrt(2._wp*pi)/sd if (mod(ir, 2) == 0) then local_weight(ir) = tmp*4._wp*dphi/3._wp @@ -323,9 +323,9 @@ contains end subroutine s_simpson !> This procedure computes the cross product of two vectors. - !! First vector. - !! Second vector. - !! cross product of the two vectors. + !! @param a First vector. + !! @param b Second vector. + !! @return The cross product of the two vectors. pure function f_cross(a, b) result(c) real(wp), dimension(3), intent(in) :: a, b @@ -337,8 +337,8 @@ contains end function f_cross !> This procedure swaps two real numbers. - !! Left-hand side. - !! Right-hand side. + !! @param lhs Left-hand side. + !! @param rhs Right-hand side. elemental subroutine s_swap(lhs, rhs) real(wp), intent(inout) :: lhs, rhs @@ -350,8 +350,8 @@ contains end subroutine s_swap !> This procedure creates a transformation matrix. - !! Parameters for the transformation. - !! matrix. + !! @param p Parameters for the transformation. + !! @return Transformation matrix. function f_create_transform_matrix(param, center) result(out_matrix) type(ic_model_parameters), intent(in) :: param @@ -389,14 +389,14 @@ contains 0._wp, 0._wp, 0._wp, 1._wp], shape(tr))) if (present(center)) then - ! matrix to move center to the origin + ! Translation matrix to move center to the origin t_to_origin = transpose(reshape([ & 1._wp, 0._wp, 0._wp, -center(1), & 0._wp, 1._wp, 0._wp, -center(2), & 0._wp, 0._wp, 1._wp, -center(3), & 0._wp, 0._wp, 0._wp, 1._wp], shape(tr))) - ! matrix to move center back to original position + ! Translation matrix to move center back to original position t_back = transpose(reshape([ & 1._wp, 0._wp, 0._wp, center(1), & 0._wp, 1._wp, 0._wp, center(2), & @@ -411,8 +411,8 @@ contains end function f_create_transform_matrix !> This procedure transforms a vector by a matrix. - !! Vector to transform. - !! Transformation matrix. + !! @param vec Vector to transform. + !! @param matrix Transformation matrix. subroutine s_transform_vec(vec, matrix) real(wp), dimension(1:3), intent(inout) :: vec @@ -426,8 +426,8 @@ contains end subroutine s_transform_vec !> This procedure transforms a triangle by a matrix, one vertex at a time. - !! Triangle to transform. - !! Transformation matrix. + !! @param triangle Triangle to transform. + !! @param matrix Transformation matrix. subroutine s_transform_triangle(triangle, matrix, matrix_n) type(t_triangle), intent(inout) :: triangle @@ -444,8 +444,8 @@ contains end subroutine s_transform_triangle !> This procedure transforms a model by a matrix, one triangle at a time. - !! Model to transform. - !! Transformation matrix. + !! @param model Model to transform. + !! @param matrix Transformation matrix. subroutine s_transform_model(model, matrix, matrix_n) type(t_model), intent(inout) :: model @@ -460,8 +460,8 @@ contains end subroutine s_transform_model !> This procedure creates a bounding box for a model. - !! Model to create bounding box for. - !! box. + !! @param model Model to create bounding box for. + !! @return Bounding box. function f_create_bbox(model) result(bbox) type(t_model), intent(in) :: model @@ -488,9 +488,9 @@ contains end function f_create_bbox !> This procedure performs xor on lhs and rhs. - !! logical input. - !! other logical input. - !! result. + !! @param lhs logical input. + !! @param rhs other logical input. + !! @return xored result. elemental function f_xor(lhs, rhs) result(res) logical, intent(in) :: lhs, rhs @@ -500,8 +500,8 @@ contains end function f_xor !> This procedure converts logical to 1 or 0. - !! A Logical argument. - !! if .true., 0 if .false.. + !! @param perdicate A Logical argument. + !! @return 1 if .true., 0 if .false.. elemental function f_logical_to_int(predicate) result(int) logical, intent(in) :: predicate @@ -515,9 +515,9 @@ contains end function f_logical_to_int !> This function generates the unassociated legendre poynomials - !! is the input value - !! is the degree - !! is the unassociated legendre polynomial evaluated at x + !! @param x is the input value + !! @param l is the degree + !! @return P is the unassociated legendre polynomial evaluated at x recursive function unassociated_legendre(x, l) result(result_P) integer, intent(in) :: l @@ -535,11 +535,11 @@ contains end function unassociated_legendre !> This function calculates the spherical harmonic function evaluated at x and phi - !! is the x coordinate - !! is the phi coordinate - !! is the degree - !! is the order - !! is the spherical harmonic function evaluated at x and phi + !! @param x is the x coordinate + !! @param phi is the phi coordinate + !! @param l is the degree + !! @param m_order is the order + !! @return Y is the spherical harmonic function evaluated at x and phi recursive function spherical_harmonic_func(x, phi, l, m_order) result(Y) integer, intent(in) :: l, m_order @@ -557,11 +557,11 @@ contains end function spherical_harmonic_func !> This function generates the associated legendre polynomials evaluated - !! with inputs l and m - !! is the input value - !! is the degree - !! is the order - !! is the associated legendre polynomial evaluated at x + !! at x with inputs l and m + !! @param x is the input value + !! @param l is the degree + !! @param m_order is the order + !! @return P is the associated legendre polynomial evaluated at x recursive function associated_legendre(x, l, m_order) result(result_P) integer, intent(in) :: l, m_order @@ -585,8 +585,8 @@ contains end function associated_legendre !> This function calculates the double factorial value of an integer - !! is the input integer - !! is the double factorial value of n + !! @param n_in is the input integer + !! @return R is the double factorial value of n elemental function double_factorial(n_in) result(R_result) integer, intent(in) :: n_in @@ -599,8 +599,8 @@ contains end function double_factorial !> The following function calculates the factorial value of an integer - !! is the input integer - !! is the factorial value of n + !! @param n_in is the input integer + !! @return R is the factorial value of n elemental function factorial(n_in) result(R_result) integer, intent(in) :: n_in @@ -614,11 +614,11 @@ contains end function factorial !> This function calculates a smooth cut-on function that is zero for x values - !! zero and goes to one. It can be used for generating smooth - !! - !! is the input value - !! is the smoothing parameter - !! is the cut-on function evaluated at x + !! smaller than zero and goes to one. It can be used for generating smooth + !! initial conditions + !! @param x is the input value + !! @param eps is the smoothing parameter + !! @return fx is the cut-on function evaluated at x function f_cut_on(x, eps) result(fx) real(wp), intent(in) :: x, eps @@ -629,11 +629,11 @@ contains end function f_cut_on !> This function calculates a smooth cut-off function that is one for x values - !! zero and goes to zero. It can be used for generating smooth - !! - !! is the input value - !! is the smoothing parameter - !! is the cut-ff function evaluated at x + !! smaller than zero and goes to zero. It can be used for generating smooth + !! initial conditions + !! @param x is the input value + !! @param eps is the smoothing parameter + !! @return fx is the cut-ff function evaluated at x function f_cut_off(x, eps) result(fx) real(wp), intent(in) :: x, eps @@ -644,8 +644,8 @@ contains end function f_cut_off !> This function is a helper function for the functions f_cut_on and f_cut_off - !! is the input value - !! is the result + !! @param x is the input value + !! @return gx is the result function f_gx(x) result(gx) real(wp), intent(in) :: x @@ -663,7 +663,7 @@ contains type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf, q_cons_temp - ! sampling variables + ! Down sampling variables integer :: i, j, k, l integer :: ix, iy, iz, x_id, y_id, z_id integer, intent(inout) :: m_ds, n_ds, p_ds, m_glb_ds, n_glb_ds, p_glb_ds diff --git a/src/common/m_helper_basic.fpp b/src/common/m_helper_basic.fpp index 895f13b899..d8ce26f485 100644 --- a/src/common/m_helper_basic.fpp +++ b/src/common/m_helper_basic.fpp @@ -1,6 +1,6 @@ -!! -!! module m_helper_basic +!! @file +!! @brief Contains module m_helper_basic #:include 'macros.fpp' @@ -22,10 +22,10 @@ module m_helper_basic contains !> This procedure checks if two floating point numbers of wp are within tolerance. - !! First number. - !! Second number. - !! Relative error (default = 1.e-10_wp). - !! of the comparison. + !! @param a First number. + !! @param b Second number. + !! @param tol_input Relative error (default = 1.e-10_wp). + !! @return Result of the comparison. logical elemental function f_approx_equal(a, b, tol_input) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: a, b @@ -48,10 +48,10 @@ contains end function f_approx_equal !> This procedure checks if the point numbers of wp belongs to another array are within tolerance. - !! First number. - !! Array that contains several point numbers. - !! Relative error (default = 1e-10_wp). - !! of the comparison. + !! @param a First number. + !! @param b Array that contains several point numbers. + !! @param tol_input Relative error (default = 1e-10_wp). + !! @return Result of the comparison. logical function f_approx_in_array(a, b, tol_input) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: a @@ -77,7 +77,7 @@ contains end function f_approx_in_array !> Checks if a real(wp) variable is of default value. - !! Variable to check. + !! @param var Variable to check. logical elemental function f_is_default(var) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: var @@ -86,7 +86,7 @@ contains end function f_is_default !> Checks if ALL elements of a real(wp) array are of default value. - !! Array to check. + !! @param var_array Array to check. logical function f_all_default(var_array) result(res) real(wp), intent(in) :: var_array(:) @@ -95,15 +95,15 @@ contains !logical :: res_array(size(var_array)) !integer :: i - ! i = 1, size(var_array) - ! = f_is_default(var_array(i)) - ! do + ! do i = 1, size(var_array) + ! res_array(i) = f_is_default(var_array(i)) + ! end do - ! = all(res_array) + ! res = all(res_array) end function f_all_default !> Checks if a real(wp) variable is an integer. - !! Variable to check. + !! @param var Variable to check. logical elemental function f_is_integer(var) result(res) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: var @@ -123,10 +123,10 @@ contains logical, intent(in) :: igr logical, intent(in) :: ib - ! the number of cells that are needed in order to store - ! boundary conditions data as to iterate the solution in - ! physical computational domain from one time-step iteration to - ! next one + ! Determining the number of cells that are needed in order to store + ! sufficient boundary conditions data as to iterate the solution in + ! the physical computational domain from one time-step iteration to + ! the next one if (igr) then buff_size = (igr_order - 1)/2 + 2 elseif (recon_type == WENO_TYPE) then @@ -139,7 +139,7 @@ contains buff_size = muscl_polyn + 2 end if - ! for smearing function in the lagrangian subgrid bubble model + ! Correction for smearing function in the lagrangian subgrid bubble model if (bubbles_lagrange) then buff_size = max(buff_size, 6) end if @@ -148,7 +148,7 @@ contains buff_size = max(buff_size, 10) end if - ! Coordinate Direction Indexes + ! Configuring Coordinate Direction Indexes idwint(1)%beg = 0; idwint(2)%beg = 0; idwint(3)%beg = 0 idwint(1)%end = m; idwint(2)%end = n; idwint(3)%end = p @@ -163,10 +163,10 @@ contains end subroutine s_configure_coordinate_bounds !> Updates the min and max number of cells in each set of axes - !! Min ans max values to update - !! Number of cells in x-axis - !! Number of cells in y-axis - !! Number of cells in z-axis + !! @param bounds Min ans max values to update + !! @param m Number of cells in x-axis + !! @param n Number of cells in y-axis + !! @param p Number of cells in z-axis elemental subroutine s_update_cell_bounds(bounds, m, n, p) type(cell_num_bounds), intent(out) :: bounds integer, intent(in) :: m, n, p diff --git a/src/common/m_ib_patches.fpp b/src/common/m_ib_patches.fpp index ece2c9e49f..6ff2a327a5 100644 --- a/src/common/m_ib_patches.fpp +++ b/src/common/m_ib_patches.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_patches +!! @file +!! @brief Contains module m_patches #:include 'case.fpp' #:include 'ExtrusionHardcodedIC.fpp' @@ -37,53 +37,49 @@ module m_ib_patches integer :: smooth_patch_id real(wp) :: smooth_coeff $:GPU_DECLARE(create='[smooth_patch_id, smooth_coeff]') - !! are analogous in both meaning and use to the similarly - !! in the ic_patch_parameters type (see m_derived_types.f90 - !! details). They are employed as a means to more concisely - !! actions necessary to lay out a particular patch on the grid. + !! These variables are analogous in both meaning and use to the similarly + !! named components in the ic_patch_parameters type (see m_derived_types.f90 + !! for additional details). They are employed as a means to more concisely + !! perform the actions necessary to lay out a particular patch on the grid. real(wp) :: eta $:GPU_DECLARE(create='[eta]') - !! case that smoothing of patch boundaries is enabled and the boundary - !! adjacent patches is to be smeared out, this variable's purpose - !! act as a pseudo volume fraction to indicate the contribution of each - !! the composition of a cell's fluid state. + !! In the case that smoothing of patch boundaries is enabled and the boundary + !! between two adjacent patches is to be smeared out, this variable's purpose + !! is to act as a pseudo volume fraction to indicate the contribution of each + !! patch toward the composition of a cell's fluid state. real(wp) :: cart_x, cart_y, cart_z real(wp) :: sph_phi !< $:GPU_DECLARE(create='[cart_x, cart_y, cart_z, sph_phi]') - !! be used to hold cell locations in Cartesian coordinates if - !! is using cylindrical coordinates + !! Variables to be used to hold cell locations in Cartesian coordinates if + !! 3D simulation is using cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary $:GPU_DECLARE(create='[x_boundary, y_boundary, z_boundary]') - !! combine the centroid and length parameters associated with - !! patch to yield the locations of the patch boundaries in the - !! and z-coordinate directions. They are used as a means to concisely - !! actions necessary to lay out a particular patch on the grid. + !! These variables combine the centroid and length parameters associated with + !! a particular patch to yield the locations of the patch boundaries in the + !! x-, y- and z-coordinate directions. They are used as a means to concisely + !! perform the actions necessary to lay out a particular patch on the grid. character(len=5) :: istr ! string to store int to string result for error checking contains - !> Applies all immersed boundary patches to the grid. - !! @param[inout] ib_markers_sf IB marker field storing patch IDs at grid cells. - !! @param[inout] levelset Levelset distance field for IB geometry. - !! @param[inout] levelset_norm Levelset normal vector field for IB geometry. impure subroutine s_apply_ib_patches(ib_markers_sf, levelset, levelset_norm) integer, dimension(:, :, :), intent(inout), optional :: ib_markers_sf - type(levelset_field), intent(inout), optional :: levelset - type(levelset_norm_field), intent(inout), optional :: levelset_norm + type(levelset_field), intent(inout), optional :: levelset !< Levelset determined by models + type(levelset_norm_field), intent(inout), optional :: levelset_norm !< Levelset_norm determined by models integer :: i - ! Patch Geometries + ! 3D Patch Geometries if (p > 0) then !> IB Patches !> @{ - ! patch + ! Spherical patch do i = 1, num_ibs if (patch_ib(i)%geometry == 8) then @@ -98,14 +94,14 @@ contains elseif (patch_ib(i)%geometry == 11) then call s_ib_3D_airfoil(i, ib_markers_sf) call s_3D_airfoil_levelset(i, levelset, levelset_norm) - ! patch + ! STL+IBM patch elseif (patch_ib(i)%geometry == 12) then call s_ib_model(i, ib_markers_sf, levelset, levelset_norm) end if end do !> @} - ! Patch Geometries + ! 2D Patch Geometries elseif (n > 0) then !> IB Patches @@ -120,7 +116,7 @@ contains elseif (patch_ib(i)%geometry == 4) then call s_ib_airfoil(i, ib_markers_sf) call s_airfoil_levelset(i, levelset, levelset_norm) - ! patch + ! STL+IBM patch elseif (patch_ib(i)%geometry == 5) then call s_ib_model(i, ib_markers_sf, levelset, levelset_norm) elseif (patch_ib(i)%geometry == 6) then @@ -135,13 +131,13 @@ contains end subroutine s_apply_ib_patches !> The circular patch is a 2D geometry that may be used, for - !! creating a bubble or a droplet. The geometry - !! patch is well-defined when its centroid and radius - !! Note that the circular patch DOES allow for - !! of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! True if this patch is an immersed boundary + !! example, in creating a bubble or a droplet. The geometry + !! of the patch is well-defined when its centroid and radius + !! are provided. Note that the circular patch DOES allow for + !! the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param ib True if this patch is an immersed boundary subroutine s_ib_circle(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -152,22 +148,22 @@ contains integer :: i, j, k !< Generic loop iterators - ! the circular patch's radius, centroid, smearing patch - ! and smearing coefficient information + ! Transferring the circular patch's radius, centroid, smearing patch + ! identity and smearing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid radius = patch_ib(patch_id)%radius - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the circular patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! whether the circle covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the circle covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,radius]', collapse=2) @@ -184,8 +180,8 @@ contains end subroutine s_ib_circle - !! is the patch identifier - !! Array to track patch ids + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids subroutine s_ib_airfoil(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -208,7 +204,7 @@ contains ta = patch_ib(patch_id)%t inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! is not consistent between pre_process and simulation. This IFDEF prevents compilation errors + ! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors #ifdef MFC_PRE_PROCESS Np1 = int((pa*ca_in/dx)*20) Np2 = int(((ca_in - pa*ca_in)/dx)*20) @@ -222,7 +218,7 @@ contains allocate (airfoil_grid_u(1:Np)) allocate (airfoil_grid_l(1:Np)) - ! :: The below instantiations are already handles by the loop below + ! TODO :: The below instantiations are already handles by the loop below airfoil_grid_u(1)%x = 0._wp airfoil_grid_u(1)%y = 0._wp @@ -232,7 +228,7 @@ contains eta = 1._wp do i = 1, Np1 + Np2 - 1 - ! :: This allocated the upper and lower airfoil arrays, and does not need to be performed each time the IB markers are updated. Place this as a separate subroutine. + ! TODO :: This allocated the upper and lower airfoil arrays, and does not need to be performed each time the IB markers are updated. Place this as a separate subroutine. if (i <= Np1) then xc = i*(pa*ca_in/Np1) xa = xc/ca_in @@ -337,9 +333,9 @@ contains end subroutine s_ib_airfoil - !! is the patch identifier - !! Array to track patch ids - !! True if this patch is an immersed boundary + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param ib True if this patch is an immersed boundary subroutine s_ib_3D_airfoil(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -362,7 +358,7 @@ contains ta = patch_ib(patch_id)%t inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! is not consistent between pre_process and simulation. This IFDEF prevents compilation errors + ! rank(dx) is not consistent between pre_process and simulation. This IFDEF prevents compilation errors #ifdef MFC_PRE_PROCESS Np1 = int((pa*ca_in/dx)*20) Np2 = int(((ca_in - pa*ca_in)/dx)*20) @@ -489,16 +485,16 @@ contains end subroutine s_ib_3D_airfoil !> The rectangular patch is a 2D geometry that may be used, - !! in creating a solid boundary, or pre-/post- - !! in alignment with the axes of the Cartesian - !! The geometry of such a patch is well- - !! its centroid and lengths in the x- and y- - !! are provided. Please note that the - !! DOES NOT allow for the smoothing of its - !! - !! is the patch identifier - !! Array to track patch ids - !! True if this patch is an immersed boundary + !! for example, in creating a solid boundary, or pre-/post- + !! shock region, in alignment with the axes of the Cartesian + !! coordinate system. The geometry of such a patch is well- + !! defined when its centroid and lengths in the x- and y- + !! coordinate directions are provided. Please note that the + !! rectangular patch DOES NOT allow for the smoothing of its + !! boundaries. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param ib True if this patch is an immersed boundary subroutine s_ib_rectangle(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -514,28 +510,28 @@ contains gamma = fluid_pp(1)%gamma lit_gamma = (1._wp + gamma)/gamma - ! the rectangle's centroid and length information + ! Transferring the rectangle's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid length(1) = patch_ib(patch_id)%length_x length(2) = patch_ib(patch_id)%length_y inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! the rectangular patch does not allow for its boundaries to - ! smoothed out, the pseudo volume fraction is set to 1 to ensure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the rectangular patch does not allow for its boundaries to + ! be smoothed out, the pseudo volume fraction is set to 1 to ensure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta = 1._wp - ! whether the rectangle covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the rectangle covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j, xy_local]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,inverse_rotation,x_cc,y_cc]', collapse=2) do j = 0, n do i = 0, m - ! the x and y coordinates in the local IB frame + ! get the x and y coordinates in the local IB frame xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) @@ -544,7 +540,7 @@ contains -0.5_wp*length(2) <= xy_local(2) .and. & 0.5_wp*length(2) >= xy_local(2)) then - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable ib_markers_sf(i, j, 0) = patch_id end if @@ -555,42 +551,42 @@ contains end subroutine s_ib_rectangle !> The spherical patch is a 3D geometry that may be used, - !! in creating a bubble or a droplet. The patch - !! well-defined when its centroid and radius are - !! note that the spherical patch DOES allow - !! smoothing of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! True if this patch is an immersed boundary + !! for example, in creating a bubble or a droplet. The patch + !! geometry is well-defined when its centroid and radius are + !! provided. Please note that the spherical patch DOES allow + !! for the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param ib True if this patch is an immersed boundary subroutine s_ib_sphere(patch_id, ib_markers_sf) integer, intent(in) :: patch_id integer, dimension(0:m, 0:n, 0:p), intent(inout) :: ib_markers_sf - ! loop iterators + ! Generic loop iterators integer :: i, j, k real(wp) :: radius real(wp), dimension(1:3) :: center - !! initialize the pressure field that corresponds to the - !! case found in Tiwari et al. (2013) + !! Variables to initialize the pressure field that corresponds to the + !! bubble-collapse test case found in Tiwari et al. (2013) - ! spherical patch's radius, centroid, smoothing patch - ! and smoothing coefficient information + ! Transferring spherical patch's radius, centroid, smoothing patch + ! identity and smoothing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid center(3) = patch_ib(patch_id)%z_centroid radius = patch_ib(patch_id)%radius - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the spherical patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the spherical patch's boundary is enabled. eta = 1._wp - ! whether the sphere covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the sphere covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,radius]', collapse=3) do k = 0, p @@ -602,7 +598,7 @@ contains cart_y = y_cc(j) cart_z = z_cc(k) end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (((x_cc(i) - center(1))**2 & + (cart_y - center(2))**2 & + (cart_z - center(3))**2 <= radius**2)) then @@ -616,15 +612,15 @@ contains end subroutine s_ib_sphere !> The cuboidal patch is a 3D geometry that may be used, for - !! creating a solid boundary, or pre-/post-shock - !! is aligned with the axes of the Cartesian - !! The geometry of such a patch is well- - !! its centroid and lengths in the x-, y- and - !! are provided. Please notice that - !! patch DOES NOT allow for the smearing of its - !! - !! is the patch identifier - !! Array to track patch ids + !! example, in creating a solid boundary, or pre-/post-shock + !! region, which is aligned with the axes of the Cartesian + !! coordinate system. The geometry of such a patch is well- + !! defined when its centroid and lengths in the x-, y- and + !! z-coordinate directions are provided. Please notice that + !! the cuboidal patch DOES NOT allow for the smearing of its + !! boundaries. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids subroutine s_ib_cuboid(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -634,7 +630,7 @@ contains real(wp), dimension(1:3) :: xyz_local, center, length !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! the cuboid's centroid and length information + ! Transferring the cuboid's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid center(3) = patch_ib(patch_id)%z_centroid @@ -643,16 +639,16 @@ contains length(3) = patch_ib(patch_id)%length_z inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! the cuboidal patch does not allow for its boundaries to get - ! out, the pseudo volume fraction is set to 1 to make sure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the cuboidal patch does not allow for its boundaries to get + ! smoothed out, the pseudo volume fraction is set to 1 to make sure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta = 1._wp - ! whether the cuboid covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables - ! the current patch are assigned to this cell. + ! Checking whether the cuboid covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! to that cell. If both queries check out, the primitive variables + ! of the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,xyz_local,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,inverse_rotation]', collapse=3) do k = 0, p @@ -660,7 +656,7 @@ contains do i = 0, m if (grid_geometry == 3) then - ! :: This does not work and is not covered by any tests. This should be fixed + ! TODO :: This does not work and is not covered by any tests. This should be fixed call s_convert_cylindrical_to_cartesian_coord(y_cc(j), z_cc(k)) else cart_y = y_cc(j) @@ -676,7 +672,7 @@ contains -0.5*length(3) <= xyz_local(3) .and. & 0.5*length(3) >= xyz_local(3)) then - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable ib_markers_sf(i, j, k) = patch_id end if end do @@ -687,16 +683,16 @@ contains end subroutine s_ib_cuboid !> The cylindrical patch is a 3D geometry that may be used, - !! in setting up a cylindrical solid boundary - !! a blood vessel. The geometry of this - !! well-defined when the centroid, the radius and - !! along the cylinder's axis, parallel to the x-, - !! z-coordinate direction, are provided. Please note - !! cylindrical patch DOES allow for the smoothing - !! lateral boundary. - !! is the patch identifier - !! Array to track patch ids - !! True if this patch is an immersed boundary + !! for example, in setting up a cylindrical solid boundary + !! confinement, like a blood vessel. The geometry of this + !! patch is well-defined when the centroid, the radius and + !! the length along the cylinder's axis, parallel to the x-, + !! y- or z-coordinate direction, are provided. Please note + !! that the cylindrical patch DOES allow for the smoothing + !! of its lateral boundary. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param ib True if this patch is an immersed boundary subroutine s_ib_cylinder(patch_id, ib_markers_sf) integer, intent(in) :: patch_id @@ -707,8 +703,8 @@ contains real(wp), dimension(1:3) :: xyz_local, center, length !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! the cylindrical patch's centroid, length, radius, - ! patch identity and smoothing coefficient information + ! Transferring the cylindrical patch's centroid, length, radius, + ! smoothing patch identity and smoothing coefficient information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid @@ -719,15 +715,15 @@ contains radius = patch_ib(patch_id)%radius inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smearing of the cylindrical patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smearing of the cylindrical patch's boundary is enabled. eta = 1._wp - ! whether the cylinder covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the cylinder covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. $:GPU_PARALLEL_LOOP(private='[i,j,k,xyz_local,cart_y,cart_z]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,length,radius,inverse_rotation]', collapse=3) do k = 0, p @@ -761,7 +757,7 @@ contains -0.5_wp*length(3) <= xyz_local(3) .and. & 0.5_wp*length(3) >= xyz_local(3)))) then - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable ib_markers_sf(i, j, k) = patch_id end if end do @@ -782,26 +778,26 @@ contains real(wp), dimension(1:2) :: center !< x and y coordinates in local IB frame real(wp), dimension(1:3, 1:3) :: inverse_rotation - ! the ellipse's centroid and length information + ! Transferring the ellipse's centroid and length information center(1) = patch_ib(patch_id)%x_centroid center(2) = patch_ib(patch_id)%y_centroid ellipse_coeffs(1) = 0.5_wp*patch_ib(patch_id)%length_x ellipse_coeffs(2) = 0.5_wp*patch_ib(patch_id)%length_y inverse_rotation(:, :) = patch_ib(patch_id)%rotation_matrix_inverse(:, :) - ! whether the ellipse covers a particular cell in the - ! + ! Checking whether the ellipse covers a particular cell in the + ! domain $:GPU_PARALLEL_LOOP(private='[i,j, xy_local]', copy='[ib_markers_sf]',& & copyin='[patch_id,center,ellipse_coeffs,inverse_rotation,x_cc,y_cc]', collapse=2) do j = 0, n do i = 0, m - ! the x and y coordinates in the local IB frame + ! get the x and y coordinates in the local IB frame xy_local = [x_cc(i) - center(1), y_cc(j) - center(2), 0._wp] xy_local = matmul(inverse_rotation, xy_local) - ! condition (x/a)^2 + (y/b)^2 <= 1 + ! Ellipse condition (x/a)^2 + (y/b)^2 <= 1 if ((xy_local(1)/ellipse_coeffs(1))**2 + (xy_local(2)/ellipse_coeffs(2))**2 <= 1._wp) then - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable ib_markers_sf(i, j, 0) = patch_id end if end do @@ -811,18 +807,18 @@ contains end subroutine s_ib_ellipse !> The STL patch is a 2/3D geometry that is imported from an STL file. - !! @param[in] patch_id Patch identifier index. - !! @param[inout] ib_markers_sf Array to track patch IDs at grid cells. - !! @param[inout] STL_levelset Levelset distance field for the STL model. - !! @param[inout] STL_levelset_norm Levelset normal field for the STL model. + !! @param patch_id is the patch identifier + !! @param ib_markers_sf Array to track patch ids + !! @param STL_levelset STL levelset + !! @param STL_levelset_norm STL levelset normals subroutine s_ib_model(patch_id, ib_markers_sf, STL_levelset, STL_levelset_norm) integer, intent(in) :: patch_id integer, dimension(0:m, 0:n, 0:p), intent(inout) :: ib_markers_sf - ! for IBM+STL - type(levelset_field), optional, intent(inout) :: STL_levelset - type(levelset_norm_field), optional, intent(inout) :: STL_levelset_norm + ! Variables for IBM+STL + type(levelset_field), optional, intent(inout) :: STL_levelset !< Levelset determined by models + type(levelset_norm_field), optional, intent(inout) :: STL_levelset_norm !< Levelset_norm determined by models real(wp) :: normals(1:3) !< Boundary normal buffer integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex real(wp), allocatable, dimension(:, :, :) :: boundary_v !< Boundary vertex buffer @@ -858,39 +854,39 @@ contains print *, " * Transforming model." end if - ! the model center before transforming the model + ! Get the model center before transforming the model bbox_old = f_create_bbox(model) model_center(1:3) = (bbox_old%min(1:3) + bbox_old%max(1:3))/2._wp - ! the transform matrices for vertices and normals + ! Compute the transform matrices for vertices and normals transform = f_create_transform_matrix(params, model_center) transform_n = f_create_transform_matrix(params) call s_transform_model(model, transform, transform_n) - ! the bounding box after transformation + ! Recreate the bounding box after transformation bbox = f_create_bbox(model) - ! the number of vertices in the original STL model + ! Show the number of vertices in the original STL model if (proc_rank == 0) then print *, ' * Number of input model vertices:', 3*model%ntrs end if call f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) - ! if the model needs interpolation + ! Check if the model needs interpolation if (p > 0) then call f_check_interpolation_3D(model, (/dx, dy, dz/), interpolate) else call f_check_interpolation_2D(boundary_v, boundary_edge_count, (/dx, dy, dz/), interpolate) end if - ! the number of edges and boundary edges in 2D STL models + ! Show the number of edges and boundary edges in 2D STL models if (proc_rank == 0 .and. p == 0) then print *, ' * Number of 2D model boundary edges:', boundary_edge_count end if - ! the STL model along the edges (2D) and on triangle facets (3D) + ! Interpolate the STL model along the edges (2D) and on triangle facets (3D) if (interpolate) then if (proc_rank == 0) then print *, ' * Interpolating STL vertices.' @@ -950,18 +946,18 @@ contains eta = f_model_is_inside(model, point, (/dx, dy, dz/), patch_ib(patch_id)%model_spc) - ! STL boundary vertices and compute the levelset and levelset_norm + ! Reading STL boundary vertices and compute the levelset and levelset_norm if (eta > patch_ib(patch_id)%model_threshold) then ib_markers_sf(i, j, k) = patch_id end if - ! models + ! 3D models if (p > 0) then - ! the boundary normals and shortest distance between the cell center and the model boundary + ! Get the boundary normals and shortest distance between the cell center and the model boundary call f_distance_normals_3D(model, point, normals, distance) - ! the shortest distance between the cell center and the interpolated model boundary + ! Get the shortest distance between the cell center and the interpolated model boundary if (interpolate) then STL_levelset%sf(i, j, k, patch_id) = f_interpolated_distance(interpolated_boundary_v, & total_vertices, & @@ -970,49 +966,49 @@ contains STL_levelset%sf(i, j, k, patch_id) = distance end if - ! the sign of the levelset + ! Correct the sign of the levelset if (ib_markers_sf(i, j, k) > 0) then STL_levelset%sf(i, j, k, patch_id) = -abs(STL_levelset%sf(i, j, k, patch_id)) end if - ! the sign of the levelset_norm + ! Correct the sign of the levelset_norm if (ib_markers_sf(i, j, k) == 0) then normals(1:3) = -normals(1:3) end if - ! the levelset_norm + ! Assign the levelset_norm STL_levelset_norm%sf(i, j, k, patch_id, 1:3) = normals(1:3) else - ! models + ! 2D models if (interpolate) then - ! the shortest distance between the cell center and the model boundary + ! Get the shortest distance between the cell center and the model boundary STL_levelset%sf(i, j, 0, patch_id) = f_interpolated_distance(interpolated_boundary_v, & total_vertices, & point) else - ! the shortest distance between the cell center and the interpolated model boundary + ! Get the shortest distance between the cell center and the interpolated model boundary STL_levelset%sf(i, j, 0, patch_id) = f_distance(boundary_v, & boundary_edge_count, & point) end if - ! the sign of the levelset + ! Correct the sign of the levelset if (ib_markers_sf(i, j, k) > 0) then STL_levelset%sf(i, j, 0, patch_id) = -abs(STL_levelset%sf(i, j, 0, patch_id)) end if - ! the boundary normals + ! Get the boundary normals call f_normals(boundary_v, & boundary_edge_count, & point, & normals) - ! the sign of the levelset_norm + ! Correct the sign of the levelset_norm if (ib_markers_sf(i, j, k) == 0) then normals(1:3) = -normals(1:3) end if - ! the levelset_norm + ! Assign the levelset_norm STL_levelset_norm%sf(i, j, k, patch_id, 1:3) = normals(1:3) end if @@ -1036,9 +1032,9 @@ contains real(wp), dimension(3, 3, 3) :: rotation real(wp) :: angle - ! the x, y, and z rotation matrices + ! construct the x, y, and z rotation matrices if (num_dims == 3) then - ! compute the x and y axes in 3D + ! also compute the x and y axes in 3D angle = patch_ib(patch_id)%angles(1) rotation(1, 1, :) = [1._wp, 0._wp, 0._wp] rotation(1, 2, :) = [0._wp, cos(angle), -sin(angle)] @@ -1049,23 +1045,23 @@ contains rotation(2, 2, :) = [0._wp, 1._wp, 0._wp] rotation(2, 3, :) = [-sin(angle), 0._wp, cos(angle)] - ! the y rotation to the x rotation + ! apply the y rotation to the x rotation patch_ib(patch_id)%rotation_matrix(:, :) = matmul(rotation(1, :, :), rotation(2, :, :)) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(2, :, :)), transpose(rotation(1, :, :))) end if - ! component first, since it applies in 2D and 3D + ! z component first, since it applies in 2D and 3D angle = patch_ib(patch_id)%angles(3) rotation(3, 1, :) = [cos(angle), -sin(angle), 0._wp] rotation(3, 2, :) = [sin(angle), cos(angle), 0._wp] rotation(3, 3, :) = [0._wp, 0._wp, 1._wp] if (num_dims == 3) then - ! the z rotation to the xy rotation in 3D + ! apply the z rotation to the xy rotation in 3D patch_ib(patch_id)%rotation_matrix(:, :) = matmul(patch_ib(patch_id)%rotation_matrix(:, :), rotation(3, :, :)) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = matmul(transpose(rotation(3, :, :)), patch_ib(patch_id)%rotation_matrix_inverse(:, :)) else - ! out only the z rotation in 2D + ! write out only the z rotation in 2D patch_ib(patch_id)%rotation_matrix(:, :) = rotation(3, :, :) patch_ib(patch_id)%rotation_matrix_inverse(:, :) = transpose(rotation(3, :, :)) end if @@ -1105,9 +1101,9 @@ contains end subroutine s_convert_cylindrical_to_spherical_coord !> Archimedes spiral function - !! Angle - !! Thickness - !! Starting position + !! @param myth Angle + !! @param offset Thickness + !! @param a Starting position pure elemental function f_r(myth, offset, a) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: myth, offset, a diff --git a/src/common/m_model.fpp b/src/common/m_model.fpp index 8890c41c1a..ff338dc06d 100644 --- a/src/common/m_model.fpp +++ b/src/common/m_model.fpp @@ -1,7 +1,7 @@ !> -!! -!! Le Berre -!! module m_model +!! @file +!! @author Henry Le Berre +!! @brief Contains module m_model #:include 'macros.fpp' @@ -19,7 +19,7 @@ module m_model public :: f_model_read, s_model_write, s_model_free, f_model_is_inside - ! for STL immersed boundaries + ! Subroutines for STL immersed boundaries public :: f_check_boundary, f_register_edge, f_check_interpolation_2D, & f_check_interpolation_3D, f_interpolate_2D, f_interpolate_3D, & f_interpolated_distance, f_normals, f_distance, f_distance_normals_3D, f_tri_area @@ -27,8 +27,8 @@ module m_model contains !> This procedure reads a binary STL file. - !! Path to the STL file. - !! The binary of the STL file. + !! @param filepath Path to the STL file. + !! @param model The binary of the STL file. impure subroutine s_read_stl_binary(filepath, model) character(LEN=*), intent(in) :: filepath @@ -76,8 +76,8 @@ contains end subroutine s_read_stl_binary !> This procedure reads an ASCII STL file. - !! Path to the STL file. - !! the STL file. + !! @param filepath Path to the STL file. + !! @param model the STL file. impure subroutine s_read_stl_ascii(filepath, model) character(LEN=*), intent(in) :: filepath type(t_model), intent(out) :: model @@ -184,8 +184,8 @@ contains end subroutine s_read_stl_ascii !> This procedure reads an STL file. - !! Path to the STL file. - !! the STL file. + !! @param filepath Path to the STL file. + !! @param model the STL file. impure subroutine s_read_stl(filepath, model) character(LEN=*), intent(in) :: filepath @@ -218,8 +218,8 @@ contains end subroutine s_read_stl !> This procedure reads an OBJ file. - !! Path to the odj file. - !! The obj file. + !! @param filepath Path to the odj file. + !! @param model The obj file. impure subroutine s_read_obj(filepath, model) character(LEN=*), intent(in) :: filepath @@ -294,8 +294,8 @@ contains end subroutine s_read_obj !> This procedure reads a mesh from a file. - !! Path to the file to read. - !! model read from the file. + !! @param filepath Path to the file to read. + !! @return The model read from the file. impure function f_model_read(filepath) result(model) character(LEN=*), intent(in) :: filepath @@ -316,8 +316,8 @@ contains end function f_model_read !> This procedure writes a binary STL file. - !! Path to the STL file. - !! STL to write + !! @param filepath Path to the STL file. + !! @param model STL to write impure subroutine s_write_stl(filepath, model) character(LEN=*), intent(in) :: filepath @@ -366,8 +366,8 @@ contains end subroutine s_write_stl !> This procedure writes an OBJ file. - !! Path to the obj file. - !! obj to write. + !! @param filepath Path to the obj file. + !! @param model obj to write. impure subroutine s_write_obj(filepath, model) character(LEN=*), intent(in) :: filepath @@ -403,8 +403,8 @@ contains end subroutine s_write_obj !> This procedure writes a binary STL file. - !! Path to the file to write. - !! Model to write. + !! @param filepath Path to the file to write. + !! @param model Model to write. impure subroutine s_model_write(filepath, model) character(LEN=*), intent(in) :: filepath @@ -480,11 +480,11 @@ contains end subroutine s_skip_ignored_lines !> This procedure, recursively, finds whether a point is inside an octree. - !! Model to search in. - !! Point to test. - !! Space around the point to search in (grid spacing). - !! Number of samples per cell. - !! if the point is inside the octree, false otherwise. + !! @param model Model to search in. + !! @param point Point to test. + !! @param spacing Space around the point to search in (grid spacing). + !! @param spc Number of samples per cell. + !! @return True if the point is inside the octree, false otherwise. impure function f_model_is_inside(model, point, spacing, spc) result(fraction) type(t_model), intent(in) :: model @@ -527,11 +527,11 @@ contains end function f_model_is_inside - ! https://www.scratchapixel.com/lessons/3e-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution.html + ! From https://www.scratchapixel.com/lessons/3e-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution.html !> This procedure checks if a ray intersects a triangle. - !! Ray. - !! Triangle. - !! if the ray intersects the triangle, false otherwise. + !! @param ray Ray. + !! @param triangle Triangle. + !! @return True if the ray intersects the triangle, false otherwise. elemental function f_intersects_triangle(ray, triangle) result(intersects) type(t_ray), intent(in) :: ray @@ -588,15 +588,15 @@ contains end function f_intersects_triangle !> This procedure checks and labels edges shared by two or more triangles facets of the 2D STL model. - !! @param[in] model Model to search in. - !! @param[out] boundary_v Output boundary vertices and normals. - !! @param[out] boundary_vertex_count Total boundary vertex count. - !! @param[out] boundary_edge_count Total boundary edge count. + !! @param model Model to search in. + !! @param boundary_v Output boundary vertices/normals. + !! @param boundary_vertex_count Output total boundary vertex count + !! @param boundary_edge_count Output total boundary edge counts subroutine f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) type(t_model), intent(in) :: model - real(wp), allocatable, intent(out), dimension(:, :, :) :: boundary_v - integer, intent(out) :: boundary_vertex_count, boundary_edge_count + real(wp), allocatable, intent(out), dimension(:, :, :) :: boundary_v !< Output boundary vertices/normals + integer, intent(out) :: boundary_vertex_count, boundary_edge_count !< Output boundary vertex/edge count integer :: i, j !< Model index iterator integer :: edge_count, edge_index, store_index !< Boundary edge index iterator @@ -606,32 +606,32 @@ contains integer, dimension(1:(3*model%ntrs)) :: edge_occurrence !< The manifoldness of the edges real(wp) :: edgetan, initial, v_norm, xnormal, ynormal !< The manifoldness of the edges - ! number of edges in 2D STL + ! Total number of edges in 2D STL edge_count = 3*model%ntrs - ! edge_occurrence array to zero + ! Initialize edge_occurrence array to zero edge_occurrence = 0 edge_index = 0 - ! all edges of all triangles and store them + ! Collect all edges of all triangles and store them do i = 1, model%ntrs - ! edge (v1, v2) + ! First edge (v1, v2) edge(1, 1:2) = model%trs(i)%v(1, 1:2) edge(2, 1:2) = model%trs(i)%v(2, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) - ! edge (v2, v3) + ! Second edge (v2, v3) edge(1, 1:2) = model%trs(i)%v(2, 1:2) edge(2, 1:2) = model%trs(i)%v(3, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) - ! edge (v3, v1) + ! Third edge (v3, v1) edge(1, 1:2) = model%trs(i)%v(3, 1:2) edge(2, 1:2) = model%trs(i)%v(1, 1:2) call f_register_edge(temp_boundary_v, edge, edge_index, edge_count) end do - ! all edges and count repeated edges + ! Check all edges and count repeated edges do i = 1, edge_count do j = 1, edge_count if (i /= j) then @@ -650,7 +650,7 @@ contains end do end do - ! the number of boundary vertices/edges + ! Count the number of boundary vertices/edges boundary_vertex_count = 0 boundary_edge_count = 0 @@ -661,10 +661,10 @@ contains end if end do - ! the boundary_v array based on the number of boundary edges + ! Allocate the boundary_v array based on the number of boundary edges allocate (boundary_v(boundary_edge_count, 1:3, 1:2)) - ! boundary vertices + ! Store boundary vertices store_index = 0 do i = 1, edge_count if (edge_occurrence(i) == 0) then @@ -674,7 +674,7 @@ contains end if end do - ! the normal vector of the boundary edges + ! Find/store the normal vector of the boundary edges do i = 1, boundary_edge_count boundary_edge(1) = boundary_v(i, 2, 1) - boundary_v(i, 1, 1) boundary_edge(2) = boundary_v(i, 2, 2) - boundary_v(i, 1, 2) @@ -702,10 +702,10 @@ contains end subroutine f_check_boundary !> This procedure appends the edge end vertices to a temporary buffer. - !! Temporary edge end vertex buffer - !! Edges end points to be registered - !! Edge index iterator - !! Total number of edges + !! @param temp_boundary_v Temporary edge end vertex buffer + !! @param edge Edges end points to be registered + !! @param edge_index Edge index iterator + !! @param edge_count Total number of edges subroutine f_register_edge(temp_boundary_v, edge, edge_index, edge_count) integer, intent(inout) :: edge_index !< Edge index iterator @@ -713,7 +713,7 @@ contains real(wp), intent(in), dimension(1:2, 1:2) :: edge !< Edges end points to be registered real(wp), dimension(1:edge_count, 1:2, 1:2), intent(inout) :: temp_boundary_v !< Temporary edge end vertex buffer - ! edge index and store the edge + ! Increment edge index and store the edge edge_index = edge_index + 1 temp_boundary_v(edge_index, 1, 1:2) = edge(1, 1:2) temp_boundary_v(edge_index, 2, 1:2) = edge(2, 1:2) @@ -721,14 +721,14 @@ contains end subroutine f_register_edge !> This procedure check if interpolates is needed for 2D models. - !! @param[in] boundary_v Boundary edge vertex buffer. - !! @param[in] boundary_edge_count Number of boundary edges. - !! @param[in] spacing Grid cell spacing in each dimension. - !! @param[inout] interpolate Set to true if edge interpolation is needed. + !! @param boundary_v Temporary edge end vertex buffer + !! @param boundary_edge_count Output total number of boundary edges + !! @param spacing Dimensions of the current levelset cell + !! @param interpolate Logical output subroutine f_check_interpolation_2D(boundary_v, boundary_edge_count, spacing, interpolate) - logical, intent(inout) :: interpolate - integer, intent(in) :: boundary_edge_count + logical, intent(inout) :: interpolate !< Logical indicator of interpolation + integer, intent(in) :: boundary_edge_count !< Number of boundary edges real(wp), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v real(wp), dimension(1:3), intent(in) :: spacing @@ -753,9 +753,9 @@ contains end subroutine f_check_interpolation_2D !> This procedure check if interpolates is needed for 3D models. - !! Model to search in. - !! Dimensions of the current levelset cell - !! Logical output + !! @param model Model to search in. + !! @param spacing Dimensions of the current levelset cell + !! @param interpolate Logical output subroutine f_check_interpolation_3D(model, spacing, interpolate) logical, intent(inout) :: interpolate @@ -798,11 +798,11 @@ contains end subroutine f_check_interpolation_3D !> This procedure interpolates 2D models. - !! Group of all the boundary vertices of the 2D model without interpolation - !! Output total number of boundary edges - !! Dimensions of the current levelset cell - !! Output all the boundary vertices of the interpolated 2D model - !! Total number of vertices after interpolation + !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation + !! @param boundary_edge_count Output total number of boundary edges + !! @param spacing Dimensions of the current levelset cell + !! @param interpolated_boundary_v Output all the boundary vertices of the interpolated 2D model + !! @param total_vertices Total number of vertices after interpolation subroutine f_interpolate_2D(boundary_v, boundary_edge_count, spacing, interpolated_boundary_v, total_vertices) real(wp), intent(in), dimension(:, :, :) :: boundary_v @@ -816,51 +816,51 @@ contains real(wp) :: edge_length, cell_width real(wp), dimension(1:2) :: edge_x, edge_y, edge_del - ! the number of boundary edges + ! Get the number of boundary edges cell_width = minval(spacing(1:2)) num_segments = 0 - ! pass: Calculate the total number of vertices including interpolated ones + ! First pass: Calculate the total number of vertices including interpolated ones total_vertices = 1 do i = 1, boundary_edge_count - ! the coordinates of the two ends of the current edge + ! Get the coordinates of the two ends of the current edge edge_x(1) = boundary_v(i, 1, 1) edge_y(1) = boundary_v(i, 1, 2) edge_x(2) = boundary_v(i, 2, 1) edge_y(2) = boundary_v(i, 2, 2) - ! the length of the edge + ! Compute the length of the edge edge_length = sqrt((edge_x(2) - edge_x(1))**2 + & (edge_y(2) - edge_y(1))**2) - ! the number of segments + ! Determine the number of segments if (edge_length > cell_width) then num_segments = Ifactor_2D*ceiling(edge_length/cell_width) else num_segments = 1 end if - ! edge contributes num_segments vertices + ! Each edge contributes num_segments vertices total_vertices = total_vertices + num_segments end do - ! memory for the new boundary vertices array + ! Allocate memory for the new boundary vertices array allocate (interpolated_boundary_v(1:total_vertices, 1:3)) - ! the new boundary vertices array with original and interpolated vertices + ! Fill the new boundary vertices array with original and interpolated vertices total_vertices = 1 do i = 1, boundary_edge_count - ! the coordinates of the two ends of the current edge + ! Get the coordinates of the two ends of the current edge edge_x(1) = boundary_v(i, 1, 1) edge_y(1) = boundary_v(i, 1, 2) edge_x(2) = boundary_v(i, 2, 1) edge_y(2) = boundary_v(i, 2, 2) - ! the length of the edge + ! Compute the length of the edge edge_length = sqrt((edge_x(2) - edge_x(1))**2 + & (edge_y(2) - edge_y(1))**2) - ! the number of segments and interpolation step + ! Determine the number of segments and interpolation step if (edge_length > cell_width) then num_segments = Ifactor_2D*ceiling(edge_length/cell_width) edge_del(1) = (edge_x(2) - edge_x(1))/num_segments @@ -875,14 +875,14 @@ contains interpolated_boundary_v(1, 2) = edge_y(1) interpolated_boundary_v(1, 3) = 0._wp - ! original and interpolated vertices to the output array + ! Add original and interpolated vertices to the output array do j = 1, num_segments - 1 total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = edge_x(1) + j*edge_del(1) interpolated_boundary_v(total_vertices, 2) = edge_y(1) + j*edge_del(2) end do - ! the last vertex of the edge + ! Add the last vertex of the edge if (num_segments > 0) then total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = edge_x(2) @@ -893,10 +893,10 @@ contains end subroutine f_interpolate_2D !> This procedure interpolates 3D models. - !! Model to search in. - !! Dimensions of the current levelset cell - !! Output all the boundary vertices of the interpolated 3D model - !! Total number of vertices after interpolation + !! @param model Model to search in. + !! @param spacing Dimensions of the current levelset cell + !! @param interpolated_boundary_v Output all the boundary vertices of the interpolated 3D model + !! @param total_vertices Total number of vertices after interpolation impure subroutine f_interpolate_3D(model, spacing, interpolated_boundary_v, total_vertices) real(wp), dimension(1:3), intent(in) :: spacing type(t_model), intent(in) :: model @@ -909,47 +909,47 @@ contains real(wp), dimension(1:3) :: bary_coord !< Barycentric coordinates real(wp) :: edge_length, cell_width, cell_area_min, tri_area - ! of triangles in the model + ! Number of triangles in the model num_triangles = model%ntrs cell_width = minval(spacing) - ! the minimum surface area + ! Find the minimum surface area cell_area(1) = spacing(1)*spacing(2) cell_area(2) = spacing(1)*spacing(3) cell_area(3) = spacing(2)*spacing(3) cell_area_min = minval(cell_area) num_inner_vertices = 0 - ! the total number of vertices including interpolated ones + ! Calculate the total number of vertices including interpolated ones total_vertices = 0 do i = 1, num_triangles do j = 1, 3 - ! the coordinates of the two vertices of the current edge + ! Get the coordinates of the two vertices of the current edge tri(1, 1) = model%trs(i)%v(j, 1) tri(1, 2) = model%trs(i)%v(j, 2) tri(1, 3) = model%trs(i)%v(j, 3) - ! vertex in the triangle (cyclic) + ! Next vertex in the triangle (cyclic) tri(2, 1) = model%trs(i)%v(mod(j, 3) + 1, 1) tri(2, 2) = model%trs(i)%v(mod(j, 3) + 1, 2) tri(2, 3) = model%trs(i)%v(mod(j, 3) + 1, 3) - ! the length of the edge + ! Compute the length of the edge edge_length = sqrt((tri(2, 1) - tri(1, 1))**2 + & (tri(2, 2) - tri(1, 2))**2 + & (tri(2, 3) - tri(1, 3))**2) - ! the number of segments + ! Determine the number of segments if (edge_length > cell_width) then num_segments = Ifactor_3D*ceiling(edge_length/cell_width) else num_segments = 1 end if - ! edge contributes num_segments vertices + ! Each edge contributes num_segments vertices total_vertices = total_vertices + num_segments + 1 end do - ! vertices inside the triangle + ! Add vertices inside the triangle do k = 1, 3 tri(k, 1) = model%trs(i)%v(k, 1) tri(k, 2) = model%trs(i)%v(k, 2) @@ -963,29 +963,29 @@ contains end if end do - ! memory for the new boundary vertices array + ! Allocate memory for the new boundary vertices array allocate (interpolated_boundary_v(1:total_vertices, 1:3)) - ! the new boundary vertices array with original and interpolated vertices + ! Fill the new boundary vertices array with original and interpolated vertices total_vertices = 0 do i = 1, num_triangles - ! through the 3 edges of each triangle + ! Loop through the 3 edges of each triangle do j = 1, 3 - ! the coordinates of the two vertices of the current edge + ! Get the coordinates of the two vertices of the current edge tri(1, 1) = model%trs(i)%v(j, 1) tri(1, 2) = model%trs(i)%v(j, 2) tri(1, 3) = model%trs(i)%v(j, 3) - ! vertex in the triangle (cyclic) + ! Next vertex in the triangle (cyclic) tri(2, 1) = model%trs(i)%v(mod(j, 3) + 1, 1) tri(2, 2) = model%trs(i)%v(mod(j, 3) + 1, 2) tri(2, 3) = model%trs(i)%v(mod(j, 3) + 1, 3) - ! the length of the edge + ! Compute the length of the edge edge_length = sqrt((tri(2, 1) - tri(1, 1))**2 + & (tri(2, 2) - tri(1, 2))**2 + & (tri(2, 3) - tri(1, 3))**2) - ! the number of segments and interpolation step + ! Determine the number of segments and interpolation step if (edge_length > cell_width) then num_segments = Ifactor_3D*ceiling(edge_length/cell_width) edge_del(1) = (tri(2, 1) - tri(1, 1))/num_segments @@ -996,7 +996,7 @@ contains edge_del = 0._wp end if - ! original and interpolated vertices to the output array + ! Add original and interpolated vertices to the output array do k = 0, num_segments - 1 total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = tri(1, 1) + k*edge_del(1) @@ -1004,14 +1004,14 @@ contains interpolated_boundary_v(total_vertices, 3) = tri(1, 3) + k*edge_del(3) end do - ! the last vertex of the edge + ! Add the last vertex of the edge total_vertices = total_vertices + 1 interpolated_boundary_v(total_vertices, 1) = tri(2, 1) interpolated_boundary_v(total_vertices, 2) = tri(2, 2) interpolated_boundary_v(total_vertices, 3) = tri(2, 3) end do - ! verties that are not on edges + ! Interpolate verties that are not on edges do k = 1, 3 tri(k, 1) = model%trs(i)%v(k, 1) tri(k, 2) = model%trs(i)%v(k, 2) @@ -1043,10 +1043,10 @@ contains end subroutine f_interpolate_3D !> This procedure determines the levelset distance and normals of the 3D models without interpolation. - !! Model to search in. - !! The cell centers of the current level cell - !! The output levelset normals - !! The output levelset distance + !! @param model Model to search in. + !! @param point The cell centers of the current level cell + !! @param normals The output levelset normals + !! @param distance The output levelset distance subroutine f_distance_normals_3D(model, point, normals, distance) type(t_model), intent(IN) :: model @@ -1076,7 +1076,7 @@ contains (point(3) - tri(j, 3))**2) end do - ! the surface center of each triangle facet + ! Get the surface center of each triangle facet do j = 1, 3 midp(j) = (tri(1, j) + tri(2, j) + tri(3, j))/3 end do @@ -1104,12 +1104,12 @@ contains end subroutine f_distance_normals_3D !> This procedure determines the levelset distance of 2D models without interpolation. - !! Group of all the boundary vertices of the 2D model without interpolation - !! Output the total number of boundary vertices - !! Output the total number of boundary edges - !! The cell centers of the current levelset cell - !! Dimensions of the current levelset cell - !! which the levelset distance without interpolation + !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation + !! @param boundary_vertex_count Output the total number of boundary vertices + !! @param boundary_edge_count Output the total number of boundary edges + !! @param point The cell centers of the current levelset cell + !! @param spacing Dimensions of the current levelset cell + !! @return Distance which the levelset distance without interpolation function f_distance(boundary_v, boundary_edge_count, point) result(distance) integer, intent(in) :: boundary_edge_count @@ -1137,10 +1137,10 @@ contains end function f_distance !> This procedure determines the levelset normals of 2D models without interpolation. - !! Group of all the boundary vertices of the 2D model without interpolation - !! Output the total number of boundary edges - !! The cell centers of the current levelset cell - !! Output levelset normals without interpolation + !! @param boundary_v Group of all the boundary vertices of the 2D model without interpolation + !! @param boundary_edge_count Output the total number of boundary edges + !! @param point The cell centers of the current levelset cell + !! @param normals Output levelset normals without interpolation subroutine f_normals(boundary_v, boundary_edge_count, point, normals) integer, intent(in) :: boundary_edge_count @@ -1197,10 +1197,10 @@ contains end subroutine f_tri_area !> This procedure determines the levelset of interpolated 2D models. - !! Group of all the boundary vertices of the interpolated 2D model - !! Total number of vertices after interpolation - !! The cell centers of the current levelset cell - !! which the levelset distance without interpolation + !! @param interpolated_boundary_v Group of all the boundary vertices of the interpolated 2D model + !! @param total_vertices Total number of vertices after interpolation + !! @param point The cell centers of the current levelset cell + !! @return Distance which the levelset distance without interpolation function f_interpolated_distance(interpolated_boundary_v, total_vertices, point) result(distance) integer, intent(in) :: total_vertices diff --git a/src/common/m_mpi_common.fpp b/src/common/m_mpi_common.fpp index a344a32446..f0b3d6654c 100644 --- a/src/common/m_mpi_common.fpp +++ b/src/common/m_mpi_common.fpp @@ -2,10 +2,10 @@ #:include 'macros.fpp' !> @brief The module serves as a proxy to the parameters and subroutines -!! the MPI implementation's MPI module. Specifically, -!! of the proxy is to harness basic MPI commands into -!! procedures as to accomplish the communication -!! the simulation. +!! available in the MPI implementation's MPI module. Specifically, +!! the purpose of the proxy is to harness basic MPI commands into +!! more complicated procedures as to accomplish the communication +!! goals for the simulation. module m_mpi_common #ifdef MFC_MPI @@ -26,17 +26,17 @@ module m_mpi_common integer, private :: v_size $:GPU_DECLARE(create='[v_size]') - !! used to identify and report MPI errors + !! Generic flags used to identify and report MPI errors real(wp), private, allocatable, dimension(:) :: buff_send !< - !! is utilized to pack and send the buffer of the cell-average - !! for a single computational domain boundary at the - !! the relevant neighboring processor. + !! This variable is utilized to pack and send the buffer of the cell-average + !! primitive variables, for a single computational domain boundary at the + !! time, to the relevant neighboring processor. real(wp), private, allocatable, dimension(:) :: buff_recv !< - !! utilized to receive and unpack the buffer of the cell- - !! variables, for a single computational domain boundary - !! time, from the relevant neighboring processor. + !! buff_recv is utilized to receive and unpack the buffer of the cell- + !! average primitive variables, for a single computational domain boundary + !! at the time, from the relevant neighboring processor. #ifndef __NVCOMPILER_GPU_UNIFIED_MEM $:GPU_DECLARE(create='[buff_send, buff_recv]') @@ -48,14 +48,14 @@ module m_mpi_common contains !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_mpi_common_module #ifdef MFC_MPI - ! buff_send/recv and. Please note that for the sake of - ! both variables are provided sufficient storage to hold - ! largest buffer in the computational domain. + ! Allocating buff_send/recv and. Please note that for the sake of + ! simplicity, both variables are provided sufficient storage to hold + ! the largest buffer in the computational domain. if (qbmm .and. .not. polytropic) then v_size = sys_size + 2*nb*4 @@ -92,41 +92,41 @@ contains end subroutine s_initialize_mpi_common_module !> The subroutine initializes the MPI execution environment - !! both the number of processors which will be - !! the job and the local processor rank. + !! and queries both the number of processors which will be + !! available for the job and the local processor rank. impure subroutine s_mpi_initialize #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the MPI environment + ! Initializing the MPI environment call MPI_INIT(ierr) - ! whether the MPI environment has been properly initialized + ! Checking whether the MPI environment has been properly initialized if (ierr /= MPI_SUCCESS) then print '(A)', 'Unable to initialize MPI environment. Exiting.' call MPI_ABORT(MPI_COMM_WORLD, 1, ierr) end if - ! the number of processors available for the job + ! Querying the number of processors available for the job call MPI_COMM_SIZE(MPI_COMM_WORLD, num_procs, ierr) - ! the rank of the local processor + ! Querying the rank of the local processor call MPI_COMM_RANK(MPI_COMM_WORLD, proc_rank, ierr) #else - ! run only has 1 processor + ! Serial run only has 1 processor num_procs = 1 - ! processor rank is 0 + ! Local processor rank is 0 proc_rank = 0 #endif end subroutine s_mpi_initialize - !! Conservative variables - !! track if a cell is within the immersed boundary - !! closest distance from every cell to the IB - !! normalized vector from every cell to the closest point to the IB - !! Eulerian void fraction from lagrangian bubbles + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary + !! @param levelset closest distance from every cell to the IB + !! @param levelset_norm normalized vector from every cell to the closest point to the IB + !! @param beta Eulerian void fraction from lagrangian bubbles impure subroutine s_initialize_mpi_data(q_cons_vf, ib_markers, levelset, levelset_norm, beta) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -140,7 +140,7 @@ contains #ifdef MFC_MPI - ! loop iterator + ! Generic loop iterator integer :: i, j integer :: ierr !< Generic flag used to identify and report MPI errors @@ -176,7 +176,7 @@ contains end do end if - ! global(g) and local(l) sizes for flow variables + ! Define global(g) and local(l) sizes for flow variables sizes_glb(1) = m_glb + 1; sizes_loc(1) = m + 1 if (n > 0) then sizes_glb(2) = n_glb + 1; sizes_loc(2) = n + 1 @@ -185,7 +185,7 @@ contains end if end if - ! the view for each variable + ! Define the view for each variable do i = 1, alt_sys call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_glb, sizes_loc, start_idx, & MPI_ORDER_FORTRAN, mpi_p, MPI_IO_DATA%view(i), ierr) @@ -277,7 +277,7 @@ contains end subroutine s_initialize_mpi_data - !! Conservative variables + !! @param q_cons_vf Conservative variables subroutine s_initialize_mpi_data_ds(q_cons_vf) type(scalar_field), & @@ -289,7 +289,7 @@ contains #ifdef MFC_MPI - ! loop iterator + ! Generic loop iterator integer :: i, j, q, k, l, m_ds, n_ds, p_ds, ierr sf_start_idx = (/0, 0, 0/) @@ -309,7 +309,7 @@ contains MPI_IO_DATA%var(i)%sf => q_cons_vf(i)%sf(-1:m_ds + 1, -1:n_ds + 1, -1:p_ds + 1) end do #endif - ! global(g) and local(l) sizes for flow variables + ! Define global(g) and local(l) sizes for flow variables sizes_loc(1) = m_ds + 3 if (n > 0) then sizes_loc(2) = n_ds + 3 @@ -318,7 +318,7 @@ contains end if end if - ! the view for each variable + ! Define the view for each variable do i = 1, sys_size call MPI_TYPE_CREATE_SUBARRAY(num_dims, sizes_loc, sizes_loc, sf_start_idx, & MPI_ORDER_FORTRAN, mpi_p, MPI_IO_DATA%view(i), ierr) @@ -388,19 +388,19 @@ contains end subroutine s_prohibit_abort !> The goal of this subroutine is to determine the global - !! the stability criteria in the computational - !! is performed by sifting through the local - !! each stability criterion. Note that each of - !! extrema is from a single process, within its - !! of the computational domain. Finally, - !! the global extrema values are only bookkeept - !! rank 0 processor. - !! Local maximum ICFL stability criterion - !! Local maximum VCFL stability criterion - !! Local minimum Rc stability criterion - !! Global maximum ICFL stability criterion - !! Global maximum VCFL stability criterion - !! Global minimum Rc stability criterion + !! extrema of the stability criteria in the computational + !! domain. This is performed by sifting through the local + !! extrema of each stability criterion. Note that each of + !! the local extrema is from a single process, within its + !! assigned section of the computational domain. Finally, + !! note that the global extrema values are only bookkeept + !! on the rank 0 processor. + !! @param icfl_max_loc Local maximum ICFL stability criterion + !! @param vcfl_max_loc Local maximum VCFL stability criterion + !! @param Rc_min_loc Local minimum Rc stability criterion + !! @param icfl_max_glb Global maximum ICFL stability criterion + !! @param vcfl_max_glb Global maximum VCFL stability criterion + !! @param Rc_min_glb Global minimum Rc stability criterion impure subroutine s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, & vcfl_max_loc, & Rc_min_loc, & @@ -420,8 +420,8 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! local extrema of ICFL, VCFL, CCFL and Rc numbers to their - ! extrema and bookkeeping the results on the rank 0 processor + ! Reducing local extrema of ICFL, VCFL, CCFL and Rc numbers to their + ! global extrema and bookkeeping the results on the rank 0 processor call MPI_REDUCE(icfl_max_loc, icfl_max_glb, 1, & mpi_p, MPI_MAX, 0, & MPI_COMM_WORLD, ierr) @@ -450,12 +450,12 @@ contains end subroutine s_mpi_reduce_stability_criteria_extrema !> The following subroutine takes the input local variable - !! processors and reduces to the sum of all - !! reduced variable is recorded back onto the - !! variable on each processor. - !! Some variable containing the local value which should be - !! all the processors in the communicator. - !! The globally reduced value + !! from all processors and reduces to the sum of all + !! values. The reduced variable is recorded back onto the + !! original local variable on each processor. + !! @param var_loc Some variable containing the local value which should be + !! reduced amongst all the processors in the communicator. + !! @param var_glb The globally reduced value impure subroutine s_mpi_allreduce_sum(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -464,7 +464,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the reduction procedure + ! Performing the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_SUM, MPI_COMM_WORLD, ierr) @@ -483,7 +483,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the reduction procedure + ! Performing the reduction procedure if (loc(var_loc) == loc(var_glb)) then call MPI_Allreduce(MPI_IN_PLACE, var_glb, num_vectors*vector_length, & mpi_p, MPI_SUM, MPI_COMM_WORLD, ierr) @@ -499,12 +499,12 @@ contains end subroutine s_mpi_allreduce_vectors_sum !> The following subroutine takes the input local variable - !! processors and reduces to the sum of all - !! reduced variable is recorded back onto the - !! variable on each processor. - !! Some variable containing the local value which should be - !! all the processors in the communicator. - !! The globally reduced value + !! from all processors and reduces to the sum of all + !! values. The reduced variable is recorded back onto the + !! original local variable on each processor. + !! @param var_loc Some variable containing the local value which should be + !! reduced amongst all the processors in the communicator. + !! @param var_glb The globally reduced value impure subroutine s_mpi_allreduce_integer_sum(var_loc, var_glb) integer, intent(in) :: var_loc @@ -513,7 +513,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the reduction procedure + ! Performing the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, MPI_INTEGER, & MPI_SUM, MPI_COMM_WORLD, ierr) #else @@ -523,12 +523,12 @@ contains end subroutine s_mpi_allreduce_integer_sum !> The following subroutine takes the input local variable - !! processors and reduces to the minimum of all - !! reduced variable is recorded back onto the - !! variable on each processor. - !! Some variable containing the local value which should be - !! all the processors in the communicator. - !! The globally reduced value + !! from all processors and reduces to the minimum of all + !! values. The reduced variable is recorded back onto the + !! original local variable on each processor. + !! @param var_loc Some variable containing the local value which should be + !! reduced amongst all the processors in the communicator. + !! @param var_glb The globally reduced value impure subroutine s_mpi_allreduce_min(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -537,7 +537,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the reduction procedure + ! Performing the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MIN, MPI_COMM_WORLD, ierr) @@ -546,12 +546,12 @@ contains end subroutine s_mpi_allreduce_min !> The following subroutine takes the input local variable - !! processors and reduces to the maximum of all - !! reduced variable is recorded back onto the - !! variable on each processor. - !! Some variable containing the local value which should be - !! all the processors in the communicator. - !! The globally reduced value + !! from all processors and reduces to the maximum of all + !! values. The reduced variable is recorded back onto the + !! original local variable on each processor. + !! @param var_loc Some variable containing the local value which should be + !! reduced amongst all the processors in the communicator. + !! @param var_glb The globally reduced value impure subroutine s_mpi_allreduce_max(var_loc, var_glb) real(wp), intent(in) :: var_loc @@ -560,7 +560,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the reduction procedure + ! Performing the reduction procedure call MPI_ALLREDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MAX, MPI_COMM_WORLD, ierr) @@ -569,11 +569,11 @@ contains end subroutine s_mpi_allreduce_max !> The following subroutine takes the inputted variable and - !! minimum value on the entire computational - !! result is stored back into inputted variable. - !! holds the local value to be reduced among - !! processors in communicator. On output, the variable holds - !! value, reduced amongst all of the local values. + !! determines its minimum value on the entire computational + !! domain. The result is stored back into inputted variable. + !! @param var_loc holds the local value to be reduced among + !! all the processors in communicator. On output, the variable holds + !! the minimum value, reduced amongst all of the local values. impure subroutine s_mpi_reduce_min(var_loc) real(wp), intent(inout) :: var_loc @@ -581,11 +581,11 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! storage variable that holds the reduced minimum value + ! Temporary storage variable that holds the reduced minimum value real(wp) :: var_glb - ! reduction procedure and eventually storing its result - ! the variable that was initially inputted into the subroutine + ! Performing reduction procedure and eventually storing its result + ! into the variable that was initially inputted into the subroutine call MPI_REDUCE(var_loc, var_glb, 1, mpi_p, & MPI_MIN, 0, MPI_COMM_WORLD, ierr) @@ -599,17 +599,17 @@ contains end subroutine s_mpi_reduce_min !> The following subroutine takes the first element of the - !! variable and determines its maximum - !! the entire computational domain. The result is - !! into the first element of the variable while - !! of the processor that is in charge of the sub- - !! the maximum is stored into the second - !! the variable. - !! On input, this variable holds the local value and processor rank, - !! to be reduced among all the processors in communicator. - !! this variable holds the maximum value, reduced amongst - !! the local values, and the process rank to which the value - !! + !! 2-element inputted variable and determines its maximum + !! value on the entire computational domain. The result is + !! stored back into the first element of the variable while + !! the rank of the processor that is in charge of the sub- + !! domain containing the maximum is stored into the second + !! element of the variable. + !! @param var_loc On input, this variable holds the local value and processor rank, + !! which are to be reduced among all the processors in communicator. + !! On output, this variable holds the maximum value, reduced amongst + !! all of the local values, and the process rank to which the value + !! belongs. impure subroutine s_mpi_reduce_maxloc(var_loc) real(wp), dimension(2), intent(inout) :: var_loc @@ -618,11 +618,11 @@ contains integer :: ierr !< Generic flag used to identify and report MPI errors real(wp), dimension(2) :: var_glb !< - !! variable that holds the reduced maximum value - !! rank of the processor with which the value is associated + !! Temporary storage variable that holds the reduced maximum value + !! and the rank of the processor with which the value is associated - ! reduction procedure and eventually storing its result - ! the variable that was initially inputted into the subroutine + ! Performing reduction procedure and eventually storing its result + ! into the variable that was initially inputted into the subroutine call MPI_REDUCE(var_loc, var_glb, 1, mpi_2p, & MPI_MAXLOC, 0, MPI_COMM_WORLD, ierr) @@ -636,7 +636,7 @@ contains end subroutine s_mpi_reduce_maxloc !> The subroutine terminates the MPI execution environment. - !! error message to be printed + !! @param prnt error message to be printed impure subroutine s_mpi_abort(prnt, code) character(len=*), intent(in), optional :: prnt @@ -659,7 +659,7 @@ contains stop 1 end if #else - ! the MPI environment + ! Terminating the MPI environment if (present(code)) then call MPI_ABORT(MPI_COMM_WORLD, code, ierr) else @@ -675,7 +675,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! MPI_BARRIER + ! Calling MPI_BARRIER call MPI_BARRIER(MPI_COMM_WORLD, ierr) #endif @@ -688,7 +688,7 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the MPI environment + ! Finalizing the MPI environment call MPI_FINALIZE(ierr) #endif @@ -696,11 +696,11 @@ contains end subroutine s_mpi_finalize !> The goal of this procedure is to populate the buffers of - !! conservative variables by communicating - !! neighboring processors. - !! Cell-average conservative variables - !! MPI communication coordinate direction - !! Processor boundary condition (PBC) location + !! the cell-average conservative variables by communicating + !! with the neighboring processors. + !! @param q_cons_vf Cell-average conservative variables + !! @param mpi_dir MPI communication coordinate direction + !! @param pbc_loc Processor boundary condition (PBC) location subroutine s_mpi_sendrecv_variables_buffers(q_comm, & mpi_dir, & pbc_loc, & @@ -754,12 +754,12 @@ contains beg_end = (/boundary_conditions(mpi_dir)%beg, boundary_conditions(mpi_dir)%end/) beg_end_geq_0 = beg_end(max(pbc_loc, 0) - pbc_loc + 1) >= 0 - ! - ! bc_x >= 0 -> [send/recv]_tag [dst/src]_proc - ! (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] - ! (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] - ! (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] - ! (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] + ! Implements: + ! pbc_loc bc_x >= 0 -> [send/recv]_tag [dst/src]_proc + ! -1 (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] + ! -1 (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] + ! +1 (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] + ! +1 (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] send_tag = f_logical_to_int(.not. f_xor(beg_end_geq_0, pbc_loc == 1)) recv_tag = f_logical_to_int(pbc_loc == 1) @@ -779,7 +779,7 @@ contains unpack_offset = grid_dims(mpi_dir) + buff_size + 1 end if - ! Buffer to Send + ! Pack Buffer to Send #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then #:if mpi_dir == 1 @@ -936,7 +936,7 @@ contains #:endfor call nvtxEndRange ! Packbuf - ! + ! Send/Recv #ifdef MFC_SIMULATION #:for rdma_mpi in [False, True] if (rdma_mpi .eqv. ${'.true.' if rdma_mpi else '.false.'}$) then @@ -979,7 +979,7 @@ contains MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierr) #endif - ! Received Buffer + ! Unpack Received Buffer call nvtxStartRange("RHS-COMM-UNPACKBUF") #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then @@ -1095,7 +1095,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if #:else - ! buffer from bc_z%beg + ! Unpacking buffer from bc_z%beg $:GPU_PARALLEL_LOOP(collapse=4,private='[r]') do i = 1, nVar do l = -buff_size, -1 @@ -1164,33 +1164,33 @@ contains end subroutine s_mpi_sendrecv_variables_buffers !> The purpose of this procedure is to optimally decompose - !! domain among the available processors. - !! performed by attempting to award each processor, - !! of the coordinate directions, approximately the - !! of cells, and then recomputing the affected - !! + !! the computational domain among the available processors. + !! This is performed by attempting to award each processor, + !! in each of the coordinate directions, approximately the + !! same number of cells, and then recomputing the affected + !! global parameters. subroutine s_mpi_decompose_computational_domain #ifdef MFC_MPI integer :: num_procs_x, num_procs_y, num_procs_z !< - !! of processors in the x-, y- and z-directions + !! Optimal number of processors in the x-, y- and z-directions real(wp) :: tmp_num_procs_x, tmp_num_procs_y, tmp_num_procs_z !< - !! of processors in the x-, y- and z-directions + !! Non-optimal number of processors in the x-, y- and z-directions real(wp) :: fct_min !< - !! (fct) minimization parameter + !! Processor factorization (fct) minimization parameter integer :: MPI_COMM_CART !< - !! topology communicator + !! Cartesian processor topology communicator integer :: rem_cells !< - !! of cells, in a particular coordinate direction, - !! majority is divided up among the available processors + !! Remaining number of cells, in a particular coordinate direction, + !! after the majority is divided up among the available processors integer :: recon_order !< - !! MUSCL reconstruction order + !! WENO or MUSCL reconstruction order integer :: i, j !< Generic loop iterators integer :: ierr !< Generic flag used to identify and report MPI errors @@ -1214,25 +1214,25 @@ contains recon_order = weno_order end if - ! Cartesian Processor Topology + ! 3D Cartesian Processor Topology if (n > 0) then if (p > 0) then if (fft_wrt) then - ! estimate of optimal processor topology + ! Initial estimate of optimal processor topology num_procs_x = 1 num_procs_y = 1 num_procs_z = num_procs ierr = -1 - ! the quality of this initial guess + ! Benchmarking the quality of this initial guess tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z fct_min = 10._wp*abs((n + 1)/tmp_num_procs_y & - (p + 1)/tmp_num_procs_z) - ! of the initial processor topology + ! Optimization of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1263,24 +1263,24 @@ contains else if (cyl_coord .and. p > 0) then - ! pencil processor blocking if using cylindrical coordinates so - ! all cells in azimuthal direction are stored on a single processor. - ! is necessary for efficient application of Fourier filter near axis. + ! Implement pencil processor blocking if using cylindrical coordinates so + ! that all cells in azimuthal direction are stored on a single processor. + ! This is necessary for efficient application of Fourier filter near axis. - ! values of the processor factorization optimization + ! Initial values of the processor factorization optimization num_procs_x = 1 num_procs_y = num_procs num_procs_z = 1 ierr = -1 - ! minimization variable for these initial values + ! Computing minimization variable for these initial values tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z fct_min = 10._wp*abs((m + 1)/tmp_num_procs_x & - (n + 1)/tmp_num_procs_y) - ! for optimal computational domain distribution + ! Searching for optimal computational domain distribution do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1311,13 +1311,13 @@ contains else - ! estimate of optimal processor topology + ! Initial estimate of optimal processor topology num_procs_x = 1 num_procs_y = 1 num_procs_z = num_procs ierr = -1 - ! the quality of this initial guess + ! Benchmarking the quality of this initial guess tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y tmp_num_procs_z = num_procs_z @@ -1326,7 +1326,7 @@ contains + 10._wp*abs((n + 1)/tmp_num_procs_y & - (p + 1)/tmp_num_procs_z) - ! of the initial processor topology + ! Optimization of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1375,41 +1375,41 @@ contains end if end if - ! that a valid decomposition of the computational - ! has been established. If not, the simulation exits. + ! Verifying that a valid decomposition of the computational + ! domain has been established. If not, the simulation exits. if (proc_rank == 0 .and. ierr == -1) then call s_mpi_abort('Unsupported combination of values '// & 'of num_procs, m, n, p and '// & 'weno/muscl/igr_order. Exiting.') end if - ! new communicator using the Cartesian topology + ! Creating new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 3, (/num_procs_x, & num_procs_y, num_procs_z/), & (/.true., .true., .true./), & .false., MPI_COMM_CART, ierr) - ! the Cartesian coordinates of the local process + ! Finding the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 3, & proc_coords, ierr) - ! 3D Cartesian Processor Topology + ! END: 3D Cartesian Processor Topology - ! Parameters for z-direction + ! Global Parameters for z-direction - ! of remaining cells + ! Number of remaining cells rem_cells = mod(p + 1, num_procs_z) - ! number of cells per processor + ! Optimal number of cells per processor p = (p + 1)/num_procs_z - 1 - ! the remaining cells + ! Distributing the remaining cells do i = 1, rem_cells if (proc_coords(3) == i - 1) then p = p + 1; exit end if end do - ! condition at the beginning + ! Boundary condition at the beginning if (proc_coords(3) > 0 .or. (bc_z%beg == BC_PERIODIC .and. num_procs_z > 1)) then proc_coords(3) = proc_coords(3) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1417,7 +1417,7 @@ contains proc_coords(3) = proc_coords(3) + 1 end if - ! condition at the end + ! Boundary condition at the end if (proc_coords(3) < num_procs_z - 1 .or. (bc_z%end == BC_PERIODIC .and. num_procs_z > 1)) then proc_coords(3) = proc_coords(3) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1426,14 +1426,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! zone at the beginning + ! Ghost zone at the beginning if (proc_coords(3) > 0 .and. format == 1) then offset_z%beg = 2 else offset_z%beg = 0 end if - ! zone at the end + ! Ghost zone at the end if (proc_coords(3) < num_procs_z - 1 .and. format == 1) then offset_z%end = 2 else @@ -1441,7 +1441,7 @@ contains end if #endif - ! and end sub-domain boundary locations + ! Beginning and end sub-domain boundary locations if (parallel_io) then if (proc_coords(3) < rem_cells) then start_idx(3) = (p + 1)*proc_coords(3) @@ -1469,21 +1469,21 @@ contains #endif end if - ! Cartesian Processor Topology + ! 2D Cartesian Processor Topology else - ! estimate of optimal processor topology + ! Initial estimate of optimal processor topology num_procs_x = 1 num_procs_y = num_procs ierr = -1 - ! the quality of this initial guess + ! Benchmarking the quality of this initial guess tmp_num_procs_x = num_procs_x tmp_num_procs_y = num_procs_y fct_min = 10._wp*abs((m + 1)/tmp_num_procs_x & - (n + 1)/tmp_num_procs_y) - ! of the initial processor topology + ! Optimization of the initial processor topology do i = 1, num_procs if (mod(num_procs, i) == 0 & @@ -1512,43 +1512,43 @@ contains end do - ! that a valid decomposition of the computational - ! has been established. If not, the simulation exits. + ! Verifying that a valid decomposition of the computational + ! domain has been established. If not, the simulation exits. if (proc_rank == 0 .and. ierr == -1) then call s_mpi_abort('Unsupported combination of values '// & 'of num_procs, m, n and '// & 'weno/muscl/igr_order. Exiting.') end if - ! new communicator using the Cartesian topology + ! Creating new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 2, (/num_procs_x, & num_procs_y/), (/.true., & .true./), .false., MPI_COMM_CART, & ierr) - ! the Cartesian coordinates of the local process + ! Finding the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 2, & proc_coords, ierr) end if - ! 2D Cartesian Processor Topology + ! END: 2D Cartesian Processor Topology - ! Parameters for y-direction + ! Global Parameters for y-direction - ! of remaining cells + ! Number of remaining cells rem_cells = mod(n + 1, num_procs_y) - ! number of cells per processor + ! Optimal number of cells per processor n = (n + 1)/num_procs_y - 1 - ! the remaining cells + ! Distributing the remaining cells do i = 1, rem_cells if (proc_coords(2) == i - 1) then n = n + 1; exit end if end do - ! condition at the beginning + ! Boundary condition at the beginning if (proc_coords(2) > 0 .or. (bc_y%beg == BC_PERIODIC .and. num_procs_y > 1)) then proc_coords(2) = proc_coords(2) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1556,7 +1556,7 @@ contains proc_coords(2) = proc_coords(2) + 1 end if - ! condition at the end + ! Boundary condition at the end if (proc_coords(2) < num_procs_y - 1 .or. (bc_y%end == BC_PERIODIC .and. num_procs_y > 1)) then proc_coords(2) = proc_coords(2) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, & @@ -1565,14 +1565,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! zone at the beginning + ! Ghost zone at the beginning if (proc_coords(2) > 0 .and. format == 1) then offset_y%beg = 2 else offset_y%beg = 0 end if - ! zone at the end + ! Ghost zone at the end if (proc_coords(2) < num_procs_y - 1 .and. format == 1) then offset_y%end = 2 else @@ -1580,7 +1580,7 @@ contains end if #endif - ! and end sub-domain boundary locations + ! Beginning and end sub-domain boundary locations if (parallel_io) then if (proc_coords(2) < rem_cells) then start_idx(2) = (n + 1)*proc_coords(2) @@ -1608,32 +1608,32 @@ contains #endif end if - ! Cartesian Processor Topology + ! 1D Cartesian Processor Topology else - ! processor topology + ! Optimal processor topology num_procs_x = num_procs - ! new communicator using the Cartesian topology + ! Creating new communicator using the Cartesian topology call MPI_CART_CREATE(MPI_COMM_WORLD, 1, (/num_procs_x/), & (/.true./), .false., MPI_COMM_CART, & ierr) - ! the Cartesian coordinates of the local process + ! Finding the Cartesian coordinates of the local process call MPI_CART_COORDS(MPI_COMM_CART, proc_rank, 1, & proc_coords, ierr) end if - ! Parameters for x-direction + ! Global Parameters for x-direction - ! of remaining cells + ! Number of remaining cells rem_cells = mod(m + 1, num_procs_x) - ! number of cells per processor + ! Optimal number of cells per processor m = (m + 1)/num_procs_x - 1 - ! the remaining cells + ! Distributing the remaining cells do i = 1, rem_cells if (proc_coords(1) == i - 1) then m = m + 1; exit @@ -1642,14 +1642,14 @@ contains call s_update_cell_bounds(cells_bounds, m, n, p) - ! condition at the beginning + ! Boundary condition at the beginning if (proc_coords(1) > 0 .or. (bc_x%beg == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) - 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%beg, ierr) proc_coords(1) = proc_coords(1) + 1 end if - ! condition at the end + ! Boundary condition at the end if (proc_coords(1) < num_procs_x - 1 .or. (bc_x%end == BC_PERIODIC .and. num_procs_x > 1)) then proc_coords(1) = proc_coords(1) + 1 call MPI_CART_RANK(MPI_COMM_CART, proc_coords, bc_x%end, ierr) @@ -1657,14 +1657,14 @@ contains end if #ifdef MFC_POST_PROCESS - ! zone at the beginning + ! Ghost zone at the beginning if (proc_coords(1) > 0 .and. format == 1) then offset_x%beg = 2 else offset_x%beg = 0 end if - ! zone at the end + ! Ghost zone at the end if (proc_coords(1) < num_procs_x - 1 .and. format == 1) then offset_x%end = 2 else @@ -1672,7 +1672,7 @@ contains end if #endif - ! and end sub-domain boundary locations + ! Beginning and end sub-domain boundary locations if (parallel_io) then if (proc_coords(1) < rem_cells) then start_idx(1) = (m + 1)*proc_coords(1) @@ -1704,13 +1704,13 @@ contains end subroutine s_mpi_decompose_computational_domain !> The goal of this procedure is to populate the buffers of - !! variables by communicating with the neighboring - !! that only the buffers of the cell-width - !! handled in such a way. This is because - !! of cell-boundary locations may be calculated - !! those of the cell-width distributions. - !! MPI communication coordinate direction - !! Processor boundary condition (PBC) location + !! the grid variables by communicating with the neighboring + !! processors. Note that only the buffers of the cell-width + !! distributions are handled in such a way. This is because + !! the buffers of cell-boundary locations may be calculated + !! directly from those of the cell-width distributions. + !! @param mpi_dir MPI communication coordinate direction + !! @param pbc_loc Processor boundary condition (PBC) location #ifndef MFC_PRE_PROCESS subroutine s_mpi_sendrecv_grid_variables_buffers(mpi_dir, pbc_loc) @@ -1720,14 +1720,14 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! Communication in x-direction + ! MPI Communication in x-direction if (mpi_dir == 1) then if (pbc_loc == -1) then ! PBC at the beginning if (bc_x%end >= 0) then ! PBC at the beginning and end - ! buffer to/from bc_x%end/bc_x%beg + ! Send/receive buffer to/from bc_x%end/bc_x%beg call MPI_SENDRECV( & dx(m - buff_size + 1), buff_size, & mpi_p, bc_x%end, 0, & @@ -1737,7 +1737,7 @@ contains else ! PBC at the beginning only - ! buffer to/from bc_x%beg/bc_x%beg + ! Send/receive buffer to/from bc_x%beg/bc_x%beg call MPI_SENDRECV( & dx(0), buff_size, & mpi_p, bc_x%beg, 1, & @@ -1751,7 +1751,7 @@ contains if (bc_x%beg >= 0) then ! PBC at the end and beginning - ! buffer to/from bc_x%beg/bc_x%end + ! Send/receive buffer to/from bc_x%beg/bc_x%end call MPI_SENDRECV( & dx(0), buff_size, & mpi_p, bc_x%beg, 1, & @@ -1761,7 +1761,7 @@ contains else ! PBC at the end only - ! buffer to/from bc_x%end/bc_x%end + ! Send/receive buffer to/from bc_x%end/bc_x%end call MPI_SENDRECV( & dx(m - buff_size + 1), buff_size, & mpi_p, bc_x%end, 0, & @@ -1772,16 +1772,16 @@ contains end if end if - ! MPI Communication in x-direction + ! END: MPI Communication in x-direction - ! Communication in y-direction + ! MPI Communication in y-direction elseif (mpi_dir == 2) then if (pbc_loc == -1) then ! PBC at the beginning if (bc_y%end >= 0) then ! PBC at the beginning and end - ! buffer to/from bc_y%end/bc_y%beg + ! Send/receive buffer to/from bc_y%end/bc_y%beg call MPI_SENDRECV( & dy(n - buff_size + 1), buff_size, & mpi_p, bc_y%end, 0, & @@ -1791,7 +1791,7 @@ contains else ! PBC at the beginning only - ! buffer to/from bc_y%beg/bc_y%beg + ! Send/receive buffer to/from bc_y%beg/bc_y%beg call MPI_SENDRECV( & dy(0), buff_size, & mpi_p, bc_y%beg, 1, & @@ -1805,7 +1805,7 @@ contains if (bc_y%beg >= 0) then ! PBC at the end and beginning - ! buffer to/from bc_y%beg/bc_y%end + ! Send/receive buffer to/from bc_y%beg/bc_y%end call MPI_SENDRECV( & dy(0), buff_size, & mpi_p, bc_y%beg, 1, & @@ -1815,7 +1815,7 @@ contains else ! PBC at the end only - ! buffer to/from bc_y%end/bc_y%end + ! Send/receive buffer to/from bc_y%end/bc_y%end call MPI_SENDRECV( & dy(n - buff_size + 1), buff_size, & mpi_p, bc_y%end, 0, & @@ -1826,16 +1826,16 @@ contains end if end if - ! MPI Communication in y-direction + ! END: MPI Communication in y-direction - ! Communication in z-direction + ! MPI Communication in z-direction else if (pbc_loc == -1) then ! PBC at the beginning if (bc_z%end >= 0) then ! PBC at the beginning and end - ! buffer to/from bc_z%end/bc_z%beg + ! Send/receive buffer to/from bc_z%end/bc_z%beg call MPI_SENDRECV( & dz(p - buff_size + 1), buff_size, & mpi_p, bc_z%end, 0, & @@ -1845,7 +1845,7 @@ contains else ! PBC at the beginning only - ! buffer to/from bc_z%beg/bc_z%beg + ! Send/receive buffer to/from bc_z%beg/bc_z%beg call MPI_SENDRECV( & dz(0), buff_size, & mpi_p, bc_z%beg, 1, & @@ -1859,7 +1859,7 @@ contains if (bc_z%beg >= 0) then ! PBC at the end and beginning - ! buffer to/from bc_z%beg/bc_z%end + ! Send/receive buffer to/from bc_z%beg/bc_z%end call MPI_SENDRECV( & dz(0), buff_size, & mpi_p, bc_z%beg, 1, & @@ -1869,7 +1869,7 @@ contains else ! PBC at the end only - ! buffer to/from bc_z%end/bc_z%end + ! Send/receive buffer to/from bc_z%end/bc_z%end call MPI_SENDRECV( & dz(p - buff_size + 1), buff_size, & mpi_p, bc_z%end, 0, & @@ -1882,7 +1882,7 @@ contains end if end if - ! MPI Communication in z-direction + ! END: MPI Communication in z-direction #endif end subroutine s_mpi_sendrecv_grid_variables_buffers diff --git a/src/common/m_phase_change.fpp b/src/common/m_phase_change.fpp index e10428175f..703b78c430 100644 --- a/src/common/m_phase_change.fpp +++ b/src/common/m_phase_change.fpp @@ -47,21 +47,21 @@ module m_phase_change contains !> This subroutine should dispatch to the correct relaxation solver based - !! It replaces the procedure pointer, which CCE - !! on. + !! some parameter. It replaces the procedure pointer, which CCE + !! is breaking on. impure subroutine s_relaxation_solver(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf - ! is empty because in current master the procedure pointer - ! never assigned + ! This is empty because in current master the procedure pointer + ! was never assigned @:ASSERT(.false., "s_relaxation_solver called but it currently does nothing") end subroutine s_relaxation_solver !> The purpose of this subroutine is to initialize the phase change module - !! the parameters needed for phase change and - !! phase change module that will be used - !! pTg-equilibrium) + !! by setting the parameters needed for phase change and + !! selecting the phase change module that will be used + !! (pT- or pTg-equilibrium) impure subroutine s_initialize_phasechange_module - ! used in the calculation of the saturation curves for fluids 1 and 2 + ! variables used in the calculation of the saturation curves for fluids 1 and 2 A = (gs_min(lp)*cvs(lp) - gs_min(vp)*cvs(vp) & + qvps(vp) - qvps(lp))/((gs_min(vp) - 1.0_wp)*cvs(vp)) @@ -76,10 +76,10 @@ contains end subroutine s_initialize_phasechange_module !> This subroutine is created to activate either the pT- (N fluids) or the - !! fluids for g-equilibrium) - !! considering mass depletion, depending on the incoming - !! - !! Cell-average conservative variables + !! pTg-equilibrium (2 fluids for g-equilibrium) + !! model, also considering mass depletion, depending on the incoming + !! state conditions. + !! @param q_cons_vf Cell-average conservative variables subroutine s_infinite_relaxation_k(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -89,19 +89,19 @@ contains real(wp) :: rho, rM, m1, m2, MCT !< total density, total reacting mass, individual reacting masses real(wp) :: TvF !< total volume fraction - ! - ! + ! $:GPU_DECLARE(create='[pS,pSOV,pSSL,TS,TSOV,TSSL,TSatOV,TSatSL]') + ! $:GPU_DECLARE(create='[rhoe,dynE,rhos,rho,rM,m1,m2,MCT,TvF]') #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok #:else real(wp), dimension(num_fluids) :: p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok #:endif - ! + ! $:GPU_DECLARE(create='[p_infOV,p_infpT,p_infSL,sk,hk,gk,ek,rhok]') !< Generic loop iterators integer :: i, j, k, l - ! equilibrium solver + ! starting equilibrium solver $:GPU_PARALLEL_LOOP(collapse=3, private='[i,j,k,l,p_infOV, p_infpT, p_infSL, sk, hk, gk, ek, rhok,pS, pSOV, pSSL, TS, TSOV, TSatOV, TSatSL, TSSL, rhoe, dynE, rhos, rho, rM, m1, m2, MCT, TvF]') do j = 0, m do k = 0, n @@ -111,28 +111,28 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! density + ! Mixture density rho = rho + q_cons_vf(i + contxb - 1)%sf(j, k, l) - ! Volume Fraction + ! Total Volume Fraction TvF = TvF + q_cons_vf(i + advxb - 1)%sf(j, k, l) end do - ! the total reacting mass for the phase change process. By hypothesis, this should not change - ! the phase-change process. + ! calculating the total reacting mass for the phase change process. By hypothesis, this should not change + ! throughout the phase-change process. rM = q_cons_vf(lp + contxb - 1)%sf(j, k, l) + q_cons_vf(vp + contxb - 1)%sf(j, k, l) - ! negative (reacting) mass fraction values in case they happen + ! correcting negative (reacting) mass fraction values in case they happen call s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l) - ! m1 and m2 AFTER correcting the partial densities. Note that these values must be stored for the phase - ! process that will happen a posteriori + ! fixing m1 and m2 AFTER correcting the partial densities. Note that these values must be stored for the phase + ! change process that will happen a posteriori m1 = q_cons_vf(lp + contxb - 1)%sf(j, k, l) m2 = q_cons_vf(vp + contxb - 1)%sf(j, k, l) - ! energy as an auxiliary variable to the calculation of the total internal energy + ! kinetic energy as an auxiliary variable to the calculation of the total internal energy dynE = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = momxb, momxe @@ -141,136 +141,136 @@ contains end do - ! the total energy that MUST be preserved throughout the pT- and pTg-relaxation procedures - ! each of the cells. The internal energy is calculated as the total energy minus the kinetic - ! to preserved its value at sharp interfaces + ! calculating the total energy that MUST be preserved throughout the pT- and pTg-relaxation procedures + ! at each of the cells. The internal energy is calculated as the total energy minus the kinetic + ! energy to preserved its value at sharp interfaces rhoe = q_cons_vf(E_idx)%sf(j, k, l) - dynE - ! pT-equilibrium for either finishing phase-change module, or as an IC for the pTg-equilibrium - ! this case, MFL cannot be either 0 or 1, so I chose it to be 2 + ! Calling pT-equilibrium for either finishing phase-change module, or as an IC for the pTg-equilibrium + ! for this case, MFL cannot be either 0 or 1, so I chose it to be 2 call s_infinite_pt_relaxation_k(j, k, l, 2, pS, p_infpT, q_cons_vf, rhoe, TS) - ! if pTg-equilibrium is required - ! that NOTHING else needs to be updated OTHER than the individual partial densities - ! the outputs from the pT- and pTg-equilibrium solvers are just p and one of the partial masses - ! case) + ! check if pTg-equilibrium is required + ! NOTE that NOTHING else needs to be updated OTHER than the individual partial densities + ! given the outputs from the pT- and pTg-equilibrium solvers are just p and one of the partial masses + ! (pTg- case) if ((relax_model == 6) .and. ((q_cons_vf(lp + contxb - 1)%sf(j, k, l) > mixM*rM) & .and. (q_cons_vf(vp + contxb - 1)%sf(j, k, l) > mixM*rM)) & .and. (pS < pCr) .and. (TS < TCr)) then - ! if phase change is needed, by checking whether the final solution is either subcoooled - ! or overheated vapor. + ! Checking if phase change is needed, by checking whether the final solution is either subcoooled + ! liquid or overheated vapor. - ! vapor case - ! the mass of liquid + ! overheated vapor case + ! depleting the mass of liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = mixM*rM - ! the total mass to vapor + ! transferring the total mass to vapor q_cons_vf(vp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! pT-equilibrium for overheated vapor, which is MFL = 0 + ! calling pT-equilibrium for overheated vapor, which is MFL = 0 call s_infinite_pt_relaxation_k(j, k, l, 0, pSOV, p_infOV, q_cons_vf, rhoe, TSOV) - ! Saturation temperature + ! calculating Saturation temperature call s_TSat(pSOV, TSatOV, TSOV) - ! liquid case - ! the total mass to liquid + ! subcooled liquid case + ! transferring the total mass to liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! the mass of vapor + ! depleting the mass of vapor q_cons_vf(vp + contxb - 1)%sf(j, k, l) = mixM*rM - ! pT-equilibrium for subcooled liquid, which is MFL = 1 + ! calling pT-equilibrium for subcooled liquid, which is MFL = 1 call s_infinite_pt_relaxation_k(j, k, l, 1, pSSL, p_infSL, q_cons_vf, rhoe, TSSL) - ! Saturation temperature + ! calculating Saturation temperature call s_TSat(pSSL, TSatSL, TSSL) - ! the conditions for overheated vapor and subcooled liquide + ! checking the conditions for overheated vapor and subcooled liquide if (TSOV > TSatOV) then - ! pressure + ! Assigning pressure pS = pSOV - ! Temperature + ! Assigning Temperature TS = TSOV - ! the liquid partial density + ! correcting the liquid partial density q_cons_vf(lp + contxb - 1)%sf(j, k, l) = mixM*rM - ! the vapor partial density + ! correcting the vapor partial density q_cons_vf(vp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM elseif (TSSL < TSatSL) then - ! pressure + ! Assigning pressure pS = pSSL - ! Temperature + ! Assigning Temperature TS = TSSL - ! the liquid partial density + ! correcting the liquid partial density q_cons_vf(lp + contxb - 1)%sf(j, k, l) = (1.0_wp - mixM)*rM - ! the vapor partial density + ! correcting the vapor partial density q_cons_vf(vp + contxb - 1)%sf(j, k, l) = mixM*rM else - ! partial pressures to what they were from the homogeneous solver - ! + ! returning partial pressures to what they were from the homogeneous solver + ! liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = m1 - ! + ! vapor q_cons_vf(vp + contxb - 1)%sf(j, k, l) = m2 - ! the pTg-equilibrium solver + ! calling the pTg-equilibrium solver call s_infinite_ptg_relaxation_k(j, k, l, pS, p_infpT, rhoe, q_cons_vf, TS) end if end if - ! AFTER equilibrium + ! Calculations AFTER equilibrium $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! + ! entropy sk(i) = cvs(i)*log((TS**gs_min(i)) & /((pS + ps_inf(i))**(gs_min(i) - 1.0_wp))) + qvps(i) - ! + ! enthalpy hk(i) = gs_min(i)*cvs(i)*TS & + qvs(i) - ! energy + ! Gibbs-free energy gk(i) = hk(i) - TS*sk(i) - ! + ! densities rhok(i) = (pS + ps_inf(i)) & /((gs_min(i) - 1)*cvs(i)*TS) - ! energy + ! internal energy ek(i) = (pS + gs_min(i) & *ps_inf(i))/(pS + ps_inf(i)) & *cvs(i)*TS + qvs(i) end do - ! volume fractions, internal energies, and total entropy + ! calculating volume fractions, internal energies, and total entropy rhos = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! fractions + ! volume fractions q_cons_vf(i + advxb - 1)%sf(j, k, l) = q_cons_vf(i + contxb - 1)%sf(j, k, l)/rhok(i) - ! + ! alpha*rho*e if (model_eqns == 3) then q_cons_vf(i + intxb - 1)%sf(j, k, l) = q_cons_vf(i + contxb - 1)%sf(j, k, l)*ek(i) end if - ! entropy + ! Total entropy rhos = rhos + q_cons_vf(i + contxb - 1)%sf(j, k, l)*sk(i) end do @@ -282,21 +282,21 @@ contains end subroutine s_infinite_relaxation_k !> This auxiliary subroutine is created to activate the pT-equilibrium for N fluids - !! generic loop iterator for x direction - !! generic loop iterator for y direction - !! generic loop iterator for z direction - !! flag that tells whether the fluid is gas (0), liquid (1), or a mixture (2) - !! equilibrium pressure at the interface - !! stiffness for the participating fluids under pT-equilibrium - !! sum of the reacting masses - !! Cell-average conservative variables - !! mixture energy - !! equilibrium temperature at the interface + !! @param j generic loop iterator for x direction + !! @param k generic loop iterator for y direction + !! @param l generic loop iterator for z direction + !! @param MFL flag that tells whether the fluid is gas (0), liquid (1), or a mixture (2) + !! @param pS equilibrium pressure at the interface + !! @param p_infpT stiffness for the participating fluids under pT-equilibrium + !! @param rM sum of the reacting masses + !! @param q_cons_vf Cell-average conservative variables + !! @param rhoe mixture energy + !! @param TS equilibrium temperature at the interface subroutine s_infinite_pt_relaxation_k(j, k, l, MFL, pS, p_infpT, q_cons_vf, rhoe, TS) $:GPU_ROUTINE(function_name='s_infinite_pt_relaxation_k', & & parallelism='[seq]', cray_inline=True) - ! variables + ! initializing variables integer, intent(in) :: j, k, l, MFL real(wp), intent(out) :: pS real(wp), dimension(1:), intent(out) :: p_infpT @@ -308,21 +308,21 @@ contains integer :: i, ns !< generic loop iterators - ! variables for the pT-equilibrium solver + ! auxiliary variables for the pT-equilibrium solver mCP = 0.0_wp; mQ = 0.0_wp; p_infpT_sum = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids p_infpT(i) = ps_inf(i) p_infpT_sum = p_infpT_sum + abs(p_infpT(i)) end do - ! tests before initializing the pT-equilibrium + ! Performing tests before initializing the pT-equilibrium $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! of the total alpha*rho*cp of the system + ! sum of the total alpha*rho*cp of the system mCP = mCP + q_cons_vf(i + contxb - 1)%sf(j, k, l)*cvs(i)*gs_min(i) - ! of the total alpha*rho*q of the system + ! sum of the total alpha*rho*q of the system mQ = mQ + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) end do @@ -336,16 +336,16 @@ contains end if #:endif - ! energy constraint + ! Checking energy constraint if ((rhoe - mQ - minval(p_infpT)) < 0.0_wp) then if ((MFL == 0) .or. (MFL == 1)) then - ! zero values for mass depletion cases - ! + ! Assigning zero values for mass depletion cases + ! pressure pS = 0.0_wp - ! + ! temperature TS = 0.0_wp return @@ -353,26 +353,26 @@ contains end if - ! initial estimate for pressure in the pT-relaxation procedure. I will also use this variable to - ! over the Newton's solver + ! calculating initial estimate for pressure in the pT-relaxation procedure. I will also use this variable to + ! iterate over the Newton's solver pO = 0.0_wp - ! improve this condition afterwards. As long as the initial guess is in between -min(ps_inf) - ! infinity, a solution should be able to be found. + ! Maybe improve this condition afterwards. As long as the initial guess is in between -min(ps_inf) + ! and infinity, a solution should be able to be found. pS = 1.0e4_wp - ! Solver for the pT-equilibrium + ! Newton Solver for the pT-equilibrium ns = 0 - ! this relative error metric. 1.e4_wp is just arbitrary + ! change this relative error metric. 1.e4_wp is just arbitrary do while ((abs(pS - pO) > palpha_eps) .and. (abs((pS - pO)/pO) > palpha_eps/1.e4_wp) .or. (ns == 0)) - ! counter + ! increasing counter ns = ns + 1 - ! old pressure + ! updating old pressure pO = pS - ! functions used in the Newton's solver + ! updating functions used in the Newton's solver gpp = 0.0_wp; gp = 0.0_wp; hp = 0.0_wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -387,26 +387,26 @@ contains hp = 1.0_wp/(rhoe + pS - mQ) + 1.0_wp/(pS + minval(p_infpT)) - ! common pressure for the newton solver + ! updating common pressure for the newton solver pS = pO + ((1.0_wp - gp)/gpp)/(1.0_wp - (1.0_wp - gp + abs(1.0_wp - gp)) & /(2.0_wp*gpp)*hp) end do - ! temperature + ! common temperature TS = (rhoe + pS - mQ)/mCP end subroutine s_infinite_pt_relaxation_k !> This auxiliary subroutine is created to activate the pTg-equilibrium for N fluids under pT - !! fluids under pTg-equilibrium. There is a final common p and T during relaxation - !! generic loop iterator for x direction - !! generic loop iterator for y direction - !! generic loop iterator for z direction - !! equilibrium pressure at the interface - !! stiffness for the participating fluids under pT-equilibrium - !! mixture energy - !! Cell-average conservative variables - !! equilibrium temperature at the interface + !! and 2 fluids under pTg-equilibrium. There is a final common p and T during relaxation + !! @param j generic loop iterator for x direction + !! @param k generic loop iterator for y direction + !! @param l generic loop iterator for z direction + !! @param pS equilibrium pressure at the interface + !! @param p_infpT stiffness for the participating fluids under pT-equilibrium + !! @param rhoe mixture energy + !! @param q_cons_vf Cell-average conservative variables + !! @param TS equilibrium temperature at the interface subroutine s_infinite_ptg_relaxation_k(j, k, l, pS, p_infpT, rhoe, q_cons_vf, TS) $:GPU_ROUTINE(function_name='s_infinite_ptg_relaxation_k', & & parallelism='[seq]', cray_inline=True) @@ -430,12 +430,12 @@ contains !< Generic loop iterators integer :: i, ns - ! solution procedure - ! Solver parameters - ! + ! pTg-equilibrium solution procedure + ! Newton Solver parameters + ! counter ns = 0 - ! factor + ! Relaxation factor Om = 1.0e-3_wp p_infpTg = p_infpT @@ -445,41 +445,41 @@ contains - gs_min(lp)*ps_inf(lp)/(gs_min(lp) - 1))/qvs(lp)))) .or. & ((pS >= 0.0_wp) .and. (pS < 1.0e-1_wp))) then - ! this initial condition + ! improve this initial condition pS = 1.0e4_wp end if - ! until the solution for F(X) is satisfied - ! whether I need to use both absolute and relative values - ! the residual, and how to do it adequately. - ! guess to start the pTg-equilibrium problem. - ! this initial condition + ! Loop until the solution for F(X) is satisfied + ! Check whether I need to use both absolute and relative values + ! for the residual, and how to do it adequately. + ! Dummy guess to start the pTg-equilibrium problem. + ! improve this initial condition R2D(1) = 0.0_wp; R2D(2) = 0.0_wp DeltamP(1) = 0.0_wp; DeltamP(2) = 0.0_wp do while (((sqrt(R2D(1)**2 + R2D(2)**2) > ptgalpha_eps) & .and. ((sqrt(R2D(1)**2 + R2D(2)**2)/rhoe) > (ptgalpha_eps/1.e6_wp))) & .or. (ns == 0)) - ! counter for the iterative procedure + ! Updating counter for the iterative procedure ns = ns + 1 - ! variables to help in the calculation of the residue + ! Auxiliary variables to help in the calculation of the residue mCP = 0.0_wp; mCPD = 0.0_wp; mCVGP = 0.0_wp; mCVGP2 = 0.0_wp; mQ = 0.0_wp; mQD = 0.0_wp - ! must be updated through the iterations, as they either depend on - ! partial masses for all fluids, or on the equilibrium pressure + ! Those must be updated through the iterations, as they either depend on + ! the partial masses for all fluids, or on the equilibrium pressure $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! of the total alpha*rho*cp of the system + ! sum of the total alpha*rho*cp of the system mCP = mCP + q_cons_vf(i + contxb - 1)%sf(j, k, l) & *cvs(i)*gs_min(i) - ! of the total alpha*rho*q of the system + ! sum of the total alpha*rho*q of the system mQ = mQ + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) - ! auxiliary variables now need to be updated, as the partial densities now - ! at every iteration + ! These auxiliary variables now need to be updated, as the partial densities now + ! vary at every iteration if ((i /= lp) .and. (i /= vp)) then mCVGP = mCVGP + q_cons_vf(i + contxb - 1)%sf(j, k, l) & @@ -490,7 +490,7 @@ contains mQD = mQD + q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) - ! of the total alpha*rho*cp of the system + ! sum of the total alpha*rho*cp of the system mCPD = mCPD + q_cons_vf(i + contxb - 1)%sf(j, k, l)*cvs(i) & *gs_min(i) @@ -498,12 +498,12 @@ contains end do - ! the (2D) Jacobian Matrix used in the solution of the pTg-quilibrium model + ! calculating the (2D) Jacobian Matrix used in the solution of the pTg-quilibrium model - ! of the reacting liquid + ! mass of the reacting liquid ml = q_cons_vf(lp + contxb - 1)%sf(j, k, l) - ! of the two participating fluids + ! mass of the two participating fluids mT = q_cons_vf(lp + contxb - 1)%sf(j, k, l) & + q_cons_vf(vp + contxb - 1)%sf(j, k, l) @@ -526,19 +526,19 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))**2) & + mCVGP2)*TS**2 - ! = (F1,F2) is the function whose roots we are looking for - ! = (m1, p) are the independent variables. m1 = mass of the first participant fluid, p = pressure - ! = 0 is the Gibbs free energy quality - ! = 0 is the enforcement of the thermodynamic (total - kinectic) energy - ! + ! F = (F1,F2) is the function whose roots we are looking for + ! x = (m1, p) are the independent variables. m1 = mass of the first participant fluid, p = pressure + ! F1 = 0 is the Gibbs free energy quality + ! F2 = 0 is the enforcement of the thermodynamic (total - kinectic) energy + ! dF1dm Jac(1, 1) = dFdT*dTdm - ! + ! dF1dp Jac(1, 2) = dFdT*dTdp + TS & *(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) - ! + ! dF2dm Jac(2, 1) = (qvs(vp) - qvs(lp) & + (cvs(vp)*gs_min(vp) - cvs(lp)*gs_min(lp)) & /(ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & @@ -551,7 +551,7 @@ contains /((ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mT*cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp)) + mCVGP)**2))/1 - ! + ! dF2dp Jac(2, 2) = (1 + (ml*(cvs(vp)*gs_min(vp) - cvs(lp)*gs_min(lp)) & - mT*cvs(vp)*gs_min(vp) - mCPD) & *(ml*(cvs(lp)*(gs_min(lp) - 1)/(pS + ps_inf(lp))**2 & @@ -561,41 +561,41 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mT*cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp)) + mCVGP)**2)/1 - ! elements of J^{-1} + ! intermediate elements of J^{-1} InvJac(1, 1) = Jac(2, 2) InvJac(1, 2) = -1.0_wp*Jac(1, 2) InvJac(2, 1) = -1.0_wp*Jac(2, 1) InvJac(2, 2) = Jac(1, 1) - ! of J^{T} + ! elements of J^{T} TJac(1, 1) = Jac(1, 1) TJac(1, 2) = Jac(2, 1) TJac(2, 1) = Jac(1, 2) TJac(2, 2) = Jac(2, 2) - ! by det(J) + ! dividing by det(J) InvJac = InvJac/(Jac(1, 1)*Jac(2, 2) - Jac(1, 2)*Jac(2, 1)) - ! correction array for Newton's method + ! calculating correction array for Newton's method DeltamP = -1.0_wp*(matmul(InvJac, R2D)) - ! two reacting 'masses'. Recall that inert 'masses' do not change during the phase change - ! + ! updating two reacting 'masses'. Recall that inert 'masses' do not change during the phase change + ! liquid q_cons_vf(lp + contxb - 1)%sf(j, k, l) = q_cons_vf(lp + contxb - 1)%sf(j, k, l) + Om*DeltamP(1) - ! + ! gas q_cons_vf(vp + contxb - 1)%sf(j, k, l) = q_cons_vf(vp + contxb - 1)%sf(j, k, l) - Om*DeltamP(1) - ! pressure + ! updating pressure pS = pS + Om*DeltamP(2) - ! residuals, which are (i) the difference between the Gibbs Free energy of the gas and the liquid - ! (ii) the energy before and after the phase-change process. + ! calculating residuals, which are (i) the difference between the Gibbs Free energy of the gas and the liquid + ! and (ii) the energy before and after the phase-change process. - ! of the reacting liquid + ! mass of the reacting liquid ml = q_cons_vf(lp + contxb - 1)%sf(j, k, l) - ! of the two participating fluids + ! mass of the two participating fluids mT = q_cons_vf(lp + contxb - 1)%sf(j, k, l) & + q_cons_vf(vp + contxb - 1)%sf(j, k, l) @@ -604,14 +604,14 @@ contains - cvs(vp)*(gs_min(vp) - 1)/(pS + ps_inf(vp))) & + mCVGP) - ! Free Energy Equality condition (DG) + ! Gibbs Free Energy Equality condition (DG) R2D(1) = TS*((cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp)) & *(1 - log(TS)) - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pS + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pS + ps_inf(vp))) & + qvs(lp) - qvs(vp) - ! Energy Process condition (DE) + ! Constant Energy Process condition (DE) R2D(2) = (rhoe + pS & + ml*(qvs(vp) - qvs(lp)) - mT*qvs(vp) - mQD & + (ml*(gs_min(vp)*cvs(vp) - gs_min(lp)*cvs(lp)) & @@ -622,18 +622,18 @@ contains end do - ! temperature + ! common temperature TS = (rhoe + pS - mQ)/mCP end subroutine s_infinite_ptg_relaxation_k !> This auxiliary subroutine corrects the partial densities of the REACTING fluids in case one of them is negative - !! sum is positive. Inert phases are not corrected at this moment - !! partial density correction parameter - !! Cell-average conservative variables - !! sum of the reacting masses - !! generic loop iterator for x direction - !! generic loop iterator for y direction - !! generic loop iterator for z direction + !! but their sum is positive. Inert phases are not corrected at this moment + !! @param MCT partial density correction parameter + !! @param q_cons_vf Cell-average conservative variables + !! @param rM sum of the reacting masses + !! @param j generic loop iterator for x direction + !! @param k generic loop iterator for y direction + !! @param l generic loop iterator for z direction subroutine s_correct_partial_densities(MCT, q_cons_vf, rM, j, k, l) $:GPU_ROUTINE(function_name='s_correct_partial_densities', & & parallelism='[seq]', cray_inline=True) @@ -660,11 +660,11 @@ contains end if - ! the correction in terms of an absolute value might not be the best practice. - ! a good way to do this is to partition the partial densities, giving a small percentage of the total reacting density + ! Defining the correction in terms of an absolute value might not be the best practice. + ! Maybe a good way to do this is to partition the partial densities, giving a small percentage of the total reacting density MCT = 2*mixM - ! the partial densities of the reacting fluids. What to do for the nonreacting ones? + ! correcting the partial densities of the reacting fluids. What to do for the nonreacting ones? if (q_cons_vf(lp + contxb - 1)%sf(j, k, l) < 0.0_wp) then q_cons_vf(lp + contxb - 1)%sf(j, k, l) = MCT*rM @@ -681,10 +681,10 @@ contains end subroutine s_correct_partial_densities !> This auxiliary subroutine finds the Saturation temperature for a given - !! through a newton solver - !! Saturation Pressure - !! Saturation Temperature - !! equilibrium Temperature + !! saturation pressure through a newton solver + !! @param pSat Saturation Pressure + !! @param TSat Saturation Temperature + !! @param TSIn equilibrium Temperature elemental subroutine s_TSat(pSat, TSat, TSIn) $:GPU_ROUTINE(function_name='s_TSat',parallelism='[seq]', & & cray_inline=True) @@ -695,44 +695,44 @@ contains real(wp) :: dFdT, FT, Om !< auxiliary variables - ! loop iterators + ! Generic loop iterators integer :: ns if ((f_approx_equal(pSat, 0.0_wp)) .and. (f_approx_equal(TSIn, 0.0_wp))) then - ! Saturation temperature + ! assigning Saturation temperature TSat = 0.0_wp else - ! initial estimate for temperature in the TSat procedure. I will also use this variable to - ! over the Newton's solver + ! calculating initial estimate for temperature in the TSat procedure. I will also use this variable to + ! iterate over the Newton's solver TSat = TSIn - ! counter + ! iteration counter ns = 0 - ! factor + ! underrelaxation factor Om = 1.0e-3_wp do while ((abs(FT) > ptgalpha_eps) .or. (ns == 0)) - ! counter + ! increasing counter ns = ns + 1 - ! residual + ! calculating residual FT = TSat*((cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp)) & *(1 - log(TSat)) - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pSat + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pSat + ps_inf(vp))) & + qvs(lp) - qvs(vp) - ! the jacobian + ! calculating the jacobian dFdT = & -(cvs(lp)*gs_min(lp) - cvs(vp)*gs_min(vp))*log(TSat) & - (qvps(lp) - qvps(vp)) & + cvs(lp)*(gs_min(lp) - 1)*log(pSat + ps_inf(lp)) & - cvs(vp)*(gs_min(vp) - 1)*log(pSat + ps_inf(vp)) - ! saturation temperature + ! updating saturation temperature TSat = TSat - Om*FT/dFdT end do diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index 502af29e38..1f8245da8b 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -1,14 +1,14 @@ !> -!! -!! module m_variables_conversion +!! @file +!! @brief Contains module m_variables_conversion #:include 'macros.fpp' #:include 'case.fpp' !> @brief This module consists of subroutines used in the conversion of the -!! into the primitive ones and vice versa. In -!! module also contains the subroutines used to obtain -!! variables and the subroutines used to compute pressure. +!! conservative variables into the primitive ones and vice versa. In +!! addition, the module also contains the subroutines used to obtain +!! the mixture variables and the subroutines used to compute pressure. module m_variables_conversion use m_derived_types !< Definitions of the derived types @@ -46,7 +46,7 @@ module m_variables_conversion #endif s_finalize_variables_conversion_module - !! gammas, pi_infs, and qvs are already declared in m_global_variables + !! In simulation, gammas, pi_infs, and qvs are already declared in m_global_variables #ifndef MFC_SIMULATION real(wp), allocatable, public, dimension(:) :: gammas, gs_min, pi_infs, ps_inf, cvs, qvs, qvps $:GPU_DECLARE(create='[gammas,gs_min,pi_infs,ps_inf,cvs,qvs,qvps]') @@ -68,16 +68,16 @@ module m_variables_conversion contains !> Dispatch to the s_convert_mixture_to_mixture_variables - !! subroutines. - !! procedure pointer. - !! Conservative or primitive variables - !! First-coordinate cell index - !! First-coordinate cell index - !! First-coordinate cell index - !! Density - !! Specific heat ratio function - !! Liquid stiffness function - !! Fluid reference energy + !! and s_convert_species_to_mixture_variables subroutines. + !! Replaces a procedure pointer. + !! @param q_vf Conservative or primitive variables + !! @param i First-coordinate cell index + !! @param j First-coordinate cell index + !! @param k First-coordinate cell index + !! @param rho Density + !! @param gamma Specific heat ratio function + !! @param pi_inf Liquid stiffness function + !! @param qv Fluid reference energy subroutine s_convert_to_mixture_variables(q_vf, i, j, k, & rho, gamma, pi_inf, qv, Re_K, G_K, G) @@ -100,16 +100,16 @@ contains end subroutine s_convert_to_mixture_variables !> This procedure conditionally calculates the appropriate pressure - !! Energy - !! Void Fraction - !! Dynamic Pressure - !! Liquid Stiffness - !! Specific Heat Ratio - !! Density - !! fluid reference energy - !! Pressure to calculate - !! Shear Stress - !! Momentum + !! @param energy Energy + !! @param alf Void Fraction + !! @param dyn_p Dynamic Pressure + !! @param pi_inf Liquid Stiffness + !! @param gamma Specific Heat Ratio + !! @param rho Density + !! @param qv fluid reference energy + !! @param pres Pressure to calculate + !! @param stress Shear Stress + !! @param mom Momentum subroutine s_compute_pressure(energy, alf, dyn_p, pi_inf, gamma, rho, qv, rhoYks, pres, T, stress, mom, G, pres_mag) $:GPU_ROUTINE(function_name='s_compute_pressure',parallelism='[seq]', & & cray_inline=True) @@ -122,7 +122,7 @@ contains real(stp), intent(in), optional :: stress, mom real(wp), intent(in), optional :: G, pres_mag - ! + ! Chemistry real(wp), dimension(1:num_species), intent(in) :: rhoYks real(wp), dimension(1:num_species) :: Y_rs real(wp) :: E_e @@ -132,8 +132,8 @@ contains integer :: s !< Generic loop iterator #:if not chemistry - ! on model_eqns and bubbles_euler, the appropriate procedure - ! computing pressure is targeted by the procedure pointer + ! Depending on model_eqns and bubbles_euler, the appropriate procedure + ! for computing pressure is targeted by the procedure pointer if (mhd) then pres = (energy - dyn_p - pi_inf - qv - pres_mag)/gamma @@ -149,12 +149,12 @@ contains end if if (hypoelasticity .and. present(G)) then - ! elastic contribution to Energy + ! calculate elastic contribution to Energy E_e = 0._wp do s = stress_idx%beg, stress_idx%end if (G > 0) then E_e = E_e + ((stress/rho)**2._wp)/(4._wp*G) - ! for shear stresses + ! Double for shear stresses if (any(s == shear_indices)) then E_e = E_e + ((stress/rho)**2._wp)/(4._wp*G) end if @@ -185,18 +185,18 @@ contains end subroutine s_compute_pressure !> This subroutine is designed for the gamma/pi_inf model - !! a set of either conservative or primitive - !! the density, specific heat ratio - !! the liquid stiffness function from q_vf to - !! and pi_inf. - !! conservative or primitive variables - !! cell index to transfer mixture variables - !! cell index to transfer mixture variables - !! cell index to transfer mixture variables - !! density - !! specific heat ratio function - !! liquid stiffness - !! fluid reference energy + !! and provided a set of either conservative or primitive + !! variables, transfers the density, specific heat ratio + !! function and the liquid stiffness function from q_vf to + !! rho, gamma and pi_inf. + !! @param q_vf conservative or primitive variables + !! @param i cell index to transfer mixture variables + !! @param j cell index to transfer mixture variables + !! @param k cell index to transfer mixture variables + !! @param rho density + !! @param gamma specific heat ratio function + !! @param pi_inf liquid stiffness + !! @param qv fluid reference energy subroutine s_convert_mixture_to_mixture_variables(q_vf, i, j, k, & rho, gamma, pi_inf, qv) @@ -208,14 +208,14 @@ contains real(wp), intent(out), target :: pi_inf real(wp), intent(out), target :: qv - ! the density, the specific heat ratio function and the - ! stiffness function, respectively + ! Transferring the density, the specific heat ratio function and the + ! liquid stiffness function, respectively rho = q_vf(1)%sf(i, j, k) gamma = q_vf(gamma_idx)%sf(i, j, k) pi_inf = q_vf(pi_inf_idx)%sf(i, j, k) qv = 0._wp ! keep this value nill for now. For future adjustment - ! process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated + ! Post process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated #ifdef MFC_POST_PROCESS rho_sf(i, j, k) = rho gamma_sf(i, j, k) = gamma @@ -226,18 +226,18 @@ contains end subroutine s_convert_mixture_to_mixture_variables !> This subroutine is designed for the volume fraction model - !! a set of either conservative or primitive - !! the density, the specific heat ratio - !! the liquid stiffness function from q_vf and - !! results into rho, gamma and pi_inf. - !! primitive variables - !! Cell index - !! Cell index - !! Cell index - !! density - !! specific heat ratio - !! liquid stiffness - !! fluid reference energy + !! and provided a set of either conservative or primitive + !! variables, computes the density, the specific heat ratio + !! function and the liquid stiffness function from q_vf and + !! stores the results into rho, gamma and pi_inf. + !! @param q_vf primitive variables + !! @param k Cell index + !! @param l Cell index + !! @param r Cell index + !! @param rho density + !! @param gamma specific heat ratio + !! @param pi_inf liquid stiffness + !! @param qv fluid reference energy subroutine s_convert_species_to_mixture_variables(q_vf, k, l, r, rho, & gamma, pi_inf, qv, Re_K, G_K, G) @@ -257,13 +257,13 @@ contains integer :: i, j !< Generic loop iterator - ! the density, the specific heat ratio function and the - ! stiffness function, respectively + ! Computing the density, the specific heat ratio function and the + ! liquid stiffness function, respectively call s_compute_species_fraction(q_vf, k, l, r, alpha_rho_K, alpha_K) - ! the density, the specific heat ratio function, the - ! stiffness function, and the energy reference function, - ! from the species analogs + ! Calculating the density, the specific heat ratio function, the + ! liquid stiffness function, and the energy reference function, + ! respectively, from the species analogs if (num_fluids == 1 .and. bubbles_euler) then rho = alpha_rho_K(1) gamma = gammas(1) @@ -280,7 +280,7 @@ contains end if #ifdef MFC_SIMULATION - ! the shear and bulk Reynolds numbers from species analogs + ! Computing the shear and bulk Reynolds numbers from species analogs if (viscous) then do i = 1, 2 Re_K(i) = dflt_real; if (Re_size(i) > 0) Re_K(i) = 0._wp @@ -303,7 +303,7 @@ contains G_K = max(0._wp, G_K) end if - ! process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated + ! Post process requires rho_sf/gamma_sf/pi_inf_sf/qv_sf to also be updated #ifdef MFC_POST_PROCESS rho_sf(k, l, r) = rho gamma_sf(k, l, r) = gamma @@ -335,10 +335,10 @@ contains integer :: i, j !< Generic loop iterators #ifdef MFC_SIMULATION - ! the partial densities and the volume fractions within - ! physical bounds to make sure that any mixture variables that - ! derived from them result within the limits that are set by the - ! physical parameters that make up the mixture + ! Constraining the partial densities and the volume fractions within + ! their physical bounds to make sure that any mixture variables that + ! are derived from them result within the limits that are set by the + ! fluids physical parameters that make up the mixture if (num_fluids == 1 .and. bubbles_euler) then rho_K = alpha_rho_K(1) gamma_K = gammas(1) @@ -392,8 +392,8 @@ contains end subroutine s_convert_species_to_mixture_variables_acc !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_variables_conversion_module integer :: i, j @@ -444,13 +444,13 @@ contains end if #ifdef MFC_POST_PROCESS - ! the density, the specific heat ratio function and the - ! stiffness function, respectively + ! Allocating the density, the specific heat ratio function and the + ! liquid stiffness function, respectively - ! is at least 2D + ! Simulation is at least 2D if (n > 0) then - ! is 3D + ! Simulation is 3D if (p > 0) then allocate (rho_sf(-buff_size:m + buff_size, & @@ -466,7 +466,7 @@ contains -buff_size:n + buff_size, & -buff_size:p + buff_size)) - ! is 2D + ! Simulation is 2D else allocate (rho_sf(-buff_size:m + buff_size, & @@ -483,7 +483,7 @@ contains 0:0)) end if - ! is 1D + ! Simulation is 1D else allocate (rho_sf(-buff_size:m + buff_size, & @@ -571,13 +571,13 @@ contains end subroutine s_initialize_pb !> The following procedure handles the conversion between - !! variables and the primitive variables. - !! Conservative variables - !! Primitive variables - !! Gradient magnitude of the volume fraction - !! Index bounds in first coordinate direction - !! Index bounds in second coordinate direction - !! Index bounds in third coordinate direction + !! the conservative variables and the primitive variables. + !! @param qK_cons_vf Conservative variables + !! @param qK_prim_vf Primitive variables + !! @param gm_alphaK_vf Gradient magnitude of the volume fraction + !! @param ix Index bounds in first coordinate direction + !! @param iy Index bounds in second coordinate direction + !! @param iz Index bounds in third coordinate direction subroutine s_convert_conservative_to_primitive_variables(qK_cons_vf, & q_T_sf, & qK_prim_vf, & @@ -630,7 +630,7 @@ contains if (model_eqns /= 4) then #ifdef MFC_SIMULATION - ! in simulation, use acc mixture subroutines + ! If in simulation, use acc mixture subroutines if (elasticity) then call s_convert_species_to_mixture_variables_acc(rho_K, gamma_K, pi_inf_K, qv_K, alpha_K, & alpha_rho_K, Re_K, G_K, Gs_vc) @@ -639,7 +639,7 @@ contains alpha_K, alpha_rho_K, Re_K) end if #else - ! pre-processing, use non acc mixture subroutines + ! If pre-processing, use non acc mixture subroutines if (elasticity) then call s_convert_to_mixture_variables(qK_cons_vf, j, k, l, & rho_K, gamma_K, pi_inf_K, qv_K, Re_K, G_K, fluid_pp(:)%G) @@ -682,7 +682,7 @@ contains D = D + qK_cons_vf(i)%sf(j, k, l) end do - ! + ! Newton-Raphson W = E + D $:GPU_LOOP(parallelism='[seq]') do iter = 1, relativity_cons_to_prim_max_iter @@ -690,11 +690,11 @@ contains pres = (W - D*Ga)/((gamma_K + 1)*Ga**2) ! Thermal pressure from EOS f = W - pres + (1 - 1/(2*Ga**2))*B2 - S**2/(2*W**2) - E - D - ! first equation below corrects a typo in (Mignone & Bodo, 2006) - ! → 2*m2*W**2, which would cancel with the 2* in other terms - ! corrected version is not used as the second equation empirically converges faster. - ! equation is kept for further investigation. - ! = -Ga**3 * ( S**2*(3*W**2+3*W*B2+B2**2) + m2*W**2 ) / (W**3 * (W+B2)**3) ! first (corrected) + ! The first equation below corrects a typo in (Mignone & Bodo, 2006) + ! m2*W**2 → 2*m2*W**2, which would cancel with the 2* in other terms + ! This corrected version is not used as the second equation empirically converges faster. + ! First equation is kept for further investigation. + ! dGa_dW = -Ga**3 * ( S**2*(3*W**2+3*W*B2+B2**2) + m2*W**2 ) / (W**3 * (W+B2)**3) ! first (corrected) dGa_dW = -Ga**3*(2*S**2*(3*W**2 + 3*W*B2 + B2**2) + m2*W**2)/(2*W**3*(W + B2)**3) ! second (in paper) dp_dW = (Ga*(1 + D*dGa_dW) - 2*W*dGa_dW)/((gamma_K + 1)*Ga**3) @@ -705,11 +705,11 @@ contains if (abs(dW) < 1.e-12_wp*W) exit end do - ! pressure using converged W + ! Recalculate pressure using converged W Ga = (W + B2)*W/sqrt((W + B2)**2*W**2 - (m2*W**2 + S**2*(2*W + B2))) qK_prim_vf(E_idx)%sf(j, k, l) = (W - D*Ga)/((gamma_K + 1)*Ga**2) - ! the other primitive variables + ! Recover the other primitive variables $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 qK_prim_vf(momxb + i - 1)%sf(j, k, l) = (qK_cons_vf(momxb + i - 1)%sf(j, k, l) + (S/W)*B(i))/(W + B2) @@ -848,12 +848,12 @@ contains if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = strxb, strxe - ! elastic contribution for pressure calculation + ! subtracting elastic contribution for pressure calculation if (G_K > verysmall) then if (cont_damage) G_K = G_K*max((1._wp - qK_cons_vf(damage_idx)%sf(j, k, l)), 0._wp) qK_prim_vf(E_idx)%sf(j, k, l) = qK_prim_vf(E_idx)%sf(j, k, l) - & ((qK_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G_K))/gamma_K - ! for shear stresses + ! Double for shear stresses if (any(i == shear_indices)) then qK_prim_vf(E_idx)%sf(j, k, l) = qK_prim_vf(E_idx)%sf(j, k, l) - & ((qK_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G_K))/gamma_K @@ -895,22 +895,22 @@ contains end subroutine s_convert_conservative_to_primitive_variables !> The following procedure handles the conversion between - !! variables and the conservative variables. - !! Primitive variables - !! Conservative variables - !! Gradient magnitude of the volume fractions - !! Index bounds in the first coordinate direction - !! Index bounds in the second coordinate direction - !! Index bounds in the third coordinate direction + !! the primitive variables and the conservative variables. + !! @param qK_prim_vf Primitive variables + !! @param qK_cons_vf Conservative variables + !! @param gm_alphaK_vf Gradient magnitude of the volume fractions + !! @param ix Index bounds in the first coordinate direction + !! @param iy Index bounds in the second coordinate direction + !! @param iz Index bounds in the third coordinate direction impure subroutine s_convert_primitive_to_conservative_variables(q_prim_vf, & q_cons_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf - ! specific heat ratio function, liquid stiffness function - ! dynamic pressure, as defined in the incompressible flow sense, - ! + ! Density, specific heat ratio function, liquid stiffness function + ! and dynamic pressure, as defined in the incompressible flow sense, + ! respectively real(wp) :: rho real(wp) :: gamma real(wp) :: pi_inf @@ -939,18 +939,18 @@ contains G = 0._wp #ifndef MFC_SIMULATION - ! the primitive variables to the conservative variables + ! Converting the primitive variables to the conservative variables do l = 0, p do k = 0, n do j = 0, m - ! the density, specific heat ratio function - ! the liquid stiffness function, respectively + ! Obtaining the density, specific heat ratio function + ! and the liquid stiffness function, respectively call s_convert_to_mixture_variables(q_prim_vf, j, k, l, & rho, gamma, pi_inf, qv, Re_K, G, fluid_pp(:)%G) if (.not. igr .or. num_fluids > 1) then - ! the advection equation(s) variable(s) + ! Transferring the advection equation(s) variable(s) do i = adv_idx%beg, adv_idx%end q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l) end do @@ -1000,7 +1000,7 @@ contains q_cons_vf(E_idx)%sf(j, k, l) = rho*h*Ga**2 - q_prim_vf(E_idx)%sf(j, k, l) & + 0.5_wp*(B2 + v2*B2 - vdotB**2) - ! rest energy + ! Remove rest energy do i = 1, contxe q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) - q_cons_vf(i)%sf(j, k, l) end do @@ -1013,16 +1013,16 @@ contains end if - ! the continuity equation(s) variable(s) + ! Transferring the continuity equation(s) variable(s) do i = 1, contxe q_cons_vf(i)%sf(j, k, l) = q_prim_vf(i)%sf(j, k, l) end do - ! out the dynamic pressure since it is computed - ! by cycling through the velocity equations + ! Zeroing out the dynamic pressure since it is computed + ! iteratively by cycling through the velocity equations dyn_pres = 0._wp - ! momenta and dynamic pressure from velocity + ! Computing momenta and dynamic pressure from velocity do i = momxb, momxe q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) dyn_pres = dyn_pres + q_cons_vf(i)%sf(j, k, l)* & @@ -1042,7 +1042,7 @@ contains q_cons_vf(E_idx)%sf(j, k, l) = & dyn_pres + rho*e_mix else - ! the energy from the pressure + ! Computing the energy from the pressure if (mhd) then if (n == 0) then pres_mag = 0.5_wp*(Bx0**2 + q_prim_vf(B_idx%beg)%sf(j, k, l)**2 + q_prim_vf(B_idx%beg + 1)%sf(j, k, l)**2) @@ -1053,11 +1053,11 @@ contains gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pres_mag & + pi_inf + qv elseif ((model_eqns /= 4) .and. (bubbles_euler .neqv. .true.)) then - ! = Gamma*P + \rho u u /2 + \pi_inf + (\alpha\rho qv) + ! E = Gamma*P + \rho u u /2 + \pi_inf + (\alpha\rho qv) q_cons_vf(E_idx)%sf(j, k, l) = & gamma*q_prim_vf(E_idx)%sf(j, k, l) + dyn_pres + pi_inf + qv else if ((model_eqns /= 4) .and. (bubbles_euler)) then - ! = dyn_pres + (1-\alf)(\Gamma p_l + \Pi_inf) + ! \tilde{E} = dyn_pres + (1-\alf)(\Gamma p_l + \Pi_inf) q_cons_vf(E_idx)%sf(j, k, l) = dyn_pres + & (1._wp - q_prim_vf(alf_idx)%sf(j, k, l))* & (gamma*q_prim_vf(E_idx)%sf(j, k, l) + pi_inf) @@ -1067,10 +1067,10 @@ contains end if end if - ! the internal energies from the pressure and continuities + ! Computing the internal energies from the pressure and continuities if (model_eqns == 3) then do i = 1, num_fluids - ! energy calculation for each of the fluids + ! internal energy calculation for each of the fluids q_cons_vf(i + intxb - 1)%sf(j, k, l) = q_cons_vf(i + advxb - 1)%sf(j, k, l)* & (gammas(i)*q_prim_vf(E_idx)%sf(j, k, l) + pi_infs(i)) + & q_cons_vf(i + contxb - 1)%sf(j, k, l)*qvs(i) @@ -1078,7 +1078,7 @@ contains end if if (bubbles_euler) then - ! prim: Compute nbub = (3/4pi) * \alpha / \bar{R^3} + ! From prim: Compute nbub = (3/4pi) * \alpha / \bar{R^3} do i = 1, nb Rtmp(i) = q_prim_vf(bub_idx%rs(i))%sf(j, k, l) end do @@ -1115,8 +1115,8 @@ contains end if if (elasticity) then - ! the elastic contribution - ! \tau to \rho \tau + ! adding the elastic contribution + ! Multiply \tau to \rho \tau do i = strxb, strxe q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) end do @@ -1124,13 +1124,13 @@ contains if (hypoelasticity) then do i = strxb, strxe - ! elastic contribution + ! adding elastic contribution if (G > verysmall) then if (cont_damage) G = G*max((1._wp - q_prim_vf(damage_idx)%sf(j, k, l)), 0._wp) q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) + & (q_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G) - ! for shear stresses + ! Double for shear stresses if (any(i == shear_indices)) then q_cons_vf(E_idx)%sf(j, k, l) = q_cons_vf(E_idx)%sf(j, k, l) + & (q_prim_vf(i)%sf(j, k, l)**2._wp)/(4._wp*G) @@ -1139,9 +1139,9 @@ contains end do end if - ! \rho xi as the conservative formulation stated in Kamrin et al. JFM 2022 + ! using \rho xi as the conservative formulation stated in Kamrin et al. JFM 2022 if (hyperelasticity) then - ! \xi to \rho \xi + ! Multiply \xi to \rho \xi do i = xibeg, xiend q_cons_vf(i)%sf(j, k, l) = rho*q_prim_vf(i)%sf(j, k, l) end do @@ -1168,13 +1168,13 @@ contains end subroutine s_convert_primitive_to_conservative_variables !> The following subroutine handles the conversion between - !! variables and the Eulerian flux variables. - !! Primitive variables - !! Flux variables - !! Flux source variables - !! Index bounds in the first coordinate direction - !! Index bounds in the second coordinate direction - !! Index bounds in the third coordinate direction + !! the primitive variables and the Eulerian flux variables. + !! @param qK_prim_vf Primitive variables + !! @param FK_vf Flux variables + !! @param FK_src_vf Flux source variables + !! @param ix Index bounds in the first coordinate direction + !! @param iy Index bounds in the second coordinate direction + !! @param iz Index bounds in the third coordinate direction subroutine s_convert_primitive_to_flux_variables(qK_prim_vf, & FK_vf, & FK_src_vf, & @@ -1187,9 +1187,9 @@ contains type(int_bounds_info), intent(in) :: is1, is2, is3 - ! densities, density, velocity, pressure, energy, advection - ! the specific heat ratio and liquid stiffness functions, - ! shear and volume Reynolds numbers and the Weber numbers + ! Partial densities, density, velocity, pressure, energy, advection + ! variables, the specific heat ratio and liquid stiffness functions, + ! the shear and volume Reynolds numbers and the Weber numbers #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: alpha_rho_K real(wp), dimension(3) :: alpha_K @@ -1220,8 +1220,8 @@ contains $:GPU_UPDATE(device='[is1b,is2b,is3b,is1e,is2e,is3e]') - ! the flux variables from the primitive variables, without - ! for the contribution of either viscosity or capillarity + ! Computing the flux variables from the primitive variables, without + ! accounting for the contribution of either viscosity or capillarity #ifdef MFC_SIMULATION $:GPU_PARALLEL_LOOP(collapse=3, private='[alpha_rho_K, vel_K, alpha_K, Re_K, Y_K, rho_K, vel_K_sum, pres_K, E_K, gamma_K, pi_inf_K, qv_K, G_K, T_K, mix_mol_weight, R_gas]') do l = is3b, is3e @@ -1259,7 +1259,7 @@ contains alpha_K, alpha_rho_K, Re_K) end if - ! the energy from the pressure + ! Computing the energy from the pressure if (chemistry) then $:GPU_LOOP(parallelism='[seq]') @@ -1273,12 +1273,12 @@ contains call get_mixture_energy_mass(T_K, Y_K, E_K) E_K = rho_K*E_K + 5.e-1_wp*rho_K*vel_K_sum else - ! the energy from the pressure + ! Computing the energy from the pressure E_K = gamma_K*pres_K + pi_inf_K & + 5.e-1_wp*rho_K*vel_K_sum + qv_K end if - ! flux, this should be \alpha_i \rho_i u_i + ! mass flux, this should be \alpha_i \rho_i u_i $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe FK_vf(j, k, l, i) = alpha_rho_K(i)*vel_K(dir_idx(1)) @@ -1292,10 +1292,10 @@ contains + pres_K*dir_flg(dir_idx(i)) end do - ! flux, u(E+p) + ! energy flux, u(E+p) FK_vf(j, k, l, E_idx) = vel_K(dir_idx(1))*(E_K + pres_K) - ! advection Flux, \rho*u*Y + ! Species advection Flux, \rho*u*Y if (chemistry) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_species @@ -1311,7 +1311,7 @@ contains end do else - ! be bubbles_euler! + ! Could be bubbles_euler! $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe FK_vf(j, k, l, i) = vel_K(dir_idx(1))*alpha_K(i - E_idx) @@ -1384,8 +1384,8 @@ contains impure subroutine s_finalize_variables_conversion_module() - ! the density, the specific heat ratio function and the - ! stiffness function + ! Deallocating the density, the specific heat ratio function and the + ! liquid stiffness function #ifdef MFC_POST_PROCESS deallocate (rho_sf, gamma_sf, pi_inf_sf, qv_sf) #endif @@ -1431,7 +1431,7 @@ contains c = sqrt((1.0_wp + 1.0_wp/gamma)*pres/rho) end if elseif (relativity) then - ! supports perfect gas for now + ! Only supports perfect gas for now c = sqrt((1._wp + 1._wp/gamma)*pres/rho/H) else if (alt_soundspeed) then @@ -1449,7 +1449,7 @@ contains end do c = c/rho elseif (((model_eqns == 4) .or. (model_eqns == 2 .and. bubbles_euler))) then - ! speed for bubble mixture to order O(\alpha) + ! Sound speed for bubble mixture to order O(\alpha) if (mpp_lim .and. (num_fluids > 1)) then c = (1._wp/gamma + 1._wp)* & @@ -1491,7 +1491,7 @@ contains term = c**2 + B2/rho disc = term**2 - 4*c**2*(B(norm)**2/rho) else - ! this is approximation for the non-relatisitic limit; accurate solution requires solving a quartic equation + ! Note: this is approximation for the non-relatisitic limit; accurate solution requires solving a quartic equation term = (c**2*(B(norm)**2 + rho*h) + B2)/(rho*h + B2) disc = term**2 - 4*c**2*B(norm)**2/(rho*h + B2) end if diff --git a/src/post_process/m_checker.fpp b/src/post_process/m_checker.fpp index 883e1406d8..82aacff953 100644 --- a/src/post_process/m_checker.fpp +++ b/src/post_process/m_checker.fpp @@ -22,7 +22,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! the post_process stage + !! Used by the post_process stage impure subroutine s_check_inputs call s_check_inputs_output_format diff --git a/src/post_process/m_data_input.f90 b/src/post_process/m_data_input.f90 index 1b07d591cc..f88da90cb9 100644 --- a/src/post_process/m_data_input.f90 +++ b/src/post_process/m_data_input.f90 @@ -1,5 +1,5 @@ !> -!! @file m_data_input.f90 +!! @file !> @brief Contains module m_data_input !> @brief This module features procedures, which for a specific time-step, @@ -145,7 +145,6 @@ end subroutine s_setup_mpi_io_params !> Helper subroutine to read IB data files !! @param file_loc_base Base file location for IB data - !! @param t_step Optional time step index for restart data impure subroutine s_read_ib_data_files(file_loc_base, t_step) character(len=*), intent(in) :: file_loc_base diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index 2f549e6342..2b5416fe87 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_data_output +!! @file +!! @brief Contains module m_data_output !> @brief This module enables the restructuring of the raw simulation data -!! formatted database file(s). The formats that may be -!! include Silo-HDF5 and Binary. Each of these database -!! information about the grid as well as each of -!! variable(s) that were chosen by the user to be included. +!! file(s) into formatted database file(s). The formats that may be +!! chosen from include Silo-HDF5 and Binary. Each of these database +!! structures contains information about the grid as well as each of +!! the flow variable(s) that were chosen by the user to be included. module m_data_output use m_derived_types ! Definitions of the derived types @@ -41,92 +41,92 @@ module m_data_output s_close_energy_data_file, & s_finalize_data_output_module - ! the Silo Fortran interface library that features the subroutines - ! parameters that are required to write in the Silo-HDF5 database format - ! 'silo.inc' + ! Including the Silo Fortran interface library that features the subroutines + ! and parameters that are required to write in the Silo-HDF5 database format + ! INCLUDE 'silo.inc' include 'silo_f9x.inc' - ! storage for flow variable(s) that are to be written to formatted - ! file(s). Note that for 1D simulations, q_root_sf is employed to - ! the flow variable(s) from all sub-domains on to the root process. - ! the run is not parallel, but serial, then q_root_sf is equal to q_sf. + ! Generic storage for flow variable(s) that are to be written to formatted + ! database file(s). Note that for 1D simulations, q_root_sf is employed to + ! gather the flow variable(s) from all sub-domains on to the root process. + ! If the run is not parallel, but serial, then q_root_sf is equal to q_sf. real(wp), allocatable, dimension(:, :, :), public :: q_sf real(wp), allocatable, dimension(:, :, :) :: q_root_sf real(wp), allocatable, dimension(:, :, :) :: cyl_q_sf - ! precision storage for flow variables + ! Single precision storage for flow variables real(sp), allocatable, dimension(:, :, :), public :: q_sf_s real(sp), allocatable, dimension(:, :, :) :: q_root_sf_s real(sp), allocatable, dimension(:, :, :) :: cyl_q_sf_s - ! spatial and data extents array variables contain information about the - ! and maximum values of the grid and flow variable(s), respectively. - ! purpose of bookkeeping this information is to boost the visualization - ! the Silo-HDF5 database file(s) in VisIt. + ! The spatial and data extents array variables contain information about the + ! minimum and maximum values of the grid and flow variable(s), respectively. + ! The purpose of bookkeeping this information is to boost the visualization + ! of the Silo-HDF5 database file(s) in VisIt. real(wp), allocatable, dimension(:, :) :: spatial_extents real(wp), allocatable, dimension(:, :) :: data_extents - ! size of the ghost zone layer at beginning of each coordinate direction - ! and at end of each coordinate direction (hi). Adding this information - ! Silo-HDF5 database file(s) is recommended since it supplies VisIt with - ! information between the sub-domains of a parallel data set. + ! The size of the ghost zone layer at beginning of each coordinate direction + ! (lo) and at end of each coordinate direction (hi). Adding this information + ! to Silo-HDF5 database file(s) is recommended since it supplies VisIt with + ! connectivity information between the sub-domains of a parallel data set. integer, allocatable, dimension(:) :: lo_offset integer, allocatable, dimension(:) :: hi_offset - ! Silo-HDF5 database format, this variable is used to keep track of the - ! of cell-boundaries, for the grid associated with the local process, - ! each of the active coordinate directions. + ! For Silo-HDF5 database format, this variable is used to keep track of the + ! number of cell-boundaries, for the grid associated with the local process, + ! in each of the active coordinate directions. integer, allocatable, dimension(:) :: dims - ! of various folders in the case's directory tree, associated with - ! choice of the formatted database format. These include, in order, the - ! of the folder named after the selected formatted database format, - ! the locations of two sub-directories of the latter, the first of which - ! named after the local processor rank, while the second is named 'root'. - ! folder associated with the local processor rank contains only the data - ! to the part of the domain taken care of by the local processor. - ! root directory, on the other hand, will contain either the information - ! the connectivity required to put the entire domain back together, or - ! actual data associated with the entire computational domain. This all - ! on dimensionality and the choice of the formatted database format. + ! Locations of various folders in the case's directory tree, associated with + ! the choice of the formatted database format. These include, in order, the + ! location of the folder named after the selected formatted database format, + ! and the locations of two sub-directories of the latter, the first of which + ! is named after the local processor rank, while the second is named 'root'. + ! The folder associated with the local processor rank contains only the data + ! pertaining to the part of the domain taken care of by the local processor. + ! The root directory, on the other hand, will contain either the information + ! about the connectivity required to put the entire domain back together, or + ! the actual data associated with the entire computational domain. This all + ! depends on dimensionality and the choice of the formatted database format. character(LEN=path_len + name_len) :: dbdir character(LEN=path_len + 2*name_len) :: proc_rank_dir character(LEN=path_len + 2*name_len) :: rootdir - ! of the formatted database master/root file, slave/local processor - ! and options list. The list of options is explicitly used in the Silo- - ! database format to provide additional details about the contents of a - ! database file, such as the previously described spatial and data - ! + ! Handles of the formatted database master/root file, slave/local processor + ! file and options list. The list of options is explicitly used in the Silo- + ! HDF5 database format to provide additional details about the contents of a + ! formatted database file, such as the previously described spatial and data + ! extents. integer :: dbroot integer :: dbfile integer :: optlist - ! total number of flow variable(s) to be stored in a formatted database - ! Note that this is only needed when using the Binary format. + ! The total number of flow variable(s) to be stored in a formatted database + ! file. Note that this is only needed when using the Binary format. integer :: dbvars - ! error flags utilized in the handling, checking and the reporting - ! the input and output operations errors with a formatted database file + ! Generic error flags utilized in the handling, checking and the reporting + ! of the input and output operations errors with a formatted database file integer, private :: err contains impure subroutine s_initialize_data_output_module() - ! Computation of parameters, allocation procedures, and/or - ! other tasks needed to properly setup the module + ! Description: Computation of parameters, allocation procedures, and/or + ! any other tasks needed to properly setup the module - ! string used to store the location of a particular file + ! Generic string used to store the location of a particular file character(LEN=len_trim(case_dir) + 2*name_len) :: file_loc - ! logical used to test the existence of a particular folder + ! Generic logical used to test the existence of a particular folder logical :: dir_check integer :: i - ! the generic storage for the flow variable(s) that are - ! to be written to the formatted database file(s). Note once - ! that the root variable is only required for 1D computations. + ! Allocating the generic storage for the flow variable(s) that are + ! going to be written to the formatted database file(s). Note once + ! more that the root variable is only required for 1D computations. allocate (q_sf(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end)) @@ -154,10 +154,10 @@ contains end if end if - ! the spatial and data extents and also the variables for - ! offsets and the one bookkeeping the number of cell-boundaries - ! each active coordinate direction. Note that all these variables - ! only needed by the Silo-HDF5 format for multidimensional data. + ! Allocating the spatial and data extents and also the variables for + ! the offsets and the one bookkeeping the number of cell-boundaries + ! in each active coordinate direction. Note that all these variables + ! are only needed by the Silo-HDF5 format for multidimensional data. if (format == 1) then allocate (data_extents(1:2, 0:num_procs - 1)) @@ -181,13 +181,13 @@ contains end if - ! size of the ghost zone layer in each of the active coordinate - ! was set in the module m_mpi_proxy.f90. The results are - ! transferred to the local variables of this module when they are - ! by the Silo-HDF5 format, for multidimensional data sets. - ! the same, latter, requirements, the variables bookkeeping the - ! of cell-boundaries in each active coordinate direction are - ! set here. + ! The size of the ghost zone layer in each of the active coordinate + ! directions was set in the module m_mpi_proxy.f90. The results are + ! now transferred to the local variables of this module when they are + ! required by the Silo-HDF5 format, for multidimensional data sets. + ! With the same, latter, requirements, the variables bookkeeping the + ! number of cell-boundaries in each active coordinate direction are + ! also set here. if (format == 1) then if (p > 0) then if (grid_geometry == 3) then @@ -220,10 +220,10 @@ contains end if end if - ! Silo-HDF5 Directory Tree + ! Generating Silo-HDF5 Directory Tree if (format == 1) then - ! the directory associated with the local process + ! Creating the directory associated with the local process dbdir = trim(case_dir)//'/silo_hdf5' write (proc_rank_dir, '(A,I0)') '/p', proc_rank @@ -237,7 +237,7 @@ contains call s_create_directory(trim(proc_rank_dir)) end if - ! the directory associated with the root process + ! Creating the directory associated with the root process if (proc_rank == 0) then rootdir = trim(dbdir)//'/root' @@ -251,11 +251,11 @@ contains end if - ! Binary Directory Tree + ! Generating Binary Directory Tree else - ! the directory associated with the local process + ! Creating the directory associated with the local process dbdir = trim(case_dir)//'/binary' write (proc_rank_dir, '(A,I0)') '/p', proc_rank @@ -270,7 +270,7 @@ contains call s_create_directory(trim(proc_rank_dir)) end if - ! the directory associated with the root process + ! Creating the directory associated with the root process if (n == 0 .and. proc_rank == 0) then rootdir = trim(dbdir)//'/root' @@ -299,24 +299,24 @@ contains end if end if - ! to the Silo-HDF5 database format, handles of the Binary - ! master/root and slave/local process files are perfectly - ! throughout post-process. Hence, they are set here so that - ! do not have to be repetitively computed in later procedures. + ! Contrary to the Silo-HDF5 database format, handles of the Binary + ! database master/root and slave/local process files are perfectly + ! static throughout post-process. Hence, they are set here so that + ! they do not have to be repetitively computed in later procedures. if (format == 2) then if (n == 0 .and. proc_rank == 0) dbroot = 2 dbfile = 1 end if - ! Number of Flow Variable(s) in Binary Output + ! Querying Number of Flow Variable(s) in Binary Output if (format == 2) then - ! the counter of the number of flow variable(s) to - ! written to the formatted database file(s) + ! Initializing the counter of the number of flow variable(s) to + ! be written to the formatted database file(s) dbvars = 0 - ! densities + ! Partial densities if ((model_eqns == 2) .or. (model_eqns == 3)) then do i = 1, num_fluids if (alpha_rho_wrt(i) & @@ -327,7 +327,7 @@ contains end do end if - ! + ! Density if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & .and. (.not. relativity)) then dbvars = dbvars + 1 @@ -336,37 +336,37 @@ contains if (relativity .and. (rho_wrt .or. prim_vars_wrt)) dbvars = dbvars + 1 if (relativity .and. (rho_wrt .or. cons_vars_wrt)) dbvars = dbvars + 1 - ! + ! Momentum do i = 1, E_idx - mom_idx%beg if (mom_wrt(i) .or. cons_vars_wrt) dbvars = dbvars + 1 end do - ! + ! Velocity do i = 1, E_idx - mom_idx%beg if (vel_wrt(i) .or. prim_vars_wrt) dbvars = dbvars + 1 end do - ! limiter function + ! Flux limiter function do i = 1, E_idx - mom_idx%beg if (flux_wrt(i)) dbvars = dbvars + 1 end do - ! + ! Energy if (E_wrt .or. cons_vars_wrt) dbvars = dbvars + 1 - ! + ! Pressure if (pres_wrt .or. prim_vars_wrt) dbvars = dbvars + 1 - ! stresses + ! Elastic stresses if (hypoelasticity) dbvars = dbvars + (num_dims*(num_dims + 1))/2 - ! state variable + ! Damage state variable if (cont_damage) dbvars = dbvars + 1 - ! cleaning for MHD + ! Hyperbolic cleaning for MHD if (hyper_cleaning) dbvars = dbvars + 1 - ! field + ! Magnetic field if (mhd) then if (n == 0) then dbvars = dbvars + 2 @@ -375,7 +375,7 @@ contains end if end if - ! fraction(s) + ! Volume fraction(s) if ((model_eqns == 2) .or. (model_eqns == 3)) then do i = 1, num_fluids - 1 @@ -395,7 +395,7 @@ contains end if - ! heat ratio function + ! Specific heat ratio function if (gamma_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & @@ -403,10 +403,10 @@ contains dbvars = dbvars + 1 end if - ! heat ratio + ! Specific heat ratio if (heat_ratio_wrt) dbvars = dbvars + 1 - ! stiffness function + ! Liquid stiffness function if (pi_inf_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) & @@ -414,13 +414,13 @@ contains dbvars = dbvars + 1 end if - ! stiffness + ! Liquid stiffness if (pres_inf_wrt) dbvars = dbvars + 1 - ! of sound + ! Speed of sound if (c_wrt) dbvars = dbvars + 1 - ! + ! Vorticity if (p > 0) then do i = 1, num_vels if (omega_wrt(i)) dbvars = dbvars + 1 @@ -431,12 +431,12 @@ contains end do end if - ! Schlieren function + ! Numerical Schlieren function if (schlieren_wrt) dbvars = dbvars + 1 end if - ! Querying Number of Flow Variable(s) in Binary Output + ! END: Querying Number of Flow Variable(s) in Binary Output end subroutine s_initialize_data_output_module @@ -466,7 +466,7 @@ contains end if end do - ! no grid points are within the output region + ! If no grid points are within the output region if ((${X}$_cc(lower_bound) > ${X}$_output%end) .or. (${X}$_cc(upper_bound) < ${X}$_output%beg)) then ${X}$_output_idx%beg = 0 ${X}$_output_idx%end = 0 @@ -477,52 +477,52 @@ contains end subroutine s_define_output_region impure subroutine s_open_formatted_database_file(t_step) - ! This subroutine opens a new formatted database file, or - ! an old one, and readies it for the data storage - ! the grid and the flow variable(s) associated with the - ! time-step, t_step. This is performed by all the - ! process(es). The root processor, in addition, must - ! generate a master formatted database file whose job - ! be to link, and thus combine, the data from all of - ! local process(es). Note that for the Binary format, - ! extra task that is assigned to the root process is - ! performed in multidimensions. - - ! that is currently being post-processed + ! Description: This subroutine opens a new formatted database file, or + ! replaces an old one, and readies it for the data storage + ! of the grid and the flow variable(s) associated with the + ! current time-step, t_step. This is performed by all the + ! local process(es). The root processor, in addition, must + ! also generate a master formatted database file whose job + ! will be to link, and thus combine, the data from all of + ! the local process(es). Note that for the Binary format, + ! this extra task that is assigned to the root process is + ! not performed in multidimensions. + + ! Time-step that is currently being post-processed integer, intent(IN) :: t_step - ! string used to store the location of a particular file + ! Generic string used to store the location of a particular file character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc integer :: ierr !< Generic flag used to identify and report database errors - ! Database Format + ! Silo-HDF5 Database Format if (format == 1) then - ! the relative path to the formatted database slave - ! that is to be opened for the current time-step, t_step + ! Generating the relative path to the formatted database slave + ! file, that is to be opened for the current time-step, t_step write (file_loc, '(A,I0,A)') '/', t_step, '.silo' file_loc = trim(proc_rank_dir)//trim(file_loc) - ! formatted database slave file at the above location - ! setting up the structure of the file and its header info + ! Creating formatted database slave file at the above location + ! and setting up the structure of the file and its header info ierr = DBCREATE(trim(file_loc), len_trim(file_loc), & DB_CLOBBER, DB_LOCAL, 'MFC v3.0', 8, & DB_HDF5, dbfile) - ! that the creation and setup process of the formatted - ! slave file has been performed without errors. If this - ! not the case, the post-process exits. + ! Verifying that the creation and setup process of the formatted + ! database slave file has been performed without errors. If this + ! is not the case, the post-process exits. if (dbfile == -1) then call s_mpi_abort('Unable to create Silo-HDF5 database '// & 'slave file '//trim(file_loc)//'. '// & 'Exiting.') end if - ! analogous steps to the ones above are carried out by the - ! process to create and setup the formatted database master - ! + ! Next, analogous steps to the ones above are carried out by the + ! root process to create and setup the formatted database master + ! file. if (proc_rank == 0) then write (file_loc, '(A,I0,A)') '/collection_', t_step, '.silo' @@ -540,32 +540,32 @@ contains end if - ! Database Format + ! Binary Database Format else - ! the relative path to the formatted database slave - ! that is to be opened for the current time-step, t_step + ! Generating the relative path to the formatted database slave + ! file, that is to be opened for the current time-step, t_step write (file_loc, '(A,I0,A)') '/', t_step, '.dat' file_loc = trim(proc_rank_dir)//trim(file_loc) - ! the formatted database slave file, at the previously - ! relative path location, and setting up its structure + ! Creating the formatted database slave file, at the previously + ! precised relative path location, and setting up its structure open (dbfile, IOSTAT=err, FILE=trim(file_loc), & FORM='unformatted', STATUS='replace') - ! that the creation and setup process of the formatted - ! slave file has been performed without errors. If this - ! not the case, the post-process exits. + ! Verifying that the creation and setup process of the formatted + ! database slave file has been performed without errors. If this + ! is not the case, the post-process exits. if (err /= 0) then call s_mpi_abort('Unable to create Binary database slave '// & 'file '//trim(file_loc)//'. Exiting.') end if - ! defining the structure of the formatted database slave - ! by describing in it the dimensionality of post-processed - ! as well as the total number of flow variable(s) that will - ! be stored in it + ! Further defining the structure of the formatted database slave + ! file by describing in it the dimensionality of post-processed + ! data as well as the total number of flow variable(s) that will + ! eventually be stored in it if (output_partial_domain) then write (dbfile) x_output_idx%end - x_output_idx%beg, & y_output_idx%end - y_output_idx%beg, & @@ -575,9 +575,9 @@ contains write (dbfile) m, n, p, dbvars end if - ! analogous steps to the ones above are carried out by the - ! process to create and setup the formatted database master - ! Note that this is only done in multidimensional cases. + ! Next, analogous steps to the ones above are carried out by the + ! root process to create and setup the formatted database master + ! file. Note that this is only done in multidimensional cases. if (n == 0 .and. proc_rank == 0) then write (file_loc, '(A,I0,A)') '/', t_step, '.dat' @@ -607,12 +607,12 @@ contains impure subroutine s_open_intf_data_file() character(LEN=path_len + 3*name_len) :: file_path !< - !! to a file in the case directory + !! Relative path to a file in the case directory write (file_path, '(A)') '/intf_data.dat' file_path = trim(case_dir)//trim(file_path) - ! the simulation data file + ! Opening the simulation data file open (211, FILE=trim(file_path), & FORM='formatted', & POSITION='append', & @@ -623,12 +623,12 @@ contains impure subroutine s_open_energy_data_file() character(LEN=path_len + 3*name_len) :: file_path !< - !! to a file in the case directory + !! Relative path to a file in the case directory write (file_path, '(A)') '/eng_data.dat' file_path = trim(case_dir)//trim(file_path) - ! the simulation data file + ! Opening the simulation data file open (251, FILE=trim(file_path), & FORM='formatted', & POSITION='append', & @@ -637,48 +637,48 @@ contains end subroutine s_open_energy_data_file impure subroutine s_write_grid_to_formatted_database_file(t_step) - ! The general objective of this subroutine is to write the - ! grid data to the formatted database file, for - ! current time-step, t_step. The local processor will - ! the grid data of the domain segment that it is in - ! of to the formatted database slave file. The root - ! will additionally take care of linking that grid - ! in the formatted database master file. In the Silo- - ! database format, the spatial extents of each local - ! grid are also written to the master file. In the - ! format, note that no master file is maintained in - ! Finally, in 1D, no grid data is written - ! this subroutine for the Silo-HDF5 format because - ! objects rather than quadrilateral meshes are used. - ! curve objects, in contrast to the quadrilateral mesh - ! the grid data is included side by side with the - ! variable data. Then, in this case, we take care of - ! both the grid and the flow variable data in the - ! s_write_variable_to_formatted_database_file. - - ! that is currently being post-processed + ! Description: The general objective of this subroutine is to write the + ! necessary grid data to the formatted database file, for + ! the current time-step, t_step. The local processor will + ! write the grid data of the domain segment that it is in + ! charge of to the formatted database slave file. The root + ! process will additionally take care of linking that grid + ! data in the formatted database master file. In the Silo- + ! HDF5 database format, the spatial extents of each local + ! process grid are also written to the master file. In the + ! Binary format, note that no master file is maintained in + ! multidimensions. Finally, in 1D, no grid data is written + ! within this subroutine for the Silo-HDF5 format because + ! curve objects rather than quadrilateral meshes are used. + ! For curve objects, in contrast to the quadrilateral mesh + ! objects, the grid data is included side by side with the + ! flow variable data. Then, in this case, we take care of + ! writing both the grid and the flow variable data in the + ! subroutine s_write_variable_to_formatted_database_file. + + ! Time-step that is currently being post-processed integer, intent(IN) :: t_step - ! variables storing the name and type of mesh that is - ! by the local processor(s). Note that due to an internal - ! Fortran compiler problem, these two variables could not be - ! dynamically. + ! Bookkeeping variables storing the name and type of mesh that is + ! handled by the local processor(s). Note that due to an internal + ! NAG Fortran compiler problem, these two variables could not be + ! allocated dynamically. character(LEN=4*name_len), dimension(num_procs) :: meshnames integer, dimension(num_procs) :: meshtypes - ! loop iterator + ! Generic loop iterator integer :: i integer :: ierr !< Generic flag used to identify and report database errors - ! Database Format + ! Silo-HDF5 Database Format if (format == 1) then - ! multidimensional data sets, the spatial extents of all of - ! grid(s) handled by the local processor(s) are recorded so - ! they may be written, by root processor, to the formatted - ! master file. + ! For multidimensional data sets, the spatial extents of all of + ! the grid(s) handled by the local processor(s) are recorded so + ! that they may be written, by root processor, to the formatted + ! database master file. if (num_procs > 1) then call s_mpi_gather_spatial_extents(spatial_extents) elseif (p > 0) then @@ -698,10 +698,10 @@ contains spatial_extents(:, 0) = (/minval(x_cb), maxval(x_cb)/) end if - ! the root processor proceeds to record all of the spatial - ! in the formatted database master file. In addition, it - ! records a sub-domain connectivity map so that the entire - ! may be reassembled by looking at the master file. + ! Next, the root processor proceeds to record all of the spatial + ! extents in the formatted database master file. In addition, it + ! also records a sub-domain connectivity map so that the entire + ! grid may be reassembled by looking at the master file. if (proc_rank == 0) then do i = 1, num_procs @@ -724,9 +724,9 @@ contains end if - ! the local quadrilateral mesh, either 2D or 3D, along - ! its offsets that indicate the presence and size of ghost - ! layer(s), are put in the formatted database slave file. + ! Finally, the local quadrilateral mesh, either 2D or 3D, along + ! with its offsets that indicate the presence and size of ghost + ! zone layer(s), are put in the formatted database slave file. if (p > 0) then err = DBMKOPTLIST(2, optlist) @@ -767,15 +767,15 @@ contains optlist, ierr) err = DBFREEOPTLIST(optlist) end if - ! Silo-HDF5 Database Format + ! END: Silo-HDF5 Database Format - ! Database Format + ! Binary Database Format elseif (format == 2) then - ! local grid data is written to the formatted - ! slave file. Recall that no master file to maintained - ! multidimensions. + ! Multidimensional local grid data is written to the formatted + ! database slave file. Recall that no master file to maintained + ! in multidimensions. if (p > 0) then if (precision == 1) then write (dbfile) real(x_cb, sp), & @@ -804,9 +804,9 @@ contains end if end if - ! local grid data is written to the formatted - ! slave file. In addition, the local grid data is put - ! by the root process and written to the master file. + ! One-dimensional local grid data is written to the formatted + ! database slave file. In addition, the local grid data is put + ! together by the root process and written to the master file. else if (precision == 1) then @@ -844,55 +844,55 @@ contains end subroutine s_write_grid_to_formatted_database_file impure subroutine s_write_variable_to_formatted_database_file(varname, t_step) - ! The goal of this subroutine is to write to the formatted - ! file the flow variable at the current time-step, - ! The local process(es) write the part of the flow - ! that they handle to the formatted database slave - ! The root process, on the other hand, will also take - ! of connecting all of the flow variable data in the - ! database master file. In the Silo-HDF5 database - ! the extents of each local process flow variable - ! also written to the master file. Note that in Binary - ! no master file is maintained in multidimensions. - ! note that in 1D, grid data is also written within - ! subroutine for Silo-HDF5 database format since curve - ! not the quadrilateral variable objects are used, see - ! of s_write_grid_to_formatted_database_file - ! more details on this topic. - - ! of the flow variable, which will be written to the formatted - ! file at the current time-step, t_step + ! Description: The goal of this subroutine is to write to the formatted + ! database file the flow variable at the current time-step, + ! t_step. The local process(es) write the part of the flow + ! variable that they handle to the formatted database slave + ! file. The root process, on the other hand, will also take + ! care of connecting all of the flow variable data in the + ! formatted database master file. In the Silo-HDF5 database + ! format, the extents of each local process flow variable + ! are also written to the master file. Note that in Binary + ! format, no master file is maintained in multidimensions. + ! Finally note that in 1D, grid data is also written within + ! this subroutine for Silo-HDF5 database format since curve + ! and not the quadrilateral variable objects are used, see + ! description of s_write_grid_to_formatted_database_file + ! for more details on this topic. + + ! Name of the flow variable, which will be written to the formatted + ! database file at the current time-step, t_step character(LEN=*), intent(IN) :: varname - ! that is currently being post-processed + ! Time-step that is currently being post-processed integer, intent(IN) :: t_step - ! variables storing the name and type of flow variable - ! is about to be handled by the local processor(s). Note that - ! to an internal NAG Fortran compiler problem, these variables - ! not be allocated dynamically. + ! Bookkeeping variables storing the name and type of flow variable + ! that is about to be handled by the local processor(s). Note that + ! due to an internal NAG Fortran compiler problem, these variables + ! could not be allocated dynamically. character(LEN=4*name_len), dimension(num_procs) :: varnames integer, dimension(num_procs) :: vartypes - ! loop iterator + ! Generic loop iterator integer :: i, j, k integer :: ierr !< Generic flag used to identify and report database errors - ! Database Format + ! Silo-HDF5 Database Format if (format == 1) then - ! the extents of the flow variable on each local - ! and gathering all this information on root process + ! Determining the extents of the flow variable on each local + ! process and gathering all this information on root process if (num_procs > 1) then call s_mpi_gather_data_extents(q_sf, data_extents) else data_extents(:, 0) = (/minval(q_sf), maxval(q_sf)/) end if - ! the root process proceeds to write the gathered flow - ! data extents to formatted database master file. + ! Next, the root process proceeds to write the gathered flow + ! variable data extents to formatted database master file. if (proc_rank == 0) then do i = 1, num_procs @@ -914,9 +914,9 @@ contains end if - ! each of the local processor(s) proceeds to write - ! flow variable data that it is responsible for to the - ! database slave file. + ! Finally, each of the local processor(s) proceeds to write + ! the flow variable data that it is responsible for to the + ! formatted database slave file. if (wp == dp) then if (precision == 1) then do i = -offset_x%beg, m + offset_x%end @@ -1002,23 +1002,23 @@ contains end if #:endfor - ! Silo-HDF5 Database Format + ! END: Silo-HDF5 Database Format - ! Database Format + ! Binary Database Format else - ! the name of the flow variable and its data, associated - ! the local processor, to the formatted database slave file + ! Writing the name of the flow variable and its data, associated + ! with the local processor, to the formatted database slave file if (precision == 1) then write (dbfile) varname, real(q_sf, wp) else write (dbfile) varname, q_sf end if - ! 1D, the root process also takes care of gathering the flow - ! data from all of the local processor(s) and writes it - ! the formatted database master file. + ! In 1D, the root process also takes care of gathering the flow + ! variable data from all of the local processor(s) and writes it + ! to the formatted database master file. if (n == 0) then if (num_procs > 1) then @@ -1042,7 +1042,7 @@ contains end subroutine s_write_variable_to_formatted_database_file !> Subroutine that writes the post processed results in the folder 'lag_bubbles_data' - !! Current time step + !! @param t_step Current time step impure subroutine s_write_lag_bubbles_results_to_text(t_step) integer, intent(in) :: t_step @@ -1071,11 +1071,11 @@ contains real(wp), dimension(1:1, 1:lag_io_vars) :: lag_io_null lag_io_null = 0._wp - ! file path + ! Construct file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! if file exists + ! Check if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -1106,7 +1106,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! to processor counts position + ! Skip to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -1239,11 +1239,11 @@ contains dummy = 0._wp dummy_data = 0._wp - ! file path + ! Construct file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! if file exists + ! Check if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -1274,7 +1274,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! to processor counts position + ! Skip to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -1285,7 +1285,7 @@ contains call MPI_BCAST(proc_bubble_counts, file_num_procs, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - ! time variables from file + ! Set time variables from file nBub = proc_bubble_counts(proc_rank + 1) @@ -1317,7 +1317,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! extended header + ! Skip extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1328,8 +1328,8 @@ contains call MPI_FILE_CLOSE(ifile, ierr) call MPI_TYPE_FREE(view, ierr) - ! data from MPI_IO_DATA_lg_bubbles array - ! these indices based on your actual data layout + ! Extract data from MPI_IO_DATA_lg_bubbles array + ! Adjust these indices based on your actual data layout #:for VAR, IDX in [('bub_id', 1), ('px', 2), ('py',3), ('pz',4), ('ppx',5), ('ppy',6), ('ppz',7), & ('vx',8), ('vy',9), ('vz',10), ('radius',11), ('rvel',12), & ('rnot',13), ('rmax',14), ('rmin',15), ('dphidt',16), & @@ -1337,10 +1337,10 @@ contains ${VAR}$ (:) = MPI_IO_DATA_lg_bubbles(:, ${IDX}$) #:endfor - ! the root processor proceeds to record all of the spatial - ! in the formatted database master file. In addition, it - ! records a sub-domain connectivity map so that the entire - ! may be reassembled by looking at the master file. + ! Next, the root processor proceeds to record all of the spatial + ! extents in the formatted database master file. In addition, it + ! also records a sub-domain connectivity map so that the entire + ! grid may be reassembled by looking at the master file. if (proc_rank == 0) then do i = 1, num_procs @@ -1388,7 +1388,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! extended header + ! Skip extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1685,26 +1685,26 @@ contains end subroutine s_write_energy_data_file impure subroutine s_close_formatted_database_file() - ! The purpose of this subroutine is to close any formatted - ! file(s) that may be opened at the time-step that - ! currently being post-processed. The root process must - ! close two files, one associated with the local - ! and the other with the entire domain. The non- - ! process(es) must close one file, which is associated - ! the local sub-domain. Note that for the Binary data- - ! format and multidimensional data, the root process - ! has to close the file associated with the local sub- - ! because one associated with the entire domain is - ! generated. + ! Description: The purpose of this subroutine is to close any formatted + ! database file(s) that may be opened at the time-step that + ! is currently being post-processed. The root process must + ! typically close two files, one associated with the local + ! sub-domain and the other with the entire domain. The non- + ! root process(es) must close one file, which is associated + ! with the local sub-domain. Note that for the Binary data- + ! base format and multidimensional data, the root process + ! only has to close the file associated with the local sub- + ! domain, because one associated with the entire domain is + ! not generated. integer :: ierr !< Generic flag used to identify and report database errors - ! database format + ! Silo-HDF5 database format if (format == 1) then ierr = DBCLOSE(dbfile) if (proc_rank == 0) ierr = DBCLOSE(dbroot) - ! database format + ! Binary database format else close (dbfile) if (n == 0 .and. proc_rank == 0) close (dbroot) @@ -1726,21 +1726,21 @@ contains end subroutine s_close_energy_data_file impure subroutine s_finalize_data_output_module() - ! Deallocation procedures for the module + ! Description: Deallocation procedures for the module - ! the generic storage employed for the flow variable(s) - ! were written to the formatted database file(s). Note that the - ! variable is only deallocated in the case of a 1D computation. + ! Deallocating the generic storage employed for the flow variable(s) + ! that were written to the formatted database file(s). Note that the + ! root variable is only deallocated in the case of a 1D computation. deallocate (q_sf) if (n == 0) deallocate (q_root_sf) if (grid_geometry == 3) then deallocate (cyl_q_sf) end if - ! spatial and data extents and also the variables for - ! offsets and the one bookkeeping the number of cell-boundaries - ! each active coordinate direction. Note that all these variables - ! only needed by Silo-HDF5 format for multidimensional data. + ! Deallocating spatial and data extents and also the variables for + ! the offsets and the one bookkeeping the number of cell-boundaries + ! in each active coordinate direction. Note that all these variables + ! were only needed by Silo-HDF5 format for multidimensional data. if (format == 1) then deallocate (spatial_extents) deallocate (data_extents) diff --git a/src/post_process/m_derived_variables.fpp b/src/post_process/m_derived_variables.fpp index 8e7d9a9ca8..d0bf8a689e 100644 --- a/src/post_process/m_derived_variables.fpp +++ b/src/post_process/m_derived_variables.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_derived_variables +!! @file +!! @brief Contains module m_derived_variables !> @brief This module features subroutines that allow for the derivation of -!! variables from the conservative and primitive ones. -!! available derived variables include the unadvected -!! specific heat ratio, liquid stiffness, speed of -!! and the numerical Schlieren function. +!! numerous flow variables from the conservative and primitive ones. +!! Currently, the available derived variables include the unadvected +!! volume fraction, specific heat ratio, liquid stiffness, speed of +!! sound, vorticity and the numerical Schlieren function. module m_derived_variables @@ -35,14 +35,14 @@ module m_derived_variables s_finalize_derived_variables_module real(wp), allocatable, dimension(:, :, :) :: gm_rho_sf !< - !! (gm) of the density for each cell of the computational - !! variable is employed in the calculation of the numerical - !! + !! Gradient magnitude (gm) of the density for each cell of the computational + !! sub-domain. This variable is employed in the calculation of the numerical + !! Schlieren function. !> @name Finite-difference (fd) coefficients in x-, y- and z-coordinate directions. - !! because sufficient boundary information is available for all the - !! directions, the centered family of the finite-difference - !! used. + !! Note that because sufficient boundary information is available for all the + !! active coordinate directions, the centered family of the finite-difference + !! schemes is used. !> @{ real(wp), allocatable, dimension(:, :), public :: fd_coeff_x real(wp), allocatable, dimension(:, :), public :: fd_coeff_y @@ -50,43 +50,43 @@ module m_derived_variables !> @} integer, private :: flg !< - !! variable used to annotate the dimensionality of the dataset - !! undergoing the post-process. A flag value of 1 indicates that the - !! 3D, while a flag value of 0 indicates that it is not. This flg - !! necessary to avoid cycling through the third dimension of the - !! when the simulation is not 3D and the size of the buffer - !! Note that a similar procedure does not have to be applied to - !! dimension since in 1D, the buffer size is always zero. + !! Flagging (flg) variable used to annotate the dimensionality of the dataset + !! that is undergoing the post-process. A flag value of 1 indicates that the + !! dataset is 3D, while a flag value of 0 indicates that it is not. This flg + !! variable is necessary to avoid cycling through the third dimension of the + !! flow variable(s) when the simulation is not 3D and the size of the buffer + !! is non-zero. Note that a similar procedure does not have to be applied to + !! the second dimension since in 1D, the buffer size is always zero. contains !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_derived_variables_module - ! the gradient magnitude of the density variable provided - ! numerical Schlieren function is outputted during post-process + ! Allocating the gradient magnitude of the density variable provided + ! that numerical Schlieren function is outputted during post-process if (schlieren_wrt) then allocate (gm_rho_sf(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end)) end if - ! the variables which will store the coefficients of the - ! family of finite-difference schemes. Note that sufficient - ! is allocated so that the coefficients up to any chosen order - ! accuracy may be bookkept. However, if higher than fourth-order - ! coefficients are wanted, the formulae required to compute - ! coefficients will have to be implemented in the subroutine - ! + ! Allocating the variables which will store the coefficients of the + ! centered family of finite-difference schemes. Note that sufficient + ! space is allocated so that the coefficients up to any chosen order + ! of accuracy may be bookkept. However, if higher than fourth-order + ! accuracy coefficients are wanted, the formulae required to compute + ! these coefficients will have to be implemented in the subroutine + ! s_compute_finite_difference_coefficients. - ! centered finite-difference coefficients in x-direction + ! Allocating centered finite-difference coefficients in x-direction if (omega_wrt(2) .or. omega_wrt(3) .or. schlieren_wrt .or. liutex_wrt) then allocate (fd_coeff_x(-fd_number:fd_number, & -offset_x%beg:m + offset_x%end)) end if - ! centered finite-difference coefficients in y-direction + ! Allocating centered finite-difference coefficients in y-direction if (omega_wrt(1) .or. omega_wrt(3) .or. liutex_wrt & .or. & (n > 0 .and. schlieren_wrt)) then @@ -94,7 +94,7 @@ contains -offset_y%beg:n + offset_y%end)) end if - ! centered finite-difference coefficients in z-direction + ! Allocating centered finite-difference coefficients in z-direction if (omega_wrt(1) .or. omega_wrt(2) .or. liutex_wrt & .or. & (p > 0 .and. schlieren_wrt)) then @@ -102,9 +102,9 @@ contains -offset_z%beg:p + offset_z%end)) end if - ! the dimensionality of the dataset undergoing the post- - ! A flag value of 1 indicates that the dataset is 3D, while - ! flag value of 0 indicates that it is not. + ! Annotating the dimensionality of the dataset undergoing the post- + ! process. A flag value of 1 indicates that the dataset is 3D, while + ! a flag value of 0 indicates that it is not. if (p > 0) then flg = 1 else @@ -114,10 +114,10 @@ contains end subroutine s_initialize_derived_variables_module !> This subroutine receives as input the specific heat ratio - !! and derives from it the specific heat - !! latter is stored in the derived flow quantity - !! q_sf. - !! Specific heat ratio + !! function, gamma_sf, and derives from it the specific heat + !! ratio. The latter is stored in the derived flow quantity + !! storage variable, q_sf. + !! @param q_sf Specific heat ratio subroutine s_derive_specific_heat_ratio(q_sf) real(wp), & @@ -128,7 +128,7 @@ contains integer :: i, j, k !< Generic loop iterators - ! specific heat ratio from specific heat ratio function + ! Computing specific heat ratio from specific heat ratio function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end @@ -140,11 +140,11 @@ contains end subroutine s_derive_specific_heat_ratio !> This subroutine admits as inputs the specific heat ratio - !! the liquid stiffness function, gamma_sf and - !! These are used to calculate the - !! the liquid stiffness, which are stored in the - !! quantity storage variable, q_sf. - !! Liquid stiffness + !! function and the liquid stiffness function, gamma_sf and + !! pi_inf_sf, respectively. These are used to calculate the + !! values of the liquid stiffness, which are stored in the + !! derived flow quantity storage variable, q_sf. + !! @param q_sf Liquid stiffness subroutine s_derive_liquid_stiffness(q_sf) real(wp), & @@ -155,8 +155,8 @@ contains integer :: i, j, k !< Generic loop iterators - ! the values of the liquid stiffness from those of the - ! heat ratio function and the liquid stiffness function + ! Calculating the values of the liquid stiffness from those of the + ! specific heat ratio function and the liquid stiffness function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end @@ -168,12 +168,12 @@ contains end subroutine s_derive_liquid_stiffness !> This subroutine admits as inputs the primitive variables, - !! the specific heat ratio function and liquid - !! It then computes from those variables - !! of the speed of sound, which are stored in the - !! quantity storage variable, q_sf. - !! Primitive variables - !! Speed of sound + !! the density, the specific heat ratio function and liquid + !! stiffness function. It then computes from those variables + !! the values of the speed of sound, which are stored in the + !! derived flow quantity storage variable, q_sf. + !! @param q_prim_vf Primitive variables + !! @param q_sf Speed of sound subroutine s_derive_sound_speed(q_prim_vf, q_sf) type(scalar_field), & @@ -188,16 +188,16 @@ contains integer :: i, j, k !< Generic loop iterators - ! bulk modulus for alternate sound speed + ! Fluid bulk modulus for alternate sound speed real(wp) :: blkmod1, blkmod2 - ! speed of sound values from those of pressure, density, - ! heat ratio function and the liquid stiffness function + ! Computing speed of sound values from those of pressure, density, + ! specific heat ratio function and the liquid stiffness function do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end do i = -offset_x%beg, m + offset_x%end - ! mixture sound speed + ! Compute mixture sound speed if (alt_soundspeed .neqv. .true.) then q_sf(i, j, k) = (((gamma_sf(i, j, k) + 1._wp)* & q_prim_vf(E_idx)%sf(i, j, k) + & @@ -224,13 +224,13 @@ contains end subroutine s_derive_sound_speed !> This subroutine derives the flux_limiter at cell boundary - !! is an approximation because the velocity used - !! the upwind direction is the velocity at the - !! i instead of the contact velocity at the cell - !! the Riemann solver. - !! Component indicator - !! Primitive variables - !! Flux limiter + !! i+1/2. This is an approximation because the velocity used + !! to determine the upwind direction is the velocity at the + !! cell center i instead of the contact velocity at the cell + !! boundary from the Riemann solver. + !! @param i Component indicator + !! @param q_prim_vf Primitive variables + !! @param q_sf Flux limiter subroutine s_derive_flux_limiter(i, q_prim_vf, q_sf) integer, intent(in) :: i @@ -291,15 +291,15 @@ contains if (f_approx_equal(top, bottom)) then slope = 1._wp - ! == 0._wp .AND. bottom /= 0._wp) & - ! & - ! == 0._wp .AND. top /= 0._wp)) THEN - ! = 0._wp + ! ELSEIF((top == 0._wp .AND. bottom /= 0._wp) & + ! .OR. & + ! (bottom == 0._wp .AND. top /= 0._wp)) THEN + ! slope = 0._wp else slope = (top*bottom)/(bottom**2._wp + 1.e-16_wp) end if - ! limiter function + ! Flux limiter function if (flux_lim == 1) then ! MINMOD (MM) q_sf(j, k, l) = max(0._wp, min(1._wp, slope)) elseif (flux_lim == 2) then ! MUSCL (MC) @@ -321,10 +321,10 @@ contains end subroutine s_derive_flux_limiter !> Computes the solution to the linear system Ax=b w/ sol = x - !! Input matrix - !! right-hane-side - !! Solution - !! Problem size + !! @param A Input matrix + !! @param b right-hane-side + !! @param sol Solution + !! @param ndim Problem size subroutine s_solve_linear_system(A, b, sol, ndim) integer, intent(in) :: ndim @@ -336,10 +336,10 @@ contains integer :: i, j, k - ! linear system using own linear solver (Thomson/Darter/Comet/Stampede) - ! elimination + ! Solve linear system using own linear solver (Thomson/Darter/Comet/Stampede) + ! Forward elimination do i = 1, ndim - ! + ! Pivoting j = i - 1 + maxloc(abs(A(i:ndim, i)), 1) sol = A(i, :) A(i, :) = A(j, :) @@ -347,7 +347,7 @@ contains sol(1) = b(i) b(i) = b(j) b(j) = sol(1) - ! + ! Elimination b(i) = b(i)/A(i, i) A(i, :) = A(i, :)/A(i, i) do k = i + 1, ndim @@ -356,7 +356,7 @@ contains end do end do - ! substitution + ! Backward substitution do i = ndim, 1, -1 sol(i) = b(i) do k = i + 1, ndim @@ -367,14 +367,14 @@ contains end subroutine s_solve_linear_system !> This subroutine receives as inputs the indicator of the - !! the vorticity that should be outputted and - !! variables. From those inputs, it proceeds - !! values of the desired vorticity component, - !! subsequently stored in derived flow quantity - !! q_sf. - !! Vorticity component indicator - !! Primitive variables - !! Vorticity component + !! component of the vorticity that should be outputted and + !! the primitive variables. From those inputs, it proceeds + !! to calculate values of the desired vorticity component, + !! which are subsequently stored in derived flow quantity + !! storage variable, q_sf. + !! @param i Vorticity component indicator + !! @param q_prim_vf Primitive variables + !! @param q_sf Vorticity component subroutine s_derive_vorticity_component(i, q_prim_vf, q_sf) integer, intent(in) :: i @@ -391,7 +391,7 @@ contains integer :: j, k, l, r !< Generic loop iterators - ! the vorticity component in the x-coordinate direction + ! Computing the vorticity component in the x-coordinate direction if (i == 1) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -420,7 +420,7 @@ contains end do end do - ! the vorticity component in the y-coordinate direction + ! Computing the vorticity component in the y-coordinate direction elseif (i == 2) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -448,7 +448,7 @@ contains end do end do - ! the vorticity component in the z-coordinate direction + ! Computing the vorticity component in the z-coordinate direction else do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -472,11 +472,11 @@ contains end subroutine s_derive_vorticity_component !> This subroutine gets as inputs the primitive variables. From those - !! proceeds to calculate the value of the Q_M - !! are subsequently stored in the derived flow - !! variable, q_sf. - !! Primitive variables - !! Q_M + !! inputs, it proceeds to calculate the value of the Q_M + !! function, which are subsequently stored in the derived flow + !! quantity storage variable, q_sf. + !! @param q_prim_vf Primitive variables + !! @param q_sf Q_M subroutine s_derive_qm(q_prim_vf, q_sf) type(scalar_field), & dimension(sys_size), & @@ -498,22 +498,22 @@ contains do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end - ! velocity gradient tensor + ! Get velocity gradient tensor q_jacobian_sf(:, :) = 0._wp do r = -fd_number, fd_number do jj = 1, 3 - ! + ! d()/dx q_jacobian_sf(jj, 1) = & q_jacobian_sf(jj, 1) + & fd_coeff_x(r, j)* & q_prim_vf(mom_idx%beg + jj - 1)%sf(r + j, k, l) - ! + ! d()/dy q_jacobian_sf(jj, 2) = & q_jacobian_sf(jj, 2) + & fd_coeff_y(r, k)* & q_prim_vf(mom_idx%beg + jj - 1)%sf(j, r + k, l) - ! + ! d()/dz q_jacobian_sf(jj, 3) = & q_jacobian_sf(jj, 3) + & fd_coeff_z(r, l)* & @@ -521,7 +521,7 @@ contains end do end do - ! J into asymmetric matrix, S, and a skew-symmetric matrix, O + ! Decompose J into asymmetric matrix, S, and a skew-symmetric matrix, O do jj = 1, 3 do kk = 1, 3 S(jj, kk) = 0.5_wp* & @@ -531,7 +531,7 @@ contains end do end do - ! S2 = S*S' + ! Compute S2 = S*S' do jj = 1, 3 do kk = 1, 3 O2(jj, kk) = O(jj, 1)*O(kk, 1) + & @@ -543,7 +543,7 @@ contains end do end do - ! Q + ! Compute Q Q = 0.5_wp*((O2(1, 1) + O2(2, 2) + O2(3, 3)) - & (S2(1, 1) + S2(2, 2) + S2(3, 3))) trS = S(1, 1) + S(2, 2) + S(3, 3) @@ -558,11 +558,11 @@ contains end subroutine s_derive_qm !> This subroutine gets as inputs the primitive variables. From those - !! proceeds to calculate the Liutex vector and its - !! on Xu et al. (2019). - !! @param[in] q_prim_vf Primitive variables - !! @param[out] liutex_mag Liutex magnitude - !! @param[out] liutex_axis Liutex rotation axis (3D vector field) + !! inputs, it proceeds to calculate the Liutex vector and its + !! magnitude based on Xu et al. (2019). + !! @param q_prim_vf Primitive variables + !! @param liutex_mag Liutex magnitude + !! @param liutex_axis Liutex axis impure subroutine s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis) integer, parameter :: nm = 3 type(scalar_field), & @@ -573,13 +573,13 @@ contains dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end), & - intent(out) :: liutex_mag + intent(out) :: liutex_mag !< Liutex magnitude real(wp), & dimension(-offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & -offset_z%beg:p + offset_z%end, nm), & - intent(out) :: liutex_axis + intent(out) :: liutex_axis !< Liutex rigid rotation axis character, parameter :: ivl = 'N' !< compute left eigenvectors character, parameter :: ivr = 'V' !< compute right eigenvectors @@ -603,22 +603,22 @@ contains do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end - ! velocity gradient tensor (VGT) + ! Get velocity gradient tensor (VGT) vgt(:, :) = 0._wp do r = -fd_number, fd_number do i = 1, 3 - ! + ! d()/dx vgt(i, 1) = & vgt(i, 1) + & fd_coeff_x(r, j)* & q_prim_vf(mom_idx%beg + i - 1)%sf(r + j, k, l) - ! + ! d()/dy vgt(i, 2) = & vgt(i, 2) + & fd_coeff_y(r, k)* & q_prim_vf(mom_idx%beg + i - 1)%sf(j, r + k, l) - ! + ! d()/dz vgt(i, 3) = & vgt(i, 3) + & fd_coeff_z(r, l)* & @@ -626,14 +626,14 @@ contains end do end do - ! appropriate LAPACK routine based on precision + ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call sgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info) #else call dgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info) #endif - ! real eigenvector + ! Find real eigenvector idx = 1 do r = 2, 3 if (abs(li(r)) < abs(li(idx))) then @@ -642,7 +642,7 @@ contains end do eigvec = vr(:, idx) - ! real eigenvector if it is effectively non-zero + ! Normalize real eigenvector if it is effectively non-zero eigvec_mag = sqrt(eigvec(1)**2._wp & + eigvec(2)**2._wp & + eigvec(3)**2._wp) @@ -652,22 +652,22 @@ contains eigvec = 0._wp end if - ! vorticity projected on the eigenvector + ! Compute vorticity projected on the eigenvector omega_proj = (vgt(3, 2) - vgt(2, 3))*eigvec(1) & + (vgt(1, 3) - vgt(3, 1))*eigvec(2) & + (vgt(2, 1) - vgt(1, 2))*eigvec(3) - ! eigenvector can have +/- signs, we can choose the sign - ! that omega_proj is positive + ! As eigenvector can have +/- signs, we can choose the sign + ! so that omega_proj is positive if (omega_proj < 0._wp) then eigvec = -eigvec omega_proj = -omega_proj end if - ! imaginary part of complex eigenvalue + ! Find imaginary part of complex eigenvalue lci = li(mod(idx, 3) + 1) - ! Liutex magnitude + ! Compute Liutex magnitude alpha = omega_proj**2._wp - 4._wp*lci**2._wp ! (2*alpha)^2 if (alpha > 0._wp) then liutex_mag(j, k, l) = omega_proj - sqrt(alpha) @@ -675,7 +675,7 @@ contains liutex_mag(j, k, l) = omega_proj end if - ! Liutex axis + ! Compute Liutex axis liutex_axis(j, k, l, 1) = eigvec(1) liutex_axis(j, k, l, 2) = eigvec(2) liutex_axis(j, k, l, 3) = eigvec(3) @@ -687,12 +687,12 @@ contains end subroutine s_derive_liutex !> This subroutine gets as inputs the conservative variables - !! From those inputs, it proceeds to calculate - !! of the numerical Schlieren function, which are - !! in the derived flow quantity storage - !! - !! Conservative variables - !! Numerical Schlieren function + !! and density. From those inputs, it proceeds to calculate + !! the values of the numerical Schlieren function, which are + !! subsequently stored in the derived flow quantity storage + !! variable, q_sf. + !! @param q_cons_vf Conservative variables + !! @param q_sf Numerical Schlieren function impure subroutine s_derive_numerical_schlieren_function(q_cons_vf, q_sf) type(scalar_field), & @@ -706,19 +706,19 @@ contains intent(inout) :: q_sf real(wp) :: drho_dx, drho_dy, drho_dz !< - !! of the density in the x-, y- and z-directions + !! Spatial derivatives of the density in the x-, y- and z-directions real(wp), dimension(2) :: gm_rho_max !< - !! of the gradient magnitude (gm) of the density field - !! computational domain and not just the local sub-domain. - !! position in the variable contains the maximum value and - !! contains the rank of the processor on which it occurred. + !! Maximum value of the gradient magnitude (gm) of the density field + !! in entire computational domain and not just the local sub-domain. + !! The first position in the variable contains the maximum value and + !! the second contains the rank of the processor on which it occurred. integer :: i, j, k, l !< Generic loop iterators - ! Gradient Magnitude of Density + ! Computing Gradient Magnitude of Density - ! from the x- and y-coordinate directions + ! Contributions from the x- and y-coordinate directions do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end do j = -offset_x%beg, m + offset_x%end @@ -737,7 +737,7 @@ contains end do end do - ! from the z-coordinate direction + ! Contribution from the z-coordinate direction if (p > 0) then do l = -offset_z%beg, p + offset_z%end do k = -offset_y%beg, n + offset_y%end @@ -763,31 +763,31 @@ contains end do end if - ! until now, only the dot product of the gradient of the density - ! has been calculated and stored in the gradient magnitude of - ! variable. So now we proceed to take the square-root as to - ! the desired calculation. + ! Up until now, only the dot product of the gradient of the density + ! field has been calculated and stored in the gradient magnitude of + ! density variable. So now we proceed to take the square-root as to + ! complete the desired calculation. gm_rho_sf = sqrt(gm_rho_sf) - ! the local maximum of the gradient magnitude of density - ! bookkeeping the result, along with rank of the local processor + ! Determining the local maximum of the gradient magnitude of density + ! and bookkeeping the result, along with rank of the local processor gm_rho_max = (/maxval(gm_rho_sf), real(proc_rank, wp)/) - ! the local maximum gradient magnitude of the density on - ! processor to the those computed on the remaining processors. - ! allows for the global maximum to be computed and the rank of - ! processor on which it has occurred to be recorded. + ! Comparing the local maximum gradient magnitude of the density on + ! this processor to the those computed on the remaining processors. + ! This allows for the global maximum to be computed and the rank of + ! the processor on which it has occurred to be recorded. if (num_procs > 1) call s_mpi_reduce_maxloc(gm_rho_max) - ! Numerical Schlieren Function + ! Computing Numerical Schlieren Function - ! form of the numerical Schlieren function depends on the choice - ! the multicomponent flow model. For the gamma/pi_inf model, the - ! of the negative, normalized, gradient magnitude of the - ! is computed. For the volume fraction model, the amplitude - ! the exponential's inside is also modulated with respect to the - ! of the fluid in which the function is evaluated. For more - ! refer to Marquina and Mulet (2003). + ! The form of the numerical Schlieren function depends on the choice + ! of the multicomponent flow model. For the gamma/pi_inf model, the + ! exponential of the negative, normalized, gradient magnitude of the + ! density is computed. For the volume fraction model, the amplitude + ! of the exponential's inside is also modulated with respect to the + ! identity of the fluid in which the function is evaluated. For more + ! information, refer to Marquina and Mulet (2003). if (model_eqns == 1) then ! Gamma/pi_inf model q_sf = -gm_rho_sf/gm_rho_max(1) @@ -810,9 +810,9 @@ contains end do end if - ! until now, only the inside of the exponential of the numerical - ! function has been evaluated and stored. Then, to finish - ! computation, the exponential of the inside quantity is taken. + ! Up until now, only the inside of the exponential of the numerical + ! Schlieren function has been evaluated and stored. Then, to finish + ! the computation, the exponential of the inside quantity is taken. q_sf = exp(q_sf) end subroutine s_derive_numerical_schlieren_function @@ -820,13 +820,13 @@ contains !> Deallocation procedures for the module impure subroutine s_finalize_derived_variables_module - ! the variable containing the gradient magnitude of the - ! field provided that the numerical Schlieren function was - ! outputted during the post-process + ! Deallocating the variable containing the gradient magnitude of the + ! density field provided that the numerical Schlieren function was + ! was outputted during the post-process if (schlieren_wrt) deallocate (gm_rho_sf) - ! the variables that might have been used to bookkeep - ! finite-difference coefficients in the x-, y- and z-directions + ! Deallocating the variables that might have been used to bookkeep + ! the finite-difference coefficients in the x-, y- and z-directions if (allocated(fd_coeff_x)) deallocate (fd_coeff_x) if (allocated(fd_coeff_y)) deallocate (fd_coeff_y) if (allocated(fd_coeff_z)) deallocate (fd_coeff_z) diff --git a/src/post_process/m_global_parameters.fpp b/src/post_process/m_global_parameters.fpp index 9e1d96789a..1411b104d4 100644 --- a/src/post_process/m_global_parameters.fpp +++ b/src/post_process/m_global_parameters.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_global_parameters +!! @file +!! @brief Contains module m_global_parameters #:include 'case.fpp' !> @brief This module contains all of the parameters characterizing the -!! simulation algorithm, stiffened equation of -!! finally, the formatted database file(s) structure. +!! computational domain, simulation algorithm, stiffened equation of +!! state and finally, the formatted database file(s) structure. module m_global_parameters #ifdef MFC_MPI @@ -27,7 +27,7 @@ module m_global_parameters character(LEN=path_len) :: case_dir !< Case folder location !> @} - ! Domain Parameters + ! Computational Domain Parameters integer :: proc_rank !< Rank of the local processor @@ -74,9 +74,9 @@ module m_global_parameters !> @} integer :: buff_size !< - !! cells in buffer region. For the variables which feature a buffer - !! region is used to store information outside the computational - !! on the boundary conditions. + !! Number of cells in buffer region. For the variables which feature a buffer + !! region, this region is used to store information outside the computational + !! domain based on the boundary conditions. integer :: t_step_start !< First time-step directory integer :: t_step_stop !< Last time-step directory @@ -92,9 +92,9 @@ module m_global_parameters integer :: n_start !> @} - ! The variables m_root, x_root_cb and x_root_cc contain the grid data - ! the defragmented computational domain. They are only used in 1D. For - ! simulations, they are equal to m, x_cb and x_cc, respectively. + ! NOTE: The variables m_root, x_root_cb and x_root_cc contain the grid data + ! of the defragmented computational domain. They are only used in 1D. For + ! serial simulations, they are equal to m, x_cb and x_cc, respectively. !> @name Simulation Algorithm Parameters !> @{ @@ -147,13 +147,13 @@ module m_global_parameters integer :: psi_idx !< Index of hyperbolic cleaning state variable for MHD !> @} - ! Indices for the (local) interior points (O-m, O-n, 0-p). - ! for "InDices With BUFFer". + ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). + ! Stands for "InDices With BUFFer". type(int_bounds_info) :: idwint(1:3) - ! Indices for the entire (local) domain. In simulation, this includes - ! buffer region. idwbuff and idwint are the same otherwise. - ! for "InDices With BUFFer". + ! Cell Indices for the entire (local) domain. In simulation, this includes + ! the buffer region. idwbuff and idwint are the same otherwise. + ! Stands for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) integer :: num_bc_patches @@ -165,22 +165,22 @@ module m_global_parameters integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! the stress components that represent shear stress + !! Indices of the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! shear stress components to reflect for boundary conditions + !! Number of shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! shear stress components to reflect for boundary conditions. - !! 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! Indices of shear stress components to reflect for boundary conditions. + !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) logical :: parallel_io !< Format of the data files logical :: sim_data logical :: file_per_process !< output format integer, allocatable, dimension(:) :: proc_coords !< - !! in MPI_CART_COMM + !! Processor coordinates in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! index of local processor in global grid + !! Starting cell-center index of local processor in global grid integer :: num_ibs !< Number of immersed boundaries @@ -201,16 +201,16 @@ module m_global_parameters !> @} type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! the physical parameters of each of the fluids that is present - !! flow. These include the stiffened gas equation of state parameters, - !! Reynolds numbers. + !! Database of the physical parameters of each of the fluids that is present + !! in the flow. These include the stiffened gas equation of state parameters, + !! and the Reynolds numbers. - ! Bubble Parameters + ! Subgrid Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp real(wp), allocatable, dimension(:) :: adv !< Advection variables - ! Database File(s) Structure Parameters + ! Formatted Database File(s) Structure Parameters integer :: format !< Format of the database file(s) @@ -223,20 +223,20 @@ module m_global_parameters type(int_bounds_info) :: x_output_idx, y_output_idx, z_output_idx !< Indices of domain to output for post-processing !> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions. - !! of the ghost zone layers is only necessary when using the - !! file format in multidimensions. These zones provide VisIt - !! subdomain connectivity information that it requires in order to - !! plots. + !! The definition of the ghost zone layers is only necessary when using the + !! Silo database file format in multidimensions. These zones provide VisIt + !! with the subdomain connectivity information that it requires in order to + !! produce smooth plots. !> @{ type(int_bounds_info) :: offset_x, offset_y, offset_z !> @} !> @name The list of all possible flow variables that may be written to a database - !! includes partial densities, density, momentum, velocity, energy, - !! fraction(s), specific heat ratio function, specific heat - !! stiffness function, liquid stiffness, primitive variables, - !! speed of sound, the vorticity, - !! numerical Schlieren function. + !! file. It includes partial densities, density, momentum, velocity, energy, + !! pressure, volume fraction(s), specific heat ratio function, specific heat + !! ratio, liquid stiffness function, liquid stiffness, primitive variables, + !! conservative variables, speed of sound, the vorticity, + !! and the numerical Schlieren function. !> @{ logical, dimension(num_fluids_max) :: alpha_rho_wrt logical :: rho_wrt @@ -286,20 +286,20 @@ module m_global_parameters !> @} real(wp), dimension(num_fluids_max) :: schlieren_alpha !< - !! of the numerical Schlieren function that are used - !! the intensity of numerical Schlieren renderings for individual - !! enables waves and interfaces of varying strengths and in all - !! fluids to be made simultaneously visible on a single plot. + !! Amplitude coefficients of the numerical Schlieren function that are used + !! to adjust the intensity of numerical Schlieren renderings for individual + !! fluids. This enables waves and interfaces of varying strengths and in all + !! of the fluids to be made simultaneously visible on a single plot. integer :: fd_order !< - !! of the finite-difference (fd) approximations of the first-order - !! need to be evaluated when vorticity and/or the numerical - !! are to be outputted to the formatted database file(s). + !! The order of the finite-difference (fd) approximations of the first-order + !! derivatives that need to be evaluated when vorticity and/or the numerical + !! Schlieren function are to be outputted to the formatted database file(s). integer :: fd_number !< - !! number is given by MAX(1, fd_order/2). Essentially, - !! a measure of the half-size of the finite-difference stencil for the - !! of accuracy. + !! The finite-difference number is given by MAX(1, fd_order/2). Essentially, + !! it is a measure of the half-size of the finite-difference stencil for the + !! selected order of accuracy. !> @name Reference parameters for Tait EOS !> @{ @@ -361,16 +361,16 @@ module m_global_parameters contains !> Assigns default values to user inputs prior to reading - !! This allows for an easier consistency check of - !! once they are read from the input file. + !! them in. This allows for an easier consistency check of + !! these parameters once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i !< Generic loop iterator - ! + ! Logistics case_dir = '.' - ! domain parameters + ! Computational domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -389,7 +389,7 @@ contains n_start = dflt_int t_stop = dflt_real - ! algorithm parameters + ! Simulation algorithm parameters model_eqns = dflt_int num_fluids = dflt_int recon_type = WENO_TYPE @@ -428,7 +428,7 @@ contains chem_params%gamma_method = 1 chem_params%transport_model = 1 - ! physical parameters + ! Fluids physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -438,7 +438,7 @@ contains fluid_pp(i)%G = dflt_real end do - ! bubble parameters + ! Subgrid bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -460,7 +460,7 @@ contains bub_pp%R_v = dflt_real; R_v = dflt_real bub_pp%R_g = dflt_real; R_g = dflt_real - ! database file(s) structure parameters + ! Formatted database file(s) structure parameters format = dflt_int precision = dflt_int @@ -520,11 +520,11 @@ contains fd_order = dflt_int avg_state = dflt_int - ! EOS + ! Tait EOS rhoref = dflt_real pref = dflt_real - ! modeling + ! Bubble modeling bubbles_euler = .false. qbmm = .false. R0ref = dflt_real @@ -536,13 +536,13 @@ contains surface_tension = .false. adv_n = .false. - ! bubbles modeling + ! Lagrangian bubbles modeling bubbles_lagrange = .false. - ! + ! IBM num_ibs = dflt_int - ! partial domain + ! Output partial domain output_partial_domain = .false. x_output%beg = dflt_real x_output%end = dflt_real @@ -551,29 +551,29 @@ contains z_output%beg = dflt_real z_output%end = dflt_real - ! + ! MHD Bx0 = dflt_real end subroutine s_assign_default_values_to_user_inputs !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_global_parameters_module integer :: i, j, fac - ! m_root equal to m in the case of a 1D serial simulation + ! Setting m_root equal to m in the case of a 1D serial simulation if (n == 0) m_root = m_glb - ! Model + ! Gamma/Pi_inf Model if (model_eqns == 1) then - ! number of fluids + ! Setting number of fluids num_fluids = 1 - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the gamma/pi_inf model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -585,12 +585,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Fraction Model (5-equation model) + ! Volume Fraction Model (5-equation model) else if (model_eqns == 2) then - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the volume fraction model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -598,17 +598,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! fractions are stored in the indices immediately following - ! energy equation. IGR tracks a total of (N-1) volume fractions - ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! adv_idx%end < adv_idx%beg, which skips all loops over the - ! fractions since there is no volume fraction to track + ! Volume fractions are stored in the indices immediately following + ! the energy equation. IGR tracks a total of (N-1) volume fractions + ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! then adv_idx%end < adv_idx%beg, which skips all loops over the + ! volume fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 ! Alpha for fluid 1 adv_idx%end = E_idx + num_fluids - 1 else - ! fractions are stored in the indices immediately following - ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! Volume fractions are stored in the indices immediately following + ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -690,12 +690,12 @@ contains sys_size = B_idx%end end if - ! Fraction Model (6-equation model) + ! Volume Fraction Model (6-equation model) else if (model_eqns == 3) then - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the volume fraction model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -768,10 +768,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! stress index is 2 for 2D and 2,4,5 for 3D + ! shear stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -779,7 +779,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! x-dir and y-dir: flip tau_xy only + ! Both x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -787,18 +787,18 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! flip tau_xy and tau_xz - ! flip tau_xy and tau_yz - ! flip tau_xz and tau_yz + ! x-dir: flip tau_xy and tau_xz + ! y-dir: flip tau_xy and tau_yz + ! z-dir: flip tau_xz and tau_yz end if end if if (hyperelasticity) then xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! three more equations for the \xi field and the elastic energy + ! adding three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 - ! of entries in the symmetric btensor plus the jacobian + ! number of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 tensor_size = num_dims**2 + 1 end if @@ -874,11 +874,11 @@ contains if (ib) allocate (MPI_IO_IB_DATA%var%sf(0:m, 0:n, 0:p)) #endif - ! of the ghost zone layer is non-zero only when post-processing - ! raw simulation data of a parallel multidimensional computation - ! the Silo-HDF5 format. If this is the case, one must also verify - ! the raw simulation data is 2D or 3D. In the 2D case, size - ! the z-coordinate direction ghost zone layer must be zeroed out. + ! Size of the ghost zone layer is non-zero only when post-processing + ! the raw simulation data of a parallel multidimensional computation + ! in the Silo-HDF5 format. If this is the case, one must also verify + ! whether the raw simulation data is 2D or 3D. In the 2D case, size + ! of the z-coordinate direction ghost zone layer must be zeroed out. if (num_procs == 1 .or. format /= 1) then offset_x%beg = 0 @@ -902,12 +902,12 @@ contains end if - ! the finite-difference number and the buffer size. Note - ! the size of the buffer is unrelated to the order of the WENO - ! Rather, it is directly dependent on maximum size of ghost - ! layers and possibly the order of the finite difference scheme - ! for the computation of vorticity and/or numerical Schlieren - ! + ! Determining the finite-difference number and the buffer size. Note + ! that the size of the buffer is unrelated to the order of the WENO + ! scheme. Rather, it is directly dependent on maximum size of ghost + ! zone layers and possibly the order of the finite difference scheme + ! used for the computation of vorticity and/or numerical Schlieren + ! function. buff_size = max(offset_x%beg, offset_x%end, offset_y%beg, & offset_y%end, offset_z%beg, offset_z%end) @@ -916,7 +916,7 @@ contains buff_size = buff_size + fd_number end if - ! Coordinate Direction Indexes + ! Configuring Coordinate Direction Indexes idwint(1)%beg = 0; idwint(2)%beg = 0; idwint(3)%beg = 0 idwint(1)%end = m; idwint(2)%end = n; idwint(3)%end = p @@ -928,15 +928,15 @@ contains idwbuff(2)%end = idwint(2)%end - idwbuff(2)%beg idwbuff(3)%end = idwint(3)%end - idwbuff(3)%beg - ! single precision grid variables if needed + ! Allocating single precision grid variables if needed allocate (x_cc_s(-buff_size:m + buff_size)) - ! the grid variables in the x-coordinate direction + ! Allocating the grid variables in the x-coordinate direction allocate (x_cb(-1 - offset_x%beg:m + offset_x%end)) allocate (x_cc(-buff_size:m + buff_size)) allocate (dx(-buff_size:m + buff_size)) - ! grid variables in the y- and z-coordinate directions + ! Allocating grid variables in the y- and z-coordinate directions if (n > 0) then allocate (y_cb(-1 - offset_y%beg:n + offset_y%end)) @@ -949,8 +949,8 @@ contains allocate (dz(-buff_size:p + buff_size)) end if - ! the grid variables, only used for the 1D simulations, - ! containing the defragmented computational domain grid data + ! Allocating the grid variables, only used for the 1D simulations, + ! and containing the defragmented computational domain grid data else allocate (x_root_cb(-1:m_root)) @@ -995,16 +995,16 @@ contains #ifdef MFC_MPI - ! for Lustre file system (Darter/Comet/Stampede) + ! Option for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! for UNIX file system (Hooke/Thomson) - ! '(A)') '/ufs_' - ! = TRIM(mpiiofs) - ! = MPI_INFO_NULL + ! Option for UNIX file system (Hooke/Thomson) + ! WRITE(mpiiofs, '(A)') '/ufs_' + ! mpiiofs = TRIM(mpiiofs) + ! mpi_info_int = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1017,18 +1017,18 @@ contains integer :: i - ! the grid variables for the x-coordinate direction + ! Deallocating the grid variables for the x-coordinate direction deallocate (x_cc, x_cb, dx) - ! grid variables for the y- and z-coordinate directions + ! Deallocating grid variables for the y- and z-coordinate directions if (n > 0) then deallocate (y_cc, y_cb, dy) if (p > 0) then deallocate (z_cc, z_cb, dz) end if else - ! the grid variables, only used for the 1D simulations, - ! containing the defragmented computational domain grid data + ! Deallocating the grid variables, only used for the 1D simulations, + ! and containing the defragmented computational domain grid data deallocate (x_root_cb, x_root_cc) end if diff --git a/src/post_process/m_mpi_proxy.fpp b/src/post_process/m_mpi_proxy.fpp index 1420274812..8c004dc8bc 100644 --- a/src/post_process/m_mpi_proxy.fpp +++ b/src/post_process/m_mpi_proxy.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_mpi_proxy +!! @file +!! @brief Contains module m_mpi_proxy !> @brief This module serves as a proxy to the parameters and subroutines -!! the MPI implementation's MPI module. Specifically, -!! of the proxy is to harness basic MPI commands into more -!! as to achieve the required communication goals -!! post-process. +!! available in the MPI implementation's MPI module. Specifically, +!! the role of the proxy is to harness basic MPI commands into more +!! complex procedures as to achieve the required communication goals +!! for the post-process. module m_mpi_proxy #ifdef MFC_MPI @@ -24,8 +24,8 @@ module m_mpi_proxy implicit none !> @name Receive counts and displacement vector variables, respectively, used in - !! to gather varying amounts of data from all processes to the - !! + !! enabling MPI to gather varying amounts of data from all processes to the + !! root process !> @{ integer, allocatable, dimension(:) :: recvcounts integer, allocatable, dimension(:) :: displs @@ -34,7 +34,7 @@ module m_mpi_proxy contains !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_mpi_proxy_module #ifdef MFC_MPI @@ -42,10 +42,10 @@ contains integer :: i !< Generic loop iterator integer :: ierr !< Generic flag used to identify and report MPI errors - ! and configuring the receive counts and the displacement - ! variables used in variable-gather communication procedures. - ! that these are only needed for either multidimensional runs - ! utilize the Silo database file format or for 1D simulations. + ! Allocating and configuring the receive counts and the displacement + ! vector variables used in variable-gather communication procedures. + ! Note that these are only needed for either multidimensional runs + ! that utilize the Silo database file format or for 1D simulations. if ((format == 1 .and. n > 0) .or. n == 0) then allocate (recvcounts(0:num_procs - 1)) @@ -73,17 +73,17 @@ contains end subroutine s_initialize_mpi_proxy_module !> Since only processor with rank 0 is in charge of reading - !! the consistency of the user provided inputs, - !! not available to the remaining processors. This - !! then in charge of broadcasting the required - !! + !! and checking the consistency of the user provided inputs, + !! these are not available to the remaining processors. This + !! subroutine is then in charge of broadcasting the required + !! information. impure subroutine s_mpi_bcast_user_inputs #ifdef MFC_MPI integer :: i !< Generic loop iterator integer :: ierr !< Generic flag used to identify and report MPI errors - ! + ! Logistics call MPI_BCAST(case_dir, len(case_dir), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) #:for VAR in [ 'm', 'n', 'p', 'm_glb', 'n_glb', 'p_glb', & @@ -136,7 +136,7 @@ contains call MPI_BCAST(fluid_pp(i)%G, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) end do - ! bubble parameters + ! Subgrid bubble parameters if (bubbles_euler .or. bubbles_lagrange) then #:for VAR in [ 'R0ref','p0ref','rho0ref','T0ref', & 'ss','pv','vd','mu_l','mu_v','mu_g','gam_v','gam_g', & @@ -157,11 +157,11 @@ contains end subroutine s_mpi_bcast_user_inputs !> This subroutine gathers the Silo database metadata for - !! extents in order to boost the performance of - !! visualization. - !! Spatial extents for each processor's sub-domain. First dimension - !! the minimum and maximum values, respectively, while - !! dimension corresponds to the processor rank. + !! the spatial extents in order to boost the performance of + !! the multidimensional visualization. + !! @param spatial_extents Spatial extents for each processor's sub-domain. First dimension + !! corresponds to the minimum and maximum values, respectively, while + !! the second dimension corresponds to the processor rank. impure subroutine s_mpi_gather_spatial_extents(spatial_extents) real(wp), dimension(1:, 0:), intent(INOUT) :: spatial_extents @@ -169,117 +169,117 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! is 3D + ! Simulation is 3D if (p > 0) then if (grid_geometry == 3) then - ! spatial extent in the r-direction + ! Minimum spatial extent in the r-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the theta-direction + ! Minimum spatial extent in the theta-direction call MPI_GATHERV(minval(z_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the z-direction + ! Minimum spatial extent in the z-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the r-direction + ! Maximum spatial extent in the r-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the theta-direction + ! Maximum spatial extent in the theta-direction call MPI_GATHERV(maxval(z_cb), 1, mpi_p, & spatial_extents(5, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the z-direction + ! Maximum spatial extent in the z-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(6, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) else - ! spatial extent in the x-direction + ! Minimum spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the y-direction + ! Minimum spatial extent in the y-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the z-direction + ! Minimum spatial extent in the z-direction call MPI_GATHERV(minval(z_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the x-direction + ! Maximum spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the y-direction + ! Maximum spatial extent in the y-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(5, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the z-direction + ! Maximum spatial extent in the z-direction call MPI_GATHERV(maxval(z_cb), 1, mpi_p, & spatial_extents(6, 0), recvcounts, 6*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) end if - ! is 2D + ! Simulation is 2D elseif (n > 0) then - ! spatial extent in the x-direction + ! Minimum spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the y-direction + ! Minimum spatial extent in the y-direction call MPI_GATHERV(minval(y_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the x-direction + ! Maximum spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(3, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the y-direction + ! Maximum spatial extent in the y-direction call MPI_GATHERV(maxval(y_cb), 1, mpi_p, & spatial_extents(4, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! is 1D + ! Simulation is 1D else - ! spatial extent in the x-direction + ! Minimum spatial extent in the x-direction call MPI_GATHERV(minval(x_cb), 1, mpi_p, & spatial_extents(1, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! spatial extent in the x-direction + ! Maximum spatial extent in the x-direction call MPI_GATHERV(maxval(x_cb), 1, mpi_p, & spatial_extents(2, 0), recvcounts, 4*displs, & mpi_p, 0, MPI_COMM_WORLD, & @@ -291,16 +291,16 @@ contains end subroutine s_mpi_gather_spatial_extents !> This subroutine collects the sub-domain cell-boundary or - !! data from all of the processors and - !! together the grid of the entire computational - !! the rank 0 processor. This is only done for 1D - !! + !! cell-center locations data from all of the processors and + !! puts back together the grid of the entire computational + !! domain on the rank 0 processor. This is only done for 1D + !! simulations. impure subroutine s_mpi_defragment_1d_grid_variable #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! database format + ! Silo-HDF5 database format if (format == 1) then call MPI_GATHERV(x_cc(0), m + 1, mpi_p, & @@ -308,7 +308,7 @@ contains mpi_p, 0, MPI_COMM_WORLD, & ierr) - ! database format + ! Binary database format else call MPI_GATHERV(x_cb(0), m + 1, mpi_p, & @@ -325,13 +325,13 @@ contains end subroutine s_mpi_defragment_1d_grid_variable !> This subroutine gathers the Silo database metadata for - !! variable's extents as to boost performance of - !! visualization. - !! Flow variable defined on a single computational sub-domain - !! The flow variable extents on each of the processor's sub-domain. - !! of array corresponds to the former's minimum and - !! respectively, while second dimension corresponds - !! processor's rank. + !! the flow variable's extents as to boost performance of + !! the multidimensional visualization. + !! @param q_sf Flow variable defined on a single computational sub-domain + !! @param data_extents The flow variable extents on each of the processor's sub-domain. + !! First dimension of array corresponds to the former's minimum and + !! maximum values, respectively, while second dimension corresponds + !! to each processor's rank. impure subroutine s_mpi_gather_data_extents(q_sf, data_extents) real(wp), dimension(:, :, :), intent(in) :: q_sf @@ -340,12 +340,12 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! flow variable extent + ! Minimum flow variable extent call MPI_GATHERV(minval(q_sf), 1, mpi_p, & data_extents(1, 0), recvcounts, 2*displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) - ! flow variable extent + ! Maximum flow variable extent call MPI_GATHERV(maxval(q_sf), 1, mpi_p, & data_extents(2, 0), recvcounts, 2*displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -355,11 +355,11 @@ contains end subroutine s_mpi_gather_data_extents !> This subroutine gathers the sub-domain flow variable data - !! of the processors and puts it back together for - !! computational domain on the rank 0 processor. - !! only done for 1D simulations. - !! Flow variable defined on a single computational sub-domain - !! Flow variable defined on the entire computational domain + !! from all of the processors and puts it back together for + !! the entire computational domain on the rank 0 processor. + !! This is only done for 1D simulations. + !! @param q_sf Flow variable defined on a single computational sub-domain + !! @param q_root_sf Flow variable defined on the entire computational domain impure subroutine s_mpi_defragment_1d_flow_variable(q_sf, q_root_sf) real(wp), dimension(0:m), intent(in) :: q_sf @@ -368,9 +368,9 @@ contains #ifdef MFC_MPI integer :: ierr !< Generic flag used to identify and report MPI errors - ! the sub-domain flow variable data from all the processes - ! putting it back together for the entire computational domain - ! the process with rank 0 + ! Gathering the sub-domain flow variable data from all the processes + ! and putting it back together for the entire computational domain + ! on the process with rank 0 call MPI_GATHERV(q_sf(0), m + 1, mpi_p, & q_root_sf(0), recvcounts, displs, & mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -384,8 +384,8 @@ contains #ifdef MFC_MPI - ! the receive counts and the displacement vector - ! used in variable-gather communication procedures + ! Deallocating the receive counts and the displacement vector + ! variables used in variable-gather communication procedures if ((format == 1 .and. n > 0) .or. n == 0) then deallocate (recvcounts) deallocate (displs) diff --git a/src/post_process/m_start_up.fpp b/src/post_process/m_start_up.fpp index 3f10c05bfb..aacd208bfe 100644 --- a/src/post_process/m_start_up.fpp +++ b/src/post_process/m_start_up.fpp @@ -1,17 +1,17 @@ #:include 'macros.fpp' !> -!! -!! module m_start_up +!! @file +!! @brief Contains module m_start_up !> @brief This module contains the subroutines that read in and check the -!! the user provided inputs. This module also allocates, initializes and -!! relevant variables and sets up the time stepping, -!! and I/O procedures +!! consistency of the user provided inputs. This module also allocates, initializes and +!! deallocates the relevant variables and sets up the time stepping, +!! MPI decomposition and I/O procedures module m_start_up - ! + ! Dependencies use, intrinsic :: iso_c_binding @@ -26,16 +26,16 @@ module m_start_up use m_boundary_common !< Common boundary conditions subroutines use m_variables_conversion !< Subroutines to change the state variables from - !! to another + !! one form to another use m_data_input !< Procedures reading raw simulation data to fill - !! primitive and grid variables + !! the conservative, primitive and grid variables use m_data_output !< Procedures that write the grid and chosen flow - !! the formatted database file(s) + !! variable(s) to the formatted database file(s) use m_derived_variables !< Procedures used to compute quantities derived - !! conservative and primitive variables + !! from the conservative and primitive variables use m_helper use m_compile_specific @@ -74,23 +74,23 @@ module m_start_up contains !> Reads the configuration file post_process.inp, in order - !! parameters in module m_global_parameters.f90 - !! user provided inputs + !! to populate parameters in module m_global_parameters.f90 + !! with the user provided inputs impure subroutine s_read_input_file character(LEN=name_len) :: file_loc !< - !! used to store the address of a particular file + !! Generic string used to store the address of a particular file logical :: file_check !< - !! used for the purpose of asserting whether a file - !! is not present in the designated location + !! Generic logical used for the purpose of asserting whether a file + !! is or is not present in the designated location integer :: iostatus - !! check iostat of file read + !! Integer to check iostat of file read character(len=1000) :: line - ! for all of the parameters to be inputted by the user + ! Namelist for all of the parameters to be inputted by the user namelist /user_inputs/ case_dir, m, n, p, t_step_start, & t_step_stop, t_step_save, model_eqns, & num_fluids, mpp_lim, & @@ -121,12 +121,12 @@ contains lag_mg_wrt, lag_betaT_wrt, lag_betaC_wrt, & alpha_rho_e_wrt - ! the status of the post_process.inp file + ! Inquiring the status of the post_process.inp file file_loc = 'post_process.inp' inquire (FILE=trim(file_loc), EXIST=file_check) - ! whether the input file is there. If it is, the input file - ! read. If not, the program is terminated. + ! Checking whether the input file is there. If it is, the input file + ! is read. If not, the program is terminated. if (file_check) then open (1, FILE=trim(file_loc), FORM='formatted', & STATUS='old', ACTION='read') @@ -150,7 +150,7 @@ contains p = int((p + 1)/3) - 1 end if - ! m,n,p into global m,n,p + ! Store m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -171,25 +171,25 @@ contains end subroutine s_read_input_file !> Checking that the user inputs make sense, i.e. that the - !! are compatible with the code's options - !! the combination of these choices results into a - !! for the post-process + !! individual choices are compatible with the code's options + !! and that the combination of these choices results into a + !! valid configuration for the post-process impure subroutine s_check_input_file character(LEN=len_trim(case_dir)) :: file_loc !< - !! used to store the address of a particular file + !! Generic string used to store the address of a particular file logical :: dir_check !< - !! used to test the existence of folders + !! Logical variable used to test the existence of folders - ! the existence of the case folder + ! Checking the existence of the case folder case_dir = adjustl(case_dir) file_loc = trim(case_dir)//'/.' call my_inquire(file_loc, dir_check) - ! on the location of the case directory + ! Constraint on the location of the case directory if (dir_check .neqv. .true.) then call s_mpi_abort('Unsupported choice for the value of '// & 'case_dir. Exiting.') @@ -217,19 +217,19 @@ contains end if end if - ! the grid and conservative variables + ! Populating the grid and conservative variables call s_read_data_files(t_step) - ! the buffer regions of the grid and conservative variables + ! Populating the buffer regions of the grid and conservative variables if (buff_size > 0) then call s_populate_grid_variables_buffers() call s_populate_variables_buffers(bc_type, q_cons_vf) end if - ! the Temperature cache. + ! Initialize the Temperature cache. if (chemistry) call s_compute_q_T_sf(q_T_sf, q_cons_vf, idwbuff) - ! the conservative variables to the primitive ones + ! Converting the conservative variables to the primitive ones call s_convert_conservative_to_primitive_variables(q_cons_vf, q_T_sf, q_prim_vf, idwbuff) end subroutine s_perform_time_step @@ -269,7 +269,7 @@ contains z_end = offset_z%end + p end if - ! a new formatted database file + ! Opening a new formatted database file call s_open_formatted_database_file(t_step) if (sim_data .and. proc_rank == 0) then @@ -282,31 +282,31 @@ contains call s_write_energy_data_file(q_prim_vf, q_cons_vf) end if - ! the grid to the formatted database file + ! Adding the grid to the formatted database file call s_write_grid_to_formatted_database_file(t_step) - ! centered finite-difference coefficients in x-direction + ! Computing centered finite-difference coefficients in x-direction if (omega_wrt(2) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. schlieren_wrt) then call s_compute_finite_difference_coefficients(m, x_cc, & fd_coeff_x, buff_size, & fd_number, fd_order, offset_x) end if - ! centered finite-difference coefficients in y-direction + ! Computing centered finite-difference coefficients in y-direction if (omega_wrt(1) .or. omega_wrt(3) .or. qm_wrt .or. liutex_wrt .or. (n > 0 .and. schlieren_wrt)) then call s_compute_finite_difference_coefficients(n, y_cc, & fd_coeff_y, buff_size, & fd_number, fd_order, offset_y) end if - ! centered finite-difference coefficients in z-direction + ! Computing centered finite-difference coefficients in z-direction if (omega_wrt(1) .or. omega_wrt(2) .or. qm_wrt .or. liutex_wrt .or. (p > 0 .and. schlieren_wrt)) then call s_compute_finite_difference_coefficients(p, z_cc, & fd_coeff_z, buff_size, & fd_number, fd_order, offset_z) end if - ! the partial densities to the formatted database file + ! Adding the partial densities to the formatted database file if ((model_eqns == 2) .or. (model_eqns == 3) .or. (model_eqns == 4)) then do i = 1, num_fluids if (alpha_rho_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then @@ -324,7 +324,7 @@ contains end do end if - ! the density to the formatted database file + ! Adding the density to the formatted database file if ((rho_wrt .or. (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) .and. (.not. relativity)) then q_sf(:, :, :) = rho_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'rho' @@ -342,8 +342,8 @@ contains end if if (relativity .and. (rho_wrt .or. cons_vars_wrt)) then - ! relativistic flow, conservative and primitive densities are different - ! single-component for now + ! For relativistic flow, conservative and primitive densities are different + ! Hard-coded single-component for now q_sf(:, :, :) = q_cons_vf(1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'D' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -351,7 +351,7 @@ contains varname(:) = ' ' end if - ! the momentum to the formatted database file + ! Adding the momentum to the formatted database file do i = 1, E_idx - mom_idx%beg if (mom_wrt(i) .or. cons_vars_wrt) then q_sf(:, :, :) = q_cons_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -363,7 +363,7 @@ contains end if end do - ! the velocity to the formatted database file + ! Adding the velocity to the formatted database file do i = 1, E_idx - mom_idx%beg if (vel_wrt(i) .or. prim_vars_wrt) then q_sf(:, :, :) = q_prim_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -375,7 +375,7 @@ contains end if end do - ! the species' concentrations to the formatted database file + ! Adding the species' concentrations to the formatted database file if (chemistry) then do i = 1, num_species if (chem_wrt_Y(i) .or. prim_vars_wrt) then @@ -397,7 +397,7 @@ contains end if end if - ! the flux limiter function to the formatted database file + ! Adding the flux limiter function to the formatted database file do i = 1, E_idx - mom_idx%beg if (flux_wrt(i)) then @@ -410,7 +410,7 @@ contains end if end do - ! the energy to the formatted database file + ! Adding the energy to the formatted database file if (E_wrt .or. cons_vars_wrt) then q_sf(:, :, :) = q_cons_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'E' @@ -420,7 +420,7 @@ contains end if - ! the individual energies to the formatted database file + ! Adding the individual energies to the formatted database file if (model_eqns == 3) then do i = 1, num_fluids if (alpha_rho_e_wrt(i) .or. cons_vars_wrt) then @@ -541,19 +541,19 @@ contains end if - ! the magnetic field to the formatted database file + ! Adding the magnetic field to the formatted database file if (mhd .and. prim_vars_wrt) then do i = B_idx%beg, B_idx%end q_sf(:, :, :) = q_prim_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) - ! output By, Bz + ! 1D: output By, Bz if (n == 0) then if (i == B_idx%beg) then write (varname, '(A)') 'By' else write (varname, '(A)') 'Bz' end if - ! output Bx, By, Bz + ! 2D/3D: output Bx, By, Bz else if (i == B_idx%beg) then write (varname, '(A)') 'Bx' @@ -569,7 +569,7 @@ contains end do end if - ! the elastic shear stresses to the formatted database file + ! Adding the elastic shear stresses to the formatted database file if (elasticity) then do i = 1, stress_idx%end - stress_idx%beg + 1 if (prim_vars_wrt) then @@ -608,7 +608,7 @@ contains varname(:) = ' ' end if - ! the pressure to the formatted database file + ! Adding the pressure to the formatted database file if (pres_wrt .or. prim_vars_wrt) then q_sf(:, :, :) = q_prim_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'pres' @@ -618,7 +618,7 @@ contains end if - ! the volume fraction(s) to the formatted database file + ! Adding the volume fraction(s) to the formatted database file if (((model_eqns == 2) .and. (bubbles_euler .neqv. .true.)) & .or. (model_eqns == 3) & ) then @@ -660,7 +660,7 @@ contains end if - ! specific heat ratio function to formatted database file + ! Adding specific heat ratio function to formatted database file if (gamma_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then @@ -672,7 +672,7 @@ contains end if - ! the specific heat ratio to the formatted database file + ! Adding the specific heat ratio to the formatted database file if (heat_ratio_wrt) then call s_derive_specific_heat_ratio(q_sf) @@ -684,7 +684,7 @@ contains end if - ! liquid stiffness function to formatted database file + ! Adding liquid stiffness function to formatted database file if (pi_inf_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then @@ -696,7 +696,7 @@ contains end if - ! the liquid stiffness to the formatted database file + ! Adding the liquid stiffness to the formatted database file if (pres_inf_wrt) then call s_derive_liquid_stiffness(q_sf) @@ -708,7 +708,7 @@ contains end if - ! the sound speed to the formatted database file + ! Adding the sound speed to the formatted database file if (c_wrt) then do k = -offset_z%beg, p + offset_z%end do j = -offset_y%beg, n + offset_y%end @@ -738,7 +738,7 @@ contains end if - ! the vorticity to the formatted database file + ! Adding the vorticity to the formatted database file do i = 1, 3 if (omega_wrt(i)) then @@ -757,7 +757,7 @@ contains call s_write_variable_to_formatted_database_file(varname, t_step) end if - ! Q_M to the formatted database file + ! Adding Q_M to the formatted database file if (p > 0 .and. qm_wrt) then call s_derive_qm(q_prim_vf, q_sf) @@ -767,13 +767,13 @@ contains varname(:) = ' ' end if - ! Liutex magnitude to the formatted database file + ! Adding Liutex magnitude to the formatted database file if (liutex_wrt) then - ! Liutex vector and its magnitude + ! Compute Liutex vector and its magnitude call s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis) - ! magnitude + ! Liutex magnitude q_sf = liutex_mag write (varname, '(A)') 'liutex_mag' @@ -781,7 +781,7 @@ contains varname(:) = ' ' - ! axis + ! Liutex axis do i = 1, 3 q_sf = liutex_axis(:, :, :, i) @@ -793,7 +793,7 @@ contains end if - ! numerical Schlieren function to formatted database file + ! Adding numerical Schlieren function to formatted database file if (schlieren_wrt) then call s_derive_numerical_schlieren_function(q_cons_vf, q_sf) @@ -805,7 +805,7 @@ contains end if - ! the color function to formatted database file + ! Adding the color function to formatted database file if (cf_wrt) then q_sf(:, :, :) = q_cons_vf(c_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'color_function' @@ -814,7 +814,7 @@ contains end if - ! the volume fraction(s) to the formatted database file + ! Adding the volume fraction(s) to the formatted database file if (bubbles_euler) then do i = adv_idx%beg, adv_idx%end q_sf(:, :, :) = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) @@ -824,7 +824,7 @@ contains end do end if - ! the bubble variables to the formatted database file + ! Adding the bubble variables to the formatted database file if (bubbles_euler) then !nR do i = 1, nb @@ -859,7 +859,7 @@ contains end do end if - ! density + ! number density if (adv_n) then q_sf(:, :, :) = q_cons_vf(n_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'n' @@ -868,9 +868,9 @@ contains end if end if - ! the lagrangian subgrid variables to the formatted database file + ! Adding the lagrangian subgrid variables to the formatted database file if (bubbles_lagrange) then - !! field + !! Void fraction field q_sf(:, :, :) = 1._wp - q_cons_vf(beta_idx)%sf( & -offset_x%beg:m + offset_x%end, & -offset_y%beg:n + offset_y%end, & @@ -888,7 +888,7 @@ contains call s_close_energy_data_file() end if - ! the formatted database file + ! Closing the formatted database file call s_close_formatted_database_file() end subroutine s_save_data @@ -974,8 +974,8 @@ contains end subroutine s_mpi_transpose_y2z impure subroutine s_initialize_modules - ! of parameters, allocation procedures, and/or any other tasks - ! to properly setup the modules + ! Computation of parameters, allocation procedures, and/or any other tasks + ! needed to properly setup the modules integer :: size_n(1), inembed(1), onembed(1) call s_initialize_global_parameters_module() @@ -992,7 +992,7 @@ contains call s_initialize_derived_variables_module() call s_initialize_data_output_module() - ! pointers for serial or parallel I/O + ! Associate pointers for serial or parallel I/O if (parallel_io .neqv. .true.) then s_read_data_files => s_read_serial_data_files else @@ -1146,13 +1146,13 @@ contains num_dims = 1 + min(1, n) + min(1, p) #ifdef MFC_MPI - ! of the MPI environment + ! Initialization of the MPI environment call s_mpi_initialize() - ! with rank 0 assigns default user input values prior to reading - ! in from the input file. Next, the user inputs are read in and their - ! is checked. The detection of any inconsistencies automatically - ! to the termination of the post-process. + ! Processor with rank 0 assigns default user input values prior to reading + ! those in from the input file. Next, the user inputs are read in and their + ! consistency is checked. The detection of any inconsistencies automatically + ! leads to the termination of the post-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() call s_read_input_file() @@ -1161,9 +1161,9 @@ contains print '(" Post-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs end if - ! the user inputs to all of the processors and performing the - ! computational domain decomposition. Neither procedure has to be - ! out if the simulation is in fact not truly executed in parallel. + ! Broadcasting the user inputs to all of the processors and performing the + ! parallel computational domain decomposition. Neither procedure has to be + ! carried out if the simulation is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() call s_initialize_parallel_io() call s_mpi_decompose_computational_domain() @@ -1174,13 +1174,13 @@ contains end subroutine s_initialize_mpi_domain impure subroutine s_finalize_modules - ! pointers for serial and parallel I/O + ! Disassociate pointers for serial and parallel I/O s_read_data_files => null() -! (sim_data .and. proc_rank == 0) then -! s_close_intf_data_file() -! s_close_energy_data_file() -! if +! if (sim_data .and. proc_rank == 0) then +! call s_close_intf_data_file() +! call s_close_energy_data_file() +! end if if (fft_wrt) then if (c_associated(fwd_plan_x)) call fftw_destroy_plan(fwd_plan_x) @@ -1204,7 +1204,7 @@ contains end if #endif - ! procedures for the modules + ! Deallocation procedures for the modules call s_finalize_data_output_module() call s_finalize_derived_variables_module() call s_finalize_data_input_module() @@ -1215,7 +1215,7 @@ contains end if call s_finalize_global_parameters_module() - ! the MPI environment + ! Finalizing the MPI environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/post_process/p_main.fpp b/src/post_process/p_main.fpp index 78e7773d2b..b8980ac012 100644 --- a/src/post_process/p_main.fpp +++ b/src/post_process/p_main.fpp @@ -1,15 +1,15 @@ !> -!! -!! program p_main +!! @file +!! @brief Contains program p_main !> @brief The post-process restructures raw unformatted data, outputted by -!! into a formatted database, Silo-HDF5 or Binary, -!! the user. The user may also specify which variables to -!! the database. The choices range from any one of the -!! conservative variables, as well as quantities that -!! derived from those such as the unadvected volume fraction, -!! ratio, liquid stiffness, speed of sound, vorticity -!! numerical Schlieren function. +!! the simulation, into a formatted database, Silo-HDF5 or Binary, +!! chosen by the user. The user may also specify which variables to +!! include in the database. The choices range from any one of the +!! primitive and conservative variables, as well as quantities that +!! can be derived from those such as the unadvected volume fraction, +!! specific heat ratio, liquid stiffness, speed of sound, vorticity +!! and the numerical Schlieren function. program p_main use m_global_parameters !< Global parameters for the code @@ -20,8 +20,8 @@ program p_main integer :: t_step !< Iterator for the main time-stepping loop character(LEN=name_len) :: varname !< - !! for the name(s) of the flow variable(s) that will be added - !! formatted database file(s) + !! Generic storage for the name(s) of the flow variable(s) that will be added + !! to the formatted database file(s) real(wp) :: pres real(wp) :: c @@ -36,18 +36,18 @@ program p_main t_step = n_start n_save = int(t_stop/t_save) + 1 else - ! the time-step iterator to the first time step to be post-processed + ! Setting the time-step iterator to the first time step to be post-processed t_step = t_step_start end if - ! Loop + ! Time-Marching Loop do - ! all time-steps are not ready to be post-processed and one rank is - ! than another, the slower rank processing the last available - ! might be killed when the faster rank attempts to process the - ! missing step, before the slower rank finishes writing the last - ! step. To avoid this, we force synchronization here. + ! If all time-steps are not ready to be post-processed and one rank is + ! faster than another, the slower rank processing the last available + ! step might be killed when the faster rank attempts to process the + ! first missing step, before the slower rank finishes writing the last + ! available step. To avoid this, we force synchronization here. call s_mpi_barrier() call cpu_time(start) @@ -71,11 +71,11 @@ program p_main exit end if else - ! the time-step iterator so that it may reach the final time- - ! to be post-processed, in the case that this one is not originally - ! through constant incrementation from the first time-step. - ! modification is performed upon reaching the final time-step. In - ! that it is not needed, the post-processor is done and may exit. + ! Modifies the time-step iterator so that it may reach the final time- + ! step to be post-processed, in the case that this one is not originally + ! attainable through constant incrementation from the first time-step. + ! This modification is performed upon reaching the final time-step. In + ! case that it is not needed, the post-processor is done and may exit. if ((t_step_stop - t_step) < t_step_save .and. t_step_stop /= t_step) then t_step = t_step_stop - t_step_save elseif (t_step == t_step_stop) then @@ -86,12 +86,12 @@ program p_main if (cfl_dt) then t_step = t_step + 1 else - ! time-step iterator to next time-step to be post-processed + ! Incrementing time-step iterator to next time-step to be post-processed t_step = t_step + t_step_save end if end do - ! Time-Marching Loop + ! END: Time-Marching Loop close (11) diff --git a/src/pre_process/m_assign_variables.fpp b/src/pre_process/m_assign_variables.fpp index 58015d61f3..6d967bb1da 100644 --- a/src/pre_process/m_assign_variables.fpp +++ b/src/pre_process/m_assign_variables.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_assign_variables +!! @file +!! @brief Contains module m_assign_variables #:include 'case.fpp' #:include 'macros.fpp' @@ -25,24 +25,24 @@ module m_assign_variables procedure(s_assign_patch_xxxxx_primitive_variables), & pointer :: s_assign_patch_primitive_variables => null() !< - !! the multicomponent flow model, this variable is a pointer to - !! subroutine s_assign_patch_mixture_primitive_variables, or the - !! + !! Depending on the multicomponent flow model, this variable is a pointer to + !! either the subroutine s_assign_patch_mixture_primitive_variables, or the + !! subroutine s_assign_patch_species_primitive_variables !> Abstract interface to the two subroutines that assign the patch primitive - !! mixture or species, depending on the subroutine, to a - !! in the computational domain + !! variables, either mixture or species, depending on the subroutine, to a + !! particular cell in the computational domain abstract interface !> Skeleton of s_assign_patch_mixture_primitive_variables - !! - !! is the patch identifier - !! (x) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! (y,th) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! (z) cell index in which the mixture or species primitive variables from the indicated patch areassigned - !! pseudo volume fraction - !! Primitive variables - !! Array to track patch ids + !! and s_assign_patch_species_primitive_variables + !! @param patch_id is the patch identifier + !! @param j (x) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! @param k (y,th) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! @param l (z) cell index in which the mixture or species primitive variables from the indicated patch areassigned + !! @param eta pseudo volume fraction + !! @param q_prim_vf Primitive variables + !! @param patch_id_fp Array to track patch ids subroutine s_assign_patch_xxxxx_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) @@ -77,9 +77,9 @@ contains allocate (alf_sum%sf(0:m, 0:n, 0:p)) end if - ! on multicomponent flow model, the appropriate procedure - ! assignment of the patch mixture or species primitive variables - ! a cell in the domain is targeted by the procedure pointer + ! Depending on multicomponent flow model, the appropriate procedure + ! for assignment of the patch mixture or species primitive variables + ! to a cell in the domain is targeted by the procedure pointer if (model_eqns == 1) then ! Gamma/pi_inf model s_assign_patch_primitive_variables => & @@ -92,22 +92,22 @@ contains end subroutine s_initialize_assign_variables_module !> This subroutine assigns the mixture primitive variables - !! patch designated by the patch_id, to the cell that - !! by the indexes (j,k,l). In addition, the - !! the patch identities in the entire - !! updated with the new assignment. Note that if - !! of the patch's boundaries is employed, the - !! variables in the cell will be a type of - !! the current patch's primitive variables - !! of the smoothing patch. The specific details - !! combination may be found in Shyue's work (1998). - !! the patch identifier - !! the x-dir node index - !! the y-dir node index - !! the z-dir node index - !! pseudo volume fraction - !! Primitive variables - !! Array to track patch ids + !! of the patch designated by the patch_id, to the cell that + !! is designated by the indexes (j,k,l). In addition, the + !! variable bookkeeping the patch identities in the entire + !! domain is updated with the new assignment. Note that if + !! the smoothing of the patch's boundaries is employed, the + !! ensuing primitive variables in the cell will be a type of + !! combination of the current patch's primitive variables + !! with those of the smoothing patch. The specific details + !! of the combination may be found in Shyue's work (1998). + !! @param patch_id the patch identifier + !! @param j the x-dir node index + !! @param k the y-dir node index + !! @param l the z-dir node index + !! @param eta pseudo volume fraction + !! @param q_prim_vf Primitive variables + !! @param patch_id_fp Array to track patch ids subroutine s_assign_patch_mixture_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) $:GPU_ROUTINE(parallelism='[seq]') @@ -127,17 +127,17 @@ contains integer :: smooth_patch_id integer :: i !< generic loop operator - ! the mixture primitive variables of a uniform state patch + ! Assigning the mixture primitive variables of a uniform state patch - ! the identity of the smoothing patch + ! Transferring the identity of the smoothing patch smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id - ! + ! Density q_prim_vf(1)%sf(j, k, l) = & eta*patch_icpp(patch_id)%rho & + (1._wp - eta)*patch_icpp(smooth_patch_id)%rho - ! + ! Velocity do i = 1, E_idx - mom_idx%beg q_prim_vf(i + 1)%sf(j, k, l) = & 1._wp/q_prim_vf(1)%sf(j, k, l)* & @@ -147,12 +147,12 @@ contains *patch_icpp(smooth_patch_id)%vel(i)) end do - ! heat ratio function + ! Specific heat ratio function q_prim_vf(gamma_idx)%sf(j, k, l) = & eta*patch_icpp(patch_id)%gamma & + (1._wp - eta)*patch_icpp(smooth_patch_id)%gamma - ! + ! Pressure q_prim_vf(E_idx)%sf(j, k, l) = & 1._wp/q_prim_vf(gamma_idx)%sf(j, k, l)* & (eta*patch_icpp(patch_id)%gamma & @@ -160,17 +160,17 @@ contains + (1._wp - eta)*patch_icpp(smooth_patch_id)%gamma & *patch_icpp(smooth_patch_id)%pres) - ! stiffness function + ! Liquid stiffness function q_prim_vf(pi_inf_idx)%sf(j, k, l) = & eta*patch_icpp(patch_id)%pi_inf & + (1._wp - eta)*patch_icpp(smooth_patch_id)%pi_inf - ! Concentrations + ! Species Concentrations if (chemistry) then block real(wp) :: sum, term - ! the species concentrations + ! Accumulating the species concentrations sum = 0._wp do i = 1, num_species term = & @@ -182,7 +182,7 @@ contains sum = max(sum, verysmall) - ! the species concentrations + ! Normalizing the species concentrations do i = 1, num_species q_prim_vf(chemxb + i - 1)%sf(j, k, l) = & q_prim_vf(chemxb + i - 1)%sf(j, k, l)/sum @@ -191,16 +191,16 @@ contains end block end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < 1.e-16_wp) patch_id_fp(j, k, l) = patch_id end subroutine s_assign_patch_mixture_primitive_variables !Stable perturbation in pressure (Ando) - !! the x-dir node index - !! the y-dir node index - !! the z-dir node index - !! Primitive variables + !! @param j the x-dir node index + !! @param k the y-dir node index + !! @param l the z-dir node index + !! @param q_prim_vf Primitive variables subroutine s_perturb_primitive(j, k, l, q_prim_vf) integer, intent(in) :: j, k, l @@ -273,15 +273,15 @@ contains end subroutine s_perturb_primitive !> This subroutine assigns the species primitive variables. This follows - !! adaptation for - !! modeling - !! the patch identifier - !! the x-dir node index - !! the y-dir node index - !! the z-dir node index - !! pseudo volume fraction - !! Primitive variables - !! Array to track patch ids + !! s_assign_patch_species_primitive_variables with adaptation for + !! ensemble-averaged bubble modeling + !! @param patch_id the patch identifier + !! @param j the x-dir node index + !! @param k the y-dir node index + !! @param l the z-dir node index + !! @param eta pseudo volume fraction + !! @param q_prim_vf Primitive variables + !! @param patch_id_fp Array to track patch ids impure subroutine s_assign_patch_species_primitive_variables(patch_id, j, k, l, & eta, q_prim_vf, patch_id_fp) $:GPU_ROUTINE(parallelism='[seq]') @@ -296,9 +296,9 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! the specific heat ratio function and the liquid stiffness - ! respectively, obtained from the combination of primitive - ! of the current and smoothing patches + ! Density, the specific heat ratio function and the liquid stiffness + ! function, respectively, obtained from the combination of primitive + ! variables of the current and smoothing patches real(wp) :: rho !< density real(wp) :: gamma real(wp) :: lit_gamma !< specific heat ratio @@ -316,15 +316,15 @@ contains real(wp) :: Ys(1:num_species) real(stp), dimension(sys_size) :: orig_prim_vf !< - !! hold original values of cell for smoothing purposes + !! Vector to hold original values of cell for smoothing purposes integer :: i !< Generic loop iterator integer :: smooth_patch_id - ! the identity of the smoothing patch + ! Transferring the identity of the smoothing patch smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id - ! original primitive variables + ! Transferring original primitive variables do i = 1, sys_size orig_prim_vf(i) = q_prim_vf(i)%sf(j, k, l) end do @@ -342,18 +342,18 @@ contains end do end if - ! Mixture Variables from Original Primitive Variables - ! s_convert_species_to_mixture_variables( & + ! Computing Mixture Variables from Original Primitive Variables + ! call s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & orig_rho, & orig_gamma, & orig_pi_inf, orig_qv) - ! Mixture Variables of Current Patch + ! Computing Mixture Variables of Current Patch if (.not. igr .or. num_fluids > 1) then - ! fraction(s) + ! Volume fraction(s) do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(patch_id)%alpha(i - E_idx) end do @@ -372,15 +372,15 @@ contains end do end if - ! densities + ! Partial densities if (model_eqns /= 4) then do i = 1, cont_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(patch_id)%alpha_rho(i) end do end if - ! and the specific heat ratio and liquid stiffness functions - ! s_convert_species_to_mixture_variables( & + ! Density and the specific heat ratio and liquid stiffness functions + ! call s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & patch_icpp(patch_id)%rho, & @@ -388,17 +388,17 @@ contains patch_icpp(patch_id)%pi_inf, & patch_icpp(patch_id)%qv) - ! Mixture Variables of Smoothing Patch + ! Computing Mixture Variables of Smoothing Patch if (model_eqns /= 4) then - ! densities + ! Partial densities do i = 1, cont_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(smooth_patch_id)%alpha_rho(i) end do end if if (.not. igr .or. num_fluids > 1) then - ! fraction(s) + ! Volume fraction(s) do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = patch_icpp(smooth_patch_id)%alpha(i - E_idx) end do @@ -417,13 +417,13 @@ contains end do end if - ! euler variables + ! Bubbles euler variables if (bubbles_euler) then do i = 1, nb muR = R0(i)*patch_icpp(smooth_patch_id)%r0/R0ref muV = patch_icpp(smooth_patch_id)%v0 if (qbmm) then - ! the moment set + ! Initialize the moment set if (dist_type == 1) then q_prim_vf(bub_idx%fullmom(i, 0, 0))%sf(j, k, l) = 1._wp q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l) = muR @@ -450,7 +450,7 @@ contains end do if (adv_n) then - ! number density + ! Initialize number density R3bar = 0._wp do i = 1, nb R3bar = R3bar + weight(i)*(q_prim_vf(bub_idx%rs(i))%sf(j, k, l))**3._wp @@ -459,8 +459,8 @@ contains end if end if - ! and the specific heat ratio and liquid stiffness functions - ! s_convert_species_to_mixture_variables( & + ! Density and the specific heat ratio and liquid stiffness functions + ! call s_convert_species_to_mixture_variables( & call s_convert_to_mixture_variables( & q_prim_vf, j, k, l, & patch_icpp(smooth_patch_id)%rho, & @@ -468,13 +468,13 @@ contains patch_icpp(smooth_patch_id)%pi_inf, & patch_icpp(smooth_patch_id)%qv) - ! + ! Pressure q_prim_vf(E_idx)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%pres & + (1._wp - eta)*orig_prim_vf(E_idx)) if (.not. igr .or. num_fluids > 1) then - ! fractions \alpha + ! Volume fractions \alpha do i = adv_idx%beg, adv_idx%end q_prim_vf(i)%sf(j, k, l) = & eta*patch_icpp(patch_id)%alpha(i - E_idx) & @@ -503,7 +503,7 @@ contains end if end if - ! Shear Stress + ! Elastic Shear Stress if (elasticity) then do i = 1, (stress_idx%end - stress_idx%beg) + 1 q_prim_vf(i + stress_idx%beg - 1)%sf(j, k, l) = & @@ -512,7 +512,7 @@ contains end do end if - ! Shear Stress + ! Elastic Shear Stress if (hyperelasticity) then if (pre_stress) then ! pre stressed initial condition in spatial domain @@ -530,7 +530,7 @@ contains xi_cart(3) = z_cc(l) end if - ! the reference map to the q_prim vector field + ! assigning the reference map to the q_prim vector field do i = 1, num_dims q_prim_vf(i + xibeg - 1)%sf(j, k, l) = eta*xi_cart(i) + & (1._wp - eta)*orig_prim_vf(i + xibeg - 1) @@ -550,7 +550,7 @@ contains end do end if - ! densities \alpha \rho + ! Partial densities \alpha \rho if (model_eqns /= 4) then !mixture density is an input do i = 1, cont_idx%end @@ -564,30 +564,30 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! = (( p_l + pi_inf)/( p_ref + pi_inf))**(1/little_gam) * rhoref(1-alf) + ! \rho = (( p_l + pi_inf)/( p_ref + pi_inf))**(1/little_gam) * rhoref(1-alf) q_prim_vf(1)%sf(j, k, l) = & (((q_prim_vf(E_idx)%sf(j, k, l) + pi_inf)/(pref + pi_inf))**(1/lit_gamma))* & rhoref*(1 - q_prim_vf(alf_idx)%sf(j, k, l)) end if - ! and the specific heat ratio and liquid stiffness functions - ! s_convert_species_to_mixture_variables(q_prim_vf, j, k, l, & + ! Density and the specific heat ratio and liquid stiffness functions + ! call s_convert_species_to_mixture_variables(q_prim_vf, j, k, l, & call s_convert_to_mixture_variables(q_prim_vf, j, k, l, & rho, gamma, pi_inf, qv) - ! + ! Velocity do i = 1, E_idx - mom_idx%beg q_prim_vf(i + cont_idx%end)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%vel(i) & + (1._wp - eta)*orig_prim_vf(i + cont_idx%end)) end do - ! Concentrations + ! Species Concentrations if (chemistry) then block real(wp) :: sum, term - ! the species concentrations + ! Accumulating the species concentrations sum = 0._wp do i = 1, num_species term = & @@ -601,7 +601,7 @@ contains sum = 1._wp end if - ! the species concentrations + ! Normalizing the species concentrations do i = 1, num_species q_prim_vf(chemxb + i - 1)%sf(j, k, l) = & q_prim_vf(chemxb + i - 1)%sf(j, k, l)/sum @@ -610,27 +610,27 @@ contains end block end if - ! streamwise velocity to hyperbolic tangent function of y + ! Set streamwise velocity to hyperbolic tangent function of y if (mixlayer_vel_profile) then q_prim_vf(1 + cont_idx%end)%sf(j, k, l) = & (eta*patch_icpp(patch_id)%vel(1)*tanh(y_cc(k)*mixlayer_vel_coef) & + (1._wp - eta)*orig_prim_vf(1 + cont_idx%end)) end if - ! partial pressures to mixture pressure for the 6-eqn model + ! Set partial pressures to mixture pressure for the 6-eqn model if (model_eqns == 3) then do i = internalEnergies_idx%beg, internalEnergies_idx%end q_prim_vf(i)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) end do end if - ! bubble variables + ! Smoothed bubble variables if (bubbles_euler) then do i = 1, nb muR = R0(i)*patch_icpp(patch_id)%r0/R0ref muV = patch_icpp(patch_id)%v0 if (qbmm) then - ! the moment set + ! Initialize the moment set if (dist_type == 1) then q_prim_vf(bub_idx%fullmom(i, 0, 0))%sf(j, k, l) = 1._wp q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l) = muR @@ -659,7 +659,7 @@ contains end do if (adv_n) then - ! number density + ! Initialize number density R3bar = 0._wp do i = 1, nb R3bar = R3bar + weight(i)*(q_prim_vf(bub_idx%rs(i))%sf(j, k, l))**3._wp @@ -685,7 +685,7 @@ contains do i = 1, nb if (f_is_default(real(q_prim_vf(bub_idx%ps(i))%sf(j, k, l), kind=wp))) then q_prim_vf(bub_idx%ps(i))%sf(j, k, l) = pb0(i) - ! *, 'setting to pb0' + ! print *, 'setting to pb0' end if if (f_is_default(real(q_prim_vf(bub_idx%ms(i))%sf(j, k, l), kind=wp))) then q_prim_vf(bub_idx%ms(i))%sf(j, k, l) = mass_v0(i) @@ -698,25 +698,25 @@ contains (1._wp - eta)*orig_prim_vf(c_idx) end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < 1.e-16_wp) patch_id_fp(j, k, l) = patch_id - ! (j == 1) then - ! *, (q_prim_vf(bub_idx%rs(i))%sf(j, k, l), i = 1, nb) - ! *, (q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l), i = 1, nb) - ! *, (R0(i), i = 1, nb) - ! *, patch_icpp(patch_id)%r0 - ! *, (bub_idx%rs(i), i = 1, nb) - ! *, (bub_idx%fullmom(i, 1, 0), i = 1, nb) - ! if + ! if (j == 1) then + ! print *, (q_prim_vf(bub_idx%rs(i))%sf(j, k, l), i = 1, nb) + ! print *, (q_prim_vf(bub_idx%fullmom(i, 1, 0))%sf(j, k, l), i = 1, nb) + ! print *, (R0(i), i = 1, nb) + ! print *, patch_icpp(patch_id)%r0 + ! print *, (bub_idx%rs(i), i = 1, nb) + ! print *, (bub_idx%fullmom(i, 1, 0), i = 1, nb) + ! end if end subroutine s_assign_patch_species_primitive_variables impure subroutine s_finalize_assign_variables_module - ! procedure pointer to the subroutine assigning either - ! patch mixture or species primitive variables to a cell in the - ! domain + ! Nullifying procedure pointer to the subroutine assigning either + ! the patch mixture or species primitive variables to a cell in the + ! computational domain s_assign_patch_primitive_variables => null() end subroutine s_finalize_assign_variables_module diff --git a/src/pre_process/m_boundary_conditions.fpp b/src/pre_process/m_boundary_conditions.fpp index d02622bd9f..1d2d706a55 100644 --- a/src/pre_process/m_boundary_conditions.fpp +++ b/src/pre_process/m_boundary_conditions.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_boundary_conditions +!! @file +!! @brief Contains module m_boundary_conditions !> @brief This module contains module m_boundary_conditions @@ -34,7 +34,7 @@ contains integer :: j - ! is a vertical line at x_beg or x_end + ! Patch is a vertical line at x_beg or x_end if (patch_bc(patch_id)%dir == 1) then y_centroid = patch_bc(patch_id)%centroid(2) length_y = patch_bc(patch_id)%length(2) @@ -42,7 +42,7 @@ contains y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! is a vertical line at x_beg and x_beg is a domain boundary + ! Patch is a vertical line at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do j = 0, n @@ -54,7 +54,7 @@ contains #:endfor end if - ! is a vertical line at y_beg or y_end + ! Patch is a vertical line at y_beg or y_end if (patch_bc(patch_id)%dir == 2) then x_centroid = patch_bc(patch_id)%centroid(1) length_x = patch_bc(patch_id)%length(1) @@ -62,7 +62,7 @@ contains x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! is a vertical line at x_beg and x_beg is a domain boundary + ! Patch is a vertical line at x_beg and x_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do j = 0, m @@ -87,7 +87,7 @@ contains y_centroid = patch_bc(patch_id)%centroid(2) z_centroid = patch_bc(patch_id)%centroid(3) radius = patch_bc(patch_id)%radius - ! is a circle at x_beg and x_beg is a domain boundary + ! Patch is a circle at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do k = 0, p @@ -105,7 +105,7 @@ contains x_centroid = patch_bc(patch_id)%centroid(1) z_centroid = patch_bc(patch_id)%centroid(3) radius = patch_bc(patch_id)%radius - ! is a circle at y_beg and y_beg is a domain boundary + ! Patch is a circle at y_beg and y_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do k = 0, p @@ -156,7 +156,7 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! is a circle at x_beg and x_beg is a domain boundary + ! Patch is a circle at x_beg and x_beg is a domain boundary #:for BOUND, X, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'm+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_x%${BOUND}$ < 0) then do k = 0, p @@ -183,7 +183,7 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! is a circle at y_beg and y_beg is a domain boundary + ! Patch is a circle at y_beg and y_beg is a domain boundary #:for BOUND, Y, LOC, IDX in [('beg', '-i', -1, 1), ('end', 'n+i', 1, 2)] if (patch_bc(patch_id)%loc == ${LOC}$ .and. bc_y%${BOUND}$ < 0) then do k = 0, p diff --git a/src/pre_process/m_check_ib_patches.fpp b/src/pre_process/m_check_ib_patches.fpp index 20ee3cd71a..1b09929dda 100644 --- a/src/pre_process/m_check_ib_patches.fpp +++ b/src/pre_process/m_check_ib_patches.fpp @@ -1,5 +1,5 @@ !> @brief This module contains subroutines that read, and check consistency -!! user provided inputs and data. +!! of, the user provided inputs and data. #:include 'macros.fpp' @@ -12,7 +12,7 @@ module m_check_ib_patches use m_mpi_proxy !< Message passing interface (MPI) module proxy use m_data_output !< Procedures to write the grid data and the - !! to files + !! conservative variables to files #ifdef MFC_MPI use mpi !< Message passing interface (MPI) module @@ -39,12 +39,12 @@ contains do i = 1, num_patches_max if (i <= num_ibs) then - ! s_check_patch_geometry(i) + ! call s_check_patch_geometry(i) call s_int_to_str(i, iStr) @:PROHIBIT(patch_ib(i)%geometry == dflt_int, "IB patch undefined. & patch_ib("//trim(iStr)//")%geometry must be set.") - ! on the geometric initial condition patch parameters + ! Constraints on the geometric initial condition patch parameters if (patch_ib(i)%geometry == 2) then call s_check_circle_ib_patch_geometry(i) else if (patch_ib(i)%geometry == 3) then @@ -79,9 +79,9 @@ contains end subroutine s_check_ib_patches !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by the - !! - !! Patch identifier + !! the circle patch have consistently been inputted by the + !! user. + !! @param patch_id Patch identifier impure subroutine s_check_circle_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -97,9 +97,9 @@ contains end subroutine s_check_circle_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by the - !! - !! Patch identifier + !! the ellipse patch have consistently been inputted by the + !! user. + !! @param patch_id Patch identifier impure subroutine s_check_ellipse_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -116,9 +116,9 @@ contains end subroutine s_check_ellipse_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by the - !! - !! Patch identifier + !! the airfoil patch have consistently been inputted by the + !! user. + !! @param patch_id Patch identifier impure subroutine s_check_airfoil_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -137,9 +137,9 @@ contains end subroutine s_check_airfoil_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! airfoil patch have consistently been inputted by the - !! - !! Patch identifier + !! the 3d airfoil patch have consistently been inputted by the + !! user. + !! @param patch_id Patch identifier impure subroutine s_check_3d_airfoil_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -160,9 +160,9 @@ contains end subroutine s_check_3d_airfoil_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by - !! - !! Patch identifier + !! the rectangle patch have consistently been inputted by + !! the user. + !! @param patch_id Patch identifier impure subroutine s_check_rectangle_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -183,9 +183,9 @@ contains end subroutine s_check_rectangle_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by - !! - !! Patch identifier + !! the sphere patch have consistently been inputted by + !! the user. + !! @param patch_id Patch identifier impure subroutine s_check_sphere_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -206,9 +206,9 @@ contains end subroutine s_check_sphere_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by - !! - !! Patch identifier + !! the cuboid patch have consistently been inputted by + !! the user. + !! @param patch_id Patch identifier impure subroutine s_check_cuboid_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -233,9 +233,9 @@ contains end subroutine s_check_cuboid_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by - !! - !! Patch identifier + !! the cylinder patch have consistently been inputted by + !! the user. + !! @param patch_id Patch identifier impure subroutine s_check_cylinder_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -274,9 +274,9 @@ contains end subroutine s_check_cylinder_ib_patch_geometry !> This subroutine verifies that the geometric parameters of - !! patch have consistently been inputted by - !! - !! Patch identifier + !! the model patch have consistently been inputted by + !! the user. + !! @param patch_id Patch identifier impure subroutine s_check_model_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -296,8 +296,8 @@ contains end subroutine s_check_model_ib_patch_geometry !!> This subroutine verifies that the geometric parameters of - !! patch remain unaltered by the user inputs. - !! Patch identifier + !! the inactive patch remain unaltered by the user inputs. + !! @param patch_id Patch identifier impure subroutine s_check_inactive_ib_patch_geometry(patch_id) integer, intent(in) :: patch_id diff --git a/src/pre_process/m_check_patches.fpp b/src/pre_process/m_check_patches.fpp index cbe1647656..2a73bd98c0 100644 --- a/src/pre_process/m_check_patches.fpp +++ b/src/pre_process/m_check_patches.fpp @@ -1,13 +1,13 @@ #:include 'macros.fpp' !> @brief This module contains subroutines that read, and check consistency -!! user provided inputs and data. +!! of, the user provided inputs and data. #:include 'macros.fpp' module m_check_patches - ! + ! Dependencies use m_derived_types !< Definitions of the derived types use m_global_parameters !< Global parameters for the code @@ -15,7 +15,7 @@ module m_check_patches use m_mpi_proxy !< Message passing interface (MPI) module proxy use m_data_output !< Procedures to write the grid data and the - !! to files + !! conservative variables to files #ifdef MFC_MPI use mpi !< Message passing interface (MPI) module @@ -44,7 +44,7 @@ contains do i = 1, num_patches_max if (i <= num_patches) then - ! s_check_patch_geometry(i) + ! call s_check_patch_geometry(i) call s_int_to_str(i, iStr) @:PROHIBIT(patch_icpp(i)%geometry == 6, "Invalid patch geometry number. "// & "patch_icpp("//trim(iStr)//")%geometry is deprecated.") @@ -57,7 +57,7 @@ contains @:PROHIBIT(patch_icpp(i)%geometry == dflt_int, "Invalid patch geometry number. "// & "patch_icpp("//trim(iStr)//")%geometry must be set.") - ! on the geometric initial condition patch parameters + ! Constraints on the geometric initial condition patch parameters if (patch_icpp(i)%geometry == 1) then call s_check_line_segment_patch_geometry(i) elseif (patch_icpp(i)%geometry == 2) then @@ -96,7 +96,7 @@ contains end if end do - ! on overwrite rights initial condition patch parameters + ! Constraints on overwrite rights initial condition patch parameters do i = 1, num_patches if (i <= num_patches) then call s_check_active_patch_alteration_rights(i) @@ -105,7 +105,7 @@ contains end if end do - ! on smoothing initial condition patch parameters + ! Constraints on smoothing initial condition patch parameters do i = 1, num_patches if (i > 1 .and. (patch_icpp(i)%geometry == 2 .or. & patch_icpp(i)%geometry == 3 .or. & @@ -125,7 +125,7 @@ contains end if end do - ! on flow variables initial condition patch parameters + ! Constraints on flow variables initial condition patch parameters do i = 1, num_patches if (i <= num_patches) then call s_check_active_patch_primitive_variables(i) @@ -137,7 +137,7 @@ contains end subroutine s_check_patches !> This subroutine checks the line segment patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_line_segment_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -151,7 +151,7 @@ contains end subroutine s_check_line_segment_patch_geometry !> This subroutine checks the circle patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_circle_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -166,7 +166,7 @@ contains end subroutine s_check_circle_patch_geometry !> This subroutine checks the rectangle patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_rectangle_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -182,7 +182,7 @@ contains end subroutine s_check_rectangle_patch_geometry !> This subroutine checks the line sweep patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_line_sweep_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -199,7 +199,7 @@ contains end subroutine s_check_line_sweep_patch_geometry !> This subroutine checks the ellipse patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_ellipse_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -216,7 +216,7 @@ contains end subroutine s_check_ellipse_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_2D_TaylorGreen_vortex_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -233,7 +233,7 @@ contains end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_sphere_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -248,7 +248,7 @@ contains end subroutine s_check_sphere_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_spherical_harmonic_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -269,10 +269,10 @@ contains end subroutine s_check_spherical_harmonic_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_cuboid_patch_geometry(patch_id) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -287,10 +287,10 @@ contains end subroutine s_check_cuboid_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_cylinder_patch_geometry(patch_id) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -300,14 +300,14 @@ contains @:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cylinder patch "//trim(iStr)//": z_centroid must be set") @:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Cylinder patch "//trim(iStr)//": radius must be greater than zero") - ! if exactly one length is defined + ! Check if exactly one length is defined @:PROHIBIT(count([ & patch_icpp(patch_id)%length_x > 0._wp, & patch_icpp(patch_id)%length_y > 0._wp, & patch_icpp(patch_id)%length_z > 0._wp & ]) /= 1, "Cylinder patch "//trim(iStr)//": Exactly one of length_x, length_y, or length_z must be defined and positive") - ! the defined length is positive + ! Ensure the defined length is positive @:PROHIBIT( & (.not. f_is_default(patch_icpp(patch_id)%length_x) .and. patch_icpp(patch_id)%length_x <= 0._wp) .or. & (.not. f_is_default(patch_icpp(patch_id)%length_y) .and. patch_icpp(patch_id)%length_y <= 0._wp) .or. & @@ -317,10 +317,10 @@ contains end subroutine s_check_cylinder_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_plane_sweep_patch_geometry(patch_id) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -335,7 +335,7 @@ contains end subroutine s_check_plane_sweep_patch_geometry !> This subroutine checks the model patch input - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_ellipsoid_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -352,8 +352,8 @@ contains end subroutine s_check_ellipsoid_patch_geometry !!> This subroutine verifies that the geometric parameters of - !! patch remain unaltered by the user inputs. - !! Patch identifier + !! the inactive patch remain unaltered by the user inputs. + !! @param patch_id Patch identifier impure subroutine s_check_inactive_patch_geometry(patch_id) integer, intent(in) :: patch_id @@ -378,7 +378,7 @@ contains end subroutine s_check_inactive_patch_geometry !> This subroutine verifies the active patch's right to overwrite the preceding patches - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_active_patch_alteration_rights(patch_id) integer, intent(in) :: patch_id @@ -391,10 +391,10 @@ contains end subroutine s_check_active_patch_alteration_rights !> This subroutine verifies that inactive patches cannot overwrite other patches - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_inactive_patch_alteration_rights(patch_id) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -404,7 +404,7 @@ contains end subroutine s_check_inactive_patch_alteration_rights !> This subroutine checks the smoothing parameters - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_supported_patch_smoothing(patch_id) integer, intent(in) :: patch_id @@ -427,10 +427,10 @@ contains end subroutine s_check_supported_patch_smoothing !> This subroutine verifies that inactive patches cannot be smoothed - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_unsupported_patch_smoothing(patch_id) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id call s_int_to_str(patch_id, iStr) @@ -444,7 +444,7 @@ contains end subroutine s_check_unsupported_patch_smoothing !> This subroutine checks the primitive variables - !! Patch identifier + !! @param patch_id Patch identifier impure subroutine s_check_active_patch_primitive_variables(patch_id) integer, intent(in) :: patch_id @@ -503,9 +503,9 @@ contains end subroutine s_check_active_patch_primitive_variables !> This subroutine verifies that the primitive variables - !! the given inactive patch remain unaltered - !! user inputs. - !! Patch identifier + !! associated with the given inactive patch remain unaltered + !! by the user inputs. + !! @param patch_id Patch identifier impure subroutine s_check_inactive_patch_primitive_variables(patch_id) integer, intent(in) :: patch_id diff --git a/src/pre_process/m_checker.fpp b/src/pre_process/m_checker.fpp index 6f4d7eff97..91d4a7f4cb 100644 --- a/src/pre_process/m_checker.fpp +++ b/src/pre_process/m_checker.fpp @@ -22,7 +22,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! the pre_process stage + !! Used by the pre_process stage impure subroutine s_check_inputs call s_check_parallel_io diff --git a/src/pre_process/m_data_output.fpp b/src/pre_process/m_data_output.fpp index 61f2727961..002188ab0b 100644 --- a/src/pre_process/m_data_output.fpp +++ b/src/pre_process/m_data_output.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_data_output +!! @file +!! @brief Contains module m_data_output !> @brief This module takes care of writing the grid and initial condition -!! into the "0" time-step directory located in the folder -!! the rank of the local processor, which is a sub- -!! the case folder specified by the user in the input -!! +!! data files into the "0" time-step directory located in the folder +!! associated with the rank of the local processor, which is a sub- +!! directory of the case folder specified by the user in the input +!! file pre_process.inp. module m_data_output use m_derived_types !< Definitions of the derived types @@ -51,16 +51,16 @@ module m_data_output abstract interface !> Interface for the conservative data - !! Conservative variables - !! track if a cell is within the immersed boundary - !! closest distance from every cell to the IB - !! normalized vector from every cell to the closest point to the IB + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary + !! @param levelset closest distance from every cell to the IB + !! @param levelset_norm normalized vector from every cell to the closest point to the IB impure subroutine s_write_abstract_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) import :: scalar_field, integer_field, sys_size, m, n, p, & pres_field, levelset_field, levelset_norm_field, num_dims - ! variables + ! Conservative variables type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf @@ -69,15 +69,15 @@ module m_data_output dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! markers + ! IB markers type(integer_field), & intent(in), optional :: ib_markers - ! + ! Levelset type(levelset_field), & intent(IN), optional :: levelset - ! Norm + ! Levelset Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -85,40 +85,40 @@ module m_data_output end interface character(LEN=path_len + 2*name_len), private :: t_step_dir !< - !! into which grid and initial condition data will be placed + !! Time-step folder into which grid and initial condition data will be placed character(LEN=path_len + 2*name_len), public :: restart_dir !< - !! folder + !! Restart data folder procedure(s_write_abstract_data_files), pointer :: s_write_data_files => null() contains !> Writes grid and initial condition data files to the "0" - !! in the local processor rank folder - !! Conservative variables - !! track if a cell is within the immersed boundary - !! closest distance from every cell to the IB - !! normalized vector from every cell to the closest point to the IB + !! time-step directory in the local processor rank folder + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary + !! @param levelset closest distance from every cell to the IB + !! @param levelset_norm normalized vector from every cell to the closest point to the IB impure subroutine s_write_serial_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf - ! types + ! BC types type(integer_field), & dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! markers + ! IB markers type(integer_field), & intent(in), optional :: ib_markers - ! + ! Levelset type(levelset_field), & intent(IN), optional :: levelset - ! Norm + ! Levelset Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -129,11 +129,11 @@ contains character(LEN= & int(floor(log10(real(sys_size, wp)))) + 1) :: file_num !< Used to store - !! in character form, of the currently - !! variable data file + !! the number, in character form, of the currently + !! manipulated conservative variable data file character(LEN=len_trim(t_step_dir) + name_len) :: file_loc !< - !! used to store the address of a particular file + !! Generic string used to store the address of a particular file integer :: i, j, k, l, r, c !< Generic loop iterator integer :: t_step @@ -154,7 +154,7 @@ contains t_step = 0 - ! the Locations of the Cell-boundaries + ! Outputting the Locations of the Cell-boundaries if (old_grid) then status = 'old' @@ -170,22 +170,22 @@ contains end if end if - ! direction + ! x-coordinate direction file_loc = trim(t_step_dir)//'/x_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) write (1) x_cb(-1:m) close (1) - ! and z-coordinate directions + ! y- and z-coordinate directions if (n > 0) then - ! direction + ! y-coordinate direction file_loc = trim(t_step_dir)//'/y_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS=status) write (1) y_cb(-1:n) close (1) - ! direction + ! z-coordinate direction if (p > 0) then file_loc = trim(t_step_dir)//'/z_cb.dat' open (1, FILE=trim(file_loc), FORM='unformatted', & @@ -197,7 +197,7 @@ contains if (ib) then - ! IB Markers + ! Outputting IB Markers file_loc = trim(t_step_dir)//'/ib.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) @@ -221,7 +221,7 @@ contains end if end do - ! Levelset Info + ! Outtputting Levelset Info file_loc = trim(t_step_dir)//'/levelset.dat' open (1, FILE=trim(file_loc), FORM='unformatted', STATUS=status) @@ -235,7 +235,7 @@ contains close (1) end if - ! Conservative Variables + ! Outputting Conservative Variables do i = 1, sys_size write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/q_cons_vf'//trim(file_num) & @@ -414,7 +414,7 @@ contains FMT = "(3F40.14)" end if - ! + ! 2D if ((n > 0) .and. (p == 0)) then do i = 1, sys_size write (file_loc, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -464,7 +464,7 @@ contains FMT = "(4F40.14)" end if - ! + ! 3D if (p > 0) then do i = 1, sys_size write (file_loc, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -517,7 +517,7 @@ contains if (ib) then - ! IB Markers + ! Write IB Markers write (file_loc, '(A,I2.2,A)') trim(t_step_dir)//'/ib_markers.', proc_rank, '.dat' open (2, FILE=trim(file_loc)) do j = 0, m @@ -557,14 +557,14 @@ contains end subroutine s_write_serial_data_files !> Writes grid and initial condition data files in parallel to the "0" - !! in the local processor rank folder - !! Conservative variables - !! track if a cell is within the immersed boundary - !! closest distance from every cell to the IB - !! normalized vector from every cell to the closest point to the IB + !! time-step directory in the local processor rank folder + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary + !! @param levelset closest distance from every cell to the IB + !! @param levelset_norm normalized vector from every cell to the closest point to the IB impure subroutine s_write_parallel_data_files(q_cons_vf, q_prim_vf, bc_type, ib_markers, levelset, levelset_norm) - ! variables + ! Conservative variables type(scalar_field), & dimension(sys_size), & intent(inout) :: q_cons_vf, q_prim_vf @@ -573,15 +573,15 @@ contains dimension(1:num_dims, -1:1), & intent(in) :: bc_type - ! markers + ! IB markers type(integer_field), & intent(in), optional :: ib_markers - ! + ! Levelset type(levelset_field), & intent(IN), optional :: levelset - ! Norm + ! Levelset Norm type(levelset_norm_field), & intent(IN), optional :: levelset_norm @@ -598,11 +598,11 @@ contains character(LEN=path_len + 2*name_len) :: file_loc logical :: file_exist, dir_check - ! loop iterators + ! Generic loop iterators integer :: i, j, k, l real(wp) :: loc_violations, glb_violations - ! variables + ! Downsample variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_save, n_glb_save, p_glb_save ! Size of array being saved @@ -633,7 +633,7 @@ contains call s_mpi_barrier() call DelayFileAccess(proc_rank) - ! MPI data I/O + ! Initialize MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_temp) else @@ -645,7 +645,7 @@ contains end if end if - ! the file to write all flow variables + ! Open the file to write all flow variables if (cfl_dt) then write (file_loc, '(I0,A,i7.7,A)') n_start, '_', proc_rank, '.dat' else @@ -661,20 +661,20 @@ contains mpi_info_int, ifile, ierr) if (down_sample) then - ! of local arrays + ! Size of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_save = m_glb_ds + 3 n_glb_save = n_glb_ds + 3 p_glb_save = p_glb_ds + 3 else - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_save = m_glb + 1 n_glb_save = n_glb + 1 p_glb_save = p_glb + 1 end if - ! some integers so MPI can write even the biggest files + ! Resize some integers so MPI can write even the biggest files m_MOK = int(m_glb_save, MPI_OFFSET_KIND) n_MOK = int(n_glb_save, MPI_OFFSET_KIND) p_MOK = int(p_glb_save, MPI_OFFSET_KIND) @@ -683,7 +683,7 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! the data for each variable + ! Write the data for each variable if (bubbles_euler) then do i = 1, sys_size! adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) @@ -721,7 +721,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) else - ! MPI data I/O + ! Initialize MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, & levelset, levelset_norm) @@ -729,7 +729,7 @@ contains call s_initialize_mpi_data(q_cons_vf) end if - ! the file to write all flow variables + ! Open the file to write all flow variables if (cfl_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -743,10 +743,10 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! some integers so MPI can write even the biggest files + ! Resize some integers so MPI can write even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -755,12 +755,12 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! the data for each variable + ! Write the data for each variable if (bubbles_euler) then do i = 1, sys_size! adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -773,7 +773,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -784,10 +784,10 @@ contains end if else do i = 1, sys_size !TODO: check if this is right - ! i = 1, adv_idx%end + ! do i = 1, adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -801,7 +801,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) end if - ! Markers + ! IB Markers if (ib) then write (file_loc, '(A)') 'ib.dat' @@ -813,7 +813,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, & @@ -823,7 +823,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) - ! + ! Levelset write (file_loc, '(A)') 'levelset.dat' file_loc = trim(restart_dir)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -833,7 +833,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_levelset_DATA%view, & @@ -843,7 +843,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) - ! Norm + ! Levelset Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(restart_dir)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -853,7 +853,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_levelsetnorm_DATA%view, & @@ -879,7 +879,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(1), & @@ -898,7 +898,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(2), & @@ -924,29 +924,29 @@ contains end subroutine s_write_parallel_data_files !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_data_output_module - ! string used to store the address of a particular file + ! Generic string used to store the address of a particular file character(LEN=len_trim(case_dir) + 2*name_len) :: file_loc character(len=15) :: temp character(LEN=1), dimension(3), parameter :: coord = (/'x', 'y', 'z'/) - ! logical used to check the existence of directories + ! Generic logical used to check the existence of directories logical :: dir_check integer :: i integer :: m_ds, n_ds, p_ds !< down sample dimensions if (parallel_io .neqv. .true.) then - ! the address of the time-step directory + ! Setting the address of the time-step directory write (t_step_dir, '(A,I0,A)') '/p_all/p', proc_rank, '/0' t_step_dir = trim(case_dir)//trim(t_step_dir) - ! the existence of the time-step directory, removing it, if - ! exists, and creating a new copy. Note that if preexisting grid - ! initial condition data are to be read in from the very same - ! then the above described steps are not executed here but - ! in the module m_start_up.f90. + ! Checking the existence of the time-step directory, removing it, if + ! it exists, and creating a new copy. Note that if preexisting grid + ! and/or initial condition data are to be read in from the very same + ! location, then the above described steps are not executed here but + ! rather in the module m_start_up.f90. if (old_grid .neqv. .true.) then file_loc = trim(t_step_dir)//'/' diff --git a/src/pre_process/m_global_parameters.fpp b/src/pre_process/m_global_parameters.fpp index 0a1272b505..169d996544 100644 --- a/src/pre_process/m_global_parameters.fpp +++ b/src/pre_process/m_global_parameters.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_global_parameters +!! @file +!! @brief Contains module m_global_parameters #:include 'case.fpp' !> @brief This module contains all of the parameters characterizing the -!! simulation algorithm, initial condition -!! stiffened equation of state. +!! computational domain, simulation algorithm, initial condition +!! and the stiffened equation of state. module m_global_parameters #ifdef MFC_MPI @@ -21,7 +21,7 @@ module m_global_parameters implicit none - ! + ! Logistics integer :: num_procs !< Number of processors character(LEN=path_len) :: case_dir !< Case folder location logical :: old_grid !< Use existing grid data @@ -31,11 +31,11 @@ module m_global_parameters logical :: cfl_adap_dt, cfl_const_dt, cfl_dt integer :: n_start, n_start_old - ! Domain Parameters + ! Computational Domain Parameters integer :: proc_rank !< Rank of the local processor - !! cells in the x-, y- and z-coordinate directions + !! Number of cells in the x-, y- and z-coordinate directions integer :: m integer :: n integer :: p @@ -54,30 +54,30 @@ module m_global_parameters integer :: grid_geometry !< Cylindrical coordinates (either axisymmetric or full 3D) real(wp), allocatable, dimension(:) :: x_cc, y_cc, z_cc !< - !! cell-centers (cc) in x-, y- and z-directions, respectively + !! Locations of cell-centers (cc) in x-, y- and z-directions, respectively real(wp), allocatable, dimension(:) :: x_cb, y_cb, z_cb !< - !! cell-boundaries (cb) in x-, y- and z-directions, respectively + !! Locations of cell-boundaries (cb) in x-, y- and z-directions, respectively real(wp) :: dx, dy, dz !< - !! in the x-, y- and z-coordinate directions + !! Minimum cell-widths in the x-, y- and z-coordinate directions type(bounds_info) :: x_domain, y_domain, z_domain !< - !! the domain bounds in the x-, y- and z-coordinate directions + !! Locations of the domain bounds in the x-, y- and z-coordinate directions logical :: stretch_x, stretch_y, stretch_z !< - !! flags for the x-, y- and z-coordinate directions + !! Grid stretching flags for the x-, y- and z-coordinate directions - ! of the grid stretching function for the x-, y- and z-coordinate - ! The "a" parameters are a measure of the rate at which the grid - ! stretched while the remaining parameters are indicative of the location - ! the grid at which the stretching begins. + ! Parameters of the grid stretching function for the x-, y- and z-coordinate + ! directions. The "a" parameters are a measure of the rate at which the grid + ! is stretched while the remaining parameters are indicative of the location + ! on the grid at which the stretching begins. real(wp) :: a_x, a_y, a_z integer :: loops_x, loops_y, loops_z real(wp) :: x_a, y_a, z_a real(wp) :: x_b, y_b, z_b - ! Algorithm Parameters + ! Simulation Algorithm Parameters integer :: model_eqns !< Multicomponent flow model logical :: relax !< activate phase change integer :: relax_model !< Relax Model @@ -105,7 +105,7 @@ module m_global_parameters integer :: igr_order !< IGR reconstruction order logical, parameter :: chemistry = .${chemistry}$. !< Chemistry modeling - ! of the structure, i.e. the organization, of the state vectors + ! Annotations of the structure, i.e. the organization, of the state vectors type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns. type(int_bounds_info) :: mom_idx !< Indexes of first & last momentum eqns. integer :: E_idx !< Index of total energy equation @@ -124,26 +124,26 @@ module m_global_parameters integer :: damage_idx !< Index of damage state variable (D) for continuum damage model integer :: psi_idx !< Index of hyperbolic cleaning state variable for MHD - ! Indices for the (local) interior points (O-m, O-n, 0-p). - ! for "InDices With BUFFer". + ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). + ! Stands for "InDices With BUFFer". type(int_bounds_info) :: idwint(1:3) - ! Indices for the entire (local) domain. In simulation and post_process, - ! includes the buffer region. idwbuff and idwint are the same otherwise. - ! for "InDices With BUFFer". + ! Cell Indices for the entire (local) domain. In simulation and post_process, + ! this includes the buffer region. idwbuff and idwint are the same otherwise. + ! Stands for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) type(int_bounds_info) :: bc_x, bc_y, bc_z !< - !! in the x-, y- and z-coordinate directions + !! Boundary conditions in the x-, y- and z-coordinate directions integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! the stress components that represent shear stress + !! Indices of the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! shear stress components to reflect for boundary conditions + !! Number of shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! shear stress components to reflect for boundary conditions. - !! 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! Indices of shear stress components to reflect for boundary conditions. + !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) logical :: parallel_io !< Format of the data files logical :: file_per_process !< type of data output @@ -155,8 +155,8 @@ module m_global_parameters logical :: mixlayer_perturb !< Superimpose instability waves to surrounding fluid flow integer :: mixlayer_perturb_nk !< Number of Fourier modes for perturbation with mixlayer_perturb flag real(wp) :: mixlayer_perturb_k0 !< Peak wavenumber of prescribed energy spectra with mixlayer_perturb flag - !! (k0 = 0.4446) is most unstable mode obtained from linear stability analysis - !! (1964, JFM) for details + !! Default value (k0 = 0.4446) is most unstable mode obtained from linear stability analysis + !! See Michalke (1964, JFM) for details logical :: simplex_perturb type(simplex_noise_params) :: simplex_params @@ -165,7 +165,7 @@ module m_global_parameters logical :: viscous logical :: bubbles_lagrange - ! density of surrounding air so as to break symmetry of grid + ! Perturb density of surrounding air so as to break symmetry of grid logical :: perturb_flow integer :: perturb_flow_fluid !< Fluid to be perturbed with perturb_flow flag real(wp) :: perturb_flow_mag !< Magnitude of perturbation with perturb_flow flag @@ -177,10 +177,10 @@ module m_global_parameters integer :: elliptic_smoothing_iters integer, allocatable, dimension(:) :: proc_coords !< - !! in MPI_CART_COMM + !! Processor coordinates in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! index of local processor in global grid + !! Starting cell-center index of local processor in global grid #ifdef MFC_MPI @@ -192,32 +192,32 @@ module m_global_parameters character(LEN=name_len) :: mpiiofs integer :: mpi_info_int !< - !! for parallel IO with Lustre file systems + !! MPI info for parallel IO with Lustre file systems #endif - ! Condition Parameters + ! Initial Condition Parameters integer :: num_patches !< Number of patches composing initial condition type(ic_patch_parameters), dimension(num_patches_max) :: patch_icpp !< - !! the initial condition patch parameters (icpp) for each of the - !! in the configuration of the initial condition. Note that - !! allowable number of patches, num_patches_max, may be changed - !! module m_derived_types.f90. + !! Database of the initial condition patch parameters (icpp) for each of the + !! patches employed in the configuration of the initial condition. Note that + !! the maximum allowable number of patches, num_patches_max, may be changed + !! in the module m_derived_types.f90. integer :: num_bc_patches !< Number of boundary condition patches logical :: bc_io !< whether or not to save BC data type(bc_patch_parameters), dimension(num_bc_patches_max) :: patch_bc - !! the boundary condition patch parameters for each of the patches - !! the configuration of the boundary conditions + !! Database of the boundary condition patch parameters for each of the patches + !! employed in the configuration of the boundary conditions - ! Physical Parameters + ! Fluids Physical Parameters type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! the physical parameters of each of the fluids that is present - !! flow. These include the stiffened gas equation of state parameters, - !! Reynolds numbers. + !! Database of the physical parameters of each of the fluids that is present + !! in the flow. These include the stiffened gas equation of state parameters, + !! and the Reynolds numbers. - ! Bubble Parameters + ! Subgrid Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp real(wp) :: rhoref, pref !< Reference parameters for Tait EOS @@ -244,10 +244,10 @@ module m_global_parameters type(ib_patch_parameters), dimension(num_patches_max) :: patch_ib type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l - !! the immersed boundary patch parameters for each of the - !! in the configuration of the initial condition. Note that - !! allowable number of patches, num_patches_max, may be changed - !! module m_derived_types.f90. + !! Database of the immersed boundary patch parameters for each of the + !! patches employed in the configuration of the initial condition. Note that + !! the maximum allowable number of patches, num_patches_max, may be changed + !! in the module m_derived_types.f90. !> @} @@ -297,9 +297,9 @@ module m_global_parameters real(wp) :: Bx0 !< Constant magnetic field in the x-direction (1D) integer :: buff_size !< - !! of cells that are necessary to be able to store enough boundary - !! to march the solution in the physical computational domain - !! next time-step. + !! The number of cells that are necessary to be able to store enough boundary + !! conditions data to march the solution in the physical computational domain + !! to the next time-step. logical :: fft_wrt logical :: dummy !< AMDFlang workaround: keep a dummy logical to avoid a compiler case-optimization bug when a parameter+GPU-kernel conditional is false @@ -307,13 +307,13 @@ module m_global_parameters contains !> Assigns default values to user inputs prior to reading - !! This allows for an easier consistency check of - !! once they are read from the input file. + !! them in. This allows for an easier consistency check of + !! these parameters once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i !< Generic loop operator - ! + ! Logistics case_dir = '.' old_grid = .false. old_ic = .false. @@ -325,7 +325,7 @@ contains cfl_dt = .false. n_start = dflt_int - ! domain parameters + ! Computational domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -356,7 +356,7 @@ contains z_a = dflt_real z_b = dflt_real - ! algorithm parameters + ! Simulation algorithm parameters model_eqns = dflt_int relax = .false. relax_model = dflt_int @@ -425,7 +425,7 @@ contains simplex_params%perturb_dens_scale(:) = dflt_real simplex_params%perturb_dens_offset(:, :) = dflt_real - ! condition parameters + ! Initial condition parameters num_patches = dflt_int do i = 1, num_patches_max @@ -502,11 +502,11 @@ contains patch_bc(i)%radius = dflt_real end do - ! EOS + ! Tait EOS rhoref = dflt_real pref = dflt_real - ! modeling + ! Bubble modeling bubbles_euler = .false. polytropic = .true. polydisperse = .false. @@ -538,11 +538,11 @@ contains Pe_c = dflt_real Tw = dflt_real - ! tension modeling + ! surface tension modeling sigma = dflt_real pi_fac = 1._wp - ! Boundaries + ! Immersed Boundaries ib = .false. num_ibs = dflt_int @@ -562,7 +562,7 @@ contains patch_ib(i)%p = dflt_real patch_ib(i)%slip = .false. - ! default values for translating STL models + ! Proper default values for translating STL models patch_ib(i)%model_scale(:) = 1._wp patch_ib(i)%model_translate(:) = 0._wp patch_ib(i)%model_rotate(:) = 0._wp @@ -570,7 +570,7 @@ contains patch_ib(i)%model_spc = num_ray patch_ib(i)%model_threshold = ray_tracing_threshold - ! to handle moving imersed boundaries, defaulting to no movement + ! Variables to handle moving imersed boundaries, defaulting to no movement patch_ib(i)%moving_ibm = 0 patch_ib(i)%vel(:) = 0._wp patch_ib(i)%angles(:) = 0._wp @@ -579,7 +579,7 @@ contains patch_ib(i)%moment = dflt_real patch_ib(i)%centroid_offset(:) = 0._wp - ! values of a rotation matrix which can be used when calculating rotations + ! sets values of a rotation matrix which can be used when calculating rotations patch_ib(i)%rotation_matrix = 0._wp patch_ib(i)%rotation_matrix(1, 1) = 1._wp patch_ib(i)%rotation_matrix(2, 2) = 1._wp @@ -590,7 +590,7 @@ contains chem_params%gamma_method = 1 chem_params%transport_model = 1 - ! physical parameters + ! Fluids physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -602,7 +602,7 @@ contains Bx0 = dflt_real - ! bubble parameters + ! Subgrid bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -627,7 +627,7 @@ contains end subroutine s_assign_default_values_to_user_inputs !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_global_parameters_module integer :: i, j, fac @@ -638,19 +638,19 @@ contains muscl_polyn = muscl_order end if - ! the layout of the state vectors and overall size of - ! system of equations, given the dimensionality and choice of - ! equations of motion + ! Determining the layout of the state vectors and overall size of + ! the system of equations, given the dimensionality and choice of + ! the equations of motion - ! Model + ! Gamma/Pi_inf Model if (model_eqns == 1) then - ! number of fluids + ! Setting number of fluids num_fluids = 1 - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the gamma/pi_inf model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -662,12 +662,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Fraction Model (5-equation model) + ! Volume Fraction Model (5-equation model) else if (model_eqns == 2) then - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the volume fraction model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -675,17 +675,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! fractions are stored in the indices immediately following - ! energy equation. IGR tracks a total of (N-1) volume fractions - ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! adv_idx%end < adv_idx%beg, which skips all loops over the - ! fractions since there is no volume fraction to track + ! Volume fractions are stored in the indices immediately following + ! the energy equation. IGR tracks a total of (N-1) volume fractions + ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! then adv_idx%end < adv_idx%beg, which skips all loops over the + ! volume fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids - 1 else - ! fractions are stored in the indices immediately following - ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! Volume fractions are stored in the indices immediately following + ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -767,12 +767,12 @@ contains sys_size = B_idx%end end if - ! Fraction Model (6-equation model) + ! Volume Fraction Model (6-equation model) else if (model_eqns == 3) then - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the volume fraction model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the volume fraction model cont_idx%beg = 1 cont_idx%end = num_fluids mom_idx%beg = cont_idx%end + 1 @@ -785,7 +785,7 @@ contains sys_size = internalEnergies_idx%end else if (model_eqns == 4) then - ! equation model with subgrid bubbles_euler + ! 4 equation model with subgrid bubbles_euler cont_idx%beg = 1 ! one continuity equation cont_idx%end = 1 ! num_fluids mom_idx%beg = cont_idx%end + 1 ! one momentum equation in each direction @@ -846,10 +846,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! stress index is 2 for 2D and 2,4,5 for 3D + ! shear stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -857,7 +857,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! x-dir and y-dir: flip tau_xy only + ! Both x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -865,19 +865,19 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! flip tau_xy and tau_xz - ! flip tau_xy and tau_yz - ! flip tau_xz and tau_yz + ! x-dir: flip tau_xy and tau_xz + ! y-dir: flip tau_xy and tau_yz + ! z-dir: flip tau_xz and tau_yz end if end if if (hyperelasticity) then - ! of entries in the symmetric btensor plus the jacobian + ! number of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 tensor_size = num_dims**2 + 1 xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! three more equations for the \xi field and the elastic energy + ! adding three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 end if @@ -957,9 +957,9 @@ contains end if #endif - ! grid variables for the x-direction + ! Allocating grid variables for the x-direction allocate (x_cc(0:m), x_cb(-1:m)) - ! grid variables for the y- and z-directions + ! Allocating grid variables for the y- and z-directions if (n > 0) then allocate (y_cc(0:n), y_cb(-1:n)) if (p > 0) then @@ -1001,16 +1001,16 @@ contains #ifdef MFC_MPI - ! for Lustre file system (Darter/Comet/Stampede) + ! Option for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! for UNIX file system (Hooke/Thomson) - ! '(A)') '/ufs_' - ! = TRIM(mpiiofs) - ! = MPI_INFO_NULL + ! Option for UNIX file system (Hooke/Thomson) + ! WRITE(mpiiofs, '(A)') '/ufs_' + ! mpiiofs = TRIM(mpiiofs) + ! mpi_info_int = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1022,9 +1022,9 @@ contains integer :: i - ! grid variables for the x-direction + ! Deallocating grid variables for the x-direction deallocate (x_cc, x_cb) - ! grid variables for the y- and z-directions + ! Deallocating grid variables for the y- and z-directions if (n > 0) then deallocate (y_cc, y_cb) if (p > 0) then diff --git a/src/pre_process/m_grid.f90 b/src/pre_process/m_grid.f90 index 5467e61f79..454531b4e1 100644 --- a/src/pre_process/m_grid.f90 +++ b/src/pre_process/m_grid.f90 @@ -1,5 +1,5 @@ !> -!! @file m_grid.f90 +!! @file !! @brief Contains module m_grid !> @brief This module takes care of creating the rectilinear grid on which diff --git a/src/pre_process/m_icpp_patches.fpp b/src/pre_process/m_icpp_patches.fpp index 87062e1913..1c3d6b54cd 100644 --- a/src/pre_process/m_icpp_patches.fpp +++ b/src/pre_process/m_icpp_patches.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_patches +!! @file +!! @brief Contains module m_patches #:include 'case.fpp' #:include 'ExtrusionHardcodedIC.fpp' @@ -42,27 +42,27 @@ module m_icpp_patches integer :: smooth_patch_id real(wp) :: smooth_coeff !< - !! are analogous in both meaning and use to the similarly - !! in the ic_patch_parameters type (see m_derived_types.f90 - !! details). They are employed as a means to more concisely - !! actions necessary to lay out a particular patch on the grid. + !! These variables are analogous in both meaning and use to the similarly + !! named components in the ic_patch_parameters type (see m_derived_types.f90 + !! for additional details). They are employed as a means to more concisely + !! perform the actions necessary to lay out a particular patch on the grid. real(wp) :: eta !< - !! case that smoothing of patch boundaries is enabled and the boundary - !! adjacent patches is to be smeared out, this variable's purpose - !! act as a pseudo volume fraction to indicate the contribution of each - !! the composition of a cell's fluid state. + !! In the case that smoothing of patch boundaries is enabled and the boundary + !! between two adjacent patches is to be smeared out, this variable's purpose + !! is to act as a pseudo volume fraction to indicate the contribution of each + !! patch toward the composition of a cell's fluid state. real(wp) :: cart_x, cart_y, cart_z real(wp) :: sph_phi !< - !! be used to hold cell locations in Cartesian coordinates if - !! is using cylindrical coordinates + !! Variables to be used to hold cell locations in Cartesian coordinates if + !! 3D simulation is using cylindrical coordinates type(bounds_info) :: x_boundary, y_boundary, z_boundary !< - !! combine the centroid and length parameters associated with - !! patch to yield the locations of the patch boundaries in the - !! and z-coordinate directions. They are used as a means to concisely - !! actions necessary to lay out a particular patch on the grid. + !! These variables combine the centroid and length parameters associated with + !! a particular patch to yield the locations of the patch boundaries in the + !! x-, y- and z-coordinate directions. They are used as a means to concisely + !! perform the actions necessary to lay out a particular patch on the grid. character(len=5) :: istr ! string to store int to string result for error checking @@ -78,7 +78,7 @@ contains #endif integer :: i - ! Patch Geometries + ! 3D Patch Geometries if (p > 0) then do i = 1, num_patches @@ -89,35 +89,35 @@ contains !> ICPP Patches !> @{ - ! patch + ! Spherical patch if (patch_icpp(i)%geometry == 8) then call s_icpp_sphere(i, patch_id_fp, q_prim_vf) - ! patch + ! Cuboidal patch elseif (patch_icpp(i)%geometry == 9) then call s_icpp_cuboid(i, patch_id_fp, q_prim_vf) - ! patch + ! Cylindrical patch elseif (patch_icpp(i)%geometry == 10) then call s_icpp_cylinder(i, patch_id_fp, q_prim_vf) - ! plane patch + ! Swept plane patch elseif (patch_icpp(i)%geometry == 11) then call s_icpp_sweep_plane(i, patch_id_fp, q_prim_vf) - ! patch + ! Ellipsoidal patch elseif (patch_icpp(i)%geometry == 12) then call s_icpp_ellipsoid(i, patch_id_fp, q_prim_vf) - ! harmonic patch + ! Spherical harmonic patch elseif (patch_icpp(i)%geometry == 14) then call s_icpp_spherical_harmonic(i, patch_id_fp, q_prim_vf) - ! Modified circular patch + ! 3D Modified circular patch elseif (patch_icpp(i)%geometry == 19) then call s_icpp_3dvarcircle(i, patch_id_fp, q_prim_vf) - ! STL patch + ! 3D STL patch elseif (patch_icpp(i)%geometry == 21) then call s_icpp_model(i, patch_id_fp, q_prim_vf) end if end do !> @} - ! Patch Geometries + ! 2D Patch Geometries elseif (n > 0) then do i = 1, num_patches @@ -128,42 +128,42 @@ contains !> ICPP Patches !> @{ - ! patch + ! Circular patch if (patch_icpp(i)%geometry == 2) then call s_icpp_circle(i, patch_id_fp, q_prim_vf) - ! patch + ! Rectangular patch elseif (patch_icpp(i)%geometry == 3) then call s_icpp_rectangle(i, patch_id_fp, q_prim_vf) - ! line patch + ! Swept line patch elseif (patch_icpp(i)%geometry == 4) then call s_icpp_sweep_line(i, patch_id_fp, q_prim_vf) - ! patch + ! Elliptical patch elseif (patch_icpp(i)%geometry == 5) then call s_icpp_ellipse(i, patch_id_fp, q_prim_vf) - ! patch (formerly isentropic vortex) + ! Unimplemented patch (formerly isentropic vortex) elseif (patch_icpp(i)%geometry == 6) then call s_mpi_abort('This used to be the isentropic vortex patch, '// & 'which no longer exists. See Examples. Exiting.') - ! Harmonic Patch + ! Spherical Harmonic Patch elseif (patch_icpp(i)%geometry == 14) then call s_icpp_spherical_harmonic(i, patch_id_fp, q_prim_vf) - ! patch + ! Spiral patch elseif (patch_icpp(i)%geometry == 17) then call s_icpp_spiral(i, patch_id_fp, q_prim_vf) - ! circular patch + ! Modified circular patch elseif (patch_icpp(i)%geometry == 18) then call s_icpp_varcircle(i, patch_id_fp, q_prim_vf) - ! vortex patch + ! TaylorGreen vortex patch elseif (patch_icpp(i)%geometry == 20) then call s_icpp_2D_TaylorGreen_vortex(i, patch_id_fp, q_prim_vf) - ! patch + ! STL patch elseif (patch_icpp(i)%geometry == 21) then call s_icpp_model(i, patch_id_fp, q_prim_vf) end if !> @} end do - ! Patch Geometries + ! 1D Patch Geometries else do i = 1, num_patches @@ -172,10 +172,10 @@ contains print *, 'Processing patch', i end if - ! segment patch + ! Line segment patch if (patch_icpp(i)%geometry == 1) then call s_icpp_line_segment(i, patch_id_fp, q_prim_vf) - ! analytical + ! 1d analytical elseif (patch_icpp(i)%geometry == 16) then call s_icpp_1d_bubble_pulse(i, patch_id_fp, q_prim_vf) end if @@ -186,14 +186,14 @@ contains end subroutine s_apply_icpp_patches !> The line segment patch is a 1D geometry that may be used, - !! in creating a Riemann problem. The geometry - !! patch is well-defined when its centroid and length - !! x-coordinate direction are provided. Note that the - !! patch DOES NOT allow for the smearing of its - !! - !! patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, in creating a Riemann problem. The geometry + !! of the patch is well-defined when its centroid and length + !! in the x-coordinate direction are provided. Note that the + !! line segment patch DOES NOT allow for the smearing of its + !! boundaries. + !! @param patch_id patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_line_segment(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -204,10 +204,10 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k - ! for the cell boundary values + ! Placeholders for the cell boundary values real(wp) :: pi_inf, gamma, lit_gamma @:HardcodedDimensionsExtrusion() @:Hardcoded1DVariables() @@ -218,25 +218,25 @@ contains j = 0 k = 0 - ! the line segment's centroid and length information + ! Transferring the line segment's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid length_x = patch_icpp(patch_id)%length_x - ! the beginning and end x-coordinates of the line segment - ! on its centroid and length + ! Computing the beginning and end x-coordinates of the line segment + ! based on its centroid and length x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! the line segment patch does not allow for its boundaries to - ! smoothed out, the pseudo volume fraction is set to 1 to ensure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the line segment patch does not allow for its boundaries to + ! be smoothed out, the pseudo volume fraction is set to 1 to ensure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta = 1._wp - ! whether the line segment covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the line segment covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & x_boundary%end >= x_cc(i) .and. & @@ -247,12 +247,12 @@ contains @:analytical() - ! if this should load a hardcoded patch + ! check if this should load a hardcoded patch if (patch_icpp(patch_id)%hcid /= dflt_int) then @:Hardcoded1D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, 0, 0) = patch_id end if @@ -262,12 +262,12 @@ contains end subroutine s_icpp_line_segment !> The spiral patch is a 2D geometry that may be used, The geometry - !! patch is well-defined when its centroid and radius - !! Note that the circular patch DOES allow for - !! of its boundary. - !! patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! of the patch is well-defined when its centroid and radius + !! are provided. Note that the circular patch DOES allow for + !! the smoothing of its boundary. + !! @param patch_id patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables impure subroutine s_icpp_spiral(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -284,8 +284,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! the circular patch's radius, centroid, smearing patch - ! and smearing coefficient information + ! Transferring the circular patch's radius, centroid, smearing patch + ! identity and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid mya = patch_icpp(patch_id)%radius @@ -326,7 +326,7 @@ contains @:Hardcoded2D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end do @@ -336,13 +336,13 @@ contains end subroutine s_icpp_spiral !> The circular patch is a 2D geometry that may be used, for - !! creating a bubble or a droplet. The geometry - !! patch is well-defined when its centroid and radius - !! Note that the circular patch DOES allow for - !! of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! example, in creating a bubble or a droplet. The geometry + !! of the patch is well-defined when its centroid and radius + !! are provided. Note that the circular patch DOES allow for + !! the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_circle(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -359,8 +359,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! the circular patch's radius, centroid, smearing patch - ! and smearing coefficient information + ! Transferring the circular patch's radius, centroid, smearing patch + ! identity and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid @@ -368,15 +368,15 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the circular patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! whether the circle covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the circle covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. do j = 0, n do i = 0, m @@ -414,13 +414,13 @@ contains end subroutine s_icpp_circle !> The varcircle patch is a 2D geometry that may be used - !! generatres an annulus - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! . It generatres an annulus + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_varcircle(patch_id, patch_id_fp, q_prim_vf) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -429,14 +429,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k real(wp) :: radius, myr, thickness @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! the circular patch's radius, centroid, smearing patch - ! and smearing coefficient information + ! Transferring the circular patch's radius, centroid, smearing patch + ! identity and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid radius = patch_icpp(patch_id)%radius @@ -444,15 +444,15 @@ contains smooth_coeff = patch_icpp(patch_id)%smooth_coeff thickness = patch_icpp(patch_id)%epsilon - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the circular patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! whether the circle covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the circle covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. do j = 0, n do i = 0, m myr = sqrt((x_cc(i) - x_centroid)**2 & @@ -470,7 +470,7 @@ contains @:Hardcoded2D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id q_prim_vf(alf_idx)%sf(i, j, 0) = patch_icpp(patch_id)%alpha(1)* & @@ -483,12 +483,12 @@ contains end subroutine s_icpp_varcircle - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_3dvarcircle(patch_id, patch_id_fp, q_prim_vf) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -497,14 +497,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k real(wp) :: radius, myr, thickness @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the circular patch's radius, centroid, smearing patch - ! and smearing coefficient information + ! Transferring the circular patch's radius, centroid, smearing patch + ! identity and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -514,17 +514,17 @@ contains smooth_coeff = patch_icpp(patch_id)%smooth_coeff thickness = patch_icpp(patch_id)%epsilon - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the circular patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the circular patch's boundary is enabled. eta = 1._wp - ! for all z + ! write for all z - ! whether the circle covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the circle covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -543,7 +543,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id q_prim_vf(alf_idx)%sf(i, j, k) = patch_icpp(patch_id)%alpha(1)* & @@ -558,12 +558,12 @@ contains end subroutine s_icpp_3dvarcircle !> The elliptical patch is a 2D geometry. The geometry of - !! is well-defined when its centroid and radii - !! Note that the elliptical patch DOES allow - !! smoothing of its boundary - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! the patch is well-defined when its centroid and radii + !! are provided. Note that the elliptical patch DOES allow + !! for the smoothing of its boundary + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_ellipse(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -579,8 +579,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded2DVariables() - ! the elliptical patch's radii, centroid, smearing - ! identity, and smearing coefficient information + ! Transferring the elliptical patch's radii, centroid, smearing + ! patch identity, and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid a = patch_icpp(patch_id)%radii(1) @@ -588,16 +588,16 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! the pseudo volume fraction value to 1. The value - ! modified as the patch is laid out on the grid, but only in - ! case that smoothing of the elliptical patch's boundary is - ! + ! Initializing the pseudo volume fraction value to 1. The value + ! be modified as the patch is laid out on the grid, but only in + ! the case that smoothing of the elliptical patch's boundary is + ! enabled. eta = 1._wp - ! whether the ellipse covers a particular cell in the - ! and verifying whether the current patch has permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the ellipse covers a particular cell in the + ! domain and verifying whether the current patch has permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do j = 0, n do i = 0, m @@ -624,7 +624,7 @@ contains @:Hardcoded2D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end do @@ -634,15 +634,15 @@ contains end subroutine s_icpp_ellipse !> The ellipsoidal patch is a 3D geometry. The geometry of - !! is well-defined when its centroid and radii - !! Note that the ellipsoidal patch DOES allow - !! smoothing of its boundary - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! the patch is well-defined when its centroid and radii + !! are provided. Note that the ellipsoidal patch DOES allow + !! for the smoothing of its boundary + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_ellipsoid(patch_id, patch_id_fp, q_prim_vf) - ! identifier + ! Patch identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -651,14 +651,14 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k real(wp) :: a, b, c @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the ellipsoidal patch's radii, centroid, smearing - ! identity, and smearing coefficient information + ! Transferring the ellipsoidal patch's radii, centroid, smearing + ! patch identity, and smearing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -668,16 +668,16 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! the pseudo volume fraction value to 1. The value - ! modified as the patch is laid out on the grid, but only in - ! case that smoothing of the ellipsoidal patch's boundary is - ! + ! Initializing the pseudo volume fraction value to 1. The value + ! be modified as the patch is laid out on the grid, but only in + ! the case that smoothing of the ellipsoidal patch's boundary is + ! enabled. eta = 1._wp - ! whether the ellipsoid covers a particular cell in the - ! and verifying whether the current patch has permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the ellipsoid covers a particular cell in the + ! domain and verifying whether the current patch has permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -714,7 +714,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if end do @@ -725,16 +725,16 @@ contains end subroutine s_icpp_ellipsoid !> The rectangular patch is a 2D geometry that may be used, - !! in creating a solid boundary, or pre-/post- - !! in alignment with the axes of the Cartesian - !! The geometry of such a patch is well- - !! its centroid and lengths in the x- and y- - !! are provided. Please note that the - !! DOES NOT allow for the smoothing of its - !! - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, in creating a solid boundary, or pre-/post- + !! shock region, in alignment with the axes of the Cartesian + !! coordinate system. The geometry of such a patch is well- + !! defined when its centroid and lengths in the x- and y- + !! coordinate directions are provided. Please note that the + !! rectangular patch DOES NOT allow for the smoothing of its + !! boundaries. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_rectangle(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -754,29 +754,29 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! the rectangle's centroid and length information + ! Transferring the rectangle's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid length_x = patch_icpp(patch_id)%length_x length_y = patch_icpp(patch_id)%length_y - ! the beginning and the end x- and y-coordinates of the - ! based on its centroid and lengths + ! Computing the beginning and the end x- and y-coordinates of the + ! rectangle based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! the rectangular patch does not allow for its boundaries to - ! smoothed out, the pseudo volume fraction is set to 1 to ensure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the rectangular patch does not allow for its boundaries to + ! be smoothed out, the pseudo volume fraction is set to 1 to ensure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta = 1._wp - ! whether the rectangle covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the rectangle covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do j = 0, n do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & @@ -802,7 +802,7 @@ contains rhoref*(1._wp - q_prim_vf(alf_idx)%sf(i, j, 0)) end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if end if @@ -813,15 +813,15 @@ contains end subroutine s_icpp_rectangle !> The swept line patch is a 2D geometry that may be used, - !! in creating a solid boundary, or pre-/post- - !! at an angle with respect to the axes of the - !! system. The geometry of the patch is - !! its centroid and normal vector, aimed - !! sweep direction, are provided. Note that the sweep - !! DOES allow the smoothing of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, in creating a solid boundary, or pre-/post- + !! shock region, at an angle with respect to the axes of the + !! Cartesian coordinate system. The geometry of the patch is + !! well-defined when its centroid and normal vector, aimed + !! in the sweep direction, are provided. Note that the sweep + !! line patch DOES allow the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_sweep_line(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -837,26 +837,26 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the centroid information of the line to be swept + ! Transferring the centroid information of the line to be swept x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! coefficients of the equation describing the sweep line + ! Obtaining coefficients of the equation describing the sweep line a = patch_icpp(patch_id)%normal(1) b = patch_icpp(patch_id)%normal(2) c = -a*x_centroid - b*y_centroid - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the sweep line patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the sweep line patch's boundary is enabled. eta = 1._wp - ! whether the region swept by the line covers a particular - ! in the domain and verifying whether the current patch has the - ! to write to that cell. If both queries check out, the - ! variables of the current patch are written to this cell. + ! Checking whether the region swept by the line covers a particular + ! cell in the domain and verifying whether the current patch has the + ! permission to write to that cell. If both queries check out, the + ! primitive variables of the current patch are written to this cell. do j = 0, n do i = 0, m @@ -880,7 +880,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id end if @@ -891,12 +891,12 @@ contains end subroutine s_icpp_sweep_line !> The Taylor Green vortex is 2D decaying vortex that may be used, - !! to verify the effects of viscous attenuation. - !! the patch is well-defined when its centroid - !! - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, to verify the effects of viscous attenuation. + !! Geometry of the patch is well-defined when its centroid + !! are provided. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_2D_TaylorGreen_Vortex(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -917,33 +917,33 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! the patch's centroid and length information + ! Transferring the patch's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid length_x = patch_icpp(patch_id)%length_x length_y = patch_icpp(patch_id)%length_y - ! the beginning and the end x- and y-coordinates - ! the patch based on its centroid and lengths + ! Computing the beginning and the end x- and y-coordinates + ! of the patch based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y y_boundary%end = y_centroid + 0.5_wp*length_y - ! the patch doesn't allow for its boundaries to be - ! out, the pseudo volume fraction is set to 1 to - ! that only the current patch contributes to the fluid - ! in the cells that this patch covers. + ! Since the patch doesn't allow for its boundaries to be + ! smoothed out, the pseudo volume fraction is set to 1 to + ! ensure that only the current patch contributes to the fluid + ! state in the cells that this patch covers. eta = 1._wp - ! is the characteristic velocity of the vortex + ! U0 is the characteristic velocity of the vortex U0 = patch_icpp(patch_id)%vel(1) - ! is the characteristic length of the vortex + ! L0 is the characteristic length of the vortex L0 = patch_icpp(patch_id)%vel(2) - ! whether the patch covers a particular cell in the - ! and verifying whether the current patch has the - ! to write to that cell. If both queries check out, - ! primitive variables of the current patch are assigned - ! this cell. + ! Checking whether the patch covers a particular cell in the + ! domain and verifying whether the current patch has the + ! permission to write to that cell. If both queries check out, + ! the primitive variables of the current patch are assigned + ! to this cell. do j = 0, n do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & @@ -960,10 +960,10 @@ contains @:Hardcoded2D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, 0) = patch_id - ! Parameters + ! Assign Parameters q_prim_vf(mom_idx%beg)%sf(i, j, 0) = U0*sin(x_cc(i)/L0)*cos(y_cc(j)/L0) q_prim_vf(mom_idx%end)%sf(i, j, 0) = -U0*cos(x_cc(i)/L0)*sin(y_cc(j)/L0) q_prim_vf(E_idx)%sf(i, j, 0) = patch_icpp(patch_id)%pres + (cos(2*x_cc(i))/L0 + & @@ -976,14 +976,14 @@ contains end subroutine s_icpp_2D_TaylorGreen_Vortex - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_1d_bubble_pulse(patch_id, patch_id_fp, q_prim_vf) - ! This patch assigns the primitive variables as analytical - ! such that the code can be verified. + ! Description: This patch assigns the primitive variables as analytical + ! functions such that the code can be verified. - ! identifier + ! Patch identifier integer, intent(in) :: patch_id #ifdef MFC_MIXED_PRECISION integer(kind=1), dimension(0:m, 0:n, 0:p), intent(inout) :: patch_id_fp @@ -992,9 +992,9 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k - ! for the cell boundary values + ! Placeholders for the cell boundary values real(wp) :: pi_inf, gamma, lit_gamma @:HardcodedDimensionsExtrusion() @:Hardcoded1DVariables() @@ -1003,25 +1003,25 @@ contains gamma = gammas(1) lit_gamma = gs_min(1) - ! the patch's centroid and length information + ! Transferring the patch's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid length_x = patch_icpp(patch_id)%length_x - ! the beginning and the end x- and y-coordinates - ! the patch based on its centroid and lengths + ! Computing the beginning and the end x- and y-coordinates + ! of the patch based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x - ! the patch doesn't allow for its boundaries to be - ! out, the pseudo volume fraction is set to 1 to - ! that only the current patch contributes to the fluid - ! in the cells that this patch covers. + ! Since the patch doesn't allow for its boundaries to be + ! smoothed out, the pseudo volume fraction is set to 1 to + ! ensure that only the current patch contributes to the fluid + ! state in the cells that this patch covers. eta = 1._wp - ! whether the line segment covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the line segment covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do i = 0, m if (x_boundary%beg <= x_cc(i) .and. & x_boundary%end >= x_cc(i) .and. & @@ -1042,10 +1042,10 @@ contains end subroutine s_icpp_1D_bubble_pulse !> This patch generates the shape of the spherical harmonics - !! perturbation to a perfect sphere - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! as a perturbation to a perfect sphere + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_spherical_harmonic(patch_id, patch_id_fp, q_prim_vf) integer, intent(IN) :: patch_id @@ -1063,7 +1063,7 @@ contains integer :: i, j, k !< generic loop iterators - ! the patch's centroid and radius information + ! Transferring the patch's centroid and radius information x_centroid_local = patch_icpp(patch_id)%x_centroid y_centroid_local = patch_icpp(patch_id)%y_centroid z_centroid_local = patch_icpp(patch_id)%z_centroid @@ -1080,17 +1080,17 @@ contains as(9) = patch_icpp(patch_id)%a(9) non_axis_sym_in = patch_icpp(patch_id)%non_axis_sym - ! the analytical patch does not allow for its boundaries to get - ! out, the pseudo volume fraction is set to 1 to make sure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the analytical patch does not allow for its boundaries to get + ! smoothed out, the pseudo volume fraction is set to 1 to make sure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta_local = 1._wp eps = 1.e-32_wp - ! whether the patch covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables - ! the current patch are assigned to this cell. + ! Checking whether the patch covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! to that cell. If both queries check out, the primitive variables + ! of the current patch are assigned to this cell. if (p > 0 .and. .not. non_axis_sym_in) then do k = 0, p do j = 0, n @@ -1190,13 +1190,13 @@ contains end subroutine s_icpp_spherical_harmonic !> The spherical patch is a 3D geometry that may be used, - !! in creating a bubble or a droplet. The patch - !! well-defined when its centroid and radius are - !! note that the spherical patch DOES allow - !! smoothing of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, in creating a bubble or a droplet. The patch + !! geometry is well-defined when its centroid and radius are + !! provided. Please note that the spherical patch DOES allow + !! for the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_sphere(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1207,17 +1207,17 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! loop iterators + ! Generic loop iterators integer :: i, j, k real(wp) :: radius @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - !! initialize the pressure field that corresponds to the - !! case found in Tiwari et al. (2013) + !! Variables to initialize the pressure field that corresponds to the + !! bubble-collapse test case found in Tiwari et al. (2013) - ! spherical patch's radius, centroid, smoothing patch - ! and smoothing coefficient information + ! Transferring spherical patch's radius, centroid, smoothing patch + ! identity and smoothing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1225,15 +1225,15 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smoothing of the spherical patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smoothing of the spherical patch's boundary is enabled. eta = 1._wp - ! whether the sphere covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! cell. If both queries check out, the primitive variables of - ! current patch are assigned to this cell. + ! Checking whether the sphere covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! that cell. If both queries check out, the primitive variables of + ! the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1276,16 +1276,16 @@ contains end subroutine s_icpp_sphere !> The cuboidal patch is a 3D geometry that may be used, for - !! creating a solid boundary, or pre-/post-shock - !! is aligned with the axes of the Cartesian - !! The geometry of such a patch is well- - !! its centroid and lengths in the x-, y- and - !! are provided. Please notice that - !! patch DOES NOT allow for the smearing of its - !! - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! example, in creating a solid boundary, or pre-/post-shock + !! region, which is aligned with the axes of the Cartesian + !! coordinate system. The geometry of such a patch is well- + !! defined when its centroid and lengths in the x-, y- and + !! z-coordinate directions are provided. Please notice that + !! the cuboidal patch DOES NOT allow for the smearing of its + !! boundaries. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_cuboid(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1300,7 +1300,7 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the cuboid's centroid and length information + ! Transferring the cuboid's centroid and length information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1308,8 +1308,8 @@ contains length_y = patch_icpp(patch_id)%length_y length_z = patch_icpp(patch_id)%length_z - ! the beginning and the end x-, y- and z-coordinates of - ! cuboid based on its centroid and lengths + ! Computing the beginning and the end x-, y- and z-coordinates of + ! the cuboid based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y @@ -1317,16 +1317,16 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! the cuboidal patch does not allow for its boundaries to get - ! out, the pseudo volume fraction is set to 1 to make sure - ! only the current patch contributes to the fluid state in the - ! that this patch covers. + ! Since the cuboidal patch does not allow for its boundaries to get + ! smoothed out, the pseudo volume fraction is set to 1 to make sure + ! that only the current patch contributes to the fluid state in the + ! cells that this patch covers. eta = 1._wp - ! whether the cuboid covers a particular cell in the domain - ! verifying whether the current patch has permission to write to - ! that cell. If both queries check out, the primitive variables - ! the current patch are assigned to this cell. + ! Checking whether the cuboid covers a particular cell in the domain + ! and verifying whether the current patch has permission to write to + ! to that cell. If both queries check out, the primitive variables + ! of the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1355,7 +1355,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if @@ -1368,16 +1368,16 @@ contains end subroutine s_icpp_cuboid !> The cylindrical patch is a 3D geometry that may be used, - !! in setting up a cylindrical solid boundary - !! a blood vessel. The geometry of this - !! well-defined when the centroid, the radius and - !! along the cylinder's axis, parallel to the x-, - !! z-coordinate direction, are provided. Please note - !! cylindrical patch DOES allow for the smoothing - !! lateral boundary. - !! is the patch identifier - !! Array to track patch ids - !! Array of primitive variables + !! for example, in setting up a cylindrical solid boundary + !! confinement, like a blood vessel. The geometry of this + !! patch is well-defined when the centroid, the radius and + !! the length along the cylinder's axis, parallel to the x-, + !! y- or z-coordinate direction, are provided. Please note + !! that the cylindrical patch DOES allow for the smoothing + !! of its lateral boundary. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Array of primitive variables subroutine s_icpp_cylinder(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1393,8 +1393,8 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the cylindrical patch's centroid, length, radius, - ! patch identity and smoothing coefficient information + ! Transferring the cylindrical patch's centroid, length, radius, + ! smoothing patch identity and smoothing coefficient information x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid @@ -1405,8 +1405,8 @@ contains smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! the beginning and the end x-, y- and z-coordinates of - ! cylinder based on its centroid and lengths + ! Computing the beginning and the end x-, y- and z-coordinates of + ! the cylinder based on its centroid and lengths x_boundary%beg = x_centroid - 0.5_wp*length_x x_boundary%end = x_centroid + 0.5_wp*length_x y_boundary%beg = y_centroid - 0.5_wp*length_y @@ -1414,15 +1414,15 @@ contains z_boundary%beg = z_centroid - 0.5_wp*length_z z_boundary%end = z_centroid + 0.5_wp*length_z - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smearing of the cylindrical patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smearing of the cylindrical patch's boundary is enabled. eta = 1._wp - ! whether the cylinder covers a particular cell in the - ! and verifying whether the current patch has the permission - ! write to that cell. If both queries check out, the primitive - ! of the current patch are assigned to this cell. + ! Checking whether the cylinder covers a particular cell in the + ! domain and verifying whether the current patch has the permission + ! to write to that cell. If both queries check out, the primitive + ! variables of the current patch are assigned to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1481,7 +1481,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if end do @@ -1492,15 +1492,15 @@ contains end subroutine s_icpp_cylinder !> The swept plane patch is a 3D geometry that may be used, - !! in creating a solid boundary, or pre-/post- - !! at an angle with respect to the axes of the - !! system. The geometry of the patch is - !! its centroid and normal vector, aimed - !! sweep direction, are provided. Note that the sweep - !! DOES allow the smoothing of its boundary. - !! is the patch identifier - !! Array to track patch ids - !! Primitive variables + !! for example, in creating a solid boundary, or pre-/post- + !! shock region, at an angle with respect to the axes of the + !! Cartesian coordinate system. The geometry of the patch is + !! well-defined when its centroid and normal vector, aimed + !! in the sweep direction, are provided. Note that the sweep + !! plane patch DOES allow the smoothing of its boundary. + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Primitive variables subroutine s_icpp_sweep_plane(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1516,28 +1516,28 @@ contains @:HardcodedDimensionsExtrusion() @:Hardcoded3DVariables() - ! the centroid information of the plane to be swept + ! Transferring the centroid information of the plane to be swept x_centroid = patch_icpp(patch_id)%x_centroid y_centroid = patch_icpp(patch_id)%y_centroid z_centroid = patch_icpp(patch_id)%z_centroid smooth_patch_id = patch_icpp(patch_id)%smooth_patch_id smooth_coeff = patch_icpp(patch_id)%smooth_coeff - ! coefficients of the equation describing the sweep plane + ! Obtaining coefficients of the equation describing the sweep plane a = patch_icpp(patch_id)%normal(1) b = patch_icpp(patch_id)%normal(2) c = patch_icpp(patch_id)%normal(3) d = -a*x_centroid - b*y_centroid - c*z_centroid - ! the pseudo volume fraction value to 1. The value will - ! modified as the patch is laid out on the grid, but only in the - ! that smearing of the sweep plane patch's boundary is enabled. + ! Initializing the pseudo volume fraction value to 1. The value will + ! be modified as the patch is laid out on the grid, but only in the + ! case that smearing of the sweep plane patch's boundary is enabled. eta = 1._wp - ! whether the region swept by the plane covers a particular - ! in the domain and verifying whether the current patch has the - ! to write to that cell. If both queries check out, the - ! variables of the current patch are written to this cell. + ! Checking whether the region swept by the plane covers a particular + ! cell in the domain and verifying whether the current patch has the + ! permission to write to that cell. If both queries check out, the + ! primitive variables of the current patch are written to this cell. do k = 0, p do j = 0, n do i = 0, m @@ -1572,7 +1572,7 @@ contains @:Hardcoded3D() end if - ! the patch identities bookkeeping variable + ! Updating the patch identities bookkeeping variable if (1._wp - eta < sgm_eps) patch_id_fp(i, j, k) = patch_id end if @@ -1584,11 +1584,11 @@ contains end subroutine s_icpp_sweep_plane !> The STL patch is a 2/3D geometry that is imported from an STL file. - !! is the patch identifier - !! Array to track patch ids - !! Primitive variables - !! STL levelset - !! STL levelset normals + !! @param patch_id is the patch identifier + !! @param patch_id_fp Array to track patch ids + !! @param q_prim_vf Primitive variables + !! @param STL_levelset STL levelset + !! @param STL_levelset_norm STL levelset normals subroutine s_icpp_model(patch_id, patch_id_fp, q_prim_vf) integer, intent(in) :: patch_id @@ -1599,7 +1599,7 @@ contains #endif type(scalar_field), dimension(1:sys_size), intent(inout) :: q_prim_vf - ! for IBM+STL + ! Variables for IBM+STL real(wp) :: normals(1:3) !< Boundary normal buffer integer :: boundary_vertex_count, boundary_edge_count, total_vertices !< Boundary vertex real(wp), allocatable, dimension(:, :, :) :: boundary_v !< Boundary vertex buffer @@ -1637,39 +1637,39 @@ contains print *, " * Transforming model." end if - ! the model center before transforming the model + ! Get the model center before transforming the model bbox_old = f_create_bbox(model) model_center(1:3) = (bbox_old%min(1:3) + bbox_old%max(1:3))/2._wp - ! the transform matrices for vertices and normals + ! Compute the transform matrices for vertices and normals transform = f_create_transform_matrix(params, model_center) transform_n = f_create_transform_matrix(params) call s_transform_model(model, transform, transform_n) - ! the bounding box after transformation + ! Recreate the bounding box after transformation bbox = f_create_bbox(model) - ! the number of vertices in the original STL model + ! Show the number of vertices in the original STL model if (proc_rank == 0) then print *, ' * Number of input model vertices:', 3*model%ntrs end if call f_check_boundary(model, boundary_v, boundary_vertex_count, boundary_edge_count) - ! if the model needs interpolation + ! Check if the model needs interpolation if (p > 0) then call f_check_interpolation_3D(model, (/dx, dy, dz/), interpolate) else call f_check_interpolation_2D(boundary_v, boundary_edge_count, (/dx, dy, dz/), interpolate) end if - ! the number of edges and boundary edges in 2D STL models + ! Show the number of edges and boundary edges in 2D STL models if (proc_rank == 0 .and. p == 0) then print *, ' * Number of 2D model boundary edges:', boundary_edge_count end if - ! the STL model along the edges (2D) and on triangle facets (3D) + ! Interpolate the STL model along the edges (2D) and on triangle facets (3D) if (interpolate) then if (proc_rank == 0) then print *, ' * Interpolating STL vertices.' @@ -1738,8 +1738,8 @@ contains call s_assign_patch_primitive_variables(patch_id, i, j, k, & eta, q_prim_vf, patch_id_fp) - ! Should probably use *eta* to compute primitive variables - ! defining them analytically. + ! Note: Should probably use *eta* to compute primitive variables + ! if defining them analytically. @:analytical() end do; end do; end do @@ -1785,9 +1785,9 @@ contains end subroutine s_convert_cylindrical_to_spherical_coord !> Archimedes spiral function - !! Angle - !! Thickness - !! Starting position + !! @param myth Angle + !! @param offset Thickness + !! @param a Starting position elemental function f_r(myth, offset, a) $:GPU_ROUTINE(parallelism='[seq]') diff --git a/src/pre_process/m_initial_condition.fpp b/src/pre_process/m_initial_condition.fpp index 22406649ce..96b91b4df1 100644 --- a/src/pre_process/m_initial_condition.fpp +++ b/src/pre_process/m_initial_condition.fpp @@ -1,19 +1,19 @@ !> -!! -!! module m_initial_condition +!! @file +!! @brief Contains module m_initial_condition !> @brief This module provides a platform that is analogous to constructive -!! techniques and in this way allows for the creation -!! wide variety of initial conditions. Several 1D, 2D and 3D -!! are included that may further be combined -!! complex shapes. This is achieved by carefully setting -!! order in which the patches are laid out in the domain and -!! priority that each patch has over the preceding -!! resulting shapes may be identified both by the values -!! primitive variables and the associated patch identities. -!! the user may choose to read in and modify a preexisting -!! The module m_start_up.f90 is responsible for -!! the relevant data files. +!! solid geometry techniques and in this way allows for the creation +!! of a wide variety of initial conditions. Several 1D, 2D and 3D +!! fundamental geometries are included that may further be combined +!! into more complex shapes. This is achieved by carefully setting +!! up the order in which the patches are laid out in the domain and +!! specifying the priority that each patch has over the preceding +!! ones. The resulting shapes may be identified both by the values +!! of their primitive variables and the associated patch identities. +!! Note that the user may choose to read in and modify a preexisting +!! initial condition. The module m_start_up.f90 is responsible for +!! reading in the relevant data files. module m_initial_condition use m_derived_types ! Definitions of the derived types @@ -25,7 +25,7 @@ module m_initial_condition use m_helper use m_variables_conversion ! Subroutines to change the state variables from - ! form to another + ! one form to another use m_ib_patches @@ -41,10 +41,10 @@ module m_initial_condition implicit none - ! The abstract interface allows for the declaration of a pointer to - ! procedure such that the choice of the model equations does not have to - ! queried every time the patch primitive variables are to be assigned in - ! cell in the computational domain. + ! NOTE: The abstract interface allows for the declaration of a pointer to + ! a procedure such that the choice of the model equations does not have to + ! be queried every time the patch primitive variables are to be assigned in + ! a cell in the computational domain. type(scalar_field), allocatable, dimension(:) :: q_prim_vf !< primitive variables type(scalar_field), allocatable, dimension(:) :: q_cons_vf !< conservative variables @@ -58,18 +58,19 @@ module m_initial_condition integer(kind=1), allocatable, dimension(:, :, :) :: patch_id_fp #else !> @endcond - integer, allocatable, dimension(:, :, :) :: patch_id_fp !< - !! Bookkeeping variable used to track the patch identities (id) associated - !! with each of the cells in the computational domain. Note that only one - !! patch identity may be associated with any one cell. + integer, allocatable, dimension(:, :, :) :: patch_id_fp !> @cond #endif !> @endcond + !! Bookkepping variable used to track the patch identities (id) associated + !! with each of the cells in the computational domain. Note that only one + !! patch identity may be associated with any one cell. + type(integer_field) :: ib_markers !< - !! used to track whether a given cell is within an - !! The default is 0, otherwise the value is assigned - !! patch ID of the immersed boundary. + !! Bookkepping variable used to track whether a given cell is within an + !! immersed boundary. The default is 0, otherwise the value is assigned + !! to the patch ID of the immersed boundary. type(levelset_field) :: levelset type(levelset_norm_field) :: levelset_norm @@ -77,12 +78,12 @@ module m_initial_condition contains !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_initial_condition_module integer :: i, j, k, l !< generic loop iterators - ! the primitive and conservative variables + ! Allocating the primitive and conservative variables allocate (q_prim_vf(1:sys_size)) allocate (q_cons_vf(1:sys_size)) @@ -99,7 +100,7 @@ contains allocate (q_T_sf%sf(0:m, 0:n, 0:p)) end if - ! the patch identities bookkeeping variable + ! Allocating the patch identities bookkeeping variable allocate (patch_id_fp(0:m, 0:n, 0:p)) if (ib) then @@ -119,17 +120,17 @@ contains 0:p, 1:nnode, 1:nb)) end if - ! default values for conservative and primitive variables so - ! in the case that the initial condition is wrongly laid out on - ! grid the simulation component will catch the problem on start- - ! The conservative variables do not need to be similarly treated - ! they are computed directly from the primitive variables. + ! Setting default values for conservative and primitive variables so + ! that in the case that the initial condition is wrongly laid out on + ! the grid the simulation component will catch the problem on start- + ! up. The conservative variables do not need to be similarly treated + ! since they are computed directly from the primitive variables. do i = 1, sys_size q_cons_vf(i)%sf = -1.e-6_stp ! real(dflt_real, kind=stp) ! TODO :: remove this magic number q_prim_vf(i)%sf = -1.e-6_stp ! real(dflt_real, kind=stp) end do - ! arrays to store the bc types + ! Allocating arrays to store the bc types allocate (bc_type(1:num_dims, 1:2)) allocate (bc_type(1, 1)%sf(0:0, 0:n, 0:p)) @@ -166,39 +167,39 @@ contains end if end if - ! damage state is always zero + ! Initial damage state is always zero if (cont_damage) then q_cons_vf(damage_idx)%sf = 0._wp q_prim_vf(damage_idx)%sf = 0._wp end if - ! hyper_cleaning state is always zero - ! more general + ! Initial hyper_cleaning state is always zero + ! TODO more general if (hyper_cleaning) then q_cons_vf(psi_idx)%sf = 0._wp q_prim_vf(psi_idx)%sf = 0._wp end if - ! default values for patch identities bookkeeping variable. - ! is necessary to avoid any confusion in the assessment of the - ! of application that the overwrite permissions give a patch - ! it is being applied in the domain. + ! Setting default values for patch identities bookkeeping variable. + ! This is necessary to avoid any confusion in the assessment of the + ! extent of application that the overwrite permissions give a patch + ! when it is being applied in the domain. patch_id_fp = 0 end subroutine s_initialize_initial_condition_module !> This subroutine peruses the patches and depending on the - !! geometry associated with a particular patch, it - !! related subroutine to setup the said geometry - !! grid using the primitive variables included with - !! parameters. The subroutine is complete once the - !! are converted to conservative ones. + !! type of geometry associated with a particular patch, it + !! calls the related subroutine to setup the said geometry + !! on the grid using the primitive variables included with + !! the patch parameters. The subroutine is complete once the + !! primitive variables are converted to conservative ones. impure subroutine s_generate_initial_condition integer :: i - ! the conservative variables to the primitive ones given - ! initial condition data files were read in on start-up + ! Converting the conservative variables to the primitive ones given + ! preexisting initial condition data files were read in on start-up if (old_ic) then call s_convert_conservative_to_primitive_variables(q_cons_vf, & q_T_sf, & @@ -222,7 +223,7 @@ contains if (simplex_perturb) call s_perturb_simplex(q_prim_vf) if (elliptic_smoothing) call s_elliptic_smoothing(q_prim_vf, bc_type) - ! the primitive variables to the conservative ones + ! Converting the primitive variables to the conservative ones call s_convert_primitive_to_conservative_variables(q_prim_vf, q_cons_vf) if (chemistry) call s_compute_T_from_primitives(q_T_sf, q_prim_vf, idwint) @@ -240,7 +241,7 @@ contains integer :: i !< Generic loop iterator - ! the primitive and conservative variables + ! Dellocating the primitive and conservative variables do i = 1, sys_size deallocate (q_prim_vf(i)%sf) deallocate (q_cons_vf(i)%sf) @@ -253,7 +254,7 @@ contains deallocate (q_T_sf%sf) end if - ! the patch identities bookkeeping variable + ! Deallocating the patch identities bookkeeping variable deallocate (patch_id_fp) if (ib) then diff --git a/src/pre_process/m_mpi_proxy.fpp b/src/pre_process/m_mpi_proxy.fpp index 449fe2ad42..c7b6bb4e4b 100644 --- a/src/pre_process/m_mpi_proxy.fpp +++ b/src/pre_process/m_mpi_proxy.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_mpi_proxy +!! @file +!! @brief Contains module m_mpi_proxy !> @brief This module serves as a proxy to the parameters and subroutines -!! the MPI implementation's MPI module. Specifically, -!! of the proxy is to harness basic MPI commands into more -!! as to achieve the required pre-processing -!! +!! available in the MPI implementation's MPI module. Specifically, +!! the role of the proxy is to harness basic MPI commands into more +!! complex procedures as to achieve the required pre-processing +!! communication goals. module m_mpi_proxy #ifdef MFC_MPI @@ -25,20 +25,20 @@ module m_mpi_proxy contains !> Since only processor with rank 0 is in charge of reading - !! the consistency of the user provided inputs, - !! not available to the remaining processors. This - !! then in charge of broadcasting the required - !! + !! and checking the consistency of the user provided inputs, + !! these are not available to the remaining processors. This + !! subroutine is then in charge of broadcasting the required + !! information. impure subroutine s_mpi_bcast_user_inputs #ifdef MFC_MPI - ! loop iterator + ! Generic loop iterator integer :: i, j - ! flag used to identify and report MPI errors + ! Generic flag used to identify and report MPI errors integer :: ierr - ! + ! Logistics call MPI_BCAST(case_dir, len(case_dir), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) #:for VAR in ['t_step_old', 't_step_start', 'm', 'n', 'p', 'm_glb', 'n_glb', 'p_glb', & @@ -124,7 +124,7 @@ contains if (chemistry) then call MPI_BCAST(patch_icpp(i)%Y, size(patch_icpp(i)%Y), mpi_p, 0, MPI_COMM_WORLD, ierr) end if - ! IB variables + ! Broadcast IB variables call MPI_BCAST(patch_ib(i)%geometry, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(patch_ib(i)%model_filepath, len(patch_ib(i)%model_filepath), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(patch_ib(i)%model_threshold, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -141,7 +141,7 @@ contains #:endfor end do - ! noise and fluid physical parameters + ! Simplex noise and fluid physical parameters do i = 1, num_fluids_max #:for VAR in [ 'gamma','pi_inf', 'G', 'cv', 'qv', 'qvp' ] call MPI_BCAST(fluid_pp(i)%${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) @@ -156,7 +156,7 @@ contains end do end do - ! bubble parameters + ! Subgrid bubble parameters if (bubbles_euler .or. bubbles_lagrange) then #:for VAR in [ 'R0ref','p0ref','rho0ref','T0ref', & 'ss','pv','vd','mu_l','mu_v','mu_g','gam_v','gam_g', & diff --git a/src/pre_process/m_perturbation.fpp b/src/pre_process/m_perturbation.fpp index 52abd7c097..ad17cf11d9 100644 --- a/src/pre_process/m_perturbation.fpp +++ b/src/pre_process/m_perturbation.fpp @@ -1,9 +1,9 @@ !> -!! -!! module m_perturbation +!! @file +!! @brief Contains module m_perturbation !> @brief This module contains subroutines that compute perturbations to the -!! flow fields. +!! initial mean flow fields. module m_perturbation use m_derived_types ! Definitions of the derived types @@ -50,11 +50,11 @@ contains perturb_alpha = q_prim_vf(E_idx + perturb_sph_fluid)%sf(i, j, k) - ! partial density fields to match perturbed volume fraction fields - ! ((perturb_alpha >= 25e-2_wp) .AND. (perturb_alpha <= 75e-2_wp)) THEN + ! Perturb partial density fields to match perturbed volume fraction fields + ! IF ((perturb_alpha >= 25e-2_wp) .AND. (perturb_alpha <= 75e-2_wp)) THEN if ((.not. f_approx_equal(perturb_alpha, 0._wp)) .and. (.not. f_approx_equal(perturb_alpha, 1._wp))) then - ! new partial densities + ! Derive new partial densities do l = 1, num_fluids q_prim_vf(l)%sf(i, j, k) = q_prim_vf(E_idx + l)%sf(i, j, k)*fluid_rho(l) end do @@ -74,7 +74,7 @@ contains real(wp) :: rand_real call random_seed() - ! partial density or velocity of surrounding flow by some random small amount of noise + ! Perturb partial density or velocity of surrounding flow by some random small amount of noise do k = 0, p do j = 0, n do i = 0, m @@ -99,10 +99,10 @@ contains do q = 1, elliptic_smoothing_iters - ! of buffer regions and apply boundary conditions + ! Communication of buffer regions and apply boundary conditions call s_populate_variables_buffers(bc_type, q_prim_vf, pb%sf, mv%sf) - ! smoothing and store in temp array + ! Perform smoothing and store in temp array if (n == 0) then do j = 0, m do i = 1, sys_size @@ -138,7 +138,7 @@ contains end do end if - ! smoothed data back to array of scalar fields + ! Copy smoothed data back to array of scalar fields do l = 0, p do k = 0, n do j = 0, m @@ -166,14 +166,14 @@ contains allocate (ofs(nOffsets, num_dims)) - ! offsets + ! Store offsets do i = 1, num_dims do j = 1, num_dims ofs(j, i) = simplex_params%perturb_vel_offset(j, i) end do end do - ! velocities + ! Perturb velocities do i = 1, num_dims if (simplex_params%perturb_vel(i)) then freq = simplex_params%perturb_vel_freq(i) @@ -204,14 +204,14 @@ contains end if end do - ! offsets + ! Store offsets do i = 1, num_dims do j = 1, num_fluids ofs(j, i) = simplex_params%perturb_dens_offset(j, i) end do end do - ! densities + ! Perturb densities do i = 1, num_fluids if (simplex_params%perturb_dens(i)) then freq = simplex_params%perturb_dens_freq(i) @@ -240,10 +240,10 @@ contains end subroutine s_perturb_simplex !> This subroutine computes velocity perturbations for a temporal mixing - !! a hyperbolic tangent mean streamwise velocity - !! an inverter version of the spectrum-based - !! generation method proposed by - !! al. (2023, JFM). + !! layer with a hyperbolic tangent mean streamwise velocity + !! profile, using an inverter version of the spectrum-based + !! synthetic turbulence generation method proposed by + !! Guo et al. (2023, JFM). subroutine s_perturb_mixlayer(q_prim_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf real(wp), dimension(mixlayer_perturb_nk) :: k, Ek @@ -252,10 +252,10 @@ contains real(wp) :: dk, alpha, Eksum, q, uu0, phi integer :: i, j, l, r, ierr - ! parameters + ! Initialize parameters dk = 1._wp/mixlayer_perturb_nk - ! prescribed energy spectra + ! Compute prescribed energy spectra Eksum = 0._wp do i = 1, mixlayer_perturb_nk k(i) = dk*i @@ -263,10 +263,10 @@ contains Eksum = Eksum + Ek(i) end do - ! loop + ! Main loop do r = 0, n - ! prescribed Reynolds stress tensor with about half - ! of its self-similar value + ! Compute prescribed Reynolds stress tensor with about half + ! magnitude of its self-similar value Rij(:, :) = 0._wp uu0 = patch_icpp(1)%vel(1)**2._wp & *(1._wp - tanh(y_cc(r)*mixlayer_vel_coef)**2._wp) @@ -276,7 +276,7 @@ contains Rij(1, 2) = -0.02_wp*uu0 Rij(2, 1) = Rij(1, 2) - ! decomposition for inhomogeneity and anisotropy + ! Cholesky decomposition for inhomogeneity and anisotropy Lmat = 0._wp Lmat(1, 1) = sqrt(Rij(1, 1)) if (abs(Lmat(1, 1)) < sgm_eps) Lmat(1, 1) = sgm_eps @@ -287,10 +287,10 @@ contains Lmat(3, 2) = (Rij(3, 2) - Lmat(3, 1)*Lmat(2, 1))/Lmat(2, 2) Lmat(3, 3) = sqrt(Rij(3, 3) - Lmat(3, 1)**2._wp - Lmat(3, 2)**2._wp) - ! perturbation for each Fourier component + ! Compute perturbation for each Fourier component do i = 1, mixlayer_perturb_nk - ! random numbers for unit wavevector khat, - ! unit vector xi, and random mode phase phi + ! Generate random numbers for unit wavevector khat, + ! random unit vector xi, and random mode phase phi if (proc_rank == 0) then call s_generate_random_perturbation(khat, xi, phi, i, y_cc(r)) end if @@ -301,12 +301,12 @@ contains call MPI_BCAST(phi, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) #endif - ! mode direction by two-time cross product + ! Compute mode direction by two-time cross product sig_tmp = f_cross(xi, khat) sig_tmp = sig_tmp/sqrt(sum(sig_tmp**2._wp)) sig = f_cross(khat, sig_tmp) - ! perturbation for each grid + ! Compute perturbation for each grid do l = 0, p do j = 0, m q = sqrt(Ek(i)/Eksum) @@ -347,7 +347,7 @@ contains end subroutine s_generate_random_perturbation - ! a random unit vector (spherical distribution) + ! Generate a random unit vector (spherical distribution) function f_unit_vector(theta, eta) result(vec) real(wp), intent(in) :: theta, eta real(wp) :: zeta, xi @@ -362,7 +362,7 @@ contains end function f_unit_vector !> This function generates a pseudo-random number between 0 and 1 based on - !! generator. + !! linear congruential generator. subroutine s_prng(var, seed) integer, intent(inout) :: seed real(wp), intent(out) :: var diff --git a/src/pre_process/m_start_up.fpp b/src/pre_process/m_start_up.fpp index 3c19809c52..298092f54b 100644 --- a/src/pre_process/m_start_up.fpp +++ b/src/pre_process/m_start_up.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_start_up +!! @file +!! @brief Contains module m_start_up !> @brief This module contains subroutines that read, and check consistency -!! user provided inputs, grid and data. This module also allocates -!! the relevant variables sets up the mpi decomposition and -!! procedures. +!! of, the user provided inputs, grid and data. This module also allocates +!! and initializes the relevant variables sets up the mpi decomposition and +!! initial condition procedures. module m_start_up use m_derived_types !< Definitions of the derived types @@ -17,14 +17,14 @@ module m_start_up use m_mpi_common use m_variables_conversion !< Subroutines to change the state variables from - !! to another + !! one form to another use m_grid !< Procedures to generate (non-)uniform grids use m_initial_condition !< Procedures to generate initial condition use m_data_output !< Procedures to write the grid data and the - !! to files + !! conservative variables to files use m_compile_specific !< Compile-specific procedures @@ -82,8 +82,8 @@ module m_start_up end subroutine s_read_abstract_grid_data_files - !! Conservative variables - !! track if a cell is within the immersed boundary + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary impure subroutine s_read_abstract_ic_data_files(q_cons_vf_in, ib_markers_in) import :: scalar_field, integer_field, sys_size, pres_field @@ -100,11 +100,11 @@ module m_start_up end interface character(LEN=path_len + name_len) :: proc_rank_dir !< - !! the folder associated with the rank of the local processor + !! Location of the folder associated with the rank of the local processor character(LEN=path_len + 2*name_len), private :: t_step_dir !< - !! of time-step folder containing preexisting grid and/or - !! data to be used as starting point for pre-process + !! Possible location of time-step folder containing preexisting grid and/or + !! conservative variables data to be used as starting point for pre-process procedure(s_read_abstract_grid_data_files), pointer :: s_read_grid_data_files => null() procedure(s_read_abstract_ic_data_files), pointer :: s_read_ic_data_files => null() @@ -112,23 +112,23 @@ module m_start_up contains !> Reads the configuration file pre_process.inp, in order to - !! parameters in module m_global_parameters.f90 - !! user provided inputs + !! populate the parameters in module m_global_parameters.f90 + !! with the user provided inputs impure subroutine s_read_input_file character(LEN=name_len) :: file_loc !< - !! used to store the address of a particular file + !! Generic string used to store the address of a particular file logical :: file_check !< - !! used for the purpose of asserting whether a file - !! is not present in the designated location + !! Generic logical used for the purpose of asserting whether a file + !! is or is not present in the designated location integer :: iostatus - !! check iostat of file read + !! Integer to check iostat of file read character(len=1000) :: line - ! for all of the parameters to be inputted by the user + ! Namelist for all of the parameters to be inputted by the user namelist /user_inputs/ case_dir, old_grid, old_ic, & t_step_old, t_step_start, m, n, p, x_domain, y_domain, z_domain, & stretch_x, stretch_y, stretch_z, a_x, a_y, & @@ -155,12 +155,12 @@ contains down_sample, recon_type, muscl_order, hyper_cleaning, & simplex_perturb, simplex_params, fft_wrt - ! the status of the pre_process.inp file + ! Inquiring the status of the pre_process.inp file file_loc = 'pre_process.inp' inquire (FILE=trim(file_loc), EXIST=file_check) - ! whether the input file is there. If it is, the input file - ! read. If not, the program is terminated. + ! Checking whether the input file is there. If it is, the input file + ! is read. If not, the program is terminated. if (file_check) then open (1, FILE=trim(file_loc), FORM='formatted', & STATUS='old', ACTION='read') @@ -176,7 +176,7 @@ contains call s_update_cell_bounds(cells_bounds, m, n, p) - ! m,n,p into global m,n,p + ! Store m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -197,18 +197,18 @@ contains end subroutine s_read_input_file !> Checking that the user inputs make sense, i.e. that the - !! are compatible with the code's options - !! the combination of these choices results into a - !! for the pre-process + !! individual choices are compatible with the code's options + !! and that the combination of these choices results into a + !! valid configuration for the pre-process impure subroutine s_check_input_file character(LEN=len_trim(case_dir)) :: file_loc !< - !! used to store the address of a particular file + !! Generic string used to store the address of a particular file logical :: dir_check !< - !! used to test the existence of folders + !! Logical variable used to test the existence of folders - ! the existence of the case folder + ! Checking the existence of the case folder case_dir = adjustl(case_dir) file_loc = trim(case_dir)//'/.' @@ -225,7 +225,7 @@ contains call s_check_inputs_common() call s_check_inputs() - ! all the patch properties + ! Check all the patch properties call s_check_patches() if (ib) call s_check_ib_patches() @@ -233,44 +233,44 @@ contains end subroutine s_check_input_file !> The goal of this subroutine is to read in any preexisting - !! as well as based on the imported grid, complete - !! global computational domain parameters. + !! grid data as well as based on the imported grid, complete + !! the necessary global computational domain parameters. impure subroutine s_read_serial_grid_data_files - ! string used to store the address of a particular file + ! Generic string used to store the address of a particular file character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc - ! variable used to test the existence of folders + ! Logical variable used to test the existence of folders logical :: dir_check - ! logical used for the purpose of asserting whether a file - ! or is not present in the designated location + ! Generic logical used for the purpose of asserting whether a file + ! is or is not present in the designated location logical :: file_check - ! address of the local processor rank and time-step directory + ! Setting address of the local processor rank and time-step directory write (proc_rank_dir, '(A,I0)') '/p_all/p', proc_rank proc_rank_dir = trim(case_dir)//trim(proc_rank_dir) write (t_step_dir, '(A,I0)') '/', t_step_start t_step_dir = trim(proc_rank_dir)//trim(t_step_dir) - ! as to the existence of the time-step directory + ! Inquiring as to the existence of the time-step directory file_loc = trim(t_step_dir)//'/.' call my_inquire(file_loc, dir_check) - ! the time-step directory is missing, the pre-process exits + ! If the time-step directory is missing, the pre-process exits if (dir_check .neqv. .true.) then call s_mpi_abort('Time-step folder '//trim(t_step_dir)// & ' is missing. Exiting.') end if - ! the Grid Data File for the x-direction + ! Reading the Grid Data File for the x-direction - ! whether x_cb.dat exists + ! Checking whether x_cb.dat exists file_loc = trim(t_step_dir)//'/x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, x_cb.dat is read + ! If it exists, x_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -281,26 +281,26 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! cell-center locations + ! Computing cell-center locations x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp - ! minimum cell-width + ! Computing minimum cell-width dx = minval(x_cb(0:m) - x_cb(-1:m - 1)) if (num_procs > 1) call s_mpi_reduce_min(dx) - ! locations of domain bounds + ! Setting locations of domain bounds x_domain%beg = x_cb(-1) x_domain%end = x_cb(m) - ! the Grid Data File for the y-direction + ! Reading the Grid Data File for the y-direction if (n > 0) then - ! whether y_cb.dat exists + ! Checking whether y_cb.dat exists file_loc = trim(t_step_dir)//'/y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, y_cb.dat is read + ! If it exists, y_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -311,25 +311,25 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! cell-center locations + ! Computing cell-center locations y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp - ! minimum cell-width + ! Computing minimum cell-width dy = minval(y_cb(0:n) - y_cb(-1:n - 1)) if (num_procs > 1) call s_mpi_reduce_min(dy) - ! locations of domain bounds + ! Setting locations of domain bounds y_domain%beg = y_cb(-1) y_domain%end = y_cb(n) - ! the Grid Data File for the z-direction + ! Reading the Grid Data File for the z-direction if (p > 0) then - ! whether z_cb.dat exists + ! Checking whether z_cb.dat exists file_loc = trim(t_step_dir)//'/z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, z_cb.dat is read + ! If it exists, z_cb.dat is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -340,14 +340,14 @@ contains trim(t_step_dir)//'. Exiting.') end if - ! cell-center locations + ! Computing cell-center locations z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp - ! minimum cell-width + ! Computing minimum cell-width dz = minval(z_cb(0:p) - z_cb(-1:p - 1)) if (num_procs > 1) call s_mpi_reduce_min(dz) - ! locations of domain bounds + ! Setting locations of domain bounds z_domain%beg = z_cb(-1) z_domain%end = z_cb(p) @@ -355,12 +355,12 @@ contains end if - ! only the preexisting grid data files are read in and there will - ! be any preexisting initial condition data files imported, then - ! directory associated with the rank of the local processor may - ! cleaned to make room for the new pre-process data. In addition, - ! time-step directory that will contain the new grid and initial - ! data are also generated. + ! If only the preexisting grid data files are read in and there will + ! not be any preexisting initial condition data files imported, then + ! the directory associated with the rank of the local processor may + ! be cleaned to make room for the new pre-process data. In addition, + ! the time-step directory that will contain the new grid and initial + ! condition data are also generated. if (old_ic .neqv. .true.) then call s_delete_directory(trim(proc_rank_dir)//'/*') call s_create_directory(trim(proc_rank_dir)//'/0') @@ -369,19 +369,19 @@ contains end subroutine s_read_serial_grid_data_files !> Cell-boundary data are checked for consistency by looking - !! (non-)uniform cell-width distributions for all the - !! directions and making sure that all of - !! are positively valued + !! at the (non-)uniform cell-width distributions for all the + !! active coordinate directions and making sure that all of + !! the cell-widths are positively valued impure subroutine s_check_grid_data_files - ! Data Consistency Check in x-direction + ! Cell-boundary Data Consistency Check in x-direction if (any(x_cb(0:m) - x_cb(-1:m - 1) <= 0._wp)) then call s_mpi_abort('x_cb.dat in '//trim(t_step_dir)// & ' contains non-positive cell-spacings. Exiting.') end if - ! Data Consistency Check in y-direction + ! Cell-boundary Data Consistency Check in y-direction if (n > 0) then @@ -391,7 +391,7 @@ contains 'Exiting.') end if - ! Data Consistency Check in z-direction + ! Cell-boundary Data Consistency Check in z-direction if (p > 0) then @@ -408,11 +408,11 @@ contains end subroutine s_check_grid_data_files !> The goal of this subroutine is to read in any preexisting - !! data files so that they may be used by - !! as a starting point in the creation of an - !! initial condition. - !! Conservative variables - !! track if a cell is within the immersed boundary + !! initial condition data files so that they may be used by + !! the pre-process as a starting point in the creation of an + !! all new initial condition. + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary impure subroutine s_read_serial_ic_data_files(q_cons_vf_in, ib_markers_in) type(scalar_field), & @@ -423,30 +423,30 @@ contains intent(inout) :: ib_markers_in character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc !< - ! string used to store the address of a particular file + ! Generic string used to store the address of a particular file character(LEN= & int(floor(log10(real(sys_size, wp)))) + 1) :: file_num !< - !! store the variable position, in character form, of the - !! conservative variable file + !! Used to store the variable position, in character form, of the + !! currently manipulated conservative variable file logical :: file_check !< - !! used for the purpose of asserting whether a file - !! is not present in the designated location + !! Generic logical used for the purpose of asserting whether a file + !! is or is not present in the designated location integer :: i, r !< Generic loop iterator - ! the Conservative Variables Data Files + ! Reading the Conservative Variables Data Files do i = 1, sys_size - ! whether data file associated with variable position - ! the currently manipulated conservative variable exists + ! Checking whether data file associated with variable position + ! of the currently manipulated conservative variable exists write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/q_cons_vf'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, the data file is read + ! If it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -464,14 +464,14 @@ contains if (qbmm .and. .not. polytropic) then do i = 1, nb do r = 1, nnode - ! whether data file associated with variable position - ! the currently manipulated bubble variable exists + ! Checking whether data file associated with variable position + ! of the currently manipulated bubble variable exists write (file_num, '(I0)') sys_size + r + (i - 1)*nnode file_loc = trim(t_step_dir)//'/pb'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, the data file is read + ! If it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -488,14 +488,14 @@ contains do i = 1, nb do r = 1, 4 - ! whether data file associated with variable position - ! the currently manipulated bubble variable exists + ! Checking whether data file associated with variable position + ! of the currently manipulated bubble variable exists write (file_num, '(I0)') sys_size + r + (i - 1)*4 file_loc = trim(t_step_dir)//'/mv'// & trim(file_num)//'.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, the data file is read + ! If it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -511,13 +511,13 @@ contains end do end if - ! the IB markers + ! Reading the IB markers if (ib) then write (file_num, '(I0)') i file_loc = trim(t_step_dir)//'/ib.dat' inquire (FILE=trim(file_loc), EXIST=file_check) - ! it exists, the data file is read + ! If it exists, the data file is read if (file_check) then open (1, FILE=trim(file_loc), FORM='unformatted', & STATUS='old', ACTION='read') @@ -530,20 +530,20 @@ contains end if end if - ! the preexisting grid and initial condition data files have - ! read in, the directory associated with the rank of the local - ! may be cleaned out to make room for new pre-process data. - ! addition, the time-step folder that will contain the new grid - ! initial condition data are also generated. + ! Since the preexisting grid and initial condition data files have + ! been read in, the directory associated with the rank of the local + ! process may be cleaned out to make room for new pre-process data. + ! In addition, the time-step folder that will contain the new grid + ! and initial condition data are also generated. call s_create_directory(trim(proc_rank_dir)//'/*') call s_create_directory(trim(proc_rank_dir)//'/0') end subroutine s_read_serial_ic_data_files !> Cell-boundary data are checked for consistency by looking - !! (non-)uniform cell-width distributions for all the - !! directions and making sure that all of - !! are positively valued + !! at the (non-)uniform cell-width distributions for all the + !! active coordinate directions and making sure that all of + !! the cell-widths are positively valued impure subroutine s_read_parallel_grid_data_files #ifdef MFC_MPI @@ -560,7 +560,7 @@ contains allocate (y_cb_glb(-1:n_glb)) allocate (z_cb_glb(-1:p_glb)) - ! in cell boundary locations in x-direction + ! Read in cell boundary locations in x-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -573,19 +573,19 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! local cell boundary locations + ! Assigning local cell boundary locations x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m)) - ! cell center locations + ! Computing cell center locations x_cc(0:m) = (x_cb(0:m) + x_cb(-1:(m - 1)))/2._wp - ! minimum cell width + ! Computing minimum cell width dx = minval(x_cb(0:m) - x_cb(-1:(m - 1))) if (num_procs > 1) call s_mpi_reduce_min(dx) - ! locations of domain bounds + ! Setting locations of domain bounds x_domain%beg = x_cb(-1) x_domain%end = x_cb(m) if (n > 0) then - ! in cell boundary locations in y-direction + ! Read in cell boundary locations in y-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -598,19 +598,19 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! local cell boundary locations + ! Assigning local cell boundary locations y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n)) - ! cell center locations + ! Computing cell center locations y_cc(0:n) = (y_cb(0:n) + y_cb(-1:(n - 1)))/2._wp - ! minimum cell width + ! Computing minimum cell width dy = minval(y_cb(0:n) - y_cb(-1:(n - 1))) if (num_procs > 1) call s_mpi_reduce_min(dy) - ! locations of domain bounds + ! Setting locations of domain bounds y_domain%beg = y_cb(-1) y_domain%end = y_cb(n) if (p > 0) then - ! in cell boundary locations in z-direction + ! Read in cell boundary locations in z-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -623,14 +623,14 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting. ') end if - ! local cell boundary locations + ! Assigning local cell boundary locations z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p)) - ! cell center locations + ! Computing cell center locations z_cc(0:p) = (z_cb(0:p) + z_cb(-1:(p - 1)))/2._wp - ! minimum cell width + ! Computing minimum cell width dz = minval(z_cb(0:p) - z_cb(-1:(p - 1))) if (num_procs > 1) call s_mpi_reduce_min(dz) - ! locations of domain bounds + ! Setting locations of domain bounds z_domain%beg = z_cb(-1) z_domain%end = z_cb(p) @@ -644,11 +644,11 @@ contains end subroutine s_read_parallel_grid_data_files !> The goal of this subroutine is to read in any preexisting - !! data files so that they may be used by - !! as a starting point in the creation of an - !! initial condition. - !! Conservative variables - !! track if a cell is within the immersed boundary + !! initial condition data files so that they may be used by + !! the pre-process as a starting point in the creation of an + !! all new initial condition. + !! @param q_cons_vf Conservative variables + !! @param ib_markers track if a cell is within the immersed boundary impure subroutine s_read_parallel_ic_data_files(q_cons_vf_in, ib_markers_in) type(scalar_field), & @@ -673,7 +673,7 @@ contains integer :: i - ! the file to read + ! Open the file to read if (cfl_adap_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -685,17 +685,17 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! MPI data I/O + ! Initialize MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf_in, ib_markers_in, levelset, levelset_norm) else call s_initialize_mpi_data(q_cons_vf_in) end if - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! some integers so MPI can read even the biggest files + ! Resize some integers so MPI can read even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -704,11 +704,11 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! the data for each variable + ! Read the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -721,7 +721,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*4 var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -769,8 +769,8 @@ contains end subroutine s_read_parallel_ic_data_files impure subroutine s_initialize_modules - ! of parameters, allocation procedures, and/or any other tasks - ! to properly setup the modules + ! Computation of parameters, allocation procedures, and/or any other tasks + ! needed to properly setup the modules call s_initialize_global_parameters_module() if (bubbles_euler .or. bubbles_lagrange) then call s_initialize_bubbles_model() @@ -785,11 +785,11 @@ contains call s_initialize_boundary_common_module() if (relax) call s_initialize_phasechange_module() - ! the D directory if it doesn't exit, to store - ! serial data files + ! Create the D directory if it doesn't exit, to store + ! the serial data files call s_create_directory('D') - ! pointers for serial or parallel I/O + ! Associate pointers for serial or parallel I/O if (parallel_io .neqv. .true.) then s_generate_grid => s_generate_serial_grid s_read_grid_data_files => s_read_serial_grid_data_files @@ -828,23 +828,23 @@ contains integer :: j, k - ! up the grid and the initial condition. If the grid is read in from - ! grid data files, it is checked for consistency. If the grid is - ! read in, it is generated from scratch according to the inputs provided - ! the user. The initial condition may also be read in. It in turn is not - ! for consistency since it WILL further be edited by the pre-process - ! also because it may be incomplete at the time it is read in. Finally, - ! the grid and initial condition are completely setup, they are written - ! their respective data files. + ! Setting up the grid and the initial condition. If the grid is read in from + ! preexisting grid data files, it is checked for consistency. If the grid is + ! not read in, it is generated from scratch according to the inputs provided + ! by the user. The initial condition may also be read in. It in turn is not + ! checked for consistency since it WILL further be edited by the pre-process + ! and also because it may be incomplete at the time it is read in. Finally, + ! when the grid and initial condition are completely setup, they are written + ! to their respective data files. - ! up grid and initial condition + ! Setting up grid and initial condition call cpu_time(start) if (old_ic) call s_read_ic_data_files(q_cons_vf, ib_markers) call s_generate_initial_condition() - ! psi + ! hard-coded psi if (hyper_cleaning) then do j = 0, m do k = 0, n @@ -907,14 +907,14 @@ contains end subroutine s_save_data impure subroutine s_initialize_mpi_domain - ! of the MPI environment + ! Initialization of the MPI environment call s_mpi_initialize() - ! 0 processor assigns default values to user inputs prior to reading - ! in from the input file. Next, the user inputs are read in and their - ! is checked. The detection of any inconsistencies automatically - ! to the termination of the pre-process. + ! Rank 0 processor assigns default values to user inputs prior to reading + ! those in from the input file. Next, the user inputs are read in and their + ! consistency is checked. The detection of any inconsistencies automatically + ! leads to the termination of the pre-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() @@ -924,22 +924,22 @@ contains print '(" Pre-processing a ", I0, "x", I0, "x", I0, " case on ", I0, " rank(s)")', m, n, p, num_procs end if - ! the user inputs to all of the processors and performing the - ! computational domain decomposition. Neither procedure has to be - ! out if pre-process is in fact not truly executed in parallel. + ! Broadcasting the user inputs to all of the processors and performing the + ! parallel computational domain decomposition. Neither procedure has to be + ! carried out if pre-process is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() call s_initialize_parallel_io() call s_mpi_decompose_computational_domain() end subroutine s_initialize_mpi_domain impure subroutine s_finalize_modules - ! pointers for serial and parallel I/O + ! Disassociate pointers for serial and parallel I/O s_generate_grid => null() s_read_grid_data_files => null() s_read_ic_data_files => null() s_write_data_files => null() - ! procedures for the modules + ! Deallocation procedures for the modules call s_finalize_mpi_common_module() call s_finalize_grid_module() call s_finalize_variables_conversion_module() @@ -950,7 +950,7 @@ contains call s_finalize_boundary_common_module() if (relax) call s_finalize_relaxation_solver_module() call s_finalize_initial_condition_module() - ! of the MPI environment + ! Finalization of the MPI environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/pre_process/p_main.f90 b/src/pre_process/p_main.f90 index 4ce377f5cb..9197eecf8f 100644 --- a/src/pre_process/p_main.f90 +++ b/src/pre_process/p_main.f90 @@ -1,5 +1,5 @@ !> -!! @file p_main.f90 +!! @file !! @brief Contains program p_main !> @brief This program takes care of setting up the initial condition and diff --git a/src/simulation/include/inline_riemann.fpp b/src/simulation/include/inline_riemann.fpp index b05438ef94..d8d0cc87c7 100644 --- a/src/simulation/include/inline_riemann.fpp +++ b/src/simulation/include/inline_riemann.fpp @@ -55,11 +55,11 @@ T_avg = (sqrt(rho_L)*T_L + sqrt(rho_R)*T_R)/(sqrt(rho_L) + sqrt(rho_R)) #:if USING_AMD if (abs(T_L - T_R) < eps) then - ! when T_L and T_R are very close + ! Case when T_L and T_R are very close Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights_nonparameter(:)) Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights_nonparameter(:) - gas_constant/molecular_weights_nonparameter(:))) else - ! calculation when T_L and T_R are sufficiently different + ! Normal calculation when T_L and T_R are sufficiently different Cp_avg = sum(Yi_avg(:)*(h_iR(:) - h_iL(:))/(T_R - T_L)) Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/molecular_weights_nonparameter(:))) end if @@ -69,11 +69,11 @@ c_sum_Yi_Phi = sum(Yi_avg(:)*Phi_avg(:)) #:else if (abs(T_L - T_R) < eps) then - ! when T_L and T_R are very close + ! Case when T_L and T_R are very close Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:)) Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:) - gas_constant/molecular_weights(:))) else - ! calculation when T_L and T_R are sufficiently different + ! Normal calculation when T_L and T_R are sufficiently different Cp_avg = sum(Yi_avg(:)*(h_iR(:) - h_iL(:))/(T_R - T_L)) Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/molecular_weights(:))) end if diff --git a/src/simulation/m_acoustic_src.fpp b/src/simulation/m_acoustic_src.fpp index 63c7ee0ae6..3a3a080578 100644 --- a/src/simulation/m_acoustic_src.fpp +++ b/src/simulation/m_acoustic_src.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_acoustic_src +!! @file +!! @brief Contains module m_acoustic_src #:include 'macros.fpp' @@ -124,15 +124,21 @@ contains end subroutine s_initialize_acoustic_src !> This subroutine updates the rhs by computing the mass, mom, energy sources - !! @param[inout] q_cons_vf Conservative variables. - !! @param[inout] q_prim_vf Primitive variables. - !! @param[in] t_step Current time step. - !! @param[inout] rhs_vf Right-hand side source terms. + !! @param q_cons_vf Conservative variables + !! @param q_prim_vf Primitive variables + !! @param t_step Current time step + !! @param rhs_vf rhs variables impure subroutine s_acoustic_src_calculations(q_cons_vf, q_prim_vf, t_step, rhs_vf) - type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf + type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf !< + !! This variable contains the WENO-reconstructed values of the cell-average + !! conservative variables, which are located in q_cons_vf, at cell-interior + !! Gaussian quadrature points (QP). - type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf + type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf !< + !! The primitive variables at cell-interior Gaussian quadrature points. These + !! are calculated from the conservative variables and gradient magnitude (GM) + !! of the volume fractions, q_cons_qp and gm_alpha_qp, respectively. type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf @@ -177,41 +183,41 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! outer loop sequel because different sources can have very different number of points + ! Keep outer loop sequel because different sources can have very different number of points do ai = 1, num_source - ! if the pulse has not started yet for sine and square waves + ! Skip if the pulse has not started yet for sine and square waves if (.not. (sim_time < delay(ai) .and. (pulse(ai) == 1 .or. pulse(ai) == 3))) then - ! if frequency need to be converted from wavelength + ! Decide if frequency need to be converted from wavelength freq_conv_flag = f_is_default(frequency(ai)) gauss_conv_flag = f_is_default(gauss_sigma_time(ai)) num_points = source_spatials_num_points(ai) ! Use scalar to force firstprivate to prevent GPU bug - ! the broadband source + ! Calculate the broadband source period_BB = 0._wp sl_BB = 0._wp ffre_BB = 0._wp sum_BB = 0._wp - ! buffers for random phase shift + ! Allocate buffers for random phase shift allocate (phi_rn(1:bb_num_freq(ai))) phi_rn(1:bb_num_freq(ai)) = 0._wp if (pulse(ai) == 4) then call random_number(phi_rn(1:bb_num_freq(ai))) - ! all the ranks have the same random phase shift + ! Ensure all the ranks have the same random phase shift call s_mpi_send_random_number(phi_rn, bb_num_freq(ai)) end if do k = 1, bb_num_freq(ai) - ! period of the wave at each discrete frequency + ! Acoustic period of the wave at each discrete frequency period_BB = 1._wp/(bb_lowest_freq(ai) + k*bb_bandwidth(ai)) - ! level at each frequency + ! Spectral level at each frequency sl_BB = broadband_spectral_level_constant*mag(ai) + k*mag(ai)/broadband_spectral_level_growth_rate - ! term corresponding to each frequencies + ! Source term corresponding to each frequencies ffre_BB = sqrt((2._wp*sl_BB*bb_bandwidth(ai)))*cos((sim_time)*2._wp*pi/period_BB + 2._wp*pi*phi_rn(k)) - ! up the source term of each frequency to obtain the total source term for broadband wave + ! Sum up the source term of each frequency to obtain the total source term for broadband wave sum_BB = sum_BB + ffre_BB end do @@ -223,7 +229,7 @@ contains k = source_spatials(ai)%coord(2, i) l = source_spatials(ai)%coord(3, i) - ! speed of sound + ! Compute speed of sound myRho = 0._wp B_tait = 0._wp small_gamma = 0._wp @@ -261,11 +267,11 @@ contains small_gamma = 1._wp/small_gamma + 1._wp c = sqrt(small_gamma*(q_prim_vf(E_idx)%sf(j, k, l) + ((small_gamma - 1._wp)/small_gamma)*B_tait)/myRho) - ! to frequency conversion + ! Wavelength to frequency conversion if (pulse(ai) == 1 .or. pulse(ai) == 3) frequency_local = f_frequency_local(freq_conv_flag, ai, c) if (pulse(ai) == 2) gauss_sigma_time_local = f_gauss_sigma_time_local(gauss_conv_flag, ai, c) - ! momentum source term + ! Update momentum source term call s_source_temporal(sim_time, c, ai, mom_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB) mom_src_diff = source_temporal*source_spatials(ai)%val(i) @@ -298,17 +304,17 @@ contains end if end if - ! mass source term + ! Update mass source term if (support(ai) < 5) then ! Planar mass_src_diff = mom_src_diff/c else ! Spherical or cylindrical support - ! source term must be calculated differently using a correction term for spherical and cylindrical support + ! Mass source term must be calculated differently using a correction term for spherical and cylindrical support call s_source_temporal(sim_time, c, ai, mass_label, frequency_local, gauss_sigma_time_local, source_temporal, sum_BB) mass_src_diff = source_temporal*source_spatials(ai)%val(i) end if mass_src(j, k, l) = mass_src(j, k, l) + mass_src_diff - ! energy source term + ! Update energy source term if (model_eqns /= 4) then E_src(j, k, l) = E_src(j, k, l) + mass_src_diff*c**2._wp/(small_gamma - 1._wp) end if @@ -318,7 +324,7 @@ contains end if end do - ! the rhs variables + ! Update the rhs variables $:GPU_PARALLEL_LOOP(private='[j,k,l]',collapse=3) do l = 0, p do k = 0, n @@ -339,13 +345,13 @@ contains end subroutine s_acoustic_src_calculations !> This subroutine gives the temporally varying amplitude of the pulse - !! Simulation time - !! Sound speed - !! Acoustic source index - !! Index of the term to be calculated (1: mass source, 2: momentum source) - !! Frequency at the spatial location for sine and square waves - !! sigma in time for Gaussian pulse - !! Source term amplitude + !! @param sim_time Simulation time + !! @param c Sound speed + !! @param ai Acoustic source index + !! @param term_index Index of the term to be calculated (1: mass source, 2: momentum source) + !! @param frequency_local Frequency at the spatial location for sine and square waves + !! @param gauss_sigma_time_local sigma in time for Gaussian pulse + !! @param source Source term amplitude elemental subroutine s_source_temporal(sim_time, c, ai, term_index, frequency_local, gauss_sigma_time_local, source, sum_BB) $:GPU_ROUTINE(parallelism='[seq]') integer, intent(in) :: ai, term_index @@ -356,7 +362,7 @@ contains real(wp) :: omega ! angular frequency real(wp) :: sine_wave ! sine function for square wave real(wp) :: foc_length_factor ! Scale amplitude with radius for spherical support - ! Spherical support -> 1/r scaling; Cylindrical support -> 1/sqrt(r) [empirical correction: ^-0.5 -> ^-0.85] + ! i.e. Spherical support -> 1/r scaling; Cylindrical support -> 1/sqrt(r) [empirical correction: ^-0.5 -> ^-0.85] integer, parameter :: mass_label = 1 if (n == 0) then @@ -395,7 +401,7 @@ contains sine_wave = sin((sim_time - delay(ai))*omega) source = mag(ai)*sign(1._wp, sine_wave) - ! max-norm differences due to compilers to pass CI + ! Prevent max-norm differences due to compilers to pass CI if (abs(sine_wave) < 1.e-2_wp) then source = mag(ai)*sine_wave*1.e2_wp end if @@ -425,7 +431,7 @@ contains @:ALLOCATE(source_spatials(1:num_source)) do ai = 1, num_source - ! pass: Count the number of points for each source + ! First pass: Count the number of points for each source count = 0 do l = 0, p do k = 0, n @@ -438,7 +444,7 @@ contains end do source_spatials_num_points(ai) = count - ! arrays with the correct size + ! Allocate arrays with the correct size @:ALLOCATE(source_spatials(ai)%coord(1:3, 1:count)) @:ALLOCATE(source_spatials(ai)%val(1:count)) @@ -447,7 +453,7 @@ contains @:ACC_SETUP_source_spatials(source_spatials(ai)) - ! pass: Store the values + ! Second pass: Store the values count = 0 ! Reset counter do l = 0, p do k = 0, n @@ -494,14 +500,14 @@ contains end subroutine s_precalculate_acoustic_spatial_sources !> This subroutine gives the spatial support of the acoustic source - !! x-index - !! y-index - !! z-index - !! Nominal source term location - !! Acoustic source index - !! Source term amplitude - !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! @param j x-index + !! @param k y-index + !! @param l z-index + !! @param loc Nominal source term location + !! @param ai Acoustic source index + !! @param source Source term amplitude + !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial(j, k, l, loc, ai, source, angle, xyz_to_r_ratios) integer, intent(in) :: j, k, l, ai real(wp), dimension(3), intent(in) :: loc @@ -509,7 +515,7 @@ contains real(wp) :: sig, r(3) - ! sig spatial support width + ! Calculate sig spatial support width if (n == 0) then sig = dx(j) elseif (p == 0) then @@ -519,7 +525,7 @@ contains end if sig = sig*acoustic_spatial_support_width - ! displacement from acoustic source location + ! Calculate displacement from acoustic source location r(1) = x_cc(j) - loc(1) if (n /= 0) r(2) = y_cc(k) - loc(2) if (p /= 0) r(3) = z_cc(l) - loc(3) @@ -534,10 +540,10 @@ contains end subroutine s_source_spatial !> This subroutine calculates the spatial support for planar acoustic sources in 1D, 2D, and 3D - !! Acoustic source index - !! Sigma value for the Gaussian distribution - !! Displacement from source to current point - !! Source term amplitude + !! @param ai Acoustic source index + !! @param sig Sigma value for the Gaussian distribution + !! @param r Displacement from source to current point + !! @param source Source term amplitude subroutine s_source_spatial_planar(ai, sig, r, source) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -551,7 +557,7 @@ contains source = 1._wp/(sqrt(2._wp*pi)*sig/2._wp)*exp(-0.5_wp*(r(1)/(sig/2._wp))**2._wp) elseif (support(ai) == 2 .or. support(ai) == 3) then ! 2D or 3D - ! we let unit vector e = (cos(dir), sin(dir)), + ! If we let unit vector e = (cos(dir), sin(dir)), dist = r(1)*cos(dir(ai)) + r(2)*sin(dir(ai)) ! dot(r,e) if ((r(1) - dist*cos(dir(ai)))**2._wp + (r(2) - dist*sin(dir(ai)))**2._wp < 0.25_wp*length(ai)**2._wp) then ! |r - dist*e| < length/2 if (support(ai) /= 3 .or. abs(r(3)) < 0.25_wp*height(ai)) then ! additional height constraint for 3D @@ -562,12 +568,12 @@ contains end subroutine s_source_spatial_planar !> This subroutine calculates the spatial support for a single transducer in 2D, 2D axisymmetric, and 3D - !! Acoustic source index - !! Sigma value for the Gaussian distribution - !! Displacement from source to current point - !! Source term amplitude - !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! @param ai Acoustic source index + !! @param sig Sigma value for the Gaussian distribution + !! @param r Displacement from source to current point + !! @param source Source term amplitude + !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial_transducer(ai, sig, r, source, angle, xyz_to_r_ratios) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -607,12 +613,12 @@ contains end subroutine s_source_spatial_transducer !> This subroutine calculates the spatial support for multiple transducers in 2D, 2D axisymmetric, and 3D - !! Acoustic source index - !! Sigma value for the Gaussian distribution - !! Displacement from source to current point - !! Source term amplitude - !! Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) - !! Ratios of the [xyz]-component of the source term to the magnitude (for 3D) + !! @param ai Acoustic source index + !! @param sig Sigma value for the Gaussian distribution + !! @param r Displacement from source to current point + !! @param source Source term amplitude + !! @param angle Angle of the source term with respect to the x-axis (for 2D or 2D axisymmetric) + !! @param xyz_to_r_ratios Ratios of the [xyz]-component of the source term to the magnitude (for 3D) subroutine s_source_spatial_transducer_array(ai, sig, r, source, angle, xyz_to_r_ratios) integer, intent(in) :: ai real(wp), intent(in) :: sig, r(3) @@ -662,13 +668,13 @@ contains do elem = elem_min, elem_max angle_elem = 2._wp*pi*real(elem, wp)/real(num_elements(ai), wp) + rotate_angle(ai) - ! 2 is the elem center + ! Point 2 is the elem center x2 = f - sqrt(f**2 - half_apert**2) y2 = half_apert*cos(angle_elem) z2 = half_apert*sin(angle_elem) - ! a plane normal to the line from the focal point to the elem center, - ! 3 is the intercept of the plane and the line from the focal point to the current location + ! Construct a plane normal to the line from the focal point to the elem center, + ! Point 3 is the intercept of the plane and the line from the focal point to the current location C = f**2._wp/((r(1) - f)*(x2 - f) + r(2)*y2 + r(3)*z2) ! Constant for intermediate step x3 = C*(r(1) - f) + f y3 = C*r(2) @@ -691,10 +697,10 @@ contains end subroutine s_source_spatial_transducer_array !> This function performs wavelength to frequency conversion - !! Determines if frequency is given or wavelength - !! Acoustic source index - !! Speed of sound - !! Converted frequency + !! @param freq_conv_flag Determines if frequency is given or wavelength + !! @param ai Acoustic source index + !! @param c Speed of sound + !! @return frequency_local Converted frequency elemental function f_frequency_local(freq_conv_flag, ai, c) $:GPU_ROUTINE(parallelism='[seq]') logical, intent(in) :: freq_conv_flag @@ -710,10 +716,10 @@ contains end function f_frequency_local !> This function performs Gaussian sigma dist to time conversion - !! Determines if sigma_dist is given or sigma_time - !! Speed of sound - !! Acoustic source index - !! Converted Gaussian sigma time + !! @param gauss_conv_flag Determines if sigma_dist is given or sigma_time + !! @param c Speed of sound + !! @param ai Acoustic source index + !! @return gauss_sigma_time_local Converted Gaussian sigma time function f_gauss_sigma_time_local(gauss_conv_flag, ai, c) $:GPU_ROUTINE(parallelism='[seq]') logical, intent(in) :: gauss_conv_flag diff --git a/src/simulation/m_body_forces.fpp b/src/simulation/m_body_forces.fpp index f53e42113e..cdf35fd366 100644 --- a/src/simulation/m_body_forces.fpp +++ b/src/simulation/m_body_forces.fpp @@ -10,7 +10,7 @@ module m_body_forces use m_nvtx -! +! $:USE_GPU_MODULE() implicit none @@ -25,23 +25,23 @@ module m_body_forces contains !> This subroutine initializes the module global array of mixture - !! each grid cell + !! densities in each grid cell impure subroutine s_initialize_body_forces_module - ! is at least 2D + ! Simulation is at least 2D if (n > 0) then - ! is 3D + ! Simulation is 3D if (p > 0) then @:ALLOCATE (rhoM(-buff_size:buff_size + m, & -buff_size:buff_size + n, & -buff_size:buff_size + p)) - ! is 2D + ! Simulation is 2D else @:ALLOCATE (rhoM(-buff_size:buff_size + m, & -buff_size:buff_size + n, & 0:0)) end if - ! is 1D + ! Simulation is 1D else @:ALLOCATE (rhoM(-buff_size:buff_size + m, & 0:0, & @@ -66,8 +66,8 @@ contains end subroutine s_compute_acceleration !> This subroutine calculates the mixture density at each cell - !! - !! Conservative variable + !! center + !! param q_cons_vf Conservative variable subroutine s_compute_mixture_density(q_cons_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -90,9 +90,9 @@ contains end subroutine s_compute_mixture_density !> This subroutine calculates the source term due to body forces - !! system can be advanced in time - !! Conservative variables - !! Primitive variables + !! so the system can be advanced in time + !! @param q_cons_vf Conservative variables + !! @param q_prim_vf Primitive variables subroutine s_compute_body_forces_rhs(q_prim_vf, q_cons_vf, rhs_vf) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf diff --git a/src/simulation/m_bubbles.fpp b/src/simulation/m_bubbles.fpp index f024294e84..65703d34ea 100644 --- a/src/simulation/m_bubbles.fpp +++ b/src/simulation/m_bubbles.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_bubbles +!! @file +!! @brief Contains module m_bubbles #:include 'macros.fpp' @@ -27,19 +27,19 @@ module m_bubbles contains !> Function that computes the bubble radial acceleration based on bubble models - !! Current density - !! Current driving pressure - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Internal bubble pressure - !! Time-derivative of internal bubble pressure - !! bubble volume fraction - !! Tait EOS parameter - !! Tait EOS parameter - !! Source for bubble volume fraction - !! Divergence of velocity - !! Speed of sound from fP (EL) + !! @param fRho Current density + !! @param fP Current driving pressure + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fpb Internal bubble pressure + !! @param fpbdot Time-derivative of internal bubble pressure + !! @param alf bubble volume fraction + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param f_bub_adv_src Source for bubble volume fraction + !! @param f_divu Divergence of velocity + !! @param fCson Speed of sound from fP (EL) elemental function f_rddot(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, fntait, fBtait, f_bub_adv_src, f_divu, fCson) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fRho, fP, fR, fV, fR0, fpb, fpbdot, alf @@ -50,7 +50,7 @@ contains real(wp) :: f_rddot if (bubble_model == 1) then - ! bubbles + ! Gilmore bubbles fCpinf = fP - Eu fCpbw = f_cpbw(fR0, fR, fV, fpb) fH = f_H(fCpbw, fCpinf, fntait, fBtait) @@ -59,7 +59,7 @@ contains fHdot = f_Hdot(fCpbw, fCpinf, fCpinf_dot, fntait, fBtait, fR, fV, fR0, fpbdot) f_rddot = f_rddot_G(fCpbw, fR, fV, fH, fHdot, c_gas, fntait, fBtait) else if (bubble_model == 2) then - ! bubbles + ! Keller-Miksis bubbles fCpinf = fP fCpbw = f_cpbw_KM(fR0, fR, fV, fpb) if (bubbles_euler) then @@ -69,21 +69,21 @@ contains end if f_rddot = f_rddot_KM(fpbdot, fCpinf, fCpbw, fRho, fR, fV, fR0, c_liquid) else if (bubble_model == 3) then - ! bubbles + ! Rayleigh-Plesset bubbles fCpbw = f_cpbw_KM(fR0, fR, fV, fpb) f_rddot = f_rddot_RP(fP, fRho, fR, fV, fCpbw) else - ! No bubble dynamics + ! Default: No bubble dynamics f_rddot = 0._wp end if end function f_rddot !> Function that computes that bubble wall pressure for Gilmore bubbles - !! Equilibrium bubble radius - !! Current bubble radius - !! Current bubble velocity - !! Internal bubble pressure + !! @param fR0 Equilibrium bubble radius + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fpb Internal bubble pressure elemental function f_cpbw(fR0, fR, fV, fpb) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR0, fR, fV, fpb @@ -99,10 +99,10 @@ contains end function f_cpbw !> Function that computes the bubble enthalpy - !! Bubble wall pressure - !! Driving bubble pressure - !! Tait EOS parameter - !! Tait EOS parameter + !! @param fCpbw Bubble wall pressure + !! @param fCpinf Driving bubble pressure + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter elemental function f_H(fCpbw, fCpinf, fntait, fBtait) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fCpinf, fntait, fBtait @@ -119,10 +119,10 @@ contains end function f_H !> Function that computes the sound speed for the bubble - !! Driving bubble pressure - !! Tait EOS parameter - !! Tait EOS parameter - !! Bubble enthalpy + !! @param fCpinf Driving bubble pressure + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param fH Bubble enthalpy elemental function f_cgas(fCpinf, fntait, fBtait, fH) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpinf, fntait, fBtait, fH @@ -130,7 +130,7 @@ contains real(wp) :: tmp real(wp) :: f_cgas - ! sound speed for Gilmore equations "C" -> c_gas + ! get sound speed for Gilmore equations "C" -> c_gas tmp = (fCpinf/(1._wp + fBtait) + 1._wp)**((fntait - 1._wp)/fntait) tmp = fntait*(1._wp + fBtait)*tmp @@ -139,13 +139,13 @@ contains end function f_cgas !> Function that computes the time derivative of the driving pressure - !! Local liquid density - !! Local pressure - !! Local void fraction - !! Tait EOS parameter - !! Tait EOS parameter - !! Advection equation source term - !! Divergence of velocity + !! @param fRho Local liquid density + !! @param fP Local pressure + !! @param falf Local void fraction + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param advsrc Advection equation source term + !! @param divu Divergence of velocity elemental function f_cpinfdot(fRho, fP, falf, fntait, fBtait, advsrc, divu) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fRho, fP, falf, fntait, fBtait, advsrc, divu @@ -153,29 +153,29 @@ contains real(wp) :: c2_liquid real(wp) :: f_cpinfdot - ! sound speed squared for liquid (only needed for pbdot) - ! = gam (p+B) / (rho*(1-alf)) + ! get sound speed squared for liquid (only needed for pbdot) + ! c_l^2 = gam (p+B) / (rho*(1-alf)) if (mpp_lim) then c2_liquid = fntait*(fP + fBtait)/fRho else c2_liquid = fntait*(fP + fBtait)/(fRho*(1._wp - falf)) end if - ! = rho sound^2 (alf_src - divu) + ! \dot{Cp_inf} = rho sound^2 (alf_src - divu) f_cpinfdot = fRho*c2_liquid*(advsrc - divu) end function f_cpinfdot !> Function that computes the time derivative of the enthalpy - !! Bubble wall pressure - !! Driving bubble pressure - !! Time derivative of the driving pressure - !! Tait EOS parameter - !! Tait EOS parameter - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Time derivative of the internal bubble pressure + !! @param fCpbw Bubble wall pressure + !! @param fCpinf Driving bubble pressure + !! @param fCpinf_dot Time derivative of the driving pressure + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fpbdot Time derivative of the internal bubble pressure elemental function f_Hdot(fCpbw, fCpinf, fCpinf_dot, fntait, fBtait, fR, fV, fR0, fpbdot) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fCpinf, fCpinf_dot, fntait, fBtait @@ -196,45 +196,45 @@ contains (fCpbw/(1._wp + fBtait) + 1._wp)**(-1._wp/fntait)*(tmp1 + tmp2) & - (fCpinf/(1._wp + fBtait) + 1._wp)**(-1._wp/fntait)*fCpinf_dot - ! = (Cpbw/(1+B) + 1)^(-1/n_tait)*(-3 gam)*(R0/R)^(3gam) V/R + ! Hdot = (Cpbw/(1+B) + 1)^(-1/n_tait)*(-3 gam)*(R0/R)^(3gam) V/R !f_Hdot = ((fCpbw/(1._wp+fBtait)+1._wp)**(-1._wp/fntait))*(-3._wp)*gam * & - ! (fR0/fR)**(3._wp*gam ))*(fV/fR) + ! ( (fR0/fR)**(3._wp*gam ))*(fV/fR) - ! = Hdot - (Cpinf/(1+B) + 1)^(-1/n_tait) Cpinfdot + ! Hdot = Hdot - (Cpinf/(1+B) + 1)^(-1/n_tait) Cpinfdot !f_Hdot = f_Hdot - ((fCpinf/(1._wp+fBtait)+1._wp)**(-1._wp/fntait))*fCpinf_dot end function f_Hdot !> Function that computes the bubble radial acceleration for Rayleigh-Plesset bubbles - !! Driving pressure - !! Current density - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Boundary wall pressure + !! @param fCp Driving pressure + !! @param fRho Current density + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fCpbw Boundary wall pressure elemental function f_rddot_RP(fCp, fRho, fR, fV, fCpbw) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCp, fRho, fR, fV, fCpbw real(wp) :: f_rddot_RP - !! (1/r) ( -3/2 rdot^2 + ((r0/r)^3\gamma - Cp)/rho ) - !! (1/r) ( -3/2 rdot^2 + (tmp1 - Cp)/rho ) - !! (1/r) ( tmp2 ) + !! rddot = (1/r) ( -3/2 rdot^2 + ((r0/r)^3\gamma - Cp)/rho ) + !! rddot = (1/r) ( -3/2 rdot^2 + (tmp1 - Cp)/rho ) + !! rddot = (1/r) ( tmp2 ) f_rddot_RP = (-1.5_wp*(fV**2._wp) + (fCpbw - fCp)/fRho)/fR end function f_rddot_RP !> Function that computes the bubble radial acceleration - !! Bubble wall pressure - !! Current bubble radius - !! Current bubble velocity - !! Current enthalpy - !! Current time derivative of the enthalpy - !! Current gas sound speed - !! Tait EOS parameter - !! Tait EOS parameter + !! @param fCpbw Bubble wall pressure + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fH Current enthalpy + !! @param fHdot Current time derivative of the enthalpy + !! @param fcgas Current gas sound speed + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter elemental function f_rddot_G(fCpbw, fR, fV, fH, fHdot, fcgas, fntait, fBtait) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fCpbw, fR, fV, fH, fHdot @@ -254,10 +254,10 @@ contains end function f_rddot_G !> Function that computes the bubble wall pressure for Keller--Miksis bubbles - !! Equilibrium bubble radius - !! Current bubble radius - !! Current bubble velocity - !! Internal bubble pressure + !! @param fR0 Equilibrium bubble radius + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fpb Internal bubble pressure elemental function f_cpbw_KM(fR0, fR, fV, fpb) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR0, fR, fV, fpb @@ -277,14 +277,14 @@ contains end function f_cpbw_KM !> Function that computes the bubble radial acceleration for Keller--Miksis bubbles - !! Time-derivative of internal bubble pressure - !! Driving pressure - !! Bubble wall pressure - !! Current density - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Current sound speed + !! @param fpbdot Time-derivative of internal bubble pressure + !! @param fCp Driving pressure + !! @param fCpbw Bubble wall pressure + !! @param fRho Current density + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fC Current sound speed elemental function f_rddot_KM(fpbdot, fCp, fCpbw, fRho, fR, fV, fR0, fC) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fpbdot, fCp, fCpbw @@ -317,41 +317,38 @@ contains end function f_rddot_KM !> Subroutine that computes bubble wall properties for vapor bubbles - !! @param[in] pb_in Internal bubble pressure. - !! @param[in] iR0 Current bubble size index. - !! @param[out] chi_vw_out Bubble wall vapor mass fraction. - !! @param[out] k_mw_out Thermal conductivity of gas mixture at bubble wall. - !! @param[out] rho_mw_out Density of mixture at bubble wall. + !! @param pb Internal bubble pressure + !! @param iR0 Current bubble size index elemental subroutine s_bwproperty(pb_in, iR0, chi_vw_out, k_mw_out, rho_mw_out) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: pb_in integer, intent(in) :: iR0 - real(wp), intent(out) :: chi_vw_out - real(wp), intent(out) :: k_mw_out - real(wp), intent(out) :: rho_mw_out + real(wp), intent(out) :: chi_vw_out !< Bubble wall properties (Ando 2010) + real(wp), intent(out) :: k_mw_out !< Bubble wall properties (Ando 2010) + real(wp), intent(out) :: rho_mw_out !< Bubble wall properties (Ando 2010) real(wp) :: x_vw - ! fraction of vapor + ! mass fraction of vapor chi_vw_out = 1._wp/(1._wp + R_v/R_g*(pb_in/pv - 1._wp)) - ! fraction of vapor & thermal conductivity of gas mixture + ! mole fraction of vapor & thermal conductivity of gas mixture x_vw = M_g*chi_vw_out/(M_v + (M_g - M_v)*chi_vw_out) k_mw_out = x_vw*k_v(iR0)/(x_vw + (1._wp - x_vw)*phi_vg) & + (1._wp - x_vw)*k_g(iR0)/(x_vw*phi_gv + 1._wp - x_vw) - ! mixture density + ! gas mixture density rho_mw_out = pv/(chi_vw_out*R_v*Tw) end subroutine s_bwproperty !> Function that computes the vapour flux - !! Current bubble radius - !! Current bubble velocity - !! - !! Current mass of vapour - !! Bubble size index (EE) or bubble identifier (EL) - !! Current gas mass (EL) - !! Mass transfer coefficient (EL) - !! Mixture gas constant (EL) - !! Mixture gamma (EL) + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fpb + !! @param fmass_v Current mass of vapour + !! @param iR0 Bubble size index (EE) or bubble identifier (EL) + !! @param fmass_g Current gas mass (EL) + !! @param fbeta_c Mass transfer coefficient (EL) + !! @param fR_m Mixture gas constant (EL) + !! @param fgamma_m Mixture gamma (EL) elemental subroutine s_vflux(fR, fV, fpb, fmass_v, iR0, vflux, fmass_g, fbeta_c, fR_m, fgamma_m) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fR @@ -369,9 +366,9 @@ contains real(wp) :: conc_v if (thermal == 3) then !transfer - ! transfer model + ! constant transfer model if (bubbles_lagrange) then - ! properties (gas+vapor) in the bubble + ! Mixture properties (gas+vapor) in the bubble conc_v = fmass_v/(fmass_v + fmass_g) if (lag_params%massTransfer_model) then conc_v = 1._wp/(1._wp + (R_v/R_g)*(fpb/pv - 1._wp)) @@ -379,7 +376,7 @@ contains fR_m = (fmass_g*R_g + fmass_v*R_v) fgamma_m = conc_v*gam_v + (1._wp - conc_v)*gam_g - ! flux + ! Vapor flux chi_bar = fmass_v/(fmass_v + fmass_g) grad_chi = (chi_bar - conc_v) rho_mw_lag = (fmass_g + fmass_v)/(4._wp/3._wp*pi*fR**3._wp) @@ -393,23 +390,23 @@ contains vflux = rho_mw*grad_chi/Pe_c/(1._wp - chi_vw)/fR end if else - ! + ! polytropic vflux = pv*fV/(R_v*Tw) end if end subroutine s_vflux !> Function that computes the time derivative of - !! bubble pressure - !! Vapour flux - !! Current bubble radius - !! Current bubble velocity - !! Current internal bubble pressure - !! Current mass of vapour - !! Bubble size index (EE) or bubble identifier (EL) - !! Mass transfer coefficient (EL) - !! Mixture gas constant (EL) - !! Mixture gamma (EL) + !! the internal bubble pressure + !! @param fvflux Vapour flux + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fpb Current internal bubble pressure + !! @param fmass_v Current mass of vapour + !! @param iR0 Bubble size index (EE) or bubble identifier (EL) + !! @param fbeta_t Mass transfer coefficient (EL) + !! @param fR_m Mixture gas constant (EL) + !! @param fgamma_m Mixture gamma (EL) elemental function f_bpres_dot(fvflux, fR, fV, fpb, fmass_v, iR0, fbeta_t, fR_m, fgamma_m) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in) :: fvflux @@ -445,27 +442,27 @@ contains end function f_bpres_dot !> Adaptive time stepping routine for subgrid bubbles - !! E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary - !! I, Chapter II.4) - !! Current density - !! Current driving pressure - !! Current bubble radius - !! Current bubble radial velocity - !! Equilibrium bubble radius - !! Internal bubble pressure - !! Time-derivative of internal bubble pressure - !! bubble volume fraction - !! Tait EOS parameter - !! Tait EOS parameter - !! Source for bubble volume fraction - !! Divergence of velocity - !! Bubble identifier (EL) - !! Current mass of vapour (EL) - !! Current mass of gas (EL) - !! Mass transfer coefficient (EL) - !! Heat transfer coefficient (EL) - !! Speed of sound (EL) - !! Fail-safe exit if max iteration count reached + !! (See Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary + !! Differential Equations I, Chapter II.4) + !! @param fRho Current density + !! @param fP Current driving pressure + !! @param fR Current bubble radius + !! @param fV Current bubble radial velocity + !! @param fR0 Equilibrium bubble radius + !! @param fpb Internal bubble pressure + !! @param fpbdot Time-derivative of internal bubble pressure + !! @param alf bubble volume fraction + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param f_bub_adv_src Source for bubble volume fraction + !! @param f_divu Divergence of velocity + !! @param bub_id Bubble identifier (EL) + !! @param fmass_v Current mass of vapour (EL) + !! @param fmass_g Current mass of gas (EL) + !! @param fbeta_c Mass transfer coefficient (EL) + !! @param fbeta_t Heat transfer coefficient (EL) + !! @param fCson Speed of sound (EL) + !! @param adap_dt_stop Fail-safe exit if max iteration count reached subroutine s_advance_step(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & bub_id, fmass_v, fmass_g, fbeta_c, & @@ -491,7 +488,7 @@ contains call s_initial_substep_h(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, fCson, h0) h = h0 - ! one step + ! Advancing one step t_new = 0._wp iter_count = 0 adap_dt_stop = 0 @@ -501,12 +498,12 @@ contains h = 0.5_wp*dt - t_new end if - ! one sub-step + ! Advancing one sub-step do while (iter_count < adap_dt_max_iters) iter_count = iter_count + 1 - ! one sub-step + ! Advance one sub-step call s_advance_substep(err(1), & fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & @@ -518,7 +515,7 @@ contains cycle end if - ! one sub-step by advancing two half steps + ! Advance one sub-step by advancing two half steps call s_advance_substep(err(2), & fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & @@ -548,34 +545,34 @@ contains err(5) = abs((myV_tmp1(4) - myV_tmp2(4))/myV_tmp1(4)) if (abs(myV_tmp1(4)) < verysmall) err(5) = 0._wp - ! acceptance/rejection and update step size - ! 1: err1, err2, err3 < tol - ! 2: myR_tmp1(4) > 0._wp - ! 3: abs((myR_tmp1(4) - myR_tmp2(4))/fR) < tol - ! 4: abs((myV_tmp1(4) - myV_tmp2(4))/fV) < tol + ! Determine acceptance/rejection and update step size + ! Rule 1: err1, err2, err3 < tol + ! Rule 2: myR_tmp1(4) > 0._wp + ! Rule 3: abs((myR_tmp1(4) - myR_tmp2(4))/fR) < tol + ! Rule 4: abs((myV_tmp1(4) - myV_tmp2(4))/fV) < tol if ((err(1) <= adap_dt_tol) .and. (err(2) <= adap_dt_tol) .and. & (err(3) <= adap_dt_tol) .and. (err(4) <= adap_dt_tol) .and. & (err(5) <= adap_dt_tol) .and. myR_tmp1(4) > 0._wp) then - ! Finalize the sub-step + ! Accepted. Finalize the sub-step t_new = t_new + h - ! R and V + ! Update R and V fR = myR_tmp1(4) fV = myV_tmp1(4) if (bubbles_lagrange) then - ! pb and mass_v + ! Update pb and mass_v fpb = myPb_tmp1(4) fmass_v = myMv_tmp1(4) end if - ! step size for the next sub-step + ! Update step size for the next sub-step h = h*min(2._wp, max(0.5_wp, (adap_dt_tol/err(1))**(1._wp/3._wp))) exit else - ! Update step size for the next try on sub-step + ! Rejected. Update step size for the next try on sub-step if (err(2) <= adap_dt_tol) then h = 0.5_wp*h else @@ -584,7 +581,7 @@ contains end if end do - ! the loop if the final time reached dt + ! Exit the loop if the final time reached dt if (f_approx_equal(t_new, 0.5_wp*dt) .or. iter_count >= adap_dt_max_iters) exit end do @@ -594,22 +591,22 @@ contains end subroutine s_advance_step !> Choose the initial time step size for the adaptive time stepping routine - !! E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary - !! I, Chapter II.4) - !! Current density - !! Current driving pressure - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Internal bubble pressure - !! Time-derivative of internal bubble pressure - !! bubble volume fraction - !! Tait EOS parameter - !! Tait EOS parameter - !! Source for bubble volume fraction - !! Divergence of velocity - !! Speed of sound (EL) - !! Time step size + !! (See Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary + !! Differential Equations I, Chapter II.4) + !! @param fRho Current density + !! @param fP Current driving pressure + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fpb Internal bubble pressure + !! @param fpbdot Time-derivative of internal bubble pressure + !! @param alf bubble volume fraction + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param f_bub_adv_src Source for bubble volume fraction + !! @param f_divu Divergence of velocity + !! @param fCson Speed of sound (EL) + !! @param h Time step size subroutine s_initial_substep_h(fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & fCson, h) @@ -625,8 +622,8 @@ contains real(wp), dimension(3) :: d_norms !< norms (d_0, d_1, d_2) real(wp), dimension(2) :: myR_tmp, myV_tmp, myA_tmp !< Bubble radius, radial velocity, and radial acceleration - ! the starting time step - ! f(x0,y0) + ! Determine the starting time step + ! Evaluate f(x0,y0) myR_tmp(1) = fR myV_tmp(1) = fV myA_tmp(1) = f_rddot(fRho, fP, myR_tmp(1), myV_tmp(1), fR0, & @@ -634,7 +631,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! d_0 = ||y0|| and d_1 = ||f(x0,y0)|| + ! Compute d_0 = ||y0|| and d_1 = ||f(x0,y0)|| d_norms(1) = sqrt((myR_tmp(1)**2._wp + myV_tmp(1)**2._wp)/2._wp) d_norms(2) = sqrt((myV_tmp(1)**2._wp + myA_tmp(1)**2._wp)/2._wp) if (d_norms(1) < threshold_first_guess .or. d_norms(2) < threshold_first_guess) then @@ -643,7 +640,7 @@ contains h_size(1) = scale_guess*(d_norms(1)/d_norms(2)) end if - ! f(x0+h0,y0+h0*f(x0,y0)) + ! Evaluate f(x0+h0,y0+h0*f(x0,y0)) myR_tmp(2) = myR_tmp(1) + h_size(1)*myV_tmp(1) myV_tmp(2) = myV_tmp(1) + h_size(1)*myA_tmp(1) myA_tmp(2) = f_rddot(fRho, fP, myR_tmp(2), myV_tmp(2), fR0, & @@ -651,11 +648,11 @@ contains f_bub_adv_src, f_divu, & fCson) - ! d_2 = ||f(x0+h0,y0+h0*f(x0,y0))-f(x0,y0)||/h0 + ! Compute d_2 = ||f(x0+h0,y0+h0*f(x0,y0))-f(x0,y0)||/h0 d_norms(3) = sqrt(((myV_tmp(2) - myV_tmp(1))**2._wp + (myA_tmp(2) - myA_tmp(1))**2._wp)/2._wp)/h_size(1) - ! h1 = (0.01/max(d_1,d_2))^{1/(p+1)} - ! max(d_1,d_2) < 1.e-15_wp, h_size(2) = max(1.e-6_wp, h0*1.e-3_wp) + ! Set h1 = (0.01/max(d_1,d_2))^{1/(p+1)} + ! if max(d_1,d_2) < 1.e-15_wp, h_size(2) = max(1.e-6_wp, h0*1.e-3_wp) if (max(d_norms(2), d_norms(3)) < threshold_second_guess) then h_size(2) = max(small_guess, h_size(1)*scale_first_guess) else @@ -667,31 +664,31 @@ contains end subroutine s_initial_substep_h !> Integrate bubble variables over the given time step size, h, using a - !! embedded Runge–Kutta scheme. - !! Estimated error - !! Current density - !! Current driving pressure - !! Current bubble radius - !! Current bubble velocity - !! Equilibrium bubble radius - !! Internal bubble pressure - !! Time-derivative of internal bubble pressure - !! bubble volume fraction - !! Tait EOS parameter - !! Tait EOS parameter - !! Source for bubble volume fraction - !! Divergence of velocity - !! Bubble identifier (EL) - !! Current mass of vapour (EL) - !! Current mass of gas (EL) - !! Mass transfer coefficient (EL) - !! Heat transfer coefficient (EL) - !! Speed of sound (EL) - !! Time step size - !! Bubble radius at each stage - !! Bubble radial velocity at each stage - !! Internal bubble pressure at each stage (EL) - !! Mass of vapor in the bubble at each stage (EL) + !! third-order accurate embedded Runge–Kutta scheme. + !! @param err Estimated error + !! @param fRho Current density + !! @param fP Current driving pressure + !! @param fR Current bubble radius + !! @param fV Current bubble velocity + !! @param fR0 Equilibrium bubble radius + !! @param fpb Internal bubble pressure + !! @param fpbdot Time-derivative of internal bubble pressure + !! @param alf bubble volume fraction + !! @param fntait Tait EOS parameter + !! @param fBtait Tait EOS parameter + !! @param f_bub_adv_src Source for bubble volume fraction + !! @param f_divu Divergence of velocity + !! @param bub_id Bubble identifier (EL) + !! @param fmass_v Current mass of vapour (EL) + !! @param fmass_g Current mass of gas (EL) + !! @param fbeta_c Mass transfer coefficient (EL) + !! @param fbeta_t Heat transfer coefficient (EL) + !! @param fCson Speed of sound (EL) + !! @param h Time step size + !! @param myR_tmp Bubble radius at each stage + !! @param myV_tmp Bubble radial velocity at each stage + !! @param myPb_tmp Internal bubble pressure at each stage (EL) + !! @param myMv_tmp Mass of vapor in the bubble at each stage (EL) subroutine s_advance_substep(err, fRho, fP, fR, fV, fR0, fpb, fpbdot, alf, & fntait, fBtait, f_bub_adv_src, f_divu, & bub_id, fmass_v, fmass_g, fbeta_c, & @@ -713,7 +710,7 @@ contains myPb_tmp(1:4) = fpb mydPbdt_tmp(1:4) = fpbdot - ! 0 + ! Stage 0 myR_tmp(1) = fR myV_tmp(1) = fV if (bubbles_lagrange) then @@ -727,7 +724,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! 1 + ! Stage 1 myR_tmp(2) = myR_tmp(1) + h*myV_tmp(1) if (myR_tmp(2) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -744,7 +741,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! 2 + ! Stage 2 myR_tmp(3) = myR_tmp(1) + (h/4._wp)*(myV_tmp(1) + myV_tmp(2)) if (myR_tmp(3) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -761,7 +758,7 @@ contains f_bub_adv_src, f_divu, & fCson) - ! 3 + ! Stage 3 myR_tmp(4) = myR_tmp(1) + (h/6._wp)*(myV_tmp(1) + myV_tmp(2) + 4._wp*myV_tmp(3)) if (myR_tmp(4) < 0._wp) then err = adap_dt_tol + 1._wp; return @@ -778,12 +775,12 @@ contains f_bub_adv_src, f_divu, & fCson) - ! error + ! Estimate error err_R = (-5._wp*h/24._wp)*(myV_tmp(2) + myV_tmp(3) - 2._wp*myV_tmp(4)) & /max(abs(myR_tmp(1)), abs(myR_tmp(4))) err_V = (-5._wp*h/24._wp)*(myA_tmp(2) + myA_tmp(3) - 2._wp*myA_tmp(4)) & /max(abs(myV_tmp(1)), abs(myV_tmp(4))) - ! correction for non-oscillating bubbles + ! Error correction for non-oscillating bubbles if (max(abs(myV_tmp(1)), abs(myV_tmp(4))) < 1.e-12_wp) then err_V = 0._wp end if @@ -796,16 +793,16 @@ contains end subroutine s_advance_substep !> Changes of pressure and vapor mass in the lagrange bubbles. - !! Bubble identifier - !! Current mass of gas - !! Mass transfer coefficient - !! Heat transfer coefficient - !! Bubble radius - !! Bubble radial velocity - !! Internal bubble pressure - !! Mass of vapor in the bubble - !! Rate of change of the internal bubble pressure - !! Rate of change of the mass of vapor in the bubble + !! @param bub_id Bubble identifier + !! @param fmass_g Current mass of gas + !! @param fbeta_c Mass transfer coefficient + !! @param fbeta_t Heat transfer coefficient + !! @param fR_tmp Bubble radius + !! @param fV_tmp Bubble radial velocity + !! @param fPb_tmp Internal bubble pressure + !! @param fMv_tmp Mass of vapor in the bubble + !! @param fdPbdt_tmp Rate of change of the internal bubble pressure + !! @param fdMvdt_tmp Rate of change of the mass of vapor in the bubble elemental subroutine s_advance_EL(fR_tmp, fV_tmp, fPb_tmp, fMv_tmp, bub_id, & fmass_g, fbeta_c, fbeta_t, fdPbdt_tmp, advance_EL) $:GPU_ROUTINE(parallelism='[seq]') diff --git a/src/simulation/m_bubbles_EE.fpp b/src/simulation/m_bubbles_EE.fpp index 0ea63842ce..e041b4f939 100644 --- a/src/simulation/m_bubbles_EE.fpp +++ b/src/simulation/m_bubbles_EE.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_bubbles_EE +!! @file +!! @brief Contains module m_bubbles_EE #:include 'macros.fpp' @@ -68,8 +68,8 @@ contains end subroutine s_initialize_bubbles_EE_module - ! the bubble volume fraction alpha from the bubble number density n - !! is the conservative variable + ! Compute the bubble volume fraction alpha from the bubble number density n + !! @param q_cons_vf is the conservative variable subroutine s_comp_alpha_from_n(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf real(wp) :: nR3bar @@ -92,15 +92,11 @@ contains end subroutine s_comp_alpha_from_n - !> Computes one directional component of velocity divergence for bubble dynamics. - !! @param[in] idir Spatial direction (1=x, 2=y, 3=z). - !! @param[in] q_prim_vf Primitive variables containing velocity components. - !! @param[inout] divu_in Velocity divergence field, accumulated across directions. subroutine s_compute_bubbles_EE_rhs(idir, q_prim_vf, divu_in) integer, intent(in) :: idir type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf - type(scalar_field), intent(inout) :: divu_in + type(scalar_field), intent(inout) :: divu_in !< matrix for div(u) integer :: j, k, l @@ -157,16 +153,14 @@ contains end subroutine s_compute_bubbles_EE_rhs !> The purpose of this procedure is to compute the source terms - !! needed for the bubble modeling. - !! @param[inout] q_cons_vf Conservative variables. - !! @param[in] q_prim_vf Primitive variables. - !! @param[inout] rhs_vf Right-hand side source terms. - !! @param[in] divu_in Velocity divergence field. + !! that are needed for the bubble modeling + !! @param q_prim_vf Primitive variables + !! @param q_cons_vf Conservative variables impure subroutine s_compute_bubble_EE_source(q_cons_vf, q_prim_vf, rhs_vf, divu_in) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf - type(scalar_field), intent(in) :: divu_in + type(scalar_field), intent(in) :: divu_in !< matrix for div(u) real(wp) :: rddot real(wp) :: pb_local, mv_local, vflux, pbdot @@ -299,7 +293,7 @@ contains pb_local = 0._wp; mv_local = 0._wp; vflux = 0._wp; pbdot = 0._wp end if - ! time stepping + ! Adaptive time stepping if (adap_dt) then adap_dt_stop = 0 diff --git a/src/simulation/m_bubbles_EL.fpp b/src/simulation/m_bubbles_EL.fpp index 6c1223ae45..0256b70138 100644 --- a/src/simulation/m_bubbles_EL.fpp +++ b/src/simulation/m_bubbles_EL.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_bubbles_EL +!! @file +!! @brief Contains module m_bubbles_EL #:include 'macros.fpp' @@ -78,22 +78,22 @@ module m_bubbles_EL contains !> Initializes the lagrangian subgrid bubble solver - !! Initial conservative variables + !! @param q_cons_vf Initial conservative variables impure subroutine s_initialize_bubbles_EL_module(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer :: nBubs_glb, i - ! number of time-stages for selected time-stepping scheme + ! Setting number of time-stages for selected time-stepping scheme lag_num_ts = time_stepper - ! space for the Eulerian fields needed to map the effect of the bubbles + ! Allocate space for the Eulerian fields needed to map the effect of the bubbles if (lag_params%solver_approach == 1) then - ! coupling + ! One-way coupling q_beta_idx = 3 elseif (lag_params%solver_approach == 2) then - ! coupling + ! Two-way coupling q_beta_idx = 4 if (p == 0) then !Subgrid noise model for 2D approximation @@ -117,7 +117,7 @@ contains @:ACC_SETUP_SFs(q_beta(i)) end do - ! space for lagrangian variables + ! Allocating space for lagrangian variables nBubs_glb = lag_params%nBubs_glb @:ALLOCATE(lag_id(1:nBubs_glb, 1:2)) @@ -145,13 +145,13 @@ contains if (adap_dt .and. f_is_default(adap_dt_tol)) adap_dt_tol = dflt_adap_dt_tol - ! bubbles + ! Starting bubbles call s_read_input_bubbles(q_cons_vf) end subroutine s_initialize_bubbles_EL_module !> The purpose of this procedure is to obtain the initial bubbles' information - !! Conservative variables + !! @param q_cons_vf Conservative variables impure subroutine s_read_input_bubbles(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -164,11 +164,11 @@ contains character(LEN=path_len + 2*name_len) :: path_D_dir !< - ! number of particles + ! Initialize number of particles bub_id = 0 id = 0 - ! the input lag_bubble file or restart point + ! Read the input lag_bubble file or restart point if (cfl_dt) then save_count = n_start qtime = n_start*t_save @@ -230,7 +230,7 @@ contains if (lag_params%write_bubbles) call s_write_lag_particles(qtime) if (save_count == 0) then - ! ./D directory + ! Create ./D directory write (path_D_dir, '(A,I0,A,I0)') trim(case_dir)//'/D' call my_inquire(path_D_dir, file_exist) if (.not. file_exist) call s_create_directory(trim(path_D_dir)) @@ -241,9 +241,9 @@ contains end subroutine s_read_input_bubbles !> The purpose of this procedure is to obtain the information of the bubbles when starting fresh - !! Bubble information - !! Conservative variables - !! Local id of the bubble + !! @param inputBubble Bubble information + !! @param q_cons_vf Conservative variables + !! @param bub_id Local id of the bubble impure subroutine s_add_bubbles(inputBubble, q_cons_vf, bub_id) type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf @@ -283,7 +283,7 @@ contains cell = -buff_size call s_locate_cell(mtn_pos(bub_id, 1:3, 1), cell, mtn_s(bub_id, 1:3, 1)) - ! if the bubble is located in the ghost cell of a symmetric, or wall boundary + ! Check if the bubble is located in the ghost cell of a symmetric, or wall boundary if ((any(bc_x%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(1) < 0) .or. & (any(bc_x%end == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(1) > m) .or. & (any(bc_y%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/)) .and. cell(2) < 0) .or. & @@ -308,7 +308,7 @@ contains if (pliq < 0) print *, "Negative pressure", proc_rank, & q_cons_vf(E_idx)%sf(cell(1), cell(2), cell(3)), pi_inf, gamma, pliq, cell, dynP - ! particle pressure + ! Initial particle pressure gas_p(bub_id, 1) = pliq + 2._wp*(1._wp/Web)/bub_R0(bub_id) if (.not. f_approx_equal((1._wp/Web), 0._wp)) then pcrit = pv - 4._wp*(1._wp/Web)/(3._wp*sqrt(3._wp*gas_p(bub_id, 1)*bub_R0(bub_id)**3._wp/(2._wp*(1._wp/Web)))) @@ -317,7 +317,7 @@ contains pcrit = 0._wp end if - ! particle mass + ! Initial particle mass volparticle = 4._wp/3._wp*pi*bub_R0(bub_id)**3._wp ! volume gas_mv(bub_id, 1) = pv*volparticle*(1._wp/(R_v*Tw))*(massflag) ! vapermass gas_mg(bub_id) = (gas_p(bub_id, 1) - pv*(massflag))*volparticle*(1._wp/(R_g*Tw)) ! gasmass @@ -326,7 +326,7 @@ contains end if totalmass = gas_mg(bub_id) + gas_mv(bub_id, 1) ! totalmass - ! natural frequency + ! Bubble natural frequency concvap = gas_mv(bub_id, 1)/(gas_mv(bub_id, 1) + gas_mg(bub_id)) omegaN_local = (3._wp*(gas_p(bub_id, 1) - pv*(massflag)) + 4._wp*(1._wp/Web)/bub_R0(bub_id))/rhol if (pv*(massflag) > gas_p(bub_id, 1)) then @@ -337,7 +337,7 @@ contains cpparticle = concvap*cp_v + (1._wp - concvap)*cp_g kparticle = concvap*k_vl + (1._wp - concvap)*k_gl - ! and heat transfer coefficients (based on Preston 2007) + ! Mass and heat transfer coefficients (based on Preston 2007) PeT = totalmass/volparticle*cpparticle*bub_R0(bub_id)**2._wp*omegaN_local/kparticle call s_transcoeff(1._wp, PeT, Re_trans, Im_trans) gas_betaT(bub_id) = Re_trans*(heatflag)*kparticle @@ -353,8 +353,8 @@ contains end subroutine s_add_bubbles !> The purpose of this procedure is to obtain the information of the bubbles from a restart point. - !! Local ID of the particle - !! File identifier + !! @param bub_id Local ID of the particle + !! @param save_count File identifier impure subroutine s_restart_bubbles(bub_id, save_count) integer, intent(inout) :: bub_id, save_count @@ -380,11 +380,11 @@ contains real(wp), dimension(1:1, 1:lag_io_vars) :: dummy dummy = 0._wp - ! file path + ! Construct file path write (file_loc, '(A,I0,A)') 'lag_bubbles_', save_count, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! if file exists + ! Check if file exists inquire (FILE=trim(file_loc), EXIST=file_exist) if (.not. file_exist) then call s_mpi_abort('Restart file '//trim(file_loc)//' does not exist!') @@ -415,7 +415,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! to processor counts position + ! Skip to processor counts position disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs), & MPI_OFFSET_KIND) call MPI_FILE_SEEK(ifile, disp, MPI_SEEK_SET, ierr) @@ -426,7 +426,7 @@ contains call MPI_BCAST(proc_bubble_counts, file_num_procs, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) - ! time variables from file + ! Set time variables from file mytime = file_time dt = file_dt @@ -455,7 +455,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! extended header + ! Skip extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -499,7 +499,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, & mpi_info_int, ifile, ierr) - ! extended header + ! Skip extended header disp = int(sizeof(file_tot_part) + 2*sizeof(file_time) + sizeof(file_num_procs) + & file_num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -521,11 +521,11 @@ contains end subroutine s_restart_bubbles !> Contains the bubble dynamics subroutines. - !! Conservative variables - !! Primitive variables - !! Calculated change of conservative variables - !! Current time step - !! Current stage in the time-stepper algorithm + !! @param q_cons_vf Conservative variables + !! @param q_prim_vf Primitive variables + !! @param rhs_vf Calculated change of conservative variables + !! @param t_step Current time step + !! @param stage Current stage in the time-stepper algorithm subroutine s_compute_bubble_EL_dynamics(q_prim_vf, stage) type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -552,9 +552,9 @@ contains call nvtxStartRange("LAGRANGE-BUBBLE-DYNAMICS") - ! p_inf model based on Maeda and Colonius (2018). + ! Subgrid p_inf model based on Maeda and Colonius (2018). if (lag_params%pressure_corrector) then - ! velocity potentials (valid for one bubble per cell) + ! Calculate velocity potentials (valid for one bubble per cell) $:GPU_PARALLEL_LOOP(private='[k,cell,paux,preterm1,term2,Romega,myR0,myR,myV,myPb,pint,term1_fac]') do k = 1, nBubs call s_get_pinf(k, q_prim_vf, 2, paux, cell, preterm1, term2, Romega) @@ -566,8 +566,8 @@ contains pint = pint + 0.5_wp*myV**2._wp if (lag_params%cluster_type == 2) then bub_dphidt(k) = (paux - pint) + term2 - ! for the potential induced by the bubble averaged over the control volume - ! that this is based on the incompressible flow assumption near the bubble. + ! Accounting for the potential induced by the bubble averaged over the control volume + ! Note that this is based on the incompressible flow assumption near the bubble. term1_fac = 3._wp/2._wp*(myR*(Romega**2._wp - myR**2._wp))/(Romega**3._wp - myR**3._wp) bub_dphidt(k) = bub_dphidt(k)/(1._wp - term1_fac) end if @@ -575,15 +575,15 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! motion model + ! Radial motion model adap_dt_stop_max = 0 $:GPU_PARALLEL_LOOP(private='[k,i,myalpha_rho,myalpha,Re,cell,myVapFlux,preterm1, term2, paux, pint, Romega, term1_fac,myR_m, mygamma_m, myPb, myMass_n, myMass_v,myR, myV, myBeta_c, myBeta_t, myR0, myPbdot, myMvdot,myPinf, aux1, aux2, myCson, myRho,gamma,pi_inf,qv,dmalf, dmntait, dmBtait, dm_bub_adv_src, dm_divu,adap_dt_stop]', & & reduction='[[adap_dt_stop_max]]',reductionOp='[MAX]', & & copy='[adap_dt_stop_max]',copyin='[stage]') do k = 1, nBubs - ! model + ! Keller-Miksis model - ! bubble state + ! Current bubble state myPb = gas_p(k, 2) myMass_n = gas_mg(k) myMass_v = gas_mv(k, 2) @@ -593,21 +593,21 @@ contains myBeta_t = gas_betaT(k) myR0 = bub_R0(k) - ! and heat fluxes + ! Vapor and heat fluxes call s_vflux(myR, myV, myPb, myMass_v, k, myVapFlux, myMass_n, myBeta_c, myR_m, mygamma_m) myPbdot = f_bpres_dot(myVapFlux, myR, myV, myPb, myMass_v, k, myBeta_t, myR_m, mygamma_m) myMvdot = 4._wp*pi*myR**2._wp*myVapFlux - ! driving pressure + ! Obtaining driving pressure call s_get_pinf(k, q_prim_vf, 1, myPinf, cell, aux1, aux2) - ! liquid density and computing speed of sound from pinf + ! Obtain liquid density and computing speed of sound from pinf call s_compute_species_fraction(q_prim_vf, cell(1), cell(2), cell(3), myalpha_rho, myalpha) call s_convert_species_to_mixture_variables_acc(myRho, gamma, pi_inf, qv, myalpha, & myalpha_rho, Re) call s_compute_cson_from_pinf(q_prim_vf, myPinf, cell, myRho, gamma, pi_inf, myCson) - ! time stepping + ! Adaptive time stepping adap_dt_stop = 0 if (adap_dt) then @@ -617,7 +617,7 @@ contains k, myMass_v, myMass_n, myBeta_c, & myBeta_t, myCson, adap_dt_stop) - ! bubble state + ! Update bubble state intfc_rad(k, 1) = myR intfc_vel(k, 1) = myV gas_p(k, 1) = myPb @@ -625,7 +625,7 @@ contains else - ! acceleration from bubble models + ! Radial acceleration from bubble models intfc_dveldt(k, stage) = f_rddot(myRho, myPinf, myR, myV, myR0, & myPb, myPbdot, dmalf, dmntait, dmBtait, & dm_bub_adv_src, dm_divu, & @@ -643,7 +643,7 @@ contains if (adap_dt .and. adap_dt_stop_max > 0) call s_mpi_abort("Adaptive time stepping failed to converge.") - ! remain in a fixed position + ! Bubbles remain in a fixed position $:GPU_PARALLEL_LOOP(collapse=2, private='[k,l]', copyin='[stage]') do k = 1, nBubs do l = 1, 3 @@ -658,10 +658,10 @@ contains end subroutine s_compute_bubble_EL_dynamics !> The purpose of this subroutine is to obtain the bubble source terms based on Maeda and Colonius (2018) - !! them to the RHS scalar field. - !! Conservative variables - !! Conservative variables - !! Time derivative of the conservative variables + !! and add them to the RHS scalar field. + !! @param q_cons_vf Conservative variables + !! @param q_prim_vf Conservative variables + !! @param rhs_vf Time derivative of the conservative variables subroutine s_compute_bubbles_EL_source(q_cons_vf, q_prim_vf, rhs_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -674,7 +674,7 @@ contains if (lag_params%solver_approach == 2) then - ! / (1 - beta)) * d(beta)/dt source + ! (q / (1 - beta)) * d(beta)/dt source if (p == 0) then $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=4) do k = 0, p @@ -714,7 +714,7 @@ contains call s_gradient_dir(q_prim_vf(E_idx)%sf, q_beta(3)%sf, l) - ! / (1 - beta)) * d(beta)/dt source + ! (q / (1 - beta)) * d(beta)/dt source $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -743,7 +743,7 @@ contains call s_gradient_dir(q_beta(3)%sf, q_beta(4)%sf, l) - ! / (1 - beta)) * d(Pu)/dl source + ! (beta / (1 - beta)) * d(Pu)/dl source $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -764,14 +764,14 @@ contains end subroutine s_compute_bubbles_EL_source !> This procedure computes the speed of sound from a given driving pressure - !! Bubble id - !! Primitive variables - !! Driving pressure - !! Bubble cell - !! Liquid density - !! Liquid specific heat ratio - !! Liquid stiffness - !! Calculated speed of sound + !! @param bub_id Bubble id + !! @param q_prim_vf Primitive variables + !! @param pinf Driving pressure + !! @param cell Bubble cell + !! @param rhol Liquid density + !! @param gamma Liquid specific heat ratio + !! @param pi_inf Liquid stiffness + !! @param cson Calculated speed of sound subroutine s_compute_cson_from_pinf(q_prim_vf, pinf, cell, rhol, gamma, pi_inf, cson) $:GPU_ROUTINE(function_name='s_compute_cson_from_pinf', & & parallelism='[seq]', cray_inline=True) @@ -828,7 +828,7 @@ contains do k = idwbuff(2)%beg, idwbuff(2)%end do j = idwbuff(1)%beg, idwbuff(1)%end q_beta(1)%sf(j, k, l) = 1._wp - q_beta(1)%sf(j, k, l) - ! void fraction given max value + ! Limiting void fraction given max value q_beta(1)%sf(j, k, l) = max(q_beta(1)%sf(j, k, l), & 1._wp - lag_params%valmaxvoid) end do @@ -841,12 +841,12 @@ contains end subroutine s_smear_voidfraction !> The purpose of this procedure is obtain the bubble driving pressure p_inf - !! Particle identifier - !! Primitive variables - !! 1: p at infinity, 2: averaged P at the bubble location - !! Driving pressure - !! Bubble cell - !! Control volume radius + !! @param bub_id Particle identifier + !! @param q_prim_vf Primitive variables + !! @param ptype 1: p at infinity, 2: averaged P at the bubble location + !! @param f_pinfl Driving pressure + !! @param cell Bubble cell + !! @param Romega Control volume radius subroutine s_get_pinf(bub_id, q_prim_vf, ptype, f_pinfl, cell, preterm1, term2, Romega) $:GPU_ROUTINE(function_name='s_get_pinf',parallelism='[seq]', & & cray_inline=True) @@ -949,9 +949,9 @@ contains dc = (3._wp*vol/(4._wp*pi))**(1._wp/3._wp) else if (lag_params%cluster_type >= 2) then - ! dynamic closure from Maeda and Colonius (2018) + ! Bubble dynamic closure from Maeda and Colonius (2018) - ! the cell that contains the bubble (mapCells+1+mapCells) + ! Include the cell that contains the bubble (mapCells+1+mapCells) smearGrid = mapCells - (-mapCells) + 1 smearGridz = smearGrid if (p == 0) smearGridz = 1 @@ -1046,7 +1046,7 @@ contains !Control volume radius if (ptype == 2) Romega = dc - ! p_inf + ! Getting p_inf if (ptype == 1) then f_pinfl = f_pinfl + preterm1*term1 + term2 end if @@ -1056,8 +1056,8 @@ contains end subroutine s_get_pinf !> This subroutine updates the Lagrange variables using the tvd RK time steppers. - !! derivative of the bubble variables must be stored at every stage to avoid precision errors. - !! Current tvd RK stage + !! The time derivative of the bubble variables must be stored at every stage to avoid precision errors. + !! @param stage Current tvd RK stage impure subroutine s_update_lagrange_tdv_rk(stage) integer, intent(in) :: stage @@ -1179,9 +1179,9 @@ contains end subroutine s_update_lagrange_tdv_rk !> This subroutine returns the computational coordinate of the cell for the given position. - !! Input coordinates - !! Computational coordinate of the cell - !! Calculated particle coordinates + !! @param pos Input coordinates + !! @param cell Computational coordinate of the cell + !! @param scoord Calculated particle coordinates subroutine s_locate_cell(pos, cell, scoord) real(wp), dimension(3), intent(in) :: pos @@ -1215,11 +1215,11 @@ contains end do end if - ! numbering of the cell of which left boundary is the domain boundary is 0. - ! comp.coord of the pos is s, the real coordinate of s is - ! coordinate of the left boundary of the Floor(s)-th cell) - ! (s-(int(s))*(cell-width). - ! other words, the coordinate of the center of the cell is x_cc(cell). + ! The numbering of the cell of which left boundary is the domain boundary is 0. + ! if comp.coord of the pos is s, the real coordinate of s is + ! (the coordinate of the left boundary of the Floor(s)-th cell) + ! + (s-(int(s))*(cell-width). + ! In other words, the coordinate of the center of the cell is x_cc(cell). !coordinates in computational space scoord(1) = cell(1) + (pos(1) - x_cb(cell(1) - 1))/dx(cell(1)) @@ -1254,34 +1254,34 @@ contains end subroutine s_transfer_data_to_tmp !> The purpose of this procedure is to determine if the global coordinates of the bubbles - !! in the current MPI processor (including ghost cells). - !! Spatial coordinates of the bubble + !! are present in the current MPI processor (including ghost cells). + !! @param pos_part Spatial coordinates of the bubble function particle_in_domain(pos_part) logical :: particle_in_domain real(wp), dimension(3), intent(in) :: pos_part - ! + ! 2D if (p == 0 .and. cyl_coord .neqv. .true.) then - ! a virtual z-axis that has the same dimensions as y-axis - ! in the input file + ! Defining a virtual z-axis that has the same dimensions as y-axis + ! defined in the input file particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (pos_part(2) < y_cb(n + buff_size)) .and. (pos_part(2) >= y_cb(-buff_size - 1)) .and. & (pos_part(3) < lag_params%charwidth/2._wp) .and. (pos_part(3) >= -lag_params%charwidth/2._wp)) else - ! + ! cyl_coord particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (abs(pos_part(2)) < y_cb(n + buff_size)) .and. (abs(pos_part(2)) >= max(y_cb(-buff_size - 1), 0._wp))) end if - ! + ! 3D if (p > 0) then particle_in_domain = ((pos_part(1) < x_cb(m + buff_size)) .and. (pos_part(1) >= x_cb(-buff_size - 1)) .and. & (pos_part(2) < y_cb(n + buff_size)) .and. (pos_part(2) >= y_cb(-buff_size - 1)) .and. & (pos_part(3) < z_cb(p + buff_size)) .and. (pos_part(3) >= z_cb(-buff_size - 1))) end if - ! symmetric and wall boundary condition + ! For symmetric and wall boundary condition if (any(bc_x%beg == (/BC_REFLECTIVE, BC_CHAR_SLIP_WALL, BC_SLIP_WALL, BC_NO_SLIP_WALL/))) then particle_in_domain = (particle_in_domain .and. (pos_part(1) >= x_cb(-1))) end if @@ -1306,8 +1306,8 @@ contains end function particle_in_domain !> The purpose of this procedure is to determine if the lagrangian bubble is located in the - !! The ghost cells are not part of the physical domain. - !! Spatial coordinates of the bubble + !! physical domain. The ghost cells are not part of the physical domain. + !! @param pos_part Spatial coordinates of the bubble function particle_in_domain_physical(pos_part) logical :: particle_in_domain_physical @@ -1323,10 +1323,10 @@ contains end function particle_in_domain_physical !> The purpose of this procedure is to calculate the gradient of a scalar field along the x, y and z directions - !! second-order central difference considering uneven widths - !! Input scalar field - !! Output gradient of q - !! Gradient spatial direction + !! following a second-order central difference considering uneven widths + !! @param q Input scalar field + !! @param dq Output gradient of q + !! @param dir Gradient spatial direction subroutine s_gradient_dir(q, dq, dir) real(stp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:), intent(inout) :: q, dq @@ -1335,7 +1335,7 @@ contains integer :: i, j, k if (dir == 1) then - ! in x dir. + ! Gradient in x dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1350,7 +1350,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() elseif (dir == 2) then - ! in y dir. + ! Gradient in y dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1365,7 +1365,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() elseif (dir == 3) then - ! in z dir. + ! Gradient in z dir. $:GPU_PARALLEL_LOOP(private='[i,j,k]', collapse=3) do k = 0, p do j = 0, n @@ -1384,7 +1384,7 @@ contains end subroutine s_gradient_dir !> Subroutine that writes on each time step the changes of the lagrangian bubbles. - !! Current time + !! @param q_time Current time impure subroutine s_write_lag_particles(qtime) real(wp), intent(in) :: qtime @@ -1420,7 +1420,7 @@ contains FMT = "(F24.16,I14,8F24.16)" end if - ! through list + ! Cycle through list do k = 1, nBubs write (11, FMT) & qtime, & @@ -1440,9 +1440,9 @@ contains end subroutine s_write_lag_particles !> Subroutine that writes some useful statistics related to the volume fraction - !! particles (void fraction) in the computatioational domain - !! time step. - !! Current time + !! of the particles (void fraction) in the computatioational domain + !! on each time step. + !! @param q_time Current time impure subroutine s_write_void_evol(qtime) real(wp), intent(in) :: qtime @@ -1462,10 +1462,10 @@ contains if (.not. file_exist) then open (12, FILE=trim(file_loc), FORM='formatted', position='rewind') !write (12, *) 'currentTime, averageVoidFraction, ', & - ! totalParticlesVolume' + ! 'maximumVoidFraction, totalParticlesVolume' !write (12, *) 'The averageVoidFraction value does ', & - ! reflect the real void fraction in the cloud since the ', & - ! which do not have bubbles are not accounted' + ! 'not reflect the real void fraction in the cloud since the ', & + ! 'cells which do not have bubbles are not accounted' else open (12, FILE=trim(file_loc), FORM='formatted', position='append') end if @@ -1500,8 +1500,8 @@ contains end if #endif voltot = lag_void_avg - ! voidavg value does not reflect the real void fraction in the cloud - ! the cell which does not have bubbles are not accounted + ! This voidavg value does not reflect the real void fraction in the cloud + ! since the cell which does not have bubbles are not accounted if (lag_vol > 0._wp) lag_void_avg = lag_void_avg/lag_vol if (proc_rank == 0) then @@ -1516,10 +1516,10 @@ contains end subroutine s_write_void_evol !> Subroutine that writes the restarting files for the particles in the lagrangian solver. - !! Current time step + !! @param t_step Current time step impure subroutine s_write_restart_lag_bubbles(t_step) - ! string used to store the address of a particular file + ! Generic string used to store the address of a particular file integer, intent(in) :: t_step character(LEN=path_len + 2*name_len) :: file_loc @@ -1528,7 +1528,7 @@ contains integer :: i, k #ifdef MFC_MPI - ! Parallel I/O + ! For Parallel I/O integer :: ifile, ierr integer, dimension(MPI_STATUS_SIZE) :: status integer(KIND=MPI_OFFSET_KIND) :: disp @@ -1553,14 +1553,14 @@ contains lsizes(1) = bub_id lsizes(2) = lag_io_vars - ! number of particles + ! Total number of particles call MPI_ALLREDUCE(bub_id, tot_part, 1, MPI_integer, & MPI_SUM, MPI_COMM_WORLD, ierr) call MPI_ALLGATHER(bub_id, 1, MPI_INTEGER, proc_bubble_counts, 1, MPI_INTEGER, & MPI_COMM_WORLD, ierr) - ! starting index for this processor's particles + ! Calculate starting index for this processor's particles call MPI_EXSCAN(lsizes(1), start_idx_part(1), 1, MPI_INTEGER, MPI_SUM, MPI_COMM_WORLD, ierr) if (proc_rank == 0) start_idx_part(1) = 0 start_idx_part(2) = 0 @@ -1571,7 +1571,7 @@ contains write (file_loc, '(A,I0,A)') 'lag_bubbles_', t_step, '.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) - ! up existing file + ! Clean up existing file if (proc_rank == 0) then inquire (FILE=trim(file_loc), EXIST=file_exist) if (file_exist) then @@ -1586,7 +1586,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! header using MPI I/O for consistency + ! Write header using MPI I/O for consistency call MPI_FILE_WRITE(ifile, tot_part, 1, MPI_INTEGER, status, ierr) call MPI_FILE_WRITE(ifile, mytime, 1, mpi_p, status, ierr) call MPI_FILE_WRITE(ifile, dt, 1, mpi_p, status, ierr) @@ -1631,7 +1631,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! header (written by rank 0) + ! Skip header (written by rank 0) disp = int(sizeof(tot_part) + 2*sizeof(mytime) + sizeof(num_procs) + & num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1651,7 +1651,7 @@ contains ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! header (written by rank 0) + ! Skip header (written by rank 0) disp = int(sizeof(tot_part) + 2*sizeof(mytime) + sizeof(num_procs) + & num_procs*sizeof(proc_bubble_counts(1)), MPI_OFFSET_KIND) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, view, 'native', mpi_info_int, ierr) @@ -1726,7 +1726,7 @@ contains end subroutine s_write_lag_bubble_stats !> The purpose of this subroutine is to remove one specific particle if dt is too small. - !! Particle id + !! @param bub_id Particle id impure subroutine s_remove_lag_bubble(bub_id) integer, intent(in) :: bub_id diff --git a/src/simulation/m_bubbles_EL_kernels.fpp b/src/simulation/m_bubbles_EL_kernels.fpp index 3795dfa78a..f9114fd829 100644 --- a/src/simulation/m_bubbles_EL_kernels.fpp +++ b/src/simulation/m_bubbles_EL_kernels.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_bubbles_EL_kernels +!! @file +!! @brief Contains module m_bubbles_EL_kernels #:include 'macros.fpp' !> @brief This module contains kernel functions used to map the effect of the lagrangian bubbles -!! Eulerian framework. +!! in the Eulerian framework. module m_bubbles_EL_kernels use m_mpi_proxy !< Message passing interface (MPI) module proxy @@ -15,13 +15,13 @@ module m_bubbles_EL_kernels contains !> The purpose of this subroutine is to smear the strength of the lagrangian - !! the Eulerian framework using different approaches. - !! Number of lagrangian bubbles in the current domain - !! Radius of the bubbles - !! Interface velocity of the bubbles - !! Computational coordinates of the bubbles - !! Spatial coordinates of the bubbles - !! Eulerian variable to be updated + !! bubbles into the Eulerian framework using different approaches. + !! @param nBubs Number of lagrangian bubbles in the current domain + !! @param lbk_rad Radius of the bubbles + !! @param lbk_vel Interface velocity of the bubbles + !! @param lbk_s Computational coordinates of the bubbles + !! @param lbk_pos Spatial coordinates of the bubbles + !! @param updatedvar Eulerian variable to be updated subroutine s_smoothfunction(nBubs, lbk_rad, lbk_vel, lbk_s, lbk_pos, updatedvar) integer, intent(in) :: nBubs @@ -39,7 +39,7 @@ contains end subroutine s_smoothfunction !> The purpose of this procedure contains the algorithm to use the delta kernel function to map the effect of the bubbles. - !! of the bubbles only affects the cell where the bubble is located. + !! The effect of the bubbles only affects the cell where the bubble is located. subroutine s_deltafunc(nBubs, lbk_rad, lbk_vel, lbk_s, updatedvar) integer, intent(in) :: nBubs @@ -95,7 +95,7 @@ contains end subroutine s_deltafunc !> The purpose of this procedure contains the algorithm to use the gaussian kernel function to map the effect of the bubbles. - !! of the bubbles affects the 3X3x3 cells that surround the bubble. + !! The effect of the bubbles affects the 3X3x3 cells that surround the bubble. subroutine s_gaussian(nBubs, lbk_rad, lbk_vel, lbk_s, lbk_pos, updatedvar) integer, intent(in) :: nBubs @@ -156,7 +156,7 @@ contains call s_applygaussian(center, cellaux, nodecoord, stddsv, 0._wp, func) if (lag_params%cluster_type >= 4) call s_applygaussian(center, cellaux, nodecoord, stddsv, 1._wp, func2) - ! cells for bubbles intersecting symmetric boundaries + ! Relocate cells for bubbles intersecting symmetric boundaries if (any((/bc_x%beg, bc_x%end, bc_y%beg, bc_y%end, bc_z%beg, bc_z%end/) == BC_REFLECTIVE)) then call s_shift_cell_symmetric_bc(cellaux, cell) end if @@ -224,29 +224,29 @@ contains else if (cyl_coord) then !< 2D cylindrical function: - ! smear particles in the azimuthal direction for given r + ! We smear particles in the azimuthal direction for given r theta = 0._wp Nr = ceiling(2._wp*pi*nodecoord(2)/(y_cb(cellaux(2)) - y_cb(cellaux(2) - 1))) dtheta = 2._wp*pi/Nr L2 = center(2)**2._wp + nodecoord(2)**2._wp - 2._wp*center(2)*nodecoord(2)*cos(theta) distance = sqrt((center(1) - nodecoord(1))**2._wp + L2) - ! 2._wp is for symmetry (upper half of the 2D field (+r) is considered) + ! Factor 2._wp is for symmetry (upper half of the 2D field (+r) is considered) func = dtheta/2._wp/pi*exp(-0.5_wp*(distance/stddsv)**2._wp)/(sqrt(2._wp*pi)*stddsv)**3._wp Nr_count = 0._wp do while (Nr_count < Nr - 1._wp) Nr_count = Nr_count + 1._wp theta = Nr_count*dtheta - ! relation + ! trigonometric relation L2 = center(2)**2._wp + nodecoord(2)**2._wp - 2._wp*center(2)*nodecoord(2)*cos(theta) distance = sqrt((center(1) - nodecoord(1))**2._wp + L2) - ! is the azimuthal width of the cell + ! nodecoord(2)*dtheta is the azimuthal width of the cell func = func + & dtheta/2._wp/pi*exp(-0.5_wp*(distance/stddsv)**2._wp)/(sqrt(2._wp*pi)*stddsv)**(3._wp*(strength_idx + 1._wp)) end do else !< 2D cartesian function: - ! smear particles considering a virtual depth (lag_params%charwidth) + ! We smear particles considering a virtual depth (lag_params%charwidth) theta = 0._wp Nr = ceiling(lag_params%charwidth/(y_cb(cellaux(2)) - y_cb(cellaux(2) - 1))) Nr_count = 1._wp - mapCells*1._wp @@ -267,8 +267,8 @@ contains end subroutine s_applygaussian !> The purpose of this subroutine is to check if the current cell is outside the computational domain or not (including ghost cells). - !! Tested cell to smear the bubble effect in. - !! If true, then cellaux is outside the computational domain. + !! @param cellaux Tested cell to smear the bubble effect in. + !! @param celloutside If true, then cellaux is outside the computational domain. subroutine s_check_celloutside(cellaux, celloutside) $:GPU_ROUTINE(function_name='s_check_celloutside',parallelism='[seq]', & & cray_inline=True) @@ -301,8 +301,8 @@ contains end subroutine s_check_celloutside !> This subroutine relocates the current cell, if it intersects a symmetric boundary. - !! Cell of the current bubble - !! Cell to map the bubble effect in. + !! @param cell Cell of the current bubble + !! @param cellaux Cell to map the bubble effect in. subroutine s_shift_cell_symmetric_bc(cellaux, cell) $:GPU_ROUTINE(function_name='s_shift_cell_symmetric_bc', & & parallelism='[seq]', cray_inline=True) @@ -310,7 +310,7 @@ contains integer, dimension(3), intent(inout) :: cellaux integer, dimension(3), intent(in) :: cell - ! + ! x-dir if (bc_x%beg == BC_REFLECTIVE .and. (cell(1) <= mapCells - 1)) then cellaux(1) = abs(cellaux(1)) - 1 end if @@ -339,9 +339,9 @@ contains end subroutine s_shift_cell_symmetric_bc !> Calculates the standard deviation of the bubble being smeared in the Eulerian framework. - !! Cell where the bubble is located - !! Volume of the bubble - !! Standard deviaton + !! @param cell Cell where the bubble is located + !! @param volpart Volume of the bubble + !! @param stddsv Standard deviaton subroutine s_compute_stddsv(cell, volpart, stddsv) $:GPU_ROUTINE(function_name='s_compute_stddsv',parallelism='[seq]', & & cray_inline=True) @@ -379,8 +379,8 @@ contains end subroutine s_compute_stddsv !> The purpose of this procedure is to calculate the characteristic cell volume - !! Computational coordinates (x, y, z) - !! Characteristic volume + !! @param cell Computational coordinates (x, y, z) + !! @param Charvol Characteristic volume subroutine s_get_char_vol(cellx, celly, cellz, Charvol) $:GPU_ROUTINE(function_name='s_get_char_vol',parallelism='[seq]', & & cray_inline=True) @@ -401,9 +401,9 @@ contains end subroutine s_get_char_vol !> This subroutine transforms the computational coordinates of the bubble from - !! into integer. - !! Computational coordinates of the bubble, real type - !! Computational coordinates of the bubble, integer type + !! real type into integer. + !! @param s Computational coordinates of the bubble, real type + !! @param get_cell Computational coordinates of the bubble, integer type subroutine s_get_cell(s_cell, get_cell) $:GPU_ROUTINE(function_name='s_get_cell',parallelism='[seq]', & & cray_inline=True) diff --git a/src/simulation/m_cbc.fpp b/src/simulation/m_cbc.fpp index 18d0a4ffb5..41800cb638 100644 --- a/src/simulation/m_cbc.fpp +++ b/src/simulation/m_cbc.fpp @@ -1,22 +1,22 @@ !> -!! -!! module m_cbc +!! @file +!! @brief Contains module m_cbc !> @brief The module features a large database of characteristic boundary -!! for the Euler system of equations. This system -!! by the appropriate advection equations utilized to -!! material interfaces. The closure is achieved by the -!! of state and mixture relations. At this time, -!! CBC are available: -!! Wall -!! Subsonic Buffer -!! Subsonic Inflow -!! Subsonic Outflow -!! Subsonic Outflow -!! Pressure Subsonic Outflow -!! Inflow -!! Outflow -!! to Thompson (1987, 1990) for detailed descriptions. +!! conditions (CBC) for the Euler system of equations. This system +!! is augmented by the appropriate advection equations utilized to +!! capture the material interfaces. The closure is achieved by the +!! stiffened equation of state and mixture relations. At this time, +!! the following CBC are available: +!! 1) Slip Wall +!! 2) Nonreflecting Subsonic Buffer +!! 3) Nonreflecting Subsonic Inflow +!! 4) Nonreflecting Subsonic Outflow +!! 5) Force-Free Subsonic Outflow +!! 6) Constant Pressure Subsonic Outflow +!! 7) Supersonic Inflow +!! 8) Supersonic Outflow +!! Please refer to Thompson (1987, 1990) for detailed descriptions. #:include 'case.fpp' #:include 'macros.fpp' @@ -44,28 +44,28 @@ module m_cbc private; public :: s_initialize_cbc_module, s_cbc, s_finalize_cbc_module - !! primitive variables. They are obtained by reshaping (RS) - !! the coordinate direction normal to the domain boundary along - !! CBC is applied. + !! The cell-average primitive variables. They are obtained by reshaping (RS) + !! q_prim_vf in the coordinate direction normal to the domain boundary along + !! which the CBC is applied. real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsx_vf real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsy_vf real(wp), allocatable, dimension(:, :, :, :) :: q_prim_rsz_vf $:GPU_DECLARE(create='[q_prim_rsx_vf,q_prim_rsy_vf,q_prim_rsz_vf]') - !! (src - source). These are directly determined from the - !! variables, q_prims_rs_vf, and not a Riemann solver. + !! Cell-average fluxes (src - source). These are directly determined from the + !! cell-average primitive variables, q_prims_rs_vf, and not a Riemann solver. real(wp), allocatable, dimension(:, :, :, :) :: F_rsx_vf, F_src_rsx_vf !< real(wp), allocatable, dimension(:, :, :, :) :: F_rsy_vf, F_src_rsy_vf !< real(wp), allocatable, dimension(:, :, :, :) :: F_rsz_vf, F_src_rsz_vf !< $:GPU_DECLARE(create='[F_rsx_vf,F_src_rsx_vf,F_rsy_vf,F_src_rsy_vf,F_rsz_vf,F_src_rsz_vf]') - !! a CCE bug that is causing some subset of these variables to interfere - !! of the same name in m_riemann_solvers.fpp, and giving this versions - !! names works around the bug. Other private module allocatable arrays - !! declare create` clauses don't have this problem, so we still need to - !! bug. + !! There is a CCE bug that is causing some subset of these variables to interfere + !! with variables of the same name in m_riemann_solvers.fpp, and giving this versions + !! unique "_l" names works around the bug. Other private module allocatable arrays + !! in `acc declare create` clauses don't have this problem, so we still need to + !! isolate this bug. real(wp), allocatable, dimension(:, :, :, :) :: flux_rsx_vf_l, flux_src_rsx_vf_l !< real(wp), allocatable, dimension(:, :, :, :) :: flux_rsy_vf_l, flux_src_rsy_vf_l @@ -74,17 +74,17 @@ module m_cbc real(wp), allocatable, dimension(:) :: ds !< Cell-width distribution in the s-direction - ! Coefficients + ! CBC Coefficients real(wp), allocatable, dimension(:, :) :: fd_coef_x !< Finite diff. coefficients x-dir real(wp), allocatable, dimension(:, :) :: fd_coef_y !< Finite diff. coefficients y-dir real(wp), allocatable, dimension(:, :) :: fd_coef_z !< Finite diff. coefficients z-dir - !! dimension identifies the location of a coefficient in the FD - !! the last dimension denotes the location of the CBC. + !! The first dimension identifies the location of a coefficient in the FD + !! formula, while the last dimension denotes the location of the CBC. - ! with NVHPC when using nullified pointers in a declare create - ! pointer, dimension(:, :) :: fd_coef => null() + ! Bug with NVHPC when using nullified pointers in a declare create + ! real(wp), pointer, dimension(:, :) :: fd_coef => null() real(wp), allocatable, dimension(:, :, :) :: pi_coef_x !< Polynomial interpolant coefficients in x-dir real(wp), allocatable, dimension(:, :, :) :: pi_coef_y !< Polynomial interpolant coefficients in y-dir @@ -92,9 +92,9 @@ module m_cbc $:GPU_DECLARE(create='[ds,fd_coef_x,fd_coef_y,fd_coef_z,pi_coef_x,pi_coef_y,pi_coef_z]') - !! dimension of the array identifies the polynomial, the - !! identifies the position of its coefficients and the last - !! the location of the CBC. + !! The first dimension of the array identifies the polynomial, the + !! second dimension identifies the position of its coefficients and the last + !! dimension denotes the location of the CBC. type(int_bounds_info) :: is1, is2, is3 !< Indical bounds in the s1-, s2- and s3-directions $:GPU_DECLARE(create='[is1,is2,is3]') @@ -106,9 +106,9 @@ module m_cbc $:GPU_DECLARE(create='[dj,bcxb,bcxe,bcyb,bcye,bczb,bcze]') $:GPU_DECLARE(create='[cbc_dir, cbc_loc,flux_cbc_index]') - !! for subsonic inflow and outflow conditions consisting of - !! pressure, density and void fraction as well as - !! and pressure + !! GRCBC inputs for subsonic inflow and outflow conditions consisting of + !! inflow velocities, pressure, density and void fraction as well as + !! outflow velocities and pressure real(wp), allocatable, dimension(:) :: pres_in, pres_out, Del_in, Del_out real(wp), allocatable, dimension(:, :) :: vel_in, vel_out @@ -120,8 +120,8 @@ module m_cbc contains !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_cbc_module integer :: i @@ -270,7 +270,7 @@ contains end if - ! the cell-width distribution in the s-direction + ! Allocating the cell-width distribution in the s-direction @:ALLOCATE(ds(0:buff_size)) if (recon_type == WENO_TYPE) then @@ -284,7 +284,7 @@ contains idx2%beg = 0 idx2%end = muscl_order - 1 end if - ! CBC Coefficients in x-direction + ! Allocating/Computing CBC Coefficients in x-direction if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13)) then @:ALLOCATE(fd_coef_x(0:buff_size, -1:1)) @@ -318,7 +318,7 @@ contains end if - ! CBC Coefficients in y-direction + ! Allocating/Computing CBC Coefficients in y-direction if (n > 0) then if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13)) then @@ -356,7 +356,7 @@ contains end if - ! CBC Coefficients in z-direction + ! Allocating/Computing CBC Coefficients in z-direction if (p > 0) then if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13)) then @@ -397,8 +397,8 @@ contains $:GPU_UPDATE(device='[fd_coef_x,fd_coef_y,fd_coef_z, & & pi_coef_x,pi_coef_y,pi_coef_z]') - ! the procedural pointer to the appropriate subroutine - ! will be utilized in the conversion to the mixture variables + ! Associating the procedural pointer to the appropriate subroutine + ! that will be utilized in the conversion to the mixture variables bcxb = bc_x%beg bcxe = bc_x%end @@ -419,13 +419,13 @@ contains $:GPU_UPDATE(device='[bczb, bcze]') end if - ! GRCBC inputs + ! Allocate GRCBC inputs @:ALLOCATE(pres_in(1:num_dims), pres_out(1:num_dims)) @:ALLOCATE(Del_in(1:num_dims), Del_out(1:num_dims)) @:ALLOCATE(vel_in(1:num_dims, 1:num_dims), vel_out(1:num_dims, 1:num_dims)) @:ALLOCATE(alpha_rho_in(1:num_fluids, 1:num_dims), alpha_in(1:num_fluids, 1:num_dims)) - ! and update GRCBC inputs + ! Assign and update GRCBC inputs #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (${CBC_DIR}$ <= num_dims) then vel_in(${CBC_DIR}$, 1) = bc_${XYZ}$%vel_in(1) @@ -453,33 +453,33 @@ contains end subroutine s_initialize_cbc_module !> Compute CBC coefficients - !! CBC coordinate direction - !! CBC coordinate location + !! @param cbc_dir_in CBC coordinate direction + !! @param cbc_loc_in CBC coordinate location subroutine s_compute_cbc_coefficients(cbc_dir_in, cbc_loc_in) - ! The purpose of this subroutine is to compute the grid - ! FD and PI coefficients, or CBC coefficients, - ! the CBC coordinate direction and location. + ! Description: The purpose of this subroutine is to compute the grid + ! dependent FD and PI coefficients, or CBC coefficients, + ! provided the CBC coordinate direction and location. - ! coordinate direction and location + ! CBC coordinate direction and location integer, intent(in) :: cbc_dir_in, cbc_loc_in - ! locations in the s-direction + ! Cell-boundary locations in the s-direction real(wp), dimension(0:buff_size + 1) :: s_cb - ! loop iterator + ! Generic loop iterator integer :: i - ! CBC coefficients pointers + ! Associating CBC coefficients pointers call s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in) - ! the cell-boundary locations in the s-direction + ! Determining the cell-boundary locations in the s-direction s_cb(0) = 0._wp do i = 0, buff_size s_cb(i + 1) = s_cb(i) + ds(i) end do - ! CBC1 Coefficients + ! Computing CBC1 Coefficients #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (cbc_dir_in == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then if (weno_order == 1) then @@ -488,7 +488,7 @@ contains fd_coef_${XYZ}$ (0, cbc_loc_in) = -2._wp/(ds(0) + ds(1)) fd_coef_${XYZ}$ (1, cbc_loc_in) = -fd_coef_${XYZ}$ (0, cbc_loc_in) - ! CBC2 Coefficients + ! Computing CBC2 Coefficients elseif (weno_order == 3) then fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp @@ -498,7 +498,7 @@ contains pi_coef_${XYZ}$ (0, 0, cbc_loc_in) = (s_cb(0) - s_cb(1))/(s_cb(0) - s_cb(2)) - ! CBC4 Coefficients + ! Computing CBC4 Coefficients else fd_coef_${XYZ}$ (:, cbc_loc_in) = 0._wp @@ -547,25 +547,25 @@ contains end if #:endfor - ! Computing CBC4 Coefficients + ! END: Computing CBC4 Coefficients - ! CBC coefficients + ! Nullifying CBC coefficients end subroutine s_compute_cbc_coefficients - !! of the procedure is to associate the FD and PI - !! CBC coefficients, with the appropriate - !! on the coordinate direction and location - !! CBC. - !! CBC coordinate direction - !! CBC coordinate location + !! The goal of the procedure is to associate the FD and PI + !! coefficients, or CBC coefficients, with the appropriate + !! targets, based on the coordinate direction and location + !! of the CBC. + !! @param cbc_dir_in CBC coordinate direction + !! @param cbc_loc_in CBC coordinate location subroutine s_associate_cbc_coefficients_pointers(cbc_dir_in, cbc_loc_in) integer, intent(in) :: cbc_dir_in, cbc_loc_in integer :: i !< Generic loop iterator - ! CBC Coefficients in x-direction + ! Associating CBC Coefficients in x-direction if (cbc_dir_in == 1) then !fd_coef => fd_coef_x; if (weno_order > 1) pi_coef => pi_coef_x @@ -580,7 +580,7 @@ contains end do end if - ! CBC Coefficients in y-direction + ! Associating CBC Coefficients in y-direction elseif (cbc_dir_in == 2) then !fd_coef => fd_coef_y; if (weno_order > 1) pi_coef => pi_coef_y @@ -595,7 +595,7 @@ contains end do end if - ! CBC Coefficients in z-direction + ! Associating CBC Coefficients in z-direction else !fd_coef => fd_coef_z; if (weno_order > 1) pi_coef => pi_coef_z @@ -617,18 +617,18 @@ contains end subroutine s_associate_cbc_coefficients_pointers !> The following is the implementation of the CBC based on - !! of Thompson (1987, 1990) on hyperbolic systems. - !! is indirectly applied in the computation of the - !! near the relevant domain boundary - !! modification of the fluxes. - !! Cell-average primitive variables - !! Cell-boundary-average fluxes - !! Cell-boundary-average flux sources - !! CBC coordinate direction - !! CBC coordinate location - !! Index bound in the first coordinate direction - !! Index bound in the second coordinate direction - !! Index bound in the third coordinate direction + !! the work of Thompson (1987, 1990) on hyperbolic systems. + !! The CBC is indirectly applied in the computation of the + !! right-hand-side (RHS) near the relevant domain boundary + !! through the modification of the fluxes. + !! @param q_prim_vf Cell-average primitive variables + !! @param flux_vf Cell-boundary-average fluxes + !! @param flux_src_vf Cell-boundary-average flux sources + !! @param cbc_dir_norm CBC coordinate direction + !! @param cbc_loc_norm CBC coordinate location + !! @param ix Index bound in the first coordinate direction + !! @param iy Index bound in the second coordinate direction + !! @param iz Index bound in the third coordinate direction subroutine s_cbc(q_prim_vf, flux_vf, flux_src_vf, & cbc_dir_norm, cbc_loc_norm, & ix, iy, iz) @@ -691,9 +691,9 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! of inputted data and association of the FD and PI - ! or CBC coefficients, respectively, hinging on - ! CBC coordinate direction + ! Reshaping of inputted data and association of the FD and PI + ! coefficients, or CBC coefficients, respectively, hinging on + ! selected CBC coordinate direction cbc_dir = cbc_dir_norm cbc_loc = cbc_loc_norm @@ -708,7 +708,7 @@ contains #:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (cbc_dir == ${CBC_DIR}$ .and. recon_type == WENO_TYPE) then - ! of flux_rs_vf and flux_src_rs_vf at j = 1/2 + ! PI2 of flux_rs_vf and flux_src_rs_vf at j = 1/2 if (weno_order == 3 .or. dummy) then call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, & @@ -743,7 +743,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! of flux_rs_vf and flux_src_rs_vf at j = 1/2, 3/2 + ! PI4 of flux_rs_vf and flux_src_rs_vf at j = 1/2, 3/2 if (weno_order == 5 .or. dummy) then call s_convert_primitive_to_flux_variables(q_prim_rs${XYZ}$_vf, & F_rs${XYZ}$_vf, & @@ -794,12 +794,12 @@ contains end if - ! or FD4 of RHS at j = 0 + ! FD2 or FD4 of RHS at j = 0 $:GPU_PARALLEL_LOOP(collapse=2, private='[r,k,alpha_rho, vel, adv_local, mf, dvel_ds, dadv_ds, Re_cbc, dalpha_rho_ds, dpres_ds, dvel_dt, dadv_dt, dalpha_rho_dt, L, lambda, Ys, dYs_dt, dYs_ds, h_k, Cp_i, Gamma_i, Xs, drho_dt, dpres_dt, dpi_inf_dt, dqv_dt, dgamma_dt, rho, pres, E, H, gamma, pi_inf, qv, c, Ma, T, sum_Enthalpies, Cv, Cp, e_mix, Mw, R_gas, vel_K_sum, vel_dv_dt_sum, i, j]', copyin='[dir_idx]') do r = is3%beg, is3%end do k = is2%beg, is2%end - ! the Primitive Variables + ! Transferring the Primitive Variables $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe alpha_rho(i) = q_prim_rs${XYZ}$_vf(0, k, r, i) @@ -859,10 +859,10 @@ contains H = (E + pres)/rho - ! mixture sound speed + ! Compute mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv_local, vel_K_sum, 0._wp, c, qv) - ! Spatial Derivatives of Primitive Variables + ! First-Order Spatial Derivatives of Primitive Variables $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -923,7 +923,7 @@ contains end if end do - ! Temporal Derivatives of Primitive Variables + ! First-Order Temporal Derivatives of Primitive Variables lambda(1) = vel(dir_idx(1)) - c lambda(2) = vel(dir_idx(1)) lambda(3) = vel(dir_idx(1)) + c @@ -939,7 +939,7 @@ contains else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_INFLOW) .or. & (cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_INFLOW)) then call s_compute_nonreflecting_subsonic_inflow_L(lambda, L, rho, c, dpres_ds, dvel_ds) - ! GRCBC for Subsonic Inflow + ! Add GRCBC for Subsonic Inflow if (bc_${XYZ}$%grcbc_in) then $:GPU_LOOP(parallelism='[seq]') do i = 2, momxb @@ -960,11 +960,11 @@ contains else if ((cbc_loc == -1 .and. bc${XYZ}$b == BC_CHAR_NR_SUB_OUTFLOW) .or. & (cbc_loc == 1 .and. bc${XYZ}$e == BC_CHAR_NR_SUB_OUTFLOW)) then call s_compute_nonreflecting_subsonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds) - ! GRCBC for Subsonic Outflow (Pressure) + ! Add GRCBC for Subsonic Outflow (Pressure) if (bc_${XYZ}$%grcbc_out) then L(advxe) = c*(1._wp - Ma)*(pres - pres_out(${CBC_DIR}$))/Del_out(${CBC_DIR}$) - ! GRCBC for Subsonic Outflow (Normal Velocity) + ! Add GRCBC for Subsonic Outflow (Normal Velocity) if (bc_${XYZ}$%grcbc_vel_out) then L(advxe) = L(advxe) + rho*c**2._wp*(1._wp - Ma)*(vel(dir_idx(1)) + vel_out(${CBC_DIR}$, dir_idx(1))*sign(1, cbc_loc))/Del_out(${CBC_DIR}$) end if @@ -983,7 +983,7 @@ contains call s_compute_supersonic_outflow_L(lambda, L, rho, c, mf, dalpha_rho_ds, dpres_ds, dvel_ds, dadv_ds, dYs_ds) end if - ! careful about the cylindrical coordinate! + ! Be careful about the cylindrical coordinate! if (cyl_coord .and. cbc_dir == 2 .and. cbc_loc == 1) then dpres_dt = -5.e-1_wp*(L(advxe) + L(1)) + rho*c*c*vel(dir_idx(1)) & /y_cc(n) @@ -1018,7 +1018,7 @@ contains end do end if - ! treatment of void fraction source is unclear + ! The treatment of void fraction source is unclear if (cyl_coord .and. cbc_dir == 2 .and. cbc_loc == 1) then $:GPU_LOOP(parallelism='[seq]') do i = 1, advxe - E_idx @@ -1049,7 +1049,7 @@ contains end do end if - ! and flux_src_rs_vf_l at j = -1/2 + ! flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf_l(-1, k, r, i) = flux_rs${XYZ}$_vf_l(0, k, r, i) & @@ -1064,7 +1064,7 @@ contains end do if (chemistry) then - ! of LODI equation of energy for real gases adjusted to perfect gas, doi:10.1006/jcph.2002.6990 + ! Evolution of LODI equation of energy for real gases adjusted to perfect gas, doi:10.1006/jcph.2002.6990 call get_species_enthalpies_rt(T, h_k) sum_Enthalpies = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -1126,7 +1126,7 @@ contains end do end if - ! flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 + ! END: flux_rs_vf_l and flux_src_rs_vf_l at j = -1/2 end do end do @@ -1134,24 +1134,24 @@ contains end if #:endfor - ! FD2 or FD4 of RHS at j = 0 + ! END: FD2 or FD4 of RHS at j = 0 - ! reshaping of outputted data and disssociation of the FD and PI - ! or CBC coefficients, respectively, based on selected - ! coordinate direction. + ! The reshaping of outputted data and disssociation of the FD and PI + ! coefficients, or CBC coefficients, respectively, based on selected + ! CBC coordinate direction. call s_finalize_cbc(flux_vf, flux_src_vf) end subroutine s_cbc !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are required for the setup of the - !! - !! Cell-average primitive variables - !! Cell-boundary-average fluxes - !! Cell-boundary-average flux sources - !! Index bound in the first coordinate direction - !! Index bound in the second coordinate direction - !! Index bound in the third coordinate direction + !! the association of pointers and/or the execution of any + !! other procedures that are required for the setup of the + !! selected CBC. + !! @param q_prim_vf Cell-average primitive variables + !! @param flux_vf Cell-boundary-average fluxes + !! @param flux_src_vf Cell-boundary-average flux sources + !! @param ix Index bound in the first coordinate direction + !! @param iy Index bound in the second coordinate direction + !! @param iz Index bound in the third coordinate direction subroutine s_initialize_cbc(q_prim_vf, flux_vf, flux_src_vf, & ix, iy, iz) @@ -1167,11 +1167,11 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! the coordinate direction indexes and flags + ! Configuring the coordinate direction indexes and flags - ! the indicial shift based on CBC location + ! Determining the indicial shift based on CBC location - ! Allocation/Association of Primitive and Flux Variables + ! END: Allocation/Association of Primitive and Flux Variables if (cbc_dir == 1) then is1%beg = 0; is1%end = buff_size; is2 = iy; is3 = iz @@ -1188,7 +1188,7 @@ contains $:GPU_UPDATE(device='[is1,is2,is3,dj]') $:GPU_UPDATE(device='[dir_idx,dir_flg]') - ! Inputted Data in x-direction + ! Reshaping Inputted Data in x-direction if (cbc_dir == 1) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1268,9 +1268,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Inputted Data in x-direction + ! END: Reshaping Inputted Data in x-direction - ! Inputted Data in y-direction + ! Reshaping Inputted Data in y-direction elseif (cbc_dir == 2) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1350,9 +1350,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Inputted Data in y-direction + ! END: Reshaping Inputted Data in y-direction - ! Inputted Data in z-direction + ! Reshaping Inputted Data in z-direction else $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1433,17 +1433,17 @@ contains end if end if - ! Reshaping Inputted Data in z-direction + ! END: Reshaping Inputted Data in z-direction - ! of the procedural pointer to the appropriate procedure - ! will be utilized in the evaluation of L variables for the CBC + ! Association of the procedural pointer to the appropriate procedure + ! that will be utilized in the evaluation of L variables for the CBC end subroutine s_initialize_cbc !> Deallocation and/or the disassociation procedures that - !! in order to finalize the CBC application - !! Cell-boundary-average fluxes - !! Cell-boundary-average flux sources + !! are necessary in order to finalize the CBC application + !! @param flux_vf Cell-boundary-average fluxes + !! @param flux_src_vf Cell-boundary-average flux sources subroutine s_finalize_cbc(flux_vf, flux_src_vf) type(scalar_field), & @@ -1452,11 +1452,11 @@ contains integer :: i, j, k, r !< Generic loop iterators - ! the indicial shift based on CBC location + ! Determining the indicial shift based on CBC location dj = max(0, cbc_loc) $:GPU_UPDATE(device='[dj]') - ! Outputted Data in x-direction + ! Reshaping Outputted Data in x-direction if (cbc_dir == 1) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1509,9 +1509,9 @@ contains end do $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Outputted Data in x-direction + ! END: Reshaping Outputted Data in x-direction - ! Outputted Data in y-direction + ! Reshaping Outputted Data in y-direction elseif (cbc_dir == 2) then $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1566,9 +1566,9 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Reshaping Outputted Data in y-direction + ! END: Reshaping Outputted Data in y-direction - ! Outputted Data in z-direction + ! Reshaping Outputted Data in z-direction else $:GPU_PARALLEL_LOOP(private='[i,j,k,r]', collapse=4) @@ -1624,11 +1624,11 @@ contains end if end if - ! Reshaping Outputted Data in z-direction + ! END: Reshaping Outputted Data in z-direction end subroutine s_finalize_cbc - ! if the problem has any characteristic boundary conditions + ! Detext if the problem has any characteristic boundary conditions elemental subroutine s_any_cbc_boundaries(toggle) logical, intent(inout) :: toggle @@ -1652,7 +1652,7 @@ contains if (is_cbc .eqv. .false.) return - ! the cell-average primitive variables + ! Deallocating the cell-average primitive variables @:DEALLOCATE(q_prim_rsx_vf) if (weno_order > 1 .or. muscl_order > 1) then @:DEALLOCATE(F_rsx_vf, F_src_rsx_vf) @@ -1674,13 +1674,13 @@ contains @:DEALLOCATE(flux_rsz_vf_l, flux_src_rsz_vf_l) end if - ! the cell-width distribution in the s-direction + ! Deallocating the cell-width distribution in the s-direction @:DEALLOCATE(ds) - ! GRCBC inputs + ! Deallocating GRCBC inputs @:DEALLOCATE(vel_in, vel_out, pres_in, pres_out, Del_in, Del_out, alpha_rho_in, alpha_in) - ! CBC Coefficients in x-direction + ! Deallocating CBC Coefficients in x-direction if (all((/bc_x%beg, bc_x%end/) <= -5) .and. all((/bc_x%beg, bc_x%end/) >= -13) .or. & bc_x%beg <= -5 .and. bc_x%beg >= -13 .or. & bc_x%end <= -5 .and. bc_x%end >= -13) then @@ -1690,7 +1690,7 @@ contains end if end if - ! CBC Coefficients in y-direction + ! Deallocating CBC Coefficients in y-direction if (n > 0) then if (all((/bc_y%beg, bc_y%end/) <= -5) .and. all((/bc_y%beg, bc_y%end/) >= -13) .or. & bc_y%beg <= -5 .and. bc_y%beg >= -13 .or. & @@ -1702,7 +1702,7 @@ contains end if end if - ! CBC Coefficients in z-direction + ! Deallocating CBC Coefficients in z-direction if (p > 0) then if (all((/bc_z%beg, bc_z%end/) <= -5) .and. all((/bc_z%beg, bc_z%end/) >= -13) .or. & bc_z%beg <= -5 .and. bc_z%beg >= -13 .or. & diff --git a/src/simulation/m_checker.fpp b/src/simulation/m_checker.fpp index 436cbc59ac..4f78f9d52d 100644 --- a/src/simulation/m_checker.fpp +++ b/src/simulation/m_checker.fpp @@ -23,7 +23,7 @@ module m_checker contains !> Checks compatibility of parameters in the input file. - !! the simulation stage + !! Used by the simulation stage impure subroutine s_check_inputs call s_check_inputs_compilers @@ -77,7 +77,7 @@ contains !> Checks constraints on geometry and precision impure subroutine s_check_inputs_geometry_precision - ! spherical geometry in single precision + ! Prevent spherical geometry in single precision #ifdef MFC_SINGLE_PRECISION @:PROHIBIT(.not. (cyl_coord .neqv. .true. .or. (cyl_coord .and. p == 0)), "Fully 3D cylindrical grid (geometry = 3) is not supported in single precision.") #endif diff --git a/src/simulation/m_compute_cbc.fpp b/src/simulation/m_compute_cbc.fpp index ea0290f560..28ae092abb 100644 --- a/src/simulation/m_compute_cbc.fpp +++ b/src/simulation/m_compute_cbc.fpp @@ -1,6 +1,6 @@ !> -!! -!! computation module +!! @file +!! @brief CBC computation module #:include 'case.fpp' #:include 'macros.fpp' @@ -49,7 +49,7 @@ contains real(wp), intent(in) :: dpres_ds integer :: i - ! + ! $:GPU_LOOP(parallelism='[seq]') do i = 2, momxb L(i) = lambda_factor*lambda2*(c*c*dalpha_rho_ds(i - 1) - mf(i - 1)*dpres_ds) end do @@ -71,7 +71,7 @@ contains real(wp), intent(in) :: lambda_factor, lambda2 integer :: i - ! + ! $:GPU_LOOP(parallelism='[seq]') do i = momxb + 1, momxe L(i) = lambda_factor*lambda2*dvel_ds(dir_idx(i - contxe)) end do @@ -93,7 +93,7 @@ contains real(wp), intent(in) :: lambda_factor, lambda2 integer :: i - ! + ! $:GPU_LOOP(parallelism='[seq]') do i = E_idx, advxe - 1 L(i) = lambda_factor*lambda2*dadv_ds(i - momxe) end do @@ -117,7 +117,7 @@ contains if (.not. chemistry) return - ! + ! $:GPU_LOOP(parallelism='[seq]') do i = chemxb, chemxe L(i) = lambda_factor*lambda2*dYs_ds(i - chemxb + 1) end do diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 8faf749d67..d0986d9628 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -1,16 +1,16 @@ -!! -!! module m_data_output +!! @file +!! @brief Contains module m_data_output #:include 'macros.fpp' #:include 'case.fpp' !> @brief The primary purpose of this module is to output the grid and the -!! data at the chosen time-step interval. In -!! module is also in charge of outputting a run-time -!! which summarizes the time-dependent behavior !of -!! criteria. The latter include the inviscid Courant– -!! viscous CFL (VCFL), capillary CFL (CCFL) -!! Reynolds (Rc) numbers. +!! conservative variables data at the chosen time-step interval. In +!! addition, this module is also in charge of outputting a run-time +!! information file which summarizes the time-dependent behavior !of +!! the stability criteria. The latter include the inviscid Courant– +!! Friedrichs–Lewy (ICFL), viscous CFL (VCFL), capillary CFL (CCFL) +!! and cell Reynolds (Rc) numbers. module m_data_output use m_derived_types !< Definitions of the derived types @@ -80,9 +80,9 @@ module m_data_output contains !> Write data files. Dispatch subroutine that replaces procedure pointer. - !! Conservative variables - !! Primitive variables - !! Current time step + !! @param q_cons_vf Conservative variables + !! @param q_prim_vf Primitive variables + !! @param t_step Current time step impure subroutine s_write_data_files(q_cons_vf, q_T_sf, q_prim_vf, t_step, bc_type, beta) type(scalar_field), & @@ -114,23 +114,23 @@ contains end subroutine s_write_data_files !> The purpose of this subroutine is to open a new or pre- - !! information file and append to it the - !! information relevant to current simulation. - !! this requires generating a table header for - !! criteria which will be written at every - !! + !! existing run-time information file and append to it the + !! basic header information relevant to current simulation. + !! In general, this requires generating a table header for + !! those stability criteria which will be written at every + !! time-step. impure subroutine s_open_run_time_information_file character(LEN=name_len), parameter :: file_name = 'run_time.inf' !< - !! the run-time information file + !! Name of the run-time information file character(LEN=path_len + name_len) :: file_path !< - !! to a file in the case directory + !! Relative path to a file in the case directory character(LEN=8) :: file_date !< - !! of the run-time information file + !! Creation date of the run-time information file - ! the run-time information file + ! Opening the run-time information file file_path = trim(case_dir)//'/'//trim(file_name) open (3, FILE=trim(file_path), & @@ -157,7 +157,7 @@ contains write (3, '(A)') ''; write (3, '(A)') '' - ! table header for the stability criteria to be outputted + ! Generating table header for the stability criteria to be outputted write (3, '(13X,A9,13X,A10,13X,A10,13X,A10)', advance="no") & trim('Time-step'), trim('dt'), trim('Time'), trim('ICFL Max') @@ -171,19 +171,19 @@ contains end subroutine s_open_run_time_information_file !> This opens a formatted data file where the root processor - !! out the CoM information + !! can write out the CoM information impure subroutine s_open_com_files() character(len=path_len + 3*name_len) :: file_path !< - !! to the CoM file in the case directory + !! Relative path to the CoM file in the case directory integer :: i !< Generic loop iterator do i = 1, num_fluids - ! the relative path to the CoM data file + ! Generating the relative path to the CoM data file write (file_path, '(A,I0,A)') '/fluid', i, '_com.dat' file_path = trim(case_dir)//trim(file_path) - ! the formatted data file and setting up its - ! + ! Creating the formatted data file and setting up its + ! structure open (i + 120, file=trim(file_path), & form='formatted', & position='append', & @@ -211,22 +211,22 @@ contains end subroutine s_open_com_files !> This opens a formatted data file where the root processor - !! out flow probe information + !! can write out flow probe information impure subroutine s_open_probe_files character(LEN=path_len + 3*name_len) :: file_path !< - !! to the probe data file in the case directory + !! Relative path to the probe data file in the case directory integer :: i !< Generic loop iterator logical :: file_exist do i = 1, num_probes - ! the relative path to the data file + ! Generating the relative path to the data file write (file_path, '(A,I0,A)') '/D/probe', i, '_prim.dat' file_path = trim(case_dir)//trim(file_path) - ! the formatted data file and setting up its - ! + ! Creating the formatted data file and setting up its + ! structure inquire (file=trim(file_path), exist=file_exist) if (file_exist) then @@ -256,12 +256,12 @@ contains end subroutine s_open_probe_files !> The goal of the procedure is to output to the run-time - !! the stability criteria extrema in the - !! domain and at the given time-step. - !! subroutine is also in charge of tracking - !! criteria extrema over all time-steps. - !! Cell-average primitive variables - !! Current time step + !! information file the stability criteria extrema in the + !! entire computational domain and at the given time-step. + !! Moreover, the subroutine is also in charge of tracking + !! these stability criteria extrema over all time-steps. + !! @param q_prim_vf Cell-average primitive variables + !! @param t_step Current time step impure subroutine s_write_run_time_information(q_prim_vf, t_step) type(scalar_field), dimension(sys_size), intent(in) :: q_prim_vf @@ -285,7 +285,7 @@ contains real(wp), dimension(2) :: Re !< Cell-avg. Reynolds numbers integer :: j, k, l - ! Stability Criteria at Current Time-step + ! Computing Stability Criteria at Current Time-step $:GPU_PARALLEL_LOOP(collapse=3, private='[j,k,l,vel, alpha, Re, rho, vel_sum, pres, gamma, pi_inf, c, H, qv]') do l = 0, p do k = 0, n @@ -305,9 +305,9 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! Computing Stability Criteria at Current Time-step + ! end: Computing Stability Criteria at Current Time-step - ! local stability criteria extrema at current time-step + ! Determining local stability criteria extrema at current time-step #ifdef _CRAYFTN $:GPU_UPDATE(host='[icfl_sf]') @@ -334,7 +334,7 @@ contains end if #endif - ! global stability criteria extrema at current time-step + ! Determining global stability criteria extrema at current time-step if (num_procs > 1) then call s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, & vcfl_max_loc, & @@ -348,7 +348,7 @@ contains if (viscous) Rc_min_glb = Rc_min_loc end if - ! the stability criteria extrema over all the time-steps + ! Determining the stability criteria extrema over all the time-steps if (icfl_max_glb > icfl_max) icfl_max = icfl_max_glb if (viscous) then @@ -356,7 +356,7 @@ contains if (Rc_min_glb < Rc_min) Rc_min = Rc_min_glb end if - ! global stability criteria extrema at current time-step + ! Outputting global stability criteria extrema at current time-step if (proc_rank == 0) then write (3, '(13X,I9,13X,F10.6,13X,F10.6,13X,F10.6)', advance="no") & t_step, dt, mytime, icfl_max_glb @@ -391,10 +391,10 @@ contains end subroutine s_write_run_time_information !> The goal of this subroutine is to output the grid and - !! data files for given time-step. - !! Cell-average conservative variables - !! Cell-average primitive variables - !! Current time-step + !! conservative variables data files for given time-step. + !! @param q_cons_vf Cell-average conservative variables + !! @param q_prim_vf Cell-average primitive variables + !! @param t_step Current time-step impure subroutine s_write_serial_data_files(q_cons_vf, q_T_sf, q_prim_vf, t_step, bc_type, beta) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -405,13 +405,13 @@ contains type(integer_field), dimension(1:num_dims, -1:1), intent(in) :: bc_type character(LEN=path_len + 2*name_len) :: t_step_dir !< - !! to the current time-step directory + !! Relative path to the current time-step directory character(LEN=path_len + 3*name_len) :: file_path !< - !! to the grid and conservative variables data files + !! Relative path to the grid and conservative variables data files logical :: file_exist !< - !! to check existence of current time-step directory + !! Logical used to check existence of current time-step directory character(LEN=15) :: FMT @@ -419,10 +419,10 @@ contains real(wp) :: gamma, lit_gamma, pi_inf, qv !< Temporary EOS params - ! or overwriting the time-step root directory + ! Creating or overwriting the time-step root directory write (t_step_dir, '(A,I0,A,I0)') trim(case_dir)//'/p_all' - ! or overwriting the current time-step directory + ! Creating or overwriting the current time-step directory write (t_step_dir, '(a,i0,a,i0)') trim(case_dir)//'/p_all/p', & proc_rank, '/', t_step @@ -431,7 +431,7 @@ contains if (file_exist) call s_delete_directory(trim(t_step_dir)) call s_create_directory(trim(t_step_dir)) - ! the grid data file in the x-direction + ! Writing the grid data file in the x-direction file_path = trim(t_step_dir)//'/x_cb.dat' open (2, FILE=trim(file_path), & @@ -439,7 +439,7 @@ contains STATUS='new') write (2) x_cb(-1:m); close (2) - ! the grid data files in the y- and z-directions + ! Writing the grid data files in the y- and z-directions if (n > 0) then file_path = trim(t_step_dir)//'/y_cb.dat' @@ -462,7 +462,7 @@ contains end if - ! the conservative variables data files + ! Writing the conservative variables data files do i = 1, sys_size write (file_path, '(A,I0,A)') trim(t_step_dir)//'/q_cons_vf', & i, '.dat' @@ -502,7 +502,7 @@ contains end do end if - ! the IB markers + ! Writing the IB markers if (ib) then write (file_path, '(A,I0,A)') trim(t_step_dir)//'/ib.dat' @@ -524,7 +524,7 @@ contains FMT = "(2F40.14)" end if - ! an output directory + ! writing an output directory write (t_step_dir, '(A,I0,A,I0)') trim(case_dir)//'/D' file_path = trim(t_step_dir)//'/.' @@ -537,7 +537,7 @@ contains do i = 1, sys_size $:GPU_UPDATE(host='[q_prim_vf(i)%sf(:,:,:)]') end do - ! stores the value of nb needed in riemann solvers, so replace with true primitive value (=1._wp) + ! q_prim_vf(bubxb) stores the value of nb needed in riemann solvers, so replace with true primitive value (=1._wp) if (qbmm) then q_prim_vf(bubxb)%sf = 1._wp end if @@ -552,7 +552,7 @@ contains open (2, FILE=trim(file_path)) do j = 0, m - ! revisit change here + ! todo: revisit change here if (((i >= adv_idx%beg) .and. (i <= adv_idx%end))) then write (2, FMT) x_cb(j), q_cons_vf(i)%sf(j, 0, 0) else @@ -605,7 +605,7 @@ contains FMT = "(3F40.14)" end if - ! + ! 2D if ((n > 0) .and. (p == 0)) then do i = 1, sys_size write (file_path, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -690,7 +690,7 @@ contains FMT = "(4F40.14)" end if - ! + ! 3D if (p > 0) then do i = 1, sys_size write (file_path, '(A,I0,A,I2.2,A,I6.6,A)') trim(t_step_dir)//'/cons.', i, '.', proc_rank, '.', t_step, '.dat' @@ -787,10 +787,10 @@ contains end subroutine s_write_serial_data_files !> The goal of this subroutine is to output the grid and - !! data files for given time-step. - !! Cell-average conservative variables - !! Current time-step - !! Eulerian void fraction from lagrangian bubbles + !! conservative variables data files for given time-step. + !! @param q_cons_vf Cell-average conservative variables + !! @param t_step Current time-step + !! @param beta Eulerian void fraction from lagrangian bubbles impure subroutine s_write_parallel_data_files(q_cons_vf, t_step, bc_type, beta) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -818,7 +818,7 @@ contains integer :: alt_sys !< Altered system size for the lagrangian subgrid bubble model - ! sampling variables + ! Down sampling variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_save, n_glb_save, p_glb_save ! Global save size @@ -838,7 +838,7 @@ contains call s_int_to_str(t_step, t_step_string) - ! MPI data I/O + ! Initialize MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_temp_ds) else @@ -860,10 +860,10 @@ contains call s_mpi_barrier() call DelayFileAccess(proc_rank) - ! MPI data I/O + ! Initialize MPI data I/O call s_initialize_mpi_data(q_cons_vf) - ! the file to write all flow variables + ! Open the file to write all flow variables write (file_loc, '(I0,A,i7.7,A)') t_step, '_', proc_rank, '.dat' file_loc = trim(case_dir)//'/restart_data/lustre_'//trim(t_step_string)//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -874,20 +874,20 @@ contains mpi_info_int, ifile, ierr) if (down_sample) then - ! of local arrays + ! Size of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_save = m_glb_ds + 1 n_glb_save = n_glb_ds + 1 p_glb_save = p_glb_ds + 1 else - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_save = m_glb + 1 n_glb_save = n_glb + 1 p_glb_save = p_glb + 1 end if - ! some integers so MPI can write even the biggest files + ! Resize some integers so MPI can write even the biggest files m_MOK = int(m_glb_save + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb_save + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb_save + 1, MPI_OFFSET_KIND) @@ -897,7 +897,7 @@ contains NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) if (bubbles_euler) then - ! the data for each variable + ! Write the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) @@ -933,7 +933,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) else - ! MPI data I/O + ! Initialize MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, levelset, levelset_norm) @@ -952,10 +952,10 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, ior(MPI_MODE_WRONLY, MPI_MODE_CREATE), & mpi_info_int, ifile, ierr) - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! some integers so MPI can write even the biggest files + ! Resize some integers so MPI can write even the biggest files m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -965,11 +965,11 @@ contains NVARS_MOK = int(alt_sys, MPI_OFFSET_KIND) if (bubbles_euler) then - ! the data for each variable + ! Write the data for each variable do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -982,7 +982,7 @@ contains do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -995,7 +995,7 @@ contains do i = 1, sys_size !TODO: check if correct (sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(i), & @@ -1005,11 +1005,11 @@ contains end do end if - ! for the lagrangian subgrid bubble model + ! Correction for the lagrangian subgrid bubble model if (present(beta)) then var_MOK = int(sys_size + 1, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_p, MPI_IO_DATA%view(sys_size + 1), & @@ -1043,10 +1043,10 @@ contains end subroutine s_write_parallel_data_files !> This writes a formatted data file where the root processor - !! out the CoM information - !! Current time-step - !! Center of mass information - !! Higher moment information + !! can write out the CoM information + !! @param t_step Current time-step + !! @param q_com Center of mass information + !! @param moments Higher moment information impure subroutine s_write_com_files(t_step, c_mass_in) integer, intent(in) :: t_step @@ -1054,7 +1054,7 @@ contains integer :: i !< Generic loop iterator real(wp) :: nondim_time !< Non-dimensional time - ! time calculation + ! Non-dimensional time calculation if (t_step_old /= dflt_int) then nondim_time = real(t_step + t_step_old, wp)*dt else @@ -1095,9 +1095,9 @@ contains end subroutine s_write_com_files !> This writes a formatted data file for the flow probe information - !! Current time-step - !! Conservative variables - !! Acceleration magnitude information + !! @param t_step Current time-step + !! @param q_cons_vf Conservative variables + !! @param accel_mag Acceleration magnitude information impure subroutine s_write_probe_files(t_step, q_cons_vf, accel_mag) integer, intent(in) :: t_step @@ -1108,9 +1108,9 @@ contains real(wp), dimension(-1:n) :: disty real(wp), dimension(-1:p) :: distz - ! cell-averaged partial densities, density, velocity, pressure, - ! fractions, specific heat ratio function, liquid stiffness - ! and sound speed. + ! The cell-averaged partial densities, density, velocity, pressure, + ! volume fractions, specific heat ratio function, liquid stiffness + ! function, and sound speed. real(wp) :: lit_gamma, nbub real(wp) :: rho real(wp), dimension(num_vels) :: vel @@ -1142,7 +1142,7 @@ contains real(wp) :: nondim_time !< Non-dimensional time real(wp) :: tmp !< - !! to store quantity for mpi_allreduce + !! Temporary variable to store quantity for mpi_allreduce integer :: npts !< Number of included integral points real(wp) :: rad, thickness !< For integral quantities @@ -1152,7 +1152,7 @@ contains T = dflt_T_guess - ! time calculation + ! Non-dimensional time calculation if (time_stepper == 23) then nondim_time = mytime else @@ -1164,7 +1164,7 @@ contains end if do i = 1, num_probes - ! out flow variables for all processors + ! Zeroing out flow variables for all processors rho = 0._wp do s = 1, num_vels vel(s) = 0._wp @@ -1191,8 +1191,8 @@ contains end do damage_state = 0._wp - ! probe location in terms of indices on a - ! processor + ! Find probe location in terms of indices on a + ! specific processor if (n == 0) then ! 1D simulation if ((probe(i)%x >= x_cb(-1)) .and. (probe(i)%x <= x_cb(m))) then do s = -1, m @@ -1210,7 +1210,7 @@ contains end do end if - ! necessary state variables + ! Computing/Sharing necessary state variables if (elasticity) then call s_convert_to_mixture_variables(q_cons_vf, j - 2, k, l, & rho, gamma, pi_inf, qv, & @@ -1297,7 +1297,7 @@ contains ptot = pres - ptilde end if - ! mixture sound Speed + ! Compute mixture sound Speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1326,7 +1326,7 @@ contains if (k == 1) k = 2 ! Pick first point if probe is at edge l = 0 - ! necessary state variables + ! Computing/Sharing necessary state variables call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l, & rho, gamma, pi_inf, qv, & Re, G_local, fluid_pp(:)%G) @@ -1387,7 +1387,7 @@ contains R(:) = nR(:)/nbub Rdot(:) = nRdot(:)/nbub end if - ! mixture sound speed + ! Compute mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1416,7 +1416,7 @@ contains if (k == 1) k = 2 ! Pick first point if probe is at edge if (l == 1) l = 2 ! Pick first point if probe is at edge - ! necessary state variables + ! Computing/Sharing necessary state variables call s_convert_to_mixture_variables(q_cons_vf, j - 2, k - 2, l - 2, & rho, gamma, pi_inf, qv, & Re, G_local, fluid_pp(:)%G) @@ -1452,7 +1452,7 @@ contains rhoYks, pres, T) end if - ! mixture sound speed + ! Compute mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, & ((gamma + 1._wp)*pres + pi_inf)/rho, alpha, 0._wp, 0._wp, c, qv) @@ -1529,8 +1529,8 @@ contains Rdot(1), & nR(1), & nRdot(1) - ! & - ! + ! ptilde, & + ! ptot end if else if (bubbles_euler .and. (num_fluids == 3)) then write (i + 30, '(6x,f12.6,f24.8,f24.8,f24.8,f24.8,f24.8,'// & @@ -1766,15 +1766,15 @@ contains end subroutine s_write_probe_files !> The goal of this subroutine is to write to the run-time - !! basic footer information applicable to - !! computation and to close the file when done. - !! contains the stability criteria extrema over - !! the time-steps and the simulation run-time. + !! information file basic footer information applicable to + !! the current computation and to close the file when done. + !! The footer contains the stability criteria extrema over + !! all of the time-steps and the simulation run-time. impure subroutine s_close_run_time_information_file real(wp) :: run_time !< Run-time of the simulation - ! the footer of and closing the run-time information file + ! Writing the footer of and closing the run-time information file write (3, '(A)') ' ' write (3, '(A)') '' @@ -1813,13 +1813,13 @@ contains end subroutine s_close_probe_files !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_data_output_module integer :: i, m_ds, n_ds, p_ds - ! ICFL, VCFL, CCFL and Rc stability criteria + ! Allocating/initializing ICFL, VCFL, CCFL and Rc stability criteria if (run_time_info) then @:ALLOCATE(icfl_sf(0:m, 0:n, 0:p)) icfl_max = 0._wp @@ -1860,7 +1860,7 @@ contains end if if (run_time_info) then - ! the ICFL, VCFL, CCFL, and Rc stability criteria + ! Deallocating the ICFL, VCFL, CCFL, and Rc stability criteria @:DEALLOCATE(icfl_sf) if (viscous) then @:DEALLOCATE(vcfl_sf, Rc_sf) diff --git a/src/simulation/m_derived_variables.fpp b/src/simulation/m_derived_variables.fpp index 86cd7a5ac9..589d5710a3 100644 --- a/src/simulation/m_derived_variables.fpp +++ b/src/simulation/m_derived_variables.fpp @@ -1,12 +1,12 @@ !> -!! -!! module m_derived_variables +!! @file +!! @brief Contains module m_derived_variables !> @brief This module features subroutines that allow for the derivation of -!! variables from the conservative and primitive ones. -!! available derived variables include the unadvected -!! specific heat ratio, liquid stiffness, speed of -!! and the numerical Schlieren function. +!! numerous flow variables from the conservative and primitive ones. +!! Currently, the available derived variables include the unadvected +!! volume fraction, specific heat ratio, liquid stiffness, speed of +!! sound, vorticity and the numerical Schlieren function. #:include 'macros.fpp' module m_derived_variables @@ -33,10 +33,10 @@ module m_derived_variables s_finalize_derived_variables_module !> @name Finite-difference coefficients - !! coefficients in x-, y- and z-coordinate directions. - !! because sufficient boundary information is available for all the - !! directions, the centered family of the finite-difference - !! used. + !! Finite-difference (fd) coefficients in x-, y- and z-coordinate directions. + !! Note that because sufficient boundary information is available for all the + !! active coordinate directions, the centered family of the finite-difference + !! schemes is used. !> @{ real(wp), public, allocatable, dimension(:, :) :: fd_coeff_x real(wp), public, allocatable, dimension(:, :) :: fd_coeff_y @@ -45,7 +45,7 @@ module m_derived_variables $:GPU_DECLARE(create='[fd_coeff_x,fd_coeff_y,fd_coeff_z]') - ! Variables for computing acceleration + ! @name Variables for computing acceleration !> @{ real(wp), public, allocatable, dimension(:, :, :) :: accel_mag real(wp), public, allocatable, dimension(:, :, :) :: x_accel, y_accel, z_accel @@ -55,18 +55,18 @@ module m_derived_variables contains !> Computation of parameters, allocation procedures, and/or - !! tasks needed to properly setup the module + !! any other tasks needed to properly setup the module impure subroutine s_initialize_derived_variables_module - ! the variables which will store the coefficients of the - ! family of finite-difference schemes. Note that sufficient - ! is allocated so that the coefficients up to any chosen order - ! accuracy may be bookkept. However, if higher than fourth-order - ! coefficients are wanted, the formulae required to compute - ! coefficients will have to be implemented in the subroutine - ! + ! Allocating the variables which will store the coefficients of the + ! centered family of finite-difference schemes. Note that sufficient + ! space is allocated so that the coefficients up to any chosen order + ! of accuracy may be bookkept. However, if higher than fourth-order + ! accuracy coefficients are wanted, the formulae required to compute + ! these coefficients will have to be implemented in the subroutine + ! s_compute_finite_difference_coefficients. - ! centered finite-difference coefficients + ! Allocating centered finite-difference coefficients if (probe_wrt) then @:ALLOCATE(fd_coeff_x(-fd_number:fd_number, 0:m)) if (n > 0) then @@ -92,12 +92,12 @@ contains impure subroutine s_initialize_derived_variables if (probe_wrt) then - ! and writing header of flow probe files + ! Opening and writing header of flow probe files if (proc_rank == 0) then call s_open_probe_files() call s_open_com_files() end if - ! centered finite difference coefficients + ! Computing centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x]') @@ -117,7 +117,7 @@ contains end subroutine s_initialize_derived_variables !> Writes coherent body information, communication files, and probes. - !! Current time-step + !! @param t_step Current time-step subroutine s_compute_derived_variables(t_step, q_cons_vf, q_prim_ts1, q_prim_ts2) integer, intent(in) :: t_step @@ -177,17 +177,17 @@ contains end subroutine s_compute_derived_variables !> This subroutine receives as inputs the indicator of the - !! the acceleration that should be outputted and - !! variables. From those inputs, it proceeds - !! values of the desired acceleration component, - !! subsequently stored in derived flow quantity - !! q_sf. - !! Acceleration component indicator - !! Primitive variables - !! Primitive variables - !! Primitive variables - !! Primitive variables - !! Acceleration component + !! component of the acceleration that should be outputted and + !! the primitive variables. From those inputs, it proceeds + !! to calculate values of the desired acceleration component, + !! which are subsequently stored in derived flow quantity + !! storage variable, q_sf. + !! @param i Acceleration component indicator + !! @param q_prim_vf0 Primitive variables + !! @param q_prim_vf1 Primitive variables + !! @param q_prim_vf2 Primitive variables + !! @param q_prim_vf3 Primitive variables + !! @param q_sf Acceleration component subroutine s_derive_acceleration_component(i, q_prim_vf0, q_prim_vf1, & q_prim_vf2, q_prim_vf3, q_sf) @@ -202,7 +202,7 @@ contains integer :: j, k, l, r !< Generic loop iterators - ! the acceleration component in the x-coordinate direction + ! Computing the acceleration component in the x-coordinate direction if (i == 1) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -286,7 +286,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if end if - ! the acceleration component in the y-coordinate direction + ! Computing the acceleration component in the y-coordinate direction elseif (i == 2) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -357,7 +357,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if end if - ! the acceleration component in the z-coordinate direction + ! Computing the acceleration component in the z-coordinate direction else $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) do l = 0, p @@ -416,12 +416,12 @@ contains end subroutine s_derive_acceleration_component !> This subroutine is used together with the volume fraction - !! when called upon, it computes the location of - !! center of mass for each fluid from the inputted - !! q_prim_vf. The computed location - !! written to a formatted data file by the root process. - !! Primitive variables - !! Mass,x-location,y-location,z-location + !! model and when called upon, it computes the location of + !! of the center of mass for each fluid from the inputted + !! primitive variables, q_prim_vf. The computed location + !! is then written to a formatted data file by the root process. + !! @param q_prim_vf Primitive variables + !! @param c_m Mass,x-location,y-location,z-location impure subroutine s_derive_center_of_mass(q_vf, c_m) type(scalar_field), dimension(sys_size), intent(IN) :: q_vf real(wp), dimension(1:num_fluids, 1:5), intent(INOUT) :: c_m @@ -447,13 +447,13 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids !Loop over individual fluids dV = dx(j) - ! + ! Mass $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! weighted + ! x-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! fraction + ! Volume fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -469,16 +469,16 @@ contains $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids !Loop over individual fluids dV = dx(j)*dy(k) - ! + ! Mass $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! weighted + ! x-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! weighted + ! y-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! fraction + ! Volume fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -495,19 +495,19 @@ contains do i = 1, num_fluids !Loop over individual fluids dV = dx(j)*dy(k)*dz(l) - ! + ! Mass $:GPU_ATOMIC(atomic='update') c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! weighted + ! x-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! weighted + ! y-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! weighted + ! z-location weighted $:GPU_ATOMIC(atomic='update') c_m(i, 4) = c_m(i, 4) + q_vf(i)%sf(j, k, l)*dV*z_cc(l) - ! fraction + ! Volume fraction $:GPU_ATOMIC(atomic='update') c_m(i, 5) = c_m(i, 5) + q_vf(i + advxb - 1)%sf(j, k, l)*dV end do @@ -521,7 +521,7 @@ contains if (n == 0) then !1D simulation do i = 1, num_fluids !Loop over individual fluids - ! all components across all processors using MPI_ALLREDUCE + ! Sum all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -533,12 +533,12 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! quotients + ! Compute quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) end do elseif (p == 0) then !2D simulation do i = 1, num_fluids !Loop over individual fluids - ! all components across all processors using MPI_ALLREDUCE + ! Sum all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -553,13 +553,13 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! quotients + ! Compute quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) c_m(i, 3) = c_m(i, 3)/c_m(i, 1) end do else !3D simulation do i = 1, num_fluids !Loop over individual fluids - ! all components across all processors using MPI_ALLREDUCE + ! Sum all components across all processors using MPI_ALLREDUCE if (num_procs > 1) then tmp = c_m(i, 1) call s_mpi_allreduce_sum(tmp, tmp_out) @@ -577,7 +577,7 @@ contains call s_mpi_allreduce_sum(tmp, tmp_out) c_m(i, 5) = tmp_out end if - ! quotients + ! Compute quotients c_m(i, 2) = c_m(i, 2)/c_m(i, 1) c_m(i, 3) = c_m(i, 3)/c_m(i, 1) c_m(i, 4) = c_m(i, 4)/c_m(i, 1) @@ -589,7 +589,7 @@ contains !> Deallocation procedures for the module impure subroutine s_finalize_derived_variables_module - ! CoM and flow probe files + ! Closing CoM and flow probe files if (proc_rank == 0) then call s_close_com_files() if (probe_wrt) then @@ -607,8 +607,8 @@ contains end if end if - ! the variables that might have been used to bookkeep - ! finite-difference coefficients in the x-, y- and z-directions + ! Deallocating the variables that might have been used to bookkeep + ! the finite-difference coefficients in the x-, y- and z-directions if (allocated(fd_coeff_x)) deallocate (fd_coeff_x) if (allocated(fd_coeff_y)) deallocate (fd_coeff_y) if (allocated(fd_coeff_z)) deallocate (fd_coeff_z) diff --git a/src/simulation/m_fftw.fpp b/src/simulation/m_fftw.fpp index c90b0a9d83..03f5df32a6 100644 --- a/src/simulation/m_fftw.fpp +++ b/src/simulation/m_fftw.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_fftw +!! @file +!! @brief Contains module m_fftw #:include 'macros.fpp' @@ -39,10 +39,10 @@ module m_fftw real(c_double), pointer :: data_real(:) !< Real data complex(c_double_complex), pointer :: data_cmplx(:) !< - !! in Fourier space + !! Complex data in Fourier space complex(c_double_complex), pointer :: data_fltr_cmplx(:) !< - !! data in Fourier space + !! Filtered complex data in Fourier space #if defined(MFC_GPU) $:GPU_DECLARE(create='[real_size,cmplx_size,x_size,batch_size,Nfq]') @@ -57,7 +57,7 @@ module m_fftw integer :: fwd_plan_gpu, bwd_plan_gpu #else !> @endcond - type(c_ptr) :: fwd_plan_gpu, bwd_plan_gpu !< GPU FFT plan handles + type(c_ptr) :: fwd_plan_gpu, bwd_plan_gpu !> @cond #endif !> @endcond @@ -70,15 +70,15 @@ module m_fftw contains !> The purpose of this subroutine is to create the fftw plan - !! be used in the forward and backward DFTs when - !! Fourier filter in the azimuthal direction. + !! that will be used in the forward and backward DFTs when + !! applying the Fourier filter in the azimuthal direction. impure subroutine s_initialize_fftw_module integer :: ierr !< Generic flag used to identify and report GPU errors - ! of input array going into DFT + ! Size of input array going into DFT real_size = p + 1 - ! of output array coming out of DFT + ! Size of output array coming out of DFT cmplx_size = (p + 1)/2 + 1 x_size = m + 1 @@ -95,16 +95,16 @@ contains $:GPU_ENTER_DATA(copyin='[real_size,cmplx_size,x_size,sys_size,batch_size,Nfq]') $:GPU_UPDATE(device='[real_size,cmplx_size,x_size,sys_size,batch_size]') #else - ! input and output DFT data sizes + ! Allocate input and output DFT data sizes fftw_real_data = fftw_alloc_real(int(real_size, c_size_t)) fftw_cmplx_data = fftw_alloc_complex(int(cmplx_size, c_size_t)) fftw_fltr_cmplx_data = fftw_alloc_complex(int(cmplx_size, c_size_t)) - ! input and output data pointers with allocated memory + ! Associate input and output data pointers with allocated memory call c_f_pointer(fftw_real_data, data_real, [real_size]) call c_f_pointer(fftw_cmplx_data, data_cmplx, [cmplx_size]) call c_f_pointer(fftw_fltr_cmplx_data, data_fltr_cmplx, [cmplx_size]) - ! plans for forward and backward DFTs + ! Generate plans for forward and backward DFTs fwd_plan = fftw_plan_dft_r2c_1d(real_size, data_real, data_cmplx, FFTW_ESTIMATE) bwd_plan = fftw_plan_dft_c2r_1d(real_size, data_fltr_cmplx, data_real, FFTW_ESTIMATE) #endif @@ -127,17 +127,17 @@ contains end subroutine s_initialize_fftw_module !> The purpose of this subroutine is to apply a Fourier low- - !! to the flow variables in the azimuthal direction - !! the high-frequency content. This alleviates the - !! condition arising from cells near the axis. - !! Conservative variables + !! pass filter to the flow variables in the azimuthal direction + !! to remove the high-frequency content. This alleviates the + !! restrictive CFL condition arising from cells near the axis. + !! @param q_cons_vf Conservative variables impure subroutine s_apply_fourier_filter(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer :: i, j, k, l !< Generic loop iterators integer :: ierr !< Generic flag used to identify and report GPU errors - ! filter to processors that have cells adjacent to axis + ! Restrict filter to processors that have cells adjacent to axis if (bc_y%beg >= 0) return #if defined(MFC_GPU) @@ -281,7 +281,7 @@ contains end do end do - ! Fourier filter to additional rings + ! Apply Fourier filter to additional rings do i = 1, fourier_rings Nfq = min(floor(2_dp*real(i, dp)*pi), cmplx_size) do j = 0, m @@ -301,8 +301,8 @@ contains end subroutine s_apply_fourier_filter !> The purpose of this subroutine is to destroy the fftw plan - !! be used in the forward and backward DFTs when - !! Fourier filter in the azimuthal direction. + !! that will be used in the forward and backward DFTs when + !! applying the Fourier filter in the azimuthal direction. impure subroutine s_finalize_fftw_module #if defined(MFC_GPU) diff --git a/src/simulation/m_global_parameters.fpp b/src/simulation/m_global_parameters.fpp index 7d23d6751c..7736425f33 100644 --- a/src/simulation/m_global_parameters.fpp +++ b/src/simulation/m_global_parameters.fpp @@ -1,16 +1,16 @@ !> -!! -!! module m_global_parameters +!! @file +!! @brief Contains module m_global_parameters #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains all of the parameters describing the program -!! computational domain and the simulation algorithm. -!! the volume fraction model, physical parameters -!! of the fluids present in the flow are located here. They -!! gas equation of state parameters, the Reynolds -!! the Weber numbers. +!! logistics, the computational domain and the simulation algorithm. +!! Additionally, for the volume fraction model, physical parameters +!! of each of the fluids present in the flow are located here. They +!! include stiffened gas equation of state parameters, the Reynolds +!! numbers and the Weber numbers. module m_global_parameters #ifdef MFC_MPI @@ -21,20 +21,20 @@ module m_global_parameters use m_helper_basic !< Functions to compare floating point numbers - ! + ! $:USE_GPU_MODULE() implicit none real(wp) :: wall_time = 0 real(wp) :: wall_time_avg = 0 - ! + ! Logistics integer :: num_procs !< Number of processors character(LEN=path_len) :: case_dir !< Case folder location logical :: run_time_info !< Run-time output flag integer :: t_step_old !< Existing IC/grid folder - ! Domain Parameters + ! Computational Domain Parameters integer :: proc_rank !< Rank of the local processor !> @name Number of cells in the x-, y- and z-directions, respectively @@ -69,7 +69,7 @@ module m_global_parameters real(wp), target, allocatable, dimension(:) :: x_cc, y_cc, z_cc !> @} !type(bounds_info) :: x_domain, y_domain, z_domain !< - !! the domain bounds in the x-, y- and z-coordinate directions + !! Locations of the domain bounds in the x-, y- and z-coordinate directions !> @name Cell-width distributions in the x-, y- and z-directions, respectively !> @{ @@ -81,13 +81,13 @@ module m_global_parameters $:GPU_DECLARE(create='[x_cb,y_cb,z_cb,x_cc,y_cc,z_cc,dx,dy,dz,dt,m,n,p]') !> @name Starting time-step iteration, stopping time-step iteration and the number - !! iterations between successive solution backups, respectively + !! of time-step iterations between successive solution backups, respectively !> @{ integer :: t_step_start, t_step_stop, t_step_save !> @} !> @name Starting time, stopping time, and time between backups, simulation time, - !! cfl respectively + !! and prescribed cfl respectively !> @{ real(wp) :: t_stop, t_save, cfl_target integer :: n_start @@ -98,7 +98,7 @@ module m_global_parameters integer :: t_step_print !< Number of time-steps between printouts - ! Algorithm Parameters + ! Simulation Algorithm Parameters integer :: model_eqns !< Multicomponent flow model #:if MFC_CASE_OPTIMIZATION integer, parameter :: num_dims = ${num_dims}$ !< Number of spatial dimensions @@ -159,9 +159,9 @@ module m_global_parameters !> @{ logical :: nv_uvm_out_of_core ! Enable out-of-core storage of q_cons_ts(2) in timestepping (default FALSE) integer :: nv_uvm_igr_temps_on_gpu ! 0 => jac, jac_rhs, and jac_old on CPU - ! => jac on GPU, jac_rhs and jac_old on CPU - ! => jac and jac_rhs on GPU, jac_old on CPU - ! => jac, jac_rhs, and jac_old on GPU (default) + ! 1 => jac on GPU, jac_rhs and jac_old on CPU + ! 2 => jac and jac_rhs on GPU, jac_old on CPU + ! 3 => jac, jac_rhs, and jac_old on GPU (default) logical :: nv_uvm_pref_gpu ! Enable explicit gpu memory hints (default FALSE) !> @} @@ -203,7 +203,7 @@ module m_global_parameters #:endfor real(wp), dimension(3) :: accel_bf $:GPU_DECLARE(create='[accel_bf]') - ! + ! $:GPU_DECLARE(create='[k_x,w_x,p_x,g_x,k_y,w_y,p_y,g_y,k_z,w_z,p_z,g_z]') integer :: cpu_start, cpu_end, cpu_rate @@ -251,10 +251,10 @@ module m_global_parameters $:GPU_DECLARE(create='[down_sample]') integer, allocatable, dimension(:) :: proc_coords !< - !! in MPI_CART_COMM + !! Processor coordinates in MPI_CART_COMM integer, allocatable, dimension(:) :: start_idx !< - !! index of local processor in global grid + !! Starting cell-center index of local processor in global grid type(mpi_io_var), public :: MPI_IO_DATA type(mpi_io_ib_var), public :: MPI_IO_IB_DATA @@ -270,7 +270,7 @@ module m_global_parameters !> @} !> @name Annotations of the structure of the state and flux vectors in terms of the - !! the configuration of the system of equations to which they belong + !! size and the configuration of the system of equations to which they belong !> @{ integer :: sys_size !< Number of unknowns in system of eqns. type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns. @@ -297,20 +297,20 @@ module m_global_parameters $:GPU_DECLARE(create='[pi_inf_idx,B_idx,stress_idx,xi_idx,b_size]') $:GPU_DECLARE(create='[tensor_size,species_idx,c_idx]') - ! Indices for the (local) interior points (O-m, O-n, 0-p). - ! for "InDices With INTerior". + ! Cell Indices for the (local) interior points (O-m, O-n, 0-p). + ! Stands for "InDices With INTerior". type(int_bounds_info) :: idwint(1:3) $:GPU_DECLARE(create='[idwint]') - ! Indices for the entire (local) domain. In simulation and post_process, - ! includes the buffer region. idwbuff and idwint are the same otherwise. - ! for "InDices With BUFFer". + ! Cell Indices for the entire (local) domain. In simulation and post_process, + ! this includes the buffer region. idwbuff and idwint are the same otherwise. + ! Stands for "InDices With BUFFer". type(int_bounds_info) :: idwbuff(1:3) $:GPU_DECLARE(create='[idwbuff]') !> @name The number of fluids, along with their identifying indexes, respectively, - !! viscous effects, e.g. the shear and/or the volume Reynolds (Re) - !! be non-negligible. + !! for which viscous effects, e.g. the shear and/or the volume Reynolds (Re) + !! numbers, will be non-negligible. !> @{ integer, dimension(2) :: Re_size integer :: Re_size_max @@ -319,11 +319,11 @@ module m_global_parameters $:GPU_DECLARE(create='[Re_size,Re_size_max,Re_idx]') - ! WENO average (WA) flag regulates whether the calculation of any cell- - ! spatial derivatives is carried out in each cell by utilizing the - ! mean of the left and right, WENO-reconstructed, cell-boundary - ! or simply, the unaltered left and right, WENO-reconstructed, cell- - ! values. + ! The WENO average (WA) flag regulates whether the calculation of any cell- + ! average spatial derivatives is carried out in each cell by utilizing the + ! arithmetic mean of the left and right, WENO-reconstructed, cell-boundary + ! values or simply, the unaltered left and right, WENO-reconstructed, cell- + ! boundary values. !> @{ real(wp) :: wa_flg !> @{ @@ -331,9 +331,9 @@ module m_global_parameters $:GPU_DECLARE(create='[wa_flg]') !> @name The coordinate direction indexes and flags (flg), respectively, for which - !! will be determined with respect to a working direction - !! will be used to isolate the contributions, in that direction, in - !! split system of equations. + !! the configurations will be determined with respect to a working direction + !! and that will be used to isolate the contributions, in that direction, in + !! the dimensionally split system of equations. !> @{ integer, dimension(3) :: dir_idx real(wp), dimension(3) :: dir_flg @@ -343,44 +343,44 @@ module m_global_parameters $:GPU_DECLARE(create='[dir_idx,dir_flg,dir_idx_tau]') integer :: buff_size !< - !! of cells that are necessary to be able to store enough boundary - !! to march the solution in the physical computational domain - !! next time-step. + !! The number of cells that are necessary to be able to store enough boundary + !! conditions data to march the solution in the physical computational domain + !! to the next time-step. $:GPU_DECLARE(create='[buff_size]') integer :: shear_num !! Number of shear stress components integer, dimension(3) :: shear_indices !< - !! the stress components that represent shear stress + !! Indices of the stress components that represent shear stress integer :: shear_BC_flip_num !< - !! shear stress components to reflect for boundary conditions + !! Number of shear stress components to reflect for boundary conditions integer, dimension(3, 2) :: shear_BC_flip_indices !< - !! shear stress components to reflect for boundary conditions. - !! 1:shear_BC_flip_num) for (x/y/z, [indices]) + !! Indices of shear stress components to reflect for boundary conditions. + !! Size: (1:3, 1:shear_BC_flip_num) for (x/y/z, [indices]) $:GPU_DECLARE(create='[shear_num,shear_indices,shear_BC_flip_num,shear_BC_flip_indices]') - ! Simulation Algorithm Parameters + ! END: Simulation Algorithm Parameters - ! Physical Parameters + ! Fluids Physical Parameters type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !< - !! the physical parameters of each of the fluids that is present - !! flow. These include the stiffened gas equation of state parameters, - !! Reynolds numbers. + !! Database of the physical parameters of each of the fluids that is present + !! in the flow. These include the stiffened gas equation of state parameters, + !! and the Reynolds numbers. - ! Bubble Parameters + ! Subgrid Bubble Parameters type(subgrid_bubble_physical_parameters) :: bub_pp integer :: fd_order !< - !! of the finite-difference (fd) approximations of the first-order - !! need to be evaluated when the CoM or flow probe data - !! to be written at each time step + !! The order of the finite-difference (fd) approximations of the first-order + !! derivatives that need to be evaluated when the CoM or flow probe data + !! files are to be written at each time step integer :: fd_number !< - !! number is given by MAX(1, fd_order/2). Essentially, - !! a measure of the half-size of the finite-difference stencil for the - !! of accuracy. + !! The finite-difference number is given by MAX(1, fd_order/2). Essentially, + !! it is a measure of the half-size of the finite-difference stencil for the + !! selected order of accuracy. $:GPU_DECLARE(create='[fd_order,fd_number]') logical :: probe_wrt @@ -404,10 +404,10 @@ module m_global_parameters type(ib_patch_parameters), dimension(num_patches_max) :: patch_ib type(vec3_dt), allocatable, dimension(:) :: airfoil_grid_u, airfoil_grid_l integer :: Np - !! the immersed boundary patch parameters for each of the - !! in the configuration of the initial condition. Note that - !! allowable number of patches, num_patches_max, may be changed - !! module m_derived_types.f90. + !! Database of the immersed boundary patch parameters for each of the + !! patches employed in the configuration of the initial condition. Note that + !! the maximum allowable number of patches, num_patches_max, may be changed + !! in the module m_derived_types.f90. $:GPU_DECLARE(create='[ib,num_ibs,patch_ib]') !> @} @@ -564,18 +564,18 @@ module m_global_parameters contains !> Assigns default values to the user inputs before reading - !! This enables for an easier consistency check of - !! once they are read from the input file. + !! them in. This enables for an easier consistency check of + !! these parameters once they are read from the input file. impure subroutine s_assign_default_values_to_user_inputs integer :: i, j !< Generic loop iterator - ! + ! Logistics case_dir = '.' run_time_info = .false. t_step_old = dflt_int - ! domain parameters + ! Computational domain parameters m = dflt_int; n = 0; p = 0 call s_update_cell_bounds(cells_bounds, m, n, p) @@ -597,12 +597,12 @@ contains t_stop = dflt_real t_save = dflt_real - ! UVM options + ! NVIDIA UVM options nv_uvm_out_of_core = .false. nv_uvm_igr_temps_on_gpu = 3 ! => jac, jac_rhs, and jac_old on GPU (default) nv_uvm_pref_gpu = .false. - ! algorithm parameters + ! Simulation algorithm parameters model_eqns = dflt_int mpp_lim = .false. time_stepper = dflt_int @@ -679,7 +679,7 @@ contains y_domain%beg = dflt_real; y_domain%end = dflt_real z_domain%beg = dflt_real; z_domain%end = dflt_real - ! physical parameters + ! Fluids physical parameters do i = 1, num_fluids_max fluid_pp(i)%gamma = dflt_real fluid_pp(i)%pi_inf = dflt_real @@ -690,7 +690,7 @@ contains fluid_pp(i)%G = 0._wp end do - ! bubble parameters + ! Subgrid bubble parameters bub_pp%R0ref = dflt_real; R0ref = dflt_real bub_pp%p0ref = dflt_real; p0ref = dflt_real bub_pp%rho0ref = dflt_real; rho0ref = dflt_real @@ -712,15 +712,15 @@ contains bub_pp%R_v = dflt_real; R_v = dflt_real bub_pp%R_g = dflt_real; R_g = dflt_real - ! EOS + ! Tait EOS rhoref = dflt_real pref = dflt_real - ! Boundaries + ! Immersed Boundaries ib = .false. num_ibs = dflt_int - ! modeling + ! Bubble modeling bubbles_euler = .false. bubble_model = 1 polytropic = .true. @@ -744,7 +744,7 @@ contains pi_fac = 1._wp - ! inputs for qbmm for simulation code + ! User inputs for qbmm for simulation code qbmm = .false. Eu = dflt_real @@ -753,11 +753,11 @@ contains Web = dflt_real poly_sigma = dflt_real - ! source + ! Acoustic source acoustic_source = .false. num_source = dflt_int - ! tension + ! Surface tension sigma = dflt_real surface_tension = .false. @@ -823,14 +823,14 @@ contains integral(i)%ymax = dflt_real end do - ! flags + ! GRCBC flags #:for dir in {'x', 'y', 'z'} bc_${dir}$%grcbc_in = .false. bc_${dir}$%grcbc_out = .false. bc_${dir}$%grcbc_vel_out = .false. #:endfor - ! subgrid bubble model + ! Lagrangian subgrid bubble model bubbles_lagrange = .false. lag_params%solver_approach = dflt_int lag_params%cluster_type = dflt_int @@ -845,12 +845,12 @@ contains lag_params%charwidth = dflt_real lag_params%valmaxvoid = dflt_real - ! damage model + ! Continuum damage model tau_star = dflt_real cont_damage_s = dflt_real alpha_bar = dflt_real - ! + ! MHD Bx0 = dflt_real hyper_cleaning_speed = dflt_real hyper_cleaning_tau = dflt_real @@ -863,15 +863,15 @@ contains end subroutine s_assign_default_values_to_user_inputs !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_global_parameters_module integer :: i, j, k integer :: fac #:if not MFC_CASE_OPTIMIZATION - ! the degree of the WENO polynomials + ! Determining the degree of the WENO polynomials if (recon_type == WENO_TYPE) then weno_polyn = (weno_order - 1)/2 if (teno) then @@ -889,20 +889,20 @@ contains $:GPU_UPDATE(device='[igr,igr_order,igr_iter_solver]') #:endif - ! the number of fluids for which viscous effects will - ! non-negligible, the number of distinctive material interfaces - ! which surface tension will be important and also, the number - ! fluids for which the physical and geometric curvatures of the - ! will be computed + ! Initializing the number of fluids for which viscous effects will + ! be non-negligible, the number of distinctive material interfaces + ! for which surface tension will be important and also, the number + ! of fluids for which the physical and geometric curvatures of the + ! interfaces will be computed Re_size = 0 Re_size_max = 0 - ! Model + ! Gamma/Pi_inf Model if (model_eqns == 1) then - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the gamma/pi_inf model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the gamma/pi_inf model cont_idx%beg = 1 cont_idx%end = cont_idx%beg mom_idx%beg = cont_idx%end + 1 @@ -914,12 +914,12 @@ contains pi_inf_idx = adv_idx%end sys_size = adv_idx%end - ! Fraction Model + ! Volume Fraction Model else - ! structure of the state and flux vectors belonging - ! the system of equations defined by the selected number of - ! dimensions and the volume fraction model + ! Annotating structure of the state and flux vectors belonging + ! to the system of equations defined by the selected number of + ! spatial dimensions and the volume fraction model if (model_eqns == 2) then cont_idx%beg = 1 cont_idx%end = num_fluids @@ -928,17 +928,17 @@ contains E_idx = mom_idx%end + 1 if (igr) then - ! fractions are stored in the indices immediately following - ! energy equation. IGR tracks a total of (N-1) volume fractions - ! N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 - ! adv_idx%end < adv_idx%beg, which skips all loops over the - ! fractions since there is no volume fraction to track + ! Volume fractions are stored in the indices immediately following + ! the energy equation. IGR tracks a total of (N-1) volume fractions + ! for N fluids, hence the "-1" in adv_idx%end. If num_fluids = 1 + ! then adv_idx%end < adv_idx%beg, which skips all loops over the + ! volume fractions since there is no volume fraction to track adv_idx%beg = E_idx + 1 ! Alpha for fluid 1 adv_idx%end = E_idx + num_fluids - 1 else - ! fractions are stored in the indices immediately following - ! energy equation. WENO/MUSCL + Riemann tracks a total of (N) - ! fractions for N fluids, hence the lack of "-1" in adv_idx%end + ! Volume fractions are stored in the indices immediately following + ! the energy equation. WENO/MUSCL + Riemann tracks a total of (N) + ! volume fractions for N fluids, hence the lack of "-1" in adv_idx%end adv_idx%beg = E_idx + 1 adv_idx%end = E_idx + num_fluids end if @@ -956,7 +956,7 @@ contains if (qbmm) then nmomsp = 4 !number of special moments if (nnode == 4) then - ! = 6 : It is already a parameter + ! nmom = 6 : It is already a parameter nmomtot = nmom*nb end if bub_idx%end = adv_idx%end + nb*nmom @@ -1071,8 +1071,8 @@ contains end if end if - ! the number of fluids for which the shear and the - ! Reynolds numbers, e.g. viscous effects, are important + ! Determining the number of fluids for which the shear and the + ! volume Reynolds numbers, e.g. viscous effects, are important do i = 1, num_fluids if (fluid_pp(i)%Re(1) > 0) Re_size(1) = Re_size(1) + 1 if (fluid_pp(i)%Re(2) > 0) Re_size(2) = Re_size(2) + 1 @@ -1085,8 +1085,8 @@ contains $:GPU_UPDATE(device='[Re_size,Re_size_max,shear_stress,bulk_stress]') - ! the indexes of any viscous fluids and any pairs of - ! whose interface will support effects of surface tension + ! Bookkeeping the indexes of any viscous fluids and any pairs of + ! fluids whose interface will support effects of surface tension if (viscous) then @:ALLOCATE(Re_idx(1:2, 1:Re_size_max)) @@ -1116,10 +1116,10 @@ contains stress_idx%beg = sys_size + 1 stress_idx%end = sys_size + (num_dims*(num_dims + 1))/2 if (cyl_coord) stress_idx%end = stress_idx%end + 1 - ! of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D + ! number of stresses is 1 in 1D, 3 in 2D, 4 in 2D-Axisym, 6 in 3D sys_size = stress_idx%end - ! stress index is 2 for 2D and 2,4,5 for 3D + ! shear stress index is 2 for 2D and 2,4,5 for 3D if (num_dims == 1) then shear_num = 0 else if (num_dims == 2) then @@ -1127,7 +1127,7 @@ contains shear_indices(1) = stress_idx%beg - 1 + 2 shear_BC_flip_num = 1 shear_BC_flip_indices(1:2, 1) = shear_indices(1) - ! x-dir and y-dir: flip tau_xy only + ! Both x-dir and y-dir: flip tau_xy only else if (num_dims == 3) then shear_num = 3 shear_indices(1:3) = stress_idx%beg - 1 + (/2, 4, 5/) @@ -1135,21 +1135,21 @@ contains shear_BC_flip_indices(1, 1:2) = shear_indices((/1, 2/)) shear_BC_flip_indices(2, 1:2) = shear_indices((/1, 3/)) shear_BC_flip_indices(3, 1:2) = shear_indices((/2, 3/)) - ! flip tau_xy and tau_xz - ! flip tau_xy and tau_yz - ! flip tau_xz and tau_yz + ! x-dir: flip tau_xy and tau_xz + ! y-dir: flip tau_xy and tau_yz + ! z-dir: flip tau_xz and tau_yz end if $:GPU_UPDATE(device='[shear_num,shear_indices,shear_BC_flip_num,shear_BC_flip_indices]') end if if (hyperelasticity) then - ! of entries in the symmetric btensor plus the jacobian + ! number of entries in the symmetric btensor plus the jacobian b_size = (num_dims*(num_dims + 1))/2 + 1 - ! the jacobian in the last entry + ! storing the jacobian in the last entry tensor_size = num_dims**2 + 1 xi_idx%beg = sys_size + 1 xi_idx%end = sys_size + num_dims - ! three more equations for the \xi field and the elastic energy + ! adding three more equations for the \xi field and the elastic energy sys_size = xi_idx%end + 1 end if @@ -1170,7 +1170,7 @@ contains end if - ! Volume Fraction Model + ! END: Volume Fraction Model if (chemistry) then species_idx%beg = sys_size + 1 @@ -1207,15 +1207,15 @@ contains end do end if - ! the WENO average flag that will be used to regulate - ! any spatial derivatives are to computed in each cell by - ! the arithmetic mean of left and right, WENO-reconstructed, - ! values or otherwise, the unaltered left and right, - ! cell-boundary values + ! Configuring the WENO average flag that will be used to regulate + ! whether any spatial derivatives are to computed in each cell by + ! using the arithmetic mean of left and right, WENO-reconstructed, + ! cell-boundary values or otherwise, the unaltered left and right, + ! WENO-reconstructed, cell-boundary values wa_flg = 0._wp; if (weno_avg) wa_flg = 1._wp $:GPU_UPDATE(device='[wa_flg]') - ! to default WENO-JS if no other WENO scheme is selected + ! Resort to default WENO-JS if no other WENO scheme is selected #:if not MFC_CASE_OPTIMIZATION wenojs = .not. (mapped_weno .or. wenoz .or. teno) #:endif @@ -1242,7 +1242,7 @@ contains num_dims, igr, ib) $:GPU_UPDATE(device='[idwint, idwbuff]') - ! Coordinate Direction Indexes + ! Configuring Coordinate Direction Indexes if (bubbles_euler) then @:ALLOCATE(ptil(& & idwbuff(1)%beg:idwbuff(1)%end, & @@ -1316,7 +1316,7 @@ contains $:GPU_UPDATE(device='[relax,relax_model,palpha_eps,ptgalpha_eps]') - ! grid variables for the x-, y- and z-directions + ! Allocating grid variables for the x-, y- and z-directions @:ALLOCATE(x_cb(-1 - buff_size:m + buff_size)) @:ALLOCATE(x_cc(-buff_size:m + buff_size)) @:ALLOCATE(dx(-buff_size:m + buff_size)) @@ -1365,17 +1365,17 @@ contains #ifdef MFC_MPI - ! for Lustre file system (Darter/Comet/Stampede) + ! Option for Lustre file system (Darter/Comet/Stampede) write (mpiiofs, '(A)') '/lustre_' mpiiofs = trim(mpiiofs) call MPI_INFO_CREATE(mpi_info_int, ierr) call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr) - ! for UNIX file system (Hooke/Thomson) - ! '(A)') '/ufs_' - ! = TRIM(mpiiofs) - ! = MPI_INFO_NULL + ! Option for UNIX file system (Hooke/Thomson) + ! WRITE(mpiiofs, '(A)') '/ufs_' + ! mpiiofs = TRIM(mpiiofs) + ! mpi_info_int = MPI_INFO_NULL allocate (start_idx(1:num_dims)) @@ -1388,9 +1388,9 @@ contains integer :: i - ! the variables bookkeeping the indexes of any viscous - ! and any pairs of fluids whose interfaces supported effects - ! surface tension + ! Deallocating the variables bookkeeping the indexes of any viscous + ! fluids and any pairs of fluids whose interfaces supported effects + ! of surface tension if (viscous) then @:DEALLOCATE(Re_idx) end if @@ -1415,7 +1415,7 @@ contains if (ib) MPI_IO_IB_DATA%var%sf => null() - ! grid variables for the x-, y- and z-directions + ! Deallocating grid variables for the x-, y- and z-directions @:DEALLOCATE(x_cb, x_cc, dx) if (n == 0) return; diff --git a/src/simulation/m_hyperelastic.fpp b/src/simulation/m_hyperelastic.fpp index cbc2eba49c..0133613904 100644 --- a/src/simulation/m_hyperelastic.fpp +++ b/src/simulation/m_hyperelastic.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_hyperelastic +!! @file +!! @brief Contains module m_hyperelastic #:include 'macros.fpp' !> @brief This module consists of subroutines used in the calculation -!! cauchy tensor +!! of the cauchy tensor module m_hyperelastic @@ -23,8 +23,8 @@ module m_hyperelastic s_initialize_hyperelastic_module, & s_finalize_hyperelastic_module - !! at the cell-interior Gaussian quadrature points. - !! is needed to be calculated once and make the code DRY. + !! The btensor at the cell-interior Gaussian quadrature points. + !! These tensor is needed to be calculated once and make the code DRY. type(vector_field) :: btensor !< $:GPU_DECLARE(create='[btensor]') @@ -38,13 +38,13 @@ module m_hyperelastic contains !> The following subroutine handles the calculation of the btensor. - !! of the btensor takes qprimvf. - !! Primitive variables - !! is the output - !! grad_xi, grad_xi is a nxn tensor - !! inverse of grad_xi to obtain F, F is a nxn tensor - !! FFtranspose to obtain the btensor, btensor is nxn tensor - !! symmetric, save the data space + !! The calculation of the btensor takes qprimvf. + !! @param q_prim_vf Primitive variables + !! @param btensor is the output + !! calculate the grad_xi, grad_xi is a nxn tensor + !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor + !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor + !! btensor is symmetric, save the data space impure subroutine s_initialize_hyperelastic_module integer :: i !< generic iterator @@ -69,7 +69,7 @@ contains @:ALLOCATE(fd_coeff_z_hyper(-fd_number:fd_number, 0:p)) end if - ! centered finite difference coefficients + ! Computing centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x_hyper, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x_hyper]') @@ -87,13 +87,13 @@ contains end subroutine s_initialize_hyperelastic_module !> The following subroutine handles the calculation of the btensor. - !! of the btensor takes qprimvf. - !! Primitive variables - !! is the output - !! grad_xi, grad_xi is a nxn tensor - !! inverse of grad_xi to obtain F, F is a nxn tensor - !! FFtranspose to obtain the btensor, btensor is nxn tensor - !! symmetric, save the data space + !! The calculation of the btensor takes qprimvf. + !! @param q_prim_vf Primitive variables + !! @param btensor is the output + !! calculate the grad_xi, grad_xi is a nxn tensor + !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor + !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor + !! btensor is symmetric, save the data space subroutine s_hyperelastic_rmt_stress_update(q_cons_vf, q_prim_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -121,7 +121,7 @@ contains call s_compute_species_fraction(q_cons_vf, j, k, l, alpha_rho_k, alpha_k) - ! in simulation, use acc mixture subroutines + ! If in simulation, use acc mixture subroutines call s_convert_species_to_mixture_variables_acc(rho, gamma, pi_inf, qv, alpha_k, & alpha_rho_k, Re, G_local, Gs_hyper) rho = max(rho, sgm_eps) @@ -133,27 +133,27 @@ contains do i = 1, tensor_size tensora(i) = 0._wp end do - ! 1: computing the grad_xi tensor using finite differences - ! definition / organization - ! for the tensor 1-3: dxix_dx, dxiy_dx, dxiz_dx - ! : dxix_dy, dxiy_dy, dxiz_dy - ! : dxix_dz, dxiy_dz, dxiz_dz + ! STEP 1: computing the grad_xi tensor using finite differences + ! grad_xi definition / organization + ! number for the tensor 1-3: dxix_dx, dxiy_dx, dxiz_dx + ! 4-6 : dxix_dy, dxiy_dy, dxiz_dy + ! 7-9 : dxix_dz, dxiy_dz, dxiz_dz $:GPU_LOOP(parallelism='[seq]') do r = -fd_number, fd_number - ! in the x-direction + ! derivatives in the x-direction tensora(1) = tensora(1) + q_prim_vf(xibeg)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) tensora(2) = tensora(2) + q_prim_vf(xibeg + 1)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) tensora(3) = tensora(3) + q_prim_vf(xiend)%sf(j + r, k, l)*fd_coeff_x_hyper(r, j) - ! in the y-direction + ! derivatives in the y-direction tensora(4) = tensora(4) + q_prim_vf(xibeg)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) tensora(5) = tensora(5) + q_prim_vf(xibeg + 1)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) tensora(6) = tensora(6) + q_prim_vf(xiend)%sf(j, k + r, l)*fd_coeff_y_hyper(r, k) - ! in the z-direction + ! derivatives in the z-direction tensora(7) = tensora(7) + q_prim_vf(xibeg)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) tensora(8) = tensora(8) + q_prim_vf(xibeg + 1)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) tensora(9) = tensora(9) + q_prim_vf(xiend)%sf(j, k, l + r)*fd_coeff_z_hyper(r, l) end do - ! 2a: computing the adjoint of the grad_xi tensor for the inverse + ! STEP 2a: computing the adjoint of the grad_xi tensor for the inverse tensorb(1) = tensora(5)*tensora(9) - tensora(6)*tensora(8) tensorb(2) = -(tensora(2)*tensora(9) - tensora(3)*tensora(8)) tensorb(3) = tensora(2)*tensora(6) - tensora(3)*tensora(5) @@ -164,45 +164,45 @@ contains tensorb(8) = -(tensora(1)*tensora(8) - tensora(2)*tensora(7)) tensorb(9) = tensora(1)*tensora(5) - tensora(2)*tensora(4) - ! 2b: computing the determinant of the grad_xi tensor + ! STEP 2b: computing the determinant of the grad_xi tensor tensorb(tensor_size) = tensora(1)*(tensora(5)*tensora(9) - tensora(6)*tensora(8)) & - tensora(2)*(tensora(4)*tensora(9) - tensora(6)*tensora(7)) & + tensora(3)*(tensora(4)*tensora(8) - tensora(5)*tensora(7)) if (tensorb(tensor_size) > verysmall) then - ! 2c: computing the inverse of grad_xi tensor = F - ! is the adjoint, tensora becomes F + ! STEP 2c: computing the inverse of grad_xi tensor = F + ! tensorb is the adjoint, tensora becomes F $:GPU_LOOP(parallelism='[seq]') do i = 1, tensor_size - 1 tensora(i) = tensorb(i)/tensorb(tensor_size) end do - ! 2d: computing the J = det(F) = 1/det(\grad{\xi}) + ! STEP 2d: computing the J = det(F) = 1/det(\grad{\xi}) tensorb(tensor_size) = 1._wp/tensorb(tensor_size) - ! 3: computing F transpose F + ! STEP 3: computing F transpose F tensorb(1) = tensora(1)**2 + tensora(2)**2 + tensora(3)**2 tensorb(5) = tensora(4)**2 + tensora(5)**2 + tensora(6)**2 tensorb(9) = tensora(7)**2 + tensora(8)**2 + tensora(9)**2 tensorb(2) = tensora(1)*tensora(4) + tensora(2)*tensora(5) + tensora(3)*tensora(6) tensorb(3) = tensora(1)*tensora(7) + tensora(2)*tensora(8) + tensora(3)*tensora(9) tensorb(6) = tensora(4)*tensora(7) + tensora(5)*tensora(8) + tensora(6)*tensora(9) - ! 4: update the btensor, this is consistent with Riemann solvers + ! STEP 4: update the btensor, this is consistent with Riemann solvers #:for BIJ, TXY in [(1,1),(2,2),(3,5),(4,3),(5,6),(6,9)] btensor%vf(${BIJ}$)%sf(j, k, l) = tensorb(${TXY}$) #:endfor - ! the determinant at the last entry of the btensor + ! store the determinant at the last entry of the btensor btensor%vf(b_size)%sf(j, k, l) = tensorb(tensor_size) - ! 5a: updating the Cauchy stress primitive scalar field + ! STEP 5a: updating the Cauchy stress primitive scalar field if (hyper_model == 1) then call s_neoHookean_cauchy_solver(btensor%vf, q_prim_vf, G_local, j, k, l) elseif (hyper_model == 2) then call s_Mooney_Rivlin_cauchy_solver(btensor%vf, q_prim_vf, G_local, j, k, l) end if - ! 5b: updating the pressure field + ! STEP 5b: updating the pressure field q_prim_vf(E_idx)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) - & G_local*q_prim_vf(xiend + 1)%sf(j, k, l)/gamma - ! 5c: updating the Cauchy stress conservative scalar field + ! STEP 5c: updating the Cauchy stress conservative scalar field $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_cons_vf(strxb + i - 1)%sf(j, k, l) = & @@ -217,13 +217,13 @@ contains end subroutine s_hyperelastic_rmt_stress_update !> The following subroutine handles the calculation of the btensor. - !! of the btensor takes qprimvf. - !! Primitive variables - !! is the output - !! grad_xi, grad_xi is a nxn tensor - !! inverse of grad_xi to obtain F, F is a nxn tensor - !! FFtranspose to obtain the btensor, btensor is nxn tensor - !! symmetric, save the data space + !! The calculation of the btensor takes qprimvf. + !! @param q_prim_vf Primitive variables + !! @param btensor is the output + !! calculate the grad_xi, grad_xi is a nxn tensor + !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor + !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor + !! btensor is symmetric, save the data space subroutine s_neoHookean_cauchy_solver(btensor_in, q_prim_vf, G_param, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -235,34 +235,34 @@ contains real(wp), parameter :: f13 = 1._wp/3._wp integer :: i !< Generic loop iterators - ! is the symmetric tensor & calculate the trace of the tensor + ! tensor is the symmetric tensor & calculate the trace of the tensor trace = btensor_in(1)%sf(j, k, l) + btensor_in(3)%sf(j, k, l) + btensor_in(6)%sf(j, k, l) - ! the deviatoric of the tensor + ! calculate the deviatoric of the tensor #:for IJ in [1,3,6] btensor_in(${IJ}$)%sf(j, k, l) = btensor_in(${IJ}$)%sf(j, k, l) - f13*trace #:endfor - ! by the jacobian for neo-Hookean model - ! the tensor to the stresses for riemann solver + ! dividing by the jacobian for neo-Hookean model + ! setting the tensor to the stresses for riemann solver $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_prim_vf(strxb + i - 1)%sf(j, k, l) = & G_param*btensor_in(i)%sf(j, k, l)/btensor_in(b_size)%sf(j, k, l) end do - ! the invariant without the elastic modulus + ! compute the invariant without the elastic modulus q_prim_vf(xiend + 1)%sf(j, k, l) = & 0.5_wp*(trace - 3.0_wp)/btensor_in(b_size)%sf(j, k, l) end subroutine s_neoHookean_cauchy_solver !> The following subroutine handles the calculation of the btensor. - !! of the btensor takes qprimvf. - !! Primitive variables - !! is the output - !! grad_xi, grad_xi is a nxn tensor - !! inverse of grad_xi to obtain F, F is a nxn tensor - !! FFtranspose to obtain the btensor, btensor is nxn tensor - !! symmetric, save the data space + !! The calculation of the btensor takes qprimvf. + !! @param q_prim_vf Primitive variables + !! @param btensor is the output + !! calculate the grad_xi, grad_xi is a nxn tensor + !! calculate the inverse of grad_xi to obtain F, F is a nxn tensor + !! calculate the FFtranspose to obtain the btensor, btensor is nxn tensor + !! btensor is symmetric, save the data space subroutine s_Mooney_Rivlin_cauchy_solver(btensor_in, q_prim_vf, G_param, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), dimension(sys_size), intent(inout) :: q_prim_vf @@ -275,22 +275,22 @@ contains integer :: i !< Generic loop iterators !TODO Make this 1D and 2D capable - ! is the symmetric tensor & calculate the trace of the tensor + ! tensor is the symmetric tensor & calculate the trace of the tensor trace = btensor_in(1)%sf(j, k, l) + btensor_in(3)%sf(j, k, l) + btensor_in(6)%sf(j, k, l) - ! the deviatoric of the tensor + ! calculate the deviatoric of the tensor btensor_in(1)%sf(j, k, l) = btensor_in(1)%sf(j, k, l) - f13*trace btensor_in(3)%sf(j, k, l) = btensor_in(3)%sf(j, k, l) - f13*trace btensor_in(6)%sf(j, k, l) = btensor_in(6)%sf(j, k, l) - f13*trace - ! by the jacobian for neo-Hookean model - ! the tensor to the stresses for riemann solver + ! dividing by the jacobian for neo-Hookean model + ! setting the tensor to the stresses for riemann solver $:GPU_LOOP(parallelism='[seq]') do i = 1, b_size - 1 q_prim_vf(strxb + i - 1)%sf(j, k, l) = & G_param*btensor_in(i)%sf(j, k, l)/btensor_in(b_size)%sf(j, k, l) end do - ! the invariant without the elastic modulus + ! compute the invariant without the elastic modulus q_prim_vf(xiend + 1)%sf(j, k, l) = & 0.5_wp*(trace - 3.0_wp)/btensor_in(b_size)%sf(j, k, l) @@ -300,7 +300,7 @@ contains integer :: i !< iterator - ! memory + ! Deallocating memory do i = 1, b_size @:DEALLOCATE(btensor%vf(i)%sf) end do diff --git a/src/simulation/m_hypoelastic.fpp b/src/simulation/m_hypoelastic.fpp index 8832be0f13..fead6ee117 100644 --- a/src/simulation/m_hypoelastic.fpp +++ b/src/simulation/m_hypoelastic.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_hypoelastic +!! @file +!! @brief Contains module m_hypoelastic #:include 'macros.fpp' @@ -65,7 +65,7 @@ contains @:ALLOCATE(fd_coeff_z_hypo(-fd_number:fd_number, 0:p)) end if - ! centered finite difference coefficients + ! Computing centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x_hypo, buff_size, & fd_number, fd_order) $:GPU_UPDATE(device='[fd_coeff_x_hypo]') @@ -83,10 +83,10 @@ contains end subroutine s_initialize_hypoelastic_module !> The purpose of this procedure is to compute the source terms - !! needed for the elastic stress equations - !! Dimension splitting index - !! Primitive variables - !! rhs variables + !! that are needed for the elastic stress equations + !! @param idir Dimension splitting index + !! @param q_prim_vf Primitive variables + !! @param rhs_vf rhs variables subroutine s_compute_hypoelastic_rhs(idir, q_prim_vf, rhs_vf) integer, intent(in) :: idir @@ -101,8 +101,8 @@ contains ndirs = 1; if (n > 0) ndirs = 2; if (p > 0) ndirs = 3 if (idir == 1) then - ! velocity gradients + rho_K and G_K - ! re-organize these loops one by one for GPU efficiency if possible? + ! calculate velocity gradients + rho_K and G_K + ! TODO: re-organize these loops one by one for GPU efficiency if possible? $:GPU_PARALLEL_LOOP(collapse=3) do q = 0, p @@ -158,7 +158,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! + ! 3D if (ndirs == 3) then $:GPU_PARALLEL_LOOP(collapse=3) @@ -220,7 +220,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! rhs source term to elastic stress equation + ! apply rhs source term to elastic stress equation $:GPU_PARALLEL_LOOP(collapse=3) do q = 0, p do l = 0, n @@ -345,22 +345,22 @@ contains do q = 0, p do l = 0, n do k = 0, m - ! -= rho * v/r * (tau_xx + 2/3*G) + ! S_xx -= rho * v/r * (tau_xx + 2/3*G) rhs_vf(strxb)%sf(k, l, q) = rhs_vf(strxb)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & (q_prim_vf(strxb)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q)) ! tau_xx + 2/3*G - ! -= rho * v/r * tau_xr + ! S_xr -= rho * v/r * tau_xr rhs_vf(strxb + 1)%sf(k, l, q) = rhs_vf(strxb + 1)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & q_prim_vf(strxb + 1)%sf(k, l, q) ! tau_xx - ! -= rho * v/r * (tau_rr + 2/3*G) + ! S_rr -= rho * v/r * (tau_rr + 2/3*G) rhs_vf(strxb + 2)%sf(k, l, q) = rhs_vf(strxb + 2)%sf(k, l, q) - & rho_K_field(k, l, q)*q_prim_vf(momxb + 1)%sf(k, l, q)/y_cc(l)* & (q_prim_vf(strxb + 2)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q)) ! tau_rr + 2/3*G - ! += rho * ( -(tau_thetatheta + 2/3*G)*(du/dx + dv/dr + v/r) + 2*(tau_thetatheta + G)*v/r ) + ! S_thetatheta += rho * ( -(tau_thetatheta + 2/3*G)*(du/dx + dv/dr + v/r) + 2*(tau_thetatheta + G)*v/r ) rhs_vf(strxb + 3)%sf(k, l, q) = rhs_vf(strxb + 3)%sf(k, l, q) + & rho_K_field(k, l, q)*( & -(q_prim_vf(strxb + 3)%sf(k, l, q) + (2._wp/3._wp)*G_K_field(k, l, q))* & @@ -414,7 +414,7 @@ contains $:GPU_PARALLEL_LOOP(collapse=2, private='[tau_p]') do l = 0, n do k = 0, m - ! principal stress + ! Maximum principal stress tau_p = 0.5_wp*(q_cons_vf(stress_idx%beg)%sf(k, l, q) + & q_cons_vf(stress_idx%beg + 2)%sf(k, l, q)) + & sqrt((q_cons_vf(stress_idx%beg)%sf(k, l, q) - & @@ -437,14 +437,14 @@ contains tau_yz = q_cons_vf(stress_idx%beg + 4)%sf(k, l, q) tau_zz = q_cons_vf(stress_idx%beg + 5)%sf(k, l, q) - ! of the stress tensor + ! Invariants of the stress tensor I1 = tau_xx + tau_yy + tau_zz I2 = tau_xx*tau_yy + tau_xx*tau_zz + tau_yy*tau_zz - & (tau_xy**2.0_wp + tau_xz**2.0_wp + tau_yz**2.0_wp) I3 = tau_xx*tau_yy*tau_zz + 2.0_wp*tau_xy*tau_xz*tau_yz - & tau_xx*tau_yz**2.0_wp - tau_yy*tau_xz**2.0_wp - tau_zz*tau_xy**2.0_wp - ! principal stress + ! Maximum principal stress temp = I1**2.0_wp - 3.0_wp*I2 sqrt_term_1 = sqrt(max(temp, 0.0_wp)) if (sqrt_term_1 > verysmall) then ! Avoid 0/0 diff --git a/src/simulation/m_ibm.fpp b/src/simulation/m_ibm.fpp index 6aa7931f03..c63027a1ff 100644 --- a/src/simulation/m_ibm.fpp +++ b/src/simulation/m_ibm.fpp @@ -1,11 +1,11 @@ !> -!! -!! module m_ibm +!! @file +!! @brief Contains module m_ibm #:include 'macros.fpp' !> @brief This module is used to handle all operations related to immersed -!! (IBMs) +!! boundary methods (IBMs) module m_ibm use m_derived_types !< Definitions of the derived types @@ -89,13 +89,13 @@ contains end subroutine s_initialize_ibm_module !> Initializes the values of various IBM variables, such as ghost points and - !! + !! image points. impure subroutine s_ibm_setup() integer :: i, j, k integer :: max_num_gps, max_num_inner_gps - ! all set up for moving immersed boundaries + ! do all set up for moving immersed boundaries moving_immersed_boundary_flag = .false. do i = 1, num_ibs if (patch_ib(i)%moving_ibm /= 0) then @@ -107,24 +107,24 @@ contains end do $:GPU_ENTER_DATA(copyin='[patch_ib]') - ! the patch identities bookkeeping variable + ! Allocating the patch identities bookkeeping variable allocate (patch_id_fp(0:m, 0:n, 0:p)) $:GPU_UPDATE(device='[ib_markers%sf]') $:GPU_UPDATE(device='[levelset%sf]') $:GPU_UPDATE(device='[levelset_norm%sf]') - ! neighboring IB variables from other processors + ! Get neighboring IB variables from other processors call s_populate_ib_buffers() $:GPU_UPDATE(host='[ib_markers%sf]') - ! the number of ghost points and set them to be the maximum total across ranks + ! find the number of ghost points and set them to be the maximum total across ranks call s_find_num_ghost_points(num_gps, num_inner_gps) call s_mpi_allreduce_integer_sum(num_gps, max_num_gps) call s_mpi_allreduce_integer_sum(num_inner_gps, max_num_inner_gps) - ! the size of the ghost point arrays to be the amount of points total, plus a factor of 2 buffer + ! set the size of the ghost point arrays to be the amount of points total, plus a factor of 2 buffer $:GPU_UPDATE(device='[num_gps, num_inner_gps]') @:ALLOCATE(ghost_points(1:int((max_num_gps + max_num_inner_gps) * 2.0))) @:ALLOCATE(inner_points(1:int((max_num_gps + max_num_inner_gps) * 2.0))) @@ -155,19 +155,19 @@ contains end subroutine s_populate_ib_buffers !> Subroutine that updates the conservative variables at the ghost points - !! @param[inout] q_cons_vf Conservative variables. - !! @param[inout] q_prim_vf Primitive variables. - !! @param[inout] pb_in Internal bubble pressure (optional, for QBMM). - !! @param[inout] mv_in Mass of vapor in bubble (optional, for QBMM). + !! @param q_cons_vf Conservative Variables + !! @param q_prim_vf Primitive variables + !! @param pb Internal bubble pressure + !! @param mv Mass of vapor in bubble subroutine s_ibm_correct_state(q_cons_vf, q_prim_vf, pb_in, mv_in) type(scalar_field), & dimension(sys_size), & - intent(INOUT) :: q_cons_vf + intent(INOUT) :: q_cons_vf !< Primitive Variables type(scalar_field), & dimension(sys_size), & - intent(INOUT) :: q_prim_vf + intent(INOUT) :: q_prim_vf !< Primitive Variables real(stp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:, 1:), optional, intent(INOUT) :: pb_in, mv_in @@ -194,8 +194,8 @@ contains real(wp), dimension(nb*nmom) :: nmom_IP real(wp), dimension(nb*nnode) :: presb_IP, massv_IP #:endif - !! at the image point associated with a ghost point, - !! surrounding fluid cells. + !! Primitive variables at the image point associated with a ghost point, + !! interpolated from surrounding fluid cells. real(wp), dimension(3) :: norm !< Normal vector from GP to IP real(wp), dimension(3) :: physical_loc !< Physical loc of GP @@ -208,7 +208,7 @@ contains type(ghost_point) :: gp type(ghost_point) :: innerp - ! the Moving IBM interior Pressure Values + ! set the Moving IBM interior Pressure Values $:GPU_PARALLEL_LOOP(private='[i,j,k,patch_id,rho]', copyin='[E_idx,momxb]', collapse=3) do l = 0, p do k = 0, n @@ -222,7 +222,7 @@ contains rho = rho + q_prim_vf(contxb + i - 1)%sf(j, k, l) end do - ! the momentum + ! Sets the momentum do i = 1, num_dims q_cons_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i)*rho q_prim_vf(momxb + i - 1)%sf(j, k, l) = patch_ib(patch_id)%vel(i) @@ -244,7 +244,7 @@ contains l = gp%loc(3) patch_id = ghost_points(i)%ib_patch_id - ! physical location of GP + ! Calculate physical location of GP if (p > 0) then physical_loc = [x_cc(j), y_cc(k), z_cc(l)] else @@ -271,7 +271,7 @@ contains dyn_pres = 0._wp - ! q_prim_vf params at GP so that mixture vars calculated properly + ! Set q_prim_vf params at GP so that mixture vars calculated properly $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids q_prim_vf(q)%sf(j, k, l) = alpha_rho_IP(q) @@ -282,20 +282,20 @@ contains q_prim_vf(c_idx)%sf(j, k, l) = c_IP end if - ! the pressure + ! set the pressure if (patch_ib(patch_id)%moving_ibm <= 1) then q_prim_vf(E_idx)%sf(j, k, l) = pres_IP else q_prim_vf(E_idx)%sf(j, k, l) = 0._wp $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids - ! the pressure inside a moving immersed boundary based upon the pressure of the image point. acceleration, and normal vector direction + ! Se the pressure inside a moving immersed boundary based upon the pressure of the image point. acceleration, and normal vector direction q_prim_vf(E_idx)%sf(j, k, l) = q_prim_vf(E_idx)%sf(j, k, l) + pres_IP/(1._wp - 2._wp*abs(levelset%sf(j, k, l, patch_id)*alpha_rho_IP(q)/pres_IP)*dot_product(patch_ib(patch_id)%force/patch_ib(patch_id)%mass, levelset_norm%sf(j, k, l, patch_id, :))) end do end if if (model_eqns /= 4) then - ! in simulation, use acc mixture subroutines + ! If in simulation, use acc mixture subroutines if (elasticity) then call s_convert_species_to_mixture_variables_acc(rho, gamma, pi_inf, qv_K, alpha_IP, & alpha_rho_IP, Re_K, G_K, Gs) @@ -305,7 +305,7 @@ contains end if end if - ! velocity of ghost cell + ! Calculate velocity of ghost cell if (gp%slip) then norm(1:3) = levelset_norm%sf(gp%loc(1), gp%loc(2), gp%loc(3), gp%ib_patch_id, 1:3) buf = sqrt(sum(norm**2)) @@ -313,33 +313,33 @@ contains vel_norm_IP = sum(vel_IP*norm)*norm vel_g = vel_IP - vel_norm_IP if (patch_ib(patch_id)%moving_ibm /= 0) then - ! the linear velocity of the ghost point due to rotation + ! compute the linear velocity of the ghost point due to rotation radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, & patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid] call s_cross_product(matmul(patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector, rotation_velocity) - ! only the component of the IB's motion that is normal to the surface + ! add only the component of the IB's motion that is normal to the surface vel_g = vel_g + sum((patch_ib(patch_id)%vel + rotation_velocity)*norm)*norm end if else if (patch_ib(patch_id)%moving_ibm == 0) then - ! know the object is not moving if moving_ibm is 0 (false) + ! we know the object is not moving if moving_ibm is 0 (false) vel_g = 0._wp else - ! the vector that points from the centroid to the ghost + ! get the vector that points from the centroid to the ghost radial_vector = physical_loc - [patch_ib(patch_id)%x_centroid, & patch_ib(patch_id)%y_centroid, patch_ib(patch_id)%z_centroid] - ! the angular velocity from the inertial reference frame to the fluids frame, then convert to linear velocity + ! convert the angular velocity from the inertial reference frame to the fluids frame, then convert to linear velocity call s_cross_product(matmul(patch_ib(patch_id)%rotation_matrix, patch_ib(patch_id)%angular_vel), radial_vector, rotation_velocity) do q = 1, 3 - ! mibm is 1 or 2, then the boundary may be moving + ! if mibm is 1 or 2, then the boundary may be moving vel_g(q) = patch_ib(patch_id)%vel(q) ! add the linear velocity vel_g(q) = vel_g(q) + rotation_velocity(q) ! add the rotational velocity end do end if end if - ! momentum + ! Set momentum $:GPU_LOOP(parallelism='[seq]') do q = momxb, momxe q_cons_vf(q)%sf(j, k, l) = rho*vel_g(q - momxb + 1) @@ -347,25 +347,25 @@ contains vel_g(q - momxb + 1)/2._wp end do - ! continuity and adv vars + ! Set continuity and adv vars $:GPU_LOOP(parallelism='[seq]') do q = 1, num_fluids q_cons_vf(q)%sf(j, k, l) = alpha_rho_IP(q) q_cons_vf(advxb + q - 1)%sf(j, k, l) = alpha_IP(q) end do - ! color function + ! Set color function if (surface_tension) then q_cons_vf(c_idx)%sf(j, k, l) = c_IP end if - ! Energy + ! Set Energy if (bubbles_euler) then q_cons_vf(E_idx)%sf(j, k, l) = (1 - alpha_IP(1))*(gamma*pres_IP + pi_inf + dyn_pres) else q_cons_vf(E_idx)%sf(j, k, l) = gamma*pres_IP + pi_inf + dyn_pres end if - ! bubble vars + ! Set bubble vars if (bubbles_euler .and. .not. qbmm) then call s_comp_n_from_prim(alpha_IP(1), r_IP, nbub, weight) $:GPU_LOOP(parallelism='[seq]') @@ -438,9 +438,9 @@ contains end subroutine s_ibm_correct_state !> Function that computes the image points for each ghost point - !! Ghost Points - !! Closest distance from each grid cell to IB - !! Vector pointing in the direction of the closest distance + !! @param ghost_points Ghost Points + !! @param levelset Closest distance from each grid cell to IB + !! @param levelset_norm Vector pointing in the direction of the closest distance impure subroutine s_compute_image_points(ghost_points_in, levelset_in, levelset_norm_in) type(ghost_point), dimension(num_gps), intent(INOUT) :: ghost_points_in @@ -467,23 +467,23 @@ contains j = gp%loc(2) k = gp%loc(3) - ! physical location of ghost point + ! Calculate physical location of ghost point if (p > 0) then physical_loc = [x_cc(i), y_cc(j), z_cc(k)] else physical_loc = [x_cc(i), y_cc(j), 0._wp] end if - ! and store the precise location of the image point + ! Calculate and store the precise location of the image point patch_id = gp%ib_patch_id dist = abs(real(levelset_in%sf(i, j, k, patch_id), kind=wp)) norm(:) = levelset_norm_in%sf(i, j, k, patch_id, :) ghost_points_in(q)%ip_loc(:) = physical_loc(:) + 2*dist*norm(:) - ! the closest grid point to the image point + ! Find the closest grid point to the image point do dim = 1, num_dims - ! points to the dim array we need + ! s_cc points to the dim array we need if (dim == 1) then s_cc => x_cc bound = m + buff_size - 1 @@ -496,7 +496,7 @@ contains end if if (f_approx_equal(norm(dim), 0._wp)) then - ! the ghost point is almost equal to a cell location, we set it equal and continue + ! if the ghost point is almost equal to a cell location, we set it equal and continue ghost_points_in(q)%ip_grid(dim) = ghost_points_in(q)%loc(dim) else if (norm(dim) > 0) then @@ -529,7 +529,7 @@ contains end subroutine s_compute_image_points !> Function that finds the number of ghost points, used for allocating - !! + !! memory. subroutine s_find_num_ghost_points(num_gps_out, num_inner_gps_out) integer, intent(out) :: num_gps_out @@ -596,7 +596,7 @@ contains do i = 0, m do j = 0, n if (p == 0) then - ! + ! 2D if (ib_markers%sf(i, j, 0) /= 0) then subsection_2D = ib_markers%sf( & i - gp_layers:i + gp_layers, & @@ -608,7 +608,7 @@ contains patch_id ghost_points_in(count)%slip = patch_ib(patch_id)%slip - ! = proc_rank + ! ghost_points(count)%rank = proc_rank if ((x_cc(i) - dx(i)) < x_domain%beg) then ghost_points_in(count)%DB(1) = -1 @@ -639,7 +639,7 @@ contains end if end if else - ! + ! 3D do k = 0, p if (ib_markers%sf(i, j, k) /= 0) then subsection_3D = ib_markers%sf( & @@ -710,11 +710,11 @@ contains integer :: i1, i2, j1, j2, k1, k2 !< Grid indexes integer :: patch_id - ! + ! 2D if (p <= 0) then do i = 1, num_gps gp = ghost_points_in(i) - ! the interpolation points + ! Get the interpolation points i1 = gp%ip_grid(1); i2 = i1 + 1 j1 = gp%ip_grid(2); j2 = j1 + 1 @@ -766,12 +766,12 @@ contains else do i = 1, num_gps gp = ghost_points_in(i) - ! the interpolation points + ! Get the interpolation points i1 = gp%ip_grid(1); i2 = i1 + 1 j1 = gp%ip_grid(2); j2 = j1 + 1 k1 = gp%ip_grid(3); k2 = k1 + 1 - ! interpolation weights (Chaudhuri et al. 2011, JCP) + ! Get interpolation weights (Chaudhuri et al. 2011, JCP) dist(1, 1, 1) = sqrt( & (x_cc(i1) - gp%ip_loc(1))**2 + & (y_cc(j1) - gp%ip_loc(2))**2 + & @@ -848,30 +848,15 @@ contains end subroutine s_compute_interpolation_coeffs - !> Interpolates flow state at an image point using surrounding cell data. - !! @param[in] q_prim_vf Primitive variables at cell centers. - !! @param[in] gp Ghost point with image point location and interpolation coefficients. - !! @param[inout] alpha_rho_IP Interpolated partial densities at image point. - !! @param[inout] alpha_IP Interpolated volume fractions at image point. - !! @param[inout] pres_IP Interpolated pressure at image point. - !! @param[inout] vel_IP Interpolated velocity vector at image point. - !! @param[inout] c_IP Interpolated color function at image point. - !! @param[inout] r_IP Interpolated bubble radii (optional, Euler bubbles). - !! @param[inout] v_IP Interpolated bubble velocities (optional, Euler bubbles). - !! @param[inout] pb_IP Interpolated bubble pressures (optional, Euler bubbles). - !! @param[inout] mv_IP Interpolated vapor masses (optional, Euler bubbles). - !! @param[inout] nmom_IP Interpolated moments (optional, QBMM). - !! @param[in] pb_in Bubble pressure field (optional, non-polytropic QBMM). - !! @param[in] mv_in Vapor mass field (optional, non-polytropic QBMM). - !! @param[inout] presb_IP Interpolated bubble pressures (optional, QBMM). - !! @param[inout] massv_IP Interpolated vapor masses (optional, QBMM). + !> Function that uses the interpolation coefficients and the current state + !! at the cell centers in order to estimate the state at the image point subroutine s_interpolate_image_point(q_prim_vf, gp, alpha_rho_IP, alpha_IP, & pres_IP, vel_IP, c_IP, r_IP, v_IP, pb_IP, & mv_IP, nmom_IP, pb_in, mv_in, presb_IP, massv_IP) $:GPU_ROUTINE(parallelism='[seq]') type(scalar_field), & dimension(sys_size), & - intent(IN) :: q_prim_vf + intent(IN) :: q_prim_vf !< Primitive Variables real(stp), optional, dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:, 1:), intent(IN) :: pb_in, mv_in @@ -1003,12 +988,12 @@ contains integer :: i, ierr - ! the existing immersed boundary indices + ! Clears the existing immersed boundary indices ib_markers%sf = 0._wp levelset%sf = 0._wp levelset_norm%sf = 0._wp - ! the rotation matrix based upon the new angles + ! recalulcate the rotation matrix based upon the new angles do i = 1, num_ibs if (patch_ib(i)%moving_ibm /= 0) then call s_update_ib_rotation_matrix(i) @@ -1017,13 +1002,13 @@ contains $:GPU_UPDATE(device='[patch_ib]') - ! the new ib_patch locations and broadcast them. + ! recompute the new ib_patch locations and broadcast them. call s_apply_ib_patches(ib_markers%sf(0:m, 0:n, 0:p), levelset, levelset_norm) call s_populate_ib_buffers() ! transmits the new IB markers via MPI $:GPU_UPDATE(device='[ib_markers%sf]') $:GPU_UPDATE(host='[levelset%sf, levelset_norm%sf]') - ! the ghost point locations and coefficients + ! recalculate the ghost point locations and coefficients call s_find_num_ghost_points(num_gps, num_inner_gps) $:GPU_UPDATE(device='[num_gps, num_inner_gps]') @@ -1038,14 +1023,14 @@ contains end subroutine s_update_mib - ! the surface integrals of the IB via a volume integraion method described in - ! coupled IBM/Euler-Lagrange framework for simulating shock-induced particle size segregation" - ! Archana Sridhar and Jesse Capecelatro + ! compute the surface integrals of the IB via a volume integraion method described in + ! "A coupled IBM/Euler-Lagrange framework for simulating shock-induced particle size segregation" + ! by Archana Sridhar and Jesse Capecelatro subroutine s_compute_ib_forces(q_prim_vf, fluid_pp) - ! dimension(idwbuff(1)%beg:idwbuff(1)%end, & - ! & - ! intent(in) :: pressure + ! real(wp), dimension(idwbuff(1)%beg:idwbuff(1)%end, & + ! idwbuff(2)%beg:idwbuff(2)%end, & + ! idwbuff(3)%beg:idwbuff(3)%end), intent(in) :: pressure type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf type(physical_parameters), dimension(1:num_fluids), intent(in) :: fluid_pp @@ -1078,7 +1063,7 @@ contains do k = 0, p ib_idx = ib_markers%sf(i, j, k) if (ib_idx /= 0) then - ! the vector pointing to the grid cell from the IB centroid + ! get the vector pointing to the grid cell from the IB centroid if (num_dims == 3) then radial_vector = [x_cc(i), y_cc(j), z_cc(k)] - [patch_ib(ib_idx)%x_centroid, patch_ib(ib_idx)%y_centroid, patch_ib(ib_idx)%z_centroid] else @@ -1089,11 +1074,11 @@ contains local_force_contribution(:) = 0._wp do fluid_idx = 0, num_fluids - 1 - ! the pressure contribution to force via a finite difference to compute the 2D components of the gradient of the pressure and cell volume + ! Get the pressure contribution to force via a finite difference to compute the 2D components of the gradient of the pressure and cell volume local_force_contribution(1) = local_force_contribution(1) - (q_prim_vf(E_idx + fluid_idx)%sf(i + 1, j, k) - q_prim_vf(E_idx + fluid_idx)%sf(i - 1, j, k))/(2._wp*dx) ! force is the negative pressure gradient local_force_contribution(2) = local_force_contribution(2) - (q_prim_vf(E_idx + fluid_idx)%sf(i, j + 1, k) - q_prim_vf(E_idx + fluid_idx)%sf(i, j - 1, k))/(2._wp*dy) cell_volume = abs(dx*dy) - ! the 3D component of the pressure gradient, if we are working in 3 dimensions + ! add the 3D component of the pressure gradient, if we are working in 3 dimensions if (num_dims == 3) then dz = z_cc(k + 1) - z_cc(k) local_force_contribution(3) = local_force_contribution(3) - (q_prim_vf(E_idx + fluid_idx)%sf(i, j, k + 1) - q_prim_vf(E_idx + fluid_idx)%sf(i, j, k - 1))/(2._wp*dz) @@ -1101,26 +1086,26 @@ contains end if end do - ! the force values atomically to prevent race conditions + ! Update the force values atomically to prevent race conditions call s_cross_product(radial_vector, local_force_contribution, local_torque_contribution) - ! the viscous stress and add its contribution if that is considered - ! :: This is really bad code + ! get the viscous stress and add its contribution if that is considered + ! TODO :: This is really bad code if (viscous) then - ! the volume-weighted local dynamic viscosity + ! compute the volume-weighted local dynamic viscosity dynamic_viscosity = 0._wp do fluid_idx = 1, num_fluids - ! dynamic viscosity is the dynamic viscosity of the fluid times alpha of the fluid + ! local dynamic viscosity is the dynamic viscosity of the fluid times alpha of the fluid dynamic_viscosity = dynamic_viscosity + (q_prim_vf(fluid_idx + advxb - 1)%sf(i, j, k)*dynamic_viscosities(fluid_idx)) end do - ! the linear force component first + ! get the linear force component first call s_compute_viscous_stress_tensor(viscous_stress_div_1, q_prim_vf, dynamic_viscosity, i - 1, j, k) call s_compute_viscous_stress_tensor(viscous_stress_div_2, q_prim_vf, dynamic_viscosity, i + 1, j, k) viscous_stress_div = (viscous_stress_div_2 - viscous_stress_div_1)/(2._wp*dx) ! get the x derivative of the viscous stress tensor local_force_contribution(1:3) = local_force_contribution(1:3) + viscous_stress_div(1, 1:3) ! add te x components of the derivative to the force do l = 1, 3 - ! the cross products for the torque component + ! take the cross products for the torque component call s_cross_product(radial_vector, viscous_stress_div_1(l, 1:3), viscous_cross_1(l, 1:3)) call s_cross_product(radial_vector, viscous_stress_div_2(l, 1:3), viscous_cross_2(l, 1:3)) end do @@ -1166,11 +1151,11 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! the forces across all MPI ranks + ! reduce the forces across all MPI ranks call s_mpi_allreduce_vectors_sum(forces, forces, num_ibs, 3) call s_mpi_allreduce_vectors_sum(torques, torques, num_ibs, 3) - ! body forces after reducing to avoid double counting + ! consider body forces after reducing to avoid double counting do i = 1, num_ibs if (bf_x) then forces(i, 1) = forces(i, 1) + accel_bf(1)*patch_ib(i)%mass @@ -1183,7 +1168,7 @@ contains end if end do - ! the summed forces + ! apply the summed forces do i = 1, num_ibs patch_ib(i)%force(:) = forces(i, :) patch_ib(i)%torque(:) = matmul(patch_ib(i)%rotation_matrix_inverse, torques(i, :)) ! torques must be converted to the local coordinates of the IB @@ -1209,7 +1194,7 @@ contains integer :: i, j, k, num_cells, num_cells_local real(wp), dimension(1:3) :: center_of_mass, center_of_mass_local - ! only needs to be computes for specific geometries + ! Offset only needs to be computes for specific geometries if (patch_ib(ib_marker)%geometry == 4 .or. & patch_ib(ib_marker)%geometry == 5 .or. & patch_ib(ib_marker)%geometry == 11 .or. & @@ -1218,7 +1203,7 @@ contains center_of_mass_local = [0._wp, 0._wp, 0._wp] num_cells_local = 0 - ! the summed mass distribution and number of cells to divide by + ! get the summed mass distribution and number of cells to divide by do i = 0, m do j = 0, n do k = 0, p @@ -1231,7 +1216,7 @@ contains end do end do - ! the mass contribution over all MPI ranks and compute COM + ! reduce the mass contribution over all MPI ranks and compute COM call s_mpi_allreduce_integer_sum(num_cells_local, num_cells) if (num_cells /= 0) then call s_mpi_allreduce_sum(center_of_mass_local(1), center_of_mass(1)) @@ -1243,14 +1228,14 @@ contains return end if - ! the centroid offset as a vector pointing from the true COM to the "centroid" in the input file and replace the current centroid + ! assign the centroid offset as a vector pointing from the true COM to the "centroid" in the input file and replace the current centroid patch_ib(ib_marker)%centroid_offset = [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, patch_ib(ib_marker)%z_centroid] & - center_of_mass patch_ib(ib_marker)%x_centroid = center_of_mass(1) patch_ib(ib_marker)%y_centroid = center_of_mass(2) patch_ib(ib_marker)%z_centroid = center_of_mass(3) - ! the centroid offset back into the local coords of the IB + ! rotate the centroid offset back into the local coords of the IB patch_ib(ib_marker)%centroid_offset = matmul(patch_ib(ib_marker)%rotation_matrix_inverse, patch_ib(ib_marker)%centroid_offset) else patch_ib(ib_marker)%centroid_offset(:) = [0._wp, 0._wp, 0._wp] @@ -1258,12 +1243,9 @@ contains end subroutine s_compute_centroid_offset - !> Computes the moment of inertia of an immersed boundary about an axis. - !! @param[in] ib_marker Immersed boundary patch ID. - !! @param[in] axis Rotation axis vector (used in 3D; defaults to z-axis in 2D). subroutine s_compute_moment_of_inertia(ib_marker, axis) - real(wp), dimension(3), intent(in) :: axis + real(wp), dimension(3), intent(in) :: axis !< the axis about which we compute the moment. Only required in 3D. integer, intent(in) :: ib_marker real(wp) :: moment, distance_to_axis, cell_volume @@ -1273,14 +1255,14 @@ contains if (p == 0) then normal_axis = [0, 0, 1] else if (sqrt(sum(axis**2)) == 0) then - ! the object is not actually rotating at this time, return a dummy value and exit + ! if the object is not actually rotating at this time, return a dummy value and exit patch_ib(ib_marker)%moment = 1._wp return else normal_axis = axis/sqrt(sum(axis)) end if - ! the IB is in 2D or a 3D sphere, we can compute this exactly + ! if the IB is in 2D or a 3D sphere, we can compute this exactly if (patch_ib(ib_marker)%geometry == 2) then ! circle patch_ib(ib_marker)%moment = 0.5_wp*patch_ib(ib_marker)%mass*(patch_ib(ib_marker)%radius)**2 elseif (patch_ib(ib_marker)%geometry == 3) then ! rectangle @@ -1306,19 +1288,19 @@ contains $:GPU_ATOMIC(atomic='update') count = count + 1 ! increment the count of total cells in the boundary - ! the position in local coordinates so that the axis passes through 0, 0, 0 + ! get the position in local coordinates so that the axis passes through 0, 0, 0 if (p == 0) then position = [x_cc(i), y_cc(j), 0._wp] - [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, 0._wp] else position = [x_cc(i), y_cc(j), z_cc(k)] - [patch_ib(ib_marker)%x_centroid, patch_ib(ib_marker)%y_centroid, patch_ib(ib_marker)%z_centroid] end if - ! the position along the axis to find the closest distance to the rotation axis + ! project the position along the axis to find the closest distance to the rotation axis closest_point_along_axis = normal_axis*dot_product(normal_axis, position) vector_to_axis = position - closest_point_along_axis distance_to_axis = dot_product(vector_to_axis, vector_to_axis) ! saves the distance to the axis squared - ! the position component of the moment + ! compute the position component of the moment $:GPU_ATOMIC(atomic='update') moment = moment + distance_to_axis end if @@ -1327,7 +1309,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! the final moment assuming the points are all uniform density + ! write the final moment assuming the points are all uniform density patch_ib(ib_marker)%moment = moment*patch_ib(ib_marker)%mass/(count*cell_volume) $:GPU_UPDATE(device='[patch_ib(ib_marker)%moment]') end if diff --git a/src/simulation/m_igr.fpp b/src/simulation/m_igr.fpp index 699b638269..fa06ef9092 100644 --- a/src/simulation/m_igr.fpp +++ b/src/simulation/m_igr.fpp @@ -33,8 +33,8 @@ module m_igr real(wp), allocatable, dimension(:, :, :), pinned, target :: jac_old_host #else !> @endcond - real(wp), allocatable, target, dimension(:, :, :) :: jac !< IGR Jacobian field - real(wp), allocatable, dimension(:, :, :) :: jac_rhs, jac_old !< IGR RHS and previous Jacobian + real(wp), allocatable, target, dimension(:, :, :) :: jac + real(wp), allocatable, dimension(:, :, :) :: jac_rhs, jac_old $:GPU_DECLARE(create='[jac, jac_rhs, jac_old]') !> @cond #endif @@ -156,7 +156,7 @@ contains idwbuff(3)%beg:idwbuff(3)%end)) end if #else - ! map + ! create map nv_uvm_temp_on_gpu(1:3) = 0 nv_uvm_temp_on_gpu(1:nv_uvm_igr_temps_on_gpu) = 1 diff --git a/src/simulation/m_mpi_proxy.fpp b/src/simulation/m_mpi_proxy.fpp index 4a634e5988..1cb9f684c0 100644 --- a/src/simulation/m_mpi_proxy.fpp +++ b/src/simulation/m_mpi_proxy.fpp @@ -1,15 +1,15 @@ !> -!! -!! module m_mpi_proxy +!! @file +!! @brief Contains module m_mpi_proxy #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module serves as a proxy to the parameters and subroutines -!! the MPI implementation's MPI module. Specifically, -!! of the proxy is to harness basic MPI commands into -!! procedures as to accomplish the communication -!! the simulation. +!! available in the MPI implementation's MPI module. Specifically, +!! the purpose of the proxy is to harness basic MPI commands into +!! more complicated procedures as to accomplish the communication +!! goals for the simulation. module m_mpi_proxy #ifdef MFC_MPI @@ -33,14 +33,14 @@ module m_mpi_proxy implicit none integer, private, allocatable, dimension(:) :: ib_buff_send !< - !! is utilized to pack and send the buffer of the immersed - !! for a single computational domain boundary at the - !! the relevant neighboring processor. + !! This variable is utilized to pack and send the buffer of the immersed + !! boundary markers, for a single computational domain boundary at the + !! time, to the relevant neighboring processor. integer, private, allocatable, dimension(:) :: ib_buff_recv !< - !! utilized to receive and unpack the buffer of the - !! markers, for a single computational domain boundary - !! time, from the relevant neighboring processor. + !! q_cons_buff_recv is utilized to receive and unpack the buffer of the + !! immersed boundary markers, for a single computational domain boundary + !! at the time, from the relevant neighboring processor. integer :: i_halo_size $:GPU_DECLARE(create='[i_halo_size]') @@ -74,10 +74,10 @@ contains end subroutine s_initialize_mpi_proxy_module !> Since only the processor with rank 0 reads and verifies - !! of user inputs, these are initially not - !! the other processors. Then, the purpose of - !! is to distribute the user inputs to the - !! in the communicator. + !! the consistency of user inputs, these are initially not + !! available to the other processors. Then, the purpose of + !! this subroutine is to distribute the user inputs to the + !! remaining processors in the communicator. impure subroutine s_mpi_bcast_user_inputs() #ifdef MFC_MPI @@ -249,7 +249,7 @@ contains #:endfor end do - ! UVM variables + ! NVIDIA UVM variables call MPI_BCAST(nv_uvm_out_of_core, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(nv_uvm_igr_temps_on_gpu, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCAST(nv_uvm_pref_gpu, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr) @@ -292,12 +292,12 @@ contains beg_end = (/boundary_conditions(mpi_dir)%beg, boundary_conditions(mpi_dir)%end/) beg_end_geq_0 = beg_end(max(pbc_loc, 0) - pbc_loc + 1) >= 0 - ! - ! bc_x >= 0 -> [send/recv]_tag [dst/src]_proc - ! (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] - ! (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] - ! (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] - ! (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] + ! Implements: + ! pbc_loc bc_x >= 0 -> [send/recv]_tag [dst/src]_proc + ! -1 (=0) 0 -> [1,0] [0,0] | 0 0 [1,0] [beg,beg] + ! -1 (=0) 1 -> [0,0] [1,0] | 0 1 [0,0] [end,beg] + ! +1 (=1) 0 -> [0,1] [1,1] | 1 0 [0,1] [end,end] + ! +1 (=1) 1 -> [1,1] [0,1] | 1 1 [1,1] [beg,end] send_tag = f_logical_to_int(.not. f_xor(beg_end_geq_0, pbc_loc == 1)) recv_tag = f_logical_to_int(pbc_loc == 1) @@ -317,7 +317,7 @@ contains unpack_offset = grid_dims(mpi_dir) + buff_size + 1 end if - ! Buffer to Send + ! Pack Buffer to Send #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then #:if mpi_dir == 1 @@ -393,7 +393,7 @@ contains end if #:endfor - ! Received Buffer + ! Unpack Received Buffer call nvtxStartRange("IB-MARKER-COMM-UNPACKBUF") #:for mpi_dir in [1, 2, 3] if (mpi_dir == ${mpi_dir}$) then @@ -421,7 +421,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() #:else - ! buffer from bc_z%beg + ! Unpacking buffer from bc_z%beg $:GPU_PARALLEL_LOOP(collapse=3,private='[j,k,l,r]') do l = -buff_size, -1 do k = -buff_size, n + buff_size diff --git a/src/simulation/m_muscl.fpp b/src/simulation/m_muscl.fpp index 6fd907c2eb..91e32a7c6a 100644 --- a/src/simulation/m_muscl.fpp +++ b/src/simulation/m_muscl.fpp @@ -27,12 +27,12 @@ module m_muscl $:GPU_DECLARE(create='[is1_muscl,is2_muscl,is3_muscl]') !> @name The cell-average variables that will be MUSCL-reconstructed. Formerly, they - !! in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR - !! be reshaped (RS) and/or characteristically decomposed. The reshaping - !! muscl procedure to be independent of the coordinate direction of - !! Lastly, notice that the left (L) and right (R) results - !! characteristic decomposition are stored in custom-constructed muscl- - !! that are annexed to each position of a given scalar field. + !! are stored in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR + !! as to be reshaped (RS) and/or characteristically decomposed. The reshaping + !! allows the muscl procedure to be independent of the coordinate direction of + !! the reconstruction. Lastly, notice that the left (L) and right (R) results + !! of the characteristic decomposition are stored in custom-constructed muscl- + !! stencils (WS) that are annexed to each position of a given scalar field. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: v_rs_ws_x_muscl, v_rs_ws_y_muscl, v_rs_ws_z_muscl !> @} @@ -42,7 +42,7 @@ contains subroutine s_initialize_muscl_module() - ! in x-direction + ! Initializing in x-direction is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg if (n == 0) then is2_muscl%beg = 0 @@ -65,7 +65,7 @@ contains if (n == 0) return - ! in y-direction + ! initializing in y-direction is2_muscl%beg = -buff_size; is2_muscl%end = n - is2_muscl%beg is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg @@ -82,7 +82,7 @@ contains if (p == 0) return - ! in z-direction + ! initializing in z-direction is2_muscl%beg = -buff_size; is2_muscl%end = n - is2_muscl%beg is1_muscl%beg = -buff_size; is1_muscl%end = m - is1_muscl%beg is3_muscl%beg = -buff_size; is3_muscl%end = p - is3_muscl%beg @@ -160,7 +160,7 @@ contains end if if (muscl_order == 2 .or. dummy) then - ! Reconstruction + ! MUSCL Reconstruction #:for MUSCL_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] if (muscl_dir == ${MUSCL_DIR}$) then $:GPU_PARALLEL_LOOP(collapse=4,private='[i,j,k,l,slopeL,slopeR,slope]') @@ -201,11 +201,11 @@ contains end if end if - ! from left side + ! reconstruct from left side vL_rs_vf_${XYZ}$ (j, k, l, i) = & v_rs_ws_${XYZ}$_muscl(j, k, l, i) - (5.e-1_wp*slope) - ! from the right side + ! reconstruct from the right side vR_rs_vf_${XYZ}$ (j, k, l, i) = & v_rs_ws_${XYZ}$_muscl(j, k, l, i) + (5.e-1_wp*slope) @@ -270,7 +270,7 @@ contains B = exp(sign*ic_beta*(2._wp*C - 1._wp)) A = (B/cosh(ic_beta) - 1._wp)/tanh(ic_beta) - ! reconstruction + ! Left reconstruction aTHINC = qmin + 5e-1_wp*qmax*(1._wp + sign*A) if (aTHINC < ic_eps) aTHINC = ic_eps if (aTHINC > 1 - ic_eps) aTHINC = 1 - ic_eps @@ -281,7 +281,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, advxb) = aTHINC vL_rs_vf_${XYZ}$ (j, k, l, advxe) = 1 - aTHINC - ! reconstruction + ! Right reconstruction aTHINC = qmin + 5e-1_wp*qmax*(1._wp + sign*(tanh(ic_beta) + A)/(1._wp + A*tanh(ic_beta))) if (aTHINC < ic_eps) aTHINC = ic_eps if (aTHINC > 1 - ic_eps) aTHINC = 1 - ic_eps @@ -310,11 +310,11 @@ contains integer :: j, k, l, q !< Generic loop iterators - ! the number of cell-average variables which will be - ! and mapping their indical bounds in the x-, - ! and z-directions to those in the s1-, s2- and s3-directions - ! to reshape the inputted data in the coordinate direction of - ! muscl reconstruction + ! Determining the number of cell-average variables which will be + ! muscl-reconstructed and mapping their indical bounds in the x-, + ! y- and z-directions to those in the s1-, s2- and s3-directions + ! as to reshape the inputted data in the coordinate direction of + ! the muscl reconstruction v_size = ubound(v_vf, 1) $:GPU_UPDATE(device='[v_size]') @@ -332,7 +332,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! onto Characteristic Fields in y-direction + ! Reshaping/Projecting onto Characteristic Fields in y-direction if (n == 0) return if (muscl_dir == 2) then @@ -349,7 +349,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! onto Characteristic Fields in z-direction + ! Reshaping/Projecting onto Characteristic Fields in z-direction if (p == 0) return if (muscl_dir == 3) then $:GPU_PARALLEL_LOOP(private='[j,k,l,q]', collapse=4) diff --git a/src/simulation/m_pressure_relaxation.fpp b/src/simulation/m_pressure_relaxation.fpp index c4e57ef8c7..5482778357 100644 --- a/src/simulation/m_pressure_relaxation.fpp +++ b/src/simulation/m_pressure_relaxation.fpp @@ -1,14 +1,14 @@ !> -!! -!! module m_pressure_relaxation +!! @file +!! @brief Contains module m_pressure_relaxation #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains the subroutines used to perform pressure relaxation -!! flows using the 6-equation model. This includes -!! correction, Newton-Raphson pressure equilibration, and -!! correction to maintain thermodynamic consistency. +!! for multi-component flows using the 6-equation model. This includes +!! volume fraction correction, Newton-Raphson pressure equilibration, and +!! internal energy correction to maintain thermodynamic consistency. module m_pressure_relaxation use m_derived_types !< Definitions of the derived types @@ -52,7 +52,7 @@ contains end subroutine s_finalize_pressure_relaxation_module !> The main pressure relaxation procedure - !! Cell-average conservative variables + !! @param q_cons_vf Cell-average conservative variables subroutine s_pressure_relaxation_procedure(q_cons_vf) type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf @@ -77,15 +77,15 @@ contains type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_vf integer, intent(in) :: j, k, l - ! fraction correction + ! Volume fraction correction if (mpp_lim) call s_correct_volume_fractions(q_cons_vf, j, k, l) - ! equilibration + ! Pressure equilibration if (s_needs_pressure_relaxation(q_cons_vf, j, k, l)) then call s_equilibrate_pressure(q_cons_vf, j, k, l) end if - ! energy correction + ! Internal energy correction call s_correct_internal_energies(q_cons_vf, j, k, l) end subroutine s_relax_cell_pressure @@ -155,7 +155,7 @@ contains real(wp), parameter :: TOLERANCE = 1.e-10_wp integer :: iter, i - ! pressures + ! Initialize pressures pres_relax = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -170,7 +170,7 @@ contains pres_relax = pres_relax + q_cons_vf(i + advxb - 1)%sf(j, k, l)*pres_K_init(i) end do - ! iteration + ! Newton-Raphson iteration f_pres = 1.e-9_wp df_pres = 1.e9_wp $:GPU_LOOP(parallelism='[seq]') @@ -178,13 +178,13 @@ contains if (abs(f_pres) > TOLERANCE) then pres_relax = pres_relax - f_pres/df_pres - ! pressure bounds + ! Enforce pressure bounds do i = 1, num_fluids if (pres_relax <= -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp) & pres_relax = -(1._wp - 1.e-8_wp)*ps_inf(i) + 1.e-8_wp end do - ! step + ! Newton-Raphson step f_pres = -1._wp df_pres = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -202,7 +202,7 @@ contains end if end do - ! volume fractions + ! Update volume fractions $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids if (q_cons_vf(i + advxb - 1)%sf(j, k, l) > sgm_eps) & @@ -232,7 +232,7 @@ contains alpha(i) = q_cons_vf(E_idx + i)%sf(j, k, l) end do - ! mixture properties (combined bubble and standard logic) + ! Compute mixture properties (combined bubble and standard logic) rho = 0._wp gamma = 0._wp pi_inf = 0._wp @@ -290,7 +290,7 @@ contains end if end if - ! dynamic pressure and update internal energies + ! Compute dynamic pressure and update internal energies dyn_pres = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = momxb, momxe diff --git a/src/simulation/m_qbmm.fpp b/src/simulation/m_qbmm.fpp index eeb274d48f..d580688ba6 100644 --- a/src/simulation/m_qbmm.fpp +++ b/src/simulation/m_qbmm.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_qbmm +!! @file +!! @brief Contains module m_qbmm #:include 'case.fpp' #:include 'macros.fpp' @@ -50,10 +50,10 @@ contains #:if not MFC_CASE_OPTIMIZATION if (bubble_model == 2) then - ! without viscosity/surface tension + ! Keller-Miksis without viscosity/surface tension nterms = 32 else if (bubble_model == 3) then - ! with viscosity/surface tension + ! Rayleigh-Plesset with viscosity/surface tension nterms = 7 end if @@ -65,9 +65,9 @@ contains @:ALLOCATE(momrhs(1:3, 0:2, 0:2, 1:nterms, 1:nb)) momrhs = 0._wp - ! the required RHS moments for moment transport equations - ! rhs%(:,3) is only to be used for R0 quadrature, not for computing X/Y indices - ! for different governing equations in polytropic and non-polytropic models + ! Assigns the required RHS moments for moment transport equations + ! The rhs%(:,3) is only to be used for R0 quadrature, not for computing X/Y indices + ! Accounts for different governing equations in polytropic and non-polytropic models if (.not. polytropic) then do q = 1, nb do i1 = 0, 2; do i2 = 0, 2 @@ -90,14 +90,14 @@ contains momrhs(3, i1, i2, 4, q) = 0._wp if (.not. f_is_default(Re_inv)) then - ! viscosity + ! add viscosity momrhs(1, i1, i2, 5, q) = -2._wp + i1 momrhs(2, i1, i2, 5, q) = i2 momrhs(3, i1, i2, 5, q) = 0._wp end if if (.not. f_is_default(Web)) then - ! surface tension + ! add surface tension momrhs(1, i1, i2, 6, q) = -2._wp + i1 momrhs(2, i1, i2, 6, q) = -1._wp + i2 momrhs(3, i1, i2, 6, q) = 0._wp @@ -108,7 +108,7 @@ contains momrhs(3, i1, i2, 7, q) = 0._wp else if (bubble_model == 2) then - ! with approximation of 1/(1-V/C) = 1+V/C + ! KM with approximation of 1/(1-V/C) = 1+V/C momrhs(1, i1, i2, 1, q) = -1._wp + i1 momrhs(2, i1, i2, 1, q) = 1._wp + i2 momrhs(3, i1, i2, 1, q) = 0._wp @@ -263,14 +263,14 @@ contains momrhs(3, i1, i2, 4, q) = 0._wp if (.not. f_is_default(Re_inv)) then - ! viscosity + ! add viscosity momrhs(1, i1, i2, 5, q) = -2._wp + i1 momrhs(2, i1, i2, 5, q) = i2 momrhs(3, i1, i2, 5, q) = 0._wp end if if (.not. f_is_default(Web)) then - ! surface tension + ! add surface tension momrhs(1, i1, i2, 6, q) = -2._wp + i1 momrhs(2, i1, i2, 6, q) = -1._wp + i2 momrhs(3, i1, i2, 6, q) = 0._wp @@ -281,7 +281,7 @@ contains momrhs(3, i1, i2, 7, q) = 0._wp else if (bubble_model == 2) then - ! with approximation of 1/(1-V/C) = 1+V/C + ! KM with approximation of 1/(1-V/C) = 1+V/C momrhs(1, i1, i2, 1, q) = -1._wp + i1 momrhs(2, i1, i2, 1, q) = 1._wp + i2 momrhs(3, i1, i2, 1, q) = 0._wp @@ -539,7 +539,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! following block is not repeated and is left as is + ! The following block is not repeated and is left as is if (idir == 1) then $:GPU_PARALLEL_LOOP(private='[i,l,q]', collapse=3) do l = 0, p @@ -585,7 +585,7 @@ contains if ((i1 + i2) <= 2) then if (bubble_model == 3) then #:if not MFC_CASE_OPTIMIZATION or nterms > 1 - ! + ! RPE coeffs(1, i1, i2) = -1._wp*i2*pres/rho coeffs(2, i1, i2) = -3._wp*i2/2._wp coeffs(3, i1, i2) = i2/rho @@ -595,7 +595,7 @@ contains coeffs(7, i1, i2) = 0._wp #:endif else if (bubble_model == 2) then - ! with approximation of 1/(1-V/C) = 1+V/C + ! KM with approximation of 1/(1-V/C) = 1+V/C #:if not MFC_CASE_OPTIMIZATION or nterms > 7 coeffs(1, i1, i2) = -3._wp*i2/2._wp coeffs(2, i1, i2) = -i2/c @@ -663,7 +663,7 @@ contains do i2 = 0, 2; do i1 = 0, 2 if ((i1 + i2) <= 2) then if (bubble_model == 3) then - ! + ! RPE #:if not MFC_CASE_OPTIMIZATION or nterms > 1 coeffs(1, i1, i2) = -1._wp*i2*pres/rho coeffs(2, i1, i2) = -3._wp*i2/2._wp @@ -674,7 +674,7 @@ contains coeffs(7, i1, i2) = i2*pv/rho #:endif else if (bubble_model == 2) then - ! with approximation of 1/(1-V/C) = 1+V/C + ! KM with approximation of 1/(1-V/C) = 1+V/C #:if not MFC_CASE_OPTIMIZATION or nterms > 7 coeffs(1, i1, i2) = -3._wp*i2/2._wp coeffs(2, i1, i2) = -i2/c @@ -764,7 +764,7 @@ contains nbub = q_cons_vf(bubxb)%sf(id1, id2, id3) $:GPU_LOOP(parallelism='[seq]') do q = 1, nb - ! moments for this bubble bin + ! Gather moments for this bubble bin $:GPU_LOOP(parallelism='[seq]') do r = 2, nmom moms(r) = q_prim_vf(bubmoms(q, r))%sf(id1, id2, id3) @@ -794,7 +794,7 @@ contains end do end if - ! change in moments due to bubble dynamics + ! Compute change in moments due to bubble dynamics r = 1 $:GPU_LOOP(parallelism='[seq]') do i2 = 0, 2 @@ -830,7 +830,7 @@ contains end do end do - ! change in pb and mv for non-polytropic model + ! Compute change in pb and mv for non-polytropic model if (.not. polytropic) then $:GPU_LOOP(parallelism='[seq]') do j = 1, nnode @@ -847,7 +847,7 @@ contains end if end do - ! special high-order moments + ! Compute special high-order moments momsp(1)%sf(id1, id2, id3) = f_quad(abscX, abscY, wght, 3._wp, 0._wp, 0._wp) momsp(2)%sf(id1, id2, id3) = 4._wp*pi*nbub*f_quad(abscX, abscY, wght, 2._wp, 1._wp, 0._wp) momsp(3)%sf(id1, id2, id3) = f_quad(abscX, abscY, wght, 3._wp, 2._wp, 0._wp) @@ -882,7 +882,7 @@ contains $:END_GPU_PARALLEL_LOOP() contains - ! to select the correct coefficient routine + ! Helper to select the correct coefficient routine subroutine s_coeff_selector(pres, rho, c, coeff, polytropic) $:GPU_ROUTINE(function_name='s_coeff_selector',parallelism='[seq]', & & cray_inline=True) @@ -907,14 +907,14 @@ contains real(wp), dimension(nmom), intent(in) :: momin real(wp), dimension(nnode), intent(inout) :: wght, abscX, abscY - ! variables + ! Local variables real(wp), dimension(0:2, 0:2) :: moms real(wp), dimension(3) :: M1, M3 real(wp), dimension(2) :: myrho, myrho3, up, up3, Vf real(wp) :: bu, bv, d20, d11, d_02, c20, c11, c02 real(wp) :: mu2, vp21, vp22, rho21, rho22 - ! moments to 2D array for clarity + ! Assign moments to 2D array for clarity moms(0, 0) = momin(1) moms(1, 0) = momin(2) moms(0, 1) = momin(3) @@ -922,7 +922,7 @@ contains moms(1, 1) = momin(5) moms(0, 2) = momin(6) - ! means and central moments + ! Compute means and central moments bu = moms(1, 0)/moms(0, 0) bv = moms(0, 1)/moms(0, 0) d20 = moms(2, 0)/moms(0, 0) @@ -933,26 +933,26 @@ contains c11 = d11 - bu*bv c02 = d_02 - bv**2._wp - ! 1D quadrature (X direction) + ! First 1D quadrature (X direction) M1 = (/1._wp, 0._wp, c20/) call s_hyqmom(myrho, up, M1) Vf = c11*up/c20 - ! 1D quadrature (Y direction, conditional on X) + ! Second 1D quadrature (Y direction, conditional on X) mu2 = max(0._wp, c02 - sum(myrho*(Vf**2._wp))) M3 = (/1._wp, 0._wp, mu2/) call s_hyqmom(myrho3, up3, M3) - ! roots and weights for 2D quadrature + ! Assign roots and weights for 2D quadrature vp21 = up3(1) vp22 = up3(2) rho21 = myrho3(1) rho22 = myrho3(2) - ! weights (vectorized) + ! Compute weights (vectorized) wght = moms(0, 0)*[myrho(1)*rho21, myrho(1)*rho22, myrho(2)*rho21, myrho(2)*rho22] - ! abscissas (vectorized) + ! Compute abscissas (vectorized) abscX = bu + [up(1), up(1), up(2), up(2)] abscY = bv + [Vf(1) + vp21, Vf(1) + vp22, Vf(2) + vp21, Vf(2) + vp22] diff --git a/src/simulation/m_rhs.fpp b/src/simulation/m_rhs.fpp index 1813efe5f5..4fca1f0620 100644 --- a/src/simulation/m_rhs.fpp +++ b/src/simulation/m_rhs.fpp @@ -1,22 +1,22 @@ !> -!! -!! module m_rhs +!! @file +!! @brief Contains module m_rhs #:include 'case.fpp' #:include 'macros.fpp' !> @brief The module contains the subroutines used to calculate the right- -!! in the quasi-conservative, shock- and interface- -!! framework for the multicomponent Navier- -!! supplemented by appropriate advection equations -!! capture the material interfaces. The system of equations -!! by the stiffened gas equation of state, as well as any -!! relationships. Capillarity effects are included -!! modeled by the means of a volume force acting across the -!! interface region. The implementation details of -!! may be found in Perigaud and Saurel (2005). Note -!! viscous and surface tension effects are only available -!! volume fraction model. +!! hane-side (RHS) in the quasi-conservative, shock- and interface- +!! capturing finite-volume framework for the multicomponent Navier- +!! Stokes equations supplemented by appropriate advection equations +!! used to capture the material interfaces. The system of equations +!! is closed by the stiffened gas equation of state, as well as any +!! required mixture relationships. Capillarity effects are included +!! and are modeled by the means of a volume force acting across the +!! diffuse material interface region. The implementation details of +!! surface tension may be found in Perigaud and Saurel (2005). Note +!! that both viscous and surface tension effects are only available +!! in the volume fraction model. module m_rhs use m_derived_types !< Definitions of the derived types @@ -28,10 +28,10 @@ module m_rhs use m_variables_conversion !< State variables type conversion procedures use m_weno !< Weighted and essentially non-oscillatory (WENO) - !! spatial reconstruction of variables + !! schemes for spatial reconstruction of variables use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! conservation laws + !! schemes for conservation laws use m_riemann_solvers !< Exact and approximate Riemann problem solvers @@ -75,32 +75,32 @@ module m_rhs s_compute_rhs, & s_finalize_rhs_module - !! contains the WENO-reconstructed values of the cell-average - !! which are located in q_cons_vf, at cell-interior - !! points (QP). + !! This variable contains the WENO-reconstructed values of the cell-average + !! conservative variables, which are located in q_cons_vf, at cell-interior + !! Gaussian quadrature points (QP). type(vector_field) :: q_cons_qp !< $:GPU_DECLARE(create='[q_cons_qp]') - !! variables at cell-interior Gaussian quadrature points. These - !! from the conservative variables and gradient magnitude (GM) - !! volume fractions, q_cons_qp and gm_alpha_qp, respectively. + !! The primitive variables at cell-interior Gaussian quadrature points. These + !! are calculated from the conservative variables and gradient magnitude (GM) + !! of the volume fractions, q_cons_qp and gm_alpha_qp, respectively. type(vector_field) :: q_prim_qp !< $:GPU_DECLARE(create='[q_prim_qp]') !> @name The first-order spatial derivatives of the primitive variables at cell- - !! quadrature points. These are WENO-reconstructed from - !! cell-average values, obtained through the application - !! divergence theorem on the integral-average cell-boundary values - !! primitive variables, located in qK_prim_n, where K = L or R. + !! interior Gaussian quadrature points. These are WENO-reconstructed from + !! their respective cell-average values, obtained through the application + !! of the divergence theorem on the integral-average cell-boundary values + !! of the primitive variables, located in qK_prim_n, where K = L or R. !> @{ type(vector_field), allocatable, dimension(:) :: dq_prim_dx_qp, dq_prim_dy_qp, dq_prim_dz_qp $:GPU_DECLARE(create='[dq_prim_dx_qp,dq_prim_dy_qp,dq_prim_dz_qp]') !> @} !> @name The left and right WENO-reconstructed cell-boundary values of the cell- - !! spatial derivatives of the primitive variables. The - !! the first-order spatial derivatives may be found in the - !! where s = x, y or z. + !! average first-order spatial derivatives of the primitive variables. The + !! cell-average of the first-order spatial derivatives may be found in the + !! variables dq_prim_ds_qp, where s = x, y or z. !> @{ type(vector_field), allocatable, dimension(:) :: dqL_prim_dx_n, dqL_prim_dy_n, dqL_prim_dz_n type(vector_field), allocatable, dimension(:) :: dqR_prim_dx_n, dqR_prim_dy_n, dqR_prim_dz_n @@ -114,14 +114,14 @@ module m_rhs $:GPU_DECLARE(create='[tau_Re_vf]') type(vector_field) :: gm_alpha_qp !< - !! magnitude of the volume fractions at cell-interior Gaussian - !! gm_alpha_qp is calculated from individual first-order - !! located in dq_prim_ds_qp. + !! The gradient magnitude of the volume fractions at cell-interior Gaussian + !! quadrature points. gm_alpha_qp is calculated from individual first-order + !! spatial derivatives located in dq_prim_ds_qp. $:GPU_DECLARE(create='[gm_alpha_qp]') !> @name The left and right WENO-reconstructed cell-boundary values of the cell- - !! magnitude of volume fractions, located in gm_alpha_qp. + !! average gradient magnitude of volume fractions, located in gm_alpha_qp. !> @{ type(vector_field), allocatable, dimension(:) :: gm_alphaL_n type(vector_field), allocatable, dimension(:) :: gm_alphaR_n @@ -131,8 +131,8 @@ module m_rhs !> @} !> @name The cell-boundary values of the fluxes (src - source, gsrc - geometrical - !! are computed by applying the chosen Riemann problem solver - !! left and right cell-boundary values of the primitive variables + !! source). These are computed by applying the chosen Riemann problem solver + !! .on the left and right cell-boundary values of the primitive variables !> @{ type(vector_field), allocatable, dimension(:) :: flux_n type(vector_field), allocatable, dimension(:) :: flux_src_n @@ -179,8 +179,8 @@ module m_rhs contains !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_rhs_module integer :: i, j, k, l, id !< Generic loop iterators @@ -202,9 +202,9 @@ contains end if if (surface_tension) then - ! assumes that the color function advection equation is - ! last equation. If this changes then this logic will - ! updated + ! This assumes that the color function advection equation is + ! the last equation. If this changes then this logic will + ! need updated do l = adv_idx%end + 1, sys_size - 1 @:ALLOCATE(q_prim_qp%vf(l)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) end do @@ -220,7 +220,7 @@ contains do l = 1, cont_idx%end if (relativity) then - ! and Prim densities are different for relativity + ! Cons and Prim densities are different for relativity @:ALLOCATE(q_prim_qp%vf(l)%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) else q_prim_qp%vf(l)%sf => q_cons_qp%vf(l)%sf @@ -250,7 +250,7 @@ contains $:GPU_ENTER_DATA(attach='[q_prim_qp%vf(psi_idx)%sf]') end if - ! of flux_n, flux_src_n, and flux_gsrc_n + ! Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n if (.not. igr) then @:ALLOCATE(flux_n(1:num_dims)) @:ALLOCATE(flux_src_n(1:num_dims)) @@ -341,12 +341,12 @@ contains end if end do - ! Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n + ! END: Allocation/Association of flux_n, flux_src_n, and flux_gsrc_n end if if ((.not. igr) .or. dummy) then - ! of dq_prim_ds_qp + ! Allocation of dq_prim_ds_qp @:ALLOCATE(dq_prim_dx_qp(1:1)) @:ALLOCATE(dq_prim_dy_qp(1:1)) @:ALLOCATE(dq_prim_dz_qp(1:1)) @@ -354,7 +354,7 @@ contains @:ALLOCATE(qL_prim(1:num_dims)) @:ALLOCATE(qR_prim(1:num_dims)) - ! of dqK_prim_ds_n + ! Allocation/Association of dqK_prim_ds_n @:ALLOCATE(dqL_prim_dx_n(1:num_dims)) @:ALLOCATE(dqL_prim_dy_n(1:num_dims)) @:ALLOCATE(dqL_prim_dz_n(1:num_dims)) @@ -621,9 +621,9 @@ contains if (mpp_lim .and. bubbles_euler) then @:ALLOCATE(alf_sum%sf(idwbuff(1)%beg:idwbuff(1)%end, idwbuff(2)%beg:idwbuff(2)%end, idwbuff(3)%beg:idwbuff(3)%end)) end if - ! Allocation/Association of qK_cons_n and qK_prim_n + ! END: Allocation/Association of qK_cons_n and qK_prim_n - ! of gm_alphaK_n + ! Allocation of gm_alphaK_n if (.not. igr) then @:ALLOCATE(gm_alphaL_n(1:num_dims)) @:ALLOCATE(gm_alphaR_n(1:num_dims)) @@ -665,7 +665,7 @@ contains call cpu_time(t_start) if (.not. igr .or. dummy) then - ! of Working Variables + ! Association/Population of Working Variables $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=4) do i = 1, sys_size do l = idwbuff(3)%beg, idwbuff(3)%end @@ -678,7 +678,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! Conservative to Primitive Variables + ! Converting Conservative to Primitive Variables if (mpp_lim .and. bubbles_euler) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) @@ -753,7 +753,7 @@ contains call nvtxEndRange end if - ! Splitting Loop + ! Dimensional Splitting Loop do id = 1, num_dims if (igr .or. dummy) then @@ -788,12 +788,12 @@ contains end if if ((.not. igr) .or. dummy) then! Finite volume solve - ! Primitive/Conservative Variables + ! Reconstructing Primitive/Conservative Variables call nvtxStartRange("RHS-WENO") if (.not. surface_tension) then if (all(Re_size == 0)) then - ! densitiess + ! Reconstruct densitiess iv%beg = 1; iv%end = sys_size call s_reconstruct_cell_boundary_values( & q_prim_qp%vf(1:sys_size), & @@ -863,7 +863,7 @@ contains end if - ! viscous derivatives for viscosity + ! Reconstruct viscous derivatives for viscosity if (weno_Re_flux) then iv%beg = momxb; iv%end = momxe call s_reconstruct_cell_boundary_values_visc_deriv( & @@ -892,7 +892,7 @@ contains call nvtxEndRange ! WENO - ! Coordinate Direction Indexes + ! Configuring Coordinate Direction Indexes if (id == 1) then irx%beg = -1; iry%beg = 0; irz%beg = 0 elseif (id == 2) then @@ -901,9 +901,9 @@ contains irx%beg = 0; iry%beg = 0; irz%beg = -1 end if irx%end = m; iry%end = n; irz%end = p - ! - ! *, "L", qL_rsx_vf(100:300, 0, 0, 1) - ! *, "R", qR_rsx_vf(100:300, 0, 0, 1) + ! $:GPU_UPDATE(host='[qL_rsx_vf,qR_rsx_vf]') + ! print *, "L", qL_rsx_vf(100:300, 0, 0, 1) + ! print *, "R", qR_rsx_vf(100:300, 0, 0, 1) !Computing Riemann Solver Flux and Source Flux call nvtxStartRange("RHS-RIEMANN-SOLVER") @@ -927,8 +927,8 @@ contains !$:GPU_UPDATE(host='[flux_n(1)%vf(1)%sf]') !print *, "FLUX", flux_n(1)%vf(1)%sf(100:300, 0, 0) - ! physics and source terms - ! addition for advection source + ! Additional physics and source terms + ! RHS addition for advection source call nvtxStartRange("RHS-ADVECTION-SRC") call s_compute_advection_source_term(id, & rhs_vf, & @@ -937,21 +937,21 @@ contains flux_src_n(id)) call nvtxEndRange - ! additions for hypoelasticity + ! RHS additions for hypoelasticity call nvtxStartRange("RHS-HYPOELASTICITY") if (hypoelasticity) call s_compute_hypoelastic_rhs(id, & q_prim_qp%vf, & rhs_vf) call nvtxEndRange - ! for diffusion + ! RHS for diffusion if (chemistry .and. chem_params%diffusion) then call nvtxStartRange("RHS-CHEM-DIFFUSION") call s_compute_chemistry_diffusion_flux(id, q_prim_qp%vf, flux_src_n(id)%vf, irx, iry, irz) call nvtxEndRange end if - ! additions for viscosity + ! RHS additions for viscosity if (viscous .or. surface_tension .or. chem_params%diffusion) then call nvtxStartRange("RHS-ADD-PHYSICS") call s_compute_additional_physics_rhs(id, & @@ -964,14 +964,14 @@ contains call nvtxEndRange end if - ! additions for sub-grid bubbles_euler + ! RHS additions for sub-grid bubbles_euler if (bubbles_euler) then call nvtxStartRange("RHS-BUBBLES-COMPUTE") call s_compute_bubbles_EE_rhs(id, q_prim_qp%vf, divu) call nvtxEndRange end if - ! additions for qbmm bubbles + ! RHS additions for qbmm bubbles if (qbmm) then call nvtxStartRange("RHS-QBMM") call s_compute_qbmm_rhs(id, & @@ -983,7 +983,7 @@ contains rhs_pb) call nvtxEndRange end if - ! Additional physics and source terms + ! END: Additional physics and source terms if (hyper_cleaning) then $:GPU_PARALLEL_LOOP(private='[j,k,l]', collapse=3) @@ -998,10 +998,10 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Additional physics and source terms + ! END: Additional physics and source terms end if end do - ! Dimensional Splitting Loop + ! END: Dimensional Splitting Loop if (ib) then $:GPU_PARALLEL_LOOP(private='[i,j,k,l]', collapse=3) @@ -1019,8 +1019,8 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Physics and Source Temrs - ! for acoustic_source + ! Additional Physics and Source Temrs + ! Additions for acoustic_source if (acoustic_source) then call nvtxStartRange("RHS-ACOUSTIC-SRC") call s_acoustic_src_calculations(q_cons_qp%vf(1:sys_size), & @@ -1030,7 +1030,7 @@ contains call nvtxEndRange end if - ! bubbles source term + ! Add bubbles source term if (bubbles_euler .and. (.not. adap_dt) .and. (.not. qbmm)) then call nvtxStartRange("RHS-BUBBLES-SRC") call s_compute_bubble_EE_source( & @@ -1042,14 +1042,14 @@ contains end if if (bubbles_lagrange) then - ! additions for sub-grid bubbles_lagrange + ! RHS additions for sub-grid bubbles_lagrange call nvtxStartRange("RHS-EL-BUBBLES-SRC") call s_compute_bubbles_EL_source( & q_cons_qp%vf(1:sys_size), & q_prim_qp%vf(1:sys_size), & rhs_vf) call nvtxEndRange - ! bubble dynamics + ! Compute bubble dynamics if (.not. adap_dt) then call nvtxStartRange("RHS-EL-BUBBLES-DYN") call s_compute_bubble_EL_dynamics( & @@ -1067,7 +1067,7 @@ contains if (cont_damage) call s_compute_damage_state(q_cons_qp%vf, rhs_vf) - ! Additional pphysics and source terms + ! END: Additional pphysics and source terms if (run_time_info .or. probe_wrt .or. ib .or. bubbles_lagrange) then if (.not. igr .or. dummy) then @@ -1344,7 +1344,7 @@ contains type(vector_field), intent(in) :: q_cons_vf_arg type(vector_field), intent(in) :: q_prim_vf_arg type(vector_field), intent(in) :: flux_src_n_vf_arg - ! DECLARATION FOR Kterm_arg: + ! CORRECTED DECLARATION FOR Kterm_arg: real(wp), allocatable, dimension(:, :, :), intent(in) :: Kterm_arg integer :: j_adv, k_idx, l_idx, q_idx @@ -1735,8 +1735,8 @@ contains end if end if - ! the geometrical viscous Riemann source fluxes calculated as average - ! values at cell boundaries + ! Applying the geometrical viscous Riemann source fluxes calculated as average + ! of values at cell boundaries if (cyl_coord) then if ((bc_y%beg == -2) .or. (bc_y%beg == -14)) then @@ -1868,15 +1868,15 @@ contains end subroutine s_compute_additional_physics_rhs !> The purpose of this subroutine is to WENO-reconstruct the - !! the right cell-boundary values, including values - !! Gaussian quadrature points, from the cell-averaged - !! - !! Cell-average variables - !! Left WENO-reconstructed, cell-boundary values including - !! at the quadrature points, of the cell-average variables - !! Right WENO-reconstructed, cell-boundary values including - !! at the quadrature points, of the cell-average variables - !! Splitting coordinate direction + !! left and the right cell-boundary values, including values + !! at the Gaussian quadrature points, from the cell-averaged + !! variables. + !! @param v_vf Cell-average variables + !! @param vL_qp Left WENO-reconstructed, cell-boundary values including + !! the values at the quadrature points, of the cell-average variables + !! @param vR_qp Right WENO-reconstructed, cell-boundary values including + !! the values at the quadrature points, of the cell-average variables + !! @param norm_dir Splitting coordinate direction subroutine s_reconstruct_cell_boundary_values(v_vf, vL_x, vL_y, vL_z, vR_x, vR_y, vR_z, & norm_dir) @@ -1891,7 +1891,7 @@ contains #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! in s1-direction + ! Reconstruction in s1-direction if (norm_dir == 1) then is1 = idwbuff(1); is2 = idwbuff(2); is3 = idwbuff(3) recon_dir = 1; is1%beg = is1%beg + ${SCHEME}$_polyn @@ -1942,7 +1942,7 @@ contains integer :: recon_dir !< Coordinate direction of the WENO reconstruction integer :: i, j, k, l - ! in s1-direction + ! Reconstruction in s1-direction #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl', 'MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then @@ -2020,7 +2020,7 @@ contains if (.not. igr) then do j = cont_idx%beg, cont_idx%end if (relativity) then - ! and Prim densities are different for relativity + ! Cons and Prim densities are different for relativity @:DEALLOCATE(q_cons_qp%vf(j)%sf) @:DEALLOCATE(q_prim_qp%vf(j)%sf) else diff --git a/src/simulation/m_riemann_solvers.fpp b/src/simulation/m_riemann_solvers.fpp index 22f5a0b46e..0416bfc464 100644 --- a/src/simulation/m_riemann_solvers.fpp +++ b/src/simulation/m_riemann_solvers.fpp @@ -1,23 +1,23 @@ !> -!! -!! module m_riemann_solvers +!! @file +!! @brief Contains module m_riemann_solvers !> @brief This module features a database of approximate and exact Riemann -!! for the Navier-Stokes system of equations, which -!! by appropriate advection equations that are used -!! the material interfaces. The closure of the system is -!! the stiffened gas equation of state and any required -!! Surface tension effects are accounted for and -!! by means of a volume force acting across the diffuse -!! region. The implementation details of viscous -!! effects, into the Riemann solvers, may be found in -!! Saurel (2005). Note that both effects are available -!! the volume fraction model. At this time, the approximate -!! Riemann solvers that are listed below are available: -!! Leer (HLL) -!! Leer-Contact (HLLC) -!! -!! Leer Discontinuities (HLLD) - for MHD only +!! problem solvers for the Navier-Stokes system of equations, which +!! is supplemented by appropriate advection equations that are used +!! to capture the material interfaces. The closure of the system is +!! achieved by the stiffened gas equation of state and any required +!! mixture relations. Surface tension effects are accounted for and +!! are modeled by means of a volume force acting across the diffuse +!! material interface region. The implementation details of viscous +!! and capillary effects, into the Riemann solvers, may be found in +!! Perigaud and Saurel (2005). Note that both effects are available +!! only in the volume fraction model. At this time, the approximate +!! and exact Riemann solvers that are listed below are available: +!! 1) Harten-Lax-van Leer (HLL) +!! 2) Harten-Lax-van Leer-Contact (HLLC) +!! 3) Exact +!! 4) Harten-Lax-van Leer Discontinuities (HLLD) - for MHD only #:include 'case.fpp' #:include 'macros.fpp' @@ -64,9 +64,9 @@ module m_riemann_solvers s_finalize_riemann_solvers_module !> The cell-boundary values of the fluxes (src - source) that are computed - !! chosen Riemann problem solver, and the direct evaluation of - !! by using the left and right states given in qK_prim_rs_vf, - !! ds = dx, dy or dz. + !! through the chosen Riemann problem solver, and the direct evaluation of + !! source terms, by using the left and right states given in qK_prim_rs_vf, + !! dqK_prim_ds_vf where ds = dx, dy or dz. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: flux_rsx_vf, flux_src_rsx_vf @@ -76,8 +76,8 @@ module m_riemann_solvers !> @} !> The cell-boundary values of the geometrical source flux that are computed - !! chosen Riemann problem solver by using the left and right - !! in qK_prim_rs_vf. Currently 2D axisymmetric for inviscid only. + !! through the chosen Riemann problem solver by using the left and right + !! states given in qK_prim_rs_vf. Currently 2D axisymmetric for inviscid only. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: flux_gsrc_rsx_vf !< @@ -86,8 +86,8 @@ module m_riemann_solvers $:GPU_DECLARE(create='[flux_gsrc_rsx_vf,flux_gsrc_rsy_vf,flux_gsrc_rsz_vf]') !> @} - ! cell-boundary values of the velocity. vel_src_rs_vf is determined as - ! of Riemann problem solution and is used to evaluate the source flux. + ! The cell-boundary values of the velocity. vel_src_rs_vf is determined as + ! part of Riemann problem solution and is used to evaluate the source flux. real(wp), allocatable, dimension(:, :, :, :) :: vel_src_rsx_vf real(wp), allocatable, dimension(:, :, :, :) :: vel_src_rsy_vf @@ -121,37 +121,37 @@ module m_riemann_solvers contains !> Dispatch to the subroutines that are utilized to compute the - !! solution. For additional information please reference: - !! - !! - !! - !! - !! The left WENO-reconstructed cell-boundary values of the - !! variables - !! The right WENO-reconstructed cell-boundary values of the - !! variables - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! Left averaged gradient magnitude - !! Right averaged gradient magnitude - !! Intra-cell fluxes - !! Intra-cell fluxes sources - !! Intra-cell geometric fluxes sources - !! Dir. splitting direction - !! Index bounds in the x-dir - !! Index bounds in the y-dir - !! Index bounds in the z-dir - !! Cell-averaged primitive variables + !! Riemann problem solution. For additional information please reference: + !! 1) s_hll_riemann_solver + !! 2) s_hllc_riemann_solver + !! 3) s_exact_riemann_solver + !! 4) s_hlld_riemann_solver + !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param gm_alphaL_vf Left averaged gradient magnitude + !! @param gm_alphaR_vf Right averaged gradient magnitude + !! @param flux_vf Intra-cell fluxes + !! @param flux_src_vf Intra-cell fluxes sources + !! @param flux_gsrc_vf Intra-cell geometric fluxes sources + !! @param norm_dir Dir. splitting direction + !! @param ix Index bounds in the x-dir + !! @param iy Index bounds in the y-dir + !! @param iz Index bounds in the z-dir + !! @param q_prim_vf Cell-averaged primitive variables subroutine s_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & dqL_prim_dz_vf, & @@ -204,10 +204,10 @@ contains end subroutine s_riemann_solver !> Dispatch to the subroutines that are utilized to compute - !! source fluxes for either Cartesian or cylindrical geometries. - !! information please refer to: - !! - !! + !! the viscous source fluxes for either Cartesian or cylindrical geometries. + !! For more information please refer to: + !! 1) s_compute_cartesian_viscous_source_flux + !! 2) s_compute_cylindrical_viscous_source_flux subroutine s_compute_viscous_source_flux(velL_vf, & dvelL_dx_vf, & dvelL_dy_vf, & @@ -283,7 +283,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! fluxes + ! Intercell fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -353,8 +353,8 @@ contains integer :: i, j, k, l, q !< Generic loop iterators - ! the buffers of the left and right Riemann problem - ! variables, based on the choice of boundary conditions + ! Populating the buffers of the left and right Riemann problem + ! states variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -364,7 +364,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! inputted data based on dimensional splitting direction + ! Reshaping inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -510,14 +510,14 @@ contains call get_species_specific_heats_r(T_R, Cp_iR) if (chem_params%gamma_method == 1) then - ! = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. + ! gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. Gamma_iL = Cp_iL/(Cp_iL - 1.0_wp) Gamma_iR = Cp_iR/(Cp_iR - 1.0_wp) gamma_L = sum(Xs_L(:)/(Gamma_iL(:) - 1.0_wp)) gamma_R = sum(Xs_R(:)/(Gamma_iR(:) - 1.0_wp)) else if (chem_params%gamma_method == 2) then - ! = 2: c_p / c_v where c_p, c_v are specific heats. + ! gamma_method = 2: c_p / c_v where c_p, c_v are specific heats. call get_mixture_specific_heat_cp_mass(T_L, Ys_L, Cp_L) call get_mixture_specific_heat_cp_mass(T_R, Ys_R, Cp_R) call get_mixture_specific_heat_cv_mass(T_L, Ys_L, Cv_L) @@ -552,7 +552,7 @@ contains pres_mag%L = 0.5_wp*(B2%L/Ga%L**2._wp + vdotB%L**2._wp) pres_mag%R = 0.5_wp*(B2%R/Ga%R**2._wp + vdotB%R**2._wp) - ! EOS + ! Hard-coded EOS H_L = 1._wp + (gamma_L + 1)*pres_L/rho_L H_R = 1._wp + (gamma_R + 1)*pres_R/rho_R #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 @@ -578,7 +578,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! energy update + ! elastic energy update if (hypoelasticity) then G_L = 0._wp; G_R = 0._wp @@ -597,12 +597,12 @@ contains do i = 1, strxe - strxb + 1 tau_e_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) tau_e_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough !TODO take out if statement if stable without if ((G_L > 1000) .and. (G_R > 1000)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! for shear stresses + ! Double for shear stresses if (any(strxb - 1 + i == shear_indices)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -611,36 +611,36 @@ contains end do end if - ! energy update + ! elastic energy update !if ( hyperelasticity ) then - ! = 0._wp - ! = 0._wp + ! G_L = 0._wp + ! G_R = 0._wp ! - ! - ! i = 1, num_fluids - ! = G_L + alpha_L(i)*Gs_rs(i) - ! = G_R + alpha_R(i)*Gs_rs(i) - ! do - ! Elastic contribution to energy if G large enough - ! ((G_L > 1.e-3_wp) .and. (G_R > 1.e-3_wp)) then - ! = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) - ! = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) - ! - ! i = 1, b_size-1 - ! = G_L*qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) - ! = G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! do - ! - ! i = 1, b_size-1 - ! = 0._wp - ! = 0._wp - ! do - ! - ! i = 1, num_dims - ! = qL_prim_rs${XYZ}$_vf(j, k, l, xibeg - 1 + i) - ! = qR_prim_rs${XYZ}$_vf(j + 1, k, l, xibeg - 1 + i) - ! do - ! if + ! $:GPU_LOOP(parallelism='[seq]') + ! do i = 1, num_fluids + ! G_L = G_L + alpha_L(i)*Gs_rs(i) + ! G_R = G_R + alpha_R(i)*Gs_rs(i) + ! end do + ! ! Elastic contribution to energy if G large enough + ! if ((G_L > 1.e-3_wp) .and. (G_R > 1.e-3_wp)) then + ! E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) + ! E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) + ! $:GPU_LOOP(parallelism='[seq]') + ! do i = 1, b_size-1 + ! tau_e_L(i) = G_L*qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) + ! tau_e_R(i) = G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) + ! end do + ! $:GPU_LOOP(parallelism='[seq]') + ! do i = 1, b_size-1 + ! tau_e_L(i) = 0._wp + ! tau_e_R(i) = 0._wp + ! end do + ! $:GPU_LOOP(parallelism='[seq]') + ! do i = 1, num_dims + ! xi_field_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, xibeg - 1 + i) + ! xi_field_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, xibeg - 1 + i) + ! end do + ! end if !end if @:compute_average_state() @@ -652,7 +652,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! are placeholders to call the subroutine. + ! variables are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, c_sum_Yi_Phi, c_avg, qv_avg) @@ -741,14 +741,14 @@ contains + (5.e-1_wp - sign(5.e-1_wp, s_L)) & *(5.e-1_wp + sign(5.e-1_wp, s_R)) - ! Mach correction + ! Low Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! + ! Mass if (.not. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -771,12 +771,12 @@ contains end do end if - ! + ! Momentum if (mhd .and. (.not. relativity)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! of rho*v_i in the ${XYZ}$ direction - ! rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! Flux of rho*v_i in the ${XYZ}$ direction + ! = rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(rho_R*vel_R(i)*vel_R(norm_dir) & - B%R(i)*B%R(norm_dir) & @@ -790,8 +790,8 @@ contains elseif (mhd .and. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! of m_i in the ${XYZ}$ direction - ! m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! Flux of m_i in the ${XYZ}$ direction + ! = m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(cm%R(i)*vel_R(norm_dir) & - b4%R(i)/Ga%R*B%R(norm_dir) & @@ -850,9 +850,9 @@ contains end do end if - ! + ! Energy if (mhd .and. (.not. relativity)) then - ! flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) + ! energy flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(vel_R(norm_dir)*(E_R + pres_R + pres_mag%R) - B%R(norm_dir)*(vel_R(1)*B%R(1) + vel_R(2)*B%R(2) + vel_R(3)*B%R(3))) & @@ -861,8 +861,8 @@ contains /(s_M - s_P) #:endif elseif (mhd .and. relativity) then - ! flux = m_${XYZ}$ - mass flux - ! for single-component for now + ! energy flux = m_${XYZ}$ - mass flux + ! Hard-coded for single-component for now flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(cm%R(norm_dir) - Ga%R*alpha_rho_R(1)*vel_R(norm_dir)) & - s_P*(cm%L(norm_dir) - Ga%L*alpha_rho_L(1)*vel_L(norm_dir)) & @@ -895,7 +895,7 @@ contains + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp end if - ! Stresses + ! Elastic Stresses if (hypoelasticity) then do i = 1, strxe - strxb + 1 !TODO: this indexing may be slow flux_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) = & @@ -909,7 +909,7 @@ contains end do end if - ! + ! Advection $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -923,7 +923,7 @@ contains end do if (bubbles_euler) then - ! HLLC: Kills mass transport @ bubble gas density + ! From HLLC: Kills mass transport @ bubble gas density if (num_fluids > 1) then flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if @@ -945,8 +945,8 @@ contains if (mhd) then if (n == 0) then ! 1D: d/dx flux only & Bx = Bx0 = const. - ! flux = v_x * B_y - v_y * Bx0 - ! flux = v_x * B_z - v_z * Bx0 + ! B_y flux = v_x * B_y - v_y * Bx0 + ! B_z flux = v_x * B_z - v_z * Bx0 $:GPU_LOOP(parallelism='[seq]') do i = 0, 1 flux_rsx_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(1)*B%R(2 + i) - vel_R(2 + i)*Bx0) & @@ -954,9 +954,9 @@ contains + s_M*s_P*(B%L(2 + i) - B%R(2 + i)))/(s_M - s_P) end do else ! 2D/3D: Bx, By, Bz /= const. but zero flux component in the same direction - ! d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) - ! d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) - ! d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) + ! B_x d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) + ! B_y d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) + ! B_z d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) $:GPU_LOOP(parallelism='[seq]') do i = 0, 2 flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(dir_idx(1))*B%R(i + 1) - vel_R(i + 1)*B%R(norm_dir)) - & @@ -965,7 +965,7 @@ contains end do if (hyper_cleaning) then - ! magnetic field divergence as a wave + ! propagate magnetic field divergence as a wave flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + norm_dir - 1) = flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + norm_dir - 1) + & (s_M*qR_prim_rs${XYZ}$_vf(j + 1, k, l, psi_idx) - s_P*qL_prim_rs${XYZ}$_vf(j, k, l, psi_idx))/(s_M - s_P) @@ -984,11 +984,11 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_rs${XYZ}$_vf(j, k, l, contxe + 2) & - (s_M*pres_R - s_P*pres_L)/(s_M - s_P) - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) @@ -996,7 +996,7 @@ contains end if if (cyl_coord .and. hypoelasticity) then - ! tau_sigmasigma using HLL + ! += tau_sigmasigma using HLL flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) + & (s_M*tau_e_R(4) - s_P*tau_e_L(4)) & @@ -1074,7 +1074,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! fluxes + ! Intercell fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -1147,8 +1147,8 @@ contains integer :: i, j, k, l, q !< Generic loop iterators integer, dimension(3) :: idx_right_phys !< Physical (j,k,l) indices for right state. - ! the buffers of the left and right Riemann problem - ! variables, based on the choice of boundary conditions + ! Populating the buffers of the left and right Riemann problem + ! states variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -1158,7 +1158,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! inputted data based on dimensional splitting direction + ! Reshaping inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -1305,14 +1305,14 @@ contains call get_species_specific_heats_r(T_R, Cp_iR) if (chem_params%gamma_method == 1) then - ! = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. + ! gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97. Gamma_iL = Cp_iL/(Cp_iL - 1.0_wp) Gamma_iR = Cp_iR/(Cp_iR - 1.0_wp) gamma_L = sum(Xs_L(:)/(Gamma_iL(:) - 1.0_wp)) gamma_R = sum(Xs_R(:)/(Gamma_iR(:) - 1.0_wp)) else if (chem_params%gamma_method == 2) then - ! = 2: c_p / c_v where c_p, c_v are specific heats. + ! gamma_method = 2: c_p / c_v where c_p, c_v are specific heats. call get_mixture_specific_heat_cp_mass(T_L, Ys_L, Cp_L) call get_mixture_specific_heat_cp_mass(T_R, Ys_R, Cp_R) call get_mixture_specific_heat_cv_mass(T_L, Ys_L, Cv_L) @@ -1346,7 +1346,7 @@ contains pres_mag%L = 0.5_wp*(B2%L/Ga%L**2._wp + vdotB%L**2._wp) pres_mag%R = 0.5_wp*(B2%R/Ga%R**2._wp + vdotB%R**2._wp) - ! EOS + ! Hard-coded EOS H_L = 1._wp + (gamma_L + 1)*pres_L/rho_L H_R = 1._wp + (gamma_R + 1)*pres_R/rho_R @@ -1370,7 +1370,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! energy update + ! elastic energy update if (hypoelasticity) then G_L = 0._wp; G_R = 0._wp @@ -1388,12 +1388,12 @@ contains do i = 1, strxe - strxb + 1 tau_e_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) tau_e_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, strxb - 1 + i) - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough !TODO take out if statement if stable without if ((G_L > 1000) .and. (G_R > 1000)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! for shear stresses + ! Double for shear stresses if (any(strxb - 1 + i == shear_indices)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -1430,14 +1430,14 @@ contains s_L = s_M s_R = s_P - ! Mach correction + ! Low Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! + ! Mass if (.not. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe @@ -1460,12 +1460,12 @@ contains end do end if - ! + ! Momentum if (mhd .and. (.not. relativity)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! of rho*v_i in the ${XYZ}$ direction - ! rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! Flux of rho*v_i in the ${XYZ}$ direction + ! = rho * v_i * v_${XYZ}$ - B_i * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(rho_R*vel_R(i)*vel_R(norm_dir) & - B%R(i)*B%R(norm_dir) & @@ -1479,8 +1479,8 @@ contains elseif (mhd .and. relativity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, 3 - ! of m_i in the ${XYZ}$ direction - ! m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot + ! Flux of m_i in the ${XYZ}$ direction + ! = m_i * v_${XYZ}$ - b_i/Gamma * B_${XYZ}$ + delta_(${XYZ}$,i) * p_tot flux_rs${XYZ}$_vf(j, k, l, contxe + i) = & (s_M*(cm%R(i)*vel_R(norm_dir) & - b4%R(i)/Ga%R*B%R(norm_dir) & @@ -1539,9 +1539,9 @@ contains end do end if - ! + ! Energy if (mhd .and. (.not. relativity)) then - ! flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) + ! energy flux = (E + p + p_mag) * v_${XYZ}$ - B_${XYZ}$ * (v_x*B_x + v_y*B_y + v_z*B_z) #:if not MFC_CASE_OPTIMIZATION or num_dims > 1 flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(vel_R(norm_dir)*(E_R + pres_R + pres_mag%R) - B%R(norm_dir)*(vel_R(1)*B%R(1) + vel_R(2)*B%R(2) + vel_R(3)*B%R(3))) & @@ -1550,8 +1550,8 @@ contains /(s_M - s_P) #:endif elseif (mhd .and. relativity) then - ! flux = m_${XYZ}$ - mass flux - ! for single-component for now + ! energy flux = m_${XYZ}$ - mass flux + ! Hard-coded for single-component for now flux_rs${XYZ}$_vf(j, k, l, E_idx) = & (s_M*(cm%R(norm_dir) - Ga%R*alpha_rho_R(1)*vel_R(norm_dir)) & - s_P*(cm%L(norm_dir) - Ga%L*alpha_rho_L(1)*vel_L(norm_dir)) & @@ -1584,7 +1584,7 @@ contains + (s_M/s_L)*(s_P/s_R)*pcorr*(vel_R_rms - vel_L_rms)/2._wp end if - ! Stresses + ! Elastic Stresses if (hypoelasticity) then do i = 1, strxe - strxb + 1 !TODO: this indexing may be slow flux_rs${XYZ}$_vf(j, k, l, strxb - 1 + i) = & @@ -1598,7 +1598,7 @@ contains end do end if - ! + ! Advection $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -1612,7 +1612,7 @@ contains end do if (bubbles_euler) then - ! HLLC: Kills mass transport @ bubble gas density + ! From HLLC: Kills mass transport @ bubble gas density if (num_fluids > 1) then flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if @@ -1634,8 +1634,8 @@ contains if (mhd) then if (n == 0) then ! 1D: d/dx flux only & Bx = Bx0 = const. - ! flux = v_x * B_y - v_y * Bx0 - ! flux = v_x * B_z - v_z * Bx0 + ! B_y flux = v_x * B_y - v_y * Bx0 + ! B_z flux = v_x * B_z - v_z * Bx0 $:GPU_LOOP(parallelism='[seq]') do i = 0, 1 flux_rsx_vf(j, k, l, B_idx%beg + i) = (s_M*(vel_R(1)*B%R(2 + i) - vel_R(2 + i)*Bx0) & @@ -1643,9 +1643,9 @@ contains + s_M*s_P*(B%L(2 + i) - B%R(2 + i)))/(s_M - s_P) end do else ! 2D/3D: Bx, By, Bz /= const. but zero flux component in the same direction - ! d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) - ! d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) - ! d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) + ! B_x d/d${XYZ}$ flux = (1 - delta(x,${XYZ}$)) * (v_${XYZ}$ * B_x - v_x * B_${XYZ}$) + ! B_y d/d${XYZ}$ flux = (1 - delta(y,${XYZ}$)) * (v_${XYZ}$ * B_y - v_y * B_${XYZ}$) + ! B_z d/d${XYZ}$ flux = (1 - delta(z,${XYZ}$)) * (v_${XYZ}$ * B_z - v_z * B_${XYZ}$) $:GPU_LOOP(parallelism='[seq]') do i = 0, 2 flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + i) = (1 - dir_flg(i + 1))*( & @@ -1664,11 +1664,11 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_rs${XYZ}$_vf(j, k, l, contxe + 2) & - (s_M*pres_R - s_P*pres_L)/(s_M - s_P) - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) @@ -1676,7 +1676,7 @@ contains end if if (cyl_coord .and. hypoelasticity) then - ! tau_sigmasigma using HLL + ! += tau_sigmasigma using HLL flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + 2) + & (s_M*tau_e_R(4) - s_P*tau_e_L(4)) & @@ -1925,36 +1925,36 @@ contains end subroutine s_lf_riemann_solver !> This procedure is the implementation of the Harten, Lax, - !! and contact (HLLC) approximate Riemann solver, - !! (1999) and Johnsen (2007). The viscous and the - !! effects have been included by modifying - !! Riemann solver of Perigaud and Saurel (2005). - !! The left WENO-reconstructed cell-boundary values of the - !! variables - !! The right WENO-reconstructed cell-boundary values of the - !! variables - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! Left averaged gradient magnitude - !! Right averaged gradient magnitude - !! Intra-cell fluxes - !! Intra-cell fluxes sources - !! Intra-cell geometric fluxes sources - !! Dir. splitting direction - !! Index bounds in the x-dir - !! Index bounds in the y-dir - !! Index bounds in the z-dir - !! Cell-averaged primitive variables + !! van Leer, and contact (HLLC) approximate Riemann solver, + !! see Toro (1999) and Johnsen (2007). The viscous and the + !! surface tension effects have been included by modifying + !! the exact Riemann solver of Perigaud and Saurel (2005). + !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param gm_alphaL_vf Left averaged gradient magnitude + !! @param gm_alphaR_vf Right averaged gradient magnitude + !! @param flux_vf Intra-cell fluxes + !! @param flux_src_vf Intra-cell fluxes sources + !! @param flux_gsrc_vf Intra-cell geometric fluxes sources + !! @param norm_dir Dir. splitting direction + !! @param ix Index bounds in the x-dir + !! @param iy Index bounds in the y-dir + !! @param iz Index bounds in the z-dir + !! @param q_prim_vf Cell-averaged primitive variables subroutine s_hllc_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & dqL_prim_dz_vf, & @@ -1978,7 +1978,7 @@ contains dqL_prim_dy_vf, dqR_prim_dy_vf, & dqL_prim_dz_vf, dqR_prim_dz_vf - ! fluxes + ! Intercell fluxes type(scalar_field), & dimension(sys_size), & intent(inout) :: flux_vf, flux_src_vf, flux_gsrc_vf @@ -2067,8 +2067,8 @@ contains integer :: Re_max, i, j, k, l, q !< Generic loop iterators - ! the buffers of the left and right Riemann problem - ! variables, based on the choice of boundary conditions + ! Populating the buffers of the left and right Riemann problem + ! states variables, based on the choice of boundary conditions call s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & @@ -2079,7 +2079,7 @@ contains dqR_prim_dz_vf, & norm_dir, ix, iy, iz) - ! inputted data based on dimensional splitting direction + ! Reshaping inputted data based on dimensional splitting direction call s_initialize_riemann_solver( & flux_src_vf, & @@ -2089,7 +2089,7 @@ contains if (norm_dir == ${NORM_DIR}$) then - ! MODEL WITH HLLC + ! 6-EQUATION MODEL WITH HLLC if (model_eqns == 3) then !ME3 $:GPU_PARALLEL_LOOP(collapse=3, private='[i,j,k,l, q, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, Yi_avg, Phi_avg, h_iL, h_iR, h_avg_2, tau_e_L, tau_e_R, flux_ene_e, xi_field_L, xi_field_R, pcorr, zcoef, rho_L, rho_R, pres_L, pres_R, E_L, E_R, H_L, H_R, Cp_avg, Cv_avg, T_avg, eps, c_sum_Yi_Phi, T_L, T_R, Y_L, Y_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, Gamm_L, Gamm_R, gamma_L, gamma_R, pi_inf_L, pi_inf_R, qv_L, qv_R, qv_avg, c_L, c_R, G_L, G_R, rho_avg, H_avg, c_avg, gamma_avg, ptilde_L, ptilde_R, vel_L_rms, vel_R_rms, vel_avg_rms, vel_L_tmp, vel_R_tmp, Ms_L, Ms_R, pres_SL, pres_SR, alpha_L_sum, alpha_R_sum, rho_Star, E_Star, p_Star, p_K_Star, vel_K_star, s_L, s_R, s_M, s_P, s_S, xi_M, xi_P, xi_L, xi_R, xi_MP, xi_PP]') @@ -2188,7 +2188,7 @@ contains E_L = gamma_L*pres_L + pi_inf_L + 5.e-1_wp*rho_L*vel_L_rms + qv_L E_R = gamma_R*pres_R + pi_inf_R + 5.e-1_wp*rho_R*vel_R_rms + qv_R - ! ADJUSTMENTS FOR HYPOELASTIC ENERGY + ! ENERGY ADJUSTMENTS FOR HYPOELASTIC ENERGY if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -2203,11 +2203,11 @@ contains end do $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough if ((G_L > verysmall) .and. (G_R > verysmall)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! terms in 2D and 3D + ! Additional terms in 2D and 3D if ((i == 2) .or. (i == 4) .or. (i == 5)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -2216,7 +2216,7 @@ contains end do end if - ! ADJUSTMENTS FOR HYPERELASTIC ENERGY + ! ENERGY ADJUSTMENTS FOR HYPERELASTIC ENERGY if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2226,11 +2226,11 @@ contains G_L = 0._wp; G_R = 0._wp; $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! left and right shear modulus + ! Mixture left and right shear modulus G_L = G_L + alpha_L(i)*Gs_rs(i) G_R = G_R + alpha_R(i)*Gs_rs(i) end do - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough if (G_L > verysmall .and. G_R > verysmall) then E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) @@ -2254,7 +2254,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! are placeholders to call the subroutine. + ! variables are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2265,12 +2265,12 @@ contains end do end if - ! Mach correction + ! Low Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if - ! THE DIRECT WAVE SPEEDS + ! COMPUTING THE DIRECT WAVE SPEEDS if (wave_speeds == 1) then if (elasticity) then s_L = min(vel_L(dir_idx(1)) - sqrt(c_L*c_L + & @@ -2313,22 +2313,22 @@ contains (rho_avg*c_avg)) end if - ! Einfeldt et al. - ! = min/max(0.,s_L/R) + ! follows Einfeldt et al. + ! s_M/P = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! with q_star_L/R = xi_L/R * (variable) - ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! goes with q_star_L/R = xi_L/R * (variable) + ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! with numerical star velocity in x/y/z directions - ! = 0.5 +/m sgn(0.5,s_star) + ! goes with numerical star velocity in x/y/z directions + ! xi_P/M = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(0.5_wp, s_S)) xi_P = (5.e-1_wp - sign(0.5_wp, s_S)) - ! with the numerical velocity in x/y/z directions - ! (pressure) = min/max(0. sgn(1,sL/sR)) + ! goes with the numerical velocity in x/y/z directions + ! xi_P/M (pressure) = min/max(0. sgn(1,sL/sR)) xi_MP = -min(0._wp, sign(1._wp, s_L)) xi_PP = max(0._wp, sign(1._wp, s_R)) @@ -2345,15 +2345,15 @@ contains vel_K_Star = vel_L(dir_idx(1))*(1._wp - xi_MP) + xi_MP*vel_R(dir_idx(1)) + & xi_MP*xi_PP*(s_S - vel_R(dir_idx(1))) - ! Mach correction + ! Low Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! FLUXES - ! FLUX. + ! COMPUTING FLUXES + ! MASS FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -2361,8 +2361,8 @@ contains xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)*(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! FLUX. - ! = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! MOMENTUM FLUX. + ! f = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = rho_Star*vel_K_Star* & @@ -2370,21 +2370,21 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! FLUX. - ! = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) + ! ENERGY FLUX. + ! f = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = (E_star + p_Star)*vel_K_Star & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! Elastic shear stress additions for the momentum and energy flux + ! ELASTICITY. Elastic shear stress additions for the momentum and energy flux if (elasticity) then flux_ene_e = 0._wp; $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims - ! ELASTIC FLUX. + ! MOMENTUM ELASTIC FLUX. flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) & - xi_M*tau_e_L(dir_idx_tau(i)) - xi_P*tau_e_R(dir_idx_tau(i)) - ! ELASTIC FLUX. + ! ENERGY ELASTIC FLUX. flux_ene_e = flux_ene_e - & xi_M*(vel_L(dir_idx(i))*tau_e_L(dir_idx_tau(i)) + & s_M*(xi_L*((s_S - vel_L(i))*(tau_e_L(dir_idx_tau(i))/(s_L - vel_L(i)))))) - & @@ -2394,7 +2394,7 @@ contains flux_rs${XYZ}$_vf(j, k, l, E_idx) = flux_rs${XYZ}$_vf(j, k, l, E_idx) + flux_ene_e end if - ! FRACTION FLUX. + ! VOLUME FRACTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -2402,7 +2402,7 @@ contains xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)*s_S end do - ! TERM FOR VOLUME FRACTION ADVECTION FLUX. + ! SOURCE TERM FOR VOLUME FRACTION ADVECTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -2410,8 +2410,8 @@ contains xi_P*(vel_R(dir_idx(i)) + dir_flg(dir_idx(i))*(s_S*(xi_PP*(xi_R - 1) + 1) - vel_R(dir_idx(i)))) end do - ! ENERGIES ADVECTION FLUX. - ! pressure and velocity in preparation for the internal energy flux + ! INTERNAL ENERGIES ADVECTION FLUX. + ! K-th pressure and velocity in preparation for the internal energy flux $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids p_K_Star = xi_M*(xi_MP*((pres_L + pi_infs(i)/(1._wp + gammas(i)))* & @@ -2429,7 +2429,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! STRESS EVOLUTION FLUX. + ! HYPOELASTIC STRESS EVOLUTION FLUX. if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -2439,7 +2439,7 @@ contains end do end if - ! MAP FLUX. + ! REFERENCE MAP FLUX. if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2451,14 +2451,14 @@ contains end do end if - ! FUNCTION FLUX + ! COLOR FUNCTION FLUX if (surface_tension) then flux_rs${XYZ}$_vf(j, k, l, c_idx) = & (xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, c_idx) + & xi_P*qR_prim_rs${XYZ}$_vf(j + 1, k, l, c_idx))*s_S end if - ! source flux for cylindrical coordinates + ! Geometrical source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then !Substituting the advective flux into the inviscid geometrical source flux @@ -2470,10 +2470,10 @@ contains do i = intxb, intxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, momxb - 1 + dir_idx(1)) = & flux_gsrc_rs${XYZ}$_vf(j, k, l, momxb - 1 + dir_idx(1)) - p_Star - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -2567,7 +2567,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! are placeholders to call the subroutine. + ! variables are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2604,17 +2604,17 @@ contains (rho_avg*c_avg)) end if - ! Einfeldt et al. - ! = min/max(0.,s_L/R) + ! follows Einfeldt et al. + ! s_M/P = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! with q_star_L/R = xi_L/R * (variable) - ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! goes with q_star_L/R = xi_L/R * (variable) + ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! with numerical velocity in x/y/z directions - ! = 0.5 +/m sgn(0.5,s_star) + ! goes with numerical velocity in x/y/z directions + ! xi_P/M = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) @@ -2627,8 +2627,8 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! flux. - ! = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! Momentum flux. + ! f = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -2647,7 +2647,7 @@ contains end do if (bubbles_euler) then - ! p_tilde in + ! Put p_tilde in $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -2668,7 +2668,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! for volume fraction advection equation + ! Source for volume fraction advection equation $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -2678,7 +2678,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! advection flux for bubble variables + ! Add advection flux for bubble variables if (bubbles_euler) then $:GPU_LOOP(parallelism='[seq]') do i = bubxb, bubxe @@ -2690,16 +2690,16 @@ contains end do end if - ! source flux for cylindrical coordinates + ! Geometrical source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then - ! the advective flux into the inviscid geometrical source flux + ! Substituting the advective flux into the inviscid geometrical source flux $:GPU_LOOP(parallelism='[seq]') do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -2711,7 +2711,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -2771,7 +2771,7 @@ contains vel_R_rms = vel_R_rms + vel_R(i)**2._wp end do - ! this in the refactor + ! Retain this in the refactor if (mpp_lim .and. (num_fluids > 2)) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -2938,7 +2938,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! are placeholders to call the subroutine. + ! variables are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, 0._wp, c_avg, qv_avg) @@ -2949,7 +2949,7 @@ contains end do end if - ! Mach correction + ! Low Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if @@ -2986,21 +2986,21 @@ contains (rho_avg*c_avg)) end if - ! Einfeldt et al. - ! = min/max(0.,s_L/R) + ! follows Einfeldt et al. + ! s_M/P = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! with q_star_L/R = xi_L/R * (variable) - ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! goes with q_star_L/R = xi_L/R * (variable) + ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! with numerical velocity in x/y/z directions - ! = 0.5 +/m sgn(0.5,s_star) + ! goes with numerical velocity in x/y/z directions + ! xi_P/M = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) - ! Mach correction + ! Low Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else @@ -3017,14 +3017,14 @@ contains end do if (bubbles_euler .and. (num_fluids > 1)) then - ! mass transport @ gas density + ! Kill mass transport @ gas density flux_rs${XYZ}$_vf(j, k, l, contxe) = 0._wp end if - ! flux. - ! = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! Momentum flux. + ! f = \rho u u + p I, q = \rho u, q_star = \xi * \rho*(s_star, v, w) - ! p_tilde + ! Include p_tilde if (avg_state == 2) then if (alpha_L(num_fluids) < small_alf .or. R3Lbar < small_alf) then @@ -3060,8 +3060,8 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! flux. - ! = u*(E+p), q = E, q_star = \xi*E+(s-u)(\rho s_star + p/(s-u)) + ! Energy flux. + ! f = u*(E+p), q = E, q_star = \xi*E+(s-u)(\rho s_star + p/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = & xi_M*(vel_L(dir_idx(1))*(E_L + pres_L) + & s_M*(xi_L*(E_L + (s_S - vel_L(dir_idx(1)))* & @@ -3073,7 +3073,7 @@ contains (s_R - vel_R(dir_idx(1))))) - E_R)) & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! fraction flux + ! Volume fraction flux $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3083,7 +3083,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! for volume fraction advection equation + ! Source for volume fraction advection equation $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -3099,7 +3099,7 @@ contains flux_src_rs${XYZ}$_vf(j, k, l, advxb) = vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(1)) - ! advection flux for bubble variables + ! Add advection flux for bubble variables $:GPU_LOOP(parallelism='[seq]') do i = bubxb, bubxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3125,15 +3125,15 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end if - ! source flux for cylindrical coordinates + ! Geometrical source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then - ! the advective flux into the inviscid geometrical source flux + ! Substituting the advective flux into the inviscid geometrical source flux $:GPU_LOOP(parallelism='[seq]') do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -3145,7 +3145,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -3179,7 +3179,7 @@ contains end do $:END_GPU_PARALLEL_LOOP() else - ! MODEL WITH HLLC + ! 5-EQUATION MODEL WITH HLLC $:GPU_PARALLEL_LOOP(collapse=3, private='[Re_max, i, q, T_L, T_R, vel_L_rms, vel_R_rms, pres_L, pres_R, rho_L, gamma_L, pi_inf_L, qv_L, rho_R, gamma_R, pi_inf_R, qv_R, alpha_L_sum, alpha_R_sum, E_L, E_R, MW_L, MW_R, R_gas_L, R_gas_R, Cp_L, Cp_R, Cv_L, Cv_R, Gamm_L, Gamm_R, Y_L, Y_R, H_L, H_R, qv_avg, rho_avg, gamma_avg, H_avg, c_L, c_R, c_avg, s_P, s_M, xi_P, xi_M, xi_L, xi_R, Ms_L, Ms_R, pres_SL, pres_SR, vel_L, vel_R, Re_L, Re_R, alpha_L, alpha_R, s_L, s_R, s_S, vel_avg_rms, pcorr, zcoef, vel_L_tmp, vel_R_tmp, Ys_L, Ys_R, Xs_L, Xs_R, Gamma_iL, Gamma_iR, Cp_iL, Cp_iR, tau_e_L, tau_e_R, xi_field_L, xi_field_R, Yi_avg,Phi_avg, h_iL, h_iR, h_avg_2, G_L, G_R]', copyin='[is1, is2, is3]') do l = is3%beg, is3%end do k = is2%beg, is2%end @@ -3209,8 +3209,8 @@ contains pres_L = qL_prim_rs${XYZ}$_vf(j, k, l, E_idx) pres_R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, E_idx) - ! this by splitting it into the cases - ! in the bubbles_euler + ! Change this by splitting it into the cases + ! present in the bubbles_euler if (mpp_lim) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids @@ -3326,7 +3326,7 @@ contains H_R = (E_R + pres_R)/rho_R end if - ! ADJUSTMENTS FOR HYPOELASTIC ENERGY + ! ENERGY ADJUSTMENTS FOR HYPOELASTIC ENERGY if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -3342,11 +3342,11 @@ contains end do $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough if ((G_L > verysmall) .and. (G_R > verysmall)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) - ! terms in 2D and 3D + ! Additional terms in 2D and 3D if ((i == 2) .or. (i == 4) .or. (i == 5)) then E_L = E_L + (tau_e_L(i)*tau_e_L(i))/(4._wp*G_L) E_R = E_R + (tau_e_R(i)*tau_e_R(i))/(4._wp*G_R) @@ -3355,7 +3355,7 @@ contains end do end if - ! ADJUSTMENTS FOR HYPERELASTIC ENERGY + ! ENERGY ADJUSTMENTS FOR HYPERELASTIC ENERGY if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -3366,11 +3366,11 @@ contains G_R = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_fluids - ! left and right shear modulus + ! Mixture left and right shear modulus G_L = G_L + alpha_L(i)*Gs_rs(i) G_R = G_R + alpha_R(i)*Gs_rs(i) end do - ! contribution to energy if G large enough + ! Elastic contribution to energy if G large enough if (G_L > verysmall .and. G_R > verysmall) then E_L = E_L + G_L*qL_prim_rs${XYZ}$_vf(j, k, l, xiend + 1) E_R = E_R + G_R*qR_prim_rs${XYZ}$_vf(j + 1, k, l, xiend + 1) @@ -3394,7 +3394,7 @@ contains vel_R_rms, 0._wp, c_R, qv_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' - ! are placeholders to call the subroutine. + ! variables are placeholders to call the subroutine. call s_compute_speed_of_sound(pres_R, rho_avg, gamma_avg, pi_inf_R, H_avg, alpha_R, & vel_avg_rms, c_sum_Yi_Phi, c_avg, qv_avg) @@ -3408,7 +3408,7 @@ contains end do end if - ! Mach correction + ! Low Mach correction if (low_Mach == 2) then @:compute_low_Mach_correction() end if @@ -3455,29 +3455,29 @@ contains (rho_avg*c_avg)) end if - ! Einfeldt et al. - ! = min/max(0.,s_L/R) + ! follows Einfeldt et al. + ! s_M/P = min/max(0.,s_L/R) s_M = min(0._wp, s_L); s_P = max(0._wp, s_R) - ! with q_star_L/R = xi_L/R * (variable) - ! = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) + ! goes with q_star_L/R = xi_L/R * (variable) + ! xi_L/R = ( ( s_L/R - u_L/R )/(s_L/R - s_star) ) xi_L = (s_L - vel_L(dir_idx(1)))/(s_L - s_S) xi_R = (s_R - vel_R(dir_idx(1)))/(s_R - s_S) - ! with numerical velocity in x/y/z directions - ! = 0.5 +/m sgn(0.5,s_star) + ! goes with numerical velocity in x/y/z directions + ! xi_P/M = 0.5 +/m sgn(0.5,s_star) xi_M = (5.e-1_wp + sign(5.e-1_wp, s_S)) xi_P = (5.e-1_wp - sign(5.e-1_wp, s_S)) - ! Mach correction + ! Low Mach correction if (low_Mach == 1) then @:compute_low_Mach_correction() else pcorr = 0._wp end if - ! THE HLLC FLUXES - ! FLUX. + ! COMPUTING THE HLLC FLUXES + ! MASS FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, contxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3487,8 +3487,8 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! FLUX. - ! = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) + ! MOMENTUM FLUX. + ! f = \rho u u - \sigma, q = \rho u, q_star = \xi * \rho*(s_star, v, w) $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & @@ -3507,8 +3507,8 @@ contains + (s_M/s_L)*(s_P/s_R)*dir_flg(dir_idx(i))*pcorr end do - ! FLUX. - ! = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) + ! ENERGY FLUX. + ! f = u*(E-\sigma), q = E, q_star = \xi*E+(s-u)(\rho s_star - \sigma/(s-u)) flux_rs${XYZ}$_vf(j, k, l, E_idx) = & xi_M*(vel_L(dir_idx(1))*(E_L + pres_L) + & s_M*(xi_L*(E_L + (s_S - vel_L(dir_idx(1)))* & @@ -3520,16 +3520,16 @@ contains (s_R - vel_R(dir_idx(1))))) - E_R)) & + (s_M/s_L)*(s_P/s_R)*pcorr*s_S - ! Elastic shear stress additions for the momentum and energy flux + ! ELASTICITY. Elastic shear stress additions for the momentum and energy flux if (elasticity) then flux_ene_e = 0._wp $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims - ! ELASTIC FLUX. + ! MOMENTUM ELASTIC FLUX. flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) = & flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) & - xi_M*tau_e_L(dir_idx_tau(i)) - xi_P*tau_e_R(dir_idx_tau(i)) - ! ELASTIC FLUX. + ! ENERGY ELASTIC FLUX. flux_ene_e = flux_ene_e - & xi_M*(vel_L(dir_idx(i))*tau_e_L(dir_idx_tau(i)) + & s_M*(xi_L*((s_S - vel_L(i))*(tau_e_L(dir_idx_tau(i))/(s_L - vel_L(i)))))) - & @@ -3539,7 +3539,7 @@ contains flux_rs${XYZ}$_vf(j, k, l, E_idx) = flux_rs${XYZ}$_vf(j, k, l, E_idx) + flux_ene_e end if - ! STRESS EVOLUTION FLUX. + ! HYPOELASTIC STRESS EVOLUTION FLUX. if (hypoelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, strxe - strxb + 1 @@ -3549,7 +3549,7 @@ contains end do end if - ! FRACTION FLUX. + ! VOLUME FRACTION FLUX. $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = & @@ -3559,7 +3559,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end do - ! FRACTION SOURCE FLUX. + ! VOLUME FRACTION SOURCE FLUX. $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims vel_src_rs${XYZ}$_vf(j, k, l, dir_idx(i)) = & @@ -3571,7 +3571,7 @@ contains s_P*(xi_R - 1._wp)) end do - ! FUNCTION FLUX + ! COLOR FUNCTION FLUX if (surface_tension) then flux_rs${XYZ}$_vf(j, k, l, c_idx) = & xi_M*qL_prim_rs${XYZ}$_vf(j, k, l, c_idx) & @@ -3580,7 +3580,7 @@ contains *(vel_R(dir_idx(1)) + s_P*(xi_R - 1._wp)) end if - ! MAP FLUX. + ! REFERENCE MAP FLUX. if (hyperelasticity) then $:GPU_LOOP(parallelism='[seq]') do i = 1, num_dims @@ -3606,7 +3606,7 @@ contains end do end if - ! source flux for cylindrical coordinates + ! Geometrical source flux for cylindrical coordinates #:if (NORM_DIR == 2) if (cyl_coord) then !Substituting the advective flux into the inviscid geometrical source flux @@ -3614,7 +3614,7 @@ contains do i = 1, E_idx flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = flux_rs${XYZ}$_vf(j, k, l, i) end do - ! the radial momentum geometric source flux + ! Recalculating the radial momentum geometric source flux flux_gsrc_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = & xi_M*(rho_L*(vel_L(dir_idx(1))* & vel_L(dir_idx(1)) + & @@ -3626,7 +3626,7 @@ contains s_P*(xi_R*(dir_flg(dir_idx(1))*s_S + & (1._wp - dir_flg(dir_idx(1)))* & vel_R(dir_idx(1))) - vel_R(dir_idx(1))))) - ! source of the void fraction(s) is zero + ! Geometrical source of the void fraction(s) is zero $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_gsrc_rs${XYZ}$_vf(j, k, l, i) = 0._wp @@ -3663,7 +3663,7 @@ contains end if end if #:endfor - ! HLLC flux and source flux for Euler system of equations + ! Computing HLLC flux and source flux for Euler system of equations if (viscous .or. dummy) then if (weno_Re_flux) then @@ -3707,7 +3707,7 @@ contains end subroutine s_hllc_riemann_solver !> HLLD Riemann solver resolves 5 of the 7 waves of MHD equations: - !! wave, 2 Alfvén waves, 2 fast magnetosonic waves. + !! 1 entropy wave, 2 Alfvén waves, 2 fast magnetosonic waves. subroutine s_hlld_riemann_solver(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, & dqL_prim_dx_vf, dqL_prim_dy_vf, dqL_prim_dz_vf, & qL_prim_vf, & @@ -3733,7 +3733,7 @@ contains integer, intent(in) :: norm_dir type(int_bounds_info), intent(in) :: ix, iy, iz - ! variables: + ! Local variables: #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3) :: alpha_L, alpha_R, alpha_rho_L, alpha_rho_R #:else @@ -3747,16 +3747,16 @@ contains type(riemann_states_vec3) :: B type(riemann_states) :: c, c_fast, pres_mag - ! speeds and intermediate state variables: + ! HLLD speeds and intermediate state variables: real(wp) :: s_L, s_R, s_M, s_starL, s_starR real(wp) :: pTot_L, pTot_R, p_star, rhoL_star, rhoR_star, E_starL, E_starR real(wp), dimension(7) :: U_L, U_R, U_starL, U_starR, U_doubleL, U_doubleR real(wp), dimension(7) :: F_L, F_R, F_starL, F_starR, F_hlld - ! for U and F: (rho, rho*vel(1), rho*vel(2), rho*vel(3), By, Bz, E) - ! vel and B are permutated, so vel(1) is the normal velocity, and x is the normal direction - ! Bx is omitted as the magnetic flux is always zero in the normal direction + ! Indices for U and F: (rho, rho*vel(1), rho*vel(2), rho*vel(3), By, Bz, E) + ! Note: vel and B are permutated, so vel(1) is the normal velocity, and x is the normal direction + ! Note: Bx is omitted as the magnetic flux is always zero in the normal direction real(wp) :: sqrt_rhoL_star, sqrt_rhoR_star, denom_ds, sign_Bx real(wp) :: vL_star, vR_star, wL_star, wR_star @@ -3781,13 +3781,13 @@ contains do k = is2%beg, is2%end do j = is1%beg, is1%end - ! Extract the left/right primitive states + ! (1) Extract the left/right primitive states do i = 1, contxe alpha_rho_L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, i) alpha_rho_R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, i) end do - ! unlike HLL & HLLC, vel_L here is permutated by dir_idx for simpler logic + ! NOTE: unlike HLL & HLLC, vel_L here is permutated by dir_idx for simpler logic do i = 1, num_vels vel%L(i) = qL_prim_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(i)) vel%R(i) = qR_prim_rs${XYZ}$_vf(j + 1, k, l, contxe + dir_idx(i)) @@ -3804,7 +3804,7 @@ contains pres%L = qL_prim_rs${XYZ}$_vf(j, k, l, E_idx) pres%R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, E_idx) - ! unlike HLL, Bx, By, Bz are permutated by dir_idx for simpler logic + ! NOTE: unlike HLL, Bx, By, Bz are permutated by dir_idx for simpler logic if (mhd) then if (n == 0) then ! 1D: constant Bx; By, Bz as variables; only in x so not permutated B%L = [Bx0, qL_prim_rs${XYZ}$_vf(j, k, l, B_idx%beg), qL_prim_rs${XYZ}$_vf(j, k, l, B_idx%beg + 1)] @@ -3819,7 +3819,7 @@ contains end if end if - ! properties of all fluid components + ! Sum properties of all fluid components rho%L = 0._wp; gamma%L = 0._wp; pi_inf%L = 0._wp; qv%L = 0._wp rho%R = 0._wp; gamma%R = 0._wp; pi_inf%R = 0._wp; qv%R = 0._wp $:GPU_LOOP(parallelism='[seq]') @@ -3842,13 +3842,13 @@ contains H_no_mag%L = (E%L + pres%L - pres_mag%L)/rho%L H_no_mag%R = (E%R + pres%R - pres_mag%R)/rho%R ! stagnation enthalpy here excludes magnetic energy (only used to find speed of sound) - ! Compute fast wave speeds + ! (2) Compute fast wave speeds call s_compute_speed_of_sound(pres%L, rho%L, gamma%L, pi_inf%L, H_no_mag%L, alpha_L, vel_rms%L, 0._wp, c%L, qv%L) call s_compute_speed_of_sound(pres%R, rho%R, gamma%R, pi_inf%R, H_no_mag%R, alpha_R, vel_rms%R, 0._wp, c%R, qv%R) call s_compute_fast_magnetosonic_speed(rho%L, c%L, B%L, norm_dir, c_fast%L, H_no_mag%L) call s_compute_fast_magnetosonic_speed(rho%R, c%R, B%R, norm_dir, c_fast%R, H_no_mag%R) - ! Compute contact speed s_M [Miyoshi Equ. (38)] + ! (3) Compute contact speed s_M [Miyoshi Equ. (38)] s_L = min(vel%L(1) - c_fast%L, vel%R(1) - c_fast%R) s_R = max(vel%R(1) + c_fast%R, vel%L(1) + c_fast%L) @@ -3859,20 +3859,20 @@ contains (s_L - vel%L(1))*rho%L*vel%L(1) - pTot_R + pTot_L)/ & ((s_R - vel%R(1))*rho%R - (s_L - vel%L(1))*rho%L)) - ! Compute star state variables + ! (4) Compute star state variables rhoL_star = rho%L*(s_L - vel%L(1))/(s_L - s_M) rhoR_star = rho%R*(s_R - vel%R(1))/(s_R - s_M) p_star = pTot_L + rho%L*(s_L - vel%L(1))*(s_M - vel%L(1))/(s_L - s_M) E_starL = ((s_L - vel%L(1))*E%L - pTot_L*vel%L(1) + p_star*s_M)/(s_L - s_M) E_starR = ((s_R - vel%R(1))*E%R - pTot_R*vel%R(1) + p_star*s_M)/(s_R - s_M) - ! Compute left/right state vectors and fluxes + ! (5) Compute left/right state vectors and fluxes U_L = [rho%L, rho%L*vel%L(1:3), B%L(2:3), E%L] U_starL = [rhoL_star, rhoL_star*s_M, rhoL_star*vel%L(2:3), B%L(2:3), E_starL] U_R = [rho%R, rho%R*vel%R(1:3), B%R(2:3), E%R] U_starR = [rhoR_star, rhoR_star*s_M, rhoR_star*vel%R(2:3), B%R(2:3), E_starR] - ! the left/right fluxes + ! Compute the left/right fluxes F_L(1) = U_L(2) F_L(2) = U_L(2)*vel%L(1) - B%L(1)*B%L(1) + pTot_L F_L(3:4) = U_L(2)*vel%L(2:3) - B%L(1)*B%L(2:3) @@ -3884,18 +3884,18 @@ contains F_R(3:4) = U_R(2)*vel%R(2:3) - B%R(1)*B%R(2:3) F_R(5:6) = vel%R(1)*B%R(2:3) - vel%R(2:3)*B%R(1) F_R(7) = (E%R + pTot_R)*vel%R(1) - B%R(1)*(vel%R(1)*B%R(1) + vel%R(2)*B%R(2) + vel%R(3)*B%R(3)) - ! the star flux using HLL relation + ! Compute the star flux using HLL relation F_starL = F_L + s_L*(U_starL - U_L) F_starR = F_R + s_R*(U_starR - U_R) - ! the rotational (Alfvén) speeds + ! Compute the rotational (Alfvén) speeds s_starL = s_M - abs(B%L(1))/sqrt(rhoL_star) s_starR = s_M + abs(B%L(1))/sqrt(rhoR_star) - ! the double–star states [Miyoshi Eqns. (59)-(62)] + ! Compute the double–star states [Miyoshi Eqns. (59)-(62)] sqrt_rhoL_star = sqrt(rhoL_star); sqrt_rhoR_star = sqrt(rhoR_star) vL_star = vel%L(2); wL_star = vel%L(3) vR_star = vel%R(2); wR_star = vel%R(3) - ! Compute the double–star states [Miyoshi Eqns. (59)-(62)] + ! (6) Compute the double–star states [Miyoshi Eqns. (59)-(62)] denom_ds = sqrt_rhoL_star + sqrt_rhoR_star sign_Bx = sign(1._wp, B%L(1)) v_double = (sqrt_rhoL_star*vL_star + sqrt_rhoR_star*vR_star + (B%R(2) - B%L(2))*sign_Bx)/denom_ds @@ -3910,7 +3910,7 @@ contains U_doubleL = [rhoL_star, rhoL_star*s_M, rhoL_star*v_double, rhoL_star*w_double, By_double, Bz_double, E_double] U_doubleR = [rhoR_star, rhoR_star*s_M, rhoR_star*v_double, rhoR_star*w_double, By_double, Bz_double, E_double] - ! Choose HLLD flux based on wave-speed regions + ! (11) Choose HLLD flux based on wave-speed regions if (0.0_wp <= s_L) then F_hlld = F_L else if (0.0_wp <= s_starL) then @@ -3925,14 +3925,14 @@ contains F_hlld = F_R end if - ! Reorder and write temporary variables to the flux array - ! + ! (12) Reorder and write temporary variables to the flux array + ! Mass flux_rs${XYZ}$_vf(j, k, l, 1) = F_hlld(1) ! TODO multi-component - ! + ! Momentum flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(1)) = F_hlld(2) flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(2)) = F_hlld(3) flux_rs${XYZ}$_vf(j, k, l, contxe + dir_idx(3)) = F_hlld(4) - ! field + ! Magnetic field if (n == 0) then flux_rs${XYZ}$_vf(j, k, l, B_idx%beg) = F_hlld(5) flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + 1) = F_hlld(6) @@ -3940,9 +3940,9 @@ contains flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + dir_idx(2) - 1) = F_hlld(5) flux_rs${XYZ}$_vf(j, k, l, B_idx%beg + dir_idx(3) - 1) = F_hlld(6) end if - ! + ! Energy flux_rs${XYZ}$_vf(j, k, l, E_idx) = F_hlld(7) - ! fraction + ! Partial fraction $:GPU_LOOP(parallelism='[seq]') do i = advxb, advxe flux_rs${XYZ}$_vf(j, k, l, i) = 0._wp ! TODO multi-component (zero for now) @@ -3961,13 +3961,13 @@ contains end subroutine s_hlld_riemann_solver !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_riemann_solvers_module - ! the variables that will be utilized to formulate the - ! right, and average states of the Riemann problem, as well - ! Riemann problem solution + ! Allocating the variables that will be utilized to formulate the + ! left, right, and average states of the Riemann problem, as well + ! the Riemann problem solution integer :: i, j @:ALLOCATE(Gs_rs(1:num_fluids)) @@ -4076,30 +4076,30 @@ contains end subroutine s_initialize_riemann_solvers_module !> The purpose of this subroutine is to populate the buffers - !! left and right Riemann states variables, depending - !! boundary conditions. - !! The left WENO-reconstructed cell-boundary values of the - !! variables - !! The right WENO-reconstructed cell-boundary values of the - !! variables - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The left WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! The right WENO-reconstructed cell-boundary values of the - !! spatial derivatives - !! Left averaged gradient magnitude - !! Right averaged gradient magnitude - !! Dir. splitting direction - !! Index bounds in the x-dir - !! Index bounds in the y-dir - !! Index bounds in the z-dir + !! of the left and right Riemann states variables, depending + !! on the boundary conditions. + !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param dqL_prim_dx_vf The left WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqL_prim_dy_vf The left WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqL_prim_dz_vf The left WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param dqR_prim_dx_vf The right WENO-reconstructed cell-boundary values of the + !! first-order x-dir spatial derivatives + !! @param dqR_prim_dy_vf The right WENO-reconstructed cell-boundary values of the + !! first-order y-dir spatial derivatives + !! @param dqR_prim_dz_vf The right WENO-reconstructed cell-boundary values of the + !! first-order z-dir spatial derivatives + !! @param gm_alphaL_vf Left averaged gradient magnitude + !! @param gm_alphaR_vf Right averaged gradient magnitude + !! @param norm_dir Dir. splitting direction + !! @param ix Index bounds in the x-dir + !! @param iy Index bounds in the y-dir + !! @param iz Index bounds in the z-dir subroutine s_populate_riemann_states_variables_buffers( & qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, dqL_prim_dx_vf, & dqL_prim_dy_vf, & @@ -4146,12 +4146,12 @@ contains end if isx = ix; isy = iy; isz = iz - ! stuff in the same module + ! for stuff in the same module $:GPU_UPDATE(device='[isx,isy,isz]') - ! stuff in different modules + ! for stuff in different modules $:GPU_UPDATE(device='[dir_idx,dir_flg,dir_idx_tau]') - ! of Buffers in x-direction + ! Population of Buffers in x-direction if (norm_dir == 1) then if (bc_x%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4271,9 +4271,9 @@ contains end if end if - ! Population of Buffers in x-direction + ! END: Population of Buffers in x-direction - ! of Buffers in y-direction + ! Population of Buffers in y-direction elseif (norm_dir == 2) then if (bc_y%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4382,9 +4382,9 @@ contains end if end if - ! Population of Buffers in y-direction + ! END: Population of Buffers in y-direction - ! of Buffers in z-direction + ! Population of Buffers in z-direction else if (bc_z%beg == BC_RIEMANN_EXTRAP) then ! Riemann state extrap. BC at beginning @@ -4485,26 +4485,26 @@ contains end if end if - ! Population of Buffers in z-direction + ! END: Population of Buffers in z-direction end subroutine s_populate_riemann_states_variables_buffers !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! needed to configure the chosen Riemann - !! - !! The left WENO-reconstructed cell-boundary values of the - !! variables - !! The right WENO-reconstructed cell-boundary values of the - !! variables - !! Intra-cell fluxes - !! Intra-cell fluxes sources - !! Intra-cell geometric fluxes sources - !! Dir. splitting direction - !! Index bounds in the x-dir - !! Index bounds in the y-dir - !! Index bounds in the z-dir - !! Cell-averaged primitive variables + !! the association of pointers and/or the execution of any + !! other procedures needed to configure the chosen Riemann + !! solver algorithm. + !! @param qL_prim_vf The left WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param qR_prim_vf The right WENO-reconstructed cell-boundary values of the + !! cell-average primitive variables + !! @param flux_vf Intra-cell fluxes + !! @param flux_src_vf Intra-cell fluxes sources + !! @param flux_gsrc_vf Intra-cell geometric fluxes sources + !! @param norm_dir Dir. splitting direction + !! @param ix Index bounds in the x-dir + !! @param iy Index bounds in the y-dir + !! @param iz Index bounds in the z-dir + !! @param q_prim_vf Cell-averaged primitive variables subroutine s_initialize_riemann_solver( & flux_src_vf, & norm_dir) @@ -4517,7 +4517,7 @@ contains integer :: i, j, k, l ! Generic loop iterators - ! Inputted Data in x-direction + ! Reshaping Inputted Data in x-direction if (norm_dir == 1) then @@ -4566,7 +4566,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Inputted Data in y-direction + ! Reshaping Inputted Data in y-direction elseif (norm_dir == 2) then if (viscous .or. (surface_tension) .or. dummy) then @@ -4613,7 +4613,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Inputted Data in z-direction + ! Reshaping Inputted Data in z-direction else if (viscous .or. (surface_tension) .or. dummy) then @@ -4665,22 +4665,22 @@ contains end subroutine s_initialize_riemann_solver !> @brief Computes cylindrical viscous source flux contributions for momentum and energy. - !! components of the stress tensor using averaged velocity derivatives - !! geometric factors, then updates `flux_src_vf`. - !! is axial (z_cyl), y-dir is radial (r_cyl), z-dir is azimuthal (theta_cyl for derivatives). - !! Left boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). - !! Left boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). - !! Left boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). - !! Left boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). - !! Right boundary velocity ($v_x, v_y, v_z$) (num_dims scalar_field). - !! Right boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). - !! Right boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). - !! Right boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). - !! Intercell source flux array to update (sys_size scalar_field). - !! Interface normal direction (1=x-face, 2=y-face, 3=z-face). - !! Global X-direction loop bounds (int_bounds_info). - !! Global Y-direction loop bounds (int_bounds_info). - !! Global Z-direction loop bounds (int_bounds_info). + !! Calculates Cartesian components of the stress tensor using averaged velocity derivatives + !! and cylindrical geometric factors, then updates `flux_src_vf`. + !! Assumes x-dir is axial (z_cyl), y-dir is radial (r_cyl), z-dir is azimuthal (theta_cyl for derivatives). + !! @param[in] velL_vf Left boundary velocity (\f$v_x, v_y, v_z\f$) (num_dims scalar_field). + !! @param[in] dvelL_dx_vf Left boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). + !! @param[in] dvelL_dy_vf Left boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). + !! @param[in] dvelL_dz_vf Left boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). + !! @param[in] velR_vf Right boundary velocity (\f$v_x, v_y, v_z\f$) (num_dims scalar_field). + !! @param[in] dvelR_dx_vf Right boundary \f$\partial v_i/\partial x\f$ (num_dims scalar_field). + !! @param[in] dvelR_dy_vf Right boundary \f$\partial v_i/\partial y\f$ (num_dims scalar_field). + !! @param[in] dvelR_dz_vf Right boundary \f$\partial v_i/\partial z\f$ (num_dims scalar_field). + !! @param[inout] flux_src_vf Intercell source flux array to update (sys_size scalar_field). + !! @param[in] norm_dir Interface normal direction (1=x-face, 2=y-face, 3=z-face). + !! @param[in] ix Global X-direction loop bounds (int_bounds_info). + !! @param[in] iy Global Y-direction loop bounds (int_bounds_info). + !! @param[in] iz Global Z-direction loop bounds (int_bounds_info). subroutine s_compute_cylindrical_viscous_source_flux(velL_vf, & dvelL_dx_vf, dvelL_dy_vf, dvelL_dz_vf, & velR_vf, & @@ -4695,21 +4695,21 @@ contains integer, intent(in) :: norm_dir type(int_bounds_info), intent(in) :: ix, iy, iz - ! variables + ! Local variables #:if not MFC_CASE_OPTIMIZATION and USING_AMD - real(wp), dimension(3) :: avg_v_int !!< Averaged interface velocity $(v_x, v_y, v_z)$ (grid directions). + real(wp), dimension(3) :: avg_v_int !!< Averaged interface velocity (\f$v_x, v_y, v_z\f$) (grid directions). real(wp), dimension(3) :: avg_dvdx_int !!< Averaged interface \f$\partial v_i/\partial x\f$ (grid dir 1). real(wp), dimension(3) :: avg_dvdy_int !!< Averaged interface \f$\partial v_i/\partial y\f$ (grid dir 2). real(wp), dimension(3) :: avg_dvdz_int !!< Averaged interface \f$\partial v_i/\partial z\f$ (grid dir 3). - real(wp), dimension(3) :: vel_src_int !!< Interface velocity $(v_1,v_2,v_3)$ (grid directions) for viscous work. - real(wp), dimension(3) :: stress_vector_shear !!< Shear stress vector \f$(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})\f$ on N-face (grid directions). + real(wp), dimension(3) :: vel_src_int !!< Interface velocity (\f$v_1,v_2,v_3\f$) (grid directions) for viscous work. + real(wp), dimension(3) :: stress_vector_shear !!< Shear stress vector (\f$\sigma_{N1}, \sigma_{N2}, \sigma_{N3}\f$) on N-face (grid directions). #:else - real(wp), dimension(num_dims) :: avg_v_int !!< Averaged interface velocity $(v_x, v_y, v_z)$ (grid directions). + real(wp), dimension(num_dims) :: avg_v_int !!< Averaged interface velocity (\f$v_x, v_y, v_z\f$) (grid directions). real(wp), dimension(num_dims) :: avg_dvdx_int !!< Averaged interface \f$\partial v_i/\partial x\f$ (grid dir 1). real(wp), dimension(num_dims) :: avg_dvdy_int !!< Averaged interface \f$\partial v_i/\partial y\f$ (grid dir 2). real(wp), dimension(num_dims) :: avg_dvdz_int !!< Averaged interface \f$\partial v_i/\partial z\f$ (grid dir 3). - real(wp), dimension(num_dims) :: vel_src_int !!< Interface velocity $(v_1,v_2,v_3)$ (grid directions) for viscous work. - real(wp), dimension(num_dims) :: stress_vector_shear !!< Shear stress vector \f$(\sigma_{N1}, \sigma_{N2}, \sigma_{N3})\f$ on N-face (grid directions). + real(wp), dimension(num_dims) :: vel_src_int !!< Interface velocity (\f$v_1,v_2,v_3\f$) (grid directions) for viscous work. + real(wp), dimension(num_dims) :: stress_vector_shear !!< Shear stress vector (\f$\sigma_{N1}, \sigma_{N2}, \sigma_{N3}\f$) on N-face (grid directions). #:endif real(wp) :: stress_normal_bulk !!< Normal bulk stress component \f$\sigma_{NN}\f$ on N-face. @@ -4718,21 +4718,21 @@ contains real(wp) :: div_v_term_const !!< Common term \f$-(2/3)(\nabla \cdot \mathbf{v}) / \text{Re}_s\f$ for shear stress diagonal. real(wp) :: divergence_cyl !!< Full divergence \f$\nabla \cdot \mathbf{v}\f$ in cylindrical coordinates. - integer :: j, k, l !!< Loop iterators for $x, y, z$ grid directions. + integer :: j, k, l !!< Loop iterators for \f$x, y, z\f$ grid directions. integer :: i_vel !!< Loop iterator for velocity components. - integer :: idx_rp(3) !!< Indices $(j,k,l)$ of 'right' point for averaging. + integer :: idx_rp(3) !!< Indices \f$(j,k,l)\f$ of 'right' point for averaging. $:GPU_PARALLEL_LOOP(collapse=3, private='[idx_rp, avg_v_int, avg_dvdx_int, avg_dvdy_int, avg_dvdz_int, Re_s, Re_b, vel_src_int, r_eff, divergence_cyl, stress_vector_shear, stress_normal_bulk, div_v_term_const]') do l = iz%beg, iz%end do k = iy%beg, iy%end do j = ix%beg, ix%end - ! indices for the 'right' state for averaging across the interface + ! Determine indices for the 'right' state for averaging across the interface idx_rp = [j, k, l] idx_rp(norm_dir) = idx_rp(norm_dir) + 1 - ! velocities and their derivatives at the interface - ! cylindrical: x-dir ~ axial (z_cyl), y-dir ~ radial (r_cyl), z-dir ~ azimuthal (theta_cyl) + ! Average velocities and their derivatives at the interface + ! For cylindrical: x-dir ~ axial (z_cyl), y-dir ~ radial (r_cyl), z-dir ~ azimuthal (theta_cyl) $:GPU_LOOP(parallelism='[seq]') do i_vel = 1, num_dims avg_v_int(i_vel) = 0.5_wp*(velL_vf(i_vel)%sf(j, k, l) + velR_vf(i_vel)%sf(idx_rp(1), idx_rp(2), idx_rp(3))) @@ -4753,7 +4753,7 @@ contains end if end do - ! Re numbers and interface velocity for viscous work + ! Get Re numbers and interface velocity for viscous work select case (norm_dir) case (1) ! x-face (axial face in z_cyl direction) Re_s = Re_avg_rsx_vf(j, k, l, 1) @@ -4772,7 +4772,7 @@ contains r_eff = y_cc(k) end select - ! in cylindrical coordinates (vx=vz_cyl, vy=vr_cyl, vz=vtheta_cyl) + ! Divergence in cylindrical coordinates (vx=vz_cyl, vy=vr_cyl, vz=vtheta_cyl) #:if not MFC_CASE_OPTIMIZATION or num_dims > 1 divergence_cyl = avg_dvdx_int(1) + avg_dvdy_int(2) + avg_v_int(2)/r_eff if (num_dims > 2) then @@ -4847,21 +4847,21 @@ contains end subroutine s_compute_cylindrical_viscous_source_flux !> @brief Computes Cartesian viscous source flux contributions for momentum and energy. - !! velocity gradients, gets Re and interface velocities, - !! for shear/bulk stress, then updates `flux_src_vf`. - !! Left boundary velocity (num_dims scalar_field). - !! Left boundary d(vel)/dx (num_dims scalar_field). - !! Left boundary d(vel)/dy (num_dims scalar_field). - !! Left boundary d(vel)/dz (num_dims scalar_field). - !! Right boundary velocity (num_dims scalar_field). - !! Right boundary d(vel)/dx (num_dims scalar_field). - !! Right boundary d(vel)/dy (num_dims scalar_field). - !! Right boundary d(vel)/dz (num_dims scalar_field). - !! Intercell source flux array to update (sys_size scalar_field). - !! Interface normal direction (1=x, 2=y, 3=z). - !! X-direction loop bounds (int_bounds_info). - !! Y-direction loop bounds (int_bounds_info). - !! Z-direction loop bounds (int_bounds_info). + !! Calculates averaged velocity gradients, gets Re and interface velocities, + !! calls helpers for shear/bulk stress, then updates `flux_src_vf`. + !! @param[in] velL_vf Left boundary velocity (num_dims scalar_field). + !! @param[in] dvelL_dx_vf Left boundary d(vel)/dx (num_dims scalar_field). + !! @param[in] dvelL_dy_vf Left boundary d(vel)/dy (num_dims scalar_field). + !! @param[in] dvelL_dz_vf Left boundary d(vel)/dz (num_dims scalar_field). + !! @param[in] velR_vf Right boundary velocity (num_dims scalar_field). + !! @param[in] dvelR_dx_vf Right boundary d(vel)/dx (num_dims scalar_field). + !! @param[in] dvelR_dy_vf Right boundary d(vel)/dy (num_dims scalar_field). + !! @param[in] dvelR_dz_vf Right boundary d(vel)/dz (num_dims scalar_field). + !! @param[inout] flux_src_vf Intercell source flux array to update (sys_size scalar_field). + !! @param[in] norm_dir Interface normal direction (1=x, 2=y, 3=z). + !! @param[in] ix X-direction loop bounds (int_bounds_info). + !! @param[in] iy Y-direction loop bounds (int_bounds_info). + !! @param[in] iz Z-direction loop bounds (int_bounds_info). subroutine s_compute_cartesian_viscous_source_flux(dvelL_dx_vf, & dvelL_dy_vf, & dvelL_dz_vf, & @@ -4871,14 +4871,14 @@ contains flux_src_vf, & norm_dir) - ! + ! Arguments type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dx_vf, dvelR_dx_vf type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dy_vf, dvelR_dy_vf type(scalar_field), dimension(num_dims), intent(in) :: dvelL_dz_vf, dvelR_dz_vf type(scalar_field), dimension(sys_size), intent(inout) :: flux_src_vf integer, intent(in) :: norm_dir - ! variables + ! Local variables #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3, 3) :: vel_grad_avg !< Averaged velocity gradient tensor `d(vel_i)/d(coord_j)`. real(wp), dimension(3, 3) :: current_tau_shear !< Current shear stress tensor. @@ -4958,7 +4958,7 @@ contains end if if (shear_stress) then - ! = 0.0_wp + ! current_tau_shear = 0.0_wp call s_calculate_shear_stress_tensor(vel_grad_avg, Re_shear, divergence_v, current_tau_shear) do i_dim = 1, num_dims @@ -4972,7 +4972,7 @@ contains end if if (bulk_stress) then - ! = 0.0_wp + ! current_tau_bulk = 0.0_wp call s_calculate_bulk_stress_tensor(Re_bulk, divergence_v, current_tau_bulk) do i_dim = 1, num_dims @@ -4993,15 +4993,15 @@ contains end subroutine s_compute_cartesian_viscous_source_flux !> @brief Calculates shear stress tensor components. - !! ( (dui/dxj + duj/dxi) - (2/3)*(div_v)*delta_ij ) / Re_shear - !! Averaged velocity gradient tensor (d(vel_i)/d(coord_j)). - !! Shear Reynolds number. - !! Velocity divergence (du/dx + dv/dy + dw/dz). - !! Calculated shear stress tensor (stress on i-face, j-direction). + !! tau_ij_shear = ( (dui/dxj + duj/dxi) - (2/3)*(div_v)*delta_ij ) / Re_shear + !! @param[in] vel_grad_avg Averaged velocity gradient tensor (d(vel_i)/d(coord_j)). + !! @param[in] Re_shear Shear Reynolds number. + !! @param[in] divergence_v Velocity divergence (du/dx + dv/dy + dw/dz). + !! @param[out] tau_shear_out Calculated shear stress tensor (stress on i-face, j-direction). subroutine s_calculate_shear_stress_tensor(vel_grad_avg, Re_shear, divergence_v, tau_shear_out) $:GPU_ROUTINE(parallelism='[seq]') - ! + ! Arguments #:if not MFC_CASE_OPTIMIZATION and USING_AMD real(wp), dimension(3, 3), intent(in) :: vel_grad_avg real(wp), dimension(3, 3), intent(out) :: tau_shear_out @@ -5012,7 +5012,7 @@ contains real(wp), intent(in) :: Re_shear real(wp), intent(in) :: divergence_v - ! variables + ! Local variables integer :: i_dim !< Loop iterator for face normal. integer :: j_dim !< Loop iterator for force component direction. @@ -5031,14 +5031,14 @@ contains end subroutine s_calculate_shear_stress_tensor !> @brief Calculates bulk stress tensor components (diagonal only). - !! (div_v) / Re_bulk. Off-diagonals are zero. - !! Bulk Reynolds number. - !! Velocity divergence (du/dx + dv/dy + dw/dz). - !! Calculated bulk stress tensor (stress on i-face, i-direction). + !! tau_ii_bulk = (div_v) / Re_bulk. Off-diagonals are zero. + !! @param[in] Re_bulk Bulk Reynolds number. + !! @param[in] divergence_v Velocity divergence (du/dx + dv/dy + dw/dz). + !! @param[out] tau_bulk_out Calculated bulk stress tensor (stress on i-face, i-direction). subroutine s_calculate_bulk_stress_tensor(Re_bulk, divergence_v, tau_bulk_out) $:GPU_ROUTINE(parallelism='[seq]') - ! + ! Arguments real(wp), intent(in) :: Re_bulk real(wp), intent(in) :: divergence_v #:if not MFC_CASE_OPTIMIZATION and USING_AMD @@ -5047,7 +5047,7 @@ contains real(wp), dimension(num_dims, num_dims), intent(out) :: tau_bulk_out #:endif - ! variables + ! Local variables integer :: i_dim !< Loop iterator for diagonal components. tau_bulk_out = 0.0_wp @@ -5059,11 +5059,11 @@ contains end subroutine s_calculate_bulk_stress_tensor !> Deallocation and/or disassociation procedures that are - !! finalize the selected Riemann problem solver - !! Intercell fluxes - !! Intercell source fluxes - !! Intercell geometric source fluxes - !! Dimensional splitting coordinate direction + !! needed to finalize the selected Riemann problem solver + !! @param flux_vf Intercell fluxes + !! @param flux_src_vf Intercell source fluxes + !! @param flux_gsrc_vf Intercell geometric source fluxes + !! @param norm_dir Dimensional splitting coordinate direction subroutine s_finalize_riemann_solver(flux_vf, flux_src_vf, & flux_gsrc_vf, & norm_dir) @@ -5076,7 +5076,7 @@ contains integer :: i, j, k, l !< Generic loop iterators - ! Outputted Data in y-direction + ! Reshaping Outputted Data in y-direction if (norm_dir == 2) then $:GPU_PARALLEL_LOOP(collapse=4) do i = 1, sys_size @@ -5132,7 +5132,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! Outputted Data in z-direction + ! Reshaping Outputted Data in z-direction elseif (norm_dir == 3) then $:GPU_PARALLEL_LOOP(collapse=4) do i = 1, sys_size diff --git a/src/simulation/m_sim_helpers.fpp b/src/simulation/m_sim_helpers.fpp index d77dcc6088..f5d75aa148 100644 --- a/src/simulation/m_sim_helpers.fpp +++ b/src/simulation/m_sim_helpers.fpp @@ -18,9 +18,9 @@ module m_sim_helpers contains !> Computes the modified dtheta for Fourier filtering in azimuthal direction - !! y coordinate index - !! z coordinate index - !! Modified dtheta value for cylindrical coordinates + !! @param k y coordinate index + !! @param l z coordinate index + !! @return fltr_dtheta Modified dtheta value for cylindrical coordinates function f_compute_filtered_dtheta(k, l) result(fltr_dtheta) $:GPU_ROUTINE(parallelism='[seq]') integer, intent(in) :: k, l @@ -42,12 +42,12 @@ contains end function f_compute_filtered_dtheta !> Computes inviscid CFL terms for multi-dimensional cases (2D/3D only) - !! directional velocities - !! mixture speed of sound - !! x coordinate index - !! y coordinate index - !! z coordinate index - !! computed CFL terms for 2D/3D cases + !! @param vel directional velocities + !! @param c mixture speed of sound + !! @param j x coordinate index + !! @param k y coordinate index + !! @param l z coordinate index + !! @return cfl_terms computed CFL terms for 2D/3D cases function f_compute_multidim_cfl_terms(vel, c, j, k, l) result(cfl_terms) $:GPU_ROUTINE(parallelism='[seq]') real(wp), dimension(num_vels), intent(in) :: vel @@ -79,19 +79,19 @@ contains end function f_compute_multidim_cfl_terms !> Computes enthalpy - !! cell centered primitive variables - !! mixture pressure - !! mixture density - !! mixture gamma - !! mixture pi_inf - !! mixture reynolds number - !! mixture enthalpy - !! component alphas - !! directional velocities - !! squard sum of velocity components - !! x index - !! y index - !! z index + !! @param q_prim_vf cell centered primitive variables + !! @param pres mixture pressure + !! @param rho mixture density + !! @param gamma mixture gamma + !! @param pi_inf mixture pi_inf + !! @param Re mixture reynolds number + !! @param H mixture enthalpy + !! @param alpha component alphas + !! @param vel directional velocities + !! @param vel_sum squard sum of velocity components + !! @param j x index + !! @param k y index + !! @param l z index subroutine s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, qv, j, k, l) $:GPU_ROUTINE(function_name='s_compute_enthalpy',parallelism='[seq]', & & cray_inline=True) @@ -152,7 +152,7 @@ contains E = gamma*pres + pi_inf + 5.e-1_wp*rho*vel_sum + qv end if - ! energy for hyperelasticity + ! Adjust energy for hyperelasticity if (hyperelasticity) then E = E + G_local*q_prim_vf(xiend + 1)%sf(j, k, l) end if @@ -162,15 +162,15 @@ contains end subroutine s_compute_enthalpy !> Computes stability criterion for a specified dt - !! directional velocities - !! mixture speed of sound - !! mixture Reynolds number - !! x index - !! y index - !! z index - !! cell-centered inviscid cfl number - !! (optional) cell-centered viscous CFL number - !! (optional) cell centered Rc + !! @param vel directional velocities + !! @param c mixture speed of sound + !! @param Re_l mixture Reynolds number + !! @param j x index + !! @param k y index + !! @param l z index + !! @param icfl_sf cell-centered inviscid cfl number + !! @param vcfl_sf (optional) cell-centered viscous CFL number + !! @param Rc_sf (optional) cell centered Rc subroutine s_compute_stability_from_dt(vel, c, rho, Re_l, j, k, l, icfl_sf, vcfl_sf, Rc_sf) $:GPU_ROUTINE(parallelism='[seq]') real(wp), intent(in), dimension(num_vels) :: vel @@ -182,16 +182,16 @@ contains real(wp) :: fltr_dtheta - ! CFL calculation + ! Inviscid CFL calculation if (p > 0 .or. n > 0) then - ! + ! 2D/3D icfl_sf(j, k, l) = dt/f_compute_multidim_cfl_terms(vel, c, j, k, l) else - ! + ! 1D icfl_sf(j, k, l) = (dt/dx(j))*(abs(vel(1)) + c) end if - ! calculations + ! Viscous calculations if (viscous) then if (p > 0) then #:if not MFC_CASE_OPTIMIZATION or num_dims > 2 @@ -229,13 +229,13 @@ contains end subroutine s_compute_stability_from_dt !> Computes dt for a specified CFL number - !! directional velocities - !! cell centered maximum dt - !! cell centered density - !! cell centered Reynolds number - !! x coordinate - !! y coordinate - !! z coordinate + !! @param vel directional velocities + !! @param max_dt cell centered maximum dt + !! @param rho cell centered density + !! @param Re_l cell centered Reynolds number + !! @param j x coordinate + !! @param k y coordinate + !! @param l z coordinate subroutine s_compute_dt_from_cfl(vel, c, max_dt, rho, Re_l, j, k, l) $:GPU_ROUTINE(parallelism='[seq]') real(wp), dimension(num_vels), intent(in) :: vel @@ -247,16 +247,16 @@ contains real(wp) :: icfl_dt, vcfl_dt real(wp) :: fltr_dtheta - ! CFL calculation + ! Inviscid CFL calculation if (p > 0 .or. n > 0) then - ! cases + ! 2D/3D cases icfl_dt = cfl_target*f_compute_multidim_cfl_terms(vel, c, j, k, l) else - ! case + ! 1D case icfl_dt = cfl_target*(dx(j)/(abs(vel(1)) + c)) end if - ! calculations + ! Viscous calculations if (viscous) then if (p > 0) then !3D diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index db772642f5..a4243b4418 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -1,22 +1,22 @@ !> -!! -!! module m_start_up +!! @file +!! @brief Contains module m_start_up #:include 'case.fpp' #:include 'macros.fpp' !> @brief The purpose of the module is primarily to read in the files that -!! inputs, the initial condition data and the grid data -!! provided by the user. The module is additionally tasked -!! the consistency of the user inputs and completing -!! variablesThe purpose of the module is primarily to read -!! files that -!! inputs, the initial condition data and the grid data -!! provided by the user. The module is additionally tasked -!! the consistency of the user inputs and completing -!! variables. This module also also allocating, initializing -!! deallocating the relevant variables on both cpus and gpus as well as -!! the time stepping, domain decomposition and I/O procedures. +!! contain the inputs, the initial condition data and the grid data +!! that are provided by the user. The module is additionally tasked +!! with verifying the consistency of the user inputs and completing +!! the grid variablesThe purpose of the module is primarily to read +!! in the files that +!! contain the inputs, the initial condition data and the grid data +!! that are provided by the user. The module is additionally tasked +!! with verifying the consistency of the user inputs and completing +!! the grid variables. This module also also allocating, initializing +!! I/O, and deallocating the relevant variables on both cpus and gpus as well as +!! setting up the time stepping, domain decomposition and I/O procedures. module m_start_up use m_derived_types !< Definitions of the derived types @@ -30,10 +30,10 @@ module m_start_up use m_variables_conversion !< State variables type conversion procedures use m_weno !< Weighted and essentially non-oscillatory (WENO) - !! spatial reconstruction of variables + !! schemes for spatial reconstruction of variables use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! convservation laws + !! schemes for convservation laws use m_riemann_solvers !< Exact and approximate Riemann problem solvers @@ -54,7 +54,7 @@ module m_start_up use m_qbmm !< Quadrature MOM use m_derived_variables !< Procedures used to compute quantities derived - !! conservative and primitive variables + !! from the conservative and primitive variables use m_hypoelastic use m_hyperelastic @@ -113,7 +113,7 @@ module m_start_up contains !> Read data files. Dispatch subroutine that replaces procedure pointer. - !! Conservative variables + !! @param q_cons_vf Conservative variables impure subroutine s_read_data_files(q_cons_vf) type(scalar_field), & @@ -129,22 +129,22 @@ contains end subroutine s_read_data_files !> The purpose of this procedure is to first verify that an - !! has been made available by the user. Provided - !! is so, the input file is then read in. + !! input file has been made available by the user. Provided + !! that this is so, the input file is then read in. impure subroutine s_read_input_file - ! path to the input file provided by the user + ! Relative path to the input file provided by the user character(LEN=name_len), parameter :: file_path = './simulation.inp' logical :: file_exist !< - !! to check the existence of the input file + !! Logical used to check the existence of the input file integer :: iostatus - !! check iostat of file read + !! Integer to check iostat of file read character(len=1000) :: line - ! of the global parameters which may be specified by user + ! Namelist of the global parameters which may be specified by user namelist /user_inputs/ case_dir, run_time_info, m, n, p, dt, & t_step_start, t_step_stop, t_step_save, t_step_print, & model_eqns, mpp_lim, time_stepper, weno_eps, & @@ -188,8 +188,8 @@ contains int_comp, ic_eps, ic_beta, nv_uvm_out_of_core, & nv_uvm_igr_temps_on_gpu, nv_uvm_pref_gpu, down_sample, fft_wrt - ! that an input file has been provided by the user. If it - ! then the input file is read in, otherwise, simulation exits. + ! Checking that an input file has been provided by the user. If it + ! has, then the input file is read in, otherwise, simulation exits. inquire (FILE=trim(file_path), EXIST=file_exist) if (file_exist) then @@ -213,7 +213,7 @@ contains bodyForces = .true. end if - ! m,n,p into global m,n,p + ! Store m,n,p into global m,n,p m_glb = m n_glb = n p_glb = p @@ -234,17 +234,17 @@ contains end subroutine s_read_input_file !> The goal of this procedure is to verify that each of the - !! inputs is valid and that their combination - !! meaningful configuration for the simulation. + !! user provided inputs is valid and that their combination + !! constitutes a meaningful configuration for the simulation. impure subroutine s_check_input_file - ! path to the current directory file in the case directory + ! Relative path to the current directory file in the case directory character(LEN=path_len) :: file_path - ! used to check the existence of the current directory file + ! Logical used to check the existence of the current directory file logical :: file_exist - ! + ! Logistics file_path = trim(case_dir)//'/.' call my_inquire(file_path, file_exist) @@ -258,29 +258,29 @@ contains end subroutine s_check_input_file - !! and grid data files. The cell-average - !! constitute the former, while the - !! in x-, y- and z-directions make - !! latter. This procedure also calculates the cell- - !! from the cell-boundary locations. - !! Cell-averaged conservative variables + !! initial condition and grid data files. The cell-average + !! conservative variables constitute the former, while the + !! cell-boundary locations in x-, y- and z-directions make + !! up the latter. This procedure also calculates the cell- + !! width distributions from the cell-boundary locations. + !! @param q_cons_vf Cell-averaged conservative variables impure subroutine s_read_serial_data_files(q_cons_vf) type(scalar_field), dimension(sys_size), intent(INOUT) :: q_cons_vf character(LEN=path_len + 2*name_len) :: t_step_dir !< - !! to the starting time-step directory + !! Relative path to the starting time-step directory character(LEN=path_len + 3*name_len) :: file_path !< - !! to the grid and conservative variables data files + !! Relative path to the grid and conservative variables data files logical :: file_exist !< - ! used to check the existence of the data files + ! Logical used to check the existence of the data files integer :: i, r !< Generic loop iterator - ! that the directory from which the initial condition and - ! grid data files are to be read in exists and exiting otherwise + ! Confirming that the directory from which the initial condition and + ! the grid data files are to be read in exists and exiting otherwise if (cfl_dt) then write (t_step_dir, '(A,I0,A,I0)') & trim(case_dir)//'/p_all/p', proc_rank, '/', n_start @@ -302,7 +302,7 @@ contains call s_assign_default_bc_type(bc_type) end if - ! Locations in x-direction + ! Cell-boundary Locations in x-direction file_path = trim(t_step_dir)//'/x_cb.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -328,7 +328,7 @@ contains end do end if - ! Locations in y-direction + ! Cell-boundary Locations in y-direction if (n > 0) then file_path = trim(t_step_dir)//'/y_cb.dat' @@ -350,7 +350,7 @@ contains end if - ! Locations in z-direction + ! Cell-boundary Locations in z-direction if (p > 0) then file_path = trim(t_step_dir)//'/z_cb.dat' @@ -388,7 +388,7 @@ contains end do if (bubbles_euler .or. elasticity) then - ! pb and mv for non-polytropic qbmm + ! Read pb and mv for non-polytropic qbmm if (qbmm .and. .not. polytropic) then do i = 1, nb do r = 1, nnode @@ -425,9 +425,9 @@ contains end if end if - ! IBM Data + ! Read IBM Data if (ib) then - ! IB markers + ! Read IB markers write (file_path, '(A,I0,A)') & trim(t_step_dir)//'/ib.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -441,7 +441,7 @@ contains call s_mpi_abort(trim(file_path)//' is missing. Exiting.') end if - ! Levelset + ! Read Levelset write (file_path, '(A)') & trim(t_step_dir)//'/levelset.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -451,12 +451,12 @@ contains ACTION='read', & STATUS='old') read (2) levelset%sf(0:m, 0:n, 0:p, 1:num_ibs); close (2) - ! 'check', STL_levelset(106, 50, 0, 1) + ! print*, 'check', STL_levelset(106, 50, 0, 1) else call s_mpi_abort(trim(file_path)//' is missing. Exiting.') end if - ! Levelset Norm + ! Read Levelset Norm write (file_path, '(A)') & trim(t_step_dir)//'/levelset_norm.dat' inquire (FILE=trim(file_path), EXIST=file_exist) @@ -507,7 +507,7 @@ contains end subroutine s_read_serial_data_files - !! Conservative variables + !! @param q_cons_vf Conservative variables impure subroutine s_read_parallel_data_files(q_cons_vf) type(scalar_field), & @@ -533,7 +533,7 @@ contains integer :: i, j - ! data variables + ! Downsampled data variables integer :: m_ds, n_ds, p_ds integer :: m_glb_ds, n_glb_ds, p_glb_ds integer :: m_glb_read, n_glb_read, p_glb_read ! data size of read @@ -542,7 +542,7 @@ contains allocate (y_cb_glb(-1:n_glb)) allocate (z_cb_glb(-1:p_glb)) - ! in cell boundary locations in x-direction + ! Read in cell boundary locations in x-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'x_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -565,11 +565,11 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! local cell boundary locations + ! Assigning local cell boundary locations x_cb(-1:m) = x_cb_glb((start_idx(1) - 1):(start_idx(1) + m)) - ! the cell width distribution + ! Computing the cell width distribution dx(0:m) = x_cb(0:m) - x_cb(-1:m - 1) - ! the cell center locations + ! Computing the cell center locations x_cc(0:m) = x_cb(-1:m - 1) + dx(0:m)/2._wp if (ib) then @@ -582,7 +582,7 @@ contains end if if (n > 0) then - ! in cell boundary locations in y-direction + ! Read in cell boundary locations in y-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'y_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -595,15 +595,15 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! local cell boundary locations + ! Assigning local cell boundary locations y_cb(-1:n) = y_cb_glb((start_idx(2) - 1):(start_idx(2) + n)) - ! the cell width distribution + ! Computing the cell width distribution dy(0:n) = y_cb(0:n) - y_cb(-1:n - 1) - ! the cell center locations + ! Computing the cell center locations y_cc(0:n) = y_cb(-1:n - 1) + dy(0:n)/2._wp if (p > 0) then - ! in cell boundary locations in z-direction + ! Read in cell boundary locations in z-direction file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//'z_cb.dat' inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -616,11 +616,11 @@ contains call s_mpi_abort('File '//trim(file_loc)//'is missing. Exiting.') end if - ! local cell boundary locations + ! Assigning local cell boundary locations z_cb(-1:p) = z_cb_glb((start_idx(3) - 1):(start_idx(3) + p)) - ! the cell width distribution + ! Computing the cell width distribution dz(0:p) = z_cb(0:p) - z_cb(-1:p - 1) - ! the cell center locations + ! Computing the cell center locations z_cc(0:p) = z_cb(-1:p - 1) + dz(0:p)/2._wp end if @@ -640,7 +640,7 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! MPI data I/O + ! Initialize MPI data I/O if (down_sample) then call s_initialize_mpi_data_ds(q_cons_vf) else @@ -653,20 +653,20 @@ contains end if if (down_sample) then - ! of local arrays + ! Size of local arrays data_size = (m_ds + 3)*(n_ds + 3)*(p_ds + 3) m_glb_read = m_glb_ds + 1 n_glb_read = n_glb_ds + 1 p_glb_read = p_glb_ds + 1 else - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) m_glb_read = m_glb + 1 n_glb_read = n_glb + 1 p_glb_read = p_glb + 1 end if - ! some integers so MPI can read even the biggest file + ! Resize some integers so MPI can read even the biggest file m_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) n_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) p_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) @@ -675,7 +675,7 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! the data for each variable + ! Read the data for each variable if (bubbles_euler .or. elasticity) then do i = 1, sys_size!adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) @@ -715,7 +715,7 @@ contains call MPI_FILE_CLOSE(ifile, ierr) if (ib) then - ! IB Markers + ! Read IB Markers write (file_loc, '(A)') 'ib.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -735,7 +735,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Levelset + ! Read Levelset write (file_loc, '(A)') 'levelset.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -755,7 +755,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Levelset Norm + ! Read Levelset Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -781,7 +781,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if else - ! the file to read conservative variables + ! Open the file to read conservative variables if (cfl_dt) then write (file_loc, '(I0,A)') n_start, '.dat' else @@ -793,7 +793,7 @@ contains if (file_exist) then call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! MPI data I/O + ! Initialize MPI data I/O if (ib) then call s_initialize_mpi_data(q_cons_vf, ib_markers, & @@ -804,10 +804,10 @@ contains end if - ! of local arrays + ! Size of local arrays data_size = (m + 1)*(n + 1)*(p + 1) - ! some integers so MPI can read even the biggest file + ! Resize some integers so MPI can read even the biggest file m_MOK = int(m_glb + 1, MPI_OFFSET_KIND) n_MOK = int(n_glb + 1, MPI_OFFSET_KIND) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) @@ -816,11 +816,11 @@ contains str_MOK = int(name_len, MPI_OFFSET_KIND) NVARS_MOK = int(sys_size, MPI_OFFSET_KIND) - ! the data for each variable + ! Read the data for each variable if (bubbles_euler .or. elasticity) then do i = 1, sys_size !adv_idx%end var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -832,7 +832,7 @@ contains if (qbmm .and. .not. polytropic) then do i = sys_size + 1, sys_size + 2*nb*nnode var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -845,7 +845,7 @@ contains do i = 1, sys_size var_MOK = int(i, MPI_OFFSET_KIND) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1) call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_DATA%view(i), & @@ -861,7 +861,7 @@ contains if (ib) then - ! IB Markers + ! Read IB Markers write (file_loc, '(A)') 'ib.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -881,7 +881,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Levelset + ! Read Levelset write (file_loc, '(A)') 'levelset.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -901,7 +901,7 @@ contains call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting.') end if - ! Levelset Norm + ! Read Levelset Norm write (file_loc, '(A)') 'levelset_norm.dat' file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc) inquire (FILE=trim(file_loc), EXIST=file_exist) @@ -944,7 +944,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(1), & @@ -961,7 +961,7 @@ contains call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr) - ! displacement to skip at beginning of file + ! Initial displacement to skip at beginning of file disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, mpi_io_p, MPI_IO_airfoil_IB_DATA%view(2), & @@ -997,10 +997,10 @@ contains end subroutine s_read_parallel_data_files !> The purpose of this procedure is to initialize the - !! the internal-energy equations of each phase - !! mass of each phase, the mixture momentum and - !! - !! conservative variables + !! values of the internal-energy equations of each phase + !! from the mass of each phase, the mixture momentum and + !! mixture-total-energy equations. + !! @param v_vf conservative variables subroutine s_initialize_internal_energy_equations(v_vf) type(scalar_field), dimension(sys_size), intent(inout) :: v_vf @@ -1124,14 +1124,14 @@ contains mytime = mytime + dt - ! (TVD) Runge-Kutta (RK) time-steppers + ! Total-variation-diminishing (TVD) Runge-Kutta (RK) time-steppers if (any(time_stepper == (/1, 2, 3/))) then call s_tvd_rk(t_step, time_avg, time_stepper) end if if (relax) call s_infinite_relaxation_k(q_cons_ts(1)%vf) - ! loop controls + ! Time-stepping loop controls t_step = t_step + 1 end subroutine s_perform_time_step @@ -1349,7 +1349,7 @@ contains end do end if - ! in the user provided initial condition and grid data + ! Reading in the user provided initial condition and grid data if (down_sample) then call s_read_data_files(q_cons_temp) call s_upsample_data(q_cons_ts(1)%vf, q_cons_temp) @@ -1364,7 +1364,7 @@ contains call s_read_data_files(q_cons_ts(1)%vf) end if - ! the buffers of the grid variables using the boundary conditions + ! Populating the buffers of the grid variables using the boundary conditions call s_populate_grid_variables_buffers() if (model_eqns == 3) call s_initialize_internal_energy_equations(q_cons_ts(1)%vf) @@ -1372,12 +1372,12 @@ contains if (bodyForces) call s_initialize_body_forces_module() if (acoustic_source) call s_precalculate_acoustic_spatial_sources() - ! the Temperature cache. + ! Initialize the Temperature cache. if (chemistry) call s_compute_q_T_sf(q_T_sf, q_cons_ts(1)%vf, idwint) - ! of parameters, allocation of memory, association of pointers, - ! execution of any other tasks that are needed to properly configure - ! modules. The preparations below DO DEPEND on the grid being complete. + ! Computation of parameters, allocation of memory, association of pointers, + ! and/or execution of any other tasks that are needed to properly configure + ! the modules. The preparations below DO DEPEND on the grid being complete. if (igr .or. dummy) then call s_initialize_igr_module() end if @@ -1413,11 +1413,11 @@ contains #endif #endif - ! MPI execution environment + ! Initializing MPI execution environment call s_mpi_initialize() - ! GPUs if OpenACC is enabled + ! Bind GPUs if OpenACC is enabled #ifdef MFC_GPU #ifndef MFC_MPI local_size = 1 @@ -1441,10 +1441,10 @@ contains #endif #endif - ! rank 0 processor assigns default values to the user inputs prior to - ! them in from the input file. Next, the user inputs are read and - ! consistency is checked. The identification of any inconsistencies - ! result in the termination of the simulation. + ! The rank 0 processor assigns default values to the user inputs prior to + ! reading them in from the input file. Next, the user inputs are read and + ! their consistency is checked. The identification of any inconsistencies + ! will result in the termination of the simulation. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() call s_read_input_file() @@ -1466,9 +1466,9 @@ contains #endif end if - ! the user inputs to all of the processors and performing the - ! computational domain decomposition. Neither procedure has to be - ! out if the simulation is in fact not truly executed in parallel. + ! Broadcasting the user inputs to all of the processors and performing the + ! parallel computational domain decomposition. Neither procedure has to be + ! carried out if the simulation is in fact not truly executed in parallel. call s_mpi_bcast_user_inputs() @@ -1583,7 +1583,7 @@ contains if (surface_tension) call s_finalize_surface_tension_module() if (bodyForces) call s_finalize_body_forces_module() - ! MPI execution environment + ! Terminating MPI execution environment call s_mpi_finalize() end subroutine s_finalize_modules diff --git a/src/simulation/m_surface_tension.fpp b/src/simulation/m_surface_tension.fpp index 183a730bc9..99bac7d722 100644 --- a/src/simulation/m_surface_tension.fpp +++ b/src/simulation/m_surface_tension.fpp @@ -16,7 +16,7 @@ module m_surface_tension use m_weno use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! conservation laws + !! schemes for conservation laws use m_helper @@ -248,7 +248,7 @@ contains isx%end = m; isy%end = n; isz%end = p - ! gradient components + ! compute gradient components $:GPU_PARALLEL_LOOP(collapse=3) do l = 0, p do k = 0, n @@ -308,7 +308,7 @@ contains iv%beg = 1; iv%end = num_dims + 1 - ! gradient components at cell boundaries + ! reconstruct gradient components at cell boundaries do i = 1, num_dims call s_reconstruct_cell_boundary_values_capillary(c_divs, gL_x, gL_y, gL_z, gR_x, gR_y, gR_z, i) end do @@ -329,7 +329,7 @@ contains #:for SCHEME, TYPE in [('weno', 'WENO_TYPE'),('muscl', 'MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! in s1-direction + ! Reconstruction in s1-direction if (norm_dir == 1) then is1 = idwbuff(1); is2 = idwbuff(2); is3 = idwbuff(3) diff --git a/src/simulation/m_time_steppers.fpp b/src/simulation/m_time_steppers.fpp index dc46e2b073..098888782a 100644 --- a/src/simulation/m_time_steppers.fpp +++ b/src/simulation/m_time_steppers.fpp @@ -1,16 +1,16 @@ !> -!! -!! module m_time_steppers +!! @file +!! @brief Contains module m_time_steppers #:include 'macros.fpp' #:include 'case.fpp' !> @brief The following module features a variety of time-stepping schemes. -!! includes the following Runge-Kutta (RK) algorithms: -!! Order TVD RK -!! Order TVD RK -!! Order TVD RK -!! designates a total-variation-diminishing time-stepper. +!! Currently, it includes the following Runge-Kutta (RK) algorithms: +!! 1) 1st Order TVD RK +!! 2) 2nd Order TVD RK +!! 3) 3rd Order TVD RK +!! where TVD designates a total-variation-diminishing time-stepper. module m_time_steppers use m_derived_types !< Definitions of the derived types @@ -52,31 +52,31 @@ module m_time_steppers implicit none type(vector_field), allocatable, dimension(:) :: q_cons_ts !< - !! variables at each time-stage (TS) + !! Cell-average conservative variables at each time-stage (TS) type(scalar_field), allocatable, dimension(:) :: q_prim_vf !< - !! variables at the current time-stage + !! Cell-average primitive variables at the current time-stage type(scalar_field), allocatable, dimension(:) :: rhs_vf !< - !! variables at the current time-stage + !! Cell-average RHS variables at the current time-stage type(integer_field), allocatable, dimension(:, :) :: bc_type !< - !! identifiers + !! Boundary condition identifiers type(vector_field), allocatable, dimension(:) :: q_prim_ts1, q_prim_ts2 !< - !! variables at consecutive TIMESTEPS + !! Cell-average primitive variables at consecutive TIMESTEPS real(wp), allocatable, dimension(:, :, :, :, :) :: rhs_pb type(scalar_field) :: q_T_sf !< - !! variables at the current time-stage + !! Cell-average temperature variables at the current time-stage real(wp), allocatable, dimension(:, :, :, :, :) :: rhs_mv real(wp), allocatable, dimension(:, :, :) :: max_dt integer, private :: num_ts !< - !! time stages in the time-stepping scheme + !! Number of time stages in the time-stepping scheme integer :: stor !< storage index real(wp), allocatable, dimension(:, :) :: rk_coef @@ -98,8 +98,8 @@ module m_time_steppers contains !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_time_steppers_module #ifdef FRONTIER_UNIFIED use hipfort @@ -111,7 +111,7 @@ contains #endif integer :: i, j !< Generic loop iterators - ! number of time-stages for selected time-stepping scheme + ! Setting number of time-stages for selected time-stepping scheme if (time_stepper == 1) then num_ts = 1 elseif (any(time_stepper == (/2, 3/))) then @@ -122,7 +122,7 @@ contains num_probe_ts = 2 end if - ! the cell-average conservative variables + ! Allocating the cell-average conservative variables @:ALLOCATE(q_cons_ts(1:num_ts)) @:PREFER_GPU(q_cons_ts) @@ -131,9 +131,10 @@ contains @:PREFER_GPU(q_cons_ts(i)%vf) end do +!> @cond #if defined(__NVCOMPILER_GPU_UNIFIED_MEM) if (num_ts == 2 .and. nv_uvm_out_of_core) then - ! allocation for q_cons_ts(2)%vf(j)%sf for all j + ! host allocation for q_cons_ts(2)%vf(j)%sf for all j allocate (q_cons_ts_pool_host(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end, & @@ -141,14 +142,14 @@ contains end if do j = 1, sys_size - ! lives on the device + ! q_cons_ts(1) lives on the device @:ALLOCATE(q_cons_ts(1)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end)) @:PREFER_GPU(q_cons_ts(1)%vf(j)%sf) if (num_ts == 2) then if (nv_uvm_out_of_core) then - ! lives on the host + ! q_cons_ts(2) lives on the host q_cons_ts(2)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_host(:, :, :, j) @@ -165,8 +166,8 @@ contains @:ACC_SETUP_VFs(q_cons_ts(i)) end do #elif defined(FRONTIER_UNIFIED) - ! to memory regions using hip calls - ! we will attach pointers to + ! Allocate to memory regions using hip calls + ! that we will attach pointers to do i = 1, 3 pool_dims(i) = idwbuff(i)%end - idwbuff(i)%beg + 1 pool_starts(i) = idwbuff(i)%beg @@ -183,15 +184,15 @@ contains call c_f_pointer(cptr_host, q_cons_ts_pool_host, shape=pool_dims) q_cons_ts_pool_host(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:) => q_cons_ts_pool_host #else - ! hipMalloc then mapping should be most performant + ! Doing hipMalloc then mapping should be most performant call hipCheck(hipMalloc(q_cons_ts_pool_device, dims8=pool_dims, lbounds8=pool_starts)) - ! this map CCE will still create a device copy, because it's silly like that + ! Without this map CCE will still create a device copy, because it's silly like that #if defined(MFC_OpenACC) call acc_map_data(q_cons_ts_pool_device, c_loc(q_cons_ts_pool_device), c_sizeof(q_cons_ts_pool_device)) #endif - ! see it can access this and will leave it on the host. It will stay on the host so long as HSA_XNACK=1 - ! WE CANNOT DO ATOMICS INTO THIS MEMORY. We have to change a property to use atomics here - ! leaving this as fine-grained will actually help performance since it can't be cached in GPU L2 + ! CCE see it can access this and will leave it on the host. It will stay on the host so long as HSA_XNACK=1 + ! NOTE: WE CANNOT DO ATOMICS INTO THIS MEMORY. We have to change a property to use atomics here + ! Otherwise leaving this as fine-grained will actually help performance since it can't be cached in GPU L2 if (num_ts == 2) then call hipCheck(hipMallocManaged(q_cons_ts_pool_host, dims8=pool_dims, lbounds8=pool_starts, flags=hipMemAttachGlobal)) #if defined(MFC_OpenMP) @@ -201,12 +202,12 @@ contains #endif do j = 1, sys_size - ! lives on the device + ! q_cons_ts(1) lives on the device q_cons_ts(1)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_device(:, :, :, j) if (num_ts == 2) then - ! lives on the host + ! q_cons_ts(2) lives on the host q_cons_ts(2)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & idwbuff(2)%beg:idwbuff(2)%end, & idwbuff(3)%beg:idwbuff(3)%end) => q_cons_ts_pool_host(:, :, :, j) @@ -220,6 +221,7 @@ contains end do end do #else +!> @endcond do i = 1, num_ts do j = 1, sys_size @:ALLOCATE(q_cons_ts(i)%vf(j)%sf(idwbuff(1)%beg:idwbuff(1)%end, & @@ -228,9 +230,11 @@ contains end do @:ACC_SETUP_VFs(q_cons_ts(i)) end do +!> @cond #endif +!> @endcond - ! the cell-average primitive ts variables + ! Allocating the cell-average primitive ts variables if (probe_wrt) then @:ALLOCATE(q_prim_ts1(1:num_probe_ts)) @@ -263,7 +267,7 @@ contains end do end if - ! the cell-average primitive variables + ! Allocating the cell-average primitive variables @:ALLOCATE(q_prim_vf(1:sys_size)) if (.not. igr) then @@ -442,7 +446,7 @@ contains @:ALLOCATE(rhs_mv(0,0,0,0,0)) end if - ! the cell-average RHS variables + ! Allocating the cell-average RHS variables @:ALLOCATE(rhs_vf(1:sys_size)) @:PREFER_GPU(rhs_vf) @@ -459,7 +463,7 @@ contains end do end if - ! and writing the header of the run-time information file + ! Opening and writing the header of the run-time information file if (proc_rank == 0 .and. run_time_info) then call s_open_run_time_information_file() end if @@ -468,7 +472,7 @@ contains @:ALLOCATE(max_dt(0:m, 0:n, 0:p)) end if - ! arrays to store the bc types + ! Allocating arrays to store the bc types @:ALLOCATE(bc_type(1:num_dims,1:2)) @:ALLOCATE(bc_type(1,1)%sf(0:0,0:n,0:p)) @@ -493,14 +497,14 @@ contains end do if (any(time_stepper == (/1, 2, 3/))) then - ! array index for TVD RK + ! temporary array index for TVD RK if (time_stepper == 1) then stor = 1 else stor = 2 end if - ! RK coefficients + ! TVD RK coefficients @:ALLOCATE (rk_coef(time_stepper, 4)) if (time_stepper == 1) then rk_coef(1, :) = (/1._wp, 0._wp, 1._wp, 1._wp/) @@ -532,7 +536,7 @@ contains call cpu_time(start) call nvtxStartRange("TIMESTEP") - ! dt: initial stage + ! Adaptive dt: initial stage if (adap_dt) call s_adaptive_dt_bubble(1) do s = 1, nstage @@ -627,12 +631,12 @@ contains if (adv_n) call s_comp_alpha_from_n(q_cons_ts(1)%vf) if (ib) then - ! if any IBMS are moving, and if so, update the markers, ghost points, levelsets, and levelset norms + ! check if any IBMS are moving, and if so, update the markers, ghost points, levelsets, and levelset norms if (moving_immersed_boundary_flag) then call s_propagate_immersed_boundaries(s) end if - ! the ghost fluid properties point values based on IB state + ! update the ghost fluid properties point values based on IB state if (qbmm .and. .not. polytropic) then call s_ibm_correct_state(q_cons_ts(1)%vf, q_prim_vf, pb_ts(1)%sf, mv_ts(1)%sf) else @@ -642,7 +646,7 @@ contains end do - ! dt: final stage + ! Adaptive dt: final stage if (adap_dt) call s_adaptive_dt_bubble(3) call nvtxEndRange @@ -659,7 +663,7 @@ contains end subroutine s_tvd_rk !> Bubble source part in Strang operator splitting scheme - !! Current time-step + !! @param t_step Current time-step impure subroutine s_adaptive_dt_bubble(stage) integer, intent(in) :: stage @@ -737,7 +741,7 @@ contains call s_compute_enthalpy(q_prim_vf, pres, rho, gamma, pi_inf, Re, H, alpha, vel, vel_sum, qv, j, k, l) end if - ! mixture sound speed + ! Compute mixture sound speed call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, alpha, vel_sum, 0._wp, c, qv) call s_compute_dt_from_cfl(vel, c, max_dt, rho, Re, j, k, l) @@ -760,18 +764,15 @@ contains end subroutine s_compute_dt - !> This subroutine applies the body forces source term at each Runge-Kutta stage. - !! @param[inout] q_cons_vf Conservative variables to update. - !! @param[in] q_prim_vf_in Primitive variables for computing source terms. - !! @param[inout] rhs_vf_in Right-hand side vector for body force terms. - !! @param[in] ldt Local time step size. + !> This subroutine applies the body forces source term at each + !! Runge-Kutta stage subroutine s_apply_bodyforces(q_cons_vf, q_prim_vf_in, rhs_vf_in, ldt) type(scalar_field), dimension(1:sys_size), intent(inout) :: q_cons_vf type(scalar_field), dimension(1:sys_size), intent(in) :: q_prim_vf_in type(scalar_field), dimension(1:sys_size), intent(inout) :: rhs_vf_in - real(wp), intent(in) :: ldt + real(wp), intent(in) :: ldt !< local dt integer :: i, j, k, l @@ -818,28 +819,28 @@ contains patch_ib(i)%angular_vel = (rk_coef(s, 1)*patch_ib(i)%step_angular_vel + rk_coef(s, 2)*patch_ib(i)%angular_vel)/rk_coef(s, 4) if (patch_ib(i)%moving_ibm == 1) then - ! in analytic velocities for 1-way coupling, if it exists + ! plug in analytic velocities for 1-way coupling, if it exists @:mib_analytical() else if (patch_ib(i)%moving_ibm == 2) then ! if we are using two-way coupling, apply force and torque - ! the force and torque on the IB from the fluid + ! compute the force and torque on the IB from the fluid if (.not. forces_computed) then call s_compute_ib_forces(q_prim_vf, fluid_pp) forces_computed = .true. end if - ! the velocity from the force value + ! update the velocity from the force value patch_ib(i)%vel = patch_ib(i)%vel + rk_coef(s, 3)*dt*(patch_ib(i)%force/patch_ib(i)%mass)/rk_coef(s, 4) - ! the angular velocity with the torque value + ! update the angular velocity with the torque value patch_ib(i)%angular_vel = (patch_ib(i)%angular_vel*patch_ib(i)%moment) + (rk_coef(s, 3)*dt*patch_ib(i)%torque/rk_coef(s, 4)) ! add the torque to the angular momentum call s_compute_moment_of_inertia(i, patch_ib(i)%angular_vel) ! update the moment of inertia to be based on the direction of the angular momentum patch_ib(i)%angular_vel = patch_ib(i)%angular_vel/patch_ib(i)%moment ! convert back to angular velocity with the new moment of inertia end if - ! the angle of the IB + ! Update the angle of the IB patch_ib(i)%angles = (rk_coef(s, 1)*patch_ib(i)%step_angles + rk_coef(s, 2)*patch_ib(i)%angles + rk_coef(s, 3)*patch_ib(i)%angular_vel*dt)/rk_coef(s, 4) - ! the position of the IB + ! Update the position of the IB patch_ib(i)%x_centroid = (rk_coef(s, 1)*patch_ib(i)%step_x_centroid + rk_coef(s, 2)*patch_ib(i)%x_centroid + rk_coef(s, 3)*patch_ib(i)%vel(1)*dt)/rk_coef(s, 4) patch_ib(i)%y_centroid = (rk_coef(s, 1)*patch_ib(i)%step_y_centroid + rk_coef(s, 2)*patch_ib(i)%y_centroid + rk_coef(s, 3)*patch_ib(i)%vel(2)*dt)/rk_coef(s, 4) patch_ib(i)%z_centroid = (rk_coef(s, 1)*patch_ib(i)%step_z_centroid + rk_coef(s, 2)*patch_ib(i)%z_centroid + rk_coef(s, 3)*patch_ib(i)%vel(3)*dt)/rk_coef(s, 4) @@ -851,8 +852,8 @@ contains end subroutine s_propagate_immersed_boundaries !> This subroutine saves the temporary q_prim_vf vector - !! q_prim_ts vector that is then used in p_main - !! current time-step + !! into the q_prim_ts vector that is then used in p_main + !! @param t_step current time-step subroutine s_time_step_cycling(t_step) integer, intent(in) :: t_step @@ -935,7 +936,7 @@ contains #endif integer :: i, j !< Generic loop iterators - ! the cell-average conservative variables + ! Deallocating the cell-average conservative variables #if defined(__NVCOMPILER_GPU_UNIFIED_MEM) do j = 1, sys_size @:DEALLOCATE(q_cons_ts(1)%vf(j)%sf) @@ -978,7 +979,7 @@ contains @:DEALLOCATE(q_cons_ts) - ! the cell-average primitive ts variables + ! Deallocating the cell-average primitive ts variables if (probe_wrt) then do i = 1, num_probe_ts do j = 1, sys_size @@ -990,7 +991,7 @@ contains end if if (.not. igr) then - ! the cell-average primitive variables + ! Deallocating the cell-average primitive variables do i = 1, adv_idx%end @:DEALLOCATE(q_prim_vf(i)%sf) end do @@ -1036,14 +1037,14 @@ contains @:DEALLOCATE(q_prim_vf) - ! the cell-average RHS variables + ! Deallocating the cell-average RHS variables do i = 1, sys_size @:DEALLOCATE(rhs_vf(i)%sf) end do @:DEALLOCATE(rhs_vf) - ! the footer of and closing the run-time information file + ! Writing the footer of and closing the run-time information file if (proc_rank == 0 .and. run_time_info) then call s_close_run_time_information_file() end if diff --git a/src/simulation/m_viscous.fpp b/src/simulation/m_viscous.fpp index c507b7bf3d..177b8c6bb4 100644 --- a/src/simulation/m_viscous.fpp +++ b/src/simulation/m_viscous.fpp @@ -1,6 +1,6 @@ !> -!! -!! module m_viscous +!! @file +!! @brief Contains module m_viscous #:include 'case.fpp' #:include 'macros.fpp' @@ -14,7 +14,7 @@ module m_viscous use m_weno use m_muscl !< Monotonic Upstream-centered (MUSCL) - !! conservation laws + !! schemes for conservation laws use m_helper @@ -53,14 +53,14 @@ contains end subroutine s_initialize_viscous_module !> The purpose of this subroutine is to compute the viscous - ! tensor for the cells directly next to the axis in - ! coordinates. This is necessary to avoid the - ! singularity that arises at the cell boundary coinciding - ! the axis, i.e., y_cb(-1) = 0. - ! q_prim_vf Cell-average primitive variables - ! grad_x_vf Cell-average primitive variable derivatives, x-dir - ! grad_y_vf Cell-average primitive variable derivatives, y-dir - ! grad_z_vf Cell-average primitive variable derivatives, z-dir + ! stress tensor for the cells directly next to the axis in + ! cylindrical coordinates. This is necessary to avoid the + ! 1/r singularity that arises at the cell boundary coinciding + ! with the axis, i.e., y_cb(-1) = 0. + ! @param q_prim_vf Cell-average primitive variables + ! @param grad_x_vf Cell-average primitive variable derivatives, x-dir + ! @param grad_y_vf Cell-average primitive variable derivatives, y-dir + ! @param grad_z_vf Cell-average primitive variable derivatives, z-dir subroutine s_compute_viscous_stress_cylindrical_boundary(q_prim_vf, grad_x_vf, grad_y_vf, grad_z_vf, & tau_Re_vf, & ix, iy, iz) @@ -530,9 +530,9 @@ contains end subroutine s_compute_viscous_stress_cylindrical_boundary !> Computes viscous terms - !! Cell-averaged conservative variables - !! Cell-averaged primitive variables - !! Cell-averaged RHS variables + !! @param q_cons_vf Cell-averaged conservative variables + !! @param q_prim_vf Cell-averaged primitive variables + !! @param rhs_vf Cell-averaged RHS variables subroutine s_get_viscous(qL_prim_rsx_vf, qL_prim_rsy_vf, qL_prim_rsz_vf, & dqL_prim_dx_n, dqL_prim_dy_n, dqL_prim_dz_n, & qL_prim, & @@ -577,8 +577,8 @@ contains end do if (weno_Re_flux) then - ! velocity gradient at cell centers using scalar - ! theorem + ! Compute velocity gradient at cell centers using scalar + ! divergence theorem do i = 1, num_dims if (i == 1) then call s_apply_scalar_divergence_theorem( & @@ -1021,7 +1021,7 @@ contains #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$ .or. dummy) then - ! in s1-direction + ! Reconstruction in s1-direction if (norm_dir == 1) then is1_viscous = ix; is2_viscous = iy; is3_viscous = iz @@ -1123,7 +1123,7 @@ contains integer :: i, j, k, l #:for SCHEME, TYPE in [('weno','WENO_TYPE'), ('muscl','MUSCL_TYPE')] if (recon_type == ${TYPE}$) then - ! in s1-direction + ! Reconstruction in s1-direction if (norm_dir == 1) then is1_viscous = ix; is2_viscous = iy; is3_viscous = iz @@ -1213,21 +1213,21 @@ contains end subroutine s_reconstruct_cell_boundary_values_visc_deriv !> The purpose of this subroutine is to employ the inputted - !! right cell-boundary integral-averaged variables - !! the relevant cell-average first-order spatial - !! the x-, y- or z-direction by means of the - !! theorem. - !! Left cell-boundary integral averages - !! Right cell-boundary integral averages - !! Cell-average first-order spatial derivatives - !! Splitting coordinate direction + !! left and right cell-boundary integral-averaged variables + !! to compute the relevant cell-average first-order spatial + !! derivatives in the x-, y- or z-direction by means of the + !! scalar divergence theorem. + !! @param vL_vf Left cell-boundary integral averages + !! @param vR_vf Right cell-boundary integral averages + !! @param dv_ds_vf Cell-average first-order spatial derivatives + !! @param norm_dir Splitting coordinate direction subroutine s_apply_scalar_divergence_theorem(vL_vf, vR_vf, & dv_ds_vf, & norm_dir, & ix, iy, iz, iv_in, & dL, dim, buff_size_in) - ! of cell widths + ! arrays of cell widths type(scalar_field), & dimension(iv%beg:iv%end), & intent(in) :: vL_vf, vR_vf @@ -1250,14 +1250,14 @@ contains $:GPU_UPDATE(device='[is1_viscous, is2_viscous, is3_viscous, iv]') - ! Spatial Derivatives in x-direction + ! First-Order Spatial Derivatives in x-direction if (norm_dir == 1) then - ! general application of the scalar divergence theorem that - ! the left and right cell-boundary integral-averages, - ! each cell, or an arithmetic mean of these two at the - ! to calculate the cell-averaged first-order - ! derivatives inside the cell. + ! A general application of the scalar divergence theorem that + ! utilizes the left and right cell-boundary integral-averages, + ! inside each cell, or an arithmetic mean of these two at the + ! cell-boundaries, to calculate the cell-averaged first-order + ! spatial derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg, is3_viscous%end @@ -1277,16 +1277,16 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! First-Order Spatial Derivatives in x-direction + ! END: First-Order Spatial Derivatives in x-direction - ! Spatial Derivatives in y-direction + ! First-Order Spatial Derivatives in y-direction elseif (norm_dir == 2) then - ! general application of the scalar divergence theorem that - ! the left and right cell-boundary integral-averages, - ! each cell, or an arithmetic mean of these two at the - ! to calculate the cell-averaged first-order - ! derivatives inside the cell. + ! A general application of the scalar divergence theorem that + ! utilizes the left and right cell-boundary integral-averages, + ! inside each cell, or an arithmetic mean of these two at the + ! cell-boundaries, to calculate the cell-averaged first-order + ! spatial derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg, is3_viscous%end @@ -1306,16 +1306,16 @@ contains end do $:END_GPU_PARALLEL_LOOP() - ! First-Order Spatial Derivatives in y-direction + ! END: First-Order Spatial Derivatives in y-direction - ! Spatial Derivatives in z-direction + ! First-Order Spatial Derivatives in z-direction else - ! general application of the scalar divergence theorem that - ! the left and right cell-boundary integral-averages, - ! each cell, or an arithmetic mean of these two at the - ! to calculate the cell-averaged first-order - ! derivatives inside the cell. + ! A general application of the scalar divergence theorem that + ! utilizes the left and right cell-boundary integral-averages, + ! inside each cell, or an arithmetic mean of these two at the + ! cell-boundaries, to calculate the cell-averaged first-order + ! spatial derivatives inside the cell. $:GPU_PARALLEL_LOOP(collapse=3) do l = is3_viscous%beg + 1, is3_viscous%end - 1 @@ -1336,16 +1336,16 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! First-Order Spatial Derivatives in z-direction + ! END: First-Order Spatial Derivatives in z-direction end subroutine s_apply_scalar_divergence_theorem !> Computes the scalar gradient fields via finite differences - !! Variable to compute derivative of - !! First coordinate direction component of the derivative - !! Second coordinate direction component of the derivative - !! Third coordinate direction component of the derivative - !! Norm of the gradient vector + !! @param var Variable to compute derivative of + !! @param grad_x First coordinate direction component of the derivative + !! @param grad_y Second coordinate direction component of the derivative + !! @param grad_z Third coordinate direction component of the derivative + !! @param norm Norm of the gradient vector subroutine s_compute_fd_gradient(var, grad_x, grad_y, grad_z) type(scalar_field), intent(in) :: var @@ -1523,7 +1523,7 @@ contains end subroutine s_compute_fd_gradient - ! the viscous stress tensor at a particule i, j, k element + ! computes the viscous stress tensor at a particule i, j, k element subroutine s_compute_viscous_stress_tensor(viscous_stress_tensor, q_prim_vf, dynamic_viscosity, i, j, k) $:GPU_ROUTINE(parallelism='[seq]') @@ -1537,19 +1537,19 @@ contains real(wp) :: divergence integer :: l, q ! iterators - ! the viscous stress, collection of velocity diriviatives, and spacial finite differences + ! zero the viscous stress, collection of velocity diriviatives, and spacial finite differences viscous_stress_tensor = 0._wp velocity_gradient_tensor = 0._wp dx = 0._wp - ! the change in x used in the finite difference equaiont + ! get the change in x used in the finite difference equaiont dx(1) = 0.5_wp*(x_cc(i + 1) - x_cc(i - 1)) dx(2) = 0.5_wp*(y_cc(j + 1) - y_cc(j - 1)) if (num_dims == 3) then dx(3) = 0.5_wp*(z_cc(k + 1) - z_cc(k - 1)) end if - ! the velocity gradient tensor + ! compute the velocity gradient tensor do l = 1, num_dims velocity_gradient_tensor(l, 1) = (q_prim_vf(momxb + l - 1)%sf(i + 1, j, k) - q_prim_vf(momxb + l - 1)%sf(i - 1, j, k))/(2._wp*dx(1)) velocity_gradient_tensor(l, 2) = (q_prim_vf(momxb + l - 1)%sf(i, j + 1, k) - q_prim_vf(momxb + l - 1)%sf(i, j - 1, k))/(2._wp*dx(2)) @@ -1558,20 +1558,20 @@ contains end if end do - ! divergence + ! compute divergence divergence = 0._wp do l = 1, num_dims divergence = divergence + velocity_gradient_tensor(l, l) end do - ! up the shear stress tensor + ! set up the shear stress tensor do l = 1, num_dims do q = 1, num_dims viscous_stress_tensor(l, q) = dynamic_viscosity*(velocity_gradient_tensor(l, q) + velocity_gradient_tensor(q, l)) end do end do - ! the viscous_stress_tensor + ! populate the viscous_stress_tensor do l = 1, num_dims viscous_stress_tensor(l, l) = viscous_stress_tensor(l, l) - 2._wp*divergence*dynamic_viscosity/3._wp end do diff --git a/src/simulation/m_weno.fpp b/src/simulation/m_weno.fpp index 77e02dbdc0..962c171c83 100644 --- a/src/simulation/m_weno.fpp +++ b/src/simulation/m_weno.fpp @@ -1,22 +1,22 @@ !> -!! -!! module m_weno +!! @file +!! @brief Contains module m_weno #:include 'case.fpp' #:include 'macros.fpp' !> @brief Weighted essentially non-oscillatory (WENO) reconstruction scheme -!! supplemented with monotonicity preserving bounds (MPWENO) -!! mapping function that boosts the accuracy of the non-linear -!! MPWENO, see Balsara and Shu (2000), prevents the -!! to lay outside the range set by the stencil, -!! see Henrick et al. (2005), recovers the formal order -!! of the reconstruction at critical points. Please note -!! basic WENO approach is implemented according to the work -!! and Shu (1996). WENO-Z, which is less dissipative than -!! WENO-M, is implemented according to the work of -!! al. (2008). TENO, which is even less dissipative than -!! is less robust, is implemented according to the work -!! et al. (2016). +!! that is supplemented with monotonicity preserving bounds (MPWENO) +!! and a mapping function that boosts the accuracy of the non-linear +!! weights (WENOM). MPWENO, see Balsara and Shu (2000), prevents the +!! reconstructed values to lay outside the range set by the stencil, +!! while WENOM, see Henrick et al. (2005), recovers the formal order +!! of accuracy of the reconstruction at critical points. Please note +!! that the basic WENO approach is implemented according to the work +!! of Jiang and Shu (1996). WENO-Z, which is less dissipative than +!! WENO-JS and WENO-M, is implemented according to the work of +!! Borges, et al. (2008). TENO, which is even less dissipative than +!! WENO-Z but is less robust, is implemented according to the work +!! of Fu et al. (2016). module m_weno use m_derived_types !< Definitions of the derived types @@ -25,7 +25,7 @@ module m_weno use m_variables_conversion !< State variables type conversion procedures - ! + ! $:USE_GPU_MODULE() use m_mpi_proxy @@ -34,24 +34,24 @@ module m_weno private; public :: s_initialize_weno_module, s_initialize_weno, s_finalize_weno_module, s_weno !> @name The cell-average variables that will be WENO-reconstructed. Formerly, they - !! in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR - !! be reshaped (RS) and/or characteristically decomposed. The reshaping - !! WENO procedure to be independent of the coordinate direction of - !! Lastly, notice that the left (L) and right (R) results - !! characteristic decomposition are stored in custom-constructed WENO- - !! that are annexed to each position of a given scalar field. + !! are stored in v_vf. However, they are transferred to v_rs_wsL and v_rs_wsR + !! as to be reshaped (RS) and/or characteristically decomposed. The reshaping + !! allows the WENO procedure to be independent of the coordinate direction of + !! the reconstruction. Lastly, notice that the left (L) and right (R) results + !! of the characteristic decomposition are stored in custom-constructed WENO- + !! stencils (WS) that are annexed to each position of a given scalar field. !> @{ real(wp), allocatable, dimension(:, :, :, :) :: v_rs_ws_x, v_rs_ws_y, v_rs_ws_z !> @} $:GPU_DECLARE(create='[v_rs_ws_x,v_rs_ws_y,v_rs_ws_z]') - ! Coefficients + ! WENO Coefficients !> @name Polynomial coefficients at the left and right cell-boundaries (CB) and at - !! and right quadrature points (QP), in the x-, y- and z-directions. - !! the first dimension of the array identifies the polynomial, the - !! identifies the position of its coefficients and the last - !! the cell-location in the relevant coordinate direction. + !! the left and right quadrature points (QP), in the x-, y- and z-directions. + !! Note that the first dimension of the array identifies the polynomial, the + !! second dimension identifies the position of its coefficients and the last + !! dimension denotes the cell-location in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :, :) :: poly_coef_cbL_x real(wp), target, allocatable, dimension(:, :, :) :: poly_coef_cbL_y @@ -64,9 +64,9 @@ module m_weno $:GPU_DECLARE(create='[poly_coef_cbR_x,poly_coef_cbR_y,poly_coef_cbR_z]') !> @name The ideal weights at the left and the right cell-boundaries and at the - !! the right quadrature points, in x-, y- and z-directions. Note - !! first dimension of the array identifies the weight, while the - !! the cell-location in the relevant coordinate direction. + !! left and the right quadrature points, in x-, y- and z-directions. Note + !! that the first dimension of the array identifies the weight, while the + !! last denotes the cell-location in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :) :: d_cbL_x real(wp), target, allocatable, dimension(:, :) :: d_cbL_y @@ -79,9 +79,9 @@ module m_weno $:GPU_DECLARE(create='[d_cbL_x,d_cbL_y,d_cbL_z,d_cbR_x,d_cbR_y,d_cbR_z]') !> @name Smoothness indicator coefficients in the x-, y-, and z-directions. Note - !! first array dimension identifies the smoothness indicator, the - !! the position of its coefficients and the last denotes - !! in the relevant coordinate direction. + !! that the first array dimension identifies the smoothness indicator, the + !! second identifies the position of its coefficients and the last denotes + !! the cell-location in the relevant coordinate direction. !> @{ real(wp), target, allocatable, dimension(:, :, :) :: beta_coef_x real(wp), target, allocatable, dimension(:, :, :) :: beta_coef_y @@ -89,7 +89,7 @@ module m_weno !> @} $:GPU_DECLARE(create='[beta_coef_x,beta_coef_y,beta_coef_z]') - ! WENO Coefficients + ! END: WENO Coefficients integer :: v_size !< Number of WENO-reconstructed cell-average variables $:GPU_DECLARE(create='[v_size]') @@ -106,13 +106,13 @@ module m_weno contains !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are necessary to setup the module. + !! the association of pointers and/or the execution of any + !! other procedures that are necessary to setup the module. impure subroutine s_initialize_weno_module if (weno_order == 1) return - ! WENO Coefficients in x-direction + ! Allocating/Computing WENO Coefficients in x-direction is1_weno%beg = -buff_size; is1_weno%end = m - is1_weno%beg if (n == 0) then is2_weno%beg = 0 @@ -140,15 +140,15 @@ contains @:ALLOCATE(beta_coef_x(is1_weno%beg + weno_polyn:is1_weno%end - weno_polyn, 0:weno_polyn, & 0:weno_polyn*(weno_polyn + 1)/2 - 1)) - ! of cross terms for dvd = (k-1)(k-1+1)/2, where weno_polyn = k-1 - ! k-1 not k because we are using value differences (dvd) not the values themselves + ! Number of cross terms for dvd = (k-1)(k-1+1)/2, where weno_polyn = k-1 + ! Note: k-1 not k because we are using value differences (dvd) not the values themselves call s_compute_weno_coefficients(1, is1_weno) @:ALLOCATE(v_rs_ws_x(is1_weno%beg:is1_weno%end, & is2_weno%beg:is2_weno%end, is3_weno%beg:is3_weno%end, 1:sys_size)) - ! WENO Coefficients in y-direction + ! Allocating/Computing WENO Coefficients in y-direction if (n == 0) return is2_weno%beg = -buff_size; is2_weno%end = n - is2_weno%beg @@ -178,7 +178,7 @@ contains @:ALLOCATE(v_rs_ws_y(is2_weno%beg:is2_weno%end, & is1_weno%beg:is1_weno%end, is3_weno%beg:is3_weno%end, 1:sys_size)) - ! WENO Coefficients in z-direction + ! Allocating/Computing WENO Coefficients in z-direction if (p == 0) return is2_weno%beg = -buff_size; is2_weno%end = n - is2_weno%beg @@ -204,12 +204,12 @@ contains end subroutine s_initialize_weno_module !> The purpose of this subroutine is to compute the grid - !! of the WENO polynomials, ideal - !! smoothness indicators, provided the order, - !! direction and the location of the WENO - !! - !! Coordinate direction of the WENO reconstruction - !! Index bounds in the s-direction + !! dependent coefficients of the WENO polynomials, ideal + !! weights and smoothness indicators, provided the order, + !! the coordinate direction and the location of the WENO + !! reconstruction. + !! @param weno_dir Coordinate direction of the WENO reconstruction + !! @param is Index bounds in the s-direction subroutine s_compute_weno_coefficients(weno_dir, is) integer, intent(in) :: weno_dir @@ -217,7 +217,7 @@ contains integer :: s real(wp), pointer, dimension(:) :: s_cb => null() !< - !! in the s-direction + !! Cell-boundary locations in the s-direction type(int_bounds_info) :: bc_s !< Boundary conditions (BC) in the s-direction @@ -226,9 +226,9 @@ contains real(wp) :: w(1:8) ! Intermediate var for ideal weights: s_cb across overall stencil real(wp) :: y(1:4) ! Intermediate var for poly & beta: diff(s_cb) across sub-stencil - ! the number of cells, the cell-boundary locations and - ! boundary conditions in the coordinate direction selected for - ! WENO reconstruction + ! Determining the number of cells, the cell-boundary locations and + ! the boundary conditions in the coordinate direction selected for + ! the WENO reconstruction if (weno_dir == 1) then s = m; s_cb => x_cb; bc_s = bc_x elseif (weno_dir == 2) then @@ -238,7 +238,7 @@ contains end if #:for WENO_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')] - ! WENO3 Coefficients + ! Computing WENO3 Coefficients if (weno_dir == ${WENO_DIR}$) then if (weno_order == 3) then do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn @@ -266,10 +266,10 @@ contains end do - ! the ideal weights coefficients in the neighborhood - ! beginning and end Riemann state extrapolation BC to avoid - ! contributions from outside of the physical domain during - ! WENO reconstruction + ! Modifying the ideal weights coefficients in the neighborhood + ! of beginning and end Riemann state extrapolation BC to avoid + ! any contributions from outside of the physical domain during + ! the WENO reconstruction if (null_weights) then if (bc_s%beg == BC_RIEMANN_EXTRAP) then d_cbR_${XYZ}$ (1, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp @@ -281,9 +281,9 @@ contains d_cbL_${XYZ}$ (0, s) = 0._wp; d_cbL_${XYZ}$ (1, s) = 1._wp end if end if - ! Computing WENO3 Coefficients + ! END: Computing WENO3 Coefficients - ! WENO5 Coefficients + ! Computing WENO5 Coefficients elseif (weno_order == 5) then do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn @@ -412,10 +412,10 @@ contains end do - ! the ideal weights coefficients in the neighborhood - ! beginning and end Riemann state extrapolation BC to avoid - ! contributions from outside of the physical domain during - ! WENO reconstruction + ! Modifying the ideal weights coefficients in the neighborhood + ! of beginning and end Riemann state extrapolation BC to avoid + ! any contributions from outside of the physical domain during + ! the WENO reconstruction if (null_weights) then if (bc_s%beg == BC_RIEMANN_EXTRAP) then d_cbR_${XYZ}$ (1:2, 0) = 0._wp; d_cbR_${XYZ}$ (0, 0) = 1._wp @@ -438,16 +438,16 @@ contains do i = is%beg - 1 + weno_polyn, is%end - 1 - weno_polyn - ! Shu (1997) "Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory Schemes for Hyperbolic Conservation Laws" - ! 2.20: Polynomial Coefficients (poly_coef_cb) - ! 2.61: Smoothness Indicators (beta_coef) - ! reduce computational cost, we leverage the fact that all polynomial coefficients in a stencil sum to 1 - ! compute the polynomial coefficients (poly_coef_cb) for the cell value differences (dvd) instead of the values themselves. - ! computation of coefficients is further simplified by using grid spacing (y or w) rather than the grid locations (s_cb) directly. - ! weights (d_cb) are obtained by comparing the grid location coefficients of the polynomial coefficients. - ! smoothness indicators (beta_coef) are calculated through numerical differentiation and integration of each cross term of the polynomial coefficients, - ! the cell value differences (dvd) instead of the values themselves. - ! the polynomial coefficients sum to 1, the derivative of 1 is 0, which means it does not create additional cross terms in the smoothness indicators. + ! Reference: Shu (1997) "Essentially Non-Oscillatory and Weighted Essentially Non-Oscillatory Schemes for Hyperbolic Conservation Laws" + ! Equation 2.20: Polynomial Coefficients (poly_coef_cb) + ! Equation 2.61: Smoothness Indicators (beta_coef) + ! To reduce computational cost, we leverage the fact that all polynomial coefficients in a stencil sum to 1 + ! and compute the polynomial coefficients (poly_coef_cb) for the cell value differences (dvd) instead of the values themselves. + ! The computation of coefficients is further simplified by using grid spacing (y or w) rather than the grid locations (s_cb) directly. + ! Ideal weights (d_cb) are obtained by comparing the grid location coefficients of the polynomial coefficients. + ! The smoothness indicators (beta_coef) are calculated through numerical differentiation and integration of each cross term of the polynomial coefficients, + ! using the cell value differences (dvd) instead of the values themselves. + ! While the polynomial coefficients sum to 1, the derivative of 1 is 0, which means it does not create additional cross terms in the smoothness indicators. w = s_cb(i - 3:i + 4) - s_cb(i) ! Offset using s_cb(i) to reduce floating point error d_cbR_${XYZ}$ (0, i + 1) = ((w(5) - w(6))*(w(5) - w(7))*(w(5) - w(8)))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))) !& @@ -460,7 +460,7 @@ contains d_cbL_${XYZ}$ (1, i + 1) = ((w(1) - w(5))*(w(2) - w(5))*(w(5) - w(8))*(w(1)*w(2) + w(1)*w(3) + w(2)*w(3) - w(1)*w(7) - w(1)*w(8) - w(2)*w(7) - w(2)*w(8) - w(3)*w(7) - w(3)*w(8) + w(7)*w(8) + w(7)**2 + w(8)**2))/((w(1) - w(7))*(w(1) - w(8))*(w(2) - w(7))*(w(2) - w(8))*(w(3) - w(8))) !& d_cbL_${XYZ}$ (2, i + 1) = ((w(1) - w(5))*(w(5) - w(7))*(w(5) - w(8))*(w(1)*w(2) - w(1)*w(6) - w(1)*w(7) - w(2)*w(6) - w(1)*w(8) - w(2)*w(7) - w(2)*w(8) + w(6)*w(7) + w(6)*w(8) + w(7)*w(8) + w(1)**2 + w(2)**2))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))*(w(2) - w(7))*(w(2) - w(8))) !& d_cbL_${XYZ}$ (3, i + 1) = ((w(5) - w(6))*(w(5) - w(7))*(w(5) - w(8)))/((w(1) - w(6))*(w(1) - w(7))*(w(1) - w(8))) !& - ! Left has the reversed order of both points and coefficients compared to the right + ! Note: Left has the reversed order of both points and coefficients compared to the right y = s_cb(i + 1:i + 4) - s_cb(i:i + 3) poly_coef_cbR_${XYZ}$ (i + 1, 0, 0) = (y(1)*y(2)*(y(2) + y(3)))/((y(3) + y(4))*(y(2) + y(3) + y(4))*(y(1) + y(2) + y(3) + y(4))) !& @@ -503,7 +503,7 @@ contains poly_coef_cbL_${XYZ}$ (i + 1, 0, 0) = (y(4)*(y(3) + y(4))*(y(2) + y(3) + y(4)))/((y(1) + y(2))*(y(1) + y(2) + y(3))*(y(1) + y(2) + y(3) + y(4))) !& poly_coef_cbL_${XYZ}$ (i + 1, :, :) = -poly_coef_cbL_${XYZ}$ (i + 1, :, :) - ! negative sign as the direction of taking the difference (dvd) is reversed + ! Note: negative sign as the direction of taking the difference (dvd) is reversed y = s_cb(i - 2:i + 1) - s_cb(i - 3:i) beta_coef_${XYZ}$ (i + 1, 3, 0) = (4*y(4)**2*(5*y(1)**2*y(2)**2 + 20*y(1)**2*y(2)*y(3) + 15*y(1)**2*y(2)*y(4) + 20*y(1)**2*y(3)**2 + 30*y(1)**2*y(3)*y(4) + 60*y(1)**2*y(4)**2 + 10*y(1)*y(2)**3 + 60*y(1)*y(2)**2*y(3) + 45*y(1)*y(2)**2*y(4) + 110*y(1)*y(2)*y(3)**2 + 165*y(1)*y(2)*y(3)*y(4) & !& @@ -604,7 +604,7 @@ contains end do else ! TENO (only supports uniform grid) - ! et al., 2016) Table 2 (for right flux) + ! (Fu, et al., 2016) Table 2 (for right flux) d_cbL_${XYZ}$ (0, :) = 18._wp/35._wp d_cbL_${XYZ}$ (1, :) = 3._wp/35._wp d_cbL_${XYZ}$ (2, :) = 9._wp/35._wp @@ -631,7 +631,7 @@ contains $:GPU_UPDATE(device='[poly_coef_cbL_z,poly_coef_cbR_z,d_cbL_z,d_cbR_z,beta_coef_z]') end if - ! WENO coefficients and cell-boundary locations pointers + ! Nullifying WENO coefficients and cell-boundary locations pointers nullify (s_cb) @@ -728,7 +728,7 @@ contains do k = is2_weno%beg, is2_weno%end do j = is1_weno%beg, is1_weno%end do i = 1, v_size - ! from left side + ! reconstruct from left side alpha(:) = 0._wp omega(:) = 0._wp @@ -759,7 +759,7 @@ contains *(omega(0:weno_num_stencils)/(d_cbL_${XYZ}$ (0:weno_num_stencils, j)**2._wp + omega(0:weno_num_stencils)*(1._wp - 2._wp*d_cbL_${XYZ}$ (0:weno_num_stencils, j)))) elseif (wenoz) then - ! et al. (2008) + ! Borges, et al. (2008) tau = abs(beta(1) - beta(0)) alpha(0:weno_num_stencils) = d_cbL_${XYZ}$ (0:weno_num_stencils, j)*(1._wp + tau/beta(0:weno_num_stencils)) @@ -770,7 +770,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, i) = omega(0)*poly(0) + omega(1)*poly(1) - ! from right side + ! reconstruct from right side poly(0) = v_rs_ws_${XYZ}$ (j, k, l, i) & + poly_coef_cbR_${XYZ}$ (j, 0, 0)*dvd(0) @@ -814,7 +814,7 @@ contains do j = is1_weno%beg, is1_weno%end $:GPU_LOOP(parallelism='[seq]') do i = 1, v_size - ! from left side + ! reconstruct from left side alpha(:) = 0._wp omega(:) = 0._wp @@ -864,7 +864,7 @@ contains elseif (wenoz) then - ! et al. (2008) + ! Borges, et al. (2008) tau = abs(beta(2) - beta(0)) ! Equation 25 $:GPU_LOOP(parallelism='[seq]') @@ -873,8 +873,8 @@ contains end do elseif (teno) then - ! et al. (2016) - ! code: https://dx.doi.org/10.13140/RG.2.2.36250.34247 + ! Fu, et al. (2016) + ! Fu''s code: https://dx.doi.org/10.13140/RG.2.2.36250.34247 tau = abs(beta(2) - beta(0)) $:GPU_LOOP(parallelism='[seq]') do q = 0, weno_num_stencils @@ -898,7 +898,7 @@ contains vL_rs_vf_${XYZ}$ (j, k, l, i) = omega(0)*poly(0) + omega(1)*poly(1) + omega(2)*poly(2) - ! from right side + ! reconstruct from right side poly(0) = v_rs_ws_${XYZ}$ (j, k, l, i) & + poly_coef_cbR_${XYZ}$ (j, 0, 0)*dvd(1) & @@ -1002,11 +1002,11 @@ contains else #:if not MFC_CASE_OPTIMIZATION or weno_num_stencils > 3 - ! et al., 2016) Table 1 - ! Unlike TENO5, TENO7 stencils differ from WENO7 stencils - ! Figure 2 (right) for right-sided flux (at i+1/2) - ! we need the left-sided flux, so we flip the weights with respect to the x=i point - ! we need to keep the stencil order to reuse the beta coefficients + ! (Fu, et al., 2016) Table 1 + ! Note: Unlike TENO5, TENO7 stencils differ from WENO7 stencils + ! See Figure 2 (right) for right-sided flux (at i+1/2) + ! Here we need the left-sided flux, so we flip the weights with respect to the x=i point + ! But we need to keep the stencil order to reuse the beta coefficients poly(0) = ( 2._wp*v(-1) + 5._wp*v( 0) - 1._wp*v( 1)) / 6._wp !& poly(1) = (11._wp*v( 0) - 7._wp*v( 1) + 2._wp*v( 2)) / 6._wp !& poly(2) = (-1._wp*v(-2) + 5._wp*v(-1) + 2._wp*v( 0)) / 6._wp !& @@ -1051,7 +1051,7 @@ contains else ! TENO #:if not MFC_CASE_OPTIMIZATION or weno_num_stencils > 3 - ! Low-Dissipation Targeted ENO Schemes for Ideal Magnetohydrodynamics (Fu & Tang, 2019) Section 3.2 + ! High-Order Low-Dissipation Targeted ENO Schemes for Ideal Magnetohydrodynamics (Fu & Tang, 2019) Section 3.2 beta(0) = 13._wp/12._wp*(v(-1) - 2._wp*v( 0) + v( 1))**2._wp + (( v(-1) - v( 1))**2._wp)/4._wp + weno_eps !& beta(1) = 13._wp/12._wp*(v( 0) - 2._wp*v( 1) + v( 2))**2._wp + ((3._wp*v( 0) - 4._wp*v( 1) + v( 2))**2._wp)/4._wp + weno_eps !& beta(2) = 13._wp/12._wp*(v(-2) - 2._wp*v(-1) + v( 0))**2._wp + (( v(-2) - 4._wp*v(-1) + 3._wp*v( 0))**2._wp)/4._wp + weno_eps !& @@ -1080,8 +1080,8 @@ contains *(omega(0:weno_num_stencils)/(d_cbL_${XYZ}$ (0:weno_num_stencils, j)**2._wp + omega(0:weno_num_stencils)*(1._wp - 2._wp*d_cbL_${XYZ}$ (0:weno_num_stencils, j)))) elseif (wenoz) then - ! et al. (2010) - ! & Borges (2013) also helps + ! Castro, et al. (2010) + ! Don & Borges (2013) also helps tau = abs(beta(3) - beta(0)) ! Equation 50 $:GPU_LOOP(parallelism='[seq]') do q = 0, weno_num_stencils @@ -1196,17 +1196,17 @@ contains end subroutine s_weno !> The computation of parameters, the allocation of memory, - !! of pointers and/or the execution of any - !! that are required for the setup of the - !! - !! Cell-averaged variables - !! Left WENO reconstructed cell-boundary values - !! Right WENO reconstructed cell-boundary values - !! Characteristic decommposition coordinate direction - !! Coordinate direction of the WENO reconstruction - !! Index bounds in first coordinate direction - !! Index bounds in second coordinate direction - !! Index bounds in third coordinate direction + !! the association of pointers and/or the execution of any + !! other procedures that are required for the setup of the + !! WENO reconstruction. + !! @param v_vf Cell-averaged variables + !! @param vL_vf Left WENO reconstructed cell-boundary values + !! @param vR_vf Right WENO reconstructed cell-boundary values + !! @param norm_dir Characteristic decommposition coordinate direction + !! @param weno_dir Coordinate direction of the WENO reconstruction + !! @param is1_weno Index bounds in first coordinate direction + !! @param is2_weno Index bounds in second coordinate direction + !! @param is3_weno Index bounds in third coordinate direction subroutine s_initialize_weno(v_vf, & weno_dir) @@ -1216,11 +1216,11 @@ contains integer :: j, k, l, q - ! the number of cell-average variables which will be - ! and mapping their indical bounds in the x-, - ! and z-directions to those in the s1-, s2- and s3-directions - ! to reshape the inputted data in the coordinate direction of - ! WENO reconstruction + ! Determining the number of cell-average variables which will be + ! WENO-reconstructed and mapping their indical bounds in the x-, + ! y- and z-directions to those in the s1-, s2- and s3-directions + ! as to reshape the inputted data in the coordinate direction of + ! the WENO reconstruction v_size = ubound(v_vf, 1) $:GPU_UPDATE(device='[v_size]') @@ -1238,7 +1238,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! onto Characteristic Fields in y-direction + ! Reshaping/Projecting onto Characteristic Fields in y-direction if (n == 0) return if (weno_dir == 2) then @@ -1255,7 +1255,7 @@ contains $:END_GPU_PARALLEL_LOOP() end if - ! onto Characteristic Fields in z-direction + ! Reshaping/Projecting onto Characteristic Fields in z-direction if (p == 0) return if (weno_dir == 3) then @@ -1275,16 +1275,16 @@ contains end subroutine s_initialize_weno !> The goal of this subroutine is to ensure that the WENO - !! monotonic. The latter is achieved by - !! preserving bounds of Suresh and - !! The resulting MPWENO reconstruction, see - !! Shu (2000), ensures that the reconstructed - !! not reside outside the range spanned by WENO - !! - !! Equation number - !! First-coordinate cell index - !! Secone-coordinate cell index - !! Thire-coordinate cell index + !! reconstruction is monotonic. The latter is achieved by + !! enforcing monotonicity preserving bounds of Suresh and + !! Huynh (1997). The resulting MPWENO reconstruction, see + !! Balsara and Shu (2000), ensures that the reconstructed + !! values do not reside outside the range spanned by WENO + !! stencil. + !! @param i Equation number + !! @param j First-coordinate cell index + !! @param k Secone-coordinate cell index + !! @param l Thire-coordinate cell index subroutine s_preserve_monotonicity(v_rs_ws, vL_rs_vf, vR_rs_vf) real(wp), dimension(idwbuff(1)%beg:, idwbuff(2)%beg:, idwbuff(3)%beg:, 1:), intent(IN) :: v_rs_ws @@ -1295,11 +1295,11 @@ contains real(wp), dimension(-1:1) :: d !< Curvature measures at the zone centers real(wp) :: d_MD, d_LC !< - !! curvature and large curvature (LC) measures + !! Median (md) curvature and large curvature (LC) measures - ! left and right upper bounds (UL), medians, large curvatures, - ! and maxima of the WENO-reconstructed values of the cell- - ! variables. + ! The left and right upper bounds (UL), medians, large curvatures, + ! minima, and maxima of the WENO-reconstructed values of the cell- + ! average variables. real(wp) :: vL_UL, vR_UL real(wp) :: vL_MD, vR_MD real(wp) :: vL_LC, vR_LC @@ -1307,14 +1307,14 @@ contains real(wp) :: vL_max, vR_max real(wp), parameter :: alpha = 2._wp !> - !! maximum Courant–Friedrichs–Lewy (CFL) number that - !! utilized with the scheme. In theory, for stability, a CFL - !! than 1/(1+alpha) is necessary. The default value for - !! 2. + !! Determines the maximum Courant–Friedrichs–Lewy (CFL) number that + !! may be utilized with the scheme. In theory, for stability, a CFL + !! number less than 1/(1+alpha) is necessary. The default value for + !! alpha is 2. real(wp), parameter :: beta = 4._wp/3._wp !< - !! amount of freedom available from utilizing a large - !! the local curvature. The default value for beta is 4/3. + !! Determines the amount of freedom available from utilizing a large + !! value for the local curvature. The default value for beta is 4/3. real(wp), parameter :: alpha_mp = 2._wp real(wp), parameter :: beta_mp = 4._wp/3._wp @@ -1380,9 +1380,9 @@ contains + sign(5.e-1_wp, vL_max - vL_rs_vf(j, k, l, i))) & *min(abs(vL_min - vL_rs_vf(j, k, l, i)), & abs(vL_max - vL_rs_vf(j, k, l, i))) - ! Left Monotonicity Preserving Bound + ! END: Left Monotonicity Preserving Bound - ! Monotonicity Preserving Bound + ! Right Monotonicity Preserving Bound d(-1) = v_rs_ws(j, k, l, i) & + v_rs_ws(j - 2, k, l, i) & - v_rs_ws(j - 1, k, l, i) & @@ -1439,7 +1439,7 @@ contains + sign(5.e-1_wp, vR_max - vR_rs_vf(j, k, l, i))) & *min(abs(vR_min - vR_rs_vf(j, k, l, i)), & abs(vR_max - vR_rs_vf(j, k, l, i))) - ! Right Monotonicity Preserving Bound + ! END: Right Monotonicity Preserving Bound end do end do end do @@ -1453,17 +1453,17 @@ contains if (weno_order == 1) return - ! the WENO-stencil of the WENO-reconstructed variables + ! Deallocating the WENO-stencil of the WENO-reconstructed variables !deallocate(vL_rs_vf_x, vR_rs_vf_x) @:DEALLOCATE(v_rs_ws_x) - ! WENO coefficients in x-direction + ! Deallocating WENO coefficients in x-direction @:DEALLOCATE(poly_coef_cbL_x, poly_coef_cbR_x) @:DEALLOCATE(d_cbL_x, d_cbR_x) @:DEALLOCATE(beta_coef_x) - ! WENO coefficients in y-direction + ! Deallocating WENO coefficients in y-direction if (n == 0) return !deallocate(vL_rs_vf_y, vR_rs_vf_y) @@ -1473,7 +1473,7 @@ contains @:DEALLOCATE(d_cbL_y, d_cbR_y) @:DEALLOCATE(beta_coef_y) - ! WENO coefficients in z-direction + ! Deallocating WENO coefficients in z-direction if (p == 0) return !deallocate(vL_rs_vf_z, vR_rs_vf_z) diff --git a/src/simulation/p_main.fpp b/src/simulation/p_main.fpp index ba3aa3235b..e65722e191 100644 --- a/src/simulation/p_main.fpp +++ b/src/simulation/p_main.fpp @@ -1,17 +1,17 @@ !> -!! -!! program p_main +!! @file +!! @brief Contains program p_main !> @brief Quasi-conservative, shock- and interface- capturing finite-volume -!! the multicomponent Navier-Stokes equations. The system -!! with the relevant advection equations to capture the -!! and closed by the stiffened equation of state -!! as any required mixture relations. The effects of surface -!! included and modeled through a volume force that acts -!! diffuse material interface regions. The implementation -!! surface tension may be found in the work by Perigaud -!! (2005). Note that both viscous and capillarity effects -!! available in the volume fraction model. +!! scheme for the multicomponent Navier-Stokes equations. The system +!! is augmented with the relevant advection equations to capture the +!! material interfaces and closed by the stiffened equation of state +!! as well as any required mixture relations. The effects of surface +!! tension are included and modeled through a volume force that acts +!! across the diffuse material interface regions. The implementation +!! specifics of surface tension may be found in the work by Perigaud +!! and Saurel (2005). Note that both viscous and capillarity effects +!! are only available in the volume fraction model. program p_main use m_global_parameters !< Definitions of the global parameters @@ -54,7 +54,7 @@ program p_main call s_initialize_gpu_vars() call nvtxEndRange - ! the time-step iterator to the first time-step + ! Setting the time-step iterator to the first time-step if (cfl_dt) then t_step = 0 mytime = t_save*n_start @@ -71,7 +71,7 @@ program p_main call nvtxEndRange ! INIT call nvtxStartRange("SIMULATION-TIME-MARCH") - ! Loop + ! Time-stepping Loop do if (cfl_dt) then