Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions smithers/io/openfoam/mesh_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,18 @@ def parse_line(line):
except ValueError:
pass

string_coords = content[start_idx:start_idx+num_points]
if not is_binary:
string_coords = content[start_idx:start_idx+num_points]

data = np.array(list(map(parse_line, string_coords)), dtype=float)
return data

#TODO binary
# if is_binary:
# buf = b''.join(content[n+1:])
# disp = struct.calcsize('c')
# vv = np.array(struct.unpack('{}d'.format(num*3),
# buf[disp:num*3*struct.calcsize('d') + disp]))
# data = vv.reshape((num, 3))
data = np.array(list(map(parse_line, string_coords)), dtype=float)
else:
buf = b''.join(content[start_idx-1:])
disp = struct.calcsize('c')
vv = np.array(struct.unpack('{}d'.format(num_points*3),
buf[disp:num_points*3*struct.calcsize('d') + disp]))
data = vv.reshape((num_points, 3))

return data

@classmethod
def parse_owner_neighbour_content(cls, content, is_binary, skip=10):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


6
(
inlet
{
type patch;
nFaces 100;
startFace 143280;
}

outlet
{
type patch;
nFaces 100;
startFace 143380;
}

top
{
type wall;
inGroups List<word> 1(wall);
nFaces 420;
startFace 143480;
}

bottom
{
type wall;
inGroups List<word> 1(wall);
nFaces 420;
startFace 143900;
}

obstacle
{
type wall;
inGroups List<word> 1(wall);
nFaces 400;
startFace 144320;
}

frontAndBack
{
type empty;
inGroups List<word> 1(empty);
nFaces 144000;
startFace 144720;
}

)


// ************************************************************************* //
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: http://www.foam-extend.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;

nu nu [0 2 -1 0 0 0 0] 1.5e-5;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 4.0 |
| \\ / A nd | Web: http://www.foam-extend.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 changes: 56 additions & 0 deletions tests/test_datasets/openfoam_mesh_binary/0/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
arch "LSB;label=32;scalar=64";
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 1 -1 0 0 0 0 ];

internalField uniform ( 0 0 0 );

boundaryField
{
inlet
{
type fixedValue;
value uniform ( 0.0001 0 0 );
}
outlet
{
type zeroGradient;
}
top
{
type fixedValue;
value uniform ( 0 0 0 );
}
bottom
{
type fixedValue;
value uniform ( 0 0 0 );
}
obstacle
{
type fixedValue;
value uniform ( 0 0 0 );
}
frontAndBack
{
type empty;
}
}


// ************************************************************************* //
53 changes: 53 additions & 0 deletions tests/test_datasets/openfoam_mesh_binary/0/p
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
arch "LSB;label=32;scalar=64";
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [ 0 2 -2 0 0 0 0 ];

internalField uniform 0;

boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
top
{
type zeroGradient;
}
bottom
{
type zeroGradient;
}
obstacle
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}


// ************************************************************************* //
Binary file added tests/test_datasets/openfoam_mesh_binary/1088/U
Binary file not shown.
Binary file added tests/test_datasets/openfoam_mesh_binary/1088/p
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/test_datasets/openfoam_mesh_binary/1088/uniform/time
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "1088/uniform";
object time;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

value 1088.00000000011028;

name "1088";

index 5440;

deltaT 0.2;

deltaT0 0.2;


// ************************************************************************* //
Binary file added tests/test_datasets/openfoam_mesh_binary/4196/U
Binary file not shown.
Binary file added tests/test_datasets/openfoam_mesh_binary/4196/p
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/test_datasets/openfoam_mesh_binary/4196/uniform/time
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "4196/uniform";
object time;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

value 4195.99999999837473;

name "4196";

index 20980;

deltaT 0.2;

deltaT0 0.2;


// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
arch "LSB;label=32;scalar=64";
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


6
(
inlet
{
type patch;
nFaces 100;
startFace 143280;
}

outlet
{
type patch;
nFaces 100;
startFace 143380;
}

top
{
type wall;
inGroups List<word> 1(wall);
nFaces 420;
startFace 143480;
}

bottom
{
type wall;
inGroups List<word> 1(wall);
nFaces 420;
startFace 143900;
}

obstacle
{
type wall;
inGroups List<word> 1(wall);
nFaces 400;
startFace 144320;
}

frontAndBack
{
type empty;
inGroups List<word> 1(empty);
nFaces 144000;
startFace 144720;
}

)


// ************************************************************************* //
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading