-
Notifications
You must be signed in to change notification settings - Fork 177
Fieldsplit: update MatNest Jacobian and support bcs on AssembledMatrix #4708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release
Are you sure you want to change the base?
Changes from all commits
aaabace
61b421d
469f583
6d9f609
c7c10cf
537c6cd
1d753e3
8952e3f
4ab9490
b7ea78c
866fda2
561480f
4688ff1
6767898
0a3fa46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,8 @@ | ||
|
|
||
| import numpy | ||
| import collections | ||
|
|
||
| from ufl import as_tensor, as_vector, split | ||
| from ufl.classes import Zero, FixedIndex, ListTensor, ZeroBaseForm | ||
| from ufl.classes import Form, Zero, FixedIndex, ListTensor, ZeroBaseForm | ||
| from ufl.algorithms.map_integrands import map_integrand_dags | ||
| from ufl.algorithms import expand_derivatives | ||
| from ufl.corealg.map_dag import MultiFunction, map_expr_dags | ||
|
|
@@ -161,27 +160,58 @@ def cofunction(self, o): | |
| return Cofunction(W, val=MixedDat(o.dat[i] for i in indices)) | ||
|
|
||
| def matrix(self, o): | ||
| from firedrake.bcs import DirichletBC, EquationBCSplit | ||
| ises = [] | ||
| args = [] | ||
| argument_indices = [] | ||
| for a in o.arguments(): | ||
| V = a.function_space() | ||
| iset = PETSc.IS() | ||
| if a.number() in self.blocks: | ||
| fields = self.blocks[a.number()] | ||
| asplit = self._subspace_argument(a) | ||
| for f in self.blocks[a.number()]: | ||
| for f in fields: | ||
| fset = V.dof_dset.field_ises[f] | ||
| iset = iset.expand(fset) | ||
| else: | ||
| fields = tuple(range(len(V))) | ||
| asplit = a | ||
| for fset in V.dof_dset.field_ises: | ||
| iset = iset.expand(fset) | ||
|
|
||
| ises.append(iset) | ||
| args.append(asplit) | ||
| argument_indices.append(fields) | ||
|
|
||
| if isinstance(o.a, Form): | ||
| form = self.split(o.a, argument_indices=argument_indices) | ||
| if isinstance(form, ZeroBaseForm): | ||
| return form | ||
| else: | ||
| form = None | ||
|
|
||
| submat = o.petscmat.createSubMatrix(*ises) | ||
| bcs = () | ||
| return AssembledMatrix(tuple(args), bcs, submat) | ||
|
|
||
| bcs = [] | ||
| spaces = [a.function_space() for a in o.arguments()] | ||
| for bc in o.bcs: | ||
| W = bc.function_space() | ||
| while W.parent is not None: | ||
| W = W.parent | ||
|
|
||
| number = spaces.index(W) | ||
| V = args[number].function_space() | ||
| field = self.blocks[number] | ||
| if isinstance(bc, DirichletBC): | ||
| bc_temp = bc.reconstruct(field=field, V=V, g=bc.function_arg, use_split=True) | ||
| elif isinstance(bc, EquationBCSplit): | ||
| row_field, col_field = argument_indices | ||
| bc_temp = bc.reconstruct(field=field, V=V, row_field=row_field, col_field=col_field, use_split=True) | ||
| bc_temp = None | ||
| if bc_temp is not None: | ||
| bcs.append(bc_temp) | ||
|
|
||
| return AssembledMatrix(form or tuple(args), tuple(bcs), submat) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we know what
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should have a dispatcher mechanism |
||
|
|
||
| def zero_base_form(self, o): | ||
| return ZeroBaseForm(tuple(map(self, o.arguments()))) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.