// addload_example.fe

// Demonstration of using the addload command to load multiple
// copies of the same file.  Basic surface is that of mound.fe,
// a liquid drop on a plane.
// Each separate mound will have its own contact angle, implemented
// by having a contact angle attribute for each edge.


define edge attribute angle real   // interior angle between plane and surface, degrees

gravity_constant 0  // start with gravity off

#define WALLT  (-cos(angle*pi/180))  // virtual tension of facet on plane
 
constraint 1   /* the table top */
formula: x3 = 0
energy:  // for contact angle
e1: -(WALLT*y)
e2: 0
e3: 0 

vertices
1   0.0  0.0 0.0  constraint 1  /* 4 vertices on plane */
2   1.0  0.0 0.0  constraint 1
3   1.0  1.0 0.0  constraint 1
4   0.0  1.0 0.0  constraint 1
5   0.0  0.0 1.0
6   1.0  0.0 1.0
7   1.0  1.0 1.0
8   0.0  1.0 1.0
9   2.0  2.0 0.0  fixed   /* for table top */
10  2.0 -1.0 0.0  fixed
11 -1.0 -1.0 0.0  fixed
12 -1.0  2.0 0.0  fixed

edges  /* given by endpoints and attribute */
1   1 2    constraint 1 /* 4 edges on plane */
2   2 3    constraint 1
3   3 4    constraint 1
4   4 1    constraint 1
5   5 6
6   6 7  
7   7 8 
8   8 5
9   1 5   
10  2 6  
11  3 7 
12  4 8
13  9 10 no_refine  fixed  /* for table top */
14 10 11 no_refine  fixed
15 11 12 no_refine  fixed
16 12  9 no_refine  fixed

faces  /* given by oriented edge loop */
1   1 10 -5  -9
2   2 11 -6 -10
3   3 12 -7 -11
4   4  9 -8 -12
5   5  6  7   8
7  13 14 15  16  no_refine density 0 fixed /* table top for display */

bodies  /* one body, defined by its oriented faces */
1   1 2 3 4 5   volume 1  density 1

read

setup := {
  
  // Read in 3 x 3 arrangement of drops.  The first has already been
  // read in, so we need to read in 8 more copies of this datafile.
  // We use a vertex attribute to distinguish between old and new
  // elements; for more elaborate massaging of new input you could
  // use more attributes on more types of elements.
  
  define vertex attribute load_marker integer;
  for ( row := 0 ; row < 3 ; row += 1 )
    for ( col := 0 ; col < 3  ; col += 1 )
    { if ( row > 0 or col > 0 ) then addload datafilename;
      // Move and mark vertices
      foreach vertex vv where load_marker == 0 do
      { vv.x += 2*row;
        vv.y += 2*col;
        vv.load_marker := 3*row+col+1;  // different loads get different marks
      };
    };
  
  // Now assign contact angles to contact line edges
  foreach edge ee where on_constraint 1 do
    ee.angle := 90 + (ee.vertex[1].load_marker - 5)*10;
  
}  // end setup

setup

// From here on, we have the usual evolution commands

re := {refine edges where on_constraint 1 }

// Typical evolution
gogo := { re; g 5; r; g 5; r; g 5; hessian; hessian; }



