| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2012 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * 
 | 
|---|
| 6 |  *
 | 
|---|
| 7 |  *   This file is part of MoleCuilder.
 | 
|---|
| 8 |  *
 | 
|---|
| 9 |  *    MoleCuilder is free software: you can redistribute it and/or modify
 | 
|---|
| 10 |  *    it under the terms of the GNU General Public License as published by
 | 
|---|
| 11 |  *    the Free Software Foundation, either version 2 of the License, or
 | 
|---|
| 12 |  *    (at your option) any later version.
 | 
|---|
| 13 |  *
 | 
|---|
| 14 |  *    MoleCuilder is distributed in the hope that it will be useful,
 | 
|---|
| 15 |  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 16 |  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 17 |  *    GNU General Public License for more details.
 | 
|---|
| 18 |  *
 | 
|---|
| 19 |  *    You should have received a copy of the GNU General Public License
 | 
|---|
| 20 |  *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
| 21 |  */
 | 
|---|
| 22 | 
 | 
|---|
| 23 | /*
 | 
|---|
| 24 |  * InterfaceVMGDebugGridJob.cpp
 | 
|---|
| 25 |  *
 | 
|---|
| 26 |  *  Created on: 10.06.2012
 | 
|---|
| 27 |  *      Author: Frederik Heber
 | 
|---|
| 28 |  */
 | 
|---|
| 29 | 
 | 
|---|
| 30 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 31 | #include <config.h>
 | 
|---|
| 32 | #endif
 | 
|---|
| 33 | 
 | 
|---|
| 34 | #ifdef HAVE_MPI
 | 
|---|
| 35 | #include "mpi.h"
 | 
|---|
| 36 | #endif
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #include "base/vector.hpp"
 | 
|---|
| 39 | #include "base/math.hpp"
 | 
|---|
| 40 | #include "comm/comm.hpp"
 | 
|---|
| 41 | #include "grid/grid.hpp"
 | 
|---|
| 42 | #include "grid/multigrid.hpp"
 | 
|---|
| 43 | #include "mg.hpp"
 | 
|---|
| 44 | 
 | 
|---|
| 45 | #include "InterfaceVMGDebugGridJob.hpp"
 | 
|---|
| 46 | 
 | 
|---|
| 47 | //#include "CodePatterns/MemDebug.hpp"
 | 
|---|
| 48 | 
 | 
|---|
| 49 | #include <cmath>
 | 
|---|
| 50 | #include <iostream>
 | 
|---|
| 51 | 
 | 
|---|
| 52 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 53 | 
 | 
|---|
| 54 | #include "Jobs/WindowGrid_converter.hpp"
 | 
|---|
| 55 | 
 | 
|---|
| 56 | using namespace VMG;
 | 
|---|
| 57 | using VMGInterfaces::InterfaceVMGDebugGridJob;
 | 
|---|
| 58 | 
 | 
|---|
| 59 | InterfaceVMGDebugGridJob::InterfaceVMGDebugGridJob(
 | 
|---|
| 60 |     const SamplingGrid &_sampled_input,
 | 
|---|
| 61 |     VMG::Boundary boundary,
 | 
|---|
| 62 |     int levelMin,
 | 
|---|
| 63 |     int levelMax,
 | 
|---|
| 64 |     const VMG::Vector &box_begin,
 | 
|---|
| 65 |     vmg_float box_end,
 | 
|---|
| 66 |     const int& near_field_cells,
 | 
|---|
| 67 |     int coarseningSteps,
 | 
|---|
| 68 |     double alpha) :
 | 
|---|
| 69 |   VMG::Interface(boundary, levelMin, levelMax,
 | 
|---|
| 70 |       box_begin, box_end, coarseningSteps, alpha),
 | 
|---|
| 71 |   sampled_input(_sampled_input),
 | 
|---|
| 72 |   level(levelMax)
 | 
|---|
| 73 | {
 | 
|---|
| 74 | }
 | 
|---|
| 75 | 
 | 
|---|
| 76 | void InterfaceVMGDebugGridJob::ImportRightHandSide(Multigrid& multigrid)
 | 
|---|
| 77 | {
 | 
|---|
| 78 |   Index i;
 | 
|---|
| 79 |   Vector pos;
 | 
|---|
| 80 |   //  VMG::TempGrid *temp_grid = new VMG::TempGrid(129, 0, 0., 1.);
 | 
|---|
| 81 | 
 | 
|---|
| 82 |   Grid& grid = multigrid(multigrid.MaxLevel());
 | 
|---|
| 83 |   //grid.ClearBoundary(); // we don't have a boundary under periodic boundary conditions
 | 
|---|
| 84 | 
 | 
|---|
| 85 |   // print debugging info on grid size
 | 
|---|
| 86 |   LOG(1, "INFO: Mesh has extent " << grid.Extent().MeshWidth() << ".");
 | 
|---|
| 87 |   const int gridpoints = pow(2, level);
 | 
|---|
| 88 |   LOG(1, "INFO: gridpoints on finest level are " << gridpoints << ".");
 | 
|---|
| 89 |   LOG(1, "INFO: "
 | 
|---|
| 90 |       << "X in [" << grid.Local().Begin().X() << "," << grid.Local().End().X() << "],"
 | 
|---|
| 91 |       << "Y in [" << grid.Local().Begin().Y() << "," << grid.Local().End().Y() << "],"
 | 
|---|
| 92 |       << "Z in [" << grid.Local().Begin().Z() << "," << grid.Local().End().Z() << "].");
 | 
|---|
| 93 | 
 | 
|---|
| 94 |   // add sampled grid points to grid
 | 
|---|
| 95 |   WindowGrid_converter::addWindowOntoGrid(
 | 
|---|
| 96 |       grid,
 | 
|---|
| 97 |       sampled_input,
 | 
|---|
| 98 |       -1.);
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   // print electron grid to vtk
 | 
|---|
| 101 |   Comm& comm = *MG::GetComm();
 | 
|---|
| 102 |   comm.PrintGrid(grid, "Sampled Grid");
 | 
|---|
| 103 | }
 | 
|---|
| 104 | 
 | 
|---|
| 105 | void InterfaceVMGDebugGridJob::ExportSolution(Grid& grid)
 | 
|---|
| 106 | {
 | 
|---|
| 107 |   // we don't solve anything, hence nothing to do here
 | 
|---|
| 108 | }
 | 
|---|