Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bar2vtk) Allow arbitrary read/write values #63

Open
jrwrigh opened this issue Aug 6, 2021 · 1 comment
Open

(bar2vtk) Allow arbitrary read/write values #63

jrwrigh opened this issue Aug 6, 2021 · 1 comment

Comments

@jrwrigh
Copy link
Member

jrwrigh commented Aug 6, 2021

Allow for reading in arbitrary binary files with arbitrary ordering of data. Namely for SST velbar files, which include the TKE and Omega in them.

Allow for explicitly declaring the order of the components of a binary array by a comma-separated string, and have automatic treatment of those values.

Standard processed values:

String Value
u, v, w (Mean) Velocity components
p (Mean) pressure
uu, vv, ww, uv, uw, vw (Mean) Velocity product (to calculate Reynolds stress by <u'u'> = <uu> - <u><u> )

Any other values parsed will simply be passed to the vtm file.

Examples:

Example String
Standard velbar file 'u,v,w,p'
Standard stsbar file 'uu,vv,ww,uv,uw,vw'
SST velbar file 'u,v,w,p,k,omega'
@jrwrigh
Copy link
Member Author

jrwrigh commented Jan 11, 2022

Psuedocode/snippets:

def parseArbitraryInput(input: str):
    collist = input.split(',')
    velmap = ['u', 'v', 'w']
    reystrmap = ['uu', 'vv', 'ww', 'uv', 'uw', 'vw']
    velindx =  [-1]*3
    reystrindx = [-1]*6
    other = {}
	for i, col in enumerate(collist):
        if col in velmap:
            velindx[velmap.index(col)] = i
        elif col in reystrmap:
            reystrindx[reystrmap.index(col)] = i
        else:
            other[col] = i
    return velindx, reystrindx, other

Assume we have two lists: inputs and files, each entry of which corresponds to the others (so inputs[0] is the input string for files[0]). This would come out of the CLI parser.

# npnts defined somewhere else
data = {}
for input, file in zip(inputs, files):
    velindx, resystrindx, other = parseAribtraryInputs(input)
	ncols = len(velindx) + len(reystrindx) + len(other)
    rawdata = readBinaryArray(file, ncols)
    
    if not all([-1 == n for n in velindx]):
		if not 'Velocity' in data.keys(): data['Velocity'] = np.zeros((npnts,3))
		for i, idx in enumerate(velindx):
			if not idx == -1:
				data['Velocity'][i,:] = rawdata[idx,:]
	# Repeat for reynolds stress
    if other:
		for label, idx in other.items():
			data[label] = rawdata[idx,:]

data is now a dictionary of the "Velocity", "ReynoldsStress", and other random labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant