{"action":"created","issue":{"url":"https://api.github.com/repos/schmie/hemeMove/issues/371","labels_url":"https://api.github.com/repos/schmie/hemeMove/issues/371/labels{/name}","comments_url":"https://api.github.com/repos/schmie/hemeMove/issues/371/comments","events_url":"https://api.github.com/repos/schmie/hemeMove/issues/371/events","html_url":"https://github.com/schmie/hemeMove/issues/371","id":96276531,"number":371,"title":"Implement API for telling LB about forces","user":{"login":"schmie","id":6473158,"avatar_url":"https://avatars.githubusercontent.com/u/6473158?v=3","gravatar_id":"","url":"https://api.github.com/users/schmie","html_url":"https://github.com/schmie","followers_url":"https://api.github.com/users/schmie/followers","following_url":"https://api.github.com/users/schmie/following{/other_user}","gists_url":"https://api.github.com/users/schmie/gists{/gist_id}","starred_url":"https://api.github.com/users/schmie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmie/subscriptions","organizations_url":"https://api.github.com/users/schmie/orgs","repos_url":"https://api.github.com/users/schmie/repos","events_url":"https://api.github.com/users/schmie/events{/privacy}","received_events_url":"https://api.github.com/users/schmie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"schmie","id":6473158,"avatar_url":"https://avatars.githubusercontent.com/u/6473158?v=3","gravatar_id":"","url":"https://api.github.com/users/schmie","html_url":"https://github.com/schmie","followers_url":"https://api.github.com/users/schmie/followers","following_url":"https://api.github.com/users/schmie/following{/other_user}","gists_url":"https://api.github.com/users/schmie/gists{/gist_id}","starred_url":"https://api.github.com/users/schmie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmie/subscriptions","organizations_url":"https://api.github.com/users/schmie/orgs","repos_url":"https://api.github.com/users/schmie/repos","events_url":"https://api.github.com/users/schmie/events{/privacy}","received_events_url":"https://api.github.com/users/schmie/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-07-21T09:58:00Z","updated_at":"2015-07-21T09:58:27Z","closed_at":null,"body":"**Reported by hywel on 9 Aug 2012 10:09 UTC**\nNone"},"comment":{"url":"https://api.github.com/repos/schmie/hemeMove/issues/comments/123246236","html_url":"https://github.com/schmie/hemeMove/issues/371#issuecomment-123246236","issue_url":"https://api.github.com/repos/schmie/hemeMove/issues/371","id":123246236,"user":{"login":"schmie","id":6473158,"avatar_url":"https://avatars.githubusercontent.com/u/6473158?v=3","gravatar_id":"","url":"https://api.github.com/users/schmie","html_url":"https://github.com/schmie","followers_url":"https://api.github.com/users/schmie/followers","following_url":"https://api.github.com/users/schmie/following{/other_user}","gists_url":"https://api.github.com/users/schmie/gists{/gist_id}","starred_url":"https://api.github.com/users/schmie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmie/subscriptions","organizations_url":"https://api.github.com/users/schmie/orgs","repos_url":"https://api.github.com/users/schmie/repos","events_url":"https://api.github.com/users/schmie/events{/privacy}","received_events_url":"https://api.github.com/users/schmie/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T09:58:27Z","updated_at":"2015-07-21T09:58:27Z","body":"**Comment by dholmes on 15 Aug 2012 12:14 UTC**\nI have already implemented something very similar to this as part of #399.\r\n\r\nI chose to create a !BodyForces class to contain these methods (as well as initialisation-from-xml-config code and a !GetForcesForParticle(const Particle&) method).\r\n```\r\n    /** container for all body forces currently active in the simulation */\r\n    class BodyForces\r\n    {\r\n      public:\r\n        /** factory method - gets initial values from xml configuration file */\r\n        static const void InitBodyForces(const io::xml::XmlAbstractionLayer& xml);\r\n\r\n        static const void AddBodyForce(const std::string name, const BodyForce* const);\r\n\r\n        /** accumulates the effects of all known body forces on the particle */\r\n        static const LatticeForceVector GetBodyForcesForParticle(const Particle& particle);\r\n\r\n        static void ClearBodyForcesForAllSiteIds()\r\n        {\r\n          forceForEachSite.clear();\r\n        }\r\n\r\n        static void SetBodyForcesForSiteId(const site_t siteId, const LatticeForceVector force)\r\n        {\r\n          forceForEachSite[= force;\r\n        }\r\n\r\n        static const LatticeForceVector GetBodyForcesForSiteId(const site_t siteId)\r\n        {\r\n          return forceForEachSite[siteId](siteId]);\r\n        }\r\n\r\n      private:\r\n        /**\r\n         * stores the details of all known body forces\r\n         * the value type must be a base class pointer\r\n         * as only pointers are type-compatible in C++\r\n         */\r\n        static std::map<std::string, const BodyForce* const> bodyForces;\r\n        static std::map<site_t, LatticeForceVector> forceForEachSite;\r\n    };\r\n\r\n```\r\n\r\nNote: I have defined !LatticeForce as a scalar, i.e. double, and !LatticeForceVector as a Vector3D<!LatticeForce>.\r\n\r\nThe !BodyForce class is abstract. I am currently implementing an example derivative class for gravity (because that has the simpler physics than magnetism)."}}