source: src/Filling/Mesh/CubeMesh.cpp@ 4464ef

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError 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 JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was a2a2f7, checked in by Frederik Heber <heber@…>, 11 years ago

Huge warning fix.

  • fixed unused variables.
  • fixed set but unused variables.
  • fixed signed vs. unsigned int comparison.
  • fixed static_warning_test<false, 98> (commented out _IMPLEMENT).
  • Property mode set to 100644
File size: 3.7 KB
Line 
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 * CubeMesh.cpp
25 *
26 * Created on: Jan 20, 2012
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "CodePatterns/MemDebug.hpp"
36
37#include <boost/lambda/lambda.hpp>
38#include <cmath>
39
40#include "CodePatterns/Log.hpp"
41#include "CubeMesh.hpp"
42#include "LinearAlgebra/RealSpaceMatrix.hpp"
43#include "LinearAlgebra/Vector.hpp"
44
45/** Constructor for class CubeMesh.
46 *
47 * Here, we generate nodes homogeneously distributed over a cuboid.
48 *
49 * \a offset shifts the coordinates, e.g. if counts = 2, we would set nodes at
50 * 0 and 0.5 with offset = 0 and 0.4999... and 0.9999.. with offset = 0.999...
51 *
52 * @param counts number of points per axis
53 * @param offset offset Vector (coordinates in [0,1))
54 * @param M matrix to transform the default cuboid from (0,0,0) to (1,1,1).
55 */
56CubeMesh::CubeMesh(const Vector &counts, const Vector &offset, const RealSpaceMatrix &M)
57{
58#ifndef NDEBUG
59 for (size_t i=0;i<NDIM;++i) {
60 ASSERT((offset[i] >= 0.) && (offset[i] < 1.),
61 "CubeMesh::CubeMesh() - offset coordinates must be in [0,1) but offset["
62 +toString(i)+"] is "+toString(offset[i])+".");
63 ASSERT(counts[i] == (int)counts[i],
64 "CubeMesh::CubeMesh() - counts["+toString(i)+"] must be integer: != "+toString(counts[i])+".");
65 }
66#endif
67
68 std::vector< unsigned int> size_counts;
69 for (size_t i=0;i<NDIM;++i) {
70 size_counts.push_back( (int)counts[i] );
71 }
72 init(size_counts, offset, M);
73}
74
75/** Constructor for class CubeMesh.
76 *
77 * Here, we generate nodes homogeneously distributed over a cuboid.
78 *
79 * \a offset shifts the coordinates, e.g. if counts = 2, we would set nodes at
80 * 0 and 0.5 with offset = 0 and 0.4999... and 0.9999.. with offset = 0.999...
81 *
82 * @param counts number of points per axis
83 * @param offset offset Vector (coordinates in [0,1))
84 * @param M matrix to transform the default cuboid from (0,0,0) to (1,1,1).
85 */
86CubeMesh::CubeMesh(const std::vector< unsigned int > &counts, const Vector &offset, const RealSpaceMatrix &M)
87{
88 ASSERT(counts.size() == 3,
89 "CubeMesh::CubeMesh() - counts does not have three but "
90 +toString(counts.size())+" entries.");
91
92 init(counts, offset, M);
93}
94
95void CubeMesh::init(const std::vector< unsigned int > &counts, const Vector &offset, const RealSpaceMatrix &M)
96{
97 RealSpaceMatrix partition;
98
99 partition.setZero();
100 for(int i=0;i<NDIM;i++)
101 partition.at(i,i) = 1./(double)counts[i];
102 LOG(1, "INFO: partition is " << partition << ".");
103
104 // go over [0,1]^3 filler grid
105 size_t n[NDIM];
106 for (n[0] = 0; n[0] < counts[0]; n[0]++)
107 for (n[1] = 0; n[1] < counts[1]; n[1]++)
108 for (n[2] = 0; n[2] < counts[2]; n[2]++) {
109 const Vector CurrentPosition((double)n[0], (double)n[1], (double)n[2]);
110 nodes.push_back(M * partition * (CurrentPosition + offset));
111 }
112}
113
114/** Destructor for class CubeMesh.
115 *
116 */
117CubeMesh::~CubeMesh()
118{}
Note: See TracBrowser for help on using the repository browser.