IFM Callbacks¶
Callbacks represent locations in the internal FEFLOW code where external (plug-in) code can be called. Within the framework of the plug-in, the callbacks used in a specific plug-in correspond to C++ member functions of the plug-in class. The callbacks to be used for a plug-in are chosen when setting up the plug-in by application of the IFM wizard in Microsoft Visual Studio.
Document-related Callbacks¶
OnBeginDocument¶
OnBeginDocument is called always when a FEM problem begins to exist:
-
Creating a new FEM problem after mesh generation.
-
While loading a FEM problem from a file and detecting the MODULE keyword (ASCII).
-
or record type 46 (BINARY).
OnEndDocument¶
OnEndDocument is called when a FEM problem is closed. (Discarding Problem, Design new ...).
OnEditDocument¶
OnEditDocument allows the implementation of an own graphical user interface (GUI) to edit plug-in related FEM problem data.
OnEnterProblemEditor¶
OnEnterProblemEditor is called immediately after the problem editor has been opened. For deciding whether the editor is called from withing the simulator or not, implement OnEnterSimulator and OnLeaveSimulator also.
OnLeaveProblemEditor¶
OnLeaveProblemEditor is called immediately before the problem editor is going to be closed.
PreSaveDocument¶
PreSaveDocument is called just before the current FEM problem is going to be saved.
PostSaveDocument¶
PostSaveDocument is called after saving the current FEM problem including all IFM plug-ins.
PostLoadDocument¶
PostLoadDocument is called after loading the current FEM problem including all IFM plug-ins.
Module-related Callbacks¶
OnInitModule¶
OnInitModule is called immediately after a plug-in (DSO, DLL) is loaded. The Interface manager accepts the plug-in only if OnInitModule returns True (1)! Otherwise the plug-in will be be detached automatically.
OnExitModule¶
OnExitModule is called immediately before the plug-in (DSO, DLL) is unloaded. Use this function to free all allocated memory, remove all temporary files etc. InitModule and ExitModule are called always pair wise.
ExceptionHandler¶
The ExceptionHandler is called whenever an exceptional condition in one of the interface functions occurs. The default exception handler prevents the interface function from returning. The execution skips to the next plug-in.
OnActivate¶
OnActivate is called when the user presses the plug-in's taskbar button outside of the problem editor. Inside the problem editor, the callback OnEditDocument is called instead.
OnStateChanged¶
OnStateChanged notifies the plug-in about changes document state, e.g. the plug-in has been becoming enabled or disabled.
OnStateChanging¶
OnStateChanging is called when the plug-in's state becomes changed, e.g. the plug-in becomes enabled or disabled. If this function returns FALSE the state change will be rejected, otherwise accepted.
Serialize¶
Serialize is called from 4 points:
-
With archive mode IfmINIT immediately after calling OnBeginDocument.
-
With archive mode IfmLOAD when loading a FEM problem and detecting the keyword MODULE (ASCII) or record type 46 (BINARY).
-
With archive mode IfmSTORE when saving a FEM problem.
-
With archive mode IfmFREE immediately before calling EndDocument.
Topology-related Callbacks¶
OnChangeTopology¶
OnChangeTopology is called when the FEM problem's topology has been changed by any kind of mesh (de)refinement, manually or automatically.
OnChangeProblemClass¶
OnChangeProblemClass is called when the FEM problem's class has been changed.
OnMarkElementsForAMR¶
OnMarkElementsForAMR will be called after a full time step to calculate a new mesh topology by refining (enriching) or derefining (deenrichment) the existing elements. Call IfmSetAmrElementRefinement to mark an element for refining/derefining and resetting the markup.
OnRefineElementAttributes¶
OnRefineElementAttributes is called while the mesh refinement to fill new elements with attribute data or to join multiple elements into one or more new elements. Use the indices of the old elements to calculate the values for all new elements.
OnRefineNodeAttributes¶
OnRefineNodeAttributes is called while the mesh refinement to interpolate attributes for a new node based on one row two old nodes.
PreRefineProblem¶
PreRefineProblem is called after the calculation of a new mesh topology via mesh refinement/derefinement to fill the refined problem with copied or interpolated values. Implement PreRefineProblem to allocate memory for plug-in maintained attribute vectors. Subsequent calls of OnRefineNodeAttributes and OnRefineElementAttributes have to be used to calculate new parameter values. Finally, PostRefineProblem is called to install (swap) or discard (on error) the prepared vector.
PostRefineProblem¶
PostRefineProblem is called after the mesh refinement to install or discard the prepared plug-in held parameters. See PreRefineProblem for more information.
OnUpdateMaterials¶
OnUpdateMaterials is called immediately after the simulator updates time-dependent material data.
Time-Series-related Callbacks¶
OnLockPowerID¶
OnLockPowerID is called to determine if a power function is used by the IFM plug-in. The plug-in should return True (1) to indicate that the power function used and therefore has to be locked.
Simulator-related Callbacks¶
PreEnterSimulator¶
PreEnterSimulator is called immediately before the simulator is going to be started. Remind the difference to PreSimulation! Use the callback to raise graphical elements related to the simulation process (e.g. diagrams). You should implement OnLeaveSimulator also to hide the raised elements.
PostEnterSimulator¶
PostEnterSimulator is called immediately after the simulator has been started. Remind the difference to PreSimulation! Use the callback to raise graphical elements related to the simulation process (e.g. diagrams). You should implement OnLeaveSimulator also to hide the raised elements.
OnLeaveSimulator¶
OnLeaveSimulator is called immediately before the simulator menu is going to be closed. Use this callback to hide graphical elements created in OnEnterSimulator.
PreSimulation¶
PreSimulation is called before running the simulation time loop and allows the implementation of own preprocessing functionality or allocation of additional memory needed for the plug-in.
PostSimulation¶
PostSimulation is called after running the simulation time loop and allows the implementation of own postprocessing functionality or freeing of memory which has been additionally allocated during the plug-in run.
Time-Steps-related Callbacks¶
OnTimeStepConstraint¶
OnTimeStepConstraint is called when the simulator determines the next time step. The current time as well as the proposed length of the time step are passed to this callback function. The proposed interval can be reduced due to the needs of the plug-in (adjusting to power function points, etc.). If the proposed interval is increased, a warning will appear.
PreTimeStep¶
PreTimeStep is called at beginning of each time step and allows the implementation of own functionality for updating time-related properties and user-specific actions.
PostTimeStep¶
PostTimeStep is called at the end of a current time step and allows the implementation of own functionality for updating time-related properties and user-specific actions.
Problem-Class-related Callbacks¶
PreFlowSimulation¶
PreFlowSimulation is called immediately before solving the flow equations and allows the implementation of own functionality for properties and actions related to the flow problem before it becomes solved.
PostFlowSimulation¶
PostFlowSimulation is called immediately after solving the flow equations and allows the implementation of own functionality for properties and actions related to the flow problem after it has been solved.
PreMassSimulation¶
PreMassSimulation is called immediately before solving the mass transport equations and allows the implementation of own functionality for properties and actions related to the mass transport problem before it becomes solved. The current species index is passed through the iSpecies argument.
PostMassSimulation¶
PostMassSimulation is called immediately after solving the mass transport equations and allows the implementation of own functionality for properties and actions related to the mass transport problem after it has been solved. The current species index is passed through the iSpecies argument.
PreHeatSimulation¶
PreHeatSimulation is called immediately before solving the heat transport equations and allows the implementation of own functionality for properties and actions related to the heat transport problem before it becomes solved.
PostHeatSimulation¶
PostHeatSimulation is called immediately after solving the heat transport equations and allows the implementation of own functionality for properties and actions related to the heat transport problem after it has been solved.