Skip to content

Commit

Permalink
Replace splatting by dispatch on availability of data record
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed May 25, 2020
1 parent 7811d32 commit 5bc58da
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/vfvm_testfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,9 @@ function integrate(this::AbstractSystem{Tv,Ti},tf::Vector{Tv},U::AbstractMatrix{
edge=Edge{Tv,Ti}(this)
data=this.physics.data
UKL=Array{Tv,2}(undef,nspecies,2)

nodeparams=(node,)
edgeparams=(edge,)

if isdata(data)
nodeparams=(node,data,)
edgeparams=(edge,data,)
end
UK=Array{Tv,1}(undef,nspecies)
UKold=Array{Tv,1}(undef,nspecies)


geom=grid[CellGeometries][1]
csys=grid[CoordinateSystem]
Expand All @@ -134,7 +129,11 @@ function integrate(this::AbstractSystem{Tv,Ti},tf::Vector{Tv},U::AbstractMatrix{
UKL[ispec,2]=U[ispec,edge.node[2]]
end
res.=0
@views this.physics.flux(res,UKL,edgeparams...)
if isdata(data)
this.physics.flux(res,UKL,edge,data)
else
this.physics.flux(res,UKL,edge)
end
for ispec=1:nspecies
if this.node_dof[ispec,edge.node[1]]==ispec && this.node_dof[ispec,edge.node[2]]==ispec
integral[ispec]+=this.celledgefactors[iedge,icell]*res[ispec]*(tf[edge.node[1]]-tf[edge.node[2]])
Expand All @@ -144,13 +143,23 @@ function integrate(this::AbstractSystem{Tv,Ti},tf::Vector{Tv},U::AbstractMatrix{

for inode=1:num_nodes(geom)
_fill!(node,cellnodes,cellregions,inode,icell)
@views begin
begin
res.=0
stor.=0
storold.=0
this.physics.reaction(res,U[:,node.index],nodeparams...)
this.physics.storage(stor,U[:,node.index],nodeparams...)
this.physics.storage(storold,Uold[:,node.index],nodeparams...)
for ispec=1:nspecies
UK[ispec]=U[ispec,node.index]
UKold[ispec]=Uold[ispec,node.index]
end
if isdata(data)
this.physics.reaction(res,UK,node,data)
this.physics.storage(stor,UK,node,data)
this.physics.storage(storold,UKold,node,data)
else
this.physics.reaction(res,UK,node)
this.physics.storage(stor,UK,node)
this.physics.storage(storold,UKold,node)
end
end
for ispec=1:nspecies
if this.node_dof[ispec,node.index]==ispec
Expand Down

0 comments on commit 5bc58da

Please sign in to comment.