Specify f coefficient with an integral

조회 수: 1 (최근 30일)
Roberto Brenes
Roberto Brenes 2020년 6월 17일
댓글: ADSW121365 2020년 8월 3일
I am trying to solve a 2 dimensional PDE in a square domain of size L with the PDE toolbox that contains an "f" coefficient of the form:
I have no problem implementing the exponential part. However, I don't know how to access the spatial information of the current solution state.u so I can either create an interpolation of the solution at arbitrary points (x,y) or somehow evaluate the integral numerically. This old question seems to indicate that it might not be possible to create an interpolation of the current solution since the solver only passes certain values of state.u, not the solution for every point.
Still, I thought I would ask to see if there was some way to work around it. I included some code for my definition of "f" below in case it can make things clearer.
function fout = ffunction(location,state)
fout = zeros(1,numel(location.x));
L = 1; %for demonstration purposes
%Somehow create an interpolation of state.u in the domain x:[-L/2, L/2] and y:[-L/2, L/2]. Code below doesn't always create
%an interpolation in the entire domain
uinterp = @(xx,yy)interp2(location.x,location.y,state.u,xx,yy);
for ii = 1:numel(location.x)
fun = @(xx,yy)exp(-sqrt((xx-location.x(ii)).^2+(yy-location.y(ii)).^2));
fout(1,ii) = integral2(uinterp*fun,-L/2,L/2,-L/2,L/2);
end
end
  댓글 수: 1
ADSW121365
ADSW121365 2020년 8월 3일
Without access to some of the internals, I'm not sure this is possible. The PDE Toolbox uses Gauss Quadrature points instead of nodal locations to calculate the finite-element matrices which means knowing the specific nodal locations called by the f coefficient maybe difficult. I'm also interested in this approach so hopefully someone has a more useful suggestion.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Conditions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by