Exemplo n.º 1
0
def test_get_version():
    # ALERT: This is testing the configuration object, not the temporary
    # directory created for other tests.
    cmlenv.cml_reset_versions()
    cmlenv.cml_get_version("10.11")
    with pytest.raises(KeyError):
        cmlenv.cml_get_version("3.84")
Exemplo n.º 2
0
def has_cml(exe_name="blockMesh"):
    try:
        env = cmlenv.cml_get_version()
        bindir = env.bin_dir
        return os.path.exists(os.path.join(bindir, exe_name))
    except:  # pylint: disable=bare-except
        return False
Exemplo n.º 3
0
def test_cmlsim_load(cmlsim_casedir, template_casedir):
    casedir = cmlsim_casedir
    env = cmlenv.cml_get_version()

    case = CMLSimulation.load(env, str(casedir))
    assert (case.run_flags["updated"])
    assert (not case.run_flags["prepped"])
    assert (not case.run_config)

    # Setup run_config
    change_inputs = CaelusDict(
        controlDict=CaelusDict(endTime=1, writeFormat="binary"))
    prep = [
        CaelusDict(
            copy_tree=CaelusDict(src=os.path.join(str(template_casedir), "0"),
                                 dest=os.path.join(str(casedir), "0")))
    ]
    run_config = CaelusDict(num_ranks=4,
                            mpi_extra_args="-machinefile mymachines",
                            queue_settings=dict(account="caelus"),
                            reconstruct=False,
                            change_inputs=change_inputs,
                            prep=prep,
                            solve="simpleSolver")
    case.run_config = run_config
    case.update()
    case.save_state()
Exemplo n.º 4
0
def test_cmlsim_prep(cmlsim_casedir):
    casedir = cmlsim_casedir
    env = cmlenv.cml_get_version()
    case = CMLSimulation.load(env, str(casedir))
    assert (case.run_config)
    assert (not case.run_flags["prepped"])

    case.prep_case()
    decomp_dict = os.path.join(str(casedir), "system", "decomposeParDict")
    assert (os.path.exists(decomp_dict))
    assert (case.run_flags.prepped)
    case.save_state()
Exemplo n.º 5
0
def test_cmlsim_post(cmlsim_casedir):
    casedir = cmlsim_casedir
    env = cmlenv.cml_get_version()
    case = CMLSimulation.load(env, str(casedir))
    assert (case.solver)
    assert (case.run_flags.solve_completed)

    clog = case.case_log()
    clog.solve_completed = True
    case.post_case()
    assert (case.run_flags.post_done)
    assert (not case.run_flags.failed)
Exemplo n.º 6
0
def test_cmlsim_accesssors(cmlsim_casedir):
    casedir = cmlsim_casedir
    env = cmlenv.cml_get_version()

    case = CMLSimulation.load(env, str(casedir))
    cdict = case.controlDict
    assert (cdict.writeFormat == "binary")
    cdict = case.fvSchemes
    assert (cdict.interpolationSchemes["interpolate(U)"] == "linear")
    cdict = case.fvSolution
    assert (cdict.PISO.nCorrectors == 2)
    cdict = case.transportProperties
    assert (cdict.transportModel == "Newtonian")
    cdict = case.turbulenceProperties
    assert (cdict.simulationType == "RASModel")
    cdict = case.RASProperties
    assert (cdict.model == "realizableKE")
    assert (not cdict.coeffs)
Exemplo n.º 7
0
def test_cmlsim_solve(cmlsim_casedir):
    casedir = cmlsim_casedir
    env = cmlenv.cml_get_version()
    case = CMLSimulation.load(env, str(casedir))
    assert (not case.solver)
    assert (not case.run_flags.solve_submitted)

    case.solve()
    assert (case.logfile == "simpleSolver.log")
    assert (case.run_flags.solve_submitted)
    assert (not case.run_flags.solve_completed)
    curr_status = case.status()
    assert (curr_status == "Running")

    # Check status updates
    clog = case.case_log()
    clog.solve_completed = True
    curr_status = case.status()
    assert (curr_status == "Solved")
    case.save_state()
Exemplo n.º 8
0
def test_cmlsim_basic(cmlsim_casedir, template_casedir):
    name = "caelus_case"
    casedir = cmlsim_casedir
    basedir = os.path.dirname(str(casedir))
    env = cmlenv.cml_get_version()
    case = CMLSimulation(name, env, basedir)
    assert (not os.path.exists(str(casedir)))

    # Test cloning
    case.clone(str(template_casedir))
    assert (os.path.exists(os.path.join(str(casedir), "0")))

    # Test clean case method
    case.clean(preserve_zero=False)
    assert (not os.path.exists(os.path.join(str(casedir), "0")))

    # Update utility
    case.update(input_mods={})
    assert (case.run_flags["updated"])

    # Persistence capability
    case.save_state()
    jfile = casedir.join(".cmlsimulation.json")
    assert (os.path.exists(str(jfile)))
Exemplo n.º 9
0
def test_caelus_execute(test_casedir):
    env = cmlenv.cml_get_version()
    casedir = str(test_casedir)
    cml_cmd = CaelusCmd("blockMesh", casedir=casedir, cml_env=env)
    cml_cmd()
    assert (os.path.exists(os.path.join(casedir, "blockMesh.log")))
Exemplo n.º 10
0
import os
import sys
import shutil

import matplotlib.pyplot as plt

from caelus.config.cmlenv import cml_get_version
from caelus.io import DictFile, DecomposeParDict
from caelus.run.cmd import CaelusCmd
from caelus.run.core import get_mpi_size
from caelus.post.logs import LogProcessor, SolverLog
from caelus.post.plots import CaelusPlot

print("Searching for default caelus version...")
cenv_default = cml_get_version()

cenv = cenv_default
print("Using Caelus version: " + cenv.version)
print("Caelus path: " + cenv.project_dir)

status = 0
print("Executing blockMesh... ")
caelus_cmd = CaelusCmd("blockMesh", cml_env=cenv)
status = caelus_cmd()
if status != 0:
    print("ERROR generating blockMesh. Exiting!")
    sys.exit(1)

shutil.copy2("0/alpha1.org", "0/alpha1")