示例#1
0
void smp_flush_tlb_range(struct mm_struct *mm, unsigned long start,
			 unsigned long end)
{
	if(mm->context != NO_CONTEXT) {
		if(mm->cpu_vm_mask != (1 << smp_processor_id()))
			xc3((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_range), (unsigned long) mm, start, end);
		local_flush_tlb_range(mm, start, end);
	}
}
示例#2
0
文件: smp.c 项目: maliyu/SOM2416
void smp_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
			 unsigned long end)
{
	struct mm_struct *mm = vma->vm_mm;

	if (mm->context != NO_CONTEXT) {
		cpumask_t cpu_mask = mm->cpu_vm_mask;
		cpu_clear(smp_processor_id(), cpu_mask);
		if (!cpus_empty(cpu_mask))
			xc3((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_range), (unsigned long) vma, start, end);
		local_flush_tlb_range(vma, start, end);
	}
}
示例#3
0
void smp_flush_cache_range(struct vm_area_struct *vma, unsigned long start,
			   unsigned long end)
{
	struct mm_struct *mm = vma->vm_mm;

	if (mm->context != NO_CONTEXT) {
		cpumask_t cpu_mask;
		cpumask_copy(&cpu_mask, mm_cpumask(mm));
		cpumask_clear_cpu(smp_processor_id(), &cpu_mask);
		if (!cpumask_empty(&cpu_mask))
			xc3((smpfunc_t) BTFIXUP_CALL(local_flush_cache_range), (unsigned long) vma, start, end);
		local_flush_cache_range(vma, start, end);
	}
}
示例#4
0
int main(int argc, char* argv[])
{
  Polycurve_conic_traits_2 traits;
    //polycurve constructors
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_mono_polycurve = traits.construct_x_monotone_curve_2_object();
  Polycurve_conic_traits_2::Construct_curve_2  construct_polycurve =
    traits.construct_curve_2_object();

   //create a curve

  Conic_curve_2 c3(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(0), Algebraic(0)),
                   Conic_point_2(Algebraic(3), Algebraic(9)));
  Conic_curve_2 c4(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(3), Algebraic(9)),
                   Conic_point_2(Algebraic(5), Algebraic(25)));
  Conic_curve_2 c5(0,1,0,1,0,0, CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-25), Algebraic(-5)),
                   Conic_point_2(Algebraic(0), Algebraic(0)));

  Conic_curve_2 c6(1,1,0,6,-26,162,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-7), Algebraic(13)),
                   Conic_point_2(Algebraic(-3), Algebraic(9)));
  Conic_curve_2 c7(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-3), Algebraic(9)),
                   Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c8(0,1,0,-1,0,0, CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(0), Algebraic(0)),
                   Conic_point_2(Algebraic(4), Algebraic(-2)));

  Conic_curve_2 c9(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(-5), Algebraic(25)),
                   Conic_point_2(Algebraic(5), Algebraic(25)));
  Conic_curve_2 c10(58, 72, -48, 0, 0, -360);

  //This vector is used to store curves that will be used to create polycurve
  std::vector<Conic_curve_2> conic_curves;
  conic_curves.push_back(c9);

  //construct poly-curve
  Polycurve_conic_traits_2::Curve_2 conic_polycurve =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  Conic_curve_2 c11(0,1,0,-1,0,0,CGAL::COUNTERCLOCKWISE,
                     Conic_point_2(Algebraic(25), Algebraic(-5)),
                     Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c12(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                     Conic_point_2(Algebraic(0), Algebraic(0)),
                     Conic_point_2(Algebraic(5), Algebraic(25)));
  conic_curves.clear();
  conic_curves.push_back(c11);
  conic_curves.push_back(c12);

  //construct poly-curve
  Polycurve_conic_traits_2::Curve_2 conic_polycurve_2 =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  /* VERY IMPORTANT
   * For efficiency reasons, we recommend users not to construct
   * x-monotone conic arc directly, but rather use the Make_x_monotone_2
   * functor supplied by the conic-arc traits class to convert conic curves
   * to x-monotone curves.
   */
  Conic_x_monotone_curve_2 xc3(c3);
  Conic_x_monotone_curve_2 xc4(c4);
  Conic_x_monotone_curve_2 xc5(c5);
  Conic_x_monotone_curve_2 xc6(c6);
  Conic_x_monotone_curve_2 xc7(c7);
  Conic_x_monotone_curve_2 xc8(c8);


  //This vector is used to store curves that will be used to create
  //X-monotone-polycurve
  std::vector<Conic_x_monotone_curve_2> xmono_conic_curves_2;
  xmono_conic_curves_2.push_back(xc5);
  xmono_conic_curves_2.push_back(xc3);
  xmono_conic_curves_2.push_back(xc4);


  //construct x-monotone poly-curve
  Pc_x_monotone_curve_2 conic_x_mono_polycurve_1 =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc6);
  xmono_conic_curves_2.push_back(xc7);
  xmono_conic_curves_2.push_back(xc8);
  //construct x-monotone poly-curve
  Pc_x_monotone_curve_2 conic_x_mono_polycurve_2 =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc5);

  Pc_x_monotone_curve_2 x_polycurve_push =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());
  Polycurve_conic_traits_2::X_monotone_subcurve_2 xcurve_push =
    Polycurve_conic_traits_2::X_monotone_subcurve_2(c5);
  //traits.construct_x_monotone_curve_2_object()(c5);

  xmono_conic_curves_2.clear();
  xmono_conic_curves_2.push_back(xc3);
  xmono_conic_curves_2.push_back(xc4);
  Pc_x_monotone_curve_2 base_curve =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  //curves for push_back
  Conic_curve_2 c13(1,1,0,-50,12,660,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(25), Algebraic(-7)),
                    Conic_point_2(Algebraic(25), Algebraic(-5)));
  Conic_curve_2 c14(0,1,0,-1,0,0,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(25), Algebraic(-5)),
                    Conic_point_2(Algebraic(0), Algebraic(0)));
  Conic_curve_2 c15(-1,0,0,0,1,0,CGAL::COUNTERCLOCKWISE,
                    Conic_point_2(Algebraic(0), Algebraic(0)),
                    Conic_point_2(Algebraic(5), Algebraic(25)));
  conic_curves.clear();
  conic_curves.push_back(c13);
  conic_curves.push_back(c14);
  Polycurve_conic_traits_2::Curve_2 base_curve_push_back =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  conic_curves.push_back(c15);
  Polycurve_conic_traits_2::Curve_2 Expected_push_back_result =
    construct_polycurve(conic_curves.begin(), conic_curves.end());

  // //checking the orientattion consistency
  // Conic_curve_2 c21(0,1,0,1,0,0,CGAL::CLOCKWISE,
  //                  Conic_point_2(Algebraic(9), Algebraic(-3)),
  //                  Conic_point_2(Algebraic(0), Algebraic(0)));
  // Conic_curve_2 c20(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
  //                   Conic_point_2(Algebraic(0), Algebraic(0)),
  //                   Conic_point_2(Algebraic(3), Algebraic(9)));
  //  Conic_x_monotone_curve_2 xc20(c20);
  //  Conic_x_monotone_curve_2 xc21(c21);
  //  xmono_conic_curves_2.clear();
  //  xmono_conic_curves_2.push_back(xc20);
  // xmono_conic_curves_2.push_back(xc21);
  // Pc_x_monotone_curve_2 eric_polycurve =
  //   construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
  //                              xmono_conic_curves_2.end());
  // std::cout << "the polycurve is: " << eric_polycurve << std::endl;

  // std::cout<< std::endl;

  //check_compare_x_2(xc3, xc5);

  // check_equal();
  // std::cout<< std::endl;

   //check_intersect(conic_x_mono_polycurve_1, conic_x_mono_polycurve_2);
   //std::cout<< std::endl;

  // check_compare_end_points_xy_2();
  // std::cout<< std::endl;

  //check_split(conic_x_mono_polycurve_1, conic_x_mono_polycurve_2);
  // std::cout<< std::endl;

  //check_make_x_monotne_curve(conic_polycurve_2);
   //std::cout<< std::endl;

  // check_is_vertical();
  // std::cout<< std::endl;

  //check_compare_y_at_x_2();
  //std::cout<< std::endl;

  //adds the segment to the right.
  //check_push_back(base_curve_push_back, c15);
  //std::cout<< std::endl;

  //adds the segment to the left.
  //check_push_front(base_curve, xcurve_push);
  //std::cout<< std::endl;

  // check_are_mergable();
  // std::cout<< std::endl;

  // check_merge_2();
  // std::cout<< std::endl;

  // check_construct_opposite();
  // std::cout<< std::endl;

  // check_compare_y_at_x_right();
  // std::cout<< std::endl;

  // check_compare_y_at_x_left();
  // std::cout<< std::endl;
  //check_compare_points(conic_x_mono_polycurve_1);

  //number of segments
  //std::cout << "Number of segments: "
  //          << traits.number_of_points_2_object()(base_curve_push_back)
  //          << std::endl;

  check_trim(conic_x_mono_polycurve_1, atoi(argv[1]), atoi(argv[2]),
             atoi(argv[3]), atoi(argv[4]));
  std::cout << std::endl;

  //std::cout << (atoi(argv[1]) + atoi(argv[2])) << std::endl;
  // Conic_traits_2 con_traits;
  // Conic_curve_2 cc3(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
  //                   Conic_point_2(Algebraic(0), Algebraic(0)),
  //                   Conic_point_2(Algebraic(3), Algebraic(9)));
  // Conic_x_monotone_curve_2 xcc3(cc3);
  // Conic_point_2       ps2(0, 0);
  // Conic_point_2       pt2(3, 9);
  // std::cout << "conic curve is : " << xcc3 << std::endl;
  // Conic_x_monotone_curve_2 trimmed_curve =
  //   con_traits.trim_2_object()(xc3, ps2, pt2);
  // std::cout << "trimmed conic curve is : " << trimmed_curve << std::endl;

  return 0;
}
示例#5
0
bool check_compare_y_at_x_2()
{
  Polycurve_conic_traits_2 traits;
  Polycurve_conic_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 =
    traits.compare_y_at_x_2_object();
  //polycurve constructors
  Polycurve_conic_traits_2::Construct_x_monotone_curve_2
    construct_x_mono_polycurve = traits.construct_x_monotone_curve_2_object();
  Polycurve_conic_traits_2::Construct_curve_2  construct_polycurve =
    traits.construct_curve_2_object();

   //create a curve
  Rat_point_2 ps1(1, 10);
  Rat_point_2 pmid1(5, 4);
  Rat_point_2 pt1(10, 1);
  Conic_curve_2 c1(ps1, pmid1, pt1);

   //create a curve
  Rat_point_2 ps2(10, 1);
  Rat_point_2 pmid2(15, 5);
  Rat_point_2 pt2(20, 10);
  Conic_curve_2 c2(ps2, pmid2, pt2);

  Conic_curve_2 c3(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(0), Algebraic(0)),
                   Conic_point_2(Algebraic(3), Algebraic(9)));
  Conic_curve_2 c4(1,0,0,0,-1,0,CGAL::COUNTERCLOCKWISE,
                   Conic_point_2(Algebraic(3), Algebraic(9)),
                   Conic_point_2(Algebraic(5), Algebraic(25)));

  std::vector<Conic_curve_2> conic_curves, conic_curves_2, Conic_curves_3;
  conic_curves.push_back(c1);
  conic_curves.push_back(c2);

  //conic_curves_2.push_back(c3);
  //conic_curves_2.push_back(c4);

  Conic_x_monotone_curve_2 xc1(c1);
  Conic_x_monotone_curve_2 xc2(c2);
  Conic_x_monotone_curve_2 xc3(c3);
  Conic_x_monotone_curve_2 xc4(c4);

  std::vector<Conic_x_monotone_curve_2> xmono_conic_curves, xmono_conic_curves_2;
  /* VERY IMPORTANT
   * For efficiency reasons, we recommend users not to construct x-monotone
   * conic arc directly, but rather use the Make_x_monotone_2 functor supplied
   * by the conic-arc traits class to convert conic curves to x-monotone curves.
   */
  xmono_conic_curves.push_back(xc1);
  xmono_conic_curves.push_back(xc2);
  xmono_conic_curves_2.push_back(xc3);
  xmono_conic_curves_2.push_back(xc4);

  //construct x-monotone poly-curve
  Polycurve_conic_traits_2::X_monotone_curve_2 conic_x_mono_polycurve =
    construct_x_mono_polycurve(xmono_conic_curves.begin(),
                               xmono_conic_curves.end());
  Polycurve_conic_traits_2::X_monotone_curve_2 conic_x_mono_polycurve_2 =
    construct_x_mono_polycurve(xmono_conic_curves_2.begin(),
                               xmono_conic_curves_2.end());

  //construct poly-curve
  Polycurve_conic_traits_2::Curve_2 conic_polycurve =
    construct_polycurve(conic_curves.begin(), conic_curves.end());
  //Polycurve_conic_traits_2::Curve_2 conic_polycurve_2 =
  //  construct_polycurve(conic_curves_2.begin(), conic_curves_2.end());

  //make x-monotone curve
  //Polycurve_conic_traits_2::X_monotone_curve_2 polyline_xmc1 =
  //  construct_x_monotone_curve_2(c1);

  //create points
  Polycurve_conic_traits_2::Point_2
    point_above_line = Polycurve_conic_traits_2::Point_2(2,10),
    point_below_line = Polycurve_conic_traits_2::Point_2(4,7),
    point_on_line = Polycurve_conic_traits_2::Point_2(2,4);

  CGAL::Comparison_result result;

  result =  cmp_y_at_x_2(point_above_line, conic_x_mono_polycurve_2);
  std::cout << "Compare_y_at_x_2:: for point above the curve computed Answer is:  "
            << (result == CGAL::SMALLER ? "Below":
               (result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;

  result =  cmp_y_at_x_2(point_below_line, conic_x_mono_polycurve_2);
  std::cout << "Compare_y_at_x_2:: for point below the curve computed Answer is:  "
            << (result == CGAL::SMALLER ? "Below":
               (result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;

  result =  cmp_y_at_x_2(point_on_line, conic_x_mono_polycurve_2);
  std::cout << "Compare_y_at_x_2:: for point on the curve computed Answer is:  "
            << (result == CGAL::SMALLER ? "Below":
               (result == CGAL::LARGER ? "Above" : "On-line")) << std::endl;

  return true;
}
示例#6
0
//---------------------------------------------------------
void EulerShock2D::precalc_limiter_data()
//---------------------------------------------------------
{

  //---------------------------------------------
  // pre-calculate element geometry and constant 
  // factors for use in this->EulerLimiter2D()
  //---------------------------------------------

  Lim_AVE = 0.5 * MassMatrix.col_sums();
  DMat dropAVE = eye(Np) - outer(ones(Np),Lim_AVE);
  Lim_dx = dropAVE*x; 
  Lim_dy = dropAVE*y;

  // Extract coordinates of vertices of elements
  IVec v1=EToV(All,1);  Lim_xv1=VX(v1); Lim_yv1=VY(v1);
  IVec v2=EToV(All,2);  Lim_xv2=VX(v2); Lim_yv2=VY(v2);
  IVec v3=EToV(All,3);  Lim_xv3=VX(v3); Lim_yv3=VY(v3);  

  const DVec &xv1=Lim_xv1,&xv2=Lim_xv2,&xv3=Lim_xv3;
  const DVec &yv1=Lim_yv1,&yv2=Lim_yv2,&yv3=Lim_yv3;
  DMat &fnx=Lim_fnx, &fny=Lim_fny, &fL=Lim_fL;

  // Compute face unit normals and lengths
  fnx.resize(3,K); fny.resize(3,K);

  // fnx = (3,K) = [yv2-yv1; yv3-yv2; yv1-yv3];
  fnx.set_row(1, yv2-yv1); fnx.set_row(2, yv3-yv2); fnx.set_row(3, yv1-yv3);

  // fny = (3,K) =  -[xv2-xv1;xv3-xv2;xv1-xv3];
//fny.set_row(1, xv2-xv1); fny.set_row(2, xv3-xv2); fny.set_row(3, xv1-xv3);
  fny.set_row(1, xv1-xv2); fny.set_row(2, xv2-xv3); fny.set_row(3, xv3-xv1);

  fL = sqrt(sqr(fnx)+sqr(fny)); fnx.div_element(fL); fny.div_element(fL);

  //-------------------------------------------------------
  // Compute coords of element centers and face weights
  //-------------------------------------------------------

  // Find neighbors in patch
  Lim_E1=EToE(All,1); Lim_E2=EToE(All,2); Lim_E3=EToE(All,3);

  // Compute coordinates of element centers
  xc0=Lim_AVE*x; xc1=xc0(Lim_E1); xc2=xc0(Lim_E2); xc3=xc0(Lim_E3);
  yc0=Lim_AVE*y; yc1=yc0(Lim_E1); yc2=yc0(Lim_E2); yc3=yc0(Lim_E3);

  // Compute weights for face gradients 
  A0=Lim_AVE*J*TWOTHIRD;
  A1=A0+A0(Lim_E1); A2=A0+A0(Lim_E2); A3=A0+A0(Lim_E3);
  A1_A2_A3 = A1+A2+A3;

  // Find boundary faces for each face 
  Lim_id1=find(BCType.get_col(1),'!',0);
  Lim_id2=find(BCType.get_col(2),'!',0);
  Lim_id3=find(BCType.get_col(3),'!',0);

  // Compute location of centers of reflected ghost elements at boundary faces
  if (1) {
    DMat FL1=fL(1,Lim_id1), Fnx1=fnx(1,Lim_id1), Fny1=fny(1,Lim_id1);
    DVec fL1=FL1, fnx1=Fnx1, fny1=Fny1;
    DVec H1   = 2.0*(dd(A0(Lim_id1),fL1));
    xc1(Lim_id1) += 2.0*fnx1.dm(H1);
    yc1(Lim_id1) += 2.0*fny1.dm(H1);

    DMat FL2=fL(2,Lim_id2), Fnx2=fnx(2,Lim_id2), Fny2=fny(2,Lim_id2);
    DVec fL2=FL2, fnx2=Fnx2, fny2=Fny2;
    DVec H2   = 2.0*(dd(A0(Lim_id2),fL2));
    xc2(Lim_id2) += 2.0*fnx2.dm(H2);
    yc2(Lim_id2) += 2.0*fny2.dm(H2);

    DMat FL3=fL(3,Lim_id3), Fnx3=fnx(3,Lim_id3), Fny3=fny(3,Lim_id3);
    DVec fL3=FL3, fnx3=Fnx3, fny3=Fny3;
    DVec H3   = 2.0*(dd(A0(Lim_id3),fL3));
    xc3(Lim_id3) += 2.0*fnx3.dm(H3);
    yc3(Lim_id3) += 2.0*fny3.dm(H3);
  }

  // Find boundary faces
  IVec bct = trans(BCType);
  Lim_idI = find(bct, '=', (int)BC_In);
  Lim_idO = find(bct, '=', (int)BC_Out);
  Lim_idW = find(bct, '=', (int)BC_Wall);
  Lim_idC = find(bct, '=', (int)BC_Cyl);

  Lim_ctx.resize(3,K); Lim_cty.resize(3,K);
  Lim_ctx.set_row(1,xc1); Lim_ctx.set_row(2,xc2); Lim_ctx.set_row(3,xc3);
  Lim_cty.set_row(1,yc1); Lim_cty.set_row(2,yc2); Lim_cty.set_row(3,yc3);

  // load the set of ids
  Lim_ids.resize(6);
  Lim_ids(1)=1;      Lim_ids(2)=Nfp;    Lim_ids(3)=Nfp+1;
  Lim_ids(4)=2*Nfp;  Lim_ids(5)=3*Nfp;  Lim_ids(6)=2*Nfp+1;

  limQ = Q;
}