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

Add tool for generic operator inversion #1439

Merged
merged 60 commits into from
Dec 14, 2018
Merged

Conversation

d7919
Copy link
Member

@d7919 d7919 commented Dec 11, 2018

Header only class that can be used to invert arbitrary linear operators (i.e. equations of the form A.x =b). Requires PETSc.

This is adopts a fairly brute force approach which might be useful for testing/development. It may also be possible that with some appropriate tuning of PETSc settings that this could be competitive in some situations.

operator

This is a work in progress and relies on PETSc.

It has been written according to the PETSc 3.9 api and is unlikely to
work with sufficiently old versions currently. Probably easy enough to
fix.

The class is templated on Field type to define the problem domain.
Seems to allow localmesh to be made private
This allows setup to take any one of:

* A function with signature `InvertOperator<T>::function_signature`
* A struct derived from `OperatorWrapper`
* A lambda matching `InvertOperator<T>::function_signature`

This provides flexibility to the user -- they can pass a function if no
extra data is required or a struct if further information/state is
needed etc.
Provides interface to set the function
Allows the function to be made private
May want to revisit the need/location for these.
This commit should probably be reverted and a better thought out
interface to extracting regions from Fields implemented instead.

Also adds RGN_NOCORNERS which should be RGN_NOBNDRY plus the actual
boundary cells (not the guard cells) without corner locations.
@d7919 d7919 added the feature label Dec 11, 2018
Copy link
Member

@ZedThree ZedThree left a comment

Choose a reason for hiding this comment

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

Are all the functions that return PetscErrorCode called by PETSc functions? If not, could they instead throw BoutException? This would presumably need to replace CHKERRQ

include/bout/invertable_operator.hxx Outdated Show resolved Hide resolved
include/bout/invertable_operator.hxx Outdated Show resolved Hide resolved
manual/sphinx/user_docs/invertable_operator.rst Outdated Show resolved Hide resolved
src/mesh/mesh.cxx Outdated Show resolved Hide resolved
@ZedThree
Copy link
Member

Please could you add some tests? Preferably unit tests if possible, but integrated ones would be fine!

@d7919
Copy link
Member Author

d7919 commented Dec 12, 2018

I've added an integrated test (although this requires petsc).

@bendudson bendudson merged commit 40ee305 into next Dec 14, 2018
@bendudson bendudson deleted the generic_operator_inversion branch December 14, 2018 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants