Error. Need help to start with.

Hi, guys!

Thank you for this code. I talked with Orestis for a while and decided to try Linux and the framework. Sorry to bother you. But any advice can help, because I am really new in it. Make files for examples are OK - they produce .gif files. However for the first lesson, when I do my makefile and run it - I’ve got compilation errors:

simplecode.cpp:21: error: cannot declare variable ‘bulkDynamics’ to be of abstract type ‘olb::Dynamics<double, olb::descriptors::D2Q9Descriptor>’

and …

simplecode.cpp:24: error: no matching function for call to ‘olb::BlockLattice2D<double, olb::descriptors::D2Q9Descriptor>::defineDynamics(int, int, int, int, olb::BGKdynamics<double, olb::descriptors::D2Q9Descriptor>&)’
…/OpenLB/OpenLB/src/core/blockLattice2D.hh:169: note: candidates are: void olb::BlockLattice2D<T, Lattice>::defineDynamics(int, int, int, int, olb::Dynamics<T, Lattice>*) [with T = double, Lattice = olb::descriptors::D2Q9Descriptor]
simplecode.cpp:45: error: ‘ImageWriter’ was not declared in this scope
simplecode.cpp:45: error: expected primary-expression before ‘>’ token
simplecode.cpp:45: error: ‘imageWriter’ was not declared in this scope
simplecode.cpp:48: error: ‘blockLattice’ was not declared in this scope
make: *** [/home/shurik/work/development/simplecode/simplecode.o] Error 1

Any help is more than welcome. Thank you,

Hi Alex,
it’s a bit difficult to be sure what exactly are the errors without seeing the code, maybe it will be easier if you post it. But let us give it a try.

The first error is because you declared your variable bulkDynamics as a Dynamics object which is purely virtual. Try declaring it as a BGKdynamics or any dynamics you want.

The second one is because you try to defineDynamics with a reference instead of a pointer.

Then the imageWriter error is maybe because you did not incule the namespace graphics.

I hope this can give you hints. If not just post the code and we’ll see what we can do for you.


Hi, Orestis!

Thank you very much for your help. The code produces something at least :slight_smile: Please add the following to the pdf guide for the first lesson:

Instead of lattice.defineDynamics(0,nx-1,0,ny-1,bulkDynamics) we need lattice.defineDynamics(0,nx-1,0,ny-1,&bulkDynamics)

and the following for ImageWriter.writeScaledGif (
“lesson1”, blockLattice.getDataAnalysis().computeVelocityNorm());

It should be the following:
ImageWriter.writeScaledGif (
“lesson1”, lattice.getDataAnalysis().getPressure());

because it can’t find the computeVelocityNorm() method.

Probably I’m not right - but at least it helps. Could you please comment on it? Probably I don’t know how to access this method computeVelocityNorm().

Thank you,

P.S. Probably see you in Amsterdam.

Great! These points are relevant to my “lesson codes” post.

Below is what worked for me. Comments indicate changes from what is in lesson codes. These will be completely obvious to some of you, but may help others (like me!)

// DJP April 17 2008 - following lessons in olb-0.4r3 User Guide
// Somewhat expanded Code 1.1 //

#include “olb2D.h”
#ifndef OLB_PRECOMPILED // Unless precompiled version is used,
#include “olb2D.hh” // include full template code

// Not necessary here but left it as appears in all example codes
#define DESCRIPTOR D2Q9Descriptor

using namespace olb;
using namespace olb::descriptors;
using namespace olb::graphics;
using namespace std;

int main(int argc, char* argv[]) {
olbInit(&argc, &argv);

// Start Code 1.2 //

#define LATTICE D2Q9Descriptor

typedef double T;
int nx = 20;
int ny = 30;
int numIter = 100;
T omega = 1.;
// need r too!
int r = 5;

BlockLattice2D<T, LATTICE> lattice(nx,ny);

BGKdynamics<T, LATTICE> bulkDynamics (
instances::getBulkMomenta<T, LATTICE>()

//lattice.defineDynamics(0,nx-1,0,ny-1, bulkDynamics);
lattice.defineDynamics(0,nx-1,0,ny-1, &bulkDynamics);

for (int iX=0; iX<nx; ++iX) {
for (int iY=0; iY<ny; ++iY) {
T rho=1., u[2] = {0.,0.};
if ((iX-nx/2)(iX-nx/2) + (iY-ny/2)(iY-ny/2) < r*r) {
rho = 1.01;

for (int iT=0; iT<numIter; ++iT) {

ImageWriter imageWriter(“leeloo” ) ;

imageWriter.writeScaledGif (
// End Code 1.2 //