oomph::MyProblem Class Reference

#include <my_problem.h>

+ Inheritance diagram for oomph::MyProblem:

Public Member Functions

 MyProblem ()
 Default constructor. More...
 
virtual ~MyProblem ()
 
double smart_time_step (double dt, const double &tol)
 
virtual bool finished () const
 
void get_solver_parameters (SolverParameters &sp)
 
void set_solver_parameters (SolverParameters &sp)
 
bool explicit_flag ()
 
bool is_steady ()
 
virtual void actions_before_newton_step ()
 
unsigned nnewton_step_this_solve () const
 
virtual void actions_before_explicit_stage ()
 
virtual void actions_after_explicit_stage ()
 
virtual void actions_before_time_integration ()
 
virtual void actions_before_explicit_timestep ()
 Actions that should be performed before each explicit time step. More...
 
virtual void actions_after_explicit_timestep ()
 Actions that should be performed after each explicit time step. More...
 
virtual void actions_after_implicit_timestep ()
 
virtual void actions_before_implicit_timestep ()
 
virtual void actions_after_newton_step ()
 
virtual void actions_before_newton_solve ()
 
void segregated_pin_indices (const Vector< unsigned > &indices)
 
void undo_segregated_pinning ()
 Remove pinning set up by segregated_pin_indices. More...
 
void check_not_segregated (const char *function) const
 Check that nothing is currently pinned for a segregated solve. More...
 
void check_norm_limits ()
 
double min_element_size ()
 ??ds More...
 
void write_trace (const unsigned &t_hist=0)
 
virtual void write_additional_trace_data (const unsigned &t_hist, std::ofstream &trace_file) const
 
virtual void write_additional_trace_headers (std::ofstream &trace_file) const
 
virtual void output_solution (std::ofstream &soln_file) const
 Overload to write any problem specific data. More...
 
virtual void final_doc_additional () const
 
virtual void initial_doc_additional () const
 
void initial_doc ()
 
void final_doc ()
 
void doc_solution (const unsigned &t_hist=0, const std::string &prefix="")
 
virtual void output_solution (const unsigned &t, std::ostream &outstream, const unsigned &npoints=2) const
 
virtual void doc_boundaries (const std::string &boundary_file_basename) const
 Output nodes with boundary number to csv file. More...
 
void output_solution (std::ostream &outstream, const unsigned &npoints=2) const
 
virtual void output_exact_solution (const unsigned &t_hist, std::ostream &outstream, const unsigned &npoints=2) const
 
virtual double get_error_norm (const unsigned &t_hist=0) const
 Error norm calculator. More...
 
virtual double get_solution_norm (const unsigned &t_hist=0) const
 Dummy solution norm calculator (overload in derived classes). More...
 
virtual bool should_doc_this_step (const double &dt, const double &time) const
 
void set_doc_times (Vector< double > &doc_times)
 Assign a vector of times to output the full solution at. More...
 
double lte_norm ()
 
bool doc_exact () const
 
virtual Vector< doubletrace_values (const unsigned &t_hist=0) const
 
void dump_current_mm_or_jacobian_residuals (const std::string &label)
 
IterativeLinearSolveriterative_linear_solver_pt () const
 
virtual void build (Vector< Mesh * > &bulk_mesh_pt)
 Perform set up of problem. More...
 
const unsigned dim () const
 Get problem dimension (nodal dimension). More...
 
virtual std::string problem_name () const
 
virtual void set_up_impulsive_initial_condition ()
 Set all history values/dts to be the same as the present values/dt. More...
 
virtual void my_set_initial_condition (const SolutionFunctorBase &ic)
 Assign initial conditions from function pointer. More...
 
virtual void actions_after_set_initial_condition ()
 
virtual double integrate_over_problem (const ElementalFunction *func_pt, const Integral *quadrature_pt=0) const
 
virtual void dump (std::ofstream &dump_file) const
 
virtual void read (std::ifstream &restart_file)
 
void output_ltes (const unsigned &t_hist, std::ostream &output) const
 
Vector< doubleexact_solution (const double &t, const Vector< double > &x) const
 Get exact solution. More...
 
- Public Member Functions inherited from oomph::Problem
virtual void debug_hook_fct (const unsigned &i)
 
void set_analytic_dparameter (double *const &parameter_pt)
 
void unset_analytic_dparameter (double *const &parameter_pt)
 
bool is_dparameter_calculated_analytically (double *const &parameter_pt)
 
void set_analytic_hessian_products ()
 
void unset_analytic_hessian_products ()
 
bool are_hessian_products_calculated_analytically ()
 
void set_pinned_values_to_zero ()
 
bool distributed () const
 
virtual void actions_before_adapt ()
 
virtual void actions_after_adapt ()
 Actions that are to be performed after a mesh adaptation. More...
 
OomphCommunicatorcommunicator_pt ()
 access function to the oomph-lib communicator More...
 
const OomphCommunicatorcommunicator_pt () const
 access function to the oomph-lib communicator, const version More...
 
 Problem ()
 
 Problem (const Problem &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const Problem &)=delete
 Broken assignment operator. More...
 
virtual ~Problem ()
 Virtual destructor to clean up memory. More...
 
Mesh *& mesh_pt ()
 Return a pointer to the global mesh. More...
 
Mesh *const & mesh_pt () const
 Return a pointer to the global mesh (const version) More...
 
Mesh *& mesh_pt (const unsigned &imesh)
 
Mesh *const & mesh_pt (const unsigned &imesh) const
 Return a pointer to the i-th submesh (const version) More...
 
unsigned nsub_mesh () const
 Return number of submeshes. More...
 
unsigned add_sub_mesh (Mesh *const &mesh_pt)
 
void flush_sub_meshes ()
 
void build_global_mesh ()
 
void rebuild_global_mesh ()
 
LinearSolver *& linear_solver_pt ()
 Return a pointer to the linear solver object. More...
 
LinearSolver *const & linear_solver_pt () const
 Return a pointer to the linear solver object (const version) More...
 
LinearSolver *& mass_matrix_solver_for_explicit_timestepper_pt ()
 
LinearSolvermass_matrix_solver_for_explicit_timestepper_pt () const
 
EigenSolver *& eigen_solver_pt ()
 Return a pointer to the eigen solver object. More...
 
EigenSolver *const & eigen_solver_pt () const
 Return a pointer to the eigen solver object (const version) More...
 
Time *& time_pt ()
 Return a pointer to the global time object. More...
 
Timetime_pt () const
 Return a pointer to the global time object (const version). More...
 
doubletime ()
 Return the current value of continuous time. More...
 
double time () const
 Return the current value of continuous time (const version) More...
 
TimeStepper *& time_stepper_pt ()
 
const TimeSteppertime_stepper_pt () const
 
TimeStepper *& time_stepper_pt (const unsigned &i)
 Return a pointer to the i-th timestepper. More...
 
ExplicitTimeStepper *& explicit_time_stepper_pt ()
 Return a pointer to the explicit timestepper. More...
 
unsigned long set_timestepper_for_all_data (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data=false)
 
virtual void shift_time_values ()
 Shift all values along to prepare for next timestep. More...
 
AssemblyHandler *& assembly_handler_pt ()
 Return a pointer to the assembly handler object. More...
 
AssemblyHandler *const & assembly_handler_pt () const
 Return a pointer to the assembly handler object (const version) More...
 
doubleminimum_dt ()
 Access function to min timestep in adaptive timestepping. More...
 
doublemaximum_dt ()
 Access function to max timestep in adaptive timestepping. More...
 
unsignedmax_newton_iterations ()
 Access function to max Newton iterations before giving up. More...
 
void problem_is_nonlinear (const bool &prob_lin)
 Access function to Problem_is_nonlinear. More...
 
doublemax_residuals ()
 
booltime_adaptive_newton_crash_on_solve_fail ()
 Access function for Time_adaptive_newton_crash_on_solve_fail. More...
 
doublenewton_solver_tolerance ()
 
void add_time_stepper_pt (TimeStepper *const &time_stepper_pt)
 
void set_explicit_time_stepper_pt (ExplicitTimeStepper *const &explicit_time_stepper_pt)
 
void initialise_dt (const double &dt)
 
void initialise_dt (const Vector< double > &dt)
 
Data *& global_data_pt (const unsigned &i)
 Return a pointer to the the i-th global data object. More...
 
void add_global_data (Data *const &global_data_pt)
 
void flush_global_data ()
 
LinearAlgebraDistribution *const & dof_distribution_pt () const
 Return the pointer to the dof distribution (read-only) More...
 
unsigned long ndof () const
 Return the number of dofs. More...
 
unsigned ntime_stepper () const
 Return the number of time steppers. More...
 
unsigned nglobal_data () const
 Return the number of global data values. More...
 
unsigned self_test ()
 Self-test: Check meshes and global data. Return 0 for OK. More...
 
void enable_store_local_dof_pt_in_elements ()
 
void disable_store_local_dof_pt_in_elements ()
 
unsigned long assign_eqn_numbers (const bool &assign_local_eqn_numbers=true)
 
void describe_dofs (std::ostream &out= *(oomph_info.stream_pt())) const
 
void enable_discontinuous_formulation ()
 
void disable_discontinuous_formulation ()
 
void get_dofs (DoubleVector &dofs) const
 
void get_dofs (const unsigned &t, DoubleVector &dofs) const
 Return vector of the t'th history value of all dofs. More...
 
void set_dofs (const DoubleVector &dofs)
 Set the values of the dofs. More...
 
void set_dofs (const unsigned &t, DoubleVector &dofs)
 Set the history values of the dofs. More...
 
void set_dofs (const unsigned &t, Vector< double * > &dof_pt)
 
void add_to_dofs (const double &lambda, const DoubleVector &increment_dofs)
 Add lambda x incremenet_dofs[l] to the l-th dof. More...
 
doubleglobal_dof_pt (const unsigned &i)
 
doubledof (const unsigned &i)
 i-th dof in the problem More...
 
double dof (const unsigned &i) const
 i-th dof in the problem (const version) More...
 
double *& dof_pt (const unsigned &i)
 Pointer to i-th dof in the problem. More...
 
doubledof_pt (const unsigned &i) const
 Pointer to i-th dof in the problem (const version) More...
 
virtual void get_inverse_mass_matrix_times_residuals (DoubleVector &Mres)
 
virtual void get_dvaluesdt (DoubleVector &f)
 
virtual void get_residuals (DoubleVector &residuals)
 Get the total residuals Vector for the problem. More...
 
virtual void get_jacobian (DoubleVector &residuals, DenseDoubleMatrix &jacobian)
 
virtual void get_jacobian (DoubleVector &residuals, CRDoubleMatrix &jacobian)
 
virtual void get_jacobian (DoubleVector &residuals, CCDoubleMatrix &jacobian)
 
virtual void get_jacobian (DoubleVector &residuals, SumOfMatrices &jacobian)
 
void get_fd_jacobian (DoubleVector &residuals, DenseMatrix< double > &jacobian)
 Get the full Jacobian by finite differencing. More...
 
void get_derivative_wrt_global_parameter (double *const &parameter_pt, DoubleVector &result)
 
void get_hessian_vector_products (DoubleVectorWithHaloEntries const &Y, Vector< DoubleVectorWithHaloEntries > const &C, Vector< DoubleVectorWithHaloEntries > &product)
 
void solve_eigenproblem (const unsigned &n_eval, Vector< std::complex< double >> &eigenvalue, Vector< DoubleVector > &eigenvector, const bool &steady=true)
 Solve the eigenproblem. More...
 
void solve_eigenproblem (const unsigned &n_eval, Vector< std::complex< double >> &eigenvalue, const bool &steady=true)
 
virtual void get_eigenproblem_matrices (CRDoubleMatrix &mass_matrix, CRDoubleMatrix &main_matrix, const double &shift=0.0)
 
void assign_eigenvector_to_dofs (DoubleVector &eigenvector)
 Assign the eigenvector passed to the function to the dofs. More...
 
void add_eigenvector_to_dofs (const double &epsilon, const DoubleVector &eigenvector)
 
void store_current_dof_values ()
 Store the current values of the degrees of freedom. More...
 
void restore_dof_values ()
 Restore the stored values of the degrees of freedom. More...
 
void enable_jacobian_reuse ()
 
void disable_jacobian_reuse ()
 Disable recycling of Jacobian in Newton iteration. More...
 
bool jacobian_reuse_is_enabled ()
 Is recycling of Jacobian in Newton iteration enabled? More...
 
booluse_predictor_values_as_initial_guess ()
 
void newton_solve ()
 Use Newton method to solve the problem. More...
 
void enable_globally_convergent_newton_method ()
 enable globally convergent Newton method More...
 
void disable_globally_convergent_newton_method ()
 disable globally convergent Newton method More...
 
void newton_solve (unsigned const &max_adapt)
 
void steady_newton_solve (unsigned const &max_adapt=0)
 
void copy (Problem *orig_problem_pt)
 
virtual Problemmake_copy ()
 
