# nanoFluidX Companion

nanoFluidX companion, also known as nFX[c], is a post-processing tool developed to accompany the nanoFluidX solver allowing for an easier execution of certain post-processing tasks.

Use nFX[c] to execute a post-processing step that is known in ParaView as SPH Volume Interpolation and, optionally, Temporal Statistics. It does so using the same VTK libraries as ParaView and with less user interaction. Alternatively, nFX[c] can be used to interpolate nanoFluidX output data onto an AcuSolve mesh, or any other mesh (point cloud) provided to it (assuming appropriate format).

nFX[c] is shipped together with the nFX binary and can be found in the same folder as the nFX binary.

The output of the nFX[c] is a mesh-based data set, which can be broken down into separate variable fields for faster loading.
Restriction: The SPH volume interpolation in nFX[c] is carried out only for FLUID, not for WALL or MOVINGWALL phase types.
Benefits of using nFX[c] as a post-processing include the following:
• No need for SPH Volume Interpolation inside ParaView, which results in fewer filters and less need to involve a workflow.
• Create movies in minutes instead of hours.
• Photorealistic rendering using the OSPRay plugin in ParaView becomes plausible.
• Automatically execute and save temporal statistics.
Important: The relative paths in nanoFluidX are relative to the nanoFluidX cfg path, whereas in nFX[c] the relative paths are with respect to the present work directory (pwd). The recommended running approach is to cd to the case folder directory and run nFX[c] from there. Both cfg files do not need to be in the same directory. This avoids any possible confusion between launching nFX[c] and nanoFluidX.

## Using nFX[c]

The usage of nFX[c] is fairly straightforward as it is in principle similar to using nanoFluidX. In that sense it requires its own .cfg file with the commands described below. Once set_nFX_environment.sh script has been sourced and the nFX[c] .cfg file set up, the following command will execute basic post-processing:
nFXc example.cfg
If performing AcuSolve mesh interpolation, the command would be:
nFXc --acusolve example.cfg
Note: nFX[c] only needs one of these sections at a time (postparams, acupostparams, or cldpostparams).
postparams
{
PostJobName     postjobname
OutputFormat    vtk

TandemInterp    false
FrameSuite      inplace

ThrshFirst      false
ConstPrtlVol    true
Normalize       false
NormLowThrsh    0.25
SpacingFactor   1.0

InstOutRange    all
InstOutStart    0.5
InstOutEnd      0.9

Overwrite       false
InstOutRange    all
InstOutStart    0.5
InstOutEnd      1.0

BreakVars       true
ArchiveData     0
TimeAvg         true
TimeAvgStart    0.5
TimeAvgEnd      1.0
}
acupostparams
{

SaveAsVTU       true

MeshDataRoot    path/to/acusolve/mesh
cnnFile         filename.cnn
crdFile         filename.crd
specFile        filename.nic
presFile        filename.nic
veloFile        filename.nic

MeshScale       1

ThrshFirst      false
TimeAvgStart    0.5
TimeAvgEnd      1.0
}
cldpostparams
{

SaveAsVTU       true

MeshDataRoot    path/to/acusolve/mesh
crdFile         filename
specFile        filename
presFile        filename
veloFile        filename

MeshScale       1

ThrshFirst      false
TimeAvgStart    0.5
TimeAvgEnd      1.0
}

## nFX[c] Commands

Full path to the directory containing simulation data and Used_casefile.cfg.
Enclose [CaseDataDir] in quotation marks if it contains any blank space.
PostJobName
Job name (used as the folder name to store interpolated data).
It may not be empty or contain/character.
Enclose [PostJobName] in quotation marks if it contains any blank space.
OutputFormat
Output format of the interpolated data files containing all variables.
vtk option will export only VTK format, whereas vtkens will export both VTK and EnSight Gold format results with structured fluid and unstructured solid coordinates. By using vtkp option, VTK image (vti and pvd) file as well as pretransformed solid surfaces combined with fluid data (vti, vtp, vtm and pvd), will be exported.
Options: vtk/vtkens/vtkensu/vtkp
TandemInterp
Interpolate during nanoFluidX runtime.
Options: true/false
FrameSuite
Interpolate during nanoFluidX runtime.
This command supports the nanoFluidX frame suite set of features. It allows for the user to choose whether the interpolated data will be simply interpolated as is in the simulation (inplace) or will the coordinates and velocities be transformed such that the car would appear static (transform).
If the transform is selected, the car will appear static in the interpolated data. This may allow for easier and more intuitive post-processing, despite the simulation actually running with a sliding frame settings.
Options: inplace/transform
Default: inplace
ThrshFirst
Setting this to true executes a split between all the phases (threshold filter) before proceeding to the SPH data interpolation.
This is the common way it is done in ParaView, however it is not the preferred way. It is recommended to set this to false, as the property interpolation will in that case include WALL and MOVINGWALL phases, which will make for a better representation of the results.
Note: For this command to take effect when set to true, solid particles WALL and MOVINGWALL need to be output.
Options: true/false
ConstPrtlVol
Setting this to true is similar to standard ParaView command execution. Setting it to false uses kernel summation as a volume value and is much more time consuming.
It is recommended that you keep this command set to true.
Options: true/false
Normalize
Divide all the variables by the Shepard Summation, to likely produce more uniform and accurate results. Some cases may cause occurrence of discontinuities or unphysical data in the results.
It is recommended that unless you are confident in understanding what division by Shepard Coefficient implies, keep this command set to false.
Options: true/false
NormLowThrsh
This command is optional.
When Normalize is true, the values will be normalized only if the local Shepard Summation is larger than or equal to NormLowThrsh value. By using this option the renormalized output data will avoid peaks in the representation of the variables when there are lone particles in the data.
The command has no effect when Normalize is false.
Default: 0.25
SpacingFactor
A number value that determines the resolution of the mesh data.
dx_mesh_data = dx_simulation*SpacingFactor
For maximum accuracy set to 1.0.
For speedier (and coarser) interpolation use values higher than 1.0.
Setting this below 1.0 does not gain anything and slows down the post-processing.
Overwrite
Overwrite previous data in a job folder to avoid unintentional overwriting.
It is recommended that you set this command to false for first job run.
Note: You may return to a previous job (restart nFX[c]) by setting [Overwrite] to false. When returning to a previous job, nFX[c] will continue from the last converted file.

Changing [BreakVars], [TimeAvg], [TimeAvgStart] or [TimeAvgEnd] is allowed in a returning job.

Changing [CaseDataDir], [PostJobName], [ThrshFirst], [ConstPrtlVol], [Normalize] or [SpacingFactor] is not allowed in a returning job.

