-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,877 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
# **Problem Description** | ||
|
||
Solve the same problem as in [fluid/pipe_RCR_3d](../pipe_RCR_3D). Instead of using the RCR within the `svFSIplus` solver, this example demonstrates how to set up RCR boundary condition in a more generalized framework using sv0DSolver. | ||
|
||
## Introduction | ||
|
||
Both sv0DSolver and genBC (see [pipe_RCR_genBC](../pipe_RCR_genBC)) provide a framework to programmatically define custom inflow and outflow boundary conditions for a CFD simulation. The framework allows users to create an arbitrary lumped parameter network (LPN, or 0D model) layout suitable for their application. Some common examples include a lumped parameter heart model that models contraction of the heart chambers to use as an inlet boundary condition, sophisticated models of the downstream circulation for various areas of the body such as the legs and upper body, or a closed-loop formulation where all outflow of the SimVascular model returns back to the inflow after passing through the veins, heart, and pulmonary arteries. | ||
|
||
**Essentially, sv0D and genBC are two different implementations of the same functionality, and sv0D is the preferred choice.** genBC is a legacy code developed for [svSolver](https://github.com/SimVascular/svSolver) and requires direct input of a system of equations. sv0DSolver has pre-defined blocks with associated equations and is more user-friendly. Still, `svFSIplus` provides backward compatibility for genBC so that svSolver users can migrate to the new solver easily. | ||
|
||
## Configuration of genBC | ||
|
||
There are excellent tutorials online that show the users how to set up genBC step-by-step. | ||
SimVascular website: https://simvascular.github.io/docsGenBC.html | ||
Youtube tutorial: https://www.youtube.com/watch?v=znfV0XLV79s&ab_channel=SimVascular | ||
|
||
**We strongly encourage users to go through these tutorials first to become familiar with the concept and the workflow.** | ||
|
||
The input file [svFSI_genBC.inp](./svFSI_genBC.inp) follows the master input file as a template. Some specific input options are discussed below: | ||
|
||
``` | ||
<Couple_to_genBC type="SI"> | ||
<ZeroD_code_file_path> genBC/genBC.exe </ZeroD_code_file_path> | ||
</Couple_to_genBC> | ||
``` | ||
|
||
This tells the solver that the 0d models will be calculated through genBC. Options to couple 0D codes with svFSI are `N`: none; `I`: implicit; `SI`: semi-implicit; `E`: explicit. | ||
|
||
``` | ||
<Add_BC name="lumen_inlet" > | ||
<Type> Dir </Type> | ||
<Time_dependence> Unsteady </Time_dependence> | ||
<Temporal_values_file_path> lumen_inlet.flw</Temporal_values_file_path> | ||
<Zero_out_perimeter> true </Zero_out_perimeter> | ||
<Impose_flux> true </Impose_flux> | ||
</Add_BC> | ||
<Add_BC name="lumen_outlet" > | ||
<Type> Neu </Type> | ||
<Time_dependence> Coupled </Time_dependence> | ||
</Add_BC> | ||
``` | ||
|
||
In this example, we use the LPN for just the outlet RCR boundary condition and use a file to specify the inlet flow conditions. | ||
|
||
### Matching faces between 3D and 0D | ||
|
||
In genBC, user has to provide face tags in the USER.f file and make sure that these tags match the ones in solver.inp file for svSolver. In essence, when using genBC, it is the user's responsibility to match both the bcs provided in the svPresolver and svSolver files, and also in the USER.f file. | ||
|
||
### Implementation of 0D model | ||
|
||
The 0D model or LPN is defined in USER.f. Here are the boundary conditions implemented in genBC: | ||
|
||
```fortran | ||
! BC | ||
Rp = 121D0 | ||
C = 1.5D-4 | ||
Rd = 1212D0 | ||
f(1) = (1D0/C) * (Q(1) - x(1)/Rd) | ||
offset(1) = Q(1)*Rp | ||
! Assign the additional parameters to be printed | ||
Xprint(1)=t | ||
Xprint(2)= Q(1) | ||
Xprint(3) = offset(1) | ||
``` | ||
|
||
Here, we specify the RCR boundary used at the outlet, with the corresponding formulation defined in `f(1)`. | ||
|
||
In genBC, `Q(:)` and `P(:)` are defined as flow rates of Neumann faces and pressure of Dirichlet faces, respectively. It is the user's responsibility to carefully match the component `Q(i)` to the corresponding face, which can be error-prone when the number of faces are large. On the other hand, in cplBC, `Q(i)` simply represents the flow rate on the ith face. | ||
|
||
|
||
### Outputs from 0D model | ||
|
||
genBC writes out the results in `AllData` in the current folder, and it includes all the unknowns and the user-specified outputs. In this case, the order will be | ||
|
||
``` | ||
outlet_pressure time outlet_flux offset(1) | ||
``` | ||
|
||
Here, the last three are user-defined outputs. | ||
|
||
### Initial conditions | ||
|
||
In genBC, the initial conditions are specified in USER.f through variable `tZeroX`. Hence, user needs to recompile genBC every time it changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# | ||
# Copyright (c) Stanford University, The Regents of the University of | ||
# California, and others. | ||
# | ||
# All Rights Reserved. | ||
# | ||
# See Copyright-SimVascular.txt for additional details. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject | ||
# to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
#-------------------------------------------------------------------- | ||
# | ||
# This is the Makefile to build GenBC. | ||
# | ||
#-------------------------------------------------------------------- | ||
|
||
# HERE COMES THE DEFINITION | ||
|
||
include Makefile.in | ||
|
||
INCLUDES = -I./include | ||
|
||
MYFUN = Modules.f \ | ||
USER.f \ | ||
GenBC.f | ||
|
||
GenBC_EXE = genBC.exe | ||
|
||
DSYM_DIR = | ||
ifeq ($(debug),1) | ||
ifeq ($(OS),Darwin) | ||
DSYM_DIR = $(GenBC_EXE).dSYM | ||
endif | ||
endif | ||
############################################################################# | ||
# AND HERE ARE THE RULES | ||
|
||
SRC = $(patsubst %,$(SRC_DIR)/%,$(MYFUN)) | ||
OBJ = $(patsubst %.f,$(OBJ_DIR)/%.o,$(MYFUN)) | ||
|
||
#.PHONY: $(TEST) | ||
#$(TEST): $(TEST:.exe=.f) $(GenBC_EXE) | ||
# $(FORTRAN) $< $(FFLAGS) $(INCLUDES) -o $@ | ||
|
||
.PHONY: $(GenBC_EXE) | ||
$(GenBC_EXE): $(OBJ) | ||
$(FORTRAN) $(OBJ) $(FFLAGS) -o $@ | ||
|
||
$(OBJ): | $(OBJ_DIR) | ||
|
||
$(OBJ_DIR): | ||
mkdir -p $@ | ||
|
||
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.f | ||
$(FORTRAN) $(FFLAGS) $(INCLUDES) -c $< -o $@ | ||
|
||
clean: | ||
rm -r -f $(OBJ_DIR) $(GenBC_EXE) $(TEST) $(DSYM_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# | ||
# Copyright (c) Stanford University, The Regents of the University of | ||
# California, and others. | ||
# | ||
# All Rights Reserved. | ||
# | ||
# See Copyright-SimVascular.txt for additional details. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject | ||
# to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
#-------------------------------------------------------------------- | ||
# | ||
# This is the definitions for building process. | ||
# | ||
#-------------------------------------------------------------------- | ||
|
||
|
||
.SUFFIXES: .f .o | ||
|
||
OS:= $(shell uname) | ||
|
||
AR = ar rv | ||
RANLIB = ar -ts | ||
|
||
CFLAGS = -O3 -DAdd_ | ||
CXXFLAGS = -O3 -std=c++11 | ||
FFLAGS = -O3 -cpp | ||
FCFLAGS = -lstdc++ -cpp | ||
#FCFLAGS = -lc++ -cpp ## This may work if lstdc++ is not found | ||
OBJ_DIR = obj | ||
SRC_DIR = src | ||
|
||
MAKE_GUI = 0 | ||
|
||
debug = 0 | ||
ifeq ($(debug),1) | ||
CFLAGS = -O0 -DAdd_ | ||
CXXFLAGS = -O0 -std=c++11 | ||
FFLAGS = -O0 -cpp | ||
endif | ||
|
||
seq = 1 | ||
ifeq ($(seq),1) | ||
CC = gcc | ||
CXX = g++ | ||
FORTRAN = gfortran | ||
CFLAGS += -DSEQ | ||
else | ||
CC = mpicc | ||
CXX = mpicxx | ||
FORTRAN = mpif90 | ||
endif | ||
|
||
# ---------------------------------------------------------------- | ||
# Normally you would not need to change any line beyond this point | ||
# ---------------------------------------------------------------- | ||
|
||
# Here I am finding the compiler group | ||
ifeq ($(seq),1) | ||
F_COMP = $(FORTRAN) | ||
else | ||
F_COMP = $(firstword $(shell $(FORTRAN) -show)) | ||
endif | ||
ifeq ($(F_COMP),gfortran) | ||
COMP_GRP = gnu | ||
endif | ||
ifeq ($(F_COMP),gcc) | ||
COMP_GRP = gnu | ||
endif | ||
ifeq ($(F_COMP),g77) | ||
COMP_GRP = gnu | ||
endif | ||
ifeq ($(F_COMP),f95) | ||
COMP_GRP = gnu | ||
endif | ||
ifeq ($(F_COMP),ifort) | ||
COMP_GRP = intel | ||
endif | ||
ifeq ($(F_COMP),pgf90) | ||
COMP_GRP = pgi | ||
endif | ||
ifeq ($(F_COMP),pgf77) | ||
COMP_GRP = pgi | ||
endif | ||
|
||
ifeq ($(OS),Darwin) | ||
COMP_GRP = gnu | ||
endif | ||
|
||
# If profiling is requested | ||
prof = 0 | ||
ifeq ($(prof),1) | ||
FFLAGS += -pg -g | ||
endif | ||
|
||
# If debuging is requested | ||
ifeq ($(debug),1) | ||
ifeq ($(COMP_GRP),gnu) | ||
FFLAGS += -g -Wall -Wconversion -Wline-truncation -pedantic -fimplicit-none -fbacktrace -fbounds-check -p -fcheck=all #-ffpe-trap=invalid,zero,overflow,underflow | ||
CXXFLAGS += -g -Wall -pedantic -fbounds-check | ||
CFLAGS += -g -Wall -pedantic -fbounds-check | ||
endif | ||
ifeq ($(COMP_GRP),intel) | ||
FFLAGS += -g -traceback -check all -check bounds -check uninit -ftrapuv -debug all -fpe0 | ||
CFLAGS += -g -traceback -check-uninit -fpe0 | ||
CXXFLAGS += -g -traceback -check-uninit -fpe0 | ||
endif | ||
ifeq ($(COMP_GRP),pgi) | ||
FFLAGS += # You need to add debuging flag for pgi compiler here | ||
endif | ||
OBJ_DIR = dbg | ||
endif | ||
|
||
# If openMP parallelization is requested | ||
mp = 0 | ||
ifeq ($(mp),1) | ||
ifeq ($(COMP_GRP),gnu) | ||
FFLAGS += -fopenmp | ||
endif | ||
ifeq ($(COMP_GRP),intel) | ||
FFLAGS += -openmp | ||
endif | ||
ifeq ($(COMP_GRP),pgi) | ||
FFLAGS += -mp | ||
endif | ||
endif | ||
|
||
# To make directories a bit cleaner with intel compiler | ||
ifeq ($(COMP_GRP),intel) | ||
FFLAGS += -module $(OBJ_DIR) | ||
endif | ||
ifeq ($(COMP_GRP),gnu) | ||
FFLAGS += -J $(OBJ_DIR) | ||
CFLAGS += -J $(OBJ_DIR) | ||
CXXFLAGS += -J $(OBJ_DIR) | ||
endif | ||
|
||
#LAPACK Library | ||
ifeq ($(COMP_GRP),gnu) | ||
LAPACK_INC = | ||
LAPACK_LIB = | ||
LAPACK_LFLAGS = -llapack | ||
endif | ||
|
Oops, something went wrong.