Skip to content

Commit

Permalink
Allowing to pass directly a function when defining a linear form
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Aug 9, 2019
1 parent 061e211 commit bb42847
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/FESpaces/FEBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function inner(a::FEBasis,b::CellField)
varinner(a.cellbasis,b)
end

function inner(a::FEBasis,f::Function)
b = CellField(a.trian,f)
inner(a,b)
end

function inner(a::FEBasis,b::FEBasis)
varinner(a.cellbasis,b.cellbasis)
end
Expand Down
5 changes: 5 additions & 0 deletions src/MultiField/MultiFEBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ function inner(a::FEBasisWithFieldId,b::CellField)
MultiCellMap(blocks,fieldids)
end

function inner(a::FEBasisWithFieldId,f::Function)
b = CellField(a.febasis.trian,f)
inner(a,b)
end

function inner(a::FEBasisWithFieldId,b::FEBasisWithFieldId)
block = inner(a.febasis,b.febasis)
blocks = [block,]
Expand Down
10 changes: 2 additions & 8 deletions test/FESpacesTests/FEOperatorsTestsMixin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ U = TrialFESpace(fespace,ufun)
trian = Triangulation(model)
quad = CellQuadrature(trian,order=2)

# Define cell field describing the source term
bfield = CellField(trian,bfun)

# Define forms
a(v,u) = inner((v), (u))
b(v) = inner(v,bfield)
b(v) = inner(v,bfun)

# Define Assembler
assem = SparseMatrixAssembler(V,U)
Expand Down Expand Up @@ -85,11 +82,8 @@ neumanntags = [8,]
btrian = BoundaryTriangulation(model,neumanntags)
bquad = CellQuadrature(btrian,order=2)

# Object describing Neumann function
gfield = CellField(btrian,gfun)

# Integrand of the Neumann BC
g(v) = inner(v,gfield)
g(v) = inner(v,gfun)

# Define weak form terms
t_Ω = AffineFETerm(a,b,trian,quad)
Expand Down
7 changes: 2 additions & 5 deletions test/MultiFieldTests/MultiFEOperatorsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,13 @@ btrian = BoundaryTriangulation(model,neumanntags)
bquad = CellQuadrature(btrian,order=2)

# Terms in the volume
b1field = CellField(trian,b1fun)
b2field = CellField(trian,b2fun)
a(v,u) = inner((v[1]),(u[1])) + inner(v[1],u[2]) + inner((v[2]),(u[2]))
b(v) = inner(v[1],b1field) + inner(v[2],b2field)
b(v) = inner(v[1],b1fun) + inner(v[2],b2fun)
t_Ω = AffineFETerm(a,b,trian,quad)

# Terms on Neumann boundary
# Note that the Neumann BC only applies on the first field
g1field = CellField(btrian,g1fun)
g(v) = inner(v[1],g1field)
g(v) = inner(v[1],g1fun)
t_Γ = FESource(g,btrian,bquad)

# Define Assembler
Expand Down

0 comments on commit bb42847

Please sign in to comment.