Skip to content

Piled Foundations ​

Piled Foundations, rendered in the brepjs playground
BIM · 183 lines▶ Run it in the playground

The foundations of a concrete frame with the ground cut open: bored piles, pile caps, ground beams, columns and the suspended slab that they carry. Piles and footings are typed IFC elements (IfcPile, IfcFooting), so a structural model can schedule them. The pile spacing, the cap edge distance, the concrete cover and the guide rate for the steel in a cap are published figures, and the kernel measures the concrete of each class and the bars of one cap. The grid, the sizes, the strata and the cage are a display model.

Code ​

This is the full program. The playground runs it in your browser without a change.

ts
import { BimModel, placedSolids, toIfc } from 'brepjs-bim';
import { box, compound, cutAll, cylinder, measureVolume, torus, translate, unwrap } from 'brepjs/quick';
import { color, present } from 'brepjs/playground';

// Piled foundations of a concrete frame, with the ground cut open. Piles, pile caps and ground beams are
// typed IFC elements (IfcPile, IfcFooting, IfcBeam), so a structural model can schedule them.
// Units are millimetres. Z is up, and z = 0 is the top of the ground floor slab.
interface FoundationParams {
  pileLength?: number; // 5000 to 15000
  cutaway?: boolean; // cut the ground at the middle grid line and show the cage of one cap. The model keeps all
}

// ---- published figures
const PILE_RULE = { spacing: 3, edge: 150 }; // pile centres at 3 diameters, and the cap goes 150 mm past the piles
const COVER = 75; // concrete cover to the steel where the concrete is cast against earth
const CAP_STEEL = { low: 110, high: 150 }; // guide rate for pile caps, kg of bar in each m3
const STEEL = 7850e-9; // kg in each mm3

// ---- display model
const GRID = [0, 5000, 10000];
const PILE = { diameter: 450 };
const SPACING = PILE_RULE.spacing * PILE.diameter; // 1350
const CAP = { long: SPACING + PILE.diameter + 2 * PILE_RULE.edge, short: PILE.diameter + 2 * PILE_RULE.edge, depth: 1000 }; // 2100 by 750
const SLAB = { depth: 225, edge: 300 };
const BEAM = { width: 450, depth: 600 };
const COLUMN = { side: 400, height: 3200 };
const TOP = -SLAB.depth; // top of the caps and the ground beams
const CUT_OFF = TOP - CAP.depth; // top of the piles, and the level of the dig
const STRATA = [{ name: 'made ground', top: CUT_OFF, tint: '#6b5a48' }, { name: 'firm clay', top: -2600, tint: '#8c6f55' }, { name: 'dense gravel', top: -6500, tint: '#b79a6c' }];
const CONCRETE = 'Concrete C32/40';

type P3 = [number, number, number];
type Body = ReturnType<typeof box>;
type Id = Extract<ReturnType<BimModel['addSlab']>, { ok: true }>['value'];
const X: P3 = [1, 0, 0], Y: P3 = [0, 1, 0], Z: P3 = [0, 0, 1];

// The model stays alive for the IFC file. Each temporary solid is freed, also when the build throws.
function foundations({ pileLength = 8000, cutaway = true }: FoundationParams = {}) {
  const model = new BimModel(), owned: Body[] = [];
  const own = <T extends Body>(s: T): T => { owned.push(s); return s; };
  try {
    model.init({ name: 'Foundations', projectId: 'foundations-demo' });
    const site = unwrap(model.addSite({ name: 'Site' }));
    const building = unwrap(model.addBuilding({ name: 'Block A' }));
    const storey = unwrap(model.addStorey({ name: 'Substructure', elevation: 0 }));
    const project = model.getProject();
    if (project) model.aggregate(project.localId, site);
    model.aggregate(site, building);
    model.aggregate(building, storey);
    const tone = new Map<Id, string>(), hidden = new Set<Id>();
    const put = (made: ReturnType<BimModel['addSlab']>, tint: string, hide = false): Id => {
      const id = unwrap(made);
      model.placeIn(id, storey);
      tone.set(id, tint);
      if (hide) hidden.add(id);
      return id;
    };

    // ---- the lesson. Each grid node gets its piles, then a cap on them, then the column on the cap.
    // A pile takes a profile like each linear member, so a bored pile is a CIRCULAR section. The node at
    // the middle carries the most load and stands on four piles. The others stand on two.
    const piles: P3[] = [];
    GRID.forEach((x, i) => GRID.forEach((y, j) => {
      const four = i === 1 && j === 1, bare = i === 2 && j === 0; // the cap that the view shows as a cage
      const across = four ? [-SPACING / 2, SPACING / 2] : [0];
      for (const dx of across) for (const dy of [-SPACING / 2, SPACING / 2]) {
        piles.push([x + dx, y + dy, CUT_OFF - pileLength]);
        put(model.addPile({ length: pileLength, profile: { kind: 'CIRCULAR', radius: PILE.diameter / 2 }, origin: [x + dx, y + dy, CUT_OFF - pileLength], axisX: X, axisZ: Z, predefinedType: 'BORED', constructionType: 'CAST_IN_PLACE', materialName: CONCRETE }), '#9d978b', bare);
      }
      const length = four ? CAP.long : CAP.short;
      put(model.addFooting({ length, width: CAP.long, thickness: CAP.depth, origin: [x - length / 2, y - CAP.long / 2, CUT_OFF], axisX: X, axisZ: Z, predefinedType: 'PILE_CAP', materialName: CONCRETE }), '#a8a294', bare);
      put(model.addColumn({ height: COLUMN.height - TOP, profile: { kind: 'RECTANGULAR', width: COLUMN.side, height: COLUMN.side }, origin: [x, y, TOP], axisX: X, axisZ: Z, materialName: CONCRETE }), '#d8d4c8', bare);
    }));

    // Ground beams tie the caps together. Each beam stops at the faces of its two caps.
    const beam = { profile: { kind: 'RECTANGULAR', width: BEAM.width, height: BEAM.depth }, axisZ: Z, predefinedType: 'BEAM', materialName: CONCRETE } as const;
    const z = TOP - BEAM.depth / 2;
    for (const line of GRID) for (const k of [0, 1]) {
      const a = GRID[k]!, b = GRID[k + 1]!, wide = (i: number): number => (i === 1 && line === GRID[1] ? CAP.long : CAP.short) / 2;
      put(model.addBeam({ ...beam, length: b - a - wide(k) - wide(k + 1), origin: [a + wide(k), line, z], axisX: X }), '#bdb7aa');
      put(model.addBeam({ ...beam, length: b - a - CAP.long, origin: [line, a + CAP.long / 2, z], axisX: Y }), '#bdb7aa');
    }

    // The suspended ground slab, in two pours that meet at the cut. Each column goes through a hole in it.
    const joint = GRID[1]! + SLAB.edge, far = GRID[2]! + SLAB.edge, wide = far + SLAB.edge;
    [[-SLAB.edge, joint], [joint, far]].forEach(([x0, x1], pour) => {
      const slab = put(model.addSlab({ length: x1! - x0!, width: wide, thickness: SLAB.depth, origin: [x0!, -SLAB.edge, TOP], axisX: X, axisZ: Z, predefinedType: 'FLOOR', materialName: CONCRETE }), '#e9e5da', pour === 1);
      for (const x of GRID) for (const y of GRID) if (x > x0! && x < x1!)
        unwrap(model.addSlabOpening({ slabLocalId: slab, offsetX: x - COLUMN.side / 2 - x0!, offsetY: y - COLUMN.side / 2 + SLAB.edge, sizeX: COLUMN.side, sizeY: COLUMN.side }));
    });
    console.log(model.getPiles().length + ' piles, ' + model.getFootings().length + ' pile caps, ' + model.getColumns().length + ' columns, ' + model.getBeams().length + ' ground beams');

    // ---- the view and the takeoff. The kernel measures the concrete of each class of element.
    const groups = new Map<string, Body[]>(), m3 = new Map<string, number>();
    for (const el of model.getAllElements()) {
      const tint = tone.get(el.localId);
      if (tint === undefined) continue;
      const solids = unwrap(placedSolids(el));
      owned.push(...solids);
      m3.set(el.category, (m3.get(el.category) ?? 0) + solids.reduce((sum, s) => sum + unwrap(measureVolume(s)), 0) / 1e9);
      if (!(cutaway && hidden.has(el.localId))) groups.set(tint, [...(groups.get(tint) ?? []), ...solids]);
    }
    console.log('concrete: ' + [...m3].map(([category, v]) => category.toLowerCase() + ' ' + v.toFixed(1) + ' m3').join(', '));
    const toe = CUT_OFF - pileLength, gravel = STRATA[2]!.top;
    console.log('pile toe at ' + (toe / 1000).toFixed(1) + ' m: ' + (toe < gravel ? ((gravel - toe) / 1000).toFixed(1) + ' m into the dense gravel' : 'it does not reach the dense gravel'));

    const shown = [...groups].map(([tint, solids]) => color(compound(solids), tint));
    shown.push(...ground(piles, toe, cutaway, own));
    if (cutaway) {
      const bars = cage(GRID[2]!, GRID[0]!, toe, own);
      const kg = bars.cap.reduce((sum, s) => sum + unwrap(measureVolume(s)), 0) * STEEL, capM3 = (CAP.short * CAP.long * CAP.depth) / 1e9;
      console.log('cage of one cap: ' + kg.toFixed(0) + ' kg of bar in ' + capM3.toFixed(2) + ' m3 = ' + (kg / capM3).toFixed(0) + ' kg for each m3 (guide: ' + CAP_STEEL.low + ' to ' + CAP_STEEL.high + ')');
      shown.push(color(compound([...bars.cap, ...bars.rest]), '#ff5a1f'));
    }
    return { model, shown };
  } catch (error) {
    model[Symbol.dispose]();
    throw error;
  } finally {
    owned.splice(0).forEach((s) => s.delete());
  }
}

