Please find a tiny code snippet below, which illustrates the workflow. The workflow is based on a Python script. The scripts loads the FEFLOW kernel externally.
The snippet does the following:
1. Get the element members of the selection with the name “sheet_piles_elements”
2. Start a simulation
3. Deactivate the elements of the selection “sheet_piles_elements” after 200 d
4. Re-activate the elements of the same selection after 300 d and initialize corresponding nodal heads with a value of 10 m. Nodes which has been previously completely surrounded by inactive elements are considered only. I detected these nodes based on selections, but you could also check whether or not a nodal head values correspond to nan (not a number).
Please note that the tiny snippet has not been carefully tested (e.g. 3D, unsaturated flow etc). Accordingly, I cannot provide any warranty that the script works correctly. Instead, the script is simple starting point into inactive elements using the FEFLOW API.
[font=courier][color=blue]
import sys, os
sys.path.append('C:\\Program Files\\DHI\\2017\\FEFLOW 7.1\\bin64')
import ifm
from ifm import Enum
try:
def onTimeStepConstraint(doc, tNow, dT):
timeIntervals = [100., 200., 300.]
for i in range(0, len(timeIntervals) - 1):
if timeIntervals[i] < tNow < timeIntervals[i + 1]:
if tNow + dT > timeIntervals[i + 1]:
dT = timeIntervals[i + 1] - tNow
if tNow == deactivation_time:
print "Elements will be deactivated at t = ", tNow
for inactive_element in inactive_elements_list:
doc.setMatElementActive(inactive_element, inactive_element_state)
if tNow == activation_time:
print "Elements will be activated at t = ", tNow
for inactive_element in inactive_elements_list:
doc.setMatElementActive(inactive_element, active_element_state)
for inactive_node in inactive_node_list_reduced:
doc.setPredictorHeadTimeValue(inactive_node, initializing_value)
doc.setResultsFlowHeadValue(inactive_node, initializing_value)
return dT
cwd = os.getcwd()
FEM_FILE_in = cwd + "\\..\\femdata\\barrier_in.fem"
FEM_FILE_out = cwd + "\\..\\femdata\\barrier_out.fem"
DAC_FILE_out = cwd + "\\..\\results\\barrier.dac"
# Time to deactivate elements
deactivation_time = 200
# Time to activate elements and process variable initialization
activation_time = 300
inactive_elements_list = []
inactive_node_list = []
connected_node_list = []
inactive_node_list_reduced = []
sel_type_element = 1 # element=0
sel_type_node = 0 # nodal=0
inactive_element_state = 0 # inactive = 0
active_element_state = 1 # active = 1
initializing_value = 10
# Load FEFLOW document
doc=ifm.loadDocument(FEM_FILE_in)
# Prepare selections
element_selection_id = doc.findSelection(sel_type_element, "sheet_piles_elements")
doc.createSelection(sel_type_node, "sheet_piles_nodes")
node_selection_id = doc.findSelection(sel_type_node, "sheet_piles_nodes")
nElements = doc.getNumberOfElements()
nNodes = doc.getNumberOfNodes()
# Get inactive element list
for element_id in range(nElements):
if doc.selectionItemIsSet(sel_type_element, element_selection_id, element_id) == 1:
inactive_elements_list.append(element_id)
for inactive_element in inactive_elements_list:
# Nodes connected to elements
for ElementNode in range(0, doc.getNumberOfElementNodes(inactive_element)):
ElementNode_id = doc.getNode(inactive_element, ElementNode)
# Elements connected to node
inactive_NodeElements_list = [ElementNode_id, doc.getNumberOfNodeElements(ElementNode_id)]
for NodeElement in range(0, doc.getNumberOfNodeElements(ElementNode_id)):
NodeElement_id = doc.getElement(ElementNode_id, NodeElement)
if doc.selectionItemIsSet(sel_type_element, element_selection_id, NodeElement_id) == 1:
inactive_NodeElements_list.append(1)
connected_node_list.append(inactive_NodeElements_list)
# Make nodal selection for initialization of process variable head
for node_incident_list in connected_node_list:
if node_incident_list[1] == node_incident_list.count(1):
doc.setSelectionItem(sel_type_node, node_selection_id, node_incident_list[0])
inactive_node_list.append(node_incident_list[0])
# Remove doubles
for inactive_node in inactive_node_list:
if inactive_node not in inactive_node_list_reduced:
inactive_node_list_reduced.append(inactive_node)
# Enable parameter recording in output dac-file for inactive elements (pseudo material)
doc.enableParamRecording(Enum.P_INACTIVE_ELE)
doc.saveDocument(FEM_FILE_out)
doc.startSimulator(DAC_FILE_out)
doc.stopSimulator()
except Exception as err:
print >> sys.stderr, err
exit(-1);
[/color][/font]