[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 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/>.
|
---|
[bcf653] | 21 | */
|
---|
| 22 |
|
---|
[83c09a] | 23 | /*
|
---|
| 24 | * Box.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Jun 30, 2010
|
---|
| 27 | * Author: crueger
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[bf3817] | 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
|
---|
[6e00dd] | 36 |
|
---|
[83c09a] | 37 | #include "Box.hpp"
|
---|
| 38 |
|
---|
[f429d7] | 39 | #include <cmath>
|
---|
[d2938f] | 40 | #include <cstdlib>
|
---|
[c52e08] | 41 | #include <iostream>
|
---|
| 42 | #include <sstream>
|
---|
[f429d7] | 43 |
|
---|
[06aedc] | 44 | #include "CodePatterns/Assert.hpp"
|
---|
| 45 | #include "CodePatterns/Log.hpp"
|
---|
[99f4ee] | 46 | #include "CodePatterns/Observer/Channels.hpp"
|
---|
| 47 | #include "CodePatterns/Observer/Notification.hpp"
|
---|
[06aedc] | 48 | #include "CodePatterns/Verbose.hpp"
|
---|
| 49 | #include "Helpers/defs.hpp"
|
---|
[cca9ef] | 50 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[57f243] | 51 | #include "LinearAlgebra/Vector.hpp"
|
---|
| 52 | #include "LinearAlgebra/Plane.hpp"
|
---|
[c538d1] | 53 | #include "Shapes/BaseShapes.hpp"
|
---|
| 54 | #include "Shapes/ShapeOps.hpp"
|
---|
[83c09a] | 55 |
|
---|
[6e00dd] | 56 |
|
---|
[528b3e] | 57 | Box::Box() :
|
---|
[99f4ee] | 58 | Observable("Box"),
|
---|
[528b3e] | 59 | M(new RealSpaceMatrix()),
|
---|
| 60 | Minv(new RealSpaceMatrix())
|
---|
[83c09a] | 61 | {
|
---|
[de29ad6] | 62 | internal_list.reserve(pow(3,3));
|
---|
| 63 | coords.reserve(NDIM);
|
---|
| 64 | index.reserve(NDIM);
|
---|
[99f4ee] | 65 |
|
---|
| 66 | // observable stuff
|
---|
| 67 | Channels *OurChannel = new Channels;
|
---|
[708277] | 68 | NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) );
|
---|
[99f4ee] | 69 | // add instance for each notification type
|
---|
| 70 | for (size_t type = 0; type < NotificationType_MAX; ++type)
|
---|
| 71 | OurChannel->addChannel(type);
|
---|
| 72 |
|
---|
[9eb7580] | 73 | M->setIdentity();
|
---|
| 74 | Minv->setIdentity();
|
---|
[83c09a] | 75 | }
|
---|
| 76 |
|
---|
[528b3e] | 77 | Box::Box(const Box& src) :
|
---|
[99f4ee] | 78 | Observable("Box"),
|
---|
| 79 | conditions(src.conditions),
|
---|
| 80 | M(new RealSpaceMatrix(*src.M)),
|
---|
| 81 | Minv(new RealSpaceMatrix(*src.Minv))
|
---|
[de29ad6] | 82 | {
|
---|
| 83 | internal_list.reserve(pow(3,3));
|
---|
| 84 | coords.reserve(NDIM);
|
---|
| 85 | index.reserve(NDIM);
|
---|
[99f4ee] | 86 |
|
---|
| 87 | // observable stuff
|
---|
| 88 | Channels *OurChannel = new Channels;
|
---|
[708277] | 89 | NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) );
|
---|
[99f4ee] | 90 | // add instance for each notification type
|
---|
| 91 | for (size_t type = 0; type < NotificationType_MAX; ++type)
|
---|
| 92 | OurChannel->addChannel(type);
|
---|
[de29ad6] | 93 | }
|
---|
[528b3e] | 94 |
|
---|
| 95 | Box::Box(RealSpaceMatrix _M) :
|
---|
[99f4ee] | 96 | Observable("Box"),
|
---|
[528b3e] | 97 | M(new RealSpaceMatrix(_M)),
|
---|
| 98 | Minv(new RealSpaceMatrix())
|
---|
| 99 | {
|
---|
[de29ad6] | 100 | internal_list.reserve(pow(3,3));
|
---|
| 101 | coords.reserve(NDIM);
|
---|
| 102 | index.reserve(NDIM);
|
---|
[99f4ee] | 103 |
|
---|
| 104 | // observable stuff
|
---|
| 105 | Channels *OurChannel = new Channels;
|
---|
[708277] | 106 | NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) );
|
---|
[99f4ee] | 107 | // add instance for each notification type
|
---|
| 108 | for (size_t type = 0; type < NotificationType_MAX; ++type)
|
---|
| 109 | OurChannel->addChannel(type);
|
---|
| 110 |
|
---|
[528b3e] | 111 | ASSERT(M->determinant()!=0,"Matrix in Box construction was not invertible");
|
---|
| 112 | *Minv = M->invert();
|
---|
[7579a4b] | 113 | }
|
---|
| 114 |
|
---|
[83c09a] | 115 | Box::~Box()
|
---|
| 116 | {
|
---|
| 117 | delete M;
|
---|
| 118 | delete Minv;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[cca9ef] | 121 | const RealSpaceMatrix &Box::getM() const{
|
---|
[83c09a] | 122 | return *M;
|
---|
| 123 | }
|
---|
[cca9ef] | 124 | const RealSpaceMatrix &Box::getMinv() const{
|
---|
[83c09a] | 125 | return *Minv;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[cca9ef] | 128 | void Box::setM(RealSpaceMatrix _M){
|
---|
[3bf9e2] | 129 | ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible");
|
---|
[99f4ee] | 130 | OBSERVE;
|
---|
[d00370] | 131 | if (_M != *M)
|
---|
| 132 | NOTIFY(MatrixChanged);
|
---|
[83c09a] | 133 | *M =_M;
|
---|
| 134 | *Minv = M->invert();
|
---|
| 135 | }
|
---|
[7579a4b] | 136 |
|
---|
[014475] | 137 | Vector Box::translateIn(const Vector &point) const{
|
---|
[3dcb1f] | 138 | return (*M) * point;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[014475] | 141 | Vector Box::translateOut(const Vector &point) const{
|
---|
[3dcb1f] | 142 | return (*Minv) * point;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
[712886] | 145 | Vector Box::enforceBoundaryConditions(const Vector &point) const{
|
---|
[f429d7] | 146 | Vector helper = translateOut(point);
|
---|
| 147 | for(int i=NDIM;i--;){
|
---|
[c72562] | 148 |
|
---|
| 149 | switch(conditions[i]){
|
---|
[d66cb7] | 150 | case BoundaryConditions::Wrap:
|
---|
[c72562] | 151 | helper.at(i)=fmod(helper.at(i),1);
|
---|
[d2938f] | 152 | helper.at(i)+=(helper.at(i)>=0)?0:1;
|
---|
[c72562] | 153 | break;
|
---|
[d66cb7] | 154 | case BoundaryConditions::Bounce:
|
---|
[c72562] | 155 | {
|
---|
| 156 | // there probably is a better way to handle this...
|
---|
| 157 | // all the fabs and fmod modf probably makes it very slow
|
---|
| 158 | double intpart,fracpart;
|
---|
| 159 | fracpart = modf(fabs(helper.at(i)),&intpart);
|
---|
| 160 | helper.at(i) = fabs(fracpart-fmod(intpart,2));
|
---|
| 161 | }
|
---|
| 162 | break;
|
---|
[d66cb7] | 163 | case BoundaryConditions::Ignore:
|
---|
[c72562] | 164 | break;
|
---|
| 165 | default:
|
---|
| 166 | ASSERT(0,"No default case for this");
|
---|
[68c923] | 167 | break;
|
---|
[c72562] | 168 | }
|
---|
| 169 |
|
---|
[f429d7] | 170 | }
|
---|
| 171 | return translateIn(helper);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
[0ff6b5] | 174 | bool Box::isInside(const Vector &point) const
|
---|
| 175 | {
|
---|
| 176 | bool result = true;
|
---|
[29ac78] | 177 | Vector tester = translateOut(point);
|
---|
[0ff6b5] | 178 |
|
---|
| 179 | for(int i=0;i<NDIM;i++)
|
---|
[f3be87] | 180 | result = result &&
|
---|
[d66cb7] | 181 | ((conditions[i] == BoundaryConditions::Ignore) ||
|
---|
[f3be87] | 182 | ((tester[i] >= -MYEPSILON) &&
|
---|
| 183 | ((tester[i] - 1.) < MYEPSILON)));
|
---|
[0ff6b5] | 184 |
|
---|
| 185 | return result;
|
---|
| 186 | }
|
---|
| 187 |
|
---|
[2a0271] | 188 | bool Box::isValid(const Vector &point) const
|
---|
| 189 | {
|
---|
| 190 | bool result = true;
|
---|
| 191 | Vector tester = translateOut(point);
|
---|
| 192 |
|
---|
| 193 | for(int i=0;i<NDIM;i++)
|
---|
| 194 | result = result &&
|
---|
| 195 | ((conditions[i] != BoundaryConditions::Ignore) ||
|
---|
| 196 | ((tester[i] >= -MYEPSILON) &&
|
---|
| 197 | ((tester[i] - 1.) < MYEPSILON)));
|
---|
| 198 |
|
---|
| 199 | return result;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[0ff6b5] | 202 |
|
---|
[de29ad6] | 203 | VECTORSET(std::vector) Box::explode(const Vector &point,int n) const{
|
---|
[16648f] | 204 | ASSERT(isInside(point),"Exploded point not inside Box");
|
---|
[025048] | 205 | internal_explode(point, n);
|
---|
[de29ad6] | 206 | VECTORSET(std::vector) res(internal_list);
|
---|
[025048] | 207 | return res;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | void Box::internal_explode(const Vector &point,int n) const{
|
---|
[31021ab] | 211 | // internal_list.clear();
|
---|
[de29ad6] | 212 | size_t list_index = 0;
|
---|
[89e820] | 213 |
|
---|
[16648f] | 214 | Vector translater = translateOut(point);
|
---|
| 215 | Vector mask; // contains the ignored coordinates
|
---|
| 216 |
|
---|
| 217 | // count the number of coordinates we need to do
|
---|
| 218 | int dims = 0; // number of dimensions that are not ignored
|
---|
[de29ad6] | 219 | coords.clear();
|
---|
| 220 | index.clear();
|
---|
[16648f] | 221 | for(int i=0;i<NDIM;++i){
|
---|
[d66cb7] | 222 | if(conditions[i]==BoundaryConditions::Ignore){
|
---|
[16648f] | 223 | mask[i]=translater[i];
|
---|
| 224 | continue;
|
---|
| 225 | }
|
---|
| 226 | coords.push_back(i);
|
---|
| 227 | index.push_back(-n);
|
---|
| 228 | dims++;
|
---|
| 229 | } // there are max vectors in total we need to create
|
---|
[31021ab] | 230 | const int new_size = pow(2*n+1, dims);
|
---|
| 231 | if (internal_list.size() != new_size)
|
---|
| 232 | internal_list.resize(new_size);
|
---|
[16648f] | 233 |
|
---|
| 234 | if(!dims){
|
---|
| 235 | // all boundaries are ignored
|
---|
[de29ad6] | 236 | internal_list[list_index++] = point;
|
---|
[025048] | 237 | return;
|
---|
[89e820] | 238 | }
|
---|
| 239 |
|
---|
[d2938f] | 240 | bool done = false;
|
---|
| 241 | while(!done){
|
---|
[16648f] | 242 | // create this vector
|
---|
| 243 | Vector helper;
|
---|
| 244 | for(int i=0;i<dims;++i){
|
---|
| 245 | switch(conditions[coords[i]]){
|
---|
[d66cb7] | 246 | case BoundaryConditions::Wrap:
|
---|
[16648f] | 247 | helper[coords[i]] = index[i]+translater[coords[i]];
|
---|
| 248 | break;
|
---|
[d66cb7] | 249 | case BoundaryConditions::Bounce:
|
---|
[16648f] | 250 | {
|
---|
| 251 | // Bouncing the coordinate x produces the series:
|
---|
| 252 | // 0 -> x
|
---|
| 253 | // 1 -> 2-x
|
---|
| 254 | // 2 -> 2+x
|
---|
| 255 | // 3 -> 4-x
|
---|
| 256 | // 4 -> 4+x
|
---|
| 257 | // the first number is the next bigger even number (n+n%2)
|
---|
| 258 | // the next number is the value with alternating sign (x-2*(n%2)*x)
|
---|
| 259 | // the negative numbers produce the same sequence reversed and shifted
|
---|
[d2938f] | 260 | int n = abs(index[i]) + ((index[i]<0)?-1:0);
|
---|
[16648f] | 261 | int sign = (index[i]<0)?-1:+1;
|
---|
| 262 | int even = n%2;
|
---|
| 263 | helper[coords[i]]=n+even+translater[coords[i]]-2*even*translater[coords[i]];
|
---|
| 264 | helper[coords[i]]*=sign;
|
---|
| 265 | }
|
---|
| 266 | break;
|
---|
[d66cb7] | 267 | case BoundaryConditions::Ignore:
|
---|
[16648f] | 268 | ASSERT(0,"Ignored coordinate handled in generation loop");
|
---|
[025048] | 269 | break;
|
---|
[16648f] | 270 | default:
|
---|
| 271 | ASSERT(0,"No default case for this switch-case");
|
---|
[025048] | 272 | break;
|
---|
[7ac4af] | 273 | }
|
---|
| 274 |
|
---|
[16648f] | 275 | }
|
---|
| 276 | // add back all ignored coordinates (not handled in above loop)
|
---|
| 277 | helper+=mask;
|
---|
[de29ad6] | 278 | ASSERT(list_index < internal_list.size(),
|
---|
| 279 | "Box::internal_explode() - we have estimated the number of vectors wrong: "
|
---|
| 280 | +toString(list_index) +" >= "+toString(internal_list.size())+".");
|
---|
| 281 | internal_list[list_index++] = translateIn(helper);
|
---|
[16648f] | 282 | // set the new indexes
|
---|
[d2938f] | 283 | int pos=0;
|
---|
[16648f] | 284 | ++index[pos];
|
---|
[d2938f] | 285 | while(index[pos]>n){
|
---|
[16648f] | 286 | index[pos++]=-n;
|
---|
[d2938f] | 287 | if(pos>=dims) { // it's trying to increase one beyond array... all vectors generated
|
---|
| 288 | done = true;
|
---|
| 289 | break;
|
---|
[7ac4af] | 290 | }
|
---|
[16648f] | 291 | ++index[pos];
|
---|
[7ac4af] | 292 | }
|
---|
| 293 | }
|
---|
| 294 | }
|
---|
| 295 |
|
---|
[de29ad6] | 296 | VECTORSET(std::vector) Box::explode(const Vector &point) const{
|
---|
[16648f] | 297 | ASSERT(isInside(point),"Exploded point not inside Box");
|
---|
| 298 | return explode(point,1);
|
---|
| 299 | }
|
---|
| 300 |
|
---|
[7b9fe0] | 301 | const Vector Box::periodicDistanceVector(const Vector &point1,const Vector &point2) const{
|
---|
[712886] | 302 | Vector helper1(enforceBoundaryConditions(point1));
|
---|
| 303 | Vector helper2(enforceBoundaryConditions(point2));
|
---|
[025048] | 304 | internal_explode(helper1,1);
|
---|
[7b9fe0] | 305 | const Vector res = internal_list.minDistance(helper2);
|
---|
[014475] | 306 | return res;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[7b9fe0] | 309 | double Box::periodicDistanceSquared(const Vector &point1,const Vector &point2) const{
|
---|
| 310 | const Vector res = periodicDistanceVector(point1, point2);
|
---|
| 311 | return res.NormSquared();
|
---|
| 312 | }
|
---|
| 313 |
|
---|
[014475] | 314 | double Box::periodicDistance(const Vector &point1,const Vector &point2) const{
|
---|
[7b9fe0] | 315 | double res = sqrt(periodicDistanceSquared(point1,point2));
|
---|
[014475] | 316 | return res;
|
---|
[527de2] | 317 | }
|
---|
| 318 |
|
---|
[66fd49] | 319 | double Box::DistanceToBoundary(const Vector &point) const
|
---|
| 320 | {
|
---|
| 321 | std::map<double, Plane> DistanceSet;
|
---|
| 322 | std::vector<std::pair<Plane,Plane> > Boundaries = getBoundingPlanes();
|
---|
| 323 | for (int i=0;i<NDIM;++i) {
|
---|
| 324 | const double tempres1 = Boundaries[i].first.distance(point);
|
---|
| 325 | const double tempres2 = Boundaries[i].second.distance(point);
|
---|
| 326 | DistanceSet.insert( make_pair(tempres1, Boundaries[i].first) );
|
---|
[47d041] | 327 | LOG(1, "Inserting distance " << tempres1 << " and " << tempres2 << ".");
|
---|
[66fd49] | 328 | DistanceSet.insert( make_pair(tempres2, Boundaries[i].second) );
|
---|
| 329 | }
|
---|
| 330 | ASSERT(!DistanceSet.empty(), "Box::DistanceToBoundary() - no distances in map!");
|
---|
| 331 | return (DistanceSet.begin())->first;
|
---|
| 332 | }
|
---|
| 333 |
|
---|
[c538d1] | 334 | Shape Box::getShape() const{
|
---|
| 335 | return transform(Cuboid(Vector(0,0,0),Vector(1,1,1)),(*M));
|
---|
[6c438f] | 336 | }
|
---|
| 337 |
|
---|
[c52e08] | 338 | const std::string Box::getConditionNames() const
|
---|
| 339 | {
|
---|
| 340 | std::stringstream outputstream;
|
---|
| 341 | outputstream << conditions;
|
---|
| 342 | return outputstream.str();
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | const BoundaryConditions::Conditions_t & Box::getConditions() const
|
---|
[66fd49] | 346 | {
|
---|
[d66cb7] | 347 | return conditions.get();
|
---|
[77374e] | 348 | }
|
---|
[c538d1] | 349 |
|
---|
[c52e08] | 350 | const BoundaryConditions::BoundaryCondition_t Box::getCondition(size_t i) const
|
---|
| 351 | {
|
---|
| 352 | return conditions.get(i);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | void Box::setCondition(size_t i, const BoundaryConditions::BoundaryCondition_t _condition)
|
---|
| 356 | {
|
---|
| 357 | OBSERVE;
|
---|
[d00370] | 358 | if (conditions.get(i) != _condition)
|
---|
| 359 | NOTIFY(BoundaryConditionsChanged);
|
---|
[c52e08] | 360 | conditions.set(i, _condition);
|
---|
| 361 | }
|
---|
| 362 |
|
---|
| 363 | void Box::setConditions(const BoundaryConditions::Conditions_t & _conditions)
|
---|
| 364 | {
|
---|
| 365 | OBSERVE;
|
---|
[d00370] | 366 | if (conditions.get() != _conditions)
|
---|
[c52e08] | 367 | NOTIFY(BoundaryConditionsChanged);
|
---|
| 368 | conditions.set(_conditions);
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | void Box::setConditions(const std::string & _conditions)
|
---|
[99f4ee] | 372 | {
|
---|
| 373 | OBSERVE;
|
---|
| 374 | NOTIFY(BoundaryConditionsChanged);
|
---|
[c52e08] | 375 | std::stringstream inputstream(_conditions);
|
---|
| 376 | inputstream >> conditions;
|
---|
[77374e] | 377 | }
|
---|
| 378 |
|
---|
[97f9b9] | 379 | void Box::setConditions(const std::vector< std::string >& _conditions)
|
---|
| 380 | {
|
---|
| 381 | OBSERVE;
|
---|
| 382 | NOTIFY(BoundaryConditionsChanged);
|
---|
| 383 | conditions.set(_conditions);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
[de29ad6] | 386 | const std::vector<std::pair<Plane,Plane> > Box::getBoundingPlanes() const
|
---|
[66fd49] | 387 | {
|
---|
[de29ad6] | 388 | std::vector<std::pair<Plane,Plane> > res;
|
---|
[29ac78] | 389 | for(int i=0;i<NDIM;++i){
|
---|
| 390 | Vector base1,base2,base3;
|
---|
| 391 | base2[(i+1)%NDIM] = 1.;
|
---|
| 392 | base3[(i+2)%NDIM] = 1.;
|
---|
| 393 | Plane p1(translateIn(base1),
|
---|
| 394 | translateIn(base2),
|
---|
| 395 | translateIn(base3));
|
---|
| 396 | Vector offset;
|
---|
| 397 | offset[i]=1;
|
---|
| 398 | Plane p2(translateIn(base1+offset),
|
---|
| 399 | translateIn(base2+offset),
|
---|
| 400 | translateIn(base3+offset));
|
---|
| 401 | res.push_back(make_pair(p1,p2));
|
---|
| 402 | }
|
---|
[66fd49] | 403 | ASSERT(res.size() == 3, "Box::getBoundingPlanes() - does not have three plane pairs!");
|
---|
[29ac78] | 404 | return res;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[99f4ee] | 407 | void Box::setCuboid(const Vector &endpoint)
|
---|
| 408 | {
|
---|
| 409 | OBSERVE;
|
---|
| 410 | NOTIFY(MatrixChanged);
|
---|
[e1ab97] | 411 | ASSERT(endpoint[0]>0 && endpoint[1]>0 && endpoint[2]>0,"Vector does not define a full cuboid");
|
---|
[9eb7580] | 412 | M->setIdentity();
|
---|
[e1ab97] | 413 | M->diagonal()=endpoint;
|
---|
| 414 | Vector &dinv = Minv->diagonal();
|
---|
| 415 | for(int i=NDIM;i--;)
|
---|
| 416 | dinv[i]=1/endpoint[i];
|
---|
[c538d1] | 417 | }
|
---|
| 418 |
|
---|
[99f4ee] | 419 | Box &Box::operator=(const Box &src)
|
---|
| 420 | {
|
---|
[7579a4b] | 421 | if(&src!=this){
|
---|
[99f4ee] | 422 | OBSERVE;
|
---|
| 423 | // new matrix
|
---|
| 424 | NOTIFY(MatrixChanged);
|
---|
[7579a4b] | 425 | delete M;
|
---|
| 426 | delete Minv;
|
---|
[cca9ef] | 427 | M = new RealSpaceMatrix(*src.M);
|
---|
| 428 | Minv = new RealSpaceMatrix(*src.Minv);
|
---|
[99f4ee] | 429 | // new boundary conditions
|
---|
| 430 | NOTIFY(BoundaryConditionsChanged);
|
---|
[77374e] | 431 | conditions = src.conditions;
|
---|
[7579a4b] | 432 | }
|
---|
| 433 | return *this;
|
---|
| 434 | }
|
---|
| 435 |
|
---|
[99f4ee] | 436 | Box &Box::operator=(const RealSpaceMatrix &mat)
|
---|
| 437 | {
|
---|
| 438 | OBSERVE;
|
---|
| 439 | NOTIFY(MatrixChanged);
|
---|
[7579a4b] | 440 | setM(mat);
|
---|
| 441 | return *this;
|
---|
| 442 | }
|
---|
[528b3e] | 443 |
|
---|
[de29ad6] | 444 | std::ostream & operator << (std::ostream& ost, const Box &m)
|
---|
[528b3e] | 445 | {
|
---|
| 446 | ost << m.getM();
|
---|
| 447 | return ost;
|
---|
| 448 | }
|
---|