[Top][All Lists]

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

Re: defining a field on the mesh dofs

From: Konstantinos Poulios
Subject: Re: defining a field on the mesh dofs
Date: Thu, 2 Dec 2021 09:09:21 +0100

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
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

On Wed, Dec 1, 2021 at 10:42 PM Lesage,Anne Cecile J <> 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.set_variable("pc", pfield)


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


Thank you










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]