Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Mixing io ii #23

Merged
merged 11 commits into from
Jun 30, 2015
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
25 changes: 25 additions & 0 deletions Allwclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

export FOAM_MPI_INCLUDE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI/include
rm -rf dist build foam_wrappers.egg-info
pushd .
cd openfoam-interface
wclean
rm -rf build
popd
pushd .
rm -f openfoam-interface/internal-interface/bin/*
cd openfoam-interface/internal-interface/libs
wclean incompressibleTurbulenceModel/turbulenceModel
wclean incompressibleTurbulenceModel/RAS
rm -rf incompressibleTurbulenceModel
popd
pushd .
cd openfoam-interface/internal-interface/wrapper
python setup.py clean
wclean
rm -rf build
popd
find . -iname "*~" | xargs rm -f
find . -iname "log" | xargs rm -f
find . -iname "*pyc" | xargs rm -f
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ Release 0.1.1

* Surface tension setup fixed (#21)

Release 0.1.2
-------------

* Internal Interfaces wrapper added (#23)

19 changes: 11 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ Requirements
Installation
------------

Package foam_controlwrapper requires python 2.7.x, OpenFOAM 2.2.x and pyFoam 0.6.4
Package foam_controlwrapper requires python 2.7.x, OpenFOAM 2.2.2 and pyFoam 0.6.4

Installation is based on setuptools::

# build and install
python setup.py install

or::

# build for in-place development
python setup.py develop


Testing
-------

Expand All @@ -48,4 +42,13 @@ Directory structure
Subpackages:


- foam_controlwrapper -- wrapper class and tests for OpenFOAM -wrapping using pyFoam
- foam_controlwrapper -- wrapper class and tests for OpenFOAM using IO wrapping
- foam_internalwrapper -- wrapper class and tests for OpenFOAM wrapping using internal interfaces

Cleaning
-------

To run the cleaner run::

python setup.py clean

6 changes: 3 additions & 3 deletions foam_controlwrapper/examples/poiseuille.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"""

from simphony.core.cuba import CUBA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khiltunen, @jmarcelogimenez , the foam_controlwrapper/examples/poiseuille.py and foam_internalwrapper/examples/poiseuille.py are also mostly the same. Both types of wrappers support the same functionality, right? When looking at the files, it seems so..except for one minor thing (i.e. CUBAExt.NUMBER_OF_CORES).

I would think that these are examples of using simphony-openfoam (regardless of its its the INTERNAL or FILE-IO version). Therefore, foam_controlwrapper/examples/poiseuille.py and foam_internalwrapper/examples/poiseuille.py could be replaced by`examples/poiseuille.py``.

I would suggest not trying to tackle this in this PR but to address it in a seperate PR and an issue should be opened up now (e.g. "make a single poiseuille.py")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarcelogimenez , this comment has been not addressed. An issue should be opened if it is not going to be addressed in this PR.

from simphony.engine import openfoam
from simphony.engine import openfoam_file_io
from simphony.io.h5_cuds import H5CUDS
import os

wrapper = openfoam.FoamControlWrapper()
CUBAExt = openfoam.CUBAExt
wrapper = openfoam_file_io.FoamControlWrapper()
CUBAExt = openfoam_file_io.CUBAExt

name = 'poiseuille'

Expand Down
6 changes: 3 additions & 3 deletions foam_controlwrapper/examples/poiseuille_vof.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"""

from simphony.core.cuba import CUBA
from simphony.engine import openfoam
from simphony.engine import openfoam_file_io
from simphony.io.h5_cuds import H5CUDS
import os

wrapper = openfoam.FoamControlWrapper()
CUBAExt = openfoam.CUBAExt
wrapper = openfoam_file_io.FoamControlWrapper()
CUBAExt = openfoam_file_io.CUBAExt

name = 'poiseuille_vof'

Expand Down
4 changes: 2 additions & 2 deletions foam_controlwrapper/tests/test_plugin_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def test_plugin_integration(self):
"""

# Assert that we can import the openfoam plugin
from simphony.engine import openfoam
from simphony.engine import openfoam_file_io

# Check that the expected top level objects are available
self.assertTrue(hasattr(openfoam, 'FoamControlWrapper'))
self.assertTrue(hasattr(openfoam_file_io, 'FoamControlWrapper'))


if __name__ == '__main__':
Expand Down
5 changes: 5 additions & 0 deletions foam_internalwrapper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Functions, classes and constants exported here will be available
# when the `openfoam` module is imported.
from .foam_internalwrapper import FoamInternalWrapper
from .cuba_extension import CUBAExt
__all__ = ['FoamInternalWrapper', 'CUBAExt']
20 changes: 20 additions & 0 deletions foam_internalwrapper/cuba_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
""" Provisional CUBA keywords specific for this revision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file foam_internalwrapper/cuba_extension.py is identical to foam_controlwrapper/cuba_extension.py. There should be a single module that both the FILE-IO and INTERNAL wrapper uses.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarcelogimenez , this comment has been not addressed. An issue should be opened.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added #34


"""

from enum import IntEnum, unique


@unique
class CUBAExt(IntEnum):

INCOMPRESSIBLE = 1
COMPRESSIBLE = 2
VOF = 3
LAMINAR_MODEL = 4
GE = 5
PATCH_TYPE = 6
PHASE_LIST = 7
MAX_COURANT_NUMBER = 8
SURFACE_TENSION = 9
NUMBER_OF_CORES = 10
63 changes: 63 additions & 0 deletions foam_internalwrapper/examples/poiseuille.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Example to solve 2D poiseuille flow

"""

from simphony.core.cuba import CUBA
from simphony.engine import openfoam_internal
from simphony.io.h5_cuds import H5CUDS
import os

# Only for postprocessing purposes
import matplotlib.pyplot as plt

wrapper = openfoam_internal.FoamInternalWrapper()
CUBAExt = openfoam_internal.CUBAExt

name = 'poiseuille'

wrapper.CM[CUBA.NAME] = name

wrapper.CM_extensions[CUBAExt.GE] = (CUBAExt.INCOMPRESSIBLE,
CUBAExt.LAMINAR_MODEL)

wrapper.CM_extensions[CUBAExt.NUMBER_OF_CORES] = 1

wrapper.SP[CUBA.TIME_STEP] = 1
wrapper.SP[CUBA.NUMBER_OF_TIME_STEPS] = 1000
wrapper.SP[CUBA.DENSITY] = 1.0
wrapper.SP[CUBA.DYNAMIC_VISCOSITY] = 1.0

# this is just an example. It is not enough for general setting of BC's
wrapper.BC[CUBA.VELOCITY] = {'boundary0': (0, 0, 0),
'boundary2': 'zeroGradient',
'boundary1': (0.1, 0, 0),
'boundary3': 'empty'}
wrapper.BC[CUBA.PRESSURE] = {'boundary0': 'zeroGradient',
'boundary2': 0,
'boundary1': 'zeroGradient',
'boundary3': 'empty'}

mesh_file = H5CUDS.open(os.path.join(name, 'poiseuille.cuds'))
mesh_from_file = mesh_file.get_mesh(name)

print "Mesh name ", mesh_from_file.name

mesh_inside_wrapper = wrapper.add_mesh(mesh_from_file)

print "Case directory ", mesh_inside_wrapper.path

for cell in mesh_inside_wrapper.iter_cells():
cell.data[CUBA.PRESSURE] = 1.0
cell.data[CUBA.VELOCITY] = [0.0, 0.0, 0.0]
mesh_inside_wrapper.update_cell(cell)

# run returns the latest time
lastTime = wrapper.run()
print "lastTime: " + str(lastTime)

print "post-processing"
XYZUVW = mesh_inside_wrapper.getXYZUVW()
plt.quiver(XYZUVW[:, 0], XYZUVW[:, 1], XYZUVW[:, 3], XYZUVW[:, 4])
plt.axis('equal')
plt.savefig("result.png")
plt.show()
Binary file not shown.
Loading