DEMO_febio_0049_gap_close_01.m

Below is a demonstration for:

Contents

Keywords

clear; close all; clc;

Plot settings

fontSize=15;
faceAlpha1=0.8;
faceAlpha2=0.3;
markerSize=25;
lineWidth=3;

Control parameters

% Path names
defaultFolder = fileparts(fileparts(mfilename('fullpath')));
savePath=fullfile(defaultFolder,'data','temp');

% Defining file names
febioFebFileNamePart='tempModel';
febioFebFileName=fullfile(savePath,[febioFebFileNamePart,'.feb']); %FEB file name
febioLogFileName=fullfile(savePath,[febioFebFileNamePart,'.txt']); %FEBio log file name
febioLogFileName_disp=[febioFebFileNamePart,'_disp_out.txt']; %Log file name for exporting displacement
febioLogFileName_force=[febioFebFileNamePart,'_force_out.txt']; %Log file name for exporting force
febioLogFileName_stress=[febioFebFileNamePart,'_stress_out.txt']; %Log file name for exporting stress
febioLogFileName_strain=[febioFebFileNamePart,'_strain_out.txt']; %Log file name for exporting strain
febioLogFileName_strainEnergy=[febioFebFileNamePart,'_sed_out.txt']; %Log file name for exporting strain

%Material parameter set
c1_1=1e-3; %Shear-modulus-like parameter
m1_1=2; %Material parameter setting degree of non-linearity
k_1=c1_1*100; %Bulk modulus

% FEA control settings
numTimeSteps=10; %Number of time steps desired
max_refs=25; %Max reforms
max_ups=0; %Set to zero to use full-Newton iterations
opt_iter=10; %Optimum number of iterations
max_retries=5; %Maximum number of retires
dtmin=(1/numTimeSteps)/100; %Minimum time step size
dtmax=1/numTimeSteps; %Maximum time step size
symmetric_stiffness=0;
min_residual=1e-20;

%Specifying dimensions and number of elements
pointSpacing=0.5;
sampleWidth=12; %Width
sampleThickness=pointSpacing*3; %Thickness
sampleHeight=6; %Height
pointSpacings=pointSpacing*ones(1,3); %Desired point spacing between nodes
numElementsWidth=round(sampleWidth/pointSpacings(1)); %Number of elemens in dir 1
numElementsThickness=round(sampleThickness/pointSpacings(2)); %Number of elemens in dir 2
numElementsHeight=round(sampleHeight/pointSpacings(3)); %Number of elemens in dir 3

A=3;
S=1.5;

Creating model geometry and mesh

A box is created with tri-linear hexahedral (hex8) elements using the hexMeshBox function. The function offers the boundary faces with seperate labels for the top, bottom, left, right, front, and back sides. As such these can be used to define boundary conditions on the exterior.

% Create a box with hexahedral elements
cubeDimensions=[sampleWidth sampleThickness sampleHeight]; %Dimensions
cubeElementNumbers=[numElementsWidth numElementsThickness numElementsHeight]; %Number of elements
outputStructType=2; %A structure compatible with mesh view
[meshStruct]=hexMeshBox(cubeDimensions,cubeElementNumbers,outputStructType);

%Access elements, nodes, and faces from the structure
E=meshStruct.elements; %The elements
V=meshStruct.nodes; %The nodes (vertices)
Fb=meshStruct.facesBoundary; %The boundary faces
Cb=meshStruct.boundaryMarker; %The "colors" or labels for the boundary faces
elementMaterialIndices=ones(size(E,1),1); %Element material indices

Plotting model boundary surfaces and a cut view

hFig=cFigure;

subplot(1,2,1); hold on;
title('Model boundary surfaces and labels','FontSize',fontSize);
gpatch(Fb,V,Cb,'k',faceAlpha1);
colormap(gjet(6)); icolorbar;
axisGeom(gca,fontSize);

hs=subplot(1,2,2); hold on;
title('Cut view of solid mesh','FontSize',fontSize);
optionStruct.hFig=[hFig hs];
meshView(meshStruct,optionStruct);
axisGeom(gca,fontSize);

drawnow;
T=-V(:,3);
minT=min(T(:));
T=T-minT;
maxT=max(T(:));
T=T./maxT;

x=V(:,1);
G=A*exp(-(x.^2)./(2*S^2));
G(G<pointSpacing/10)=0;
V(:,3)=V(:,3)+(G.*T);
minV=min(V(:,3));
V(:,3)=V(:,3)-min(V(:,3));

Visualize map

cFigure; hold on;
gpatch(Fb,V,T,'k',faceAlpha1);
colormap viridis; colorbar;
axisGeom(gca,fontSize);
drawnow;

cFigure; hold on;
gpatch(Fb,V,T,'k',faceAlpha1);
colormap viridis; colorbar;
axisGeom(gca,fontSize);
drawnow;
E=[E;E(:,[5 6 7 8 1 2 3 4])+size(V,1);];
Fb=[Fb;fliplr(Fb)+size(V,1);];
Cb=[Cb;Cb];

V2=V;
V2(:,3)=-V2(:,3);
V=[V;V2];
F=element2patch(E);

[F,V,~,ind2]=mergeVertices(F,V);

E=ind2(E);
Fb=ind2(Fb);
[~,ind1,ind2,faceCount]=cunique(sort(Fb,2),'rows');
Fb=Fb(faceCount==1,:);
Cb=Cb(faceCount==1,:);
cFigure; hold on;
gpatch(Fb,V,Cb,'k',0.5,1);
axisGeom(gca,fontSize);
camlight headlight;
colormap gjet; icolorbar;
drawnow;

Define boundary conditions

bcPrescribeList=unique(Fb(Cb==5,:));
displacementMagnitude_Z=-V(bcPrescribeList,3);
bcSupportList=unique(Fb(ismember(Cb,[1 2 6]),:));

Visualize BC's

cFigure;
title('Boundary conditions model','FontSize',fontSize);
hold on;

gpatch(Fb,V,'w','none',0.5,1);

hl2(1)=plotV(V(bcSupportList,:),'k.','MarkerSize',markerSize);
hl2(2)=plotV(V(bcPrescribeList,:),'r.','MarkerSize',markerSize);
quiverVec(V(bcPrescribeList,:),[zeros(size(displacementMagnitude_Z)) zeros(size(displacementMagnitude_Z)) displacementMagnitude_Z])
legend(hl2,{'BC support','BC prescribe'});

axisGeom(gca,fontSize);
camlight headlight;
drawnow;

Defining the FEBio input structure

See also febioStructTemplate and febioStruct2xml and the FEBio user manual.

%Get a template with default settings
[febio_spec]=febioStructTemplate;

%febio_spec version
febio_spec.ATTR.version='2.5';

%Module section
febio_spec.Module.ATTR.type='solid';

%Control section
febio_spec.Control.analysis.ATTR.type='static';
febio_spec.Control.time_steps=numTimeSteps;
febio_spec.Control.step_size=1/numTimeSteps;
febio_spec.Control.time_stepper.dtmin=dtmin;
febio_spec.Control.time_stepper.dtmax=dtmax;
febio_spec.Control.time_stepper.max_retries=max_retries;
febio_spec.Control.time_stepper.opt_iter=opt_iter;
febio_spec.Control.max_refs=max_refs;
febio_spec.Control.max_ups=max_ups;
febio_spec.Control.symmetric_stiffness=symmetric_stiffness;
febio_spec.Control.min_residual=min_residual;

%Material section
febio_spec.Material.material{1}.ATTR.type='Ogden';
febio_spec.Material.material{1}.ATTR.id=1;
febio_spec.Material.material{1}.c1=c1_1;
febio_spec.Material.material{1}.m1=m1_1;
febio_spec.Material.material{1}.c2=c1_1;
febio_spec.Material.material{1}.m2=-m1_1;
febio_spec.Material.material{1}.k=k_1;

%Geometry section
% -> Nodes
febio_spec.Geometry.Nodes{1}.ATTR.name='nodeSet_all'; %The node set name
febio_spec.Geometry.Nodes{1}.node.ATTR.id=(1:size(V,1))'; %The node id's
febio_spec.Geometry.Nodes{1}.node.VAL=V; %The nodel coordinates

% -> Elements
febio_spec.Geometry.Elements{1}.ATTR.type='hex8'; %Element type of this set
febio_spec.Geometry.Elements{1}.ATTR.mat=1; %material index for this set
febio_spec.Geometry.Elements{1}.ATTR.name='mat1'; %Name of the element set
febio_spec.Geometry.Elements{1}.elem.ATTR.id=(1:1:size(E,1))'; %Element id's
febio_spec.Geometry.Elements{1}.elem.VAL=E;

% -> NodeSets
febio_spec.Geometry.NodeSet{1}.ATTR.name='bcSupportList';
febio_spec.Geometry.NodeSet{1}.node.ATTR.id=bcSupportList(:);

febio_spec.Geometry.NodeSet{2}.ATTR.name='bcPrescribe';
febio_spec.Geometry.NodeSet{2}.node.ATTR.id=bcPrescribeList(:);

%Boundary condition section
% -> Fix boundary conditions
febio_spec.Boundary.fix{1}.ATTR.bc='x';
febio_spec.Boundary.fix{1}.ATTR.node_set=febio_spec.Geometry.NodeSet{1}.ATTR.name;
febio_spec.Boundary.fix{2}.ATTR.bc='y';
febio_spec.Boundary.fix{2}.ATTR.node_set=febio_spec.Geometry.NodeSet{1}.ATTR.name;
febio_spec.Boundary.fix{3}.ATTR.bc='z';
febio_spec.Boundary.fix{3}.ATTR.node_set=febio_spec.Geometry.NodeSet{1}.ATTR.name;

% febio_spec.Boundary.fix{4}.ATTR.bc='x';
% febio_spec.Boundary.fix{4}.ATTR.node_set=febio_spec.Geometry.NodeSet{2}.ATTR.name;
% febio_spec.Boundary.fix{5}.ATTR.bc='y';
% febio_spec.Boundary.fix{5}.ATTR.node_set=febio_spec.Geometry.NodeSet{2}.ATTR.name;

% -> Prescribe boundary conditions

%Define mesh data for displacement increments
febio_spec.MeshData.NodeData{1}.ATTR.name='Z-displacement';
febio_spec.MeshData.NodeData{1}.ATTR.node_set=febio_spec.Geometry.NodeSet{2}.ATTR.name;
febio_spec.MeshData.NodeData{1}.node.ATTR.lid=(1:1:numel(bcPrescribeList))';
febio_spec.MeshData.NodeData{1}.node.VAL=displacementMagnitude_Z;

%Define prescribed displacements
febio_spec.Boundary.prescribe{1}.ATTR.bc='z';
febio_spec.Boundary.prescribe{1}.ATTR.node_set=febio_spec.Geometry.NodeSet{2}.ATTR.name;
febio_spec.Boundary.prescribe{1}.scale.ATTR.lc=1;
febio_spec.Boundary.prescribe{1}.scale.VAL=1;
febio_spec.Boundary.prescribe{1}.relative=1;
febio_spec.Boundary.prescribe{1}.value.ATTR.node_data=febio_spec.MeshData.NodeData{1}.ATTR.name;

%Output section
% -> log file
febio_spec.Output.logfile.ATTR.file=febioLogFileName;
febio_spec.Output.logfile.node_data{1}.ATTR.file=febioLogFileName_disp;
febio_spec.Output.logfile.node_data{1}.ATTR.data='ux;uy;uz';
febio_spec.Output.logfile.node_data{1}.ATTR.delim=',';
febio_spec.Output.logfile.node_data{1}.VAL=1:size(V,1);

febio_spec.Output.logfile.element_data{1}.ATTR.file=febioLogFileName_stress;
febio_spec.Output.logfile.element_data{1}.ATTR.data='s1;s2;s3';
febio_spec.Output.logfile.element_data{1}.ATTR.delim=',';
febio_spec.Output.logfile.element_data{1}.VAL=1:size(E,1);

febio_spec.Output.logfile.element_data{2}.ATTR.file=febioLogFileName_strain;
febio_spec.Output.logfile.element_data{2}.ATTR.data='E1;E2;E3';
febio_spec.Output.logfile.element_data{2}.ATTR.delim=',';
febio_spec.Output.logfile.element_data{2}.VAL=1:size(E,1);

febio_spec.Output.logfile.element_data{3}.ATTR.file=febioLogFileName_strainEnergy;
febio_spec.Output.logfile.element_data{3}.ATTR.data='sed';
febio_spec.Output.logfile.element_data{3}.ATTR.delim=',';
febio_spec.Output.logfile.element_data{3}.VAL=1:size(E,1);

febio_spec.Output.logfile.node_data{2}.ATTR.file=febioLogFileName_force;
febio_spec.Output.logfile.node_data{2}.ATTR.data='Rx;Ry;Rz';
febio_spec.Output.logfile.node_data{2}.ATTR.delim=',';
febio_spec.Output.logfile.node_data{2}.VAL=1:size(V,1);

Quick viewing of the FEBio input file structure

The febView function can be used to view the xml structure in a MATLAB figure window.

febView(febio_spec); %Viewing the febio file

Exporting the FEBio input file

Exporting the febio_spec structure to an FEBio input file is done using the febioStruct2xml function.

febioStruct2xml(febio_spec,febioFebFileName); %Exporting to file and domNode

Running the FEBio analysis

To run the analysis defined by the created FEBio input file the runMonitorFEBio function is used. The input for this function is a structure defining job settings e.g. the FEBio input file name. The optional output runFlag informs the user if the analysis was run succesfully.

febioAnalysis.run_filename=febioFebFileName; %The input file name
febioAnalysis.run_logname=febioLogFileName; %The name for the log file
febioAnalysis.disp_on=1; %Display information on the command window
febioAnalysis.disp_log_on=1; %Display convergence information in the command window
febioAnalysis.runMode='internal';%'internal';
febioAnalysis.t_check=0.25; %Time for checking log file (dont set too small)
febioAnalysis.maxtpi=1e99; %Max analysis time
febioAnalysis.maxLogCheckTime=10; %Max log file checking time

[runFlag]=runMonitorFEBio(febioAnalysis);%START FEBio NOW!!!!!!!!
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- STARTING FEBIO JOB --- 13-Mar-2020 12:17:02
===========================================================================
         ________    _________   _________     __     _________            
        |        |\ |        |\ |        |\   |  |\  /         \\          
        |    ____|| |    ____|| |    __  ||   |__|| |    ___    ||         
        |   |\___\| |   |\___\| |   |\_| ||    \_\| |   //  \   ||         
        |   ||      |   ||      |   || | ||    __   |  ||    |  ||         
        |   ||__    |   ||__    |   ||_| ||   |  |\ |  ||    |  ||         
        |       |\  |       |\  |         \\  |  || |  ||    |  ||         
        |    ___||  |    ___||  |    ___   || |  || |  ||    |  ||         
        |   |\__\|  |   |\__\|  |   |\__|  || |  || |  ||    |  ||         
        |   ||      |   ||      |   ||  |  || |  || |  ||    |  ||         
        |   ||      |   ||___   |   ||__|  || |  || |   \\__/   ||         
        |   ||      |        |\ |          || |  || |           ||         
        |___||      |________|| |__________|| |__||  \_________//          
                                                                           
      F I N I T E   E L E M E N T S   F O R   B I O M E C H A N I C S      
                                                                           
                 --- v e r s i o n - 2 . 9 . 1 ---                 
                                                                           
                                                                           
  http://febio.org                                                         
  FEBio is a registered trademark.                                         
  copyright (c) 2006-2019 - All rights reserved                            
                                                                           
===========================================================================


Reading file /mnt/data/MATLAB/GIBBON/data/temp/tempModel.feb ...SUCCESS!
 ]0;(0%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 1 : 0.1 =====
Reforming stiffness matrix: reformation #1

===== reforming stiffness matrix:
	Nr of equations ........................... : 6552
	Nr of nonzeroes in stiffness matrix ....... : 408780

 1
 Nonlinear solution status: time= 0.1
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.781046e-02    5.155469e-06    0.000000e+00 
	   energy              2.466391e-01    9.463724e-04    2.466391e-03 
	   displacement        1.424295e+01    1.424295e+01    1.424295e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.1
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.781046e-02    3.294243e-10    0.000000e+00 
	   energy              2.466391e-01    3.618907e-08    2.466391e-03 
	   displacement        1.424295e+01    3.010767e-02    1.418118e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.1
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.781046e-02    1.952464e-13    0.000000e+00 
	   energy              2.466391e-01    5.181604e-11    2.466391e-03 
	   displacement        1.424295e+01    2.074613e-04    1.415881e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.1
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.781046e-02    1.041911e-23    0.000000e+00 
	   energy              2.466391e-01    1.427569e-17    2.466391e-03 
	   displacement        1.424295e+01    7.112444e-10    1.415871e-05 

------- converged at time : 0.1

 ]0;(10%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 2 : 0.2 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.2
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.068368e-02    3.991266e-06    0.000000e+00 
	   energy              2.280276e-01    6.299015e-04    2.280276e-03 
	   displacement        1.408445e+01    1.408445e+01    1.408445e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.2
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.068368e-02    1.688876e-10    0.000000e+00 
	   energy              2.280276e-01    3.437595e-08    2.280276e-03 
	   displacement        1.408445e+01    2.065864e-02    1.400717e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.2
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.068368e-02    4.100442e-14    0.000000e+00 
	   energy              2.280276e-01    4.476794e-13    2.280276e-03 
	   displacement        1.408445e+01    1.126066e-04    1.398396e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.2
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            3.068368e-02    2.508361e-25    0.000000e+00 
	   energy              2.280276e-01    1.042366e-18    2.280276e-03 
	   displacement        1.408445e+01    1.144829e-10    1.398393e-05 

------- converged at time : 0.2

 ]0;(20%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 3 : 0.3 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.3
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            2.472222e-02    3.319791e-06    0.000000e+00 
	   energy              2.090185e-01    4.405340e-04    2.090185e-03 
	   displacement        1.389516e+01    1.389516e+01    1.389516e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.3
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            2.472222e-02    1.113544e-10    0.000000e+00 
	   energy              2.090185e-01    4.430250e-08    2.090185e-03 
	   displacement        1.389516e+01    1.481024e-02    1.381637e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.3
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            2.472222e-02    1.161930e-14    0.000000e+00 
	   energy              2.090185e-01    5.806135e-13    2.090185e-03 
	   displacement        1.389516e+01    6.995082e-05    1.379865e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.3
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            2.472222e-02    3.291314e-26    0.000000e+00 
	   energy              2.090185e-01    2.917009e-19    2.090185e-03 
	   displacement        1.389516e+01    3.927074e-11    1.379864e-05 

------- converged at time : 0.3

 ]0;(30%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 4 : 0.4 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.4
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.994460e-02    2.834827e-06    0.000000e+00 
	   energy              1.908750e-01    3.225712e-04    1.908750e-03 
	   displacement        1.371579e+01    1.371579e+01    1.371579e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.4
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.994460e-02    8.050435e-11    0.000000e+00 
	   energy              1.908750e-01    4.309253e-08    1.908750e-03 
	   displacement        1.371579e+01    1.087964e-02    1.364688e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.4
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.994460e-02    3.544402e-15    0.000000e+00 
	   energy              1.908750e-01    2.710718e-12    1.908750e-03 
	   displacement        1.371579e+01    4.616750e-05    1.363638e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.4
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.994460e-02    6.166314e-27    0.000000e+00 
	   energy              1.908750e-01    7.223170e-20    1.908750e-03 
	   displacement        1.371579e+01    2.005433e-11    1.363637e-05 

------- converged at time : 0.4

 ]0;(40%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 5 : 0.5 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.5
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.621223e-02    2.428217e-06    0.000000e+00 
	   energy              1.741809e-01    2.434307e-04    1.741809e-03 
	   displacement        1.357054e+01    1.357054e+01    1.357054e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.5
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.621223e-02    5.937366e-11    0.000000e+00 
	   energy              1.741809e-01    3.954444e-08    1.741809e-03 
	   displacement        1.357054e+01    8.089323e-03    1.351613e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.5
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.621223e-02    1.202789e-15    0.000000e+00 
	   energy              1.741809e-01    3.988113e-12    1.741809e-03 
	   displacement        1.357054e+01    3.225826e-05    1.351209e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.5
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.621223e-02    1.152431e-27    0.000000e+00 
	   energy              1.741809e-01    1.748203e-20    1.741809e-03 
	   displacement        1.357054e+01    1.347086e-11    1.351209e-05 

------- converged at time : 0.5

 ]0;(50%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 6 : 0.6 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.6
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.334118e-02    2.067127e-06    0.000000e+00 
	   energy              1.591085e-01    1.815464e-04    1.591085e-03 
	   displacement        1.346497e+01    1.346497e+01    1.346497e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.6
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.334118e-02    4.341531e-11    0.000000e+00 
	   energy              1.591085e-01    3.531263e-08    1.591085e-03 
	   displacement        1.346497e+01    6.043549e-03    1.342321e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.6
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.334118e-02    5.291240e-16    0.000000e+00 
	   energy              1.591085e-01    3.789240e-12    1.591085e-03 
	   displacement        1.346497e+01    2.341042e-05    1.342378e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.6
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.334118e-02    6.224625e-28    0.000000e+00 
	   energy              1.591085e-01    1.262148e-20    1.591085e-03 
	   displacement        1.346497e+01    1.005913e-11    1.342378e-05 

------- converged at time : 0.6

 ]0;(60%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 7 : 0.7 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.7
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.115366e-02    1.746142e-06    0.000000e+00 
	   energy              1.456001e-01    1.228640e-04    1.456001e-03 
	   displacement        1.339030e+01    1.339030e+01    1.339030e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.7
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.115366e-02    3.132385e-11    0.000000e+00 
	   energy              1.456001e-01    3.107668e-08    1.456001e-03 
	   displacement        1.339030e+01    4.513534e-03    1.335508e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.7
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.115366e-02    2.967022e-16    0.000000e+00 
	   energy              1.456001e-01    2.911469e-12    1.456001e-03 
	   displacement        1.339030e+01    1.698115e-05    1.335835e-05 
Reforming stiffness matrix: reformation #4

 4
 Nonlinear solution status: time= 0.7
	stiffness updates             = 0
	right hand side evaluations   = 5
	stiffness matrix reformations = 4
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            1.115366e-02    7.406912e-28    0.000000e+00 
	   energy              1.456001e-01    1.124474e-20    1.456001e-03 
	   displacement        1.339030e+01    6.696426e-12    1.335836e-05 

------- converged at time : 0.7

 ]0;(70%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 8 : 0.8 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.8
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            9.497638e-03    1.466527e-06    0.000000e+00 
	   energy              1.334972e-01    6.017164e-05    1.334972e-03 
	   displacement        1.333014e+01    1.333014e+01    1.333014e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.8
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            9.497638e-03    2.236933e-11    0.000000e+00 
	   energy              1.334972e-01    2.746228e-08    1.334972e-03 
	   displacement        1.333014e+01    3.355968e-03    1.329385e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.8
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            9.497638e-03    1.675271e-16    0.000000e+00 
	   energy              1.334972e-01    1.928423e-12    1.334972e-03 
	   displacement        1.333014e+01    1.198211e-05    1.329836e-05 

------- converged at time : 0.8

 ]0;(80%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 9 : 0.9 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 0.9
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            8.250300e-03    1.228594e-06    0.000000e+00 
	   energy              1.226226e-01    7.738012e-06    1.226226e-03 
	   displacement        1.326684e+01    1.326684e+01    1.326684e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 0.9
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            8.250300e-03    1.586063e-11    0.000000e+00 
	   energy              1.226226e-01    2.476917e-08    1.226226e-03 
	   displacement        1.326684e+01    2.480542e-03    1.322284e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 0.9
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            8.250300e-03    8.503257e-17    0.000000e+00 
	   energy              1.226226e-01    1.149339e-12    1.226226e-03 
	   displacement        1.326684e+01    8.195371e-06    1.322765e-05 

------- converged at time : 0.9

 ]0;(90%) tempModel.feb - FEBio 2.9.1.0  
===== beginning time step 10 : 1 =====
Reforming stiffness matrix: reformation #1

 1
 Nonlinear solution status: time= 1
	stiffness updates             = 0
	right hand side evaluations   = 2
	stiffness matrix reformations = 1
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            7.315007e-03    1.030431e-06    0.000000e+00 
	   energy              1.128226e-01    7.776228e-05    1.128226e-03 
	   displacement        1.318631e+01    1.318631e+01    1.318631e-05 
Reforming stiffness matrix: reformation #2

 2
 Nonlinear solution status: time= 1
	stiffness updates             = 0
	right hand side evaluations   = 3
	stiffness matrix reformations = 2
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            7.315007e-03    1.118211e-11    0.000000e+00 
	   energy              1.128226e-01    2.284008e-08    1.128226e-03 
	   displacement        1.318631e+01    1.828962e-03    1.313065e-05 
Reforming stiffness matrix: reformation #3

 3
 Nonlinear solution status: time= 1
	stiffness updates             = 0
	right hand side evaluations   = 4
	stiffness matrix reformations = 3
	step from line search         = 1.000000
	convergence norms :     INITIAL         CURRENT         REQUIRED
	   residual            7.315007e-03    3.888344e-17    0.000000e+00 
	   energy              1.128226e-01    6.376155e-13    1.128226e-03 
	   displacement        1.318631e+01    5.507539e-06    1.313523e-05 

