7#ifndef _H_MAIA_RIGIDBODIES_
8#define _H_MAIA_RIGIDBODIES_
36 using Grid =
typename CartesianSolver::Grid;
37 using GridProxy =
typename CartesianSolver::GridProxy;
41 using CartesianSolver::domainId;
42 using CartesianSolver::domainOffset;
43 using CartesianSolver::grid;
44 using CartesianSolver::haloCellId;
45 using CartesianSolver::localPartitionCellOffsets;
46 using CartesianSolver::m_adaptation;
47 using CartesianSolver::m_bandWidth;
48 using CartesianSolver::m_freeIndices;
49 using CartesianSolver::m_innerBandWidth;
50 using CartesianSolver::m_Ma;
51 using CartesianSolver::m_outerBandWidth;
52 using CartesianSolver::m_Re;
53 using CartesianSolver::m_recalcIds;
54 using CartesianSolver::m_residualInterval;
55 using CartesianSolver::m_restartFile;
56 using CartesianSolver::m_solutionInterval;
57 using CartesianSolver::m_solutionOffset;
58 using CartesianSolver::m_solutionTimeSteps;
59 using CartesianSolver::m_solverId;
60 using CartesianSolver::maxLevel;
61 using CartesianSolver::maxNoGridCells;
62 using CartesianSolver::maxRefinementLevel;
63 using CartesianSolver::maxUniformRefinementLevel;
64 using CartesianSolver::minLevel;
65 using CartesianSolver::mpiComm;
66 using CartesianSolver::neighborDomain;
67 using CartesianSolver::noDomains;
68 using CartesianSolver::noHaloCells;
69 using CartesianSolver::noNeighborDomains;
70 using CartesianSolver::noWindowCells;
71 using CartesianSolver::outputDir;
72 using CartesianSolver::restartDir;
73 using CartesianSolver::restartInterval;
74 using CartesianSolver::solverId;
75 using CartesianSolver::solverMethod;
76 using CartesianSolver::updateDomainInfo;
77 using CartesianSolver::windowCellId;
103 MPI_Comm
mpiComm()
const {
return MPI_COMM_WORLD; }
108 std::vector<MFloat>& NotUsed(sensorWeight),
109 std::vector<std::bitset<64>>& NotUsed(sensorCellFlag),
110 std::vector<MInt>& NotUsed(sensorSolverId))
override{};
112 void setSensors(std::vector<std::vector<MFloat>>& , std::vector<MFloat>& ,
113 std::vector<std::bitset<64>>& , std::vector<MInt>& )
override{};
222 MFloat*
const vectorWorld);
225 MFloat*
const vectorBody);
261 std::array<MFloat, 3> x);
353 std::vector<std::vector<MInt>>& homeDomainIdsForRemoteDomain,
354 std::map<
MInt, std::vector<MInt>>& tmpRemoteMap);
356 std::vector<std::vector<MInt>>& remoteDomainIdsForHomeDomain,
357 std::vector<std::vector<std::array<MFloat, nDim>>>& shiftForHomeDomain);
383 template <MInt bodyType>
396 mTerm(1, AT_,
"BodyType not implemented!");
438 void addForce(
const MInt bodyId,
const std::array<MFloat, nDim>& force) {
439 for(
MInt n = 0; n < nDim; n++) {
440 m_bodies.bodyForce(bodyId, n) += force[n];
469 IF_CONSTEXPR(nDim == 2) { std::cout <<
"Revise volume for 2D!" << std::endl; }
475 std::cerr <<
"Implement volume formula!" << std::endl;
484 for(
MInt n = 0; n < nDim; n++) {
485 velocity[n] =
m_bodies.bodyVelocity(bodyId, n);
514 return m_bodies.bodyAccelerationOld(bodyId, dim);
537 return m_bodies.bodyQuaternionT1B2(bodyId, dim);
542 return m_bodies.angularVelocityT1(bodyId, dim);
547 return m_bodies.angularVelocityT1B2(bodyId, dim);
551 return m_bodies.angularVelocityBodyT1(bodyId, dim);
554 return m_bodies.angularVelocityBodyT1(bodyId, dim);
558 return m_bodies.angularVelocityBodyT1B2(bodyId, dim);
561 return m_bodies.angularVelocityBodyT1B2(bodyId, dim);
565 return m_bodies.angularAccelerationT1(bodyId, dim);
568 return m_bodies.angularAccelerationT1(bodyId, dim);
572 return m_bodies.angularAccelerationBody(bodyId, dim);
575 return m_bodies.angularAccelerationBody(bodyId, dim);
602 for(
MInt n = 0; n < nDim; n++) {
GridCell
Grid cell Property Labels.
MFloat & a_angularVelocity(const MInt bodyId, const MInt dim)
MString m_bodyCenterInitMethod
void transformToBodyFrame(const MFloat *const quaternion, const MFloat *const vectorWorld, MFloat *const vectorBody)
Transform a vector form the world frame to the body frame.
MFloat time() const override
Return the time.
MFloat getDistancePiston(const MFloat *coordinates, const MInt bodyId)
Calculates the closest distance between a given point and a piston.
std::ofstream m_debugFileStream
void initBodyLog()
Initalize log-file.
MFloat a_angularVelocityBodyT1(const MInt bodyId, const MInt dim) const
void exchangeBufferLengthsAllToAll(std::vector< MInt > &noToRecv, const MInt noToSend)
exchange of Buffer lengths all to all
void resizeGridMap()
Swap the given cells.
std::map< MInt, std::map< MInt, std::array< MFloat, nDim > > > m_periodicShift
MFloat a_angularVelocityT1B2(const MInt bodyId, const MInt dim) const
MFloat & a_bodyTemperature(const MInt bodyId)
void setTimestep(const MFloat timestep)
MFloat a_bodyVelocityMag(const MInt bodyId)
MFloat & a_bodyCenter(const MInt bodyId, const MInt dim)
std::array< MFloat, nDim > gravity
MBool isRemoteBody(MInt bodyId)
void correctRotation(const MInt bodyId)
void getAngularVelocity(const MInt bodyId, std::array< MFloat, nRot > &angularVelocity)
void exchangeNeighborConnectionInfo()
void swapCells(const MInt, const MInt) override
Swap the given cells.
void preTimeStep() override
Resetting the 2-Step predictor-corrector cycle.
maia::rb::collector::RigidBodyCollector< nDim > m_bodies
void correctorStep()
Correct the state of all bodies using external forces/fluxes/torques.
void refineCell(const MInt) override
Refine the given cell.
void checkDummyBodiesForSwap()
void loadBodyRestartFile()
Loads restart file for the RigidBodies solver.
MFloat & a_torqueT1(const MInt bodyId, const MInt dim)
MBool hasAssociatedDummyBody(const MInt bodyId) const
MFloat getDistanceEllipsoid(const MFloat *coordinates, const MInt bodyId)
Calculates the closest distance between a given point and a ellipsoid.
MFloat a_bodyHeatFlux(const MInt bodyId) const
std::vector< MFloat > m_initBodyDensityRatios
MBool solutionStep() override
void collideSpheres(const MInt bodyA, const MInt bodyB)
Calculate collision force between two spheres.
MFloat * m_static_computeBodyProperties_liftStartAngle1
MFloat findClosestPointEllipsoid(const MFloat *const relPos, const MInt bodyId)
void initGridProperties()
MFloat & a_bodyRadius(const MInt bodyId)
void exchangeNeighborNeighborRemote(std::vector< std::vector< MInt > > &bodyIdsForRemoteDomain, std::vector< std::vector< MInt > > &homeDomainIdsForRemoteDomain, std::map< MInt, std::vector< MInt > > &tmpRemoteMap)
std::vector< MFloat > m_initBodyRadius
MInt noEmbeddedBodies() const
void reIntAfterRestart(MBool) override
void exchangeBufferLengthsNeighbors(std::vector< MInt > &noToRecv, const MInt noToSend)
exchange of Buffer lengths all to all in direct neighborhood
MFloat a_angularAccelerationBody(const MInt bodyId, const MInt dim) const
MFloat & a_bodyVelocityOld(const MInt bodyId, const MInt dim)
MFloat getDistance(const MFloat *const coordinates, const MInt bodyId)
Calculates the closest distance between a given point and body.
void transformToWorldFrame(const MFloat *const quaternion, const MFloat *const vectorBody, MFloat *const vectorWorld)
Transform a vector form the body frame to the world frame.
MFloat * a_bodyTorque(const MInt bodyId)
MFloat & a_bodyForce(const MInt bodyId, const MInt dim)
void postAdaptation() override
post adaptation for split adaptation within the adaptation loop
typename maia::CartesianSolver< nDim, RigidBodies > CartesianSolver
void deleteDummyBody(const MInt bodyId, const MInt collectorShift=0)
Delete dummy bodies from collector that are not relevant anymore.
MFloat a_angularAccelerationT1(const MInt bodyId, const MInt dim) const
void correctBodies()
Correcting the state of all bodies using all available external forces/fluxes.
MFloat & a_bodyDensityRatio(const MInt bodyId)
MFloat & a_angularVelocityBodyT1(const MInt bodyId, const MInt dim)
MFloat a_bodyMass(const MInt bodyId)
MFloat a_bodyCenterOld(const MInt bodyId, const MInt dim) const
void predictorStep()
Peform a prediction for all bodies.
MFloat c_cellLengthAtMaxLevel() const
const MFloat m_bodyHeatCapacity
void createDummyBody(MInt bodyId)
appends new DummyBody to collector
void loadBodiesSizeAndPosition()
loadind no of embedded bodies and it's position from restart file
void prepareAdaptation(std::vector< std::vector< MFloat > > &NotUsed(sensors), std::vector< MFloat > &NotUsed(sensorWeight), std::vector< std::bitset< 64 > > &NotUsed(sensorCellFlag), std::vector< MInt > &NotUsed(sensorSolverId)) override
MFloat a_angularVelocityT1(const MInt bodyId, const MInt dim) const
MInt a_hasNeighbor(const MInt, const MInt) const
MFloat a_bodyTemperature(const MInt bodyId) const
MFloat calculatePeriodicShift(MInt intersectingCellId, MInt direction)
periodic shift for position for further data exchange
MFloat a_bodyVelocityOld(const MInt bodyId, const MInt dim) const
void finalizeAdaptation() override
finalize adaptation for split sadptation after the adaptation loop
void printBodyDomainConnections()
debugging: print all necessary mappings for each partition in specific file
MFloat a_torqueT1(const MInt bodyId, const MInt dim) const
void readProperties()
Reading all necessary properties for the RigidBodies solver.
MInt getGlobalBodyId(MInt localBodyId)
MFloat a_bodyCenter(const MInt bodyId, const MInt dim) const
MFloat & a_angularAccelerationBody(const MInt bodyId, const MInt dim)
MInt * m_static_computeBodyProperties_bodyToFunction
std::array< MFloat, 2 > m_distFac
void deleteIrrelevantBodies(std::list< std::pair< MInt, MInt > > &removeList)
Delete remote bodies from collector that are not relevant anymore.
void collideBodies()
Calculate collisions forces for all bodies.
MFloat & a_angularVelocityT1B2(const MInt bodyId, const MInt dim)
MFloat * m_static_computeBodyProperties_freqFactor
void saveBodyRestartFile(const MBool backup)
Write restart file for the RigidBody solver.
Status a_status(const MInt bodyId) const
void addForce(const MInt bodyId, const std::array< MFloat, nDim > &force)
MFloat * getBodyProperties(MInt returnMode, MInt bodyId)
MFloat getDistanceCube(const MFloat *coordinates, const MInt bodyId)
Calculates the closest distance between a given point and a cube.
void exchangeBufferLengthsRemoteToHome(std::vector< MInt > &noToRecv, std::vector< MInt > &noToSend)
MInt noInternalCells() const override
Return the number of internal cells within this solver.
static constexpr MInt nQuat
void exchangeFsiData()
exchange of summed forces and torques
MFloat & a_bodyVelocity(const MInt bodyId, const MInt dim)
MFloat & a_bodyQuaternionT1B2(const MInt bodyId, const MInt dim)
MFloat a_angularVelocityBody(const MInt bodyId, const MInt dim) const
MFloat * m_static_computeBodyProperties_rotAngle
void exchangeBufferLengthsNeighbor(std::vector< MInt > &noToRecv, std::vector< std::vector< MInt > > &bodyList)
exchange of Buffer legnths for further exchanges
typename maia::grid::tree::Tree< nDim >::Cell Cell
MFloat * m_static_computeBodyProperties_omega
std::vector< std::vector< MInt > > m_transferBodies
MFloat m_uniformBodyTemperature
void findLocalBodies()
searches in all initial Bodies for local bodies
void addTorque(const MInt bodyId, const std::array< MFloat, nRot > &torque)
std::map< MInt, MInt > m_associatedDummyBodies
std::array< MFloat, nDim > m_globDomainLength
void swapProxy(const MInt cellId0, const MInt cellId1)
Swap the given cells.
MFloat a_bodyInertia(const MInt bodyId, const MInt dim) const
void logBodyData()
Writing a simple log file containing the current state for all bodies.
MFloat a_bodyQuaternionT1(const MInt bodyId, const MInt dim) const
MFloat & a_angularVelocityBody(const MInt bodyId, const MInt dim)
void advanceBodies()
Copy the body data for time t to t-1 to prepare the next timestep.
MString outputDir() const
void reinitAfterAdaptation() override
maia::rb::collector::RigidBodyCollector< nDim > m_bResFile
void writeRestartFile(const MBool writeRestart, const MBool writeBackup, const MString, MInt *) override
Write restart file for the RigidBody solver.
~RigidBodies()
D'tor for the RigidBodies solver.
MFloat getDistanceSphere(const MFloat *coordinates, const MInt bodyId)
Calculates the closest distance between a given point and a sphere.
void findTransferBodies()
creates list with all edge bodies that are no longer contained within local domain
std::map< MInt, std::vector< MInt > > m_remoteDomainLocalBodies
MFloat & a_angularAccelerationT1(const MInt bodyId, const MInt dim)
MFloat & a_bodyCenterOld(const MInt bodyId, const MInt dim)
MFloat a_bodyTorque(const MInt bodyId, const MInt dim) const
MFloat * m_static_computeBodyProperties_amplitude
void initRemoteDummyBodyData(const MInt bodyId)
initalize kinematic data of dummyBody that is associated with a remoteBody
void getVelocity(const MInt bodyId, std::array< MFloat, nDim > &velocity)
void exchangeNeighborNeighborHome(std::vector< std::vector< MInt > > &bodyIdsForHomeDomain, std::vector< std::vector< MInt > > &remoteDomainIdsForHomeDomain, std::vector< std::vector< std::array< MFloat, nDim > > > &shiftForHomeDomain)
std::vector< MString > m_logVars
MInt noHomeDomains() const
MFloat * a_bodyForce(const MInt bodyId)
void prepareAdaptation() override
prepare adaptation for split adaptation before the adaptation loop
void exchangeBodyVariablesAllToAll()
exchange of Body Variables all to all
void computeBodies()
Calculates the new state for all bodies.
typename CartesianSolver::Grid Grid
MFloat a_volume(const MInt bodyId)
MInt noCollectorBodies() const
void updateInfoDiameter(const MBool initCall=false)
MFloat * m_static_computeBodyProperties_normal
MFloat a_angularVelocity(const MInt bodyId, const MInt dim) const
MFloat * m_static_computeBodyProperties_initialBodyCenter
MFloat getHeatFlux(const MInt bodyId)
MFloat * m_static_computeBodyProperties_circleStartAngle
MFloat a_bodyDensityRatio(const MInt bodyId) const
MInt localToRemoteBody(const MInt collectorId, const MInt oldBodyId, const MInt domain)
this function transforms a localBody to a remoteBody on the current domain, necessary if a body cross...
MFloat * m_static_computeBodyProperties_liftEndAngle1
MBool isLocalBody(MInt bodyId)
std::vector< MString > m_logAngVars
void exchangeTransferBodies()
exchanges transfer bodies
void linSpace(MFloat start, MFloat end, MInt num, std::vector< MFloat > &linspaced)
MBool m_printKineticEnergy
MFloat & a_bodyTemperatureOld(const MInt bodyId)
std::map< MInt, std::vector< MInt > > m_homeDomainRemoteBodies
void updateBodyDomainConnections(MBool initCall)
updates local/ edge body domain connections
MFloat distancePointEllipsoid(const std::array< MFloat, 3 > e, const std::array< MFloat, 3 > y, std::array< MFloat, 3 > x)
Calculates the closest distance between a given point and a ellipsoid in 3D.
MFloat & a_bodyHeatFlux(const MInt bodyId)
MFloat * m_static_computeBodyProperties_Strouhal
Geom & geometry() const
Access the solver's geometry.
MFloat * m_static_computeBodyProperties_liftEndAngle2
MLong getDomainOffset()
for new restartFile format
void quaternionToEuler(const MFloat *const quaternion, MFloat *const angles)
Transform the quaternion to Euler angles.
MFloat a_bodyAccelerationOld(const MInt bodyId, const MInt dim) const
static constexpr MInt nRot
std::vector< MInt > m_globalBodyIds
MFloat a_bodyTemperatureOld(const MInt bodyId) const
MBool m_static_computeBodyProperties_first
void computeBodyPropertiesForced(MInt returnMode, MFloat *bodyData, MInt bodyId, MFloat time)
typename CartesianSolver::GridProxy GridProxy
void advanceQuaternion(const MFloat *const angularVelocity, const MFloat dt, const MFloat *const qIn, MFloat *const qOut)
Advance the rotational state by one timestep for a given angular velocity.
void initBodyData()
Allocating and initializing body data necessary for the solver run.
void exchangeKinematicData()
exchange of predictor & corrector step output
MInt getLocalBodyId(MInt globalBodyId)
void saveSolverSolution(const MBool, const MBool)
void setCellWeights(MFloat *) override
Set cell weights.
std::vector< MFloat > m_initialBodyCenters
std::vector< MFloat > m_initBodyRadii
MFloat & a_bodyAccelerationOld(const MInt bodyId, const MInt dim)
void exchangeBufferLengthsAllToRoot(std::vector< MInt > &noToRecv, const MInt noToSend)
exchange of Buffer lengths all to root
void removeChilds(const MInt) override
Coarsen the given cell.
MFloat & a_bodyTorque(const MInt bodyId, const MInt dim)
void setSensors(std::vector< std::vector< MFloat > > &, std::vector< MFloat > &, std::vector< std::bitset< 64 > > &, std::vector< MInt > &) override
set solver sensors for split adaptation within the adaptation loop
void exchangeEdgeBodyData()
exchanges relevant body connections with new neighbor domains
MFloat a_bodyVelocity(const MInt bodyId, const MInt dim) const
Status & a_status(const MInt bodyId)
MFloat & a_bodyAcceleration(const MInt bodyId, const MInt dim)
MFloat * m_static_computeBodyProperties_mu2
void totalKineticEnergy()
MFloat a_angularVelocityBodyT1B2(const MInt bodyId, const MInt dim) const
MFloat & a_bodyQuaternionT1(const MInt bodyId, const MInt dim)
std::array< MInt, Timers::_count > m_timers
void incrementHeatFlux(const MInt bodyId, MFloat heatflux)
void predictRotation(const MInt bodyId)
void updateMaxLevel(MInt newMaxLevel)
MFloat a_bodyAcceleration(const MInt bodyId, const MInt dim) const
void printScalingVariables()
MFloat currMaxLevel() const
MFloat & a_angularVelocityBodyT1B2(const MInt bodyId, const MInt dim)
MFloat a_bodyForce(const MInt bodyId, const MInt dim) const
MFloat a_bodyQuaternionT1B2(const MInt bodyId, const MInt dim) const
MBool prepareRestart(MBool writeRestart, MBool &) override
Prepare the solvers for a grid-restart.
MFloat & a_bodyRadii(const MInt bodyId, const MInt n)
void finalizeInitSolver() override
MFloat & a_bodyInertia(const MInt bodyId, const MInt dim)
void initSolver() override
MInt noRemoteDomains() const
MFloat & a_angularVelocityT1(const MInt bodyId, const MInt dim)
MFloat * m_static_computeBodyProperties_mu
MInt noConnectingBodies() const
MFloat * m_static_computeBodyProperties_liftStartAngle2
std::vector< MInt > m_indirectHomeDomains
MInt solverId() const
Return the solverId.
constexpr GridProxy & grid() const
Class that represents DG element collector.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr Real POW2(const Real x)
std::basic_string< char > MString
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)