示例#1
0
void CPlotter::set_data_set(const URI &uri)
{
  cf3_assert ( !uri.empty() );
  cf3_assert ( uri.scheme() == URI::Scheme::CPATH );

  m_data = uri;
}
示例#2
0
void FaceConnectivity::compute_face( const mesh::Faces& faces, const Uint face_idx)
{
  if (m_face.comp != &faces || m_face.idx != face_idx)
  {
    m_face = Entity(faces,face_idx);
    cf3_assert( is_not_null( m_face.comp->connectivity_face2cell() ) );
    const mesh::FaceCellConnectivity& cell_connectivity = *m_face.comp->connectivity_face2cell();
    cf3_assert( m_face.idx < cell_connectivity.size() );

    m_orientation             = MATCHED;
    m_rotation                = 0;
    m_cells[LEFT]             = cell_connectivity.connectivity()[m_face.idx][LEFT];
    m_cells_rotation[LEFT]    = cell_connectivity.cell_rotation()[m_face.idx][LEFT];
    m_cells_orientation[LEFT] = cell_connectivity.cell_orientation()[m_face.idx][LEFT];
    m_cells_face_nb[LEFT]     = cell_connectivity.face_number()[m_face.idx][LEFT];
    
    m_is_bdry_face = cell_connectivity.is_bdry_face()[m_face.idx];
    if (m_is_bdry_face == false)
    {
      m_cells[RIGHT]             = cell_connectivity.connectivity()[m_face.idx][RIGHT];
      m_cells_rotation[RIGHT]    = cell_connectivity.cell_rotation()[m_face.idx][RIGHT];
      m_cells_orientation[RIGHT] = cell_connectivity.cell_orientation()[m_face.idx][RIGHT];
      m_cells_face_nb[RIGHT]     = cell_connectivity.face_number()[m_face.idx][RIGHT];
    } 
  }
}
示例#3
0
bool Entities::is_ghost(const Uint idx) const
{
  cf3_assert_desc(to_str(idx)+">="+to_str(size()),idx < size());
  cf3_assert(size() == m_rank->size());
  cf3_assert(idx<m_rank->size());
  return (*m_rank)[idx] != PE::Comm::instance().rank();
}
示例#4
0
  void compute_properties(const PhysData& data, RealVectorNEQS& properties)
  {
      Real P;
      compute_transformation_velocity(data.coord,m_Vt);
      cf3_assert(data.solution[0]>0);
      properties[0]  = data.solution[0];                //rho
      properties[1]  = data.solution[1]/properties[0];  //u
      properties[2]  = data.solution[2]/properties[0];  //v
      cf3_assert(data.solution[3]>0);
      cf3_assert(properties[0]>0);
      P = (gamma-1.)*(data.solution[3]-0.5*properties[0]*(properties[1]*properties[1]+properties[2]*properties[2])+0.5*properties[0]*(m_Vt[0] * m_Vt[0] + m_Vt[1] * m_Vt[1]));
      properties[3]  = (data.solution[3] + P) / properties[0];            //H

//      std::cout << "P = " << P << std::endl;
//      std::cout << "data.solution[0] = " << data.solution[0] << std::endl;
//      std::cout << "data.solution[1] = " << data.solution[1] << std::endl;
//      std::cout << "data.solution[2] = " << data.solution[2] << std::endl;
//      std::cout << "data.solution[3] = " << data.solution[3] << std::endl;
//      std::cout << "properties[0] = " << properties[0] << std::endl;
//      std::cout << "properties[1] = " << properties[1] << std::endl;
//      std::cout << "properties[2] = " << properties[2] << std::endl;
//      std::cout << "properties[3] = " << properties[3] << std::endl;
//      std::cout << "data.coord = " << data.coord.transpose() << std::endl;
      cf3_assert(P>0);
      cf3_assert(properties[3]>0);

  }
示例#5
0
void Line1D::compute_centroid(const NodesT& nodes , CoordsT& centroid)
{
  cf3_assert(nodes.rows()==2);
  cf3_assert(nodes.cols()==1);
  cf3_assert(centroid.size()==1);
  centroid[0] = 0.5*(nodes(0,XX)+nodes(1,XX));
}
示例#6
0
const SignalFrame & SignalFrame::map ( const std::string & name ) const
{
  cf3_assert ( node.is_valid() );
  cf3_assert ( !name.empty() );

  std::map<std::string, SignalFrame>::const_iterator it_map = m_maps.find(name);
  cf3_assert ( it_map != m_maps.end() );
  return it_map->second;
}
示例#7
0
 /// Copies the contents out of the LSS::Vector to table.
 void get( boost::multi_array<Real, 2>& data)
 {
   cf3_assert(m_is_created);
   cf3_assert(data.shape()[0]==m_blockrow_size);
   cf3_assert(data.shape()[1]==m_neq);
   for (boost::multi_array_types::index i = 0; i < data.shape()[0]; ++i)
     for (boost::multi_array_types::index j = 0; j < data.shape()[1]; ++j)
       data[i][j]=0.;
 }
