How to get AssembleFEMatrices for a nonlinear and Time dependent PDE problem in PDEtool box
4 views (last 30 days)
Show older comments
In MATLAB pde tool box, To get the assemble matrices for time dependent pde or nonlinear pde - ''FEM = assembleFEMatrices(___,state) '' this command is used. But how to get a assemble matrices for a pde with time dependent and nonlinear.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/538236/image.png)
clear,clc,close all;
model = createpde();
%% Geometry
R1 = [3;4;-1;1;1;-1;-1;-1;1;1];
g = decsg(R1);
heatmodel_geom = geometryFromEdges(model,g);
%% Mesh
msh = generateMesh(model,'GeometricOrder','linear');
[P,E,T] = meshToPet( msh );
%% Specify Coefficients
c = @(~,state) 0.7+0.003*state.u; % nonlinear coefficient
specifyCoefficients(model,'m',0,'d',1,'c',c,'a',0,'f',1);
%% Spacial BC
applyBoundaryCondition(model,'dirichlet','edge',[1 2 3 4],'u',0);
%% Initial guess
setInitialConditions(model,0);
%% assemble the finite elements matrices with imposed spacial BC
tlist = linspace(0,0.1,20);
Rnonlin = solvepde(model,tlist);
state.u = Rnonlin.NodalSolution;
state.time = tlist(1);
FEMn = assembleFEMatrices(model,'nullspace',state);
I could see lot of errors when i run this code. Am not sure if this approch is correct or not to get assemble FEMatrices... Please help me with a way to get assemble matrices for a pde which is nonlinear and time dependent?
My commands are based on the link given below
Thank you
0 Comments
Answers (1)
Ravi Kumar
on 4 Mar 2021
Solution matrix must of of the size NumPDEs x NumNodes. In your case, you are providing several solutions at all the time-steps as inputs. Change the line:.
state.u = Rnonlin.NodalSolution;
to
state.u = Rnonlin.NodalSolution(:,1)';
If you want matrices at multuple time steps, you need to updated state struct with corresponding solution and time values and call assembleFEMatrices.
Regards,
Ravi
0 Comments
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!