parameters: (current_global_index,pickled_coarse_model,pickled_coarse_project_parameters,pickled_custom_metric_refinement_parameters,pickled_custom_remesh_refinement_parameters,random_variable,current_index,current_analysis_stage,previous_computational_time,open_mp_threads,mapping_flag,pickled_mapping_reference_model,print_to_file,filename)
return_statement: return qoi,pickled_finer_model,computational_time
docstring: Auxiliary method to the solve method of the KratosSolverWrapper class. Firstly, if needed, adaptive refinement is performed. Then the problem is solved calling Kratos. To be called if the selected refinement strategy is stochastic_adaptive_refinement.
  
      Inputs:
      current_global_index: integer.
          Index we are interested in and for which we have called the solve method of the solver wrapper.
      pickled_coarse_model: serialization of the KratosMultiphysics.Model.
      pickled_coarse_project_parameters: serialization of the KratosMultiphysics.Parameters.
      pickled_custom_metric_refinement_parameters: serialization of metric adaptive refinement parameters.
      pickled_custom_remesh_refinement_parameters: serialization of remeshing adaptive refinement parameters.
      random_variable: list.
          List containing all random variables.
      current_index: integer.
          Index we are currently solving at this moment. May be different from current_global_index for "stocharstic_adaptive_refinement" strategy.
      current_analysis_stage: KratosMultiphysics.AnalysisStage of the problem.
      previous_computational_time: scalar.
          Time to solution of previous indices, if any.
      open_mp_threads: integer.
          Number of threads we are exploiting to solve current task.
      mapping_flag: boolean.
          It defines if in current_analysis_stage = SimulationScenario class mapping is required.
      pickled_mapping_reference_model: KratosMultiphysics.Model
          Model to which mapping is performed, if required.
      print_to_file: boolean.
          If true, the specific filename is passed to the analysis stage.
      filename: string.
          String which defines the name of the file the task will write, if any.
  
      Outputs:
      qoi: list.
          List of quantities of interest.
      pickled_finer_model: serialized adaptively refined KratosMultiphysics.Model, used at current index.
      computational_time: scalar.
          Time to solution up to current index.
