/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * CubeMesh.cpp * * Created on: Jan 20, 2012 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include #include #include "CodePatterns/Log.hpp" #include "CubeMesh.hpp" #include "LinearAlgebra/RealSpaceMatrix.hpp" #include "LinearAlgebra/Vector.hpp" /** Constructor for class CubeMesh. * * Here, we generate nodes homogeneously distributed over a cuboid. * * \a offset shifts the coordinates, e.g. if counts = 2, we would set nodes at * 0 and 0.5 with offset = 0 and 0.4999... and 0.9999.. with offset = 0.999... * * @param counts number of points per axis * @param offset offset Vector (coordinates in [0,1)) * @param M matrix to transform the default cuboid from (0,0,0) to (1,1,1). */ CubeMesh::CubeMesh(const Vector &counts, const Vector &offset, const RealSpaceMatrix &M) { #ifndef NDEBUG for (size_t i=0;i= 0.) && (offset[i] < 1.), "CubeMesh::CubeMesh() - offset coordinates must be in [0,1) but offset[" +toString(i)+"] is "+toString(offset[i])+"."); ASSERT(counts[i] == (int)counts[i], "CubeMesh::CubeMesh() - counts["+toString(i)+"] must be integer: != "+toString(counts[i])+"."); } #endif std::vector< unsigned int> size_counts; for (size_t i=0;i &counts, const Vector &offset, const RealSpaceMatrix &M) { ASSERT(counts.size() == 3, "CubeMesh::CubeMesh() - counts does not have three but " +toString(counts.size())+" entries."); init(counts, offset, M); } void CubeMesh::init(const std::vector< unsigned int > &counts, const Vector &offset, const RealSpaceMatrix &M) { RealSpaceMatrix partition; partition.setZero(); for(int i=0;i