MATLAB Answers

How to apply the boundary conditons to the mass and stiffness matrices?

8 views (last 30 days)
Julian Henning
Julian Henning on 18 Jun 2019
Commented: Ravi Kumar on 19 Jun 2019
I'm using the Partial Differential equation toolbox for getting the mass and stiffness matrices of a cube and liked to apply boundary conditions on the faces. My code looks like that:
gm = multicuboid(2,2,2);
model = createpde;
model.Geometry = gm;
specifyCoefficients(model,'m',0,'d',1,'c',1,'a',0,'f',1);
applyBoundaryCondition(model,'dirichlet','Face',1:6,'u',0);
mesh = generateMesh(model,'GeometricOrder','linear', ...
'Hmax', 2^-2);
FEM = asembleFEMatricess(model);
M = FEM.M; K = FEM.K;
How can I apply the boundary conditions to the matrices M and K. I know, that FEM also contains the matrices
FEM =
struct with fields:
K: [919×919 double]
A: [919×919 double]
F: [919×1 double]
Q: [919×919 double]
G: [919×1 double]
H: [452×919 double]
R: [452×1 double]
M: [919×919 double]
where G,H,R,M store some sort of information about the boundary conditions, but I'm not sure how to combine that with M and K. I'm also not sure if which matrices the 'nullspace' options returns.
PS: I need the matrices for solving the heat equation with a space-time-method, that is why a don't use the solve option from the model.
PPS: This should also work for quadratic meshs, thats why I can't just delete rows and columns.

  0 Comments

Sign in to comment.

Accepted Answer

Ravi Kumar
Ravi Kumar on 18 Jun 2019
Use the 'nullspace' as second argument, you will get matrices with BC imposed by eleminating dirichlet DoFs.
Regards,
Ravi

  2 Comments

Julian Henning
Julian Henning on 19 Jun 2019
Thank you for your answer. This solution seems to work. I also tried 'stiff-spring' as an option, this also seems to work and for this option the size of the matrices still equals the number of nodes. If I use the 'nullspace' option the matrices have fewer elements (obviously the nodes with the Dirichlet conditions are missing). Is there an easy option to transfer the solution which also has fewer elements than the mesh back to the origianl size for easy plotting (meaning to add zeros at the 'correct' positions)?
Edit: I figured out that B * solutions seems to work. Is this correct?

Sign in to comment.

More Answers (0)

Sign in to answer this question.