is there “automatic” way to enable free-slip boundary conditions on one boundary and Dirichlet on another using the VectorH1 space?
Alternatives would of course to be a separate H1 space for each component each with different Dirichlet flags like here, using Nitsche to enforce the Dirichlet on only one component or to manually set the freedofs array like here.
V = VectorH1(mesh, order = 3)
Q = H1(mesh,order=2)
X = FESpace([V,Q])
freedofs = X.FreeDofs()
fesx,fesy = V.components
for el in fesx.Elements(BND):
if (el.mat=="dir"):
for dof in el.dofs:
freedofs.Clear(dof)
freedofs.Clear(fesx.ndof+dof) # y-component
if (el.mat=="neu"):
for dof in el.dofs:
freedofs.Clear(dof)
if (el.mat == "wall" or el.mat =="inlet" or el.mat =="outlet"):
for dof in el.dofs:
freedofs.Clear(fesx.ndof+dof) # y-component
thank for your help! I was was hoping to avoid a loop over the elements, as I have to update the freedofs array in every time-step, but your way is probably still the best.
within the bulk, the dofs are selected with element markers obtained via a level-set function (which changes in each time-step). The mesh boundary dofs will stay the same in each time-step.
Hm I guess then your best option is to create a map of element number to dofs and in each timestep clear the freedofs and then use the map to set the marked dofs. This is most likely faster than iterating over all elements.
Best
Christopher
Thank you for your advice! I think I can do it even more simply: Before the time loop, I create list of the dofs which need to be set on the slip boundary, and in each time step I loop just over this list and set the respective dofs.
As I have not seen this in the online documentation yet, for reference to anyone who might also need this: I have seen that the VectorH1 space now takes the arguments dirichletx, dirichlety and dirichletz to set separate Dirichlet BCs on the components of the space.