Options: true/false
InstOutRange
Interpolation and writing of instantaneous output is controlled by this option.
Options: all, none, custom
Specifying all will interpolate and write all the instantaneous output.
Specifying none will not write any instantaneous output at all. This can be used, for example, if you want to only output the time averaged result.
Specifying the custom option allows you to define a specific time range in which you want the instantaneous output written.
InstOutStart
If you have specified the InstOutRange as custom, this command marks the beginning of the time interval where instantaneous data is written.
InstOutEnd
If you have specified the InstOutRange as custom, this command marks the end time of the interval where instantaneous data is written.
BreakVars
Save each variable in a separate file for faster load in addition to the single file containing all variables.
It is recommended that you set this command to true.
ArchiveData
This command is optional.
Archive data after the interpolation depending on the selected option:
0
No archiving
1
Create a tar file PostJobName.tar in CaseDataDir from PostJobName/AllVars, MOTION, LOG, PHASEINFO, PROBEINFO, PVSTATE/PostJobName.py, PVSTATE/phaseinfo* and PVSTATE/probeinfo*.
1+
Same as 1, but with additional OUTPUT and PVSTATE/particles.py
2
gzip compress the archive outlined in item 2 creating [PostJobName].tar.gz in [CaseDataDir]
2+
Same as 2, but with additional OUTPUT and PVSTATE/particles.py.
Default: 0
TimeAvg
Time average of the data.
It is recommended that you set this command to true.
TimeAvgStart
Starting time after you want to start averaging the data. Because of the transient nature of the simulation, ramp-up time of the RPM can bias the time-averaged result.
It is recommended that you set this to the time when the ramp-up of the motions ends.
TimeAvgEnd
Ending time for the time averaging.
This command is usually set to be the final time of the simulation, or larger than simulation time.
nanoFluidX Companion has the capability to specify the number of threads that the code will use to execute the interpolation task.
This command is an integer number specifying the number of threads that you want to dedicate to nFX[c] post-processing.
The following set of parameters are used to interpolate nanoFluidX data onto an AcuSolve or arbitrary mesh.
SaveAsVTU
To inspect your interpolation, you are allowed to export a VTU dataset to visualize in ParaView.
It is recommended that you set this command to true.
MeshDataRoot
Full path to the directory containing mesh data of AcuSolve (or an arbitrary mesh). Interpolated data will be saved in this folder as well.
Enclose [MeshDataRoot] in quotation marks, if it contains any blank space.
It is recommended that you set this command to true.
cnnFile
Nodal connectivity file for the fluid region.
Only applicable for the AcuSolve mesh interpolation.
Provide the name including the file extension (.cnn).
crdFile
Node coordinates file for the fluid region.
Only applicable for both the AcuSolve and arbitrary mesh interpolation.
Provide the name including the file extension (.crd in case of AcuSolve mesh)
If using this command to interpolate nanoFluidX data to an arbitrary mesh, the format that the cfdFile file needs to satisfy is either:
NodeID		X	Y	Z
or
X	Y	Z
Where, the delimiter is space.
specFile
Full name (including the extension) of the output file containing interpolated volume fraction.
Applicable for both the AcuSolve and arbitrary mesh interpolation.
Provide the name including the file extension (.nic in case of AcuSolve mesh).
presFile
Full name (including the extension) of the output file containing interpolated pressure field.
Applicable for both the AcuSolve and arbitrary mesh interpolation.
Provide the name including the file extension (.nic in case of AcuSolve mesh).
veloFile
Full name (including the extension) of the output file containing interpolated velocity field.
Applicable for both the AcuSolve and arbitrary mesh interpolation.
Provide the name including the file extension (.nic in case of AcuSolve mesh).
combFile
Full name (including the extension) of the output file containing coordinates and interpolated values arranged as x,y,z,u,v,w,p,s (path always relative to MeshDataRoot).
The output file, when set to true, is an internally generated cloud point (hex) mesh with coordinates, velocities, pressure, and species output.
If not defined, nFX[c] will search for veloFile, presFile and specFile.
MeshScale
Coordinate data is multiplied by [MeshScale] before interpolation.

To further clarify the relationship of the options, note the following items.

MeshDataRoot is always required. Points to the reading and writing directory.
• crdFile is the key to activating internal generation. If provided, the points in the file will be used. Otherwise, internal point generation will be used.
• specFile, presFile, veloFile, combFile:
• At least one set of specFile, presFile, veloFile or combFile is needed. Both can be present.
• specFile, presFile, veloFile: Optional, if one is provided, all should be available.
• Without crdFile, there will be an additional file containing the coordinates when the triplet file outputs are chosen.
• combFile: optional.
MeshScale: Equal to one when not provided. When set to zero, MeshScale is equal to nFX.domain.inputfile_factor. When non-zero, used as is.
• With a valid crdFile: The points read from crdFile will be multiplied by MeshScale value.
• Without crdFile: nFX.kernel.dx is multiplied by MeshScale before generating the internal cuboid based on nFX.domain.min/max_domain or nFX.domain.min/max_boundingbox expanded by nFX.kernel.dx.

## Special Note on Point-Cloud Interpolation and Coupling to AcuSolve

To provide a simpler avenue of using cloud point interpolation cldpostparams, nFX[c] is now able to perform interpolation and averaging of the nanoFluidX data onto an internally generated uniformly distributed cuboid of points based on nanoFluidX simulation settings. This allows for quick preparation of interpolated data sets for use in other applications. One such application is to conduct a SimLab mediated nanoFluidX-AcuSolve off-line one-way coupled simulation, where SimLab performs a further interpolation onto the AcuSolve mesh internally. This provides an alternative to direct interpolation to an AcuSolve mesh for nanoFluidX-AcuSolve off-line one-way coupled simulation.

