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

tfluct as input to solver, following rp #424

Merged
merged 9 commits into from
Aug 24, 2014
Merged

Conversation

sanromd
Copy link
Contributor

@sanromd sanromd commented Jun 19, 2014

This PR

  • adds the ability to provide a tfluct solver to SharpClaw directly in the same fashion as Riemann solvers are passed. When solver.tfluct_solver=True, a fortran python-wrapped routine can be given through import _name-of-tfluct-solver_, solver.tfluct=_name-of-tfluct-solver_
  • solver follows API convention of Riemann solvers
  • works in n-d
  • euler_1d has been modified to provide an example of usage

@sanromd
Copy link
Contributor Author

sanromd commented Jun 19, 2014

@ketch @hadjimy this PR adds the ability we have been discussing. Likely, it could be beneficial to do the same for evec, maybe by setting solver.evec_decomp=True/False and provide the evec routine through solver.evec

! =========================================================
subroutine tfluct(maxmx,num_eqn,num_waves,num_ghost,mx,ql,qr,auxl,auxr, &
s,adq)
subroutine tfluct(ixyz,maxnx,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,amdq2)
Copy link
Member

Choose a reason for hiding this comment

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

Is this stub supposed to match the example above? The function signatures and name are different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mandli the tfluct stub example was left untouched for a long time, the API was never updated. This PR fixes that and provides a method to set tfluct following this standard, see for example euler_1d

Copy link
Member

Choose a reason for hiding this comment

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

I think I see what you are saying although now having different signatures for each dimension's implementation (which I think is fine) means you may want to have the stub mimic this (i.e. have stub for tfluct1, tfluct2, and tfluct3 which have the correct signatures). Often times users will copy these stub functions and use them so this could be dangerous otherwise even if you are passing them through to flux*.

@sanromd
Copy link
Contributor Author

sanromd commented Jun 22, 2014

@mandli following your suggestion I have added dimension dependent stub functions for tfluct.

@sanromd
Copy link
Contributor Author

sanromd commented Jun 22, 2014

@ketch any comments?

@sanromd sanromd self-assigned this Jun 22, 2014
! =========================================================
subroutine tfluct(maxmx,num_eqn,num_waves,num_ghost,mx,ql,qr,auxl,auxr, &
s,adq)
subroutine tfluct1(maxnx,meqn,mwaves,maux,mbc,mx,ql,qr,auxl,auxr,amdq2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mandli note that now the stub functions are different for 1d and 2d...

Copy link
Member

Choose a reason for hiding this comment

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

Please delete these stubs and write some documentation of the interface instead.

@mandli
Copy link
Member

mandli commented Jun 22, 2014

At this point I defer approval to those that know more about SharpClaw.

@sanromd
Copy link
Contributor Author

sanromd commented Jun 25, 2014

@ahmadia @ketch

double precision, intent(in) :: ql(meqn,1-mbc:maxnx+mbc)
double precision, intent(in) :: qr(meqn,1-mbc:maxnx+mbc)

double precision, intent(out) :: amdq2(meqn,1-mbc:maxnx+mbc)
Copy link
Member

Choose a reason for hiding this comment

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

The correct name for this variable here is adq, not amdq2. The function is supposed to compute the total fluctuation.

@ketch
Copy link
Member

ketch commented Jun 25, 2014

This PR is a model of good practice: it does one thing only, and what it does is explained clearly.

@ahmadia
Copy link
Member

ahmadia commented Jun 25, 2014

Hi :)

Agreed that this is a good PR.

Comments:

  • This introduces some complicated functionality. It would be nice if you added two small tests, one that correctly imports a tfluct solver and runs for a very short time, and another that raises an error when trying to set tfluct but without importing an appropriate module
  • I'm not familiar with what tfluct is or how it is used. Perhaps it would be worth adding just a couple of sentences to the PyClaw documentation?
  • Agreed with David's statement earlier, you also need to sort out whether the tfluct module will be available by default (compiled into the SharpClaw Fortran extension module) or whether it will only be available in examples. It should not be in both. I lean towards making things available in libraries when we install Clawpack, but I don't have a strong opinion.

@ketch
Copy link
Member

ketch commented Jun 25, 2014

Regarding the stub functions: I think you can get rid of them completely. Instead, just put the following near the top of sharpclaw/solver.py:

def empty_fun():
    raise Exception('This is a dummy function and should never be called.')

Then

if solver.tfluct_solver == False:
    solver.tfluct = empty_fun

