From 24f511be90f1510aca834adf438897dd10fdee85 Mon Sep 17 00:00:00 2001 From: Ping He Date: Sun, 16 Jun 2024 16:57:32 -0500 Subject: [PATCH] Added an API to read OF fields. --- pyofm/__init__.py | 2 +- pyofm/pyOFM.py | 14 ++++++++++++ src/OFMesh.H | 56 +++++++++++++++++++++++++++++++++++++++++++++-- src/pyOFMesh.pyx | 17 ++++++++++++-- src/setup.py | 3 +++ 5 files changed, 87 insertions(+), 5 deletions(-) diff --git a/pyofm/__init__.py b/pyofm/__init__.py index 656569d..f714086 100755 --- a/pyofm/__init__.py +++ b/pyofm/__init__.py @@ -1,3 +1,3 @@ -__version__ = '1.2.0' +__version__ = '1.2.1' from .pyOFM import PYOFM diff --git a/pyofm/pyOFM.py b/pyofm/pyOFM.py index 8ac02c9..d0951a3 100755 --- a/pyofm/pyOFM.py +++ b/pyofm/pyOFM.py @@ -306,3 +306,17 @@ def writeCompression(self): if "on" in cols[1]: writecompress = True return writecompress + + def readField(self, fieldName, fieldType, timeName, field): + """ + Read OpenFoam field and return the internal field as an array + + Inputs: + fieldName: name of the field to read + fieldType: can be either volScalarField or volVectorField + timeName: the time folder name to read, e.g., "0" or "1000" + Output: + field: an np array to save the field + """ + + self.ofMesh.readField(fieldName, fieldType, timeName, field) diff --git a/src/OFMesh.H b/src/OFMesh.H index 5ab2ebc..583ac2e 100755 --- a/src/OFMesh.H +++ b/src/OFMesh.H @@ -35,12 +35,12 @@ private: /// all the arguments char* argsAll_; - autoPtr argsPtr_; - autoPtr meshPtr_; autoPtr