docstring_summary: Auxiliary method to the solve method of the KratosSolverWrapper class. Firstly, if needed, adaptive refinement is performed. Then the problem is solved calling Kratos. To be called if the selected refinement strategy is stochastic_adaptive_refinement.
docstring_tokens: Auxiliary method to the solve method of the KratosSolverWrapper class . Firstly if needed adaptive refinement is performed . Then the problem is solved calling Kratos . To be called if the selected refinement strategy is stochastic_adaptive_refinement .
function: def ExecuteInstanceStochasticAdaptiveRefinementAux_Functionality(current_global_index,pickled_coarse_model,pickled_coarse_project_parameters,pickled_custom_metric_refinement_parameters,pickled_custom_remesh_refinement_parameters,random_variable,current_index,current_analysis_stage,previous_computational_time,open_mp_threads,mapping_flag,pickled_mapping_reference_model,print_to_file,filename):
      """
      Auxiliary method to the solve method of the KratosSolverWrapper class. Firstly, if needed, adaptive refinement is performed. Then the problem is solved calling Kratos. To be called if the selected refinement strategy is stochastic_adaptive_refinement.
  
      Inputs:
      current_global_index: integer.
          Index we are interested in and for which we have called the solve method of the solver wrapper.
      pickled_coarse_model: serialization of the KratosMultiphysics.Model.
      pickled_coarse_project_parameters: serialization of the KratosMultiphysics.Parameters.
      pickled_custom_metric_refinement_parameters: serialization of metric adaptive refinement parameters.
      pickled_custom_remesh_refinement_parameters: serialization of remeshing adaptive refinement parameters.
      random_variable: list.
          List containing all random variables.
      current_index: integer.
          Index we are currently solving at this moment. May be different from current_global_index for "stocharstic_adaptive_refinement" strategy.
      current_analysis_stage: KratosMultiphysics.AnalysisStage of the problem.
      previous_computational_time: scalar.
          Time to solution of previous indices, if any.
      open_mp_threads: integer.
          Number of threads we are exploiting to solve current task.
      mapping_flag: boolean.
          It defines if in current_analysis_stage = SimulationScenario class mapping is required.
      pickled_mapping_reference_model: KratosMultiphysics.Model
          Model to which mapping is performed, if required.
      print_to_file: boolean.
          If true, the specific filename is passed to the analysis stage.
      filename: string.
          String which defines the name of the file the task will write, if any.
  
      Outputs:
      qoi: list.
          List of quantities of interest.
      pickled_finer_model: serialized adaptively refined KratosMultiphysics.Model, used at current index.
      computational_time: scalar.
          Time to solution up to current index.
      """
  
      start_time = time.time()
      # unpickle model and build Kratos Model object
      serialized_model = pickle.loads(pickled_coarse_model)
      current_model = KratosMultiphysics.Model()
      serialized_model.Load("ModelSerialization",current_model)
      del(serialized_model)
      # unpickle parameters and build Kratos Parameters object
      serialized_project_parameters = pickle.loads(pickled_coarse_project_parameters)
      current_project_parameters = KratosMultiphysics.Parameters()
      serialized_project_parameters.Load("ParametersSerialization",current_project_parameters)
      del(serialized_project_parameters)
      # refine if current current_global_index > 0, adaptive refinement based on the solution of previous index
      if (current_index > 0):
          # unpickle metric and remesh refinement parameters and build Kratos Parameters objects
          serialized_custom_metric_refinement_parameters = pickle.loads(pickled_custom_metric_refinement_parameters)
          serialized_custom_remesh_refinement_parameters = pickle.loads(pickled_custom_remesh_refinement_parameters)
          current_custom_metric_refinement_parameters = KratosMultiphysics.Parameters()
          current_custom_remesh_refinement_parameters = KratosMultiphysics.Parameters()
          serialized_custom_metric_refinement_parameters.Load("MetricRefinementParametersSerialization",current_custom_metric_refinement_parameters)
          serialized_custom_remesh_refinement_parameters.Load("RemeshRefinementParametersSerialization",current_custom_remesh_refinement_parameters)
          del(serialized_custom_metric_refinement_parameters,serialized_custom_remesh_refinement_parameters)
          # refine the model Kratos object
          adaptive_refinement_manager = AdaptiveRefinement(current_index,current_model,current_project_parameters,current_custom_metric_refinement_parameters,current_custom_remesh_refinement_parameters)
          refined_model,refined_project_parameters = adaptive_refinement_manager.ComputeAdaptiveRefinement()
          current_model = refined_model
          del(refined_model,refined_project_parameters)
      # constructor analysis stage
      simulation = current_analysis_stage(current_model,current_project_parameters,random_variable)
      # add filename flag print_to_file is true
      if (print_to_file):
          simulation.filename = filename
      # add flag if current index is maximum index
      if (current_index == current_global_index):
          simulation.is_current_index_maximum_index = True
      else:
          simulation.is_current_index_maximum_index = False
      # mapping if in current finest level and mapping flag is true
      # otherwise standard behavior
      if (mapping_flag is True and current_index == current_global_index):
          # unpickle mapping reference model and build Kratos Model object
          serialized_mapping_reference_model = pickle.loads(pickled_mapping_reference_model)
          mapping_reference_model = KratosMultiphysics.Model()
          serialized_mapping_reference_model.Load("ModelSerialization",mapping_reference_model)
          del(serialized_mapping_reference_model)
          # send reference model to analysis stage for mapping and set mapping flag to true
          simulation.mapping_reference_model = mapping_reference_model
          simulation.mapping = True
      simulation.Run()
      # mapping if in current finest level and mapping flag is true
      # otherwise standard qoi evaluation
      if (mapping_flag is True and current_index == current_global_index):
          qoi = simulation.MappingAndEvaluateQuantityOfInterest()
      else:
          qoi = simulation.EvaluateQuantityOfInterest()
      # save model and parameters as MpiSerializer Kratos objects
      serialized_finer_model = KratosMultiphysics.MpiSerializer()
      serialized_finer_model.Save("ModelSerialization",simulation.model)
      # pickle model and parameters
      pickled_finer_model = pickle.dumps(serialized_finer_model, 2) # second argument is the protocol and is NECESSARY (according to pybind11 docs)
      del(simulation)
      end_time = time.time()
      computational_time = previous_computational_time + open_mp_threads*(end_time-start_time) # multiply by open mp threads to consider real machine cost
      return qoi,pickled_finer_model,computational_time
