|
From: | Lesage,Anne Cecile J |
Subject: | RE: [EXT] Re: defining a field on the mesh dofs |
Date: | Tue, 14 Dec 2021 00:52:39 +0000 |
Dear Konstantinos This worked Maybe not the most elegant solution file = open("Gfield.txt","r") gdata = np.loadtxt(file,dtype=float) #print(gdata) x = gdata[:,0:3] #print(x) tree = KDTree(x) #print(tree) print(mfpb.basic_dof_nodes(0)) Pt=mfpb.basic_dof_nodes(1) print(Pt) Pt=mfpb.basic_dof_nodes(2) print(Pt) a = np.empty([meshb.nbpts(),3]) for i in range(meshb.nbpts()): Pt=mfpb.basic_dof_nodes(i) a[i][0]=Pt[0] a[i][1]=Pt[1] a[i][2]=Pt[2] # #a = mfpb.basic_dof_nodes() #y = a.transpose() print(a[1][0]) dd,ii = tree.query(a) for i in range(10): print(ii[i]) print('Read G as field on nodes'); md.add_fem_data("gf", mfpb) md.set_variable("gf", gdata[ii,3]) mfoutb = gf.MeshFem(meshb) mfoutb.set_classical_discontinuous_fem(2) mfoutb.export_to_vtu("gf.vtu", mfpb, md.variable("gf"), "ShearMod") From: Lesage,Anne Cecile J <AJLesage@mdanderson.org> It seems that mfpb.basic_dof_nodes() does not have the right structure to be compared to tree From: Getfem-users <getfem-users-bounces+ajlesage=mdanderson.org@nongnu.org>
On Behalf Of Lesage,Anne Cecile J
Dear Konstantinos I adapted your solution to the interpolation of a shear modulus field on the mesh. from
scipy.spatial import
KDTree file = open("Gfield.txt","r") gdata = np.loadtxt(file,dtype=float) tree = KDTree(gdata[:,0:3]) dd,ii = tree.query(mfpb.basic_dof_nodes()) md.add_fem_data("gf", mfpb) md.set_variable("gf", gdata[ii,3]) However I get the following error Traceback (most recent call last): File "testresect5poroelasticbrainheadv1.py", line 208, in <module> dd,ii = tree.query(mfpb.basic_dof_nodes()) File "/home/ajlesage/.local/lib/python3.8/site-packages/scipy/spatial/kdtree.py", line 472, in query d, i = super().query(x, k, eps, p, distance_upper_bound, workers) File "ckdtree.pyx", line 779, in scipy.spatial.ckdtree.cKDTree.query File "ckdtree.pyx", line 1604, in scipy.spatial.ckdtree.num_points ValueError: x must consist of vectors of length 4 but has shape (3, 18154) What do you think is the issue there? My data is a four column ascii file x, y, z, value From: Konstantinos Poulios <logari81@googlemail.com>
Dear Anne-Ceclie I guess what pfield.txt contains is a list of values ordered in the same order as the mesh nodes. In general there is no guarantee that the mesh nodes will be in the same order in GetFEM but if your original numbering of nodes is contiguous,
chances are good that GetFEM will keep the same numbering. Then the next point is that dof numbering and mesh node numbering do not need to be the same. In fact you can even have a larger or smaller number of dofs than the number of mesh nodes. A more general solution for you would be to save in the pfield.txt file 4 values, x,y,z coordinates and field value. Then you can always read the value of the closest point for each dof with something like: import numpy as np Best regards Kostas On Wed, Dec 1, 2021 at 10:42 PM Lesage,Anne Cecile J <AJLesage@mdanderson.org> wrote:
The information contained in this e-mail message may be privileged, confidential, and/or protected from disclosure. This e-mail message may contain protected health information (PHI); dissemination of PHI should comply with applicable federal
and state laws. If you are not the intended recipient, or an authorized representative of the intended recipient, any further review, disclosure, use, dissemination, distribution, or copying of this message or any attachment (or the information contained therein)
is strictly prohibited. If you think that you have received this e-mail message in error, please notify the sender by return e-mail and delete all references to it and its contents from your systems.
The information contained in this e-mail message may be privileged, confidential, and/or protected from disclosure. This e-mail message may contain protected health information (PHI); dissemination of PHI should comply with applicable federal and state laws. If you are not the intended recipient, or an authorized representative of the intended recipient, any further review, disclosure, use, dissemination, distribution, or copying of this message or any attachment (or the information contained therein) is strictly prohibited. If you think that you have received this e-mail message in error, please notify the sender by return e-mail and delete all references to it and its contents from your systems.
|
[Prev in Thread] | Current Thread | [Next in Thread] |