# Periodic Boundary Conditions

3 messages
Open this post in threaded view
|

## Periodic Boundary Conditions

 Dear FEA users I am currently running simulations of coupled advection diffusion equations. For a single advection diffusion equation, I could use the trick recommended in the example https://www.featool.com/tutorial/2017/10/30/periodic-boundary-conditions-and-the-solver-hook-functionality: fea = parsephys( fea ); fea.bdr.d{1} = { [] [] }; fea.bdr.n{1}{2} = 'solve_hook_periodic_bc'; fea = parseprob( fea ); where periodic_bc is a function that implements the periodic boundary condition and it works perfectly well. As soon as I have two coupled advection diffusion equation and try to reuse the same trick: fea = parsephys( fea ); fea.bdr.d{1} = { [] [] }; fea.bdr.n{1}{2} = 'solve_hook_periodic_bc'; fea.bdr.d{2} = { [] [] }; fea.bdr.n{2}{2} = 'solve_hook_periodic_bc'; fea = parseprob( fea ); it doesn't work in the sense that I get a warning telling me that the file periodic_bc.m cannot be found. No need to say that the codes run from the same directory where the file periodic_bc.m also is. Any clue? Thanks
 Administrator This post was updated on . I suspect the issue is due to not modifying the solver hook function to handle more dependent variables. (In this case the same warning will appear irrespective if an error has occurred or the function has not been found.) To clarify, as the solver hook functions basically allow modification of the underlying sparse finite element matrices they can not be generalized and must be adapted to each individual problem (which is why there currently isn't a convenient periodic boundary option available in the GUI). I assume you have tried to use the "periodic_bc" function from the "ex_periodic1" example just as it is. To support multiple dependent variable in this example, lines 104-105 in the file ex_periodic1.m must be changed from  dof_i = 1; dof_j = prob.eqn.ndof; to  offset = sum(prob.eqn.ndof(1:i_dvar-1)); dof_i = offset+1; dof_j = offset+prob.eqn.ndof(i_dvar); to match up the first and last degrees of freedom (the periodic matches) for each dependent variable.