libMesh
Public Member Functions | Protected Attributes | List of all members
libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction Class Reference

This object is passed to MeshTools::Modification::redistribute() to redistribute the points on a uniform grid into the Gauss-Lobatto points on the actual grid. More...

Inheritance diagram for libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction:
[legend]

Public Member Functions

 GaussLobattoRedistributionFunction (unsigned int nx, Real xmin, Real xmax, unsigned int ny=0, Real ymin=0, Real ymax=0, unsigned int nz=0, Real zmin=0, Real zmax=0)
 Constructor class base class ctor with NULL master. More...
 
virtual UniquePtr< FunctionBase< Real > > clone () const
 We must provide a way to clone ourselves to satisfy the pure virtual interface. More...
 
virtual void operator() (const Point &p, const Real, DenseVector< Real > &output) libmesh_override
 This is the actual function that MeshTools::Modification::redistribute() calls. More...
 
virtual Real operator() (const Point &, const Real)
 We must also override operator() which returns a Real, but this function should never be called, so it's left unimplemented. More...
 
virtual void init ()
 The actual initialization process. More...
 
virtual void clear ()
 Clears the function. More...
 
void operator() (const Point &p, DenseVector< Real > &output)
 Evaluation function for time-independent vector-valued functions. More...
 
virtual Real component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 Function to set whether this is a time-dependent function or not. More...
 
bool is_time_dependent () const
 

Protected Attributes

std::vector< Real_mins
 
std::vector< unsigned int_nelem
 
std::vector< Real_widths
 
std::vector< std::vector< Real > > _cosines
 
const FunctionBase_master
 Const pointer to our master, initialized to NULL. More...
 
bool _initialized
 When init() was called so that everything is ready for calls to operator() (...), then this bool is true. More...
 
bool _is_time_dependent
 Cache whether or not this function is actually time-dependent. More...
 

Detailed Description

This object is passed to MeshTools::Modification::redistribute() to redistribute the points on a uniform grid into the Gauss-Lobatto points on the actual grid.

Definition at line 143 of file mesh_generation.C.

Constructor & Destructor Documentation

libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::GaussLobattoRedistributionFunction ( unsigned int  nx,
Real  xmin,
Real  xmax,
unsigned int  ny = 0,
Real  ymin = 0,
Real  ymax = 0,
unsigned int  nz = 0,
Real  zmin = 0,
Real  zmax = 0 
)

Constructor class base class ctor with NULL master.

Definition at line 149 of file mesh_generation.C.

References _cosines, _mins, _nelem, _widths, and libMesh::pi.

Referenced by libMesh::MeshTools::Generation::build_cube(), and clone().

157  :
158  FunctionBase<Real>(libmesh_nullptr)
159  {
160  _nelem.resize(3);
161  _nelem[0] = nx;
162  _nelem[1] = ny;
163  _nelem[2] = nz;
164 
165  _mins.resize(3);
166  _mins[0] = xmin;
167  _mins[1] = ymin;
168  _mins[2] = zmin;
169 
170  _widths.resize(3);
171  _widths[0] = xmax - xmin;
172  _widths[1] = ymax - ymin;
173  _widths[2] = zmax - zmin;
174 
175  // Precompute the cosine values.
176  _cosines.resize(3);
177  for (unsigned dir=0; dir<3; ++dir)
178  if (_nelem[dir] != 0)
179  {
180  _cosines[dir].resize(_nelem[dir]+1);
181  for (std::size_t i=0; i<_cosines[dir].size(); ++i)
182  _cosines[dir][i] = std::cos(libMesh::pi * i / _nelem[dir]);
183  }
184  }
const class libmesh_nullptr_t libmesh_nullptr
const Real pi
.
Definition: libmesh.h:172

Member Function Documentation

virtual void libMesh::FunctionBase< Real >::clear ( )
virtualinherited
virtual UniquePtr<FunctionBase<Real> > libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::clone ( ) const
virtual

We must provide a way to clone ourselves to satisfy the pure virtual interface.

We use the autogenerated copy constructor.

Implements libMesh::FunctionBase< Real >.

Definition at line 190 of file mesh_generation.C.

References GaussLobattoRedistributionFunction().

191  {
192  return UniquePtr<FunctionBase<Real>> (new GaussLobattoRedistributionFunction(*this));
193  }
GaussLobattoRedistributionFunction(unsigned int nx, Real xmin, Real xmax, unsigned int ny=0, Real ymin=0, Real ymax=0, unsigned int nz=0, Real zmin=0, Real zmax=0)
Constructor class base class ctor with NULL master.
virtual Real libMesh::FunctionBase< Real >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
)
virtualinherited
Returns
The vector component i at coordinate p and time time.
Note
Subclasses aren't required to override this, since the default implementation is based on the full vector evaluation, which is often correct.
Subclasses are recommended to override this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.
virtual void libMesh::FunctionBase< Real >::init ( )
virtualinherited

The actual initialization process.

Definition at line 81 of file function_base.h.

81 {}
bool libMesh::FunctionBase< Real >::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.
bool libMesh::FunctionBase< Real >::is_time_dependent ( ) const
inherited
Returns
true when the function this object represents is actually time-dependent, false otherwise.
void libMesh::FunctionBase< Real >::operator() ( const Point p,
DenseVector< Real > &  output 
)
inherited

Evaluation function for time-independent vector-valued functions.

Sets output values in the passed-in output DenseVector.

virtual void libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::operator() ( const Point p,
const Real  ,
DenseVector< Real > &  output 
)
virtual

This is the actual function that MeshTools::Modification::redistribute() calls.

Moves the points of the grid to the Gauss-Lobatto points.

Implements libMesh::FunctionBase< Real >.

Definition at line 200 of file mesh_generation.C.

References _cosines, _mins, _nelem, _widths, std::abs(), libMesh::Real, and libMesh::TOLERANCE.

203  {
204  output.resize(3);
205 
206  for (unsigned dir=0; dir<3; ++dir)
207  if (_nelem[dir] != 0)
208  {
209  // Figure out the index of the current point.
210  Real float_index = (p(dir) - _mins[dir]) * _nelem[dir] / _widths[dir];
211 
212  // std::modf separates the fractional and integer parts of the index.
213  Real integer_part = 0;
214  Real fractional_part = std::modf(float_index, &integer_part);
215 
216  // Vertex node?
217  if (std::abs(fractional_part) < TOLERANCE || std::abs(fractional_part - 1.0) < TOLERANCE)
218  {
219  int index = round(float_index);
220 
221  // Move node to the Gauss-Lobatto position.
222  output(dir) = _mins[dir] + _widths[dir] * 0.5 * (1.0 - _cosines[dir][index]);
223  }
224 
225  // Mid-edge (quadratic) node?
226  else if (std::abs(fractional_part - 0.5) < TOLERANCE)
227  {
228  // Move node to the Gauss-Lobatto position, which is the average of
229  // the node to the left and the node to the right.
230  output(dir) = _mins[dir] + _widths[dir] * 0.5 *
231  (1.0 - 0.5*(_cosines[dir][integer_part] + _cosines[dir][integer_part+1]));
232  }
233 
234  // 1D only: Left interior (cubic) node?
235  else if (std::abs(fractional_part - 1./3.) < TOLERANCE)
236  {
237  // Move node to the Gauss-Lobatto position, which is
238  // 2/3*left_vertex + 1/3*right_vertex.
239  output(dir) = _mins[dir] + _widths[dir] * 0.5 *
240  (1.0 - 2./3.*_cosines[dir][integer_part] - 1./3.*_cosines[dir][integer_part+1]);
241  }
242 
243  // 1D only: Right interior (cubic) node?
244  else if (std::abs(fractional_part - 2./3.) < TOLERANCE)
245  {
246  // Move node to the Gauss-Lobatto position, which is
247  // 1/3*left_vertex + 2/3*right_vertex.
248  output(dir) = _mins[dir] + _widths[dir] * 0.5 *
249  (1.0 - 1./3.*_cosines[dir][integer_part] - 2./3.*_cosines[dir][integer_part+1]);
250  }
251 
252  else
253  libmesh_error_msg("Cannot redistribute node: " << p);
254  }
255  }
double abs(double a)
static const Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::operator() ( const Point ,
const Real   
)
virtual

We must also override operator() which returns a Real, but this function should never be called, so it's left unimplemented.

Implements libMesh::FunctionBase< Real >.

Definition at line 261 of file mesh_generation.C.

263  {
264  libmesh_not_implemented();
265  }
void libMesh::FunctionBase< Real >::set_is_time_dependent ( bool  is_time_dependent)
inherited

Function to set whether this is a time-dependent function or not.

This is intended to be only used by subclasses who cannot natively determine time-dependence. In such a case, this function should be used immediately following construction.

Member Data Documentation

std::vector<std::vector<Real> > libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::_cosines
protected

Definition at line 274 of file mesh_generation.C.

Referenced by GaussLobattoRedistributionFunction(), and operator()().

bool libMesh::FunctionBase< Real >::_initialized
protectedinherited

When init() was called so that everything is ready for calls to operator() (...), then this bool is true.

Definition at line 174 of file function_base.h.

bool libMesh::FunctionBase< Real >::_is_time_dependent
protectedinherited

Cache whether or not this function is actually time-dependent.

Definition at line 179 of file function_base.h.

const FunctionBase* libMesh::FunctionBase< Real >::_master
protectedinherited

Const pointer to our master, initialized to NULL.

There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.

Definition at line 168 of file function_base.h.

std::vector<Real> libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::_mins
protected

Definition at line 269 of file mesh_generation.C.

Referenced by GaussLobattoRedistributionFunction(), and operator()().

std::vector<unsigned int> libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::_nelem
protected

Definition at line 270 of file mesh_generation.C.

Referenced by GaussLobattoRedistributionFunction(), and operator()().

std::vector<Real> libMesh::MeshTools::Generation::Private::GaussLobattoRedistributionFunction::_widths
protected

Definition at line 271 of file mesh_generation.C.

Referenced by GaussLobattoRedistributionFunction(), and operator()().


The documentation for this class was generated from the following file: