Replies: 3 comments 6 replies
-
You don't have to call This can be made more clear by looking at how the Pseudocode example
Then, no matter what value is in If you want to change the essential dofs for the next timestep, you have to set the values in your solution vector before the computation. The rhs, contrary to a linear computation, does not matter in case of essential dofs. |
Beta Was this translation helpful? Give feedback.
-
I have tried the following: auto fixed_dirichlet_dofs = mfem::Array<int>{};
auto append_dof = [&](const auto boundary, const auto normal) {
auto tmp = mfem::Array<int>{};
auto boundaries_markers = mfem::Array<int>(mesh->bdr_attributes.Max());
boundaries_markers = 0;
boundaries_markers[boundary] = 1;
fespace->GetEssentialTrueDofs(boundaries_markers, tmp, normal);
fixed_dirichlet_dofs.Append(tmp);
return boundaries_markers;
};
append_dof(0, 1); // xz0
append_dof(1, 2); // xy0
append_dof(4, 0); // yz0
yz1_markers = append_dof(2, 0); // yz1
p.SetEssentialBC(fixed_dirichlet_dofs); And at each time step: mfem::GridFunction x(fespace.get());
x.MakeTRef(fespace.get(), u1, 0);
x.SetFromTrueVector();
mfem::Vector u_values(3);
u_values(0) = 1e-2 * (t + dt) / 10;
u_values(1) = u_values(2) = 0;
mfem::VectorConstantCoefficient u_coefficients(u_values);
x.ProjectBdrCoefficient(u_coefficients, yz1_markers); where newton_solver.Solve(u1); However:
|
Beta Was this translation helpful? Give feedback.
-
Hi, auto fixed_dirichlet_dofs = mfem::Array<mfem_mgis::size_type>{};
auto append_dof = [&](const auto boundary, const auto normal) {
auto tmp = mfem::Array<int>{};
auto boundaries_markers = mfem::Array<int>(mesh->bdr_attributes.Max());
boundaries_markers = 0;
boundaries_markers[boundary] = 1;
fespace->GetEssentialTrueDofs(boundaries_markers, tmp, normal);
fixed_dirichlet_dofs.Append(tmp);
return tmp;
};
append_dof(0, 1); // xz0
append_dof(1, 2); // xy0
append_dof(4, 0); // yz0
auto yz1_ux_dofs = append_dof(2, 0); // yz1
p.SetEssentialTrueDofs(fixed_dirichlet_dofs); and set the imposed values as follows: const auto u = 1e-2 * (t + dt) / 10;
for (mfem_mgis::size_type idx = 0; idx != yz1_ux_dofs.Size(); ++idx) {
u1[yz1_ux_dofs[idx]] = u;
} |
Beta Was this translation helpful? Give feedback.
-
Dear all,
I have defined a
NonlinearForm
on which I want to impose evolving non homogenous Dirichlet boundary conditions. By evolving, I mean that theNonlinearForm
will be used for several time steps and I want to change the values of the imposed Dirichlet boundary conditions at each time step.It seems that there is no example of using
SetEssentialBC
with a right hand side.To make things clearer, here is a (non functional, of course) code snipset which tries to impose the boundary conditions on a unit cube. The faces of the cube are xy0 (normal along Oz), xy1, etc...
I came to the following code which I call at each time step:
where
p
is my non linear form.I don't know is this is the right way to do this. Indeed, there are many thing questionable here:
SetEssentialBC
but its implementation shows that I am probably totally wrong.SetEssentialBC
at each time step. I don't know if it is valid.Currently, my residuals are 0, so probably no BC is applied and my code finishes with a memory fault (double free)...
Any help would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions