Example #1
0
void AdvectionManager::init(const Domain &domain, const Mesh &mesh,
                            const ConfigManager &configManager,
                            const TimeManager &timeManager) {
    this->domain = &domain;
    this->mesh = &mesh;

    io.init(timeManager);
    string output_prefix;
    if (configManager.hasKey("tspas", "output_prefix")) {
        configManager.getValue("tspas", "output_prefix", output_prefix);
    } else {
        output_prefix = "tspas."+
            boost::lexical_cast<string>(mesh.getNumGrid(0, FULL))+"x"+
            boost::lexical_cast<string>(mesh.getNumGrid(1, FULL));
    }
    outputFileIdx = io.registerOutputFile(mesh, output_prefix,
                                          IOFrequencyUnit::STEPS, 10);

    Qstar.create("qstar", "N/A", "intermediate tracer density", mesh, CENTER);
    FX.create("fx", "N/A", "flux along x direction", mesh, X_FACE);
    FY.create("fy", "N/A", "flux along y direction", mesh, Y_FACE);
    A.create("a", "N/A", "shape-preserving judger", mesh, CENTER);
    B.create("b", "N/A", "beta", mesh, CENTER);
    volume.create("volume", "m2 or m3", "the volume of grid cells", mesh, CENTER);
    
    io.file(outputFileIdx).registerOutputField<double, 1, FULL_DIMENSION>(1, &volume);

    int js = 0, jn = mesh.getNumGrid(1, FULL)-1;

    for (int i = 0; i < mesh.getTotalNumGrid(CENTER); ++i) {
        volume(i) = mesh.getCellVolume(i);
    }

    dlon.resize(mesh.getNumGrid(0, HALF));
    for (int i = 0; i < mesh.getNumGrid(0, HALF); ++i) {
        dlon[i] = mesh.getGridInterval(0, FULL, i); // this is correct
    }
    dlat.resize(mesh.getNumGrid(1, HALF));
    for (int j = 0; j < mesh.getNumGrid(1, HALF); ++j) {
        dlat[j] = mesh.getGridInterval(1, FULL, j); // this is correct
    }
    cosLatFull.set_size(mesh.getNumGrid(1, FULL));
    for (int j = 0; j < mesh.getNumGrid(1, FULL); ++j) {
        cosLatFull[j] = mesh.getCosLat(FULL, j);
    }
    cosLatFull[js] = 0;
    cosLatFull[jn] = 0;
    cosLatHalf.set_size(mesh.getNumGrid(1, HALF));
    for (int j = 0; j < mesh.getNumGrid(1, HALF); ++j) {
        cosLatHalf[j] = mesh.getCosLat(HALF, j);
    }
}