Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

DislocationDynamicsModule.h

Go to the documentation of this file.
00001 /*
00002  * File:        DislocationDynamicsModule.h
00003  * Copyright:   (c) 2005-2007 Princeton University
00004  * Author(s):   Kevin T. Chu
00005  * Revision:    $Revision: 379 $
00006  * Modified:    $Date: 2007-08-07 10:02:34 -0400 (Tue, 07 Aug 2007) $
00007  * Description: Header file for the DislocationDynamicsModule class
00008  */
00009 
00010 #ifndef included_DislocationDynamicsModule_h
00011 #define included_DislocationDynamicsModule_h
00012 
00339 // System Headers
00340 #include <float.h>
00341 #include <string>
00342 #include <vector>
00343 
00344 // SAMRAI Headers
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 // Level Set Method Headers
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 // LSMDD Headers
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 // namespaces
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  * DislocationDynamicsModule Class Definition
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    *  USERS NEED NOT BE CONCERNED WITH FOLLOWING METHODS.  THEY
00741    *  ARE PART OF THE IMPLEMENTATION DETAILS FOR THE LEVEL SET 
00742    *  METHOD DISLOCATION DYNAMICS CALCULATION.
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    * Input parameters
01205    */
01206 
01207   // simulation parameters 
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   // LSMDD_Parameters
01220   LSMDD_Parameters d_lsmdd_params;
01221 
01222 
01223   /* 
01224    * Pointers to algorithm and data structure objects
01225    */
01226 
01227   // pointer to PatchHierarchy
01228   Pointer< PatchHierarchy<3> > d_patch_hierarchy;
01229 
01230   // pointer to CartesianGridGeometry
01231   Pointer< CartesianGridGeometry<3> > d_grid_geometry;
01232 
01233   // array of Burgers vectors for dislocation lines
01234   Array< BurgersVector > d_burgers_vectors;
01235   int d_num_dislocation_lines;
01236 
01237   // pointer to LevelSetMethodAlgorithm object
01238   Pointer< LevelSetMethodAlgorithm<3> > d_lsm_algorithm;
01239 
01240   // pointer to FieldExtensionAlgorithm objects
01241   Pointer< FieldExtensionAlgorithm<3> > d_lsm_phi_field_extension_alg;
01242   Pointer< FieldExtensionAlgorithm<3> > d_lsm_psi_field_extension_alg;
01243 
01244   // pointer to ElasticStressStrategy
01245   ElasticStressStrategy *d_elastic_stress_strategy;
01246 
01247   // pointer to LSMDD_PhysicsStrategy
01248   LSMDD_PhysicsStrategy* d_lsmdd_physics_strategy;
01249 
01250   // pointer to BoundaryConditionModule
01251   Pointer< BoundaryConditionModule<3> > d_level_set_fcn_bc_module;
01252 
01253   // boundary conditions for level set functions
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   // boundary conditions for velocity field
01260   IntVector<3> d_lower_bc_velocity;
01261   IntVector<3> d_upper_bc_velocity;
01262 
01263   /*
01264    * Geometry and boundary condition parameters
01265    */
01266   IntVector<3> d_level_set_fcn_scratch_ghostcell_width;
01267 
01268 
01269   /*
01270    * PatchData handles
01271    */
01272 
01273   // PatchData handles for computation
01274   int d_phi_scratch_handle;               // PatchData handle for phi
01275                                           // scratch data
01276   int d_psi_scratch_handle;               // PatchData handle for psi
01277                                           // scratch data
01278   int d_grad_phi_plus_handle;             // PatchData handle for grad(phi) 
01279                                           // plus
01280   int d_grad_phi_minus_handle;            // PatchData handle for grad(phi)
01281                                           // minus
01282   int d_grad_phi_central_handle;          // PatchData handle for central
01283                                           // approximation to grad(phi)
01284   int d_grad_psi_plus_handle;             // PatchData handle for grad(psi)
01285                                           // plus
01286   int d_grad_psi_minus_handle;            // PatchData handle for grad(psi)
01287                                           // minus
01288   int d_grad_psi_central_handle;          // PatchData handle for central
01289                                           // approximation to grad(psi)
01290 
01291   int d_dislocation_line_field_handle;    // PatchData handle for dislocation
01292                                           // line field given by 
01293                                           // delta(phi)*delta(phi)*unit_tangent
01294   int d_velocity_handle;                  // PatchData handle for velocity
01295   int d_aux_stress_field_handle;          // PatchData handle for auxiliary
01296                                           // stress field
01297   int d_force_handle;                     // PatchData handle for force on
01298                                           // dislocation line
01299   vector<int> d_tangent_vector_handles;   // PatchData handle for unit tangent
01300                                           // vectors of dislocation line
01301   int d_distance_handle;                  // PatchData handle for the closest
01302                                           // distance from the nearest 
01303                                           // dislocation line to the center
01304                                           // of the grid cell
01305 
01306                                           // dislocation line
01307   ComponentSelector d_tangent_vectors;    // Component selector to manage
01308                                           // allocation/deallocation of 
01309                                           // tangent vector PatchData
01310 
01311   /*
01312    * Data communication objects
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    * Parameters for outputing data to file
01323    */
01324   static const int s_lsmdd_version;
01325   static const int s_lsmdd_binary_output_max_num_dislocations;
01326 
01327   /*
01328    * Object state variables 
01329    */
01330   double d_current_time;                         // current simulation time
01331   double d_last_stress_update_time;              // last time that stress
01332                                                  // field was updated
01333   int d_num_simulation_steps_taken;              // number of simulation steps 
01334                                                  // taken
01335   bool d_upwind_spatial_derivative_flag;         // flag indicating whether 
01336                                                  // upwind or downwind spatial 
01337                                                  // derivatives should be used 
01338                                                  // during calculation of 
01339                                                  // dislocation lines
01340   bool d_hierarchy_configuration_needs_reset;    // flag indicating that 
01341                                                  // communication schedules
01342                                                  // need to be recomputed
01343   bool d_velocity_data_allocated;                // flag indicating if velocity
01344                                                  // data has been allocated
01345 
01346 
01347 private:
01348  
01349   /*
01350    * Private copy constructor to prevent use.
01351    *
01352    * Arguments:
01353    *  - rhs (in):  DislocationDynamicsModule object to copy
01354    *
01355    */
01356   DislocationDynamicsModule(const DislocationDynamicsModule& rhs){}
01357 
01358   /*
01359    * Private assignment operator to prevent use.
01360    *
01361    * Arguments:
01362    *  - rhs (in):   DislocationDynamicsModule object to copy
01363    *
01364    * Return value:  *this
01365    *
01366    */
01367   const DislocationDynamicsModule& operator=(
01368     const DislocationDynamicsModule& rhs){ return *this; }
01369 
01370 };
01371 
01372 } // end LSMDD namespace
01373 
01374 #ifndef LSMDD_DEBUG_NO_INLINE
01375 #include "DislocationDynamicsModule.inline"
01376 #endif
01377 
01378 #endif
01379 

Generated on Tue Aug 7 15:43:41 2007 for LSMDD by doxygen 1.3.4