示例#8
0
 /// U -= U
 Field& operator -=(const Field& U)
 {
   cf3_assert(size() == U.size());
   cf3_assert(row_size() == U.row_size());
   for (Uint i=0; i<size(); ++i)
     for (Uint j=0; j<row_size(); ++j)
       array()[i][j] -= U.array()[i][j];
   return *this;
 }
示例#9
0
 void config_a0()
 {
     std::vector<Real> a0_vec= options().value< std::vector<Real> >("a0");
     cf3_assert(a0_vec.size() == 3);
     cf3_assert(a0_vec[2] == 0);
     a0[0] = a0_vec[0];
     a0[1] = a0_vec[1];
     a0[2] = a0_vec[2];
 }
示例#10
0
 void config_dOmegadt()
 {
     std::vector<Real> dOmegadt_vec= options().value< std::vector<Real> >("dOmegadt");
     cf3_assert(dOmegadt_vec.size() == 3);
     cf3_assert(dOmegadt_vec[0] == 0);
     cf3_assert(dOmegadt_vec[1] == 0);
     dOmegadt[0] = dOmegadt_vec[0];
     dOmegadt[1] = dOmegadt_vec[1];
     dOmegadt[2] = dOmegadt_vec[2];
 }
示例#11
0
void ListeningThread::add_communicator( Communicator comm )
{
  m_mutex.lock();

  cf3_assert( comm != MPI_COMM_NULL );
  cf3_assert( m_comms.find(comm) == m_comms.end() );

  m_comms[comm] = new ListeningInfo();

  m_mutex.unlock();
}
示例#12
0
  inline void cross_product (const T1& v1,
                             const T2& v2,
                             T3& result)
  {
    // sanity checks
    cf3_assert(v1.size() == 3);
    cf3_assert(v2.size() == 3);
    cf3_assert(result.size() == 3);

    result[0] =  v1[1]*v2[2] - v1[2]*v2[1];
    result[1] = -v1[0]*v2[2] + v1[2]*v2[0];
    result[2] =  v1[0]*v2[1] - v1[1]*v2[0];
  }
示例#13
0
  inline void tensor_product(const T1& v1, const T2& v2, T3& m)
  {
    cf3_assert(m.getNbRows()    == v1.size());
    cf3_assert(m.getNbColumns() == v2.size());

    const Uint v1size = v1.size();
    const Uint v2size = v2.size();
    for (Uint i = 0; i < v1size; ++i) {
      for (Uint j = 0; j < v2size; ++j) {
        m(i,j) = v1[i]*v2[j];
      }
    }
  }
示例#14
0
SignalFrame & SignalFrame::map ( const std::string & name )
{
  cf3_assert ( node.is_valid() );
  cf3_assert ( !name.empty() );

  if( m_maps.find(name) == m_maps.end() ) // if the node does not exist yet, we create it
  {
    XmlNode node = main_map.content.add_node( Protocol::Tags::node_value() );
    node.set_attribute( Protocol::Tags::attr_key(), name );
    m_maps[name] = SignalFrame(node); // SignalFrame() adds a map under the node
  }

  return m_maps[name];
}
示例#15
0
  inline Real mixed_product (const T1& v1,
                             const T2& v2,
                             const T3& v3,
                             T4& temp)
  {
    // sanity checks
    cf3_assert(v1.size() == 3);
    cf3_assert(v2.size() == 3);
    cf3_assert(v3.size() == 3);
    cf3_assert(temp.size() == 3);

    cross_product(v1, v2, temp);
    return inner_product(v3, temp);
  }
示例#16
0
  void change_elements()
  {
    connectivity =
        elements().handle<mesh::Elements>()->geometry_space().connectivity().handle< mesh::Connectivity >();
    coordinates =
        elements().geometry_fields().coordinates().handle< mesh::Field >();

    cf3_assert( is_not_null(connectivity) );
    cf3_assert( is_not_null(coordinates) );

    solution   = csolution;
    residual   = cresidual;
    wave_speed = cwave_speed;
  }
