ENH: lumped point motion using local linear basic functions (#1341)

- the earlier implementation of externally controlled lumped point
  motion (see merge request !120 and OpenFOAM-v1706 release notes) was
  conceived for the motion of simple structures such as buildings or
  simple beams. The motion controller was simply defined in terms of
  an orientation axis and divisions along that axis.

  To include complex structures, multiple motion controllers are
  defined in terms of support points and connectivity.

  The points can have additional node Ids associated with them, which
  makes it easier to map to/from FEA models.

  OLD system/lumpedPointMovement specification
  --------------------------------------------

      //- Reference axis for the locations
      axis            (0 0 1);

      //- Locations of the lumped points
      locations       (0 0.05 .. 0.5);

  NEW system/lumpedPointMovement specification
  --------------------------------------------

      // Locations of the lumped points
      points
      (
          (0  0  0.00)
          (0  0  0.05)
          ...
          (0  0  0.50)
      );

      //- Connectivity for motion controllers
      controllers
      {
          vertical
          {
              pointLabels (0 1 2 3 4 5 6 7 8 9 10);
          }
      }

  And the controller(s) must be associated with the given
  pointDisplacement patch. Eg,

     somePatch
     {
         type            lumpedPointDisplacement;
         value           uniform (0 0 0);
         controllers     ( vertical );   // <-- NEW
     }

TUT: adjust building motion tutorial

- use new controllor definitions
- replace building response file with executable
- add updateControl in dynamicMeshDict for slowly moving structure
This commit is contained in:
Mark Olesen
2020-06-10 01:10:27 +02:00
parent 17ea2c544d
commit b0136d835e
44 changed files with 4059 additions and 1356 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,8 +27,8 @@ Application
lumpedPointForces
Description
Extract force/moment information from existing calculations based
on the segmentation of the pressure integration zones.
Extract force/moment information from simulation results that
use the lumped points movement description.
\*---------------------------------------------------------------------------*/
@ -37,7 +37,7 @@ Description
#include "timeSelector.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "foamVtkSeriesWriter.H"
#include "lumpedPointTools.H"
#include "lumpedPointIOMovement.H"
@ -83,8 +83,8 @@ int main(int argc, char *argv[])
{
argList::addNote
(
"Extract force/moment information from existing calculations based"
" on the lumpedPoints pressure zones."
"Extract force/moment information from simulation results that"
" use the lumped points movement description."
);
argList::addBoolOption
@ -102,31 +102,33 @@ int main(int argc, char *argv[])
const bool withVTK = args.found("vtk");
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New
(
runTime
);
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh);
if (!movement.valid())
if (!movement)
{
Info<< "no valid movement given" << endl;
Info<< "No valid movement found" << endl;
return 1;
}
const labelList patchLst = lumpedPointTools::lumpedPointPatchList(mesh);
if (patchLst.empty())
const label nPatches = lumpedPointTools::setPatchControls(mesh);
if (!nPatches)
{
Info<< "no patch list found" << endl;
Info<< "No point patches with lumped movement found" << endl;
return 2;
}
movement().setMapping(mesh, patchLst, lumpedPointTools::points0Field(mesh));
Info<<"Lumped point patch controls set on " << nPatches
<< " patches" << nl;
vtk::seriesWriter forceSeries;
List<vector> forces, moments;
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timei], timei);
@ -164,11 +166,21 @@ int main(int argc, char *argv[])
forces,
moments
);
forceSeries.append(runTime.timeIndex(), outputName);
}
}
}
Info<< "End\n" << endl;
// Create file series
if (forceSeries.size())
{
forceSeries.write("forces.vtp");
}
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -40,15 +40,50 @@ Description
#include "argList.H"
#include "Time.H"
#include "timeSelector.H"
#include "OFstream.H"
#include "foamVtkSeriesWriter.H"
#include "lumpedPointTools.H"
#include "lumpedPointIOMovement.H"
using namespace Foam;
inline List<lumpedPointStateTuple> getResponseTable
(
const fileName& file,
const lumpedPointState& state0
)
{
return lumpedPointTools::lumpedPointStates
(
file,
state0.rotationOrder(),
state0.degrees()
);
}
void echoTableLimits
(
const List<lumpedPointStateTuple>& tbl,
const label span,
const label maxOut
)
{
Info<< "Using response table with " << tbl.size() << " entries" << nl;
if (span)
{
Info<< "Increment input by " << span << nl;
}
if (maxOut)
{
Info<< "Stopping after " << maxOut << " outputs" << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -59,7 +94,6 @@ int main(int argc, char *argv[])
" for diagnostic purposes."
);
argList::noParallel();
argList::noFunctionObjects(); // Never use function objects
argList::addOption
(
@ -71,7 +105,7 @@ int main(int argc, char *argv[])
(
"span",
"N",
"Increment each input by factor N (default: 1)"
"Increment each input by N (default: 1)"
);
argList::addOption
(
@ -79,6 +113,17 @@ int main(int argc, char *argv[])
"factor",
"Relaxation/scaling factor for movement (default: 1)"
);
argList::addOption
(
"visual-length",
"len",
"Visualization length for planes (visualized as triangles)"
);
argList::addBoolOption
(
"dry-run",
"Test movement without a mesh"
);
argList::addBoolOption
(
"removeLock",
@ -96,45 +141,70 @@ int main(int argc, char *argv[])
const label maxOut = Foam::max(0, args.getOrDefault<label>("max", 0));
const label span = Foam::max(1, args.getOrDefault<label>("span", 1));
const scalar relax = args.getOrDefault<scalar>("scale", 1);
// Control parameters
const bool dryrun = args.found("dry-run");
const bool slave = args.found("slave");
const bool removeLock = args.found("removeLock");
#include "createTime.H"
const scalar relax = args.getOrDefault<scalar>("scale", 1);
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New
(
runTime
);
args.readIfPresent("visual-length", lumpedPointState::visLength);
if (!movement.valid())
{
Info<< "no valid movement given" << endl;
return 1;
}
const fileName responseFile(args[1]);
List<lumpedPointStateTuple> responseTable =
lumpedPointTools::lumpedPointStates(args[1]);
Info<< "Using response table with " << responseTable.size()
<< " entries" << endl;
Info << "Increment input by " << span << nl;
if (maxOut)
{
Info<< "Stopping after " << maxOut << " outputs" << endl;
}
// ----------------------------------------------------------------------
// Slave mode
// ----------------------------------------------------------------------
if (slave)
{
Info<< "Running as slave responder" << endl;
externalFileCoupler& coupler = movement().coupler();
if (Pstream::parRun())
{
FatalErrorInFunction
<< "Running as slave responder is not permitted in parallel"
<< nl
<< exit(FatalError);
}
label count = 0;
for (label index = 0; index < responseTable.size(); index += span)
#include "createTime.H"
// Create movement without a mesh
autoPtr<lumpedPointIOMovement> movementPtr =
lumpedPointIOMovement::New(runTime);
if (!movementPtr)
{
Info<< "No valid movement found" << endl;
return 1;
}
auto& movement = *movementPtr;
// Reference state0
const lumpedPointState& state0 = movement.state0();
List<lumpedPointStateTuple> responseTable =
getResponseTable(responseFile, state0);
echoTableLimits(responseTable, span, maxOut);
if (dryrun)
{
Info<< "dry-run: response table with " << responseTable.size()
<< " entries" << nl
<< "\nEnd\n" << endl;
return 0;
}
externalFileCoupler& coupler = movement.coupler();
for
(
label timei = 0, outputCount = 0;
timei < responseTable.size();
timei += span
)
{
Info<< args.executable() << ": waiting for master" << endl;
@ -146,14 +216,14 @@ int main(int argc, char *argv[])
break;
}
lumpedPointState state = responseTable[index].second();
state.relax(relax, movement().state0());
lumpedPointState state = responseTable[timei].second();
state.relax(relax, state0);
// Generate input for OpenFOAM
OFstream os(coupler.resolveFile(movement().inputName()));
OFstream os(coupler.resolveFile(movement.inputName()));
if
(
movement().inputFormat()
movement.inputFormat()
== lumpedPointState::inputFormatType::PLAIN
)
{
@ -161,101 +231,236 @@ int main(int argc, char *argv[])
}
else
{
os.writeEntry("time", responseTable[index].first());
os.writeEntry("time", responseTable[timei].first());
state.writeDict(os);
}
Info<< args.executable()
<< ": updated to state " << index
<< ": updated to state " << timei
<< " - switch to master"
<< endl;
// Let OpenFOAM know that it can continue
coupler.useMaster();
if (maxOut && ++count >= maxOut)
++outputCount;
if (maxOut && outputCount >= maxOut)
{
Info<< args.executable()
<<": stopping after " << maxOut << " outputs" << endl;
<< ": stopping after " << maxOut << " outputs" << endl;
break;
}
}
if (removeLock)
{
Info<< args.executable() <<": removing lock file" << endl;
Info<< args.executable() << ": removing lock file" << endl;
coupler.useSlave(); // This removes the lock-file
}
Info<< args.executable() << ": finishing" << nl;
Info<< "\nEnd\n" << endl;
return 0;
}
else
// ----------------------------------------------------------------------
// dry-run
// ----------------------------------------------------------------------
if (dryrun)
{
runTime.setTime(instant(0, runTime.constant()), 0);
Info<< "dry-run: creating states only" << nl;
#include "createNamedPolyMesh.H"
#include "createTime.H"
const labelList patchLst = lumpedPointTools::lumpedPointPatchList(mesh);
if (patchLst.empty())
// Create movement without a mesh
autoPtr<lumpedPointIOMovement> movementPtr =
lumpedPointIOMovement::New(runTime);
if (!movementPtr)
{
Info<< "no patch list found" << endl;
return 2;
Info<< "No valid movement found" << endl;
return 1;
}
auto& movement = *movementPtr;
pointIOField points0 = lumpedPointTools::points0Field(mesh);
movement().setBoundBox(mesh, patchLst, points0);
// Reference state0
const lumpedPointState& state0 = movement.state0();
label index = 0;
List<lumpedPointStateTuple> responseTable =
getResponseTable(responseFile, state0);
// Initial geometry
movement().writeVTP("geom_init.vtp", mesh, patchLst, points0);
echoTableLimits(responseTable, span, maxOut);
forAll(responseTable, i)
vtk::seriesWriter stateSeries;
for
(
label timei = 0, outputCount = 0;
timei < responseTable.size();
timei += span
)
{
const bool output = ((i % span) == 0);
lumpedPointState state = responseTable[i].second();
state.relax(relax, movement().state0());
lumpedPointState state = responseTable[timei].second();
if (output)
{
Info<<"output [" << i << "/"
<< responseTable.size() << "]" << endl;
}
else
{
continue;
}
state += movement.origin();
movement.scalePoints(state);
state.relax(relax, state0);
Info<< "output [" << timei << '/' << responseTable.size() << ']';
// State/response = what comes back from FEM
{
const word outputName = word::printf("state_%06d.vtp", index);
const word outputName =
word::printf("state_%06d.vtp", outputCount);
Info<<" " << outputName << endl;
Info<< " " << outputName;
state.writeVTP(outputName, movement().axis());
movement.writeStateVTP(state, outputName);
stateSeries.append(outputCount, outputName);
}
Info<< endl;
++outputCount;
if (maxOut && outputCount >= maxOut)
{
const word outputName = word::printf("geom_%06d.vtp", index);
Info<<" " << outputName << endl;
movement().writeVTP(outputName, state, mesh, patchLst, points0);
Info<< "Max output " << maxOut << " ... stopping" << endl;
break;
}
}
{
++index;
// Write file series
bool canOutput = !maxOut || (index <= maxOut);
if (!canOutput)
{
Info<<"stopping output after "
<< maxOut << " outputs" << endl;
break;
}
}
if (stateSeries.size())
{
Info<< nl << "write state.vtp.series" << nl;
stateSeries.write("state.vtp");
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ----------------------------------------------------------------------
// test patch movement
// ----------------------------------------------------------------------
#include "createTime.H"
runTime.setTime(instant(runTime.constant()), 0);
#include "createNamedMesh.H"
// Create movement with mesh
autoPtr<lumpedPointIOMovement> movementPtr =
lumpedPointIOMovement::New(mesh);
if (!movementPtr)
{
Info<< "No valid movement found" << endl;
return 1;
}
auto& movement = *movementPtr;
// Reference state0
const lumpedPointState& state0 = movement.state0();
List<lumpedPointStateTuple> responseTable =
getResponseTable(responseFile, state0);
echoTableLimits(responseTable, span, maxOut);
pointIOField points0(lumpedPointTools::points0Field(mesh));
const label nPatches = lumpedPointTools::setPatchControls(mesh, points0);
if (!nPatches)
{
Info<< "No point patches with lumped movement found" << endl;
return 2;
}
Info<< "Lumped point patch controls set on "
<< nPatches << " patches" << nl;
lumpedPointTools::setInterpolators(mesh, points0);
// Output vtk file series
vtk::seriesWriter stateSeries;
vtk::seriesWriter geomSeries;
// Initial geometry
movement.writeVTP("geom_init.vtp", state0, mesh, points0);
lumpedPointTools::setInterpolators(mesh);
for
(
label timei = 0, outputCount = 0;
timei < responseTable.size();
timei += span
)
{
lumpedPointState state = responseTable[timei].second();
state += movement.origin();
movement.scalePoints(state);
state.relax(relax, state0);
Info<< "output [" << timei << '/' << responseTable.size() << ']';
// State/response = what comes back from FEM
{
const word outputName =
word::printf("state_%06d.vtp", outputCount);
Info<< " " << outputName;
movement.writeStateVTP(state, outputName);
stateSeries.append(outputCount, outputName);
}
{
const word outputName =
word::printf("geom_%06d.vtp", outputCount);
Info<< " " << outputName;
movement.writeVTP(outputName, state, mesh, points0);
geomSeries.append(outputCount, outputName);
}
Info<< endl;
++outputCount;
if (maxOut && outputCount >= maxOut)
{
Info<< "Max output " << maxOut << " ... stopping" << endl;
break;
}
}
Info<< args.executable() << ": finishing" << nl;
// Write file series
if (geomSeries.size())
{
Info<< nl << "write geom.vtp.series" << nl;
geomSeries.write("geom.vtp");
}
if (stateSeries.size())
{
Info<< nl << "write state.vtp.series" << nl;
stateSeries.write("state.vtp");
}
Info<< "\nEnd\n" << endl;

View File

@ -2,9 +2,12 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lumpedPointMotion/lnInclude
-I$(LIB_SRC)/lumpedPointMotion/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfileFormats \
-lmeshTools \
-llumpedPointMotion
-llumpedPointMotion \
-ldynamicMesh

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,6 +39,7 @@ Description
#include "lumpedPointTools.H"
#include "lumpedPointIOMovement.H"
#include "fvMesh.H"
using namespace Foam;
@ -52,9 +53,26 @@ int main(int argc, char *argv[])
" pressure integration zones used by lumpedPoint BC."
);
argList::noParallel(); // The VTP writer is not yet in parallel
argList::noFunctionObjects(); // Never use function objects
argList::addBoolOption
(
"dry-run",
"Test initial lumped points state without a mesh"
);
argList::addOption
(
"visual-length",
"len",
"Visualization length for planes (visualized as triangles)"
);
argList::addBoolOption
(
"no-interpolate",
"Suppress calculation/display of point interpolators"
);
argList::addBoolOption
(
"verbose",
@ -62,47 +80,89 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "setRootCase.H"
const bool noInterpolate = args.found("no-interpolate");
const bool dryrun = args.found("dry-run");
// const bool verbose = args.found("verbose");
args.readIfPresent("visual-length", lumpedPointState::visLength);
#include "createTime.H"
runTime.setTime(instant(0, runTime.constant()), 0);
if (dryrun)
{
// Create without a mesh
autoPtr<lumpedPointIOMovement> movement =
lumpedPointIOMovement::New(runTime);
#include "createNamedPolyMesh.H"
if (!movement.valid())
{
Info<< "No valid movement found" << endl;
return 1;
}
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New
(
runTime
);
const word outputName("state.vtp");
Info<< "dry-run: writing " << outputName << nl;
movement().writeStateVTP(movement().state0(), outputName);
Info<< "\nEnd\n" << endl;
return 0;
}
runTime.setTime(instant(runTime.constant()), 0);
#include "createNamedMesh.H"
autoPtr<lumpedPointIOMovement> movement = lumpedPointIOMovement::New(mesh);
if (!movement.valid())
{
Info<< "no valid movement found" << endl;
Info<< "No valid movement found" << endl;
return 1;
}
const labelList patchLst = lumpedPointTools::lumpedPointPatchList(mesh);
if (patchLst.empty())
// Initial positions/rotations
movement().writeStateVTP("state.vtp");
pointIOField points0(lumpedPointTools::points0Field(mesh));
const label nPatches = lumpedPointTools::setPatchControls(mesh, points0);
if (!nPatches)
{
Info<< "no patch list found" << endl;
Info<< "No point patches with lumped movement found" << endl;
return 2;
}
pointIOField points0 = lumpedPointTools::points0Field(mesh);
movement().setMapping(mesh, patchLst, points0);
Info<<"Lumped point patch controls set on "
<< nPatches << " patches" << nl;
// Initial geometry, but with zone colouring
movement().writeZonesVTP("lumpedPointZones.vtp", mesh, points0);
Info<<"Areas per point: " << flatOutput(movement().areas(mesh)) << nl;
// Initial positions/rotations
movement().writeStateVTP("initialState.vtp");
if (noInterpolate)
{
// Initial geometry, with zones
movement().writeZonesVTP("lumpedPointZones.vtp", mesh, points0);
}
else
{
lumpedPointTools::setInterpolators(mesh, points0);
// Initial geometry, with zones and interpolations
movement().writeVTP("lumpedPointZones.vtp", mesh, points0);
}
Info<< nl
<< "wrote 'state.vtp' (reference state)" << nl
<< "wrote 'lumpedPointZones.vtp'" << nl
<< "wrote 'initialState.vtp'" << nl
<< "End\n" << endl;
<< "\nEnd\n" << endl;
return 0;
}