/[escript]/trunk/finley/src/CPPAdapter/MeshAdapter.h
ViewVC logotype

Diff of /trunk/finley/src/CPPAdapter/MeshAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/finley/src/CPPAdapter/MeshAdapter.h revision 104 by jgs, Fri Dec 17 07:43:12 2004 UTC trunk/finley/src/CPPAdapter/MeshAdapter.h revision 1059 by gross, Fri Mar 23 11:01:53 2007 UTC
# Line 1  Line 1 
1  // $Id$  // $Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13                                                                                                                                                        
14  #if !defined  finley_MeshAdapter_20040526_H  #if !defined finley_MeshAdapter_20040526_H
15  #define finley_MeshAdapter_20040526_H  #define finley_MeshAdapter_20040526_H
16    #include "system_dep.h"
17    
 #include "escript/Data/AbstractContinuousDomain.h"  
 #include "escript/Data/Data.h"  
 #include "escript/Data/FunctionSpace.h"  
18  extern "C" {  extern "C" {
19  #include "finley/finleyC/Mesh.h"  #include "../Mesh.h"
20    #include "../Finley.h"
21    #include "../Assemble.h"
22    #include "paso/SystemMatrix.h"
23  }  }
24  #include "finley/CPPAdapter/SystemMatrixAdapter.h"  
25    #include "FinleyError.h"
26    #include "FinleyAdapterException.h"
27    
28    #include "SystemMatrixAdapter.h"
29    #include "escript/AbstractContinuousDomain.h"
30    #include "escript/FunctionSpace.h"
31    #include "escript/FunctionSpaceFactory.h"
32    
33  #include <boost/shared_ptr.hpp>  #include <boost/shared_ptr.hpp>
34  #include <boost/python/object.hpp>  #include <boost/python/dict.hpp>
35    #include <boost/python/extract.hpp>
36    
37  #include <map>  #include <map>
38  #include <vector>  #include <vector>
39  #include <string>  #include <string>
40    #include <sstream>
41    
42    //
43    // forward declarations
44    class Data;
45    
46    //using namespace escript;
47    
48  namespace finley {  namespace finley {
49    
50    struct null_deleter
51    {
52      void operator()(void const *ptr) const
53      {
54      }
55    };
56    
57    
58  /**  /**
59     \brief     \brief
60     MeshAdapter implements the AbstractContinuousDomain     MeshAdapter implements the AbstractContinuousDomain
# Line 41  namespace finley { Line 65  namespace finley {
65     interface for the Finley library.     interface for the Finley library.
66  */  */
67    
68  class MeshAdapter:public escript::AbstractContinuousDomain {  class MeshAdapter : public escript::AbstractContinuousDomain {
69    
70   public:   public:
71    
# Line 51  class MeshAdapter:public escript::Abstra Line 75  class MeshAdapter:public escript::Abstra
75    static const int ReducedDegreesOfFreedom;    static const int ReducedDegreesOfFreedom;
76    static const int Nodes;    static const int Nodes;
77    static const int Elements;    static const int Elements;
78      static const int ReducedElements;
79    static const int FaceElements;    static const int FaceElements;
80      static const int ReducedFaceElements;
81    static const int Points;    static const int Points;
82    static const int ContactElementsZero;    static const int ContactElementsZero;
83      static const int ReducedContactElementsZero;
84    static const int ContactElementsOne;    static const int ContactElementsOne;
85      static const int ReducedContactElementsOne;
86    
87    /**    /**
88       \brief       \brief
# Line 74  class MeshAdapter:public escript::Abstra Line 102  class MeshAdapter:public escript::Abstra
102                                 Finley_Mesh_deallocate in the MeshAdapter                                 Finley_Mesh_deallocate in the MeshAdapter
103                                 destructor.                                 destructor.
104    */    */
105      FINLEY_DLL_API
106    MeshAdapter(Finley_Mesh* finleyMesh=0);    MeshAdapter(Finley_Mesh* finleyMesh=0);
107    
108    /**    /**
109       \brief       \brief
110       Copy constructor.       Copy constructor.
111    */    */
112      FINLEY_DLL_API
113    MeshAdapter(const MeshAdapter& in);    MeshAdapter(const MeshAdapter& in);
114    
115    /**    /**
116       \brief       \brief
117       Destructor for MeshAdapter. As specified in the constructor       Destructor for MeshAdapter. As specified in the constructor
118       this calls  Finley_Mesh_deallocate for the pointer given to the       this calls Finley_Mesh_deallocate for the pointer given to the
119       constructor.       constructor.
120    */    */
121      FINLEY_DLL_API
122    ~MeshAdapter();    ~MeshAdapter();
123    
124    /**    /**
125       \brief       \brief
126       return this as an AbstractContinuousDomain.       return this as an AbstractContinuousDomain.
# Line 104  class MeshAdapter:public escript::Abstra Line 138  class MeshAdapter:public escript::Abstra
138    {    {
139       return *(static_cast<const AbstractDomain*>(this));       return *(static_cast<const AbstractDomain*>(this));
140    }    }
141    
142    /**    /**
143       \brief       \brief
144       Write the current mesh to a file with the given name.       Write the current mesh to a file with the given name.
145       \param fileName Input - The name of the file to write to.       \param fileName Input - The name of the file to write to.
146    */    */
147      FINLEY_DLL_API
148    void write(const std::string& fileName) const;    void write(const std::string& fileName) const;
149    
150    /**    /**
151       \brief       \brief
152       return the pointer of the underlying finley mesh structure       return the pointer to the underlying finley mesh structure
153    */    */
154      FINLEY_DLL_API
155    Finley_Mesh* getFinley_Mesh() const;    Finley_Mesh* getFinley_Mesh() const;
156    
157       /**
158         \brief
159         Return the tag key for the given sample number.
160         \param functionSpaceType Input - The function space type.
161         \param sampleNo Input - The sample number.
162      */
163      FINLEY_DLL_API
164      int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
165    
166    /**    /**
167       \brief       \brief
168       Return the tag list indexed by sampleNo.       Return the reference number of  the given sample number.
169       \param functionSpaceType Input       \param functionSpaceType Input - The function space type.
      \param tagList Output  
      \param numTags Output  
170    */    */
171      FINLEY_DLL_API
172      int* borrowSampleReferenceIDs(int functionSpaceType) const;
173    
   void getTagList(int functionSpaceType, int** tagList,  
                    int* numTags) const;  
174    /**    /**
175       \brief       \brief
176       Returns true if the given integer is a valid function space type       Returns true if the given integer is a valid function space type
177       for this domain.       for this domain.
178    */    */
179      FINLEY_DLL_API
180    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
181    
182    /**    /**
183       \brief       \brief
184       Return a description for this domain       Return a description for this domain
185    */    */
186      FINLEY_DLL_API
187    virtual std::string getDescription() const;    virtual std::string getDescription() const;
188    
189    /**    /**
190       \brief       \brief
191       Return a description for the given function space type code       Return a description for the given function space type code
192    */    */
193      FINLEY_DLL_API
194    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
195    /**  
      \brief  
      Return the tag key for the given sample number.  
      \param functionSpaceType Input - The function space type.  
      \param sampleNo Input - The sample number.  
   */  
   virtual int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;  
196    /**    /**
197       \brief       \brief
198       Build the table of function space type names       Build the table of function space type names
199    */    */
200      FINLEY_DLL_API
201    void setFunctionSpaceTypeNames();    void setFunctionSpaceTypeNames();
202    
203    /**    /**
204       \brief       \brief
205       Return a continuous FunctionSpace code       Return a continuous FunctionSpace code
206    */    */
207      FINLEY_DLL_API
208    virtual int getContinuousFunctionCode() const;    virtual int getContinuousFunctionCode() const;
209    
210    /**    /**
211       \brief       \brief
212       Return a functon FunctionSpace code       Return a function FunctionSpace code
213    */    */
214      FINLEY_DLL_API
215    virtual int getFunctionCode() const;    virtual int getFunctionCode() const;
216    
217      /**
218         \brief
219         Return a function with reduced integration order FunctionSpace code
220      */
221      FINLEY_DLL_API
222      virtual int getReducedFunctionCode() const;
223    
224    /**    /**
225       \brief       \brief
226       Return a function on boundary FunctionSpace code       Return a function on boundary FunctionSpace code
227    */    */
228      FINLEY_DLL_API
229    virtual int getFunctionOnBoundaryCode() const;    virtual int getFunctionOnBoundaryCode() const;
230    
231      /**
232         \brief
233         Return a function on boundary with reduced integration order FunctionSpace code
234      */
235      FINLEY_DLL_API
236      virtual int getReducedFunctionOnBoundaryCode() const;
237    
238    /**    /**
239       \brief       \brief
240       Return a FunctionOnContactZero code       Return a FunctionOnContactZero code
241    */    */
242      FINLEY_DLL_API
243    virtual int getFunctionOnContactZeroCode() const;    virtual int getFunctionOnContactZeroCode() const;
244    
245      /**
246         \brief
247         Return a FunctionOnContactZero code  with reduced integration order
248      */
249      FINLEY_DLL_API
250      virtual int getReducedFunctionOnContactZeroCode() const;
251    
252    /**    /**
253       \brief       \brief
254       Return a FunctionOnContactOne code       Return a FunctionOnContactOne code
255    */    */
256      FINLEY_DLL_API
257    virtual int getFunctionOnContactOneCode() const;    virtual int getFunctionOnContactOneCode() const;
258    
259      /**
260         \brief
261         Return a FunctionOnContactOne code  with reduced integration order
262      */
263      FINLEY_DLL_API
264      virtual int getReducedFunctionOnContactOneCode() const;
265    
266    /**    /**
267       \brief       \brief
268       Return a Solution code       Return a Solution code
269    */    */
270      FINLEY_DLL_API
271    virtual int getSolutionCode() const;    virtual int getSolutionCode() const;
272    
273    /**    /**
274       \brief       \brief
275       Return a ReducedSolution code       Return a ReducedSolution code
276    */    */
277      FINLEY_DLL_API
278    virtual int getReducedSolutionCode() const;    virtual int getReducedSolutionCode() const;
279    
280    /**    /**
281       \brief       \brief
282       Return a DiracDeltaFunction code       Return a DiracDeltaFunction code
283    */    */
284      FINLEY_DLL_API
285    virtual int getDiracDeltaFunctionCode() const;    virtual int getDiracDeltaFunctionCode() const;
286    //  
287    //    /**
288             5B
289         \brief
290      */
291    typedef std::map<int, std::string> FunctionSpaceNamesMapType;    typedef std::map<int, std::string> FunctionSpaceNamesMapType;
292    
293    /**    /**
294       \brief       \brief
295    */    */
296      FINLEY_DLL_API
297    virtual int getDim() const;    virtual int getDim() const;
298   /**  
299      /**
300       \brief       \brief
301       Return the number of data points per sample, and the number of samples as a pair.       Return the number of data points per sample, and the number of samples as a pair.
302       \param functionSpace Input -       \param functionSpaceCode Input -
303    */    */
304      FINLEY_DLL_API
305    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
306    
307    /**    /**
# Line 212  class MeshAdapter:public escript::Abstra Line 309  class MeshAdapter:public escript::Abstra
309       copies the location of data points into arg. The domain of arg has to match this.       copies the location of data points into arg. The domain of arg has to match this.
310       has to be implemented by the actual Domain adapter.       has to be implemented by the actual Domain adapter.
311    */    */
312      FINLEY_DLL_API
313    virtual void setToX(escript::Data& arg) const;    virtual void setToX(escript::Data& arg) const;
314    
315      /**
316         \brief
317         sets a map from a clear tag name to a tag key
318         \param name Input - tag name.
319         \param tag Input - tag key.
320      */
321      FINLEY_DLL_API
322      virtual void setTagMap(const std::string& name,  int tag);
323    
324      /**
325         \brief
326         Return the tag key for tag name.
327         \param name Input - tag name
328      */
329      FINLEY_DLL_API
330      virtual int getTag(const std::string& name) const;
331    
332      /**
333         \brief
334         Returns true if name is a defined tage name.
335         \param name Input - tag name to be checked.
336      */
337      FINLEY_DLL_API
338      virtual bool isValidTagName(const std::string& name) const;
339    
340      /**
341         \brief
342         Returns all tag names in a single string sperated by commas
343      */
344      FINLEY_DLL_API
345      virtual std::string showTagNames() const;
346    
347    /**    /**
348       \brief       \brief
349       assigns new location to the domain       assigns new location to the domain
350    */    */
351      FINLEY_DLL_API
352    virtual void setNewX(const escript::Data& arg);    virtual void setNewX(const escript::Data& arg);
353    
354    /**    /**
355       \brief       \brief
356       interpolates data given on source onto target where source and target have to be given on the same domain.       interpolates data given on source onto target where source and target have to be given on the same domain.
357    */    */
358      FINLEY_DLL_API
359    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
360      FINLEY_DLL_API
361    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
362    
363    /**    /**
364       \brief       \brief
365       interpolates data given on source onto target where source and target are given on different domains.       interpolates data given on source onto target where source and target are given on different domains.
366       has to be implemented by the actual Domain adapter.       has to be implemented by the actual Domain adapter.
367    */    */
368      FINLEY_DLL_API
369    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
370      FINLEY_DLL_API
371    virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;    virtual bool probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const;
372    
373    /**    /**
374       \brief       \brief
375       copies the surface normals at data points into out.  The actual function space to be considered       copies the surface normals at data points into out. The actual function space to be considered
376       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
377    */    */
378      FINLEY_DLL_API
379    virtual void setToNormal(escript::Data& out) const;    virtual void setToNormal(escript::Data& out) const;
380    
381    /**    /**
382       \brief       \brief
383       copies the size of samples into out. The actual function space to be considered       copies the size of samples into out. The actual function space to be considered
384       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
385    */    */
386      FINLEY_DLL_API
387    virtual void setToSize(escript::Data& out) const;    virtual void setToSize(escript::Data& out) const;
388    
389    /**    /**
# Line 249  class MeshAdapter:public escript::Abstra Line 391  class MeshAdapter:public escript::Abstra
391       copies the gradient of arg into grad. The actual function space to be considered       copies the gradient of arg into grad. The actual function space to be considered
392       for the gradient is defined by grad. arg and grad have to be defined on this.       for the gradient is defined by grad. arg and grad have to be defined on this.
393    */    */
394      FINLEY_DLL_API
395    virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;    virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
396    
397    /**    /**
# Line 256  class MeshAdapter:public escript::Abstra Line 399  class MeshAdapter:public escript::Abstra
399       copies the integrals of the function defined by arg into integrals.       copies the integrals of the function defined by arg into integrals.
400       arg has to be defined on this.       arg has to be defined on this.
401    */    */
402      FINLEY_DLL_API
403    virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;    virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
404    
405   /**    /**
406       \brief       \brief
407       return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, preconditioner       return the identifier of the matrix type to be used for the global stiffness matrix when a particular solver, package
408       and symmetric matrix is used.       and symmetric matrix is used.
409       \param solver       \param solver
410       \param symmetry       \param symmetry
411    */    */
412    virtual int getSystemMatrixTypeId(const int solver, const bool symmetry) const;    FINLEY_DLL_API
413      virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
414    
415    /**    /**
416       \brief       \brief
417       returns true if data on this domain and a function space of type functionSpaceCode has to       returns true if data on this domain and a function space of type functionSpaceCode has to
418       considered as cell centered data.       considered as cell centered data.
419    */    */
420      FINLEY_DLL_API
421    virtual bool isCellOriented(int functionSpaceCode) const;    virtual bool isCellOriented(int functionSpaceCode) const;
422    
423    /**    /**
424       \brief       \brief
425       saves data arg to a OpenDX input file.       Saves a dictonary of Data objects to an OpenDX input file. The keywords are used as identifier
426       considered as cell centered data.                                                                                                                                                                          
427         This has to be implemented by the actual Domain adapter.
428    */    */
429    virtual void saveDX(const std::string& filename,const escript::Data& arg) const;    FINLEY_DLL_API
430      virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
431    
432    
433      /**
434         \brief
435         Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
436                                                                                                                                                                            
437         This has to be implemented by the actual Domain adapter.
438      */
439      FINLEY_DLL_API
440      virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
441    
442    /**    /**
443       \brief       \brief
444       returns the function space representation of the type functionSpaceCode on this domain       returns the function space representation of the type functionSpaceCode on this domain
445       as a vtkObject.       as a vtkObject.
446    */    */
447    // vtkObject createVtkObject(int functionSpaceCode) const;    // vtkObject createVtkObject(int functionSpaceCode) const;
448    
449    /**    /**
450       \brief       \brief
451       adds a PDE onto the stiffness matrix mat and a rhs       adds a PDE onto the stiffness matrix mat and a rhs
452    */    */
453      FINLEY_DLL_API
454    virtual void addPDEToSystem(    virtual void addPDEToSystem(
455                       SystemMatrixAdapter& mat, escript::Data& rhs,                       SystemMatrixAdapter& mat, escript::Data& rhs,
456                       const escript::Data& A, const escript::Data& B, const escript::Data& C,                       const escript::Data& A, const escript::Data& B, const escript::Data& C,
457                       const escript::Data& D, const escript::Data& X, const escript::Data& Y,                       const escript::Data& D, const escript::Data& X, const escript::Data& Y,
458                       const escript::Data& d, const escript::Data& y,                       const escript::Data& d, const escript::Data& y,
459                       const escript::Data& d_contact, const escript::Data& y_contact) const;                       const escript::Data& d_contact, const escript::Data& y_contact) const;
460    
461    /**    /**
462       \brief       \brief
463       adds a PDE onto the stiffness matrix mat and a rhs       adds a PDE onto the stiffness matrix mat and a rhs
464    */    */
465      FINLEY_DLL_API
466    virtual void addPDEToRHS(escript::Data& rhs,    virtual void addPDEToRHS(escript::Data& rhs,
467                       const escript::Data& X, const escript::Data& Y,                       const escript::Data& X, const escript::Data& Y,
468                       const escript::Data& y, const escript::Data& y_contact) const;                       const escript::Data& y, const escript::Data& y_contact) const;
469    
470    /**    /**
471       \brief       \brief
472      creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:      creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
473    */    */
474      FINLEY_DLL_API
475    SystemMatrixAdapter newSystemMatrix(    SystemMatrixAdapter newSystemMatrix(
476                        const int row_blocksize,                        const int row_blocksize,
477                        const escript::FunctionSpace& row_functionspace,                        const escript::FunctionSpace& row_functionspace,
# Line 316  class MeshAdapter:public escript::Abstra Line 482  class MeshAdapter:public escript::Abstra
482    /**    /**
483       \brief returns locations in the FEM nodes       \brief returns locations in the FEM nodes
484    */    */
485      FINLEY_DLL_API
486    virtual escript::Data getX() const;    virtual escript::Data getX() const;
487    
488    /**    /**
489       \brief return boundary normals at the quadrature point on the face elements       \brief return boundary normals at the quadrature point on the face elements
490    */    */
491      FINLEY_DLL_API
492    virtual escript::Data getNormal() const;    virtual escript::Data getNormal() const;
493    
494    /**    /**
495       \brief returns the element size       \brief returns the element size
496    */    */
497      FINLEY_DLL_API
498    virtual escript::Data getSize() const;    virtual escript::Data getSize() const;
499    
500    bool operator==(const MeshAdapter& other) const;    /**
501    bool operator!=(const MeshAdapter& other) const;       \brief comparison operators
502      */
503      FINLEY_DLL_API
504      virtual bool operator==(const AbstractDomain& other) const;
505      FINLEY_DLL_API
506      virtual bool operator!=(const AbstractDomain& other) const;
507    
508      /**
509         \brief assigns new tag newTag to all samples of functionspace with a positive
510         value of mask for any its sample point.
511    
512      */
513      FINLEY_DLL_API
514      virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
515    
516   protected:   protected:
517    
518   private:   private:
519    
520    //    //
521    // pointer to the externally created finley mesh    // pointer to the externally created finley mesh
522    boost::shared_ptr<Finley_Mesh> m_finleyMesh;    boost::shared_ptr<Finley_Mesh> m_finleyMesh;
# Line 341  class MeshAdapter:public escript::Abstra Line 526  class MeshAdapter:public escript::Abstra
526  };  };
527    
528  } // end of namespace  } // end of namespace
529    
530  #endif  #endif

Legend:
Removed from v.104  
changed lines
  Added in v.1059

  ViewVC Help
Powered by ViewVC 1.1.26