source: ThirdParty/vmg/src/discretization/boundary_value_setter.cpp@ 33a694

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes
Last change on this file since 33a694 was 7faa5c, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit 'de061d9d851257a04e924d4472df4523d33bb08b' as 'ThirdParty/vmg'

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * vmg - a versatile multigrid solver
3 * Copyright (C) 2012-2013 Institute for Numerical Simulation, University of Bonn
4 *
5 * vmg is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * vmg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * @file boundary_value_setter.cpp
21 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
22 * @date Mon Apr 15 16:21:40 2013
23 *
24 * @brief Class for setting boundary values with open
25 * boundary conditions.
26 *
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "libvmg_config.h"
31#endif
32
33#include "comm/comm.hpp"
34#include "discretization/boundary_value_setter.hpp"
35#include "grid/grid.hpp"
36#include "grid/grid_index_translations.hpp"
37#include "grid/multigrid.hpp"
38#include "mg.hpp"
39
40using namespace VMG;
41
42void BoundaryValueSetter::ComputeBoundaryValues()
43{
44 const Grid& grid_ml = (*MG::GetRhs())(MG::GetRhs()->MaxLevel());
45 Grid& rhs_gml = (*MG::GetRhs())(MG::GetRhs()->GlobalMaxLevel());
46 Grid& sol_gml = (*MG::GetSol())(MG::GetSol()->GlobalMaxLevel());
47
48 for (std::vector<BoundaryValue>::iterator iter_b = boundary_values.begin(); iter_b != boundary_values.end(); ++iter_b)
49 iter_b->Val() = 0.0;
50
51 for (GridIterator iter_g = grid_ml.Iterators().Local().Begin(); iter_g != grid_ml.Iterators().Local().End(); ++iter_g)
52 for (std::vector<BoundaryValue>::iterator iter_b = boundary_values.begin(); iter_b != boundary_values.end(); ++iter_b)
53 iter_b->Val() += grid_ml.GetVal(*iter_g) * greens_function((iter_b->GetPos() - grid_ml.GetSpatialPos(*iter_g)).Length());
54
55 std::vector<BoundaryValue> list_bv = MG::GetComm()->CommBoundaryValues();
56
57 for (std::vector<BoundaryValue>::iterator iter = list_bv.begin(); iter != list_bv.end(); ++iter) {
58 const Index i = GridIndexTranslations::GlobalToLocal(rhs_gml, iter->GetIndex());
59 const vmg_float val = grid_ml.Extent().MeshWidth().Product() * iter->Val();
60 rhs_gml(i) = val;
61 sol_gml(i) = val;
62 }
63
64 MG::GetComm()->PrintGrid(rhs_gml, "DEBUG GREEN BOUNDARY");
65}
66
67void BoundaryValueSetter::InitBoundaryValueSetter()
68{
69 Comm& comm = *MG::GetComm();
70
71 const Grid& grid = (*MG::GetRhs())(MG::GetRhs()->GlobalMaxLevel());
72
73 Index begin_local, end_local, i;
74 for (int i=0; i<3; ++i) {
75 begin_local[i] = grid.Global().GlobalBegin()[i] + (comm.BoundaryConditions()[i] == Open ? 1 : 0);
76 end_local[i] = grid.Global().GlobalEnd()[i] - (comm.BoundaryConditions()[i] == Open ? 1 : 0);
77 }
78
79 if (comm.BoundaryConditions().X() == Open) {
80
81 i.X() = grid.Global().GlobalBegin().X();
82 for (i.Y() = begin_local.Y(); i.Y() < end_local.Y(); ++i.Y())
83 for (i.Z() = begin_local.Z(); i.Z() < end_local.Z(); ++i.Z())
84 boundary_values.push_back(BoundaryValue(grid, i));
85
86 i.X() = grid.Global().GlobalEnd().X()-1;
87 for (i.Y() = begin_local.Y(); i.Y() < end_local.Y(); ++i.Y())
88 for (i.Z() = begin_local.Z(); i.Z() < end_local.Z(); ++i.Z())
89 boundary_values.push_back(BoundaryValue(grid, i));
90
91 }
92
93 if (comm.BoundaryConditions().Y() == Open) {
94
95 i.Y() = grid.Global().GlobalBegin().Y();
96 for (i.X() = begin_local.X(); i.X() < end_local.X(); ++i.X())
97 for (i.Z() = begin_local.Z(); i.Z() < end_local.Z(); ++i.Z())
98 boundary_values.push_back(BoundaryValue(grid, i));
99
100 i.Y() = grid.Global().GlobalEnd().Y() - 1;
101 for (i.X() = begin_local.X(); i.X() < end_local.X(); ++i.X())
102 for (i.Z() = begin_local.Z(); i.Z() < end_local.Z(); ++i.Z())
103 boundary_values.push_back(BoundaryValue(grid, i));
104
105 }
106
107 if (comm.BoundaryConditions().Z() == Open) {
108
109 i.Z() = grid.Global().GlobalBegin().Z();
110 for (i.X() = begin_local.X(); i.X() < end_local.X(); ++i.X())
111 for (i.Y() = begin_local.Y(); i.Y() < end_local.Y(); ++i.Y())
112 boundary_values.push_back(BoundaryValue(grid, i));
113
114 i.Z() = grid.Global().GlobalEnd().Z() - 1;
115 for (i.X() = begin_local.X(); i.X() < end_local.X(); ++i.X())
116 for (i.Y() = begin_local.Y(); i.Y() < end_local.Y(); ++i.Y())
117 boundary_values.push_back(BoundaryValue(grid, i));
118
119 }
120
121}
122
123BoundaryValueSetter::~BoundaryValueSetter()
124{
125
126}
Note: See TracBrowser for help on using the repository browser.