56 std::size_t maxIndex(0);
58 for ( std::size_t node = 0; node < mesh.
get_nnodes(); ++node ) {
60 if ( std::abs(mesh(node,var)) > max ) {
62 max = std::abs( mesh(node,var) );
65 if ( ( maxIndex == 0 ) || ( maxIndex == mesh.
get_nnodes()-1 ) ) {
66 std::cout <<
"[WARNING] MaxAbsLocationRange: maximumum absolute nodal value is first/last node. \n";
67 return mesh.
coord( maxIndex );
71 f1 = std::abs(mesh(maxIndex-1,var));
72 f2 = std::abs(mesh(maxIndex,var));
73 f3 = std::abs(mesh(maxIndex+1,var));
74 x1 = mesh.
coord(maxIndex-1);
75 x2 = mesh.
coord(maxIndex);
76 x3 = mesh.
coord(maxIndex+1);
77 return ( f1*(x2+x3)/((x1-x2)*(x1-x3)) + f2*(x1+x3)/((x2-x1)*(x2-x3)) + f3*(x1+x2)/((x3-x1)*(x3-x2)) )
78 / ( 2.*f1/((x1-x2)*(x1-x3)) + 2.*f2/((x2-x1)*(x2-x3)) + 2.*f3/((x3-x1)*(x3-x2)) );
84 std::size_t maxIndex(0);
86 for ( std::size_t node = 0; node < mesh.
get_nnodes(); ++node ) {
88 if ( ( mesh.
coord(node) >= left ) && ( mesh.
coord(node) <= right ) ) {
89 if ( std::abs(mesh(node,var)) > max ) {
91 max = std::abs( mesh(node,var) );
95 if ( ( maxIndex == 0 ) || ( maxIndex == mesh.
get_nnodes()-1 ) ) {
96 std::cout <<
"[WARNING] MaxAbsLocationRange: maximumum absolute nodal value is first/last node. \n";
97 return mesh.
coord( maxIndex );
101 f1 = std::abs(mesh(maxIndex-1,var));
102 f2 = std::abs(mesh(maxIndex,var));
103 f3 = std::abs(mesh(maxIndex+1,var));
104 x1 = mesh.
coord(maxIndex-1);
105 x2 = mesh.
coord(maxIndex);
106 x3 = mesh.
coord(maxIndex+1);
107 return ( f1*(x2+x3)/((x1-x2)*(x1-x3)) + f2*(x1+x3)/((x2-x1)*(x2-x3)) + f3*(x1+x2)/((x3-x1)*(x3-x2)) )
108 / ( 2.*f1/((x1-x2)*(x1-x3)) + 2.*f2/((x2-x1)*(x2-x3)) + 2.*f3/((x3-x1)*(x3-x2)) );
116 const double delta = (upper - lower) / (N - 1);
117 for(std::size_t i = 0; i < N; ++i) {
118 V.push_back(lower + delta * i);
125 for(std::size_t i = 0; i < N; ++i) {
126 V[ i ] = lower + (upper - lower) * std::pow((
double)i / (N - 1), power);
135 for(std::size_t i = 1; i < N2+1; ++i) {
146 for(std::size_t i = 1; i < N2+1; ++i) {
149 for(std::size_t i = 1; i < N3+1; ++i) {
158 for(std::size_t i = 0; i < N; ++i) {
159 double s(-1.0 + 2.0 * i / (N - 1));
160 node_vector[ i ] = (weight * std::pow(s, 3) + s) / (weight + 1);
163 for(std::size_t i = 0; i < N; ++i) {
165 node_vector[ i ] += 1.0;
167 node_vector[ i ] /= 2.0;
169 node_vector[ i ] *= (upper - lower);
170 node_vector[ i ] += lower;
179 for(std::size_t i = 0; i < X.
size(); ++i) {
180 temp[ i ] = X[ i ].real();
187 for(std::size_t i = 0; i < X.
size(); ++i) {
188 temp[ i ] = X[ i ].imag();
194 std::stringstream temp;
200 std::stringstream temp;
228 problem =
"The Utilities::multiply method has been called\n";
229 problem +=
"but the compiler option -DLAPACK was not provided when\n";
230 problem +=
"the library was built. This non-member function requires BLAS.";
234 std::size_t M = A.nrows();
235 std::size_t N = B.
ncols();
236 std::size_t K = A.ncols();
245 std::string problem(
" The LAPACK::multiply method has detected a failure \n");
251 BLAS_DGEMM((
char*)
"N", (
char*)
"N", N, M, K, 1.0, Bf.
base(), N, Af.
base(), K, 0.0, Cf.
base(), N);
The collection of CppNoddy exceptions.
Some interface definitions for calling external fortran routines from BLAS.
#define BLAS_DGEMM(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
The BLAS DOUBLE dot-product Fortran interface : FUNCTION DDOT(N,X,INCX,Y,INCY)
A spec for a collection of utility functions.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
std::size_t nrows() const
std::size_t ncols() const
An DenseVector class – a dense vector object.
void push_back(const _Type &fill)
A pass-thru definition of push_back.
std::size_t size() const
A pass-thru definition to get the size of the vector.
An exception to indicate that an error has been detected in an external (LAPACK) routine.
An exception class to be thrown when a container of incorrect geometry used in any class/method.
A little (legacy) utility class for passing CppNoddy containers to Fortran library routines.
DenseMatrix< double > to_dense_matrix(std::size_t rows, std::size_t cols)
Convert the data to a double dense format.
double * base()
Get the pointer to the first element.
A one dimensional mesh utility object.
const _Xtype & coord(const std::size_t &node) const
Access a nodal position.
std::size_t get_nnodes() const
DenseVector< double > real(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the real part of a complex DENSE vector.
DenseMatrix< double > multiply(DenseMatrix< double > &A, DenseMatrix< double > &B)
BLAS wrapper to do DOUBLE DENSE A_{MxK} * B_{KxN} = C_{MxN} Since this is a Fortran library,...
DenseVector< double > three_uniform_node_vector(const double &lower, const double &mid1, const double &mid2, const double &upper, const std::size_t &N1, const std::size_t &N2, const std::size_t &N3)
Return a dense vector with two uniform distributions in two separate regions.
DenseVector< double > power_node_vector(const double &lower, const double &upper, const std::size_t &N, const double &power)
Return a DENSE vector with the nodal points of a non-uniform mesh distributed between the upper/lower...
DenseVector< double > mid_weighted_node_vector(const double &lower, const double &upper, const std::size_t &N, const double &power)
Return a dense vector of nodal positions with more nodes concentrated at the mid point of the range.
DenseVector< double > two_uniform_node_vector(const double &lower, const double &mid, const double &upper, const std::size_t &N1, const std::size_t &N2)
Return a dense vector with two uniform distributions in two separate regions.
double max_abs_location(OneD_Node_Mesh< double > &mesh, unsigned var)
DenseVector< double > imag(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the imaginary part of a complex DENSE vector.
double max_abs_location_range(OneD_Node_Mesh< double > &mesh, unsigned var, double left, double right)
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...