示例#17
0
RealVector& VectorialFunction::operator()( const RealVector& var_values)
{
  cf3_assert(m_is_parsed);
  cf3_assert(var_values.size() == m_nbvars);

  // evaluate and store the functions line by line in the result vector
  std::vector<FunctionParser*>::const_iterator parser = m_parsers.begin();
  std::vector<FunctionParser*>::const_iterator end = m_parsers.end();
  Uint i = 0;
  for( ; parser != end ; ++parser, ++i )
    m_result[i] = (*parser)->Eval(&var_values[0]);

  return m_result;
}
示例#18
0
void ListeningThread::remove_comunicator( Communicator comm )
{
  m_mutex.lock();

  cf3_assert( comm!= MPI_COMM_NULL );

  std::map<Communicator, ListeningInfo*>::iterator it = m_comms.find(comm);

  cf3_assert( it != m_comms.end() );

  m_comms.erase(it);

  m_mutex.unlock();
}
示例#19
0
 void compute_jacobian_dispatch(boost::mpl::true_, const typename EtypeT::MappedCoordsT& mapped_coords) const
 {
   EtypeT::compute_jacobian(mapped_coords, m_nodes, m_jacobian_matrix);
   bool is_invertible;
   m_jacobian_matrix.computeInverseAndDetWithCheck(m_jacobian_inverse, m_jacobian_determinant, is_invertible);
   cf3_assert(is_invertible);
 }
示例#20
0
  virtual void compute_analytical_flux(PhysData& data, const RealVectorNDIM& unit_normal,
                                       RealVectorNEQS& flux, Real& wave_speed)
  {
      Real rho, rhou, rhov, rhoE;
      Real u, v, H, P;
      Real um;
      Real a; // speed of sound

      compute_transformation_velocity(data.coord,m_Vt);

      rho   = data.solution[0];
      rhou  = data.solution[1];
      rhov  = data.solution[2];
      rhoE  = data.solution[3];

      cf3_assert(rho>0);
      u     = rhou / rho;
      v     = rhov / rho;
      P     = (gamma - 1) * (rhoE - 0.5 * rho *(u*u + v*v) + 0.5 * rho * ( m_Vt.dot(m_Vt)));
      H     = rhoE / rho + P / rho;

      um    = u * unit_normal[XX] + v * unit_normal[YY];

      a     = std::sqrt(gamma * P / rho);


      flux[0] = rho * um;
      flux[1] = rho * um * u + P * unit_normal[XX];
      flux[2] = rho * um * v + P * unit_normal[YY];
      flux[3] = rho * um * H;

      wave_speed = std::max(std::abs(um + a), std::abs(um - a));
  }
示例#21
0
Notifier::Notifier( const Handle<common::PE::Manager>& manager )
  : m_manager(manager)
{
  cf3_assert( is_not_null(manager) );

  m_observed_queue = m_manager->notification_queue();
}
示例#22
0
  void read_data_block(char *data, const Uint count, const Uint block_idx)
  {
    static const std::string block_prefix("__CFDATA_BEGIN");
    
    XmlNode block_node = get_block_node(block_idx);
      
    const Uint block_begin = from_str<Uint>(block_node.attribute_value("begin"));
    const Uint block_end = from_str<Uint>(block_node.attribute_value("end"));
    const Uint compressed_size = block_end - block_begin - block_prefix.size();

    // Check the prefix
    binary_file.seekg(block_begin);
    std::vector<char> prefix_buf(block_prefix.size());
    binary_file.read(&prefix_buf[0], block_prefix.size());
    const std::string read_prefix(prefix_buf.begin(), prefix_buf.end());
    if(read_prefix != block_prefix)
      throw SetupError(FromHere(), "Bad block prefix for block " + to_str(block_idx));
   
    if(count != 0)
    {
      // Build a decompressing stream
      boost::iostreams::filtering_istream decompressing_stream;
      decompressing_stream.set_auto_close(false);
      decompressing_stream.push(boost::iostreams::zlib_decompressor());
      decompressing_stream.push(boost::iostreams::restrict(binary_file, 0, compressed_size));
      
      // Read the data
      decompressing_stream.read(data, count);
      decompressing_stream.pop();
    }
    
    cf3_assert(binary_file.tellg() == block_end);
  }
示例#23
0
 void to_vector(RealVector& result, const RowT& row)
 {
   const Uint row_size = row.size();
   cf3_assert(result.size() >= row_size);
   for(Uint i =0; i != row_size; ++i)
     result[i] = row[i];
 }
