Reputation: 1
How can we modify the matlab PDE toolbox code to implement periodic boundary conditions?
Upvotes: 0
Views: 1910
Reputation: 1
I was able to implement periodic boundary conditions in 2016a for use within the pde toolbox. It took quite a bit of time because so many of the functions and data structures are not documented. Please note that my domain is a three dimensional cube, but the approach here will work for 2D too. (I have tested it for both parabolic and hyperbolic problems). It seems that periodic boundary conditions should be possible by altering the PDE toolbox's "H" matrix, but I haven't been able to get such an approach to work for ellipic, parabolic, or hyperbolic problems.
Here is the approach for implementing periodic boundary conditions for parabolic and hyperbolic problems (using the method of lines of the pde toolbox):
Create a mesh using a delaunay triangulation of your points (make sure nodes touching the boundary of the domain have nodes which "match" on the opposite face). Note that the nodes of meshes produced by the pde toolbox for a 3D cube cannot be used, since they do not have the appropriate periodic structure.
Treat the periodic boundary condition as a time dependent dirichlet boundary condition. You may have a bit of trouble getting matlab to treate your boundary conditions at time dependent ones (I have to omit the details here). However, here is the function that I used in the applyBoundaryCondition() function is as follows:
function [ bcMatrix ] = tdependentdiri( region, state )
% nan is used to "trick" matlab into treating the boundary conditions as time-dependent dirichlet
if( isnan( state.time ) )
bcMatrix = NaN;
else
bcMatrix = state.u;
end
end
[nodes, fas, tet, Hmax, Hmin] = genmeshinternal(self.Geometry,Hmax,Hmin,geomOrder);
Note that nodes and tet are taken care of by the delaunay triangulation.
state.u = self.uN(:,pbc_indx); % self.uN holds the current time's solution
I put this right after the line which reads: appRegion = self.applicationRegion(xyzPts(:,i), faceNormals(:,i));
There could be an easier way, but at least this one eventually works.
Upvotes: 0