Anharmonic properties from a generalized third-orderab initioapproach: Theory and applications to graphite and graphene | Synapse