Commit 033843a4 authored by Matthieu Constant's avatar Matthieu Constant
Browse files

compute cfl function

parent 19a1d659
Pipeline #5763 passed with stage
in 2 minutes and 11 seconds
......@@ -327,6 +327,16 @@ class FluidProblem :
nit = self._lib.fluid_problem_implicit_euler(self._fp, c_double(dt), c_double(newton_atol), c_double(newton_rtol), c_int(newton_max_it))
return nit
def compute_cfl(self):
"""Compute the CFL number divided by the time step
"""
nv = np.linalg.norm(self.solution()[:,:self._dim],axis=1)
nvmax = np.max(nv[self.elements()],axis=1,keepdims=True)
h = self._get_matrix("element_size",self.n_elements(),1)
cfl = nvmax / (0.1*h)
return np.max(cfl)
def advance_concentration(self,dt):
"""Solve the advection equation for the concentration using the current velocity field.
......@@ -334,11 +344,8 @@ class FluidProblem :
dt -- computation time step
"""
if self._n_fluids == 2 :
nv = np.linalg.norm(self.solution()[:,:self._dim],axis=1)
nvmax = np.max(nv[self.elements()],axis=1,keepdims=True)
h = self._get_matrix("element_size",self.n_elements(),1)
cfl = dt*nvmax / (0.1*h)
nsub = int(np.max(cfl)+1)
cfl = self.compute_cfl()
nsub = int(cfl*dt+1)
if (nsub != 1) :
print("sub-iterating advection for cfl : %i sub-iterations"%nsub)
for i in range(nsub) :
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment