Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_PSYS_FORCE_UTIL_PSYS_COMPUTE_RANDOM_FORCE_FIELD_H
00002 #define OPENTISSUE_DYNAMICS_PSYS_FORCE_UTIL_PSYS_COMPUTE_RANDOM_FORCE_FIELD_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <boost/cast.hpp>
00013 #include <cassert>
00014
00015 namespace OpenTissue
00016 {
00017 namespace psys
00018 {
00019
00020 template<typename grid_type>
00021 void compute_random_force_field( grid_type & field, double magnitude )
00022 {
00023 assert(magnitude>0 || !"compute_random_force_field(): magnitude was non-positive");
00024
00025 typedef typename grid_type::iterator iterator;
00026 typedef typename grid_type::value_type vector3_type;
00027 typedef typename vector3_type::value_type real_type;
00028
00029
00030 if(field.empty())
00031 {
00032 std::cerr << " compute_random_force_field(): map was empty, did you forget to call create?" << std::endl;
00033 return;
00034 }
00035
00036 real_type higher = boost::numeric_cast <real_type>(magnitude);
00037 real_type lower = - higher;
00038
00039 for( iterator iter = field.begin(); iter != field.end(); ++iter )
00040 random((*iter),lower,higher);
00041 }
00042
00043 }
00044 }
00045
00046
00047 #endif