svMultiPhysics
Loading...
Searching...
No Matches
svOneD_interface.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef SV1D_SUBROUTINES_H
5#define SV1D_SUBROUTINES_H
6
7#include "Simulation.h"
8#include "consts.h"
9#include "svOneD_interface/OneDSolverInterface.h"
10
11/**
12 * @namespace svOneD
13 * @brief 3D-1D coupling subroutines.
14 *
15 * These routines interface the 3D finite-element solver svMultiPhysics with
16 * the 1D blood-flow solver svOneDSolver via a dynamically loaded shared
17 * library, such as libsvOneDSolver_interface.so or libsvOneDSolver_interface.dylib.
18 *
19 * @par Coupling overview
20 * NEU coupling, where the 1D inlet is driven by the 3D outflow:
21 * - 3D to 1D: flow rate Q, passed through params[3] and params[4].
22 * - 1D to 3D: pressure P, returned through cpl_value.
23 * - 3D boundary condition: Neumann pressure traction.
24 *
25 * DIR coupling, where the 1D outlet is driven by the 3D pressure:
26 * - 3D to 1D: pressure P, passed through params[3] and params[4].
27 * - 1D to 3D: flow rate Q, returned through cpl_value.
28 * - 3D boundary condition: Dirichlet velocity profile.
29 *
30 * @par Parallelism model
31 * Unlike the 0D solver, which is solved once on the master rank, each 1D model
32 * is independent and has its own input file. Multiple 1D models are therefore
33 * read, initialized, and solved in parallel.
34 *
35 * Initialization in init_svOneD() has two phases:
36 * - Parallel initialization:
37 * - Collect all svOneD-coupled faces into a list indexed from 0 to N-1.
38 * - Assign face/model k to MPI rank k % nProcs.
39 * - Each rank reads and initializes only its owned model(s), with no MPI
40 * synchronization, so all ranks work simultaneously.
41 * - Batch metadata exchange:
42 * - After all ranks finish initializing their owned model(s), share
43 * system_size and coupled_dof via MPI_Bcast so that all ranks know the
44 * sizes needed for subsequent result broadcasts.
45 *
46 * Time stepping in calc_svOneD() also has two phases:
47 * - Parallel solve:
48 * - Each rank runs the 1D solve for its owned model(s), with no MPI calls,
49 * so different models can run concurrently on different ranks.
50 * - Batch result exchange:
51 * - After all ranks finish solving, results are shared via MPI_Bcast so that
52 * all ranks know each result and can update the corresponding coupled
53 * boundary condition value.
54 *
55 * @par Parameters passed to run_1d_simulation_step_1d_
56 * - params[0]: number of time points, currently 2.0.
57 * - params[1]: t_old, the time at the start of the step.
58 * - params[2]: t_new, the time at the end of the step.
59 * - params[3]: BC_val_old, the coupled Q or P value at t_old.
60 * - params[4]: BC_val_new, the coupled Q or P value at t_new.
61 */
62namespace svOneD {
63
64/// @brief Initialize the 1D solver and populate the initial cplBC state.
65/// Called once from baf_ini() after the BC data structures are set up.
66void init_svOneD(ComMod& com_mod, const CmMod& cm_mod);
67
68/// @brief Advance the 1D solver by one time step and update the coupled BC value.
69///
70/// @param BCFlag 'D' - derivative / perturbation step (state is NOT committed).
71/// 'L' - last Newton iteration (state IS committed, time advances).
72void calc_svOneD(ComMod& com_mod, const CmMod& cm_mod, char BCFlag);
73
74} // namespace svOneD
75
76#endif // SV1D_SUBROUTINES_H
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:36
The ComMod class duplicates the data structures in the Fortran COMMOD module defined in MOD....
Definition ComMod.h:1597
3D-1D coupling subroutines.
Definition svOneD_interface.cpp:22
void init_svOneD(ComMod &com_mod, const CmMod &cm_mod)
Initialize the 1D solver and populate the initial cplBC state. Called once from baf_ini() after the B...
Definition svOneD_interface.cpp:115
void calc_svOneD(ComMod &com_mod, const CmMod &cm_mod, char BCFlag)
Advance the 1D solver by one time step and update the coupled BC value.
Definition svOneD_interface.cpp:245