Output medium properties (permeability, porosity, ... )

Hello everyone,

I’ve been searching through the discourse and the manuals but i can’t find a way to map a property field (for example permeability). Is it possible to do so via the .prj file maybe in the output block ? And is it also possible to do it for other medium properties (porosity, thermal conductivity, viscosity, …) ?

Thanks in advance,

RN

1 Like

What exactly do you mean by ‘map a property field’? Do you want to use a property field in the simulation that was read from an input mesh? This can be done via parameter type MeshNode or MeshElement. In the definition of a physical property (for instance permeability) the parameter can be used.

Thanks for you answer.
So, no I’ve already created a heterogeneous permeability field that I introduced in my prj file with parameter and MeshElement. But I have 2 mediums in my mesh and this permeability field is only applied for cells with MaterialIDs = 2. For the other medium I use a constant value of permeability that I apply directly in the medium, phase and property blocks for MaterialIDs = 1.
What I want to be able to do is when i run ogs to generate an output vtk/vtu file of the final permeability field that I created (because the permeability field i introduced with MeshElement doesn’t take into account the constant field i introduced for my first medium with MaterialIDs = 1).
Sorry in advance if it doesn’t make sense.

1 Like

As far as I know such a functionality isn’t implemented yet. It is possible to output the input data.


<output>
    ...
    <variables>
        <variable>your_input_permeability_field_name</variable>
        ...
    </variables>
</output>

But the constant value in the example described above isn’t transferred to the mesh and thus isn’t written to output file.

Ok too bad but thanks for your time, I’ll find an other way.

One could write the permeability for both materials into the input files…

I think this can be related to this feature request:

Yes i know. I’ve previously used VTUinterface to create a vtu file with a permeability gradient depth-dependent (y-dependent) using the " data.func_to_m_dim_field " function in a python script like so Heterogeneous material such as position-dependent Youngs modulus - #3 by joergbuchwald. But the thing is I tried to change the script so it can be y-dependent and also MaterialIDs dependent but with no success. That’s why I was trying to find an alternative. But I’m interested if you know how I can do that ?

I don’t see, unfortunately, an easy/small code modification to output material properties.

Best would be not to mix a Constant with MeshNode properties for, say permeability, but go with MeshNode property for both materials. Performance-wise the difference is negligible.

I tried to put a MeshNode property on both materials with a vtu created with VTUinterface and I succeeded in creating a y-dependent permeability but when i want to create a y-dependent and an MaterialIDs dependent permeability that’s where it gets tricky for me.

Materials are usually given as MeshElement properties.
To create a MeshElement property that depends on MaterialIDs and coordinates
you can use cell center points:

import numpy as np
import vtuIO
f = vtuIO.VTUIO("Mesh.vtu")
pts = f.cell_center_points
mat_ids = f.get_cell_field("MaterialIDs")
permeability = np.zeros(len(pts))
for i in range(len(pts)):
    if mat_ids[i] == 0:
        permeability[i] = 1e-20
    if mat_ids[i] ==1:
        permeability[i] = pts[i,1]*1e-18
f.add_cell_field(permeability,"permeability","mesh.vtu") 

This should create a linear in y permeability field for Material id 1.
If you want to set a MeshNode property you can use the usual nodal points instead of cell center points and map the material ids (important: use nearest neighbor/voronoi interpolator otherwise youl get fractional material ids at the interface :wink: ) to these points:

pts = f.points
mat_ids = f.get_set_data("MaterialIDs", pointsetarray=pts, data_type="cell", interpolation_method="voronoi")
1 Like

Thanks for your help it works fine ! But I have a hard time trying to adapt your code with the function “func_to_m_dim_field” to get a multidimensional field (kx, ky).

The code above should work with multidimensional data as well:


permeability = np.zeros((len(pts),4))

Alternatively, you can also use func_to_m_dim_field([kx,ky], "permeability", ofilename="mesh.vtu", cell=True, writefile=True) defining
multiple functions:

def kx(x,y,z):
    ...
def ky(x,y,z):
    ...

Within those functions, you can check for each point which cell center point is closest and which MaterialID it belongs to. (The code is applied for the cell center points either way only) This can be done with get_set_data("MaterialIDs", pointsetarray=points, data_type="cell", interpolation_method="voronoi").

Thank you so much for your help ! I succeeded to create a multidimensional data with the first alternative you proposed with the ‘add_cell_field’ function. So i can work with that.
I still don’t know why i have an issue in doing the 2nd option with the ‘func_to_m_dim_field’ function (i have ValueError: setting an array element with a sequence), but I’ll work on it.

Thanks !

The ValueError is raised if a wrong type is used.
Not sure which array element you want to set by a sequence, in the example above, the elements of the list you provide the method func_to_m_dim_field in the first argument with are the function names, i.e. they are of type function.
Every of those functions should return floats or integers when executed.