@ketch
Copy link
Member

ketch commented Jun 25, 2014

I think that eventually it would make sense to keep tfluct solvers in the Riemann repository and handle them just like Riemann solvers. However, since we only have one tfluct solver at present, it doesn't seem worthwhile to disrupt the current layout of the Riemann repository. And it is useful to have an example showing how a user can employ their own tfluct solver.

@mandli
Copy link
Member

mandli commented Jun 26, 2014

A couple of comments about what @ketch said:

  • Wouldn't the stub functions have to be present if they are being called from Fortran (some platforms, notably those with the ability to have a non-flat namespace, should be fine)? I guess you are thinking that we would handle this as a cpointer into the Fortran? I might not be thinking about this quite right so please correct me if I am off base on this point.
  • If what you suggest would work then I think it should also be said that the stub functions also provide a nice, empty template for those who need to write their own. Beyond this small quibble I think removing the stub functions more broadly is not a bad idea.
  • I fully support moving the tfluct solvers into the Riemann repository as soon as it makes sense to do so.

@ketch
Copy link
Member

ketch commented Jun 26, 2014

Response to @mandli :

Wouldn't the stub functions have to be present if they are being called from Fortran (some platforms, notably those with the ability to have a non-flat namespace, should be fine)? I guess you are thinking that we would handle this as a cpointer into the Fortran? I might not be thinking about this quite right so please correct me if I am off base on this point.

The functions don't get called from the fortran unless tfluct_solver is True. The code I wrote in my previous comment works fine (I tested it).

If what you suggest would work then I think it should also be said that the stub functions also provide a nice, empty template for those who need to write their own. Beyond this small quibble I think removing the stub functions more broadly is not a bad idea.

True. But if those functions are really just documentation of an API, then we should instead document the API (in the docs!)

@mandli
Copy link
Member

mandli commented Jun 27, 2014

Response to @ketch (nested quoting works!):

Wouldn't the stub functions have to be present if they are being called from Fortran (some platforms, notably those with the ability to have a non-flat namespace, should be fine)? I guess you are thinking that we would handle this as a cpointer into the Fortran? I might not be thinking about this quite right so please correct me if I am off base on this point.

The functions don't get called from the fortran unless tfluct_solver is True. The code I wrote in my previous comment works fine (I tested it).

Yeah, now that I think about it as long as it is being passed as a function argument it should be fine. It might be worthwhile checking on Linux whose ELF binary format is more sensitive to this than OS X's Mach-O format.

If what you suggest would work then I think it should also be said that the stub functions also provide a nice, empty template for those who need to write their own. Beyond this small quibble I think removing the stub functions more broadly is not a bad idea.

True. But if those functions are really just documentation of an API, then we should instead document the API (in the docs!)

Heh, good point. I think I am too used to what we have needed to do in the past with Fortran.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling c6ea3a6 on sanromd:dev-tfluct into d6c8f92 on clawpack:master.

@ketch
Copy link
Member

ketch commented Jul 18, 2014

Just to be clear: this PR is waiting on @sanromd to clean it up following the comments above.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling c891e4b on sanromd:dev-tfluct into a94b1a6 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling a36a7e5 on sanromd:dev-tfluct into a94b1a6 on clawpack:master.

@sanromd
Copy link
Contributor Author

sanromd commented Jul 19, 2014

@ketch The issues raised have been solved. I have left the stub functions tfluct on sharp claw for reference to the user, although they are not used anymore. Perhaps we could create a dummy folder on Riemann for the tfluct solvers as a separate PR.

I think now this is ready to merge.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) when pulling b1a0d5a on sanromd:dev-tfluct into a94b1a6 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) when pulling b1a0d5a on sanromd:dev-tfluct into a94b1a6 on clawpack:master.

@sanromd
Copy link
Contributor Author

sanromd commented Aug 24, 2014

@ketch corrections committed

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.93%) when pulling a1de1d3 on sanromd:dev-tfluct into a94b1a6 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) when pulling 06d57dd on sanromd:dev-tfluct into 1fef8a4 on clawpack:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) when pulling 06d57dd on sanromd:dev-tfluct into 1fef8a4 on clawpack:master.

ketch added a commit that referenced this pull request Aug 24, 2014
tfluct as input to solver, following rp
@ketch ketch merged commit a92d418 into clawpack:master Aug 24, 2014
@sanromd sanromd deleted the dev-tfluct branch December 2, 2014 13:16
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.

5 participants