def solve(self): comm = mpi_comm_world() mpiRank = MPI.rank(comm) tol = self.TOL() maxiter = 100 t = 0.0 dt = self.dt() mprob = NonlinearVariationalProblem(self.MForm, self.mf, bcs=self.fbcs, J=self.dMForm) msol = self.choose_solver(mprob) sprob = NonlinearVariationalProblem(self.SForm, self.Us, bcs=self.sbcs, J=self.dSForm) ssol = self.choose_solver(sprob) while t < self.params['Parameter']['tf']: if mpiRank == 0: utils.print_time(t) for con in self.tconditions: con.t = t iter = 0 eps = 1 mf_ = Function(self.FS_F) while eps > tol and iter < maxiter: mf_.assign(self.p[0]) ssol.solve() self.fluid_solid_coupling() msol.solve() e = self.p[0] - mf_ eps = np.sqrt(assemble(e**2 * dx)) iter += 1 # Store current solution as previous self.mf_n.assign(self.mf) self.Us_n.assign(self.Us) # Calculate fluid vector self.calculate_flow_vector() # transform mf into list mf_list = [self.mf.sub(i) for i in range(self.N)] yield mf_list, self.Uf, self.p, self.Us, t self.move_mesh() t += dt # Add a last print so that next output won't overwrite my time print statements print()
def solve(self): comm = mpi_comm_world() mpiRank = MPI.rank(comm) tol = self.TOL() maxiter = 50 t = 0.0 dt = self.dt() mprob = NonlinearVariationalProblem(self.MForm, self.mf, bcs=self.fbcs, J=self.dMForm) msol = self.choose_solver(mprob) sprob = NonlinearVariationalProblem(self.SForm, self.Us, bcs=self.sbcs, J=self.dSForm) ssol = self.choose_solver(sprob) while t < self.params.params['tf']: if mpiRank == 0: utils.print_time(t) for con in self.tconditions: con.t = t self.qi.t = t iter = 0 eps = 1 mf_ = Function(self.FS_F) while eps > tol and iter < maxiter: iter += 1 ssol.solve() self.fluid_solid_coupling(t) msol.solve() diff = self.mf.vector().get_local() - mf_.vector().get_local() eps = np.linalg.norm(diff, ord=np.Inf) mf_.assign(self.mf) # Store current solution as previous self.mf_n.assign(self.mf) self.Us_n.assign(self.Us) # Calculate fluid vector self.calculate_flow_vector() yield self.mf, self.Uf, self.p, self.Us, t self.move_mesh() t += dt # Add a last print so that next output won't overwrite my time print statements print()
def step(self): comm = mpi_comm_world() mpiRank = MPI.rank(comm) tol = self.TOL() maxiter = 100 t = 0.0 dt = self.dt() steps = [] mprob = NonlinearVariationalProblem(self.MForm, self.mf, bcs=self.fbcs, J=self.dMForm) msol = self.choose_solver(mprob) while t < self.params['Parameter']['tf'] and (len(steps) < 1): if mpiRank == 0: utils.print_time(t) iter = 0 eps = 1 mf_ = Function(self.FS_F) while eps > tol and iter < maxiter: mf_.assign(self.p[0]) self.Constitutive_Law() self.fluid_solid_coupling() msol.solve() e = self.p[0] - mf_ eps = np.sqrt(assemble(e**2 * dx)) iter += 1 sig = (self.mf - mf_) / Constant( self.dt()) - self.rho() * self.q_in() sig = project(sig, self.FS_M) # Store current solution as previous self.mf_n.assign(self.mf) m = self.sum_fluid_mass() # Kinematics #self.Constitutive_Law() if self.N == 1: yield self.mf, self.Uf, self.p, self.f, t, sig steps.append(t) t += dt # Add a last print so that next output won't overwrite my time print statements print()
def solve(self): #pdb.set_trace() comm = mpi_comm_world() mpiRank = MPI.rank(comm) tol = self.TOL() maxiter = 100 t = 0.0 dt = self.dt() mprob = NonlinearVariationalProblem(self.MForm, self.mf, bcs=self.fbcs, J=self.dMForm) msol = self.choose_solver(mprob) mprob = NonlinearVariationalProblem(self.MForm, self.mf, bcs=self.fbcs, J=self.dMForm) msol = self.choose_solver(mprob) sprob = NonlinearVariationalProblem(self.SForm, self.Us, bcs=self.sbcs, J=self.dSForm) ssol = self.choose_solver(sprob) while t < self.params['Parameter']['tf']: if mpiRank == 0: utils.print_time(t) iter = 0 eps = 1 mf_ = Function(self.FS_F) while eps > tol and iter < maxiter: mf_.assign(self.p[0]) ssol.solve() #sys.exit() self.fluid_solid_coupling() msol.solve() e = self.p[0] - mf_ eps = np.sqrt(assemble(e**2 * dx)) iter += 1 # Store current solution as previous self.Us_n.assign(self.Us) self.mf_n.assign(self.mf) # Calculate fluid vector if self.params['Parameter']['dt'] == self.params['Parameter'][ 'tf']: print("\n ****************************************\n\ Flow vector can only be calculated if dt!= tf \n\ Simulation will continue without calculating the flow vector.\ \n **************************************** )") elif (self.params['Parameter']['qo'] == 0.0) and (self.params['Parameter']['qi'] == 0.0): print("\n ****************************************\n\ Flow vector can only be calculated if qi,qo!=0 ! \n\ Simulation will continue without calculating the flow vector.\ \n **************************************** )") else: self.calculate_flow_vector() # transform mf into list if self.N > 1: mf_list = [self.mf.sub(i) for i in range(self.N)] if self.N == 1: yield self.mf, self.Uf, self.p, self.Us, t else: yield mf_list, self.Uf, self.p, self.Us, t self.move_mesh() t += dt # Add a last print so that next output won't overwrite my time print statements print()