Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Global Sum Factorization for Psydac
This PR aims to speed up the
assembly
of matrices corresponding to 2D and 3DBilinearForms
on thedomain
.How is a matrix assembled?
Previously:
DiscreteBasic
generates the assembly code (self._func
) and setsself._free_args
. The latter consists of information regarding freeFemFields
in the BilinearForm.self.allocate_matrices
generates theStencilMatrices
we write into.self.construct_arguments
generates all the arguments required for the assembly that are not already covered byself._free_args
. Additional arguments in the case ofopenmp
parallelization are generated.Now:
DiscreteBasic
generates the assembly code (self._func
) and setsself._free_args
. The latter consists of information regarding freeFemFields
in the BilinearForm. We will overwriteself._func
later.self.allocate_matrices
generates theStencilMatrices
we write into.self._new_assembly == True
orself._new_assembly == False
?self.construct_arguments
generates all the arguments required for the assembly that are not already covered byself._free_args
. Additional arguments in the case ofopenmp
parallelization are generated.self.construct_arguments_generate_assembly_file
generates all the arguments required for the new assembly method that are not already covered byself._free_args
. Noopenmp
support! Additionally, new assembly code is generated and pyccelized.Summary of what the new
self.construct_arguments_generate_assembly_file
method does follows next week.No
openmp
support - What now?I don't intend on supporting
openmp
parallelization. At least not until everything else works as a cherry on top.But:
openmp
related Github tests fail. I want to detect whether code is run withopenmp
and accordingly don't setnew_assembly
toTrue
. But I don't know how to do that. Help please.No
multiplicity
support - What now?Changing the
multiplicity
(of ...?) results in a changed assembly algorithm. I didn't look into it yet. I suppose it's related to additional quadrature points.The new assembly method can of course be altered such that it's compatible with a changed
multiplicity
, but, again, I don't intend to do that right now. Instead, I want to detect such cases and don't setnew_assembly
toTrue
. This can eventually be fixed once everything else runs.What is left to do?
read import informationfrom theBilinearForm
.DiscreteBilinearForm
will be merged into two.allocate_matrix
function. I will better document this issue next week.AnalyticalMappings
wrong? Will need to investigate next week.Also: The fact that all tests currently run implies that matrix assembly is poorly tested. I will need to properly test matrix assembly with tests that don't run forever - This will be difficult, as
BilinearForm
discretization can be slow, but I'll need to test all possibilities.#--------------------------------------------------------------------------------------------------------------------------------------
Is it finally happening? Fast Bilinear Form Matrix Assembly is coming to Psydac!
ToDo:
Understand
._free_args
<- DONEIn
DiscreteBilinearForm
, the following happens:As I did not consider BilinearForms with additional free FemFields yet, the assembly of such matrices will for sure fail.
I will need to consider such cases and test them properly.
Include free FemFields in the test cases <- DONE
Just to make sure: Once 1. is done, properly test the inclusion of free FemFields in the matrix assembly of BilinearForms.
Get the imports right
A
BilinearForm
as defined below will require the import of thesin
function, e.g. fromnumpy
, inside the generatedassemble_matrix
method in theassembly.py
file. I currently have no way of automatically including this import, rather I hardcodedin the
_assembly_template_head
property of theDiscreteBilinearForm
.Handle
VectorFunctionSpaces
not belonging to a de Rham sequence. <- not a problem after all, test cases have been addedVectorFunctionSpaces
not belonging to a de Rham sequence have (always?) the sameBasis
in each direction, whereas e.g. a discrete Hcurl space belonging to a de Rham sequence has three different bases for each direction.Hence, certain variables are of different length. For example, given a discretization with
degree = [3, 3, 3]
Bsplines, one might find in one casetrial_degrees = (3, 3, 3)
and in the othertrial_degrees = (2, 3, 3, 3, 2, 3, 3, 3, 2)
.I need to find a way to deal with this issue. In addition, I must include sufficient tests!
Temporary workaround:
Remove coupling_term=0 sub_expr <- DONE
This is an important change to do! Currently, often times when not including a
Mapping
, we'll find something like thisin the assembly method. We can save a lot of computations by excluding subexpressions from the assembly method that don't contribute to the global matrix.
Remove not-required global matrices <- DONE
Related to 5. - At times, mostly when not including
Mappings
, we are including not just subexpressions that don't contribute to the global matrix, but in the case of vector valued functions, even entire global matrices that remain zero, but potentially still require a lot of computational power. I will need to make sure this doesn't happen.Enable different multiplicity in DiscreteDerham
Tests with a multiplicity different from
1
currently fail. Will need to investigate further.Enable openmp support
Must use different assembly function names
At the moment, the assembly function file is simply called
assemble.py
. Discretizing multiple BilinearForms before assemblying them hence won't work, because we over-write the assembly file.