virtual void read (std::ifstream &restart_file, bool &unsteady_restart)
 
void dump (const std::string &dump_file_name) const
 
void delete_all_external_storage ()
 
virtual void symmetrise_eigenfunction_for_adaptive_pitchfork_tracking ()
 
doublebifurcation_parameter_pt () const
 
void get_bifurcation_eigenfunction (Vector< DoubleVector > &eigenfunction)
 
void activate_fold_tracking (double *const &parameter_pt, const bool &block_solve=true)
 
void activate_bifurcation_tracking (double *const &parameter_pt, const DoubleVector &eigenvector, const bool &block_solve=true)
 
void activate_bifurcation_tracking (double *const &parameter_pt, const DoubleVector &eigenvector, const DoubleVector &normalisation, const bool &block_solve=true)
 
void activate_pitchfork_tracking (double *const &parameter_pt, const DoubleVector &symmetry_vector, const bool &block_solve=true)
 
void activate_hopf_tracking (double *const &parameter_pt, const bool &block_solve=true)
 
void activate_hopf_tracking (double *const &parameter_pt, const double &omega, const DoubleVector &null_real, const DoubleVector &null_imag, const bool &block_solve=true)
 
void deactivate_bifurcation_tracking ()
 
void reset_assembly_handler_to_default ()
 Reset the system to the standard non-augemented state. More...
 
double arc_length_step_solve (double *const &parameter_pt, const double &ds, const unsigned &max_adapt=0)
 
double arc_length_step_solve (Data *const &data_pt, const unsigned &data_index, const double &ds, const unsigned &max_adapt=0)
 
void reset_arc_length_parameters ()
 
intsign_of_jacobian ()
 
void explicit_timestep (const double &dt, const bool &shift_values=true)
 Take an explicit timestep of size dt. More...
 
void unsteady_newton_solve (const double &dt)
 
void unsteady_newton_solve (const double &dt, const bool &shift_values)
 
void unsteady_newton_solve (const double &dt, const unsigned &max_adapt, const bool &first, const bool &shift=true)
 
double doubly_adaptive_unsteady_newton_solve (const double &dt, const double &epsilon, const unsigned &max_adapt, const bool &first, const bool &shift=true)
 
double doubly_adaptive_unsteady_newton_solve (const double &dt, const double &epsilon, const unsigned &max_adapt, const unsigned &suppress_resolve_after_spatial_adapt_flag, const bool &first, const bool &shift=true)
 
double adaptive_unsteady_newton_solve (const double &dt_desired, const double &epsilon)
 
double adaptive_unsteady_newton_solve (const double &dt_desired, const double &epsilon, const bool &shift_values)
 
void assign_initial_values_impulsive ()
 
void assign_initial_values_impulsive (const double &dt)
 
void calculate_predictions ()
 Calculate predictions. More...
 
void enable_mass_matrix_reuse ()
 
void disable_mass_matrix_reuse ()
 
bool mass_matrix_reuse_is_enabled ()
 Return whether the mass matrix is being reused. More...
 
void refine_uniformly (const Vector< unsigned > &nrefine_for_mesh)
 
void refine_uniformly (const Vector< unsigned > &nrefine_for_mesh, DocInfo &doc_info)
 
void refine_uniformly_and_prune (const Vector< unsigned > &nrefine_for_mesh)
 
void refine_uniformly_and_prune (const Vector< unsigned > &nrefine_for_mesh, DocInfo &doc_info)
 
void refine_uniformly (DocInfo &doc_info)
 
void refine_uniformly_and_prune (DocInfo &doc_info)
 
void refine_uniformly ()
 
void refine_uniformly (const unsigned &i_mesh, DocInfo &doc_info)
 Do uniform refinement for submesh i_mesh with documentation. More...
 
void refine_uniformly (const unsigned &i_mesh)
 Do uniform refinement for submesh i_mesh without documentation. More...
 
void p_refine_uniformly (const Vector< unsigned > &nrefine_for_mesh)
 
void p_refine_uniformly (const Vector< unsigned > &nrefine_for_mesh, DocInfo &doc_info)
 
void p_refine_uniformly_and_prune (const Vector< unsigned > &nrefine_for_mesh)
 
void p_refine_uniformly_and_prune (const Vector< unsigned > &nrefine_for_mesh, DocInfo &doc_info)
 
void p_refine_uniformly (DocInfo &doc_info)
 
void p_refine_uniformly_and_prune (DocInfo &doc_info)
 
void p_refine_uniformly ()
 
void p_refine_uniformly (const unsigned &i_mesh, DocInfo &doc_info)
 Do uniform p-refinement for submesh i_mesh with documentation. More...
 
void p_refine_uniformly (const unsigned &i_mesh)
 Do uniform p-refinement for submesh i_mesh without documentation. More...
 
void refine_selected_elements (const Vector< unsigned > &elements_to_be_refined)
 
void refine_selected_elements (const Vector< RefineableElement * > &elements_to_be_refined_pt)
 
void refine_selected_elements (const unsigned &i_mesh, const Vector< unsigned > &elements_to_be_refined)
 
void refine_selected_elements (const unsigned &i_mesh, const Vector< RefineableElement * > &elements_to_be_refined_pt)
 
void refine_selected_elements (const Vector< Vector< unsigned >> &elements_to_be_refined)
 
void refine_selected_elements (const Vector< Vector< RefineableElement * >> &elements_to_be_refined_pt)
 
void p_refine_selected_elements (const Vector< unsigned > &elements_to_be_refined)
 
void p_refine_selected_elements (const Vector< PRefineableElement * > &elements_to_be_refined_pt)
 
void p_refine_selected_elements (const unsigned &i_mesh, const Vector< unsigned > &elements_to_be_refined)
 
void p_refine_selected_elements (const unsigned &i_mesh, const Vector< PRefineableElement * > &elements_to_be_refined_pt)
 
void p_refine_selected_elements (const Vector< Vector< unsigned >> &elements_to_be_refined)
 
void p_refine_selected_elements (const Vector< Vector< PRefineableElement * >> &elements_to_be_refined_pt)
 
unsigned unrefine_uniformly ()
 
unsigned unrefine_uniformly (const unsigned &i_mesh)
 
void p_unrefine_uniformly (DocInfo &doc_info)
 
void p_unrefine_uniformly (const unsigned &i_mesh, DocInfo &doc_info)
 Do uniform p-unrefinement for submesh i_mesh without documentation. More...
 
void adapt (unsigned &n_refined, unsigned &n_unrefined)
 
void adapt ()
 
void p_adapt (unsigned &n_refined, unsigned &n_unrefined)
 
void p_adapt ()
 
void adapt_based_on_error_estimates (unsigned &n_refined, unsigned &n_unrefined, Vector< Vector< double >> &elemental_error)
 
void adapt_based_on_error_estimates (Vector< Vector< double >> &elemental_error)
 
void get_all_error_estimates (Vector< Vector< double >> &elemental_error)
 
void doc_errors (DocInfo &doc_info)
 Get max and min error for all elements in submeshes. More...
 
void doc_errors ()
 Get max and min error for all elements in submeshes. More...
 
void enable_info_in_newton_solve ()
 
void disable_info_in_newton_solve ()
 Disable the output of information when in the newton solver. More...
 
- Public Member Functions inherited from oomph::ExplicitTimeSteppableObject
 ExplicitTimeSteppableObject ()
 Empty constructor. More...
 
 ExplicitTimeSteppableObject (const ExplicitTimeSteppableObject &)=delete
 Broken copy constructor. More...
 
void operator= (const ExplicitTimeSteppableObject &)=delete
 Broken assignment operator. More...
 
virtual ~ExplicitTimeSteppableObject ()
 Empty destructor. More...
 

Public Attributes

MyDocInfo Doc_info
 
unsigned Output_precision
 
unsigned N_steps_taken
 
double Total_step_time
 
std::string Trace_filename
 
std::string Info_filename
 
double Error_norm_limit
 
double Solution_norm_limit
 
bool Disable_mass_matrix_solver_optimisations
 
bool Always_write_trace
 Should we output to trace file every step? More...
 
bool Want_doc_exact
 Should we try to output exact solution? More...
 
bool Should_doc_boundaries
 Should we output the locations of the boundary nodes? More...
 
bool Dump
 Should we dump ready for a restart? More...
 
bool Output_ltes
 Should we output the local truncation error at each node as well? More...
 
bool Output_predictor_values
 Should we output the predicted values too? More...
 
bool Output_initial_condition
 Should we write output for initial conditions as though they are time steps as well? More...
 
SolutionFunctorBaseExact_solution_pt
 Function pointer for exact solution. More...
 
- Public Attributes inherited from oomph::Problem
bool Shut_up_in_newton_solve
 

Protected Attributes

const std::string Trace_seperator
 
double Dummy_doc_data
 
unsigned Dim
 
- Protected Attributes inherited from oomph::Problem
Vector< Problem * > Copy_of_problem_pt
 
std::map< double *, boolCalculate_dparameter_analytic
 
bool Calculate_hessian_products_analytic
 
LinearAlgebraDistributionDof_distribution_pt
 
Vector< double * > Dof_pt
 Vector of pointers to dofs. More...
 
DoubleVectorWithHaloEntries Element_count_per_dof
 
double Relaxation_factor
 
double Newton_solver_tolerance
 
unsigned Max_newton_iterations
 Maximum number of Newton iterations. More...
 
unsigned Nnewton_iter_taken
 
Vector< doubleMax_res
 Maximum residuals at start and after each newton iteration. More...
 
double Max_residuals
 
bool Time_adaptive_newton_crash_on_solve_fail
 
bool Jacobian_reuse_is_enabled
 Is re-use of Jacobian in Newton iteration enabled? Default: false. More...
 
bool Jacobian_has_been_computed
 
bool Problem_is_nonlinear
 
bool Pause_at_end_of_sparse_assembly
 
bool Doc_time_in_distribute
 
unsigned Sparse_assembly_method
 
unsigned Sparse_assemble_with_arrays_initial_allocation
 
unsigned Sparse_assemble_with_arrays_allocation_increment
 
Vector< Vector< unsigned > > Sparse_assemble_with_arrays_previous_allocation
 
double Numerical_zero_for_sparse_assembly
 
double FD_step_used_in_get_hessian_vector_products
 
bool Mass_matrix_reuse_is_enabled
 
bool Mass_matrix_has_been_computed
 
bool Discontinuous_element_formulation
 
double Minimum_dt
 Minimum desired dt: if dt falls below this value, exit. More...
 
double Maximum_dt
 Maximum desired dt. More...
 
double DTSF_max_increase
 
double DTSF_min_decrease
 
double Minimum_dt_but_still_proceed
 
bool Scale_arc_length
 Boolean to control whether arc-length should be scaled. More...
 
double Desired_proportion_of_arc_length
 Proportion of the arc-length to taken by the parameter. More...
 
double Theta_squared
 
int Sign_of_jacobian
 Storage for the sign of the global Jacobian. More...
 
double Continuation_direction
 
double Parameter_derivative
 Storage for the derivative of the global parameter wrt arc-length. More...
 
double Parameter_current
 Storage for the present value of the global parameter. More...
 
bool Use_continuation_timestepper
 Boolean to control original or new storage of dof stuff. More...
 
unsigned Dof_derivative_offset
 
unsigned Dof_current_offset
 
Vector< doubleDof_derivative
 Storage for the derivative of the problem variables wrt arc-length. More...
 
Vector< doubleDof_current
 Storage for the present values of the variables. More...
 
double Ds_current
 Storage for the current step value. More...
 
unsigned Desired_newton_iterations_ds
 
double Minimum_ds
 Minimum desired value of arc-length. More...
 
bool Bifurcation_detection
 Boolean to control bifurcation detection via determinant of Jacobian. More...
 
bool Bisect_to_find_bifurcation
 Boolean to control wheter bisection is used to located bifurcation. More...
 
bool First_jacobian_sign_change
 Boolean to indicate whether a sign change has occured in the Jacobian. More...
 
bool Arc_length_step_taken
 Boolean to indicate whether an arc-length step has been taken. More...
 
bool Use_finite_differences_for_continuation_derivatives
 
OomphCommunicatorCommunicator_pt
 The communicator for this problem. More...
 
bool Always_take_one_newton_step
 
double Timestep_reduction_factor_after_nonconvergence
 
bool Keep_temporal_error_below_tolerance
 

Private Member Functions

 MyProblem (const MyProblem &dummy)
 Inaccessible copy constructor. More...
 
void operator= (const MyProblem &dummy)
 Inaccessible assignment operator. More...
 

Private Attributes

Vector< doubleJacobian_setup_times
 
Vector< doubleSolver_times
 
Vector< doubleSolver_iterations
 
Vector< doublePreconditioner_setup_times
 
Vector< doubleDoc_times
 Times at which we want to output the full solution. More...
 

Additional Inherited Members

- Public Types inherited from oomph::Problem
typedef void(* SpatialErrorEstimatorFctPt) (Mesh *&mesh_pt, Vector< double > &elemental_error)
 Function pointer for spatial error estimator. More...
 
typedef void(* SpatialErrorEstimatorWithDocFctPt) (Mesh *&mesh_pt, Vector< double > &elemental_error, DocInfo &doc_info)
 Function pointer for spatial error estimator with doc. More...
 
- Static Public Attributes inherited from oomph::Problem
static bool Suppress_warning_about_actions_before_read_unstructured_meshes
 
- Protected Types inherited from oomph::Problem
enum  Assembly_method {
  Perform_assembly_using_vectors_of_pairs , Perform_assembly_using_two_vectors , Perform_assembly_using_maps , Perform_assembly_using_lists ,
  Perform_assembly_using_two_arrays
}
 Enumerated flags to determine which sparse assembly method is used. More...
 
- Protected Member Functions inherited from oomph::Problem
unsigned setup_element_count_per_dof ()
 
virtual void sparse_assemble_row_or_column_compressed (Vector< int * > &column_or_row_index, Vector< int * > &row_or_column_start, Vector< double * > &value, Vector< unsigned > &nnz, Vector< double * > &residual, bool compressed_row_flag)
 
virtual void actions_after_newton_solve ()
 
virtual void actions_before_newton_convergence_check ()
 
virtual void actions_after_implicit_timestep_and_error_estimation ()
 
virtual void actions_before_read_unstructured_meshes ()
 
virtual void actions_after_read_unstructured_meshes ()
 
virtual void actions_after_change_in_global_parameter (double *const &parameter_pt)
 
virtual void actions_after_change_in_bifurcation_parameter ()
 
virtual void actions_after_parameter_increase (double *const &parameter_pt)
 
doubledof_derivative (const unsigned &i)
 
doubledof_current (const unsigned &i)
 
virtual void set_initial_condition ()
 
virtual double global_temporal_error_norm ()
 
unsigned newton_solve_continuation (double *const &parameter_pt)
 
unsigned newton_solve_continuation (double *const &parameter_pt, DoubleVector &z)
 
void calculate_continuation_derivatives (double *const &parameter_pt)
 
void calculate_continuation_derivatives (const DoubleVector &z)
 
void calculate_continuation_derivatives_fd (double *const &parameter_pt)
 
bool does_pointer_correspond_to_problem_data (double *const &parameter_pt)
 
void set_consistent_pinned_values_for_continuation ()
 
- Static Protected Attributes inherited from oomph::Problem
static ContinuationStorageScheme Continuation_time_stepper
 Storage for the single static continuation timestorage object. More...
 

Constructor & Destructor Documentation

◆ MyProblem() [1/2]

oomph::MyProblem::MyProblem ( )
inline

Default constructor.

134  :
135  Trace_filename("trace"),
136  Info_filename("info"),
137  Trace_seperator("; "),
138  Dummy_doc_data(-1)
139  {
140  Dim = 0;
141  Output_precision = 8;
142  Error_norm_limit = -1.0;
143  Solution_norm_limit = -1.0;
144 
145  // Throw a real error (not just a warning) if the output directory
146  // does not exist.
148 
150 
151  // By default output to trace file every step
152  Always_write_trace = true;
153 
154  Dump = false;
155  Output_ltes = false;
156  Output_predictor_values = false;
157  Want_doc_exact = false;
158  Output_initial_condition = false;
159  Should_doc_boundaries = false;
160 
161  N_steps_taken = 0;
162  Total_step_time= 0;
163  }
void enable_error_if_directory_does_not_exist()
Call to throw an error if directory does not exist.
Definition: oomph_utilities.h:584
double Total_step_time
Definition: my_problem.h:872
double Error_norm_limit
Definition: my_problem.h:877
bool Should_doc_boundaries
Should we output the locations of the boundary nodes?
Definition: my_problem.h:891
bool Want_doc_exact
Should we try to output exact solution?
Definition: my_problem.h:888
unsigned Output_precision
Definition: my_problem.h:869
bool Disable_mass_matrix_solver_optimisations
Definition: my_problem.h:882
std::string Info_filename
Definition: my_problem.h:875
unsigned N_steps_taken
Definition: my_problem.h:871
double Dummy_doc_data
Definition: my_problem.h:927
bool Output_predictor_values
Should we output the predicted values too?
Definition: my_problem.h:900
bool Output_ltes
Should we output the local truncation error at each node as well?
Definition: my_problem.h:897
unsigned Dim
Definition: my_problem.h:928
MyDocInfo Doc_info
Definition: my_problem.h:868
bool Dump
Should we dump ready for a restart?
Definition: my_problem.h:894
double Solution_norm_limit
Definition: my_problem.h:878
const std::string Trace_seperator
Definition: my_problem.h:926
bool Output_initial_condition
Should we write output for initial conditions as though they are time steps as well?
Definition: my_problem.h:903
bool Always_write_trace
Should we output to trace file every step?
Definition: my_problem.h:885
std::string Trace_filename
Definition: my_problem.h:874

References Global_Variables::Dim, and GlobalParameters::Doc_info.

◆ ~MyProblem()

virtual oomph::MyProblem::~MyProblem ( )
inlinevirtual

Virtual destructor. Policy decision: my problem classes won't call delete on anything. That's up to the driver code or whatever. Ideally we should just start using c++11 smart pointers and not have to worry so much about memory management!

169 {}

◆ MyProblem() [2/2]

oomph::MyProblem::MyProblem ( const MyProblem dummy)
inlineprivate

Inaccessible copy constructor.

942  {BrokenCopy::broken_copy("MyProblem");}
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212

References oomph::BrokenCopy::broken_copy().

Member Function Documentation

◆ actions_after_explicit_stage()

virtual void oomph::MyProblem::actions_after_explicit_stage ( )
inlinevirtual

Empty virtual function that should be overloaded to update any dependent data or boundary conditions that should be advanced after each stage of an explicit time step (Runge-Kutta steps contain multiple stages per time step, most others only contain one).

Reimplemented from oomph::ExplicitTimeSteppableObject.

291  {
292  Jacobian_setup_times.push_back
293  (this->mass_matrix_solver_for_explicit_timestepper_pt()->jacobian_setup_time());
294  Solver_times.push_back
295  (this->mass_matrix_solver_for_explicit_timestepper_pt()->linear_solver_solution_time());
296 
297  // No non-linear residuals to store
298 
299  const IterativeLinearSolver* its_pt
300  = dynamic_cast<const IterativeLinearSolver*>(this->mass_matrix_solver_for_explicit_timestepper_pt());
301  if(its_pt != 0)
302  {
303  Solver_iterations.push_back(its_pt->iterations());
304  Preconditioner_setup_times.push_back(its_pt->preconditioner_setup_time());
305  }
306  else
307  {
308  // Fill in dummy data
311  }
312 
313  // Not quite the same as actions after newton step because we are
314  // interested in what happened in the explicit solver instead of the
315  // main solver.
316  }
Vector< double > Solver_times
Definition: my_problem.h:933
Vector< double > Preconditioner_setup_times
Definition: my_problem.h:935
Vector< double > Solver_iterations
Definition: my_problem.h:934
Vector< double > Jacobian_setup_times
Definition: my_problem.h:932
LinearSolver *& mass_matrix_solver_for_explicit_timestepper_pt()
Definition: problem.h:1479

References oomph::IterativeLinearSolver::iterations(), and oomph::IterativeLinearSolver::preconditioner_setup_time().

◆ actions_after_explicit_timestep()

virtual void oomph::MyProblem::actions_after_explicit_timestep ( )
inlinevirtual

Actions that should be performed after each explicit time step.

Reimplemented from oomph::Problem.

327  {
329  }
virtual void actions_after_newton_solve()
Definition: problem.h:1038

References oomph::Problem::actions_after_newton_solve().

◆ actions_after_implicit_timestep()

virtual void oomph::MyProblem::actions_after_implicit_timestep ( )
inlinevirtual

Actions that should be performed after each implicit time step. This is needed when one wants to solve a steady problem before timestepping and needs to distinguish between the two cases

Reimplemented from oomph::Problem.

331 {}

◆ actions_after_newton_step()

virtual void oomph::MyProblem::actions_after_newton_step ( )
inlinevirtual

Any actions that are to be performed after each individual Newton step. Most likely to be used for diagnostic purposes to doc the solution during a non-converging iteration, say.

Reimplemented from oomph::Problem.

340  {
341  Jacobian_setup_times.push_back
342  (this->linear_solver_pt()->jacobian_setup_time());
343  Solver_times.push_back
344  (this->linear_solver_pt()->linear_solver_solution_time());
345 
346  const IterativeLinearSolver* its_pt
347  = dynamic_cast<const IterativeLinearSolver*>(this->linear_solver_pt());
348  if(its_pt != 0)
349  {
350  Solver_iterations.push_back(its_pt->iterations());
351  Preconditioner_setup_times.push_back(its_pt->preconditioner_setup_time());
352  }
353  else
354  {
355  // Fill in dummy data
358  }
359  }
LinearSolver *& linear_solver_pt()
Return a pointer to the linear solver object.
Definition: problem.h:1466

References oomph::IterativeLinearSolver::iterations(), and oomph::IterativeLinearSolver::preconditioner_setup_time().

◆ actions_after_set_initial_condition()

void MyProblem::actions_after_set_initial_condition ( )
virtual

Hook to be overloaded with any calculations needed after setting of initial conditions.

1114  {
1115  // If using TR calculate initial derivative with these initial conditions
1116  TR* tr_pt = dynamic_cast<TR*>(time_stepper_pt());
1117  if(tr_pt != 0)
1118  {
1119  tr_pt->setup_initial_derivative(this);
1120  }
1121  }
TimeStepper *& time_stepper_pt()
Definition: problem.h:1524
#define TR
Definition: common.h:40

References oomph::TR::setup_initial_derivative().

Referenced by oomph::ODEProblem::my_set_initial_condition().

◆ actions_before_explicit_stage()

virtual void oomph::MyProblem::actions_before_explicit_stage ( )
inlinevirtual

Empty virtual function to do anything needed before a stage of an explicit time step (Runge-Kutta steps contain multiple stages per time step, most others only contain one).

Reimplemented from oomph::ExplicitTimeSteppableObject.

virtual void actions_before_newton_step()
Definition: my_problem.h:268

References actions_before_newton_step().

◆ actions_before_explicit_timestep()

virtual void oomph::MyProblem::actions_before_explicit_timestep ( )
inlinevirtual

Actions that should be performed before each explicit time step.

Reimplemented from oomph::Problem.

321  {
324  }
virtual void actions_before_newton_solve()
Definition: my_problem.h:361
void check_norm_limits()
Definition: my_problem.h:467

References actions_before_newton_solve().

◆ actions_before_implicit_timestep()

virtual void oomph::MyProblem::actions_before_implicit_timestep ( )
inlinevirtual

Actions that should be performed before each implicit time step. This is needed when one wants to solve a steady problem before timestepping and needs to distinguish between the two cases

Reimplemented from oomph::Problem.

334  {
336  }

◆ actions_before_newton_solve()

virtual void oomph::MyProblem::actions_before_newton_solve ( )
inlinevirtual

Any actions that are to be performed before a complete Newton solve (e.g. adjust boundary conditions). CAREFUL: This step should (and if the FD-based LinearSolver FD_LU is used, must) only update values that are pinned!

Reimplemented from oomph::Problem.

362  {
363  // Clean up times vectors
364  Jacobian_setup_times.clear();
365  Solver_times.clear();
366  Solver_iterations.clear();
368  }

Referenced by actions_before_explicit_timestep().

◆ actions_before_newton_step()

virtual void oomph::MyProblem::actions_before_newton_step ( )
inlinevirtual

Any actions that are to be performed before each individual Newton step. Most likely to be used for diagnostic purposes to doc the solution during a non-converging iteration, say.

Reimplemented from oomph::Problem.

269  {
270  // Output Jacobian and residuals if requested
271  if(to_lower(Doc_info.output_jacobian) == "always")
272  {
273  // label with doc_info number and the newton step number
275  + "_"
277 
279  }
280  }
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
std::string output_jacobian
Definition: my_problem.h:125
unsigned nnewton_step_this_solve() const
Definition: my_problem.h:282
void dump_current_mm_or_jacobian_residuals(const std::string &label)
Definition: my_problem.h:960
label
Definition: UniformPSDSelfTest.py:24
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
std::string to_lower(const std::string &input)
Convert a string to lower case (outputs a copy).
Definition: oomph_utilities.cc:345

References GlobalParameters::Doc_info, UniformPSDSelfTest::label, oomph::Global_string_for_annotation::string(), oomph::StringConversion::to_lower(), and oomph::StringConversion::to_string().

Referenced by actions_before_explicit_stage().

◆ actions_before_time_integration()

virtual void oomph::MyProblem::actions_before_time_integration ( )
inlinevirtual
318 {}

◆ build()

void MyProblem::build ( Vector< Mesh * > &  bulk_mesh_pt)
virtual

