Commit ebf9e11a authored by matecellab's avatar matecellab
Browse files

added option to plot principal strains to extractAbaPlot

parent 19e0ffac
......@@ -52,7 +52,9 @@ if ~isfield(param,'pvar'), param.pvar = 'ESEDEN'; end % plot variable (string, d
if ~isfield(param,'pframe'), param.pframe = -1; end % frames/increments to plot. default = -1 (last frame, end-of-simulation)
if ~isfield(param,'pz'), param.pz = []; end % z-positions to plot. default = [] (position of indenter tip at end of simulation)
if ~isfield(param,'pslice'), param.pslice = []; end % slice postions to plot. Empty = do not use
if ~isfield(param,'svg'), param.svg = 1; end % export svg-figure (1, default) or not (0)
if ~isfield(param,'png'), param.png = 1; end % export png-figure (1, default) or not (0)
if ~isfield(param,'pexec'), param.pexec = 1; end % automagically have abaqus run the script (1, default) or not (0)
for b = 1:numel(basil)
......@@ -75,6 +77,9 @@ for b = 1:numel(basil)
else
fprintf(fid,'param.pslice = [];\n');
end
fprintf(fid,'param.png = %i;\n',param.png);
fprintf(fid,'param.svg = %i;\n',param.svg);
fprintf(fid,'param.pexec = %i;\n',param.pexec);
fclose(fid);
% load bone com (offset model to bone com = [0 0 0])
......@@ -100,9 +105,7 @@ for b = 1:numel(basil)
end
end
% start abaqus modelling script
% start abaqus cae plotting script
fid = fopen(sprintf('basil%i_abaPlot.py',basil(b)),'w+');
fprintf(fid,'"""===============================\n');
fprintf(fid,'Script to make an abaqus job of a rat leg with tibia,\n');
......@@ -125,7 +128,15 @@ for b = 1:numel(basil)
fprintf(fid,'view.setValues(displayedObject=o1)\n');
% select output
fprintf(fid,'# plot variable\n');
fprintf(fid,'view.odbDisplay.setPrimaryVariable(variableLabel=''%s'', outputPosition=WHOLE_ELEMENT, )\n',param.pvar);
if strcmpi(param.pvar,'LEmaxP')
fprintf(fid,'view.odbDisplay.setPrimaryVariable(variableLabel=''LE'', outputPosition=INTEGRATION_POINT, refinement=( INVARIANT, ''Max. Principal''), )\n');
elseif strcmpi(param.pvar,'LEmidP')
fprintf(fid,'view.odbDisplay.setPrimaryVariable(variableLabel=''LE'', outputPosition=INTEGRATION_POINT, refinement=( INVARIANT, ''Mid. Principal''), )\n');
elseif strcmpi(param.pvar,'LEminP')
fprintf(fid,'view.odbDisplay.setPrimaryVariable(variableLabel=''LE'', outputPosition=INTEGRATION_POINT, refinement=( INVARIANT, ''Min. Principal''), )\n');
else
fprintf(fid,'view.odbDisplay.setPrimaryVariable(variableLabel=''%s'', outputPosition=WHOLE_ELEMENT, )\n',param.pvar);
end
% deformed or undeformed mesh
if param.pstate == 0
fprintf(fid,'view.odbDisplay.display.setValues(plotState=CONTOURS_ON_UNDEF)\n');
......@@ -163,38 +174,50 @@ for b = 1:numel(basil)
% select z-position(s) to plot
if isempty(param.pz) % underneath indenter tip end
writez(fid,basil(b),param.pvar,indSE(2,3)-bcom(1,3));
writez(fid,basil(b),param,indSE(2,3)-bcom(1,3));
elseif isnan(param.pz) % underneath indenter tip start
writez(fid,basil(b),param.pvar,indSE(1,3)-bcom(1,3));
writez(fid,basil(b),param,indSE(1,3)-bcom(1,3));
elseif numel(param.pz) == 1 % single manually selected z-slice
writez(fid,basil(b),param.pvar,param.pz-bcom(1,3));
writez(fid,basil(b),param,param.pz-bcom(1,3));
else
for pz = 1:numel(param.pz)
writez(fid,basil(b),param.pvar,param.pz(pz)-bcom(1,3),pz);
writez(fid,basil(b),param,param.pz(pz)-bcom(1,3),pz);
end
end
fclose(fid);
if param.pexec > 0
system(sprintf('abaqus cae noGUI=basil%i_abaPlot.py',basil(b)));
end
end
end
function writez(fid,basil,pvar,z,nz)
function writez(fid,basil,param,z,nz)
fprintf(fid,'\n# pick z-position\n');
fprintf(fid,'view.odbDisplay.viewCuts[''Z-Plane''].setValues(position=%f)\n',z);
fprintf(fid,'view.odbDisplay.setValues(viewCut=ON)\n');
fprintf(fid,'view.odbDisplay.viewCuts[''Z-Plane''].setValues(showModelBelowCut=False)\n');
fprintf(fid,'view.odbDisplay.viewCuts[''Z-Plane''].setValues(showModelOnCut=True)\n');
fprintf(fid,'view.view.fitView()\n');
fprintf(fid,'\n# export plot\n');
if nargin == 4
fprintf(fid,'\n# pick z-position\n');
fprintf(fid,'view.odbDisplay.viewCuts[''Z-Plane''].setValues(position=%f)\n',z);
fprintf(fid,'view.odbDisplay.setValues(viewCut=ON)\n');
fprintf(fid,'view.view.fitView()\n');
fprintf(fid,'# export plot\n');
fprintf(fid,'session.printToFile(fileName=''basil%i_%s.svg'', format=SVG, canvasObjects=(view, ))\n',basil,lower(pvar));
if param.svg > 0
fprintf(fid,'session.printToFile(fileName=''basil%i_%s.svg'', format=SVG, canvasObjects=(view, ))\n',basil,param.pvar);
end
if param.png >0
fprintf(fid,'session.printToFile(fileName=''basil%i_%s.png'', format=PNG, canvasObjects=(view, ))\n',basil,param.pvar);
end
else
fprintf(fid,'\n# pick z-position\n');
fprintf(fid,'view.odbDisplay.viewCuts[''Z-Plane''].setValues(position=%f)\n',z);
fprintf(fid,'view.odbDisplay.setValues(viewCut=ON)\n');
fprintf(fid,'view.view.fitView()\n');
fprintf(fid,'# export plot\n');
fprintf(fid,'session.printToFile(fileName=''basil%i_%s_z%i.svg'', format=SVG, canvasObjects=(view, ))\n',basil,lower(pvar),nz);
if param.svg > 0
fprintf(fid,'session.printToFile(fileName=''basil%i_%s_z%i.svg'', format=SVG, canvasObjects=(view, ))\n',basil,param.pvar,nz);
end
if param.png > 0
fprintf(fid,'session.printToFile(fileName=''basil%i_%s_z%i.png'', format=PNG, canvasObjects=(view, ))\n',basil,param.pvar,nz);
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment