{"action":"created","issue":{"url":"https://api.github.com/repos/idaholab/moose/issues/5661","labels_url":"https://api.github.com/repos/idaholab/moose/issues/5661/labels{/name}","comments_url":"https://api.github.com/repos/idaholab/moose/issues/5661/comments","events_url":"https://api.github.com/repos/idaholab/moose/issues/5661/events","html_url":"https://github.com/idaholab/moose/pull/5661","id":104628356,"number":5661,"title":"AD MOOSE","user":{"login":"friedmud","id":870705,"avatar_url":"https://avatars.githubusercontent.com/u/870705?v=3","gravatar_id":"","url":"https://api.github.com/users/friedmud","html_url":"https://github.com/friedmud","followers_url":"https://api.github.com/users/friedmud/followers","following_url":"https://api.github.com/users/friedmud/following{/other_user}","gists_url":"https://api.github.com/users/friedmud/gists{/gist_id}","starred_url":"https://api.github.com/users/friedmud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/friedmud/subscriptions","organizations_url":"https://api.github.com/users/friedmud/orgs","repos_url":"https://api.github.com/users/friedmud/repos","events_url":"https://api.github.com/users/friedmud/events{/privacy}","received_events_url":"https://api.github.com/users/friedmud/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/idaholab/moose/labels/PR:%20Under%20Development","name":"PR: Under Development","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-03T06:06:47Z","updated_at":"2015-09-03T16:20:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/idaholab/moose/pulls/5661","html_url":"https://github.com/idaholab/moose/pull/5661","diff_url":"https://github.com/idaholab/moose/pull/5661.diff","patch_url":"https://github.com/idaholab/moose/pull/5661.patch"},"body":"The code fairy has left you a package :wink: \r\n\r\nI probably should have done this a few years ago... but better late than never.\r\n\r\nThis adds proper Automatic Differentiation support to MOOSE!\r\n\r\nIt's using @roystgnr 's https://github.com/roystgnr/MetaPhysicL , but of course it's all wrapped up nice and tidy so our users don't even see any templating!\r\n\r\nHere's how it works:\r\n\r\n1.  There is a new type called `ADReal`.  Use it anywhere you would normally use a `Real` and it will keep track of derivative information.  (other new types: ADRealVectorValue, ADRealTensor, ADVariableValue, ADVariableGradient, ADVariableSecond)\r\n2.  There is a new `Kernel` called `ADKernel` that implements `computeJacobian()` and `computeOffDiagJacobian()` automatically.  All a user needs to do is inherit from `ADKernel` and fill out `computeQpResidual()` like normal and all the Jacobian stuff is taken care of!\r\n3.  To enable this `MooseVariable` can now be asked for AD versions of value, gradient and second derivative (note that \"old\" and \"older\" are unnecessary as they don't need to carry derivative information).  Currently these values are only computed for Element quadrature points (just the point that I'm at currently... nothing stopping the rest).\r\n3.  ADReal also works as a material property!  That means, for the first time, we can get _perfect_ derivatives of residuals... even if they couple to highly nonlinear material properties (including off-diagonal Jacobians!)\r\n4.  MetaPhysicL tracks derivatives in a big long vector that hangs off of a regular Real value.  I'm using each entry in that vector to represent the derivative of the quantity with respect to a particular coefficient on the current element.  To do that, I compute an offset into that vector for each variable (using the maximum number of DoFs by any variable on any element.. the new `MaxVarNDofsPerElem` object).\r\n5.  There is currently a bug in MetaPhysicL so we cannot use dynamically sized derivative vectors... the current limit is 100 DoFs per element... set arbitrarily by me to just get up and running.  Once @roystgnr gives me the green light I'll switch over to dynamically sized stuff and the 100 DoF per element restriction will go away.\r\n6.  This all requires C++11... I guess it's time to thrown that switch (we're going to want it for that scripting language that @aeslaughter found anyway)\r\n\r\nI've implemented all of this _along side_ the current way of doing things.  This means that we can merge this in, even if it's not complete.  I would like to do that so that I can start to get some feedback and find bugs.\r\n\r\nNote: I know it won't pass the tests right now... mainly because of C++11 support.  I've added a crap-ton of tests on my own too... trying to cover most corners, but, as with any new tests I'm sure I'll need to shake them out a bit.\r\n\r\nAll-in-all this is not bad at all.  It all went a little more smoothly than I thought.  There is still a lot left to do (look at my list over here: https://github.com/idaholab/moose/issues/5658 ) but this is a REALLY good start!"},"comment":{"url":"https://api.github.com/repos/idaholab/moose/issues/comments/137501288","html_url":"https://github.com/idaholab/moose/pull/5661#issuecomment-137501288","issue_url":"https://api.github.com/repos/idaholab/moose/issues/5661","id":137501288,"user":{"login":"jwpeterson","id":1775907,"avatar_url":"https://avatars.githubusercontent.com/u/1775907?v=3","gravatar_id":"","url":"https://api.github.com/users/jwpeterson","html_url":"https://github.com/jwpeterson","followers_url":"https://api.github.com/users/jwpeterson/followers","following_url":"https://api.github.com/users/jwpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jwpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jwpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwpeterson/subscriptions","organizations_url":"https://api.github.com/users/jwpeterson/orgs","repos_url":"https://api.github.com/users/jwpeterson/repos","events_url":"https://api.github.com/users/jwpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jwpeterson/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T16:20:29Z","updated_at":"2015-09-03T16:20:29Z","body":"Should we add MetaPhysicL as a git submodule for https://github.com/roystgnr/MetaPhysicL instead of just copying it into contrib.  Seems like it's under active development..."}}