def set_solid_variational_form(self, neumann_bcs): U = self.Us dU, L = split(U) V = TestFunction(self.FS_S) v, w = split(V) #v = V # parameters rho = self.rho() phi0 = Constant(self.params['Parameter']['phi']) m = self.sum_fluid_mass() # Kinematics n = FacetNormal(self.mesh) #Return the dimension of the space this cell is embedded in d = dU.geometric_dimension() self.I = Identity(d) self.F = variable(self.I + ufl_grad(dU)) self.J = variable(det(self.F)) self.C = variable(self.F.T * self.F) self.Psi = self.material.constitutive_law(J=self.J, C=self.C, phi=phi0) Psic = self.Psi * dx + L * (self.J - Constant(1) - m / rho) * dx for condition, boundary in neumann_bcs: Psic += dot(condition * n, dU) * self.ds(boundary) Form = derivative(Psic, U, V) dF = derivative(Form, U, TrialFunction(self.FS_S)) return Form, dF
def set_solid_variational_form(self, neumann_bcs): U = self.Us dU, L = split(U) V = TestFunction(self.FS_S) v, w = split(V) # parameters rho = Constant(self.params.params['rho']) # fluid Solution m = self.mf # Kinematics n = FacetNormal(self.mesh) d = dU.geometric_dimension() I = Identity(d) F = variable(I + ufl_grad(dU)) J = variable(det(F)) C = variable(F.T*F) # modified Cauchy-Green invariants I1 = variable(J**(-2/3) * tr(C)) I2 = variable(J**(-4/3) * 0.5 * (tr(C)**2 - tr(C*C))) Psi = self.material.constitutive_law(F, M=self.mf, rho=self.rho(), phi0=self.phi()) Psic = Psi*dx + L*(J-m/rho-Constant(1))*dx for boundary, condition in neumann_bcs.items(): Psic += dot(condition*n, dU)*self.ds(boundary) Form = derivative(Psic, U, V) dF = derivative(Form, U, TrialFunction(self.FS_S)) return Form, dF
def fluid_solid_coupling(self, t): dU, L = self.Us.split(True) p = self.p q = TestFunction(self.FS_F) rho = self.rho() phi0 = self.phi() d = dU.geometric_dimension() I = Identity(d) F = variable(I + ufl_grad(dU)) J = variable(det(F)) Psi = self.material.constitutive_law(F, M=self.mf, rho=self.rho(), phi0=self.phi()) phi = (self.mf + rho*phi0) Jphi = variable(J*phi) p = diff(Psi, Jphi) - L self.p = project(p, self.FS_F)
def set_fluid_variational_form(self): m = self.mf m_n = self.mf_n vm = TestFunction(self.FS_F) dU, L = self.Us.split(True) dU_n, L_n = self.Us_n.split(True) # Parameters self.qi = self.q_in() q_out = self.q_out() rho = self.rho() si = Constant(0.0) k = Constant(1/self.dt()) th, th_ = self.theta() # Kinematics from solid d = dU.geometric_dimension() I = Identity(d) F = variable(I + ufl_grad(dU)) J = variable(det(F)) # VK = TensorFunctionSpace(self.mesh, "P", 1) # if d == 2: # exp = Expression((('0.5', '0.0'),('0.0', '1.0')), degree=1) # elif d == 3: # exp = Expression((('1.0', '0.0', '0.0'),('0.0', '1.0', '0.0'), # ('0.0', '0.0', '1.0')), degree=1) # self.K = project(Ki*exp, VK, solver_type='mumps') # theta-rule / Crank-Nicolson M = th*m + th_*m_n # Fluid variational form A = variable(rho * J * inv(F) * self.K() * inv(F.T)) Form = k*(m - m_n)*vm*dx + dot(grad(M), k*(dU-dU_n))*vm*dx -\ inner(-A*grad(self.p), grad(vm))*dx + rho*si*vm*dx # Add inflow terms Form += -self.rho()*self.qi*vm*dx # Add outflow term Form += self.rho()*q_out*vm*dx dF = derivative(Form, m, TrialFunction(self.FS_F)) return Form, dF
def calculate_flow_vector(self): FS = VectorFunctionSpace(self.mesh, 'P', 1) dU, L = self.Us.split(True) m = TrialFunction(self.FS_V) mv = TestFunction(self.FS_V) # Parameters rho = Constant(self.rho()) phi0 = self.phi() k = Constant(1/self.dt()) # Kinematics from solid d = dU.geometric_dimension() I = Identity(d) F = variable(I + ufl_grad(dU)) J = variable(det(F)) phi = (self.mf + rho*phi0) a = (1/rho)*inner(F*m, mv)*dx L = inner(-J*self.K()*inv(F.T)*grad(self.p), mv)*dx solve(a == L, self.Uf, solver_parameters={"linear_solver": "minres", "preconditioner": "hypre_amg"})
def Grad(v): return ufl_grad(v)