Cannot be resolved or is not a field error

Good morning,

I’m fairly new to processing, and ran into some trouble with my code regarding an error “body cannot be resolved or is not a field”. Processing also tells me that the global variable body does not exist, despite it being in the second line of code.

BDIM flow;
Body body;
SaveData dat;
FloodPlot flood;
boolean recording= true;
float t=0; float n=(int)pow(2,7); float xLengths=n/10; float yLengths=0.4; float xStart=n/3; float yStart=n/2; float yDist; float zoom;     
void setup() {
  size(700, 700);                            // display window size
  int resolution=(int)pow(2,7);                       // number of grid points                           
  Window window = new Window(resolution, resolution);
  body = new EllipseBody(n/3,n/2,n/10,0.4,window);     // define geom
  flow = new BDIM(resolution, resolution, 1.5, body);             // solve for flow using BDIM
  dat = new SaveData("saved/pressForce.txt", flow.body.pressForce(flow.p),n,xLengths,yLengths,zoom);
  flood = new FloodPlot(window);               // initialize a flood plot...
  flood.setLegend("pressure", -1,1);       //    and its legend
void draw() {
  float D=(n/10)/0.4;
  t += flow.dt/D;
  body.follow();                             // update the body
  flow.update2(); // 2-step fluid update
  flow.p.display(-0.5, 0.5); // display pressure
  dat.addData(flow.t, flow.body.pressForce(flow.p), flow.p);    // add the pressure to the data file
    saveFrame("saved/frame-####.png");   // save images.
  flood.display(flow.p);              // compute and display pressure
  body.display();                            // display the body

I have tried some other methods such as replacing

dat = new SaveData(“saved/pressForce.txt”, flow.body.pressForce(flow.p),n,xLengths,yLengths,zoom);


dat = new SaveData(“saved/pressForce.txt”, flow.BDIM.pressForce(flow.p),n,xLengths,yLengths,zoom);

which worked in the past when I was not trying to save the data but no longer works since updating processing to 3.5.3.

I would appreciate any advice or help, and apologize if this is a really simple question.

Thank you for your time

1 Like

Please format your code with </> button, not ".

You code begins:

Body body;

That means that the compiler will look, in your code on that tab, or another tab, or in an included library, for a definition of what the class “Body” is – something like:

class Body {
  int foo;
  Body (int foo){ = foo;

Based on the fact that later in the code you try to create a Body by initializing an EllipsseBody object, It looks like you are using a library of some kind? And the include statement for that library is missing?