void Foam::displacementMotionSolver::updateMesh(const mapPolyMesh& mpm) { // pointMesh already updates pointFields motionSolver::updateMesh(mpm); // Map points0_. Bit special since we somehow have to come up with // a sensible points0 position for introduced points. // Find out scaling between points0 and current points // Get the new points either from the map or the mesh const pointgpuField& points = ( mpm.hasMotionPoints() ? mpm.preMotionPoints() : mesh().points() ); // Note: boundBox does reduce const vector span0 = boundBox(points0_).span(); const vector span = boundBox(points).span(); vector scaleFactors(cmptDivide(span0, span)); pointField newPoints0(mpm.pointMap().size()); forAll(newPoints0, pointI) { label oldPointI = mpm.pointMap()[pointI]; if (oldPointI >= 0) { label masterPointI = mpm.reversePointMap()[oldPointI]; if (masterPointI == pointI) { newPoints0[pointI] = points0_[oldPointI]; } else { // New point - assume motion is scaling newPoints0[pointI] = points0_[oldPointI] + cmptMultiply ( scaleFactors, points[pointI] - points[masterPointI] ); } } else { FatalErrorIn ( "displacementMotionSolver::updateMesh" "(const mapPolyMesh&)" ) << "Cannot determine co-ordinates of introduced vertices." << " New vertex " << pointI << " at co-ordinate " << points[pointI] << exit(FatalError); } }
void Foam::componentDisplacementMotionSolver::updateMesh(const mapPolyMesh& mpm) { // pointMesh already updates pointFields. motionSolver::updateMesh(mpm); // Map points0_. Bit special since we somehow have to come up with // a sensible points0 position for introduced points. // Find out scaling between points0 and current points // Get the new points either from the map or the mesh const scalarField points ( mpm.hasMotionPoints() ? mpm.preMotionPoints().component(cmpt_) : mesh().points().component(cmpt_) ); // Get extents of points0 and points and determine scale const scalar scale = (gMax(points0_)-gMin(points0_)) /(gMax(points)-gMin(points)); scalarField newPoints0(mpm.pointMap().size()); forAll(newPoints0, pointI) { label oldPointI = mpm.pointMap()[pointI]; if (oldPointI >= 0) { label masterPointI = mpm.reversePointMap()[oldPointI]; if (masterPointI == pointI) { newPoints0[pointI] = points0_[oldPointI]; } else { // New point. Assume motion is scaling. newPoints0[pointI] = points0_[oldPointI] + scale*(points[pointI]-points[masterPointI]); } } else { FatalErrorIn ( "displacementLaplacianFvMotionSolver::updateMesh" "(const mapPolyMesh& mpm)" ) << "Cannot work out coordinates of introduced vertices." << " New vertex " << pointI << " at coordinate " << points[pointI] << exit(FatalError); } }
void Foam::displacementSBRStressFvMotionSolver::updateMesh ( const mapPolyMesh& mpm ) { fvMotionSolver::updateMesh(mpm); // Map points0_ // Map points0_. Bit special since we somehow have to come up with // a sensible points0 position for introduced points. // Find out scaling between points0 and current points // Get the new points either from the map or the mesh const pointField& points = ( mpm.hasMotionPoints() ? mpm.preMotionPoints() : fvMesh_.points() ); // Note: boundBox does reduce const boundBox bb0(points0_, true); const vector span0(bb0.max()-bb0.min()); const boundBox bb(points, true); const vector span(bb.max()-bb.min()); vector scaleFactors(cmptDivide(span0, span)); pointField newPoints0(mpm.pointMap().size()); forAll(newPoints0, pointI) { label oldPointI = mpm.pointMap()[pointI]; if (oldPointI >= 0) { label masterPointI = mpm.reversePointMap()[oldPointI]; if (masterPointI == pointI) { newPoints0[pointI] = points0_[oldPointI]; } else { // New point. Assume motion is scaling. newPoints0[pointI] = points0_[oldPointI] + cmptMultiply ( scaleFactors, points[pointI]-points[masterPointI] ); } } else { FatalErrorIn ( "displacementSBRStressFvMotionSolver::updateMesh" "(const mapPolyMesh& mpm)" ) << "Cannot work out coordinates of introduced vertices." << " New vertex " << pointI << " at coordinate " << points[pointI] << exit(FatalError); } }