Highlights:
• Support for internally generated cuboid of points based on nanoFluidX cfg for pointcloud interpolation mode in nFX[c].
• Support for comma separated output of coordinates, velocities, pressure and volume fraction in nFX[c] pointcloud (--pointcloud) and image (--nfx) interpolation modes.
• Support for SimLab mediated nanoFluidX/AcuSolve off-line one-way coupled thermal simulation via comma separated output.
The current nanoFluidX/AcuSolve off-line one-way coupled simulation implementation has the following characteristics:
• Only fully filled containers of one or two fluid phases are supported.
• The flow field data is time averaged and carries no trace of fluctuations or transient information. Fluctuations and transient events may or may not have an impact on the average heat transfer rate.
• The time averaged field is inherently non-solenoidal (not divergence-free). This may or may not affect the convergence of the solution observed via fluxes.
• The time averaged field may have signs of boundary layers that are not affected by the motions.
• The time averaged field is motion void compensated. This applies to locations in AcuSolve geometry where a fluid is expected but contain intermittent fluid/solid presence during nanoFluidX simulation due to motions.
• The AcuSolve solution does not have any transient or moving components. It may or may not be suitable to compensate this by averaging the results over the moving parts. The following items when using the internal point cloud for SimLab 2020.1 mediated nanoFluidX-AcuSolve off-line one-way coupled simulation. These points may or may not be important.
• Interpolation to a body fitted mesh has the advantage that motion void compensation is more likely to coincide with the points on the surface. The interpolation to a cuboid of points does not follow the surfaces that have contact with fluid and motion void compensation may not be as effective. Further interpolation on this field disregards the original compensation. However, this may not be as important in practice as the output of nFX[c] is averaged over time and may be less susceptible to further interpolation errors.
• The SimLab mediation process involves double interpolation, first to a uniformly spaced cuboid and then to a body fitted mesh. In principle, this may lead to non-negligible interpolation errors. In practice, the output of nFX[c] is averaged over time and may be less susceptible to further interpolation errors.
• SimLab 2020.1 uses a nearest neighbor interpolation scheme. In principle, this may lead to non-negligible interpolation errors. In practice, the output of nFX[c] is averaged over time and may be less susceptible to further interpolation errors.

## EnSight Gold output file format support

To provide users with a wider choice in post-processing tools as well as facilitating the development of Altair post-processors such as HW-CFD in its current form, nFX[c] 2021.2 offers an additional output option in EnSight Gold Case file format.

To activate the EnSight Gold format output the user needs to add OutputFormat command to the postparam section of the nFX[c] configuration file and specify its value to either vtk or vtkens value.

Choosing the vtkens option results in the creation of an additional directory named EnsVars besides AllVars directory under PostJobName directory to store all EnSight Gold files. The EnSight Gold files include data of each variable as well as the geometry in separate files and as a result setting BreakVars to true has no effect on the EnSight Gold output. EnSight Gold files are larger than VTK image files since they do not offer data compression. Additionally, please note that currently it is not possible to avoid VTK image output as the files are required for reducing the complexity of returning nFX[c] jobs.

The EnSight Gold output written by nFX[c] has three elements. These are data files for each output time, geometry files for each output time and a case file referencing the other files and defining time information. The EnSight Gold data files only contain fluid data while geometry files include both fluid interpolation points (block uniform or image) and solid surfaces (coordinates or unstructured) at the time of the output. The geometry file description for the fluid interpolation points reads FLUID(s) and moving walls and stationary walls are described as MOVINGWALL: phasename and WALL: phasename, respectively, where phasename is the name of the respective solid phase. The geometry file of the time averaged data includes solids at the first input time of the field data pvd file from nanoFluidX.

When opened in ParaView, an EnSight Gold case file appears as multiblock data with geometry file descriptions shown as block names. Use an Extract Block filter to visualize separate blocks. Similar to their pvd counterparts, transient and time averaged case files are named interpData.case and timeAverage.case, respectively.

nFXc  --help
nFXc