FLOAT_TYPE PressureService::GetBulkModulus() const
    {
        const FLOAT_TYPE secondContractionRate = 0.9999;
        const FLOAT_TYPE firstContractionRate = 0.999;

        FLOAT_TYPE pressureDerivative = (GetPressure(secondContractionRate, 2.0) - GetPressure(firstContractionRate, 2.0)) / (secondContractionRate - firstContractionRate);
        FLOAT_TYPE bulkModulus = - 1.0 / DIMENSIONS * firstContractionRate * pressureDerivative;
        return bulkModulus;
    }
Ejemplo n.º 2
0
void FGAtmosphere::Calculate(double altitude)
{
  FGPropertyNode* node = PropertyManager->GetNode();
  if (!PropertyManager->HasNode("atmosphere/override/temperature"))
    Temperature = GetTemperature(altitude);
  else
    Temperature = node->GetDouble("atmosphere/override/temperature");

  if (!PropertyManager->HasNode("atmosphere/override/pressure"))
    Pressure = GetPressure(altitude);
  else
    Pressure = node->GetDouble("atmosphere/override/pressure");

  if (!PropertyManager->HasNode("atmosphere/override/density"))
    Density = Pressure/(Reng*Temperature);
  else
    Density = node->GetDouble("atmosphere/override/density");

  Soundspeed  = sqrt(SHRatio*Reng*(Temperature));
  PressureAltitude = altitude;
  DensityAltitude = altitude;

  Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
  KinematicViscosity = Viscosity / Density;
}
Ejemplo n.º 3
0
double FGStandardAtmosphere::GetDensity(double altitude) const
{
  double P = GetPressure(altitude);
  double Pa = P - VaporPressure; // Partial pressure of air

  return (Pa/Reng + Mwater*VaporPressure/Rstar)/GetTemperature(altitude);
}
Ejemplo n.º 4
0
void ConvertDataValue(WIDATAITEM *UpdateData, char *Data) 
{
	char str[MAX_DATA_LEN];

	// convert the unit
	if (strcmp(Data, Translate("<Error>")) && strcmp(Data, NODATA) && strcmp(Data, Translate(NODATA))) 
	{
		// temperature
		if (!strcmp(UpdateData->Name, "Temperature") || !strcmp(UpdateData->Name, "High") || 
			!strcmp(UpdateData->Name, "Low") || !strcmp(UpdateData->Name, "Feel") || 
			!strcmp(UpdateData->Name, "Dewpoint") ||
			!_stricmp(UpdateData->Unit, "C") || !_stricmp(UpdateData->Unit, "F") || 
			!_stricmp(UpdateData->Unit, "K"))
		{
			GetTemp(Data, UpdateData->Unit, str);
			strcpy(Data, str);
		}
		// pressure
		else if (!strcmp(UpdateData->Name, "Pressure") || !_stricmp(UpdateData->Unit, "HPA") || 
			!_stricmp(UpdateData->Unit, "KPA") || !_stricmp(UpdateData->Unit, "MB") ||
			!_stricmp(UpdateData->Unit, "TORR") || !_stricmp(UpdateData->Unit, "IN") || 
			!_stricmp(UpdateData->Unit, "MM"))
		{
			GetPressure(Data, UpdateData->Unit, str);
			strcpy(Data, str);
		}
		// speed
		else if (!strcmp(UpdateData->Name, "Wind Speed") || !_stricmp(UpdateData->Unit, "KM/H") || 
			!_stricmp(UpdateData->Unit, "M/S") || !_stricmp(UpdateData->Unit, "MPH") || 
			!_stricmp(UpdateData->Unit, "KNOTS"))
		{
			GetSpeed(Data, UpdateData->Unit, str);
			strcpy(Data, str);
		}
		// visibility
		else if (!strcmp(UpdateData->Name, "Visibility") || !_stricmp(UpdateData->Unit, "KM") || 
			!_stricmp(UpdateData->Unit, "MILES"))
		{
			GetDist(Data, UpdateData->Unit, str);
			strcpy(Data, str);
		}
		// converting case for condition to the upper+lower format
		else if (!_stricmp(UpdateData->Unit, "COND"))
			CaseConv(Data);
		// degree sign
		else if (!_stricmp(UpdateData->Unit, "DEG"))
		{
			if (!opt.DoNotAppendUnit) strcat(Data, opt.DegreeSign);
		}
		// percent sign
		else if (!_stricmp(UpdateData->Unit, "%"))
		{
			if (!opt.DoNotAppendUnit) strcat(Data, "%");
		}
		// truncating strings for day/month to 2 or 3 characters
		else if (!_stricmp(UpdateData->Unit, "DAY") || !_stricmp(UpdateData->Unit, "MONTH"))
			if (opt.dUnit > 1 && strlen(Data) > opt.dUnit)		Data[opt.dUnit] = '\0';
	}
}
Ejemplo n.º 5
0
void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
{
	TCHAR str[MAX_DATA_LEN];

	// convert the unit
	if (mir_tstrcmp(Data, TranslateT("<Error>")) && mir_tstrcmp(Data, NODATA) && mir_tstrcmp(Data, TranslateTS(NODATA))) {
		// temperature
		if (!mir_tstrcmp(UpdateData->Name, _T("Temperature")) || !mir_tstrcmp(UpdateData->Name, _T("High")) ||
			!mir_tstrcmp(UpdateData->Name, _T("Low")) || !mir_tstrcmp(UpdateData->Name, _T("Feel")) ||
			!mir_tstrcmp(UpdateData->Name, _T("Dewpoint")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("C")) || !mir_tstrcmpi(UpdateData->Unit, _T("F")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("K"))) {
			GetTemp(Data, UpdateData->Unit, str);
			mir_tstrcpy(Data, str);
		}
		// pressure
		else if (!mir_tstrcmp(UpdateData->Name, _T("Pressure")) || !mir_tstrcmpi(UpdateData->Unit, _T("HPA")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("KPA")) || !mir_tstrcmpi(UpdateData->Unit, _T("MB")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("TORR")) || !mir_tstrcmpi(UpdateData->Unit, _T("IN")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("MM"))) {
			GetPressure(Data, UpdateData->Unit, str);
			mir_tstrcpy(Data, str);
		}
		// speed
		else if (!mir_tstrcmp(UpdateData->Name, _T("Wind Speed")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM/H")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("M/S")) || !mir_tstrcmpi(UpdateData->Unit, _T("MPH")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("KNOTS"))) {
			GetSpeed(Data, UpdateData->Unit, str);
			mir_tstrcpy(Data, str);
		}
		// visibility
		else if (!mir_tstrcmp(UpdateData->Name, _T("Visibility")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("MILES"))) {
			GetDist(Data, UpdateData->Unit, str);
			mir_tstrcpy(Data, str);
		}
		// elevation
		else if (!mir_tstrcmp(UpdateData->Name, _T("Elevation")) || !mir_tstrcmpi(UpdateData->Unit, _T("FT")) ||
			!mir_tstrcmpi(UpdateData->Unit, _T("M"))) {
			GetElev(Data, UpdateData->Unit, str);
			mir_tstrcpy(Data, str);
		}
		// converting case for condition to the upper+lower format
		else if (!mir_tstrcmpi(UpdateData->Unit, _T("COND")))
			CaseConv(Data);
		// degree sign
		else if (!mir_tstrcmpi(UpdateData->Unit, _T("DEG"))) {
			if (!opt.DoNotAppendUnit) mir_tstrcat(Data, opt.DegreeSign);
		}
		// percent sign
		else if (!mir_tstrcmpi(UpdateData->Unit, _T("%"))) {
			if (!opt.DoNotAppendUnit) mir_tstrcat(Data, _T("%"));
		}
		// truncating strings for day/month to 2 or 3 characters
		else if (!mir_tstrcmpi(UpdateData->Unit, _T("DAY")) || !mir_tstrcmpi(UpdateData->Unit, _T("MONTH")))
			if (opt.dUnit > 1 && mir_tstrlen(Data) > opt.dUnit)
				Data[opt.dUnit] = '\0';
	}
}
Ejemplo n.º 6
0
/****************************************************************
   CALL:    Pressure_Update()
                             
   INTRO:   Update (Refresh) Sensor Readings
****************************************************************/
void Pressure_Update()
{
	long  pressure = 0L;
	short tempC = 0;
	
	s_dataTable[Pressure_Time]++;   // Simple counter for now.
	if( GetPressure(&pressure) == 0x0 )
		s_dataTable[Pressure_Pressure] = (int)pressure;	
	if( GetTemperature(&tempC) == 0x0 )
		s_dataTable[Pressure_Temperature] = (int)tempC;
}
Ejemplo n.º 7
0
void FGAtmosphere::Calculate(double altitude)
{
  Temperature = GetTemperature(altitude);
  Pressure    = GetPressure(altitude);
  Density     = Pressure/(Reng*Temperature);
  Soundspeed  = sqrt(SHRatio*Reng*(Temperature));
  PressureAltitude = altitude;
  DensityAltitude = altitude;

  Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
  KinematicViscosity = Viscosity / Density;
}
    void PressureService::FillPressures(const vector<FLOAT_TYPE>& contractionRatios, const vector<FLOAT_TYPE>& energyPowers, vector<FLOAT_TYPE>* pressures) const
    {
        pressures->clear();

        int contractionRatiosCount = contractionRatios.size();
        for (int i = 0; i < contractionRatiosCount; ++i)
        {
            FLOAT_TYPE contractionRatio = contractionRatios[i];
            FLOAT_TYPE energyPower = energyPowers[i];
            FLOAT_TYPE pressure = GetPressure(contractionRatio, energyPower);
            pressures->push_back(pressure);
        }
    }
Ejemplo n.º 9
0
void GridManager::AddBox(Vector2d p, Vector2d size, GridBox* box) {

  if(box == nullptr) {
    std::cout << "[GridManager::AddBox] Cannot add null box." << std::endl;
    return;
  }

  CellConfig def_config;
  def_config.pressure = GetPressure();
  def_config.T = GetTemperature();
  def_config.boundary_T = GetTemperature();

  Vector2d& cell_size = Config::vCellSize;

  box->p = Vector2i(p.x() / cell_size.x(), p.y() / cell_size.y());
  box->size = Vector2i(size.x() / cell_size.x(), size.y() / cell_size.y());
  box->def_config = def_config;

  boxes_stack_.push_back(box);
}
Ejemplo n.º 10
0
void GRIBTable::InitGribTable( int zone, ArrayOfGribRecordSets *rsa )
{
    //init fonts and colours
    wxFont dayfont = wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
    wxFont labelfont = wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
    wxFont timefont = wxFont( 9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD );
    wxFont datafont = wxFont( 9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );

    wxColour colour;
    GetGlobalColor(_T("DILG1"), &colour);
   
    //populate "cursor position" display 
    wxString l;
    l.Append(toSDMM_PlugIn(1, m_pGDialog->m_cursor_lat)).Append(_T("   "))
        .Append(toSDMM_PlugIn(2, m_pGDialog->m_cursor_lon));
    m_pCursorPosition->SetLabel(l);
    m_pCursorPosition->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
    m_pPositionText->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));

    //init row attr
    wxGridCellAttr *daysrow = new wxGridCellAttr();
    daysrow->SetFont(dayfont);
    daysrow->SetBackgroundColour(colour);
    daysrow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);

    wxGridCellAttr *timerow = new wxGridCellAttr();
    timerow->SetFont(timefont);
    timerow->SetBackgroundColour(colour);
    timerow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);

    wxGridCellAttr *singledatarow = new wxGridCellAttr();
    singledatarow->SetFont(datafont);
    singledatarow->SetAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);

    wxGridCellAttr *doubledatarow = new wxGridCellAttr();
    doubledatarow->SetFont(datafont);
    doubledatarow->SetAlignment(wxALIGN_CENTRE, -1);

    //init labels
    m_pGribTable->SetLabelFont(labelfont);                  
    m_pGribTable->SetLabelBackgroundColour(colour);

    //create as columns as necessary
    m_pGribTable->AppendCols(rsa->GetCount());
    m_pGribTable->SetSelectionBackground(colour);
    m_pGribTable->SetSelectionForeground(m_pGribTable->GetDefaultCellTextColour());

    //init days row
    m_pGribTable->SetRowLabelValue(0, wxEmptyString);
    m_pGribTable->SetRowAttr(0, daysrow);

    //init time row
    m_pGribTable->SetRowLabelValue(1, wxEmptyString);
    m_pGribTable->SetRowAttr(1, timerow);

    //populate grib
    wxDateTime day(rsa->Item(0).m_Reference_Time);
    wxDateTime time;
    int ncols = -1,nrows,dcol = 0;

    for(unsigned i = 0; i < rsa->GetCount(); i++ ) {
        time = rsa->Item(i).m_Reference_Time;
   
        //populate 'time' row
        m_pGribTable->SetCellValue(GetTimeRowsStrings( rsa->Item(i).m_Reference_Time, zone , 0), 1, i );
        
        nrows = 2;

        m_pTimeset = m_pGDialog->GetTimeLineRecordSet(time);
        GribRecord **RecordArray = m_pTimeset->m_GribRecordPtrArray;

        //create and polulate wind data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VX) != wxNOT_FOUND &&
            m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_VY) != wxNOT_FOUND) {
                AddDataRow( nrows, i, _("Wind"), doubledatarow );
                wxString wc(GetWind(RecordArray));
                //wind is a special case: if current unit is not bf ==> double speed display (current unit + bf)
                if(m_pGDialog->m_OverlaySettings.Settings[GribOverlaySettings::WIND].m_Units != GribOverlaySettings::BFS)
                    if(!wc.IsEmpty()) wc.Append(_T("\n")).Append(GetWindBf(RecordArray));
                //
                m_pGribTable->SetCellValue(nrows, i, wc);
                m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
                nrows++;
        }
        //create and polulate Pressure data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRESSURE) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Pressure"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetPressure(RecordArray));
            nrows++;
        }
        //create and polulate Wind gusts data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WIND_GUST) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Wind Gust"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetWindGust(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate Waves data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_HTSIGW) != wxNOT_FOUND ||
            m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_WVDIR) != wxNOT_FOUND) {
                AddDataRow( nrows, i, _("Waves"), doubledatarow );
                m_pGribTable->SetCellValue(nrows, i, GetWaves(RecordArray));
                m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
                nrows++;
        }
        //create and polulate total rainfall data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_PRECIP_TOT) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Rainfall"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetRainfall(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate total cloud control
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CLOUD_TOT) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Cloud"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetCloudCover(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate the Air Temperature data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_AIR_TEMP) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Air\nTemperature"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetAirTemp(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate the Sea Surface Temperature data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEA_TEMP) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("Sea\nTemperature"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetSeaTemp(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate the Convective Available Potential Energy (CAPE) data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_CAPE) != wxNOT_FOUND) {
            AddDataRow( nrows, i, _("CAPE"), singledatarow );
            m_pGribTable->SetCellValue(nrows, i, GetCAPE(RecordArray));
            m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
            nrows++;
        }
        //create and polulate the current data row
        if(m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VX) != wxNOT_FOUND &&
            m_pGDialog->m_bGRIBActiveFile->m_GribIdxArray.Index(Idx_SEACURRENT_VY) != wxNOT_FOUND) {
                AddDataRow( nrows, i, _("Current"), doubledatarow );
                m_pGribTable->SetCellValue(nrows, i, GetCurrent(RecordArray));
                m_pGribTable->SetCellBackgroundColour(nrows, i, m_pDataCellsColour);
                nrows++;
        }

        m_pGribTable->AutoSizeColumn(i, false);
        ncols++;

        //write 'days' row
        if(time.GetDateOnly() != day.GetDateOnly() || i == rsa->GetCount()- 1){
            if( i == 0 ) continue;                                      //not the first item

            if(i == rsa->GetCount() - 1 && ncols != 1) ncols++;         ////if end of time range don't forgett the last col

            m_pGribTable->SetCellSize(0, dcol, 1, ncols);
            m_pGribTable->SetCellValue(0, dcol, GetTimeRowsStrings(day.GetDateOnly() , zone, 1));

            day = rsa->Item(i).m_Reference_Time;
            dcol = i;

            if( ncols == 1){                                            //if only one item per day
                m_pGribTable->AutoSizeColumn(i-1, false);
                if(i == rsa->GetCount() - 1 ) {                         //if end of time range
                    m_pGribTable->SetCellValue(0, i, GetTimeRowsStrings(day.GetDateOnly() , zone, 1));
                    m_pGribTable->AutoSizeColumn(i, false);
                }
            }  
            ncols = 0;
        }
    }
    AutoSizeDataRows();
    m_pGribTable->SetGridCursor( m_pGribTable->GetNumberRows(), 0);     //put cursor outside the grid

    this->Fit();
    this->Refresh();
}
Ejemplo n.º 11
0
double FGAtmosphere::GetDensity(double altitude) const
{
  return GetPressure(altitude)/(Reng * GetTemperature(altitude));
}
Ejemplo n.º 12
0
TGeoMedium* KVSpectroDetector::GetGeoMedium(const Char_t* mat_name){
	// By default, return pointer to TGeoMedium corresponding to this KVMaterial.
	// If argument "mat_name" is given, a pointer to a medium is return for this material.
	// mat_name = "Vacuum" is a special case: if the "Vacuum" does not exist, we create it.
	//
	// Instance of geometry manager class TGeoManager must be created before calling this
	// method, otherwise 0x0 will be returned.
	// If the required TGeoMedium is not already available in the TGeoManager, we create
	// a new TGeoMedium corresponding to the material given in argument.

	if( !gGeoManager ) return NULL;


   	TString medName, matName;
	if( !strcmp(mat_name,"") ){
   		// for gaseous materials, the TGeoMedium/Material name is of the form
   		//      gasname_pressure
   		// e.g. C3F8_37.5 for C3F8 gas at 37.5 torr
   		// each gas with different pressure has to have a separate TGeoMaterial/Medium
   		matName = GetName();
    	KVIonRangeTableMaterial* irmat = KVMaterial::GetRangeTable()->GetMaterial(matName.Data());
   		if(irmat->IsGas()) medName.Form("%s_%f", matName.Data(), GetPressure());
   		else medName = GetName();
  	} 
	else{
		matName = mat_name;
		medName = mat_name;
 	}

	TGeoMedium* gmed = gGeoManager->GetMedium( medName);
	if( gmed ) return gmed;

	TGeoMaterial *gmat = gGeoManager->GetMaterial( medName);
	if( !gmat ){
 		if( !strcmp(matName.Data(), "Vacuum") ){
			// create material
			gmat = new TGeoMaterial("Vacuum",0,0,0 );
		}
		else{
			// create material
			gmat = GetRangeTable()->GetTGeoMaterial(matName.Data());
			if(!gmat){
				Error("GetGeoMedium","Material %s is nowhere to be found in %s"
						,matName.Data(),GetRangeTable()->GetName());
				return NULL;
			}
			gmat->SetPressure( GetPressure() );
			gmat->SetTemperature( GetTemperature() );
			gmat->SetTransparency(0);
      	}
	}

	// For the moment the names of material and medium do not
	// depend on the temperature of the material.
	gmat->SetName(medName);
    gmat->SetTitle(matName);

	// create medium
	TGeoMedium* lastmed = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last();
	Int_t numed = (lastmed ? lastmed->GetId()+1 : 0); // static counter variable used to number media
	gmed = new TGeoMedium( medName, numed, gmat );
	numed+=1;

	return gmed;
}
Ejemplo n.º 13
0
    void EulerADCFE::DoOdeRhs(
        const Array<OneD, const Array<OneD, NekDouble> > &inarray,
        Array<OneD,       Array<OneD, NekDouble> > &outarray,
        const NekDouble                                   time)
    {
        int i;
        int nvariables = inarray.num_elements();
        int npoints    = GetNpoints();

        Array<OneD, Array<OneD, NekDouble> > advVel;
        Array<OneD, Array<OneD, NekDouble> > outarrayAdv(nvariables);
        Array<OneD, Array<OneD, NekDouble> > outarrayDiff(nvariables);

        for (i = 0; i < nvariables; ++i)
        {
            outarrayAdv[i] = Array<OneD, NekDouble>(npoints, 0.0);
            outarrayDiff[i] = Array<OneD, NekDouble>(npoints, 0.0);
        }

        m_advection->Advect(nvariables, m_fields, advVel, inarray,
                                        outarrayAdv, m_time);

        for (i = 0; i < nvariables; ++i)
        {
            Vmath::Neg(npoints, outarrayAdv[i], 1);
        }

        m_diffusion->Diffuse(nvariables, m_fields, inarray, outarrayDiff);

        if (m_shockCaptureType == "NonSmooth")
        {
            for (i = 0; i < nvariables; ++i)
            {
                Vmath::Vadd(npoints,
                            outarrayAdv[i], 1,
                            outarrayDiff[i], 1,
                            outarray[i], 1);
            }
        }
        if(m_shockCaptureType == "Smooth")
        {
            const Array<OneD, int> ExpOrder = GetNumExpModesPerExp();

            NekDouble pOrder = Vmath::Vmax(ExpOrder.num_elements(), ExpOrder, 1);

            Array <OneD, NekDouble > a_vel  (npoints, 0.0);
            Array <OneD, NekDouble > u_abs  (npoints, 0.0);
            Array <OneD, NekDouble > pres   (npoints, 0.0);
            Array <OneD, NekDouble > wave_sp(npoints, 0.0);

            GetPressure(inarray, pres);
            GetSoundSpeed(inarray, pres, a_vel);
            GetAbsoluteVelocity(inarray, u_abs);

            Vmath::Vadd(npoints, a_vel, 1, u_abs, 1, wave_sp, 1);

            NekDouble max_wave_sp = Vmath::Vmax(npoints, wave_sp, 1);

            Vmath::Smul(npoints,
                        m_C2,
                        outarrayDiff[nvariables-1], 1,
                        outarrayDiff[nvariables-1], 1);

            Vmath::Smul(npoints,
                        max_wave_sp,
                        outarrayDiff[nvariables-1], 1,
                        outarrayDiff[nvariables-1], 1);

            Vmath::Smul(npoints,
                        pOrder,
                        outarrayDiff[nvariables-1], 1,
                        outarrayDiff[nvariables-1], 1);

            for (i = 0; i < nvariables; ++i)
            {
                Vmath::Vadd(npoints,
                            outarrayAdv[i], 1,
                            outarrayDiff[i], 1,
                            outarray[i], 1);
            }

            Array<OneD, Array<OneD, NekDouble> > outarrayForcing(nvariables);

            for (i = 0; i < nvariables; ++i)
            {
                outarrayForcing[i] = Array<OneD, NekDouble>(npoints, 0.0);
            }

            GetForcingTerm(inarray, outarrayForcing);

            for (i = 0; i < nvariables; ++i)
            {
                // Add Forcing Term
                Vmath::Vadd(npoints,
                            outarray[i], 1,
                            outarrayForcing[i], 1,
                            outarray[i], 1);
            }
        }

        // Add sponge layer if defined in the session file
        std::vector<SolverUtils::ForcingSharedPtr>::const_iterator x;
        for (x = m_forcing.begin(); x != m_forcing.end(); ++x)
        {
            (*x)->Apply(m_fields, inarray, outarray, time);
        }
    }