Modeling masonry as a linear elastic no-tension material, an original approach is implemented to analyze 3D structural elements, with special attention to walls. Masonry is replaced by a suitable equivalent orthotropic material with spatially varying elastic properties and negligible stiffness in case of tensile strain. An energy-based minimization problem is implemented to define the distribution and the orientation of the equivalent material for a given compatible load, so as to obtain a compressive state of stress throughout the structural element. A regular mesh of hexahedrons is used to speed up the sensitivity analysis. The capabilities of the approach in predicting no-tension stress solutions in masonry walls is shown, conside...