Posted Mon, 04 Jan 2016 17:49:48 GMT by S Heermann
The 'What's new in FEFLOW 7?' help page refers to some new functions for selection handling (e.g. IfmGetNumberofSelections, IfmCreateSelection) but these are not listed in the IFM API Functions page.  What's up?
Posted Tue, 05 Jan 2016 12:24:20 GMT by Björn Kaiser
The update of new API function documentation will be provided with the next patch. In the meanwhile please find the selection handling below:

[color=blue][font=courier]
  int        IfmGetNumberOfSelections(IfmDocument pDoc, IfmSEL_TYPE nSelType);
  int        IfmGetSelectionCapacity (IfmDocument pDoc, IfmSEL_TYPE nSelType);
  int        IfmFindSelection (IfmDocument pDoc, IfmSEL_TYPE nSelType, const char* pszSelName);
  int        IfmCreateSelection (IfmDocument pDoc, IfmSEL_TYPE nSelType, const char* pszSelName);
  IfmResult  IfmDeleteSelection (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex);
  const char* IfmGetSelectionName (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex);
  int        IfmEnumSelectionItems (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex, int nStartPos);
  IfmBool    IfmSelectionItemIsSet (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex, int nItem);
  void      IfmSetSelectionItem (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex, int nItem);
  void      IfmClearSelectionItem (IfmDocument pDoc, IfmSEL_TYPE nSelType, int nSelIndex, int nItem);
[/font][/color]

with

[color=blue][font=courier]
typedef enum IfmSEL_TYPE {        /* Selection types ... */
  IfmSEL_NODAL = 0,              /* Nodal selection */
  IfmSEL_ELEMENTAL = 1,                  /* Elemental selection */
  IfmSEL_INVALID = -1                    /* Invalid selection type */
} IfmSEL_TYPE;
[/font][/color]

[color=blue][font=courier]nSelIndex[/font][/color] represents the index of a selection. The indexing corresponds to the numbering of available selections stored within the Selection panel from top to bottom. [color=blue][font=courier]nItem[/font][/color] stands for the node index or the element index of the mesh depending whether you have a nodal selection or elemental selection. [color=blue][font=courier]pszSelName[/font][/color] is the name of the selection.
Posted Sun, 24 Jan 2016 11:52:39 GMT by Carlos Andres Rivera Villarreyes Global Product Specialist - FEFLOW
Hi,

In addition, you can always get the list of complete functions from the documentp.h, which is included automatically in each IFM project. You can also see when each function was implemented.

Carlos
Posted Fri, 12 Feb 2016 19:28:50 GMT by S Heermann
So what can one do with this added capability?  Are there any ifm functions that can take a selection as an input item? 

Also, how could one extract a list of nodes or elements using the selection handling functions?
Posted Wed, 16 Mar 2016 20:57:45 GMT by adacovsk
With the unstructured meshing, it provides me element selections so I can assign material properties to specific layers via a csv file... But maybe there an easier way through the interface?

Also, recommendation would be to have Layer10 to follow Layer9 rather than follow Layer1.
Currently, this happens: Layer1, Layer10, Layer11, Layer2, etc.

Thanks,

Adam
Posted Tue, 19 Apr 2016 12:16:17 GMT by Björn Kaiser
Stephen,

At the moment you cannot use an entire selection as an input item. Instead, you have to loop through the items contained by a selection. The snippet below shows a simple example for the assignment of DirichletBC's based on nodal selections.

[color=blue]
import sys, os
sys.path.append('C:\\Program Files\\DHI\\2016\\FEFLOW 7.0\\bin32')
import ifm, random

try:
  dir=os.getcwd()
  print "My current working directory: " + dir
  print ""

  def postTimeStep(doc):
    random.random()

    for list_ele in item_list:
        for node in list_ele:
            if (node % 2 == 0):
                value=-0.5
            else:
                value=random.random()

            doc.setBcFlowTypeAndValueAtCurrentTime(node,1,0,value)

  FEM_FILE = dir+"\\..\\femdata\\exercise_fri13.fem"
  DAC_FILE = dir+"\\..\\results\\exercise_fri13.dac"

  print FEM_FILE
  print DAC_FILE
  print ""

  doc = ifm.loadDocument(FEM_FILE)

  max_sel=doc.getNumberOfSelections(0)
  max_nodes=doc.getNumberOfNodes()

  item_list=[]

  for sel_counter in range(0,max_sel):
    item_list.append([])

    for node in range(0, max_nodes):
        if doc.selectionItemIsSet(0, sel_counter, node)==1:
            item_list[sel_counter].append(node)

  doc.startSimulator(DAC_FILE, 0)
  doc.stopSimulator()

except Exception as err:
print >> sys.stderr, 'Error: ' + str(err) + '!'
sys.exit(-1);
[/color]
Posted Tue, 19 Apr 2016 12:25:49 GMT by Björn Kaiser
Adam,

There are several ways for the assignment of material properties to unstructured elements or layered-based elements. A nice workflow is indeed to use a Python csv-reader and assign the parameters based on available selections and its intrinsic items. Of course, you could also use selections stored in the Selection Panel of the Graphical User Interface (GUI).

The alphanumeric ordering is a generic option. I suggest to change the naming. For example, you could use the name [b]Layer01[/b] instead of [b]Layer1[/b].
Posted Tue, 31 Jan 2017 16:55:48 GMT by Denim Umeshkumar Anajwala
Hi.

I just learned today how to use IFM commands for selections on C++. As Björn explained you have to use a loop to visit all the items (elements or nodes) contained in a selection. I put here an example for a selection of elements. Code is in blue.

1) Create a node selection in FEFLOW GUI and name it, i.e. "swamp". The plug-in needs to find which is the index of selection named "swamp". It is stored on variable int_sel_index

[color=blue]int elem_sel_index = IfmFindSelection(pDoc, IfmSEL_ELEMENTAL, "swamp"); [/color]

2) Then, ask FEFLOW the maximum possible capacity of an element selection:

[color=blue]long number_of_elements = IfmGetSelectionCapacity(pDoc, IfmSEL_ELEMENTAL);[/color]

3) Create an array (vector) where the element indexes that belong to "swamp" will be stored:

[color=blue]std::vector<long> elem_indexes; [/color]

Next comes the loop. I use more lines than necessary to show explicitly how it works. 4.1)  The FOR loop visits every element in the model. 4.2) IfmSelectionItemIsSet asks to the element with index = elem_counter if it belongs to selection elem_sel_index. If the element is in the selection the output if 1, if not it's 0. This value is stored on variable "belongs". 4.3) If the variable belongs is equal to one (element is in selection) the element index is stored in the array using the push.back function. When the loop ends the array named elem_indexes contains all the element indexes that belong to selection "swamp" created on FEFLOW GUI.

[color=blue]for (long elem_counter=0; elem_counter < number_of_elements; elem_counter++)                              // 4.1
{
      int belongs = IfmSelectionItemIsSet(pDoc, IfmSEL_ELEMENTAL,elem_sel_index,elem_counter);    // 4.2
      if (belongs == 1){ elem_indexes.push_back(elem_counter); }                                                    // 4.3
}[/color]                                                                                                                   

4) For example, if element selection "elem_indexes" is used to set K = 10 meters/day, another loop is used.

[color=blue]long elem_indexes_length = static_cast<int>(elem_indexes.size());
for (int n = 0; n < elem_indexes_length;n++)

    IfmSetMatConductivityValue2D(pDoc, elem_indexes[n], 10);
}[/color]
Posted Mon, 06 Feb 2017 10:28:15 GMT by Björn Kaiser
Great, thank you for your input axa.maqueda.
Posted Thu, 23 Mar 2017 10:29:59 GMT by hidromatrix
Assuming I created a nodal selection, is there a way to activate the Budget-history charting via IFM?
Posted Fri, 24 Mar 2017 08:56:13 GMT by Björn Kaiser
Hi Eduardo, at the moment this function does not exist. I added this function to the FEFLOW wish list for possible future developments.
Posted Tue, 22 May 2018 06:30:36 GMT by Razi Sadath P V Senior Research Fellow
anyone pls expain step by step on how to calibrated boundary condition using IFM pilot points? since im new to programing i cant understand above code. but still iw ant to learn it

You must be signed in to post in this forum.