Skip to content

Commit 83bc1af

Browse files
committed
Add truncation flag in CoupledDofsRestriction
1 parent 88e2ead commit 83bc1af

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

src/common_restrictions/coupled_dofs_restriction.jl

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,32 @@ end
1616
The matrix can be obtained from, e.g., `get_periodic_coupling_matrix`.
1717
"""
1818
function CoupledDofsRestriction(matrix::AbstractMatrix)
19-
return CoupledDofsRestriction([matrix], Dict{Symbol, Any}(:name => "CoupledDofsRestriction"))
19+
return CoupledDofsRestriction(
20+
[matrix],
21+
Dict{Symbol, Any}(
22+
:name => "CoupledDofsRestriction",
23+
:reduce_col_space => false
24+
)
25+
)
2026
end
2127

2228

2329
"""
2430
CoupledDofsRestriction(matrices::Vector{AM}) where {AM <: AbstractMatrix}
2531
2632
Creates a `CoupledDofsRestriction` from multiple given coupling matrices.
33+
34+
By default, the column space of the matrices is reduced to be of full rank.
35+
This can toggled by the `:reduce_col_space` parameter.
2736
"""
2837
function CoupledDofsRestriction(matrices::Vector{AM}) where {AM <: AbstractMatrix}
29-
return CoupledDofsRestriction(matrices, Dict{Symbol, Any}(:name => "CoupledDofsRestriction"))
38+
return CoupledDofsRestriction(
39+
matrices,
40+
Dict{Symbol, Any}(
41+
:name => "CoupledDofsRestriction",
42+
:reduce_col_space => true
43+
)
44+
)
3045
end
3146

3247

@@ -39,12 +54,14 @@ function assemble!(R::CoupledDofsRestriction, sol, SC; kwargs...)
3954
# combine all into one matrix
4055
B = hcat(Bs...)
4156

42-
# eliminate redundant cols by QR:
43-
qr_result = qr(B)
57+
if R.parameters[:reduce_col_space]
58+
# eliminate redundant cols by QR:
59+
qr_result = qr(B)
4460

45-
# pick minimal number of cols that are rank preserving
46-
cols_of_interest = qr_result.pcol[1:rank(qr_result)]
47-
B = B[:, cols_of_interest]
61+
# pick minimal number of cols that are rank preserving
62+
cols_of_interest = qr_result.pcol[1:rank(qr_result)]
63+
B = B[:, cols_of_interest]
64+
end
4865

4966
R.parameters[:matrix] = B
5067
R.parameters[:rhs] = Zeros(size(B, 2))

0 commit comments

Comments
 (0)