Skip to content

Commit acc51f2

Browse files
hanzhao2020Han Zhaoaabrown100-git
authored
Adding unfitted resistive immersed surface (RIS) method functions (#421)
* Fixed spatial dimension bug in bw_fluid_3d and index error in set_bc_dir_wl * Adding explicit RIS code. * Updating output and restrat functions for explicit RIS * Adding an explicit RIS method test case * Adding implicit RIS functions for serial simulation. * Parallelization for implicit RIS code. * Adding RIS0D functions. * Fixed bugs for parallelization in implicit RIS code. * Fixed a bug in same_side function and cleaned up the code. * Improve the SDF function and add valve thickness and ressitance specification. * Fixed increments in saving ris surfaces. * Adding option for using customized resistance value whenthe RIS valve is closed. * Adding test for unfitted RIS valve * Adding test file for the unfitted RIS method * Resolving a double definition of bcast for int array * Fixed a bug in unfitted RIS valve test case * Fixed a bug in MPI_Bcast for int array --------- Co-authored-by: Han Zhao <[email protected]> Co-authored-by: Aaron Brown <[email protected]>
1 parent edee4b3 commit acc51f2

File tree

72 files changed

+4578
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4578
-55
lines changed

Code/Source/solver/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ set(CSRCS
207207
ustruct.h ustruct.cpp
208208
vtk_xml.h vtk_xml.cpp
209209
vtk_xml_parser.h vtk_xml_parser.cpp
210+
ris.h ris.cpp
211+
uris.h uris.cpp
210212

211213
CepMod.h CepMod.cpp
212214
CepModAp.h CepModAp.cpp

Code/Source/solver/CmMod.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ void cmType::bcast(const CmMod& cm_mod, Array<double>& data, const std::string&
138138
MPI_Bcast(data.data(), data.size(), cm_mod::mpreal, cm_mod.master, com());
139139
}
140140

141+
/// @brief bcast int array
142+
void cmType::bcast(const CmMod& cm_mod, Array<int>& data, const std::string& name) const
143+
{
144+
MPI_Bcast(data.data(), data.size(), cm_mod::mpint, cm_mod.master, com());
145+
}
146+
141147
/// @brief bcast double Vector
142148
void cmType::bcast(const CmMod& cm_mod, Vector<double>& data, const std::string& name) const
143149
{
@@ -155,12 +161,6 @@ void cmType::bcast(const CmMod& cm_mod, int* data) const
155161

156162
/// @brief bcast int Vector
157163
void cmType::bcast(const CmMod& cm_mod, Vector<int>& data) const
158-
{
159-
MPI_Bcast(data.data(), data.size(), cm_mod::mpint, cm_mod.master, com());
160-
}
161-
162-
/// @brief bcast int array
163-
void cmType::bcast(const CmMod& cm_mod, Array<int>& data, const std::string& name) const
164164
{
165165
MPI_Bcast(data.data(), data.size(), cm_mod::mpint, cm_mod.master, com());
166166
}

Code/Source/solver/ComMod.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ComMod::ComMod()
6161
pstEq = false;
6262
sstEq = false;
6363
ibFlag = false;
64+
risFlag = false;
6465

6566
}
6667

Code/Source/solver/ComMod.h

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class bcType
161161
// Robin: apply only in normal direction
162162
bool rbnN = false;
163163

164+
// Strong/Weak application of Dirichlet BC
165+
int clsFlgRis = 0;
166+
164167
// Pre/Res/Flat/Para... boundary types
165168
//
166169
// This stores differnt BCs as bitwise values.
@@ -194,6 +197,9 @@ class bcType
194197
// Robin: damping
195198
double c = 0.0;
196199

200+
// RIS0D: resistance
201+
double resistance = 0.0;
202+
197203
// Penalty parameters for weakly applied Dir BC
198204
Vector<double> tauB{0.0, 0.0};
199205
//double tauB[2];
@@ -961,6 +967,15 @@ class mshType
961967
/// @brief IB: Mesh size parameter
962968
double dx = 0.0;
963969

970+
/// @brief RIS resistance value
971+
double res = 0.0;
972+
973+
/// @brief RIS projection tolerance
974+
double tol = 0.0;
975+
976+
/// @brief The volume of this mesh
977+
double v = 0.0;
978+
964979
/// @breif ordering: node ordering for boundaries
965980
std::vector<std::vector<int>> ordering;
966981

@@ -1061,6 +1076,13 @@ class mshType
10611076
/// @brief IB: tracers
10621077
traceType trc;
10631078

1079+
/// @brief RIS: flags of whether elemets are adjacent to RIS projections
1080+
// std::vector<bool> eRIS;
1081+
Vector<int> eRIS;
1082+
1083+
/// @brief RIS: processor ids to change element partitions to
1084+
Vector<int> partRIS;
1085+
10641086
/// @brief TET4 quadrature modifier
10651087
double qmTET4 = (5.0+3.0*sqrt(5.0))/20.0;
10661088

@@ -1115,6 +1137,9 @@ class eqType
11151137
/// @brief IB: Number of possible outputs
11161138
int nOutIB = 0;
11171139

1140+
/// @brief URIS: Number of possible outputs
1141+
int nOutURIS = 0;
1142+
11181143
/// @brief Number of domains
11191144
int nDmn = 0;
11201145

@@ -1203,6 +1228,9 @@ class eqType
12031228
/// @brief IB: Outputs
12041229
std::vector<outputType> outIB;
12051230

1231+
/// @brief URIS: Outputs
1232+
std::vector<outputType> outURIS;
1233+
12061234
/// @brief Body force associated with this equation
12071235
std::vector<bfType> bf;
12081236
};
@@ -1400,6 +1428,113 @@ class ibType
14001428
ibCommType cm;
14011429
};
14021430

