Changeset dfed1c for src/interface/interface_fcs.cpp
- Timestamp:
- Nov 22, 2011, 9:22:10 PM (14 years ago)
- Children:
- facba0
- Parents:
- 66f24d
- File:
-
- 1 edited
-
src/interface/interface_fcs.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/interface/interface_fcs.cpp
r66f24d rdfed1c 19 19 20 20 #include "base/object.hpp" 21 #include "comm/comm_serial.hpp" 21 #include "base/timer.hpp" 22 #include "comm/comm_mpi.hpp" 23 #include "comm/domain_decomposition_mpi.hpp" 22 24 #include "interface/interface_fcs.h" 23 25 #include "interface/interface_particles.hpp" … … 33 35 #include "solver/givens.hpp" 34 36 #endif 35 #include "solver/solver_ dirichlet.hpp"36 #include "solver/solver_ periodic.hpp"37 #include "solver/solver_regular.hpp" 38 #include "solver/solver_singular.hpp" 37 39 38 40 using namespace VMG; 39 41 40 void VMGInterfaceFCSInit(vmg_int level, vmg_int periodic, vmg_int spline_degree, 41 vmg_int max_iter, vmg_int smoothing_steps, vmg_int gamma, 42 vmg_float precision, vmg_float box_begin, vmg_float box_end, 43 MPI_Comm mpi_comm) 44 { 45 const BC bc = (periodic ? Periodic : Dirichlet); 46 47 /* 48 * Register all the parameters for later use. 49 */ 50 new ObjectStorage<int>("LEVEL_FCS", level); 51 new ObjectStorage<int>("PERIODIC_FCS", periodic); 52 new ObjectStorage<int>("SPLINE_DEGREE_FCS", spline_degree); 53 new ObjectStorage<int>("MAX_ITER_FCS", max_iter); 54 new ObjectStorage<int>("SMOOTHING_STEPS_FCS", smoothing_steps); 55 new ObjectStorage<int>("GAMMA_FCS", gamma); 56 new ObjectStorage<vmg_float>("PRECISION_FCS", precision); 57 new ObjectStorage<vmg_float>("BOX_BEGIN_FCS", box_begin); 58 new ObjectStorage<vmg_float>("BOX_END_FCS", box_end); 59 new ObjectStorage<MPI_Comm>("MPI_COMM_FCS", mpi_comm); 42 namespace VMGBackupSettings 43 { 44 static vmg_int level = -1; 45 static vmg_int periodic[3] = {-1, -1, -1}; 46 static vmg_int max_iter = -1; 47 static vmg_int smoothing_steps = -1; 48 static vmg_int gamma = -1; 49 static vmg_float precision = -1; 50 static vmg_float box_offset[3]; 51 static vmg_float box_size = -1.0; 52 static vmg_int near_field_cells = -1; 53 static MPI_Comm mpi_comm; 54 } 55 56 static void VMG_fcs_init(vmg_int level, vmg_int* periodic,vmg_int max_iter, 57 vmg_int smoothing_steps, vmg_int gamma, vmg_float precision, 58 vmg_float* box_offset, vmg_float box_size, 59 vmg_int near_field_cells, MPI_Comm mpi_comm) 60 { 61 VMGBackupSettings::level = level; 62 std::memcpy(VMGBackupSettings::periodic, periodic, 3*sizeof(vmg_int)); 63 VMGBackupSettings::max_iter = max_iter; 64 VMGBackupSettings::smoothing_steps = smoothing_steps; 65 VMGBackupSettings::gamma = gamma; 66 VMGBackupSettings::precision = precision; 67 std::memcpy(VMGBackupSettings::box_offset, box_offset, 3*sizeof(vmg_float)); 68 VMGBackupSettings::box_size = box_size; 69 VMGBackupSettings::near_field_cells = near_field_cells; 70 VMGBackupSettings::mpi_comm = mpi_comm; 71 72 const Boundary boundary(periodic[0] ? Periodic : Open, 73 periodic[1] ? Periodic : Open, 74 periodic[2] ? Periodic : Open); 75 76 const bool singular = periodic[0] * periodic[1] * periodic[2]; 60 77 61 78 /* 62 79 * Register communication class. 63 * For now, parallel version is not yet released. 64 */ 65 Comm* comm = new CommSerial(bc); 80 */ 81 Comm* comm = new CommMPI(boundary, new DomainDecompositionMPI()); 66 82 comm->Register("COMM"); 67 83 … … 69 85 * Register particle interface. 70 86 */ 71 Interface* interface = new VMG::InterfaceParticles(b c, 2, level, box_begin, box_end);87 Interface* interface = new VMG::InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells); 72 88 MG::SetInterface(interface, comm); 73 89 … … 96 112 */ 97 113 #ifdef HAVE_LAPACK 98 Solver* solver = ( periodic?99 static_cast<Solver*>(new DSYSV<Solver Periodic>()) :100 static_cast<Solver*>(new DGESV<Solver Dirichlet>()));114 Solver* solver = (singular ? 115 static_cast<Solver*>(new DSYSV<SolverSingular>()) : 116 static_cast<Solver*>(new DGESV<SolverRegular>())); 101 117 #else 102 Solver* solver = ( periodic?103 static_cast<Solver*>(new Givens<Solver Periodic>()) :104 static_cast<Solver*>(new Givens<Solver Dirichlet>()));118 Solver* solver = (singular ? 119 static_cast<Solver*>(new Givens<SolverSingular>()) : 120 static_cast<Solver*>(new Givens<SolverRegular>())); 105 121 #endif 106 122 solver->Register("SOLVER"); … … 109 125 * Set commands for the actual multigrid cycle 110 126 */ 111 if ( periodic)127 if (singular) 112 128 Techniques::SetCorrectionSchemePeriodic(2, level, gamma); 113 129 else … … 122 138 new ObjectStorage<int>("MAX_ITERATION", max_iter); 123 139 140 new ObjectStorage<int>("PARTICLE_NEAR_FIELD_CELLS", near_field_cells); 141 124 142 /* 125 143 * Check whether the library is correctly initialized now. … … 128 146 } 129 147 130 void VMGInterfaceFCSRun(vmg_float* x, vmg_float* q, vmg_float* p, vmg_float* f, vmg_int num_particles_local) 148 void VMG_fcs_setup(vmg_int level, vmg_int* periodic, vmg_int max_iter, 149 vmg_int smoothing_steps, vmg_int gamma, vmg_float precision, 150 vmg_float* box_offset, vmg_float box_size, 151 vmg_int near_field_cells, MPI_Comm mpi_comm) 152 { 153 if (VMGBackupSettings::level != level || 154 VMGBackupSettings::periodic[0] != periodic[0] || 155 VMGBackupSettings::periodic[1] != periodic[1] || 156 VMGBackupSettings::periodic[2] != periodic[2] || 157 VMGBackupSettings::max_iter != max_iter || 158 VMGBackupSettings::smoothing_steps != smoothing_steps || 159 VMGBackupSettings::gamma != gamma || 160 VMGBackupSettings::precision != precision || 161 VMGBackupSettings::box_offset[0] != box_offset[0] || 162 VMGBackupSettings::box_offset[1] != box_offset[1] || 163 VMGBackupSettings::box_offset[2] != box_offset[2] || 164 VMGBackupSettings::box_size != box_size || 165 VMGBackupSettings::near_field_cells != near_field_cells || 166 VMGBackupSettings::mpi_comm != mpi_comm) { 167 168 VMG_fcs_destroy(); 169 VMG_fcs_init(level, periodic, max_iter, 170 smoothing_steps, gamma, precision, 171 box_offset, box_size, near_field_cells, 172 mpi_comm); 173 174 } 175 } 176 177 void VMG_fcs_run(vmg_float* x, vmg_float* q, vmg_float* p, vmg_float* f, vmg_int num_particles_local) 131 178 { 132 179 /* 133 180 * Register parameters for later use. 134 181 */ 135 new ObjectStorage<vmg_float*>(" X_FCS", x);136 new ObjectStorage<vmg_float*>(" Q_FCS", q);137 new ObjectStorage<vmg_float*>("P _FCS", p);138 new ObjectStorage<vmg_float*>(" F_FCS", f);139 new ObjectStorage<vmg_int>(" NUM_PARTICLES_LOCAL_FCS", num_particles_local);182 new ObjectStorage<vmg_float*>("PARTICLE_POS_ARRAY", x); 183 new ObjectStorage<vmg_float*>("PARTICLE_CHARGE_ARRAY", q); 184 new ObjectStorage<vmg_float*>("PARTICLE_POTENTIAL_ARRAY", p); 185 new ObjectStorage<vmg_float*>("PARTICLE_FORCE_ARRAY", f); 186 new ObjectStorage<vmg_int>("PARTICLE_NUM_LOCAL", num_particles_local); 140 187 141 188 /* … … 145 192 } 146 193 147 void VMGInterfaceFCSDestroy(void) 194 void VMG_fcs_print_timer() 195 { 196 Timer::Print(); 197 } 198 199 void VMG_fcs_destroy(void) 148 200 { 149 201 /*
Note:
See TracChangeset
for help on using the changeset viewer.
