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

Diff of /temp_trunk_copy/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 767 by gross, Fri Jun 30 07:29:08 2006 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 74  class MeshAdapter:public escript::Abstra Line 98  class MeshAdapter:public escript::Abstra
98                                 Finley_Mesh_deallocate in the MeshAdapter                                 Finley_Mesh_deallocate in the MeshAdapter
99                                 destructor.                                 destructor.
100    */    */
101      FINLEY_DLL_API
102    MeshAdapter(Finley_Mesh* finleyMesh=0);    MeshAdapter(Finley_Mesh* finleyMesh=0);
103    
104    /**    /**
105       \brief       \brief
106       Copy constructor.       Copy constructor.
107    */    */
108      FINLEY_DLL_API
109    MeshAdapter(const MeshAdapter& in);    MeshAdapter(const MeshAdapter& in);
110    
111    /**    /**
112       \brief       \brief
113       Destructor for MeshAdapter. As specified in the constructor       Destructor for MeshAdapter. As specified in the constructor
114       this calls  Finley_Mesh_deallocate for the pointer given to the       this calls Finley_Mesh_deallocate for the pointer given to the
115       constructor.       constructor.
116    */    */
117      FINLEY_DLL_API
118    ~MeshAdapter();    ~MeshAdapter();
119    
120    /**    /**
121       \brief       \brief
122       return this as an AbstractContinuousDomain.       return this as an AbstractContinuousDomain.
# Line 104  class MeshAdapter:public escript::Abstra Line 134  class MeshAdapter:public escript::Abstra
134    {    {
135       return *(static_cast<const AbstractDomain*>(this));       return *(static_cast<const AbstractDomain*>(this));
136    }    }
137    
138    /**    /**
139       \brief       \brief
140       Write the current mesh to a file with the given name.       Write the current mesh to a file with the given name.
141       \param fileName Input - The name of the file to write to.       \param fileName Input - The name of the file to write to.
142    */    */
143      FINLEY_DLL_API
144    void write(const std::string& fileName) const;    void write(const std::string& fileName) const;
145    
146    /**    /**
147       \brief       \brief
148       return the pointer of the underlying finley mesh structure       return the pointer to the underlying finley mesh structure
149    */    */
150      FINLEY_DLL_API
151    Finley_Mesh* getFinley_Mesh() const;    Finley_Mesh* getFinley_Mesh() const;
152    
153       /**
154         \brief
155         Return the tag key for the given sample number.
156         \param functionSpaceType Input - The function space type.
157         \param sampleNo Input - The sample number.
158      */
159      FINLEY_DLL_API
160      int getTagFromSampleNo(int functionSpaceType, int sampleNo) const;
161    
162    /**    /**
163       \brief       \brief
164       Return the tag list indexed by sampleNo.       Return the reference number of  the given sample number.
165       \param functionSpaceType Input       \param functionSpaceType Input - The function space type.
166       \param tagList Output       \param sampleNo Input - The sample number.
      \param numTags Output  
167    */    */
168      FINLEY_DLL_API
169      int getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const;
170    
   void getTagList(int functionSpaceType, int** tagList,  
                    int* numTags) const;  
171    /**    /**
172       \brief       \brief
173       Returns true if the given integer is a valid function space type       Returns true if the given integer is a valid function space type
174       for this domain.       for this domain.
175    */    */
176      FINLEY_DLL_API
177    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;    virtual bool isValidFunctionSpaceType(int functionSpaceType) const;
178    
179    /**    /**
180       \brief       \brief
181       Return a description for this domain       Return a description for this domain
182    */    */
183      FINLEY_DLL_API
184    virtual std::string getDescription() const;    virtual std::string getDescription() const;
185    
186    /**    /**
187       \brief       \brief
188       Return a description for the given function space type code       Return a description for the given function space type code
189    */    */
190      FINLEY_DLL_API
191    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;    virtual std::string functionSpaceTypeAsString(int functionSpaceType) const;
192    /**  
      \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;  
193    /**    /**
194       \brief       \brief
195       Build the table of function space type names       Build the table of function space type names
196    */    */
197      FINLEY_DLL_API
198    void setFunctionSpaceTypeNames();    void setFunctionSpaceTypeNames();
199    
200    /**    /**
201       \brief       \brief
202       Return a continuous FunctionSpace code       Return a continuous FunctionSpace code
203    */    */
204      FINLEY_DLL_API
205    virtual int getContinuousFunctionCode() const;    virtual int getContinuousFunctionCode() const;
206    
207    /**    /**
208       \brief       \brief
209       Return a functon FunctionSpace code       Return a functon FunctionSpace code
210    */    */
211      FINLEY_DLL_API
212    virtual int getFunctionCode() const;    virtual int getFunctionCode() const;
213    
214    /**    /**
215       \brief       \brief
216       Return a function on boundary FunctionSpace code       Return a function on boundary FunctionSpace code
217    */    */
218      FINLEY_DLL_API
219    virtual int getFunctionOnBoundaryCode() const;    virtual int getFunctionOnBoundaryCode() const;
220    
221    /**    /**
222       \brief       \brief
223       Return a FunctionOnContactZero code       Return a FunctionOnContactZero code
224    */    */
225      FINLEY_DLL_API
226    virtual int getFunctionOnContactZeroCode() const;    virtual int getFunctionOnContactZeroCode() const;
227    
228    /**    /**
229       \brief       \brief
230       Return a FunctionOnContactOne code       Return a FunctionOnContactOne code
231    */    */
232      FINLEY_DLL_API
233    virtual int getFunctionOnContactOneCode() const;    virtual int getFunctionOnContactOneCode() const;
234    
235    /**    /**
236       \brief       \brief
237       Return a Solution code       Return a Solution code
238    */    */
239      FINLEY_DLL_API
240    virtual int getSolutionCode() const;    virtual int getSolutionCode() const;
241    
242    /**    /**
243       \brief       \brief
244       Return a ReducedSolution code       Return a ReducedSolution code
245    */    */
246      FINLEY_DLL_API
247    virtual int getReducedSolutionCode() const;    virtual int getReducedSolutionCode() const;
248    
249    /**    /**
250       \brief       \brief
251       Return a DiracDeltaFunction code       Return a DiracDeltaFunction code
252    */    */
253      FINLEY_DLL_API
254    virtual int getDiracDeltaFunctionCode() const;    virtual int getDiracDeltaFunctionCode() const;
255    //  
256    //    /**
257         \brief
258      */
259    typedef std::map<int, std::string> FunctionSpaceNamesMapType;    typedef std::map<int, std::string> FunctionSpaceNamesMapType;
260    
261    /**    /**
262       \brief       \brief
263    */    */
264      FINLEY_DLL_API
265    virtual int getDim() const;    virtual int getDim() const;
266   /**  
267      /**
268       \brief       \brief
269       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.
270       \param functionSpace Input -       \param functionSpaceCode Input -
271    */    */
272      FINLEY_DLL_API
273    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;    virtual std::pair<int,int> getDataShape(int functionSpaceCode) const;
274    
275    /**    /**
# Line 212  class MeshAdapter:public escript::Abstra Line 277  class MeshAdapter:public escript::Abstra
277       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.
278       has to be implemented by the actual Domain adapter.       has to be implemented by the actual Domain adapter.
279    */    */
280      FINLEY_DLL_API
281    virtual void setToX(escript::Data& arg) const;    virtual void setToX(escript::Data& arg) const;
282    
283    /**    /**
284       \brief       \brief
285       assigns new location to the domain       assigns new location to the domain
286    */    */
287      FINLEY_DLL_API
288    virtual void setNewX(const escript::Data& arg);    virtual void setNewX(const escript::Data& arg);
289    
290    /**    /**
291       \brief       \brief
292       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.
293    */    */
294      FINLEY_DLL_API
295    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;    virtual void interpolateOnDomain(escript::Data& target,const escript::Data& source) const;
296      FINLEY_DLL_API
297    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;    virtual bool probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const;
298    
299    /**    /**
300       \brief       \brief
301       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.
302       has to be implemented by the actual Domain adapter.       has to be implemented by the actual Domain adapter.
303    */    */
304      FINLEY_DLL_API
305    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;    virtual void interpolateACross(escript::Data& target, const escript::Data& source) const;
306      FINLEY_DLL_API
307    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;
308    
309    /**    /**
310       \brief       \brief
311       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
312       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
313    */    */
314      FINLEY_DLL_API
315    virtual void setToNormal(escript::Data& out) const;    virtual void setToNormal(escript::Data& out) const;
316    
317    /**    /**
318       \brief       \brief
319       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
320       is defined by out. out has to be defined on this.       is defined by out. out has to be defined on this.
321    */    */
322      FINLEY_DLL_API
323    virtual void setToSize(escript::Data& out) const;    virtual void setToSize(escript::Data& out) const;
324    
325    /**    /**
# Line 249  class MeshAdapter:public escript::Abstra Line 327  class MeshAdapter:public escript::Abstra
327       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
328       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.
329    */    */
330      FINLEY_DLL_API
331    virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;    virtual void setToGradient(escript::Data& grad,const escript::Data& arg) const;
332    
333    /**    /**
# Line 256  class MeshAdapter:public escript::Abstra Line 335  class MeshAdapter:public escript::Abstra
335       copies the integrals of the function defined by arg into integrals.       copies the integrals of the function defined by arg into integrals.
336       arg has to be defined on this.       arg has to be defined on this.
337    */    */
338      FINLEY_DLL_API
339    virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;    virtual void setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const;
340    
341   /**    /**
342       \brief       \brief
343       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
344       and symmetric matrix is used.       and symmetric matrix is used.
345       \param solver       \param solver
346       \param symmetry       \param symmetry
347    */    */
348    virtual int getSystemMatrixTypeId(const int solver, const bool symmetry) const;    FINLEY_DLL_API
349      virtual int getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const;
350    
351    /**    /**
352       \brief       \brief
353       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
354       considered as cell centered data.       considered as cell centered data.
355    */    */
356      FINLEY_DLL_API
357    virtual bool isCellOriented(int functionSpaceCode) const;    virtual bool isCellOriented(int functionSpaceCode) const;
358    
359    /**    /**
360       \brief       \brief
361       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
362       considered as cell centered data.                                                                                                                                                                          
363         This has to be implemented by the actual Domain adapter.
364    */    */
365    virtual void saveDX(const std::string& filename,const escript::Data& arg) const;    FINLEY_DLL_API
366      virtual void saveDX(const std::string& filename,const boost::python::dict& arg) const;
367    
368    
369      /**
370         \brief
371         Saves a dictonary of Data objects to an VTK XML input file. The keywords are used as identifier
372                                                                                                                                                                            
373         This has to be implemented by the actual Domain adapter.
374      */
375      FINLEY_DLL_API
376      virtual void saveVTK(const std::string& filename,const boost::python::dict& arg) const;
377    
378    /**    /**
379       \brief       \brief
380       returns the function space representation of the type functionSpaceCode on this domain       returns the function space representation of the type functionSpaceCode on this domain
381       as a vtkObject.       as a vtkObject.
382    */    */
383    // vtkObject createVtkObject(int functionSpaceCode) const;    // vtkObject createVtkObject(int functionSpaceCode) const;
384    
385    /**    /**
386       \brief       \brief
387       adds a PDE onto the stiffness matrix mat and a rhs       adds a PDE onto the stiffness matrix mat and a rhs
388    */    */
389      FINLEY_DLL_API
390    virtual void addPDEToSystem(    virtual void addPDEToSystem(
391                       SystemMatrixAdapter& mat, escript::Data& rhs,                       SystemMatrixAdapter& mat, escript::Data& rhs,
392                       const escript::Data& A, const escript::Data& B, const escript::Data& C,                       const escript::Data& A, const escript::Data& B, const escript::Data& C,
393                       const escript::Data& D, const escript::Data& X, const escript::Data& Y,                       const escript::Data& D, const escript::Data& X, const escript::Data& Y,
394                       const escript::Data& d, const escript::Data& y,                       const escript::Data& d, const escript::Data& y,
395                       const escript::Data& d_contact, const escript::Data& y_contact) const;                       const escript::Data& d_contact, const escript::Data& y_contact) const;
396    
397    /**    /**
398       \brief       \brief
399       adds a PDE onto the stiffness matrix mat and a rhs       adds a PDE onto the stiffness matrix mat and a rhs
400    */    */
401      FINLEY_DLL_API
402    virtual void addPDEToRHS(escript::Data& rhs,    virtual void addPDEToRHS(escript::Data& rhs,
403                       const escript::Data& X, const escript::Data& Y,                       const escript::Data& X, const escript::Data& Y,
404                       const escript::Data& y, const escript::Data& y_contact) const;                       const escript::Data& y, const escript::Data& y_contact) const;
405    
406    /**    /**
407       \brief       \brief
408      creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:      creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
409    */    */
410      FINLEY_DLL_API
411    SystemMatrixAdapter newSystemMatrix(    SystemMatrixAdapter newSystemMatrix(
412                        const int row_blocksize,                        const int row_blocksize,
413                        const escript::FunctionSpace& row_functionspace,                        const escript::FunctionSpace& row_functionspace,
# Line 316  class MeshAdapter:public escript::Abstra Line 418  class MeshAdapter:public escript::Abstra
418    /**    /**
419       \brief returns locations in the FEM nodes       \brief returns locations in the FEM nodes
420    */    */
421      FINLEY_DLL_API
422    virtual escript::Data getX() const;    virtual escript::Data getX() const;
423    
424    /**    /**
425       \brief return boundary normals at the quadrature point on the face elements       \brief return boundary normals at the quadrature point on the face elements
426    */    */
427      FINLEY_DLL_API
428    virtual escript::Data getNormal() const;    virtual escript::Data getNormal() const;
429    
430    /**    /**
431       \brief returns the element size       \brief returns the element size
432    */    */
433      FINLEY_DLL_API
434    virtual escript::Data getSize() const;    virtual escript::Data getSize() const;
435    
436    bool operator==(const MeshAdapter& other) const;    /**
437    bool operator!=(const MeshAdapter& other) const;       \brief comparison operators
438      */
439      FINLEY_DLL_API
440      virtual bool operator==(const AbstractDomain& other) const;
441      FINLEY_DLL_API
442      virtual bool operator!=(const AbstractDomain& other) const;
443    
444      /**
445         \brief assigns new tag newTag to all samples of functionspace with a positive
446         value of mask for any its sample point.
447    
448      */
449      FINLEY_DLL_API
450      virtual void setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const;
451    
452   protected:   protected:
453    
454   private:   private:
455    
456    //    //
457    // pointer to the externally created finley mesh    // pointer to the externally created finley mesh
458    boost::shared_ptr<Finley_Mesh> m_finleyMesh;    boost::shared_ptr<Finley_Mesh> m_finleyMesh;
# Line 341  class MeshAdapter:public escript::Abstra Line 462  class MeshAdapter:public escript::Abstra
462  };  };
463    
464  } // end of namespace  } // end of namespace
465    
466  #endif  #endif

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

  ViewVC Help
Powered by ViewVC 1.1.26