1431+
/// @brief Data type for Resistive Immersed Surface
1432+
//
1433+
class risFaceType
1434+
{
1435+
public:
1436+
1437+
/// @brief Number of RIS surface
1438+
int nbrRIS = 0;
1439+
1440+
/// @brief Count time steps where no check is needed
1441+
Vector<int> nbrIter;
1442+
1443+
/// @brief List of meshes, and faces connected. The first face is the
1444+
// proximal pressure's face, while the second is the distal one
1445+
Array3<int> lst;
1446+
1447+
/// @brief Resistance value
1448+
Vector<double> Res;
1449+
1450+
/// @brief Flag closed surface active, the valve is considerd open initially
1451+
std::vector<bool> clsFlg;
1452+
1453+
/// @brief Mean distal and proximal pressure (1: distal, 2: proximal)
1454+
Array<double> meanP;
1455+
1456+
/// @brief Mean flux on the RIS surface
1457+
Vector<double> meanFl;
1458+
1459+
/// @brief Status RIS interface
1460+
std::vector<bool> status;
1461+
};
1462+
1463+
/// @brief Unfitted Resistive Immersed surface data type
1464+
//
1465+
class urisType
1466+
{
1467+
public:
1468+
1469+
// Name of the URIS instance.
1470+
std::string name;
1471+
1472+
// Whether any file has been saved.
1473+
bool savedOnce = false;
1474+
1475+
// Total number of IB nodes.
1476+
int tnNo = 0;
1477+
1478+
// Number of IB meshes.
1479+
int nFa = 0;
1480+
1481+
// Position coordinates (2D array: rows x columns).
1482+
Array<double> x;
1483+
1484+
// Displacement (new) (2D array).
1485+
Array<double> Yd;
1486+
1487+
// Default signed distance value away from the valve.
1488+
double sdf_default = 10.0;
1489+
1490+
// Default distance value of the valve boundary (valve thickness).
1491+
double sdf_deps = 0.04;
1492+
1493+
// Default distance value of the valve boundary when the valve is closed.
1494+
double sdf_deps_close = 0.25;
1495+
1496+
// Displacements of the valve when it opens (3D array).
1497+
Array3<double> DxOpen;
1498+
1499+
// Displacements of the valve when it closes (3D array).
1500+
Array3<double> DxClose;
1501+
1502+
// Normal vector pointing in the positive flow direction (1D array).
1503+
Vector<double> nrm;
1504+
1505+
// Close flag.
1506+
bool clsFlg = true;
1507+
1508+
// Iteration count.
1509+
int cnt = 1000000;
1510+
1511+
// URIS: signed distance function of each node to the uris (1D array).
1512+
Vector<double> sdf;
1513+
1514+
// Mesh scale factor.
1515+
double scF = 1.0;
1516+
1517+
// Mean pressure upstream.
1518+
double meanPU = 0.0;
1519+
1520+
// Mean pressure downstream.
1521+
double meanPD = 0.0;
1522+
1523+
// Relaxation factor to compute weighted averages of pressure values.
1524+
double relax_factor = 0.5;
1525+
1526+
// Array to store the fluid mesh elements that the uris node is in (2D array).
1527+
Array<int> elemId;
1528+
1529+
// Array to count how many times a uris node is found in the fluid mesh of a processor (1D array).
1530+
Vector<int> elemCounter;
1531+
1532+
// Derived type variables
1533+
// IB meshes
1534+
std::vector<mshType> msh;
1535+
1536+
};
1537+
14031538
/// @brief The ComMod class duplicates the data structures in the Fortran COMMOD module
14041539
/// defined in MOD.f.
14051540
///
@@ -1470,9 +1605,29 @@ class ComMod {
14701605
/// @brief Postprocess step - convert bin to vtk
14711606
bool bin2VTK = false;
14721607

1608+
/// @brief Whether any RIS surface is considered
1609+
bool risFlag = false;
1610+
1611+
/// @brief Whether any one-sided RIS surface with 0D coupling is considered
1612+
bool ris0DFlag = false;
1613+
1614+
/// @brief Whether any URIS surface is considered
1615+
bool urisFlag = false;
1616+
1617+
/// @brief Whether the URIS surface is active
1618+
bool urisActFlag = false;
1619+
1620+
/// @brief Number of URIS surfaces (uninitialized, to be set later)
1621+
int nUris;
1622+
1623+
/// @brief URIS resistance
1624+
double urisRes;
1625+
1626+
/// @brief URIS resistance when the valve is closed
1627+
double urisResClose;
1628+
14731629
/// @brief Whether to use precomputed state-variable solutions
14741630
bool usePrecomp = false;
1475-
14761631
//----- int members -----//
14771632

14781633
/// @brief Current domain
@@ -1532,7 +1687,7 @@ class ComMod {
15321687
/// @brief Total number of degrees of freedom per node
15331688
int tDof = 0;
15341689

1535-
/// @brief Total number of nodes (total number of nodes on current processor across
1690+
/// @brief Total number of nodes (number of nodes on current proc across
15361691
/// all meshes)
15371692
int tnNo = 0;
15381693

@@ -1542,6 +1697,9 @@ class ComMod {
15421697
/// @brief Number of stress values to be stored
15431698
int nsymd = 0;
15441699

1700+
/// @brief Nbr of iterations
1701+
int RisnbrIter = 0;
1702+
15451703

15461704
//----- double members -----//
15471705

@@ -1601,6 +1759,18 @@ class ComMod {
16011759
/// @brief IB: iblank used for immersed boundaries (1 => solid, 0 => fluid)
16021760
Vector<int> iblank;
16031761

1762+
/// @brief TODO: for now, better to organize these within a class
1763+
struct Array2D {
1764+
// std::vector<std::vector<int>> map;
1765+
Array<int> map;
1766+
};
1767+
1768+
/// @brief RIS mapping array, with local (mesh) enumeration
1769+
std::vector<Array2D> risMapList;
1770+
1771+
/// @brief RIS mapping array, with global (total) enumeration
1772+
std::vector<Array2D> grisMapList;
1773+
16041774
/// @brief Old time derivative of variables (acceleration); known result at current time step
16051775
Array<double> Ao;
16061776

@@ -1692,6 +1862,12 @@ class ComMod {
16921862
/// @brief IB: Immersed boundary data structure
16931863
ibType ib;
16941864

1865+
/// @brief risFace object
1866+
risFaceType ris;
1867+
1868+
/// @brief unfitted RIS object
1869+
std::vector<urisType> uris;
1870+
16951871
bool debug_active = false;
16961872

16971873
Timer timer;

0 commit comments

Comments
 (0)