Skip to content
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

Staggered grids in InvertPar #2087

Merged
merged 10 commits into from
Sep 10, 2020
Merged

Staggered grids in InvertPar #2087

merged 10 commits into from
Sep 10, 2020

Conversation

johnomotani
Copy link
Contributor

@johnomotani johnomotani commented Aug 25, 2020

Allows InvertPar to work on staggered grids.

CELL_YLOW version requires changes to the boundary conditions. The Neumann boundary conditions have to be put in with one-sided differences, which (because the matrix in InvertParCR is tri-diagonal) are only first-order accurate. As long as InvertPar is only being used for preconditioners, hopefully this should not be a problem.

Also addresses a comment above the InvertPar::Create() method that it should be called create and take Options* (and now CELL_LOC) arguments.

Adds tests both for staggered grids and on open field lines (which were not previously tested).

  • InvertPar::create() supported in bin/bout-b5-factory-upgrader.py

@johnomotani johnomotani added backport candidiate Does not break backward compatibility, so can be back-ported to v4.4 breaking change Introduces a change that is not backward compatible with the previous major version feature labels Aug 25, 2020
@johnomotani
Copy link
Contributor Author

I keep forgetting - do we have a list of breaking changes that I should add InvertPar::Create->InvertPar::create to? It should probably go into the bout_4to5 script too I guess. @ZedThree can you help with that?

@johnomotani
Copy link
Contributor Author

The fedora test is failing :-(
It's failing test-petsc-laplace3d, which shouldn't be affected by any of the changes here. Could be a fedora and/or PETSc-version issue? I think the failure is a result only marginally over the tolerance anyway.

I don't have a fedora system to test on. Could someone please check the latest next on fedora rawhide? If it's not this PR, then next should have the same issue. @dschwoerer @ZedThree?

@ZedThree
Copy link
Member

ZedThree commented Sep 1, 2020

I just merged a couple of PRs, I guess we'll see if the problem is also in next quite soon! I will also try to check Fedora locally, if I can remember how to an interactive session going in docker/podman.

CHANGELOG.md has a Breaking Changes section. There's also bin/bout-b5-factory-upgrader.py that's probably the best place to fix Create -> create. I'll try to do that today.

ZedThree
ZedThree previously approved these changes Sep 4, 2020
Copy link
Contributor Author

@johnomotani johnomotani 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, thanks @ZedThree!

return source
return re.sub(
r"({factory_name})\s*::\s*{old_create_method}\b".format(**factory),
r"\1::{create_method}".format(**factory),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we check that there's no argument to the Create method? The old version could take a Mesh* argument, which I'd be surprised if anyone was using, but if they were it'd be an error to pass as the first argument to the new create (which is an Options*). Don't think it's worth bothering to fix if there was an argument, but raising an error or a warning might be nice?

Copy link
Member

Choose a reason for hiding this comment

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

Done. It's a bit dumb, in that it always warns if a factory where the arguments have changed is used. Hopefully the documentation is sufficiently useful for users to know what to do, otherwise we'll have to rely on the compiler. For me, using gcc 10.2, I get the following error (with nice colours too):

../tests/integrated/test-invpar/test_invpar.cxx: In function ‘int main(int, char**)’:
../tests/integrated/test-invpar/test_invpar.cxx:33:32: error: cannot convert ‘Mesh*’ to ‘Options*’
   33 |   auto inv = InvertPar::create(mesh);
      |                                ^~~~
      |                                |
      |                                Mesh*
In file included from ../tests/integrated/test-invpar/test_invpar.cxx:8:
../include/invert_parderiv.hxx:104:53: note:   initializing argument 1 of ‘static std::unique_ptr<InvertPar> InvertPar::create(Options*, CELL_LOC, Mesh*)’
  104 |   static std::unique_ptr<InvertPar> create(Options *opt_in = nullptr,
      |                                            ~~~~~~~~~^~~~~~~~~~~~~~~~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks good to me, thanks @ZedThree!

@johnomotani johnomotani merged commit 17706e1 into next Sep 10, 2020
@johnomotani johnomotani deleted the InvertPar_staggered branch September 10, 2020 09:49
@ZedThree ZedThree mentioned this pull request Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport candidiate Does not break backward compatibility, so can be back-ported to v4.4 breaking change Introduces a change that is not backward compatible with the previous major version feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants