function intrpDisp = interpolateDisplacement(obj,varargin)
%interpolateDisplacement - Interpolate displacement at specified spatial locations for all time steps
% intrpDisp = interpolateDisplacement(R,QP) interpolates all components of
% displacement vector in a TransientStructuralResults object R at the query
% point locations QP for all time steps. The points QP are represented as
% an Ndim-by-Numq matrix, where Ndim is the number of spatial dimensions,
% and Numq is the number of query points. The output intrpDisp is a
% FEStruct object with the properties that represent the spatial components of
% displacement vector at the query points QP.
%
% intrpDisp = interpolateDisplacement(R,xq,yq) and 
% intrpDisp = interpolateDisplacement(R,xq,yq,zq) interpolates the
% displacement vector to the query points specified as vectors of
% coordinates or an N-D grid.
% 
%     % Example: Interpolate displacement at the geometric center of a beam
%     % subject to harmonic excitation.
% 
%     %Create a dynamic model, assign a beam geometry, and generate a mesh.
%     model = createpde('structural','transient-solid');
%     gm = multicuboid(0.06,0.005,0.01);
%     model.Geometry = gm;
%     generateMesh(model,'Hmax',0.01);
% 
%     % Assign material properties.
%     structuralProperties(model,'YoungsModulus',210E9,'PoissonsRatio',0.3,...
%                                                            'MassDensity',7800);
% 
%     % Fix one end of the beam.
%     structuralBC(model,'Face',5,'Constraint','fixed');
% 
%     % Apply a harmonically varying prescribed displacement along y-direction on
%     % the end opposite to the fixed end of the beam.
%     yDisplacementFunc = @(region,state) ones(size(region.y))*1E-4*sin(50*state.time);
%     structuralBC(model,'Face',3,'YDisplacement',yDisplacementFunc);
% 
%     % Specify zero initial displacement and velocity. Solve the model.
%     structuralIC(model,'Displacement',[0,0,0],'Velocity',[0,0,0]);
%     tlist = 0:0.002:0.2;
%     R = solve(model,tlist);
% 
%     % Interpolate displacement at the geometric center of the beam.
%     coordsMidSpan = [0;0;0.005];
%     intrpDisp = interpolateDisplacement(R,coordsMidSpan);
% 
%     %Plot the y-displacement of the geometric center of the beam.
%     figure
%     plot(R.SolutionTimes,intrpDisp.uy)
%     title('Y-Displacement of the Geometric Center of the Beam')
%
% See also pde.StructuralModel/solve,
% pde.TransientStructuralResults/interpolateVelocity, 
% pde.TransientStructuralResults/interpolateAcceleration, 
% pde.TransientStructuralResults/evaluateStress, 
% pde.TransientStructuralResults/evaluateStrain, 
% pde.TransientStructuralResults/interpolateStress, 
% pde.TransientStructuralResults/evaluateVonMisesStress,
% pde.TransientStructuralResults/evaluateReaction

% Copyright 2017-2022 The MathWorks, Inc.

interpolatedVector = interpolateVectorDataInternal(obj,'Displacement', varargin{:});
intrpDisp = FEStruct('Displacement',obj.ElasticityType,interpolatedVector);

end