Addition of expression to field in multiscale linear boundary condition

I’m coding multiscale linear boundary condition, thus, the solution is the fluctuation field. The solution of interest, however, is the sum of the fluctuation with a linear expression:

u = u_0 + grad_u*(x-x_centroid) + u_fluctuation.

I tried to define the linear bit using u_0 and grad_u as Constant, but the values of the field u were wrong. Do I have to project this linear bit at each loading step to get a function? I’m really clueless by this point. Thank you in advance!

P.S.: I’m using Dolfin

I don’t quite understand your boundary condition here.

Do you have a PDE for u, which depends on u_{fluctuation}, such that

A(u) = b \Omega \\ u = u_0 + \nabla(u)\cdot (x-x_c) + u_{fluctuation}) \text{on} \partial \Omega

?

Additionally, explaining what you have tried in code so far would give us a pointer to what kind of issue you are having.

In the microscale BVP of a multiscale analysis, it is common to write the microscale field, \mathbf{u}_{\mu}, as

\mathbf{u}_{\mu} = \mathbf{u}_{M} + \operatorname{Grad}\left(\mathbf{u}_{M}\right)\left(\mathbf{x}-\mathbf{x}_{c}\right) + \tilde{\mathbf{u}}\implies A\left(\mathbf{u}_{\mu}\right)=b,

where \mathbf{u}_{M} is the equivalent field in the macroscale. This is done because it simplifies application of boundary conditions to the microscaçe BVP. One example is the linear BC, which dictates that the fluctuation field, \tilde{\mathbf{u}}, must be zero on the microscale boundary. Thus, I can create a function space for \tilde{\mathbf{u}} and just correct it using the linear expression to apply on the constitutive model.

Actually, I’ve solved the problem (I do not know if it is the best option): I’ve added a correction,

u_M = Constant([0.0, 0.0, 0.0]) 
Grad_uM = Constant([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]) 
correction = u_M + dot(Grad_uM, x - x_c) 

I’ve also created an user expression that I can interpolate during post-processing to save the full field, \mathbf{u}_{\mu}. The results were validated and are indeed correct.

After solving this problem, I moved to the periodic boundary condition, but I’m struggling to apply DirichletBC to one single node. For which, I created another topic here in the forum (How to apply boundary conditions to a single node in dolfin?). Thanks for your interest in my problem.