aboutsummaryrefslogtreecommitdiff
path: root/Source/Initialization/VelocityProperties.cpp
blob: 95f41d403d01846e9c327990c4aefe896eb43741 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Copyright 2021 Hannah Klion
 *
 *
 * This file is part of WarpX.
 *
 * License: BSD-3-Clause-LBNL
 */

#include "VelocityProperties.H"

#include "Utils/Parser/ParserUtils.H"
#include "Utils/TextMsg.H"

VelocityProperties::VelocityProperties (amrex::ParmParse& pp) {
    // Set defaults
    std::string vel_dist_s = "constant";
    std::string vel_dir_s = "x";
    m_velocity = 0;

    pp.query("bulk_vel_dir", vel_dir_s);
    if(vel_dir_s[0] == '-'){
        m_sign_dir = -1;
    }
    else {
        m_sign_dir = 1;
    }

    if ((vel_dir_s == "x" || vel_dir_s[1] == 'x') ||
       (vel_dir_s == "X" || vel_dir_s[1] == 'X')){
        m_dir = 0;
    }
    else if ((vel_dir_s == "y" || vel_dir_s[1] == 'y') ||
               (vel_dir_s == "Y" || vel_dir_s[1] == 'Y')){
        m_dir = 1;
    }
    else if ((vel_dir_s == "z" || vel_dir_s[1] == 'z') ||
            (vel_dir_s == "Z" || vel_dir_s[1] == 'Z')) {
        m_dir = 2;
    }
    else {
        amrex::Abort(Utils::TextMsg::Err(
            "Cannot interpret <s_name>.bulk_vel_dir input '" + vel_dir_s +
            "'. Please enter +/- x, y, or z with no whitespace between the sign and"+
            " other character."));
    }

    pp.query("beta_distribution_type", vel_dist_s);
    if (vel_dist_s == "constant") {
        utils::parser::queryWithParser(pp, "beta", m_velocity);
        m_type = VelConstantValue;
        WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
            m_velocity > -1 && m_velocity < 1,
            "Magnitude of velocity beta = " + std::to_string(m_velocity) +
            " is greater than or equal to 1"
        );
    }
    else if (vel_dist_s == "parser") {
        std::string str_beta_function;
        utils::parser::Store_parserString(pp, "beta_function(x,y,z)", str_beta_function);
        m_ptr_velocity_parser =
            std::make_unique<amrex::Parser>(
                utils::parser::makeParser(str_beta_function,{"x","y","z"}));
        m_type = VelParserFunction;
    }
    else {
        amrex::Abort(Utils::TextMsg::Err(
            "Velocity distribution type '" + vel_dist_s + "' not recognized."));
    }
}