A method for producing an essentially defect-free epitaxially grown structure, comprising the steps of: - providing a substrate formed of a first crystalline material, - placing or producing a mask structure on the surface of said substrate, the mask structure comprising: • a first level comprising a first dielectric layer (4,60) provided with at least one opening (1,50,61) through the complete thickness of said layer, so that the bottom of said opening is formed by a portion of the surface of said substrate, • a second level on top of the first, the second level comprising one or more barriers placed at least on two opposite sides of each of said at least one opening (1,61) or of a group of said openings, - growing a second crystalline material by epitaxial growth on said surface portion, the second material having a lattice constant that is different from the lattice constant of the first material, said second material overgrowing said opening (1,61,50) and forming a layer of the second material, wherein the depth and shape of said opening (1,61,50) is such that lattice defects propagating from said surface portion in at least one direction are trapped in said opening (1,61,50), by having a depth of said opening being equal to or higher than three times its width, - stopping said growing step when at least a part of the height of said barrier is covered by the layer of the second material, - planarizing the layer of the second material, wherein: - said opening is a first trench provided in the first dielectric layer OR the first dielectric layer comprises a row of said openings, - the second level further comprises a second dielectric layer on the first dielectric layer (4,60) provided with at least one second trench oriented at an angle different from zero with respect to the first trench or with respect to said row of openings, at least a portion of the second trench or trenches being located laterally with respect to the longitudinal direction of said first trench or row of openings, - any defects propagating in the longitudinal direction of said second trench(es) are trapped in said first trench or in said row of openings, - the depth and width of the second trench or trenches is such that essentially defect-free material grows in at least a portion of the second trench or trenches, by having a depth of said second trench(es) being equal to or higher than three times its width, - said barriers are located at least on two opposite sides of the longitudinal direction of said first trench or of said row of openings. - providing a substrate formed of a first crystalline material, - placing or producing a mask structure on the surface of said substrate, the mask structure comprising: • a first level comprising a first dielectric layer (4,60) provided with at least one opening (1,50,61) through the complete thickness of said layer, so that the bottom of said opening is formed by a portion of the surface of said substrate, • a second level on top of the first, the second level comprising one or more barriers placed at least on two opposite sides of each of said at least one opening (1,61) or of a group of said openings, • a first level comprising a first dielectric layer (4,60) provided with at least one opening (1,50,61) through the complete thickness of said layer, so that the bottom of said opening is formed by a portion of the surface of said substrate, • a second level on top of the first, the second level comprising one or more barriers placed at least on two opposite sides of each of said at least one opening (1,61) or of a group of said openings, - growing a second crystalline material by epitaxial growth on said surface portion, the second material having a lattice constant that is different from the lattice constant of the first material, said second material overgrowing said opening (1,61,50) and forming a layer of the second material, wherein the depth and shape of said opening (1,61,50) is such that lattice defects propagating from said surface portion in at least one direction are trapped in said opening (1,61,50), by having a depth of said opening being equal to or higher than three times its width, - stopping said growing step when at least a part of the height of said barrier is covered by the layer of the second material, - planarizing the layer of the second material, - said opening is a first trench provided in the first dielectric layer OR the first dielectric layer comprises a row of said openings, - the second level further comprises a second dielectric layer on the first dielectric layer (4,60) provided with at least one second trench oriented at an angle different from zero with respect to the first trench or with respect to said row of openings, at least a portion of the second trench or trenches being located laterally with respect to the longitudinal direction of said first trench or row of openings, - any defects propagating in the longitudinal direction of said second trench(es) are trapped in said first trench or in said row of openings, - the depth and width of the second trench or trenches is such that essentially defect-free material grows in at least a portion of the second trench or trenches, by having a depth of said second trench(es) being equal to or higher than three times its width, - said barriers are located at least on two opposite sides of the longitudinal direction of said first trench or of said row of openings.