function_tokens: def ExecuteInstanceStochasticAdaptiveRefinementAux_Functionality ( current_global_index , pickled_coarse_model , pickled_coarse_project_parameters , pickled_custom_metric_refinement_parameters , pickled_custom_remesh_refinement_parameters , random_variable , current_index , current_analysis_stage , previous_computational_time , open_mp_threads , mapping_flag , pickled_mapping_reference_model , print_to_file , filename ) : start_time = time . time ( ) # unpickle model and build Kratos Model object serialized_model = pickle . loads ( pickled_coarse_model ) current_model = KratosMultiphysics . Model ( ) serialized_model . Load ( "ModelSerialization" , current_model ) del ( serialized_model ) # unpickle parameters and build Kratos Parameters object serialized_project_parameters = pickle . loads ( pickled_coarse_project_parameters ) current_project_parameters = KratosMultiphysics . Parameters ( ) serialized_project_parameters . Load ( "ParametersSerialization" , current_project_parameters ) del ( serialized_project_parameters ) # refine if current current_global_index > 0, adaptive refinement based on the solution of previous index if ( current_index > 0 ) : # unpickle metric and remesh refinement parameters and build Kratos Parameters objects serialized_custom_metric_refinement_parameters = pickle . loads ( pickled_custom_metric_refinement_parameters ) serialized_custom_remesh_refinement_parameters = pickle . loads ( pickled_custom_remesh_refinement_parameters ) current_custom_metric_refinement_parameters = KratosMultiphysics . Parameters ( ) current_custom_remesh_refinement_parameters = KratosMultiphysics . Parameters ( ) serialized_custom_metric_refinement_parameters . Load ( "MetricRefinementParametersSerialization" , current_custom_metric_refinement_parameters ) serialized_custom_remesh_refinement_parameters . Load ( "RemeshRefinementParametersSerialization" , current_custom_remesh_refinement_parameters ) del ( serialized_custom_metric_refinement_parameters , serialized_custom_remesh_refinement_parameters ) # refine the model Kratos object adaptive_refinement_manager = AdaptiveRefinement ( current_index , current_model , current_project_parameters , current_custom_metric_refinement_parameters , current_custom_remesh_refinement_parameters ) refined_model , refined_project_parameters = adaptive_refinement_manager . ComputeAdaptiveRefinement ( ) current_model = refined_model del ( refined_model , refined_project_parameters ) # constructor analysis stage simulation = current_analysis_stage ( current_model , current_project_parameters , random_variable ) # add filename flag print_to_file is true if ( print_to_file ) : simulation . filename = filename # add flag if current index is maximum index if ( current_index == current_global_index ) : simulation . is_current_index_maximum_index = True else : simulation . is_current_index_maximum_index = False # mapping if in current finest level and mapping flag is true # otherwise standard behavior if ( mapping_flag is True and current_index == current_global_index ) : # unpickle mapping reference model and build Kratos Model object serialized_mapping_reference_model = pickle . loads ( pickled_mapping_reference_model ) mapping_reference_model = KratosMultiphysics . Model ( ) serialized_mapping_reference_model . Load ( "ModelSerialization" , mapping_reference_model ) del ( serialized_mapping_reference_model ) # send reference model to analysis stage for mapping and set mapping flag to true simulation . mapping_reference_model = mapping_reference_model simulation . mapping = True simulation . Run ( ) # mapping if in current finest level and mapping flag is true # otherwise standard qoi evaluation if ( mapping_flag is True and current_index == current_global_index ) : qoi = simulation . MappingAndEvaluateQuantityOfInterest ( ) else : qoi = simulation . EvaluateQuantityOfInterest ( ) # save model and parameters as MpiSerializer Kratos objects serialized_finer_model = KratosMultiphysics . MpiSerializer ( ) serialized_finer_model . Save ( "ModelSerialization" , simulation . model ) # pickle model and parameters pickled_finer_model = pickle . dumps ( serialized_finer_model , 2 ) # second argument is the protocol and is NECESSARY (according to pybind11 docs) del ( simulation ) end_time = time . time ( ) computational_time = previous_computational_time + open_mp_threads * ( end_time - start_time ) # multiply by open mp threads to consider real machine cost return qoi , pickled_finer_model , computational_time