OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Implementing Surface-directed spinodal decomposition Reply To: Implementing Surface-directed spinodal decomposition

#7206
FBukreev
Keymaster

Hello,

you can write your own analytical function that depends on the z coordinate and then define the force with that functor. Here one example.

``````template <typename T, typename S, typename DESCRIPTOR>
class PorosityProfil3D : public AnalyticalF3D<T, S>
{
private:
T x0, x1, y0, y1, z0, z1, u_p;
UnitConverter<T, DESCRIPTOR> const &converter;
int iT, tempCase;

public:
PorosityProfil3D(T x0_, T x1_, T y0_, T y1_, T z0_, T z1_, T u_p_, int iT_, int tempCase_, UnitConverter<T, DESCRIPTOR> const &converter_) : AnalyticalF3D<T, S>(3),
x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_), u_p(u_p_), iT(iT_), tempCase(tempCase_), converter(converter_)
{
this->getName() = "PorosityProfil3D";
};

bool operator()(T output[1], const S x[3])
{
T res = converter.getResolution();
T gf = res / (res + 1);
T distX = 2 * M_PI * (x[0] - tempCase * u_p * converter.getPhysTime(iT) - x0) / (x1 - x0) * gf;
T distY = 2 * M_PI * (x[1] - tempCase * u_p * converter.getPhysTime(iT) - y0) / (y1 - y0) * gf;
T distZ = 2 * M_PI * (x[2] - tempCase * u_p * converter.getPhysTime(iT) - y0) / (z1 - z0) * gf;

output[0] = 0.5 + 0.4 * util::sin(distX) * util::sin(distY) * util::sin(distZ);

return true;
};
};
``````

the x[2] is the z variable. For the force you need to change output[1] to the 3 dimensional output[3] array.

What do you mean under thermal noise? You can add advection diffusion equation for temperature scalar and couple it to the main equations.

Greetings
Fedor