|
[Sponsors] |
Orthogonal decompositions using the modred module in python |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 28, 2018, 18:56 |
Orthogonal decompositions using the modred module in python
|
#1 |
New Member
sin
Join Date: Feb 2018
Posts: 1
Rep Power: 0 |
I am trying to write a code for orthogonal decompositions using the modred module in python. My custom vector class is defined as:
class CustomVector(mr.Vector): def __init__(self, data_array): self.data_array = data_array def inner_product(self, other): return np.dot(self.data_array, other.data_array) Another class definition is given as: class CustomVecHandle(mr.VecHandle): def __init__(self, vec_path, base_handle=None, scale=None): mr.VecHandle.__init__(self, base_handle, scale) self.vec_path = vec_path self.res_path = result_root def _get(self): # read in the values print ("reading data from {}".format(self.vec_path)) reader = vtk.vtkPolyDataReader() reader.SetFileName(self.vec_path) reader.Update() data = dsa.WrapDataObject(reader.GetOutput()).PointData['U'] return CustomVector(data) And another function is defined outside all classes as: def inner_product(v1, v2): return v1.inner_product(v2) I have created a list object as: vec_handles = [CustomVecHandle(os.path.join(data_root, d, "{}_0.vtk".format(d)))for d in dirs] This vec_handles is given as the input for a function in the modred module, and the following operations are done in the main modred code: test_vec = vec_handles IP_burn = self.inner_product(test_vec, test_vec) But when I run the following code I am getting the error that: File "/home/sindhuja/.local/lib/python2.7/site-packages/modred/vectorspace.py", line 495, in compute_symmetric_inner_product_mat IP_burn = self.inner_product(test_vec, test_vec) File "podd.py", line 58, in inner_product return v1.inner_product(v2) AttributeError: 'list' object has no attribute 'inner_product' I understand that the created vec_handles is a list of objects for the class CustomVecHandle. And trying to get the method using .innerproduct(test_vec) is not possible but since it's the code of the modred module, I don't think that's wrong. So how do I solve this error? |
|
April 13, 2021, 13:21 |
|
#2 | |
Senior Member
Ehsan Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18 |
Quote:
Hi, It's interesting because I was trying to do something similar and I noted the same thing in modred documentation. Did you find the explanation as to why that line is there? Could you please share your custom vector class? syavash P.S. I came to this understanding that "inner_product(v1, v2)" should be explicitly defined, as per https://modred.readthedocs.io/en/sta...ml#sec-details. I guess it could be defined such that it return a numpy function such as numpy.dot. Last edited by syavash; April 13, 2021 at 15:30. |
||
Tags |
modred, orthogonal decomposition, pod, python |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[General] Paraview.simple python module and loading legacy vtk file timeseries | awa5114 | ParaView | 2 | July 17, 2017 09:40 |
[foam-extend.org] Module file foam-extend 3.2 CentOS cluster | KarthickRajkumar | OpenFOAM Installation | 2 | March 26, 2017 14:52 |
[OpenFOAM] Python and paraview.simple libprotobuf error | Private Mandella | ParaView | 1 | October 26, 2016 14:25 |
[OpenFOAM] paraview v4 - building with python - OF2.3.0, PVv4, Python 2.7 | aylalisa | ParaView | 4 | June 13, 2014 09:52 |
Can someone PLEASE document the development version installation | bernd | OpenFOAM Installation | 76 | November 14, 2008 22:51 |