Perform set up of problem.

Reimplemented in oomph::ODEProblem.

968  {
969  // Copy the first mesh's first timestepper to the problem
970 
971  FiniteElement* fele_pt = dynamic_cast<FiniteElement*>
972  (bulk_mesh_pt[0]->element_pt(0));
973 
974  // Finite element mesh: grab ts from node
975  if(fele_pt != 0)
976  {
977  TimeStepper* ts_pt = bulk_mesh_pt[0]->node_pt(0)->time_stepper_pt();
978  this->add_time_stepper_pt(ts_pt);
979 
980  // ??ds assumed any timesteppers hiding somewhere else are added elsewhere
981 
982 #ifdef PARANOID
983  for(unsigned j=0; j<bulk_mesh_pt.size(); j++)
984  {
985  if(bulk_mesh_pt[j]->node_pt(0)->time_stepper_pt()
986  != ts_pt)
987  {
988  std::string err = "Multiple timesteppers, you need to do somedhing more fancy here";
989  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
991  }
992  }
993 #endif
994  }
995 
996  // Non finite element mesh: grab ts from internal data
997  else
998  {
999  TimeStepper* ts_pt = bulk_mesh_pt[0]->element_pt(0)->
1000  internal_data_pt(0)->time_stepper_pt();
1001  this->add_time_stepper_pt(ts_pt);
1002 
1003  // ??ds again assumed any timesteppers hiding somewhere else are added elsewhere
1004 
1005 #ifdef PARANOID
1006  for(unsigned j=0; j<bulk_mesh_pt.size(); j++)
1007  {
1008  if(bulk_mesh_pt[j]->element_pt(0)->
1009  internal_data_pt(0)->time_stepper_pt() != ts_pt)
1010  {
1011  std::string err = "Multiple timesteppers? you need to do somedhing more fancy here";
1012  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1014  }
1015  }
1016 #endif
1017  }
1018 
1019 
1020  // Push all the meshes into the problem's sub mesh list
1021  for(unsigned j=0; j<bulk_mesh_pt.size(); j++)
1022  {
1023  add_sub_mesh(bulk_mesh_pt[j]);
1024  }
1025 
1026  // If we have an iterative solver with a block preconditioner then
1027  // add all the meshes to the block preconditioner as well.
1028  IterativeLinearSolver* its_pt = iterative_linear_solver_pt();
1029  if(its_pt != 0)
1030  {
1031 // RRR add comments to why this is incorrect:
1032 // We cannot call set_nmesh and set_mesh, this is handled by the derived
1033 // classes.
1034  // Try to get a block preconditioner from the preconditioner
1035  BlockPreconditioner<CRDoubleMatrix>* bp_pt
1036  = smart_cast_preconditioner<BlockPreconditioner<CRDoubleMatrix>*>
1037  (its_pt->preconditioner_pt());
1038 
1039  if(bp_pt != 0)
1040  {
1041 #ifdef PARANOID
1042  {
1043  std::string err = "IS THIS EVER USED?";
1044  throw OomphLibError(err, OOMPH_CURRENT_FUNCTION,
1046  }
1047 #endif
1048 
1049  // This part of the code is never executed in the driver code.
1050  // Commented out since it no longer make sense. The functions
1051  // set_nmesh() and set_mesh() are made protected. Each derived
1052  // block preconditioner has to call set_nmesh() and set_mesh(),
1053  // since the preconditioner knows which mesh goes where, the
1054  // writer of the driver code does not necessarily know.
1055 
1056 // // Set up meshes
1057 // bp_pt->set_nmesh(nsub_mesh());
1058 // for(unsigned i=0; i< nsub_mesh(); i++)
1059 // {
1060 // bp_pt->set_mesh(i, mesh_pt(i));
1061 // }
1062  }
1063  }
1064 
1065  // Get the problem dimension
1066  if(fele_pt != 0)
1067  {
1068  Dim = fele_pt->nodal_dimension();
1069  }
1070  else
1071  {
1072  // Presumably if a "bulk" mesh contains non-finite elements
1073  // then this is not a pde, so no dimension as such.
1074  Dim = 0;
1075  }
1076 
1078  {
1079  // Set the solver for explicit timesteps (mass matrix) to CG with a
1080  // diagonal predconditioner.
1081  IterativeLinearSolver* expl_solver_pt = new CG<CRDoubleMatrix>;
1082  expl_solver_pt->preconditioner_pt() =
1083  new MatrixBasedLumpedPreconditioner<CRDoubleMatrix>;
1084 
1085  // If it takes more than 100 iterations then something has almost
1086  // certainly gone wrong!
1087  expl_solver_pt->max_iter() = 100;
1088  expl_solver_pt->enable_error_after_max_iter();
1090 
1091  // expl_solver_pt->enable_doc_convergence_history();
1092 
1093  // Store + re-use the mass matrix used in explicit steps (since we
1094  // are almost certainly not going to do spatially adaptivity
1095  // anytime soon this is safe).
1096  this->enable_mass_matrix_reuse();
1097  }
1098 
1099 
1100  // If we requested exact solution output then check we have a solution
1101  if(Want_doc_exact && Exact_solution_pt == 0)
1102  {
1103  std::string warning = "Requested doc'ing exact solution, but we don't have an exact solution function pointer.";
1104  OomphLibWarning(warning, OOMPH_CURRENT_FUNCTION,
1106 
1107  }
1108  }
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:55
SolutionFunctorBase * Exact_solution_pt
Function pointer for exact solution.
Definition: my_problem.h:906
IterativeLinearSolver * iterative_linear_solver_pt() const
Definition: my_problem.h:751
void add_time_stepper_pt(TimeStepper *const &time_stepper_pt)
Definition: problem.cc:1545
unsigned add_sub_mesh(Mesh *const &mesh_pt)
Definition: problem.h:1330
void enable_mass_matrix_reuse()
Definition: problem.cc:11807
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Global_Variables::Dim, oomph::IterativeLinearSolver::enable_error_after_max_iter(), j, oomph::IterativeLinearSolver::max_iter(), oomph::FiniteElement::nodal_dimension(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::IterativeLinearSolver::preconditioner_pt(), and oomph::Global_string_for_annotation::string().

Referenced by oomph::ODEProblem::build().

◆ check_norm_limits()

void oomph::MyProblem::check_norm_limits ( )
inline
468  {
469  // If a limit has been set
470  if(Error_norm_limit != -1.0)
471  {
472  double error_norm = get_error_norm();
473 
474  if((error_norm != Dummy_doc_data)
475  && (error_norm > Error_norm_limit))
476  {
477  std::string err = "Error norm " + to_string(error_norm);
478  err += " exceeds the limit " + to_string(Error_norm_limit);
479  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
481  }
482  }
483 
484  // Same for solution norm
485  if(Solution_norm_limit != -1.0)
486  {
487  double solution_norm = get_solution_norm();
488 
489  if((solution_norm != Dummy_doc_data)
490  && (solution_norm > Solution_norm_limit))
491  {
492  std::string err = "Solution norm " + to_string(solution_norm);
493  err += " exceeds the limit " + to_string(Solution_norm_limit);
494  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
496  }
497  }
498  }
virtual double get_error_norm(const unsigned &t_hist=0) const
Error norm calculator.
Definition: my_problem.h:627
virtual double get_solution_norm(const unsigned &t_hist=0) const
Dummy solution norm calculator (overload in derived classes).
Definition: my_problem.h:666

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Global_string_for_annotation::string(), and oomph::StringConversion::to_string().

◆ check_not_segregated()

void oomph::MyProblem::check_not_segregated ( const char function) const
inline

Check that nothing is currently pinned for a segregated solve.

444  {
445 #ifdef PARANOID
446  for(unsigned msh=0, nmsh=nsub_mesh(); msh<nmsh; msh++)
447  {
448  Mesh* mesh_pt = this->mesh_pt(msh);
449  for(unsigned nd=0, nnd=mesh_pt->nnode(); nd<nnd; nd++)
450  {
451  Node* nd_pt = mesh_pt->node_pt(nd);
452  for(unsigned j=0; j<nd_pt->nvalue(); j++)
453  {
454  if(nd_pt->eqn_number(j) == Data::Is_segregated_solve_pinned)
455  {
456  throw OomphLibError("Some dofs already segregated",
458  function);
459  }
460  }
461  }
462  }
463 #endif
464  }
static long Is_segregated_solve_pinned
Definition: nodes.h:188
unsigned long nnode() const
Return number of nodes in the mesh.
Definition: mesh.h:596
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:436
Mesh *& mesh_pt()
Return a pointer to the global mesh.
Definition: problem.h:1280
unsigned nsub_mesh() const
Return number of submeshes.
Definition: problem.h:1323

References oomph::Data::eqn_number(), oomph::Data::Is_segregated_solve_pinned, j, oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::Data::nvalue(), and OOMPH_EXCEPTION_LOCATION.

◆ dim()

const unsigned oomph::MyProblem::dim ( ) const
inline

Get problem dimension (nodal dimension).

762 {return this->Dim;}

References Global_Variables::Dim.

◆ doc_boundaries()

void MyProblem::doc_boundaries ( const std::string &  boundary_file_basename) const
virtual

Output nodes with boundary number to csv file.

1620  {
1621  const unsigned n_boundary = mesh_pt()->nboundary();
1622  for(unsigned b=0; b<n_boundary; b++)
1623  {
1624  std::ofstream boundary_file((boundary_file_basename +
1625  to_string(b) + ".csv").c_str(),
1626  std::ios::out);
1627 
1628  // write headers
1629  boundary_file << "x,y,z,b" << std::endl;
1630 
1631  const unsigned n_boundary_node = mesh_pt()->nboundary_node(b);
1632  for(unsigned nd=0; nd<n_boundary_node; nd++)
1633  {
1634  Node* node_pt = mesh_pt()->boundary_node_pt(b, nd);
1635  Vector<double> position = node_pt->position();
1636 
1637  // Write out this node
1638  for(unsigned i=0; i<dim(); i++)
1639  {
1640  boundary_file << position[i] << ",";
1641  }
1642  for(unsigned i=dim(); i<3; i++)
1643  {
1644  boundary_file << 0.0 << ",";
1645  }
1646  boundary_file << b << std::endl;
1647  }
1648 
1649  boundary_file.close();
1650  }
1651  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
Definition: mesh.h:833
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
Node *& boundary_node_pt(const unsigned &b, const unsigned &n)
Return pointer to node n on boundary b.
Definition: mesh.h:493
const unsigned dim() const
Get problem dimension (nodal dimension).
Definition: my_problem.h:762
void position(Vector< double > &pos) const
Definition: nodes.cc:2499
std::ofstream out("Result.txt")

References b, i, out(), oomph::Node::position(), and oomph::StringConversion::to_string().

◆ doc_exact()

bool oomph::MyProblem::doc_exact ( ) const
inline
721  {
722  return Want_doc_exact && (Exact_solution_pt != 0);
723  }

◆ doc_solution()

void MyProblem::doc_solution ( const unsigned t_hist = 0,
const std::string &  prefix = "" 
)

General output function: output to trace file. Maybe output Jacobian depending on Doc_info.output_jacobian. Maybe output full solution depending on should_doc_this_step(..) function. Maybe output ltes depending on value of Output_ltes. Extend by overloading output_solution(...). Optional prefix for special outputs (special outputs don't go in pvd file, yet? too messy...)

1261  {
1262  bool doc_this_step = true;
1263  if(!is_steady())
1264  {
1265  doc_this_step = should_doc_this_step(time_pt()->dt(t_hist),
1266  time_pt()->time(t_hist));
1267  }
1268 
1269  const std::string dir = Doc_info.directory();
1270  const std::string num = to_string(Doc_info.number());
1271 
1272  if(Always_write_trace || doc_this_step)
1273  {
1274  // Always output trace file data
1275  write_trace(t_hist);
1276  }
1277 
1278  // Output full set of data if requested for this timestep
1279  if(doc_this_step)
1280  {
1281 
1282  // Solution itself
1283  std::ofstream soln_file((dir + "/" + prefix + "soln" + num + ".dat").c_str(),
1284  std::ios::out);
1285  soln_file.precision(Output_precision);
1286  output_solution(t_hist, soln_file);
1287  soln_file.close();
1288 
1289  // Exact solution if available and requested
1290  if(doc_exact())
1291  {
1292  std::ofstream exact_file((dir + "/" + prefix + "exact" + num + ".dat").c_str(),
1293  std::ios::out);
1294  exact_file.precision(Output_precision);
1295  output_exact_solution(t_hist, exact_file);
1296  exact_file.close();
1297  }
1298 
1299  // If not a steady state problem then write time information
1300  if(!is_steady() && prefix == "")
1301  {
1302  // Write the simulation time and filename to the solution pvd
1303  // file
1304  std::ofstream pvd_file((dir + "/" + "soln.pvd").c_str(),
1305  std::ios::app);
1306  pvd_file.precision(Output_precision);
1307 
1308  pvd_file << "<DataSet timestep=\"" << time_pt()->time(t_hist)
1309  << "\" group=\"\" part=\"0\" file=\"" << "soln"
1310  << num << ".vtu"
1311  << "\"/>" << std::endl;
1312 
1313  pvd_file.close();
1314 
1315 
1316  // Write the simulation time and filename to the exact solution
1317  // pvd file
1318  if(doc_exact())
1319  {
1320  std::ofstream exact_pvd_file((dir + "/" + "exact.pvd").c_str(),
1321  std::ios::app);
1322  exact_pvd_file.precision(Output_precision);
1323 
1324  exact_pvd_file << "<DataSet timestep=\"" << time()
1325  << "\" group=\"\" part=\"0\" file=\"" << "exact"
1326  << num << ".vtu"
1327  << "\"/>" << std::endl;
1328 
1329  exact_pvd_file.close();
1330  }
1331  }
1332 
1333 
1334  // Maybe dump the restart data
1335  if(Dump)
1336  {
1337  std::ofstream dump_file((dir + "/" + "dump" + num + ".dat").c_str(),
1338  std::ios::out);
1339  this->dump(dump_file);
1340  dump_file.close();
1341  }
1342 
1343  // Maybe dump ltes
1344  if(Output_ltes)
1345  {
1346  std::ofstream ltefile((dir + "/ltes" + num + ".csv").c_str(),
1347  std::ios::out);
1348  output_ltes(t_hist, ltefile);
1349  ltefile.close();
1350  }
1351 
1352  // Maybe write out predicted values, check we only have one time
1353  // stepper first though.
1354 #ifdef PARANOID
1356  {
1357  std::string err = "Can only output predictor values for a single time stepper";
1358  throw OomphLibError(err, OOMPH_CURRENT_FUNCTION,
1360 
1361  // Otherwise we would have multiple "predictor_time" values
1362  // below.
1363  }
1364 #endif
1365 
1366  if(t_hist != 0)
1367  {
1368  std::string err = "Can't output history of predicted value: they aren't stored.";
1369  OomphLibWarning(err, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1370  }
1371  else if(Output_predictor_values && time_stepper_pt()->adaptive_flag())
1372  {
1373  const unsigned predictor_time =
1375 
1376  std::ofstream pred_file((dir + "/" + "predsoln" + num + ".dat").c_str(),
1377  std::ios::out);
1378  pred_file.precision(Output_precision);
1379  output_solution(predictor_time, pred_file, 2);
1380  pred_file.close();
1381  }
1382 
1383 
1384  Doc_info.number()++;
1385  }
1386  }
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
void write_trace(const unsigned &t_hist=0)
Definition: my_problem.h:1426
virtual void dump(std::ofstream &dump_file) const
Definition: my_problem.h:782
virtual void output_exact_solution(const unsigned &t_hist, std::ostream &outstream, const unsigned &npoints=2) const
Definition: my_problem.h:605
virtual void output_solution(std::ofstream &soln_file) const
Overload to write any problem specific data.
Definition: my_problem.h:521
virtual bool should_doc_this_step(const double &dt, const double &time) const
Definition: my_problem.h:676
bool doc_exact() const
Definition: my_problem.h:720
bool is_steady()
Definition: my_problem.h:262
void output_ltes(const unsigned &t_hist, std::ostream &output) const
Definition: my_problem.h:824
Time *& time_pt()
Return a pointer to the global time object.
Definition: problem.h:1504
unsigned ntime_stepper() const
Return the number of time steppers.
Definition: problem.h:1680
double & time()
Return the current value of continuous time.
Definition: problem.cc:11531
unsigned predictor_storage_index() const
Definition: timesteppers.h:438
double & time()
Return the current value of the continuous time.
Definition: timesteppers.h:123

References GlobalParameters::Doc_info, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, out(), oomph::Global_string_for_annotation::string(), and oomph::StringConversion::to_string().

◆ dump()

virtual void oomph::MyProblem::dump ( std::ofstream &  dump_file) const
inlinevirtual

Dump refinement pattern of all refineable meshes and all generic Problem data to file for restart.

Reimplemented from oomph::Problem.

783  {
784  // Set very high precision to avoid any issues
785  dump_file.precision(14);
786 
787  dump_file << Doc_info.number() << " # Doc_info.number()" << std::endl;
788  dump_file << N_steps_taken << " # N_steps_taken" << std::endl;
789  Problem::dump(dump_file);
790  }
virtual void dump(std::ofstream &dump_file) const
Definition: problem.cc:12029

References GlobalParameters::Doc_info, and oomph::Problem::dump().

◆ dump_current_mm_or_jacobian_residuals()

void MyProblem::dump_current_mm_or_jacobian_residuals ( const std::string &  label)
961  {
962  throw OomphLibError("Not implemented (yet?).", OOMPH_CURRENT_FUNCTION,
964  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ exact_solution()

Vector<double> oomph::MyProblem::exact_solution ( const double t,
const Vector< double > &  x 
) const
inline

Get exact solution.

910  {
911 #ifdef PARANOID
912  if(Exact_solution_pt == 0)
913  {
914  std::string err = "Exact_solution_pt is null!";
915  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
917  }
918 #endif
919  return (*Exact_solution_pt)(t, x);
920  }
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Global_string_for_annotation::string(), plotPSD::t, and plotDoE::x.

◆ explicit_flag()

bool oomph::MyProblem::explicit_flag ( )
inline
257  {
258  return (explicit_time_stepper_pt() != 0)
259  && (time_stepper_pt()->is_steady());
260  }
ExplicitTimeStepper *& explicit_time_stepper_pt()
Return a pointer to the explicit timestepper.
Definition: problem.h:1555
bool is_steady() const
Definition: timesteppers.h:389

◆ final_doc()

void oomph::MyProblem::final_doc ( )
inline

Outputs to be done at the end of a run (e.g. closing tags for XML files).

534  {
535  // Output Jacobian if requested
536  if((to_lower(Doc_info.output_jacobian) == "at_end")
537  || (to_lower(Doc_info.output_jacobian) == "always"))
538  {
540  }
541 
542  // Write end of .pvd XML file
543  std::ofstream pvd_file((Doc_info.directory() + "/" + "soln.pvd").c_str(),
544  std::ios::app);
545  pvd_file << "</Collection>" << std::endl
546  << "</VTKFile>" << std::endl;
547  pvd_file.close();
548 
549  // Write end of exact.pvd XML file
550  if(doc_exact())
551  {
552  std::ofstream pvd_file((Doc_info.directory() + "/" + "exact.pvd").c_str(),
553  std::ios::app);
554  pvd_file << "</Collection>" << std::endl
555  << "</VTKFile>" << std::endl;
556  pvd_file.close();
557  }
558 
559  // Write out anything requested from an inheriting class.
561  }
virtual void final_doc_additional() const
Definition: my_problem.h:522

References GlobalParameters::Doc_info, and oomph::StringConversion::to_lower().

◆ final_doc_additional()

virtual void oomph::MyProblem::final_doc_additional ( ) const
inlinevirtual
522 {}

◆ finished()

virtual bool oomph::MyProblem::finished ( ) const
inlinevirtual

Use to specify a condition for time stepping to halt early. By default never halt early.

206  {
207  return false;
208  }

◆ get_error_norm()

virtual double oomph::MyProblem::get_error_norm ( const unsigned t_hist = 0) const
inlinevirtual

Error norm calculator.

Reimplemented in oomph::ODEProblem.

628  {
629  if(Exact_solution_pt != 0)
630  {
631  // ExactFunctionDiffSquared f;
632  // f.Exact_pt = Exact_solution_pt;
633  // return std::sqrt(integrate_over_problem(&f));
634 
635  // Nodal rms difference
636  const double t = time_pt()->time(t_hist);
637 
638  double diffsq = 0;
639 
640  const unsigned n_node = mesh_pt()->nnode();
641  for(unsigned nd=0; nd<n_node; nd++)
642  {
643  Node* nd_pt = mesh_pt()->node_pt(nd);
644  Vector<double> values(nd_pt->nvalue(), 0.0), x(dim(), 0.0);
645  nd_pt->position(t_hist, x);
646  nd_pt->value(t_hist, values);
647 
648  Vector<double> exact = exact_solution(t, x);
649 
650  const unsigned ni = values.size();
651  for(unsigned i=0; i<ni; i++)
652  {
653  diffsq += std::pow(values[i] - exact[i], 2);
654  }
655  }
656 
657  return std::sqrt(diffsq);
658  }
659  else
660  {
661  return Dummy_doc_data;
662  }
663  }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
Vector< double > exact_solution(const double &t, const Vector< double > &x) const
Get exact solution.
Definition: my_problem.h:909
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625

References Global_Parameters::exact_solution(), i, oomph::Data::nvalue(), oomph::Node::position(), Eigen::bfloat16_impl::pow(), sqrt(), plotPSD::t, oomph::Node::value(), and plotDoE::x.

◆ get_solution_norm()

virtual double oomph::MyProblem::get_solution_norm ( const unsigned t_hist = 0) const
inlinevirtual

Dummy solution norm calculator (overload in derived classes).

667  {
668  DoubleVector dofs;
669  get_dofs(t_hist, dofs);
670  return dofs.norm();
671  }
std::vector< double > DoubleVector
loads clump configuration
Definition: ClumpInput.h:26
void get_dofs(DoubleVector &dofs) const
Definition: problem.cc:2479

References oomph::DoubleVector::norm().

◆ get_solver_parameters()

void oomph::MyProblem::get_solver_parameters ( SolverParameters sp)
inline
211  {
212  sp.linear_solver_pt = linear_solver_pt();
213 
214  // Newton options
215  sp.newton_solver_tolerance = newton_solver_tolerance();
216  sp.max_newton_iterations = max_newton_iterations();
217  sp.max_residuals = max_residuals();
218  sp.shut_up_in_newton_solve = Shut_up_in_newton_solve;
219  sp.always_take_one_newton_step = Always_take_one_newton_step;
220 
221  // Linear optimisations
222  sp.jacobian_reuse_is_enabled = jacobian_reuse_is_enabled();
223  sp.jacobian_has_been_computed = Jacobian_has_been_computed;
224  sp.problem_is_nonlinear = Problem_is_nonlinear;
225 
226  // Explicit solver
227  sp.mass_matrix_solver_for_explicit_timestepper_pt = mass_matrix_solver_for_explicit_timestepper_pt();
228  sp.mass_matrix_reuse_is_enabled = mass_matrix_reuse_is_enabled();
229  sp.mass_matrix_has_been_computed = Mass_matrix_has_been_computed;
230  sp.discontinuous_element_formulation = Discontinuous_element_formulation;
231  }
bool Always_take_one_newton_step
Definition: problem.h:2197
double & max_residuals()
Definition: problem.h:1608
bool Jacobian_has_been_computed
Definition: problem.h:622
bool jacobian_reuse_is_enabled()
Is recycling of Jacobian in Newton iteration enabled?
Definition: problem.h:1989
bool Mass_matrix_has_been_computed
Definition: problem.h:695
bool Discontinuous_element_formulation
Definition: problem.h:700
unsigned & max_newton_iterations()
Access function to max Newton iterations before giving up.
Definition: problem.h:1594
double & newton_solver_tolerance()
Definition: problem.h:1621
bool Shut_up_in_newton_solve
Definition: problem.h:2191
bool Problem_is_nonlinear
Definition: problem.h:628
bool mass_matrix_reuse_is_enabled()
Return whether the mass matrix is being reused.
Definition: problem.h:2568

References oomph::SolverParameters::always_take_one_newton_step, oomph::SolverParameters::discontinuous_element_formulation, oomph::SolverParameters::jacobian_has_been_computed, oomph::SolverParameters::jacobian_reuse_is_enabled, oomph::SolverParameters::linear_solver_pt, oomph::SolverParameters::mass_matrix_has_been_computed, oomph::SolverParameters::mass_matrix_reuse_is_enabled, oomph::SolverParameters::mass_matrix_solver_for_explicit_timestepper_pt, oomph::SolverParameters::max_newton_iterations, oomph::SolverParameters::max_residuals, oomph::SolverParameters::newton_solver_tolerance, oomph::SolverParameters::problem_is_nonlinear, and oomph::SolverParameters::shut_up_in_newton_solve.

◆ initial_doc()

void MyProblem::initial_doc ( )

Outputs to be done at the start of a run (i.e. outputing basic info on command line args etc, writing trace file headers, outputting initial conditions).

1124  {
1125 #ifdef PARANOID
1126  if(*(Doc_info.directory().end()-1) == '/')
1127  {
1128  std::string error_msg = "Don't put a / on the end of results dir";
1129  throw OomphLibError(error_msg, OOMPH_CURRENT_FUNCTION,
1131  }
1132 #endif
1133 
1134  const std::string& dir = Doc_info.directory();
1135 
1136  // Output Jacobian if requested
1137  if((to_lower(Doc_info.output_jacobian) == "at_start")
1138  || (to_lower(Doc_info.output_jacobian) == "always"))
1139  {
1141  }
1142 
1143  // pvd files
1144  // ============================================================
1145  // Write start of .pvd XML file
1146  std::ofstream pvd_file((dir + "/" + "soln.pvd").c_str(),
1147  std::ios::out);
1148  pvd_file << "<?xml version=\"1.0\"?>" << std::endl
1149  << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">"
1150  << std::endl
1151  << "<Collection>" << std::endl;
1152  pvd_file.close();
1153 
1154  // Write start of exact.pvd XML file
1155  if(doc_exact())
1156  {
1157  std::ofstream pvd_file((dir + "/" + "exact.pvd").c_str(),
1158  std::ios::out);
1159  pvd_file << "<?xml version=\"1.0\"?>" << std::endl
1160  << "<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\">"
1161  << std::endl
1162  << "<Collection>" << std::endl;
1163  pvd_file.close();
1164  }
1165 
1166  // Trace file
1167  // ============================================================
1168 
1169  // Clear (by overwriting) and write headers
1170  std::ofstream trace_file((dir + "/" + Trace_filename).c_str());
1171  trace_file
1172  << "DocInfo_numbers"
1173  << Trace_seperator << "times"
1174  << Trace_seperator << "dts"
1175  << Trace_seperator << "error_norms"
1176 
1177  << Trace_seperator << "n_newton_iters"
1178  << Trace_seperator << "n_solver_iters"
1179 
1180  << Trace_seperator << "solver_times"
1181  << Trace_seperator << "jacobian_setup_times"
1182  << Trace_seperator << "preconditioner_setup_times"
1183 
1184  << Trace_seperator << "LTE_norms"
1185  << Trace_seperator << "trace_values"
1186 
1187  << Trace_seperator << "unix_timestamp"
1188  << Trace_seperator << "newton_residuals"
1189  << Trace_seperator << "solution_norms"
1190  << Trace_seperator << "total_step_time"
1191 
1192 
1193  // Reserved slots in case I think of more things to add later
1194  << Trace_seperator << "dummy"
1195  << Trace_seperator << "dummy"
1196  << Trace_seperator << "dummy"
1197  << Trace_seperator << "dummy"
1198  << Trace_seperator << "dummy"
1199  << Trace_seperator << "dummy";
1200 
1201  // Other headers depending on the derived class
1202  write_additional_trace_headers(trace_file);
1203 
1204  // Finish the line and close
1205  trace_file << std::endl;
1206  trace_file.close();
1207 
1208 
1209  // Info file
1210  // ============================================================
1211  std::ofstream info_file((dir + "/" + Info_filename).c_str());
1212  info_file
1213  << "real_time " << real_date_time() << std::endl
1214  << "unix_time " << std::time(0) << std::endl
1215  << "driver_name " << problem_name() << std::endl
1216  << "initial_nnode " << mesh_pt()->nnode() << std::endl
1217  << "initial_nelement " << mesh_pt()->nelement() << std::endl
1218  << "initial_nsub_mesh " << nsub_mesh() << std::endl;
1219 
1220  info_file << Doc_info.args_str;
1221  info_file.close();
1222 
1223  // If requested then output history values before t=0.
1225  {
1226 #ifdef PARANOID
1227  if(ntime_stepper() != 1)
1228  {
1229  std::string err = "More/less that 1 time stepper, not sure what to output.";
1230  throw OomphLibError(err, OOMPH_CURRENT_FUNCTION,
1232  }
1233 #endif
1234 
1235  // Output info for each history value in order.
1236  const unsigned nval = time_stepper_pt()->nprev_values();
1237  for(unsigned it=nval-1; it>0; it--)
1238  {
1239  doc_solution(it);
1240  }
1241  }
1242 
1243  // Output boundary numbers for each boundary node
1244  // ============================================================
1246  {
1247  this->doc_boundaries(dir + "/nodes_on_boundary");
1248  }
1249 
1250 
1251  // Write initial solution and anything else problem specific
1252  // (e.g. more trace file headers)
1254 
1255  // Doc the initial condition
1256  this->doc_solution();
1257  }
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
std::string args_str
Definition: my_problem.h:126
virtual void write_additional_trace_headers(std::ofstream &trace_file) const
Definition: my_problem.h:517
virtual std::string problem_name() const
Definition: my_problem.h:764
virtual void doc_boundaries(const std::string &boundary_file_basename) const
Output nodes with boundary number to csv file.
Definition: my_problem.h:1619
void doc_solution(const unsigned &t_hist=0, const std::string &prefix="")
Definition: my_problem.h:1259
virtual void initial_doc_additional() const
Definition: my_problem.h:523
virtual unsigned nprev_values() const =0
Number of previous values available: 0 for static, 1 for BDF<1>,...
std::string real_date_time()
Definition: my_problem.h:64

References GlobalParameters::Doc_info, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, out(), oomph::real_date_time(), oomph::Global_string_for_annotation::string(), and oomph::StringConversion::to_lower().

◆ initial_doc_additional()

virtual void oomph::MyProblem::initial_doc_additional ( ) const
inlinevirtual
523 {}

◆ integrate_over_problem()

double MyProblem::integrate_over_problem ( const ElementalFunction *  func_pt,
const Integral quadrature_pt = 0 
) const
virtual

Integrate a function given by func_pt over every element in every bulk mesh in this problem.

953  {
954  throw OomphLibError("Not implemented (yet?).", OOMPH_CURRENT_FUNCTION,
956 
957  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ is_steady()

bool oomph::MyProblem::is_steady ( )
inline
263  {
264  return (explicit_time_stepper_pt() == 0)
265  && (time_stepper_pt()->is_steady());
266  }

◆ iterative_linear_solver_pt()

IterativeLinearSolver* oomph::MyProblem::iterative_linear_solver_pt ( ) const
inline
752  {
753  return dynamic_cast<IterativeLinearSolver*>
754  (this->linear_solver_pt());
755  }

◆ lte_norm()

double oomph::MyProblem::lte_norm ( )
inline

Get an lte error norm using the same norm and values as the adaptive time stepper used.

708  {
709  if(time_stepper_pt()->adaptive_flag())
710  {
711  // Just return the error that would be used for adaptivity.
713  }
714  else
715  {
716  return Dummy_doc_data;
717  }
718  }
virtual double global_temporal_error_norm()
Definition: problem.h:1230

◆ min_element_size()

double MyProblem::min_element_size ( )

??ds

1389  {
1390  // Check that we have finite elements ??ds this will still go wrong
1391  // if there are only some none finite elements in the mesh...
1392 
1393  //??ds what happens with face elements?
1394  FiniteElement* test_pt = dynamic_cast<FiniteElement*>
1395  (mesh_pt(0)->element_pt(0));
1396 
1397  if(test_pt != 0)
1398  {
1399  double min_size = mesh_pt(0)->finite_element_pt(0)->compute_physical_size();
1400 
1401  // Loop over all meshes in problem
1402  for(unsigned msh=0, nmsh=nsub_mesh(); msh<nmsh; msh++)
1403  {
1404  Mesh* mesh_pt = this->mesh_pt(msh);
1405  for(unsigned ele=0, nele=mesh_pt->nelement(); ele<nele; ele++)
1406  {
1407  FiniteElement* ele_pt = mesh_pt->finite_element_pt(ele);
1408  double new_size = ele_pt->compute_physical_size();
1409  if(new_size < min_size)
1410  {
1411  min_size = new_size;
1412  }
1413  }
1414  }
1415 
1416  return min_size;
1417  }
1418  // If it's not a finite element then we can't get a size so return
1419  // a dummy value.
1420  else
1421  {
1422  return Dummy_doc_data;
1423  }
1424  }
virtual double compute_physical_size() const
Definition: elements.h:2825
FiniteElement * finite_element_pt(const unsigned &e) const
Definition: mesh.h:473
GeneralisedElement *& element_pt(const unsigned long &e)
Return pointer to element e.
Definition: mesh.h:448

References oomph::FiniteElement::compute_physical_size(), oomph::Mesh::finite_element_pt(), and oomph::Mesh::nelement().

◆ my_set_initial_condition()

void MyProblem::my_set_initial_condition ( const SolutionFunctorBase ic)
virtual

Assign initial conditions from function pointer.

Reimplemented in oomph::ODEProblem.

1702  {
1703 #ifdef PARANOID
1704  // Can't set global data from a function of space... have to overload this
1705  // if you have any
1706  if(nglobal_data() != 0)
1707  {
1708  std::string err = "Problem has global data which cannot be set from function pt.";
1709  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1711  }
1712 #endif
1713 
1714  // Loop over current & previous timesteps (so we need t<nprev_values+1).
1715  const int nprev_values = this->time_stepper_pt()->nprev_values();
1716  for(int tindex=0; tindex<nprev_values+1; tindex++)
1717  {
1718  double time = time_pt()->time(tindex);
1719 
1720  // Loop over all nodes in all meshes in problem and set values.
1721  const unsigned nmsh = nsub_mesh();
1722  for(unsigned msh=0; msh<nmsh; msh++)
1723  {
1724  Mesh* mesh_pt = this->mesh_pt(msh);
1725 
1726  for(unsigned nd=0, nnd=mesh_pt->nnode(); nd<nnd; nd++)
1727  {
1728  Node* nd_pt = mesh_pt->node_pt(nd);
1729 
1730  // Get the position at present time
1731  const unsigned dim = nd_pt->ndim();
1732  Vector<double> x(dim);
1733  nd_pt->position(x);
1734 
1735  // Set position at tindex time to be the same as at present
1736  // (impulsive positions).
1737  for(unsigned j=0; j<dim; j++)
1738  {
1739  nd_pt->x(tindex, j) = x[j];
1740  }
1741 
1742  // Get the values
1743  Vector<double> values = ic(time, x);
1744 
1745 #ifdef PARANOID
1746  if(values.size() != nd_pt->nvalue())
1747  {
1748  std::string err = "Wrong number of values in initial condition.";
1749  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1751  }
1752 #endif
1753  // Copy into dofs
1754  for(unsigned j=0, nj=values.size(); j<nj; j++)
1755  {
1756  nd_pt->set_value(tindex, j, values[j]);
1757  }
1758  }
1759 
1760 #ifdef PARANOID
1761  // Can't set internal data like this so check that we have none.
1762  for(unsigned ele=0, nele=mesh_pt->nelement(); ele<nele; ele++)
1763  {
1764  FiniteElement* ele_pt = mesh_pt->finite_element_pt(ele);
1765  if(ele_pt->ninternal_data() != 0)
1766  {
1767  std::string err =
1768  "Element with non-nodal data, cannot set via function...";
1769  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1771  }
1772  }
1773 #endif
1774  }
1775  }
1776 
1778  }
virtual void actions_after_set_initial_condition()
Definition: my_problem.h:1113
unsigned nglobal_data() const
Return the number of global data values.
Definition: problem.h:1686

References oomph::Mesh::finite_element_pt(), j, oomph::Node::ndim(), oomph::Mesh::nelement(), oomph::GeneralisedElement::ninternal_data(), oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::Data::nvalue(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Node::position(), oomph::Data::set_value(), oomph::Global_string_for_annotation::string(), plotDoE::x, and oomph::Node::x().

◆ nnewton_step_this_solve()

unsigned oomph::MyProblem::nnewton_step_this_solve ( ) const
inline
283  {
284  return Jacobian_setup_times.size();
285  }

◆ operator=()

void oomph::MyProblem::operator= ( const MyProblem dummy)
inlineprivate

Inaccessible assignment operator.

946  {BrokenCopy::broken_assign("MyProblem");}
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:195

References oomph::BrokenCopy::broken_assign().

◆ output_exact_solution()

virtual void oomph::MyProblem::output_exact_solution ( const unsigned t_hist,
std::ostream &  outstream,
const unsigned npoints = 2 
) const
inlinevirtual

Standard output function: loop over all elements in all meshes and output exact solution.

608  {
609  const double time = time_pt()->time();
610 
611  const unsigned n_msh = nsub_mesh();
612  for(unsigned msh=0; msh<n_msh; msh++)
613  {
614  Mesh* msh_pt = mesh_pt(msh);
615 
616  const unsigned n_ele = msh_pt->nelement();
617  for(unsigned ele=0; ele<n_ele; ele++)
618  {
619  FiniteElement* ele_pt = msh_pt->finite_element_pt(ele);
620  ele_pt->output_fct(outstream, npoints, time,
622  }
623  }
624  }

References oomph::Mesh::finite_element_pt(), oomph::Mesh::nelement(), and oomph::FiniteElement::output_fct().

◆ output_ltes()

void oomph::MyProblem::output_ltes ( const unsigned t_hist,
std::ostream &  output 
) const
inline

Output lte values of each nodal value along with spatial position for plotting with paraview. To plot load the csv file, use "Table To Points", add a 3D view, set the ltes to visible and color by the lte of interest. Useful to set "Representation" to "Points" and increase point size so that things are easily visible. Not implemented for nodes with varying numbers of values (you might need something fancier than a csv file for this).

825  {
826  // Output position labels
827  for(unsigned j=0; j<Dim; j++)
828  {
829  output << "x" << j << ", ";
830  }
831 
832  // Output labels for ltes, assuming that all nodes have the same
833  // number of values...
834  for(unsigned j=0; j<mesh_pt()->node_pt(0)->nvalue(); j++)
835  {
836  output << "error" << j << ", ";
837  }
838 
839  output << std::endl;
840 
841  // Output actual positions and ltes
842  for(unsigned i=0, ni=mesh_pt()->nnode(); i<ni; i++)
843  {
844  Node* nd_pt = mesh_pt()->node_pt(i);
845 
846  // Output position of node
847  for(unsigned j=0; j<Dim; j++)
848  {
849  output << nd_pt->x(j) << ", ";
850  }
851 
852  // Output ltes of node
853  for(unsigned j=0; j<nd_pt->nvalue(); j++)
854  {
855  // Get timestepper's error estimate for this direction of m
856  // at this point.
857  double error = nd_pt->time_stepper_pt()->
858  temporal_error_in_value(nd_pt, j);
859 
860  output << error << ", ";
861  }
862 
863  output << std::endl;
864  }
865  }
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483
int error
Definition: calibrate.py:297
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: gen_axisym_advection_diffusion_elements.h:161

References Global_Variables::Dim, calibrate::error, i, j, oomph::Data::nvalue(), oomph::output(), oomph::Data::time_stepper_pt(), and oomph::Node::x().

◆ output_solution() [1/3]

virtual void oomph::MyProblem::output_solution ( const unsigned t,
std::ostream &  outstream,
const unsigned npoints = 2 
) const
inlinevirtual

Standard output function: loop over all elements in all meshes and output.

Reimplemented in oomph::ODEProblem.

577  {
578  const unsigned n_msh = nsub_mesh();
579  for(unsigned msh=0; msh<n_msh; msh++)
580  {
581  Mesh* msh_pt = mesh_pt(msh);
582 
583  const unsigned n_ele = msh_pt->nelement();
584  for(unsigned ele=0; ele<n_ele; ele++)
585  {
586  FiniteElement* ele_pt = msh_pt->finite_element_pt(ele);
587  ele_pt->output(t, outstream, npoints);
588  }
589  }
590  }

References oomph::Mesh::finite_element_pt(), oomph::Mesh::nelement(), oomph::FiniteElement::output(), and plotPSD::t.

◆ output_solution() [2/3]

virtual void oomph::MyProblem::output_solution ( std::ofstream &  soln_file) const
inlinevirtual

Overload to write any problem specific data.

521 {}

◆ output_solution() [3/3]

void oomph::MyProblem::output_solution ( std::ostream &  outstream,
const unsigned npoints = 2 
) const
inline

output_solution(...) with default output time step = 0 = current time.

599  {
600  output_solution(0, outstream, npoints);
601  }

◆ problem_name()

virtual std::string oomph::MyProblem::problem_name ( ) const
inlinevirtual
764 {return "unknown";}

◆ read()

virtual void oomph::MyProblem::read ( std::ifstream &  restart_file)
inlinevirtual

Read refinement pattern of all refineable meshes and refine them accordingly, then read all Data and nodal position info from file for restart.

Reimplemented from oomph::Problem.

793  {
794  // buffer
795  std::string input_string;
796 
797  // Read in Doc_info number. Read line up to termination sign then
798  // ignore.
799  getline(restart_file, input_string, '#');
800  restart_file.ignore(80,'\n');
801  Doc_info.number() = std::atoi(input_string.c_str());
802 
803  // Read in number of steps taken. Read line up to termination sign
804  // then ignore.
805  getline(restart_file, input_string, '#');
806  restart_file.ignore(80,'\n');
807  N_steps_taken = std::atoi(input_string.c_str());
808 
809  // Let base class handle the rest
810  Problem::read(restart_file);
811 
812  // Decrement doc info number so that it is correct after initial doc
813  // Doc_info.number()--;
814  }
virtual void read(std::ifstream &restart_file, bool &unsteady_restart)
Definition: problem.cc:12251

References GlobalParameters::Doc_info, oomph::Problem::read(), and oomph::Global_string_for_annotation::string().

◆ segregated_pin_indices()

void oomph::MyProblem::segregated_pin_indices ( const Vector< unsigned > &  indices)
inline

Pin all dofs with index in node one of indices in all nodes. Uses a different magic pinning number so that it can be easily undone using undo_segregated_pinning(). Does not handle: global data, element data, nodes with varying nvalue.

377  {
378  for(unsigned msh=0, nmsh=nsub_mesh(); msh<nmsh; msh++)
379  {
380  Mesh* mesh_pt = this->mesh_pt(msh);
381  for(unsigned nd=0, nnd=mesh_pt->nnode(); nd<nnd; nd++)
382  {
383  Node* nd_pt = mesh_pt->node_pt(nd);
384  for(unsigned j=0; j<indices.size(); j++)
385  {
386  if(!nd_pt->is_pinned(indices[j]))
387  {
388  nd_pt->eqn_number(indices[j])
390  }
391  }
392  }
393  }
394  // Output information
395  oomph_info << "Segregated solve, without indices:\n";
396 
397  // Loop over the entries of indices and output
398  unsigned indices_length=indices.size();
399  if (indices_length==0)
400  {
401  oomph_info << Trace_seperator << "[]";
402  }
403  else
404  {
405  oomph_info << Trace_seperator << "[" << indices[0];
406  if (indices_length>1)
407  {
408  for (unsigned i=1;i<indices_length;i++)
409  {
410  oomph_info << ", " << indices[i];
411  }
412  }
413  oomph_info << "]";
414  }
415 
416  // Output the number of equations
417  oomph_info << "Number of equations: " << assign_eqn_numbers() << std::endl;
418  }
long & eqn_number(const unsigned &i)
Return the equation number of the i-th stored variable.
Definition: nodes.h:367
unsigned long assign_eqn_numbers(const bool &assign_local_eqn_numbers=true)
Definition: problem.cc:1989
OomphInfo oomph_info
Definition: oomph_definitions.cc:319

References oomph::Data::eqn_number(), i, oomph::Data::is_pinned(), oomph::Data::Is_segregated_solve_pinned, j, oomph::Mesh::nnode(), oomph::Mesh::node_pt(), and oomph::oomph_info.

◆ set_doc_times()

void oomph::MyProblem::set_doc_times ( Vector< double > &  doc_times)
inline

Assign a vector of times to output the full solution at.

700  {
701  Doc_times = doc_times;
702  }
Vector< double > Doc_times
Times at which we want to output the full solution.
Definition: my_problem.h:938

◆ set_solver_parameters()

void oomph::MyProblem::set_solver_parameters ( SolverParameters sp)
inline
234  {
235  linear_solver_pt() = sp.linear_solver_pt;
236 
237  // Newton options
238  newton_solver_tolerance() = sp.newton_solver_tolerance;
239  max_newton_iterations() = sp.max_newton_iterations;
240  max_residuals() = sp.max_residuals;
241  Shut_up_in_newton_solve = sp.shut_up_in_newton_solve;
242  Always_take_one_newton_step = sp.always_take_one_newton_step;
243 
244  // Linear optimisations
245  Jacobian_reuse_is_enabled = sp.jacobian_reuse_is_enabled;
246  Jacobian_has_been_computed = sp.jacobian_has_been_computed;
247  Problem_is_nonlinear = sp.problem_is_nonlinear;
248 
249  // Explicit solver
250  mass_matrix_solver_for_explicit_timestepper_pt() = sp.mass_matrix_solver_for_explicit_timestepper_pt;
251  Mass_matrix_reuse_is_enabled = sp.mass_matrix_reuse_is_enabled;
252  Mass_matrix_has_been_computed = sp.mass_matrix_has_been_computed;
253  Discontinuous_element_formulation = sp.discontinuous_element_formulation;
254  }
bool Jacobian_reuse_is_enabled
Is re-use of Jacobian in Newton iteration enabled? Default: false.
Definition: problem.h:618
bool Mass_matrix_reuse_is_enabled
Definition: problem.h:691

References oomph::SolverParameters::always_take_one_newton_step, oomph::SolverParameters::discontinuous_element_formulation, oomph::SolverParameters::jacobian_has_been_computed, oomph::SolverParameters::jacobian_reuse_is_enabled, oomph::SolverParameters::linear_solver_pt, oomph::SolverParameters::mass_matrix_has_been_computed, oomph::SolverParameters::mass_matrix_reuse_is_enabled, oomph::SolverParameters::mass_matrix_solver_for_explicit_timestepper_pt, oomph::SolverParameters::max_newton_iterations, oomph::SolverParameters::max_residuals, oomph::SolverParameters::newton_solver_tolerance, oomph::SolverParameters::problem_is_nonlinear, and oomph::SolverParameters::shut_up_in_newton_solve.

◆ set_up_impulsive_initial_condition()

void MyProblem::set_up_impulsive_initial_condition ( )
virtual

Set all history values/dts to be the same as the present values/dt.

1654  {
1655 
1656 #ifdef PARANOID
1657  if(nglobal_data() != 0)
1658  {
1659  std::string err = "Problem has global data which cannot be set from function pt.";
1660  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1662  }
1663 #endif
1664  unsigned nprev_steps=this->time_stepper_pt()->nprev_values();
1665  for(unsigned t=0; t< nprev_steps; t++)
1666  {
1667  // Loop over all nodes in all meshes in problem and set values.
1668  for(unsigned msh=0, nmsh=nsub_mesh(); msh<nmsh; msh++)
1669  {
1670  Mesh* mesh_pt = this->mesh_pt(msh);
1671 
1672  for(unsigned nd=0, nnd=mesh_pt->nnode(); nd<nnd; nd++)
1673  {
1674  Node* nd_pt = mesh_pt->node_pt(nd);
1675  for(unsigned j=0, nj=nd_pt->nvalue(); j<nj; j++)
1676  {
1677  nd_pt->set_value(t, j, nd_pt->value(0, j));
1678  }
1679  }
1680 
1681 #ifdef PARANOID
1682  for(unsigned ele=0, nele=mesh_pt->nelement(); ele<nele; ele++)
1683  {
1684  FiniteElement* ele_pt = mesh_pt->finite_element_pt(ele);
1685  if(ele_pt->ninternal_data() != 0)
1686  {
1687  std::string err =
1688  "Element with non-nodal data, cannot set via function...";
1689  throw OomphLibError(err, OOMPH_EXCEPTION_LOCATION,
1691  }
1692  }
1693 #endif
1694 
1695  }
1696  }
1697 
1699  }
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271

References oomph::Mesh::finite_element_pt(), j, oomph::Mesh::nelement(), oomph::GeneralisedElement::ninternal_data(), oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::Data::nvalue(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Data::set_value(), oomph::Global_string_for_annotation::string(), plotPSD::t, and oomph::Node::value().

◆ should_doc_this_step()

virtual bool oomph::MyProblem::should_doc_this_step ( const double dt,
const double time 
) const
inlinevirtual

should the previous step be doc'ed? Check if we went past an entry of Doc_times in the last step. If no Doc_times have been set then always output.

677  {
678  // I'm sure there should be a more efficient way to do this if we
679  // know that Doc_times is ordered, but it shouldn't really matter I
680  // guess--Jacobian calculation and solve times will always be far
681  // far larger than this brute force search.
682 
683  // If no Doc_times have been set then always output.
684  if(Doc_times.empty()) return true;
685 
686  // Loop over entries of Doc_times and check if they are in the
687  // range (t - dt, t].
688  for(unsigned j=0; j<Doc_times.size(); j++)
689  {
690  if(( time >= Doc_times[j]) && ((time - dt) < Doc_times[j]))
691  {
692  return true;
693  }
694  }
695  return false;
696  }

References j.

◆ smart_time_step()

double oomph::MyProblem::smart_time_step ( double  dt,
const double tol 
)
inline

Do the newton solve or explicit step (different ones depending flags set).

174  {
175  double step_time_start = TimingHelpers::timer();
176 
177  // The Newton step itself, adaptive if requested.
178  if(explicit_flag())
179  {
180  explicit_timestep(dt);
181  }
182  else if(tol != 0.0)
183  {
184  dt = adaptive_unsteady_newton_solve(dt, tol);
185  }
186  else
187  {
189  }
190 
191  double step_time_stop = TimingHelpers::timer();
192  Total_step_time = step_time_stop - step_time_start;
193 
194 
195  oomph_info << "Time for step " << Total_step_time
196  << std::endl;
197 
198  N_steps_taken++;
199 
200  return dt;
201  }
bool explicit_flag()
Definition: my_problem.h:256
void explicit_timestep(const double &dt, const bool &shift_values=true)
Take an explicit timestep of size dt.
Definition: problem.cc:10918
double adaptive_unsteady_newton_solve(const double &dt_desired, const double &epsilon)
Definition: problem.cc:11056
void unsteady_newton_solve(const double &dt)
Definition: problem.cc:10953
double timer()
returns the time in seconds after some point in past
Definition: oomph_utilities.cc:1295

References oomph::oomph_info, and oomph::TimingHelpers::timer().

◆ trace_values()

virtual Vector<double> oomph::MyProblem::trace_values ( const unsigned t_hist = 0) const
inlinevirtual

Reimplemented in oomph::ODEProblem.

726  {
727  unsigned nele = mesh_pt()->nelement();
728  unsigned e = nele/2;
729 
730  Vector<double> values;
731  if(dynamic_cast<FiniteElement*>(mesh_pt()->element_pt(e)))
732  {
733  // Just use an element somewhere in the middle...
734  Node* nd_pt = mesh_pt()->finite_element_pt(e)->node_pt(0);
735  values.assign(nd_pt->nvalue(), 0.0);
736  nd_pt->value(t_hist, values);
737  }
738  else
739  {
740  // Not finite elements so no idea what to use
741  values.assign(1, Dummy_doc_data);
742  }
743 
744  return values;
745  }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
double value(const unsigned &i) const
Definition: nodes.cc:2408

References e(), oomph::Data::nvalue(), and oomph::Node::value().

◆ undo_segregated_pinning()

void oomph::MyProblem::undo_segregated_pinning ( )
inline

Remove pinning set up by segregated_pin_indices.

422  {
423  for(unsigned msh=0, nmsh=nsub_mesh(); msh<nmsh; msh++)
424  {
425  Mesh* mesh_pt = this->mesh_pt(msh);
426  for(unsigned nd=0, nnd=mesh_pt->nnode(); nd<nnd; nd++)
427  {
428  Node* nd_pt = mesh_pt->node_pt(nd);
429  for(unsigned j=0; j<nd_pt->nvalue(); j++)
430  {
431  if(nd_pt->eqn_number(j) == Data::Is_segregated_solve_pinned)
432  {
434  }
435  }
436  }
437  }
438  oomph_info << "un-segregated n eqn " << assign_eqn_numbers() << std::endl;
439  }
static long Is_unclassified
Definition: nodes.h:192

References oomph::Data::eqn_number(), oomph::Data::Is_segregated_solve_pinned, oomph::Data::Is_unclassified, j, oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::Data::nvalue(), and oomph::oomph_info.

◆ write_additional_trace_data()

virtual void oomph::MyProblem::write_additional_trace_data ( const unsigned t_hist,
std::ofstream &  trace_file 
) const
inlinevirtual

Overload to write problem specific data into trace file. Note: don't add any line endings, seperate data with the Trace_seperator string (BEFORE each data entry).

Reimplemented in oomph::ODEProblem.

512  {}

◆ write_additional_trace_headers()

virtual void oomph::MyProblem::write_additional_trace_headers ( std::ofstream &  trace_file) const
inlinevirtual

Overload to write problem specific headers into trace file. Note: don't add any line endings, seperate headers with the Trace_seperator string (BEFORE each data entry).

Reimplemented in oomph::ODEProblem.

518  {}

◆ write_trace()

void MyProblem::write_trace ( const unsigned t_hist = 0)

Write some general data about the previous time step to a trace file. Extend by overloading write_additional_trace_data(...).

1427  {
1428  std::ofstream trace_file((Doc_info.directory() + "/" + Trace_filename).c_str(),
1429  std::ios::app);
1430  trace_file.precision(Output_precision);
1431 
1432  double time = Dummy_doc_data, dt = Dummy_doc_data;
1433  if(!is_steady())
1434  {
1435  time = this->time_pt()->time(t_hist);
1436  dt = this->time_pt()->dt(t_hist);
1437  }
1438 
1439  // Some values are impossible to get for history values, print dummy
1440  // values instead.
1441  double nnewton_iter_taken = Dummy_doc_data,
1443  real_time = Dummy_doc_data,
1444  total_step_time = Dummy_doc_data;
1445 
1446  Vector<double> solver_iterations(1, Dummy_doc_data),
1447  solver_times(1, Dummy_doc_data),
1448  jacobian_setup_times(1, Dummy_doc_data),
1449  preconditioner_setup_times(1, Dummy_doc_data),
1450  max_res(1, Dummy_doc_data);
1451 
1452  if(t_hist == 0)
1453  {
1454  nnewton_iter_taken = Nnewton_iter_taken;
1455  solver_iterations = Solver_iterations;
1456  solver_times = Solver_times;
1457  jacobian_setup_times = Jacobian_setup_times;
1458  preconditioner_setup_times = Preconditioner_setup_times;
1459  real_time = std::time(0);
1460  total_step_time = Total_step_time;
1461  max_res = Max_res;
1462 
1463  if(!is_steady())
1464  {
1465  lte_norm = this->lte_norm();
1466  }
1467  }
1468 
1469  // Write out data that can be done for every problem
1470  trace_file
1471  << Doc_info.number()
1472  << Trace_seperator << time
1473  << Trace_seperator << dt
1474  << Trace_seperator << get_error_norm(t_hist)
1475 
1476  << Trace_seperator << nnewton_iter_taken;
1477 
1478  // Loop over the entries of solver_iterations and output
1479  unsigned solver_iterations_length=solver_iterations.size();
1480  if (solver_iterations_length==0)
1481  {
1482  trace_file << Trace_seperator << "[]";
1483  }
1484  else
1485  {
1486  trace_file << Trace_seperator << "[" << solver_iterations[0];
1487  if (solver_iterations_length>1)
1488  {
1489  for (unsigned i=1;i<solver_iterations_length;i++)
1490  {
1491  trace_file << ", " << solver_iterations[i];
1492  }
1493  }
1494  trace_file << "]";
1495  }
1496 
1497  // Loop over the entries of solver_times and output
1498  unsigned solver_times_length=solver_times.size();
1499  if (solver_times_length==0)
1500  {
1501  trace_file << Trace_seperator << "[]";
1502  }
1503  else
1504  {
1505  trace_file << Trace_seperator << "[" << solver_times[0];
1506  if (solver_times_length>1)
1507  {
1508  for (unsigned i=1;i<solver_times_length;i++)
1509  {
1510  trace_file << ", " << solver_times[i];
1511  }
1512  }
1513  trace_file << "]";
1514  }
1515 
1516  // Loop over the entries of jacobian_setup_times and output
1517  unsigned jacobian_setup_times_length=jacobian_setup_times.size();
1518  if (jacobian_setup_times_length==0)
1519  {
1520  trace_file << Trace_seperator << "[]";
1521  }
1522  else
1523  {
1524  trace_file << Trace_seperator << "[" << jacobian_setup_times[0];
1525  if (jacobian_setup_times_length>1)
1526  {
1527  for (unsigned i=1;i<jacobian_setup_times_length;i++)
1528  {
1529  trace_file << ", " << jacobian_setup_times[i];
1530  }
1531  }
1532  trace_file << "]";
1533  }
1534 
1535  // Loop over the entries of preconditioner_setup_times and output
1536  unsigned preconditioner_setup_times_length=preconditioner_setup_times.size();
1537  if (preconditioner_setup_times_length==0)
1538  {
1539  trace_file << Trace_seperator << "[]";
1540  }
1541  else
1542  {
1543  trace_file << Trace_seperator << "[" << preconditioner_setup_times[0];
1544  if (preconditioner_setup_times_length>1)
1545  {
1546  for (unsigned i=1;i<preconditioner_setup_times_length;i++)
1547  {
1548  trace_file << ", " << preconditioner_setup_times[i];
1549  }
1550  }
1551  trace_file << "]";
1552  }
1553 
1554  trace_file << Trace_seperator << lte_norm;
1555 
1556  // Create a temporary vector
1557  Vector<double> output_vector=trace_values(t_hist);
1558 
1559  // Loop over the entries of output_vector and output
1560  unsigned output_vector_length=output_vector.size();
1561  if (output_vector_length==0)
1562  {
1563  trace_file << Trace_seperator << "[]";
1564  }
1565  else
1566  {
1567  trace_file << Trace_seperator << "[" << output_vector[0];
1568  if (output_vector_length>1)
1569  {
1570  for (unsigned i=1;i<output_vector_length;i++)
1571  {
1572  trace_file << ", " << output_vector[i];
1573  }
1574  }
1575  trace_file << "]";
1576  }
1577 
1578  trace_file << Trace_seperator << real_time;
1579 
1580  // Loop over the entries of output_vector and output
1581  unsigned max_res_length=max_res.size();
1582  if (max_res_length==0)
1583  {
1584  trace_file << Trace_seperator << "[]";
1585  }
1586  else
1587  {
1588  trace_file << Trace_seperator << "[" << max_res[0];
1589  if (max_res_length>1)
1590  {
1591  for (unsigned i=1;i<max_res_length;i++)
1592  {
1593  trace_file << ", " << max_res[i];
1594  }
1595  }
1596  trace_file << "]";
1597  }
1598 
1599  trace_file << Trace_seperator << get_solution_norm(t_hist)
1600  << Trace_seperator << total_step_time
1601 
1602  // Reserved slots in case I think of more things to add later
1609 
1610 
1611  // Add problem specific data
1612  write_additional_trace_data(t_hist, trace_file);
1613 
1614  // Finish off this line
1615  trace_file << std::endl;
1616  trace_file.close();
1617  }
double lte_norm()
Definition: my_problem.h:707
virtual void write_additional_trace_data(const unsigned &t_hist, std::ofstream &trace_file) const
Definition: my_problem.h:511
virtual Vector< double > trace_values(const unsigned &t_hist=0) const
Definition: my_problem.h:725
unsigned Nnewton_iter_taken
Definition: problem.h:603
Vector< double > Max_res
Maximum residuals at start and after each newton iteration.
Definition: problem.h:606
double & dt(const unsigned &t=0)
Definition: timesteppers.h:136
void output_vector(const Vector< myType > &given_vector)
Definition: crdoublematrix_copy_constructor.cc:49

References GlobalParameters::Doc_info, i, and output_vector().

Member Data Documentation

◆ Always_write_trace

bool oomph::MyProblem::Always_write_trace

Should we output to trace file every step?

Referenced by oomph::ODEProblem::ODEProblem().

◆ Dim

unsigned oomph::MyProblem::Dim
protected

◆ Disable_mass_matrix_solver_optimisations

bool oomph::MyProblem::Disable_mass_matrix_solver_optimisations

Option to turn off optimisation of the linear solves needed for explicit timestepping (for debugging purposes).

◆ Doc_info

MyDocInfo oomph::MyProblem::Doc_info

◆ Doc_times

Vector<double> oomph::MyProblem::Doc_times
private

Times at which we want to output the full solution.

◆ Dummy_doc_data

double oomph::MyProblem::Dummy_doc_data
protected

◆ Dump

bool oomph::MyProblem::Dump

Should we dump ready for a restart?

◆ Error_norm_limit

double oomph::MyProblem::Error_norm_limit

◆ Exact_solution_pt

SolutionFunctorBase* oomph::MyProblem::Exact_solution_pt

Function pointer for exact solution.

◆ Info_filename

std::string oomph::MyProblem::Info_filename

◆ Jacobian_setup_times

Vector<double> oomph::MyProblem::Jacobian_setup_times
private

◆ N_steps_taken

unsigned oomph::MyProblem::N_steps_taken

◆ Output_initial_condition

bool oomph::MyProblem::Output_initial_condition

Should we write output for initial conditions as though they are time steps as well?

◆ Output_ltes

bool oomph::MyProblem::Output_ltes

Should we output the local truncation error at each node as well?

◆ Output_precision

unsigned oomph::MyProblem::Output_precision

◆ Output_predictor_values

bool oomph::MyProblem::Output_predictor_values

Should we output the predicted values too?

◆ Preconditioner_setup_times

Vector<double> oomph::MyProblem::Preconditioner_setup_times
private

◆ Should_doc_boundaries

bool oomph::MyProblem::Should_doc_boundaries

Should we output the locations of the boundary nodes?

◆ Solution_norm_limit

double oomph::MyProblem::Solution_norm_limit

◆ Solver_iterations

Vector<double> oomph::MyProblem::Solver_iterations
private

◆ Solver_times

Vector<double> oomph::MyProblem::Solver_times
private

◆ Total_step_time

double oomph::MyProblem::Total_step_time

◆ Trace_filename

std::string oomph::MyProblem::Trace_filename

◆ Trace_seperator

const std::string oomph::MyProblem::Trace_seperator
protected

String to insert between fields in trace file. Use "; " by default (so that "," or " " can be used for lists if needed).

Referenced by oomph::ODEProblem::output_solution(), oomph::ODEProblem::write_additional_trace_data(), and oomph::ODEProblem::write_additional_trace_headers().

◆ Want_doc_exact

bool oomph::MyProblem::Want_doc_exact

Should we try to output exact solution?


The documentation for this class was generated from the following file: