Skip to content

Conversation

@ck768
Copy link

@ck768 ck768 commented Jun 4, 2025

Proposed changes

Users can specify the degree order when setting up a FESTIM model. This argument is optional, default is set to 1.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

  • Black formatted
  • Pytest succesful

Example usage:

my_model.settings = F.Settings(
atol=1e10,
rtol=1e-10,
max_iterations=30,
final_time=50,
element_degree=2
)

Modified settings.py and hydrogen_transport_problem.py to add optional degree order for finite element - defaults to 1
@ck768
Copy link
Author

ck768 commented Jun 4, 2025

Solves #991

@RemDelaporteMathurin RemDelaporteMathurin linked an issue Jun 4, 2025 that may be closed by this pull request
Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ck768 for this first contribution!

Could you also propagate this change to HydrogenTransportProblemDiscontinuous which is the multi-material version of the hydrogen problem class?

degree = 1
element_CG = basix.ufl.element(
basix.ElementFamily.P,
subdomain.submesh.basix_cell(),
degree,
basix.LagrangeVariant.equispaced,
)

@RemDelaporteMathurin
Copy link
Collaborator

Also, it seems like the CI is failing, are the tests passing locally?

python -m pytest .

@RemDelaporteMathurin
Copy link
Collaborator

@ck768 I see why some tests are failing. Now whenever we call define_function_spaces the .settings attribute needs to be set because that's where we take the degree from.

Now the straightforward way of fixing that is to add a settings attribute in all the failing tests.

Otherwise, it may be better to instead have element_degree as an argument of the define_function_spaces() method

def define_function_space(self, element_degree=1):
    ...

Then inside initialise() we simply have

def initialise(self):
    ...
    self.define_function_space(element_degree=self.settings.element_degree)

That way you don't have to modify all the tests and it's a better design altogether

@jhdark
Copy link
Collaborator

jhdark commented Jun 4, 2025

Yeah seems the CI is failing because in many tests, settings aren't given to the problem object.

Just wondering if this argument should live in settings, maybe within Mesh class instead? Even though they are different, they're more closely related than this an settings, which is more for solver and transient parameters. And, in building the function spaces it already gets the basix_cell from the mesh, so would make it more compatible.

What do you think @RemDelaporteMathurin ?

@RemDelaporteMathurin
Copy link
Collaborator

I would keep it in the settings instead of mesh and keep the mesh object for anything geometry related

@ck768
Copy link
Author

ck768 commented Jun 4, 2025

Hmm, that's interesting. I ran the tests locally and I had initial errors that I needed to install some Python modules, but after I installed them, it said the tests were successful. I've been running the line
python -m pytest .
in my cloned and forked repo (on the fenicsx branch). Is there a better way I should test the CI?

@RemDelaporteMathurin
Copy link
Collaborator

This is how you run tests locally. The tests should fail (see explanation above). Are you sure you are running pytest on ck768:fenicsx and not festim-dev:fenicsx?

ck768 added 2 commits June 5, 2025 22:58
Inputs the degree in define_function_spaces rather than only settings
@ck768
Copy link
Author

ck768 commented Jun 6, 2025

Figured out where the problem was while running local tests (thanks @jhdark )! I changed define_function_spaces to now take in the argument, and all tests seem successful now!

@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.40%. Comparing base (d308842) to head (17f1fbb).
⚠️ Report is 164 commits behind head on fenicsx.

Additional details and impacted files
@@           Coverage Diff            @@
##           fenicsx     #997   +/-   ##
========================================
  Coverage    95.39%   95.40%           
========================================
  Files           46       46           
  Lines         2847     2851    +4     
========================================
+ Hits          2716     2720    +4     
  Misses         131      131           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I'll let @jhdark add any potential last comments and then we can merge this! Thanks @ck768 !

@RemDelaporteMathurin RemDelaporteMathurin merged commit 0a262f0 into festim-dev:fenicsx Jun 11, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose order of finite element

3 participants