From 7db868b5093d376046e51f22684dbbc87c2f91d1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 15 Jun 2020 20:24:09 +0200 Subject: [PATCH] TUT: bridge using external lumped point motion (#1341) - see its accompanying README for additional setup instructions --- .../lumpedPointMotion/bridge/Allclean | 12 + .../lumpedPointMotion/bridge/Allrun | 47 + .../lumpedPointMotion/bridge/Allrun.move | 35 + .../lumpedPointMotion/bridge/README.md | 90 + .../lumpedPointMotion/bridge/code/Allclean | 13 + .../lumpedPointMotion/bridge/code/Make/files | 3 + .../bridge/code/Make/options | 13 + .../bridge/code/polynomial-motion.C | 642 + .../bridge/files/Allrun.moveMesh | 35 + .../bridge/files/Allrun.movement | 36 + .../bridge/files/Allrun.transient | 35 + .../bridge/files/RunFunctions | 147 + .../bridge/files/polynomials.dict | 979 ++ .../lumpedPointMotion/bridge/steady/0.orig/U | 52 + .../bridge/steady/0.orig/epsilon | 54 + .../bridge/steady/0.orig/include/controllers | 20 + .../bridge/steady/0.orig/include/environ | 26 + .../steady/0.orig/include/initialConditions | 15 + .../lumpedPointMotion/bridge/steady/0.orig/k | 54 + .../bridge/steady/0.orig/nut | 50 + .../bridge/steady/0.orig/omega | 53 + .../lumpedPointMotion/bridge/steady/0.orig/p | 53 + .../bridge/steady/0.orig/pointDisplacement | 75 + .../lumpedPointMotion/bridge/steady/Allclean | 14 + .../lumpedPointMotion/bridge/steady/Allrun | 25 + .../bridge/steady/Allrun.init | 12 + .../bridge/steady/Allrun.pre | 50 + .../bridge/steady/constant/dynamicMeshDict | 35 + .../steady/constant/transportProperties | 21 + .../steady/constant/turbulenceProperties | 29 + .../bridge/steady/system/PDRblockMeshDict | 80 + .../bridge/steady/system/blockMeshDict | 98 + .../bridge/steady/system/controlDict | 80 + .../bridge/steady/system/decomposeParDict | 27 + .../bridge/steady/system/fvSchemes | 72 + .../bridge/steady/system/fvSolution | 135 + .../steady/system/lumpedPointControllers | 245 + .../bridge/steady/system/lumpedPointMovement | 86 + .../bridge/steady/system/meshQualityDict | 24 + .../bridge/steady/system/snappyHexMeshDict | 305 + .../steady/system/surfaceFeatureExtractDict | 33 + tutorials/resources/geometry/fsi-bridge1.obj | 12484 ++++++++++++++++ 42 files changed, 16394 insertions(+) create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/Allclean create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/Allrun create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/Allrun.move create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/README.md create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/code/Allclean create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/code/Make/files create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/code/Make/options create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/files/Allrun.moveMesh create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/files/Allrun.movement create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/files/Allrun.transient create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/files/RunFunctions create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/files/polynomials.dict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/U create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/epsilon create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/include/controllers create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/include/environ create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/include/initialConditions create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/k create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/nut create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/omega create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/p create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/0.orig/pointDisplacement create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/steady/Allclean create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/steady/Allrun create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/steady/Allrun.init create mode 100755 tutorials/incompressible/lumpedPointMotion/bridge/steady/Allrun.pre create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/constant/dynamicMeshDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/constant/transportProperties create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/constant/turbulenceProperties create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/PDRblockMeshDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/blockMeshDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/controlDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/decomposeParDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/fvSchemes create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/fvSolution create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/lumpedPointControllers create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/lumpedPointMovement create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/meshQualityDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/snappyHexMeshDict create mode 100644 tutorials/incompressible/lumpedPointMotion/bridge/steady/system/surfaceFeatureExtractDict create mode 100644 tutorials/resources/geometry/fsi-bridge1.obj diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/Allclean b/tutorials/incompressible/lumpedPointMotion/bridge/Allclean new file mode 100755 index 0000000000..e560111894 --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/Allclean @@ -0,0 +1,12 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +#------------------------------------------------------------------------------ + +(cd code && ./Allclean) + +(cd steady && ./Allclean) + +rm -rf movement +rm -rf transient + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/Allrun b/tutorials/incompressible/lumpedPointMotion/bridge/Allrun new file mode 100755 index 0000000000..4483a51c52 --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/Allrun @@ -0,0 +1,47 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +# 1) Run steady-state to establish a good initial field +# 2) Copy state-state results -> transient case, +# but need to copy the pointDisplacement from the 0/ directory +# since it will not have been used for the steady-state case +# 3) Relocate this initial solution to coincide with the first deltaT +# to avoid overwriting the 0/ directory at all. + +# Do steady-state case +steady/Allrun $* + +if notTest "$@" +then + if canCompile + then + (cd code && wmake) + else + exit 0 + fi + + . files/RunFunctions + + caseName="transient" + + latestTime=$(foamListTimes -case steady -noZero -latestTime -processor) + + # Clone the steady-state case to transient + cloneParallelCase steady "$caseName" 0 "$latestTime" + + copyParallelPointDisplacement "$caseName" "$latestTime" + + # Adjust application (from simpleFoam -> pimpleFoam) + foamDictionary transient/system/controlDict \ + -entry application -set pimpleFoam + + # Copy/link support files + linkFiles files "$caseName" + + # Run + "$caseName/Allrun.$caseName" $* +fi + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/Allrun.move b/tutorials/incompressible/lumpedPointMotion/bridge/Allrun.move new file mode 100755 index 0000000000..78f3593b0b --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/Allrun.move @@ -0,0 +1,35 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +# 1) Run meshing +# 2) Test input zones and movement + +# Meshing +steady/Allrun.pre $* + +if notTest "$@" +then + if canCompile + then + (cd code && wmake) + else + exit 0 + fi + + . files/RunFunctions + + caseName="movement" + + # Copy/link the steady-state case to movement + linkParallelCase steady "$caseName" + + # Copy/link support files + linkFiles files "$caseName" + + # Run + "$caseName/Allrun.$caseName" $* +fi + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/README.md b/tutorials/incompressible/lumpedPointMotion/bridge/README.md new file mode 100644 index 0000000000..e4eb723a1d --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/README.md @@ -0,0 +1,90 @@ +Setting up the FSI linear controllers can be easy or difficult, +depending on the complexity of the structure and the source of the +input data. + +If you already have an FEA model with nodes and beam elements, it will +be fairly straightforward to instrument your structure. If you just +have the control points but need to define the connectivity yourself, +it will obviously be more work. + +In this case it can help to import your raw points as a csv table in +paraview and use the TableToPoints filter to visualize their locations +and overlay this with the surface geometry. With this you can piece +together the connectivity, which specifies the motion _controllors_. + +To debug the setup, within `steady/` + +Copy the geometry +``` +./Allrun.init +``` +Verify connectivity +``` +lumpedPointZones -dry-run +``` + +This will generate a `state.vtp` file with the lumped points, connected +as per the controller description. + + +Next generate the mesh (eg, with snappyHexMesh). For example, +``` +./Allrun.pre +``` + +Test the mapping +``` +lumpedPointZones # serial or parallel + +paraview lumpedPointZones.vtp +``` +Inspect the nearest/next nearest and weighting. +Adjust the controllers definitions if required. + + +For setup, it is often helpful if you have some predefined structural +response data that can be used for testing. + +Check the quality of response data by visualizing how it affects the +movement of the points: +``` +lumpedPointMovement {options} -dry-run response.txt + +paraview state.vtk.series +``` + +You can add visualization options such as `-scale` or +`-visual-length`. If the there are many time points in the response +data, use `-span` to skip over some of them. + + +The `lumpedPointMovement` command can be used as above, but without +the `-dry-run` option. This will extract the patch surface associated +with the controllers and generate corresponding surface files in VTK +format. +``` +lumpedPointMovement {options} response.txt + +paraview geom.vtp.series +``` + +Using a larger scale factor (eg, `-scale 10`) can help highlight +potential interpolation problems. + + +## Additional Notes + +The `files/polynomials.dict` represent a vague approximation of +measurement data, but are only intended as a compacter means of +representing the movement. They can be used with the accompanying +`code/polynomial-motion.C` to act as a response slave, or to +pre-generate a response file. For example, + +``` +code/polynomial-motion -output response.txt -deltaT 0.001 -nTimes 5001 files/polynomials.dict +``` + +To query the values at an individual time: +``` +code/polynomial-motion -query -time 0.5 files/polynomials.dict +``` diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/code/Allclean b/tutorials/incompressible/lumpedPointMotion/bridge/code/Allclean new file mode 100755 index 0000000000..03329f2ae8 --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/code/Allclean @@ -0,0 +1,13 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +#------------------------------------------------------------------------------ + +wclean + +# Remove executable +rm -f polynomial-motion + +# Remove known output/debug files +rm -f *.txt *.vtp *.vtp.series + +#------------------------------------------------------------------------------ diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/files b/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/files new file mode 100644 index 0000000000..0e8bf890c4 --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/files @@ -0,0 +1,3 @@ +polynomial-motion.C + +EXE = $(PWD)/polynomial-motion diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/options b/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/options new file mode 100644 index 0000000000..6211233098 --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/code/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/lumpedPointMotion/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lfileFormats \ + -lmeshTools \ + -ldynamicMesh \ + -llumpedPointMotion diff --git a/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C b/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C new file mode 100644 index 0000000000..f6280dd0de --- /dev/null +++ b/tutorials/incompressible/lumpedPointMotion/bridge/code/polynomial-motion.C @@ -0,0 +1,642 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2020 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 . + +Application + polynomial-motion + +Description + Polynomial representations of position/angle for fluid-structure + interface check. + Generates position and rotation angle of each node. + +Note + The values may or may not correspond to experimental values. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "Fstream.H" +#include "polynomialFunction.H" +#include "unitConversion.H" +#include "foamVtkSeriesWriter.H" +#include "lumpedPointTools.H" +#include "lumpedPointState.H" +#include "lumpedPointIOMovement.H" +#include + +using namespace Foam; + +//- Position/angle generator based on polynomials +class position_generator +{ + // Private Data + + typedef FixedList xyzPoly; + + List points_; + List angles_; + + + // Private Member Functions + + //- Calculate position/rotation at given time + lumpedPointState calc(scalar currTime) const + { + // Limit the time + currTime = min(currTime, maxTime); + + const auto polyToValue = + [=](const xyzPoly& p) -> vector + { + return vector + ( + p[0].value(currTime), + p[1].value(currTime), + p[2].value(currTime) + ); + }; + + pointField pts(points_.size()); + std::transform + ( + points_.cbegin(), points_.cend(), pts.begin(), polyToValue + ); + + vectorField ang(angles_.size()); + std::transform + ( + angles_.cbegin(), angles_.cend(), ang.begin(), polyToValue + ); + + return lumpedPointState{pts, ang}; + } + + +public: + + // Control Parameters + + // Upper time limit on polynomials + scalar maxTime = GREAT; + + + // Constructors + + //- Default construct + position_generator() = default; + + //- Read construct from dictionary + position_generator(const dictionary& dict) + { + dict.readIfPresent("maxTime", maxTime); + dict.readEntry("points", points_); + dict.readEntry("angles", angles_); + + if (angles_.size() != points_.size()) + { + Info<< "Resized angles to match number of points" << nl; + angles_.resize(points_.size(), xyzPoly(polynomialFunction())); + } + } + + + // Member Functions + + //- Calculate position/rotation at given time + lumpedPointState state(const scalar currTime) const + { + return calc(currTime); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Polynomial representations of position/angle for fluid-structure" + " interface check." + " Generates position and rotation angle of each node." + ); + + argList::noBanner(); + argList::noParallel(); + + // Time control + argList::addOption + ( + "time", + "value", + "The time to use" + ); + argList::addOption + ( + "deltaT", + "value", + "The time increment for multiple time loops" + ); + argList::addOption + ( + "nTimes", + "value", + "The number of time loops" + ); + + // Query, output + argList::addBoolOption + ( + "query", + "Report values only and exit" + ); + argList::addOption + ( + "output", + "file", + "write to file, with header" + ); + + argList::addOption + ( + "scale", + "factor", + "Scaling factor for movement (default: 1)" + ); + argList::addOption + ( + "visual-length", + "len", + "Visualization length for planes (visualized as triangles)" + ); + + // Run controls + argList::addBoolOption + ( + "dry-run", + "Test movement without a mesh" + ); + argList::addBoolOption + ( + "removeLock", + "Remove lock-file on termination of slave" + ); + argList::addBoolOption + ( + "slave", + "Invoke as a slave responder for testing" + ); + + argList::addArgument + ( + "file", + "Points/angles as triples of polynomials.\n" + "Dictionary format" + ); + + #include "setRootCase.H" + + // The position/angle generator + position_generator gen; + + { + // Input polynomials file + IFstream is(args[1]); + + dictionary dict(is); + gen = position_generator(dict); + } + + + // Control parameters + const bool dryrun = args.found("dry-run"); + const bool slave = args.found("slave"); + const bool removeLock = args.found("removeLock"); + + const bool optQuery = args.found("query"); + const fileName outputFile(args.getOrDefault("output", "")); + + const scalar relax = args.getOrDefault("scale", 1); + + args.readIfPresent("visual-length", lumpedPointState::visLength); + + // Time parameters + scalar currTime = args.getOrDefault("time", 0); + const scalar deltaT = args.getOrDefault("deltaT", 0.001); + const label nTimes = args.getOrDefault