FlashData Class Reference

#include <flashdata.h>

List of all members.

Public Member Functions

 FlashData (unsigned n_phases, unsigned n_comps, double *mem)
 FlashData (unsigned n_phases, unsigned n_comps)
 FlashData (const FlashData &data)
 ~FlashData ()
void allocateOwnMemory ()
double getMoles (unsigned phase, unsigned comp) const
void setMoles (unsigned phase, unsigned comp, const double &value)
void zeroEntries ()
double getPhaseTotalMoles (unsigned n_phase) const
double getTotalMoles () const
unsigned getNPhases () const
unsigned getNComponents () const
void multiply (VecDouble &B, const VecDouble &X) const
void getPhasesTotalMoles (VecDouble &phases) const
void getPhaseConcentrationsAndTotalMoles (Matrix &phasesC, VecDouble &phases) const
void getMixtureComposition (VecDouble &vComp, double &nT)
void getTotalComponentsMoles (VecDouble &totalComponentsMoles) const
void getPhasesDensities (VecDouble &vDensities, const VecDouble &componentsMolarMass, const VecDouble &phasesVol)
const double * getData () const
void setData (double *)
void setData (FlashData &data)
void print (std::ostream &out=std::cout)
void deepCopy (const FlashData &data)
void operator= (const FlashData &data)

Protected Attributes

double * m_phaseCompositions
unsigned n_phases
unsigned n_comps
bool m_Del

Friends

class FlashDataArray

Detailed Description

FlashData

Definition at line 11 of file flashdata.h.


Constructor & Destructor Documentation

FlashData::FlashData ( unsigned  n_phases,
unsigned  n_comps,
double *  mem 
)

Definition at line 22 of file flashdata.cpp.

00023    :n_phases(n_phases),n_comps(n_comps)
00024  {
00025    m_phaseCompositions=mem;
00026    m_Del=false;
00027  }

FlashData::FlashData ( unsigned  n_phases,
unsigned  n_comps 
)

Definition at line 29 of file flashdata.cpp.

00030    :n_phases(n_phases),n_comps(n_comps)
00031 {
00032   m_Del=false;
00033   allocateOwnMemory();
00034 } 

FlashData::FlashData ( const FlashData data  ) 

Definition at line 286 of file flashdata.cpp.

00287  {
00288    assert(data.m_phaseCompositions != NULL);
00289    n_phases=data.n_phases;
00290    n_comps=data.n_comps;
00291    m_phaseCompositions=NULL;
00292    m_Del = false;
00293    allocateOwnMemory();
00294    memcpy(m_phaseCompositions,data.m_phaseCompositions,n_phases*n_comps*sizeof(double));
00295 }

FlashData::~FlashData (  ) 

Definition at line 37 of file flashdata.cpp.

00038 {
00039   if (m_Del)
00040     delete [] m_phaseCompositions;
00041 }


Member Function Documentation

void FlashData::allocateOwnMemory (  ) 

Definition at line 45 of file flashdata.cpp.

00046 {
00047   if (!m_Del)
00048   {
00049     m_phaseCompositions=new double[n_phases*n_comps];
00050     m_Del=true;
00051     
00052   }
00053 }

void FlashData::deepCopy ( const FlashData data  ) 

Definition at line 258 of file flashdata.cpp.

00259 {
00260   assert(!m_Del);  //Flash Data must not be the owner of its data
00261   assert(n_phases==data.n_phases);
00262   assert(n_comps==data.n_comps);
00263   m_phaseCompositions=new double[n_phases*n_comps];
00264   m_Del=true;
00265   memcpy(m_phaseCompositions,data.m_phaseCompositions,n_phases*n_comps*sizeof(double));
00266 }

const double * FlashData::getData (  )  const

Definition at line 172 of file flashdata.cpp.

00173 {
00174   assert(m_phaseCompositions);
00175   return m_phaseCompositions;
00176 }

void FlashData::getMixtureComposition ( VecDouble vComp,
double &  nT 
)

Definition at line 152 of file flashdata.cpp.

