示例#1
0
def tstep_hook(t, tstep, stats_intv, statsfile, field_to_subspace,
               field_to_subproblem, subproblems, w_, enable_PF, **namespace):
    info_blue("Timestep = {}".format(tstep))
    if enable_PF and stats_intv and tstep % stats_intv == 0:
        # GL: Seems like a rather awkward way of doing this,
        # but any other way seems to f**k up the simulation.
        # Anyhow, a better idea could be to move some of this to a post-processing stage.
        # GL: Move into common/utilities at a certain point.
        subproblem_name, subproblem_i = field_to_subproblem["phi"]
        phi = w_[subproblem_name].split(deepcopy=True)[subproblem_i]
        bubble = 0.5 * (1. - df.sign(phi))
        mass = df.assemble(bubble * df.dx)
        massy = df.assemble(bubble * df.Expression("x[1]", degree=1) * df.dx)
        if mpi_is_root():
            with file(statsfile, "a") as outfile:
                outfile.write("{} {} {} \n".format(t, mass, massy))
示例#2
0
def tstep_hook(t, tstep, stats_intv, statsfile, field_to_subspace,
               field_to_subproblem, subproblems, w_, enable_PF, **namespace):
    info_blue("Timestep = {}".format(tstep))
    if stats_intv and tstep % stats_intv == 0 and enable_PF:
        # GL: Seems like a rather awkward way of doing this, but any
        # other way seems to f**k up the simulation.  Anyhow, a better
        # idea could be to move some of this to a post-processing
        # stage.
        subproblem_name, subproblem_i = field_to_subproblem["phi"]
        Q = w_[subproblem_name].split(deepcopy=True)[subproblem_i]
        bubble = df.interpolate(Q, field_to_subspace["phi"].collapse())
        bubble = 0.5 * (1. - df.sign(bubble))
        mass = df.assemble(bubble * df.dx)
        massy = df.assemble(bubble * df.Expression("x[1]", degree=1) * df.dx)
        if mpi_is_root():
            with file(statsfile, "a") as outfile:
                outfile.write("{} {} {} \n".format(t, mass, massy))
示例#3
0
def absolute(q):
    return df.sign(q)*q
示例#4
0
def min_value(a, b):
    return 0.5*(a+b-df.sign(a-b)*(a-b))
示例#5
0
def max_value(a, b):
    return 0.5*(a+b+df.sign(a-b)*(a-b))
示例#6
0
def pf_mobility(phi, gamma):
    """ Phase field mobility function. """
    # return gamma * (phi**2-1.)**2
    func = 1.-phi**2
    return 0.75 * gamma * 0.5 * (1. + df.sign(func)) * func