Source

enzo-dev-problem-types / src / enzo / InitializationKernel.C

/***********************************************************************
/
/  KERNELS FOR INITIALIZATION OF DATA
/
/  written by: Matthew Turk, Devin Silvia
/  date:       January 2012
/
/  PURPOSE:
/
************************************************************************/

#ifdef NEW_PROBLEM_TYPES
#include <string.h>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <iostream>
#include "ErrorExceptions.h"
#include "macros_and_parameters.h"
#include "typedefs.h"
#include "global_data.h"
#include "Fluxes.h"
#include "GridList.h"
#include "ExternalBoundary.h"
#include "Grid.h"
#include "Hierarchy.h"
#include "TopGridData.h"
#include "ProblemType.h"
#include "EventHooks.h"

InitializationKernelConstant::InitializationKernelConstant(
    FieldContainer *constants, int additive)
{
    this->constants = constants;
    this->additive = additive;
}

void InitializationKernelConstant::Apply(FieldContainer *fields_,
                FLOAT x, FLOAT y, FLOAT z,
                FLOAT dx, FLOAT dy, FLOAT dz)
{
    FieldContainer fields = (*fields_);
    std::map<std::string, float>::iterator it;
    for(it = this->constants->start();
        it != this->constants->end();
        it++)
    {
      if (this->additive == TRUE) {
        fields[(*it).first] += (*it).second;
      } else {
        fields[(*it).first] = (*it).second;
      }
    }
    return;
}

#endif