Kratos
Kratos copied to clipboard
internal discussion about multistage
Description Ongoing discussion about multistage.
this are just working notes of the internal discussion within the @KratosMultiphysics/technical-committee
{
"stage1" : {
"stage_initialize" : {
"modelers" : [{
"modeler_name": "read_model_part_from_mdpa",
"Parameters" : {...}
},
{
"modeler_name": "mapping_from_previous_stage",
"Parameters" : {...}
},
],
"stage_preprocess" : [ { ... } ], //OPERATION(only implementing "Execute") to be called AFTER the modellers
},
"stage_finalize" : {
"stage_finalizer_list" : [
{
"finalizer_name" : "...",
"Parameters" : {...}
},
{
"finalizer_name" : "my_custom_process",
"Parameters" : {...}
}
],
"stage_postprocess" : [ { ... } ], //OPERATION(only implementing "Execute")
},
"problem_data" : { ... },
"solver_settings" : { ... },
"output_processes" : [
"constraints_process_list" : [ { ... } ],
"loads_process_list" : [ { ... } ],
"list_other_processes" : [ { ... } ],
]
}
}
next iteration
//things that live through an analysis:
Model
Project (yet to be added)
serialized_streams/files ????
if restart
skip preprocess
{
"stage1" : {
"depends_on" : "nothing/previous/...", ??????????????? to be discussed in the next meeting (proposal by Riccardo if we want to have stages as tasks NOT DISCUSSED)
"stage_preprocess" : {
"model_restart" : {
"read_restart" : false,
"restart_options" : {
"SaveRestart" : "False",
"RestartFrequency" : 0,
"LoadRestart" : "False",
"Restart_Step" : 0
},
//restart is mutually exclusive with the use of modelers
},
"modelers" : [
{
"modeler_name": "read_model_part_from_mdpa",
"Parameters" : {...}
},
{
"modeler_name": "mapping_from_previous_stage",
"Parameters" : {...}
},
],
"stage_initializer_list" : [
{
"operation_name" : "...",
"Parameters" : {...}
},
{
"operation_name" : "...",
"Parameters" : {...}
}
] //OPERATION(only implementing "Execute") to be called AFTER the modellers
},
"stage_postprocess" : {
"prepare_restart" : {
"write_restart" : false,
"restart_settings" : {...}
},
"stage_finalizer_list" : [
{
"operation_name" : "...",
"Parameters" : {...}
},
{
"operation_name" : "...", //for example if we want to remove a modelpart which is not needed anymore this would be the place to do it
"Parameters" : {...}
}
] //OPERATION(only implementing "Execute")
},
"problem_data" : { ... },
"solver_settings" : { ... },
"output_processes" : [
"constraints_process_list" : [ { ... } ],
"loads_process_list" : [ { ... } ],
"list_other_processes" : [ { ... } ],
]
},
"stage2" : {...}
//********************************************************************************************
//********************************************************************************************
//NOT AGREED YET ... various options follow
//********************************************************************************************
//********************************************************************************************
"stage_execution" : {
"start_from_latest" : {...}, //"stages_to_be_executed" : [/stage1, /stage2]
"stages_to_be_executed" : [/stage2]
}
//"stages_to_be_executed" : [/stage1, /stage2]
"stages_to_be_executed" : [/stage2]
}
stage_initializer_list and stage_finalizer_list keys must be renamed to operations. This makes possible to use the same mechanism that we use to instantiate the processes right now.
Today's conclusions:
- First part of
Initializefunction in baseAnalysisStagemust be
self._CreateModelers() #FIXME: MODELERS CREATE THE MODEL PARTS (e.g. FluidModelPart, ThermalModelPart, Structure)
self._GetSolver().AddVariables()
self._ModelersSetupGeometryModel()
self._ModelersPrepareGeometryModel()
self._ModelersSetupModelPart() #FIXME: MODEL PART IMPORT MUST HAPPEN IN HERE --> CREATE ImportModelPartModeler
self._GetSolver().PrepareModelPart()
self._GetSolver().AddDofs()
self.ModifyInitialProperties()
self.ModifyInitialGeometry()
- In
model.hCreateModelPartmethod we should issue a warning (right now an error) if asking for creating an already existent model part. Then we return such already existent model part. This would eventually ease retrocompatibility.
result about factory for operations
import KratosMultiphysics as KM
import KratosMultiphysics.FluidDynamics as CFD
settigns = KM.ProjectParamters("""
[
{
"type" : "KratosMultiphysics.FluidDynamicsApplication.CppOp",
"parameters" : {...}
},
{
"type" : "KratosMultiphysics.FluidDynamicsApplication.PyOp",
"parameters" : {...}
},
]
""")
def OperationFactory(model, settings):
try:
throw error if same thing in c++ and python
if operation_registry.Has(settings["type"]): # in cpp
operation_registry[settings["type"]].Create(model,settings)
else: #in python
importlib.attr(settings["type"])
except:
...
@KratosMultiphysics/altair FYI
The conclusion of the discussion about registry of python stuff is the following (this discussion does not apply to c++ stuff, which is threated differently):
We will create an auxiliary file to tell what classes (for example Processes, Operations, etc.) have to be added to the registry. This file will be then loaded from the init of each application so that the list of things to be loaded is available.
An important point here is that we DO NOT load all of the modules in the init, modules will be loaded as needed.
An example is the following:
filename: python_registry_list.py
operations_to_be_registered = [
"module_name1.OperationName1",
"module_name2.OperationName2",
]
process_to_be_registered = [
"module_name3.ProcessName1",
"module_name4.ProcessName2",
]
in the init.py we will then preprocess those lists and add them with the correct path
__init__.py
import python_registry_list
for operation in python_registry_list.operations_to_be_registered:
KM.Registry.RegisterOperation(".".join("KratosMultiphysics",app_name,operation))
for process in python_registry_list.processes_to_be_registered:
KM.Registry.RegisterProcess(".".join("KratosMultiphysics",app_name,process))
for a local file
my_example_directory
....
my_very_special_process_not_in_kratos.py
....
class SpecialProcess(KM.Process)
.....
MainKratos.py
import KratosMultiphysics
KM.Registry.RegisterProcess("my_very_special_process_not_in_kratos.Special_process")
We assume that this is finished and additional features like serialization, etc. we will use separate issues.