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 00018 #if !defined finley_MeshAdapter_20040526_H 00019 #define finley_MeshAdapter_20040526_H 00020 #include "system_dep.h" 00021 00022 #include "finley/Mesh.h" 00023 #include "finley/Finley.h" 00024 #include "finley/Assemble.h" 00025 #include "FinleyAdapterException.h" 00026 00027 #include <pasowrap/SystemMatrixAdapter.h> 00028 #include <pasowrap/TransportProblemAdapter.h> 00029 #include "escript/AbstractContinuousDomain.h" 00030 #include "escript/FunctionSpace.h" 00031 #include "escript/FunctionSpaceFactory.h" 00032 00033 #include <boost/shared_ptr.hpp> 00034 #include <boost/python/dict.hpp> 00035 #include <boost/python/extract.hpp> 00036 00037 #include <map> 00038 #include <vector> 00039 #include <string> 00040 #include <sstream> 00041 00042 namespace finley { 00043 00044 // These are friends implemented in MeshAdapterFactory.cpp 00045 // They are only fwd declared here so that vis.studio will accept the friend 00046 // decls 00047 FINLEY_DLL_API 00048 escript::Domain_ptr brick(int n0, int n1, int n2, int order, 00049 double l0, double l1, double l2, 00050 bool periodic0, bool periodic1, bool periodic2, 00051 int integrationOrder, int reducedIntegrationOrder, 00052 bool useElementsOnFace, bool useFullElementOrder, 00053 bool optimize, const std::vector<double>& points, 00054 const std::vector<int>& tags, 00055 const std::map<std::string, int>& tagnamestonums); 00056 00057 FINLEY_DLL_API 00058 escript::Domain_ptr rectangle(int n0, int n1, int order, 00059 double l0, double l1, 00060 bool periodic0, bool periodic1, 00061 int integrationOrder, int reducedIntegrationOrder, 00062 bool useElementsOnFace, bool useFullElementOrder, 00063 bool optimize, const std::vector<double>& points, 00064 const std::vector<int>& tags, 00065 const std::map<std::string, int>& tagnamestonums); 00066 00067 struct null_deleter 00068 { 00069 void operator()(void const *ptr) const 00070 { 00071 } 00072 }; 00073 00074 00080 class MeshAdapter : public escript::AbstractContinuousDomain { 00081 00082 public: 00083 00084 // 00085 // Codes for function space types supported 00086 static const int DegreesOfFreedom; 00087 static const int ReducedDegreesOfFreedom; 00088 static const int Nodes; 00089 static const int ReducedNodes; 00090 static const int Elements; 00091 static const int ReducedElements; 00092 static const int FaceElements; 00093 static const int ReducedFaceElements; 00094 static const int Points; 00095 static const int ContactElementsZero; 00096 static const int ReducedContactElementsZero; 00097 static const int ContactElementsOne; 00098 static const int ReducedContactElementsOne; 00099 00118 FINLEY_DLL_API 00119 MeshAdapter(Mesh* finleyMesh=0); 00120 00125 FINLEY_DLL_API 00126 MeshAdapter(const MeshAdapter& in); 00127 00134 FINLEY_DLL_API 00135 ~MeshAdapter(); 00136 00141 FINLEY_DLL_API 00142 virtual int getMPISize() const; 00148 FINLEY_DLL_API 00149 virtual int getMPIRank() const; 00150 00156 FINLEY_DLL_API 00157 virtual void MPIBarrier() const; 00158 00164 FINLEY_DLL_API 00165 virtual bool onMasterProcessor() const; 00166 00167 FINLEY_DLL_API 00168 #ifdef ESYS_MPI 00169 MPI_Comm 00170 #else 00171 unsigned int 00172 #endif 00173 getMPIComm() const; 00174 00180 FINLEY_DLL_API 00181 void write(const std::string& fileName) const; 00182 00187 FINLEY_DLL_API 00188 void Print_Mesh_Info(const bool full=false) const; 00189 00195 FINLEY_DLL_API 00196 void dump(const std::string& fileName) const; 00197 00202 FINLEY_DLL_API 00203 Mesh* getFinley_Mesh() const; 00204 00211 FINLEY_DLL_API 00212 int getTagFromSampleNo(int functionSpaceType, int sampleNo) const; 00213 00219 FINLEY_DLL_API 00220 const int* borrowSampleReferenceIDs(int functionSpaceType) const; 00221 00227 FINLEY_DLL_API 00228 virtual bool isValidFunctionSpaceType(int functionSpaceType) const; 00229 00234 FINLEY_DLL_API 00235 virtual std::string getDescription() const; 00236 00241 FINLEY_DLL_API 00242 virtual std::string functionSpaceTypeAsString(int functionSpaceType) const; 00243 00248 FINLEY_DLL_API 00249 void setFunctionSpaceTypeNames(); 00250 00255 FINLEY_DLL_API 00256 virtual int getContinuousFunctionCode() const; 00257 00262 FINLEY_DLL_API 00263 virtual int getReducedContinuousFunctionCode() const; 00264 00269 FINLEY_DLL_API 00270 virtual int getFunctionCode() const; 00271 00276 FINLEY_DLL_API 00277 virtual int getReducedFunctionCode() const; 00278 00283 FINLEY_DLL_API 00284 virtual int getFunctionOnBoundaryCode() const; 00285 00290 FINLEY_DLL_API 00291 virtual int getReducedFunctionOnBoundaryCode() const; 00292 00297 FINLEY_DLL_API 00298 virtual int getFunctionOnContactZeroCode() const; 00299 00304 FINLEY_DLL_API 00305 virtual int getReducedFunctionOnContactZeroCode() const; 00306 00311 FINLEY_DLL_API 00312 virtual int getFunctionOnContactOneCode() const; 00313 00318 FINLEY_DLL_API 00319 virtual int getReducedFunctionOnContactOneCode() const; 00320 00325 FINLEY_DLL_API 00326 virtual int getSolutionCode() const; 00327 00332 FINLEY_DLL_API 00333 virtual int getReducedSolutionCode() const; 00334 00339 FINLEY_DLL_API 00340 virtual int getDiracDeltaFunctionsCode() const; 00341 00345 typedef std::map<int, std::string> FunctionSpaceNamesMapType; 00346 00350 FINLEY_DLL_API 00351 virtual int getDim() const; 00352 00361 FINLEY_DLL_API 00362 virtual StatusType getStatus() const; 00363 00364 00369 FINLEY_DLL_API 00370 virtual int getNumDataPointsGlobal() const; 00371 00377 FINLEY_DLL_API 00378 virtual std::pair<int,int> getDataShape(int functionSpaceCode) const; 00379 00385 FINLEY_DLL_API 00386 virtual void setToX(escript::Data& arg) const; 00387 00394 FINLEY_DLL_API 00395 virtual void setTagMap(const std::string& name, int tag); 00396 00402 FINLEY_DLL_API 00403 virtual int getTag(const std::string& name) const; 00404 00410 FINLEY_DLL_API 00411 virtual bool isValidTagName(const std::string& name) const; 00412 00417 FINLEY_DLL_API 00418 virtual std::string showTagNames() const; 00419 00424 FINLEY_DLL_API 00425 virtual void setNewX(const escript::Data& arg); 00426 00431 FINLEY_DLL_API 00432 virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const; 00433 00434 00435 FINLEY_DLL_API 00436 virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const; 00437 00438 FINLEY_DLL_API 00439 virtual signed char preferredInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const; 00440 00441 00442 00447 FINLEY_DLL_API 00448 bool 00449 commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const; 00450 00456 FINLEY_DLL_API 00457 virtual void interpolateACross(escript::Data& target, const escript::Data& source) const; 00458 00463 FINLEY_DLL_API 00464 virtual bool probeInterpolationACross(int functionSpaceType_source,const escript::AbstractDomain& targetDomain, int functionSpaceType_target) const; 00465 00471 FINLEY_DLL_API 00472 virtual void setToNormal(escript::Data& out) const; 00473 00479 FINLEY_DLL_API 00480 virtual void setToSize(escript::Data& out) const; 00481 00487 FINLEY_DLL_API 00488 virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const; 00489 00495 FINLEY_DLL_API 00496 virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const; 00497 00507 FINLEY_DLL_API 00508 virtual int getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const; 00509 00519 FINLEY_DLL_API 00520 virtual int getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const; 00521 00527 FINLEY_DLL_API 00528 virtual bool isCellOriented(int functionSpaceCode) const; 00529 00530 00531 FINLEY_DLL_API 00532 virtual bool ownSample(int fs_code, index_t id) const; 00533 00539 // vtkObject createVtkObject(int functionSpaceCode) const; 00540 00545 FINLEY_DLL_API 00546 virtual void addPDEToSystem( 00547 escript::AbstractSystemMatrix& mat, escript::Data& rhs, 00548 const escript::Data& A, const escript::Data& B, const escript::Data& C, 00549 const escript::Data& D, const escript::Data& X, const escript::Data& Y, 00550 const escript::Data& d, const escript::Data& y, 00551 const escript::Data& d_contact, const escript::Data& y_contact, 00552 const escript::Data& d_dirac, const escript::Data& y_dirac) const; 00557 FINLEY_DLL_API 00558 virtual void addPDEToLumpedSystem( 00559 escript::Data& mat, 00560 const escript::Data& D, 00561 const escript::Data& d, 00562 const escript::Data& d_dirac, 00563 const bool useHRZ) const; 00564 00569 FINLEY_DLL_API 00570 virtual void addPDEToRHS(escript::Data& rhs, 00571 const escript::Data& X, const escript::Data& Y, 00572 const escript::Data& y, const escript::Data& y_contact, const escript::Data& y_dirac) const; 00578 FINLEY_DLL_API 00579 virtual void addPDEToTransportProblem( 00580 escript::AbstractTransportProblem& tp, escript::Data& source, 00581 const escript::Data& M, 00582 const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D, 00583 const escript::Data& X,const escript::Data& Y, 00584 const escript::Data& d, const escript::Data& y, 00585 const escript::Data& d_contact,const escript::Data& y_contact, const escript::Data& d_dirac,const escript::Data& y_dirac) const; 00586 00587 00592 FINLEY_DLL_API 00593 escript::ASM_ptr newSystemMatrix( 00594 const int row_blocksize, 00595 const escript::FunctionSpace& row_functionspace, 00596 const int column_blocksize, 00597 const escript::FunctionSpace& column_functionspace, 00598 const int type) const; 00605 FINLEY_DLL_API 00606 escript::ATP_ptr newTransportProblem( 00607 const int blocksize, 00608 const escript::FunctionSpace& functionspace, 00609 const int type) const; 00610 00614 FINLEY_DLL_API 00615 virtual escript::Data getX() const; 00616 00620 FINLEY_DLL_API 00621 virtual escript::Data getNormal() const; 00622 00626 FINLEY_DLL_API 00627 virtual escript::Data getSize() const; 00628 00632 FINLEY_DLL_API 00633 virtual bool operator==(const escript::AbstractDomain& other) const; 00634 FINLEY_DLL_API 00635 virtual bool operator!=(const escript::AbstractDomain& other) const; 00636 00642 FINLEY_DLL_API 00643 virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const; 00644 00649 FINLEY_DLL_API 00650 virtual int getNumberOfTagsInUse(int functionSpaceCode) const; 00651 00652 FINLEY_DLL_API 00653 virtual const int* borrowListOfTagsInUse(int functionSpaceCode) const; 00654 00655 00659 FINLEY_DLL_API 00660 virtual 00661 bool canTag(int functionSpaceCode) const; 00662 00667 FINLEY_DLL_API 00668 virtual 00669 int getApproximationOrder(const int functionSpaceCode) const; 00670 00671 FINLEY_DLL_API 00672 bool supportsContactElements() const; 00673 00674 00675 FINLEY_DLL_API 00676 virtual escript::Data randomFill(const escript::DataTypes::ShapeType& shape, 00677 const escript::FunctionSpace& what, long seed, const boost::python::tuple& filter) const; 00678 00679 00680 private: 00681 00688 FINLEY_DLL_API 00689 void addDiracPoints( const std::vector<double>& points, const std::vector<int>& tags) const; 00690 // FINLEY_DLL_API 00691 // void addDiracPoint( const boost::python::list& points, const int tag=-1) const; 00692 // FINLEY_DLL_API 00693 // void addDiracPointWithTagName( const boost::python::list& points, const std::string& tag) const; 00694 00695 protected: 00696 00697 private: 00698 // 00699 // pointer to the externally created finley mesh 00700 boost::shared_ptr<Mesh> m_finleyMesh; 00701 00702 // This is only provided so that the friends below can add tags during construction 00703 // do not use for any other purpose 00704 boost::shared_ptr<Mesh> getMesh() 00705 { 00706 return m_finleyMesh; 00707 } 00708 00709 static FunctionSpaceNamesMapType m_functionSpaceTypeNames; 00710 00711 friend escript::Domain_ptr brick(int n0, int n1, int n2, int order, 00712 double l0, double l1, double l2, 00713 bool periodic0, bool periodic1, bool periodic2, 00714 int integrationOrder, 00715 int reducedIntegrationOrder, 00716 bool useElementsOnFace, 00717 bool useFullElementOrder, 00718 bool optimize, 00719 const std::vector<double>& points, 00720 const std::vector<int>& tags, 00721 const std::map<std::string, int>& tagnamestonums); 00722 00723 00724 friend escript::Domain_ptr rectangle(int n0, int n1, int order, 00725 double l0, double l1, 00726 bool periodic0, bool periodic1, 00727 int integrationOrder, 00728 int reducedIntegrationOrder, 00729 bool useElementsOnFace, 00730 bool useFullElementOrder, 00731 bool optimize, 00732 const std::vector<double>& points, 00733 const std::vector<int>& tags, 00734 const std::map<std::string, int>& tagnamestonums); 00735 }; 00736 00737 00738 } // end of namespace 00739 00740 #endif 00741