From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Mon, 24 Jun 2019 14:43:36 +0200
Subject: Initialize at openlb-1-3
---
examples/multiComponent/contactAngle2d/Makefile | 105 +++++
.../contactAngle2d/contactAngle2d.cpp | 389 ++++++++++++++++++
.../multiComponent/contactAngle2d/definitions.mk | 30 ++
examples/multiComponent/contactAngle2d/module.mk | 29 ++
examples/multiComponent/contactAngle3d/Makefile | 105 +++++
.../contactAngle3d/contactAngle3d.cpp | 393 ++++++++++++++++++
.../multiComponent/contactAngle3d/definitions.mk | 30 ++
examples/multiComponent/contactAngle3d/module.mk | 29 ++
examples/multiComponent/microFluidics2d/Makefile | 105 +++++
.../multiComponent/microFluidics2d/definitions.mk | 30 ++
.../microFluidics2d/microFluidics2d.cpp | 456 +++++++++++++++++++++
examples/multiComponent/microFluidics2d/module.mk | 29 ++
examples/multiComponent/phaseSeparation2d/Makefile | 105 +++++
.../phaseSeparation2d/definitions.mk | 30 ++
.../multiComponent/phaseSeparation2d/module.mk | 29 ++
.../phaseSeparation2d/phaseSeparation2d.cpp | 216 ++++++++++
examples/multiComponent/phaseSeparation3d/Makefile | 105 +++++
.../phaseSeparation3d/definitions.mk | 30 ++
.../multiComponent/phaseSeparation3d/module.mk | 29 ++
.../phaseSeparation3d/phaseSeparation3d.cpp | 217 ++++++++++
examples/multiComponent/rayleighTaylor2d/Makefile | 105 +++++
.../multiComponent/rayleighTaylor2d/definitions.mk | 30 ++
examples/multiComponent/rayleighTaylor2d/module.mk | 29 ++
.../rayleighTaylor2d/rayleighTaylor2d.cpp | 309 ++++++++++++++
examples/multiComponent/rayleighTaylor3d/Makefile | 105 +++++
.../multiComponent/rayleighTaylor3d/definitions.mk | 30 ++
examples/multiComponent/rayleighTaylor3d/module.mk | 29 ++
.../rayleighTaylor3d/rayleighTaylor3d.cpp | 312 ++++++++++++++
examples/multiComponent/youngLaplace2d/Makefile | 105 +++++
.../multiComponent/youngLaplace2d/definitions.mk | 30 ++
examples/multiComponent/youngLaplace2d/module.mk | 29 ++
.../youngLaplace2d/youngLaplace2d.cpp | 315 ++++++++++++++
examples/multiComponent/youngLaplace3d/Makefile | 105 +++++
.../multiComponent/youngLaplace3d/definitions.mk | 30 ++
examples/multiComponent/youngLaplace3d/module.mk | 29 ++
.../youngLaplace3d/youngLaplace3d.cpp | 316 ++++++++++++++
36 files changed, 4399 insertions(+)
create mode 100644 examples/multiComponent/contactAngle2d/Makefile
create mode 100644 examples/multiComponent/contactAngle2d/contactAngle2d.cpp
create mode 100644 examples/multiComponent/contactAngle2d/definitions.mk
create mode 100644 examples/multiComponent/contactAngle2d/module.mk
create mode 100644 examples/multiComponent/contactAngle3d/Makefile
create mode 100644 examples/multiComponent/contactAngle3d/contactAngle3d.cpp
create mode 100644 examples/multiComponent/contactAngle3d/definitions.mk
create mode 100644 examples/multiComponent/contactAngle3d/module.mk
create mode 100644 examples/multiComponent/microFluidics2d/Makefile
create mode 100644 examples/multiComponent/microFluidics2d/definitions.mk
create mode 100644 examples/multiComponent/microFluidics2d/microFluidics2d.cpp
create mode 100644 examples/multiComponent/microFluidics2d/module.mk
create mode 100644 examples/multiComponent/phaseSeparation2d/Makefile
create mode 100644 examples/multiComponent/phaseSeparation2d/definitions.mk
create mode 100644 examples/multiComponent/phaseSeparation2d/module.mk
create mode 100644 examples/multiComponent/phaseSeparation2d/phaseSeparation2d.cpp
create mode 100644 examples/multiComponent/phaseSeparation3d/Makefile
create mode 100644 examples/multiComponent/phaseSeparation3d/definitions.mk
create mode 100644 examples/multiComponent/phaseSeparation3d/module.mk
create mode 100644 examples/multiComponent/phaseSeparation3d/phaseSeparation3d.cpp
create mode 100644 examples/multiComponent/rayleighTaylor2d/Makefile
create mode 100644 examples/multiComponent/rayleighTaylor2d/definitions.mk
create mode 100644 examples/multiComponent/rayleighTaylor2d/module.mk
create mode 100644 examples/multiComponent/rayleighTaylor2d/rayleighTaylor2d.cpp
create mode 100644 examples/multiComponent/rayleighTaylor3d/Makefile
create mode 100644 examples/multiComponent/rayleighTaylor3d/definitions.mk
create mode 100644 examples/multiComponent/rayleighTaylor3d/module.mk
create mode 100644 examples/multiComponent/rayleighTaylor3d/rayleighTaylor3d.cpp
create mode 100644 examples/multiComponent/youngLaplace2d/Makefile
create mode 100644 examples/multiComponent/youngLaplace2d/definitions.mk
create mode 100644 examples/multiComponent/youngLaplace2d/module.mk
create mode 100644 examples/multiComponent/youngLaplace2d/youngLaplace2d.cpp
create mode 100644 examples/multiComponent/youngLaplace3d/Makefile
create mode 100644 examples/multiComponent/youngLaplace3d/definitions.mk
create mode 100644 examples/multiComponent/youngLaplace3d/module.mk
create mode 100644 examples/multiComponent/youngLaplace3d/youngLaplace3d.cpp
(limited to 'examples/multiComponent')
diff --git a/examples/multiComponent/contactAngle2d/Makefile b/examples/multiComponent/contactAngle2d/Makefile
new file mode 100644
index 0000000..a953954
--- /dev/null
+++ b/examples/multiComponent/contactAngle2d/Makefile
@@ -0,0 +1,105 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+###########################################################################
+## definitions
+
+include definitions.mk
+
+include $(ROOT)/global.mk
+
+OBJECTS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.o))
+DEPS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.d))
+
+###########################################################################
+## all
+
+all : depend compile link
+
+
+###########################################################################
+## dependencies
+
+depend : $(DEPS)
+
+$(PWD)/%.d : %.cpp
+ @echo Create dependencies for $<
+ @$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(IDIR) $< \
+ | sed -e "s!$*\.o!$(PWD)\/$*\.o!1" > .tmpfile; \
+ cp -f .tmpfile $@;'
+
+###########################################################################
+## compile
+
+compile : $(OBJECTS)
+
+$(PWD)/%.o: %.cpp
+ @echo Compile $<
+ $(CXX) $(CXXFLAGS) $(IDIR) -c $< -o $@
+
+###########################################################################
+## clean
+
+clean : cleanrub cleanobj cleandep
+
+cleanrub:
+ @echo Clean rubbish files
+ @rm -f *~ core .tmpfile tmp/*.* $(OUTPUT)
+ @rm -f tmp/vtkData/*.* tmp/vtkData/data/*.* tmp/imageData/*.* tmp/gnuplotData/*.* tmp/gnuplotData/data/*.*
+
+cleanobj:
+ @echo Clean object files
+ @rm -f $(OBJECTS)
+
+cleandep:
+ @echo Clean dependencies files
+ @rm -f $(DEPS)
+
+cleanbuild:
+ @cd $(ROOT); \
+ $(MAKE) cleanlib;
+
+###########################################################################
+## update lib
+
+$(ROOT)/$(LIBDIR)/lib$(LIB).a :
+ @cd $(ROOT); \
+ $(MAKE) all
+
+###########################################################################
+## link
+
+link: $(OUTPUT)
+
+$(OUTPUT): $(OBJECTS) $(ROOT)/$(LIBDIR)/lib$(LIB).a
+ @echo Link $@
+ $(CXX) $(foreach file, $(SRC), $(file:.cpp=.o)) $(LDFLAGS) -L$(ROOT)/$(LIBDIR) -l$(LIB) -lz -o $@
+
+###########################################################################
+## include dependencies
+
+ifneq "$(strip $(wildcard *.d))" ""
+ include $(foreach file,$(DEPS),$(file))
+endif
+
+###########################################################################
+###########################################################################
diff --git a/examples/multiComponent/contactAngle2d/contactAngle2d.cpp b/examples/multiComponent/contactAngle2d/contactAngle2d.cpp
new file mode 100644
index 0000000..5726b65
--- /dev/null
+++ b/examples/multiComponent/contactAngle2d/contactAngle2d.cpp
@@ -0,0 +1,389 @@
+/* Lattice Boltzmann sample, written in C++, using the OpenLB
+ * library
+ *
+ * Copyright (C) 2019 Sam Avis
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* contactAngle2d.cpp
+ * In this example a semi-circular droplet of fluid is initialised
+ * within a different fluid at a solid boundary. The contact angle
+ * is measured as the droplet comes to equilibrium. This is compared
+ * with the analytical angle (100 degrees) predicted by the
+ * parameters set for the boundary.
+ *
+ * This example demonstrates how to use the wetting solid boundaries
+ * for the free-energy model with two fluid components.
+ */
+
+#include "olb2D.h"
+#include "olb2D.hh" // use only generic version!
+#include
+#include
+#include
+#include
+
+using namespace olb;
+using namespace olb::descriptors;
+using namespace olb::graphics;
+using namespace std;
+
+typedef double T;
+#define DESCRIPTOR D2Q9
+
+// Parameters for the simulation setup
+const int N = 75;
+const T nx = 75.;
+const T ny = 50.;
+const T radius = 0.25 * nx;
+
+const T alpha = 1.; // Interfacial width [lattice units]
+const T kappa1 = 0.005; // For surface tensions [lattice units]
+const T kappa2 = 0.005; // For surface tensions [lattice units]
+const T gama = 10.; // For mobility of interface [lattice units]
+const T h1 = 0.0001448; // Contact angle 100 degrees [lattice units]
+const T h2 = -0.0001448; // Contact angle 100 degrees [lattice units]
+
+const int maxIter = 70000;
+const int vtkIter = 1000;
+const int statIter = 1000;
+const bool calcAngle = true;
+
+T angle_prev = 90.;
+
+
+void prepareGeometry( SuperGeometry2D& superGeometry,
+ UnitConverter& converter) {
+
+ OstreamManager clout( std::cout,"prepareGeometry" );
+ clout << "Prepare Geometry ..." << std::endl;
+
+ superGeometry.rename( 0,2 );
+
+ Vector extend(nx+2., ny-1.*converter.getPhysDeltaX() );
+ Vector origin( -1., 0.5*converter.getPhysDeltaX() );
+ IndicatorCuboid2D inner ( extend, origin );
+ superGeometry.rename( 2,1,inner );
+
+ superGeometry.innerClean();
+ superGeometry.checkForErrors();
+ superGeometry.print();
+
+ clout << "Prepare Geometry ... OK" << std::endl;
+}
+
+
+void prepareLattice( SuperLattice2D& sLattice1,
+ SuperLattice2D& sLattice2,
+ Dynamics& bulkDynamics1,
+ Dynamics& bulkDynamics2,
+ UnitConverter& converter,
+ SuperGeometry2D& superGeometry,
+ sOnLatticeBoundaryCondition2D& sOnBC1,
+ sOnLatticeBoundaryCondition2D& sOnBC2 ) {
+
+ OstreamManager clout( std::cout,"prepareLattice" );
+ clout << "Prepare Lattice ..." << std::endl;
+
+ // Define lattice Dynamics
+ sLattice1.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice1.defineDynamics( superGeometry, 1, &bulkDynamics1 );
+ sLattice2.defineDynamics( superGeometry, 1, &bulkDynamics2 );
+ sLattice1.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+
+ // Add wall boundary
+ sOnBC1.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, h1, h2, 1 );
+ sOnBC2.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, h1, h2, 2 );
+
+ // Bulk initial conditions
+ // Define circular domain for fluid 2
+ std::vector v( 2,T() );
+ AnalyticalConst2D zeroVelocity( v );
+
+ AnalyticalConst2D one( 1.0 );
+ SmoothIndicatorCircle2D circle( {nx/2., 0.}, radius, 10.*alpha );
+
+ AnalyticalIdentity2D rho( one );
+ AnalyticalIdentity2D phi( one - circle - circle );
+
+ sLattice1.iniEquilibrium( superGeometry, 1, rho, zeroVelocity );
+ sLattice2.iniEquilibrium( superGeometry, 1, phi, zeroVelocity );
+
+ sLattice1.iniEquilibrium( superGeometry, 2, rho, zeroVelocity );
+ sLattice2.iniEquilibrium( superGeometry, 2, phi, zeroVelocity );
+
+ sLattice1.initialize();
+ sLattice2.initialize();
+
+ sLattice1.communicate();
+ sLattice2.communicate();
+
+ clout << "Prepare Lattice ... OK" << std::endl;
+}
+
+
+void prepareCoupling( SuperLattice2D& sLattice1,
+ SuperLattice2D& sLattice2,
+ SuperGeometry2D& superGeometry ) {
+
+ OstreamManager clout( std::cout,"prepareCoupling" );
+ clout << "Add lattice coupling" << endl;
+
+ // Add the lattice couplings (not to the solid nodes)
+ // The chemical potential coupling must come before the force coupling
+ FreeEnergyChemicalPotentialGenerator2D coupling1(
+ alpha, kappa1, kappa2);
+ FreeEnergyForceGenerator2D coupling2;
+
+ sLattice1.addLatticeCoupling( superGeometry, 1, coupling1, sLattice2 );
+ sLattice2.addLatticeCoupling( superGeometry, 1, coupling2, sLattice1 );
+
+ clout << "Add lattice coupling ... OK!" << endl;
+}
+
+
+void getResults( SuperLattice2D& sLattice1,
+ SuperLattice2D& sLattice2, int iT,
+ SuperGeometry2D& superGeometry, Timer& timer,
+ UnitConverter converter ) {
+
+ OstreamManager clout( std::cout,"getResults" );
+ SuperVTMwriter2D vtmWriter( "contactAngle2d" );
+
+ if ( iT==0 ) {
+ // Writes the geometry, cuboid no. and rank no. as vti file for visualization
+ SuperLatticeGeometry2D geometry( sLattice1, superGeometry );
+ SuperLatticeCuboid2D cuboid( sLattice1 );
+ SuperLatticeRank2D rank( sLattice1 );
+ vtmWriter.write( geometry );
+ vtmWriter.write( cuboid );
+ vtmWriter.write( rank );
+ vtmWriter.createMasterFile();
+ }
+
+ // Get statistics
+ if ( iT%statIter==0 ) {
+ // Timer console output
+ timer.update( iT );
+ timer.printStep();
+ sLattice1.getStatistics().print( iT, converter.getPhysTime(iT) );
+ sLattice2.getStatistics().print( iT, converter.getPhysTime(iT) );
+ }
+
+ // Writes the VTK files
+ if ( iT%vtkIter==0 ) {
+ AnalyticalConst2D half_( 0.5 );
+ SuperLatticeFfromAnalyticalF2D half(half_, sLattice1);
+
+ SuperLatticeVelocity2D velocity( sLattice1 );
+ SuperLatticeDensity2D rho( sLattice1 );
+ rho.getName() = "rho";
+ SuperLatticeDensity2D phi( sLattice2 );
+ phi.getName() = "phi";
+
+ SuperIdentity2D c1 (half*(rho+phi));
+ c1.getName() = "density-fluid-1";
+ SuperIdentity2D c2 (half*(rho-phi));
+ c2.getName() = "density-fluid-2";
+
+ vtmWriter.addFunctor( velocity );
+ vtmWriter.addFunctor( rho );
+ vtmWriter.addFunctor( phi );
+ vtmWriter.addFunctor( c1 );
+ vtmWriter.addFunctor( c2 );
+ vtmWriter.write( iT );
+
+ // Evaluation of contact angle
+ if (calcAngle) {
+ int Ny = (int)( N * ny / nx );
+ T dx = converter.getPhysDeltaX();
+ AnalyticalFfromSuperF2D interpolPhi( phi, true, 1 );
+
+ T base1 = 0.;
+ T base2 = 0.;
+ T height1 = 0.;
+ T height2 = 0.;
+
+ double pos[2] = {0., dx};
+ for(int ix=0; ix 0.) {
+ pos[1] = (iy-1) * dx;
+ interpolPhi( &phi2, pos );
+ height1 = iy - 1. - phi1/(phi1-phi2);
+ height2 = iy - 3. - phi1/(phi1-phi2);
+ break;
+ }
+ }
+
+ // Calculate simulated contact angle
+ T pi = 3.14159265;
+ T height = height1 + 1.;
+ T base = base1 + 2 * (radius - height1) / base1;
+ T radius = (4.*height2*height2 + base2*base2) / ( 8.*height2 );
+ T angle_rad = pi + atan( 0.5*base / (radius - height) );
+ T angle = angle_rad * 180. / pi;
+ if ( angle > 180. ) angle -= 180.;
+
+ // Calculate theoretical contact angle
+ T ak1 = alpha * kappa1;
+ T ak2 = alpha * kappa2;
+ T k12 = kappa1 + kappa2;
+ T num1 = pow(ak1 + 4 * h1, 1.5) - pow(ak1 - 4 * h1, 1.5);
+ T num2 = pow(ak2 + 4 * h2, 1.5) - pow(ak2 - 4 * h2, 1.5);
+ T angle_an = 180 / pi * acos(num2 / (2 * k12 * sqrt(ak2)) - \
+ num1 / (2 * k12 * sqrt(ak1)));
+
+ clout << "----->>>>> Contact angle: " << angle << " ; ";
+ clout << "Analytical contact angle: " << angle_an << std::endl;
+ clout << "----->>>>> Difference to previous: " << angle-angle_prev << std::endl;
+ angle_prev = angle;
+ }
+ }
+}
+
+
+int main( int argc, char *argv[] ) {
+
+ // === 1st Step: Initialization ===
+
+ olbInit( &argc, &argv );
+ singleton::directories().setOutputDir( "./tmp/" );
+ OstreamManager clout( std::cout,"main" );
+
+ UnitConverterFromResolutionAndRelaxationTime converter(
+ (T) N, // resolution
+ (T) 1., // lattice relaxation time (tau)
+ (T) nx, // charPhysLength: reference length of simulation geometry
+ (T) 0.0001, // charPhysVelocity: maximal/highest expected velocity during simulation in __m / s__
+ (T) 1.002e-8, // physViscosity: physical kinematic viscosity in __m^2 / s__
+ (T) 1. // physDensity: physical density in __kg / m^3__
+ );
+
+ // Prints the converter log as console output
+ converter.print();
+
+ // === 2nd Step: Prepare Geometry ===
+ std::vector extend = { nx, ny };
+ std::vector origin = { 0., 0. };
+ IndicatorCuboid2D cuboid(extend,origin);
+#ifdef PARALLEL_MODE_MPI
+ CuboidGeometry2D cGeometry( cuboid, converter.getPhysDeltaX(), singleton::mpi().getSize() );
+#else
+ CuboidGeometry2D cGeometry( cuboid, converter.getPhysDeltaX() );
+#endif
+
+ // Set periodic boundaries to the domain
+ cGeometry.setPeriodicity( true, false );
+
+ // Instantiation of loadbalancer
+ HeuristicLoadBalancer loadBalancer( cGeometry );
+ loadBalancer.print();
+
+ // Instantiation of superGeometry
+ SuperGeometry2D superGeometry( cGeometry,loadBalancer );
+
+ prepareGeometry( superGeometry, converter );
+
+ // === 3rd Step: Prepare Lattice ===
+ SuperLattice2D sLattice1( superGeometry );
+ SuperLattice2D sLattice2( superGeometry );
+
+ ForcedBGKdynamics bulkDynamics1 (
+ converter.getLatticeRelaxationFrequency(),
+ instances::getBulkMomenta() );
+
+ FreeEnergyBGKdynamics bulkDynamics2 (
+ converter.getLatticeRelaxationFrequency(), gama,
+ instances::getBulkMomenta() );
+
+ sOnLatticeBoundaryCondition2D sOnBC1( sLattice1 );
+ sOnLatticeBoundaryCondition2D sOnBC2( sLattice2 );
+ createLocalBoundaryCondition2D (sOnBC1);
+ createLocalBoundaryCondition2D (sOnBC2);
+
+ prepareLattice( sLattice1, sLattice2, bulkDynamics1, bulkDynamics2,
+ converter, superGeometry, sOnBC1, sOnBC2 );
+
+ prepareCoupling( sLattice1, sLattice2, superGeometry);
+
+ SuperExternal2D sExternal1 (superGeometry, sLattice1, sLattice1.getOverlap() );
+ SuperExternal2D sExternal2 (superGeometry, sLattice2, sLattice2.getOverlap() );
+
+ // === 4th Step: Main Loop with Timer ===
+ int iT = 0;
+ clout << "starting simulation..." << endl;
+ Timer timer( maxIter, superGeometry.getStatistics().getNvoxel() );
+ timer.start();
+
+ for ( iT=0; iT<=maxIter; ++iT ) {
+ // Computation and output of the results
+ getResults( sLattice1, sLattice2, iT, superGeometry, timer, converter );
+
+ // Collide and stream execution
+ sLattice1.collideAndStream();
+ sLattice2.collideAndStream();
+
+ // MPI communication for lattice data
+ sLattice1.communicate();
+ sLattice2.communicate();
+
+ // Execute coupling between the two lattices
+ sLattice1.executeCoupling();
+ sExternal1.communicate();
+ sExternal2.communicate();
+ sLattice2.executeCoupling();
+ }
+
+ timer.stop();
+ timer.printSummary();
+
+}
+
diff --git a/examples/multiComponent/contactAngle2d/definitions.mk b/examples/multiComponent/contactAngle2d/definitions.mk
new file mode 100644
index 0000000..57bdd14
--- /dev/null
+++ b/examples/multiComponent/contactAngle2d/definitions.mk
@@ -0,0 +1,30 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+
+###########################################################################
+###########################################################################
+## DEFINITIONS TO BE CHANGED
+
+ROOT := ../../..
+SRC := contactAngle2d.cpp
+OUTPUT := contactAngle2d
diff --git a/examples/multiComponent/contactAngle2d/module.mk b/examples/multiComponent/contactAngle2d/module.mk
new file mode 100644
index 0000000..1190482
--- /dev/null
+++ b/examples/multiComponent/contactAngle2d/module.mk
@@ -0,0 +1,29 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2017 Markus Mohrhard
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+current_dir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+
+include global.mk
+include rules.mk
+include $(addsuffix definitions.mk, $(current_dir))
+
+$(eval $(call sample,$(current_dir)$(OUTPUT),$(addprefix $(current_dir), $(SRC))))
diff --git a/examples/multiComponent/contactAngle3d/Makefile b/examples/multiComponent/contactAngle3d/Makefile
new file mode 100644
index 0000000..a953954
--- /dev/null
+++ b/examples/multiComponent/contactAngle3d/Makefile
@@ -0,0 +1,105 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+###########################################################################
+## definitions
+
+include definitions.mk
+
+include $(ROOT)/global.mk
+
+OBJECTS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.o))
+DEPS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.d))
+
+###########################################################################
+## all
+
+all : depend compile link
+
+
+###########################################################################
+## dependencies
+
+depend : $(DEPS)
+
+$(PWD)/%.d : %.cpp
+ @echo Create dependencies for $<
+ @$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(IDIR) $< \
+ | sed -e "s!$*\.o!$(PWD)\/$*\.o!1" > .tmpfile; \
+ cp -f .tmpfile $@;'
+
+###########################################################################
+## compile
+
+compile : $(OBJECTS)
+
+$(PWD)/%.o: %.cpp
+ @echo Compile $<
+ $(CXX) $(CXXFLAGS) $(IDIR) -c $< -o $@
+
+###########################################################################
+## clean
+
+clean : cleanrub cleanobj cleandep
+
+cleanrub:
+ @echo Clean rubbish files
+ @rm -f *~ core .tmpfile tmp/*.* $(OUTPUT)
+ @rm -f tmp/vtkData/*.* tmp/vtkData/data/*.* tmp/imageData/*.* tmp/gnuplotData/*.* tmp/gnuplotData/data/*.*
+
+cleanobj:
+ @echo Clean object files
+ @rm -f $(OBJECTS)
+
+cleandep:
+ @echo Clean dependencies files
+ @rm -f $(DEPS)
+
+cleanbuild:
+ @cd $(ROOT); \
+ $(MAKE) cleanlib;
+
+###########################################################################
+## update lib
+
+$(ROOT)/$(LIBDIR)/lib$(LIB).a :
+ @cd $(ROOT); \
+ $(MAKE) all
+
+###########################################################################
+## link
+
+link: $(OUTPUT)
+
+$(OUTPUT): $(OBJECTS) $(ROOT)/$(LIBDIR)/lib$(LIB).a
+ @echo Link $@
+ $(CXX) $(foreach file, $(SRC), $(file:.cpp=.o)) $(LDFLAGS) -L$(ROOT)/$(LIBDIR) -l$(LIB) -lz -o $@
+
+###########################################################################
+## include dependencies
+
+ifneq "$(strip $(wildcard *.d))" ""
+ include $(foreach file,$(DEPS),$(file))
+endif
+
+###########################################################################
+###########################################################################
diff --git a/examples/multiComponent/contactAngle3d/contactAngle3d.cpp b/examples/multiComponent/contactAngle3d/contactAngle3d.cpp
new file mode 100644
index 0000000..9f08d4e
--- /dev/null
+++ b/examples/multiComponent/contactAngle3d/contactAngle3d.cpp
@@ -0,0 +1,393 @@
+/* Lattice Boltzmann sample, written in C++, using the OpenLB
+ * library
+ *
+ * Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* contactAngle3d.cpp
+ * In this example a semi-spherical droplet of fluid is initialised
+ * within a different fluid at a solid boundary. The contact angle
+ * is measured as the droplet comes to equilibrium. This is compared
+ * with the analytical angle (100 degrees) predicted by the
+ * parameters set for the boundary.
+ *
+ * This example demonstrates how to use the wetting solid boundaries
+ * for the free-energy model with two fluid components.
+ */
+
+#include "olb3D.h"
+#include "olb3D.hh" // use only generic version!
+#include
+#include
+#include
+#include
+
+using namespace olb;
+using namespace olb::descriptors;
+using namespace olb::graphics;
+using namespace std;
+
+typedef double T;
+#define DESCRIPTOR D3Q19
+
+// Parameters for the simulation setup
+const int N = 75;
+const T nxy = 75.;
+const T nz = 50.;
+const T radius = 0.25 * nxy;
+
+const T alpha = 1.; // Interfacial width [lattice units]
+const T kappa1 = 0.005; // For surface tensions [lattice units]
+const T kappa2 = 0.005; // For surface tensions [lattice units]
+const T gama = 10.; // For mobility of interface [lattice units]
+const T h1 = 0.0001448; // Contact angle 80 degrees [lattice units]
+const T h2 = -0.0001448; // Contact angle 100 degrees [lattice units]
+
+const int maxIter = 70000;
+const int vtkIter = 200;
+const int statIter = 200;
+const bool calcAngle = true;
+
+T angle_prev = 90.;
+
+
+void prepareGeometry( SuperGeometry3D& superGeometry,
+ UnitConverter& converter) {
+
+ OstreamManager clout( std::cout,"prepareGeometry" );
+ clout << "Prepare Geometry ..." << std::endl;
+
+ superGeometry.rename( 0,2 );
+
+ Vector extend(nxy+2., nxy+2., nz-1.*converter.getPhysDeltaX() );
+ Vector origin( -1., -1., 0.5*converter.getPhysDeltaX() );
+ IndicatorCuboid3D inner ( extend, origin );
+ superGeometry.rename( 2,1,inner );
+
+ superGeometry.innerClean();
+ superGeometry.checkForErrors();
+ superGeometry.print();
+
+ clout << "Prepare Geometry ... OK" << std::endl;
+}
+
+
+void prepareLattice( SuperLattice3D& sLattice1,
+ SuperLattice3D& sLattice2,
+ Dynamics& bulkDynamics1,
+ Dynamics& bulkDynamics2,
+ UnitConverter& converter,
+ SuperGeometry3D& superGeometry,
+ sOnLatticeBoundaryCondition3D& sOnBC1,
+ sOnLatticeBoundaryCondition3D& sOnBC2 ) {
+
+ OstreamManager clout( std::cout,"prepareLattice" );
+ clout << "Prepare Lattice ..." << std::endl;
+
+ // Define lattice Dynamics
+ sLattice1.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice1.defineDynamics( superGeometry, 1, &bulkDynamics1 );
+ sLattice2.defineDynamics( superGeometry, 1, &bulkDynamics2 );
+ sLattice1.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+
+ // Add wall boundary
+ sOnBC1.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, h1, h2, 1 );
+ sOnBC2.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, h1, h2, 2 );
+
+ // Bulk initial conditions
+ // Define spherical domain for fluid 2
+ std::vector v( 3,T() );
+ AnalyticalConst3D zeroVelocity( v );
+
+ AnalyticalConst3D one( 1.0 );
+ SmoothIndicatorSphere3D sphere( {nxy/2., nxy/2., 0.}, radius, 10.*alpha );
+
+ AnalyticalIdentity3D rho( one );
+ AnalyticalIdentity3D phi( one - sphere - sphere );
+
+ sLattice1.iniEquilibrium( superGeometry, 1, rho, zeroVelocity );
+ sLattice2.iniEquilibrium( superGeometry, 1, phi, zeroVelocity );
+
+ sLattice1.iniEquilibrium( superGeometry, 2, rho, zeroVelocity );
+ sLattice2.iniEquilibrium( superGeometry, 2, phi, zeroVelocity );
+
+ sLattice1.initialize();
+ sLattice2.initialize();
+
+ sLattice1.communicate();
+ sLattice2.communicate();
+
+ clout << "Prepare Lattice ... OK" << std::endl;
+}
+
+
+void prepareCoupling( SuperLattice3D& sLattice1,
+ SuperLattice3D& sLattice2,
+ SuperGeometry3D& superGeometry ) {
+
+ OstreamManager clout( std::cout,"prepareCoupling" );
+ clout << "Add lattice coupling" << endl;
+
+ // Add the lattice couplings (not to the solid nodes)
+ // The chemical potential coupling must come before the force coupling
+ FreeEnergyChemicalPotentialGenerator3D coupling1(
+ alpha, kappa1, kappa2);
+ FreeEnergyForceGenerator3D coupling2;
+
+ // Suppress compiler warnings
+ coupling1.shift(0, 0, 0);
+ coupling2.shift(0, 0, 0);
+
+ sLattice1.addLatticeCoupling( superGeometry, 1, coupling1, sLattice2 );
+ sLattice2.addLatticeCoupling( superGeometry, 1, coupling2, sLattice1 );
+
+ clout << "Add lattice coupling ... OK!" << endl;
+}
+
+
+void getResults( SuperLattice3D& sLattice1,
+ SuperLattice3D& sLattice2, int iT,
+ SuperGeometry3D& superGeometry, Timer& timer,
+ UnitConverter converter ) {
+
+ OstreamManager clout( std::cout,"getResults" );
+ SuperVTMwriter3D vtmWriter( "contactAngle3d" );
+
+ if ( iT==0 ) {
+ // Writes the geometry, cuboid no. and rank no. as vti file for visualization
+ SuperLatticeGeometry3D geometry( sLattice1, superGeometry );
+ SuperLatticeCuboid3D cuboid( sLattice1 );
+ SuperLatticeRank3D rank( sLattice1 );
+ vtmWriter.write( geometry );
+ vtmWriter.write( cuboid );
+ vtmWriter.write( rank );
+ vtmWriter.createMasterFile();
+ }
+
+ // Get statistics
+ if ( iT%statIter==0 ) {
+ // Timer console output
+ timer.update( iT );
+ timer.printStep();
+ sLattice1.getStatistics().print( iT, converter.getPhysTime(iT) );
+ sLattice2.getStatistics().print( iT, converter.getPhysTime(iT) );
+ }
+
+ // Writes the VTK files
+ if ( iT%vtkIter==0 ) {
+ AnalyticalConst3D half_( 0.5 );
+ SuperLatticeFfromAnalyticalF3D half(half_, sLattice1);
+
+ SuperLatticeVelocity3D velocity( sLattice1 );
+ SuperLatticeDensity3D rho( sLattice1 );
+ rho.getName() = "rho";
+ SuperLatticeDensity3D phi( sLattice2 );
+ phi.getName() = "phi";
+
+ SuperIdentity3D c1 (half*(rho+phi));
+ c1.getName() = "density-fluid-1";
+ SuperIdentity3D c2 (half*(rho-phi));
+ c2.getName() = "density-fluid-2";
+
+ vtmWriter.addFunctor( velocity );
+ vtmWriter.addFunctor( rho );
+ vtmWriter.addFunctor( phi );
+ vtmWriter.addFunctor( c1 );
+ vtmWriter.addFunctor( c2 );
+ vtmWriter.write( iT );
+
+ // Evaluation of contact angle
+ if (calcAngle) {
+ int Nz = (int)( N * nz / nxy );
+ T dx = converter.getPhysDeltaX();
+ AnalyticalFfromSuperF3D interpolPhi( phi, true, 1 );
+
+ T base1 = 0.;
+ T base2 = 0.;
+ T height1 = 0.;
+ T height2 = 0.;
+
+ double pos[3] = {0., nxy/2., dx};
+ for(int ix=0; ix 0.) {
+ pos[2] = (iz-1) * dx;
+ interpolPhi( &phi2, pos );
+ height1 = iz - 1. - phi1/(phi1-phi2);
+ height2 = iz - 3. - phi1/(phi1-phi2);
+ break;
+ }
+ }
+
+ // Calculate simulated contact angle
+ T pi = 3.14159265;
+ T height = height1 + 1.;
+ T base = base1 + 2 * (radius - height1) / base1;
+ T radius = (4.*height2*height2 + base2*base2) / ( 8.*height2 );
+ T angle_rad = pi + atan( 0.5*base / (radius - height) );
+ T angle = angle_rad * 180. / pi;
+ if ( angle > 180. ) angle -= 180.;
+
+ // Calculate theoretical contact angle
+ T ak1 = alpha * kappa1;
+ T ak2 = alpha * kappa2;
+ T k12 = kappa1 + kappa2;
+ T num1 = pow(ak1 + 4 * h1, 1.5) - pow(ak1 - 4 * h1, 1.5);
+ T num2 = pow(ak2 + 4 * h2, 1.5) - pow(ak2 - 4 * h2, 1.5);
+ T angle_an = 180 / pi * acos(num2 / (2 * k12 * sqrt(ak2)) - \
+ num1 / (2 * k12 * sqrt(ak1)));
+
+ clout << "----->>>>> Contact angle: " << angle << " ; ";
+ clout << "Analytical contact angle: " << angle_an << std::endl;
+ clout << "----->>>>> Difference to previous: " << angle-angle_prev << std::endl;
+ angle_prev = angle;
+ }
+ }
+}
+
+
+int main( int argc, char *argv[] ) {
+
+ // === 1st Step: Initialization ===
+
+ olbInit( &argc, &argv );
+ singleton::directories().setOutputDir( "./tmp/" );
+ OstreamManager clout( std::cout,"main" );
+
+ UnitConverterFromResolutionAndRelaxationTime converter(
+ (T) N, // resolution
+ (T) 1., // lattice relaxation time (tau)
+ (T) nxy, // charPhysLength: reference length of simulation geometry
+ (T) 0.0001, // charPhysVelocity: maximal/highest expected velocity during simulation in __m / s__
+ (T) 1.002e-8, // physViscosity: physical kinematic viscosity in __m^2 / s__
+ (T) 1. // physDensity: physical density in __kg / m^3__
+ );
+
+ // Prints the converter log as console output
+ converter.print();
+
+ // === 2nd Step: Prepare Geometry ===
+ std::vector extend = { nxy, nxy, nz };
+ std::vector origin = { 0., 0., 0. };
+ IndicatorCuboid3D cuboid(extend,origin);
+#ifdef PARALLEL_MODE_MPI
+ CuboidGeometry3D cGeometry( cuboid, converter.getPhysDeltaX(), singleton::mpi().getSize() );
+#else
+ CuboidGeometry3D cGeometry( cuboid, converter.getPhysDeltaX() );
+#endif
+
+ // Set periodic boundaries to the domain
+ cGeometry.setPeriodicity( true, true, false );
+
+ // Instantiation of loadbalancer
+ HeuristicLoadBalancer loadBalancer( cGeometry );
+ loadBalancer.print();
+
+ // Instantiation of superGeometry
+ SuperGeometry3D superGeometry( cGeometry,loadBalancer );
+
+ prepareGeometry( superGeometry, converter );
+
+ // === 3rd Step: Prepare Lattice ===
+ SuperLattice3D sLattice1( superGeometry );
+ SuperLattice3D sLattice2( superGeometry );
+
+ ForcedBGKdynamics bulkDynamics1 (
+ converter.getLatticeRelaxationFrequency(),
+ instances::getBulkMomenta() );
+
+ FreeEnergyBGKdynamics bulkDynamics2 (
+ converter.getLatticeRelaxationFrequency(), gama,
+ instances::getBulkMomenta() );
+
+ sOnLatticeBoundaryCondition3D sOnBC1( sLattice1 );
+ sOnLatticeBoundaryCondition3D sOnBC2( sLattice2 );
+ createLocalBoundaryCondition3D (sOnBC1);
+ createLocalBoundaryCondition3D (sOnBC2);
+
+ prepareLattice( sLattice1, sLattice2, bulkDynamics1, bulkDynamics2,
+ converter, superGeometry, sOnBC1, sOnBC2 );
+
+ prepareCoupling( sLattice1, sLattice2, superGeometry);
+
+ SuperExternal3D sExternal1 (superGeometry, sLattice1, sLattice1.getOverlap() );
+ SuperExternal3D sExternal2 (superGeometry, sLattice2, sLattice2.getOverlap() );
+
+ // === 4th Step: Main Loop with Timer ===
+ int iT = 0;
+ clout << "starting simulation..." << endl;
+ Timer timer( maxIter, superGeometry.getStatistics().getNvoxel() );
+ timer.start();
+
+ for ( iT=0; iT<=maxIter; ++iT ) {
+ // Computation and output of the results
+ getResults( sLattice1, sLattice2, iT, superGeometry, timer, converter );
+
+ // Collide and stream execution
+ sLattice1.collideAndStream();
+ sLattice2.collideAndStream();
+
+ // MPI communication for lattice data
+ sLattice1.communicate();
+ sLattice2.communicate();
+
+ // Execute coupling between the two lattices
+ sLattice1.executeCoupling();
+ sExternal1.communicate();
+ sExternal2.communicate();
+ sLattice2.executeCoupling();
+ }
+
+ timer.stop();
+ timer.printSummary();
+
+}
+
diff --git a/examples/multiComponent/contactAngle3d/definitions.mk b/examples/multiComponent/contactAngle3d/definitions.mk
new file mode 100644
index 0000000..478fb07
--- /dev/null
+++ b/examples/multiComponent/contactAngle3d/definitions.mk
@@ -0,0 +1,30 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+
+###########################################################################
+###########################################################################
+## DEFINITIONS TO BE CHANGED
+
+ROOT := ../../..
+SRC := contactAngle3d.cpp
+OUTPUT := contactAngle3d
diff --git a/examples/multiComponent/contactAngle3d/module.mk b/examples/multiComponent/contactAngle3d/module.mk
new file mode 100644
index 0000000..1190482
--- /dev/null
+++ b/examples/multiComponent/contactAngle3d/module.mk
@@ -0,0 +1,29 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2017 Markus Mohrhard
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+current_dir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+
+include global.mk
+include rules.mk
+include $(addsuffix definitions.mk, $(current_dir))
+
+$(eval $(call sample,$(current_dir)$(OUTPUT),$(addprefix $(current_dir), $(SRC))))
diff --git a/examples/multiComponent/microFluidics2d/Makefile b/examples/multiComponent/microFluidics2d/Makefile
new file mode 100644
index 0000000..a953954
--- /dev/null
+++ b/examples/multiComponent/microFluidics2d/Makefile
@@ -0,0 +1,105 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+###########################################################################
+## definitions
+
+include definitions.mk
+
+include $(ROOT)/global.mk
+
+OBJECTS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.o))
+DEPS := $(foreach file, $(SRC), $(PWD)/$(file:.cpp=.d))
+
+###########################################################################
+## all
+
+all : depend compile link
+
+
+###########################################################################
+## dependencies
+
+depend : $(DEPS)
+
+$(PWD)/%.d : %.cpp
+ @echo Create dependencies for $<
+ @$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(IDIR) $< \
+ | sed -e "s!$*\.o!$(PWD)\/$*\.o!1" > .tmpfile; \
+ cp -f .tmpfile $@;'
+
+###########################################################################
+## compile
+
+compile : $(OBJECTS)
+
+$(PWD)/%.o: %.cpp
+ @echo Compile $<
+ $(CXX) $(CXXFLAGS) $(IDIR) -c $< -o $@
+
+###########################################################################
+## clean
+
+clean : cleanrub cleanobj cleandep
+
+cleanrub:
+ @echo Clean rubbish files
+ @rm -f *~ core .tmpfile tmp/*.* $(OUTPUT)
+ @rm -f tmp/vtkData/*.* tmp/vtkData/data/*.* tmp/imageData/*.* tmp/gnuplotData/*.* tmp/gnuplotData/data/*.*
+
+cleanobj:
+ @echo Clean object files
+ @rm -f $(OBJECTS)
+
+cleandep:
+ @echo Clean dependencies files
+ @rm -f $(DEPS)
+
+cleanbuild:
+ @cd $(ROOT); \
+ $(MAKE) cleanlib;
+
+###########################################################################
+## update lib
+
+$(ROOT)/$(LIBDIR)/lib$(LIB).a :
+ @cd $(ROOT); \
+ $(MAKE) all
+
+###########################################################################
+## link
+
+link: $(OUTPUT)
+
+$(OUTPUT): $(OBJECTS) $(ROOT)/$(LIBDIR)/lib$(LIB).a
+ @echo Link $@
+ $(CXX) $(foreach file, $(SRC), $(file:.cpp=.o)) $(LDFLAGS) -L$(ROOT)/$(LIBDIR) -l$(LIB) -lz -o $@
+
+###########################################################################
+## include dependencies
+
+ifneq "$(strip $(wildcard *.d))" ""
+ include $(foreach file,$(DEPS),$(file))
+endif
+
+###########################################################################
+###########################################################################
diff --git a/examples/multiComponent/microFluidics2d/definitions.mk b/examples/multiComponent/microFluidics2d/definitions.mk
new file mode 100644
index 0000000..43100e0
--- /dev/null
+++ b/examples/multiComponent/microFluidics2d/definitions.mk
@@ -0,0 +1,30 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias Krause
+# E-mail contact: info@openlb.net
+# The most recent release of OpenLB can be downloaded at
+#
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+
+###########################################################################
+###########################################################################
+## DEFINITIONS TO BE CHANGED
+
+ROOT := ../../..
+SRC := microFluidics2d.cpp
+OUTPUT := microFluidics2d
diff --git a/examples/multiComponent/microFluidics2d/microFluidics2d.cpp b/examples/multiComponent/microFluidics2d/microFluidics2d.cpp
new file mode 100644
index 0000000..7ebf883
--- /dev/null
+++ b/examples/multiComponent/microFluidics2d/microFluidics2d.cpp
@@ -0,0 +1,456 @@
+/* Lattice Boltzmann sample, written in C++, using the OpenLB
+ * library
+ *
+ * Copyright (C) 2019 Sam Avis
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* microfluidics2d.cpp:
+ * This example shows a microfluidic channel creating droplets of
+ * two fluid components. Poiseuille velocity profiles are imposed
+ * at the various channel inlets, while a constant density outlet
+ * is imposed at the end of the channel to allow the droplets to
+ * exit the simulation.
+ *
+ * This example demonstrates the use of three fluid components
+ * with the free energy model. It also shows the use of open
+ * boundary conditions, specifically velocity inlet and density
+ * outlet boundaries.
+ */
+
+#include "olb2D.h"
+#include "olb2D.hh" // use only generic version!
+#include
+#include
+#include
+
+using namespace olb;
+using namespace olb::descriptors;
+using namespace olb::graphics;
+using namespace std;
+
+typedef double T;
+#define DESCRIPTOR D2Q9
+
+// Parameters for the simulation setup
+const int N = 100;
+const T nx = 800.;
+const T ny = 100.;
+const T dx = ny / N;
+
+const T inSize = 175.;
+const T xl1 = inSize * 2./7.;
+const T yl1 = ny / 4.;
+const T xl2 = inSize / 7.;
+const T yl2 = ny;
+const T xl3 = inSize * 3./7.;
+const T yl3 = ny / 4.;
+const T xl4 = inSize / 7.;
+const T yl4 = ny;
+const T xl5 = nx - inSize;
+const T yl5 = ny / 2.;
+
+const T inlet1Velocity = 0.00056; // [lattice units]
+const T inlet2Velocity = 0.00055; // [lattice units]
+const T inlet3Velocity = 0.0014; // [lattice units]
+const T outletDensity = 1.; // [lattice units]
+const T alpha = 1.; // Interfacial width [lattice units]
+const T kappa1 = 0.0132; // For surface tensions [lattice units]
+const T kappa2 = 0.0012; // For surface tensions [lattice units]
+const T kappa3 = 0.0013; // For surface tensions [lattice units]
+const T gama = 1.; // For mobility of interfaces [lattice units]
+const T h1 = 0.; // Contact angle 90 degrees [lattice units]
+const T h2 = 0.; // Contact angle 90 degrees [lattice units]
+const T h3 = 0.; // Contact angle 90 degrees [lattice units]
+
+const int maxIter = 1000000;
+const int vtkIter = 1000;
+const int statIter = 2000;
+
+
+void prepareGeometry( SuperGeometry2D& superGeometry ) {
+ OstreamManager clout( std::cout,"prepareGeometry" );
+ clout << "Prepare Geometry ..." << std::endl;
+
+ std::shared_ptr> section1 = std::make_shared>( xl1, yl1, std::vector{xl1/2., ny/2.} );
+ std::shared_ptr> section2 = std::make_shared>( xl2, yl2, std::vector{xl1 + xl2/2., ny/2.} );
+ std::shared_ptr> section3 = std::make_shared>( xl3, yl3, std::vector{xl1 + xl2 + xl3/2., ny/2.} );
+ std::shared_ptr> section4 = std::make_shared>( xl4, yl4, std::vector{xl1 + xl2 + xl3 + xl4/2., ny/2.} );
+ std::shared_ptr> section5 = std::make_shared>( xl5, yl5, std::vector{xl1 + xl2 + xl3 + xl4 + xl5/2., ny/2.} );
+ IndicatorIdentity2D channel( section1 + section2 + section3 + section4 + section5 );
+
+ superGeometry.rename( 0, 2, channel );
+ superGeometry.rename( 2,1,1,1 );
+
+ // Inlets and outlet
+ IndicatorCuboid2D inlet1 ( dx, yl1, {0., ny/2.} );
+ IndicatorCuboid2D inlet21( xl2 - dx, dx, {xl1 + xl2/2., 0.} );
+ IndicatorCuboid2D inlet22( xl2 - dx, dx, {xl1 + xl2/2., ny} );
+ IndicatorCuboid2D inlet31( xl4 - dx, dx, {xl1 + xl2 + xl3 + xl4/2., 0.} );
+ IndicatorCuboid2D inlet32( xl4 - dx, dx, {xl1 + xl2 + xl3 + xl4/2., ny} );
+ IndicatorCuboid2D outlet( dx, yl5, {nx, ny/2.} );
+ superGeometry.rename( 2, 3, 1, inlet1 );
+ superGeometry.rename( 2, 4, 1, inlet21 );
+ superGeometry.rename( 2, 5, 1, inlet22 );
+ superGeometry.rename( 2, 6, 1, inlet31 );
+ superGeometry.rename( 2, 7, 1, inlet32 );
+ superGeometry.rename( 2, 8, 1, outlet );
+
+ superGeometry.innerClean();
+ superGeometry.checkForErrors();
+ superGeometry.print();
+
+ clout << "Prepare Geometry ... OK" << std::endl;
+}
+
+
+void prepareLattice( SuperLattice2D& sLattice1,
+ SuperLattice2D& sLattice2,
+ SuperLattice2D& sLattice3,
+ Dynamics& bulkDynamics1,
+ Dynamics& bulkDynamics2,
+ Dynamics& bulkDynamics3,
+ sOnLatticeBoundaryCondition2D& sOnBC1,
+ sOnLatticeBoundaryCondition2D& sOnBC2,
+ sOnLatticeBoundaryCondition2D& sOnBC3,
+ UnitConverter& converter,
+ SuperGeometry2D& superGeometry ) {
+
+ OstreamManager clout( std::cout,"prepareLattice" );
+ clout << "Prepare Lattice ..." << std::endl;
+
+ // define lattice dynamics
+ sLattice1.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 0, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 1, &bulkDynamics1 );
+ sLattice2.defineDynamics( superGeometry, 1, &bulkDynamics2 );
+ sLattice3.defineDynamics( superGeometry, 1, &bulkDynamics3 );
+
+ sLattice1.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 2, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 3, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 3, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 3, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 4, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 4, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 4, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 5, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 5, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 5, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 6, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 6, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 6, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 7, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 7, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 7, &instances::getNoDynamics() );
+
+ sLattice1.defineDynamics( superGeometry, 8, &instances::getNoDynamics() );
+ sLattice2.defineDynamics( superGeometry, 8, &instances::getNoDynamics() );
+ sLattice3.defineDynamics( superGeometry, 8, &instances::getNoDynamics() );
+
+ // add wall boundary
+ sOnBC1.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, kappa3, h1, h2, h3, 1 );
+ sOnBC2.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, kappa3, h1, h2, h3, 2 );
+ sOnBC3.addFreeEnergyWallBoundary( superGeometry, 2, alpha, kappa1, kappa2, kappa3, h1, h2, h3, 3 );
+
+ // add inlet boundaries
+ T omega = converter.getLatticeRelaxationFrequency();
+ auto inlet1Indicator = superGeometry.getMaterialIndicator(3);
+ sOnBC1.addFreeEnergyInletBoundary( inlet1Indicator, omega, "velocity", 1 );
+ sOnBC2.addFreeEnergyInletBoundary( inlet1Indicator, omega, "velocity", 2 );
+ sOnBC3.addFreeEnergyInletBoundary( inlet1Indicator, omega, "velocity", 3 );
+
+ auto inlet2Indicator = superGeometry.getMaterialIndicator({4, 5});
+ sOnBC1.addFreeEnergyInletBoundary( inlet2Indicator, omega, "velocity", 1 );
+ sOnBC2.addFreeEnergyInletBoundary( inlet2Indicator, omega, "velocity", 2 );
+ sOnBC3.addFreeEnergyInletBoundary( inlet2Indicator, omega, "velocity", 3 );
+
+ auto inlet3Indicator = superGeometry.getMaterialIndicator({6, 7});
+ sOnBC1.addFreeEnergyInletBoundary( inlet3Indicator, omega, "velocity", 1 );
+ sOnBC2.addFreeEnergyInletBoundary( inlet3Indicator, omega, "velocity", 2 );
+ sOnBC3.addFreeEnergyInletBoundary( inlet3Indicator, omega, "velocity", 3 );
+
+ // add outlet boundary
+ auto outletIndicator = superGeometry.getMaterialIndicator(8);
+ sOnBC1.addFreeEnergyOutletBoundary( outletIndicator, omega, "density", 1 );
+ sOnBC2.addFreeEnergyOutletBoundary( outletIndicator, omega, "density", 2 );
+ sOnBC3.addFreeEnergyOutletBoundary( outletIndicator, omega, "density", 3 );
+
+ // bulk initial conditions
+ std::vector v( 2,T() );
+ AnalyticalConst2D zeroVelocity( v );
+
+ AnalyticalConst2D zero ( 0. );
+ AnalyticalConst2D one ( 1. );
+ SmoothIndicatorCuboid2D section1( {xl1/2., ny/2.}, xl1+dx, ny, 0. );
+ SmoothIndicatorCuboid2D section2( {xl1 + (xl2 + xl3)/2., ny/2.}, xl2 + xl3, ny, 0. );
+
+ AnalyticalIdentity2D c1( section1 );
+ AnalyticalIdentity2D c2( section2 );
+ AnalyticalIdentity2D rho( one );
+ AnalyticalIdentity2D phi( c1 - c2 );
+ AnalyticalIdentity2D psi( rho - c1 - c2 );
+
+ auto allIndicator = superGeometry.getMaterialIndicator({1, 2, 3, 4, 5, 6});
+ sLattice1.iniEquilibrium( allIndicator, rho, zeroVelocity );
+ sLattice2.iniEquilibrium( allIndicator, phi, zeroVelocity );
+ sLattice3.iniEquilibrium( allIndicator, psi, zeroVelocity );
+
+ // inlet boundary conditions
+ Poiseuille2D inlet1U( superGeometry, 3, 1.5*inlet1Velocity, 0. );
+ sLattice1.defineU( inlet1Indicator, inlet1U );
+ sLattice2.defineRho( inlet1Indicator, phi );
+ sLattice3.defineRho( inlet1Indicator, psi );
+
+ Poiseuille2D inlet21U( superGeometry, 4, 1.5*inlet2Velocity, 0. );
+ Poiseuille2D inlet22U( superGeometry, 5, 1.5*inlet2Velocity, 0. );
+ sLattice1.defineU( superGeometry, 4, inlet21U );
+ sLattice1.defineU( superGeometry, 5, inlet22U );
+ sLattice2.defineRho( inlet2Indicator, phi );
+ sLattice3.defineRho( inlet2Indicator, psi );
+
+ Poiseuille2D inlet31U( superGeometry, 6, 1.5*inlet3Velocity, 0. );
+ Poiseuille2D inlet32U( superGeometry, 7, 1.5*inlet3Velocity, 0. );
+ sLattice1.defineU( superGeometry, 6, inlet31U );
+ sLattice1.defineU( superGeometry, 7, inlet32U );
+ sLattice2.defineRho( inlet3Indicator, phi );
+ sLattice3.defineRho( inlet3Indicator, psi );
+
+ // outlet initial / boundary conditions
+ AnalyticalConst2D rhoOutlet( outletDensity );
+ AnalyticalIdentity2D phiOutlet( zero );
+ AnalyticalIdentity2D psiOutlet( rhoOutlet );
+ sLattice1.defineRho( outletIndicator, rhoOutlet );
+ sLattice2.defineRho( outletIndicator, phiOutlet );
+ sLattice3.defineRho( outletIndicator, psiOutlet );
+
+ // initialise lattices
+ sLattice1.initialize();
+ sLattice2.initialize();
+ sLattice3.initialize();
+
+ sLattice1.communicate();
+ sLattice2.communicate();
+ sLattice3.communicate();
+
+ clout << "Prepare Lattice ... OK" << std::endl;
+}
+
+
+void prepareCoupling(SuperLattice2D& sLattice1,
+ SuperLattice2D& sLattice2,
+ SuperLattice2D& sLattice3,
+ SuperGeometry2D& superGeometry) {
+ OstreamManager clout( std::cout,"prepareCoupling" );
+ clout << "Add lattice coupling" << endl;
+
+ // Bulk couplings
+ FreeEnergyChemicalPotentialGenerator2D coupling2( alpha, kappa1, kappa2, kappa3 );
+ FreeEnergyForceGenerator2D coupling3;
+
+ // Inlet / outlet couplings
+ FreeEnergyDensityOutletGenerator2D coupling1( outletDensity );
+ FreeEnergyInletOutletGenerator2D coupling4;
+
+ // The DensityOutlet coupling must be added to the first lattice and come before the ChemicalPotential coupling
+ // The InletOutlet couplings must be added to the second lattice and come after the Force coupling.
+ sLattice1.addLatticeCoupling( superGeometry, 8, coupling1, {&sLattice2, &sLattice3} );
+
+ sLattice1.addLatti