All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
QGpCompatibility::CompatModalFrequency Class Reference

Vector of double to store frequency samples and abstract modal object. More...

#include <CompatModalFrequency.h>

Inheritance diagram for QGpCompatibility::CompatModalFrequency:
QVector QGpCoreTools::XMLClass QGpCompatibility::CompatModalRefinedCurves QGpCompatibility::CompatModalDispersion QGpCompatibility::CompatModalEllipticity

List of all members.

Public Member Functions

void addLoveModes (int nNewModes)
virtual void addRayleighModes (int nNewModes)=0
 CompatModalFrequency ()
QVector< double > * frequencies () const
void insertOmegas (const CompatModalFrequency &samples)
bool isSameOmegas (const CompatModalFrequency &o) const
int nLoveModes () const
virtual int nModes () const =0
int nOmegas () const
int nRayleighModes () const
double & omega (int iOmega)
const double & omega (int iOmega) const
void operator= (CompatModalFrequency &o)
void setFrequencies (QVector< double > &values)
virtual void setNModes (int nm)=0
virtual void setNOmegas (int nf)
void setNRayleighModes (int nRm)
virtual const QString & xml_tagName () const
virtual ~CompatModalFrequency ()

Static Public Attributes

static const QString xmlModalFrequencyTag = "ModalFrequency"

Protected Member Functions

virtual void addInvalid ()=0
virtual void insertInvalidAt (int i)=0
virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
virtual void xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const

Protected Attributes

int _nRayleighModes

Detailed Description

Vector of double to store frequency samples and abstract modal object.


Constructor & Destructor Documentation

References _nRayleighModes, and TRACE.

{};

Member Function Documentation

virtual void QGpCompatibility::CompatModalFrequency::addInvalid ( ) [protected, pure virtual]

Because Love modes are located at the end, there is nothing else to do than adding new modes

References nModes(), setNModes(), and TRACE.

{
  TRACE;
  if(nNewModes==0) return;
  setNModes(nModes()+nNewModes);
}

if there are Love modes, the task is a bit more complex...

Implemented in QGpCompatibility::CompatModalRefinedCurves.

References nOmegas(), and omega().

{
  QVector<double> * list=new QVector<double>;
  list->reserve(nOmegas());
  double fac=0.5/M_PI;
  for(int i=0;i<nOmegas();i++)
    list->push_back(omega(i)*fac);
  return list;
}
virtual void QGpCompatibility::CompatModalFrequency::insertInvalidAt ( int  i) [protected, pure virtual]

Make sure that all samples of samples are included in this sample set. If a sample already exists nothing is performed. If not, an invalid sample is added.

References addInvalid(), insertInvalidAt(), nOmegas(), omega(), and TRACE.

{
  TRACE;
  int nf2Add=o.nOmegas();
  int i=0;
  for(int i2Add=0;i2Add<nf2Add;i2Add++) {
    double f2Add=o.omega(i2Add);
    while(i<nOmegas() && omega(i)<f2Add) i++;
    if(i>=nOmegas()) {
      append(f2Add);
      addInvalid();
    } else if(omega(i)>f2Add) {
      insert(i,f2Add);
      insertInvalidAt(i);
      i++;
    }
  }
}

References nOmegas(), omega(), and TRACE.

{
  TRACE;
  if(nOmegas()!=o.nOmegas()) return false;
  for(int i=0;i<nOmegas();i++) {
    if(omega(i)!=o.omega(i)) return false;
  }
  return true;
}
{return nModes()-_nRayleighModes;}
virtual int QGpCompatibility::CompatModalFrequency::nModes ( ) const [pure virtual]
double& QGpCompatibility::CompatModalFrequency::omega ( int  iOmega) [inline]
const double& QGpCompatibility::CompatModalFrequency::omega ( int  iOmega) const [inline]
{return operator[] (iOmega);}
void QGpCompatibility::CompatModalFrequency::operator= ( CompatModalFrequency o)

References _nRayleighModes, and TRACE.

{
  TRACE;
  QVector<double>::operator=(o);
  _nRayleighModes=o._nRayleighModes;
}

References QGpCoreTools::endl(), nOmegas(), omega(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  if(nOmegas()==(int)values.size()) {
    for(int i=0;i<nOmegas();i++) omega(i)=2*M_PI*values[i];
  }
  else App::stream() << tr("Number of frequency do not match in %1, at line %2").arg(__FILE__).arg(__LINE__) << endl;
  ASSERT (at(0)<at(nOmegas()-1));
}
virtual void QGpCompatibility::CompatModalFrequency::setNModes ( int  nm) [pure virtual]
virtual void QGpCompatibility::CompatModalFrequency::setNOmegas ( int  nf) [inline, virtual]

Reimplemented in QGpCompatibility::CompatModalRefinedCurves.

Referenced by QGpCompatibility::operator>>().

{resize(nf);}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

Reimplemented in QGpCompatibility::CompatModalRefinedCurves, and QGpCompatibility::CompatModalEllipticity.

References QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  Q_UNUSED(attributes)
  Q_UNUSED(context);
  if(tag=="values") return XMLMember(0);
  else if(tag=="val") return XMLMember(1);
  else if(tag=="DoubleVector") {
    App::stream() << tr("## WARNING ## : old style for list of frequencies, replace\n"
                 "<DoubleVector>\n"
                 "   <val>f1</val>\n"
                 "   <val>f2</val>\n"
                 "   ...\n"
                 " </DoubleVector>\n"
                 "by\n"
                 "<val>f1</val>\n"
                 "<val>f2</val>\n"
                 "  ...\n");
    return XMLMember(XMLMember::Unknown);
  } else if(tag=="nRayleighModes") return XMLMember(2);
  else return XMLMember(XMLMember::Unknown);
}

Re-implement this function to offer XML restore properties support to your class.

From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).

For a general case:

  Q_UNUSED(attributes);
  double val=content.toDouble();
  switch (memberID) {
  case 0:
    _x1=val;
    return true;
  case 1:
    _y1=val;
    return true;
  case 2:
    _x2=val;
    return true;
  case 3:
    _y2=val;
    return true;
  default:
    return false;
  }

For classes inheriting other classes (see also xml_member())

  switch (memberID) {
  case 0:
    _anInteger=content.toString();
    return true;
  case 1:
    _aString=content.toInt();
    return true;
  case 2:
    _aDouble=content.toDouble();
    return true;
  default:
    return AbstractLine::xml_setProperty(memberID-3, map, content);

For the arguments of this function use Macro XML_SETPROPERTY_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

Reimplemented in QGpCompatibility::CompatModalEllipticity.

References _nRayleighModes, QGpCoreTools::StringSection::isValid(), QGpCoreTools::StringSection::nextField(), QGpCoreTools::StringSection::toDouble(), and TRACE.

{
  TRACE;
  Q_UNUSED(tag);
  Q_UNUSED(attributes)
  Q_UNUSED(context);
  switch (memberID) {
  case 0: {
      const QChar * ptr=0;
      static const QString sep=" \n\t\r";
      StringSection f;
      clear();
      while(true) {
        f=content.nextField(ptr, sep, true);
        if(f.isValid()) append(f.toDouble()); else break;
      }
    }
    return true;
  case 1:
    append(content.toDouble());
    return true;
  case 2:
    _nRayleighModes=content.toInt();
    return true;
  default:
    return false;
  }
}
virtual const QString& QGpCompatibility::CompatModalFrequency::xml_tagName ( ) const [inline, virtual]

Reimplemented from QGpCoreTools::XMLClass.

Reimplemented in QGpCompatibility::CompatModalEllipticity.

References _nRayleighModes, QGpCoreTools::endl(), TRACE, and QGpCoreTools::XMLClass::writeProperty().

{
  TRACE;
  Q_UNUSED(context);
  writeProperty(s, "nRayleighModes",_nRayleighModes);
  QString tmp;
  tmp+=s.indent();
  tmp+="<values>\n";
  int n=count();
  for(int i=0;i<n;i++) {
    tmp+=s.indent();
    tmp+="    ";
    tmp+=QString::number(at(i));
    tmp+="\n";
  }
  tmp+=s.indent();
  tmp+="</values>";
  s << tmp << endl;
}

Member Data Documentation

const QString QGpCompatibility::CompatModalFrequency::xmlModalFrequencyTag = "ModalFrequency" [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines