![]() Export the surfaces &/or post-process your changed/target case as normal – now with delta flow fields □.Use mapFields to subtract the baseline/source fields from the changed/target fields, leaving you with a delta for each of the variables in your case.Rinse & Repeat in your changed/target case.Reconstruct this new little mesh & the data (this isn’t strictly necessary, but it speeds up mapFields, later on).Subset your volume mesh – subSetMesh– so that only those selected cells remain (don’t use -overwrite □).Use topoSet to select the cells that border the surfaces you’re interested in, using its patchToSet action.Delta = Changed – Baseline = Target – Source.A Changed case that will be your Target.A Baseline case that will be your Source.Choose two solved cases (they can have different volume meshes).So, I tweaked the workflow to give it less to do & now your deltas will be done & dusted before the kettle’s even boiled. A bit much if you just want surface deltas. You can make (& drink) several cups of tea while it crawls over your whole volume. But it’s super-slow on a “big” mesh (whatever “big” means). Think, transferring the results from a coarse-mesh onto a finer-mesh, to be used as the starting point for a new run. The mapFields utility in OpenFOAM is intended (AFAIK) to be a PRE-processing tool, used to map results from one mesh to another. I always ended up with lots of faces that couldn’t be matched & very blotchy-looking plots. You can get pretty close using ParaView, combining the Resample with Dataset & Append Attributes filters, but I never got great results. It’s not restricted to surfaces, you can also do it with volumes. It’s a useful alternative to playing spot-the-difference with two almost identical plots □ I’m guessing you already know, but just in case – a delta plot takes common(ish) surfaces from two different cases, calculates the difference between their two flow fields & uses this “delta” to illustrate where the flow has changed. ![]() One of the most elusive was “the delta plot”. Some things were rendered obsolete by new OpenFOAM functionality. Duct taping standard OpenFOAM/ParaView/Unix tools together in new & imaginative ways was (& still is) the order of the day. I’m not a developer, so rolling my own versions of those tools wasn’t quite so magical. Admittedly, some things were more useful than others, but nevertheless, it was still like magic.įast-forward to me going solo. We had a small team of developers who could conjure up new CFD tools as if by magic. I figured something out, something that’s been niggling me for a decade & I’m going to tell you about it…1) ‘cos I’m super-happy that I figured it out & 2) ‘cos that’s what this email is all about – sharing stuff that you might find useful. You know when people show you their baby/pet/baking pictures & you have to respond like it’s the cutest/cleverest/tastiest little specimen you ever did see? Well, this email is just like that. I want to share a little CFD win this week – delta plots – let’s go… The same applies to np.mean(), np.nanmean(), np.std(), np,nanstd(), etc.It’s Robin from CFD Engine, back with your weekly CFD note. If you want to avoid nan, simply use np.nansum(): da.resample(time="QS-DEC").reduce(np.nansum) So, using np.sum() the output with the nan is in the first quarter: import numpy as npĭa.resample(time="QS-DEC").reduce(np.sum) Nan is in the first quarter (not in the second as you expect) You can use the combination of xarray resample and reduce: #Dummy function to see the array groupingĭef func(x, axis): #reduce expect a function with axis argument * time (time) datetime64 answer: da.resample(time="QS-DEC",skipna=False).mean() xarray also allows resample.apply(own_func) but I have problems defining the own func.Įxample ( from xarray's documentation) : dat=np.linspace(0, 11, 12) function giving me my preferred nan treatment. With pandas I can easily apply an own mean,sum etc. the sum or mean with each resulting value being nan when at least one of the input values was nan. ![]() I'd like to resample a xarray dataset e.g.
0 Comments
Leave a Reply. |