Skip to content

Commit

Permalink
back to 2016
Browse files Browse the repository at this point in the history
  • Loading branch information
alemelis committed Nov 21, 2023
1 parent 5c55589 commit ace8b42
Show file tree
Hide file tree
Showing 19 changed files with 4,166 additions and 2,042 deletions.
129 changes: 112 additions & 17 deletions main.jl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#=
Copyright 2022 INSIGNEO Institute for in silico Medicine
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=#


push!(LOAD_PATH, "./src2")
using openBF

parsed_args = openBF.parseCommandline()
Expand All @@ -26,4 +11,114 @@ conv_ceil = parsed_args["conv_ceil"]

openBF.runSimulation(input_filename, verbose=verbose, out_files=out_files, conv_ceil=conv_ceil)

rm("main.jl")
# rm("main.jl")

#-------------------------------------------
openBF.projectPreamble(project_name)

println("Load project $project_name files")
include(join([project_name, "_constants.jl"]))

model = openBF.readModelData(join([project_name, ".csv"]))

heart, blood_prop, total_time = openBF.loadGlobalConstants(project_name,
inlet_BC_switch, cycles, rho, mu, gamma_profile)

grafo = Graphs.simple_graph(length(model[:,1])+1)

vessels = [openBF.initialiseVessel(model[1,:], 1, heart, blood_prop,Pext,
initial_pressure, Ccfl)]

Graphs.add_edge!(grafo, vessels[1].sn, vessels[1].tn)

for i in 2:length(model[:,1])


push!(vessels, openBF.initialiseVessel(model[i,:], i, heart, blood_prop,Pext,
initial_pressure, Ccfl))

Graphs.add_edge!(grafo, vessels[end].sn, vessels[end].tn)
end


edgess = Graphs.edges(grafo)


println("Start simulation \n")
current_time = 0


dts = zeros(Float64, length(edgess))
dt = openBF.calculateDeltaT(vessels, dts)


prog = ProgressMeter.Progress(int(total_time/dt)*2, 1, "Running ", 50)


passed_cycles = 0

tic()
counter = 0
counter_v = 0
while true

dt = openBF.calculateDeltaT(vessels, dts)

if venous_model
dt_v = openBF.calculateDeltaT(vessels_v, dts_v)
dt = minimum([dt, dt_v])
end

current_time += dt


openBF.solveModel(grafo, edgess, vessels, heart,
blood_prop, dt, current_time)

openBF.updateGhostCells(vessels)

if counter == 100

openBF.saveTempData(current_time, vessels)
counter = 0
else
counter += 1
end

ProgressMeter.next!(prog)

if (current_time - heart.cardiac_T*passed_cycles) >= heart.cardiac_T &&
(current_time - heart.cardiac_T*passed_cycles + dt) > heart.cardiac_T

openBF.closeTempFiles(vessels)
openBF.transferLastToOut(vessels)
openBF.openCloseLastFiles(vessels)
openBF.transferTempToLast(vessels)
openBF.openTempFiles(vessels)


passed_cycles += 1

openBF.openCloseLastFiles(vessels)
openBF.transferTempToLast(vessels)
openBF.openTempFiles(vessels)
end

if current_time >= total_time

break
end
end
@printf "\n"
toc()


openBF.closeTempFiles(vessels)
openBF.transferTempToOut(vessels)

if venous_model
openBF.closeTempFiles(vessels_v)
openBF.transferTempToOut(vessels_v)
end

cd("..")
Loading

0 comments on commit ace8b42

Please sign in to comment.