00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <Domain.hpp>
00021
00022 #include <ConformTransformation.hpp>
00023 #include <ScalarFunctionBase.hpp>
00024
00025 real_t
00026 ConformTransformationQ1Hexahedron::integrate(const ScalarFunctionBase& f) const
00027 {
00028 throw ErrorHandler(__FILE__,__LINE__,
00029 "not implemented",
00030 ErrorHandler::unexpected);
00031 return 0;
00032 }
00033
00034 bool
00035 ConformTransformationQ1Hexahedron::
00036 __inside(const real_t& x,
00037 const real_t& y,
00038 const real_t& z,
00039 TinyVector<6, bool>& faces) const
00040 {
00041 bool inside = true;
00042 faces = false;
00043 for (size_t i = 0 ; i<Hexahedron::NumberOfFaces; ++i) {
00044 TinyVector<3, real_t> faceMassCenter(0,0,0);
00045 TinyVector<Hexahedron::FaceType::NumberOfVertices, Vertex*> face;
00046
00047 for (size_t n=0; n<Hexahedron::FaceType::NumberOfVertices; ++n) {
00048 const Vertex& v = __H(Hexahedron::faces[i][n]);
00049 faceMassCenter += v;
00050 face[n] = const_cast<Vertex*>(&v);
00051 }
00052 Quadrangle Q(face);
00053 faceMassCenter *= (1./Hexahedron::FaceType::NumberOfVertices);
00054 TinyVector<3,real_t> normal = Q.normal();
00055
00056 TinyVector<3, real_t> X(x,y,z);
00057 X -= faceMassCenter;
00058 if (X*normal > 0) {
00059 faces[i] = true;
00060 inside = false;
00061 }
00062 }
00063 return inside;
00064 }
00065
00067 bool ConformTransformationQ1Hexahedron::
00068 invertT(const real_t& x,
00069 const real_t& y,
00070 const real_t& z,
00071 TinyVector<3,real_t>& Xhat) const
00072 {
00073
00074 for(size_t i=0; i<3; ++i)
00075 Xhat[i] = 0.5;
00076
00077 TinyVector<3,real_t> X;
00078 TinyVector<3,real_t> f;
00079 TinyVector<3,real_t> delta;
00080 const size_t maxiter = 100;
00081 size_t niter = 0;
00082
00083 do {
00084 niter++;
00085
00087 value(Xhat,f);
00088 f[0] -= x;
00089 f[1] -= y;
00090 f[2] -= z;
00091
00092
00093 TinyMatrix<3,3,real_t> J;
00094 dx(Xhat,X);
00095 for (size_t i=0; i<3; ++i)
00096 J(i,0) = X[i];
00097
00098 dy(Xhat,X);
00099 for (size_t i=0; i<3; ++i)
00100 J(i,1) = X[i];
00101
00102 dz(Xhat,X);
00103 for (size_t i=0; i<3; ++i)
00104 J(i,2) = X[i];
00105
00106 delta = f/J;
00107
00108
00109 Xhat -= delta;
00110
00111 if (niter>maxiter) {
00112 return false;
00113 }
00114
00115 } while(Norm(f)>1E-3);
00116
00117 for (size_t i = 0; i<Xhat.size(); ++i) {
00118 if ((Xhat[i]<1E-3) or (Xhat[i]>1.001)) {
00119 return false;
00120 }
00121 }
00122
00123 return true;
00124 }
00125
00126
00127
00128 real_t
00129 ConformTransformationP1Tetrahedron::integrate(const ScalarFunctionBase& f) const
00130 {
00131 throw ErrorHandler(__FILE__,__LINE__,
00132 "not implemented",
00133 ErrorHandler::unexpected);
00134 return 0;
00135 }
00136
00137 real_t
00138 ConformTransformationQ1CartesianHexahedron::
00139 integrateCharacteristic(const Domain& d) const
00140 {
00141 return 1;
00142
00143
00144 TinyVector<4, real_t> x;
00145 x[0] = 0.;
00146 x[1] = .27639320225002103036;
00147 x[2] = .72360679774997896964;
00148 x[3] = 1.;
00149
00150 TinyVector<4, real_t> w;
00151 w[0] = 1./12.;
00152 w[1] = 5./12.;
00153 w[2] = 5./12.;
00154 w[3] = 1./12.;
00155
00156 real_t sum = 0;
00157 TinyVector<3, real_t> X_hat;
00158 TinyVector<3, real_t> X;
00159 for (unsigned i=0; i<4; ++i) {
00160 X_hat[0] = x[i];
00161 for (unsigned j=0; j<4; ++j) {
00162 X_hat[1] = x[j];
00163 for (unsigned k=0; k<4; ++k) {
00164 X_hat[2] = x[k];
00165 this->value(X_hat, X);
00166 sum += w[i]*w[j]*w[k] * (d.inside(X) ? 1 : 0);
00167 }
00168 }
00169 }
00170 return sum;
00171 }
00172
00173
00174 real_t
00175 ConformTransformationP1Triangle::integrate(const ScalarFunctionBase& f) const
00176 {
00177 throw ErrorHandler(__FILE__,__LINE__,
00178 "not implemented",
00179 ErrorHandler::unexpected);
00180
00181 return 0.;
00182 }
00183
00184 real_t
00185 ConformTransformationQ1Quadrangle::integrate(const ScalarFunctionBase& f) const
00186 {
00187 throw ErrorHandler(__FILE__,__LINE__,
00188 "not implemented",
00189 ErrorHandler::unexpected);
00190 return 0.;
00191 }