HeartConfigDefaults.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef HEARTCONFIGDEFAULTS_HPP_
00037 #define HEARTCONFIGDEFAULTS_HPP_
00038
00090 boost::shared_ptr<cp::chaste_parameters_type> CreateDefaultParameters()
00091 {
00092
00093 cp::simulation_type simulation_params;
00094 simulation_params.SpaceDimension().set(3);
00095 cp::domain_type domain("Mono");
00096 simulation_params.Domain().set(domain);
00097 cp::ionic_model_selection_type default_ionic_model;
00098 cp::ionic_models_available_type ionic_model("LuoRudyI");
00099 default_ionic_model.Hardcoded().set(ionic_model);
00100 cp::ionic_models_type ionic_models(default_ionic_model);
00101 simulation_params.IonicModels().set(ionic_models);
00102 simulation_params.OutputDirectory().set("ChasteResults");
00103 simulation_params.OutputFilenamePrefix().set("SimulationResults");
00104
00105
00106 cp::physiological_type phys_params;
00107 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, intra_conductivities,
00108 1.75, 1.75, 1.75, "mS/cm");
00109 phys_params.IntracellularConductivities().set(intra_conductivities);
00110 XSD_CREATE_WITH_FIXED_ATTR3(cp::conductivities_type, extra_conductivities,
00111 7.0, 7.0, 7.0, "mS/cm");
00112 phys_params.ExtracellularConductivities().set(extra_conductivities);
00113 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, bath_conductivity, 7.0, "mS/cm");
00114 phys_params.BathConductivity().set(bath_conductivity);
00115 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, surface_area_to_volume_ratio, 1400, "1/cm");
00116 phys_params.SurfaceAreaToVolumeRatio().set(surface_area_to_volume_ratio);
00117 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, capacitance, 1.0, "uF/cm^2");
00118 phys_params.Capacitance().set(capacitance);
00119
00120 cp::purkinje_physiological_type purkinje_phys_params;
00121 XSD_CREATE_WITH_FIXED_ATTR1(cp::inverse_length_type, purkinje_Am, 2800, "1/cm");
00122 purkinje_phys_params.SurfaceAreaToVolumeRatio().set(purkinje_Am);
00123 XSD_CREATE_WITH_FIXED_ATTR1(cp::capacitance_type, purkinje_Cm, 1.0, "uF/cm^2");
00124 purkinje_phys_params.Capacitance().set(purkinje_Cm);
00125 XSD_CREATE_WITH_FIXED_ATTR1(cp::conductivity_type, purkinje_conductivity, 1.75, "mS/cm");
00126 purkinje_phys_params.Conductivity().set(purkinje_conductivity);
00127 phys_params.Purkinje().set(purkinje_phys_params);
00128
00129
00130 cp::numerical_type numerical_params;
00131 XSD_CREATE_WITH_FIXED_ATTR3(cp::time_steps_type, timesteps, 0.01, 0.01, 0.01, "ms");
00132 cp::ksp_tolerances_type tolerances;
00133 tolerances.KSPAbsolute().set(2e-4);
00134 cp::ksp_solver_type ksp_solver("cg");
00135 cp::ksp_preconditioner_type ksp_precond("bjacobi");
00136 cp::mesh_partitioning_type mesh_partitioning("parmetis");
00137 numerical_params.TimeSteps().set(timesteps);
00138 numerical_params.KSPTolerances().set(tolerances);
00139 numerical_params.KSPSolver().set(ksp_solver);
00140 numerical_params.KSPPreconditioner().set(ksp_precond);
00141 numerical_params.MeshPartitioning().set(mesh_partitioning);
00142 numerical_params.UseStateVariableInterpolation().set(cp::yesno_type::no);
00143
00144
00145
00146
00147
00148 boost::shared_ptr<cp::chaste_parameters_type> p_defaults(new cp::chaste_parameters_type(phys_params, numerical_params));
00149 p_defaults->Simulation().set(simulation_params);
00150
00151 return p_defaults;
00152 }
00153
00154
00161 #define MERGE_PARAM(path) \
00162 if (!pParams->path().present()) { \
00163 if (pDefaults->path().present()) { \
00164 pParams->path().set(pDefaults->path().get()); \
00165 } \
00166 }
00167
00172 #define ELSE_IF_DEFAULT(path) \
00173 else if (pDefaults->path().present())
00174
00184 void MergeDefaults(boost::shared_ptr<cp::chaste_parameters_type> pParams,
00185 boost::shared_ptr<cp::chaste_parameters_type> pDefaults)
00186 {
00187
00188 if (!pParams->ResumeSimulation().present())
00189 {
00190 MERGE_PARAM(Simulation)
00191 ELSE_IF_DEFAULT(Simulation)
00192 {
00193 MERGE_PARAM(Simulation()->SpaceDimension)
00194 MERGE_PARAM(Simulation()->Domain)
00195 MERGE_PARAM(Simulation()->IonicModels)
00196 ELSE_IF_DEFAULT(Simulation()->IonicModels)
00197 {
00198
00199 }
00200 MERGE_PARAM(Simulation()->OutputDirectory)
00201 MERGE_PARAM(Simulation()->OutputFilenamePrefix)
00202 }
00203
00204
00205
00206
00207 {
00208 MERGE_PARAM(Physiological().IntracellularConductivities)
00209 MERGE_PARAM(Physiological().ExtracellularConductivities)
00210 MERGE_PARAM(Physiological().BathConductivity)
00211 MERGE_PARAM(Physiological().SurfaceAreaToVolumeRatio)
00212 MERGE_PARAM(Physiological().Capacitance)
00213 MERGE_PARAM(Physiological().Purkinje)
00214 ELSE_IF_DEFAULT(Physiological().Purkinje)
00215 {
00216 MERGE_PARAM(Physiological().Purkinje()->SurfaceAreaToVolumeRatio)
00217 MERGE_PARAM(Physiological().Purkinje()->Capacitance)
00218 MERGE_PARAM(Physiological().Purkinje()->Conductivity)
00219 }
00220 }
00221
00222
00223
00224
00225 {
00226 MERGE_PARAM(Numerical().TimeSteps)
00227 MERGE_PARAM(Numerical().KSPTolerances)
00228 ELSE_IF_DEFAULT(Numerical().KSPTolerances)
00229 {
00230
00231 if (!pParams->Numerical().KSPTolerances()->KSPRelative().present())
00232 {
00233 MERGE_PARAM(Numerical().KSPTolerances()->KSPAbsolute)
00234 }
00235 }
00236 MERGE_PARAM(Numerical().KSPSolver)
00237 MERGE_PARAM(Numerical().KSPPreconditioner)
00238 MERGE_PARAM(Numerical().MeshPartitioning)
00239 MERGE_PARAM(Numerical().UseStateVariableInterpolation)
00240 }
00241 }
00242 }
00243
00244 #endif