00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef included_DislocationDynamicsModule_h
00011 #define included_DislocationDynamicsModule_h
00012
00339
00340 #include <float.h>
00341 #include <string>
00342 #include <vector>
00343
00344
00345 #include "SAMRAI_config.h"
00346 #include "Box.h"
00347 #include "CartesianGridGeometry.h"
00348 #include "CellData.h"
00349 #include "ComponentSelector.h"
00350 #include "IntVector.h"
00351 #include "Patch.h"
00352 #include "PatchHierarchy.h"
00353 #include "RefineAlgorithm.h"
00354 #include "RefineSchedule.h"
00355 #include "tbox/Array.h"
00356 #include "tbox/Database.h"
00357 #include "tbox/Pointer.h"
00358
00359
00360 #include "LSMLIB_config.h"
00361 #include "BoundaryConditionModule.h"
00362 #include "FieldExtensionAlgorithm.h"
00363 #include "LevelSetFunctionIntegrator.h"
00364 #include "LevelSetMethodAlgorithm.h"
00365 #include "LevelSetMethodPatchStrategy.h"
00366 #include "LevelSetMethodToolbox.h"
00367 #include "LevelSetMethodVelocityFieldStrategy.h"
00368
00369
00370 #include "LSMDD_config.h"
00371 #include "BurgersVector.h"
00372 #include "LSMDD_PhysicsStrategy.h"
00373 #include "LSMDD_Parameters.h"
00374 #include "ElasticStressStrategy.h"
00375
00376
00377 using namespace std;
00378 using namespace SAMRAI;
00379 using namespace geom;
00380 using namespace hier;
00381 using namespace pdat;
00382 using namespace tbox;
00383 using namespace xfer;
00384 using namespace LSMLIB;
00385
00386
00387
00388
00389
00390
00391
00392
00393 namespace LSMDD {
00394
00395 class DislocationDynamicsModule:
00396 public LevelSetMethodPatchStrategy<3>,
00397 public LevelSetMethodVelocityFieldStrategy<3>
00398 {
00399 public:
00400
00402
00414 typedef enum { ASCII = 0,
00415 BINARY = 1 } VISUALIZATION_FILE_FORMAT;
00416
00418
00419
00421
00447 DislocationDynamicsModule(
00448 Pointer<Database> input_db,
00449 Pointer< PatchHierarchy<3> > patch_hierarchy,
00450 ElasticStressStrategy *elastic_stress_strategy,
00451 LSMDD_PhysicsStrategy* lsmdd_physics_strategy);
00452
00453
00457 virtual ~DislocationDynamicsModule();
00458
00460
00461
00463
00478 virtual int getPhiPatchDataHandle() const;
00479
00488 virtual int getPsiPatchDataHandle() const;
00489
00499 virtual int getVelocityPatchDataHandle() const;
00500
00510 virtual int getControlVolumePatchDataHandle() const;
00511
00513
00514
00516
00531 virtual double getStartTime() const;
00532
00541 virtual double getEndTime() const;
00542
00551 virtual double getCurrentTime() const;
00552
00563 virtual bool endTimeReached() const;
00564
00574 virtual int numSimulationStepsTaken() const;
00575
00586 virtual void printClassData(ostream& os) const;
00587
00589
00590
00592
00609 virtual void initializeDislocationLevelSetFunctions();
00610
00620 virtual double computeNextDt();
00621
00635 virtual void advanceDislocations(const double dt);
00636
00646 virtual bool toggleUpwindDirection();
00647
00648
00650
00674 virtual void writeAllDislocationLinesToFile(
00675 const string& base_name,
00676 const VISUALIZATION_FILE_FORMAT file_type = ASCII);
00677
00727 virtual void writeOneDislocationLineToFile(
00728 const int line_handle,
00729 const string& base_name,
00730 const VISUALIZATION_FILE_FORMAT file_type = ASCII,
00731 const bool overwrite_file = true,
00732 const bool allocate_scratch_data = true);
00733
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00748
00772 virtual void initializeLevelSetFunctionsOnPatch(Patch<3>& patch,
00773 const double time,
00774 const int phi_handle,
00775 const int psi_handle);
00776
00792 virtual void setLevelSetFunctionBoundaryConditions(
00793 Patch<3>& patch,
00794 const double fill_time,
00795 const int phi_handle,
00796 const int psi_handle,
00797 const IntVector<3>& ghost_width_to_fill);
00798
00813 virtual double computeStableDtOnPatch(
00814 Patch<3>& patch,
00815 LevelSetFunctionIntegrator<3>* lsm_integrator,
00816 LevelSetMethodVelocityFieldStrategy<3>* lsm_velocity_field_strategy);
00817
00818
00827 virtual inline bool providesExternalVelocityField() const
00828 {
00829 return true;
00830 }
00831
00840 virtual inline bool providesNormalVelocityField() const
00841 {
00842 return false;
00843 }
00844
00857 virtual inline int getExternalVelocityFieldPatchDataHandle(
00858 int component) const
00859 {
00860 (void) component;
00861 return d_velocity_handle;
00862 }
00863
00878 virtual inline int getNormalVelocityFieldPatchDataHandle(
00879 LEVEL_SET_FCN_TYPE level_set_fcn,
00880 int component) const
00881 {
00882 (void) level_set_fcn;
00883 (void) component;
00884 return -1;
00885 }
00886
00897 virtual inline void setCurrentTime(const double time)
00898 {
00899 d_current_time = time;
00900 }
00901
00913 virtual inline double computeStableDt()
00914 {
00915 return DBL_MAX;
00916 }
00917
00932 virtual void computeVelocityField(
00933 const double time,
00934 const int phi_handle,
00935 const int psi_handle,
00936 const int line_handle);
00937
00963 virtual inline void initializeLevelData(
00964 const Pointer< PatchHierarchy<3> > hierarchy,
00965 const int level_number,
00966 const double init_data_time,
00967 const int phi_handle,
00968 const int psi_handle,
00969 const bool can_be_refined,
00970 const bool initial_time,
00971 const Pointer< PatchLevel<3> > old_level
00972 = Pointer< PatchLevel<3> >((0)),
00973 const bool allocate_data = true) {}
00974
00989 virtual void resetHierarchyConfiguration(
00990 Pointer< PatchHierarchy<3> > hierarchy,
00991 const int coarsest_level,
00992 const int finest_level);
00993
00995
00996
00997 protected:
00998
01000
01016 virtual void getFromInput(Pointer<Database> input_db);
01017
01032 virtual void computeDislocationLineField(
01033 const int line_handle,
01034 const int phi_handle,
01035 const int psi_handle);
01036
01060 virtual void computeUnitTangentVectorForDislocationLine(
01061 const int tangent_vector_handle,
01062 const int line_handle,
01063 const int phi_handle,
01064 const int psi_handle);
01065
01075 virtual void initializeVariables();
01076
01087 virtual void initializeCommunicationObjects();
01088
01126 virtual void fillGhostCellsForLevelSetFunctions(
01127 const int line_handle,
01128 const int phi_handle,
01129 const int psi_handle);
01130
01159 virtual void writeOneDislocationLineToAsciiFile(
01160 const string& base_name,
01161 const int line_handle,
01162 const bool overwrite_file = true);
01163
01196 virtual void writeOneDislocationLineToBinaryFile(
01197 const string& base_name,
01198 const int line_handle,
01199 const bool overwrite_file = true);
01200
01202
01203
01204
01205
01206
01207
01208 double d_start_time;
01209 double d_end_time;
01210 SPATIAL_DERIVATIVE_TYPE d_spatial_derivative_type;
01211 int d_spatial_derivative_order;
01212 int d_num_stabilization_iterations;
01213 int d_reinitialization_interval;
01214 int d_use_reinitialization;
01215 int d_orthogonalization_interval;
01216 int d_use_orthogonalization;
01217 bool d_use_persistent_velocity_data;
01218
01219
01220 LSMDD_Parameters d_lsmdd_params;
01221
01222
01223
01224
01225
01226
01227
01228 Pointer< PatchHierarchy<3> > d_patch_hierarchy;
01229
01230
01231 Pointer< CartesianGridGeometry<3> > d_grid_geometry;
01232
01233
01234 Array< BurgersVector > d_burgers_vectors;
01235 int d_num_dislocation_lines;
01236
01237
01238 Pointer< LevelSetMethodAlgorithm<3> > d_lsm_algorithm;
01239
01240
01241 Pointer< FieldExtensionAlgorithm<3> > d_lsm_phi_field_extension_alg;
01242 Pointer< FieldExtensionAlgorithm<3> > d_lsm_psi_field_extension_alg;
01243
01244
01245 ElasticStressStrategy *d_elastic_stress_strategy;
01246
01247
01248 LSMDD_PhysicsStrategy* d_lsmdd_physics_strategy;
01249
01250
01251 Pointer< BoundaryConditionModule<3> > d_level_set_fcn_bc_module;
01252
01253
01254 Array< IntVector<3> > d_lower_bc_phi;
01255 Array< IntVector<3> > d_upper_bc_phi;
01256 Array< IntVector<3> > d_lower_bc_psi;
01257 Array< IntVector<3> > d_upper_bc_psi;
01258
01259
01260 IntVector<3> d_lower_bc_velocity;
01261 IntVector<3> d_upper_bc_velocity;
01262
01263
01264
01265
01266 IntVector<3> d_level_set_fcn_scratch_ghostcell_width;
01267
01268
01269
01270
01271
01272
01273
01274 int d_phi_scratch_handle;
01275
01276 int d_psi_scratch_handle;
01277
01278 int d_grad_phi_plus_handle;
01279
01280 int d_grad_phi_minus_handle;
01281
01282 int d_grad_phi_central_handle;
01283
01284 int d_grad_psi_plus_handle;
01285
01286 int d_grad_psi_minus_handle;
01287
01288 int d_grad_psi_central_handle;
01289
01290
01291 int d_dislocation_line_field_handle;
01292
01293
01294 int d_velocity_handle;
01295 int d_aux_stress_field_handle;
01296
01297 int d_force_handle;
01298
01299 vector<int> d_tangent_vector_handles;
01300
01301 int d_distance_handle;
01302
01303
01304
01305
01306
01307 ComponentSelector d_tangent_vectors;
01308
01309
01310
01311
01312
01313
01314 Pointer< RefineAlgorithm<3> > d_level_set_fcn_fill_bdry_alg;
01315 Array< Pointer< RefineSchedule<3> > > d_level_set_fcn_fill_bdry_sched;
01316 Pointer< RefineAlgorithm<3> > d_force_interp_fill_bdry_alg;
01317 Array< Pointer< RefineSchedule<3> > > d_force_interp_fill_bdry_sched;
01318 Pointer< RefineAlgorithm<3> > d_tangent_fill_bdry_alg;
01319 Array< Pointer< RefineSchedule<3> > > d_tangent_fill_bdry_sched;
01320
01321
01322
01323
01324 static const int s_lsmdd_version;
01325 static const int s_lsmdd_binary_output_max_num_dislocations;
01326
01327
01328
01329
01330 double d_current_time;
01331 double d_last_stress_update_time;
01332
01333 int d_num_simulation_steps_taken;
01334
01335 bool d_upwind_spatial_derivative_flag;
01336
01337
01338
01339
01340 bool d_hierarchy_configuration_needs_reset;
01341
01342
01343 bool d_velocity_data_allocated;
01344
01345
01346
01347 private:
01348
01349
01350
01351
01352
01353
01354
01355
01356 DislocationDynamicsModule(const DislocationDynamicsModule& rhs){}
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367 const DislocationDynamicsModule& operator=(
01368 const DislocationDynamicsModule& rhs){ return *this; }
01369
01370 };
01371
01372 }
01373
01374 #ifndef LSMDD_DEBUG_NO_INLINE
01375 #include "DislocationDynamicsModule.inline"
01376 #endif
01377
01378 #endif
01379