From: michael Date: Mon, 17 May 2021 08:41:02 +0000 (+0200) Subject: Check memory is initialized in output field functions X-Git-Tag: V9_7_0~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b82851db31fb1fee7b8c77060f470b129d9b22c8;p=tools%2Fsolverlab.git Check memory is initialized in output field functions --- diff --git a/CoreFlows/Models/src/SinglePhase.cxx b/CoreFlows/Models/src/SinglePhase.cxx index 96fd147..acf6566 100755 --- a/CoreFlows/Models/src/SinglePhase.cxx +++ b/CoreFlows/Models/src/SinglePhase.cxx @@ -3090,6 +3090,9 @@ void SinglePhase::save(){ Field& SinglePhase::getPressureField() { + if(!_initializedMemory) + throw CdmathException("SinglePhase::getPressureField, Call initialize first"); + if(!_saveAllFields) { _Pressure=Field("Pressure",CELLS,_mesh,1); @@ -3105,6 +3108,9 @@ Field& SinglePhase::getPressureField() Field& SinglePhase::getTemperatureField() { + if(!_initializedMemory) + throw CdmathException("SinglePhase::getTemperatureField, Call initialize first"); + if(!_saveAllFields) { _Temperature=Field("Temperature",CELLS,_mesh,1); @@ -3120,6 +3126,9 @@ Field& SinglePhase::getTemperatureField() Field& SinglePhase::getVelocityField() { + if(!_initializedMemory) + throw CdmathException("SinglePhase::getVelocityField, Call initialize first"); + if(!_saveAllFields ) { _Vitesse=Field("Vitesse",CELLS,_mesh,3); @@ -3143,8 +3152,46 @@ Field& SinglePhase::getVelocityField() return _Vitesse; } +Field& SinglePhase::getMachNumberField() +{ + if(!_initializedMemory) + throw CdmathException("SinglePhase::getMachNumberField, Call initialize first"); + + if(!_saveAllFields ) + { + _MachNumber=Field("Mach number",CELLS,_mesh,1); + int Ii; + double p,T,rho,h, temp, u2=0; + for (long i = 0; i < _Nmailles; i++){ + Ii = i*_nVar; + VecGetValues(_primitiveVars,1,&Ii,&p); + Ii = i*_nVar +_nVar-1; + VecGetValues(_primitiveVars,1,&Ii,&T); + + for (int j = 0; j < _Ndim; j++)//On récupère les composantes de vitesse + { + int Ii = i*_nVar +1+j; + VecGetValues(_primitiveVars,1,&Ii,&temp); + u2+=temp*temp; + } + + rho=_fluides[0]->getDensity(p,T); + h =_fluides[0]->getEnthalpy(T,rho); + _MachNumber[i] =sqrt(u2)/_fluides[0]->vitesseSonEnthalpie(h); + //cout<<"u="<