In the realm of civil engineering, discuss the underlying principles and applications of finite element analysis (FEA) in structural mechanics. Explore its significance in predicting the behavior of complex structures under varying loads and environmental conditions. Highlight the key mathematical concepts and computational techniques involved in FEA, and elucidate its role in optimizing structural designs for durability, safety, and cost-effectiveness.