Specify f coefficient with an integral

8 vues (au cours des 30 derniers jours)
Roberto Brenes
Roberto Brenes le 17 Juin 2020
Commenté : ADSW121365 le 3 Août 2020
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 commentaire
ADSW121365
ADSW121365 le 3 Août 2020
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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by