Hierarchical theories of structures based on Legendre polynomial expansions with finite element applications