Last active
September 21, 2021 01:59
-
-
Save amartinhuertas/9368f08df4a2c01ca2f485b960c8f497 to your computer and use it in GitHub Desktop.
Efficient assembly of L2 Mass Matrix and its inverse using Gridap/GridapGeoScience Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Gridap | |
using GridapGeosciences | |
order=1 | |
degree=4 | |
model = CubedSphereDiscreteModel(1; radius=rₑ) | |
# Forward integration of the shallow water equations | |
Ω = Triangulation(model) | |
dΩ = Measure(Ω, degree) | |
dω = Measure(Ω, degree, ReferenceDomain()) | |
reffe_lgn = ReferenceFE(lagrangian, Float64, order) | |
Q = FESpace(model, reffe_lgn; conformity=:L2) | |
P = TrialFESpace(Q) | |
function assemble_L2MM_invL2MM(U,V,dΩ) | |
a(a,b) = ∫(a⋅b)dΩ | |
v = get_fe_basis(V) | |
u = get_trial_fe_basis(U) | |
assemblytuple = Gridap.FESpaces.collect_cell_matrix(U,V,a(u,v)) | |
cell_matrix_MM = collect(assemblytuple[1][1]) # This result is no longer a LazyArray | |
newassemblytuple = ([cell_matrix_MM],assemblytuple[2],assemblytuple[3]) | |
a=SparseMatrixAssembler(U,V) | |
L2MM=assemble_matrix(a,newassemblytuple) | |
for i in eachindex(cell_matrix_MM) | |
cell_matrix_MM[i]=inv(cell_matrix_MM[i]) | |
end | |
invL2MM=similar(L2MM) | |
Gridap.FESpaces.assemble_matrix!(invL2MM, a, newassemblytuple) | |
L2MM, invL2MM | |
end | |
A,B=assemble_L2MM_invL2MM(P,Q,dΩ) | |
println(A*B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment