Edward,
several answers - and an agreement with Alan

the word "expanding" means just that - but there are ways round it.
first safety - alll uncured Polyurethane is poisonous - very and through the skin. Do not wear latex gloves - use PVC or Nitrile (or polythene) gloves.
One-part foam is sold in all DIY stores (fills big holes, and similar names), it cures by being catalysed by water, so you lightly mist the inside of the space and huff it in carefully to about 1/3 the volume. Do give it somewhere to expand to if it gets toooooooooooooooooooooooooooooooooo big!
remember that it sticks permanently to everything - protect floor, boat, yourself with cloth or newspaper.
Surface hard in about an hour, hard right thru in 24 hours
2-part foam comes from good boat suppliers and alll fibreglass suppliers - see CFS, who have good instructions with it
http://www.cfsnet.co.uk/acatalog/CFS_Catalogue__2_Part_Polyurethane_Foam_Liquid_415.htmlIt is far more controllable and predictable than 1-part, and you can keep the rest of the tin for future use

Suggestion (if you are thinking of doing your cutty sark or similar)
insert plastic bag into the area you are aiming to fill; blow into it so it expands into the space)
Put the ship with this area at the bottom (so the bag fills upwards)
Put in foam to fill about 1/4 of the bag - leave for an hour
never close the open end of the bag
repeat as necessary (if you use 1-part foam you will have to take off the nozzle and clean with acetone or cellulose thinners so that it works later)
when hard chop off the foam and bit of bag you don't need.
This stops the foam bonding to everything in the ship - if you want this for integrity reasons (this is what they do with nail-sick roofs) stick a temporary bulkhead where you want the foam to stop with say a 2 inch hole - tape a plastic bag round the hole - or a big paper funnel so it has sonewhere harmless to expand into.
If I can help more, just ask
BTW - for small volumes I fill with polyurethane woodglue - mixed 1:1 with water - it foams well but not with overwhelming violence and will fille, say a forepeak (and of course bonds everything together)
andrew