Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
includeLinks/PatchDataUser.hpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
35 #ifndef PatchDataUser_hpp
36 #define PatchDataUser_hpp
37 
38 #include "Mesquite.hpp"
39 #include "MsqError.hpp"
40 #include "PatchData.hpp"
41 
42 #ifndef MSQ_USE_OLD_C_HEADERS
43 #include <cstddef>
44 #include <cstdlib>
45 #include <cstdio>
46 #else
47 #include <stddef.h>
48 #include <stdlib.h>
49 #include <stdio.h>
50 #endif
51 
52 
53 namespace Mesquite
54 {
55 
59  {
60  public:
62  mType(PatchData::UNDEFINED_PATCH_TYPE),
63  mParam1(0),
64  mParam2(0),
66  globalPatch(0)
67  {}
68 
70  mType = A.mType;
71  mParam1 = A.mParam1;
72  mParam2 = A.mParam2;
75  }
76 
77  friend class PatchDataUser;
78 
80 
84  inline void set_patch_type(PatchData::PatchType patch_type, MsqError &err,
85  int patch_param1=0, int patch_param2=0);
86 
89  {return mType;}
92  inline int get_nb_layers(MsqError &err);
93 
94  inline void set_global_patch_type();
95  inline void set_element_on_vertex_patch_type( unsigned num_layers );
96 
98  inline void add_culling_method(enum PatchData::culling_method cm);
100  inline void no_culling_method();
104  long unsigned int get_culling_method_bits() { return cullingMethodBits; }
105 
107  inline void set_global_patch(PatchData* pd, MsqError &err);
112  { return globalPatch; }
118  { globalPatch=0; }
119 
120 
121 
122  private:
125  long unsigned int cullingMethodBits;
127 
129  };
130 
131 
145  {
146  protected:
148  {}
149  public:
150  virtual ~PatchDataUser()
151  {}
152 
154  virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err,
155  int param1=0, int param2=0) {
156  mParams.set_patch_type(patch_type, err, param1, param2); }
159  return mParams.get_patch_type(); }
161  int get_nb_layers(MsqError &err) {
162  return mParams.get_nb_layers(err); }
163 
174  long unsigned int get_culling_method_bits() {
175  return mParams.get_culling_method_bits(); }
176 
179  { mParams = params; }
182  { return mParams; }
183 
186  { mParams.set_global_patch(pd, err); }
191  { return mParams.get_global_patch(); }
197  { mParams.no_global_patch(); }
198 
199 
200  // *** functions related to the algorithms, no to the patch parameters ***
202  virtual double loop_over_mesh(MeshSet &ms, MsqError &err) = 0;
204  virtual msq_std::string get_name() = 0;
207  virtual enum AlgorithmType get_algorithm_type() = 0;
208 
209  private:
211  };
212 
213 
220  MsqError &err,
221  int patch_param1,
222  int patch_param2)
223  {
224  // For now, no support for VERTICES_ON_ELEMENT_PATCH
225  if ( patch_type != PatchData::ELEMENTS_ON_VERTEX_PATCH
226  && patch_type != PatchData::GLOBAL_PATCH )
227  {
228  MSQ_SETERR(err)("VERTICES_ON_ELEMENT_PATCH not supported yet.",
230  return;
231  }
232 
233  if (patch_type == PatchData::ELEMENTS_ON_VERTEX_PATCH)
234  {
235  if (patch_param1 < 0)
236  {
237  MSQ_SETERR(err)("ELEMENTS_ON_VERTEX_PATCH not supported yet.",
239  return;
240  }
241  }
242 
243  mType = patch_type;
244  mParam1 = patch_param1;
245  mParam2 = patch_param2;
246 
247  return;
248  }
249 
251  {
253  }
254 
255  inline void PatchDataParameters::set_element_on_vertex_patch_type( unsigned num_layers )
256  {
258  mParam1 = num_layers;
259  }
260 
261 
263  {
265  MSQ_SETERR(err)("Patch Type is GLOBAL_PATCH.", MsqError::INVALID_STATE);
266  return 0;
267  }
268 
269  return mParam1;
270  }
271 
275  {
276  cullingMethodBits |= cm;
277  }
278 
282  {
283  cullingMethodBits = 0;
284  }
285 
289  {
290  cullingMethodBits &= ~cm;
291  }
292 
293 
295  {
297  MSQ_SETERR(err)("Trying to set a global patch whereas the "
298  "PatchType is set to something else\n."
299  "Consider using the function no_global_patch().",
301  else {
302  globalPatch = pd;
303  }
304  }
305 
306 
307 } // namespace
308 
309 #endif // PatchDataUser_hpp
void set_global_patch(PatchData *pd, MsqError &err)
Sets the Global Patch, so that it can be use by contiguoug PatchDataUser.
void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int patch_param1=0, int patch_param2=0)
Tells the MeshSet what kind of data the patches should include.
void add_culling_method(enum PatchData::culling_method cm)
Sets on the culling method passed as argument.
virtual void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int param1=0, int param2=0)
Sets the Patch Type.
long unsigned int cullingMethodBits
type of cullings are contained in this bitset.
Used to hold the error state and return it to the application.
PatchDataParameters & get_all_parameters()
Returns the PatchDataParameters object.
requested functionality is not (yet) implemented
void remove_culling_method(enum PatchData::culling_method cm)
Sets off the culling method passed as argument.
void add_culling_method(enum PatchData::culling_method cm)
Sets on a culling criterion.
This should be the parent class of all algorithms retrieving information from a MeshSet object...
long unsigned int get_culling_method_bits()
Returns the bitset containing culling methods flags.
void set_global_patch(PatchData *pd, MsqError &err)
Sets the Global Patch, so that it can be use by contiguoug PatchDataUser.
void set_all_parameters(PatchDataParameters &params)
PatchData * globalPatch
Allows storage of global patch through successive PatchDataUsers.
void no_global_patch()
Sets the Global Patch pointer to NULL.
PatchDataParameters(const PatchDataParameters &A)
PatchDataParameters mParams
Contains Patch parameters.
rational * A
Definition: vinci_lass.c:67
int get_nb_layers(MsqError &err)
Returns number of layers (if relevant for partition algorythm).
int get_nb_layers(MsqError &err)
Returns numbers of layers for local patch.
int mParam2
For general use in conjunction with PatchType.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
long unsigned int get_culling_method_bits()
returns the bitset.
PatchData::PatchType get_patch_type()
Returns the Patch Type.
PatchType
Tells MeshSet how to retrieve the mesh entities that will be stored in PatchData. ...
void no_culling_method()
No culling performed (sets off all culling criteria).
void remove_culling_method(enum PatchData::culling_method cm)
Sets off a certain culling criteria.
void set_element_on_vertex_patch_type(unsigned num_layers)
virtual msq_std::string get_name()=0
Returns the algorithm name.
PatchData * get_global_patch()
Returns the Global Patch.
virtual double loop_over_mesh(MeshSet &ms, MsqError &err)=0
This is the &quot;run&quot; function of PatchDataUser. It can do anything really.
PatchData::PatchType get_patch_type()
Returns Patch Type (local around vertices, local around elements, global)
void no_culling_method()
Sets off all culling methods.
object is in an invalid state
virtual enum AlgorithmType get_algorithm_type()=0
Return the algorithm type (to avoid RTTI use).
PatchData * get_global_patch()
Returns the Global Patch.
The MeshSet class stores one or more Mesquite::Mesh pointers and manages access to the mesh informati...
PatchData::PatchType mType
see the enum ...
void no_global_patch()
Sets the Global Patch pointer to NULL.