// ---- display only: the ground in three strata, with a hole for each pile. The cut goes through the piles
// of the middle grid line.
function ground(piles: P3[], toe: number, cutaway: boolean, own: <T extends Body>(s: T) => T) {
  const x0 = -1200, x1 = cutaway ? GRID[1]! : GRID[2]! + 1200, y0 = -1200, y1 = GRID[2]! + 1200, bottom = Math.min(toe, STRATA[2]!.top) - 1200;
  return STRATA.map((layer, i) => {
    const low = STRATA[i + 1]?.top ?? bottom;
    const block = own(box(x1 - x0, y1 - y0, layer.top - low, { at: [(x0 + x1) / 2, (y0 + y1) / 2, (layer.top + low) / 2] }));
    const holes = piles.filter(([x, , z]) => x - PILE.diameter / 2 < x1 && z < layer.top)
      .map(([x, y, z]) => own(cylinder(PILE.diameter / 2, layer.top - Math.max(z, low), { at: [x, y, Math.max(z, low)] })));
    return color(unwrap(cutAll(block, holes)), layer.tint);
  });
}

// ---- display only: the steel of one two-pile cap, of its piles and of its column. The bars touch and do not cross.
function cage(cx: number, cy: number, toe: number, own: <T extends Body>(s: T) => T) {
  const cap: Body[] = [], rest: Body[] = [];
  const bar = (list: Body[], d: number, from: P3, axis: P3, length: number): void => { list.push(own(cylinder(d / 2, length, { at: [cx + from[0], cy + from[1], from[2]], axis }))); };
  const half = { x: CAP.short / 2, y: CAP.long / 2 }, link = 16, main = 32, upper = 20;
  const low = CUT_OFF + COVER + link / 2, high = TOP - COVER - link / 2, side = half.x - COVER - link / 2;
  // Links at 150 mm: two legs across and two legs up, outside the other bars.
  for (let y = -825; y <= 825; y += 150) {
    for (const zz of [low, high]) bar(cap, link, [-half.x + COVER, y, zz], X, CAP.short - 2 * COVER);
    for (const xx of [-side, side]) bar(cap, link, [xx, y, low + link / 2], Z, high - low - link);
  }
  // Six main bars at the bottom, with a leg up at each end. Four bars at the top, and three lacers on each side.
  const end = half.y - COVER, zMain = low + link / 2 + main / 2;
  for (let i = 0; i < 6; i++) {
    const xx = (i - 2.5) * ((2 * (side - link / 2 - main / 2)) / 5);
    bar(cap, main, [xx, -end + main, zMain], Y, 2 * (end - main));
    for (const yy of [-end + main / 2, end - main / 2]) bar(cap, main, [xx, yy, zMain - main / 2], Z, 700);
  }
  for (let i = 0; i < 4; i++) bar(cap, upper, [(i - 1.5) * ((2 * (side - link / 2 - upper / 2)) / 3), -end, high - link / 2 - upper / 2], Y, 2 * end);
  for (const xx of [-side + link, side - link]) for (const zz of [-900, -700, -500]) bar(cap, link, [xx, -825, zz], Y, 1650);

  // A pile has six bars in a ring with hoops at 300 mm. The bars go 600 mm into the cap.
  const ring = 130, hoop = own(torus(ring + 8 + 4, 4));
  for (const py of [-SPACING / 2, SPACING / 2]) {
    for (let k = 0; k < 6; k++) {
      const a = ((30 + 60 * k) * Math.PI) / 180;
      bar(rest, 16, [ring * Math.cos(a), py + ring * Math.sin(a), toe + 150], Z, CUT_OFF + 600 - toe - 150);
    }
    for (let zz = toe + 300; zz < CUT_OFF - 100; zz += 300) rest.push(own(translate(hoop, [cx, cy + py, zz])));
  }
  // The starter bars of the column stand on the bottom bars, with three links above the cap.
  const corner = COLUMN.side / 2 - 40 - 8 - 12.5, out = corner + 12.5 + 4;
  for (const sx of [-corner, corner]) for (const sy of [-corner, corner]) bar(rest, 25, [sx, sy, zMain + main / 2], Z, 1200 - zMain);
  for (const zz of [TOP + 150, TOP + 450, TOP + 750]) {
    for (const s of [-out, out]) bar(rest, 8, [-out - 4, s, zz], X, 2 * out + 8);
    for (const s of [-out, out]) bar(rest, 8, [s, -out + 4, zz], Y, 2 * out - 8);
  }
  return { cap, rest };
}

// Show the cut ground and the cage. Try foundations({ pileLength: 5000 }), or foundations({ cutaway: false }).
const job = foundations();
// The IFC button saves the model. The ground and the bars are a display model, and are not in the file.
export default present(job.shown, {
  bimTree: job.model.toTreeSummary(),
  ifc: async () => unwrap(await toIfc(job.model, { applicationName: 'brepjs playground', applicationVersion: '1.0' })),
});

Functions used ​

placedSolids toIfc box compound cutAll cylinder measureVolume torus translate unwrap color present

▶ Run Piled Foundations in the playground

Released under the Apache 2.0 License.