void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) { if(mm->cpu_vm_mask == (1 << smp_processor_id())) local_flush_sig_insns(mm, insn_addr); else xc2((smpfunc_t) BTFIXUP_CALL(local_flush_sig_insns), (unsigned long) mm, insn_addr); }
void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) { cpumask_t cpu_mask = mm->cpu_vm_mask; cpu_clear(smp_processor_id(), cpu_mask); if (!cpus_empty(cpu_mask)) xc2((smpfunc_t) BTFIXUP_CALL(local_flush_sig_insns), (unsigned long) mm, insn_addr); local_flush_sig_insns(mm, insn_addr); }
void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) { cpumask_t cpu_mask; cpumask_copy(&cpu_mask, mm_cpumask(mm)); cpumask_clear_cpu(smp_processor_id(), &cpu_mask); if (!cpumask_empty(&cpu_mask)) xc2((smpfunc_t) BTFIXUP_CALL(local_flush_sig_insns), (unsigned long) mm, insn_addr); local_flush_sig_insns(mm, insn_addr); }
void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) { struct mm_struct *mm = vma->vm_mm; if(mm->context != NO_CONTEXT) { if(mm->cpu_vm_mask != (1 << smp_processor_id())) xc2((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_page), (unsigned long) vma, page); local_flush_tlb_page(vma, page); } }
void smp_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) { 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)) xc2((smpfunc_t) BTFIXUP_CALL(local_flush_tlb_page), (unsigned long) vma, page); local_flush_tlb_page(vma, page); } }
void smp_flush_cache_page(struct vm_area_struct *vma, unsigned long page) { 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)) xc2((smpfunc_t) BTFIXUP_CALL(local_flush_cache_page), (unsigned long) vma, page); local_flush_cache_page(vma, page); } }
int Generate_Model_ANCFCable2D_contact(MBS* mbs) { ElementDataContainer* edc = mbs->GetModelDataContainer(); int nel = edc->TreeGetInt("Geometry.n_fibers"); double sx = edc->TreeGetDouble("Geometry.length"); double sy = edc->TreeGetDouble("Geometry.width"); int nx = edc->TreeGetInt("Geometry.nx"); int ny = edc->TreeGetInt("Geometry.ny"); double rho = edc->TreeGetDouble("Geometry.rho"); double Em = edc->TreeGetDouble("Geometry.Em"); double nu = edc->TreeGetDouble("Geometry.nu"); double box_x = edc->TreeGetDouble("Geometry.box_x"); double box_y = edc->TreeGetDouble("Geometry.box_y"); int nbox_x = edc->TreeGetInt("Geometry.nres_x"); int nbox_y = edc->TreeGetInt("Geometry.nres_y"); Vector3D size(sx,sy,1.0); double cdim = sy/2; double wi = 1; //width of GeomLine2D elements (in pts/pixel) //===============================2D fibers========================================= ANCFCable2D cable(mbs); Vector xc1(4); Vector xc2(4); double phi = -MY_PI/4.; xc1(1)=0.5*sx*cos(phi+MY_PI); xc1(2)=0.5*sx*sin(phi+MY_PI); xc1(3)=cos(phi); xc1(4)=sin(phi); xc2(1)=xc1(1)+sx*cos(phi); xc2(2)=xc1(2)+sx*sin(phi); xc2(3)=cos(phi); xc2(4)=sin(phi); //Material m1(mbs,rho,Em,nu); //int mat1 = mbs->AddMaterial(&m1); cable.SetANCFCable2D(xc1, xc2, rho, Em, size, Vector3D(0.,0.7,0.)); //cable.SetANCFCable2D(xc1, xc2, vcenter, vcenter, n1, n2, rho, Em, size, Vector3D(0.,0.7,0.)); int nr = mbs->AddElement(&cable); MBSLoad grav; grav.SetBodyLoad(-9.81*rho,2); mbs->GetElement(nr).AddLoad(grav); //MBSSensor force_x(mbs,TMBSSensor(TSElement+TSDOF),idx1,1); //measure force via Lagrange multiplier //force_x.SetSensorName(mystr("Node_")+mystr(i)+mystr("_force_x")); //mbs->AddSensor(&force_x); TArray<Vector2D> points; double dx = sx/nx; double dy = sy/ny; for(int i=0; i<nx; ++i) points.Add(Vector2D(-0.5*sx+i*dx,-0.5*sy)); for(int i=0; i<ny; ++i) points.Add(Vector2D(0.5*sx,-0.5*sy+i*dy)); for(int i=0; i<nx; ++i) points.Add(Vector2D(0.5*sx-i*dx,0.5*sy)); for(int i=0; i<=ny; ++i) points.Add(Vector2D(-0.5*sx,0.5*sy-i*dy)); //mbs->GetElement(nr).SetAltShape(1); ////sensors for nodal positions and velocities //MBSSensor s1(mbs,TMBSSensor(TSElement+TSplanar+TSPos+TSX),nr,Vector3D(-0.5*size.X(),0.,0.)); //s1.SetSensorName(mystr("Node_")+mystr(i)+mystr("_x")); //mbs->AddSensor(&s1); //sensors //field variables not available? //{ // FieldVariableElementSensor s1(mbs); // s1.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_position,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_x),Vector2D(0.)); // s1.SetSensorName(mystr("cable")+mystr("_x")); // mbs->AddSensor(&s1); // FieldVariableElementSensor s2(mbs); // s2.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_position,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_y),Vector2D(0.)); // s2.SetSensorName(mystr("cable")+mystr("_y")); // mbs->AddSensor(&s2); // FieldVariableElementSensor s3(mbs); // s3.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_velocity,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_x),Vector2D(0.)); // s3.SetSensorName(mystr("cable")+mystr("_vx")); // mbs->AddSensor(&s3); // FieldVariableElementSensor s4(mbs); // s4.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_velocity,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_y),Vector2D(0.)); // s4.SetSensorName(mystr("cable")+mystr("_vy")); // mbs->AddSensor(&s4); //} //contact Vector3D contactcol(0.5,0,0.5); int slaveNODEmode = 0; //if NODEmode = 1, then use locnodenumbers, if NODEmode==0 then use loccoords double bordersize = 0.25*sy; //additional search radius for master and slave segments/nodes GeneralContact2D gc(mbs, slaveNODEmode, bordersize, Vector3D(0.0005,0,0), contactcol); gc.SetContactMode(0); //0 for Hertzian contact with restitution coefficient gc.SetIsLagrange(0); double friccoeff = 0.2; gc.SetFriction(1, edc->TreeGetDouble("Geometry.friction_coeff")); gc.SetContactParams(edc->TreeGetDouble("Geometry.restitution_coeff"),1); //coefficient of restitution, Hertzian contact parameter gc.SetContactMaxDist(0.5*sy); //max penetration; if exceeded, it is treated as if there where no contact gc.SetSearchTreeDim(20,20); double cstiff = edc->TreeGetDouble("Geometry.contact_stiffness"); int bodyind = 1; for(int i=1; i<points.Length(); ++i) { gc.AddSlaveNode(nr, points(i), cstiff, bodyind); } if(edc->TreeGetInt("Geometry.mutual_contact")) { for(int i=1; i<points.Length(); ++i) { gc.AddMasterSegment(nr,points(i),points(i+1),bodyind); //be careful with orientation of master segments } } //===============================rigid body==================================== { Vector x0i(6); x0i(1)=0.; x0i(2)=0.25*box_y; x0i(3)=0.; x0i(4)=0.; x0i(5)=0.; x0i(6)=0.; double r0=0.3*sx; Vector3D sizei(r0,r0,1.); Vector3D coli(1.,0.,0.); Rigid2D testbody(mbs,x0i,rho,sizei,coli); int nr = mbs->AddElement(&testbody); //MBSLoad load; //load.SetForceVector2D(Vector2D(1e-4,2e-4),Vector2D(0.)); mbs->GetElement(nr).AddLoad(grav); TArray<Vector2D> points; int ni = 32; for(int j=0; j<=ni; ++j) points.Add(Vector2D( r0*cos(2*MY_PI/ni*j), r0*sin(2*MY_PI/ni*j) )); //for better visualization of rotation GeomLine2D c1(mbs,nr,Vector2D(0.,-0.5*r0),Vector2D(0.,0.5*r0),Vector3D(1.,0.,0.)); GeomLine2D c2(mbs,nr,Vector2D(-0.5*r0,0.),Vector2D(0.5*r0,0.),Vector3D(1.,0.,0.)); c1.SetDrawParam(Vector3D(2*wi, 10., 0.)); c2.SetDrawParam(Vector3D(2*wi, 10., 0.)); mbs->GetElement(nr).Add(c1); mbs->GetElement(nr).Add(c2); mbs->GetElement(nr).SetAltShape(1); //sensors //{ // FieldVariableElementSensor s1(mbs); // s1.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_position,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_x),Vector2D(0.)); // s1.SetSensorName(mystr("rigid")+mystr("_x")); // mbs->AddSensor(&s1); // FieldVariableElementSensor s2(mbs); // s2.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_position,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_y),Vector2D(0.)); // s2.SetSensorName(mystr("rigid")+mystr("_y")); // mbs->AddSensor(&s2); // FieldVariableElementSensor s3(mbs); // s3.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_velocity,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_x),Vector2D(0.)); // s3.SetSensorName(mystr("rigid")+mystr("_vx")); // mbs->AddSensor(&s3); // FieldVariableElementSensor s4(mbs); // s4.SetFVESPos2D(nr,FieldVariableDescriptor(FieldVariableDescriptor::FieldVariableType::FVT_velocity,FieldVariableDescriptor::FieldVariableComponentIndex::FVCI_y),Vector2D(0.)); // s4.SetSensorName(mystr("rigid")+mystr("_vy")); // mbs->AddSensor(&s4); //} ////lock rotation //if(edc->TreeGetInt("Geometry.lock_rigid_body_rotation")) //{ // CoordConstraint cc1(mbs, nr, 3, cdim); // mbs->AddElement(&cc1); //} //contact bodyind = 2; for(int i=1; i<=points.Length(); ++i) { gc.AddSlaveNode(nr, points(i), cstiff, bodyind); } if(edc->TreeGetInt("Geometry.mutual_contact")) { for(int i=1; i<points.Length(); ++i) { gc.AddMasterSegment(nr,points(i),points(i+1),bodyind); //be careful with orientation of master segments GeomLine2D c1(mbs,nr,points(i),points(i+1),Vector3D(1.,0.,0.)); c1.SetDrawParam(Vector3D(2*wi, 10., 0.)); mbs->GetElement(nr).Add(c1); } } } //===============================frame========================================= points.Flush(); dx = box_x/nbox_x; dy = box_y/nbox_y; for(int i=0; i<nbox_x; ++i) points.Add(Vector2D(-0.5*box_x+i*dx,-0.5*box_y)); for(int i=0; i<nbox_y; ++i) points.Add(Vector2D(0.5*box_x,-0.5*box_y+i*dy)); for(int i=0; i<nbox_x; ++i) points.Add(Vector2D(0.5*box_x-i*dx,0.5*box_y)); for(int i=0; i<=nbox_y; ++i) points.Add(Vector2D(-0.5*box_x,0.5*box_y-i*dy)); //contact bodyind = 0; //must be 0 for mbs for(int i=1; i<points.Length(); ++i) { gc.AddMasterSegment(0,points(i+1),points(i), bodyind); //be careful with orientation of master segments GeomLine2D c1(mbs,0,points(i+1),points(i),Vector3D(0.,0.,0.)); c1.SetDrawParam(Vector3D(2*wi, 10., 0.)); mbs->Add(c1); } //finish contact gc.FinishContactDefinition(); mbs->AddElement(&gc); mbs->Assemble(); return 1; };
/** * Main function. * * Usage: VtkToFld session.xml input.vtk output.fld [options] */ int main(int argc, char* argv[]) { // Set up available options po::options_description desc("Available options"); desc.add_options() ("help,h", "Produce this help message.") ("name,n", po::value<string>()->default_value("Intensity"), "Name of field in VTK file to use for intensity.") ("outname,m", po::value<string>()->default_value("intensity"), "Name of field in output FLD file.") ("precision,p", po::value<double>()->default_value(1), "Precision of vertex matching."); po::options_description hidden("Hidden options"); hidden.add_options() ("file", po::value<vector<string> >(), "Input filename"); po::options_description cmdline_options; cmdline_options.add(desc).add(hidden); po::positional_options_description p; p.add("file", -1); po::variables_map vm; // Parse command-line options try { po::store(po::command_line_parser(argc, argv). options(cmdline_options).positional(p).run(), vm); po::notify(vm); } catch (const std::exception& e) { cerr << e.what() << endl; cerr << desc; return 1; } if ( vm.count("help") || vm.count("file") == 0 || vm["file"].as<vector<string> >().size() != 3) { cerr << "Usage: VtkToFld session.xml intensity.vtk output.fld [options]" << endl; cerr << desc; return 1; } // Extract command-line argument values std::vector<std::string> vFiles = vm["file"].as<vector<string> >(); const string infile = vFiles[1]; const string outfile = vFiles[2]; const double factor = vm["precision"].as<double>(); const string name = vm["name"].as<string>(); const string outname = vm["outname"].as<string>(); std::vector<std::string> vFilenames; LibUtilities::SessionReaderSharedPtr vSession; SpatialDomains::MeshGraphSharedPtr graph2D; MultiRegions::ExpList2DSharedPtr Exp; vFilenames.push_back(vFiles[0]); vSession = LibUtilities::SessionReader::CreateInstance(2, argv, vFilenames); try { //---------------------------------------------- // Read in mesh from input file graph2D = MemoryManager<SpatialDomains::MeshGraph2D>:: AllocateSharedPtr(vSession); //---------------------------------------------- //---------------------------------------------- // Define Expansion Exp = MemoryManager<MultiRegions::ExpList2D>:: AllocateSharedPtr(vSession,graph2D); //---------------------------------------------- //---------------------------------------------- // Set up coordinates of mesh int coordim = Exp->GetCoordim(0); int nq = Exp->GetNpoints(); Array<OneD, NekDouble> xc0(nq,0.0); Array<OneD, NekDouble> xc1(nq,0.0); Array<OneD, NekDouble> xc2(nq,0.0); switch(coordim) { case 2: Exp->GetCoords(xc0,xc1); break; case 3: Exp->GetCoords(xc0,xc1,xc2); break; default: ASSERTL0(false,"Coordim not valid"); break; } //---------------------------------------------- vtkPolyDataReader *vtkMeshReader = vtkPolyDataReader::New(); vtkMeshReader->SetFileName(infile.c_str()); vtkMeshReader->Update(); vtkPolyData *vtkMesh = vtkMeshReader->GetOutput(); vtkCellDataToPointData* c2p = vtkCellDataToPointData::New(); #if VTK_MAJOR_VERSION <= 5 c2p->SetInput(vtkMesh); #else c2p->SetInputData(vtkMesh); #endif c2p->PassCellDataOn(); c2p->Update(); vtkPolyData *vtkDataAtPoints = c2p->GetPolyDataOutput(); vtkPoints *vtkPoints = vtkMesh->GetPoints(); ASSERTL0(vtkPoints, "ERROR: cannot get points from mesh."); vtkCellArray *vtkPolys = vtkMesh->GetPolys(); ASSERTL0(vtkPolys, "ERROR: cannot get polygons from mesh."); vtkPointData *vtkPData = vtkDataAtPoints->GetPointData(); ASSERTL0(vtkPolys, "ERROR: cannot get point data from file."); VertexSet points; VertexSet::iterator vIter; double p[3]; double val; double x, y, z; int coeff_idx; int i,j,n; if (!vtkDataAtPoints->GetPointData()->HasArray(name.c_str())) { n = vtkDataAtPoints->GetPointData()->GetNumberOfArrays(); cerr << "Input file '" << infile << "' does not have a field named '" << name << "'" << endl; cerr << "There are " << n << " arrays in this file." << endl; for (int i = 0; i < n; ++i) { cerr << " " << vtkDataAtPoints->GetPointData()->GetArray(i)->GetName() << endl; } return 1; } // Build up an unordered set of vertices from the VTK file. For each // vertex a hashed value of the coordinates is generated to within a // given tolerance. n = vtkPoints->GetNumberOfPoints(); for (i = 0; i < n; ++i) { vtkPoints->GetPoint(i,p); val = vtkPData->GetScalars(name.c_str())->GetTuple1(i); boost::shared_ptr<Vertex> v(new Vertex(p[0],p[1],p[2],val,factor)); points.insert(v); } // Now process each vertex of each element in the mesh SpatialDomains::PointGeomSharedPtr vert; for (i = 0; i < Exp->GetNumElmts(); ++i) { StdRegions::StdExpansionSharedPtr e = Exp->GetExp(i); for (j = 0; j < e->GetNverts(); ++j) { // Get the index of the coefficient corresponding to this vertex coeff_idx = Exp->GetCoeff_Offset(i) + e->GetVertexMap(j); // Get the coordinates of the vertex vert = e->as<LocalRegions::Expansion2D>()->GetGeom2D() ->GetVertex(j); vert->GetCoords(x,y,z); // Look up the vertex in the VertexSet boost::shared_ptr<Vertex> v(new Vertex(x,y,z,0.0,factor)); vIter = points.find(v); // If not found, maybe the tolerance should be reduced? // If found, record the scalar value from the VTK file in the // corresponding coefficient. if (vIter == points.end()) { cerr << "Vertex " << i << " not found. Looking for (" << x << ", " << y << ", " << z << ")" << endl; } else { Exp->UpdateCoeffs()[coeff_idx] = (*vIter)->scalar; } } } Exp->SetPhysState(false); //----------------------------------------------- // Write solution to file std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef = Exp->GetFieldDefinitions(); std::vector<std::vector<NekDouble> > FieldData(FieldDef.size()); for(i = 0; i < FieldDef.size(); ++i) { FieldDef[i]->m_fields.push_back(outname); Exp->AppendFieldData(FieldDef[i], FieldData[i]); } LibUtilities::FieldIO vFld(vSession->GetComm()); vFld.Write(outfile, FieldDef, FieldData); //----------------------------------------------- } catch (...) { cout << "An error occurred." << endl; } }
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; }
//--------------------------------------------------------- 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; }