Draft
Conversation
pbrubeck
commented
Feb 17, 2026
daf58a1 to
b28fbf5
Compare
pbrubeck
commented
Feb 28, 2026
pbrubeck
commented
Mar 27, 2026
Comment on lines
+546
to
+551
| if write_solution == "all": | ||
| should_write = True | ||
| elif write_solution == "first_and_last": | ||
| if it == 0 or it == self.options.max_iterations: | ||
| should_write = True | ||
| elif write_solution == "by_iteration": |
Contributor
Author
There was a problem hiding this comment.
These are too many cases, and it is not obvious for a user. The user could decide if they want to do this by writing their own adaptivity loop and calling solver.step(). Should we just remove this function?
pbrubeck
commented
Mar 27, 2026
Comment on lines
+657
to
+664
| # Only required for my examples: | ||
| def getlabels(mesh, codim): | ||
| ngmesh = mesh.netgen_mesh | ||
| names = ngmesh.GetRegionNames(codim=codim) | ||
| names_to_labels = {} | ||
| for l in names: | ||
| names_to_labels[l] = tuple(i+1 for i, name in enumerate(names) if name == l) | ||
| return names_to_labels |
Contributor
Author
There was a problem hiding this comment.
This should probably become a class method, something like:
mesh.region_names_to_subdomain_ids(codim)
pbrubeck
commented
Mar 27, 2026
Comment on lines
+619
to
+654
| @singledispatch | ||
| def refine(expr, self, coefficient_mapping=None): | ||
| return coarsen(expr, self, coefficient_mapping=coefficient_mapping) # fallback to original | ||
|
|
||
|
|
||
| @refine.register(ufl.Mesh) | ||
| @refine.register(ufl.MeshSequence) | ||
| def refine_mesh(mesh, self, coefficient_mapping=None): | ||
| hierarchy, level = utils.get_level(mesh) | ||
| if hierarchy is None: | ||
| raise CoarseningError("No mesh hierarchy available") | ||
| return hierarchy[level + 1] | ||
|
|
||
|
|
||
| @refine.register(Cofunction) | ||
| @refine.register(Function) | ||
| def refine_function(expr, self, coefficient_mapping=None): | ||
| if coefficient_mapping is None: | ||
| coefficient_mapping = {} | ||
| new = coefficient_mapping.get(expr) | ||
| if new is None: | ||
| Vf = expr.function_space() | ||
| Vc = self(Vf, self) | ||
| name = expr.name() | ||
| if name is not None: | ||
| level_increment = -1 if self == coarsen else 1 | ||
| try: | ||
| name, prev_level = name.split("_level_") | ||
| except ValueError: | ||
| prev_level = 0 | ||
| level = int(prev_level) + level_increment | ||
| name = f"{name}_level_{level}" | ||
| new = Function(Vc, name=name) | ||
| new.interpolate(expr) | ||
| coefficient_mapping[expr] = new | ||
| return new |
Contributor
Author
There was a problem hiding this comment.
This should live in mg/ufl_utils.py
…nlinear solves while still retaining excellent error estimates.
4341140 to
34be255
Compare
34be255 to
774aedf
Compare
f59bd8e to
b920833
Compare
645af70 to
37ab7d9
Compare
b3dcbb2 to
befe0ff
Compare
befe0ff to
b241c80
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description