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