Skip to content

Commit

Permalink
Merge branch 'master' into real_imag_vectorvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagobadia authored Nov 2, 2023
2 parents ecad121 + 8ebe624 commit b03325c
Show file tree
Hide file tree
Showing 21 changed files with 1,272 additions and 273 deletions.
19 changes: 18 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Implemented real/imag for VectorValues

### Fixed

- `BlockMultiFieldStyle` available for `TransientMultiFieldFESpaces` since PR [#946](/~https://github.com/gridap/Gridap.jl/pull/946).

## [0.17.20] - 2023-10-01

### Added

- Block assembly now generalised to work with `AbstractBlockArrays`, to include changes in GridapDistributed. Since PR [939](/~https://github.com/gridap/Gridap.jl/pull/939).
- Implici-Explicit Runge-Kutta ODE solvers. Since PR [#919](/~https://github.com/gridap/Gridap.jl/pull/919).

### Fixed

- Using Broadcasting(\circ) instead of \circ in one of the lazy_maps used to transform a coarse field into a fine field. Since PR [#938](/~https://github.com/gridap/Gridap.jl/pull/938).
- Better infinite norm computation in `Algebra._check_convergence`. Now works for any `AbstractArray` type, including `PVector`. Since PR [#940](/~https://github.com/gridap/Gridap.jl/pull/940).
- Updated Runge-Kutta solver. Since PR [#919](/~https://github.com/gridap/Gridap.jl/pull/919).

## [0.17.19] - 2023-08-23

### Fixed

- Reimplemented `DomainStyle` for `CellQuadrature` to fix breaking low-level Poisson tutorial. Since PR [#937](/~https://github.com/gridap/Gridap.jl/pull/937).

## [0.17.18] - 2023-08-15
## [0.17.18] - 2023-08-15

### Added

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Gridap"
uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
authors = ["Santiago Badia <santiago.badia@monash.edu>", "Francesc Verdugo <f.verdugo.rojano@vu.nl>", "Alberto F. Martin <alberto.f.martin@anu.edu.au>"]
version = "0.17.19"
version = "0.17.20"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
2 changes: 1 addition & 1 deletion src/Adaptivity/AdaptedTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function change_domain_o2n(f_coarse,ctrian::Triangulation{Dc},ftrian::AdaptedTri
ref_coord_map = get_n2o_reference_coordinate_map(glue)

# f_fine(x_fine) = f_f2c ∘ Φ^(-1)(x_fine) = f_coarse(x_coarse)
fine_mface_to_field = lazy_map(,f_f2c,ref_coord_map)
fine_mface_to_field = lazy_map(Broadcasting(),f_f2c,ref_coord_map)

### New Model -> New Triangulation
fine_tface_to_field = lazy_map(Reindex(fine_mface_to_field),fglue.tface_to_mface)
Expand Down
16 changes: 4 additions & 12 deletions src/Algebra/NLSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,13 @@ function _solve_nr!(x,A,b,dx,ns,nls,op)
end

function _check_convergence(nls,b)
m0 = _inf_norm(b)
(false, m0)
m0 = maximum(abs,b)
return (false, m0)
end

function _check_convergence(nls,b,m0)
m = _inf_norm(b)
m < nls.tol * m0
end

function _inf_norm(b)
m = 0
for bi in b
m = max(m,abs(bi))
end
m
m = maximum(abs,b)
return m < nls.tol * m0
end

# Default concrete implementation
Expand Down
37 changes: 21 additions & 16 deletions src/MultiField/BlockSparseMatrixAssemblers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ function BlockSparseMatrixAssembler(trial::MultiFieldFESpace,
@notimplemented msg
end

function BlockSparseMatrixAssembler(trial::MultiFieldFESpace{<:BlockMultiFieldStyle{NB,SB,P}},
test::MultiFieldFESpace{<:BlockMultiFieldStyle{NB,SB,P}},
function BlockSparseMatrixAssembler(::BlockMultiFieldStyle{NB,SB,P},
trial,
test,
matrix_builder,
vector_builder,
strategy=FESpaces.DefaultAssemblyStrategy()) where {NB,SB,P}
Expand All @@ -103,12 +104,13 @@ function BlockSparseMatrixAssembler(trial::MultiFieldFESpace{<:BlockMultiFieldSt
return BlockSparseMatrixAssembler{NB,NV,SB,P}(block_assemblers)
end

function FESpaces.SparseMatrixAssembler(mat,
vec,
trial::MultiFieldFESpace{<:BlockMultiFieldStyle},
test::MultiFieldFESpace{<:BlockMultiFieldStyle},
strategy::AssemblyStrategy=DefaultAssemblyStrategy())
return BlockSparseMatrixAssembler(trial,test,SparseMatrixBuilder(mat),ArrayBuilder(vec),strategy)
function FESpaces.SparseMatrixAssembler(mat,vec,
trial::MultiFieldFESpace{MS},
test ::MultiFieldFESpace{MS},
strategy::AssemblyStrategy=DefaultAssemblyStrategy()
) where MS <: BlockMultiFieldStyle
mfs = MultiFieldStyle(test)
return BlockSparseMatrixAssembler(mfs,trial,test,SparseMatrixBuilder(mat),ArrayBuilder(vec),strategy)
end

# BlockArrays extensions
Expand Down Expand Up @@ -224,7 +226,7 @@ for T in (:AddEntriesMap,:TouchEntriesMap)
cache
end

function Fields.evaluate!(cache, k::$T,A::$MT,v::MatrixBlock,I::VectorBlock,J::VectorBlock)
function Fields.evaluate!(cache,k::$T,A::$MT,v::MatrixBlock,I::VectorBlock,J::VectorBlock)
ni,nj = size(v.touched)
for j in 1:nj
for i in 1:ni
Expand Down Expand Up @@ -272,22 +274,25 @@ end
# In place assembly modifications (for dispatching)
# We convert from BlockArray to ArrayBlock to be able to expland the blocks.
# After assembly we convert back to BlockArray automatically.
function FESpaces.assemble_vector_add!(b::BlockVector,a::BlockSparseMatrixAssembler,vecdata)
b1 = ArrayBlock(b.blocks,fill(true,size(b.blocks)))
function FESpaces.assemble_vector_add!(b::AbstractBlockVector,a::BlockSparseMatrixAssembler,vecdata)
b1 = ArrayBlock(blocks(b),fill(true,blocksize(b)))
b2 = expand_blocks(a,b1)
FESpaces.assemble_vector_add!(b2,a,vecdata)
end

function FESpaces.assemble_matrix_add!(mat::BlockMatrix,a::BlockSparseMatrixAssembler,matdata)
m1 = ArrayBlock(mat.blocks,fill(true,size(mat.blocks)))
function FESpaces.assemble_matrix_add!(mat::AbstractBlockMatrix,a::BlockSparseMatrixAssembler,matdata)
m1 = ArrayBlock(blocks(mat),fill(true,blocksize(mat)))
m2 = expand_blocks(a,m1)
FESpaces.assemble_matrix_add!(m2,a,matdata)
end

function FESpaces.assemble_matrix_and_vector_add!(A::BlockMatrix,b::BlockVector,a::BlockSparseMatrixAssembler,data)
m1 = ArrayBlock(A.blocks,fill(true,size(A.blocks)))
function FESpaces.assemble_matrix_and_vector_add!(A::AbstractBlockMatrix,
b::AbstractBlockVector,
a::BlockSparseMatrixAssembler,
data)
m1 = ArrayBlock(blocks(A),fill(true,blocksize(A)))
m2 = expand_blocks(a,m1)
b1 = ArrayBlock(b.blocks,fill(true,size(b.blocks)))
b1 = ArrayBlock(blocks(b),fill(true,blocksize(b)))
b2 = expand_blocks(a,b1)
FESpaces.assemble_matrix_and_vector_add!(m2,b2,a,data)
end
4 changes: 2 additions & 2 deletions src/MultiField/MultiFieldFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ function BlockMultiFieldStyle(NB::Integer)
return BlockMultiFieldStyle(NB,SB)
end

function BlockMultiFieldStyle(::BlockMultiFieldStyle{NB,SB,P},spaces::Vector{<:SingleFieldFESpace}) where {NB,SB,P}
function BlockMultiFieldStyle(::BlockMultiFieldStyle{NB,SB,P},spaces) where {NB,SB,P}
@check length(spaces) == sum(SB)
return BlockMultiFieldStyle(NB,SB,P)
end

function BlockMultiFieldStyle(::BlockMultiFieldStyle{0,0,0},spaces::Vector{<:SingleFieldFESpace})
function BlockMultiFieldStyle(::BlockMultiFieldStyle{0,0,0},spaces)
NB = length(spaces)
return BlockMultiFieldStyle(NB)
end
Expand Down
3 changes: 3 additions & 0 deletions src/ODEs/Exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ end
@publish_gridapodes ODETools MidPoint
@publish_gridapodes ODETools ThetaMethod
@publish_gridapodes ODETools RungeKutta
@publish_gridapodes ODETools IMEXRungeKutta
@publish_gridapodes ODETools Newmark
@publish_gridapodes ODETools GeneralizedAlpha
@publish_gridapodes ODETools ∂t
Expand All @@ -23,3 +24,5 @@ end
@publish_gridapodes TransientFETools TransientAffineFEOperator
@publish_gridapodes TransientFETools TransientConstantFEOperator
@publish_gridapodes TransientFETools TransientConstantMatrixFEOperator
@publish_gridapodes TransientFETools TransientRungeKuttaFEOperator
@publish_gridapodes TransientFETools TransientIMEXRungeKuttaFEOperator
Loading

0 comments on commit b03325c

Please sign in to comment.