[238868] | 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 |
|
---|
| 55 | using namespace VMG;
|
---|
| 56 | using VMGInterfaces::InterfaceVMGDebugGridJob;
|
---|
| 57 |
|
---|
| 58 | InterfaceVMGDebugGridJob::InterfaceVMGDebugGridJob(
|
---|
| 59 | const std::vector< double > &_sampled_input,
|
---|
| 60 | VMG::Boundary boundary,
|
---|
| 61 | int levelMin,
|
---|
| 62 | int levelMax,
|
---|
| 63 | const VMG::Vector &box_begin,
|
---|
| 64 | vmg_float box_end,
|
---|
| 65 | const int& near_field_cells,
|
---|
| 66 | int coarseningSteps,
|
---|
| 67 | double alpha) :
|
---|
| 68 | VMG::Interface(boundary, levelMin, levelMax,
|
---|
| 69 | box_begin, box_end, coarseningSteps, alpha),
|
---|
| 70 | sampled_input(_sampled_input),
|
---|
| 71 | level(levelMax)
|
---|
| 72 | {
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | InterfaceVMGDebugGridJob::~InterfaceVMGDebugGridJob()
|
---|
| 76 | {}
|
---|
| 77 |
|
---|
| 78 | void InterfaceVMGDebugGridJob::ImportRightHandSide(Multigrid& multigrid)
|
---|
| 79 | {
|
---|
| 80 | Index i;
|
---|
| 81 | Vector pos;
|
---|
| 82 | // VMG::TempGrid *temp_grid = new VMG::TempGrid(129, 0, 0., 1.);
|
---|
| 83 |
|
---|
| 84 | Grid& grid = multigrid(multigrid.MaxLevel());
|
---|
| 85 | //grid.ClearBoundary(); // we don't have a boundary under periodic boundary conditions
|
---|
| 86 |
|
---|
| 87 | // print debugging info on grid size
|
---|
| 88 | LOG(1, "INFO: Mesh has extent " << grid.Extent().MeshWidth() << ".");
|
---|
| 89 | const int gridpoints = pow(2, level);
|
---|
| 90 | LOG(1, "INFO: gridpoints on finest level are " << gridpoints << ".");
|
---|
| 91 | LOG(1, "INFO: "
|
---|
| 92 | << "X in [" << grid.Local().Begin().X() << "," << grid.Local().End().X() << "],"
|
---|
| 93 | << "Y in [" << grid.Local().Begin().Y() << "," << grid.Local().End().Y() << "],"
|
---|
| 94 | << "Z in [" << grid.Local().Begin().Z() << "," << grid.Local().End().Z() << "].");
|
---|
| 95 |
|
---|
| 96 | // add sampled grid points to grid
|
---|
| 97 | std::vector<double>::const_iterator sample_iter = sampled_input.begin();
|
---|
| 98 | for (Grid::iterator iter = grid.Iterators().Local().Begin();
|
---|
| 99 | iter != grid.Iterators().Local().End();
|
---|
| 100 | ++iter)
|
---|
| 101 | grid(*iter) = -1. * (*sample_iter++);
|
---|
| 102 | assert( sample_iter == sampled_input.end() );
|
---|
| 103 |
|
---|
| 104 | // print electron grid to vtk
|
---|
| 105 | Comm& comm = *MG::GetComm();
|
---|
| 106 | comm.PrintGrid(grid, "Sampled Grid");
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | void InterfaceVMGDebugGridJob::ExportSolution(Grid& grid)
|
---|
| 110 | {
|
---|
| 111 | // we don't solve anything, hence nothing to do here
|
---|
| 112 | }
|
---|