------- converged at time : 1

 ]0;(100%) tempModel.feb - FEBio 2.9.1.0  

N O N L I N E A R   I T E R A T I O N   I N F O R M A T I O N

	Number of time steps completed .................... : 10

	Total number of equilibrium iterations ............ : 37

	Average number of equilibrium iterations .......... : 3.7

	Total number of right hand evaluations ............ : 47

	Total number of stiffness reformations ............ : 37

	Time in linear solver: 0:00:02


 Elapsed time : 0:00:04


 N O R M A L   T E R M I N A T I O N

Waiting for log file...
Proceeding to check log file...13-Mar-2020 12:17:06
------- converged at time : 0.1
------- converged at time : 0.2
------- converged at time : 0.3
------- converged at time : 0.4
------- converged at time : 0.5
------- converged at time : 0.6
------- converged at time : 0.7
------- converged at time : 0.8
------- converged at time : 0.9
------- converged at time : 1
--- Done --- 13-Mar-2020 12:17:07

Import FEBio results

if runFlag==1 %i.e. a succesful run

    % Importing nodal displacements from a log file
    [time_mat, N_disp_mat,~]=importFEBio_logfile(fullfile(savePath,febioLogFileName_disp)); %Nodal displacements
    time_mat=[0; time_mat(:)]; %Time

    N_disp_mat=N_disp_mat(:,2:end,:);
    sizImport=size(N_disp_mat);
    sizImport(3)=sizImport(3)+1;
    N_disp_mat_n=zeros(sizImport);
    N_disp_mat_n(:,:,2:end)=N_disp_mat;
    N_disp_mat=N_disp_mat_n;

    DN_MAG=sqrt(sum(N_disp_mat.^2,2));
    DN=N_disp_mat(:,:,end);
    DN_magnitude=sqrt(sum(DN(:,3).^2,2));
    V_def=V+DN;
    V_DEF=N_disp_mat+repmat(V,[1 1 size(N_disp_mat,3)]);
    X_DEF=V_DEF(:,1,:);
    Y_DEF=V_DEF(:,2,:);
    Z_DEF=V_DEF(:,3,:);
    %     [CF]=vertexToFaceMeasure(Fb,DN_magnitude);

    for q=1:1:numel(febio_spec.Output.logfile.element_data)

        elementDataFileName=febio_spec.Output.logfile.element_data{q}.ATTR.file;

        % Importing element data from log file
        [~,E_data,~]=importFEBio_logfile(fullfile(savePath,elementDataFileName)); %Element data

        %Remove nodal index column
        E_data=E_data(:,2:end,:);

        %Add initial state
        sizImport=size(E_data);
        sizImport(3)=sizImport(3)+1;
        if strcmp('J',febio_spec.Output.logfile.element_data{q}.ATTR.data)
            E_data_mat_n=ones(sizImport);
        else
            E_data_mat_n=zeros(sizImport);
        end
        E_data_mat_n(:,:,2:end)=E_data;
        E_data=E_data_mat_n;

        for qd=1:1:size(E_data,2)
            E_data_now=E_data(:,qd,:);

            [F,CF]=element2patch(E,E_data_now(:,:,1));

            % Plotting the simulated results using |anim8| to visualize and animate
            % deformations

            % Create basic view and store graphics handle to initiate animation
            hf=cFigure; %Open figure
            gtitle([febioFebFileNamePart,', data: ',febio_spec.Output.logfile.element_data{q}.ATTR.data,', index: ',num2str(qd)]);

            hold on;
            hp1=gpatch(F,V_def,CF,'k',1); %Add graphics object to animate

            %     gpatch(FE,V,0.5*ones(1,3),'k',0.25); %A static graphics object

            colormap(gca,gjet(250)); hc=colorbar;

            caxis([min(E_data_now(:)) max(E_data_now(:))]);
            axisGeom(gca,fontSize);
            axis([min(X_DEF(:)) max(X_DEF(:)) min(Y_DEF(:)) max(Y_DEF(:)) min(Z_DEF(:)) max(Z_DEF(:))]);
            axis manual;
            camlight headlight;
            drawnow;

            % Set up animation features
            animStruct.Time=time_mat; %The time vector
            for qt=1:1:size(N_disp_mat,3) %Loop over time increments
                DN=N_disp_mat(:,:,qt); %Current displacement
                DN_magnitude=sqrt(sum(DN.^2,2)); %Current displacement magnitude
                V_def=V+DN; %Current nodal coordinates
                [~,CF]=element2patch(E,E_data_now(:,:,qt));

                %Set entries in animation structure
                animStruct.Handles{qt}=[hp1 hp1 ]; %Handles of objects to animate
                animStruct.Props{qt}={'Vertices','CData'}; %Properties of objects to animate
                animStruct.Set{qt}={V_def,CF}; %Property values for to set in order to animate
            end
            anim8(hf,animStruct); %Initiate animation feature
            drawnow;

        end
    end
end

GIBBON www.gibboncode.org

Kevin Mattheus Moerman, [email protected]

GIBBON footer text

License: https://github.com/gibbonCode/GIBBON/blob/master/LICENSE

GIBBON: The Geometry and Image-based Bioengineering add-On. A toolbox for image segmentation, image-based modeling, meshing, and finite element analysis.

Copyright (C) 2019 Kevin Mattheus Moerman

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.