inline void copy(const boost_constrow_t& vector, RealVector& realvector)
{
  cf3_assert(realvector.size() == vector.size());
  for (Uint row=0; row<realvector.rows(); ++row)
  {
    realvector[row] = vector[row];
  }
}
inline void copy(const Eigen::Matrix<Real, ROWS, 1>& realvector, std::vector<Real>& vector)
{
  cf3_assert(vector.size() == realvector.size());
  for (Uint row=0; row<ROWS; ++row)
  {
      vector[row] = realvector[row];
  }
}
inline void copy(const RealVector& realvector, boost_row_t& vector)
{
  cf3_assert(vector.size() == realvector.size());
  for (Uint row=0; row<realvector.rows(); ++row)
  {
    vector[row] = realvector[row];
  }
}
示例#27
0
void TreeBrowser::next_clicked()
{
  cf3_assert(m_current_index < m_history.size() - 1);

  m_current_index++;
  m_tree_view->setRootIndex(m_history.at(m_current_index));
  this->update_buttons();
}
示例#28
0
  inline void
  all_gathervm_impl(const Communicator& comm, const T* in_values, const int in_n, const int *in_map, T* out_values, const int *out_n, const int *out_map, const int stride )
  {
    // get data type and number of processors
    Datatype type = PE::get_mpi_datatype(*in_values);
    int nproc;
    MPI_CHECK_RESULT(MPI_Comm_size,(comm,&nproc));

    // if stride is smaller than one and unsupported functionality
    cf3_assert( stride>0 );

    // compute displacements both on send an receive side
    // also compute stride-multiplied send and receive counts
    int *out_nstride=new int[nproc];
    int *out_disp=new int[nproc];
    out_disp[0]=0;
    for(int i=0; i<nproc-1; i++) {
      out_nstride[i]=stride*out_n[i];
      out_disp[i+1]=out_disp[i]+out_nstride[i];
    }
    out_nstride[nproc-1]=out_n[nproc-1]*stride;

    // compute total number of send and receive items
    const int in_sum=stride*in_n;
    const int out_sum=out_disp[nproc-1]+stride*out_n[nproc-1];

    // set up in_buf
    T *in_buf=(T*)in_values;
    if (in_map!=0) {
      if ( (in_buf=new T[in_sum+1]) == (T*)0 ) throw cf3::common::NotEnoughMemory(FromHere(),"Could not allocate temporary buffer."); // +1 for avoiding possible zero allocation
      if (stride==1) { for(int i=0; i<in_sum; i++) in_buf[i]=in_values[in_map[i]]; }
      else { for(int i=0; i<in_sum/stride; i++) memcpy(&in_buf[stride*i],&in_values[stride*in_map[i]],stride*sizeof(T)); }
    }

    // set up out_buf
    T *out_buf=out_values;
    if ((out_map!=0)||(in_values==out_values)) {
      if ( (out_buf=new T[out_sum+1]) == (T*)0 ) throw cf3::common::NotEnoughMemory(FromHere(),"Could not allocate temporary buffer."); // +1 for avoiding possible zero allocation
    }

    // do the communication
    MPI_CHECK_RESULT(MPI_Allgatherv, (in_buf, in_sum, type, out_buf, out_nstride, out_disp, type, comm));

    // re-populate out_values
    if (out_map!=0) {
      if (stride==1) { for(int i=0; i<out_sum; i++) out_values[out_map[i]]=out_buf[i]; }
      else { for(int i=0; i<out_sum/stride; i++) memcpy(&out_values[stride*out_map[i]],&out_buf[stride*i],stride*sizeof(T)); }
      delete[] out_buf;
    } else if (in_values==out_values) {
      memcpy(out_values,out_buf,out_sum*sizeof(T));
      delete[] out_buf;
    }

    // free internal memory
    if (in_map!=0) delete[] in_buf;
    delete[] out_disp;
    delete[] out_nstride;
  }
示例#29
0
 /// U /= U
 Field& operator /=(const Field& U)
 {
   cf3_assert(size() == U.size());
   if (U.row_size() == 1) // U is a scalar field
   {
     for (Uint i=0; i<size(); ++i)
       for (Uint j=0; j<row_size(); ++j)
         array()[i][j] /= U.array()[i][0];
   }
   else
   {
     cf3_assert(row_size() == U.row_size()); // field must be same size
     for (Uint i=0; i<size(); ++i)
       for (Uint j=0; j<row_size(); ++j)
         array()[i][j] /= U.array()[i][j];
   }
   return *this;
 }
示例#30
0
  XmlNode Protocol::add_signal_frame ( XmlNode& node, const std::string & target,
                                       const URI & sender, const URI & receiver,
                                       bool user_trans )
  {
    cf3_assert(sender.scheme() == URI::Scheme::CPATH);
    cf3_assert(receiver.scheme() == URI::Scheme::CPATH);

    XmlNode signalnode = node.add_node( Tags::node_frame() );

    signalnode.set_attribute( "type", Tags::node_type_signal() );
    signalnode.set_attribute( "target", target );
    signalnode.set_attribute( "sender", sender.string() );
    signalnode.set_attribute( "receiver", receiver.string() );
    signalnode.set_attribute( "transaction", user_trans ? "user" : "auto" );
    signalnode.set_attribute( "frameid", common::UUCount().string() );

    return signalnode;
  }