예제 #1
0
파일: asd_init.hpp 프로젝트: matthdu/bagel
ASD<VecType>::ASD(const std::shared_ptr<const PTree> input, std::shared_ptr<Dimer> dimer, std::shared_ptr<DimerCISpace_base<VecType>> cispace, bool rdm)
    : ASD_base(input, dimer, rdm), cispace_(cispace) {

    Timer timer;

    cispace_->complete();
    std::cout << "  o completing CI spin space: " << timer.tick() << std::endl;

    // Organize subspaces
    dimerstates_ = 0;
    int maxspin = 0;
    // Process DimerCISpace to form and organize needed Civecs and figure out maxspin
    for ( auto& aiter : cispace_->template cispace<0>() ) {
        SpaceKey akey = aiter.first;
        // values of S_b that could give the proper spin:
        //   S_a-nspin_, S_a-nspin+2,...,S_a+nspin
        for (int Sb = std::abs(akey.S-std::abs(nspin_)); Sb <= akey.S+std::abs(nspin_); Sb+=2) {
            SpaceKey bkey( Sb, nspin_ - akey.m_s, charge_ - akey.q );
            std::shared_ptr<const VecType> bspace = cispace_->template ccvec<1>(bkey);
            if ( bspace ) {
                subspaces_.emplace_back(dimerstates_, akey, bkey, make_pair(aiter.second, bspace));
                maxspin = std::max(akey.S+Sb, maxspin);
            }
        }
    }
    max_spin_ = maxspin + 1;

    // Fix monomer CI coefficients,
    fix_ci_ = false;
}
예제 #2
0
        /**
         * @brief Update filter output with the current timestep's orthogonal
         * coefficients.
         */
        void FilterEnergy1D::v_Update(
            const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields,
            const NekDouble &time)
        {
            // Only output every m_outputFrequency
            if ((m_index++) % m_outputFrequency)
            {
                return;
            }

            int nElmt = pFields[0]->GetExpSize();

            // Loop over all elements
            m_out << "##" << endl;
            m_out << "## Time = " << time << endl;
            m_out << "##" << endl;

            for (int i = 0; i < nElmt; ++i)
            {
                // Figure out number of modes in this expansion.
                LocalRegions::ExpansionSharedPtr exp = pFields[0]->GetExp(i);
                int nModes = exp->GetBasis(0)->GetNumModes();

                // Set uo basis key for orthogonal basis
                LibUtilities::BasisType btype = LibUtilities::eOrtho_A;
                LibUtilities::BasisKey bkeyOrth(
                    btype, nModes, exp->GetBasis(0)->GetPointsKey());

                // Get basis key for existing expansion
                LibUtilities::BasisKey bkey(
                    exp->GetBasis(0)->GetBasisType(),
                    exp->GetBasis(0)->GetNumModes(),
                    exp->GetBasis(0)->GetPointsKey());

                // Find coeffs for this element in the list of all coefficients
                Array<OneD, NekDouble> coeffs =
                    pFields[0]->GetCoeffs() + pFields[0]->GetCoeff_Offset(i);

                // Storage for orthogonal coefficients
                Array<OneD, NekDouble> coeffsOrth(nModes);

                // Project from coeffs -> orthogonal coeffs
                LibUtilities::InterpCoeff1D(bkey, coeffs, bkeyOrth, coeffsOrth);

                // Write coeffs to file
                m_out << "# Element " << i << " (ID "
                      << exp->GetGeom()->GetGlobalID() << ")" << endl;
                for (int j = 0; j < nModes; ++j)
                {
                    m_out << coeffsOrth[j] << endl;
                }
            }
            m_out << endl;
        }
예제 #3
0
 void testToString( void )
 {
     Quaternion a(1,2,3.25,4.125,Quaternion::XYZW());
     std::string akey("<1,2,3.25,4.125>");
     Quaternion b(-4,-.25,-.0625,1.25,Quaternion::XYZW());
     std::string bkey("<-4,-0.25,-0.0625,1.25>");
     TS_ASSERT_EQUALS(a.toString(),akey);
     TS_ASSERT_EQUALS(b.toString(),bkey);
     std::ostringstream oss;
     oss<<a<<b;
     TS_ASSERT_EQUALS(oss.str(),akey+bkey);
 }
예제 #4
0
파일: xdbfind.cpp 프로젝트: harite/xgill
int main(int argc, const char **argv)
{
  plain_text.Enable();
  raw_tags.Enable();

  Vector<const char*> unspecified;
  bool parsed = Config::Parse(argc, argv, &unspecified);
  if (!parsed || unspecified.Size() != 2) {
    Config::PrintUsage(USAGE);
    return 1;
  }

  // we're only doing one access, we don't need the key cache
  Xdb::DisableKeyCache();

  AnalysisPrepare();

  const char *file = unspecified[0];
  const char *key = unspecified[1];

  Xdb *xdb = new Xdb(file, false, false, true);

  if (!xdb->Exists()) {
    delete xdb;
    return 0;
  }

  Buffer bkey((const uint8_t*) key, strlen(key) + 1);
  Buffer cdata;
  Buffer bdata;

  bool success = xdb->Find(&bkey, &cdata);
  if (success) {
    UncompressBufferInUse(&cdata, &bdata);
    size_t len = bdata.pos - bdata.base;

    if (plain_text.IsSpecified()) {
      for (size_t n = 0; n < len; n++)
        logout << (char) bdata.base[n];
      logout << endl;
    }
    else if (raw_tags.IsSpecified()) {
      size_t consumed = 0;
      while (consumed != len) {
        Buffer parse_data(bdata.base + consumed, len - consumed);
        parse_data.pos += len - consumed;

        size_t read_len = PrintPartialBuffer(&parse_data);

        if (read_len == 0)
          break;
        consumed += read_len;
      }
    }
    else {
      Buffer read_buf(bdata.base, len);
      while (read_buf.pos != read_buf.base + len) {
        HashObject *value = ReadSingleValue(&read_buf);
        logout << value << endl;
      }
    }
  }

  delete xdb;

  ClearBlockCaches();
  ClearMemoryCaches();
  AnalysisFinish(0);
}