escript
Revision_
|
00001 00002 /***************************************************************************** 00003 * 00004 * Copyright (c) 2003-2014 by University of Queensland 00005 * http://www.uq.edu.au 00006 * 00007 * Primary Business: Queensland, Australia 00008 * Licensed under the Open Software License version 3.0 00009 * http://www.opensource.org/licenses/osl-3.0.php 00010 * 00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC) 00012 * Development 2012-2013 by School of Earth Sciences 00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp) 00014 * 00015 *****************************************************************************/ 00016 00017 #ifndef __RIPLEY_RECTANGLE_H__ 00018 #define __RIPLEY_RECTANGLE_H__ 00019 00020 #include <paso/Coupler.h> 00021 #include <ripley/RipleyDomain.h> 00022 00023 namespace ripley { 00024 00029 class RIPLEY_DLL_API Rectangle: public RipleyDomain 00030 { 00031 public: 00032 00040 Rectangle(int n0, int n1, double x0, double y0, double x1, double y1, 00041 int d0=-1, int d1=-1, 00042 const std::vector<double>& points = std::vector<double>(), 00043 const std::vector<int>& tags = std::vector<int>(), 00044 const simap_t& tagnamestonums = simap_t()); 00045 00050 ~Rectangle(); 00051 00056 virtual std::string getDescription() const; 00057 00061 virtual bool operator==(const escript::AbstractDomain& other) const; 00062 00068 void dump(const std::string& filename) const; 00069 00072 virtual void readNcGrid(escript::Data& out, std::string filename, 00073 std::string varname, const ReaderParameters& params) const; 00074 00077 virtual void readBinaryGrid(escript::Data& out, std::string filename, 00078 const ReaderParameters& params) const; 00079 #ifdef USE_BOOSTIO 00080 00082 virtual void readBinaryGridFromZipped(escript::Data& out, std::string filename, 00083 const ReaderParameters& params) const; 00084 #endif 00085 00088 virtual void writeBinaryGrid(const escript::Data& in, 00089 std::string filename, 00090 int byteOrder, int dataType) const; 00091 00097 const int* borrowSampleReferenceIDs(int fsType) const; 00098 00103 virtual bool ownSample(int fs_code, index_t id) const; 00104 00111 virtual void setToNormal(escript::Data& out) const; 00112 00118 virtual void setToSize(escript::Data& out) const; 00119 00124 virtual int getNumDataPointsGlobal() const; 00125 00131 virtual void Print_Mesh_Info(const bool full=false) const; 00132 00137 virtual const int* getNumNodesPerDim() const { return m_NN; } 00138 00143 virtual const int* getNumElementsPerDim() const { return m_NE; } 00144 00150 virtual const int* getNumFacesPerBoundary() const { return m_faceCount; } 00151 00156 virtual IndexVector getNodeDistribution() const { return m_nodeDistribution; } 00157 00162 virtual const int* getNumSubdivisionsPerDim() const { return m_NX; } 00163 00168 virtual double getLocalCoordinate(int index, int dim) const; 00169 00174 virtual boost::python::tuple getGridParameters() const; 00175 00180 virtual escript::Data randomFill(const escript::DataTypes::ShapeType& shape, 00181 const escript::FunctionSpace& what, long seed, const boost::python::tuple& filter) const; 00182 00183 00188 virtual void setAssembler(std::string type, std::map<std::string, escript::Data> options); 00189 00190 00191 protected: 00192 virtual dim_t getNumNodes() const; 00193 virtual dim_t getNumElements() const; 00194 virtual dim_t getNumFaceElements() const; 00195 virtual dim_t getNumDOF() const; 00196 virtual dim_t insertNeighbourNodes(IndexVector& index, index_t node) const; 00197 virtual void assembleCoordinates(escript::Data& arg) const; 00198 virtual void assembleGradient(escript::Data& out, 00199 const escript::Data& in) const; 00200 virtual void assembleIntegrate(DoubleVector& integrals, 00201 const escript::Data& arg) const; 00202 virtual paso::SystemMatrixPattern_ptr getPattern(bool reducedRowOrder, bool reducedColOrder) const; 00203 virtual void interpolateNodesOnElements(escript::Data& out, 00204 const escript::Data& in, bool reduced) const; 00205 virtual void interpolateNodesOnFaces(escript::Data& out, 00206 const escript::Data& in, 00207 bool reduced) const; 00208 virtual void nodesToDOF(escript::Data& out, const escript::Data& in) const; 00209 virtual void dofToNodes(escript::Data& out, const escript::Data& in) const; 00210 virtual int getDofOfNode(int node) const; 00211 00212 private: 00213 void populateSampleIds(); 00214 void createPattern(); 00215 void addToMatrixAndRHS(paso::SystemMatrix_ptr S, escript::Data& F, 00216 const DoubleVector& EM_S, const DoubleVector& EM_F, 00217 bool addS, bool addF, int firstNode, int nEq=1, int nComp=1) const; 00218 00219 template<typename ValueType> 00220 void readBinaryGridImpl(escript::Data& out, const std::string& filename, 00221 const ReaderParameters& params) const; 00222 00223 template<typename ValueType> 00224 void readBinaryGridZippedImpl(escript::Data& out, 00225 const std::string& filename, const ReaderParameters& params) const; 00226 00227 template<typename ValueType> 00228 void writeBinaryGridImpl(const escript::Data& in, 00229 const std::string& filename, int byteOrder) const; 00230 00231 int findNode(const double *coords) const; 00232 00233 00234 escript::Data randomFillWorker(const escript::DataTypes::ShapeType& shape, 00235 long seed, const boost::python::tuple& filter) const; 00236 00238 dim_t m_gNE[2]; 00239 00241 double m_origin[2]; 00242 00244 double m_length[2]; 00245 00247 double m_dx[2]; 00248 00250 dim_t m_NX[2]; 00251 00253 dim_t m_NE[2]; 00254 00256 dim_t m_ownNE[2]; 00257 00259 dim_t m_NN[2]; 00260 00262 dim_t m_offset[2]; 00263 00265 int m_faceCount[4]; 00266 00269 IndexVector m_faceOffset; 00270 00272 IndexVector m_dofId; 00273 IndexVector m_nodeId; 00274 IndexVector m_elementId; 00275 IndexVector m_faceId; 00276 00277 // vector with first node id on each rank 00278 IndexVector m_nodeDistribution; 00279 00280 // vector that maps each node to a DOF index (used for the coupler) 00281 IndexVector m_dofMap; 00282 00283 // Paso connector used by the system matrix and to interpolate DOF to 00284 // nodes 00285 paso::Connector_ptr m_connector; 00286 00287 // the Paso System Matrix pattern 00288 paso::SystemMatrixPattern_ptr m_pattern; 00289 00290 friend class DefaultAssembler2D; 00291 friend class WaveAssembler2D; 00292 friend class LameAssembler2D; 00293 }; 00294 00296 inline int Rectangle::getDofOfNode(int node) const { 00297 return m_dofMap[node]; 00298 } 00299 00300 inline int Rectangle::getNumDataPointsGlobal() const 00301 { 00302 return (m_gNE[0]+1)*(m_gNE[1]+1); 00303 } 00304 00305 inline double Rectangle::getLocalCoordinate(int index, int dim) const 00306 { 00307 EsysAssert((dim>=0 && dim<2), "'dim' out of bounds"); 00308 EsysAssert((index>=0 && index<m_NN[dim]), "'index' out of bounds"); 00309 return m_origin[dim]+m_dx[dim]*(m_offset[dim]+index); 00310 } 00311 00312 inline boost::python::tuple Rectangle::getGridParameters() const 00313 { 00314 return boost::python::make_tuple( 00315 boost::python::make_tuple(m_origin[0], m_origin[1]), 00316 boost::python::make_tuple(m_dx[0], m_dx[1]), 00317 boost::python::make_tuple(m_gNE[0], m_gNE[1])); 00318 } 00319 00320 inline paso::SystemMatrixPattern_ptr Rectangle::getPattern(bool reducedRowOrder, 00321 bool reducedColOrder) const 00322 { 00323 // TODO: reduced 00324 return m_pattern; 00325 } 00326 00327 00328 //protected 00329 inline dim_t Rectangle::getNumDOF() const 00330 { 00331 return (m_gNE[0]+1)/m_NX[0]*(m_gNE[1]+1)/m_NX[1]; 00332 } 00333 00334 //protected 00335 inline dim_t Rectangle::getNumNodes() const 00336 { 00337 return m_NN[0]*m_NN[1]; 00338 } 00339 00340 //protected 00341 inline dim_t Rectangle::getNumElements() const 00342 { 00343 return m_NE[0]*m_NE[1]; 00344 } 00345 00346 //protected 00347 inline dim_t Rectangle::getNumFaceElements() const 00348 { 00349 return m_faceCount[0] + m_faceCount[1] + m_faceCount[2] + m_faceCount[3]; 00350 } 00351 00352 00353 } // end of namespace ripley 00354 00355 #endif // __RIPLEY_RECTANGLE_H__ 00356