  A heap is a set with a certain ternary operation that is self-distributive
(TSD) and exemplified by a group with the operation $(x,y,z)\mapsto xy^{-1}z$.
We introduce and investigate framed link invariants using heaps. In analogy
with the knot group, we define the fundamental heap of framed links using group
presentations. The fundamental heap is determined for some classes of links
such as certain families of torus and pretzel links. We show that for these
families of links there exist epimorphisms from fundamental heaps to Vinberg
and Coxeter groups, implying that corresponding groups are infinite. A relation
to the Wirtinger presentation is also described. The cocycle invariant is
defined using ternary self-distributive (TSD) cohomology, by means of a state
sum that uses ternary heap $2$-cocycles as weights. This invariant corresponds
to a rack cocycle invariant for the rack constructed by doubling of a heap,
while colorings can be regarded as heap morphisms from the fundamental heap.
For the construction of the invariant, first computational methods for the heap
cohomology are developed. It is shown that the cohomology splits into two
types, called degenerate and nondegenerate, and that the degenerate part is one
dimensional. Subcomplexes are constructed based on group cosets, that allow
computations of the nondegenerate part. Computations of the cocycle invariants
are presented using the cocycles constructed, and conversely, it is proved that
the invariant values can be used to derive algebraic properties of the
cohomology.
