FlowModelingControl / flowtorch

flowTorch - a Python library for analysis and reduced-order modeling of fluid flows
GNU General Public License v3.0
131 stars 45 forks source link

csvdataloader #44

Closed JOEJOEJOE1231231231231 closed 10 months ago

JOEJOEJOE1231231231231 commented 10 months ago

Hello Can csvdataloader load data like foamdataloader? If possible, is the data format. csv or. dat? How can I use Openfoam to calculate the results and obtain CSV data?I used Paraview to extract data at a certain section and output it in CSV format. However, when I imported it using csvdataloader, the following error occurred image

AndreWeiner commented 10 months ago

Hi, the CSVDataloader has a constructor function to load CSV files generated by OpenFOAM's sampling function object. E.g., if you sample a plane as follows:

surface
{
    type            surfaces;
    libs            (sampling);
    writeControl    writeTime;

    surfaceFormat   raw;
    fields          (total(p)_coeff yPlus p rho T);

    // interpolationScheme cellPoint;  //<- default

    surfaces
    {
        airfoil
        {
            type            patch;
            patches         (airfoil);
            interpolate     true;
            invariant       true;  // Unaffected by mesh motion
            surfaceFormat   raw;
        }
    }
}

You can load the sample output as follows:

# you will need to adjust the path
path = "postProcessing/surfaces"
loader = CSVDataloader.from_foam_surface(path, "total(p)_coeff_airfoil.raw")
times = loader.write_times
fields = loader.field_names[times[0]]

If you want to parse ParaView CSV output, I suggest using the Pandas read_csv function directly. Best, Andre

JOEJOEJOE1231231231231 commented 10 months ago

Hi, I have successfully imported the org version of Openfoam data using the CSV dataloader of Flow Torch and completed SVD decomposition. Thank you very much!