@meshioplusplus/wasm 10.6.0 → 10.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -302,6 +302,19 @@ export type OpSpec =
302
302
  output?: string;
303
303
  component?: number;
304
304
  }
305
+ | {
306
+ /**
307
+ * The Hessian (second derivative) of a scalar `point_data` field --
308
+ * `gradient`'s companion one order further, for curvature-based
309
+ * adaptive refinement. A pure data step: geometry is untouched and
310
+ * one new (n,9) array is attached.
311
+ */
312
+ op: 'hessian';
313
+ array: string;
314
+ method?: GradientMethod;
315
+ location?: 'point' | 'cell';
316
+ output?: string;
317
+ }
305
318
  | {
306
319
  /**
307
320
  * The ZZ recovery-based error indicator of a `point_data` field, plus
@@ -494,6 +507,10 @@ export type InterpolateMethod = 'nearest' | 'barycentric';
494
507
  * target: throw, replace, or write to `name + '_interp'`. */
495
508
  export type InterpolateOnConflict = 'error' | 'overwrite' | 'suffix';
496
509
 
510
+ /** What `conservativeInterpolate` does when a transferred name already
511
+ * exists on the target: throw, replace, or write to `name + '_interp'`. */
512
+ export type ConservativeInterpolateOnConflict = 'error' | 'overwrite' | 'suffix';
513
+
497
514
  /** Partitioning backend: SFC is always available; KaHIP is never compiled
498
515
  * into the WASM build, so `'kahip'` always throws and `'auto'` = `'sfc'`. */
499
516
  export type PartitionMethod = 'sfc' | 'kahip' | 'auto';
@@ -527,6 +544,41 @@ export interface DataArrayInfo {
527
544
  inconsistentBlocks: boolean;
528
545
  }
529
546
 
547
+ /** Cell-measure-weighted reduction of one array over one set of cells (the
548
+ * whole mesh, or one named Cell region) -- see `dataIntegrate`. */
549
+ export interface FieldIntegralRegion {
550
+ /** The region's name; absent on the whole-mesh `domain` entry. */
551
+ name?: string;
552
+ /** Cells with a computable measure. */
553
+ numCells: number;
554
+ /** Cells excluded: unmeasurable geometry (ragged, unsupported type, or
555
+ * degenerate). */
556
+ numSkipped: number;
557
+ /** `sum(value * |measure|)` over cells finite in component k. */
558
+ totalPerComponent: number[];
559
+ /** `totalPerComponent[k] / domainMeasurePerComponent[k]`, or NaN when that
560
+ * denominator is zero. */
561
+ meanPerComponent: number[];
562
+ /** `sum(|measure|)` over cells finite in component k. */
563
+ domainMeasurePerComponent: number[];
564
+ /** Measurable cells excluded from component k because its value was
565
+ * non-finite there. */
566
+ numNanPerComponent: number[];
567
+ }
568
+
569
+ /** One array's field integral, returned by `dataIntegrate` --
570
+ * `gradient`'s integration counterpart. See doc/field_integration.md. */
571
+ export interface FieldIntegralArray {
572
+ name: string;
573
+ numComponents: number;
574
+ /** The whole-mesh reduction. */
575
+ domain: FieldIntegralRegion;
576
+ /** One independent entry per named Cell region present on the mesh -- a
577
+ * cell in two regions contributes fully to both, one in none contributes
578
+ * to neither. */
579
+ regions: FieldIntegralRegion[];
580
+ }
581
+
530
582
  /** Heavy-data layout of a transient XDMF series. */
531
583
  export type XdmfDataFormat = 'HDF' | 'XML' | 'Binary';
532
584
 
@@ -1014,6 +1066,29 @@ export interface MeshioPlusPlusModule {
1014
1066
  onConflict?: InterpolateOnConflict,
1015
1067
  ): Mesh;
1016
1068
 
1069
+ /**
1070
+ * Mass-preserving cross-mesh field transfer: an exact overlap-measure
1071
+ * weighted remap, so that over the region the two meshes share,
1072
+ * sum(target value * target measure) equals sum(source value * source
1073
+ * measure) — the property `interpolate`'s `'barycentric'` mode does not
1074
+ * have. Both meshes are simplexified first (accepting ragged/polyhedron
1075
+ * blocks for free, unlike a restricted cell-type scope). Unlike
1076
+ * `interpolate`, an empty `arrays` transfers every source point_data AND
1077
+ * cell_data array — there is one algorithm regardless of location. Output
1078
+ * arrays are always Float64.
1079
+ * @throws {Error} on an unknown onConflict, an unknown array name, a name
1080
+ * collision under `'error'`, mismatched maximum topological dimensions
1081
+ * between the two meshes, or no triangle/tetrahedron cells on either
1082
+ * side after simplexification.
1083
+ */
1084
+ conservativeInterpolate(
1085
+ source: Mesh,
1086
+ target: Mesh,
1087
+ arrays?: string[],
1088
+ defaultValue?: number,
1089
+ onConflict?: ConservativeInterpolateOnConflict,
1090
+ ): Mesh;
1091
+
1017
1092
  /**
1018
1093
  * Green-element undo: restore `fine`'s transitional (closure-only) cells
1019
1094
  * back to their original parent, read verbatim from `coarse` — a lookup,
@@ -1248,6 +1323,41 @@ export interface MeshioPlusPlusModule {
1248
1323
  overwrite?: boolean,
1249
1324
  ): { mesh: Mesh; numSkipped: number; numFallback: number };
1250
1325
 
1326
+ /**
1327
+ * The Hessian (second derivative) of a **scalar** `point_data` field --
1328
+ * `gradient`'s companion one order further, for curvature-based adaptive
1329
+ * refinement.
1330
+ *
1331
+ * A composition of TWO `gradient` calls, not a new numerical kernel: the
1332
+ * field is differentiated once (point location), then that `(n, 3)`
1333
+ * gradient is differentiated again with the default gradient operator,
1334
+ * producing `(n, 9)` -- the flattened row-major 3x3 Hessian, `H[i][j]` at
1335
+ * index `i*3+j`. `method` is forwarded to BOTH internal passes. The width
1336
+ * travels with the array in the returned mesh's `point_data_components` /
1337
+ * `cell_data_components` maps, exactly as `gradient`'s own output does.
1338
+ *
1339
+ * A field that is at most LINEAR has an exactly zero Hessian everywhere --
1340
+ * the one mesh-shape-independent guarantee. For a genuinely quadratic
1341
+ * field the composition is exact on a structured/symmetric mesh away from
1342
+ * its own boundary and a good, standard, but genuinely approximate
1343
+ * curvature estimate on an irregular mesh (see doc/hessian.md).
1344
+ *
1345
+ * A curvature-driven refinement indicator needs no new API: `norm(...)`
1346
+ * in `dataCalc` on the 9-component output is exactly its Frobenius norm,
1347
+ * ready for `refine`'s `where` selector.
1348
+ * @throws {Error} when `array` names a `cell_data` array (piecewise
1349
+ * constant, so it has no derivative), an unknown array, or an array
1350
+ * with more than one component (hessian is scalar-only).
1351
+ */
1352
+ hessian(
1353
+ mesh: Mesh,
1354
+ array: string,
1355
+ method?: GradientMethod,
1356
+ location?: 'point' | 'cell',
1357
+ output?: string,
1358
+ overwrite?: boolean,
1359
+ ): { mesh: Mesh; numSkipped: number; numFallback: number };
1360
+
1251
1361
  /**
1252
1362
  * The Zienkiewicz-Zhu (ZZ) recovery-based error indicator of a `point_data`
1253
1363
  * field, plus optional marking. A composition of `gradient` (Green-Gauss,
@@ -1472,6 +1582,14 @@ export interface MeshioPlusPlusModule {
1472
1582
  /** Read-only per-array summary of every data array the mesh carries. */
1473
1583
  dataInfo(mesh: Mesh): DataArrayInfo[];
1474
1584
 
1585
+ /**
1586
+ * Cell-measure-weighted total/mean of one or more cell_data arrays --
1587
+ * gradient's integration counterpart. `arrays` empty/undefined means
1588
+ * every cell_data array. A point_data-only name throws naming
1589
+ * dataPointToCell as the fix. See doc/field_integration.md.
1590
+ */
1591
+ dataIntegrate(mesh: Mesh, arrays?: string[]): FieldIntegralArray[];
1592
+
1475
1593
  /**
1476
1594
  * Open a transient (time-series) XDMF writer on the virtual filesystem --
1477
1595
  * the one stateful object in this API. See {@link XdmfTimeSeriesWriter} for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshioplusplus/wasm",
3
- "version": "10.6.0",
3
+ "version": "10.9.0",
4
4
  "description": "meshio++ mesh I/O compiled to WebAssembly: read/write 41 mesh formats (incl. MED, CGNS, Exodus) in the browser or Node.js",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/index.mjs CHANGED
@@ -160,6 +160,7 @@ function resolveVariant(variant) {
160
160
  * distanceToSurface: (query: Mesh, surface: Mesh, sign?: string, location?: string, band?: number, recordInside?: boolean, watertightCheck?: string) => {mesh: Mesh, numBanded: number, quality: object},
161
161
  * computeSdf: (surface: Mesh, structure?: string, resolution?: number[], cellSize?: number, bounds?: number[], padding?: number, paddingRelative?: number, rootResolution?: number, maxDepth?: number, bandCells?: number, recordLevels?: boolean, maxCells?: number, sign?: string, location?: string, band?: number, watertightCheck?: string) => {mesh: Mesh, dims: number[], origin: number[], spacing: number[], maxDepth: number, numBanded: number, quality: object},
162
162
  * gradient: (mesh: Mesh, array: string, operator?: string, method?: string, location?: string, output?: string, component?: number, overwrite?: boolean) => {mesh: Mesh, numSkipped: number, numFallback: number},
163
+ * hessian: (mesh: Mesh, array: string, method?: string, location?: string, output?: string, overwrite?: boolean) => {mesh: Mesh, numSkipped: number, numFallback: number},
163
164
  * estimateError: (mesh: Mesh, array: string, method?: string, marking?: string, markingValue?: number, output?: string, marked?: string, overwrite?: boolean) => {mesh: Mesh, globalError: number, numSkipped: number, numMarked: number},
164
165
  * split: (mesh: Mesh, by: string, tagName?: string) => {key: string, mesh: Mesh}[],
165
166
  * convertCells: (mesh: Mesh, mode?: string, recordParentIds?: boolean) => Mesh,
@@ -177,6 +178,7 @@ function resolveVariant(variant) {
177
178
  * dataCalc: (mesh: Mesh, expression: string, location: string, outputName: string, overwrite?: boolean) => Mesh,
178
179
  * dataCondition: (mesh: Mesh, location: string, names?: string[], mode?: string, lo?: number, hi?: number, scope?: string, nanPolicy?: string, nanReplacement?: number, suffix?: string) => Mesh,
179
180
  * dataInfo: (mesh: Mesh) => object[],
181
+ * dataIntegrate: (mesh: Mesh, arrays?: string[]) => object[],
180
182
  * createXdmfTimeSeriesWriter: (path: string, options?: {dataFormat?: string, gzipLevel?: number, mode?: 'truncate'|'append', autoFlush?: boolean}) => XdmfTimeSeriesWriter,
181
183
  * }>}
182
184
  */
@@ -355,6 +357,23 @@ export async function loadMeshioPlusPlus(moduleOverrides = {}, { variant = 'auto
355
357
  defaultValue,
356
358
  onConflict,
357
359
  ),
360
+ // Mass-preserving cross-mesh field transfer: an exact overlap-measure
361
+ // weighted remap (unlike interpolate's pointwise sampling). An empty
362
+ // `arrays` = every source point_data AND cell_data array.
363
+ conservativeInterpolate: (
364
+ source,
365
+ target,
366
+ arrays = [],
367
+ defaultValue = 0,
368
+ onConflict = 'error',
369
+ ) =>
370
+ Module.conservativeInterpolate(
371
+ source,
372
+ target,
373
+ arrays,
374
+ defaultValue,
375
+ onConflict,
376
+ ),
358
377
  // Restore `fine`'s transitional (green) cells to their coarse parent,
359
378
  // read verbatim from `coarse` (a lookup, not a reconstruction).
360
379
  undoGreen: (coarse, fine) => Module.undoGreen(coarse, fine),
@@ -437,6 +456,14 @@ export async function loadMeshioPlusPlus(moduleOverrides = {}, { variant = 'auto
437
456
  overwrite = false,
438
457
  ) =>
439
458
  Module.gradient(mesh, array, operator, method, location, output, component, overwrite),
459
+ hessian: (
460
+ mesh,
461
+ array,
462
+ method = 'green-gauss',
463
+ location = 'cell',
464
+ output = '',
465
+ overwrite = false,
466
+ ) => Module.hessian(mesh, array, method, location, output, overwrite),
440
467
  estimateError: (
441
468
  mesh,
442
469
  array,
@@ -547,6 +574,7 @@ export async function loadMeshioPlusPlus(moduleOverrides = {}, { variant = 'auto
547
574
  mesh, location, names, mode, lo, hi, scope, nanPolicy, nanReplacement, suffix,
548
575
  ),
549
576
  dataInfo: (mesh) => Module.dataInfo(mesh),
577
+ dataIntegrate: (mesh, arrays = []) => Module.dataIntegrate(mesh, arrays),
550
578
  // Transient (time-series) XDMF -- the one *stateful* thing in this API.
551
579
  // The raw binding is an opaque integer handle plus seven free
552
580
  // functions (see bindings/wasm/js_bindings.cpp for why it is not an