getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [EXT] Re: defining a field on the mesh dofs


From: Lesage,Anne Cecile J
Subject: RE: [EXT] Re: defining a field on the mesh dofs
Date: Mon, 13 Dec 2021 17:57:21 +0000

 

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>
Sent: Thursday, December 2, 2021 2:09 AM
To: Lesage,Anne Cecile J <AJLesage@mdanderson.org>
Cc: getfem-users@nongnu.org
Subject: [EXT] Re: defining a field on the mesh dofs

 

WARNING: This email originated from outside of MD Anderson. Please validate the sender's email address before clicking on links or attachments as they may not be safe.

 

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
from scipy.spatial import KDTree
file = open("pfield.txt", "r") # assuming it contains 4 columns: x,y,z,value
pdata = np.loadtxt(file,dtype=float)
tree = KDTree(pdata[:,0:3])
dd,ii = tree.query(mfp.basic_dof_nodes())
md.add_fem_data("pc", mfp)
md.set_variable("pc", pdata[ii,3])

 

Best regards

Kostas

 

 

 

 

 

 

 

 

On Wed, Dec 1, 2021 at 10:42 PM Lesage,Anne Cecile J <AJLesage@mdanderson.org> wrote:

Dear all

 

I would like to define a non-constant pressure field on the mesh dofs

I would like to read the value from an ascii file

 

I am thinking of using the following python scripting

 

import numpy as np

 

file = open('pfield.txt', 'r') # 'r' = read

pfield = np.loadtxt(file,dtype=fload)

 

md.add_fem_data(“pc”,mfp)

md.set_variable("pc", pfield)

 

Will it be correct to use pc in building a week form?

 

Thank you

Regards

Anne-Cecile

 

 

 

 

 

 

 

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]