Repository navigation
Conversation
In 2D, curl(u) of a scalar function u was marked scalar, and TerminalExpr(curl(u), domain) raised TypeError because Curl_2d and LogicalCurl_2d index their argument as a vector. Mark it as a vector and evaluate it like rot(u), so both give (du/dy, -du/dx). Fixes pyccel#152
This branch has not been deployed
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.
Fixes #152.
In 2D,
curl(u)of a scalar functionushould be the vector curl. Two things were wrong:curl(u).is_scalarwasTrue, becauseCurl.__new__marked every 2D curl as scalar.TerminalExpr(curl(u), domain)raisedTypeError: 'ScalarFunction' object is not subscriptable, becauseCurl_2dandLogicalCurl_2dcomputedx(u[1]) - dy(u[0])and so expect a vector. This also broke any form using it, e.g.integral(domain, dot(curl(u), curl(v))).Changes:
Curl.__new__(sympde/calculus/core.py): a 2D curl is scalar only when its argument is not in aScalarFunctionSpace. This also coversminus(u)andplus(u).Curl_2dandLogicalCurl_2d(sympde/topology/derivatives.py): when the evaluated argument is not a matrix, return the result ofRot_2d/LogicalRot_2d, i.e.(du/dy, -du/dx). As the issue notes, this is whatrot(u)already gives. The vector case is unchanged.The curl of a vector field in 2D is still scalar, and 3D is unchanged.
Test:
test_curl_scalar_2dinsympde/calculus/tests/test_calculus.pychecksis_scalarforcurl(u),curl(minus(u))andcurl(w), and thatTerminalExpr(curl(u))equalsTerminalExpr(rot(u)). It fails onmasterwithassert not True. I also checked by hand that the bilinear formdot(curl(u), curl(v))gives the same terminal expression asdot(rot(u), rot(v)), and thatcurl(u)matchesrot(u)on a domain with aPolarMapping.pytest sympde/calculus sympde/expr sympde/topology: 158 passed, 2 skipped.