00153 {
00154   assert(vComp.size() == n_comps);
00155   const double *dd = m_phaseCompositions;
00156   for (unsigned j=0;j<n_comps;j++)
00157     vComp(j)=*(dd++);
00158   for (unsigned i=1;i<n_phases;i++)
00159   {
00160     for (unsigned j=0;j<n_comps;j++)
00161       vComp(j)+=*(dd++);
00162   }
00163   nT=0.0;
00164   for (unsigned j=0;j<n_comps;j++)
00165     nT+=vComp(j);
00166   for (unsigned j=0;j<n_comps;j++)
00167     vComp(j)/=nT;
00168       
00169 }

double FlashData::getMoles ( unsigned  phase,
unsigned  comp 
) const

Definition at line 5 of file flashdata.cpp.

00006 {
00007   assert(phase<n_phases && comp <n_comps);
00008   assert(m_phaseCompositions);
00009   return m_phaseCompositions[phase*n_comps+comp];
00010 }

unsigned FlashData::getNComponents (  )  const [inline]

Definition at line 34 of file flashdata.h.

00034 {return n_comps;} 

unsigned FlashData::getNPhases (  )  const [inline]

Definition at line 33 of file flashdata.h.

00033 {return n_phases;}

void FlashData::getPhaseConcentrationsAndTotalMoles ( Matrix phasesC,
VecDouble phases 
) const

Definition at line 90 of file flashdata.cpp.

00091 {
00092   assert(m_phaseCompositions);
00093   assert(phasesC.m() == n_phases && phasesC.n() == n_comps);
00094   assert(phasesTM.size() == n_phases);
00095   getPhasesTotalMoles(phasesTM);
00096   const double *dd=m_phaseCompositions;
00097   double *dr=&(phasesC(0,0));
00098 
00099   for (unsigned i=0;i<n_phases;i++)
00100   {    
00101     for (unsigned j=0;j<n_comps;j++)
00102     {
00103       *(dr++)=*(dd++)/phasesTM(i);
00104     }
00105   }
00106 }

void FlashData::getPhasesDensities ( VecDouble vDensities,
const VecDouble componentsMolarMass,
const VecDouble phasesVol 
)

Definition at line 238 of file flashdata.cpp.

00239 {
00240   assert(vDensities.size() == getNPhases());
00241   assert(componentsMolarMass.size() == getNComponents());
00242   assert(phasesVol.size() == getNPhases());
00243 
00244   multiply(vDensities,componentsMolarMass);
00245   NumericMethods::vectorDivideEntriesAvoidingNAN(vDensities,phasesVol);
00246   
00247 }

void FlashData::getPhasesTotalMoles ( VecDouble phases  )  const

Definition at line 73 of file flashdata.cpp.

00074 {
00075   assert(phases.size() == n_phases);
00076   assert(m_phaseCompositions);
00077   double acum;
00078   const double *dd=m_phaseCompositions;
00079   for (unsigned i=0;i<n_phases;i++)
00080   {
00081     acum=0.0;
00082     for (unsigned j=0;j<n_comps;j++)
00083     {
00084       acum+=*(dd++);
00085     }
00086     phases(i)=acum;
00087   }
00088 }

double FlashData::getPhaseTotalMoles ( unsigned  n_phase  )  const

Definition at line 60 of file flashdata.cpp.

00061 {
00062   assert(m_phaseCompositions);
00063   assert(phase<n_phases);
00064   double acum=0;
00065   const double *dd=&(m_phaseCompositions[phase*n_comps]);
00066   for (unsigned i=0;i<n_comps;i++)
00067   {
00068     acum+=*(dd++);
00069   }
00070   return acum;
00071 }

void FlashData::getTotalComponentsMoles ( VecDouble totalComponentsMoles  )  const

Get the total amount of moles of each component

Parameters:
totalComponentsMoles A vector of size equal to the number of components to contain the result

Definition at line 222 of file flashdata.cpp.

00223 {
00224   assert(totalComponentsMoles.size() == n_comps);
00225   assert(m_phaseCompositions);
00226   double *dd=m_phaseCompositions;
00227   for (unsigned j=0;j<n_comps;j++)
00228     totalComponentsMoles(j)=*dd++;
00229 
00230   for (unsigned i=1;i<n_phases;i++)
00231     for (unsigned j=0;j<n_comps;j++)
00232       totalComponentsMoles(j)+=*dd++;
00233 }

double FlashData::getTotalMoles (  )  const

Definition at line 110 of file flashdata.cpp.

00111 {
00112   assert(m_phaseCompositions);
00113   double acum=0.0;
00114   const double *dd=m_phaseCompositions;
00115   const unsigned nElems=n_phases*n_comps;
00116   for (unsigned i=0;i<nElems;i++)
00117   {
00118     acum+=*(dd++);
00119   }
00120   return acum;
00121 }

void FlashData::multiply ( VecDouble B,
const VecDouble X 
) const

Do normal matrix multiplication B := M X where M is the table containing the moles composition for each phase.

Parameters:
B Vector to receive the multiplication
X Vector to be multiplied by M
Returns:

Definition at line 131 of file flashdata.cpp.

00132 {
00133   assert(m_phaseCompositions);
00134   assert(X.size() == n_comps);
00135   assert(B.size() == n_phases);
00136   double acum;
00137   const double *dd=m_phaseCompositions;
00138   for (unsigned i=0;i<n_phases;i++)
00139   {
00140     acum=0;
00141     for (unsigned j=0;j<n_comps;j++)
00142       {
00143         acum+=*(dd++)*X(j);
00144       }
00145     B(i)=acum;
00146   }
00147 }

void FlashData::operator= ( const FlashData data  ) 

Definition at line 277 of file flashdata.cpp.

00278 {
00279   assert(m_phaseCompositions != NULL);
00280   assert(data.m_phaseCompositions != NULL);
00281   assert(n_phases == data.n_phases);
00282   assert(n_comps == data.n_comps);
00283   memcpy(m_phaseCompositions,data.m_phaseCompositions,n_phases*n_comps*sizeof(double));
00284 }

void FlashData::print ( std::ostream &  out = std::cout  ) 

Definition at line 205 of file flashdata.cpp.

00206 {
00207   assert(m_phaseCompositions);
00208   for (unsigned i=0;i<n_phases;i++)
00209   {
00210     out << "Phase " << i << ": ";
00211     for (unsigned j=0;j<n_comps;j++)
00212       out << getMoles(i,j) << "\t";
00213     out << std::endl;
00214   }
00215   
00216 }

void FlashData::setData ( FlashData data  ) 

Definition at line 249 of file flashdata.cpp.

00250 {
00251   assert(data.m_phaseCompositions != NULL);
00252   assert(!m_Del);
00253   m_phaseCompositions=data.m_phaseCompositions;
00254 }

void FlashData::setData ( double *  dd  ) 

Definition at line 179 of file flashdata.cpp.

00180 {
00181   if (!m_Del)
00182     m_phaseCompositions=dd;
00183   else
00184   {
00185     m_Del=false;
00186     if (m_phaseCompositions)
00187       delete [] m_phaseCompositions;
00188     m_phaseCompositions=dd;
00189   }
00190 }

void FlashData::setMoles ( unsigned  phase,
unsigned  comp,
const double &  value 
)

Definition at line 12 of file flashdata.cpp.

00013 {
00014   assert(m_phaseCompositions);
00015   m_phaseCompositions[phase*n_comps+comp]=value;
00016   
00017   
00018 }

void FlashData::zeroEntries (  ) 

Definition at line 194 of file flashdata.cpp.

00195 {
00196   assert(m_phaseCompositions);
00197   double *dd = m_phaseCompositions;
00198   unsigned size=n_phases*n_comps;
00199   for (unsigned i=0;i<size;i++)
00200     *dd++=0.0;
00201 }


Friends And Related Function Documentation

friend class FlashDataArray [friend]

Definition at line 13 of file flashdata.h.


Member Data Documentation

bool FlashData::m_Del [protected]

Definition at line 18 of file flashdata.h.

double* FlashData::m_phaseCompositions [protected]

Definition at line 16 of file flashdata.h.

unsigned FlashData::n_comps [protected]

Definition at line 17 of file flashdata.h.

unsigned FlashData::n_phases [protected]

Definition at line 17 of file flashdata.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Sun Apr 8 23:13:07 2012 for CO2INJECTION by  doxygen 1.6.3