void Graph::correctToSquare() { auto xMap = canvasMap(QtAPI::Plot::xBottom); auto yMap = canvasMap(QtAPI::Plot::yLeft); double xRatio = xMap.sDist() / xMap.pDist(); if (xRatio == 0) { m_needSquareCorrection = true; return; } double ySDist = xRatio * yMap.pDist(); double y0 = (yMap.s1() + yMap.s2()) / 2; setYAxisScale(y0 - ySDist/2, y0 + ySDist/2,false); std::cerr << y0 - ySDist/2 << ' ' << y0 + ySDist/2 << std::endl; }
Foam::sixDoFRigidBodyMotionSolver::sixDoFRigidBodyMotionSolver ( const polyMesh& mesh, const dictionary& dict ) : displacementMotionSolver(mesh, dict, typeName), motion_ ( coeffDict(), IOobject ( "sixDoFRigidBodyMotionState", mesh.time().timeName(), "uniform", mesh ).typeHeaderOk<IOdictionary>(true) ? IOdictionary ( IOobject ( "sixDoFRigidBodyMotionState", mesh.time().timeName(), "uniform", mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false ) ) : coeffDict() ), patches_(wordReList(coeffDict().lookup("patches"))), patchSet_(mesh.boundaryMesh().patchSet(patches_)), di_(readScalar(coeffDict().lookup("innerDistance"))), do_(readScalar(coeffDict().lookup("outerDistance"))), test_(coeffDict().lookupOrDefault<Switch>("test", false)), rhoInf_(1.0), rhoName_(coeffDict().lookupOrDefault<word>("rho", "rho")), scale_ ( IOobject ( "motionScale", mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), pointMesh::New(mesh), dimensionedScalar(dimless, 0) ), curTimeIndex_(-1) { if (rhoName_ == "rhoInf") { rhoInf_ = readScalar(coeffDict().lookup("rhoInf")); } // Calculate scaling factor everywhere // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { const pointMesh& pMesh = pointMesh::New(mesh); pointPatchDist pDist(pMesh, patchSet_, points0()); // Scaling: 1 up to di then linear down to 0 at do away from patches scale_.primitiveFieldRef() = min ( max ( (do_ - pDist.primitiveField())/(do_ - di_), scalar(0) ), scalar(1) ); // Convert the scale function to a cosine scale_.primitiveFieldRef() = min ( max ( 0.5 - 0.5 *cos(scale_.primitiveField() *Foam::constant::mathematical::pi), scalar(0) ), scalar(1) ); pointConstraints::New(pMesh).constrain(scale_); scale_.write(); } }