Parallel Finite Element - General geometry Ewald-like Method
Part of Continuum-particle Simulation Suite under MICCOM
pm_toolbox.h
Go to the documentation of this file.
1 // Parallel Finite Element-General Geometry Ewald-like Method.
2 // Copyright (C) 2015-2016 Xujun Zhao, Jiyuan Li, Xikai Jiang
3 
4 // This code is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 
10 // This code is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 
15 
16 // You should have received a copy of the GNU General Public
17 // License along with this code; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20 
21 
22 #pragma once
23 // C++ Includes
24 #include <sstream>
25 #include <iostream>
26 #include <iomanip>
27 #include <algorithm>
28 #include <vector>
29 #include <cstring>
30 #include <math.h>
31 
32 
33 // LibMesh library includes
34 //#include "libmesh/petsc_macro.h"
35 //#include "libmesh/libmesh_common.h"
36 #include "libmesh/libmesh.h" // define PI
37 #include "libmesh/point.h"
38 #include "libmesh/mesh.h"
39 #include "libmesh/serial_mesh.h"
40 
41 // dense matrix help to debug
42 #include "libmesh/dense_matrix.h"
43 #include "libmesh/dense_vector.h"
44 #include "libmesh/dense_submatrix.h"
45 #include "libmesh/dense_subvector.h"
46 #include "libmesh/parallel_object.h"
47 
48 // Bring in everything from the libMesh namespace
49 using namespace libMesh;
50 
51 
52 
53 /*
54  this class defines basic tools used in our codes
55  */
56 class PMToolBox
57 {
58 public:
59 
60  // quadratic function used for applying BC to avoid singularities at corners
61  static Real quadratic_function_2d(const Real& y,
62  const Real& YA, const Real& YB);
63 
64  static Real quadratic_function_3d(const Real& y, const Real& z,
65  const Real& YA, const Real& YB,
66  const Real& ZA, const Real& ZB);
67 
68 
69  static void output_dense_matrix(const DenseMatrix<Number>& Ke);
70 
71  static void output_dense_matrix(const DenseMatrix<Number>& Ke,
72  const unsigned int m,
73  const unsigned int n);
74 
75  static void output_dense_vector(const DenseVector<Number>& Fe);
76 
77  static void output_dense_vector(const DenseVector<Number>& Fe,
78  const unsigned int n);
79 
80  static void output_subdense_matrix(const DenseSubMatrix<Number>& Ke,
81  const unsigned int m,
82  const unsigned int n);
83 
84  static void output_subdense_vector(const DenseSubVector<Number>& Fe,
85  const unsigned int n);
86 
87  template <typename T>
88  static void output_std_vector(const std::vector<T>& std_v);
89 
90 
91  static void zero_filter_dense_matrix(DenseMatrix<Number>& Ae, const Real tol);
92  static void zero_filter_dense_vector(DenseVector<Number>& Ve, const Real tol);
93 
94 
95  /*
96  * Check if a file exists or not.
97  */
98  static bool file_exist(const std::string& filename);
99 
100 
101  /*
102  * Rotation matrix for rotating angle = [ alpha, beta, theta ]
103  * for x, y and z directions
104  */
105  static void coordinate_rotation(Point& pt,
106  const Point& angles);
107 
108  /*
109  * Output a message on the screen
110  */
111  static void output_message(const std::string& msg,
112  const Parallel::Communicator & comm_in);
113 
114  /*
115  * Compute the min/max element size of a mesh.
116  */
117  static std::vector<Real> mesh_size(const MeshBase& _mesh);
118 
119 
120  /*
121  * Magnify mesh in the x/y/z directions according to the mag_factor
122  */
123  static void magnify_serial_mesh(SerialMesh& mesh,
124  const Point& mag_factor);
125 
126 
127  /*
128  * Rotate mesh in the x/y/z axis according to the angles
129  */
130  static void rotate_serial_mesh(SerialMesh& mesh,
131  const Point& angles);
132 
133 
134  /*
135  * shift mesh in the x/y/z dirction according to a given distance
136  */
137  static void shift_serial_mesh(SerialMesh& mesh,
138  const std::vector<Real>& dist);
139 
140 };
Definition: brownian_system.h:58
Definition: pm_toolbox.h:56