Skip to content

Commit

Permalink
Merge pull request #197 from gridap/pending_work_in_trial_and_test_order
Browse files Browse the repository at this point in the history
Pending work in trial and test order
  • Loading branch information
fverdugo authored Feb 27, 2020
2 parents baa9bce + 504d344 commit 6f1b329
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 60 deletions.
6 changes: 3 additions & 3 deletions src/FESpaces/AffineFEOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ function AffineFEOperator(trial::FESpace,test::FESpace,assem::Assembler,terms::A

uhd = zero(trial)

matvecdata, matdata, vecdata = collect_cell_matrix_and_vector(v,u,uhd,terms)
matvecdata, matdata, vecdata = collect_cell_matrix_and_vector(uhd,u,v,terms)
A,b = assemble_matrix_and_vector(assem,matvecdata,matdata,vecdata)

#matdata = collect_cell_matrix(v,u,terms)
#vecdata = collect_cell_vector(v,uhd,terms)
#matdata = collect_cell_matrix(u,v,terms)
#vecdata = collect_cell_vector(uhd,v,terms)
#A = assemble_matrix(assem,matdata...)
#b = assemble_vector(assem,vecdata...)

Expand Down
8 changes: 4 additions & 4 deletions src/FESpaces/FEOperatorsFromTerms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ function allocate_jacobian(op::FEOperatorFromTerms,uh)
@assert is_a_fe_function(uh)
du = get_cell_basis(op.trial)
v = get_cell_basis(op.test)
_, cellidsrows, cellidscols = collect_cell_jacobian(uh,v,du,op.terms)
_, cellidsrows, cellidscols = collect_cell_jacobian(uh,du,v,op.terms)
allocate_matrix(op.assem, cellidsrows, cellidscols)
end

function jacobian!(A::AbstractMatrix,op::FEOperatorFromTerms,uh)
@assert is_a_fe_function(uh)
du = get_cell_basis(op.trial)
v = get_cell_basis(op.test)
cellmats, cellidsrows, cellidscols = collect_cell_jacobian(uh,v,du,op.terms)
cellmats, cellidsrows, cellidscols = collect_cell_jacobian(uh,du,v,op.terms)
assemble_matrix!(A,op.assem, cellmats, cellidsrows, cellidscols)
A
end
Expand All @@ -71,7 +71,7 @@ function residual_and_jacobian!(b::AbstractVector,A::AbstractMatrix,op::FEOperat
@assert is_a_fe_function(uh)
du = get_cell_basis(op.trial)
v = get_cell_basis(op.test)
data = collect_cell_jacobian_and_residual(uh,v,du,op.terms)
data = collect_cell_jacobian_and_residual(uh,du,v,op.terms)
assemble_matrix_and_vector!(A, b, op.assem,data...)
(b,A)
end
Expand All @@ -80,7 +80,7 @@ function residual_and_jacobian(op::FEOperatorFromTerms,uh)
@assert is_a_fe_function(uh)
du = get_cell_basis(op.trial)
v = get_cell_basis(op.test)
data = collect_cell_jacobian_and_residual(uh,v,du,op.terms)
data = collect_cell_jacobian_and_residual(uh,du,v,op.terms)
A, b = assemble_matrix_and_vector(op.assem,data...)
(b, A)
end
72 changes: 36 additions & 36 deletions src/FESpaces/FETerms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Returns an object representing
the contribution to the Jacobian of the given term. Returns nothing if the term
has not contribution to the Jacobian (typically for source terms)
"""
function get_cell_jacobian(t::FETerm,uh,v,du)
function get_cell_jacobian(t::FETerm,uh,du,v)
@abstractmethod
end

Expand All @@ -28,11 +28,11 @@ end

"""
"""
function get_cell_jacobian_and_residual(t::FETerm,uh,v,du)
function get_cell_jacobian_and_residual(t::FETerm,uh,du,v)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
celljac = get_cell_jacobian(t,uh,v,du)
celljac = get_cell_jacobian(t,uh,du,v)
cellres = get_cell_residual(t,uh,v)
_setup_jac_and_res(celljac,cellres)
end
Expand Down Expand Up @@ -68,7 +68,7 @@ Returns an object representing the contribution to the
system matrix of the given term. Returns nothing if the term has not
contribution (typically for source terms)
"""
function get_cell_matrix(t::AffineFETerm,v,u)
function get_cell_matrix(t::AffineFETerm,u,v)
@abstractmethod
end

Expand All @@ -77,7 +77,7 @@ Returns an object (e.g. a CellVector) representing the contribution to the
system rhs of the given term. Returns nothing if the term has not
contribution (typically for linear terms)
"""
function get_cell_vector(t::AffineFETerm,v,uhd)
function get_cell_vector(t::AffineFETerm,uhd,v)
@abstractmethod
end

Expand All @@ -91,20 +91,20 @@ function get_cell_values(t::FETerm,uhd)
@abstractmethod
end

function get_cell_jacobian(t::AffineFETerm,uh,v,du)
function get_cell_jacobian(t::AffineFETerm,uh,du,v)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
get_cell_matrix(t,v,du)
get_cell_matrix(t,du,v)
end

"""
"""
function get_cell_matrix_and_vector(t::AffineFETerm,v,u,uhd)
function get_cell_matrix_and_vector(t::AffineFETerm,uhd,u,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
cellmat = get_cell_matrix(t,v,u)
cellmat = get_cell_matrix(t,u,v)
cellvec = _get_cell_vector_tmp_hack(cellmat,t,v,uhd) #TODO
cellvals = get_cell_values(t,uhd)
_setup_cell_matrix_and_vector(cellmat,cellvec,cellvals)
Expand All @@ -116,7 +116,7 @@ function _get_cell_vector_tmp_hack(cellmat,t,v,uhd) #TODO
end

function _get_cell_vector_tmp_hack(cellmat::SkeletonCellMatrix,t,v,uhd) #TODO
cellvec = get_cell_vector(t,v,uhd)
cellvec = get_cell_vector(t,uhd,v)
cellvec
end

Expand Down Expand Up @@ -152,23 +152,23 @@ abstract type LinearFETerm <: AffineFETerm end
"""
abstract type FESource <: AffineFETerm end

function get_cell_matrix(t::FESource,v,u)
function get_cell_matrix(t::FESource,u,v)
nothing
end

# Working with a collection of FETerms

"""
"""
function collect_cell_jacobian(uh,v,du,terms)
function collect_cell_jacobian(uh,du,v,terms)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
w = []
r = []
c = []
for term in terms
cellvals = get_cell_jacobian(term,uh,v,du)
cellvals = get_cell_jacobian(term,uh,du,v)
cellids = get_cell_id(term)
_push_matrix_contribution!(w,r,c,cellvals,cellids)
end
Expand All @@ -177,14 +177,14 @@ end

"""
"""
function collect_cell_matrix(v,u,terms)
function collect_cell_matrix(u,v,terms)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
w = []
r = []
c = []
for term in terms
cellvals = get_cell_matrix(term,v,u)
cellvals = get_cell_matrix(term,u,v)
cellids = get_cell_id(term)
_push_matrix_contribution!(w,r,c,cellvals,cellids)
end
Expand All @@ -208,13 +208,13 @@ end

"""
"""
function collect_cell_vector(v,uhd,terms)
function collect_cell_vector(uhd,v,terms)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_function(uhd)
w = []
r = []
for term in terms
cellvals = get_cell_vector(term,v,uhd)
cellvals = get_cell_vector(term,uhd,v)
cellids = get_cell_id(term)
_push_vector_contribution!(w,r,cellvals,cellids)
end
Expand All @@ -223,7 +223,7 @@ end

"""
"""
function collect_cell_matrix_and_vector(v,u,uhd,terms)
function collect_cell_matrix_and_vector(uhd,u,v,terms)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
@assert is_a_fe_function(uhd)
Expand All @@ -233,7 +233,7 @@ function collect_cell_matrix_and_vector(v,u,uhd,terms)
vecdata = ([],[])

for term in terms
cellmatvec, cellmat, cellvec = get_cell_matrix_and_vector(term,v,u,uhd)
cellmatvec, cellmat, cellvec = get_cell_matrix_and_vector(term,uhd,u,v)
cellids = get_cell_id(term)
_push_matrix_contribution!(matvecdata...,cellmatvec,cellids)
_push_matrix_contribution!(matdata...,cellmat,cellids)
Expand All @@ -245,7 +245,7 @@ end

"""
"""
function collect_cell_jacobian_and_residual(uh,v,du,terms)
function collect_cell_jacobian_and_residual(uh,du,v,terms)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
Expand All @@ -255,7 +255,7 @@ function collect_cell_jacobian_and_residual(uh,v,du,terms)
vecdata = ([],[])

for term in terms
cellmatvec, cellmat, cellvec = get_cell_jacobian_and_residual(term,uh,v,du)
cellmatvec, cellmat, cellvec = get_cell_jacobian_and_residual(term,uh,du,v)
cellids = get_cell_id(term)
_push_matrix_contribution!(matvecdata...,cellmatvec,cellids)
_push_matrix_contribution!(matdata...,cellmat,cellids)
Expand Down Expand Up @@ -322,15 +322,15 @@ function AffineFETerm(
AffineFETermFromIntegration(biform,liform,trian,quad)
end

function get_cell_matrix(t::AffineFETermFromIntegration,v,u)
function get_cell_matrix(t::AffineFETermFromIntegration,u,v)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
_v = restrict(v,t.trian)
_u = restrict(u,t.trian)
integrate(t.biform(_u,_v),t.trian,t.quad)
end

function get_cell_vector(t::AffineFETermFromIntegration,v,uhd)
function get_cell_vector(t::AffineFETermFromIntegration,uhd,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
_v = restrict(v,t.trian)
Expand Down Expand Up @@ -377,11 +377,11 @@ function FESource(
FESourceFromIntegration(liform,trian,quad)
end

function get_cell_matrix(t::FESourceFromIntegration,v,u)
function get_cell_matrix(t::FESourceFromIntegration,u,v)
nothing
end

function get_cell_vector(t::FESourceFromIntegration,v,uhd)
function get_cell_vector(t::FESourceFromIntegration,uhd,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
_v = restrict(v,t.trian)
Expand Down Expand Up @@ -424,15 +424,15 @@ function LinearFETerm(
LinearFETermFromIntegration(biform,trian,quad)
end

function get_cell_matrix(t::LinearFETermFromIntegration,v,u)
function get_cell_matrix(t::LinearFETermFromIntegration,u,v)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
_v = restrict(v,t.trian)
_u = restrict(u,t.trian)
integrate(t.biform(_u,_v),t.trian,t.quad)
end

function get_cell_vector(t::LinearFETermFromIntegration,v,uhd)
function get_cell_vector(t::LinearFETermFromIntegration,uhd,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
_v = restrict(v,t.trian)
Expand Down Expand Up @@ -477,7 +477,7 @@ function FETerm(
NonLinearFETerm(res,jac,trian,quad)
end

function get_cell_jacobian(t::NonLinearFETerm,uh,v,du)
function get_cell_jacobian(t::NonLinearFETerm,uh,du,v)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
Expand Down Expand Up @@ -506,25 +506,25 @@ struct AffineFETermFromCellMatVec <: AffineFETerm
trian::Triangulation
end

function get_cell_matrix(t::AffineFETermFromCellMatVec,v,u)
function get_cell_matrix(t::AffineFETermFromCellMatVec,u,v)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
_v = restrict(v,t.trian)
_u = restrict(u,t.trian)
cellmatvec = t.matvecfun(_v,_u)
cellmatvec = t.matvecfun(_u,_v)
cellmat, _ = unpair_arrays(cellmatvec)
cellmat
end

function get_cell_vector(t::AffineFETermFromCellMatVec,v,uhd)
function get_cell_vector(t::AffineFETermFromCellMatVec,uhd,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
trial = TrialFESpace(get_fe_space(uhd))
u = get_cell_basis(trial)
_v = restrict(v,t.trian)
_u = restrict(u,t.trian)
_cellvals = get_cell_values(t,uhd)
cellmatvec = t.matvecfun(_v,_u)
cellmatvec = t.matvecfun(_u,_v)
cellmatvec_with_diri = attach_dirichlet_bcs(cellmatvec,_cellvals)
_, cellvec_with_diri = unpair_arrays(cellmatvec_with_diri)
cellvec_with_diri
Expand All @@ -545,14 +545,14 @@ function get_cell_values(t::AffineFETermFromCellMatVec,uhd)
reindex(cellvals,t.trian)
end

function get_cell_matrix_and_vector(t::AffineFETermFromCellMatVec,v,u,uhd)
function get_cell_matrix_and_vector(t::AffineFETermFromCellMatVec,uhd,u,v)
@assert is_a_fe_function(uhd)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(u)
_v = restrict(v,t.trian)
_u = restrict(u,t.trian)
_cellvals = get_cell_values(t,uhd)
cellmatvec = t.matvecfun(_v,_u)
cellmatvec = t.matvecfun(_u,_v)
cellmatvec_with_diri = attach_dirichlet_bcs(cellmatvec,_cellvals)
(cellmatvec_with_diri, nothing, nothing)
end
Expand All @@ -562,7 +562,7 @@ struct FETermFromCellJacRes <: FETerm
trian::Triangulation
end

function get_cell_jacobian(t::FETermFromCellJacRes,uh,v,du)
function get_cell_jacobian(t::FETermFromCellJacRes,uh,du,v)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
Expand Down Expand Up @@ -591,7 +591,7 @@ function get_cell_id(t::FETermFromCellJacRes)
get_cell_id(t.trian)
end

function get_cell_jacobian_and_residual(t::FETermFromCellJacRes,uh,v,du)
function get_cell_jacobian_and_residual(t::FETermFromCellJacRes,uh,du,v)
@assert is_a_fe_function(uh)
@assert is_a_fe_cell_basis(v)
@assert is_a_fe_cell_basis(du)
Expand Down
Loading

0 comments on commit 6f1b329

Please sign in to comment.