UpdateMesh
PURPOSE 
UPDATEMESH - update the mesh after a time step
SYNOPSIS 
function [new_mesh new_velocity_g new_temperature_g new_pressure_g]=UpdateMesh(md,grids,old_mesh,old_velocity_g,old_temperature_g,old_pressure_g,bed,thickness);
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
This function is called by:
SOURCE CODE 
0001 function [new_mesh new_velocity_g new_temperature_g new_pressure_g]=UpdateMesh(md,grids,old_mesh,old_velocity_g,old_temperature_g,old_pressure_g,bed,thickness);
0002
0003
0004
0005
0006
0007
0008
0009
0010 old_z=old_mesh.grids(:,3);
0011
0012
0013 new_z =old_z;
0014 new_velocity_g =old_velocity_g;
0015 new_temperature_g =old_temperature_g;
0016 new_pressure_g =old_pressure_g;
0017
0018 for i=1:md.numberofgrids2d
0019 for j=1:md.numlayers
0020 count=(j-1)*md.numberofgrids2d+i;
0021 new_z(count)=bed(count)+(j-1)/(md.numlayers-1)*(thickness(count));
0022
0023
0024 if new_z(count)>old_z(count),
0025 if ~isnan(md.uppergrids(count))
0026 old_upper_z=old_z(md.uppergrids(count));
0027 coeff=(new_z(count)-old_z(count))/(old_upper_z-old_z(count));
0028 new_velocity_g(grids(count).grid.doflist)=old_velocity_g(grids(count).grid.doflist)+coeff*(old_velocity_g(grids(count).grid.doflist)-old_velocity_g(grids(md.uppergrids(count)).grid.doflist));
0029 new_temperature_g(grids(count).grid.doflist)=old_temperature_g(grids(count).grid.doflist)+coeff*(old_temperature_g(grids(count).grid.doflist)-old_temperature_g(grids(md.uppergrids(count)).grid.doflist));
0030 new_pressure_g(grids(count).grid.doflist)=old_pressure_g(grids(count).grid.doflist)+coeff*(old_pressure_g(grids(count).grid.doflist)-old_pressure_g(grids(md.uppergrids(count)).grid.doflist));
0031 end
0032 else
0033 if ~isnan(md.lowergrids(count))
0034 old_lower_z=old_z(md.lowergrids(count));
0035 coeff=(new_z(count)-old_z(count))/(old_lower_z-old_z(count));
0036 new_velocity_g(grids(count).grid.doflist)=old_velocity_g(grids(count).grid.doflist)+coeff*(old_velocity_g(grids(count).grid.doflist)-old_velocity_g(grids(md.lowergrids(count)).grid.doflist));
0037 new_temperature_g(grids(count).grid.doflist)=old_temperature_g(grids(count).grid.doflist)+coeff*(old_temperature_g(grids(count).grid.doflist)-old_temperature_g(grids(md.lowergrids(count)).grid.doflist));
0038 new_pressure_g(grids(count).grid.doflist)=old_pressure_g(grids(count).grid.doflist)+coeff*(old_pressure_g(grids(count).grid.doflist)-old_pressure_g(grids(md.lowergrids(count)).grid.doflist));
0039 end
0040 end
0041 end
0042 end
0043
0044
0045 new_mesh.elements=old_mesh.elements;
0046 new_mesh.grids=old_mesh.grids;
0047 new_mesh.grids(:,3)=new_z;
Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003