how to use low level FEM?
$begingroup$
how to simulate the following partial differential equation using Low level FEM in mathematica?
D[u[x,y], x] - D[u[x,y], y]=x Sin[x y] - y Sin[x y]
the answer is Cos[x y]
added)
region is [-1,1] for x and [-1,1] for y.
Boundary Condition is u[-1,y]=Cos[-y]
here is my tried code:
delta[x_, a_] := Block[{}, If[x == a, 1, 0]];
mesh = Table[PDF[NormalDistribution[a, z], x]*
PDF[NormalDistribution[b, z], y], {a, -1, 1, 0.1},
{b, -1, 1, 0.1}];
mesh = Flatten[mesh];
cofs = Table[ToExpression[StringJoin[ToString[c],
ToString[a], ToString[b]]], {a, 0, 20}, {b, 0, 20}];
cofs = Flatten[cofs];
weights = Table[delta[x, a]*delta[y, b], {a, -1, 1, 0.05},
{b, -1, 1, 0.05}];
weights = Flatten[weights];
expr = cofs . mesh;
residual = D[expr, x] - D[expr, y] - (x*Sin[x*y] -
y*Sin[x*y]);
integrated = residual*Plus @@ weights;
toMinimize = Plus @@ Flatten[Table[integrated,
{x, -1, 1, 0.1}, {y, -1, 1, 0.1}]];
toMinimize = toMinimize^2;
cofs = Append[cofs, z];
conds = Abs[(expr /. {x -> 0, y -> 0}) - 1];
opt = NMinimize[{toMinimize + conds}, cofs,
Method -> {Automatic, PerformanceGoal -> "Speed"}];
u = expr /. Last[opt];
ListPlot3D[Table[u*Plus @@ weights /. {x -> a, y -> b},
{a, -1, 1, 0.1}, {b, -1, 1, 0.1}]]
finite-element-method
$endgroup$
|
show 5 more comments
$begingroup$
how to simulate the following partial differential equation using Low level FEM in mathematica?
D[u[x,y], x] - D[u[x,y], y]=x Sin[x y] - y Sin[x y]
the answer is Cos[x y]
added)
region is [-1,1] for x and [-1,1] for y.
Boundary Condition is u[-1,y]=Cos[-y]
here is my tried code:
delta[x_, a_] := Block[{}, If[x == a, 1, 0]];
mesh = Table[PDF[NormalDistribution[a, z], x]*
PDF[NormalDistribution[b, z], y], {a, -1, 1, 0.1},
{b, -1, 1, 0.1}];
mesh = Flatten[mesh];
cofs = Table[ToExpression[StringJoin[ToString[c],
ToString[a], ToString[b]]], {a, 0, 20}, {b, 0, 20}];
cofs = Flatten[cofs];
weights = Table[delta[x, a]*delta[y, b], {a, -1, 1, 0.05},
{b, -1, 1, 0.05}];
weights = Flatten[weights];
expr = cofs . mesh;
residual = D[expr, x] - D[expr, y] - (x*Sin[x*y] -
y*Sin[x*y]);
integrated = residual*Plus @@ weights;
toMinimize = Plus @@ Flatten[Table[integrated,
{x, -1, 1, 0.1}, {y, -1, 1, 0.1}]];
toMinimize = toMinimize^2;
cofs = Append[cofs, z];
conds = Abs[(expr /. {x -> 0, y -> 0}) - 1];
opt = NMinimize[{toMinimize + conds}, cofs,
Method -> {Automatic, PerformanceGoal -> "Speed"}];
u = expr /. Last[opt];
ListPlot3D[Table[u*Plus @@ weights /. {x -> a, y -> b},
{a, -1, 1, 0.1}, {b, -1, 1, 0.1}]]
finite-element-method
$endgroup$
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago
|
show 5 more comments
$begingroup$
how to simulate the following partial differential equation using Low level FEM in mathematica?
D[u[x,y], x] - D[u[x,y], y]=x Sin[x y] - y Sin[x y]
the answer is Cos[x y]
added)
region is [-1,1] for x and [-1,1] for y.
Boundary Condition is u[-1,y]=Cos[-y]
here is my tried code:
delta[x_, a_] := Block[{}, If[x == a, 1, 0]];
mesh = Table[PDF[NormalDistribution[a, z], x]*
PDF[NormalDistribution[b, z], y], {a, -1, 1, 0.1},
{b, -1, 1, 0.1}];
mesh = Flatten[mesh];
cofs = Table[ToExpression[StringJoin[ToString[c],
ToString[a], ToString[b]]], {a, 0, 20}, {b, 0, 20}];
cofs = Flatten[cofs];
weights = Table[delta[x, a]*delta[y, b], {a, -1, 1, 0.05},
{b, -1, 1, 0.05}];
weights = Flatten[weights];
expr = cofs . mesh;
residual = D[expr, x] - D[expr, y] - (x*Sin[x*y] -
y*Sin[x*y]);
integrated = residual*Plus @@ weights;
toMinimize = Plus @@ Flatten[Table[integrated,
{x, -1, 1, 0.1}, {y, -1, 1, 0.1}]];
toMinimize = toMinimize^2;
cofs = Append[cofs, z];
conds = Abs[(expr /. {x -> 0, y -> 0}) - 1];
opt = NMinimize[{toMinimize + conds}, cofs,
Method -> {Automatic, PerformanceGoal -> "Speed"}];
u = expr /. Last[opt];
ListPlot3D[Table[u*Plus @@ weights /. {x -> a, y -> b},
{a, -1, 1, 0.1}, {b, -1, 1, 0.1}]]
finite-element-method
$endgroup$
how to simulate the following partial differential equation using Low level FEM in mathematica?
D[u[x,y], x] - D[u[x,y], y]=x Sin[x y] - y Sin[x y]
the answer is Cos[x y]
added)
region is [-1,1] for x and [-1,1] for y.
Boundary Condition is u[-1,y]=Cos[-y]
here is my tried code:
delta[x_, a_] := Block[{}, If[x == a, 1, 0]];
mesh = Table[PDF[NormalDistribution[a, z], x]*
PDF[NormalDistribution[b, z], y], {a, -1, 1, 0.1},
{b, -1, 1, 0.1}];
mesh = Flatten[mesh];
cofs = Table[ToExpression[StringJoin[ToString[c],
ToString[a], ToString[b]]], {a, 0, 20}, {b, 0, 20}];
cofs = Flatten[cofs];
weights = Table[delta[x, a]*delta[y, b], {a, -1, 1, 0.05},
{b, -1, 1, 0.05}];
weights = Flatten[weights];
expr = cofs . mesh;
residual = D[expr, x] - D[expr, y] - (x*Sin[x*y] -
y*Sin[x*y]);
integrated = residual*Plus @@ weights;
toMinimize = Plus @@ Flatten[Table[integrated,
{x, -1, 1, 0.1}, {y, -1, 1, 0.1}]];
toMinimize = toMinimize^2;
cofs = Append[cofs, z];
conds = Abs[(expr /. {x -> 0, y -> 0}) - 1];
opt = NMinimize[{toMinimize + conds}, cofs,
Method -> {Automatic, PerformanceGoal -> "Speed"}];
u = expr /. Last[opt];
ListPlot3D[Table[u*Plus @@ weights /. {x -> a, y -> b},
{a, -1, 1, 0.1}, {b, -1, 1, 0.1}]]
finite-element-method
finite-element-method
edited 1 hour ago
Xminer
asked 2 hours ago
XminerXminer
766
766
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago
|
show 5 more comments
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
1
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago
|
show 5 more comments
1 Answer
1
active
oldest
votes
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Hope this helps a bit.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189595%2fhow-to-use-low-level-fem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Hope this helps a bit.
$endgroup$
add a comment |
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Hope this helps a bit.
$endgroup$
add a comment |
$begingroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Hope this helps a bit.
$endgroup$
I am not a 100% sure I understand your question, here is what I think could help you.
The finite element method is, strictly speaking, not a method to solve PDEs. What it does it takes a continuous PDE and converts it to an approximate equivalent matrix and vector. The matrix and vector are discrete representations of the PDE. When you solve this set of equations you will get an approximate solution to the PDE.
We set up an equation:
Needs["NDSolve`FEM`"]
{state} =
NDSolve`ProcessEquations[{Laplacian[u[x, y], {x, y}] == 1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, 0, 1}, {y, 0, 1},
Method -> {"FiniteElement"}];
Now we extract some data from the NDSolve state data object.
femdata = state["FiniteElementData"]
femdata["Properties"]
methodData = femdata["FEMMethodData"];
bcData = femdata["BoundaryConditionData"];
pdeData = femdata["PDECoefficientData"];
variableData = state["VariableData"];
solutionData = state["SolutionData"][[1]];
If you do not want to / can not use NDSolve`ProcessEquations you may need to look at InitializePDECoefficients
and such functions.
If you look at pdeData, that now contains the coefficients of the equations given in NDSolve:
pdeData["All"]
{{{{1}}, {{{{0}, {0}}}}}, {{{{{-1,
0}, {0, -1}}}}, {{{{0}, {0}}}}, {{{{0,
0}}}}, {{0}}}, {{{0}}}, {{{0}}}}
Now, the finite element method is applied. This converts the continuous PDE into a system of discrete matrices:
discretePDE = DiscretizePDE[pdeData, methodData, solutionData]
{load, stiffness, damping, mass} = discretePDE["SystemMatrices"]
You can look at the matrices:
MatrixPlot[stiffness]
The same conversion is done for the boundary conditions:
discreteBCs =
DiscretizeBoundaryConditions[bcData, methodData, solutionData];
All the finite element method does is done now. The rest is linear algebra.
We now put the discrete boundary conditions into the discrete matrices:
DeployBoundaryConditions[{load, stiffness}, discreteBCs]
Solve:
solution = LinearSolve[stiffness, load];
Generate an Interpolating function:
mesh = methodData["ElementMesh"];
ifun = ElementMeshInterpolation[{mesh}, solution]
And visualize:
Plot3D[ifun[x, y], {x, y} [Element] mesh]
Hope this helps a bit.
edited 1 hour ago
answered 1 hour ago
user21user21
19.6k44882
19.6k44882
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189595%2fhow-to-use-low-level-fem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
In what sense is this a differential equation? Normally you are looking for an unknown function that is defined through a differential equation. What is the unknown function?
$endgroup$
– Hugh
2 hours ago
$begingroup$
my code was wrong.at first,I did used Cos(xy) for creating PDE and solve by FEM. the unknown function is u[x,y]
$endgroup$
– Xminer
2 hours ago
$begingroup$
Do you have a region on which you wish to solve the equation and boundary conditions?
$endgroup$
– Hugh
2 hours ago
$begingroup$
region is {x,-1,1} and{y,-1,1}. Boundary Condition is u[-1,y]=Cos[-y]
$endgroup$
– Xminer
2 hours ago
1
$begingroup$
Can you specify what problem you encountered? Otherwise there is an entire tutorial on FiniteElementProgramming.
$endgroup$
– user21
2 hours ago