w-mesh-gms

1.0.4 • Public • Published

w-mesh-gms

A tool for GMS data.

language npm version license gzip file size npm download npm download jsdelivr download

Documentation

To view documentation or get support, visit docs.

Installation

Using npm(ES6 module):

Note: w-mesh-gms is mainly dependent on lodash-es and wsemi.

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]

尚待開發

Readme

Keywords

Package Sidebar

Install

npm i w-mesh-gms

Weekly Downloads

75

Version

1.0.4

License

MIT

Unpacked Size

1.31 MB

Total Files

54

Last publish

Collaborators

  • semisphere