コード例 #1
0
  void OldStyleBCBuilder::build_periodic_bc( const GetPot& input,
                                             const std::string& section,
                                             BoundaryID bc_id,
                                             libMesh::DofMap& dof_map )
  {
    std::string wall_input = section+"/periodic_wall_";
    wall_input += StringUtilities::T_to_string<BoundaryID>(bc_id);

    if( input.have_variable(wall_input) )
      {
        libMesh::boundary_id_type invalid_bid =
          std::numeric_limits<libMesh::boundary_id_type>::max();

        libMesh::boundary_id_type slave_id = invalid_bid;
        libMesh::boundary_id_type master_id = invalid_bid;

        if( input.vector_variable_size(wall_input) != 2 )
          libmesh_error_msg("ERROR: "+wall_input+" must have only 2 components!");

        master_id = bc_id;

        if( input(wall_input,invalid_bid,0) == bc_id )
          slave_id = input(wall_input,invalid_bid,1);
        else
          slave_id = input(wall_input,invalid_bid,0);

        std::string offset_input = section+"/periodic_offset_";
        offset_input += StringUtilities::T_to_string<BoundaryID>(bc_id);

        if( !input.have_variable(offset_input) )
          libmesh_error_msg("ERROR: Could not find "+offset_input+"!");

        unsigned int n_comps = input.vector_variable_size(offset_input);

        libMesh::Real invalid_real = std::numeric_limits<libMesh::Real>::max();

        libMesh::RealVectorValue offset_vector;
        for( unsigned int i = 0; i < n_comps; i++ )
          offset_vector(i) = input(offset_input,invalid_real,i);

        this->add_periodic_bc_to_dofmap( master_id, slave_id,
                                         offset_vector, dof_map );
      }
  }
コード例 #2
0
ファイル: baselinedetect.cpp プロジェクト: ArnoldWu/tess-two
// Returns the perpendicular distance of the point from the straight
// baseline.
double BaselineRow::PerpDistanceFromBaseline(const FCOORD& pt) const {
  FCOORD baseline_vector(baseline_pt2_ - baseline_pt1_);
  FCOORD offset_vector(pt - baseline_pt1_);
  double distance = baseline_vector * offset_vector;
  return sqrt(distance * distance / baseline_vector.sqlength());
}