OpenWAM
TCCExtremoCerrado.cpp
1 /*--------------------------------------------------------------------------------*\
2 ==========================|
3  \\ /\ /\ // O pen | OpenWAM: The Open Source 1D Gas-Dynamic Code
4  \\ | X | // W ave |
5  \\ \/_\/ // A ction | CMT-Motores Termicos / Universidad Politecnica Valencia
6  \\/ \// M odel |
7  ----------------------------------------------------------------------------------
8  License
9 
10  This file is part of OpenWAM.
11 
12  OpenWAM is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenWAM is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenWAM. If not, see <http://www.gnu.org/licenses/>.
24 
25 
26  \*--------------------------------------------------------------------------------*/
27 
28 //---------------------------------------------------------------------------
29 #pragma hdrstop
30 
31 #include "TCCExtremoCerrado.h"
32 #include "TTubo.h"
33 
34 //---------------------------------------------------------------------------
35 //---------------------------------------------------------------------------
36 
37 TCCExtremoCerrado::TCCExtremoCerrado(nmTypeBC TipoCC, int numCC, nmTipoCalculoEspecies SpeciesModel, int numeroespecies,
38  nmCalculoGamma GammaCalculation, bool ThereIsEGR) :
39  TCondicionContorno(TipoCC, numCC, SpeciesModel, numeroespecies, GammaCalculation, ThereIsEGR) {
40 
41  FTuboExtremo = NULL;
42 
43 }
44 //---------------------------------------------------------------------------
45 //---------------------------------------------------------------------------
46 
47 TCCExtremoCerrado::~TCCExtremoCerrado() {
48 
49  delete[] FTuboExtremo;
50 
51 }
52 
53 //---------------------------------------------------------------------------
54 //---------------------------------------------------------------------------
55 
56 void TCCExtremoCerrado::AsignaTubos(int NumberOfPipes, TTubo **Pipe) {
57  try {
58  int i = 0;
59 
60  FTuboExtremo = new stTuboExtremo[1];
61  FTuboExtremo[0].Pipe = NULL;
62 
63  while(FNumeroTubosCC < 1 && i < NumberOfPipes) {
64  if(Pipe[i]->getNodoIzq() == FNumeroCC) {
65  FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
66  FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmLeft;
67  FCC = &(FTuboExtremo[FNumeroTubosCC].Beta);
68  FCD = &(FTuboExtremo[FNumeroTubosCC].Landa);
69  FNodoFin = 0;
70  FIndiceCC = 0;
71  FNumeroTubosCC++;
72  }
73  if(Pipe[i]->getNodoDer() == FNumeroCC) {
74  FTuboExtremo[FNumeroTubosCC].Pipe = Pipe[i];
75  FTuboExtremo[FNumeroTubosCC].TipoExtremo = nmRight;
76  FCC = &(FTuboExtremo[FNumeroTubosCC].Landa);
77  FCD = &(FTuboExtremo[FNumeroTubosCC].Beta);
78  FNodoFin = FTuboExtremo[FNumeroTubosCC].Pipe->getNin() - 1;
79  FIndiceCC = 1;
80  FNumeroTubosCC++;
81  }
82  i++;
83  }
84 
85 // Inicializacion del transporte de especies quimicas.
86  FFraccionMasicaEspecie = new double[FNumeroEspecies - FIntEGR];
87  for(int i = 0; i < FNumeroEspecies - FIntEGR; i++) {
88  FFraccionMasicaEspecie[i] = FTuboExtremo[0].Pipe->GetFraccionMasicaInicial(i);
89  }
90 
91  } catch(exception &N) {
92  std::cout << "ERROR: TCCExtremoCerrado::AsignaTubos en la condicion de contorno: " << FNumeroCC << std::endl;
93  std::cout << "Tipo de error: " << N.what() << std::endl;
94  throw Exception(N.what());
95  }
96 }
97 
98 //---------------------------------------------------------------------------
99 //---------------------------------------------------------------------------
100 
101 void TCCExtremoCerrado::CalculaCondicionContorno(double Time) {
102  try {
103  double FraccionMasicaAcum = 0.;
104 
105  *FCD = *FCC;
106 
107 //Transporte de especies quimicas.
108  for(int j = 0; j < FNumeroEspecies - 2; j++) {
109  FFraccionMasicaEspecie[j] = FTuboExtremo[0].Pipe->GetFraccionMasicaCC(FIndiceCC, j);
110  FraccionMasicaAcum += FFraccionMasicaEspecie[j];
111  }
112  FFraccionMasicaEspecie[FNumeroEspecies - 2] = 1. - FraccionMasicaAcum;
113  if(FHayEGR)
114  FFraccionMasicaEspecie[FNumeroEspecies - 1] = FTuboExtremo[0].Pipe->GetFraccionMasicaCC(FIndiceCC, FNumeroEspecies - 1);
115  } catch(exception &N) {
116  std::cout << "ERROR: TCCExtremoCerrado::CalculaCondicionesContorno en la condicion de contorno: " << FNumeroCC <<
117  std::endl;
118  std::cout << "Tipo de error: " << N.what() << std::endl;
119  throw Exception(N.what());
120  }
121 }
122 
123 //---------------------------------------------------------------------------
124 //---------------------------------------------------------------------------
125 
126 #pragma package(smart_init)
127 
TTubo
a Finite differences pipe.
Definition: TTubo.h:116
stTuboExtremo
Definition: Globales.h:730
TTubo::GetFraccionMasicaCC
double GetFraccionMasicaCC(int j, int i)
Definition: TTubo.h:953
TTubo::GetFraccionMasicaInicial
double GetFraccionMasicaInicial(int i) const
Gets the initial mass fraction of species i.
Definition: TTubo.cpp:5440
TCondicionContorno
Definition: TCondicionContorno.h:54
Exception
Custom exception class.
Definition: Exception.hpp:39
TTubo.h