diff --git a/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C b/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C index adb5b10865..2e9b4c63c7 100644 --- a/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/componentDisplacement/componentDisplacementMotionSolver.C @@ -201,7 +201,7 @@ void Foam::componentDisplacementMotionSolver::topoChange void Foam::componentDisplacementMotionSolver::mapMesh(const polyMeshMap& map) { - points0_ == mesh().points().component(cmpt_); + points0_ = mesh().points().component(cmpt_); pointDisplacement_ == Zero; } diff --git a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C index 0e2d412102..0fc5767a7a 100644 --- a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.C @@ -160,7 +160,7 @@ void Foam::points0MotionSolver::topoChange(const polyTopoChangeMap& map) void Foam::points0MotionSolver::mapMesh(const polyMeshMap& map) { - points0_ == mesh().points(); + points0_.primitiveFieldRef() = mesh().points(); } diff --git a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.H index d40c0b56b4..dd57b45423 100644 --- a/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/points0/points0MotionSolver.H @@ -110,6 +110,7 @@ public: virtual void topoChange(const polyTopoChangeMap&); //- Update from another mesh using the given map + // Resets points0 to the points of the new mesh virtual void mapMesh(const polyMeshMap&); //- Update corresponding to the given distribution map diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.C index 56a0e889ed..08510cb1a9 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.C @@ -43,6 +43,46 @@ namespace Foam } +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::interpolatingSolidBodyMotionSolver::calcScale() +{ + 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(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::interpolatingSolidBodyMotionSolver::interpolatingSolidBodyMotionSolver @@ -67,50 +107,14 @@ Foam::interpolatingSolidBodyMotionSolver::interpolatingSolidBodyMotionSolver mesh.time().timeName(), mesh, IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::NO_WRITE ), pointMesh::New(mesh), dimensionedScalar(dimless, 0) ) { // 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(); - } + calcScale(); } @@ -131,6 +135,7 @@ Foam::interpolatingSolidBodyMotionSolver::curPoints() const tmp tpoints(new pointField(points0)); pointField& points = tpoints.ref(); + Info << points.size() << " " << scale_.size() << endl; forAll(points, pointi) { // Move non-stationary points @@ -157,4 +162,25 @@ Foam::interpolatingSolidBodyMotionSolver::curPoints() const } +void Foam::interpolatingSolidBodyMotionSolver::topoChange +( + const polyTopoChangeMap& map +) +{ + // Pending implementation of the inverse transformation of points0 + NotImplemented; +} + + +void Foam::interpolatingSolidBodyMotionSolver::mapMesh(const polyMeshMap& map) +{ + InfoInFunction << endl; + points0MotionSolver::mapMesh(map); + + // scale is resized by the meshToMesh mapper + scale_ = Zero; + calcScale(); +} + + // ************************************************************************* // diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.H index 30cdfa1fd0..5c4ff514a0 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.H @@ -75,6 +75,8 @@ class interpolatingSolidBodyMotionSolver //- Current interpolation scale (1 at patches, 0 at distance_) pointScalarField scale_; + void calcScale(); + public: @@ -112,6 +114,12 @@ public: virtual void solve() {} + //- Update local data for topology changes + virtual void topoChange(const polyTopoChangeMap&); + + //- Update from another mesh using the given map + virtual void mapMesh(const polyMeshMap&); + // Member Operators