From d96ad1cd09caf96aba2ab9fa0fd40f347492233f Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 16 Aug 2019 11:27:59 -0700 Subject: [PATCH] ENH: Add components to allow overset with multiple motion solvers 1) Add softWall rigidBody restrain 2) Add linearSpringDamper sixDoF restrain to work as soft rope 3) dynamicMotionSolverListFvMesh changed to dictionary based input 4) Add Time reference access to sixDof restraints 5) Add drivenLinearMotion to solidBodyMotionFunctions. --- .../interFoam/overInterDyMFoam/pEqn.H | 7 - .../dynamicMotionSolverListFvMesh.C | 67 +++++-- .../dynamicMotionSolverListFvMesh.H | 4 +- src/dynamicMesh/Make/files | 2 + .../displacement/displacement/zoneMotion.C | 149 ++++++++++++++ .../displacement/displacement/zoneMotion.H | 107 ++++++++++ .../points0/points0MotionSolver.C | 4 +- .../points0/points0MotionSolver.H | 6 +- .../drivenLinearMotion/drivenLinearMotion.C | 128 ++++++++++++ .../drivenLinearMotion/drivenLinearMotion.H | 138 +++++++++++++ .../motionSolvers/motionSolver/motionSolver.C | 3 +- .../motionSolvers/motionSolver/motionSolver.H | 2 +- .../dynamicOversetFvMesh.C | 20 +- .../dynamicOversetFvMesh.H | 6 +- .../dynamicOversetFvMeshTemplates.C | 12 +- src/rigidBodyDynamics/Make/files | 1 + .../restraints/softWall/softWall.C | 160 +++++++++++++++ .../restraints/softWall/softWall.H | 143 +++++++++++++ .../rigidBodyModel/rigidBodyModel.H | 5 +- .../rigidBodyModel/rigidBodyModelI.H | 7 +- src/sixDoFRigidBodyMotion/Make/files | 1 + ...gidBodyDisplacementPointPatchVectorField.C | 4 +- ...gidBodyDisplacementPointPatchVectorField.C | 6 +- .../linearSpringDamper/linearSpringDamper.C | 189 ++++++++++++++++++ .../linearSpringDamper/linearSpringDamper.H | 178 +++++++++++++++++ .../sixDoFRigidBodyMotion.C | 10 +- .../sixDoFRigidBodyMotion.H | 20 +- .../sixDoFRigidBodyMotionI.H | 6 +- .../sixDoFRigidBodyMotionSolver.C | 43 +++- .../sixDoFRigidBodyMotionSolver.H | 5 +- 30 files changed, 1368 insertions(+), 65 deletions(-) create mode 100644 src/dynamicMesh/motionSolvers/displacement/displacement/zoneMotion.C create mode 100644 src/dynamicMesh/motionSolvers/displacement/displacement/zoneMotion.H create mode 100644 src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/drivenLinearMotion/drivenLinearMotion.C create mode 100644 src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/drivenLinearMotion/drivenLinearMotion.H create mode 100644 src/rigidBodyDynamics/restraints/softWall/softWall.C create mode 100644 src/rigidBodyDynamics/restraints/softWall/softWall.H create mode 100644 src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.C create mode 100644 src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/restraints/linearSpringDamper/linearSpringDamper.H diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H index 8b36eb2347..921b4f673b 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H @@ -17,13 +17,6 @@ #include "interpolatedFaces.H" } - if (runTime.outputTime()) - { - H.write(); - rAU.write(); - HbyA.write(); - } - surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); if (ddtCorr) diff --git a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C index a0992f3b8f..234df96a24 100644 --- a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C +++ b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2016 OpenFOAM Foundation @@ -53,22 +53,57 @@ Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh ) : dynamicFvMesh(io), - motionSolvers_ + motionSolvers_() +{ + IOobject ioDict ( - IOdictionary - ( - IOobject - ( - "dynamicMeshDict", - time().constant(), - *this, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::AUTO_WRITE - ) - ).lookup("solvers"), - motionSolver::iNew(*this) - ) -{} + "dynamicMeshDict", + time().constant(), + *this, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + + IOdictionary dict(ioDict); + + label i = 0; + if (dict.found("solvers")) + { + const dictionary& solvertDict = dict.subDict("solvers"); + + motionSolvers_.setSize(solvertDict.size()); + + for (const entry& dEntry : solvertDict) + { + if (dEntry.isDict()) + { + IOobject io(ioDict); + io.readOpt() = IOobject::NO_READ; + io.writeOpt() = IOobject::AUTO_WRITE; + io.rename(dEntry.dict().dictName()); + + IOdictionary IOsolverDict + ( + io, + dEntry.dict() + ); + + motionSolvers_.set + ( + i++, + motionSolver::New(*this, IOsolverDict) + ); + } + } + motionSolvers_.setSize(i); + } + else + { + motionSolvers_.setSize(1); + motionSolvers_.set(i++, motionSolver::New(*this)); + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.H b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.H index 938146974e..f2bf72d244 100644 --- a/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.H +++ b/src/dynamicFvMesh/dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.H @@ -27,7 +27,9 @@ Class Foam::dynamicMotionSolverListFvMesh Description - Foam::dynamicMotionSolverListFvMesh + Dynamic mesh able to handle multiple motion solvers. + NOTE: If the word entry "solvers" is not found it falls back to a single + motion solver behavior. SourceFiles dynamicMotionSolverListFvMesh.C diff --git a/src/dynamicMesh/Make/files b/src/dynamicMesh/Make/files index cc322d3890..a5f08432e1 100644 --- a/src/dynamicMesh/Make/files +++ b/src/dynamicMesh/Make/files @@ -102,6 +102,7 @@ motionSmoother/badQualityToFace/badQualityToFace.C motionSolvers/motionSolver/motionSolver.C motionSolvers/displacement/points0/points0MotionSolver.C +motionSolvers/displacement/displacement/zoneMotion.C motionSolvers/displacement/displacement/displacementMotionSolver.C motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C @@ -120,6 +121,7 @@ $(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C $(solidBodyMotionFunctions)/SDA/SDA.C $(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C $(solidBodyMotionFunctions)/linearMotion/linearMotion.C +$(solidBodyMotionFunctions)/drivenLinearMotion/drivenLinearMotion.C $(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C $(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C $(solidBodyMotionFunctions)/multiMotion/multiMotion.C diff --git a/src/dynamicMesh/motionSolvers/displacement/displacement/zoneMotion.C b/src/dynamicMesh/motionSolvers/displacement/displacement/zoneMotion.C new file mode 100644 index 0000000000..524c685919 --- /dev/null +++ b/src/dynamicMesh/motionSolvers/displacement/displacement/zoneMotion.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "zoneMotion.H" +#include "syncTools.H" +#include "cellZoneMesh.H" +#include "cellSet.H" +#include "boolList.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + + +Foam::zoneMotion::zoneMotion +( + const dictionary& dict, + const polyMesh& mesh +) +: + pointIDs_(), + moveAllCells_(false) +{ + word cellZoneName = + dict.lookupOrDefault("cellZone", "none"); + + word cellSetName = + dict.lookupOrDefault("cellSet", "none"); + + if ((cellZoneName != "none") && (cellSetName != "none")) + { + FatalIOErrorInFunction(dict) + << "Either cellZone OR cellSet can be supplied, but not both. " + << "If neither is supplied, all cells will be included" + << exit(FatalIOError); + } + + labelList cellIDs; + if (cellZoneName != "none") + { + Info<< "Applying solid body motion to cellZone " << cellZoneName + << endl; + + label zoneID = mesh.cellZones().findZoneID(cellZoneName); + + if (zoneID == -1) + { + FatalErrorInFunction + << "Unable to find cellZone " << cellZoneName + << ". Valid cellZones are:" + << mesh.cellZones().names() + << exit(FatalError); + } + + cellIDs = mesh.cellZones()[zoneID]; + } + + if (cellSetName != "none") + { + Info<< "Applying solid body motion to cellSet " << cellSetName + << endl; + + cellSet set(mesh, cellSetName); + + cellIDs = set.toc(); + } + + label nCells = returnReduce(cellIDs.size(), sumOp