Skip to content

Velocities

Velocities stores the per-grid-point velocity field used by any module that advects state with a flow: PhaseField::Advect, Orientations::Advect, Composition::Advect, and the fluid-dynamics sub-tree. It carries both the average velocity and per-phase velocities so modules that need a phase-resolved velocity (e.g. rigid particles in a melt) can access both.

Key Classes and Concepts

  • Velocities : public OPObject: scalar-vector storage with per-phase entries plus a global average.

Public API

cpp
void Clear(void);
void CalculateAverage(const PhaseField& Phase);
void PrescribePhaseVelocities(PhaseField& Phase);

void SetAllPhases(dVector3& value);
void SetAverage(dVector3& value);
void SetAverage(ElasticProperties& EP, double dt);   // from displacement increment

double GetMaxVelocity();
void   SetBoundaryConditions(const BoundaryConditions& BC) override;
void   Advect(BoundaryConditions& BC, double dt, ...);

void WriteVTK(Settings& locSettings, int tStep) const;
void WriteStatistics(RunTimeControl& RTC);
bool Read (const Settings& locSettings, const BoundaryConditions& BC, const int tStep) override;
bool Write(const Settings& OPSettings, const int tStep) const override;

void MoveFrame(int dx, int dy, int dz, ...);
void PrintPointStatistics(int x, int y, int z);

Note: the default Advect(AdvectionHR&, Velocities&, …) overload is hidden for Velocities (it does not advect itself).

Usage

Input

No dedicated .opi block. The velocity field is populated by:

  • an elasticity solver (Velocities::SetAverage(EP, dt) — converts the displacement increment to a velocity),
  • a fluid solver (see Fluid Dynamics),
  • direct assignment through SetAllPhases or SetAverage.

Output

  • WriteVTK — vector field per grid point.
  • WriteStatistics — CSV-style summary bound to RunTimeControl cadence.
  • Raw I/O: Read / Write for restart.

Example

cpp
#include "Velocities.h"

Velocities Vel(OPSettings, InputFile);

dVector3 v {1.0e-3, 0.0, 0.0};
Vel.SetAllPhases(v);

for(RTC.tStep = RTC.tStart; RTC.tStep <= RTC.nSteps; RTC.IncrementTimeStep())
{
    Vel.CalculateAverage(Phi);
    // ... advection steps use Vel ...
    if (RTC.WriteVTK()) Vel.WriteVTK(OPSettings, RTC.tStep);
}

Dependencies

Released under the GNU GPLv3 License.