If I marked all interior nodes with point 1 using syntax
from dolfin import *
import numpy as np
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)
u = TrialFunction(V)
v = TestFunction(V)
NodesMarker = MeshFunction('size_t', mesh, 0)
NodesMarker.set_all(0)
a = inner(grad(u), grad(v)) * dx
L = inner(f, v) * dx
Now I want to assign u = 10 on all interior nodes(i.e. to point 0). How I can do this thing.
There is any way to define in weak formulation or we can do in any other way.
from dolfin import *
import numpy as np
# define mesh
N = 1
mesh = UnitSquareMesh(N, N)
V = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
R = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
me = MixedElement([V, R])
W = FunctionSpace(mesh, me)
(u, lmda) = TrialFunctions(W)
(v, tau) = TestFunctions(W)
g = Constant(0)
# Here i marked these two set of nodes with some condition
ActiveNodes = NodesMarker.where_equal(1)
InActiveNodes = NodesMarker.where_equal(2)
a = inner(grad(u), grad(v)) * dx - lmda * v * dx
L = inner(f, v) * dx
Now i have to impose u = g on ActiveNodes and lmda = 0 on InActiveNodes. I have to impose in such a way so that i can change set of active nodes and Inactive nodes in a iterative process.
Please suggest something. Hope to hear from you soon. THere is any way to do these things via weak formulation.
shall we impose something in a weak formulation using dS(1) but it doesn’t work. suggest something in such a way.
You could impose this weakly using Nitsche’s method for weak enforcement of boundary condition, i.e.
create a g where you assign the values on the boundary, then integrate over your boundary ds with this value. The variational formulation for Nitsche’s method has been shown for instance: Weak imposition of Dirichlet conditions for the Poisson problem — FEniCSx tutorial
Wouldn’t his mean that your problem can be split into two sections: u=\begin{cases} u=g \text{ on } \Omega_0\\ -\Delta u = f \text{ on } \Omega_1\\
u=g \text{ on } \partial\Omega_0\cap\partial\Omega_1 \end{cases}
Given that you mark all cells that satisfies being in \Omega_0 with 0, all cells in \Omega_1 with one, you can write:
while some_condition:
# Update cell marker based on some criterion
dx = Measure("dx", domain=mesh, subdomain_data=cell_marker)
a = inner(u, v)*dx(0) + inner(grad(u), grad(v))*dx(1)
L = inner(g, v)*dx(0) + inner(f, v)*dx(1)
solve(a==L, uh)