PhaseFieldUnstructured

class PhaseFieldUnstructured : public minim::NewPotential<PhaseFieldUnstructured>

Multi-component phase field potential on an unstructured grid.

System size

int nFluid = 1

The number of fluid components.

double resolution = 1

The grid resolution.

PhaseFieldUnstructured &setNFluid(int nFluid)

Set the number of fluid components.

PhaseFieldUnstructured &setGridSize(vector<int> gridSize)

Set the size of the grid along each dimension.

PhaseFieldUnstructured &setResolution(double resolution)

Set the grid resolution.

Fluid interfaces

Order: 1-2, 1-3, …, 1-N, 2-3 (continue to (N-1)-N for N-comp).

vector<double> interfaceSize

The diffuse interface size of each fluid pair.

vector<double> surfaceTension = {1}

The surface tension of each fluid pair.

PhaseFieldUnstructured &setInterfaceSize(double interfaceSize)

Set the interface size for all fluid pairs.

PhaseFieldUnstructured &setInterfaceSize(vector<double> interfaceSize)

Set the interface size of each fluid pair.

PhaseFieldUnstructured &setSurfaceTension(double surfaceTension)

Set the surface tension for all fluid pairs.

PhaseFieldUnstructured &setSurfaceTension(vector<double> surfaceTension)

Set the surface tension of each fluid pair.

Density constraint

int densityConstraint = 0

The density constraint method: 0 for hard constraint (default).

double densityConst = 1

The strength of the soft density constraint.

PhaseFieldUnstructured &setDensityConstraint(std::string method)

Set the density constraint method (“hard” or “soft”).

Volume and pressure constraints

bool volumeFixed = false

Whether the total fluid volume is fixed.

double volConst = 0.01

The strength of the volume constraint.

vector<double> pressure

The target pressure of each fluid.

vector<double> volume

The target volume of each fluid.

PhaseFieldUnstructured &setPressure(vector<double> pressure)

Set the target pressure of each fluid.

PhaseFieldUnstructured &setVolume(vector<double> volume, double volConst = 0.01)

Set the target volume of each fluid.

PhaseFieldUnstructured &setVolumeFixed(bool volumeFixed, double volConst = 0.01)

Set whether the total fluid volume is fixed.

Solid nodes

vector<char> solid

Which grid nodes are solid.

vector<double> contactAngle

The wall contact angle of each fluid pair.

PhaseFieldUnstructured &setSolid(vector<char> solid)

Set which grid nodes are solid.

PhaseFieldUnstructured &setSolid(std::function<bool(int, int, int)> solidFn)

Set which grid nodes are solid via a function of the grid indices.

PhaseFieldUnstructured &setContactAngle(vector<double> contactAngle)

Set the wall contact angle of each fluid pair.

PhaseFieldUnstructured &setContactAngle(std::function<double(int, int, int)> contactAngleFn)

Set the wall contact angle via a function of the grid indices and fluid pair.

External force

vector<vector<double>> force

An external force applied to the fluids.

PhaseFieldUnstructured &setForce(vector<double> force, vector<int> iFluid = {})

Set an external force on the given fluid (default: all).

Diffuse solid method

PhaseFieldUnstructured &setFixFluid(int iFluid, bool fix = true)

Set whether the given fluid is fixed in place.

PhaseFieldUnstructured &setConfinement(vector<double> strength)

Set the confinement strength of each fluid.

vector<double> diffuseSolid(vector<char> solid, int iFluid = 0, bool twoStep = false)

Compute a diffuse representation of the solid, usable as initial coordinates.

static vector<double> diffuseSolid(vector<char> solid, PhaseFieldUnstructured potential, int iFluid = 0, bool twoStep = false)

Compute a diffuse representation of the solid using the given potential’s grid.

static vector<double> diffuseSolid(vector<char> solid, vector<int> gridSize, int nFluid = 2, int iFluid = 0, bool twoStep = false)

Compute a diffuse representation of the solid using the given grid.

Overrides

virtual void init(const vector<double> &coords) override

Initialise the potential with the coordinates of a new state.

virtual void initLocal(const vector<double> &coords, const Communicator &comm) override

Initialise the potential with local (distributed) data.

Take care using this, if the potential is cloned any distributed parameters will be copied as they are.

virtual void blockEnergyGradient(const vector<double> &coords, const Communicator &comm, double *e, vector<double> *g) const override

Compute the energy and gradient of the local block.

virtual void elementEnergyGradient(const vector<double> &coords, const Element &el, double *e, vector<double> *g) const override

Compute the energy and gradient of a single element.