npm.io
1.0.25 • Published 20h ago

w-mesh-gms

Licence
MIT
Version
1.0.25
Deps
1
Size
1.3 MB
Vulns
0
Weekly
0

w-mesh-gms

A tool for GMS data.

language npm version license npm download npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Installation

Using npm(ES6 module):
npm i w-mesh-gms
Example for read:

Link: [dev source code]

import fs from 'fs'
import _ from 'lodash-es'
import wmg from './src/WMeshGms.mjs'


function ttc(name, nodes, eles) {

    //head
    let head = `TITLE = "Mesh" VARIABLES = "X", "Y", "Z", "M"`

    //c
    let c = head + '\n'

    //h
    let h = `ZONE T="${name}",N=${_.size(nodes)}, E=${_.size(eles)}, F=fepoint, ET=brick`
    c += h + '\n'

    _.each(nodes, (node) => {
        let vs = [
            node.x,
            node.y,
            node.z,
            node.mat,
            // v1,
            // v2,
            // v3,
        ]
        let t = _.join(vs, ' ')
        c += t + '\n'
    })

    _.each(eles, (ele) => {
        let vs = ele.nodes
        let t = _.join(vs, ' ')
        c += t + '\n'
    })

    return c
}

let fpXyz = './_mesh/YiLan_xyz.txt'
let fpTop = './_mesh/YiLan_top.txt'
let fpBot = './_mesh/YiLan_bot.txt'
let fpMat = './_mesh/YiLan_mat.txt'
let fpOut = './_mesh/cv2tecplot.dat'
let name = 'cv2tecplot'

console.log('reading...')
wmg.readGms(fpXyz, fpTop, fpBot, fpMat)
    .then((r) => {

        console.log('converting...')
        let tc = ttc(name, r.nodes, r.eles)

        console.log('writing...')
        fs.writeFileSync(fpOut, tc, 'utf8')

        console.log('finish.')
    })
    .catch((err) => {
        console.log(err)
    })
Example for write:

Link: [dev source code]

尚待開發

Keywords