Beispiel #1
0
int RegionIO::ReadData(istream &input)
{
   int i=0,NumR=5+NumIntPar;
   double *d=new double [7+NumIntPar];
   char tmp[256];
cout<<" Reading Param RegionIO::ReadData Num "<<NumPnt<<" Coreleft "<<Coreleft()<<"\n";
   input.getline(tmp,255);// EndIter
   input.getline(tmp,255);// Pos Pres...
   while ((!seek_eof(input)) && (EnterStr(input,&d[0],NumR+1,1)==0)) ;
   if (seek_eof(input))
     {cout<<"RegionIO::ReadData; NoPoints ";delete d;return 0;}
   do
        {                    
         i++;
         Pos     [i]=d[1];
         Pressure[i]=d[2]*1e5;
         Dencity [i]=d[3];
         Velocity[i]=d[5];
         Energy  [i]=d[4];
		 if (NumIntPar>0) MemoryMove(&d[6],IntPar[i],sizeof(double)*NumIntPar);
        }
   while ( (i<NumPnt) && (!seek_eof(input)) && 
			                      (EnterStr(input,&d[0],NumR+1,1)==NumR) );
   delete d;
   if ((i<NumPnt) || (NumPnt==0))
     {cout<<"RegionIO::ReadData; Entered only part of points NumPnt i "
          <<NumPnt<<"   "<<i<<"\n";
      if (i!=0) InterfaceIODelete();
      return 0;
      }
   ExtendBnd();
   return 1;
};
Beispiel #2
0
void RegionIO::Pres()
  {  
   int l,b,k,i;
   for (i=1;i<=NumMatter;i++)
	  {
		b=BndMatter[i-1]-1;l=BndMatter[i]-BndMatter[i-1];
#ifdef InternalPointsUrs
	   if (Matter[i]->NumIntPar()!=0) Matter[i]->SetIntParArr(IntPar,b);
			   Matter[i]->Pressure(&Pressure[b],&Dencity[b],&Energy[b],l);
#else
//      FstCalcP=1;
       if (FstCalcP)
			   Matter[i]->Pressure(&Pressure[b],&Dencity[b],&Energy[b],l);
       else 
        {
//         double  *TmpP=new double [l],*TmpD=new double [l],*TmpE=new double [l];
         double  *TP=TmpP,*TD=TmpD,*TE=TmpE;
         int n=0,o;
         for (o=b+1;o<=b+l;o++) 
             {
              if (!Fixed[o]) {TD[n]=Dencity[o];TE[n]=Energy[o];n++;}}
         Matter[i]->Pressure(&TP[-1],&TD[-1],&TE[-1],n);
         n=0;
         for (o=b+1;o<=b+l;o++) if (!Fixed[o]) {Pressure[o]=TP[n];n++;} else Pressure[o]=PresL[o];
        }
#endif
     }
   if (LftFree) { Pressure[0]=0;Energy[0]=0;}
   if (RgtFree) { Pressure[NumPnt]=0;Energy[NumPnt]=0;}
   MemoryMove(Pressure,PresL,sizeof(double)*(NumPnt+2));FstCalcP=0;
   for ( k=1;k<NumPnt;k++) Pressure[k]=max<double>(Pressure[k]*1e5,10);
  };
Beispiel #3
0
void RegionIO::Sound(double *S)
{  
   int l,b;//,k;
   for (int i=1;i<=NumMatter;i++)
   {
	b=BndMatter[i-1]-1;l=BndMatter[i]-BndMatter[i-1];
#ifdef InternalPointsUrs
	if (Matter[i]->NumIntPar()!=0) Matter[i]->SetIntParArr(IntPar,b);
	Matter[i]->Sound(&S[b],&Dencity[b],&Energy[b],l);
#else
//      FstCalcS=1;
      if (FstCalcS)
	Matter[i]->Sound(&S[b],&Dencity[b],&Energy[b],l);
      else 
        {
         double  *TS=TmpP,*TD=TmpD,*TE=TmpE;
         int n=0,o;
         for (o=b+1;o<=b+l;o++) 
             if (!Fixed[o]) {TD[n]=Dencity[o];TE[n]=Energy[o];n++;}
         Matter[i]->Sound(&TS[-1],&TD[-1],&TE[-1],n);
//for (k=0;k<n;k++) cout<<" ST "<<TmpS[k]<<"\n";
         n=0;
         for (o=b+1;o<=b+l;o++) if (!Fixed[o]) {S[o]=TS[n];n++;} else S[o]=SounL[o];
//         delete TmpS;delete TmpE; delete TmpD;
        }
#endif
	}

  MemoryMove(S,SounL,sizeof(double)*(NumPnt+2));FstCalcS=0;
//   for (k=1;k<NumPnt;k++) cout<<" S "<<S[k]<<" k "<<k<<"\n";
//   for ( k=1;k<NumPnt;k++) cout<<" SL "<<SounL[k]<<" k "<<k<<"\n";
//   ChRead();
};			
Beispiel #4
0
void Pxf::StringRollRight(char *str)
{
	int len_str = StringLength(str);
	char c = str[len_str-1];
	MemoryMove(str+1, str, len_str-1);
	*str = c;
}
Beispiel #5
0
void Pxf::StringRollLeft(char *str)
{
	int len_str = StringLength(str);
	char c = *str;
	MemoryMove(str, str+1, len_str-1);
	str[len_str-1] = c;
}
Beispiel #6
0
void Pxf::ReplaceString(char *str, const char *find, const char *replace)
{
	int len_find = StringLength(find);
	int len_replace = StringLength(replace);

	const char *p, *s;
	char *t;

	if (len_find - len_replace < 0) return;

	p = StringFind(str, find);
	if (!p) return;
	
	s = t = (char*)p;
	while(*s)
	{
		MemoryCopy(t, replace, len_replace);
		p += len_find;
		t += len_replace;
		s = StringFind(p, find);
		if(!s) s = p + StringLength(p);
		MemoryMove(t, p, (unsigned)(s-p));
		t += s-p;
		p = s;
	}
	*t = 0;
}
Beispiel #7
0
void RegionIO::SaveData(ostream &output)
{
   int i=0;
   double *d=new double [7+NumIntPar];

   output<<"   Pos         Pressure   Dencity    Energy     Velocity   \n";
   while (i<NumPnt)
     {
      i++;
      d[1]=Pos     [i];
      d[2]=Pressure[i]*1e-5;
      d[3]=Dencity [i];
      d[5]=Velocity[i];
      d[4]=Energy  [i];
      if (NumIntPar>0) MemoryMove(IntPar[i],&d[6],sizeof(double)*NumIntPar);

      WriteStr(output,&d[0],5+NumIntPar);
     }
			delete d;

  }; 
Beispiel #8
0
void RelaxHamInt(RelaxAverageStruct &Aver,
                 double H,double Qs,double Eta,double Is,double Wid,
                 double *x,double *y)
 {
  VecCl res(x[0]);res=res*0;y[0]=x[0];
  VecCl tmp;
  MessRelaxInpPar RelaxPar;
  Time_struct time;
  for (int k=1;k<=Aver.NumToAverage;k++)
   {
    GenerateRelaxPar(RelaxPar,Aver);
    RelaxOneHamInt(RelaxPar,H, Qs, Eta, Is, Wid, x,y);
//    RelaxOneHamIntMul(RelaxPar,H, Qs, Eta, Is, Wid, x,y);
    tmp=y;res=res+tmp;
//    Aver.Teta0=double(rand())/RAND_MAX*180;
//    Aver.Phi0=double(rand())/RAND_MAX*360;
	Aver.Phi0=RandomClass::Rnd(360);
//    Aver.MeanRotTime*=-1;
   }
  res=res/Aver.NumToAverage;
  MemoryMove(res.Ptr,y,sizeof(double)*(y[0]+1));
cout<<" Time "<<time<<"\n";cout.flush();
//  return res;
 };